@mylasertools/kerfscript 0.7.0 → 0.8.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 Q2=Object.defineProperty;var b8=Object.getOwnPropertyDescriptor;var z8=Object.getOwnPropertyNames;var w8=Object.prototype.hasOwnProperty;var k8=(c,e,t)=>e in c?Q2(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t;var L8=(c,e)=>()=>(e||c((e={exports:{}}).exports,e),e.exports),S8=(c,e)=>{for(var t in e)Q2(c,t,{get:e[t],enumerable:!0})},A8=(c,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of z8(e))!w8.call(c,a)&&a!==t&&Q2(c,a,{get:()=>e[a],enumerable:!(n=b8(e,a))||n.enumerable});return c};var C8=c=>A8(Q2({},"__esModule",{value:!0}),c);var T=(c,e,t)=>k8(c,typeof e!="symbol"?e+"":e,t);var f6=L8((ys,u6)=>{u6.exports={}});var xa={};S8(xa,{analyze:()=>ha,complete:()=>va,definition:()=>u8,hover:()=>pa,outline:()=>ya,problems:()=>Ma,references:()=>f8,rename:()=>ua,renameTarget:()=>d8,signatureHelp:()=>ga});module.exports=C8(xa);var S0=(c,e=!0)=>`line ${c.line}${e?`, column ${c.col}`:""}${c.file?` in <${c.file}>`:""}`;var D=class extends Error{constructor(t,n){super(n?`${t} (${S0(n)})`:t);this.echoes=[];this.warnings=[];this.trace=[];this.traceMore=0;this.name="KerfError",this.reason=t,n&&(this.line=n.line,this.col=n.col,this.file=n.file)}addFrame(t,n,a){let r=this.trace.find(s=>s.name===n&&s.line===a.line&&s.col===a.col&&s.file===a.file);r?r.count++:this.trace.length>=50?this.traceMore++:this.trace.push({kind:t,name:n,line:a.line,col:a.col,...a.file&&{file:a.file},count:1})}},P8=["<=",">=","==","!=","&&","||","+","-","*","/","%","^","<",">","!","?",":","=",".",",",";","(",")","[","]","{","}","#"];function r2(c,e){let t=[],n=[],a=0,r=1,s=0,i=()=>({line:r,col:a-s+1,offset:a,...e&&{file:e}}),l=o=>{for(let h=0;h<o;h++)c[a]===`
3
- `&&(r++,s=a+1),a++};for(;a<c.length;){let o=c[a];if(o===" "||o===" "||o==="\r"||o===`
4
- `){l(1);continue}if(o==="/"&&c[a+1]==="/"){let u=c.indexOf(`
5
- `,a),d=u<0?c.length:u,p=/^[ \t]*$/.test(c.slice(c.lastIndexOf(`
6
- `,a-1)+1,a));n.push({text:c.slice(a+2,d).trim(),line:r,block:!1,own:p,start:a,end:d}),a=d;continue}if(o==="/"&&c[a+1]==="*"){let u=i(),d=c.indexOf("*/",a+2);if(d<0)throw new D("Unclosed block comment",u);n.push({text:c.slice(a+2,d).trim(),line:u.line,block:!0,own:!0,start:a,end:d+2}),l(d+2-a);continue}let h=i();if(/[0-9]/.test(o)||o==="."&&/[0-9]/.test(c[a+1]??"")){let u=/^(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?(?:(?:mm|cm|m|in|ft)(?![A-Za-z0-9_]))?/.exec(c.slice(a));t.push({type:"num",value:u[0],pos:h,end:a+u[0].length}),l(u[0].length);continue}if(/[A-Za-z_$]/.test(o)){let u=/^[A-Za-z_$][A-Za-z0-9_]*/.exec(c.slice(a));t.push({type:"id",value:u[0],pos:h,end:a+u[0].length}),l(u[0].length);continue}if(o==='"'){let u="";for(l(1);a<c.length&&c[a]!=='"';){if(c[a]==="\\"){let d=c[a+1];if(d==="n")u+=`
7
- `;else if(d==="t")u+=" ";else if(d==="u"){let p=c.slice(a+2,a+6);if(!/^[0-9a-fA-F]{4}$/.test(p))throw new D("Bad \\u escape",i());u+=String.fromCharCode(parseInt(p,16)),l(4)}else u+=d;l(2);continue}if(c[a]===`
8
- `)throw new D("Unclosed string",h);u+=c[a],l(1)}if(a>=c.length)throw new D("Unclosed string",h);l(1),t.push({type:"str",value:u,pos:h,end:a});continue}if(o==="<"&&/^<[A-Za-z0-9_./-]+>/.test(c.slice(a))){let u=t[t.length-1];if(u&&u.type==="id"&&(u.value==="use"||u.value==="include")){let d=/^<([A-Za-z0-9_./-]+)>/.exec(c.slice(a));t.push({type:"str",value:d[1],pos:h,end:a+d[0].length}),l(d[0].length);continue}}let f=P8.find(u=>c.startsWith(u,a));if(!f)throw new D(`Unexpected character "${o}"`,h);t.push({type:"punct",value:f,pos:h,end:a+f.length}),l(f.length)}return t.push({type:"eof",value:"",pos:i(),end:a}),{tokens:t,comments:n}}var K3=new Set(["module","function","if","else","for","let","each","use","include","true","false","undef"]);function D0(c,e){let{tokens:t,comments:n}=r2(c,e),a=new J3(t),r=[];for(;!a.at("eof");)r.push(...a.statement());return{program:{body:r},comments:n}}var S2=class S2{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,n=0){let a=this.peek(n);return a.type===e&&(t===void 0||a.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 n=t.type==="eof"?"end of file":`"${t.value}"`;throw new D(`${e}, found ${n}`,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"||K3.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 s=[];for(;!this.isP("}");)this.at("eof")&&this.fail('Expected "}"'),s.push(...this.statement());return this.next(),[{kind:"block",body:s,pos:e.pos}]}if(this.isK("module")){this.next();let s=this.ident(),i=this.params();return[{kind:"module",name:s.value,params:i,body:this.body(),pos:e.pos,namePos:s.pos}]}if(this.isK("function")&&this.at("id",void 0,1)){this.next();let s=this.ident(),i=this.params();this.expectP("=");let l=this.expr();return this.expectP(";"),[{kind:"function",name:s.value,params:i,body:l,pos:e.pos,namePos:s.pos}]}if(this.isK("use")||this.isK("include")){this.next();let s=this.peek();return s.type!=="str"&&this.fail("Expected a library path like <kerf/box>"),this.next(),this.isP(";")&&this.next(),[{kind:"use",path:s.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 s=this.expr();this.expectP(")");let i=this.body(),l=[];return this.isK("else")&&(this.next(),l=this.body()),[{kind:"if",cond:s,then:i,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 s=this.ident().value;this.next();let i=this.peek().pos.offset,l=this.expr(),o=this.expectP(";").pos.offset;return[{kind:"assign",name:s,value:l,span:[i,o],pos:e.pos}]}let t=null;(this.isP("*")||this.isP("!")||this.isP("#")||this.isP("%"))&&(t=this.next().value);let n=this.peek();(n.type!=="id"||K3.has(n.value))&&this.fail("Expected a statement"),this.next();let a=this.args(),r=this.body();return[{kind:"call",name:n.value,args:a,children:r,modifier:t,pos:n.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(),n=null;this.isP("=")&&(this.next(),n=this.expr()),e.push({name:t.value,default:n,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 n=this.params(),a=this.expr();return{kind:"lambda",params:n,body:a,pos:e.pos,end:this.last()}}if(this.isK("let")&&this.isP("(",1)){this.next();let n=this.assigns(),a=this.expr();return{kind:"let",assigns:n,body:a,pos:e.pos,end:this.last()}}let t=this.binary(0);if(this.isP("?")){this.next();let n=this.expr();this.expectP(":");let a=this.expr();return{kind:"ternary",cond:t,then:n,else:a,pos:e.pos}}return t}binary(e){if(e>=S2.LEVELS.length)return this.unary();let t=this.binary(e+1);for(;this.at("punct")&&S2.LEVELS[e].includes(this.peek().value);){let n=this.next(),a=this.binary(e+1);t={kind:"binary",op:n.value,left:t,right:a,pos:n.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 n=this.expr();this.expectP("]"),e={kind:"index",target:e,index:n,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"){this.next();let t=/(mm|cm|m|in|ft)$/.exec(e.value);return t?{kind:"num",value:Number(e.value.slice(0,-t[1].length)),unit:t[1],pos:e.pos}:{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}):(K3.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();if(this.isP("{"))return this.record();this.fail("Expected a value")}record(){let e=this.expectP("{"),t=[];for(;!this.isP("}");){let n=this.ident();if(t.some(a=>a.name===n.value))throw new D(`Field ${n.value} is given twice`,n.pos);if(this.expectP("="),t.push({name:n.value,value:this.expr(),pos:n.pos}),!this.isP(","))break;this.next()}return this.expectP("}"),{kind:"record",fields:t,pos:e.pos}}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 a=null,r=this.expr();return this.isP(":")&&(this.next(),a=r,r=this.expr()),this.expectP("]"),{kind:"range",start:t,step:a,end:r,pos:e.pos}}let n=[{kind:"item",expr:t}];return this.listRest(n,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(),n=this.listItem();return{kind:"for",assigns:t,body:n,pos:e.pos,end:this.last()}}if(this.isK("if")&&this.isP("(",1)){this.next(),this.expectP("(");let t=this.expr();this.expectP(")");let n=this.listItem(),a=null;return this.isK("else")&&(this.next(),a=this.listItem()),{kind:"if",cond:t,then:n,else:a}}if(this.isK("let")&&this.isP("(",1)){this.next();let t=this.assigns(),n=this.listItem();return{kind:"let",assigns:t,body:n,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()}}};S2.LEVELS=[["||"],["&&"],["==","!="],["<","<=",">",">="],["+","-"],["*","/","%"]];var J3=S2;function M4(c){switch(c.kind){case"num":return c.unit?{ok:!1}:{ok:!0,value:c.value};case"str":case"bool":return{ok:!0,value:c.value};case"unary":return c.op==="-"&&c.arg.kind==="num"?{ok:!0,value:-c.arg.value}:{ok:!1};case"list":{let e=[];for(let t of c.items){if(t.kind!=="item")return{ok:!1};let n=M4(t.expr);if(!n.ok||typeof n.value!="number")return{ok:!1};e.push(n.value)}return{ok:!0,value:e}}default:return{ok:!1}}}function y4(c){let e=Number(c.trim());return c.trim()!==""&&Number.isFinite(e)?e:void 0}function x4(c){let{program:e,comments:t}=D0(c),n=t.filter(i=>i.block&&/^\[[^\]]+\]$/.test(i.text)),a=new Map(t.filter(i=>!i.block&&!i.own).map(i=>[i.line,i.text])),r=new Map(t.filter(i=>!i.block&&i.own).map(i=>[i.line,i.text])),s=[];for(let i of e.body){if(i.kind!=="assign"||/^\$f[nas]$/.test(i.name))continue;let l=M4(i.value);if(!l.ok)continue;let o=n.filter(m=>m.line<=i.pos.line).pop()?.text.slice(1,-1).trim()??"Parameters";if(o.toLowerCase()==="hidden")continue;let h=a.get(i.pos.line),f=r.get(i.pos.line-1)??"",u=l.value,d={name:i.name,caption:f,group:o,type:typeof u=="number"||Array.isArray(u)?"number":typeof u=="boolean"?"boolean":"string",initial:u,span:i.span},p=h?/^\[(.*)\]$/.exec(h.trim()):null;if(p){let m=p[1];if(m.includes(",")||/[a-zA-Z"]/.test(m)&&!/^-?[\d.]+(:-?[\d.]+){0,2}$/.test(m))d.options=m.split(",").map(v=>{let[g,y]=v.split(":").map(z=>z.trim().replace(/^"|"$/g,"")),M=y4(g),A=d.type==="number"&&M!==void 0?M:g;return{name:y??g,value:A}});else{let v=m.split(":").map(y4);v.every(g=>g!==void 0)&&(v.length===1?d.max=v[0]:v.length===2?(d.min=v[0],d.max=v[1]):(d.min=v[0],d.step=v[1],d.max=v[2]))}}s.push(d)}return{parameters:s}}var S=(c,e,t)=>({name:c,...t!==void 0&&{default:t},...e&&{doc:e}}),u1=(c,e,t)=>({...S(c,e,t),named:!0}),Q3="max(3 * $thickness, 6)",e3=[S("value")],E8=[S("x")],W1=(c,e)=>({name:c,kind:"function",params:E8,section:"Numbers and vectors",doc:e}),K0=(c,e)=>({name:c,kind:"function",params:e3,section:"Types",doc:`Whether the value is ${e}`}),b4=(c,e)=>({name:c,kind:"function",params:[S("text","The text to measure",'""'),S("size","Font size in millimetres","10"),S("font","Font name","$font"),u1("halign","left, center or right",'"left"'),u1("valign","baseline, top, center or bottom",'"baseline"'),u1("spacing","Letter spacing factor","1"),u1("fit","Measure at the size that fits this width")],section:"Text measurements",doc:e}),t3=[{name:"rect",kind:"module",params:[S("size","A number, or [width, height]","1"),S("center","Centre the rectangle on the origin instead of its corner","false"),u1("r","Corner radius","0")],section:"Shapes",doc:"A rectangle with its corner at the origin"},{name:"square",kind:"module",params:[S("size","A number, or [width, height]","1"),S("center","Centre the square on the origin instead of its corner","false"),u1("r","Corner radius","0")],section:"Shapes",doc:"Another name for rect()"},{name:"circle",kind:"module",params:[S("r","Radius","1"),u1("d","Diameter, instead of r")],section:"Shapes",doc:"A circle centred on the origin"},{name:"ellipse",kind:"module",params:[S("r","[rx, ry], or one radius for both","1")],section:"Shapes",doc:"An ellipse centred on the origin"},{name:"regular_polygon",kind:"module",params:[S("n","Number of corners","6"),S("r","Distance to the corners","10")],section:"Shapes",doc:"A regular polygon centred on the origin"},{name:"star",kind:"module",params:[S("n","Number of points","5"),S("r","Radius of the points","10"),S("inner","Radius between the points","r * 0.45")],section:"Shapes",doc:"A star centred on the origin"},{name:"polygon",kind:"module",params:[S("points","A list of [x, y] points"),S("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:[S("d",'SVG path data, as "M0 0 L10 0 L5 8 Z"'),u1("fill",'"evenodd" or "nonzero"','"evenodd"'),u1("close","Close every open subpath into an area","false")],section:"Shapes",doc:"Shapes from SVG path data: closed subpaths become areas, open ones lines"},{name:"text",kind:"module",params:[S("text","The text",'""'),S("size","Font size in millimetres","10"),S("font","Font name","$font"),u1("halign","left, center or right",'"left"'),u1("valign","baseline, top, center or bottom",'"baseline"'),u1("spacing","Letter spacing factor","1"),u1("fit","Shrink the size so the text is no wider than this")],section:"Shapes",doc:"Text as shapes; the font must be available to the renderer"},{name:"line",kind:"module",params:[S("from","Start point","[0, 0]"),S("to","End point","[10, 0]"),S("width","Make a strip this wide, an area, instead of a line")],section:"Shapes",doc:"A straight line, or with a width a strip between the points"},{name:"polyline",kind:"module",params:[S("points","A list of [x, y] points"),S("closed","Join the last point to the first","false")],section:"Shapes",doc:"Lines through a list of points"},{name:"arc",kind:"module",params:[S("r","Radius","10"),S("start","Start angle in degrees","0"),S("end","End angle in degrees","90")],section:"Shapes",doc:"An arc line around the origin"},{name:"translate",kind:"module",params:[S("v","[x, y]","[0, 0]")],children:!0,section:"Transforms",doc:"Move the children by x and y"},{name:"rotate",kind:"module",params:[S("a","Angle in degrees, anticlockwise","0"),u1("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:[S("v","One factor, or [sx, sy]","1")],children:!0,section:"Transforms",doc:"Scale the children"},{name:"mirror",kind:"module",params:[S("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:[S("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:[S("r","Grow (positive) or shrink areas with rounded corners"),u1("delta","Grow or shrink areas with sharp corners","0"),u1("chamfer","Cut the corners off when growing by delta","false")],children:!0,section:"Combining",doc:"Grow or shrink the areas of the children"},{name:"pattern",kind:"module",params:[S("spacing","Distance between copies, a number or [x, y]","10"),S("stagger","Shift of every other row, as a share of the x spacing","0")],children:!0,section:"Combining",doc:"Repeat the first child over the area of the others, clipping copies at its edge"},{name:"spline",kind:"module",params:[S("points","The [x, y] points the curve goes through"),S("width","Make an area this wide along the curve, instead of a line"),u1("steps","Points between each two given ones","8"),u1("closed","Join the curve back to its start","false")],section:"Shapes",doc:"A smooth curve through points: a line, or with a width an area"},{name:"hatch",kind:"module",params:[S("angle","Direction of the lines, in degrees from +x","45"),S("pitch","Distance between the lines","5"),S("width","Make stripes this wide, areas, instead of lines")],children:!0,section:"Combining",doc:"Parallel lines or stripes across the area of the children"},{name:"paint",kind:"module",params:[S("layers",'A layer for each child; "" leaves that child out')],children:!0,section:"Combining",doc:"Painter's order: each child loses the area of the children after it"},{name:"measure",kind:"module",params:[S("draw","Draw the first child too","false")],children:!0,section:"Combining",doc:"Set $bounds = [x0, y0, x1, y1] of the first child for the children after it"},{name:"fill_holes",kind:"module",params:[S("min_area","Fill only holes smaller than this many square millimetres")],children:!0,section:"Combining",doc:"Fill the holes in the areas of the children"},{name:"close",kind:"module",params:[S("r","Close gaps and notches narrower than twice this","0.5")],children:!0,section:"Combining",doc:"Close narrow gaps between and in the areas of the children"},{name:"stroke",kind:"module",params:[S("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:[S("side",'"front", or "back" for the face underneath, made after turning the part over','"front"')],children:!0,section:"Layers",doc:"Put the children on the score layer: lines marked without cutting through"},{name:"engrave",kind:"module",params:[S("side",'"front", or "back" for the face underneath, made after turning the part over','"front"')],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:[S("name","Layer name"),S("mode",'"cut", "line", "fill" or "guide"'),S("color",'Colour in the output, as "#00aa00"'),u1("order","Where it goes among the custom layers in the files, lowest first","0"),u1("bleed","How far past the part's edge it may print","0"),u1("side",'"front", or "back" for the face underneath, made after turning the part over','"front"')],children:!0,section:"Layers",doc:"Put the children on a layer, defining it on first use"},{name:"part",kind:"module",params:[S("name","Part name",'"part"'),S("qty","Number of copies to cut","1"),u1("at","Where the part goes in the assembled view, [x, y, z]"),u1("rotate","How the part is turned in the assembled view, [x, y, z] in degrees"),u1("stack","Layers glued in a stack at each placement, one thickness apart","1"),u1("mirror","Cut the part mirrored left to right, its text still reading","false"),u1("bend","Living hinge bends in the assembled view: [x0, x1, angle] or a list"),u1("on","The name of a bent part this one is glued to, to move with it"),u1("slots","Names of parts whose tabs pass through this one: their slots are cut"),u1("clearance","Added to the slots, in total across each","0.1"),u1("glue","The name of a part this one is glued flat onto; at and rotate are then on its face"),u1("face",'The face of the glue part it goes on: "top" or "bottom"','"top"')],children:!0,section:"Parts and sheets",doc:"A named part, with its thickness, kerf and material"},{name:"place",kind:"module",params:[S("at","Where the parts inside go, [x, y, z]","[0, 0, 0]"),S("rotate","How they are turned, [x, y, z] in degrees","[0, 0, 0]")],children:!0,section:"Parts and sheets",doc:"Place the parts inside in the assembled view, with their own placements inside this one"},{name:"call",kind:"module",params:[S("name",'The name of a module, as "roses"')],rest:!0,children:!0,section:"Other",doc:"Calls the module of that name with the other arguments and the children, so a table can carry which module draws each entry"},{name:"step",kind:"module",params:[S("text","What to do in this step",'""'),S("substeps","Steps inside it become its sub-steps; false adds them to this one","true")],children:!0,section:"Parts and sheets",doc:'An assembly step: the parts and hardware inside are added in it, in order. A step inside a step is a sub-step, named "outer: inner"'},{name:"hardware",kind:"module",params:[S("kind",'What it is, as "dowel", "screw", "magnet", "elastic" or "paper"','"dowel"'),S("from","One end, [x, y, z]"),S("to","The other end, [x, y, z]"),S("size","Diameter, or [width, height] for a flat section","6"),u1("up","The direction a [width, height] section's height points"),u1("sides","Sides of a round section in the 3D view","24"),u1("label","The name in the hardware list")],children:!0,section:"Parts and sheets",doc:"Hardware the assembly needs, in the parts list and the 3D view"},{name:"material",kind:"module",params:[S("thickness","Sets $thickness"),S("kerf","Sets $kerf"),S("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:[S("size","[width, height]"),S("edges",'"out", "in" or "flat", or [bottom, right, top, left]','"out"'),S("finger","Finger width",Q3)],section:"Joinery",doc:"A rectangle with finger joints, notched $thickness deep"},{name:"finger_holes",kind:"module",params:[S("length","Length of the edge that plugs in"),S("edge",'"out" or "in", the kind of edge that plugs in','"out"'),S("finger","Finger width",Q3)],section:"Joinery",doc:"A row of slots along x for a finger edge to plug into"},{name:"tslot",kind:"module",params:[S("d","Screw diameter","3"),S("length","Screw length into the panel","12"),S("nut","Nut size, [width, height]","[d * 1.85, d * 0.8]"),S("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:[S("size","[width, height]"),S("spacing","Distance between the rows of cuts","1.5"),S("bridge","Uncut length between cuts","3"),S("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:[S("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:[S("condition","Stops the program when false"),S("message","Says why")],section:"Other",doc:"Stop with an error when the condition is false"},W1("abs","Absolute value"),W1("sign","Sign as -1, 0 or 1"),W1("floor","Round down"),W1("ceil","Round up"),W1("round","Round to the nearest integer, halves away from zero"),W1("sqrt","Square root"),W1("exp","e raised to x"),W1("ln","Natural logarithm"),{name:"log",kind:"function",params:[S("x"),S("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"},W1("sin","Sine of an angle in degrees"),W1("cos","Cosine of an angle in degrees"),W1("tan","Tangent of an angle in degrees"),W1("asin","Inverse sine, in degrees"),W1("acos","Inverse cosine, in degrees"),W1("atan","Inverse tangent, in degrees"),{name:"atan2",kind:"function",params:[S("y"),S("x")],section:"Numbers and vectors",doc:"The angle of the point [x, y] from the x axis, in degrees"},{name:"pow",kind:"function",params:[S("x"),S("y")],section:"Numbers and vectors",doc:"x raised to y"},{name:"min",kind:"function",params:[S("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:[S("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:[S("x"),S("low"),S("high")],section:"Numbers and vectors",doc:"x limited to the interval from low to high"},{name:"lerp",kind:"function",params:[S("a"),S("b"),S("t","0 gives a, 1 gives b")],section:"Numbers and vectors",doc:"Interpolate between numbers or vectors"},{name:"norm",kind:"function",params:[S("v")],section:"Numbers and vectors",doc:"The length of a vector"},{name:"cross",kind:"function",params:[S("a"),S("b")],section:"Numbers and vectors",doc:"Cross product: a number for 2D vectors, a vector for 3D ones"},{name:"path_length",kind:"function",params:[S("points","A list of [x, y] points")],section:"Paths and rotations",doc:"The length of the lines through a list of points"},{name:"point_at",kind:"function",params:[S("points","A list of [x, y] points"),S("s","Distance along the path")],section:"Paths and rotations",doc:"The point a distance along a path; past either end it carries on straight"},{name:"heading_at",kind:"function",params:[S("points","A list of [x, y] points"),S("s","Distance along the path")],section:"Paths and rotations",doc:"The direction of a path a distance along it, in degrees from +x"},{name:"path_points",kind:"function",params:[S("d",'SVG path data, as "M0 0 L10 0 A5 5 0 0 1 20 0"'),S("tolerance","How far curves may stray from their points","0.05")],section:"Paths and rotations",doc:"The points of SVG path data: one list of points for each subpath"},{name:"spline_points",kind:"function",params:[S("points","The [x, y] points the curve goes through"),S("steps","Points between each two given ones","8"),S("closed","Join the curve back to its start","false")],section:"Paths and rotations",doc:"The points of a smooth curve through points, as spline() draws it"},{name:"rotation",kind:"function",params:[S("angles","[x, y, z] in degrees, as part() turns")],section:"Paths and rotations",doc:"The 3x3 matrix of a rotation; matrices multiply with *"},{name:"euler",kind:"function",params:[S("matrix","A 3x3 rotation matrix")],section:"Paths and rotations",doc:"The [x, y, z] angles of a rotation matrix, for part()'s rotate"},{name:"orient",kind:"function",params:[S("x","Where the part's own x axis points"),S("z","Where its z axis, out of its top face, points","[0, 0, 1]")],section:"Paths and rotations",doc:"The rotate angles that turn a part's x and z axes onto two directions"},{name:"len",kind:"function",params:e3,section:"Lists and strings",doc:"Number of items in a list, characters in a string or fields in a record"},{name:"keys",kind:"function",params:[S("record","A record, as {name = value}")],section:"Lists and strings",doc:"A record's field names, in the order they were written"},{name:"merge",kind:"function",params:[S("a","A record"),S("b","A record whose fields add to or replace those of a")],section:"Lists and strings",doc:"A record with the fields of a and b, b winning where both have one"},{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:e3,section:"Lists and strings",doc:"A list or string in reverse order"},{name:"sum",kind:"function",params:[S("values","A list of numbers")],section:"Lists and strings",doc:"The sum of a list of numbers"},{name:"slice",kind:"function",params:[S("value","A list or string"),S("start","First index","0"),S("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:[S("text")],section:"Lists and strings",doc:"The first character's Unicode code point"},{name:"upper",kind:"function",params:[S("text")],section:"Lists and strings",doc:"Text in capitals"},{name:"lower",kind:"function",params:[S("text")],section:"Lists and strings",doc:"Text in small letters"},{name:"split",kind:"function",params:[S("text"),S("separator",void 0,'" "')],section:"Lists and strings",doc:"Text split into a list of strings"},{name:"join",kind:"function",params:[S("values"),S("separator",void 0,'""')],section:"Lists and strings",doc:"Values joined into one string"},{name:"search",kind:"function",params:[S("value"),S("list","A list or string")],section:"Lists and strings",doc:"Index of the first equal item, or undef"},{name:"contains",kind:"function",params:[S("value","A list or string"),S("item")],section:"Lists and strings",doc:"Whether a list contains an item or a string contains a substring"},{name:"lookup",kind:"function",params:[S("x"),S("table","A list of [x, y] pairs")],section:"Lists and strings",doc:"Interpolate in a table; outside it, the nearest end"},K0("is_num","a number other than NaN"),K0("is_string","a string"),K0("is_bool","true or false"),K0("is_list","a list"),K0("is_undef","undef"),K0("is_function","a function"),K0("is_record","a record, as {name = value}"),{name:"type_of",kind:"function",params:e3,section:"Types",doc:"The type name: number, string, boolean, undef, list, range, function or record"},{name:"rands",kind:"function",params:[S("min"),S("max"),S("count"),S("seed","The same seed gives the same list","1")],section:"Random values",doc:"A list of count numbers between min and max"},b4("text_width","The advance width of the text, including spacing"),b4("text_metrics","The text as [advance, [[x0, y0], [x1, y1]], ascent, descent]"),{name:"finger_count",kind:"function",params:[S("length","Edge length"),S("finger","Finger width",Q3)],section:"Joint dimensions",doc:"The odd number of fingers finger_rect() puts on an edge of that length"}],T8=new Map(t3.map(c=>[c.name,c])),s2=c=>T8.get(c);function c3(c){let e=c.params.map(t=>t.default===void 0?t.name:`${t.name} = ${t.default}`);return c.rest&&e.push("..."),`${c.name}(${e.join(", ")})`}var v0={"kerf/box":`// kerf/box: finger-jointed boxes.
2
+ "use strict";var t3=Object.defineProperty;var z8=Object.getOwnPropertyDescriptor;var w8=Object.getOwnPropertyNames;var k8=Object.prototype.hasOwnProperty;var L8=(n,e,t)=>e in n?t3(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var S8=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),A8=(n,e)=>{for(var t in e)t3(n,t,{get:e[t],enumerable:!0})},C8=(n,e,t,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of w8(e))!k8.call(n,a)&&a!==t&&t3(n,a,{get:()=>e[a],enumerable:!(c=z8(e,a))||c.enumerable});return n};var P8=n=>C8(t3({},"__esModule",{value:!0}),n);var T=(n,e,t)=>L8(n,typeof e!="symbol"?e+"":e,t);var p6=S8((bs,d6)=>{d6.exports={}});var xa={};A8(xa,{analyze:()=>ua,complete:()=>ga,definition:()=>f8,hover:()=>ma,outline:()=>ba,problems:()=>Ma,references:()=>d8,rename:()=>fa,renameTarget:()=>p8,signatureHelp:()=>ya});module.exports=P8(xa);var A0=(n,e=!0)=>`line ${n.line}${e?`, column ${n.col}`:""}${n.file?` in <${n.file}>`:""}`;var D=class extends Error{constructor(t,c){super(c?`${t} (${A0(c)})`:t);this.echoes=[];this.warnings=[];this.trace=[];this.traceMore=0;this.name="KerfError",this.reason=t,c&&(this.line=c.line,this.col=c.col,this.file=c.file)}addFrame(t,c,a){let r=this.trace.find(s=>s.name===c&&s.line===a.line&&s.col===a.col&&s.file===a.file);r?r.count++:this.trace.length>=50?this.traceMore++:this.trace.push({kind:t,name:c,line:a.line,col:a.col,...a.file&&{file:a.file},count:1})}},E8=["<=",">=","==","!=","&&","||","+","-","*","/","%","^","<",">","!","?",":","=",".",",",";","(",")","[","]","{","}","#"];function r2(n,e){let t=[],c=[],a=0,r=1,s=0,i=()=>({line:r,col:a-s+1,offset:a,...e&&{file:e}}),l=o=>{for(let h=0;h<o;h++)n[a]===`
3
+ `&&(r++,s=a+1),a++};for(;a<n.length;){let o=n[a];if(o===" "||o===" "||o==="\r"||o===`
4
+ `){l(1);continue}if(o==="/"&&n[a+1]==="/"){let u=n.indexOf(`
5
+ `,a),d=u<0?n.length:u,p=/^[ \t]*$/.test(n.slice(n.lastIndexOf(`
6
+ `,a-1)+1,a));c.push({text:n.slice(a+2,d).trim(),line:r,block:!1,own:p,start:a,end:d}),a=d;continue}if(o==="/"&&n[a+1]==="*"){let u=i(),d=n.indexOf("*/",a+2);if(d<0)throw new D("Unclosed block comment",u);c.push({text:n.slice(a+2,d).trim(),line:u.line,block:!0,own:!0,start:a,end:d+2}),l(d+2-a);continue}let h=i();if(/[0-9]/.test(o)||o==="."&&/[0-9]/.test(n[a+1]??"")){let u=/^(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?(?:(?:mm|cm|m|in|ft)(?![A-Za-z0-9_]))?/.exec(n.slice(a));t.push({type:"num",value:u[0],pos:h,end:a+u[0].length}),l(u[0].length);continue}if(/[A-Za-z_$]/.test(o)){let u=/^[A-Za-z_$][A-Za-z0-9_]*/.exec(n.slice(a));t.push({type:"id",value:u[0],pos:h,end:a+u[0].length}),l(u[0].length);continue}if(o==='"'){let u="";for(l(1);a<n.length&&n[a]!=='"';){if(n[a]==="\\"){let d=n[a+1];if(d==="n")u+=`
7
+ `;else if(d==="t")u+=" ";else if(d==="u"){let p=n.slice(a+2,a+6);if(!/^[0-9a-fA-F]{4}$/.test(p))throw new D("Bad \\u escape",i());u+=String.fromCharCode(parseInt(p,16)),l(4)}else u+=d;l(2);continue}if(n[a]===`
8
+ `)throw new D("Unclosed string",h);u+=n[a],l(1)}if(a>=n.length)throw new D("Unclosed string",h);l(1),t.push({type:"str",value:u,pos:h,end:a});continue}if(o==="<"&&/^<[A-Za-z0-9_./-]+>/.test(n.slice(a))){let u=t[t.length-1];if(u&&u.type==="id"&&(u.value==="use"||u.value==="include")){let d=/^<([A-Za-z0-9_./-]+)>/.exec(n.slice(a));t.push({type:"str",value:d[1],pos:h,end:a+d[0].length}),l(d[0].length);continue}}let f=E8.find(u=>n.startsWith(u,a));if(!f)throw new D(`Unexpected character "${o}"`,h);t.push({type:"punct",value:f,pos:h,end:a+f.length}),l(f.length)}return t.push({type:"eof",value:"",pos:i(),end:a}),{tokens:t,comments:c}}var K3=new Set(["module","function","if","else","for","let","each","use","include","true","false","undef"]);function D0(n,e){let{tokens:t,comments:c}=r2(n,e),a=new J3(t),r=[];for(;!a.at("eof");)r.push(...a.statement());return{program:{body:r},comments:c}}var A2=class A2{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,c=0){let a=this.peek(c);return a.type===e&&(t===void 0||a.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 c=t.type==="eof"?"end of file":`"${t.value}"`;throw new D(`${e}, found ${c}`,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"||K3.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 s=[];for(;!this.isP("}");)this.at("eof")&&this.fail('Expected "}"'),s.push(...this.statement());return this.next(),[{kind:"block",body:s,pos:e.pos}]}if(this.isK("module")){this.next();let s=this.ident(),i=this.params();return[{kind:"module",name:s.value,params:i,body:this.body(),pos:e.pos,namePos:s.pos}]}if(this.isK("function")&&this.at("id",void 0,1)){this.next();let s=this.ident(),i=this.params();this.expectP("=");let l=this.expr();return this.expectP(";"),[{kind:"function",name:s.value,params:i,body:l,pos:e.pos,namePos:s.pos}]}if(this.isK("use")||this.isK("include")){this.next();let s=this.peek();return s.type!=="str"&&this.fail("Expected a library path like <kerf/box>"),this.next(),this.isP(";")&&this.next(),[{kind:"use",path:s.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 s=this.expr();this.expectP(")");let i=this.body(),l=[];return this.isK("else")&&(this.next(),l=this.body()),[{kind:"if",cond:s,then:i,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 s=this.ident().value;this.next();let i=this.peek().pos.offset,l=this.expr(),o=this.expectP(";").pos.offset;return[{kind:"assign",name:s,value:l,span:[i,o],pos:e.pos}]}let t=null;(this.isP("*")||this.isP("!")||this.isP("#")||this.isP("%"))&&(t=this.next().value);let c=this.peek();(c.type!=="id"||K3.has(c.value))&&this.fail("Expected a statement"),this.next();let a=this.args(),r=this.body();return[{kind:"call",name:c.value,args:a,children:r,modifier:t,pos:c.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(),c=null;this.isP("=")&&(this.next(),c=this.expr()),e.push({name:t.value,default:c,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 c=this.params(),a=this.expr();return{kind:"lambda",params:c,body:a,pos:e.pos,end:this.last()}}if(this.isK("let")&&this.isP("(",1)){this.next();let c=this.assigns(),a=this.expr();return{kind:"let",assigns:c,body:a,pos:e.pos,end:this.last()}}let t=this.binary(0);if(this.isP("?")){this.next();let c=this.expr();this.expectP(":");let a=this.expr();return{kind:"ternary",cond:t,then:c,else:a,pos:e.pos}}return t}binary(e){if(e>=A2.LEVELS.length)return this.unary();let t=this.binary(e+1);for(;this.at("punct")&&A2.LEVELS[e].includes(this.peek().value);){let c=this.next(),a=this.binary(e+1);t={kind:"binary",op:c.value,left:t,right:a,pos:c.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 c=this.expr();this.expectP("]"),e={kind:"index",target:e,index:c,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"){this.next();let t=/(mm|cm|m|in|ft)$/.exec(e.value);return t?{kind:"num",value:Number(e.value.slice(0,-t[1].length)),unit:t[1],pos:e.pos}:{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}):(K3.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();if(this.isP("{"))return this.record();this.fail("Expected a value")}record(){let e=this.expectP("{"),t=[];for(;!this.isP("}");){let c=this.ident();if(t.some(a=>a.name===c.value))throw new D(`Field ${c.value} is given twice`,c.pos);if(this.expectP("="),t.push({name:c.value,value:this.expr(),pos:c.pos}),!this.isP(","))break;this.next()}return this.expectP("}"),{kind:"record",fields:t,pos:e.pos}}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 a=null,r=this.expr();return this.isP(":")&&(this.next(),a=r,r=this.expr()),this.expectP("]"),{kind:"range",start:t,step:a,end:r,pos:e.pos}}let c=[{kind:"item",expr:t}];return this.listRest(c,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(),c=this.listItem();return{kind:"for",assigns:t,body:c,pos:e.pos,end:this.last()}}if(this.isK("if")&&this.isP("(",1)){this.next(),this.expectP("(");let t=this.expr();this.expectP(")");let c=this.listItem(),a=null;return this.isK("else")&&(this.next(),a=this.listItem()),{kind:"if",cond:t,then:c,else:a}}if(this.isK("let")&&this.isP("(",1)){this.next();let t=this.assigns(),c=this.listItem();return{kind:"let",assigns:t,body:c,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()}}};A2.LEVELS=[["||"],["&&"],["==","!="],["<","<=",">",">="],["+","-"],["*","/","%"]];var J3=A2;function M4(n){switch(n.kind){case"num":return n.unit?{ok:!1}:{ok:!0,value:n.value};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 c=M4(t.expr);if(!c.ok||typeof c.value!="number")return{ok:!1};e.push(c.value)}return{ok:!0,value:e}}default:return{ok:!1}}}function b4(n){let e=Number(n.trim());return n.trim()!==""&&Number.isFinite(e)?e:void 0}function x4(n){let{program:e,comments:t}=D0(n),c=t.filter(i=>i.block&&/^\[[^\]]+\]$/.test(i.text)),a=new Map(t.filter(i=>!i.block&&!i.own).map(i=>[i.line,i.text])),r=new Map(t.filter(i=>!i.block&&i.own).map(i=>[i.line,i.text])),s=[];for(let i of e.body){if(i.kind!=="assign"||/^\$f[nas]$/.test(i.name))continue;let l=M4(i.value);if(!l.ok)continue;let o=c.filter(m=>m.line<=i.pos.line).pop()?.text.slice(1,-1).trim()??"Parameters";if(o.toLowerCase()==="hidden")continue;let h=a.get(i.pos.line),f=r.get(i.pos.line-1)??"",u=l.value,d={name:i.name,caption:f,group:o,type:typeof u=="number"||Array.isArray(u)?"number":typeof u=="boolean"?"boolean":"string",initial:u,span:i.span},p=h?/^\[(.*)\]$/.exec(h.trim()):null;if(p){let m=p[1];if(m.includes(",")||/[a-zA-Z"]/.test(m)&&!/^-?[\d.]+(:-?[\d.]+){0,2}$/.test(m))d.options=m.split(",").map(v=>{let[g,b]=v.split(":").map(k=>k.trim().replace(/^"|"$/g,"")),y=b4(g),w=d.type==="number"&&y!==void 0?y:g;return{name:b??g,value:w}});else{let v=m.split(":").map(b4);v.every(g=>g!==void 0)&&(v.length===1?d.max=v[0]:v.length===2?(d.min=v[0],d.max=v[1]):(d.min=v[0],d.step=v[1],d.max=v[2]))}}s.push(d)}return{parameters:s}}var L=(n,e,t)=>({name:n,...t!==void 0&&{default:t},...e&&{doc:e}}),o1=(n,e,t)=>({...L(n,e,t),named:!0}),Q3="max(3 * $thickness, 6)",n3=[L("value")],T8=[L("x")],W1=(n,e)=>({name:n,kind:"function",params:T8,section:"Numbers and vectors",doc:e}),K0=(n,e)=>({name:n,kind:"function",params:n3,section:"Types",doc:`Whether the value is ${e}`}),z4=(n,e)=>({name:n,kind:"function",params:[L("text","The text to measure",'""'),L("size","Font size in millimetres","10"),L("font","Font name","$font"),o1("halign","left, center or right",'"left"'),o1("valign","baseline, top, center or bottom",'"baseline"'),o1("spacing","Letter spacing factor","1"),o1("fit","Measure at the size that fits this width")],section:"Text measurements",doc:e}),c3=[{name:"rect",kind:"module",params:[L("size","A number, or [width, height]","1"),L("center","Centre the rectangle on the origin instead of its corner","false"),o1("r","Corner radius","0")],section:"Shapes",doc:"A rectangle with its corner at the origin"},{name:"square",kind:"module",params:[L("size","A number, or [width, height]","1"),L("center","Centre the square on the origin instead of its corner","false"),o1("r","Corner radius","0")],section:"Shapes",doc:"Another name for rect()"},{name:"circle",kind:"module",params:[L("r","Radius","1"),o1("d","Diameter, instead of r")],section:"Shapes",doc:"A circle centred on the origin"},{name:"ellipse",kind:"module",params:[L("r","[rx, ry], or one radius for both","1")],section:"Shapes",doc:"An ellipse centred on the origin"},{name:"regular_polygon",kind:"module",params:[L("n","Number of corners","6"),L("r","Distance to the corners","10")],section:"Shapes",doc:"A regular polygon centred on the origin"},{name:"star",kind:"module",params:[L("n","Number of points","5"),L("r","Radius of the points","10"),L("inner","Radius between the points","r * 0.45")],section:"Shapes",doc:"A star centred on the origin"},{name:"polygon",kind:"module",params:[L("points","A list of [x, y] points"),L("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:[L("d",'SVG path data, as "M0 0 L10 0 L5 8 Z"'),o1("fill",'"evenodd" or "nonzero"','"evenodd"'),o1("close","Close every open subpath into an area","false")],section:"Shapes",doc:"Shapes from SVG path data: closed subpaths become areas, open ones lines"},{name:"text",kind:"module",params:[L("text","The text",'""'),L("size","Font size in millimetres","10"),L("font","Font name","$font"),o1("halign","left, center or right",'"left"'),o1("valign","baseline, top, center or bottom",'"baseline"'),o1("spacing","Letter spacing factor","1"),o1("fit","Shrink the size so the text is no wider than this")],section:"Shapes",doc:"Text as shapes; the font must be available to the renderer"},{name:"line",kind:"module",params:[L("from","Start point","[0, 0]"),L("to","End point","[10, 0]"),L("width","Make a strip this wide, an area, instead of a line")],section:"Shapes",doc:"A straight line, or with a width a strip between the points"},{name:"polyline",kind:"module",params:[L("points","A list of [x, y] points"),L("closed","Join the last point to the first","false")],section:"Shapes",doc:"Lines through a list of points"},{name:"arc",kind:"module",params:[L("r","Radius","10"),L("start","Start angle in degrees","0"),L("end","End angle in degrees","90")],section:"Shapes",doc:"An arc line around the origin"},{name:"translate",kind:"module",params:[L("v","[x, y]","[0, 0]")],children:!0,section:"Transforms",doc:"Move the children by x and y"},{name:"rotate",kind:"module",params:[L("a","Angle in degrees, anticlockwise","0"),o1("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:[L("v","One factor, or [sx, sy]","1")],children:!0,section:"Transforms",doc:"Scale the children"},{name:"mirror",kind:"module",params:[L("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:[L("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:[L("r","Grow (positive) or shrink areas with rounded corners"),o1("delta","Grow or shrink areas with sharp corners","0"),o1("chamfer","Cut the corners off when growing by delta","false")],children:!0,section:"Combining",doc:"Grow or shrink the areas of the children"},{name:"pattern",kind:"module",params:[L("spacing","Distance between copies, a number or [x, y]","10"),L("stagger","Shift of every other row, as a share of the x spacing","0")],children:!0,section:"Combining",doc:"Repeat the first child over the area of the others, clipping copies at its edge"},{name:"spline",kind:"module",params:[L("points","The [x, y] points the curve goes through"),L("width","Make an area this wide along the curve, instead of a line"),o1("steps","Points between each two given ones","8"),o1("closed","Join the curve back to its start","false")],section:"Shapes",doc:"A smooth curve through points: a line, or with a width an area"},{name:"hatch",kind:"module",params:[L("angle","Direction of the lines, in degrees from +x","45"),L("pitch","Distance between the lines","5"),L("width","Make stripes this wide, areas, instead of lines")],children:!0,section:"Combining",doc:"Parallel lines or stripes across the area of the children"},{name:"paint",kind:"module",params:[L("layers",'A layer for each child; "" leaves that child out')],children:!0,section:"Combining",doc:"Painter's order: each child loses the area of the children after it"},{name:"measure",kind:"module",params:[L("draw","Draw the first child too","false")],children:!0,section:"Combining",doc:"Set $bounds = [x0, y0, x1, y1], $area and $centroid = [x, y] of the first child for the children after it"},{name:"fill_holes",kind:"module",params:[L("min_area","Fill only holes smaller than this many square millimetres")],children:!0,section:"Combining",doc:"Fill the holes in the areas of the children"},{name:"close",kind:"module",params:[L("r","Close gaps and notches narrower than twice this","0.5")],children:!0,section:"Combining",doc:"Close narrow gaps between and in the areas of the children"},{name:"stroke",kind:"module",params:[L("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:[L("side",'"front", or "back" for the face underneath, made after turning the part over','"front"')],children:!0,section:"Layers",doc:"Put the children on the score layer: lines marked without cutting through"},{name:"engrave",kind:"module",params:[L("side",'"front", or "back" for the face underneath, made after turning the part over','"front"')],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:[L("name","Layer name"),L("mode",'"cut", "line", "fill" or "guide"'),L("color",'Colour in the output, as "#00aa00"'),o1("order","Where it goes among the custom layers in the files, lowest first","0"),o1("bleed","How far past the part's edge it may print","0"),o1("side",'"front", or "back" for the face underneath, made after turning the part over','"front"')],children:!0,section:"Layers",doc:"Put the children on a layer, defining it on first use"},{name:"part",kind:"module",params:[L("name","Part name",'"part"'),L("qty","Number of copies to cut","1"),o1("at","Where the part goes in the assembled view, [x, y, z]"),o1("rotate","How the part is turned in the assembled view, [x, y, z] in degrees"),o1("stack","Layers glued in a stack at each placement, one thickness apart","1"),o1("mirror","Cut the part mirrored left to right, its text still reading","false"),o1("material","The material it is cut from, as material(name = ...) sets it"),o1("bend","Living hinge bends in the assembled view: [x0, x1, angle] or a list"),o1("on","The name of a bent part this one is glued to, to move with it"),o1("slots","Names of parts whose tabs pass through this one: their slots are cut"),o1("clearance","Added to the slots, in total across each","0.1"),o1("glue","The name of a part this one is glued flat onto; at and rotate are then on its face"),o1("face",'The face of the glue part it goes on: "top" or "bottom"','"top"')],children:!0,section:"Parts and sheets",doc:"A named part, with its thickness, kerf and material"},{name:"place",kind:"module",params:[L("at","Where the parts inside go, [x, y, z]","[0, 0, 0]"),L("rotate","How they are turned, [x, y, z] in degrees","[0, 0, 0]")],children:!0,section:"Parts and sheets",doc:"Place the parts inside in the assembled view, with their own placements inside this one"},{name:"call",kind:"module",params:[L("name",'The name of a module, as "roses"')],rest:!0,children:!0,section:"Other",doc:"Calls the module of that name with the other arguments and the children, so a table can carry which module draws each entry"},{name:"step",kind:"module",params:[L("text","What to do in this step",'""'),L("substeps","Steps inside it become its sub-steps; false adds them to this one","true")],children:!0,section:"Parts and sheets",doc:'An assembly step: the parts and hardware inside are added in it, in order. A step inside a step is a sub-step, named "outer: inner"'},{name:"hardware",kind:"module",params:[L("kind",'What it is, as "dowel", "screw", "magnet", "elastic" or "paper"','"dowel"'),L("from","One end, [x, y, z]; a ball sits midway between from and to"),L("to","The other end, [x, y, z]; a ball may leave it out"),L("size","Diameter, or [width, height] for a flat section","6"),o1("up","The direction a [width, height] section's height points"),o1("sides","Sides of a round section in the 3D view; 0 makes a ball","24"),o1("shape",'"rod", or "ball" for a bulb, a marble or a bead','"rod"'),o1("label","The name in the hardware list")],children:!0,section:"Parts and sheets",doc:"Hardware the assembly needs, in the parts list and the 3D view"},{name:"material",kind:"module",params:[L("thickness","Sets $thickness"),L("kerf","Sets $kerf"),L("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:[L("size","[width, height]"),L("edges",'"out", "in" or "flat", or [bottom, right, top, left]','"out"'),L("finger","Finger width",Q3)],section:"Joinery",doc:"A rectangle with finger joints, notched $thickness deep"},{name:"finger_holes",kind:"module",params:[L("length","Length of the edge that plugs in"),L("edge",'"out" or "in", the kind of edge that plugs in','"out"'),L("finger","Finger width",Q3)],section:"Joinery",doc:"A row of slots along x for a finger edge to plug into"},{name:"tslot",kind:"module",params:[L("d","Screw diameter","3"),L("length","Screw length into the panel","12"),L("nut","Nut size, [width, height]","[d * 1.85, d * 0.8]"),L("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:[L("size","[width, height]"),L("spacing","Distance between the rows of cuts","1.5"),L("bridge","Uncut length between cuts","3"),L("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:[L("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:[L("condition","Stops the program when false"),L("message","Says why")],section:"Other",doc:"Stop with an error when the condition is false"},W1("abs","Absolute value"),W1("sign","Sign as -1, 0 or 1"),W1("floor","Round down"),W1("ceil","Round up"),W1("round","Round to the nearest integer, halves away from zero"),W1("sqrt","Square root"),W1("exp","e raised to x"),W1("ln","Natural logarithm"),{name:"log",kind:"function",params:[L("x"),L("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"},W1("sin","Sine of an angle in degrees"),W1("cos","Cosine of an angle in degrees"),W1("tan","Tangent of an angle in degrees"),W1("asin","Inverse sine, in degrees"),W1("acos","Inverse cosine, in degrees"),W1("atan","Inverse tangent, in degrees"),{name:"atan2",kind:"function",params:[L("y"),L("x")],section:"Numbers and vectors",doc:"The angle of the point [x, y] from the x axis, in degrees"},{name:"pow",kind:"function",params:[L("x"),L("y")],section:"Numbers and vectors",doc:"x raised to y"},{name:"min",kind:"function",params:[L("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:[L("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:[L("x"),L("low"),L("high")],section:"Numbers and vectors",doc:"x limited to the interval from low to high"},{name:"lerp",kind:"function",params:[L("a"),L("b"),L("t","0 gives a, 1 gives b")],section:"Numbers and vectors",doc:"Interpolate between numbers or vectors"},{name:"train_for",kind:"function",params:[L("ratio","Turns in for one turn out; under 1 speeds up"),L("stages","Pairs of gears, 1 to 3","2"),L("pinion","Fewest and most teeth of the small gears","[10, 20]"),L("wheel","Fewest and most teeth of the big gears","[20, 80]")],section:"Numbers and vectors",doc:"Tooth counts for a gear train nearest a ratio: {stages = [[driver, driven], ...], ratio, error}"},{name:"norm",kind:"function",params:[L("v")],section:"Numbers and vectors",doc:"The length of a vector"},{name:"cross",kind:"function",params:[L("a"),L("b")],section:"Numbers and vectors",doc:"Cross product: a number for 2D vectors, a vector for 3D ones"},{name:"path_length",kind:"function",params:[L("points","A list of [x, y] points")],section:"Paths and rotations",doc:"The length of the lines through a list of points"},{name:"offset_path",kind:"function",params:[L("points","A list of [x, y] points"),L("d","How far to move it: to the left going along it, or the right when less than 0"),L("closed","The path goes round, its last point joined to its first","false")],section:"Paths and rotations",doc:"The path moved sideways, each corner mitred: the two edges of a strip along a curve"},{name:"point_at",kind:"function",params:[L("points","A list of [x, y] points"),L("s","Distance along the path")],section:"Paths and rotations",doc:"The point a distance along a path; past either end it carries on straight"},{name:"heading_at",kind:"function",params:[L("points","A list of [x, y] points"),L("s","Distance along the path")],section:"Paths and rotations",doc:"The direction of a path a distance along it, in degrees from +x"},{name:"path_points",kind:"function",params:[L("d",'SVG path data, as "M0 0 L10 0 A5 5 0 0 1 20 0"'),L("tolerance","How far curves may stray from their points","0.05")],section:"Paths and rotations",doc:"The points of SVG path data: one list of points for each subpath"},{name:"spline_points",kind:"function",params:[L("points","The [x, y] points the curve goes through"),L("steps","Points between each two given ones","8"),L("closed","Join the curve back to its start","false")],section:"Paths and rotations",doc:"The points of a smooth curve through points, as spline() draws it"},{name:"rotation",kind:"function",params:[L("angles","[x, y, z] in degrees, as part() turns")],section:"Paths and rotations",doc:"The 3x3 matrix of a rotation; matrices multiply with *"},{name:"euler",kind:"function",params:[L("matrix","A 3x3 rotation matrix")],section:"Paths and rotations",doc:"The [x, y, z] angles of a rotation matrix, for part()'s rotate"},{name:"orient",kind:"function",params:[L("x","Where the part's own x axis points"),L("z","Where its z axis, out of its top face, points","[0, 0, 1]")],section:"Paths and rotations",doc:"The rotate angles that turn a part's x and z axes onto two directions"},{name:"len",kind:"function",params:n3,section:"Lists and strings",doc:"Number of items in a list, characters in a string or fields in a record"},{name:"keys",kind:"function",params:[L("record","A record, as {name = value}")],section:"Lists and strings",doc:"A record's field names, in the order they were written"},{name:"merge",kind:"function",params:[L("a","A record"),L("b","A record whose fields add to or replace those of a")],section:"Lists and strings",doc:"A record with the fields of a and b, b winning where both have one"},{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:n3,section:"Lists and strings",doc:"A list or string in reverse order"},{name:"sum",kind:"function",params:[L("values","A list of numbers")],section:"Lists and strings",doc:"The sum of a list of numbers"},{name:"slice",kind:"function",params:[L("value","A list or string"),L("start","First index","0"),L("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:[L("text")],section:"Lists and strings",doc:"The first character's Unicode code point"},{name:"upper",kind:"function",params:[L("text")],section:"Lists and strings",doc:"Text in capitals"},{name:"lower",kind:"function",params:[L("text")],section:"Lists and strings",doc:"Text in small letters"},{name:"split",kind:"function",params:[L("text"),L("separator",void 0,'" "')],section:"Lists and strings",doc:"Text split into a list of strings"},{name:"join",kind:"function",params:[L("values"),L("separator",void 0,'""')],section:"Lists and strings",doc:"Values joined into one string"},{name:"search",kind:"function",params:[L("value"),L("list","A list or string")],section:"Lists and strings",doc:"Index of the first equal item, or undef"},{name:"contains",kind:"function",params:[L("value","A list or string"),L("item")],section:"Lists and strings",doc:"Whether a list contains an item or a string contains a substring"},{name:"lookup",kind:"function",params:[L("x"),L("table","A list of [x, y] pairs")],section:"Lists and strings",doc:"Interpolate in a table; outside it, the nearest end"},K0("is_num","a number other than NaN"),K0("is_string","a string"),K0("is_bool","true or false"),K0("is_list","a list"),K0("is_undef","undef"),K0("is_function","a function"),K0("is_record","a record, as {name = value}"),{name:"type_of",kind:"function",params:n3,section:"Types",doc:"The type name: number, string, boolean, undef, list, range, function or record"},{name:"rands",kind:"function",params:[L("min"),L("max"),L("count"),L("seed","The same seed gives the same list","1")],section:"Random values",doc:"A list of count numbers between min and max"},z4("text_width","The advance width of the text, including spacing"),z4("text_metrics","The text as [advance, [[x0, y0], [x1, y1]], ascent, descent]"),{name:"finger_count",kind:"function",params:[L("length","Edge length"),L("finger","Finger width",Q3)],section:"Joint dimensions",doc:"The odd number of fingers finger_rect() puts on an edge of that length"}],I8=new Map(c3.map(n=>[n.name,n])),s2=n=>I8.get(n);function a3(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 g0={"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.
@@ -97,6 +97,62 @@ module joint_test(kerfs = [0.1, 0.15, 0.2], size = [40, 20], finger = undef, lab
97
97
  }
98
98
  }
99
99
  }
100
+ `,"kerf/cones":`// kerf/cones: cones and cut-off cones cut flat, to roll up from thin sheet.
101
+ // Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or MyLaserTools commercial licence.
102
+ //
103
+ // A cone rolled from paper, card, veneer or thin plastic is a ring sector
104
+ // when flat. Gramophone horns, lampshades, funnels and party hats all start
105
+ // as one. The sector's apex is at the origin and it opens from +x
106
+ // anticlockwise; the glue tab runs along its far edge.
107
+
108
+ // The flat pattern of a cone of radius r1 at one end, r2 at the other and h
109
+ // high: [outer radius, inner radius, angle in degrees, slant length]. A
110
+ // cylinder (r1 == r2) has no apex: it gives [undef, undef, 0, h] and is a
111
+ // rectangle 2 * PI * r1 wide.
112
+ function cone_pattern(r1, r2, h) =
113
+ let (
114
+ big = max(r1, r2),
115
+ small = min(r1, r2),
116
+ s = sqrt(h * h + pow(big - small, 2))
117
+ )
118
+ big == small ? [undef, undef, 0, h]
119
+ : [s * big / (big - small), s * small / (big - small), 360 * (big - small) / s, s];
120
+
121
+ // A cone or cut-off cone cut flat: rolled up so the far edge lies on the
122
+ // glue tab, it has radius r1 at one end, r2 at the other, and is h high.
123
+ // \`tab\` adds a glue tab that wide along the far edge, its fold scored; a
124
+ // cylinder becomes a rectangle with the tab on its right.
125
+ module cone_flat(r1, r2, h, tab = 0, steps = 0) {
126
+ p = cone_pattern(r1, r2, h);
127
+ if (is_undef(p[0])) {
128
+ w = 2 * PI * r1;
129
+ rect([w, h]);
130
+ if (tab > 0) {
131
+ polygon([[w, 0], [w + tab, min(tab, h / 4)], [w + tab, h - min(tab, h / 4)], [w, h]]);
132
+ score() line([w, 0], [w, h]);
133
+ }
134
+ } else {
135
+ a = p[2];
136
+ n = steps > 0 ? steps : max(8, ceil(a / 3));
137
+ arc_pts = function(r) [for (i = [0:n]) [r * cos(a * i / n), r * sin(a * i / n)]];
138
+ polygon(concat(arc_pts(p[0]), p[1] > 0 ? reverse(arc_pts(p[1])) : [[0, 0]]));
139
+ if (tab > 0) {
140
+ // The tab beyond the far edge, its ends cut in so it hides when rolled
141
+ ux = cos(a);
142
+ uy = sin(a);
143
+ nx = -uy;
144
+ ny = ux;
145
+ c = min(tab, p[3] / 4);
146
+ polygon([
147
+ [p[1] * ux, p[1] * uy],
148
+ [p[0] * ux, p[0] * uy],
149
+ [(p[0] - c) * ux + tab * nx, (p[0] - c) * uy + tab * ny],
150
+ [(p[1] + (p[1] > 0 ? c : tab)) * ux + tab * nx, (p[1] + (p[1] > 0 ? c : tab)) * uy + tab * ny],
151
+ ]);
152
+ score() line([p[1] * ux, p[1] * uy], [p[0] * ux, p[0] * uy]);
153
+ }
154
+ }
155
+ }
100
156
  `,"kerf/dividers":`// kerf/dividers: dividers that slot into each other like an egg crate.
101
157
  // Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or MyLaserTools commercial licence.
102
158
 
@@ -370,6 +426,209 @@ module tappets(n, r, w = 10, hub = 14, bore = 6, square = false) {
370
426
  if (square) rect([bore, bore], center = true); else circle(d = bore);
371
427
  }
372
428
  }
429
+
430
+ // Cams from a lift curve. The follower rides on the cam's top (+y) and
431
+ // moves straight up and down; turned anticlockwise by \`a\` degrees (rotate =
432
+ // [0, 0, a]), the cam lifts it lift(a) above the base circle. \`lift\` is a
433
+ // function of the angle, 0 to 360, that comes back to where it started.
434
+
435
+ // A smooth rise of \`height\` from angle a0 to a1 (cycloidal: it starts and
436
+ // stops gently): 0 before a0, height after a1. Add and take away rises to
437
+ // make dwells, rises and falls: two pecks then a rest is
438
+ // function(a) cam_rise(a, 0, 40, 8) - cam_rise(a, 40, 80, 8) + cam_rise(a, 100, 140, 8) - cam_rise(a, 140, 180, 8).
439
+ function cam_rise(a, a0, a1, height) =
440
+ a <= a0 ? 0
441
+ : a >= a1 ? height
442
+ : let (u = (a - a0) / (a1 - a0)) height * (u - sin(360 * u) / (2 * PI));
443
+
444
+ // The cam's pitch curve: where the follower's tip (or its roller's centre)
445
+ // sits, in the cam's own turn, \`steps\` points round
446
+ function cam_pitch(lift, base_r, roller_d = 0, steps = 180) =
447
+ [for (i = [0:steps - 1])
448
+ let (f = i * 360 / steps, a = (450 - f) % 360, r = base_r + roller_d / 2 + lift(a))
449
+ [r * cos(f), r * sin(f)]];
450
+
451
+ // How high the follower's tip (or its roller's centre) is above the cam's
452
+ // axle when the cam is turned to \`angle\`, to place the follower
453
+ function cam_follower(lift, base_r, angle, roller_d = 0) =
454
+ base_r + roller_d / 2 + lift(((angle % 360) + 360) % 360);
455
+
456
+ // The steepest pressure angle over a turn, in degrees: how hard the cam
457
+ // pushes the follower sideways. Keep it under about 30, by a bigger base
458
+ // circle or a longer rise.
459
+ function cam_pressure(lift, base_r, roller_d = 0, steps = 360) =
460
+ max([for (i = [0:steps - 1])
461
+ let (
462
+ a = i * 360 / steps,
463
+ r = base_r + roller_d / 2 + lift(a),
464
+ slope = (lift((a + 0.5) % 360) - lift((a + 359.5) % 360)) / (PI / 180)
465
+ )
466
+ atan(abs(slope) / r)]);
467
+
468
+ // A cam that lifts a follower lift(a) at angle a, with a hole for its
469
+ // axle. A "knife" follower rides the pitch curve itself; a "roller" one of
470
+ // diameter roller_d rolls on a profile inside it. Check cam_pressure().
471
+ module cam(lift, base_r, follower = "knife", roller_d = 0, bore = 6, steps = 180, square = false) {
472
+ assert(follower == "knife" || follower == "roller", "follower must be \\"knife\\" or \\"roller\\"");
473
+ assert(follower == "knife" || roller_d > 0, "a roller follower needs roller_d");
474
+ difference() {
475
+ if (follower == "roller") offset(r = -roller_d / 2) polygon(cam_pitch(lift, base_r, roller_d, steps));
476
+ else polygon(cam_pitch(lift, base_r, 0, steps));
477
+ if (square) rect([bore, bore], center = true); else circle(d = bore);
478
+ }
479
+ }
480
+
481
+ // A Geneva drive: a driver turning all the time steps a wheel of \`slots\`
482
+ // slots on by one slot each turn, and locks it between steps. The driver's
483
+ // axle is at the origin and the wheel's at [distance, 0]. Cut the wheel and
484
+ // the locking disc from the same sheet, side by side in one plane, and the
485
+ // crank above them; a dowel pin of pin_d through the crank's outer hole
486
+ // runs in the wheel's slots.
487
+
488
+ // The radius of the circle the driver's pin turns on
489
+ function geneva_pin_radius(slots, distance) = distance * sin(180 / slots);
490
+ // The wheel's outer radius
491
+ function geneva_wheel_radius(slots, distance, pin_d) =
492
+ sqrt(pow(distance * cos(180 / slots), 2) + pow(pin_d / 2, 2));
493
+ // The locking disc's radius
494
+ function geneva_lock_radius(slots, distance, pin_d) = geneva_pin_radius(slots, distance) - pin_d;
495
+
496
+ // How far the wheel has turned when the driver has turned \`angle\`
497
+ // anticlockwise from its pin pointing at the wheel: it turns clockwise,
498
+ // 360 / slots each turn of the driver, and stands still between steps
499
+ function geneva_turn(slots, distance, angle) =
500
+ let (
501
+ k = floor((angle + 180) / 360),
502
+ t = angle - 360 * k,
503
+ rc = geneva_pin_radius(slots, distance),
504
+ on = 90 - 180 / slots,
505
+ step = abs(t) <= on ? atan2(-rc * sin(t), distance - rc * cos(t))
506
+ : t < 0 ? 180 / slots : -180 / slots
507
+ )
508
+ step - k * 360 / slots;
509
+
510
+ // The wheel, centred on the origin, a slot along -x (towards the driver
511
+ // when geneva_turn() is 0)
512
+ module geneva_wheel(slots, distance, pin_d = 6, bore = 6, clearance = 0.2, square = false) {
513
+ rc = geneva_pin_radius(slots, distance);
514
+ ro = geneva_wheel_radius(slots, distance, pin_d);
515
+ rl = geneva_lock_radius(slots, distance, pin_d);
516
+ w = pin_d + clearance;
517
+ inner = distance - rc - clearance;
518
+ assert(rl > 0, "the pin is too thick to leave a locking disc: make the distance longer or the pin thinner");
519
+ assert(inner - w / 2 > bore / 2 + 3, "the slots reach the axle: use more slots, a longer distance or a smaller bore");
520
+ difference() {
521
+ circle(r = ro);
522
+ for (j = [0:slots - 1]) rotate(180 + j * 360 / slots) {
523
+ hull() {
524
+ translate([inner, 0]) circle(d = w);
525
+ translate([ro + 1, -w / 2]) rect([1, w]);
526
+ }
527
+ // The locking arc between this slot and the next
528
+ rotate(180 / slots) translate([distance, 0]) circle(r = rl + clearance);
529
+ }
530
+ if (square) rect([bore, bore], center = true); else circle(d = bore);
531
+ }
532
+ }
533
+
534
+ // The locking disc that turns with the driver, its relief facing the pin's
535
+ // side (+x): cut away wherever the wheel's rim passes while the pin is in a
536
+ // slot, so the wheel turns then
537
+ module geneva_lock(slots, distance, pin_d = 6, bore = 6, clearance = 0.2, square = false) {
538
+ assert(geneva_lock_radius(slots, distance, pin_d) > bore / 2 + 3, "the locking disc is too small for its axle: make the distance longer, the pin thinner or the bore smaller");
539
+ ro = geneva_wheel_radius(slots, distance, pin_d);
540
+ assert(distance - ro - clearance >= bore / 2 + 2, str("the wheel passes within ", round(10 * (distance - ro - clearance)) / 10, " mm of the driver's axle: use a bore of at most ", floor(20 * (distance - ro - clearance - 2)) / 10, " mm or fewer slots"));
541
+ difference() {
542
+ circle(r = geneva_lock_radius(slots, distance, pin_d));
543
+ // Everywhere the wheel's rim passes while the pin is in a slot
544
+ on = 90 - 180 / slots;
545
+ n = max(2, ceil(2 * on / 3));
546
+ for (i = [0:n - 1]) hull() for (t = [-on + 2 * on * i / n, -on + 2 * on * (i + 1) / n])
547
+ translate([distance * cos(t), distance * sin(t)]) circle(r = ro + clearance);
548
+ if (square) rect([bore, bore], center = true); else circle(d = bore);
549
+ }
550
+ }
551
+
552
+ // The crank above the locking disc that carries the pin, along +x
553
+ module geneva_crank(slots, distance, pin_d = 6, bore = 6, width = 0, square = false) {
554
+ rc = geneva_pin_radius(slots, distance);
555
+ w = width > 0 ? width : max(pin_d, bore) + 8;
556
+ difference() {
557
+ hull() {
558
+ circle(d = w);
559
+ translate([rc, 0]) circle(d = pin_d + 8);
560
+ }
561
+ translate([rc, 0]) circle(d = pin_d);
562
+ if (square) rect([bore, bore], center = true); else circle(d = bore);
563
+ }
564
+ }
565
+
566
+ // A ratchet wheel of \`teeth\` teeth, radius r at their tips, \`depth\` deep,
567
+ // centred on the origin with a hole for its axle. It turns anticlockwise
568
+ // freely; a pawl() stops it turning back.
569
+ module ratchet(teeth, r, depth, bore = 6, square = false) {
570
+ p = 360 / teeth;
571
+ difference() {
572
+ polygon([for (k = [0:teeth - 1], j = [0, 1])
573
+ j == 0 ? [r * cos(k * p), r * sin(k * p)]
574
+ : [(r - depth) * cos((k + 1) * p), (r - depth) * sin((k + 1) * p)]]);
575
+ if (square) rect([bore, bore], center = true); else circle(d = bore);
576
+ }
577
+ }
578
+
579
+ // The angle of the tooth face a pawl rests on, nearest \`at\` degrees
580
+ function pawl_face(teeth, at = 90) = round(at / (360 / teeth)) * 360 / teeth;
581
+
582
+ // How far the pawl leans out from the wheel's edge, in degrees: past the
583
+ // teeth's slope, so it clears them
584
+ function pawl_lean(teeth, r, depth) = atan(depth / ((r - depth / 2) * 2 * PI / teeth)) + 15;
585
+
586
+ // The shortest pawl of this width that clears the teeth: its tip edge,
587
+ // along the tooth face, must end before its far end does
588
+ function pawl_min_length(teeth, r, depth, width = 8) =
589
+ width * (0.5 + tan(pawl_lean(teeth, r, depth))) + 2;
590
+
591
+ // The pawl's outline round the wheel's centre: its tip on the root by the
592
+ // tooth face, its far end, and back along the face. Its pivot is the
593
+ // middle of its far end. A length of 0 picks 0.8 * r, or longer if the
594
+ // pawl must be to clear the teeth; pawl() refuses a length given shorter
595
+ // than pawl_min_length().
596
+ function pawl_points(teeth, r, depth, length = 0, width = 8, at = 90, clearance = 0.2) =
597
+ let (
598
+ f = pawl_face(teeth, at),
599
+ g = pawl_lean(teeth, r, depth),
600
+ shortest = pawl_min_length(teeth, r, depth, width),
601
+ L = length > 0 ? length : max(r * 0.8, shortest),
602
+ n = [cos(f), sin(f)],
603
+ tc = [sin(f), -cos(f)],
604
+ u = cos(g) * tc + sin(g) * n,
605
+ v = cos(g) * n - sin(g) * tc,
606
+ T = (r - depth + clearance) * n + clearance * tc
607
+ )
608
+ [T, T + (L - width / 2) * u, T + (L - width / 2) * u + width * v, T + width / cos(g) * n];
609
+
610
+ // Where a pawl()'s pivot is, round the wheel's centre
611
+ function pawl_pivot(teeth, r, depth, length = 0, width = 8, at = 90, clearance = 0.2) =
612
+ let (p = pawl_points(teeth, r, depth, length, width, at, clearance)) (p[1] + p[2]) / 2;
613
+
614
+ // A pawl for a ratchet() of the same sizes, drawn where it works round
615
+ // the wheel's centre: give it the wheel's placement. Its tip rests against
616
+ // the tooth face nearest \`at\` degrees, and it turns on a pin through the
617
+ // hole at pawl_pivot(). Gravity, a rubber band or a spring wire holds it
618
+ // down on the teeth.
619
+ module pawl(teeth, r, depth, length = 0, width = 8, bore = 3, at = 90, clearance = 0.2) {
620
+ shortest = pawl_min_length(teeth, r, depth, width);
621
+ assert(length == 0 || length >= shortest, str("a pawl ", width, " mm wide must be at least ", ceil(2 * shortest) / 2, " mm long to clear the teeth: make it longer or narrower"));
622
+ p = pawl_points(teeth, r, depth, length, width, at, clearance);
623
+ H = (p[1] + p[2]) / 2;
624
+ difference() {
625
+ union() {
626
+ polygon(p);
627
+ translate(H) circle(d = width);
628
+ }
629
+ translate(H) circle(d = bore);
630
+ }
631
+ }
373
632
  `,"kerf/geo":`// kerf/geo: the world's land, for maps, globes and country-shaped pieces.
374
633
  // Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or MyLaserTools commercial licence.
375
634
  // The land data is Natural Earth's 1:110m land (public domain,
@@ -1000,6 +1259,60 @@ module halved_pair(name, at = [0, 0, 0], cap = undef, feet = [], side_feet = und
1000
1259
  }
1001
1260
  }
1002
1261
  }
1262
+ `,"kerf/linkage":`// kerf/linkage: where the joints of a linkage are at a crank angle.
1263
+ // Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or MyLaserTools commercial licence.
1264
+ //
1265
+ // Each function gives the joint points of a linkage drawn flat, so a part
1266
+ // placed on a link and the link's length come from the same numbers. Use
1267
+ // them to place moving parts at a drive angle, and to check a linkage closes
1268
+ // over a whole turn.
1269
+
1270
+ // Where a circle of radius ra round a meets one of radius rb round b: the
1271
+ // point left of the line from a to b (side = 1) or right of it (side = -1).
1272
+ // undef when the circles don't meet: the links are too short or too long.
1273
+ function circle_meet(a, ra, b, rb, side = 1) =
1274
+ let (
1275
+ dx = b[0] - a[0],
1276
+ dy = b[1] - a[1],
1277
+ d = sqrt(dx * dx + dy * dy),
1278
+ along = d > 0 ? (ra * ra - rb * rb + d * d) / (2 * d) : 0,
1279
+ h2 = ra * ra - along * along
1280
+ )
1281
+ d == 0 || h2 < -1e-9 ? undef
1282
+ : let (h = sqrt(max(0, h2)), ux = dx / d, uy = dy / d)
1283
+ [a[0] + along * ux - side * h * uy, a[1] + along * uy + side * h * ux];
1284
+
1285
+ // A crank of radius r turning round the origin drives a slider along the
1286
+ // line y = offset through a connecting rod of length l. At the crank's
1287
+ // angle it gives [crank pin, slider pin]; undef if the rod can't reach.
1288
+ function slider_crank(r, l, angle, offset = 0) =
1289
+ let (
1290
+ pin = [r * cos(angle), r * sin(angle)],
1291
+ dy = offset - pin[1]
1292
+ )
1293
+ abs(dy) > l ? undef : [pin, [pin[0] + sqrt(l * l - dy * dy), offset]];
1294
+
1295
+ // How far the slider of slider_crank() travels from end to end
1296
+ function slider_stroke(r, l, offset = 0) =
1297
+ sqrt(pow(l + r, 2) - offset * offset) - sqrt(pow(l - r, 2) - offset * offset);
1298
+
1299
+ // A four-bar linkage: the crank turns round the origin, the rocker round
1300
+ // [ground, 0], and the coupler joins their ends. At the crank's angle it
1301
+ // gives [crank end, rocker end], the rocker end on the side \`side\` of the
1302
+ // line from the crank end to the rocker's pivot; undef where the links
1303
+ // can't close.
1304
+ function four_bar(ground, crank, coupler, rocker, angle, side = 1) =
1305
+ let (b = [crank * cos(angle), crank * sin(angle)], c = circle_meet(b, coupler, [ground, 0], rocker, side))
1306
+ is_undef(c) ? undef : [b, c];
1307
+
1308
+ // True when the crank of a four-bar linkage turns all the way round
1309
+ // (Grashof's rule, with the crank the shortest link)
1310
+ function four_bar_turns(ground, crank, coupler, rocker) =
1311
+ let (s = min(ground, crank, coupler, rocker), l = max(ground, crank, coupler, rocker))
1312
+ crank == s && s + l <= ground + crank + coupler + rocker - s - l;
1313
+
1314
+ // The angle in degrees of the line from a to b, from +x
1315
+ function link_angle(a, b) = atan2(b[1] - a[1], b[0] - a[0]);
1003
1316
  `,"kerf/lock":`// kerf/lock: a lock with a key, for boxes, diaries, chests and money boxes.
1004
1317
  // Copyright (c) 2026 MyLaserTools. AGPL-3.0-only or MyLaserTools commercial licence.
1005
1318
  //
@@ -1184,11 +1497,20 @@ function card_size(name) = let (s = lookup_size(name, CARD_SIZES))
1184
1497
  is_undef(s) ? assert(false, str("Unknown card size \\"", name, "\\". Known: ", size_names(CARD_SIZES))) : s;
1185
1498
 
1186
1499
  // Photo print sizes as [width, height], landscape: "4x6", "5x7", "8x10",
1187
- // "10x15" (cm), "13x18" (cm), "instax mini", "instax square", "instax wide",
1188
- // "polaroid".
1189
- function photo_size(name) = let (s = lookup_size(name, PHOTO_SIZES))
1500
+ // "10x15" (cm), "13x18" (cm), and instant film: "instant mini", "instant
1501
+ // square", "instant wide" and "instant classic".
1502
+ function photo_size(name) = let (s = lookup_size(lookup_alias(name, PHOTO_ALIASES), PHOTO_SIZES))
1190
1503
  is_undef(s) ? assert(false, str("Unknown photo size \\"", name, "\\". Known: ", size_names(PHOTO_SIZES))) : s;
1191
1504
 
1505
+ // A bought part's sizes by name, as a record: \`body\` [width, depth,
1506
+ // height], and for parts with one, the \`shaft\` diameter, the \`shaft_length\`
1507
+ // it stands out of the body and the \`hole\` to cut for it. Retail sizes vary:
1508
+ // measure yours. "music-18" (an 18-note wind-up music box movement, shaft
1509
+ // the winding key's), "quartz-clock" (a 56 mm quartz clock movement with
1510
+ // the 16.5 mm shaft for dials up to 8 mm thick), "marble-16" and "marble-25".
1511
+ function part_size(name) = let (s = lookup_size(name, PART_SIZES))
1512
+ is_undef(s) ? assert(false, str("Unknown part \\"", name, "\\". Known: ", size_names(PART_SIZES))) : s;
1513
+
1192
1514
  // A size turned to lie wider than tall
1193
1515
  function landscape(size) = size[0] >= size[1] ? size : [size[1], size[0]];
1194
1516
  // A size turned to stand taller than wide
@@ -1210,13 +1532,28 @@ CARD_SIZES = [
1210
1532
  ];
1211
1533
  PHOTO_SIZES = [
1212
1534
  ["4x6", [152.4, 101.6]], ["5x7", [177.8, 127]], ["8x10", [254, 203.2]],
1213
- ["10x15", [150, 100]], ["13x18", [180, 130]], ["instax mini", [54, 86]],
1214
- ["instax square", [72, 86]], ["instax wide", [108, 86]], ["polaroid", [88, 107]]
1535
+ ["10x15", [150, 100]], ["13x18", [180, 130]], ["instant mini", [54, 86]],
1536
+ ["instant square", [72, 86]], ["instant wide", [108, 86]], ["instant classic", [88, 107]]
1537
+ ];
1538
+ // Older names that still work, left out of the list of known names
1539
+ PHOTO_ALIASES = [
1540
+ ["instax mini", "instant mini"], ["instax square", "instant square"],
1541
+ ["instax wide", "instant wide"], ["polaroid", "instant classic"]
1542
+ ];
1543
+ PART_SIZES = [
1544
+ ["music-18", {body = [50, 44, 20], shaft = 3.5, hole = 6}],
1545
+ ["quartz-clock", {body = [56, 56, 16], shaft = 7.6, shaft_length = 16.5, hole = 8, dial = 8}],
1546
+ ["marble-16", {body = [16, 16, 16]}],
1547
+ ["marble-25", {body = [25, 25, 25]}]
1215
1548
  ];
1216
1549
 
1217
1550
  // The size of that name in a table of [name, size], ignoring case
1218
1551
  function lookup_size(name, table) = let (k = lower(name), hit = [for (e = table) if (lower(e[0]) == k) e[1]])
1219
1552
  len(hit) ? hit[0] : undef;
1553
+ // The name an older name stands for in a table of [old, new], or the name
1554
+ // itself
1555
+ function lookup_alias(name, aliases) = let (k = lower(name), hit = [for (e = aliases) if (lower(e[0]) == k) e[1]])
1556
+ len(hit) ? hit[0] : name;
1220
1557
  // The names in a table, for messages
1221
1558
  function size_names(table) = join([for (e = table) e[0]], ", ");
1222
1559
  `,"kerf/symbols":`// kerf/symbols: 867 pictograms by name, for engraving and cutting.
@@ -2219,45 +2556,45 @@ module tab_rect(size, edges = true, count = undef, width = undef) {
2219
2556
  if (e[2]) translate([w, h]) rotate(180) tabs(w, count, width);
2220
2557
  if (e[3]) translate([0, h]) rotate(270) tabs(h, count, width);
2221
2558
  }
2222
- `};var I8=/^(?:[A-Za-z_$][A-Za-z0-9_]*|(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?|"(?:[^"\\]|\\.)*"?|<=|>=|==|!=|&&|\|\|)/,z4=(c,e)=>Math.max(1,I8.exec(c.slice(e-1))?.[0].length??1);var c0=c=>typeof c=="object"&&c!==null&&!Array.isArray(c)&&c.type==="range",C0=c=>typeof c=="object"&&c!==null&&!Array.isArray(c)&&c.type==="function",k4=c=>typeof c=="number",B1=c=>typeof c=="object"&&c!==null&&!Array.isArray(c)&&c.type==="record",Y1=(c,e)=>c&&Object.prototype.hasOwnProperty.call(c,e)?c[e]:void 0;function e5(c,e,t=0){if(!(e==null||["number","string","boolean"].includes(typeof e))){if(Array.isArray(e)&&t<32){for(let n of e)e5(c,n,t+1);return}throw new Error(`Setting "${c}" must be a number, string, boolean or list`)}}function n3(c,e){let t=[];if(c.step===0||(c.step>0?c.start>c.end:c.start<c.end))return t;let n=Math.floor((c.end-c.start)/c.step+1e-9)+1;if(n>e)throw new Error(`a range of ${n} items is more than the limit of ${e}`);for(let a=0;a<n;a++)t.push(c.start+a*c.step);return t}function k1(c){return c===void 0||c===!1||c===0||c===""?!1:Array.isArray(c)?c.length>0:typeof c=="number"?!Number.isNaN(c):!0}var w4=(c,e,t)=>c0(c)&&c0(e)?c.start===e.start&&c.step===e.step&&c.end===e.end:B1(c)&&B1(e)?c.fields.size===e.fields.size&&[...c.fields].every(([n,a])=>e.fields.has(n)&&i2(a,e.fields.get(n),t)):c===e;function i2(c,e,t){if(t?.(),!Array.isArray(c)||!Array.isArray(e))return w4(c,e,t);let n=new Map,a=[],r=(s,i)=>{let l=n.get(s);return l?.has(i)?!0:s.length!==i.length?!1:(l||n.set(s,l=new Set),l.add(i),a.push([s,i,0]),!0)};if(!r(c,e))return!1;for(;a.length;){let s=a[a.length-1];if(s[2]===s[0].length){a.pop();continue}let i=s[0][s[2]],l=s[1][s[2]++];if(t?.(),Array.isArray(i)&&Array.isArray(l)?!r(i,l):!w4(i,l,t))return!1}return!0}function K1(c){return c===void 0?"undef":Array.isArray(c)?"list":c0(c)?"range":C0(c)?"function":B1(c)?"record":typeof c}function H8(c){return c===void 0?"undef":typeof c=="string"?JSON.stringify(c):typeof c=="number"?A0(c):c0(c)?`[${A0(c.start)}:${A0(c.step)}:${A0(c.end)}]`:C0(c)?`function(${c.params.map(e=>e.name).join(", ")})`:B1(c)?"{}":String(c)}function l2(c,e,t=!1){if(typeof c=="string"&&!t)return{text:c.length>e?c.slice(0,Math.max(e,0)):c,whole:c.length<=e};let n=[],a=0,r=o=>{n.push(o),a+=o.length},s=[],i=c;for(;;){Array.isArray(i)?(r("["),s.push({items:i,i:0,close:"]"})):B1(i)&&i.fields.size?(r("{"),s.push({items:[...i.fields.values()],keys:[...i.fields.keys()],i:0,close:"}"})):r(H8(i));let o=!1;for(;s.length&&!o&&a<=e;){let h=s[s.length-1];h.i<h.items.length?(h.i&&r(", "),h.keys&&r(`${h.keys[h.i]} = `),i=h.items[h.i++],o=!0):(s.pop(),r(h.close))}if(!o||a>e)break}let l=n.join("");return a>e?{text:l.slice(0,Math.max(e,0)),whole:!1}:{text:l,whole:!0}}function L4(c,e,t){let n=[],a=0;for(let r of c){n.length&&(a+=e.length);let s=l2(r,t-a);if(!s.whole)return;a+=s.text.length,n.push(s.text)}return n.join(e)}function J1(c){let e=l2(c,200,!0);return e.whole?e.text:e.text+"..."}var I1=c=>typeof c=="string"?c:J1(c);function H1(c){let e=!1;for(;Array.isArray(c)&&c.length===1;)c=c[0],e=!0;return Array.isArray(c)?c.length?NaN:0:e&&(c===void 0||typeof c=="boolean")?c===void 0?0:NaN:typeof c=="object"?NaN:Number(c)}function A0(c){return Number.isInteger(c)?String(c):String(Number(c.toPrecision(10)))}function o2(c,e=.02){let t=[],n=[],a=[],r=[0,0],s=[0,0],i=o=>{a.length>=2&&(o?t:n).push(a),a=[]},l=o=>Math.max(2,Math.min(256,Math.ceil(Math.sqrt(o/e))));for(let o of c)if(o.type==="M")i(!1),r=s=[o.x,o.y],a=[s];else if(o.type==="L")s=[o.x,o.y],a.push(s);else if(o.type==="Q"){let[h,f]=s,u=l(Math.hypot(o.x1-h,o.y1-f)+Math.hypot(o.x-o.x1,o.y-o.y1));for(let d=1;d<=u;d++){let p=d/u,m=1-p;a.push([m*m*h+2*m*p*o.x1+p*p*o.x,m*m*f+2*m*p*o.y1+p*p*o.y])}s=[o.x,o.y]}else if(o.type==="C"){let[h,f]=s,u=l(Math.hypot(o.x1-h,o.y1-f)+Math.hypot(o.x2-o.x1,o.y2-o.y1)+Math.hypot(o.x-o.x2,o.y-o.y2));for(let d=1;d<=u;d++){let p=d/u,m=1-p;a.push([m*m*m*h+3*m*m*p*o.x1+3*m*p*p*o.x2+p*p*p*o.x,m*m*m*f+3*m*m*p*o.y1+3*m*p*p*o.y2+p*p*p*o.y])}s=[o.x,o.y]}else i(!0),s=r,a=[r];return i(!1),{closed:t,open:n}}function a3(c,e=Math.PI/2,t){let n=A=>/^[a-zA-Z]$/.test(A),a=c.match(/[a-zA-Z]|[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/g)??[],r=[],s=0,i="",l=0,o=0,h=0,f=0,u=0,d=0,p=0,m=0,v="",g=()=>{let A=a[s++];if(A===void 0||n(A))throw new Error(`Bad path data near "${A??"end"}"`);return Number(A)},y=()=>{let A=a[s];if(A===void 0)throw new Error("Bad path data: missing arc flag");return A.length>1&&(A[0]==="0"||A[0]==="1")&&!A.includes(".")?(a[s]=A.slice(1),Number(A[0])):(s++,Number(A))};try{M()}catch(A){if(!t)throw A;t(A.message)}return r;function M(){for(;s<a.length;){if(n(a[s]))i=a[s++];else if(i){if(i==="Z"||i==="z")throw new Error(`Bad path data near "${a[s]}": Z takes no numbers`)}else throw new Error("Path data must start with a command");let A=i===i.toLowerCase(),z=i.toUpperCase(),E=A?l:0,k=A?o:0;if(z==="M")l=E+g(),o=k+g(),h=l,f=o,r.push({type:"M",x:l,y:o}),i=A?"l":"L";else if(z==="L")l=E+g(),o=k+g(),r.push({type:"L",x:l,y:o});else if(z==="H")l=E+g(),r.push({type:"L",x:l,y:o});else if(z==="V")o=k+g(),r.push({type:"L",x:l,y:o});else if(z==="C"||z==="S"){let C,P;if(z==="C")C=E+g(),P=k+g();else{let B=v==="C"||v==="S";C=B?2*l-u:l,P=B?2*o-d:o}let w=E+g(),I=k+g();l=E+g(),o=k+g(),u=w,d=I,r.push({type:"C",x1:C,y1:P,x2:w,y2:I,x:l,y:o})}else if(z==="Q"||z==="T"){let C,P;if(z==="Q")C=E+g(),P=k+g();else{let w=v==="Q"||v==="T";C=w?2*l-p:l,P=w?2*o-m:o}l=E+g(),o=k+g(),p=C,m=P,r.push({type:"Q",x1:C,y1:P,x:l,y:o})}else if(z==="A"){let C=g(),P=g(),w=g(),I=y(),B=y(),F=E+g(),G=k+g();r.push(...V8(l,o,C,P,w,I,B,F,G,e)),l=F,o=G}else if(z==="Z")r.push({type:"Z"}),l=h,o=f;else throw new Error(`Unknown path command "${i}"`);v=z}}}function V8(c,e,t,n,a,r,s,i,l,o=Math.PI/2){if(t===0||n===0||c===i&&e===l)return[{type:"L",x:i,y:l}];t=Math.abs(t),n=Math.abs(n);let h=a*Math.PI/180,f=Math.cos(h),u=Math.sin(h),d=(c-i)/2,p=(e-l)/2,m=f*d+u*p,v=-u*d+f*p,g=m*m/(t*t)+v*v/(n*n);g>1&&(t*=Math.sqrt(g),n*=Math.sqrt(g));let y=t*t*n*n-t*t*v*v-n*n*m*m,M=t*t*v*v+n*n*m*m,A=Math.sqrt(Math.max(0,y/M));r===s&&(A=-A);let z=A*t*v/n,E=-A*n*m/t,k=f*z-u*E+(c+i)/2,C=u*z+f*E+(e+l)/2,P=(q,o1,N,Z)=>Math.atan2(q*Z-o1*N,q*N+o1*Z),w=P(1,0,(m-z)/t,(v-E)/n),I=P((m-z)/t,(v-E)/n,(-m-z)/t,(-v-E)/n);!s&&I>0&&(I-=2*Math.PI),s&&I<0&&(I+=2*Math.PI);let B=Math.ceil(Math.abs(I)/o),F=[],G=q=>[k+t*Math.cos(q)*f-n*Math.sin(q)*u,C+t*Math.cos(q)*u+n*Math.sin(q)*f],X=q=>[-t*Math.sin(q)*f-n*Math.cos(q)*u,-t*Math.sin(q)*u+n*Math.cos(q)*f];for(let q=0;q<B;q++){let o1=w+I*q/B,N=w+I*(q+1)/B,Z=4/3*Math.tan((N-o1)/4),e1=G(o1),t1=G(N),d1=X(o1),_1=X(N);F.push({type:"C",x1:e1[0]+Z*d1[0],y1:e1[1]+Z*d1[1],x2:t1[0]-Z*_1[0],y2:t1[1]-Z*_1[1],x:t1[0],y:t1[1]})}return F}var V1=Math.PI/180,J=(c,e,t)=>({params:c.replace("...","").split(",").map(n=>n.trim()).filter(Boolean),rest:c.endsWith("..."),order:t,run:e});function T4(c,e,t){return c.order?[]:c.params.filter((n,a)=>a<e.length&&t.has(n))}function I4(c,e,t){if(c.rest){let r=[...e];return c.params.forEach((s,i)=>{t.has(s)&&(r[i]=t.get(s))}),r}if(!c.order)return c.params.map((r,s)=>t.has(r)?t.get(r):e[s]);let n=e.length+c.params.filter(r=>t.has(r)).length,a=c.order(n).filter(r=>!t.has(r));return c.params.map(r=>t.has(r)?t.get(r):e[a.indexOf(r)])}function t5(c,e,t,n){let a=L4(c,e,t.maxLength);if(a===void 0)throw new Error(`${n}(): the text would be longer than the limit of ${t.maxLength} characters`);return t.step(Math.ceil(a.length/8)),a}function l1(c,e){if(typeof c!="number")throw new Error(`${e}() needs a number, got ${K1(c)}`);return c}function l0(c,e,t){if(Array.isArray(c))return c;if(c0(c))return n3(c,t.maxLength);if(typeof c=="string")return[...c];throw new Error(`${e}() needs a list, got ${K1(c)}`)}var O8=new Set(["is_num","is_string","is_bool","is_list","is_undef","is_function","type_of","ord"]);function H4(c,e,t){if(O8.has(c))return 0;let n=0;for(let a of e)if(typeof a=="string")n+=a.length;else if(Array.isArray(a))n+=c==="len"?0:a.length;else if(c0(a)&&a.step!==0){let r=Math.floor((a.end-a.start)/a.step)+1;r>0&&(n+=Math.min(r,t+1))}return n}var X1=c=>J("x",e=>typeof e[0]=="number"?P0(c(e[0])):void 0);function P0(c){let e=Math.round(c);return Math.abs(c-e)<1e-12?e:c}function F8(c){let e=Math.floor(c)>>>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 S4(c,e,t){let n=c.length===1&&Array.isArray(c[0])?c[0]:c;if(n.length)return e(n.map(a=>l1(a,t)))}var A2={abs:X1(Math.abs),sign:X1(Math.sign),floor:X1(Math.floor),ceil:X1(Math.ceil),round:X1(c=>c<0?-Math.round(-c):Math.round(c)),sqrt:X1(Math.sqrt),exp:X1(Math.exp),ln:X1(Math.log),log:J("x, base",(c,e)=>e.given<2?P0(Math.log10(l1(c[0],"log"))):Math.log(l1(c[0],"log"))/Math.log(l1(c[1],"log")),c=>c>=2?["base","x"]:["x","base"]),sin:X1(c=>Math.sin(c*V1)),cos:X1(c=>Math.cos(c*V1)),tan:X1(c=>Math.tan(c*V1)),asin:X1(c=>Math.asin(c)/V1),acos:X1(c=>Math.acos(c)/V1),atan:X1(c=>Math.atan(c)/V1),atan2:J("y, x",c=>P0(Math.atan2(l1(c[0],"atan2"),l1(c[1],"atan2"))/V1)),pow:J("x, y",c=>Math.pow(l1(c[0],"pow"),l1(c[1],"pow"))),min:J("values...",c=>S4(c,e=>e.reduce((t,n)=>n<t?n:t,1/0),"min")),max:J("values...",c=>S4(c,e=>e.reduce((t,n)=>n>t?n:t,-1/0),"max")),clamp:J("x, low, high",c=>Math.min(Math.max(l1(c[0],"clamp"),l1(c[1],"clamp")),l1(c[2],"clamp"))),lerp:J("a, b, t",c=>{let e=l1(c[2],"lerp");if(Array.isArray(c[0])&&Array.isArray(c[1])){let t=c[1];return c[0].map((n,a)=>l1(n,"lerp")+(l1(t[a],"lerp")-l1(n,"lerp"))*e)}return l1(c[0],"lerp")+(l1(c[1],"lerp")-l1(c[0],"lerp"))*e}),norm:J("v",(c,e)=>Math.sqrt(l0(c[0],"norm",e).reduce((t,n)=>t+l1(n,"norm")**2,0))),cross:J("a, b",(c,e)=>{let t=l0(c[0],"cross",e).map(a=>l1(a,"cross")),n=l0(c[1],"cross",e).map(a=>l1(a,"cross"));return t.length===2?t[0]*n[1]-t[1]*n[0]:[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]]}),len:J("value",c=>typeof c[0]=="string"?[...c[0]].length:Array.isArray(c[0])?c[0].length:B1(c[0])?c[0].fields.size:void 0),keys:J("record",c=>B1(c[0])?[...c[0].fields.keys()]:void 0),merge:J("a, b",c=>{if(!B1(c[0])||!B1(c[1]))throw new Error("merge() takes two records");return{type:"record",fields:new Map([...c[0].fields,...c[1].fields])}}),concat:J("...",(c,e)=>{let t=c.reduce((n,a)=>n+(Array.isArray(a)?a.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 c.flatMap(n=>Array.isArray(n)?n:[n])}),reverse:J("value",(c,e)=>typeof c[0]=="string"?[...c[0]].reverse().join(""):[...l0(c[0],"reverse",e)].reverse()),sum:J("values",(c,e)=>l0(c[0],"sum",e).reduce((t,n)=>t+l1(n,"sum"),0)),slice:J("value, start, end",(c,e)=>{let n=(typeof c[0]=="string"?[...c[0]]:l0(c[0],"slice",e)).slice(l1(c[1]??0,"slice"),c[2]===void 0?void 0:l1(c[2],"slice"));return typeof c[0]=="string"?n.join(""):n}),str:J("...",(c,e)=>t5(c,"",e,"str")),chr:J("...",c=>c.flatMap(e=>Array.isArray(e)?e:[e]).map(e=>String.fromCodePoint(l1(e,"chr"))).join("")),ord:J("text",c=>typeof c[0]=="string"&&c[0].length?c[0].codePointAt(0):void 0),upper:J("text",c=>typeof c[0]=="string"?c[0].toUpperCase():void 0),lower:J("text",c=>typeof c[0]=="string"?c[0].toLowerCase():void 0),split:J("text, separator",c=>typeof c[0]=="string"?c[0].split(typeof c[1]=="string"?c[1]:" "):void 0),join:J("values, separator",(c,e)=>t5(l0(c[0],"join",e),typeof c[1]=="string"?c[1]:"",e,"join")),search:J("value, list",(c,e)=>{let n=(typeof c[1]=="string"?[...c[1]]:l0(c[1],"search",e)).findIndex(a=>i2(a,c[0],e.step));return n<0?void 0:n}),contains:J("value, item",(c,e)=>typeof c[0]=="string"?c[0].includes(t5([c[1]],"",e,"contains")):l0(c[0],"contains",e).some(t=>i2(t,c[1],e.step))),lookup:J("x, table",(c,e)=>{let t=l1(c[0],"lookup"),n=l0(c[1],"lookup",e);if(!n.length)return;let a=n.map(r=>[l1(r[0],"lookup"),l1(r[1],"lookup")]).sort((r,s)=>r[0]-s[0]);if(t<=a[0][0])return a[0][1];for(let r=1;r<a.length;r++)if(t<=a[r][0]){let[s,i]=a[r-1],[l,o]=a[r];return i+(t-s)/(l-s)*(o-i)}return a[a.length-1][1]}),rands:J("min, max, count, seed",c=>{let e=l1(c[0],"rands"),t=l1(c[1],"rands"),n=l1(c[2],"rands"),a=F8(c[3]===void 0?1:l1(c[3],"rands"));return Array.from({length:Math.min(Math.max(0,Math.floor(n)),1e6)},()=>e+(t-e)*a())}),is_num:J("value",c=>k4(c[0])&&!Number.isNaN(c[0])),is_string:J("value",c=>typeof c[0]=="string"),is_bool:J("value",c=>typeof c[0]=="boolean"),is_list:J("value",c=>Array.isArray(c[0])),is_record:J("value",c=>B1(c[0])),is_undef:J("value",c=>c[0]===void 0),is_function:J("value",c=>C0(c[0])),type_of:J("value",c=>K1(c[0])),path_length:J("points",(c,e)=>{let t=r3(c[0],"path_length",e),n=0;for(let a=1;a<t.length;a++)n+=Math.hypot(t[a][0]-t[a-1][0],t[a][1]-t[a-1][1]);return n}),point_at:J("points, s",(c,e)=>A4(r3(c[0],"point_at",e),l1(c[1],"point_at")).point),heading_at:J("points, s",(c,e)=>P0(A4(r3(c[0],"heading_at",e),l1(c[1],"heading_at")).heading)),path_points:J("d, tolerance",(c,e)=>{if(typeof c[0]!="string")throw new Error("path_points() needs SVG path data");let t=c[1]===void 0?.05:l1(c[1],"path_points");if(!(t>0))throw new Error("path_points(): tolerance must be more than 0");let n=o2(a3(c[0]),t),a=[...n.closed.map(r=>[...r,r[0]]),...n.open];return e.step(a.reduce((r,s)=>r+s.length,0)),a.map(r=>r.map(([s,i])=>[s,i]))}),spline_points:J("points, steps, closed",(c,e)=>{let t=r3(c[0],"spline_points",e),n=c[1]===void 0?8:Math.floor(l1(c[1],"spline_points"));if(!(n>=1))throw new Error("spline_points(): steps must be 1 or more");if(t.length*n>e.maxLength)throw new Error("spline_points(): the result would be too long");return e.step(t.length*n),n5(t,n,c[2]===!0)}),rotation:J("angles",c=>{let[e,t,n]=c5(c[0],"rotation");return N8(P4(q8(n),P4(U8(t),R8(e))))}),euler:J("matrix",c=>E4(D8(c[0],"euler"))),orient:J("x, z",c=>{let e=C4(c5(c[0],"orient"),"orient"),t=c5(c[1]??[0,0,1],"orient"),n=t[0]*e[0]+t[1]*e[1]+t[2]*e[2];t=C4([t[0]-n*e[0],t[1]-n*e[1],t[2]-n*e[2]],"orient");let a=[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]];return E4([[e[0],a[0],t[0]],[e[1],a[1],t[1]],[e[2],a[2],t[2]]])})};function r3(c,e,t){return l0(c,e,t).map((a,r)=>{if(!Array.isArray(a)||typeof a[0]!="number"||typeof a[1]!="number")throw new Error(`${e}(): points[${r}] must be an [x, y] point`);return[a[0],a[1]]})}function A4(c,e){if(c.length<2)throw new Error("a path needs at least two points");let t=c.filter(([l,o],h)=>h===0||l!==c[h-1][0]||o!==c[h-1][1]);if(t.length<2)return{point:[t[0][0],t[0][1]],heading:0};let n=0,a=0;for(;n<t.length-2;n++){let l=Math.hypot(t[n+1][0]-t[n][0],t[n+1][1]-t[n][1]);if(a+l>=e)break;a+=l}let[r,s]=[t[n],t[n+1]],i=(e-a)/Math.hypot(s[0]-r[0],s[1]-r[1]);return{point:[r[0]+(s[0]-r[0])*i,r[1]+(s[1]-r[1])*i],heading:Math.atan2(s[1]-r[1],s[0]-r[0])/V1}}function c5(c,e){if(!Array.isArray(c)||c.length<2||c.length>3||!c.every(t=>typeof t=="number"))throw new Error(`${e}() needs [x, y, z]`);return[c[0],c[1],c[2]??0]}function C4(c,e){let t=Math.hypot(...c);if(!(t>1e-12))throw new Error(`${e}(): a direction can't be [0, 0, 0], or x and z the same way`);return[c[0]/t,c[1]/t,c[2]/t]}function D8(c,e){if(!Array.isArray(c)||c.length<3||!c.slice(0,3).every(t=>Array.isArray(t)&&t.length>=3&&t.slice(0,3).every(n=>typeof n=="number")))throw new Error(`${e}() needs a 3x3 matrix`);return c.slice(0,3).map(t=>t.slice(0,3))}var R8=c=>{let[e,t]=[Math.cos(c*V1),Math.sin(c*V1)];return[[1,0,0],[0,e,-t],[0,t,e]]},U8=c=>{let[e,t]=[Math.cos(c*V1),Math.sin(c*V1)];return[[e,0,t],[0,1,0],[-t,0,e]]},q8=c=>{let[e,t]=[Math.cos(c*V1),Math.sin(c*V1)];return[[e,-t,0],[t,e,0],[0,0,1]]},P4=(c,e)=>c.map(t=>[0,1,2].map(n=>t[0]*e[0][n]+t[1]*e[1][n]+t[2]*e[2][n])),N8=c=>c.map(e=>e.map(P0));function E4(c){let e=-c[2][0];if(Math.abs(e)>1-1e-12){let t=e>0?90:-90,n=Math.atan2(-c[0][1],c[1][1])/V1;return[0,t,P0(n)]}return[P0(Math.atan2(c[2][1],c[2][2])/V1),P0(Math.asin(e)/V1),P0(Math.atan2(c[1][0],c[0][0])/V1)]}function n5(c,e,t=!1){if(c.length<3)return c.map(([s,i])=>[s,i]);let n=s=>{if(t)return c[(s%c.length+c.length)%c.length];if(s<0)return[2*c[0][0]-c[1][0],2*c[0][1]-c[1][1]];if(s>=c.length){let[i,l]=[c[c.length-1],c[c.length-2]];return[2*i[0]-l[0],2*i[1]-l[1]]}return c[s]},a=[],r=t?c.length:c.length-1;for(let s=0;s<r;s++){let[i,l,o,h]=[n(s-1),n(s),n(s+1),n(s+2)];for(let f=0;f<e;f++){let u=f/e,d=u*u,p=d*u;a.push([0,1].map(m=>.5*(2*l[m]+(-i[m]+o[m])*u+(2*i[m]-5*l[m]+4*o[m]-h[m])*d+(-i[m]+3*l[m]-3*o[m]+h[m])*p)))}}return a.push(t?a[0]:[c[c.length-1][0],c[c.length-1][1]]),a}var y1;(function(c){c[c.NoClip=0]="NoClip",c[c.Intersection=1]="Intersection",c[c.Union=2]="Union",c[c.Difference=3]="Difference",c[c.Xor=4]="Xor"})(y1||(y1={}));var q1;(function(c){c[c.Subject=0]="Subject",c[c.Clip=1]="Clip"})(q1||(q1={}));var r1;(function(c){c[c.EvenOdd=0]="EvenOdd",c[c.NonZero=1]="NonZero",c[c.Positive=2]="Positive",c[c.Negative=3]="Negative"})(r1||(r1={}));var i1;(function(c){c[c.IsOn=0]="IsOn",c[c.IsInside=1]="IsInside",c[c.IsOutside=2]="IsOutside"})(i1||(i1={}));var h2=Number.MAX_SAFE_INTEGER,S1=Math.floor(Math.sqrt(h2));function s3(c,e){return!Number.isSafeInteger(c)||!Number.isSafeInteger(e)?!1:c===0||e===0?!0:Math.abs(c)<=h2/Math.abs(e)}function V4(c,e){return Math.abs(c)+Math.abs(e)<=h2}function a5(c,e,t,n){if(s3(c,e)&&s3(t,n)){let a=c*e,r=t*n;if(V4(a,r))return a-r}return Number.isSafeInteger(c)&&Number.isSafeInteger(e)&&Number.isSafeInteger(t)&&Number.isSafeInteger(n)?Number(BigInt(c)*BigInt(e)-BigInt(t)*BigInt(n)):c*e-t*n}function r5(c,e,t,n){if(s3(c,e)&&s3(t,n)){let a=c*e,r=t*n;if(V4(a,r))return a+r}return Number.isSafeInteger(c)&&Number.isSafeInteger(e)&&Number.isSafeInteger(t)&&Number.isSafeInteger(n)?Number(BigInt(c)*BigInt(e)+BigInt(t)*BigInt(n)):c*e+t*n}var s5=BigInt(0),i3=BigInt(2),B8=BigInt(4),$8=BigInt(64),G8=BigInt("0xFFFFFFFFFFFFFFFF"),o5=BigInt("9223372036854775807"),C2=Number(o5/B8),O4=Number(o5),F4=1e-12,_8=.1,i5=Math.floor(S1/2),j8=Math.floor(Math.sqrt(Math.sqrt(h2/4)));function W8(c){if(!Number.isFinite(c))throw new RangeError("Scale must be a finite number");let e=Math.abs(c);return e===0?Number.POSITIVE_INFINITY:h2/e}function X8(c,e,t){if(!Number.isFinite(c)||Math.abs(c)>e)throw new RangeError(`Scaled coordinate exceeds Number.MAX_SAFE_INTEGER in ${t}`)}function Z8(c,e){if(!Number.isFinite(c)||Math.abs(c)>h2)throw new RangeError(`Coordinate exceeds Number.MAX_SAFE_INTEGER in ${e}`)}function Y8(c,e,t){let n=e.x-c.x,a=t.y-e.y,r=e.y-c.y,s=t.x-e.x;return Math.abs(n)<S1&&Math.abs(a)<S1&&Math.abs(r)<S1&&Math.abs(s)<S1?n*a-r*s:a5(n,a,r,s)}function n0(c,e,t){let n=e.x-c.x,a=t.y-e.y,r=e.y-c.y,s=t.x-e.x;if(Math.abs(n)<S1&&Math.abs(a)<S1&&Math.abs(r)<S1&&Math.abs(s)<S1){let o=n*a,h=r*s;return o>h?1:o<h?-1:0}if(!Number.isSafeInteger(n)||!Number.isSafeInteger(a)||!Number.isSafeInteger(r)||!Number.isSafeInteger(s)){let o=n*a,h=r*s;return o>h?1:o<h?-1:0}let i=BigInt(n)*BigInt(a),l=BigInt(r)*BigInt(s);return i===l?0:i>l?1:-1}function K8(c){if(c<-8||c>8)throw new Error("Error: Precision is out of range.")}function J8(c){return Math.abs(c)<=F4}function Q8(c){return c<0?-1:c>0?1:0}function e9(c,e){let t=BigInt(c),n=BigInt(e),a=t*n;return{lo64:a&G8,hi64:a>>$8}}function D4(c,e,t,n){let a=Math.abs(c),r=Math.abs(e),s=Math.abs(t),i=Math.abs(n);if(a<S1&&r<S1&&s<S1&&i<S1)return c*e===t*n;let l=(c<0?-1:c>0?1:0)*(e<0?-1:e>0?1:0),o=(t<0?-1:t>0?1:0)*(n<0?-1:n>0?1:0);if(l!==o)return!1;if(l===0)return!0;if(!Number.isSafeInteger(a)||!Number.isSafeInteger(r)||!Number.isSafeInteger(s)||!Number.isSafeInteger(i))return c*e===t*n;let h=BigInt(a),f=BigInt(r),u=BigInt(s),d=BigInt(i);return h*f===u*d}function t9(c,e,t){let n=e.x-c.x,a=t.y-e.y,r=e.y-c.y,s=t.x-e.x;return D4(n,a,r,s)}function c9(c,e,t){let n=e.x-c.x,a=t.x-e.x,r=e.y-c.y,s=t.y-e.y;return Math.abs(n)<S1&&Math.abs(a)<S1&&Math.abs(r)<S1&&Math.abs(s)<S1?n*a+r*s:r5(n,a,r,s)}function n9(c,e,t){let n=e.x-c.x,a=t.x-e.x,r=e.y-c.y,s=t.y-e.y;if(Math.abs(n)<S1&&Math.abs(a)<S1&&Math.abs(r)<S1&&Math.abs(s)<S1){let l=n*a+r*s;return l>0?1:l<0?-1:0}if(!Number.isSafeInteger(n)||!Number.isSafeInteger(a)||!Number.isSafeInteger(r)||!Number.isSafeInteger(s)){let l=n*a+r*s;return l>0?1:l<0?-1:0}let i=BigInt(n)*BigInt(a)+BigInt(r)*BigInt(s);return i===s5?0:i>s5?1:-1}function a9(c){let e=c.length;if(e<3)return 0;let t=!0;for(let r=0;r<e&&t;r++){let s=c[r];(Math.abs(s.x)>=i5||Math.abs(s.y)>=i5)&&(t=!1)}let n=c[e-1];if(t){let r=0;for(let s of c)r+=(n.y+s.y)*(n.x-s.x),n=s;return r*.5}let a=s5;for(let r of c){let s=n.y+r.y,i=n.x-r.x;if(Number.isSafeInteger(s)&&Number.isSafeInteger(i))a+=BigInt(s)*BigInt(i);else if(Number.isSafeInteger(n.y)&&Number.isSafeInteger(r.y)&&Number.isSafeInteger(n.x)&&Number.isSafeInteger(r.x)){let l=BigInt(n.y)+BigInt(r.y),o=BigInt(n.x)-BigInt(r.x);a+=l*o}else a+=BigInt(Math.round(s*i));n=r}return Number(a)*.5}function r9(c,e){return c.y*e.x-e.y*c.x}function s9(c,e){return c.x*e.x+c.y*e.y}function i9(c){let e=Math.round(c);return c===e-.5&&(e&1)!==0?e-1:e}function l9(c){return c>=C2||c<=-C2?O4:Math.round(c)}function o9(c,e,t,n){let a=e.y-c.y,r=e.x-c.x,s=n.y-t.y,i=n.x-t.x,l=a5(a,i,s,r);if(l===0)return null;let o=a5(c.x-t.x,s,c.y-t.y,i)/l;return o<=0?{x:c.x,y:c.y,z:c.z||0}:o>=1?{x:e.x,y:e.y,z:e.z||0}:{x:Math.trunc(c.x+o*r),y:Math.trunc(c.y+o*a),z:0}}function h9(c,e,t,n){let a=e.y-c.y,r=e.x-c.x,s=n.y-t.y,i=n.x-t.x,l=a*i-s*r;if(l===0)return{success:!1,ip:{x:0,y:0,z:0}};let o=((c.x-t.x)*s-(c.y-t.y)*i)/l,h;return o<=0?h={...c,z:0}:o>=1?h={...e,z:0}:h={x:c.x+o*r,y:c.y+o*a,z:0},{success:!0,ip:h}}function u9(c,e,t,n,a=!1){if(!a){let o=n0(c,t,n),h=n0(e,t,n),f=n0(t,c,e),u=n0(n,c,e);return o!==0&&h!==0&&o!==h&&f!==0&&u!==0&&f!==u}let r=n0(c,t,n),s=n0(e,t,n);if(r!==0&&r===s)return!1;let i=n0(t,c,e),l=n0(n,c,e);return i!==0&&i===l?!1:r!==0||s!==0||i!==0||l!==0}function R4(c){if(c.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 c)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 f9(c,e,t){if(e.x===t.x&&e.y===t.y)return{x:e.x,y:e.y,z:0};let n=t.x-e.x,a=t.y-e.y,r=r5(c.x-e.x,n,c.y-e.y,a)/r5(n,n,a,a),s=r<0?0:r>1?1:r;return{x:Math.round(e.x+s*n),y:Math.round(e.y+s*a),z:0}}function l5(c,e){let t=e.length,n=0;if(t<3)return i1.IsOutside;for(;n<t&&e[n].y===c.y;)n++;if(n===t)return i1.IsOutside;let a=e[n].y<c.y,r=a,s=0,i=n+1,l=t;for(;;){if(i===l){if(l===0||n===0)break;l=n,i=0}if(a)for(;i<l&&e[i].y<c.y;)i++;else for(;i<l&&e[i].y>c.y;)i++;if(i===l)continue;let h=e[i],f=i>0?e[i-1]:e[t-1];if(h.y===c.y){if(h.x===c.x||h.y===f.y&&c.x<f.x!=c.x<h.x)return i1.IsOn;if(i++,i===n)break;continue}if(!(c.x<h.x&&c.x<f.x))if(c.x>f.x&&c.x>h.x)s=1-s;else{let u=n0(f,h,c);if(u===0)return i1.IsOn;u<0===a&&(s=1-s)}a=!a,i++}if(a===r)return s===0?i1.IsOutside:i1.IsInside;i===t&&(i=0);let o=i===0?n0(e[t-1],e[0],c):n0(e[i-1],e[i],c);return o===0?i1.IsOn:(o<0===a&&(s=1-s),s===0?i1.IsOutside:i1.IsInside)}function d9(c,e){let t=i1.IsOn;for(let i of c)switch(l5(i,e)){case i1.IsOutside:if(t===i1.IsOutside)return!1;t=i1.IsOutside;break;case i1.IsInside:if(t===i1.IsInside)return!0;t=i1.IsInside;break;default:break}let n=R4(c),a,r;return Number.isSafeInteger(n.left)&&Number.isSafeInteger(n.right)&&Math.abs(n.left)+Math.abs(n.right)>Number.MAX_SAFE_INTEGER?(a=Number((BigInt(n.left)+BigInt(n.right))/i3),r=Number((BigInt(n.top)+BigInt(n.bottom))/i3)):(a=Math.round((n.left+n.right)/2),r=Math.round((n.top+n.bottom)/2)),l5({x:a,y:r},e)!==i1.IsOutside}var Q={MaxInt64:o5,MaxCoord:C2,max_coord:C2,min_coord:-C2,Invalid64:O4,floatingPointTolerance:F4,defaultMinimumEdgeLength:_8,maxCoordForSafeAreaProduct:i5,maxCoordForSafeCrossSq:j8,maxSafeCoordinateForScale:W8,checkSafeScaleValue:X8,ensureSafeInteger:Z8,crossProduct:Y8,crossProductSign:n0,checkPrecision:K8,isAlmostZero:J8,triSign:Q8,multiplyUInt64:e9,productsAreEqual:D4,isCollinear:t9,dotProduct:c9,dotProductSign:n9,area:a9,crossProductD:r9,dotProductD:s9,roundToEven:i9,checkCastInt64:l9,getLineIntersectPt:o9,getLineIntersectPtD:h9,segsIntersect:u9,getBounds:R4,getClosestPtOnSegment:f9,pointInPolygon:l5,path2ContainsPath1:d9},g0={create(c=0,e=0,t=0){return{x:Math.round(c),y:Math.round(e),z:t}},fromPointD(c){return Q.ensureSafeInteger(c.x,"Point64Utils.fromPointD"),Q.ensureSafeInteger(c.y,"Point64Utils.fromPointD"),{x:Math.round(c.x),y:Math.round(c.y),z:c.z||0}},scale(c,e){return{x:Math.round(c.x*e),y:Math.round(c.y*e),z:c.z||0}},equals(c,e){return c.x===e.x&&c.y===e.y},add(c,e){if(Number.isSafeInteger(c.x)&&Number.isSafeInteger(e.x)&&Number.isSafeInteger(c.y)&&Number.isSafeInteger(e.y)){let t=c.x+e.x,n=c.y+e.y;return Number.isSafeInteger(t)&&Number.isSafeInteger(n)?{x:t,y:n,z:0}:{x:Number(BigInt(c.x)+BigInt(e.x)),y:Number(BigInt(c.y)+BigInt(e.y)),z:0}}return{x:c.x+e.x,y:c.y+e.y,z:0}},subtract(c,e){return{x:c.x-e.x,y:c.y-e.y,z:0}},toString(c){return c.z!==void 0&&c.z!==0?`${c.x},${c.y},${c.z} `:`${c.x},${c.y} `}},l3={create(c=0,e=0,t=0){return{x:c,y:e,z:t}},fromPoint64(c){return{x:c.x,y:c.y,z:c.z||0}},scale(c,e){return{x:c.x*e,y:c.y*e,z:c.z||0}},equals(c,e){return Q.isAlmostZero(c.x-e.x)&&Q.isAlmostZero(c.y-e.y)},negate(c){c.x=-c.x,c.y=-c.y},toString(c,e=2){return c.z!==void 0&&c.z!==0?`${c.x.toFixed(e)},${c.y.toFixed(e)},${c.z}`:`${c.x.toFixed(e)},${c.y.toFixed(e)}`}},J0={create(c=0,e=0,t=0,n=0){return{left:c,top:e,right:t,bottom:n}},createInvalid(){return{left:Number.MAX_SAFE_INTEGER,top:Number.MAX_SAFE_INTEGER,right:Number.MIN_SAFE_INTEGER,bottom:Number.MIN_SAFE_INTEGER}},width(c){return c.right-c.left},height(c){return c.bottom-c.top},isEmpty(c){return c.bottom<=c.top||c.right<=c.left},isValid(c){return c.left<Number.MAX_SAFE_INTEGER},midPoint(c){if(Number.isSafeInteger(c.left)&&Number.isSafeInteger(c.right)&&Math.abs(c.left)+Math.abs(c.right)>Number.MAX_SAFE_INTEGER){let e=Number((BigInt(c.left)+BigInt(c.right))/i3),t=Number((BigInt(c.top)+BigInt(c.bottom))/i3);return{x:e,y:t}}return{x:Math.round((c.left+c.right)/2),y:Math.round((c.top+c.bottom)/2)}},contains(c,e){return e.x>c.left&&e.x<c.right&&e.y>c.top&&e.y<c.bottom},containsRect(c,e){return e.left>=c.left&&e.right<=c.right&&e.top>=c.top&&e.bottom<=c.bottom},intersects(c,e){return Math.max(c.left,e.left)<=Math.min(c.right,e.right)&&Math.max(c.top,e.top)<=Math.min(c.bottom,e.bottom)},asPath(c){return[{x:c.left,y:c.top,z:0},{x:c.right,y:c.top,z:0},{x:c.right,y:c.bottom,z:0},{x:c.left,y:c.bottom,z:0}]}},h5={create(c=0,e=0,t=0,n=0){return{left:c,top:e,right:t,bottom:n}},createInvalid(){return{left:Number.MAX_VALUE,top:Number.MAX_VALUE,right:-Number.MAX_VALUE,bottom:-Number.MAX_VALUE}},width(c){return c.right-c.left},height(c){return c.bottom-c.top},isEmpty(c){return c.bottom<=c.top||c.right<=c.left},midPoint(c){return{x:(c.left+c.right)/2,y:(c.top+c.bottom)/2}},contains(c,e){return e.x>c.left&&e.x<c.right&&e.y>c.top&&e.y<c.bottom},containsRect(c,e){return e.left>=c.left&&e.right<=c.right&&e.top>=c.top&&e.bottom<=c.bottom},intersects(c,e){return Math.max(c.left,e.left)<Math.min(c.right,e.right)&&Math.max(c.top,e.top)<Math.min(c.bottom,e.bottom)},asPath(c){return[{x:c.left,y:c.top,z:0},{x:c.right,y:c.top,z:0},{x:c.right,y:c.bottom,z:0},{x:c.left,y:c.bottom,z:0}]}};var U4=Object.freeze(J0.createInvalid()),q4=Object.freeze(h5.createInvalid());var P2=BigInt(0),p9=BigInt(2),N4=BigInt(4),m1;(function(c){c[c.None=0]="None",c[c.OpenStart=1]="OpenStart",c[c.OpenEnd=2]="OpenEnd",c[c.LocalMax=4]="LocalMax",c[c.LocalMin=8]="LocalMin"})(m1||(m1={}));var u5=class{constructor(){T(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 n=e-1>>1;if(this.data[n]>=t)break;this.data[e]=this.data[n],e=n}this.data[e]=t}siftDown(e){let t=this.data.length,n=this.data[e];for(;;){let a=(e<<1)+1;if(a>=t)break;let r=a+1,s=a;if(r<t&&this.data[r]>this.data[a]&&(s=r),this.data[s]<=n)break;this.data[e]=this.data[s],e=s}this.data[e]=n}},E2=class{constructor(e,t,n){T(this,"pt");T(this,"next",null);T(this,"prev",null);T(this,"flags");this.pt=e,this.flags=t,this.prev=n}},T2=class{constructor(e,t,n=!1){T(this,"vertex");T(this,"polytype");T(this,"isOpen");this.vertex=e,this.polytype=t,this.isOpen=n}equals(e){return e!==null&&this.vertex===e.vertex}};function B4(c,e,t){return{pt:c,edge1:e,edge2:t}}var E0=class{constructor(e,t){T(this,"pt");T(this,"next");T(this,"prev");T(this,"outrec");T(this,"horz");this.pt=e,this.outrec=t,this.next=this,this.prev=this,this.horz=null}},$1;(function(c){c[c.None=0]="None",c[c.Left=1]="Left",c[c.Right=2]="Right"})($1||($1={}));var f5;(function(c){c[c.Bottom=0]="Bottom",c[c.Middle=1]="Middle",c[c.Top=2]="Top"})(f5||(f5={}));var o3=class{constructor(){T(this,"idx",0);T(this,"owner",null);T(this,"frontEdge",null);T(this,"backEdge",null);T(this,"pts",null);T(this,"polypath",null);T(this,"bounds",{left:0,top:0,right:0,bottom:0});T(this,"path",[]);T(this,"isOpen",!1);T(this,"splits",null);T(this,"recursiveSplit",null)}},h3=class{constructor(e){T(this,"leftOp");T(this,"rightOp");T(this,"leftToRight");this.leftOp=e,this.rightOp=null,this.leftToRight=!0}},I2=class{constructor(e,t){T(this,"op1");T(this,"op2");this.op1=e,this.op2=t}};function m9(c,e){return c.rightOp===null?e.rightOp===null?0:1:e.rightOp===null?-1:c.leftOp.pt.x-e.leftOp.pt.x}function v9(c,e){return c.pt.y!==e.pt.y?c.pt.y>e.pt.y?-1:1:c.pt.x!==e.pt.x?c.pt.x<e.pt.x?-1:1:c.edge1.curX!==e.edge1.curX?c.edge1.curX<e.edge1.curX?-1:1:c.edge2.curX<e.edge2.curX?-1:c.edge2.curX>e.edge2.curX?1:0}var H2=class{constructor(){T(this,"bot",{x:0,y:0});T(this,"top",{x:0,y:0});T(this,"curX",0);T(this,"dx",0);T(this,"windDx",0);T(this,"windCount",0);T(this,"windCount2",0);T(this,"outrec",null);T(this,"prevInAEL",null);T(this,"nextInAEL",null);T(this,"prevInSEL",null);T(this,"nextInSEL",null);T(this,"jump",null);T(this,"vertexTop",null);T(this,"localMin",null);T(this,"isLeftBound",!1);T(this,"joinWith",$1.None)}},u2={addLocMin(c,e,t,n){if((c.flags&m1.LocalMin)!==m1.None)return;c.flags|=m1.LocalMin;let a=new T2(c,e,t);n.push(a)},addPathsToVertexList(c,e,t,n,a){for(let r=0,s=c.length;r<s;r++){let i=c[r],l=null,o=null,h=null;for(let p=0,m=i.length;p<m;p++){let v=i[p];if(l===null)l=new E2(v,m1.None,null),a.push(l),o=l,h=v;else if(!(h.x===v.x&&h.y===v.y)){let g=new E2(v,m1.None,o);o.next=g,o=g,h=v}}if(o?.prev==null||(!t&&o.pt.x===l.pt.x&&o.pt.y===l.pt.y&&(o=o.prev),o.next=l,l.prev=o,!t&&o.next===o))continue;let f;if(t){let p=l.next;for(;p!==l&&p.pt.y===l.pt.y;)p=p.next;f=p.pt.y<=l.pt.y,f?(l.flags=m1.OpenStart,u2.addLocMin(l,e,!0,n)):l.flags=m1.OpenStart|m1.LocalMax}else{for(o=l.prev;o!==l&&o.pt.y===l.pt.y;)o=o.prev;if(o===l)continue;f=o.pt.y>l.pt.y}let u=f;o=l;let d=l.next;for(;d!==l;)d.pt.y>o.pt.y&&f?(o.flags|=m1.LocalMax,f=!1):d.pt.y<o.pt.y&&!f&&(f=!0,u2.addLocMin(o,e,t,n)),o=d,d=d.next;t?(o.flags|=m1.OpenEnd,f?o.flags|=m1.LocalMax:u2.addLocMin(o,e,t,n)):f!==u&&(u?u2.addLocMin(o,e,!1,n):o.flags|=m1.LocalMax)}}};var u3=class{constructor(e=null){T(this,"parent");T(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 n="",a=" ".repeat(t),r=this.children.length===1?"":"s";(t&1)===0?n+=`${a}+- hole (${e}) contains ${this.children.length} nested polygon${r}.
2223
- `:n+=`${a}+- polygon (${e}) contains ${this.children.length} hole${r}.
2224
- `;for(let s=0;s<this.count;s++)this.children[s].count>0&&(n+=this.children[s].toStringInternal(s,t+1));return n}toString(){if(this.level>0)return"";let e=this.children.length===1?"":"s",t=`Polytree with ${this.children.length} polygon${e}.
2225
- `;for(let n=0;n<this.count;n++)this.children[n].count>0&&(t+=this.children[n].toStringInternal(n,1));return t+`
2226
- `}},f3=class c extends u3{constructor(t=null){super(t);T(this,"polygon",null)}get poly(){return this.polygon}addChild(t){let n=new c(this);return n.polygon=t,this.children.push(n),n}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:d5.area(this.polygon);for(let n of this.children)t+=n.area();return t}};var V2=class extends f3{};var x=class x{constructor(){T(this,"cliptype",y1.NoClip);T(this,"fillrule",r1.EvenOdd);T(this,"actives",null);T(this,"sel",null);T(this,"minimaList",[]);T(this,"intersectList",[]);T(this,"vertexList",[]);T(this,"outrecList",[]);T(this,"scanlineHeap",new u5);T(this,"scanlineSet",new Set);T(this,"scanlineArr",[]);T(this,"useScanlineArray",!1);T(this,"horzSegList",[]);T(this,"horzJoinList",[]);T(this,"currentLocMin",0);T(this,"currentBotY",0);T(this,"curXValidAtTop",!1);T(this,"isSortedMinimaList",!1);T(this,"hasOpenPaths",!1);T(this,"usingPolytree",!1);T(this,"succeeded",!1);T(this,"zCallbackInternal");T(this,"preserveCollinear",!0);T(this,"reverseSolution",!1)}getZCallback(){}xyEqual(e,t){return e.x===t.x&&e.y===t.y}setZ(e,t,n){let a=this.zCallbackInternal;a&&(x.getPolyType(e)===q1.Subject?(this.xyEqual(n,e.bot)?n.z=e.bot.z??0:this.xyEqual(n,e.top)?n.z=e.top.z??0:this.xyEqual(n,t.bot)?n.z=t.bot.z??0:this.xyEqual(n,t.top)?n.z=t.top.z??0:n.z=0,a(e.bot,e.top,t.bot,t.top,n)):(this.xyEqual(n,t.bot)?n.z=t.bot.z??0:this.xyEqual(n,t.top)?n.z=t.top.z??0:this.xyEqual(n,e.bot)?n.z=e.bot.z??0:this.xyEqual(n,e.top)?n.z=e.top.z??0:n.z=0,a(t.bot,t.top,e.bot,e.top,n)))}static isOdd(e){return(e&1)!==0}static isHotEdge(e){return e.outrec!=null}static isOpen(e){return x.openPathsEnabled&&e.localMin.isOpen}static isOpenEnd(e){return x.openPathsEnabled&&e.localMin.isOpen&&x.isOpenEndVertex(e.vertexTop)}static isOpenEndVertex(e){return(e.flags&(m1.OpenStart|m1.OpenEnd))!==m1.None}static getPrevHotEdge(e){let t=e.prevInAEL;if(!x.openPathsEnabled){for(;t!==null&&!x.isHotEdge(t);)t=t.prevInAEL;return t}for(;t!==null&&(t.localMin.isOpen||!x.isHotEdge(t));)t=t.prevInAEL;return t}static isFront(e){return e===e.outrec.frontEdge}static getDx(e,t){let n=t.y-e.y;return n!==0?(t.x-e.x)/n: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:Q.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=x.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&m1.LocalMax)!==m1.None}static isMaximaEdge(e){return(e.vertexTop.flags&m1.LocalMax)!==m1.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,n,a){let r=e.x<t.x?e.x:t.x;if((n.x>a.x?n.x:a.x)<r)return!1;let i=e.x>t.x?e.x:t.x,l=n.x<a.x?n.x:a.x;if(i<l)return!1;let o=e.y<t.y?e.y:t.y;if((n.y>a.y?n.y:a.y)<o)return!1;let f=e.y>t.y?e.y:t.y,u=n.y<a.y?n.y:a.y;return f>=u}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,n=e.length;t<n;t++){let a=e[t];this.scanlineSet.add(a),this.scanlineHeap.push(a)}e.length=0,this.useScanlineArray=!1}insertScanline(e){if(this.useScanlineArray){let t=this.scanlineArr;for(let n=0,a=t.length;n<a;n++)if(t[n]===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,n=t.length;if(n===0)return null;let a=0,r=t[0];for(let s=1;s<n;s++){let i=t[s];i>r&&(r=i,a=s)}return t[a]=t[n-1],t.pop(),r}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,n=!1){let a=[e];this.addPaths(a,t,n)}addPaths(e,t,n=!1){n&&(this.hasOpenPaths=!0),this.isSortedMinimaList=!1,u2.addPathsToVertexList(e,t,n,this.minimaList,this.vertexList)}addReuseableData(e){if(e.minimaList.length!==0){this.isSortedMinimaList=!1;for(let t of e.minimaList)this.minimaList.push(new T2(t.vertex,t.polytype,t.isOpen)),t.isOpen&&(this.hasOpenPaths=!0)}}deleteFromAEL(e){let t=e.prevInAEL,n=e.nextInAEL;t===null&&n===null&&e!==this.actives||(t!==null?t.nextInAEL=n:this.actives=n,n!==null&&(n.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 n=t;do n.pt.x<e.left&&(e.left=n.pt.x),n.pt.x>e.right&&(e.right=n.pt.x),n.pt.y<e.top&&(e.top=n.pt.y),n.pt.y>e.bottom&&(e.bottom=n.pt.y),n=n.next;while(n!==t)}return J0.isEmpty(e)?{left:0,top:0,right:0,bottom:0}:e}executeInternal(e,t){if(e===y1.NoClip)return;x.openPathsEnabled=this.hasOpenPaths,this.zCallbackInternal=this.getZCallback(),this.fillrule=t,this.cliptype=e,this.reset();let n=this.popScanline();if(n!==null){for(;this.succeeded;){this.insertLocalMinimaIntoAEL(n);let a;for(;(a=this.popHorz())!==null;)this.doHorizontal(a);this.horzSegList.length>0&&(this.convertHorzSegsToJoins(),this.horzSegList.length=0),this.currentBotY=n;let r=this.popScanline();if(r===null)break;for(n=r,this.doIntersections(n),this.doTopOfScanbeam(n);(a=this.popHorz())!==null;)this.doHorizontal(a)}this.succeeded&&this.processHorzJoins()}}insertLocalMinimaIntoAEL(e){for(;this.hasLocMinAtY(e);){let t=this.popLocalMinima(),n;(t.vertex.flags&m1.OpenStart)!==m1.None?n=null:(n=new H2,n.bot=t.vertex.pt,n.curX=t.vertex.pt.x,n.windDx=-1,n.vertexTop=t.vertex.prev,n.top=t.vertex.prev.pt,n.outrec=null,n.localMin=t,x.setDx(n));let a;if((t.vertex.flags&m1.OpenEnd)!==m1.None?a=null:(a=new H2,a.bot=t.vertex.pt,a.curX=t.vertex.pt.x,a.windDx=1,a.vertexTop=t.vertex.next,a.top=t.vertex.next.pt,a.outrec=null,a.localMin=t,x.setDx(a)),n!==null&&a!==null){if(x.isHorizontal(n)){if(x.isHeadingRightHorz(n)){let s=n;n=a,a=s}}else if(x.isHorizontal(a)){if(x.isHeadingLeftHorz(a)){let s=n;n=a,a=s}}else if(n.dx<a.dx){let s=n;n=a,a=s}}else n===null&&(n=a,a=null);let r;if(n.isLeftBound=!0,this.insertLeftEdge(n),x.openPathsEnabled?x.isOpen(n)?(this.setWindCountForOpenPathEdge(n),r=this.isContributingOpen(n)):(this.setWindCountForClosedPathEdge(n),r=this.isContributingClosed(n)):(this.setWindCountForClosedPathEdge(n),r=this.isContributingClosed(n)),a!==null){for(a.windCount=n.windCount,a.windCount2=n.windCount2,this.insertRightEdge(n,a),r&&(this.addLocalMinPoly(n,a,n.bot,!0),x.isHorizontal(n)||this.checkJoinLeft(n,n.bot));a.nextInAEL!==null&&this.isValidAelOrder(a.nextInAEL,a);)this.intersectEdges(a,a.nextInAEL,a.bot),this.swapPositionsInAEL(a,a.nextInAEL);x.isHorizontal(a)?this.pushHorz(a):(this.checkJoinRight(a,a.bot),this.insertScanline(a.top.y))}else r&&x.openPathsEnabled&&this.startOpenPath(n,n.bot);x.isHorizontal(n)?this.pushHorz(n):this.insertScanline(n.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(!x.openPathsEnabled){this.doHorizontalClosed(e);return}let t=x.isOpen(e),n=e.bot.y,a=t?this.getCurrYMaximaVertexOpen(e):this.getCurrYMaximaVertex(e),{isLeftToRight:r,leftX:s,rightX:i}=this.resetHorzDirection(e,a),l=s,o=i;if(x.isHotEdge(e)){let h=this.addOutPt(e,{x:e.curX,y:n});this.addToHorzSegList(h)}for(;;){let h=r?e.nextInAEL:e.prevInAEL;for(;h!==null;){if(h.vertexTop===a){if(x.isHotEdge(e)&&this.isJoined(h)&&this.split(h,h.top),x.isHotEdge(e)){for(;e.vertexTop!==a;)this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);r?this.addLocalMaxPoly(e,h,e.top):this.addLocalMaxPoly(h,e,e.top)}this.deleteFromAEL(h),this.deleteFromAEL(e);return}if(a!==e.vertexTop||x.isOpenEnd(e)){if(r&&h.curX>o||!r&&h.curX<l)break;if(h.curX===e.top.x&&!x.isHorizontal(h)){let d=x.nextVertex(e).pt;if(x.isOpen(h)&&!x.isSamePolyType(h,e)&&!x.isHotEdge(h)){if(r&&x.topX(h,d.y)>d.x||!r&&x.topX(h,d.y)<d.x)break}else if(r&&x.topX(h,d.y)>=d.x||!r&&x.topX(h,d.y)<=d.x)break}}let u={x:h.curX,y:n};r?(this.intersectEdges(e,h,u),this.swapPositionsInAEL(e,h),this.checkJoinLeft(h,u),e.curX=h.curX,h=e.nextInAEL):(this.intersectEdges(h,e,u),this.swapPositionsInAEL(h,e),this.checkJoinRight(h,u),e.curX=h.curX,h=e.prevInAEL),x.isHotEdge(e)&&this.addToHorzSegList(this.getLastOp(e))}if(t&&x.isOpenEnd(e)){x.isHotEdge(e)&&(this.addOutPt(e,e.top),x.isFront(e)?e.outrec.frontEdge=null:e.outrec.backEdge=null,e.outrec=null),this.deleteFromAEL(e);return}if(x.nextVertex(e).pt.y!==e.top.y)break;x.isHotEdge(e)&&this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);let f=this.resetHorzDirection(e,a);l=f.leftX,o=f.rightX}if(x.isHotEdge(e)){let h=this.addOutPt(e,e.top);this.addToHorzSegList(h)}this.updateEdgeIntoAEL(e)}doHorizontalClosed(e){let t=e.bot.y,n=this.getCurrYMaximaVertex(e),{isLeftToRight:a,leftX:r,rightX:s}=this.resetHorzDirection(e,n),i=r,l=s;if(x.isHotEdge(e)){let o=this.addOutPt(e,{x:e.curX,y:t});this.addToHorzSegList(o)}for(;;){let o=a?e.nextInAEL:e.prevInAEL;for(;o!==null;){if(o.vertexTop===n){if(x.isHotEdge(e)&&this.isJoined(o)&&this.split(o,o.top),x.isHotEdge(e)){for(;e.vertexTop!==n;)this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);a?this.addLocalMaxPoly(e,o,e.top):this.addLocalMaxPoly(o,e,e.top)}this.deleteFromAEL(o),this.deleteFromAEL(e);return}if(n!==e.vertexTop){if(a&&o.curX>l||!a&&o.curX<i)break;if(o.curX===e.top.x&&!x.isHorizontal(o)){let u=x.nextVertex(e).pt,d=x.topX(o,u.y);if(a&&d>=u.x||!a&&d<=u.x)break}}let f={x:o.curX,y:t};a?(this.intersectEdges(e,o,f),this.swapPositionsInAEL(e,o),this.checkJoinLeft(o,f),e.curX=o.curX,o=e.nextInAEL):(this.intersectEdges(o,e,f),this.swapPositionsInAEL(o,e),this.checkJoinRight(o,f),e.curX=o.curX,o=e.prevInAEL),x.isHotEdge(e)&&this.addToHorzSegList(this.getLastOp(e))}if(x.nextVertex(e).pt.y!==e.top.y)break;x.isHotEdge(e)&&this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);let h=this.resetHorzDirection(e,n);i=h.leftX,l=h.rightX}if(x.isHotEdge(e)){let o=this.addOutPt(e,e.top);this.addToHorzSegList(o)}this.updateEdgeIntoAEL(e)}convertHorzSegsToJoins(){let e=this.horzSegList,t=0;for(let n=0,a=e.length;n<a;n++){let r=e[n];this.updateHorzSegment(r)&&(e[t++]=r)}if(!(t<2)){e.length=t,this.horzSegList.sort(m9);for(let n=0;n<t-1;n++){let a=this.horzSegList[n];for(let r=n+1;r<t;r++){let s=this.horzSegList[r];if(s.leftOp.pt.x>=a.rightOp.pt.x||s.leftToRight===a.leftToRight||s.rightOp.pt.x<=a.leftOp.pt.x)continue;let i=a.leftOp.pt.y;if(a.leftToRight){for(;a.leftOp.next.pt.y===i&&a.leftOp.next.pt.x<=s.leftOp.pt.x;)a.leftOp=a.leftOp.next;for(;s.leftOp.prev.pt.y===i&&s.leftOp.prev.pt.x<=a.leftOp.pt.x;)s.leftOp=s.leftOp.prev;let l=new I2(this.duplicateOp(a.leftOp,!0),this.duplicateOp(s.leftOp,!1));this.horzJoinList.push(l)}else{for(;a.leftOp.prev.pt.y===i&&a.leftOp.prev.pt.x<=s.leftOp.pt.x;)a.leftOp=a.leftOp.prev;for(;s.leftOp.next.pt.y===i&&s.leftOp.next.pt.x<=a.leftOp.pt.x;)s.leftOp=s.leftOp.next;let l=new I2(this.duplicateOp(s.leftOp,!0),this.duplicateOp(a.leftOp,!1));this.horzJoinList.push(l)}}}}}updateHorzSegment(e){let t=e.leftOp,n=this.getRealOutRec(t.outrec),a=n.frontEdge!==null,r=t.pt.y,s=t,i=t;if(a){let o=n.pts,h=o.next;for(;s!==h&&s.prev.pt.y===r;)s=s.prev;for(;i!==o&&i.next.pt.y===r;)i=i.next}else{for(;s.prev!==i&&s.prev.pt.y===r;)s=s.prev;for(;i.next!==s&&i.next.pt.y===r;)i=i.next}let l=this.setHorzSegHeadingForward(e,s,i)&&e.leftOp.horz===null;return l?e.leftOp.horz=e:e.rightOp=null,l}setHorzSegHeadingForward(e,t,n){return t.pt.x===n.pt.x?!1:(t.pt.x<n.pt.x?(e.leftOp=t,e.rightOp=n,e.leftToRight=!0):(e.leftOp=n,e.rightOp=t,e.leftToRight=!1),!0)}duplicateOp(e,t){let n=new E0(e.pt,e.outrec);return t?(n.next=e.next,n.next.prev=n,n.prev=e,e.next=n):(n.prev=e.prev,n.prev.next=n,n.next=e,e.prev=n),n}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 n=this.actives;for(;n!==null;){if(n.top.y===e)if(n.curX=n.top.x,x.isMaximaEdge(n)){n=this.doMaxima(n);continue}else x.isHotEdge(n)&&this.addOutPt(n,n.top),this.updateEdgeIntoAEL(n),x.isHorizontal(n)&&this.pushHorz(n);else t||(n.curX=x.topX(n,e));n=n.nextInAEL}}processHorzJoins(){for(let e of this.horzJoinList){let t=this.getRealOutRec(e.op1.outrec),n=this.getRealOutRec(e.op2.outrec),a=e.op1.next,r=e.op2.prev;if(e.op1.next=e.op2,e.op2.prev=e.op1,a.prev=r,r.next=a,t===n){let s=this.newOutRec();s.pts=a,this.fixOutRecPts(s),t.pts.outrec===s&&(t.pts=e.op1,t.pts.outrec=t),this.usingPolytree?(this.path1InsidePath2(t.pts,s.pts)?([s.pts,t.pts]=[t.pts,s.pts],this.fixOutRecPts(t),this.fixOutRecPts(s),s.owner=t):this.path1InsidePath2(s.pts,t.pts)?s.owner=t:s.owner=t.owner,t.splits===null&&(t.splits=[]),t.splits.push(s.idx)):s.owner=t}else n.pts=null,this.usingPolytree?(this.setOwner(n,t),this.moveSplits(n,t)):n.owner=t}}fixOutRecPts(e){let t=e.pts;do t.outrec=e,t=t.next;while(t!==e.pts)}path1InsidePath2(e,t){let n=i1.IsOn,a=e;do{switch(this.pointInOpPolygon(a.pt,t)){case i1.IsOutside:if(n===i1.IsOutside)return!1;n=i1.IsOutside;break;case i1.IsInside:if(n===i1.IsInside)return!0;n=i1.IsInside;break;default:break}a=a.next}while(a!==e);return Q.path2ContainsPath1(this.getCleanPath(e),this.getCleanPath(t))}pointInOpPolygon(e,t){if(t===t.next||t.prev===t.next)return i1.IsOutside;let n=t;do{if(t.pt.y!==e.y)break;t=t.next}while(t!==n);if(t.pt.y===e.y)return i1.IsOutside;let a=t.pt.y<e.y,r=a,s=0;for(n=t.next;n!==t;){if(a)for(;n!==t&&n.pt.y<e.y;)n=n.next;else for(;n!==t&&n.pt.y>e.y;)n=n.next;if(n===t)break;if(n.pt.y===e.y){if(n.pt.x===e.x||n.pt.y===n.prev.pt.y&&e.x<n.prev.pt.x!=e.x<n.pt.x)return i1.IsOn;if(n=n.next,n===t)break;continue}if(n.pt.x<=e.x||n.prev.pt.x<=e.x)if(n.prev.pt.x<e.x&&n.pt.x<e.x)s=1-s;else{let i=Q.crossProductSign(n.prev.pt,n.pt,e);if(i===0)return i1.IsOn;i<0===a&&(s=1-s)}a=!a,n=n.next}if(a===r)return s===0?i1.IsOutside:i1.IsInside;{let i=Q.crossProductSign(n.prev.pt,n.pt,e);if(i===0)return i1.IsOn;i<0===a&&(s=1-s)}return s===0?i1.IsOutside:i1.IsInside}getCleanPath(e){let t=[],n=e;for(;n.next!==e&&(n.pt.x===n.next.pt.x&&n.pt.x===n.prev.pt.x||n.pt.y===n.next.pt.y&&n.pt.y===n.prev.pt.y);)n=n.next;t.push(n.pt);let a=n;for(n=n.next;n!==e;)(n.pt.x!==n.next.pt.x||n.pt.x!==a.pt.x)&&(n.pt.y!==n.next.pt.y||n.pt.y!==a.pt.y)&&(t.push(n.pt),a=n),n=n.next;return t}moveSplits(e,t){if(e.splits!==null){t.splits===null&&(t.splits=[]);for(let n of e.splits)n!==t.idx&&t.splits.push(n);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 n=null;for(;t!==null&&t.jump!==null;){let a=t,r=t.jump,s=r,i=r?.jump||null;for(t.jump=i;t!==s&&r!==i;)if(r.curX<t.curX){let l=r.prevInSEL;for(;this.addNewIntersectNode(l,r,e),l!==t;)l=l.prevInSEL;if(l=r,r=this.extractFromSEL(l),s=r,t!==null&&this.insert1Before2InSEL(l,t),t!==a)continue;a=l,a.jump=i,n===null?this.sel=a:n.jump=a}else t=t.nextInSEL;n=a,t=i}t=this.sel}return this.intersectList.length>0}processIntersectList(){this.intersectList.sort(v9);for(let e=0;e<this.intersectList.length;++e){if(!this.edgesAdjacentInAEL(this.intersectList[e])){let n=e+1;for(;!this.edgesAdjacentInAEL(this.intersectList[n]);)n++;[this.intersectList[n],this.intersectList[e]]=[this.intersectList[e],this.intersectList[n]]}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 n=Number.NEGATIVE_INFINITY,a=!1;for(;t!==null;){t.prevInSEL=t.prevInAEL,t.nextInSEL=t.nextInAEL,t.jump=t.nextInSEL;let r=x.topX(t,e);t.curX=r,r<n&&(a=!0),n=r,t=t.nextInAEL}return a}doMaxima(e){let t=e.prevInAEL,n=e.nextInAEL;if(x.isOpenEnd(e))return x.isHotEdge(e)&&this.addOutPt(e,e.top),x.isHorizontal(e)||(x.isHotEdge(e)&&(x.isFront(e)?e.outrec.frontEdge=null:e.outrec.backEdge=null,e.outrec=null),this.deleteFromAEL(e)),n;let a=x.getMaximaPair(e);if(a===null)return n;for(this.isJoined(e)&&this.split(e,e.top),this.isJoined(a)&&this.split(a,a.top);n!==a;)this.intersectEdges(e,n,e.top),this.swapPositionsInAEL(e,n),n=e.nextInAEL;return x.isOpen(e)?(x.isHotEdge(e)&&this.addLocalMaxPoly(e,a,e.top),this.deleteFromAEL(a),this.deleteFromAEL(e),t!==null?t.nextInAEL:this.actives):(x.isHotEdge(e)&&this.addLocalMaxPoly(e,a,e.top),this.deleteFromAEL(e),this.deleteFromAEL(a),t!==null?t.nextInAEL:this.actives)}updateEdgeIntoAEL(e){if(e.bot=e.top,e.vertexTop=x.nextVertex(e),e.top=e.vertexTop.pt,e.curX=e.bot.x,x.setDx(e),this.isJoined(e)&&this.split(e,e.bot),x.isHorizontal(e)){x.openPathsEnabled?x.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 n=!1,a=x.nextVertex(e).pt;for(;a.y===e.top.y&&!(t&&a.x<e.top.x!=e.bot.x<e.top.x||(e.vertexTop=x.nextVertex(e),e.top=a,n=!0,x.isMaximaVertex(e.vertexTop)));)a=x.nextVertex(e).pt;n&&x.setDx(e)}addToHorzSegList(e){e.outrec.isOpen||this.horzSegList.push(new h3(e))}addNewIntersectNode(e,t,n){let a=Q.getLineIntersectPt(e.bot,e.top,t.bot,t.top);if(a===null&&(a={x:e.curX,y:n}),a.y>this.currentBotY||a.y<n){let s=Math.abs(e.dx),i=Math.abs(t.dx);s>100&&i>100?s>i?a=Q.getClosestPtOnSegment(a,e.bot,e.top):a=Q.getClosestPtOnSegment(a,t.bot,t.top):s>100?a=Q.getClosestPtOnSegment(a,e.bot,e.top):i>100?a=Q.getClosestPtOnSegment(a,t.bot,t.top):(a.y<n?a.y=n:a.y=this.currentBotY,s<i?a.x=x.topX(e,a.y):a.x=x.topX(t,a.y))}let r=B4(a,e,t);this.intersectList.push(r)}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&(m1.OpenEnd|m1.LocalMax))===m1.None;)t=t.next;else for(;t.prev.pt.y===t.pt.y&&(t.flags&(m1.OpenEnd|m1.LocalMax))===m1.None;)t=t.prev;return x.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 x.isMaximaVertex(t)||(t=null),t}resetHorzDirection(e,t){if(e.bot.x===e.top.x){let n=e.curX,a=e.curX,r=e.nextInAEL;for(;r!==null&&r.vertexTop!==t;)r=r.nextInAEL;return{isLeftToRight:r!==null,leftX:n,rightX:a}}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===$1.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===r1.EvenOdd){let n=0,a=0;for(;t!==e;)x.getPolyType(t)===q1.Clip?a++:x.isOpen(t)||n++,t=t.nextInAEL;e.windCount=x.isOdd(n)?1:0,e.windCount2=x.isOdd(a)?1:0}else for(;t!==e;)x.getPolyType(t)===q1.Clip?e.windCount2+=t.windDx:x.isOpen(t)||(e.windCount+=t.windDx),t=t.nextInAEL}setWindCountForClosedPathEdge(e){let t=e.prevInAEL,n=x.getPolyType(e);if(!x.openPathsEnabled){for(;t!==null&&x.getPolyType(t)!==n;)t=t.prevInAEL;if(t===null?(e.windCount=e.windDx,t=this.actives):this.fillrule===r1.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===r1.EvenOdd)for(;t!==e;)x.getPolyType(t)!==n&&(e.windCount2=e.windCount2===0?1:0),t=t.nextInAEL;else for(;t!==e;)x.getPolyType(t)!==n&&(e.windCount2+=t.windDx),t=t.nextInAEL;return}for(;t!==null&&(x.getPolyType(t)!==n||x.isOpen(t));)t=t.prevInAEL;if(t===null?(e.windCount=e.windDx,t=this.actives):this.fillrule===r1.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=x.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===r1.EvenOdd)for(;t!==e;)x.getPolyType(t)!==n&&!x.isOpen(t)&&(e.windCount2=e.windCount2===0?1:0),t=t.nextInAEL;else for(;t!==e;)x.getPolyType(t)!==n&&!x.isOpen(t)&&(e.windCount2+=t.windDx),t=t.nextInAEL}isContributingOpen(e){let t,n;switch(this.fillrule){case r1.Positive:n=e.windCount>0,t=e.windCount2>0;break;case r1.Negative:n=e.windCount<0,t=e.windCount2<0;break;default:n=e.windCount!==0,t=e.windCount2!==0;break}switch(this.cliptype){case y1.Intersection:return t;case y1.Union:return!n&&!t;default:return!t}}isContributingClosed(e){switch(this.fillrule){case r1.Positive:if(e.windCount!==1)return!1;break;case r1.Negative:if(e.windCount!==-1)return!1;break;case r1.NonZero:if(Math.abs(e.windCount)!==1)return!1;break}switch(this.cliptype){case y1.Intersection:return this.fillrule===r1.Positive?e.windCount2>0:this.fillrule===r1.Negative?e.windCount2<0:e.windCount2!==0;case y1.Union:return this.fillrule===r1.Positive?e.windCount2<=0:this.fillrule===r1.Negative?e.windCount2>=0:e.windCount2===0;case y1.Difference:{let t=this.fillrule===r1.Positive?e.windCount2<=0:this.fillrule===r1.Negative?e.windCount2>=0:e.windCount2===0;return x.getPolyType(e)===q1.Subject?t:!t}case y1.Xor:return!0;default:return!1}}addLocalMinPoly(e,t,n,a=!1){let r=this.newOutRec();if(e.outrec=r,t.outrec=r,x.isOpen(e))r.owner=null,r.isOpen=!0,e.windDx>0?this.setSides(r,e,t):this.setSides(r,t,e);else{r.isOpen=!1;let i=x.getPrevHotEdge(e);i!==null?(this.usingPolytree&&this.setOwner(r,i.outrec),r.owner=i.outrec,this.outrecIsAscending(i)===a?this.setSides(r,t,e):this.setSides(r,e,t)):(r.owner=null,a?this.setSides(r,e,t):this.setSides(r,t,e))}let s=new E0(n,r);return r.pts=s,s}outrecIsAscending(e){return e===e.outrec.frontEdge}newOutRec(){let e=new o3;return e.idx=this.outrecList.length,this.outrecList.push(e),e}startOpenPath(e,t){let n=this.newOutRec();n.isOpen=!0,e.windDx>0?(n.frontEdge=e,n.backEdge=null):(n.frontEdge=null,n.backEdge=e),e.outrec=n;let a=new E0(t,n);return n.pts=a,a}checkJoinLeft(e,t,n=!1){let a=e.prevInAEL;a!==null&&(!n&&e.curX!==a.curX||!x.isHotEdge(e)||!x.isHotEdge(a)||x.isHorizontal(e)||x.isHorizontal(a)||x.isOpen(e)||x.isOpen(a)||(t.y<e.top.y+2||t.y<a.top.y+2)&&(e.bot.y>t.y||a.bot.y>t.y)||n&&this.perpendicDistFromLineSqrdGreaterThanQuarter(t,a.bot,a.top)||Q.isCollinear(e.top,t,a.top)&&(e.outrec.idx===a.outrec.idx?this.addLocalMaxPoly(a,e,t):e.outrec.idx<a.outrec.idx?this.joinOutrecPaths(e,a):this.joinOutrecPaths(a,e),a.joinWith=$1.Right,e.joinWith=$1.Left))}checkJoinRight(e,t,n=!1){let a=e.nextInAEL;a!==null&&(!n&&e.curX!==a.curX||!x.isHotEdge(e)||!x.isHotEdge(a)||x.isHorizontal(e)||x.isHorizontal(a)||x.isOpen(e)||x.isOpen(a)||(t.y<e.top.y+2||t.y<a.top.y+2)&&(e.bot.y>t.y||a.bot.y>t.y)||n&&this.perpendicDistFromLineSqrdGreaterThanQuarter(t,a.bot,a.top)||Q.isCollinear(e.top,t,a.top)&&(e.outrec.idx===a.outrec.idx?this.addLocalMaxPoly(e,a,t):e.outrec.idx<a.outrec.idx?this.joinOutrecPaths(e,a):this.joinOutrecPaths(a,e),e.joinWith=$1.Right,a.joinWith=$1.Left))}perpendicDistFromLineSqrdGreaterThanQuarter(e,t,n){let a=e.x-t.x,r=e.y-t.y,s=n.x-t.x,i=n.y-t.y;if(s===0&&i===0)return!1;let l=Q.maxCoordForSafeCrossSq;if(Math.abs(a)<l&&Math.abs(r)<l&&Math.abs(s)<l&&Math.abs(i)<l){let h=a*i-s*r;return h*h/(s*s+i*i)>.25}if(Number.isSafeInteger(a)&&Number.isSafeInteger(r)&&Number.isSafeInteger(s)&&Number.isSafeInteger(i)){let h=BigInt(a)*BigInt(i)-BigInt(s)*BigInt(r),f=h*h,u=BigInt(s)*BigInt(s)+BigInt(i)*BigInt(i);return N4*f>u}let o=a*i-s*r;return o*o/(s*s+i*i)>.25}intersectEdges(e,t,n){let a;if(this.hasOpenPaths&&(x.isOpen(e)||x.isOpen(t))){if(x.isOpen(e)&&x.isOpen(t))return;if(x.isOpen(t)){let o=e;e=t,t=o}if(this.isJoined(t)&&this.split(t,n),this.cliptype===y1.Union){if(!x.isHotEdge(t))return}else if(t.localMin.polytype===q1.Subject)return;switch(this.fillrule){case r1.Positive:if(t.windCount!==1)return;break;case r1.Negative:if(t.windCount!==-1)return;break;default:if(Math.abs(t.windCount)!==1)return;break}if(x.isHotEdge(e))a=this.addOutPt(e,n),this.setZ(e,t,a.pt),x.isFront(e)?e.outrec.frontEdge=null:e.outrec.backEdge=null,e.outrec=null;else if(n.x===e.localMin.vertex.pt.x&&n.y===e.localMin.vertex.pt.y&&!x.isOpenEndVertex(e.localMin.vertex)){let o=this.findEdgeWithMatchingLocMin(e);if(o!==null&&x.isHotEdge(o)){e.outrec=o.outrec,e.windDx>0?this.setSides(o.outrec,e,o):this.setSides(o.outrec,o,e);return}a=this.startOpenPath(e,n)}else a=this.startOpenPath(e,n);this.setZ(e,t,a.pt);return}this.isJoined(e)&&this.split(e,n),this.isJoined(t)&&this.split(t,n);let r,s;switch(e.localMin.polytype===t.localMin.polytype?this.fillrule===r1.EvenOdd?(r=e.windCount,e.windCount=t.windCount,t.windCount=r):(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!==r1.EvenOdd?e.windCount2+=t.windDx:e.windCount2=e.windCount2===0?1:0,this.fillrule!==r1.EvenOdd?t.windCount2-=e.windDx:t.windCount2=t.windCount2===0?1:0),this.fillrule){case r1.Positive:r=e.windCount,s=t.windCount;break;case r1.Negative:r=-e.windCount,s=-t.windCount;break;default:r=Math.abs(e.windCount),s=Math.abs(t.windCount);break}let i=r===0||r===1,l=s===0||s===1;if(!(!x.isHotEdge(e)&&!i||!x.isHotEdge(t)&&!l))if(x.isHotEdge(e)&&x.isHotEdge(t))if(r!==0&&r!==1||s!==0&&s!==1||e.localMin.polytype!==t.localMin.polytype&&this.cliptype!==y1.Xor)a=this.addLocalMaxPoly(e,t,n),a&&this.setZ(e,t,a.pt);else if(x.isFront(e)||e.outrec===t.outrec){a=this.addLocalMaxPoly(e,t,n),a&&this.setZ(e,t,a.pt);let o=this.addLocalMinPoly(e,t,n);this.setZ(e,t,o.pt)}else{a=this.addOutPt(e,n),this.setZ(e,t,a.pt);let o=this.addOutPt(t,n);this.setZ(e,t,o.pt),this.swapOutrecs(e,t)}else if(x.isHotEdge(e))a=this.addOutPt(e,n),this.setZ(e,t,a.pt),this.swapOutrecs(e,t);else if(x.isHotEdge(t))a=this.addOutPt(t,n),this.setZ(e,t,a.pt),this.swapOutrecs(e,t);else{let o,h;switch(this.fillrule){case r1.Positive:o=e.windCount2,h=t.windCount2;break;case r1.Negative:o=-e.windCount2,h=-t.windCount2;break;default:o=Math.abs(e.windCount2),h=Math.abs(t.windCount2);break}if(!x.isSamePolyType(e,t))a=this.addLocalMinPoly(e,t,n),this.setZ(e,t,a.pt);else if(r===1&&s===1){switch(a=null,this.cliptype){case y1.Union:if(o>0&&h>0)return;a=this.addLocalMinPoly(e,t,n);break;case y1.Difference:(x.getPolyType(e)===q1.Clip&&o>0&&h>0||x.getPolyType(e)===q1.Subject&&o<=0&&h<=0)&&(a=this.addLocalMinPoly(e,t,n));break;case y1.Xor:a=this.addLocalMinPoly(e,t,n);break;default:if(o<=0||h<=0)return;a=this.addLocalMinPoly(e,t,n);break}a&&this.setZ(e,t,a.pt)}}}swapPositionsInAEL(e,t){let n=t.nextInAEL;n!==null&&(n.prevInAEL=e);let a=e.prevInAEL;a!==null&&(a.nextInAEL=t),t.prevInAEL=a,t.nextInAEL=e,e.prevInAEL=t,e.nextInAEL=n,t.prevInAEL===null&&(this.actives=t)}isValidAelOrder(e,t){if(t.curX!==e.curX)return t.curX>e.curX;let n=Q.crossProductSign(e.top,t.bot,t.top);if(n!==0)return n<0;if(!x.isMaximaEdge(e)&&e.top.y>t.top.y)return Q.crossProductSign(t.bot,e.top,x.nextVertex(e).pt)<=0;if(!x.isMaximaEdge(t)&&t.top.y>e.top.y)return Q.crossProductSign(t.bot,t.top,x.nextVertex(t).pt)>=0;let a=t.bot.y,r=t.isLeftBound;return e.bot.y!==a||e.localMin.vertex.pt.y!==a?t.isLeftBound:e.isLeftBound!==r?r:Q.isCollinear(x.prevPrevVertex(e).pt,e.bot,e.top)?!0:Q.crossProductSign(x.prevPrevVertex(e).pt,t.bot,x.prevPrevVertex(t).pt)>0===r}isJoined(e){return e.joinWith!==$1.None}split(e,t){e.joinWith===$1.Right?(e.joinWith=$1.None,e.nextInAEL.joinWith=$1.None,this.addLocalMinPoly(e,e.nextInAEL,t,!0)):(e.joinWith=$1.None,e.prevInAEL.joinWith=$1.None,this.addLocalMinPoly(e.prevInAEL,e,t,!0))}setSides(e,t,n){e.frontEdge=t,e.backEdge=n}findEdgeWithMatchingLocMin(e){let t=e.nextInAEL;for(;t!==null;){if(t.localMin?.equals(e.localMin))return t;!x.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(!x.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 n=e.outrec,a=x.isFront(e),r=n.pts,s=r.next;if(a&&t.x===r.pt.x&&t.y===r.pt.y)return r;if(!a&&t.x===s.pt.x&&t.y===s.pt.y)return s;let i=new E0(t,n);return s.prev=i,i.prev=r,i.next=s,r.next=i,a&&(n.pts=i),i}addLocalMaxPoly(e,t,n){if(this.isJoined(e)&&this.split(e,n),this.isJoined(t)&&this.split(t,n),x.isFront(e)===x.isFront(t))if(x.isOpenEnd(e))this.swapFrontBackSides(e.outrec);else if(x.isOpenEnd(t))this.swapFrontBackSides(t.outrec);else return this.succeeded=!1,null;let a=this.addOutPt(e,n);if(e.outrec===t.outrec){let r=e.outrec;if(r.pts=a,this.usingPolytree){let s=x.getPrevHotEdge(e);s===null?r.owner=null:this.setOwner(r,s.outrec)}this.uncoupleOutRec(e)}else x.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 a}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 n=t;for(;n!==null&&n!==e;)n=n.owner;n!==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 n=e.outrec.pts,a=t.outrec.pts,r=n.next,s=a.next;x.isFront(e)?(s.prev=n,n.next=s,a.next=r,r.prev=a,e.outrec.pts=a,e.outrec.frontEdge=t.outrec.frontEdge,e.outrec.frontEdge!==null&&(e.outrec.frontEdge.outrec=e.outrec)):(r.prev=a,a.next=r,n.next=s,s.prev=n,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),x.isOpenEnd(e)&&(t.outrec.pts=e.outrec.pts,e.outrec.pts=null),e.outrec=null,t.outrec=null}swapOutrecs(e,t){let n=e.outrec,a=t.outrec;if(n===a){let r=n.frontEdge;n.frontEdge=n.backEdge,n.backEdge=r;return}n!==null&&(e===n.frontEdge?n.frontEdge=t:n.backEdge=t),a!==null&&(t===a.frontEdge?a.frontEdge=e:a.backEdge=e),e.outrec=a,t.outrec=n}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&&(x.ptsReallyClose(e.prev.pt,e.next.pt)||x.ptsReallyClose(e.pt,e.next.pt)||x.ptsReallyClose(e.pt,e.prev.pt))}static buildPath(e,t,n,a){if(e===null||e.next===e||!n&&e.next===e.prev)return!1;a.length=0;let r,s;for(t?(r=e.pt,s=e.prev):(e=e.next,r=e.pt,s=e.next),a.push(r);s!==e;)s.pt.x===r.x&&s.pt.y===r.y||(r=s.pt,a.push(r)),t?s=s.prev:s=s.next;return a.length!==3||n||!x.isVerySmallTriangle(s)}buildPaths(e,t){e.length=0,t.length=0;let n=0;for(;n<this.outrecList.length;){let a=this.outrecList[n++];if(a.pts===null)continue;let r=[];a.isOpen?x.buildPath(a.pts,this.reverseSolution,!0,r)&&t.push(r):(this.cleanCollinear(a),x.buildPath(a.pts,this.reverseSolution,!1,r)&&e.push(r))}return!0}buildTree(e,t){e.clear(),t.length=0;let n=0;for(;n<this.outrecList.length;){let a=this.outrecList[n++];if(a.pts!==null){if(a.isOpen){let r=[];x.buildPath(a.pts,this.reverseSolution,!0,r)&&t.push(r);continue}this.checkBounds(a)&&this.recursiveCheckOwners(a,e)}}}checkBounds(e){return e.pts===null?!1:J0.isEmpty(e.bounds)?(this.cleanCollinear(e),e.pts===null||!x.buildPath(e.pts,this.reverseSolution,!1,e.path)?!1:(e.bounds=Q.getBounds(e.path),!0)):!0}recursiveCheckOwners(e,t){if(!(e.polypath!==null||J0.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,n=t;for(;;){if(n!==null&&Q.isCollinear(n.prev.pt,n.pt,n.next.pt)&&(n.pt.x===n.prev.pt.x&&n.pt.y===n.prev.pt.y||n.pt.x===n.next.pt.x&&n.pt.y===n.next.pt.y||!this.preserveCollinear||Q.dotProductSign(n.prev.pt,n.pt,n.next.pt)<0)){if(n===e.pts&&(e.pts=n.prev),n=this.disposeOutPt(n),!this.isValidClosedPath(n)){e.pts=null;return}t=n;continue}if(n===null||(n=n.next,n===t))break}this.fixSelfIntersects(e)}isValidClosedPath(e){return e!==null&&e.next!==e&&(e.next!==e.prev||!x.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)&&Q.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 n=t.prev,a=t.next.next;e.pts=n;let r=Q.getLineIntersectPt(n.pt,t.pt,t.next.pt,a.pt);this.zCallbackInternal&&this.zCallbackInternal(n.pt,t.pt,t.next.pt,a.pt,r);let s=x.areaOutPt(n),i=s<P2?-s:s;if(i<N4){e.pts=null;return}let l=this.areaTriangle(r,t.pt,t.next.pt),o=l<P2?-l:l;if(r.x===n.pt.x&&r.y===n.pt.y||r.x===a.pt.x&&r.y===a.pt.y)a.prev=n,n.next=a;else{let u=new E0(r,e);u.prev=n,u.next=a,a.prev=u,n.next=u}if(!(o>p9)||!(o>i)&&l>P2!=s>P2)return;let h=this.newOutRec();h.owner=e.owner,t.outrec=h,t.next.outrec=h;let f=new E0(r,h);f.prev=t.next,f.next=t,h.pts=f,t.prev=f,t.next.next=f,this.usingPolytree&&(this.path1InsidePath2(n,f)?(h.splits===null&&(h.splits=[]),h.splits.push(e.idx)):(e.splits===null&&(e.splits=[]),e.splits.push(h.idx)))}static areaOutPt(e){let t=Q.maxCoordForSafeAreaProduct,n=0,a=!0,r=e;do{let i=r.prev,l=r.pt;if(Math.abs(i.pt.x)>=t||Math.abs(i.pt.y)>=t||Math.abs(l.x)>=t||Math.abs(l.y)>=t){a=!1;break}n+=(i.pt.y+l.y)*(i.pt.x-l.x),r=r.next}while(r!==e);if(a)return BigInt(Math.round(n));let s=P2;r=e;do{let i=r.prev;if(Number.isSafeInteger(i.pt.y)&&Number.isSafeInteger(r.pt.y)&&Number.isSafeInteger(i.pt.x)&&Number.isSafeInteger(r.pt.x)){let l=BigInt(i.pt.y)+BigInt(r.pt.y),o=BigInt(i.pt.x)-BigInt(r.pt.x);s+=l*o}else{let l=i.pt.y+r.pt.y,o=i.pt.x-r.pt.x;s+=BigInt(Math.round(l*o))}r=r.next}while(r!==e);return s}areaTriangle(e,t,n){let a=Q.maxCoordForSafeAreaProduct;if(Math.abs(e.x)<a&&Math.abs(e.y)<a&&Math.abs(t.x)<a&&Math.abs(t.y)<a&&Math.abs(n.x)<a&&Math.abs(n.y)<a){let s=(n.y+e.y)*(n.x-e.x)+(e.y+t.y)*(e.x-t.x)+(t.y+n.y)*(t.x-n.x);return BigInt(Math.round(s))}if(Number.isSafeInteger(e.x)&&Number.isSafeInteger(e.y)&&Number.isSafeInteger(t.x)&&Number.isSafeInteger(t.y)&&Number.isSafeInteger(n.x)&&Number.isSafeInteger(n.y)){let s=(BigInt(n.y)+BigInt(e.y))*(BigInt(n.x)-BigInt(e.x)),i=(BigInt(e.y)+BigInt(t.y))*(BigInt(e.x)-BigInt(t.x)),l=(BigInt(t.y)+BigInt(n.y))*(BigInt(t.x)-BigInt(n.x));return s+i+l}let r=(n.y+e.y)*(n.x-e.x)+(e.y+t.y)*(e.x-t.x)+(t.y+n.y)*(t.x-n.x);return BigInt(Math.round(r))}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 n=0;n<t.length;n++){let a=this.outrecList[t[n]];if(a.pts===null&&a.splits!==null&&this.checkSplitOwner(e,a.splits))return!0;if(a=this.getRealOutRec(a),!(a===null||a===e||a.recursiveSplit===e)){if(a.recursiveSplit=e,a.splits!==null&&this.checkSplitOwner(e,a.splits))return!0;if(!(!this.checkBounds(a)||!this.containsRect(a.bounds,e.bounds)||!this.path1InsidePath2(e.pts,a.pts)))return this.isValidOwner(e,a)||(a.owner=e.owner),e.owner=a,!0}}return!1}};T(x,"openPathsEnabled",!0);var d3=x,y0=class extends d3{constructor(){super(...arguments);T(this,"zCallback")}getZCallback(){return this.zCallback}addPath(t,n,a=!1){super.addPath(t,n,a)}addReuseableData(t){super.addReuseableData(t)}addPaths(t,n,a=!1){super.addPaths(t,n,a)}addSubject(t){this.addPaths(t,q1.Subject)}addOpenSubject(t){this.addPaths(t,q1.Subject,!0)}addClip(t){this.addPaths(t,q1.Clip)}execute(t,n,a,r){if(Array.isArray(a)){let s=a,i=r;s.length=0,i&&(i.length=0);try{this.executeInternal(t,n),this.buildPaths(s,i||[])}catch{this.succeeded=!1}return this.clearSolutionOnly(),this.succeeded}else{let s=a,i=r;s.clear(),i&&(i.length=0),this.usingPolytree=!0;try{this.executeInternal(t,n),this.buildTree(s,i||[])}catch{this.succeeded=!1}return this.clearSolutionOnly(),this.succeeded}}};var d5={area(c){return Q.area(c)},areaD(c){let e=0,t=c.length;if(t<3)return 0;let n=c[t-1];for(let a of c)e+=(n.y+a.y)*(n.x-a.x),n=a;return e*.5},scalePath64(c,e){let t=Q.maxSafeCoordinateForScale(e),n=[];for(let a of c)Q.checkSafeScaleValue(a.x,t,"scalePath64"),Q.checkSafeScaleValue(a.y,t,"scalePath64"),n.push({x:Math.round(a.x*e),y:Math.round(a.y*e)});return n},scalePaths64(c,e){let t=[];for(let n of c)t.push(d5.scalePath64(n,e));return t},scalePathD(c,e){let t=[];for(let n of c)t.push({x:n.x*e,y:n.y*e});return t},scalePathsD(c,e){let t=[];for(let n of c)t.push(d5.scalePathD(n,e));return t}};var G1;(function(c){c[c.Miter=0]="Miter",c[c.Square=1]="Square",c[c.Bevel=2]="Bevel",c[c.Round=3]="Round"})(G1||(G1={}));var w1;(function(c){c[c.Polygon=0]="Polygon",c[c.Joined=1]="Joined",c[c.Butt=2]="Butt",c[c.Square=3]="Square",c[c.Round=4]="Round"})(w1||(w1={}));var p5=class{constructor(e,t,n=w1.Polygon){T(this,"inPaths");T(this,"joinType");T(this,"endType");T(this,"pathsReversed");T(this,"lowestPathIdx");this.joinType=t,this.endType=n;let a=n===w1.Polygon||n===w1.Joined;this.inPaths=[];for(let r of e)this.inPaths.push(Q0.stripDuplicates(r,a));if(n===w1.Polygon){let r=Q0.getLowestPathInfo(this.inPaths);this.lowestPathIdx=r.idx,this.pathsReversed=this.lowestPathIdx>=0&&r.isNegArea}else this.lowestPathIdx=-1,this.pathsReversed=!1}},z1=class z1{constructor(e=2,t=0,n=!1,a=!1){T(this,"groupList",[]);T(this,"pathOut",[]);T(this,"normals",[]);T(this,"solution",[]);T(this,"solutionTree",null);T(this,"groupDelta",0);T(this,"delta",0);T(this,"mitLimSqr",0);T(this,"stepsPerRad",0);T(this,"stepSin",0);T(this,"stepCos",0);T(this,"joinType",G1.Bevel);T(this,"endType",w1.Polygon);T(this,"arcTolerance",0);T(this,"mergeGroups",!0);T(this,"miterLimit",2);T(this,"preserveCollinear",!1);T(this,"reverseSolution",!1);T(this,"zCallback");T(this,"deltaCallback",null);T(this,"ZCB",(e,t,n,a,r)=>{(e.z||0)!==0&&(e.z===n.z||e.z===a.z)?r.z=e.z:(n.z||0)!==0&&n.z===t.z?r.z=n.z:(t.z||0)!==0&&t.z===a.z?r.z=t.z:this.zCallback&&this.zCallback(e,t,n,a,r)});this.miterLimit=e,this.arcTolerance=t,this.mergeGroups=!0,this.preserveCollinear=n,this.reverseSolution=a}clear(){this.groupList.length=0}addPath(e,t,n){if(e.length===0)return;let a=[e];this.addPaths(a,t,n)}addPaths(e,t,n){e.length!==0&&this.groupList.push(new p5(e,t,n))}calcSolutionCapacity(){let e=0;for(let t of this.groupList)e+=t.endType===w1.Joined?t.inPaths.length*2:t.inPaths.length;return e}checkPathsReversed(){let e=!1;for(let t of this.groupList)if(t.endType===w1.Polygon){e=t.pathsReversed;break}return e}executeInternal(e){if(this.groupList.length===0)return;if(Math.abs(e)<.5){for(let r of this.groupList)for(let s of r.inPaths)this.solution.push(s);return}this.delta=e,this.mitLimSqr=this.miterLimit<=1?2:2/z1.sqr(this.miterLimit);for(let r of this.groupList)this.doGroupOffset(r);if(this.groupList.length===0)return;let t=this.checkPathsReversed(),n=t?r1.Negative:r1.Positive,a=new y0;a.preserveCollinear=this.preserveCollinear,a.reverseSolution=this.reverseSolution!==t,a.zCallback=this.ZCB,a.addSubject(this.solution),this.solutionTree!==null?a.execute(y1.Union,n,this.solutionTree):a.execute(y1.Union,n,this.solution)}execute(e,t){if(Array.isArray(t)){let n=t;n.length=0,this.solution=n,this.executeInternal(e)}else{let n=t;n.clear(),this.solutionTree=n,this.solution=[],this.executeInternal(e)}}executeWithCallback(e,t){this.deltaCallback=e,this.execute(1,t)}static getUnitNormal(e,t){let n=t.x-e.x,a=t.y-e.y;if(n===0&&a===0)return{x:0,y:0};let r=1/Math.sqrt(n*n+a*a);return{x:a*r,y:-n*r}}static getLowestPathInfo(e){let t=-1,n=!1,a={x:Number.MAX_SAFE_INTEGER,y:Number.MIN_SAFE_INTEGER};for(let r=0;r<e.length;++r){let s=Number.MAX_VALUE;for(let i of e[r])if(!(i.y<a.y||i.y===a.y&&i.x>=a.x)){if(s===Number.MAX_VALUE){if(s=z1.area(e[r]),s===0)break;n=s<0}t=r,a.x=i.x,a.y=i.y}}return{idx:t,isNegArea:n}}static translatePoint(e,t,n){return{x:e.x+t,y:e.y+n,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=z1.hypotenuse(e.x,e.y);if(z1.almostZero(t))return{x:0,y:0};let n=1/t;return{x:e.x*n,y:e.y*n}}static getAvgUnitVector(e,t){return z1.normalizeVector({x:e.x+t.x,y:e.y+t.y})}static intersectPoint(e,t,n,a){if(Q.isAlmostZero(e.x-t.x)){if(Q.isAlmostZero(n.x-a.x))return{x:0,y:0};let r=(a.y-n.y)/(a.x-n.x),s=n.y-r*n.x;return{x:e.x,y:r*e.x+s}}if(Q.isAlmostZero(n.x-a.x)){let r=(t.y-e.y)/(t.x-e.x),s=e.y-r*e.x;return{x:n.x,y:r*n.x+s}}else{let r=(t.y-e.y)/(t.x-e.x),s=e.y-r*e.x,i=(a.y-n.y)/(a.x-n.x),l=n.y-i*n.x;if(Q.isAlmostZero(r-i))return{x:0,y:0};let o=(l-s)/(r-i);return{x:o,y:r*o+s}}}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,n){let a,r,s=e[t].z||0;if(t===n){let i=Math.abs(this.groupDelta);a={x:Math.round(e[t].x-i*this.normals[t].x),y:Math.round(e[t].y-i*this.normals[t].y),z:s},r={x:Math.round(e[t].x+i*this.normals[t].x),y:Math.round(e[t].y+i*this.normals[t].y),z:s}}else a={x:Math.round(e[t].x+this.groupDelta*this.normals[n].x),y:Math.round(e[t].y+this.groupDelta*this.normals[n].y),z:s},r={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:s};this.pathOut.push(a),this.pathOut.push(r)}doSquare(e,t,n){let a;t===n?a={x:this.normals[t].y,y:-this.normals[t].x}:a=z1.getAvgUnitVector({x:-this.normals[n].y,y:this.normals[n].x},{x:this.normals[t].y,y:-this.normals[t].x});let r=Math.abs(this.groupDelta),s={x:e[t].x,y:e[t].y,z:e[t].z||0};s=z1.translatePoint(s,r*a.x,r*a.y);let i=z1.translatePoint(s,this.groupDelta*a.y,this.groupDelta*-a.x),l=z1.translatePoint(s,this.groupDelta*-a.y,this.groupDelta*a.x),o=this.getPerpendicD(e[n],this.normals[n]);if(t===n){let h={x:o.x+a.x*this.groupDelta,y:o.y+a.y*this.groupDelta},f=z1.intersectPoint(i,l,o,h);f.z=s.z,this.pathOut.push(g0.fromPointD(z1.reflectPoint(f,s))),this.pathOut.push(g0.fromPointD(f))}else{let h=this.getPerpendicD(e[t],this.normals[n]),f=z1.intersectPoint(i,l,o,h);f.z=s.z,this.pathOut.push(g0.fromPointD(f)),this.pathOut.push(g0.fromPointD(z1.reflectPoint(f,s)))}}doMiter(e,t,n,a){let r=this.groupDelta/(a+1);this.pathOut.push({x:Math.round(e[t].x+(this.normals[n].x+this.normals[t].x)*r),y:Math.round(e[t].y+(this.normals[n].y+this.normals[t].y)*r),z:e[t].z||0})}doRound(e,t,n,a){if(this.deltaCallback!==null){let o=Math.abs(this.groupDelta),h=this.arcTolerance>.01?this.arcTolerance:o*z1.arc_const,f=Math.PI/Math.acos(1-h/o);this.stepSin=Math.sin(2*Math.PI/f),this.stepCos=Math.cos(2*Math.PI/f),this.groupDelta<0&&(this.stepSin=-this.stepSin),this.stepsPerRad=f/(2*Math.PI)}let r=e[t],s=r.z||0,i={x:this.normals[n].x*this.groupDelta,y:this.normals[n].y*this.groupDelta};t===n&&l3.negate(i),this.pathOut.push({x:Math.round(r.x+i.x),y:Math.round(r.y+i.y),z:s});let l=Math.ceil(this.stepsPerRad*Math.abs(a));for(let o=1;o<l;o++)i={x:i.x*this.stepCos-this.stepSin*i.y,y:i.x*this.stepSin+i.y*this.stepCos},this.pathOut.push({x:Math.round(r.x+i.x),y:Math.round(r.y+i.y),z:s});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 n=0;n<t-1;n++)this.normals.push(z1.getUnitNormal(e[n],e[n+1]));this.normals.push(z1.getUnitNormal(e[t-1],e[0]))}}offsetPoint(e,t,n,a){if(g0.equals(t[n],t[a]))return;let r=Q.crossProductD(this.normals[n],this.normals[a]),s=Q.dotProductD(this.normals[n],this.normals[a]);if(r>1?r=1:r<-1&&(r=-1),this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(t,this.normals,n,a),e.pathsReversed&&(this.groupDelta=-this.groupDelta)),Math.abs(this.groupDelta)<z1.Tolerance){this.pathOut.push(t[n]);return}if(s>-.999&&r*this.groupDelta<0)this.pathOut.push(this.getPerpendic(t[n],this.normals[a])),this.pathOut.push(t[n]),this.pathOut.push(this.getPerpendic(t[n],this.normals[n]));else if(s>.999&&this.joinType!==G1.Round)this.doMiter(t,n,a,s);else switch(this.joinType){case G1.Miter:s>this.mitLimSqr-1?this.doMiter(t,n,a,s):this.doSquare(t,n,a);break;case G1.Round:this.doRound(t,n,a,Math.atan2(r,s));break;case G1.Bevel:this.doBevel(t,n,a);break;default:this.doSquare(t,n,a);break}}offsetPolygon(e,t){this.pathOut=[];let n=t.length,a=n-1;for(let r=0;r<n;r++)this.offsetPoint(e,t,r,a),a=r;this.solution.push(this.pathOut)}offsetOpenJoined(e,t){this.offsetPolygon(e,t);let n=[...t].reverse();this.buildNormals(n),this.offsetPolygon(e,n)}offsetOpenPath(e,t){this.pathOut=[];let n=t.length-1;if(this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(t,this.normals,0,0)),Math.abs(this.groupDelta)<z1.Tolerance)this.pathOut.push(t[0]);else switch(this.endType){case w1.Butt:this.doBevel(t,0,0);break;case w1.Round:this.doRound(t,0,0,Math.PI);break;default:this.doSquare(t,0,0);break}for(let a=1,r=0;a<n;a++)this.offsetPoint(e,t,a,r),r=a;for(let a=n;a>0;a--)this.normals[a]={x:-this.normals[a-1].x,y:-this.normals[a-1].y};if(this.normals[0]=this.normals[n],this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(t,this.normals,n,n)),Math.abs(this.groupDelta)<z1.Tolerance)this.pathOut.push(t[n]);else switch(this.endType){case w1.Butt:this.doBevel(t,n,n);break;case w1.Round:this.doRound(t,n,n,Math.PI);break;default:this.doSquare(t,n,n);break}for(let a=n-1,r=n;a>0;a--)this.offsetPoint(e,t,a,r),r=a;this.solution.push(this.pathOut)}doGroupOffset(e){e.endType===w1.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===G1.Round||e.endType===w1.Round){let n=this.arcTolerance>.01?this.arcTolerance:t*z1.arc_const,a=Math.PI/Math.acos(1-n/t);this.stepSin=Math.sin(2*Math.PI/a),this.stepCos=Math.cos(2*Math.PI/a),this.groupDelta<0&&(this.stepSin=-this.stepSin),this.stepsPerRad=a/(2*Math.PI)}for(let n of e.inPaths){this.pathOut=[];let a=n.length;if(a===1){let r=n[0];this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(n,this.normals,0,0),e.pathsReversed&&(this.groupDelta=-this.groupDelta));let s=r.z||0;if(e.endType===w1.Round){let i=Math.ceil(this.stepsPerRad*2*Math.PI);if(this.pathOut=z1.ellipse(r,Math.abs(this.groupDelta),Math.abs(this.groupDelta),i),s!==0)for(let l=0;l<this.pathOut.length;l++)this.pathOut[l].z=s}else{let i=Math.ceil(Math.abs(this.groupDelta)),l={left:r.x-i,top:r.y-i,right:r.x+i,bottom:r.y+i};this.pathOut=[{x:l.left,y:l.top,z:s},{x:l.right,y:l.top,z:s},{x:l.right,y:l.bottom,z:s},{x:l.left,y:l.bottom,z:s}]}this.solution.push(this.pathOut);continue}switch(a===2&&e.endType===w1.Joined&&(this.endType=e.joinType===G1.Round?w1.Round:w1.Square),this.buildNormals(n),this.endType){case w1.Polygon:this.offsetPolygon(e,n);break;case w1.Joined:this.offsetOpenJoined(e,n);break;default:this.offsetOpenPath(e,n);break}}}static stripDuplicates(e,t){let n=e.length,a=[];if(n===0)return a;let r=e[0];a.push(r);for(let s=1;s<n;s++)g0.equals(r,e[s])||(r=e[s],a.push(r));return t&&g0.equals(r,a[0])&&a.pop(),a}static area(e){return Q.area(e)}static sqr(e){return e*e}static ellipse(e,t,n=0,a=0){if(t<=0)return[];n<=0&&(n=t),a<=2&&(a=Math.ceil(Math.PI*Math.sqrt((t+n)/2)));let r=Math.sin(2*Math.PI/a),s=Math.cos(2*Math.PI/a),i=s,l=r,o=[{x:Math.round(e.x+t),y:e.y}];for(let h=1;h<a;++h){o.push({x:Math.round(e.x+t*i),y:Math.round(e.y+n*l)});let f=i*s-l*r;l=l*s+i*r,i=f}return o}};T(z1,"Tolerance",1e-12),T(z1,"arc_const",.002);var Q0=z1;var Wa=BigInt(2);function v5(c,e,t){return typeof e=="number"?m5(y1.Union,c,null,e):m5(y1.Union,c,e,t)}function m5(c,e,t,n){let a=[];if(e===null)return a;let r=new y0;return r.addPaths(e,q1.Subject),t!==null&&r.addPaths(t,q1.Clip),r.execute(c,n,a),a}function p3(c,e,t,n,a=2,r=0){let s=new Q0(a,r);s.addPaths(c,t,n);let i=[];return s.execute(e,i),i}var o0=1e4;function a0(){return{layers:new Map,parts:[]}}function O1(c,e="cut"){return{layers:new Map([[e,{regions:c,lines:[]}]]),parts:[]}}function R0(c,e="cut"){return{layers:new Map([[e,{regions:[],lines:c}]]),parts:[]}}function j4(c){if(c.parts.length)return!1;for(let e of c.layers.values())if(e.regions.length||e.lines.length)return!1;return!0}var W4=c=>c.map(e=>e.map(([t,n])=>({x:Math.round(t*o0),y:Math.round(n*o0)})));function M9(c){let e=(n,a,r)=>(a.x-n.x)*(r.y-a.y)-(a.y-n.y)*(r.x-a.x)===0,t=[];for(let n of c){for(;t.length>=2&&e(t[t.length-2],t[t.length-1],n);)t.pop();let a=t[t.length-1];(!a||a.x!==n.x||a.y!==n.y)&&t.push(n)}for(let n=!0;n&&t.length>=3;){let a=t.length;n=!0,t[a-1].x===t[0].x&&t[a-1].y===t[0].y||e(t[a-2],t[a-1],t[0])?t.pop():e(t[a-1],t[0],t[1])?t.shift():n=!1}return t}var O2=c=>W4(c).map(M9),F2=c=>c.filter(e=>e.length>=2).map(e=>e.map(t=>[t.x/o0,t.y/o0]));function s1(c,e="nonzero"){if(!c.length)return[];let t=e==="evenodd"?r1.EvenOdd:r1.NonZero;return F2(v5(O2(c),t)).filter(n=>n.length>=3)}function g5(c,e,t){if(!e.length)return[];let n=new y0;n.addSubject(O2(e)),t.length&&n.addClip(O2(t));let a=[];return n.execute(c,r1.NonZero,a),F2(a).filter(r=>r.length>=3)}var Q1=(c,e)=>e.length?g5(y1.Difference,c,e):s1(c),Z1=(c,e)=>g5(y1.Intersection,c,e),X4=(c,e)=>g5(y1.Xor,c,e);function M0(c,e,t){if(!c.length)return[];if(!e.length)return t==="outside"?c:[];let n=[];for(let m of e)for(let v=0;v<m.length;v++){let g=m[v],y=m[(v+1)%m.length];(g[0]!==y[0]||g[1]!==y[1])&&n.push([g,y])}if(!n.length)return t==="outside"?c:[];let a=x0(e),r=Math.max(a[2]-a[0],a[3]-a[1],1e-6)/Math.max(1,Math.sqrt(n.length)),s=m=>Math.floor(m/r),i=new Map,l=new Map,o=(m,v,g)=>{let y=m.get(v);y?y[y.length-1]!==g&&y.push(g):m.set(v,[g])};n.forEach(([m,v],g)=>{let y=Math.max(1,Math.ceil(Math.hypot(v[0]-m[0],v[1]-m[1])/r*2));for(let M=0;M<=y;M++){let A=m[0]+(v[0]-m[0])*M/y,z=m[1]+(v[1]-m[1])*M/y;for(let E of[-1,0,1])for(let k of[-1,0,1])o(i,`${s(A)+E},${s(z)+k}`,g)}for(let M=s(Math.min(m[1],v[1]));M<=s(Math.max(m[1],v[1]));M++)o(l,M,g)});let h=(m,v)=>{let g=new Set,y=Math.max(1,Math.ceil(Math.hypot(v[0]-m[0],v[1]-m[1])/r*2));for(let M=0;M<=y;M++){let A=m[0]+(v[0]-m[0])*M/y,z=m[1]+(v[1]-m[1])*M/y;for(let E of i.get(`${s(A)},${s(z)}`)??[])g.add(E)}return g},f=.5/o0,u=m=>{for(let g of i.get(`${s(m[0])},${s(m[1])}`)??[]){let[y,M]=n[g],A=M[0]-y[0],z=M[1]-y[1],E=Math.max(0,Math.min(1,((m[0]-y[0])*A+(m[1]-y[1])*z)/(A*A+z*z)));if(Math.hypot(m[0]-y[0]-E*A,m[1]-y[1]-E*z)<=f)return}let v=0;for(let g of l.get(s(m[1]))??[]){let[y,M]=n[g],A=(M[0]-y[0])*(m[1]-y[1])-(m[0]-y[0])*(M[1]-y[1]);y[1]<=m[1]?M[1]>m[1]&&A>0&&v++:M[1]<=m[1]&&A<0&&v--}return v!==0},d=m=>Math.round(m*o0)/o0,p=[];for(let m of c){let v=null,g=()=>{v&&v.length>=2&&p.push(v),v=null};for(let y=1;y<m.length;y++){let M=m[y-1],A=m[y],z=A[0]-M[0],E=A[1]-M[1];if(!z&&!E)continue;let k=[0,1];for(let C of h(M,A)){let[P,w]=n[C],I=w[0]-P[0],B=w[1]-P[1],F=z*B-E*I;if(Math.abs(F)>1e-15){let G=((P[0]-M[0])*B-(P[1]-M[1])*I)/F,X=((P[0]-M[0])*E-(P[1]-M[1])*z)/F;G>0&&G<1&&X>=0&&X<=1&&k.push(G)}else{let G=z*z+E*E;for(let X of[P,w]){let q=((X[0]-M[0])*z+(X[1]-M[1])*E)/G,o1=Math.abs((X[0]-M[0])*E-(X[1]-M[1])*z)/Math.sqrt(G);q>0&&q<1&&o1<=f&&k.push(q)}}}k.sort((C,P)=>C-P);for(let C=1;C<k.length;C++){if(k[C]-k[C-1]<1e-12)continue;let P=[d(M[0]+z*k[C-1]),d(M[1]+E*k[C-1])],w=[d(M[0]+z*k[C]),d(M[1]+E*k[C])],I=(k[C-1]+k[C])/2,B=u([M[0]+z*I,M[1]+E*I]);if(B!==void 0&&B===(t==="inside")){let F=v?v[v.length-1]:void 0;v&&F&&F[0]===P[0]&&F[1]===P[1]?(w[0]!==F[0]||w[1]!==F[1])&&v.push(w):(g(),v=[P,w])}else g()}}g()}return p}function N1(c,e,t="round",n=.01){if(!c.length)return[];if(e===0)return s1(c);let a=t==="round"?G1.Round:t==="square"?G1.Square:G1.Miter,r=p3(O2(s1(c)),e*o0,a,w1.Polygon,2,n*o0);return F2(r).filter(s=>s.length>=3)}function m3(c,e){if(!c.length||e<=0)return[];let t=p3(W4(c),e/2*o0,G1.Round,w1.Round,2,.01*o0);return F2(t)}function T0(c){if(!c.length)return[];let e=new V2,t=new y0;t.addSubject(O2(c)),t.execute(y1.Union,r1.NonZero,e);let n=[],a=r=>{for(let s=0;s<r.count;s++){let i=r.child(s),l=[i.poly];for(let o=0;o<i.count;o++){let h=i.child(o);l.push(h.poly),a(h)}n.push(F2(l))}};return a(e),n}function g1(c){let e=0;for(let t=0,n=c.length-1;t<c.length;n=t++)e+=(c[n][0]+c[t][0])*(c[n][1]-c[t][1]);return-e/2}function $4(c,[e,t]){return[c[0]*e+c[2]*t+c[4],c[1]*e+c[3]*t+c[5]]}function G4(c,e){let t=e[0]*e[3]-e[1]*e[2]<0,n=new Map;for(let[a,r]of c)n.set(a,{regions:r.regions.map(s=>{let i=s.map(l=>$4(e,l));return t?i.reverse():i}),lines:r.lines.map(s=>s.map(i=>$4(e,i)))});return n}function f2(c,e){return{layers:G4(c.layers,e),parts:c.parts.map(t=>({...t,layers:G4(t.layers,e)}))}}function U0(c){let e=a0();for(let t of c){for(let[n,a]of t.layers){let r=e.layers.get(n)??{regions:[],lines:[]};for(let s of a.regions)r.regions.push(s);for(let s of a.lines)r.lines.push(s);e.layers.set(n,r)}for(let n of t.parts)e.parts.push(n)}return e}function _4(c,e){let t={regions:[],lines:[]};for(let n of c.values()){for(let a of n.regions)t.regions.push(a);for(let a of n.lines)t.lines.push(a)}return new Map([[e,t]])}function D2(c,e){if(c.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:_4(c.layers,e),parts:c.parts.map(t=>({...t,layers:_4(t.layers,e)}))}}function x0(c){let e=1/0,t=1/0,n=-1/0,a=-1/0;for(let r of c)for(let[s,i]of r)s<e&&(e=s),i<t&&(t=i),s>n&&(n=s),i>a&&(a=i);return e===1/0?null:[e,t,n,a]}function r0(c,e){let t=[];for(let[n,a]of c)if(!e?.(n))for(let r of[...a.regions,...a.lines])t.push(r);return x0(t)}function Z4(c){let e=[...c].sort((r,s)=>r[0]-s[0]||r[1]-s[1]);if(e.length<3)return e;let t=(r,s,i)=>(s[0]-r[0])*(i[1]-r[1])-(s[1]-r[1])*(i[0]-r[0]),n=[];for(let r of e){for(;n.length>=2&&t(n[n.length-2],n[n.length-1],r)<=0;)n.pop();n.push(r)}let a=[];for(let r=e.length-1;r>=0;r--){let s=e[r];for(;a.length>=2&&t(a[a.length-2],a[a.length-1],s)<=0;)a.pop();a.push(s)}return a.pop(),n.pop(),n.concat(a)}function Y4(c,e,t,n){return c<1e-9?3:e>0?Math.max(Math.floor(e),3):Math.max(Math.ceil(Math.min(360/t,c*2*Math.PI/n)),5)}function v3(c,e,t){let n=[];for(let a=0;a<t;a++){let r=2*Math.PI*a/t;n.push([c*Math.cos(r),e*Math.sin(r)])}return n}function K4(c,e,t,n){if(t=Math.min(t,c/2,e/2),t<=0)return[[0,0],[c,0],[c,e],[0,e]];let a=Math.max(1,Math.ceil(n(t)/4)),r=[],s=[[c-t,t,-90],[c-t,e-t,0],[t,e-t,90],[t,t,180]];for(let[i,l,o]of s)for(let h=0;h<=a;h++){let f=(o+90*h/a)*Math.PI/180;r.push([i+t*Math.cos(f),l+t*Math.sin(f)])}return r}function g3(c,e){let t=Math.round(c/e);return t%2===0&&(t+=c/e>t?1:-1),Math.max(3,t)}var R2=(c,e,t,n)=>[[c,e],[t,e],[t,n],[c,n]];function x9(c,e,t,n){if(e==="flat")return[];let a=g3(c,n),r=c/a,s=[];for(let i=0;i<a;i++)(e==="out"?i%2===1:i%2===0)&&s.push(R2(i*r,-1,(i+1)*r,t));return s}function J4(c,e,t,n,a){let r=[([l,o])=>[l,o],([l,o])=>[c-o,l],([l,o])=>[c-l,e-o],([l,o])=>[o,e-l]],s=[c,e,c,e],i=[];return t.forEach((l,o)=>{for(let h of x9(s[o],l,n,a))i.push(h.map(r[o]))}),Q1([R2(0,0,c,e)],i)}function Q4(c,e,t,n){let a=g3(c,n),r=c/a,s=[];for(let i=0;i<a;i++)(e==="out"?i%2===0:i%2===1)&&s.push(R2(i*r,-t/2,(i+1)*r,t/2));return s}function e6(c,e,t,n,a){let r=R2(-c/2,-1,c/2,e),s=R2(-t/2,a,t/2,a+n);return[r,s]}function t6(c,e,t,n,a){let r=[],s=a+n,i=Math.floor(c/t),l=(c-i*t)/2;for(let o=0;o<=i;o++){let h=l+o*t,f=o%2===0?n:n-s/2;for(let u=f;u<e;u+=s){let d=Math.max(u,o%2===0?n:0),p=Math.min(u+a,e-(o%2===0?n:0));p-d>=n/2&&r.push([[h,d],[h,p]])}}return r}var c6=Math.PI/180;function F1(c,e){let t=new Array(16).fill(0);for(let n=0;n<4;n++)for(let a=0;a<4;a++)for(let r=0;r<4;r++)t[n*4+a]+=c[n*4+r]*e[r*4+a];return t}function y3(c,e){let t=Math.cos(e*c6),n=Math.sin(e*c6);return c===0?[1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1]:c===1?[t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1]:[t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1]}var y5=c=>Math.abs(c)<1e-12?0:c;function h0(c){if(c.matrix)return c.matrix.map(y5);let[e,t,n]=c.rotate,a=F1(y3(2,n),F1(y3(1,t),y3(0,e)));return a[3]=c.at[0],a[7]=c.at[1],a[11]=c.at[2],a.map(y5)}function M3(c,e,t,n){return[c[0]*e+c[1]*t+c[2]*n+c[3],c[4]*e+c[5]*t+c[6]*n+c[7],c[8]*e+c[9]*t+c[10]*n+c[11]]}function s6(c){let[e,t,n]=[c[3],c[7],c[11]],a=[c[0],c[4],c[8],c[1],c[5],c[9],c[2],c[6],c[10]];return[a[0],a[1],a[2],-(a[0]*e+a[1]*t+a[2]*n),a[3],a[4],a[5],-(a[3]*e+a[4]*t+a[5]*n),a[6],a[7],a[8],-(a[6]*e+a[7]*t+a[8]*n),0,0,0,1]}function x3(c){let[e,t,n,a]=[1/0,1/0,-1/0,-1/0];for(let r of c)for(let[s,i]of r)e=Math.min(e,s),t=Math.min(t,i),n=Math.max(n,s),a=Math.max(a,i);return[e,t,n,a]}function U2(c){let[e,t,n,a]=x3(c.outline),r=[1/0,1/0,1/0],s=[-1/0,-1/0,-1/0];for(let i of[e,n])for(let l of[t,a])for(let o of[0,c.thickness]){let h=M3(c.matrix,i,l,o);for(let f=0;f<3;f++)r[f]=Math.min(r[f],h[f]),s[f]=Math.max(s[f],h[f])}return[r,s]}function i6(c,e,t=10){let n=[1/0,1/0,1/0],a=[-1/0,-1/0,-1/0];for(let[h,f]of c.map(U2))for(let u=0;u<3;u++)n[u]=Math.min(n[u],h[u]),a[u]=Math.max(a[u],f[u]);let r=e.map(h=>x3(h.outline)),s=r.reduce((h,[f,,u])=>Math.max(h,u-f),a[0]-n[0]),i=0,l=0,o=0;return e.map((h,f)=>{let[u,d,p,m]=r[f];i>0&&i+p-u>s&&(i=0,l+=o+t,o=0);let v=[1,0,0,a[0]+t+i-u,0,1,0,n[1]+l-d,0,0,1,n[2],0,0,0,1];return i+=p-u+t,o=Math.max(o,m-d),{...h,matrix:v.map(y5)}})}var b9=(c,e,t)=>[0,1,2].every(n=>c[0][n]<e[1][n]-t&&e[0][n]<c[1][n]-t),d2=(c,e)=>c[0]*e[0]+c[1]*e[1]+c[2]*e[2],M5=(c,e)=>[c[1]*e[2]-c[2]*e[1],c[2]*e[0]-c[0]*e[2],c[0]*e[1]-c[1]*e[0]],n6=(c,e,t=1)=>[c[0]+e[0]*t,c[1]+e[1]*t,c[2]+e[2]*t],b3=c=>[c[2],c[6],c[10]],a6=c=>[c[3],c[7],c[11]],z9=(c,e)=>[c[0]*e[0]+c[1]*e[1]+c[2]*e[2],c[4]*e[0]+c[5]*e[1]+c[6]*e[2],c[8]*e[0]+c[9]*e[1]+c[10]*e[2]];function p2(c,e,t){let n=t[0]*t[0]+t[1]*t[1],a=[];for(let r of c)for(let s=0,i=r.length-1;s<r.length;i=s++){let l=r[i],o=r[s],h=t[0]*(l[1]-e[1])-t[1]*(l[0]-e[0]),f=t[0]*(o[1]-e[1])-t[1]*(o[0]-e[0]);if(h>0==f>0)continue;let u=h/(h-f),d=l[0]+(o[0]-l[0])*u-e[0],p=l[1]+(o[1]-l[1])*u-e[1];a.push((d*t[0]+p*t[1])/n)}return a.sort((r,s)=>r-s)}function x5(c,e,t){let n=0,a=0,r=0;for(;a+1<c.length&&r+1<e.length;){let s=Math.min(c[a+1],e[r+1])-Math.max(c[a],e[r]);s>t&&(n+=s),c[a+1]<e[r+1]?a+=2:r+=2}return n}function z3(c,e,t,n){let a=c+t,r=e-t;if(r<=a)return{at:[],size:0};let s=Math.max(4,Math.ceil((r-a)/n));return{at:Array.from({length:s},(i,l)=>a+(r-a)*(l+.5)/s),size:(r-a)/s}}function r6(c,e,t){let n=M3(c,e[0],e[1],e[2]),a=z9(c,t);return[[n[0],n[1]],[a[0],a[1]]]}function w9(c,e,t,n,a,r,s){let i=b3(c.matrix),l=b3(e.matrix),o=M5(i,l),h=Math.hypot(...o),f=[o[0]/h,o[1]/h,o[2]/h],u=M5(f,i),d=d2(l,u),p=a6(c.matrix),m=d2(l,a6(e.matrix)),v=1/0,g=-1/0;for(let E of e.outline)for(let[k,C]of E)for(let P of[0,e.thickness]){let w=M3(e.matrix,k,C,P),I=d2(i,[w[0]-p[0],w[1]-p[1],w[2]-p[2]]);I<v&&(v=I),I>g&&(g=I)}let y=z3(Math.max(0,v),Math.min(c.thickness,g),a,r),M=1/0,A=-1/0;for(let E of c.outline)for(let[k,C]of E){let P=M3(c.matrix,k,C,0),w=d2(u,[P[0]-p[0],P[1]-p[1],P[2]-p[2]]);w<M&&(M=w),w>A&&(A=w)}let z=0;for(let E of y.at){let k=n6(p,i,E),C=(m-d2(l,k))/d,P=(m+e.thickness-d2(l,k))/d,w=z3(Math.max(M,Math.min(C,P)),Math.min(A,Math.max(C,P)),a,r);for(let I of w.at){let B=n6(k,u,I),[F,G]=r6(t,B,f),[X,q]=r6(n,B,f);if(z+=x5(p2(c.outline,F,G),p2(e.outline,X,q),a)*y.size*w.size,z>s)return!0}}return!1}function k9(c,e,t,n,a,r){let s=[0,1,2,3].flatMap(k=>[0,1,2,3].map(C=>{let P=0;for(let w=0;w<4;w++)P+=t[k*4+w]*e.matrix[w*4+C];return P})),i=s[11],l=s[11]+s[10]*e.thickness,o=Math.min(c.thickness,Math.max(i,l))-Math.max(0,Math.min(i,l));if(o<=n)return!1;let h=e.outline.map(k=>k.map(([C,P])=>[s[0]*C+s[1]*P+s[3],s[4]*C+s[5]*P+s[7]])),[f,u,d,p]=x3(c.outline),[m,v,g,y]=x3(h),M=z3(Math.max(u,v),Math.min(p,y),n,a),A=0;for(let k of M.at)if(A+=x5(p2(c.outline,[0,k],[1,0]),p2(h,[0,k],[1,0]),n)*M.size*o,A>r)return!0;let z=z3(Math.max(f,m),Math.min(d,g),n,a),E=0;for(let k of z.at)if(E+=x5(p2(c.outline,[k,0],[0,1]),p2(h,[k,0],[0,1]),n)*z.size*o,E>r)return!0;return!1}function l6(c,e=1/0,t=.05,n=.25,a=.1){let r=c.map(U2),s=c.map(h=>s6(h.matrix)),i=c.map((h,f)=>f).sort((h,f)=>r[h][0][0]-r[f][0][0]),l=[],o=0;for(let h=0;h<i.length;h++)for(let f=h+1;f<i.length;f++){let u=i[h],d=i[f];if(r[d][0][0]>=r[u][1][0]-t)break;if(!b9(r[u],r[d],t))continue;if(++o>e)return{found:l,complete:!1};let[p,m]=u<d?[c[u],c[d]]:[c[d],c[u]],[v,g]=u<d?[s[u],s[d]]:[s[d],s[u]];(Math.hypot(...M5(b3(p.matrix),b3(m.matrix)))<1e-9?k9(p,m,v,t,n,a):w9(p,m,v,g,t,n,a))&&l.push([p,m])}return{found:l,complete:!0}}function I0(c,e,t){return[1,0,0,c,0,1,0,e,0,0,1,t,0,0,0,1]}var b5=I0(0,0,0);function w3(c){return s6(c)}function L9(c,e,t=c.angle,n=c.x1){let a=n-c.x0;if(!t||!(a>0))return I0(0,0,0);let r=(c.x1-c.x0)/(c.angle*Math.PI/180),s=e/2+r;return F1(I0(c.x0,0,s),F1(y3(1,-t),I0(-c.x0-a,0,-s)))}function z5(c){return[...c].sort((e,t)=>e.x0-t.x0)}function w5(c,e){let t=[I0(0,0,0)];for(let n of z5(c))t.push(F1(t[t.length-1],L9(n,e)));return t}function o6(c,e){return z5(c).filter(t=>(t.x0+t.x1)/2<e).length}function k3(c){if(!c.bends?.length)return[c];let e=z5(c.bends),t=w5(e,c.thickness),n=1e7,a=[];for(let r=0;r<=e.length;r++){let s=r===0?-n:e[r-1].x1,i=r===e.length?n:e[r].x0;if(!(i>s))continue;let l=[[s,-n],[i,-n],[i,n],[s,n]],o=Z1(c.outline,[l]);o.length&&a.push({...c,outline:o,bends:void 0,matrix:F1(c.matrix,t[r])})}return a}var k5={dowel:{color:"#e2c48f",doc:"a wooden dowel or axle"},steel:{color:"#a7adb3",metal:!0,doc:"a steel rod, pin or axle"},brass:{color:"#c9a227",metal:!0,doc:"a brass rod, tube or pin"},screw:{color:"#9aa0a6",metal:!0,doc:"a screw"},bolt:{color:"#9aa0a6",metal:!0,doc:"a bolt"},nut:{color:"#9aa0a6",metal:!0,doc:"a nut"},magnet:{color:"#55585c",metal:!0,doc:"a disc or block magnet"},paper:{color:"#fbfaf6",doc:"a sheet or strip of paper"},card:{color:"#f4f1e8",doc:"card stock"},felt:{color:"#6f6a64",doc:"felt pads or lining"},elastic:{color:"#262626",doc:"an elastic band or cord"},cord:{color:"#b23a3a",doc:"cord, string or thread"},ribbon:{color:"#c2485a",doc:"ribbon or tape"},wire:{color:"#b87333",metal:!0,doc:"wire"},led:{color:"#fff4c2",glow:!0,doc:"an LED or a strip of them"},white:{color:"#f7f7f4",doc:"anything white"}},h6={pink:"#f2a7c3",yellow:"#f5d76e",red:"#d9534f",green:"#6dbb6d",blue:"#5b8fd9",orange:"#f0a04b",purple:"#9b72cf",black:"#222222",grey:"#9a9a9a",gray:"#9a9a9a"};String.prototype.codePointAt||(function(){var c=(function(){try{var t={},n=Object.defineProperty,a=n(t,t,t)&&n}catch{}return a})(),e=function(t){if(this==null)throw TypeError();var n=String(this),a=n.length,r=t?Number(t):0;if(r!=r&&(r=0),!(r<0||r>=a)){var s=n.charCodeAt(r),i;return s>=55296&&s<=56319&&a>r+1&&(i=n.charCodeAt(r+1),i>=56320&&i<=57343)?(s-55296)*1024+i-56320+65536:s}};c?c(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e})();var $5=0,J6=-3;function B2(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function S9(c,e){this.source=c,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=e,this.destLen=0,this.ltree=new B2,this.dtree=new B2}var Q6=new B2,e7=new B2,G5=new Uint8Array(30),_5=new Uint16Array(30),t7=new Uint8Array(30),c7=new Uint16Array(30),A9=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),d6=new B2,b0=new Uint8Array(320);function n7(c,e,t,n){var a,r;for(a=0;a<t;++a)c[a]=0;for(a=0;a<30-t;++a)c[a+t]=a/t|0;for(r=n,a=0;a<30;++a)e[a]=r,r+=1<<c[a]}function C9(c,e){var t;for(t=0;t<7;++t)c.table[t]=0;for(c.table[7]=24,c.table[8]=152,c.table[9]=112,t=0;t<24;++t)c.trans[t]=256+t;for(t=0;t<144;++t)c.trans[24+t]=t;for(t=0;t<8;++t)c.trans[168+t]=280+t;for(t=0;t<112;++t)c.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 p6=new Uint16Array(16);function L5(c,e,t,n){var a,r;for(a=0;a<16;++a)c.table[a]=0;for(a=0;a<n;++a)c.table[e[t+a]]++;for(c.table[0]=0,r=0,a=0;a<16;++a)p6[a]=r,r+=c.table[a];for(a=0;a<n;++a)e[t+a]&&(c.trans[p6[e[t+a]]++]=a)}function P9(c){c.bitcount--||(c.tag=c.source[c.sourceIndex++],c.bitcount=7);var e=c.tag&1;return c.tag>>>=1,e}function z0(c,e,t){if(!e)return t;for(;c.bitcount<24;)c.tag|=c.source[c.sourceIndex++]<<c.bitcount,c.bitcount+=8;var n=c.tag&65535>>>16-e;return c.tag>>>=e,c.bitcount-=e,n+t}function V5(c,e){for(;c.bitcount<24;)c.tag|=c.source[c.sourceIndex++]<<c.bitcount,c.bitcount+=8;var t=0,n=0,a=0,r=c.tag;do n=2*n+(r&1),r>>>=1,++a,t+=e.table[a],n-=e.table[a];while(n>=0);return c.tag=r,c.bitcount-=a,e.trans[t+n]}function E9(c,e,t){var n,a,r,s,i,l;for(n=z0(c,5,257),a=z0(c,5,1),r=z0(c,4,4),s=0;s<19;++s)b0[s]=0;for(s=0;s<r;++s){var o=z0(c,3,0);b0[A9[s]]=o}for(L5(d6,b0,0,19),i=0;i<n+a;){var h=V5(c,d6);switch(h){case 16:var f=b0[i-1];for(l=z0(c,2,3);l;--l)b0[i++]=f;break;case 17:for(l=z0(c,3,3);l;--l)b0[i++]=0;break;case 18:for(l=z0(c,7,11);l;--l)b0[i++]=0;break;default:b0[i++]=h;break}}L5(e,b0,0,n),L5(t,b0,n,a)}function m6(c,e,t){for(;;){var n=V5(c,e);if(n===256)return $5;if(n<256)c.dest[c.destLen++]=n;else{var a,r,s,i;for(n-=257,a=z0(c,G5[n],_5[n]),r=V5(c,t),s=c.destLen-z0(c,t7[r],c7[r]),i=s;i<s+a;++i)c.dest[c.destLen++]=c.dest[i]}}}function T9(c){for(var e,t,n;c.bitcount>8;)c.sourceIndex--,c.bitcount-=8;if(e=c.source[c.sourceIndex+1],e=256*e+c.source[c.sourceIndex],t=c.source[c.sourceIndex+3],t=256*t+c.source[c.sourceIndex+2],e!==(~t&65535))return J6;for(c.sourceIndex+=4,n=e;n;--n)c.dest[c.destLen++]=c.source[c.sourceIndex++];return c.bitcount=0,$5}function I9(c,e){var t=new S9(c,e),n,a,r;do{switch(n=P9(t),a=z0(t,2,0),a){case 0:r=T9(t);break;case 1:r=m6(t,Q6,e7);break;case 2:E9(t,t.ltree,t.dtree),r=m6(t,t.ltree,t.dtree);break;default:r=J6}if(r!==$5)throw new Error("Data error")}while(!n);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}C9(Q6,e7);n7(G5,_5,4,3);n7(t7,c7,2,1);G5[28]=0;_5[28]=258;var H9=I9;function m2(c,e,t,n,a){return Math.pow(1-a,3)*c+3*Math.pow(1-a,2)*a*e+3*(1-a)*Math.pow(a,2)*t+Math.pow(a,3)*n}function j0(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}j0.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)};j0.prototype.addPoint=function(c,e){typeof c=="number"&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=c,this.x2=c),c<this.x1&&(this.x1=c),c>this.x2&&(this.x2=c)),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))};j0.prototype.addX=function(c){this.addPoint(c,null)};j0.prototype.addY=function(c){this.addPoint(null,c)};j0.prototype.addBezier=function(c,e,t,n,a,r,s,i){var l=[c,e],o=[t,n],h=[a,r],f=[s,i];this.addPoint(c,e),this.addPoint(s,i);for(var u=0;u<=1;u++){var d=6*l[u]-12*o[u]+6*h[u],p=-3*l[u]+9*o[u]-9*h[u]+3*f[u],m=3*o[u]-3*l[u];if(p===0){if(d===0)continue;var v=-m/d;0<v&&v<1&&(u===0&&this.addX(m2(l[u],o[u],h[u],f[u],v)),u===1&&this.addY(m2(l[u],o[u],h[u],f[u],v)));continue}var g=Math.pow(d,2)-4*m*p;if(!(g<0)){var y=(-d+Math.sqrt(g))/(2*p);0<y&&y<1&&(u===0&&this.addX(m2(l[u],o[u],h[u],f[u],y)),u===1&&this.addY(m2(l[u],o[u],h[u],f[u],y)));var M=(-d-Math.sqrt(g))/(2*p);0<M&&M<1&&(u===0&&this.addX(m2(l[u],o[u],h[u],f[u],M)),u===1&&this.addY(m2(l[u],o[u],h[u],f[u],M)))}}};j0.prototype.addQuad=function(c,e,t,n,a,r){var s=c+.6666666666666666*(t-c),i=e+2/3*(n-e),l=s+1/3*(a-c),o=i+1/3*(r-e);this.addBezier(c,e,s,i,l,o,a,r)};function P1(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}P1.prototype.moveTo=function(c,e){this.commands.push({type:"M",x:c,y:e})};P1.prototype.lineTo=function(c,e){this.commands.push({type:"L",x:c,y:e})};P1.prototype.curveTo=P1.prototype.bezierCurveTo=function(c,e,t,n,a,r){this.commands.push({type:"C",x1:c,y1:e,x2:t,y2:n,x:a,y:r})};P1.prototype.quadTo=P1.prototype.quadraticCurveTo=function(c,e,t,n){this.commands.push({type:"Q",x1:c,y1:e,x:t,y:n})};P1.prototype.close=P1.prototype.closePath=function(){this.commands.push({type:"Z"})};P1.prototype.extend=function(c){if(c.commands)c=c.commands;else if(c instanceof j0){var e=c;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,c)};P1.prototype.getBoundingBox=function(){for(var c=new j0,e=0,t=0,n=0,a=0,r=0;r<this.commands.length;r++){var s=this.commands[r];switch(s.type){case"M":c.addPoint(s.x,s.y),e=n=s.x,t=a=s.y;break;case"L":c.addPoint(s.x,s.y),n=s.x,a=s.y;break;case"Q":c.addQuad(n,a,s.x1,s.y1,s.x,s.y),n=s.x,a=s.y;break;case"C":c.addBezier(n,a,s.x1,s.y1,s.x2,s.y2,s.x,s.y),n=s.x,a=s.y;break;case"Z":n=e,a=t;break;default:throw new Error("Unexpected path command "+s.type)}}return c.isEmpty()&&c.addPoint(0,0),c};P1.prototype.draw=function(c){c.beginPath();for(var e=0;e<this.commands.length;e+=1){var t=this.commands[e];t.type==="M"?c.moveTo(t.x,t.y):t.type==="L"?c.lineTo(t.x,t.y):t.type==="C"?c.bezierCurveTo(t.x1,t.y1,t.x2,t.y2,t.x,t.y):t.type==="Q"?c.quadraticCurveTo(t.x1,t.y1,t.x,t.y):t.type==="Z"&&c.closePath()}this.fill&&(c.fillStyle=this.fill,c.fill()),this.stroke&&(c.strokeStyle=this.stroke,c.lineWidth=this.strokeWidth,c.stroke())};P1.prototype.toPathData=function(c){c=c!==void 0?c:2;function e(s){return Math.round(s)===s?""+Math.round(s):s.toFixed(c)}function t(){for(var s=arguments,i="",l=0;l<arguments.length;l+=1){var o=s[l];o>=0&&l>0&&(i+=" "),i+=e(o)}return i}for(var n="",a=0;a<this.commands.length;a+=1){var r=this.commands[a];r.type==="M"?n+="M"+t(r.x,r.y):r.type==="L"?n+="L"+t(r.x,r.y):r.type==="C"?n+="C"+t(r.x1,r.y1,r.x2,r.y2,r.x,r.y):r.type==="Q"?n+="Q"+t(r.x1,r.y1,r.x,r.y):r.type==="Z"&&(n+="Z")}return n};P1.prototype.toSVG=function(c){var e='<path d="';return e+=this.toPathData(c),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};P1.prototype.toDOMElement=function(c){var e=this.toPathData(c),t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("d",e),t};function a7(c){throw new Error(c)}function v6(c,e){c||a7(e)}var W={fail:a7,argument:v6,assert:v6},g6=32768,y6=2147483648,g2={},H={},Y={};function p0(c){return function(){return c}}H.BYTE=function(c){return W.argument(c>=0&&c<=255,"Byte value should be between 0 and 255."),[c]};Y.BYTE=p0(1);H.CHAR=function(c){return[c.charCodeAt(0)]};Y.CHAR=p0(1);H.CHARARRAY=function(c){typeof c>"u"&&(c="",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<c.length;t+=1)e[t]=c.charCodeAt(t);return e};Y.CHARARRAY=function(c){return typeof c>"u"?0:c.length};H.USHORT=function(c){return[c>>8&255,c&255]};Y.USHORT=p0(2);H.SHORT=function(c){return c>=g6&&(c=-(2*g6-c)),[c>>8&255,c&255]};Y.SHORT=p0(2);H.UINT24=function(c){return[c>>16&255,c>>8&255,c&255]};Y.UINT24=p0(3);H.ULONG=function(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]};Y.ULONG=p0(4);H.LONG=function(c){return c>=y6&&(c=-(2*y6-c)),[c>>24&255,c>>16&255,c>>8&255,c&255]};Y.LONG=p0(4);H.FIXED=H.ULONG;Y.FIXED=Y.ULONG;H.FWORD=H.SHORT;Y.FWORD=Y.SHORT;H.UFWORD=H.USHORT;Y.UFWORD=Y.USHORT;H.LONGDATETIME=function(c){return[0,0,0,0,c>>24&255,c>>16&255,c>>8&255,c&255]};Y.LONGDATETIME=p0(8);H.TAG=function(c){return W.argument(c.length===4,"Tag should be exactly 4 ASCII characters."),[c.charCodeAt(0),c.charCodeAt(1),c.charCodeAt(2),c.charCodeAt(3)]};Y.TAG=p0(4);H.Card8=H.BYTE;Y.Card8=Y.BYTE;H.Card16=H.USHORT;Y.Card16=Y.USHORT;H.OffSize=H.BYTE;Y.OffSize=Y.BYTE;H.SID=H.USHORT;Y.SID=Y.USHORT;H.NUMBER=function(c){return c>=-107&&c<=107?[c+139]:c>=108&&c<=1131?(c=c-108,[(c>>8)+247,c&255]):c>=-1131&&c<=-108?(c=-c-108,[(c>>8)+251,c&255]):c>=-32768&&c<=32767?H.NUMBER16(c):H.NUMBER32(c)};Y.NUMBER=function(c){return H.NUMBER(c).length};H.NUMBER16=function(c){return[28,c>>8&255,c&255]};Y.NUMBER16=p0(3);H.NUMBER32=function(c){return[29,c>>24&255,c>>16&255,c>>8&255,c&255]};Y.NUMBER32=p0(5);H.REAL=function(c){var e=c.toString(),t=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(e);if(t){var n=parseFloat("1e"+((t[2]?+t[2]:0)+t[1].length));e=(Math.round(c*n)/n).toString()}for(var a="",r=0,s=e.length;r<s;r+=1){var i=e[r];i==="e"?a+=e[++r]==="-"?"c":"b":i==="."?a+="a":i==="-"?a+="e":a+=i}a+=a.length&1?"f":"ff";for(var l=[30],o=0,h=a.length;o<h;o+=2)l.push(parseInt(a.substr(o,2),16));return l};Y.REAL=function(c){return H.REAL(c).length};H.NAME=H.CHARARRAY;Y.NAME=Y.CHARARRAY;H.STRING=H.CHARARRAY;Y.STRING=Y.CHARARRAY;g2.UTF8=function(c,e,t){for(var n=[],a=t,r=0;r<a;r++,e+=1)n[r]=c.getUint8(e);return String.fromCharCode.apply(null,n)};g2.UTF16=function(c,e,t){for(var n=[],a=t/2,r=0;r<a;r++,e+=2)n[r]=c.getUint16(e);return String.fromCharCode.apply(null,n)};H.UTF16=function(c){for(var e=[],t=0;t<c.length;t+=1){var n=c.charCodeAt(t);e[e.length]=n>>8&255,e[e.length]=n&255}return e};Y.UTF16=function(c){return c.length*2};var O5={"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"};g2.MACSTRING=function(c,e,t,n){var a=O5[n];if(a!==void 0){for(var r="",s=0;s<t;s++){var i=c.getUint8(e+s);i<=127?r+=String.fromCharCode(i):r+=a[i&127]}return r}};var L3=typeof WeakMap=="function"&&new WeakMap,S3,V9=function(c){if(!S3){S3={};for(var e in O5)S3[e]=new String(e)}var t=S3[c];if(t!==void 0){if(L3){var n=L3.get(t);if(n!==void 0)return n}var a=O5[c];if(a!==void 0){for(var r={},s=0;s<a.length;s++)r[a.charCodeAt(s)]=s+128;return L3&&L3.set(t,r),r}}};H.MACSTRING=function(c,e){var t=V9(e);if(t!==void 0){for(var n=[],a=0;a<c.length;a++){var r=c.charCodeAt(a);if(r>=128&&(r=t[r],r===void 0))return;n[a]=r}return n}};Y.MACSTRING=function(c,e){var t=H.MACSTRING(c,e);return t!==void 0?t.length:0};function F5(c){return c>=-128&&c<=127}function O9(c,e,t){for(var n=0,a=c.length;e<a&&n<64&&c[e]===0;)++e,++n;return t.push(128|n-1),e}function F9(c,e,t){for(var n=0,a=c.length,r=e;r<a&&n<64;){var s=c[r];if(!F5(s)||s===0&&r+1<a&&c[r+1]===0)break;++r,++n}t.push(n-1);for(var i=e;i<r;++i)t.push(c[i]+256&255);return r}function D9(c,e,t){for(var n=0,a=c.length,r=e;r<a&&n<64;){var s=c[r];if(s===0||F5(s)&&r+1<a&&F5(c[r+1]))break;++r,++n}t.push(64|n-1);for(var i=e;i<r;++i){var l=c[i];t.push(l+65536>>8&255,l+256&255)}return r}H.VARDELTAS=function(c){for(var e=0,t=[];e<c.length;){var n=c[e];n===0?e=O9(c,e,t):n>=-128&&n<=127?e=F9(c,e,t):e=D9(c,e,t)}return t};H.INDEX=function(c){for(var e=1,t=[e],n=[],a=0;a<c.length;a+=1){var r=H.OBJECT(c[a]);Array.prototype.push.apply(n,r),e+=r.length,t.push(e)}if(n.length===0)return[0,0];for(var s=[],i=1+Math.floor(Math.log(e)/Math.log(2))/8|0,l=[void 0,H.BYTE,H.USHORT,H.UINT24,H.ULONG][i],o=0;o<t.length;o+=1){var h=l(t[o]);Array.prototype.push.apply(s,h)}return Array.prototype.concat(H.Card16(c.length),H.OffSize(i),s,n)};Y.INDEX=function(c){return H.INDEX(c).length};H.DICT=function(c){for(var e=[],t=Object.keys(c),n=t.length,a=0;a<n;a+=1){var r=parseInt(t[a],0),s=c[r];e=e.concat(H.OPERAND(s.value,s.type)),e=e.concat(H.OPERATOR(r))}return e};Y.DICT=function(c){return H.DICT(c).length};H.OPERATOR=function(c){return c<1200?[c]:[12,c-1200]};H.OPERAND=function(c,e){var t=[];if(Array.isArray(e))for(var n=0;n<e.length;n+=1)W.argument(c.length===e.length,"Not enough arguments given for type"+e),t=t.concat(H.OPERAND(c[n],e[n]));else if(e==="SID")t=t.concat(H.NUMBER(c));else if(e==="offset")t=t.concat(H.NUMBER32(c));else if(e==="number")t=t.concat(H.NUMBER(c));else if(e==="real")t=t.concat(H.REAL(c));else throw new Error("Unknown operand type "+e);return t};H.OP=H.BYTE;Y.OP=Y.BYTE;var A3=typeof WeakMap=="function"&&new WeakMap;H.CHARSTRING=function(c){if(A3){var e=A3.get(c);if(e!==void 0)return e}for(var t=[],n=c.length,a=0;a<n;a+=1){var r=c[a];t=t.concat(H[r.type](r.value))}return A3&&A3.set(c,t),t};Y.CHARSTRING=function(c){return H.CHARSTRING(c).length};H.OBJECT=function(c){var e=H[c.type];return W.argument(e!==void 0,"No encoding function for type "+c.type),e(c.value)};Y.OBJECT=function(c){var e=Y[c.type];return W.argument(e!==void 0,"No sizeOf function for type "+c.type),e(c.value)};H.TABLE=function(c){for(var e=[],t=c.fields.length,n=[],a=[],r=0;r<t;r+=1){var s=c.fields[r],i=H[s.type];W.argument(i!==void 0,"No encoding function for field type "+s.type+" ("+s.name+")");var l=c[s.name];l===void 0&&(l=s.value);var o=i(l);s.type==="TABLE"?(a.push(e.length),e=e.concat([0,0]),n.push(o)):e=e.concat(o)}for(var h=0;h<n.length;h+=1){var f=a[h],u=e.length;W.argument(u<65536,"Table "+c.tableName+" too big."),e[f]=u>>8,e[f+1]=u&255,e=e.concat(n[h])}return e};Y.TABLE=function(c){for(var e=0,t=c.fields.length,n=0;n<t;n+=1){var a=c.fields[n],r=Y[a.type];W.argument(r!==void 0,"No sizeOf function for field type "+a.type+" ("+a.name+")");var s=c[a.name];s===void 0&&(s=a.value),e+=r(s),a.type==="TABLE"&&(e+=2)}return e};H.RECORD=H.TABLE;Y.RECORD=Y.TABLE;H.LITERAL=function(c){return c};Y.LITERAL=function(c){return c.length};function D1(c,e,t){if(e.length&&(e[0].name!=="coverageFormat"||e[0].value===1))for(var n=0;n<e.length;n+=1){var a=e[n];this[a.name]=a.value}if(this.tableName=c,this.fields=e,t)for(var r=Object.keys(t),s=0;s<r.length;s+=1){var i=r[s],l=t[i];this[i]!==void 0&&(this[i]=l)}}D1.prototype.encode=function(){return H.TABLE(this)};D1.prototype.sizeOf=function(){return Y.TABLE(this)};function $2(c,e,t){t===void 0&&(t=e.length);var n=new Array(e.length+1);n[0]={name:c+"Count",type:"USHORT",value:t};for(var a=0;a<e.length;a++)n[a+1]={name:c+a,type:"USHORT",value:e[a]};return n}function D5(c,e,t){var n=e.length,a=new Array(n+1);a[0]={name:c+"Count",type:"USHORT",value:n};for(var r=0;r<n;r++)a[r+1]={name:c+r,type:"TABLE",value:t(e[r],r)};return a}function G2(c,e,t){var n=e.length,a=[];a[0]={name:c+"Count",type:"USHORT",value:n};for(var r=0;r<n;r++)a=a.concat(t(e[r],r));return a}function I3(c){c.format===1?D1.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat($2("glyph",c.glyphs))):c.format===2?D1.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:2}].concat(G2("rangeRecord",c.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}]}))):W.assert(!1,"Coverage format must be 1 or 2.")}I3.prototype=Object.create(D1.prototype);I3.prototype.constructor=I3;function H3(c){D1.call(this,"scriptListTable",G2("scriptRecord",c,function(e,t){var n=e.script,a=n.defaultLangSys;return W.assert(!!a,"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 D1("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new D1("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:a.reqFeatureIndex}].concat($2("featureIndex",a.featureIndexes)))}].concat(G2("langSys",n.langSysRecords,function(r,s){var i=r.langSys;return[{name:"langSysTag"+s,type:"TAG",value:r.tag},{name:"langSys"+s,type:"TABLE",value:new D1("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:i.reqFeatureIndex}].concat($2("featureIndex",i.featureIndexes)))}]})))}]}))}H3.prototype=Object.create(D1.prototype);H3.prototype.constructor=H3;function V3(c){D1.call(this,"featureListTable",G2("featureRecord",c,function(e,t){var n=e.feature;return[{name:"featureTag"+t,type:"TAG",value:e.tag},{name:"feature"+t,type:"TABLE",value:new D1("featureTable",[{name:"featureParams",type:"USHORT",value:n.featureParams}].concat($2("lookupListIndex",n.lookupListIndexes)))}]}))}V3.prototype=Object.create(D1.prototype);V3.prototype.constructor=V3;function O3(c,e){D1.call(this,"lookupListTable",D5("lookup",c,function(t){var n=e[t.lookupType];return W.assert(!!n,"Unable to write GSUB lookup type "+t.lookupType+" tables."),new D1("lookupTable",[{name:"lookupType",type:"USHORT",value:t.lookupType},{name:"lookupFlag",type:"USHORT",value:t.lookupFlag}].concat(D5("subtable",t.subtables,n)))}))}O3.prototype=Object.create(D1.prototype);O3.prototype.constructor=O3;var O={Table:D1,Record:D1,Coverage:I3,ScriptList:H3,FeatureList:V3,LookupList:O3,ushortList:$2,tableList:D5,recordList:G2};function M6(c,e){return c.getUint8(e)}function F3(c,e){return c.getUint16(e,!1)}function R9(c,e){return c.getInt16(e,!1)}function j5(c,e){return c.getUint32(e,!1)}function r7(c,e){var t=c.getInt16(e,!1),n=c.getUint16(e+2,!1);return t+n/65535}function U9(c,e){for(var t="",n=e;n<e+4;n+=1)t+=String.fromCharCode(c.getInt8(n));return t}function q9(c,e,t){for(var n=0,a=0;a<t;a+=1)n<<=8,n+=c.getUint8(e+a);return n}function N9(c,e,t){for(var n=[],a=e;a<t;a+=1)n.push(c.getUint8(a));return n}function B9(c){for(var e="",t=0;t<c.length;t+=1)e+=String.fromCharCode(c[t]);return e}var $9={byte:1,uShort:2,short:2,uLong:4,fixed:4,longDateTime:8,tag:4};function L(c,e){this.data=c,this.offset=e,this.relativeOffset=0}L.prototype.parseByte=function(){var c=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,c};L.prototype.parseChar=function(){var c=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,c};L.prototype.parseCard8=L.prototype.parseByte;L.prototype.parseUShort=function(){var c=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,c};L.prototype.parseCard16=L.prototype.parseUShort;L.prototype.parseSID=L.prototype.parseUShort;L.prototype.parseOffset16=L.prototype.parseUShort;L.prototype.parseShort=function(){var c=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,c};L.prototype.parseF2Dot14=function(){var c=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,c};L.prototype.parseULong=function(){var c=j5(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,c};L.prototype.parseOffset32=L.prototype.parseULong;L.prototype.parseFixed=function(){var c=r7(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,c};L.prototype.parseString=function(c){var e=this.data,t=this.offset+this.relativeOffset,n="";this.relativeOffset+=c;for(var a=0;a<c;a++)n+=String.fromCharCode(e.getUint8(t+a));return n};L.prototype.parseTag=function(){return this.parseString(4)};L.prototype.parseLongDateTime=function(){var c=j5(this.data,this.offset+this.relativeOffset+4);return c-=2082844800,this.relativeOffset+=8,c};L.prototype.parseVersion=function(c){var e=F3(this.data,this.offset+this.relativeOffset),t=F3(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,c===void 0&&(c=4096),e+t/c/10};L.prototype.skip=function(c,e){e===void 0&&(e=1),this.relativeOffset+=$9[c]*e};L.prototype.parseULongList=function(c){c===void 0&&(c=this.parseULong());for(var e=new Array(c),t=this.data,n=this.offset+this.relativeOffset,a=0;a<c;a++)e[a]=t.getUint32(n),n+=4;return this.relativeOffset+=c*4,e};L.prototype.parseOffset16List=L.prototype.parseUShortList=function(c){c===void 0&&(c=this.parseUShort());for(var e=new Array(c),t=this.data,n=this.offset+this.relativeOffset,a=0;a<c;a++)e[a]=t.getUint16(n),n+=2;return this.relativeOffset+=c*2,e};L.prototype.parseShortList=function(c){for(var e=new Array(c),t=this.data,n=this.offset+this.relativeOffset,a=0;a<c;a++)e[a]=t.getInt16(n),n+=2;return this.relativeOffset+=c*2,e};L.prototype.parseByteList=function(c){for(var e=new Array(c),t=this.data,n=this.offset+this.relativeOffset,a=0;a<c;a++)e[a]=t.getUint8(n++);return this.relativeOffset+=c,e};L.prototype.parseList=function(c,e){e||(e=c,c=this.parseUShort());for(var t=new Array(c),n=0;n<c;n++)t[n]=e.call(this);return t};L.prototype.parseList32=function(c,e){e||(e=c,c=this.parseULong());for(var t=new Array(c),n=0;n<c;n++)t[n]=e.call(this);return t};L.prototype.parseRecordList=function(c,e){e||(e=c,c=this.parseUShort());for(var t=new Array(c),n=Object.keys(e),a=0;a<c;a++){for(var r={},s=0;s<n.length;s++){var i=n[s],l=e[i];r[i]=l.call(this)}t[a]=r}return t};L.prototype.parseRecordList32=function(c,e){e||(e=c,c=this.parseULong());for(var t=new Array(c),n=Object.keys(e),a=0;a<c;a++){for(var r={},s=0;s<n.length;s++){var i=n[s],l=e[i];r[i]=l.call(this)}t[a]=r}return t};L.prototype.parseStruct=function(c){if(typeof c=="function")return c.call(this);for(var e=Object.keys(c),t={},n=0;n<e.length;n++){var a=e[n],r=c[a];t[a]=r.call(this)}return t};L.prototype.parseValueRecord=function(c){if(c===void 0&&(c=this.parseUShort()),c!==0){var e={};return c&1&&(e.xPlacement=this.parseShort()),c&2&&(e.yPlacement=this.parseShort()),c&4&&(e.xAdvance=this.parseShort()),c&8&&(e.yAdvance=this.parseShort()),c&16&&(e.xPlaDevice=void 0,this.parseShort()),c&32&&(e.yPlaDevice=void 0,this.parseShort()),c&64&&(e.xAdvDevice=void 0,this.parseShort()),c&128&&(e.yAdvDevice=void 0,this.parseShort()),e}};L.prototype.parseValueRecordList=function(){for(var c=this.parseUShort(),e=this.parseUShort(),t=new Array(e),n=0;n<e;n++)t[n]=this.parseValueRecord(c);return t};L.prototype.parsePointer=function(c){var e=this.parseOffset16();if(e>0)return new L(this.data,this.offset+e).parseStruct(c)};L.prototype.parsePointer32=function(c){var e=this.parseOffset32();if(e>0)return new L(this.data,this.offset+e).parseStruct(c)};L.prototype.parseListOfLists=function(c){for(var e=this.parseOffset16List(),t=e.length,n=this.relativeOffset,a=new Array(t),r=0;r<t;r++){var s=e[r];if(s===0){a[r]=void 0;continue}if(this.relativeOffset=s,c){for(var i=this.parseOffset16List(),l=new Array(i.length),o=0;o<i.length;o++)this.relativeOffset=s+i[o],l[o]=c.call(this);a[r]=l}else a[r]=this.parseUShortList()}return this.relativeOffset=n,a};L.prototype.parseCoverage=function(){var c=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 n=new Array(t),a=0;a<t;a++)n[a]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:n}}throw new Error("0x"+c.toString(16)+": Coverage format must be 1 or 2.")};L.prototype.parseClassDef=function(){var c=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:L.uShort,end:L.uShort,classId:L.uShort})};throw new Error("0x"+c.toString(16)+": ClassDef format must be 1 or 2.")};L.list=function(c,e){return function(){return this.parseList(c,e)}};L.list32=function(c,e){return function(){return this.parseList32(c,e)}};L.recordList=function(c,e){return function(){return this.parseRecordList(c,e)}};L.recordList32=function(c,e){return function(){return this.parseRecordList32(c,e)}};L.pointer=function(c){return function(){return this.parsePointer(c)}};L.pointer32=function(c){return function(){return this.parsePointer32(c)}};L.tag=L.prototype.parseTag;L.byte=L.prototype.parseByte;L.uShort=L.offset16=L.prototype.parseUShort;L.uShortList=L.prototype.parseUShortList;L.uLong=L.offset32=L.prototype.parseULong;L.uLongList=L.prototype.parseULongList;L.struct=L.prototype.parseStruct;L.coverage=L.prototype.parseCoverage;L.classDef=L.prototype.parseClassDef;var x6={reserved:L.uShort,reqFeatureIndex:L.uShort,featureIndexes:L.uShortList};L.prototype.parseScriptList=function(){return this.parsePointer(L.recordList({tag:L.tag,script:L.pointer({defaultLangSys:L.pointer(x6),langSysRecords:L.recordList({tag:L.tag,langSys:L.pointer(x6)})})}))||[]};L.prototype.parseFeatureList=function(){return this.parsePointer(L.recordList({tag:L.tag,feature:L.pointer({featureParams:L.offset16,lookupListIndexes:L.uShortList})}))||[]};L.prototype.parseLookupList=function(c){return this.parsePointer(L.list(L.pointer(function(){var e=this.parseUShort();W.argument(1<=e&&e<=9,"GPOS/GSUB lookup type "+e+" unknown.");var t=this.parseUShort(),n=t&16;return{lookupType:e,lookupFlag:t,subtables:this.parseList(L.pointer(c[e])),markFilteringSet:n?this.parseUShort():void 0}})))||[]};L.prototype.parseFeatureVariationsList=function(){return this.parsePointer32(function(){var c=this.parseUShort(),e=this.parseUShort();W.argument(c===1&&e<1,"GPOS/GSUB feature variations table unknown.");var t=this.parseRecordList32({conditionSetOffset:L.offset32,featureTableSubstitutionOffset:L.offset32});return t})||[]};var U={getByte:M6,getCard8:M6,getUShort:F3,getCard16:F3,getShort:R9,getULong:j5,getFixed:r7,getTag:U9,getOffset:q9,getBytes:N9,bytesToString:B9,Parser:L};function G9(c,e){e.parseUShort(),c.length=e.parseULong(),c.language=e.parseULong();var t;c.groupCount=t=e.parseULong(),c.glyphIndexMap={};for(var n=0;n<t;n+=1)for(var a=e.parseULong(),r=e.parseULong(),s=e.parseULong(),i=a;i<=r;i+=1)c.glyphIndexMap[i]=s,s++}function _9(c,e,t,n,a){c.length=e.parseUShort(),c.language=e.parseUShort();var r;c.segCount=r=e.parseUShort()>>1,e.skip("uShort",3),c.glyphIndexMap={};for(var s=new U.Parser(t,n+a+14),i=new U.Parser(t,n+a+16+r*2),l=new U.Parser(t,n+a+16+r*4),o=new U.Parser(t,n+a+16+r*6),h=n+a+16+r*8,f=0;f<r-1;f+=1)for(var u=void 0,d=s.parseUShort(),p=i.parseUShort(),m=l.parseShort(),v=o.parseUShort(),g=p;g<=d;g+=1)v!==0?(h=o.offset+o.relativeOffset-2,h+=v,h+=(g-p)*2,u=U.getUShort(t,h),u!==0&&(u=u+m&65535)):u=g+m&65535,c.glyphIndexMap[g]=u}function j9(c,e){var t={};t.version=U.getUShort(c,e),W.argument(t.version===0,"cmap table version should be 0."),t.numTables=U.getUShort(c,e+2);for(var n=-1,a=t.numTables-1;a>=0;a-=1){var r=U.getUShort(c,e+4+a*8),s=U.getUShort(c,e+4+a*8+2);if(r===3&&(s===0||s===1||s===10)||r===0&&(s===0||s===1||s===2||s===3||s===4)){n=U.getULong(c,e+4+a*8+4);break}}if(n===-1)throw new Error("No valid cmap sub-tables found.");var i=new U.Parser(c,e+n);if(t.format=i.parseUShort(),t.format===12)G9(t,i);else if(t.format===4)_9(t,i,c,e,n);else throw new Error("Only format 4 and 12 cmap tables are supported (found format "+t.format+").");return t}function W9(c,e,t){c.segments.push({end:e,start:e,delta:-(e-t),offset:0,glyphIndex:t})}function X9(c){c.segments.push({end:65535,start:65535,delta:1,offset:0})}function Z9(c){var e=!0,t;for(t=c.length-1;t>0;t-=1){var n=c.get(t);if(n.unicode>65535){console.log("Adding CMAP format 12 (needed!)"),e=!1;break}}var a=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:e?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:e?12:20}];e||(a=a.concat([{name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}])),a=a.concat([{name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);var r=new O.Table("cmap",a);for(r.segments=[],t=0;t<c.length;t+=1){for(var s=c.get(t),i=0;i<s.unicodes.length;i+=1)W9(r,s.unicodes[i],t);r.segments=r.segments.sort(function(y,M){return y.start-M.start})}X9(r);var l=r.segments.length,o=0,h=[],f=[],u=[],d=[],p=[],m=[];for(t=0;t<l;t+=1){var v=r.segments[t];v.end<=65535&&v.start<=65535?(h=h.concat({name:"end_"+t,type:"USHORT",value:v.end}),f=f.concat({name:"start_"+t,type:"USHORT",value:v.start}),u=u.concat({name:"idDelta_"+t,type:"SHORT",value:v.delta}),d=d.concat({name:"idRangeOffset_"+t,type:"USHORT",value:v.offset}),v.glyphId!==void 0&&(p=p.concat({name:"glyph_"+t,type:"USHORT",value:v.glyphId}))):o+=1,!e&&v.glyphIndex!==void 0&&(m=m.concat({name:"cmap12Start_"+t,type:"ULONG",value:v.start}),m=m.concat({name:"cmap12End_"+t,type:"ULONG",value:v.end}),m=m.concat({name:"cmap12Glyph_"+t,type:"ULONG",value:v.glyphIndex}))}if(r.segCountX2=(l-o)*2,r.searchRange=Math.pow(2,Math.floor(Math.log(l-o)/Math.log(2)))*2,r.entrySelector=Math.log(r.searchRange/2)/Math.log(2),r.rangeShift=r.segCountX2-r.searchRange,r.fields=r.fields.concat(h),r.fields.push({name:"reservedPad",type:"USHORT",value:0}),r.fields=r.fields.concat(f),r.fields=r.fields.concat(u),r.fields=r.fields.concat(d),r.fields=r.fields.concat(p),r.cmap4Length=14+h.length*2+2+f.length*2+u.length*2+d.length*2+p.length*2,!e){var g=16+m.length*4;r.cmap12Offset=20+r.cmap4Length,r.fields=r.fields.concat([{name:"cmap12Format",type:"USHORT",value:12},{name:"cmap12Reserved",type:"USHORT",value:0},{name:"cmap12Length",type:"ULONG",value:g},{name:"cmap12Language",type:"ULONG",value:0},{name:"cmap12nGroups",type:"ULONG",value:m.length/3}]),r.fields=r.fields.concat(m)}return r}var s7={parse:j9,make:Z9},E3=[".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"],Y9=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],K9=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],t2=[".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 i7(c){this.font=c}i7.prototype.charToGlyphIndex=function(c){var e=c.codePointAt(0),t=this.font.glyphs;if(t){for(var n=0;n<t.length;n+=1)for(var a=t.get(n),r=0;r<a.unicodes.length;r+=1)if(a.unicodes[r]===e)return n}return null};function l7(c){this.cmap=c}l7.prototype.charToGlyphIndex=function(c){return this.cmap.glyphIndexMap[c.codePointAt(0)]||0};function D3(c,e){this.encoding=c,this.charset=e}D3.prototype.charToGlyphIndex=function(c){var e=c.codePointAt(0),t=this.encoding[e];return this.charset.indexOf(t)};function W5(c){switch(c.version){case 1:this.names=t2.slice();break;case 2:this.names=new Array(c.numberOfGlyphs);for(var e=0;e<c.numberOfGlyphs;e++)c.glyphNameIndex[e]<t2.length?this.names[e]=t2[c.glyphNameIndex[e]]:this.names[e]=c.names[c.glyphNameIndex[e]-t2.length];break;case 2.5:this.names=new Array(c.numberOfGlyphs);for(var t=0;t<c.numberOfGlyphs;t++)this.names[t]=t2[t+c.glyphNameIndex[t]];break;case 3:this.names=[];break;default:this.names=[];break}}W5.prototype.nameToGlyphIndex=function(c){return this.names.indexOf(c)};W5.prototype.glyphIndexToName=function(c){return this.names[c]};function J9(c){for(var e,t=c.tables.cmap.glyphIndexMap,n=Object.keys(t),a=0;a<n.length;a+=1){var r=n[a],s=t[r];e=c.glyphs.get(s),e.addUnicode(parseInt(r))}for(var i=0;i<c.glyphs.length;i+=1)e=c.glyphs.get(i),c.cffEncoding?c.isCIDFont?e.name="gid"+i:e.name=c.cffEncoding.charset[i]:c.glyphNames.names&&(e.name=c.glyphNames.glyphIndexToName(i))}function Q9(c){c._IndexToUnicodeMap={};for(var e=c.tables.cmap.glyphIndexMap,t=Object.keys(e),n=0;n<t.length;n+=1){var a=t[n],r=e[a];c._IndexToUnicodeMap[r]===void 0?c._IndexToUnicodeMap[r]={unicodes:[parseInt(a)]}:c._IndexToUnicodeMap[r].unicodes.push(parseInt(a))}}function ee(c,e){e.lowMemory?Q9(c):J9(c)}function te(c,e,t,n,a){c.beginPath(),c.moveTo(e,t),c.lineTo(n,a),c.stroke()}var e2={line:te};function ce(c,e){var t=e||new P1;return{configurable:!0,get:function(){return typeof t=="function"&&(t=t()),t},set:function(n){t=n}}}function s0(c){this.bindConstructorValues(c)}s0.prototype.bindConstructorValues=function(c){this.index=c.index||0,this.name=c.name||null,this.unicode=c.unicode||void 0,this.unicodes=c.unicodes||c.unicode!==void 0?[c.unicode]:[],"xMin"in c&&(this.xMin=c.xMin),"yMin"in c&&(this.yMin=c.yMin),"xMax"in c&&(this.xMax=c.xMax),"yMax"in c&&(this.yMax=c.yMax),"advanceWidth"in c&&(this.advanceWidth=c.advanceWidth),Object.defineProperty(this,"path",ce(this,c.path))};s0.prototype.addUnicode=function(c){this.unicodes.length===0&&(this.unicode=c),this.unicodes.push(c)};s0.prototype.getBoundingBox=function(){return this.path.getBoundingBox()};s0.prototype.getPath=function(c,e,t,n,a){c=c!==void 0?c:0,e=e!==void 0?e:0,t=t!==void 0?t:72;var r,s;n||(n={});var i=n.xScale,l=n.yScale;if(n.hinting&&a&&a.hinting&&(s=this.path&&a.hinting.exec(this,t)),s)r=a.hinting.getCommands(s),c=Math.round(c),e=Math.round(e),i=l=1;else{r=this.path.commands;var o=1/(this.path.unitsPerEm||1e3)*t;i===void 0&&(i=o),l===void 0&&(l=o)}for(var h=new P1,f=0;f<r.length;f+=1){var u=r[f];u.type==="M"?h.moveTo(c+u.x*i,e+-u.y*l):u.type==="L"?h.lineTo(c+u.x*i,e+-u.y*l):u.type==="Q"?h.quadraticCurveTo(c+u.x1*i,e+-u.y1*l,c+u.x*i,e+-u.y*l):u.type==="C"?h.curveTo(c+u.x1*i,e+-u.y1*l,c+u.x2*i,e+-u.y2*l,c+u.x*i,e+-u.y*l):u.type==="Z"&&h.closePath()}return h};s0.prototype.getContours=function(){if(this.points===void 0)return[];for(var c=[],e=[],t=0;t<this.points.length;t+=1){var n=this.points[t];e.push(n),n.lastPointOfContour&&(c.push(e),e=[])}return W.argument(e.length===0,"There are still points left in the current contour."),c};s0.prototype.getMetrics=function(){for(var c=this.path.commands,e=[],t=[],n=0;n<c.length;n+=1){var a=c[n];a.type!=="Z"&&(e.push(a.x),t.push(a.y)),(a.type==="Q"||a.type==="C")&&(e.push(a.x1),t.push(a.y1)),a.type==="C"&&(e.push(a.x2),t.push(a.y2))}var r={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(r.xMin)||(r.xMin=0),isFinite(r.xMax)||(r.xMax=this.advanceWidth),isFinite(r.yMin)||(r.yMin=0),isFinite(r.yMax)||(r.yMax=0),r.rightSideBearing=this.advanceWidth-r.leftSideBearing-(r.xMax-r.xMin),r};s0.prototype.draw=function(c,e,t,n,a){this.getPath(e,t,n,a).draw(c)};s0.prototype.drawPoints=function(c,e,t,n){function a(f,u,d,p){c.beginPath();for(var m=0;m<f.length;m+=1)c.moveTo(u+f[m].x*p,d+f[m].y*p),c.arc(u+f[m].x*p,d+f[m].y*p,2,0,Math.PI*2,!1);c.closePath(),c.fill()}e=e!==void 0?e:0,t=t!==void 0?t:0,n=n!==void 0?n:24;for(var r=1/this.path.unitsPerEm*n,s=[],i=[],l=this.path,o=0;o<l.commands.length;o+=1){var h=l.commands[o];h.x!==void 0&&s.push({x:h.x,y:-h.y}),h.x1!==void 0&&i.push({x:h.x1,y:-h.y1}),h.x2!==void 0&&i.push({x:h.x2,y:-h.y2})}c.fillStyle="blue",a(s,e,t,r),c.fillStyle="red",a(i,e,t,r)};s0.prototype.drawMetrics=function(c,e,t,n){var a;e=e!==void 0?e:0,t=t!==void 0?t:0,n=n!==void 0?n:24,a=1/this.path.unitsPerEm*n,c.lineWidth=1,c.strokeStyle="black",e2.line(c,e,-1e4,e,1e4),e2.line(c,-1e4,t,1e4,t);var r=this.xMin||0,s=this.yMin||0,i=this.xMax||0,l=this.yMax||0,o=this.advanceWidth||0;c.strokeStyle="blue",e2.line(c,e+r*a,-1e4,e+r*a,1e4),e2.line(c,e+i*a,-1e4,e+i*a,1e4),e2.line(c,-1e4,t+-s*a,1e4,t+-s*a),e2.line(c,-1e4,t+-l*a,1e4,t+-l*a),c.strokeStyle="green",e2.line(c,e+o*a,-1e4,e+o*a,1e4)};function C3(c,e,t){Object.defineProperty(c,e,{get:function(){return c.path,c[t]},set:function(n){c[t]=n},enumerable:!0,configurable:!0})}function X5(c,e){if(this.font=c,this.glyphs={},Array.isArray(e))for(var t=0;t<e.length;t++){var n=e[t];n.path.unitsPerEm=c.unitsPerEm,this.glyphs[t]=n}this.length=e&&e.length||0}X5.prototype.get=function(c){if(this.glyphs[c]===void 0){this.font._push(c),typeof this.glyphs[c]=="function"&&(this.glyphs[c]=this.glyphs[c]());var e=this.glyphs[c],t=this.font._IndexToUnicodeMap[c];if(t)for(var n=0;n<t.unicodes.length;n++)e.addUnicode(t.unicodes[n]);this.font.cffEncoding?this.font.isCIDFont?e.name="gid"+c:e.name=this.font.cffEncoding.charset[c]:this.font.glyphNames.names&&(e.name=this.font.glyphNames.glyphIndexToName(c)),this.glyphs[c].advanceWidth=this.font._hmtxTableData[c].advanceWidth,this.glyphs[c].leftSideBearing=this.font._hmtxTableData[c].leftSideBearing}else typeof this.glyphs[c]=="function"&&(this.glyphs[c]=this.glyphs[c]());return this.glyphs[c]};X5.prototype.push=function(c,e){this.glyphs[c]=e,this.length++};function ne(c,e){return new s0({index:e,font:c})}function ae(c,e,t,n,a,r){return function(){var s=new s0({index:e,font:c});return s.path=function(){t(s,n,a);var i=r(c.glyphs,s);return i.unitsPerEm=c.unitsPerEm,i},C3(s,"xMin","_xMin"),C3(s,"xMax","_xMax"),C3(s,"yMin","_yMin"),C3(s,"yMax","_yMax"),s}}function re(c,e,t,n){return function(){var a=new s0({index:e,font:c});return a.path=function(){var r=t(c,a,n);return r.unitsPerEm=c.unitsPerEm,r},a}}var k0={GlyphSet:X5,glyphLoader:ne,ttfGlyphLoader:ae,cffGlyphLoader:re};function o7(c,e){if(c===e)return!0;if(Array.isArray(c)&&Array.isArray(e)){if(c.length!==e.length)return!1;for(var t=0;t<c.length;t+=1)if(!o7(c[t],e[t]))return!1;return!0}else return!1}function R5(c){var e;return c.length<1240?e=107:c.length<33900?e=1131:e=32768,e}function B0(c,e,t){var n=[],a=[],r=U.getCard16(c,e),s,i;if(r!==0){var l=U.getByte(c,e+2);s=e+(r+1)*l+2;for(var o=e+3,h=0;h<r+1;h+=1)n.push(U.getOffset(c,o,l)),o+=l;i=s+n[r]}else i=e+2;for(var f=0;f<n.length-1;f+=1){var u=U.getBytes(c,s+n[f],s+n[f+1]);t&&(u=t(u)),a.push(u)}return{objects:a,startOffset:e,endOffset:i}}function se(c,e){var t=[],n=U.getCard16(c,e),a,r;if(n!==0){var s=U.getByte(c,e+2);a=e+(n+1)*s+2;for(var i=e+3,l=0;l<n+1;l+=1)t.push(U.getOffset(c,i,s)),i+=s;r=a+t[n]}else r=e+2;return{offsets:t,startOffset:e,endOffset:r}}function ie(c,e,t,n,a){var r=U.getCard16(t,n),s=0;if(r!==0){var i=U.getByte(t,n+2);s=n+(r+1)*i+2}var l=U.getBytes(t,s+e[c],s+e[c+1]);return a&&(l=a(l)),l}function le(c){for(var e="",t=15,n=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];;){var a=c.parseByte(),r=a>>4,s=a&15;if(r===t||(e+=n[r],s===t))break;e+=n[s]}return parseFloat(e)}function oe(c,e){var t,n,a,r;if(e===28)return t=c.parseByte(),n=c.parseByte(),t<<8|n;if(e===29)return t=c.parseByte(),n=c.parseByte(),a=c.parseByte(),r=c.parseByte(),t<<24|n<<16|a<<8|r;if(e===30)return le(c);if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return t=c.parseByte(),(e-247)*256+t+108;if(e>=251&&e<=254)return t=c.parseByte(),-(e-251)*256-t-108;throw new Error("Invalid b0 "+e)}function he(c){for(var e={},t=0;t<c.length;t+=1){var n=c[t][0],a=c[t][1],r=void 0;if(a.length===1?r=a[0]:r=a,e.hasOwnProperty(n)&&!isNaN(e[n]))throw new Error("Object "+e+" already has key "+n);e[n]=r}return e}function h7(c,e,t){e=e!==void 0?e:0;var n=new U.Parser(c,e),a=[],r=[];for(t=t!==void 0?t:c.length;n.relativeOffset<t;){var s=n.parseByte();s<=21?(s===12&&(s=1200+n.parseByte()),a.push([s,r]),r=[]):r.push(oe(n,s))}return he(a)}function N2(c,e){return e<=390?e=E3[e]:e=c[e-391],e}function u7(c,e,t){for(var n={},a,r=0;r<e.length;r+=1){var s=e[r];if(Array.isArray(s.type)){var i=[];i.length=s.type.length;for(var l=0;l<s.type.length;l++)a=c[s.op]!==void 0?c[s.op][l]:void 0,a===void 0&&(a=s.value!==void 0&&s.value[l]!==void 0?s.value[l]:null),s.type[l]==="SID"&&(a=N2(t,a)),i[l]=a;n[s.name]=i}else a=c[s.op],a===void 0&&(a=s.value!==void 0?s.value:null),s.type==="SID"&&(a=N2(t,a)),n[s.name]=a}return n}function ue(c,e){var t={};return t.formatMajor=U.getCard8(c,e),t.formatMinor=U.getCard8(c,e+1),t.size=U.getCard8(c,e+2),t.offsetSize=U.getCard8(c,e+3),t.startOffset=e,t.endOffset=e+4,t}var f7=[{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"}],d7=[{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 fe(c,e){var t=h7(c,0,c.byteLength);return u7(t,f7,e)}function p7(c,e,t,n){var a=h7(c,e,t);return u7(a,d7,n)}function b6(c,e,t,n){for(var a=[],r=0;r<t.length;r+=1){var s=new DataView(new Uint8Array(t[r]).buffer),i=fe(s,n);i._subrs=[],i._subrsBias=0,i._defaultWidthX=0,i._nominalWidthX=0;var l=i.private[0],o=i.private[1];if(l!==0&&o!==0){var h=p7(c,o+e,l,n);if(i._defaultWidthX=h.defaultWidthX,i._nominalWidthX=h.nominalWidthX,h.subrs!==0){var f=o+h.subrs,u=B0(c,f+e);i._subrs=u.objects,i._subrsBias=R5(i._subrs)}i._privateDict=h}a.push(i)}return a}function de(c,e,t,n){var a,r,s=new U.Parser(c,e);t-=1;var i=[".notdef"],l=s.parseCard8();if(l===0)for(var o=0;o<t;o+=1)a=s.parseSID(),i.push(N2(n,a));else if(l===1)for(;i.length<=t;){a=s.parseSID(),r=s.parseCard8();for(var h=0;h<=r;h+=1)i.push(N2(n,a)),a+=1}else if(l===2)for(;i.length<=t;){a=s.parseSID(),r=s.parseCard16();for(var f=0;f<=r;f+=1)i.push(N2(n,a)),a+=1}else throw new Error("Unknown charset format "+l);return i}function pe(c,e,t){var n,a={},r=new U.Parser(c,e),s=r.parseCard8();if(s===0)for(var i=r.parseCard8(),l=0;l<i;l+=1)n=r.parseCard8(),a[n]=l;else if(s===1){var o=r.parseCard8();n=1;for(var h=0;h<o;h+=1)for(var f=r.parseCard8(),u=r.parseCard8(),d=f;d<=f+u;d+=1)a[d]=n,n+=1}else throw new Error("Unknown encoding format "+s);return new D3(a,t)}function z6(c,e,t){var n,a,r,s,i=new P1,l=[],o=0,h=!1,f=!1,u=0,d=0,p,m,v,g;if(c.isCIDFont){var y=c.tables.cff.topDict._fdSelect[e.index],M=c.tables.cff.topDict._fdArray[y];p=M._subrs,m=M._subrsBias,v=M._defaultWidthX,g=M._nominalWidthX}else p=c.tables.cff.topDict._subrs,m=c.tables.cff.topDict._subrsBias,v=c.tables.cff.topDict._defaultWidthX,g=c.tables.cff.topDict._nominalWidthX;var A=v;function z(C,P){f&&i.closePath(),i.moveTo(C,P),f=!0}function E(){var C;C=l.length%2!==0,C&&!h&&(A=l.shift()+g),o+=l.length>>1,l.length=0,h=!0}function k(C){for(var P,w,I,B,F,G,X,q,o1,N,Z,e1,t1=0;t1<C.length;){var d1=C[t1];switch(t1+=1,d1){case 1:E();break;case 3:E();break;case 4:l.length>1&&!h&&(A=l.shift()+g,h=!0),d+=l.pop(),z(u,d);break;case 5:for(;l.length>0;)u+=l.shift(),d+=l.shift(),i.lineTo(u,d);break;case 6:for(;l.length>0&&(u+=l.shift(),i.lineTo(u,d),l.length!==0);)d+=l.shift(),i.lineTo(u,d);break;case 7:for(;l.length>0&&(d+=l.shift(),i.lineTo(u,d),l.length!==0);)u+=l.shift(),i.lineTo(u,d);break;case 8:for(;l.length>0;)n=u+l.shift(),a=d+l.shift(),r=n+l.shift(),s=a+l.shift(),u=r+l.shift(),d=s+l.shift(),i.curveTo(n,a,r,s,u,d);break;case 10:F=l.pop()+m,G=p[F],G&&k(G);break;case 11:return;case 12:switch(d1=C[t1],t1+=1,d1){case 35:n=u+l.shift(),a=d+l.shift(),r=n+l.shift(),s=a+l.shift(),X=r+l.shift(),q=s+l.shift(),o1=X+l.shift(),N=q+l.shift(),Z=o1+l.shift(),e1=N+l.shift(),u=Z+l.shift(),d=e1+l.shift(),l.shift(),i.curveTo(n,a,r,s,X,q),i.curveTo(o1,N,Z,e1,u,d);break;case 34:n=u+l.shift(),a=d,r=n+l.shift(),s=a+l.shift(),X=r+l.shift(),q=s,o1=X+l.shift(),N=s,Z=o1+l.shift(),e1=d,u=Z+l.shift(),i.curveTo(n,a,r,s,X,q),i.curveTo(o1,N,Z,e1,u,d);break;case 36:n=u+l.shift(),a=d+l.shift(),r=n+l.shift(),s=a+l.shift(),X=r+l.shift(),q=s,o1=X+l.shift(),N=s,Z=o1+l.shift(),e1=N+l.shift(),u=Z+l.shift(),i.curveTo(n,a,r,s,X,q),i.curveTo(o1,N,Z,e1,u,d);break;case 37:n=u+l.shift(),a=d+l.shift(),r=n+l.shift(),s=a+l.shift(),X=r+l.shift(),q=s+l.shift(),o1=X+l.shift(),N=q+l.shift(),Z=o1+l.shift(),e1=N+l.shift(),Math.abs(Z-u)>Math.abs(e1-d)?u=Z+l.shift():d=e1+l.shift(),i.curveTo(n,a,r,s,X,q),i.curveTo(o1,N,Z,e1,u,d);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+d1),l.length=0}break;case 14:l.length>0&&!h&&(A=l.shift()+g,h=!0),f&&(i.closePath(),f=!1);break;case 18:E();break;case 19:case 20:E(),t1+=o+7>>3;break;case 21:l.length>2&&!h&&(A=l.shift()+g,h=!0),d+=l.pop(),u+=l.pop(),z(u,d);break;case 22:l.length>1&&!h&&(A=l.shift()+g,h=!0),u+=l.pop(),z(u,d);break;case 23:E();break;case 24:for(;l.length>2;)n=u+l.shift(),a=d+l.shift(),r=n+l.shift(),s=a+l.shift(),u=r+l.shift(),d=s+l.shift(),i.curveTo(n,a,r,s,u,d);u+=l.shift(),d+=l.shift(),i.lineTo(u,d);break;case 25:for(;l.length>6;)u+=l.shift(),d+=l.shift(),i.lineTo(u,d);n=u+l.shift(),a=d+l.shift(),r=n+l.shift(),s=a+l.shift(),u=r+l.shift(),d=s+l.shift(),i.curveTo(n,a,r,s,u,d);break;case 26:for(l.length%2&&(u+=l.shift());l.length>0;)n=u,a=d+l.shift(),r=n+l.shift(),s=a+l.shift(),u=r,d=s+l.shift(),i.curveTo(n,a,r,s,u,d);break;case 27:for(l.length%2&&(d+=l.shift());l.length>0;)n=u+l.shift(),a=d,r=n+l.shift(),s=a+l.shift(),u=r+l.shift(),d=s,i.curveTo(n,a,r,s,u,d);break;case 28:P=C[t1],w=C[t1+1],l.push((P<<24|w<<16)>>16),t1+=2;break;case 29:F=l.pop()+c.gsubrsBias,G=c.gsubrs[F],G&&k(G);break;case 30:for(;l.length>0&&(n=u,a=d+l.shift(),r=n+l.shift(),s=a+l.shift(),u=r+l.shift(),d=s+(l.length===1?l.shift():0),i.curveTo(n,a,r,s,u,d),l.length!==0);)n=u+l.shift(),a=d,r=n+l.shift(),s=a+l.shift(),d=s+l.shift(),u=r+(l.length===1?l.shift():0),i.curveTo(n,a,r,s,u,d);break;case 31:for(;l.length>0&&(n=u+l.shift(),a=d,r=n+l.shift(),s=a+l.shift(),d=s+l.shift(),u=r+(l.length===1?l.shift():0),i.curveTo(n,a,r,s,u,d),l.length!==0);)n=u,a=d+l.shift(),r=n+l.shift(),s=a+l.shift(),u=r+l.shift(),d=s+(l.length===1?l.shift():0),i.curveTo(n,a,r,s,u,d);break;default:d1<32?console.log("Glyph "+e.index+": unknown operator "+d1):d1<247?l.push(d1-139):d1<251?(P=C[t1],t1+=1,l.push((d1-247)*256+P+108)):d1<255?(P=C[t1],t1+=1,l.push(-(d1-251)*256-P-108)):(P=C[t1],w=C[t1+1],I=C[t1+2],B=C[t1+3],t1+=4,l.push((P<<24|w<<16|I<<8|B)/65536))}}}return k(t),e.advanceWidth=A,i}function me(c,e,t,n){var a=[],r,s=new U.Parser(c,e),i=s.parseCard8();if(i===0)for(var l=0;l<t;l++){if(r=s.parseCard8(),r>=n)throw new Error("CFF table CID Font FDSelect has bad FD index value "+r+" (FD count "+n+")");a.push(r)}else if(i===3){var o=s.parseCard16(),h=s.parseCard16();if(h!==0)throw new Error("CFF Table CID Font FDSelect format 3 range has bad initial GID "+h);for(var f,u=0;u<o;u++){if(r=s.parseCard8(),f=s.parseCard16(),r>=n)throw new Error("CFF table CID Font FDSelect has bad FD index value "+r+" (FD count "+n+")");if(f>t)throw new Error("CFF Table CID Font FDSelect format 3 range has bad GID "+f);for(;h<f;h++)a.push(r);h=f}if(f!==t)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final GID "+f)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+i);return a}function ve(c,e,t,n){t.tables.cff={};var a=ue(c,e),r=B0(c,a.endOffset,U.bytesToString),s=B0(c,r.endOffset),i=B0(c,s.endOffset,U.bytesToString),l=B0(c,i.endOffset);t.gsubrs=l.objects,t.gsubrsBias=R5(t.gsubrs);var o=b6(c,e,s.objects,i.objects);if(o.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+o.length);var h=o[0];if(t.tables.cff.topDict=h,h._privateDict&&(t.defaultWidthX=h._privateDict.defaultWidthX,t.nominalWidthX=h._privateDict.nominalWidthX),h.ros[0]!==void 0&&h.ros[1]!==void 0&&(t.isCIDFont=!0),t.isCIDFont){var f=h.fdArray,u=h.fdSelect;if(f===0||u===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");f+=e;var d=B0(c,f),p=b6(c,e,d.objects,i.objects);h._fdArray=p,u+=e,h._fdSelect=me(c,u,t.numGlyphs,p.length)}var m=e+h.private[1],v=p7(c,m,h.private[0],i.objects);if(t.defaultWidthX=v.defaultWidthX,t.nominalWidthX=v.nominalWidthX,v.subrs!==0){var g=m+v.subrs,y=B0(c,g);t.subrs=y.objects,t.subrsBias=R5(t.subrs)}else t.subrs=[],t.subrsBias=0;var M;n.lowMemory?(M=se(c,e+h.charStrings),t.nGlyphs=M.offsets.length):(M=B0(c,e+h.charStrings),t.nGlyphs=M.objects.length);var A=de(c,e+h.charset,t.nGlyphs,i.objects);if(h.encoding===0?t.cffEncoding=new D3(Y9,A):h.encoding===1?t.cffEncoding=new D3(K9,A):t.cffEncoding=pe(c,e+h.encoding,A),t.encoding=t.encoding||t.cffEncoding,t.glyphs=new k0.GlyphSet(t),n.lowMemory)t._push=function(k){var C=ie(k,M.offsets,c,e+h.charStrings);t.glyphs.push(k,k0.cffGlyphLoader(t,k,z6,C))};else for(var z=0;z<t.nGlyphs;z+=1){var E=M.objects[z];t.glyphs.push(z,k0.cffGlyphLoader(t,z,z6,E))}}function m7(c,e){var t,n=E3.indexOf(c);return n>=0&&(t=n),n=e.indexOf(c),n>=0?t=n+E3.length:(t=E3.length+e.length,e.push(c)),t}function ge(){return new O.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 ye(c){var e=new O.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);e.names=[];for(var t=0;t<c.length;t+=1)e.names.push({name:"name_"+t,type:"NAME",value:c[t]});return e}function v7(c,e,t){for(var n={},a=0;a<c.length;a+=1){var r=c[a],s=e[r.name];s!==void 0&&!o7(s,r.value)&&(r.type==="SID"&&(s=m7(s,t)),n[r.op]={name:r.name,type:r.type,value:s})}return n}function w6(c,e){var t=new O.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return t.dict=v7(f7,c,e),t}function k6(c){var e=new O.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return e.topDicts=[{name:"topDict_0",type:"TABLE",value:c}],e}function Me(c){var e=new O.Record("String INDEX",[{name:"strings",type:"INDEX",value:[]}]);e.strings=[];for(var t=0;t<c.length;t+=1)e.strings.push({name:"string_"+t,type:"STRING",value:c[t]});return e}function xe(){return new O.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function be(c,e){for(var t=new O.Record("Charsets",[{name:"format",type:"Card8",value:0}]),n=0;n<c.length;n+=1){var a=c[n],r=m7(a,e);t.fields.push({name:"glyph_"+n,type:"SID",value:r})}return t}function ze(c){var e=[],t=c.path;e.push({name:"width",type:"NUMBER",value:c.advanceWidth});for(var n=0,a=0,r=0;r<t.commands.length;r+=1){var s=void 0,i=void 0,l=t.commands[r];if(l.type==="Q"){var o=.3333333333333333,h=2/3;l={type:"C",x:l.x,y:l.y,x1:Math.round(o*n+h*l.x1),y1:Math.round(o*a+h*l.y1),x2:Math.round(o*l.x+h*l.x1),y2:Math.round(o*l.y+h*l.y1)}}if(l.type==="M")s=Math.round(l.x-n),i=Math.round(l.y-a),e.push({name:"dx",type:"NUMBER",value:s}),e.push({name:"dy",type:"NUMBER",value:i}),e.push({name:"rmoveto",type:"OP",value:21}),n=Math.round(l.x),a=Math.round(l.y);else if(l.type==="L")s=Math.round(l.x-n),i=Math.round(l.y-a),e.push({name:"dx",type:"NUMBER",value:s}),e.push({name:"dy",type:"NUMBER",value:i}),e.push({name:"rlineto",type:"OP",value:5}),n=Math.round(l.x),a=Math.round(l.y);else if(l.type==="C"){var f=Math.round(l.x1-n),u=Math.round(l.y1-a),d=Math.round(l.x2-l.x1),p=Math.round(l.y2-l.y1);s=Math.round(l.x-l.x2),i=Math.round(l.y-l.y2),e.push({name:"dx1",type:"NUMBER",value:f}),e.push({name:"dy1",type:"NUMBER",value:u}),e.push({name:"dx2",type:"NUMBER",value:d}),e.push({name:"dy2",type:"NUMBER",value:p}),e.push({name:"dx",type:"NUMBER",value:s}),e.push({name:"dy",type:"NUMBER",value:i}),e.push({name:"rrcurveto",type:"OP",value:8}),n=Math.round(l.x),a=Math.round(l.y)}}return e.push({name:"endchar",type:"OP",value:14}),e}function we(c){for(var e=new O.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]),t=0;t<c.length;t+=1){var n=c.get(t),a=ze(n);e.charStrings.push({name:n.name,type:"CHARSTRING",value:a})}return e}function ke(c,e){var t=new O.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return t.dict=v7(d7,c,e),t}function Le(c,e){for(var t=new O.Table("CFF ",[{name:"header",type:"RECORD"},{name:"nameIndex",type:"RECORD"},{name:"topDictIndex",type:"RECORD"},{name:"stringIndex",type:"RECORD"},{name:"globalSubrIndex",type:"RECORD"},{name:"charsets",type:"RECORD"},{name:"charStringsIndex",type:"RECORD"},{name:"privateDict",type:"RECORD"}]),n=1/e.unitsPerEm,a={version:e.version,fullName:e.fullName,familyName:e.familyName,weight:e.weightName,fontBBox:e.fontBBox||[0,0,0,0],fontMatrix:[n,0,0,n,0,0],charset:999,encoding:0,charStrings:999,private:[0,999]},r={},s=[],i,l=1;l<c.length;l+=1)i=c.get(l),s.push(i.name);var o=[];t.header=ge(),t.nameIndex=ye([e.postScriptName]);var h=w6(a,o);t.topDictIndex=k6(h),t.globalSubrIndex=xe(),t.charsets=be(s,o),t.charStringsIndex=we(c),t.privateDict=ke(r,o),t.stringIndex=Me(o);var f=t.header.sizeOf()+t.nameIndex.sizeOf()+t.topDictIndex.sizeOf()+t.stringIndex.sizeOf()+t.globalSubrIndex.sizeOf();return a.charset=f,a.encoding=0,a.charStrings=a.charset+t.charsets.sizeOf(),a.private[1]=a.charStrings+t.charStringsIndex.sizeOf(),h=w6(a,o),t.topDictIndex=k6(h),t}var g7={parse:ve,make:Le};function Se(c,e){var t={},n=new U.Parser(c,e);return t.version=n.parseVersion(),t.fontRevision=Math.round(n.parseFixed()*1e3)/1e3,t.checkSumAdjustment=n.parseULong(),t.magicNumber=n.parseULong(),W.argument(t.magicNumber===1594834165,"Font header has wrong magic number."),t.flags=n.parseUShort(),t.unitsPerEm=n.parseUShort(),t.created=n.parseLongDateTime(),t.modified=n.parseLongDateTime(),t.xMin=n.parseShort(),t.yMin=n.parseShort(),t.xMax=n.parseShort(),t.yMax=n.parseShort(),t.macStyle=n.parseUShort(),t.lowestRecPPEM=n.parseUShort(),t.fontDirectionHint=n.parseShort(),t.indexToLocFormat=n.parseShort(),t.glyphDataFormat=n.parseShort(),t}function Ae(c){var e=Math.round(new Date().getTime()/1e3)+2082844800,t=e;return c.createdTimestamp&&(t=c.createdTimestamp+2082844800),new O.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}],c)}var y7={parse:Se,make:Ae};function Ce(c,e){var t={},n=new U.Parser(c,e);return t.version=n.parseVersion(),t.ascender=n.parseShort(),t.descender=n.parseShort(),t.lineGap=n.parseShort(),t.advanceWidthMax=n.parseUShort(),t.minLeftSideBearing=n.parseShort(),t.minRightSideBearing=n.parseShort(),t.xMaxExtent=n.parseShort(),t.caretSlopeRise=n.parseShort(),t.caretSlopeRun=n.parseShort(),t.caretOffset=n.parseShort(),n.relativeOffset+=8,t.metricDataFormat=n.parseShort(),t.numberOfHMetrics=n.parseUShort(),t}function Pe(c){return new O.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}],c)}var M7={parse:Ce,make:Pe};function Ee(c,e,t,n,a){for(var r,s,i=new U.Parser(c,e),l=0;l<n;l+=1){l<t&&(r=i.parseUShort(),s=i.parseShort());var o=a.get(l);o.advanceWidth=r,o.leftSideBearing=s}}function Te(c,e,t,n,a){c._hmtxTableData={};for(var r,s,i=new U.Parser(e,t),l=0;l<a;l+=1)l<n&&(r=i.parseUShort(),s=i.parseShort()),c._hmtxTableData[l]={advanceWidth:r,leftSideBearing:s}}function Ie(c,e,t,n,a,r,s){s.lowMemory?Te(c,e,t,n,a):Ee(e,t,n,a,r)}function He(c){for(var e=new O.Table("hmtx",[]),t=0;t<c.length;t+=1){var n=c.get(t),a=n.advanceWidth||0,r=n.leftSideBearing||0;e.fields.push({name:"advanceWidth_"+t,type:"USHORT",value:a}),e.fields.push({name:"leftSideBearing_"+t,type:"SHORT",value:r})}return e}var x7={parse:Ie,make:He};function Ve(c){for(var e=new O.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:c.length}]),t="",n=12+c.length*4,a=0;a<c.length;++a){var r=t.indexOf(c[a]);r<0&&(r=t.length,t+=c[a]),e.fields.push({name:"offset "+a,type:"USHORT",value:n+r}),e.fields.push({name:"length "+a,type:"USHORT",value:c[a].length})}return e.fields.push({name:"stringPool",type:"CHARARRAY",value:t}),e}function Oe(c,e){var t=new U.Parser(c,e),n=t.parseULong();W.argument(n===1,"Unsupported ltag table version."),t.skip("uLong",1);for(var a=t.parseULong(),r=[],s=0;s<a;s++){for(var i="",l=e+t.parseUShort(),o=t.parseUShort(),h=l;h<l+o;++h)i+=String.fromCharCode(c.getInt8(h));r.push(i)}return r}var b7={make:Ve,parse:Oe};function Fe(c,e){var t={},n=new U.Parser(c,e);return t.version=n.parseVersion(),t.numGlyphs=n.parseUShort(),t.version===1&&(t.maxPoints=n.parseUShort(),t.maxContours=n.parseUShort(),t.maxCompositePoints=n.parseUShort(),t.maxCompositeContours=n.parseUShort(),t.maxZones=n.parseUShort(),t.maxTwilightPoints=n.parseUShort(),t.maxStorage=n.parseUShort(),t.maxFunctionDefs=n.parseUShort(),t.maxInstructionDefs=n.parseUShort(),t.maxStackElements=n.parseUShort(),t.maxSizeOfInstructions=n.parseUShort(),t.maxComponentElements=n.parseUShort(),t.maxComponentDepth=n.parseUShort()),t}function De(c){return new O.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:c}])}var z7={parse:Fe,make:De},w7=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],k7={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"},Re={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},L7={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 Ue(c,e,t){switch(c){case 0:if(e===65535)return"und";if(t)return t[e];break;case 1:return k7[e];case 3:return L7[e]}}var U5="utf-16",qe={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"},Ne={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 S7(c,e,t){switch(c){case 0:return U5;case 1:return Ne[t]||qe[e];case 3:if(e===1||e===10)return U5;break}}function Be(c,e,t){for(var n={},a=new U.Parser(c,e),r=a.parseUShort(),s=a.parseUShort(),i=a.offset+a.parseUShort(),l=0;l<s;l++){var o=a.parseUShort(),h=a.parseUShort(),f=a.parseUShort(),u=a.parseUShort(),d=w7[u]||u,p=a.parseUShort(),m=a.parseUShort(),v=Ue(o,f,t),g=S7(o,h,f);if(g!==void 0&&v!==void 0){var y=void 0;if(g===U5?y=g2.UTF16(c,i+m,p):y=g2.MACSTRING(c,i+m,p,g),y){var M=n[d];M===void 0&&(M=n[d]={}),M[v]=y}}}var A=0;return r===1&&(A=a.parseUShort()),n}function S5(c){var e={};for(var t in c)e[c[t]]=parseInt(t);return e}function L6(c,e,t,n,a,r){return new O.Record("NameRecord",[{name:"platformID",type:"USHORT",value:c},{name:"encodingID",type:"USHORT",value:e},{name:"languageID",type:"USHORT",value:t},{name:"nameID",type:"USHORT",value:n},{name:"length",type:"USHORT",value:a},{name:"offset",type:"USHORT",value:r}])}function $e(c,e){var t=c.length,n=e.length-t+1;e:for(var a=0;a<n;a++)for(;a<n;a++){for(var r=0;r<t;r++)if(e[a+r]!==c[r])continue e;return a}return-1}function S6(c,e){var t=$e(c,e);if(t<0){t=e.length;for(var n=0,a=c.length;n<a;++n)e.push(c[n])}return t}function Ge(c,e){var t,n=[],a={},r=S5(w7);for(var s in c){var i=r[s];if(i===void 0&&(i=s),t=parseInt(i),isNaN(t))throw new Error('Name table entry "'+s+'" does not exist, see nameTableNames for complete list.');a[t]=c[s],n.push(t)}for(var l=S5(k7),o=S5(L7),h=[],f=[],u=0;u<n.length;u++){t=n[u];var d=a[t];for(var p in d){var m=d[p],v=1,g=l[p],y=Re[g],M=S7(v,y,g),A=H.MACSTRING(m,M);A===void 0&&(v=0,g=e.indexOf(p),g<0&&(g=e.length,e.push(p)),y=4,A=H.UTF16(m));var z=S6(A,f);h.push(L6(v,y,g,t,A.length,z));var E=o[p];if(E!==void 0){var k=H.UTF16(m),C=S6(k,f);h.push(L6(3,1,E,t,k.length,C))}}}h.sort(function(I,B){return I.platformID-B.platformID||I.encodingID-B.encodingID||I.languageID-B.languageID||I.nameID-B.nameID});for(var P=new O.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:h.length},{name:"stringOffset",type:"USHORT",value:6+h.length*12}]),w=0;w<h.length;w++)P.fields.push({name:"record_"+w,type:"RECORD",value:h[w]});return P.fields.push({name:"strings",type:"LITERAL",value:f}),P}var A7={parse:Be,make:Ge},q5=[{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 _e(c){for(var e=0;e<q5.length;e+=1){var t=q5[e];if(c>=t.begin&&c<t.end)return e}return-1}function je(c,e){var t={},n=new U.Parser(c,e);t.version=n.parseUShort(),t.xAvgCharWidth=n.parseShort(),t.usWeightClass=n.parseUShort(),t.usWidthClass=n.parseUShort(),t.fsType=n.parseUShort(),t.ySubscriptXSize=n.parseShort(),t.ySubscriptYSize=n.parseShort(),t.ySubscriptXOffset=n.parseShort(),t.ySubscriptYOffset=n.parseShort(),t.ySuperscriptXSize=n.parseShort(),t.ySuperscriptYSize=n.parseShort(),t.ySuperscriptXOffset=n.parseShort(),t.ySuperscriptYOffset=n.parseShort(),t.yStrikeoutSize=n.parseShort(),t.yStrikeoutPosition=n.parseShort(),t.sFamilyClass=n.parseShort(),t.panose=[];for(var a=0;a<10;a++)t.panose[a]=n.parseByte();return t.ulUnicodeRange1=n.parseULong(),t.ulUnicodeRange2=n.parseULong(),t.ulUnicodeRange3=n.parseULong(),t.ulUnicodeRange4=n.parseULong(),t.achVendID=String.fromCharCode(n.parseByte(),n.parseByte(),n.parseByte(),n.parseByte()),t.fsSelection=n.parseUShort(),t.usFirstCharIndex=n.parseUShort(),t.usLastCharIndex=n.parseUShort(),t.sTypoAscender=n.parseShort(),t.sTypoDescender=n.parseShort(),t.sTypoLineGap=n.parseShort(),t.usWinAscent=n.parseUShort(),t.usWinDescent=n.parseUShort(),t.version>=1&&(t.ulCodePageRange1=n.parseULong(),t.ulCodePageRange2=n.parseULong()),t.version>=2&&(t.sxHeight=n.parseShort(),t.sCapHeight=n.parseShort(),t.usDefaultChar=n.parseUShort(),t.usBreakChar=n.parseUShort(),t.usMaxContent=n.parseUShort()),t}function We(c){return new O.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}],c)}var N5={parse:je,make:We,unicodeRanges:q5,getUnicodeRange:_e};function Xe(c,e){var t={},n=new U.Parser(c,e);switch(t.version=n.parseVersion(),t.italicAngle=n.parseFixed(),t.underlinePosition=n.parseShort(),t.underlineThickness=n.parseShort(),t.isFixedPitch=n.parseULong(),t.minMemType42=n.parseULong(),t.maxMemType42=n.parseULong(),t.minMemType1=n.parseULong(),t.maxMemType1=n.parseULong(),t.version){case 1:t.names=t2.slice();break;case 2:t.numberOfGlyphs=n.parseUShort(),t.glyphNameIndex=new Array(t.numberOfGlyphs);for(var a=0;a<t.numberOfGlyphs;a++)t.glyphNameIndex[a]=n.parseUShort();t.names=[];for(var r=0;r<t.numberOfGlyphs;r++)if(t.glyphNameIndex[r]>=t2.length){var s=n.parseChar();t.names.push(n.parseString(s))}break;case 2.5:t.numberOfGlyphs=n.parseUShort(),t.offset=new Array(t.numberOfGlyphs);for(var i=0;i<t.numberOfGlyphs;i++)t.offset[i]=n.parseChar();break}return t}function Ze(){return new O.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 C7={parse:Xe,make:Ze},u0=new Array(9);u0[1]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:1,coverage:this.parsePointer(L.coverage),deltaGlyphId:this.parseUShort()};if(t===2)return{substFormat:2,coverage:this.parsePointer(L.coverage),substitute:this.parseOffset16List()};W.assert(!1,"0x"+e.toString(16)+": lookup type 1 format must be 1 or 2.")};u0[2]=function(){var e=this.parseUShort();return W.argument(e===1,"GSUB Multiple Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(L.coverage),sequences:this.parseListOfLists()}};u0[3]=function(){var e=this.parseUShort();return W.argument(e===1,"GSUB Alternate Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(L.coverage),alternateSets:this.parseListOfLists()}};u0[4]=function(){var e=this.parseUShort();return W.argument(e===1,"GSUB ligature table identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(L.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};var v2={sequenceIndex:L.uShort,lookupListIndex:L.uShort};u0[5]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:t,coverage:this.parsePointer(L.coverage),ruleSets:this.parseListOfLists(function(){var r=this.parseUShort(),s=this.parseUShort();return{input:this.parseUShortList(r-1),lookupRecords:this.parseRecordList(s,v2)}})};if(t===2)return{substFormat:t,coverage:this.parsePointer(L.coverage),classDef:this.parsePointer(L.classDef),classSets:this.parseListOfLists(function(){var r=this.parseUShort(),s=this.parseUShort();return{classes:this.parseUShortList(r-1),lookupRecords:this.parseRecordList(s,v2)}})};if(t===3){var n=this.parseUShort(),a=this.parseUShort();return{substFormat:t,coverages:this.parseList(n,L.pointer(L.coverage)),lookupRecords:this.parseRecordList(a,v2)}}W.assert(!1,"0x"+e.toString(16)+": lookup type 5 format must be 1, 2 or 3.")};u0[6]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:1,coverage:this.parsePointer(L.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(v2)}})};if(t===2)return{substFormat:2,coverage:this.parsePointer(L.coverage),backtrackClassDef:this.parsePointer(L.classDef),inputClassDef:this.parsePointer(L.classDef),lookaheadClassDef:this.parsePointer(L.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(v2)}})};if(t===3)return{substFormat:3,backtrackCoverage:this.parseList(L.pointer(L.coverage)),inputCoverage:this.parseList(L.pointer(L.coverage)),lookaheadCoverage:this.parseList(L.pointer(L.coverage)),lookupRecords:this.parseRecordList(v2)};W.assert(!1,"0x"+e.toString(16)+": lookup type 6 format must be 1, 2 or 3.")};u0[7]=function(){var e=this.parseUShort();W.argument(e===1,"GSUB Extension Substitution subtable identifier-format must be 1");var t=this.parseUShort(),n=new L(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:t,extension:u0[t].call(n)}};u0[8]=function(){var e=this.parseUShort();return W.argument(e===1,"GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(L.coverage),backtrackCoverage:this.parseList(L.pointer(L.coverage)),lookaheadCoverage:this.parseList(L.pointer(L.coverage)),substitutes:this.parseUShortList()}};function Ye(c,e){e=e||0;var t=new L(c,e),n=t.parseVersion(1);return W.argument(n===1||n===1.1,"Unsupported GSUB table version."),n===1?{version:n,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(u0)}:{version:n,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(u0),variations:t.parseFeatureVariationsList()}}var y2=new Array(9);y2[1]=function(e){return e.substFormat===1?new O.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new O.Coverage(e.coverage)},{name:"deltaGlyphID",type:"USHORT",value:e.deltaGlyphId}]):new O.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new O.Coverage(e.coverage)}].concat(O.ushortList("substitute",e.substitute)))};y2[2]=function(e){return W.assert(e.substFormat===1,"Lookup type 2 substFormat must be 1."),new O.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new O.Coverage(e.coverage)}].concat(O.tableList("seqSet",e.sequences,function(t){return new O.Table("sequenceSetTable",O.ushortList("sequence",t))})))};y2[3]=function(e){return W.assert(e.substFormat===1,"Lookup type 3 substFormat must be 1."),new O.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new O.Coverage(e.coverage)}].concat(O.tableList("altSet",e.alternateSets,function(t){return new O.Table("alternateSetTable",O.ushortList("alternate",t))})))};y2[4]=function(e){return W.assert(e.substFormat===1,"Lookup type 4 substFormat must be 1."),new O.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new O.Coverage(e.coverage)}].concat(O.tableList("ligSet",e.ligatureSets,function(t){return new O.Table("ligatureSetTable",O.tableList("ligature",t,function(n){return new O.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:n.ligGlyph}].concat(O.ushortList("component",n.components,n.components.length+1)))}))})))};y2[6]=function(e){if(e.substFormat===1){var t=new O.Table("chainContextTable",[{name:"substFormat",type:"USHORT",value:e.substFormat},{name:"coverage",type:"TABLE",value:new O.Coverage(e.coverage)}].concat(O.tableList("chainRuleSet",e.chainRuleSets,function(r){return new O.Table("chainRuleSetTable",O.tableList("chainRule",r,function(s){var i=O.ushortList("backtrackGlyph",s.backtrack,s.backtrack.length).concat(O.ushortList("inputGlyph",s.input,s.input.length+1)).concat(O.ushortList("lookaheadGlyph",s.lookahead,s.lookahead.length)).concat(O.ushortList("substitution",[],s.lookupRecords.length));return s.lookupRecords.forEach(function(l,o){i=i.concat({name:"sequenceIndex"+o,type:"USHORT",value:l.sequenceIndex}).concat({name:"lookupListIndex"+o,type:"USHORT",value:l.lookupListIndex})}),new O.Table("chainRuleTable",i)}))})));return t}else if(e.substFormat===2)W.assert(!1,"lookup type 6 format 2 is not yet supported.");else if(e.substFormat===3){var n=[{name:"substFormat",type:"USHORT",value:e.substFormat}];n.push({name:"backtrackGlyphCount",type:"USHORT",value:e.backtrackCoverage.length}),e.backtrackCoverage.forEach(function(r,s){n.push({name:"backtrackCoverage"+s,type:"TABLE",value:new O.Coverage(r)})}),n.push({name:"inputGlyphCount",type:"USHORT",value:e.inputCoverage.length}),e.inputCoverage.forEach(function(r,s){n.push({name:"inputCoverage"+s,type:"TABLE",value:new O.Coverage(r)})}),n.push({name:"lookaheadGlyphCount",type:"USHORT",value:e.lookaheadCoverage.length}),e.lookaheadCoverage.forEach(function(r,s){n.push({name:"lookaheadCoverage"+s,type:"TABLE",value:new O.Coverage(r)})}),n.push({name:"substitutionCount",type:"USHORT",value:e.lookupRecords.length}),e.lookupRecords.forEach(function(r,s){n=n.concat({name:"sequenceIndex"+s,type:"USHORT",value:r.sequenceIndex}).concat({name:"lookupListIndex"+s,type:"USHORT",value:r.lookupListIndex})});var a=new O.Table("chainContextTable",n);return a}W.assert(!1,"lookup type 6 format must be 1, 2 or 3.")};function Ke(c){return new O.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new O.ScriptList(c.scripts)},{name:"features",type:"TABLE",value:new O.FeatureList(c.features)},{name:"lookups",type:"TABLE",value:new O.LookupList(c.lookups,y2)}])}var P7={parse:Ye,make:Ke};function Je(c,e){var t=new U.Parser(c,e),n=t.parseULong();W.argument(n===1,"Unsupported META table version."),t.parseULong(),t.parseULong();for(var a=t.parseULong(),r={},s=0;s<a;s++){var i=t.parseTag(),l=t.parseULong(),o=t.parseULong(),h=g2.UTF8(c,e+l,o);r[i]=h}return r}function Qe(c){var e=Object.keys(c).length,t="",n=16+e*12,a=new O.Table("meta",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"offset",type:"ULONG",value:n},{name:"numTags",type:"ULONG",value:e}]);for(var r in c){var s=t.length;t+=c[r],a.fields.push({name:"tag "+r,type:"TAG",value:r}),a.fields.push({name:"offset "+r,type:"ULONG",value:n+s}),a.fields.push({name:"length "+r,type:"ULONG",value:c[r].length})}return a.fields.push({name:"stringPool",type:"CHARARRAY",value:t}),a}var E7={parse:Je,make:Qe};function A6(c){return Math.log(c)/Math.log(2)|0}function Z5(c){for(;c.length%4!==0;)c.push(0);for(var e=0,t=0;t<c.length;t+=4)e+=(c[t]<<24)+(c[t+1]<<16)+(c[t+2]<<8)+c[t+3];return e%=Math.pow(2,32),e}function C6(c,e,t,n){return new O.Record("Table Record",[{name:"tag",type:"TAG",value:c!==void 0?c:""},{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:n!==void 0?n:0}])}function T7(c){var e=new O.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=c,e.numTables=c.length;var t=Math.pow(2,A6(e.numTables));e.searchRange=16*t,e.entrySelector=A6(t),e.rangeShift=e.numTables*16-e.searchRange;for(var n=[],a=[],r=e.sizeOf()+C6().sizeOf()*e.numTables;r%4!==0;)r+=1,a.push({name:"padding",type:"BYTE",value:0});for(var s=0;s<c.length;s+=1){var i=c[s];W.argument(i.tableName.length===4,"Table name"+i.tableName+" is invalid.");var l=i.sizeOf(),o=C6(i.tableName,Z5(i.encode()),r,l);for(n.push({name:o.tag+" Table Record",type:"RECORD",value:o}),a.push({name:i.tableName+" table",type:"RECORD",value:i}),r+=l,W.argument(!isNaN(r),"Something went wrong calculating the offset.");r%4!==0;)r+=1,a.push({name:"padding",type:"BYTE",value:0})}return n.sort(function(h,f){return h.value.tag>f.value.tag?1:-1}),e.fields=e.fields.concat(n),e.fields=e.fields.concat(a),e}function P6(c,e,t){for(var n=0;n<e.length;n+=1){var a=c.charToGlyphIndex(e[n]);if(a>0){var r=c.glyphs.get(a);return r.getMetrics()}}return t}function et(c){for(var e=0,t=0;t<c.length;t+=1)e+=c[t];return e/c.length}function tt(c){for(var e=[],t=[],n=[],a=[],r=[],s=[],i=[],l,o=0,h=0,f=0,u=0,d=0,p=0;p<c.glyphs.length;p+=1){var m=c.glyphs.get(p),v=m.unicode|0;if(isNaN(m.advanceWidth))throw new Error("Glyph "+m.name+" ("+p+"): advanceWidth is not a number.");(l>v||l===void 0)&&v>0&&(l=v),o<v&&(o=v);var g=N5.getUnicodeRange(v);if(g<32)h|=1<<g;else if(g<64)f|=1<<g-32;else if(g<96)u|=1<<g-64;else if(g<123)d|=1<<g-96;else throw new Error("Unicode ranges bits > 123 are reserved for internal usage");if(m.name!==".notdef"){var y=m.getMetrics();e.push(y.xMin),t.push(y.yMin),n.push(y.xMax),a.push(y.yMax),s.push(y.leftSideBearing),i.push(y.rightSideBearing),r.push(m.advanceWidth)}}var M={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,t),xMax:Math.max.apply(null,n),yMax:Math.max.apply(null,a),advanceWidthMax:Math.max.apply(null,r),advanceWidthAvg:et(r),minLeftSideBearing:Math.min.apply(null,s),maxLeftSideBearing:Math.max.apply(null,s),minRightSideBearing:Math.min.apply(null,i)};M.ascender=c.ascender,M.descender=c.descender;var A=y7.make({flags:3,unitsPerEm:c.unitsPerEm,xMin:M.xMin,yMin:M.yMin,xMax:M.xMax,yMax:M.yMax,lowestRecPPEM:3,createdTimestamp:c.createdTimestamp}),z=M7.make({ascender:M.ascender,descender:M.descender,advanceWidthMax:M.advanceWidthMax,minLeftSideBearing:M.minLeftSideBearing,minRightSideBearing:M.minRightSideBearing,xMaxExtent:M.maxLeftSideBearing+(M.xMax-M.xMin),numberOfHMetrics:c.glyphs.length}),E=z7.make(c.glyphs.length),k=N5.make(Object.assign({xAvgCharWidth:Math.round(M.advanceWidthAvg),usFirstCharIndex:l,usLastCharIndex:o,ulUnicodeRange1:h,ulUnicodeRange2:f,ulUnicodeRange3:u,ulUnicodeRange4:d,sTypoAscender:M.ascender,sTypoDescender:M.descender,sTypoLineGap:0,usWinAscent:M.yMax,usWinDescent:Math.abs(M.yMin),ulCodePageRange1:1,sxHeight:P6(c,"xyvw",{yMax:Math.round(M.ascender/2)}).yMax,sCapHeight:P6(c,"HIKLEFJMNTZBDPRAGOQSUVWXY",M).yMax,usDefaultChar:c.hasChar(" ")?32:0,usBreakChar:c.hasChar(" ")?32:0},c.tables.os2)),C=x7.make(c.glyphs),P=s7.make(c.glyphs),w=c.getEnglishName("fontFamily"),I=c.getEnglishName("fontSubfamily"),B=w+" "+I,F=c.getEnglishName("postScriptName");F||(F=w.replace(/\s/g,"")+"-"+I);var G={};for(var X in c.names)G[X]=c.names[X];G.uniqueID||(G.uniqueID={en:c.getEnglishName("manufacturer")+":"+B}),G.postScriptName||(G.postScriptName={en:F}),G.preferredFamily||(G.preferredFamily=c.names.fontFamily),G.preferredSubfamily||(G.preferredSubfamily=c.names.fontSubfamily);var q=[],o1=A7.make(G,q),N=q.length>0?b7.make(q):void 0,Z=C7.make(),e1=g7.make(c.glyphs,{version:c.getEnglishName("version"),fullName:B,familyName:w,weightName:I,postScriptName:F,unitsPerEm:c.unitsPerEm,fontBBox:[0,M.yMin,M.ascender,M.advanceWidthMax]}),t1=c.metas&&Object.keys(c.metas).length>0?E7.make(c.metas):void 0,d1=[A,z,E,k,o1,P,Z,e1,C];N&&d1.push(N),c.tables.gsub&&d1.push(P7.make(c.tables.gsub)),t1&&d1.push(t1);for(var _1=T7(d1),M1=_1.encode(),X3=Z5(M1),k2=_1.fields,J2=!1,X0=0;X0<k2.length;X0+=1)if(k2[X0].name==="head table"){k2[X0].value.checkSumAdjustment=2981146554-X3,J2=!0;break}if(!J2)throw new Error("Could not find head table with checkSum to adjust.");return _1}var ct={make:T7,fontToTable:tt,computeCheckSum:Z5};function A5(c,e){for(var t=0,n=c.length-1;t<=n;){var a=t+n>>>1,r=c[a].tag;if(r===e)return a;r<e?t=a+1:n=a-1}return-t-1}function E6(c,e){for(var t=0,n=c.length-1;t<=n;){var a=t+n>>>1,r=c[a];if(r===e)return a;r<e?t=a+1:n=a-1}return-t-1}function T6(c,e){for(var t,n=0,a=c.length-1;n<=a;){var r=n+a>>>1;t=c[r];var s=t.start;if(s===e)return t;s<e?n=r+1:a=r-1}if(n>0)return t=c[n-1],e>t.end?0:t}function j2(c,e){this.font=c,this.tableName=e}j2.prototype={searchTag:A5,binSearch:E6,getTable:function(c){var e=this.font.tables[this.tableName];return!e&&c&&(e=this.font.tables[this.tableName]=this.createDefaultTable()),e},getScriptNames:function(){var c=this.getTable();return c?c.scripts.map(function(e){return e.tag}):[]},getDefaultScriptName:function(){var c=this.getTable();if(c){for(var e=!1,t=0;t<c.scripts.length;t++){var n=c.scripts[t].tag;if(n==="DFLT")return n;n==="latn"&&(e=!0)}if(e)return"latn"}},getScriptTable:function(c,e){var t=this.getTable(e);if(t){c=c||"DFLT";var n=t.scripts,a=A5(t.scripts,c);if(a>=0)return n[a].script;if(e){var r={tag:c,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return n.splice(-1-a,0,r),r.script}}},getLangSysTable:function(c,e,t){var n=this.getScriptTable(c,t);if(n){if(!e||e==="dflt"||e==="DFLT")return n.defaultLangSys;var a=A5(n.langSysRecords,e);if(a>=0)return n.langSysRecords[a].langSys;if(t){var r={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return n.langSysRecords.splice(-1-a,0,r),r.langSys}}},getFeatureTable:function(c,e,t,n){var a=this.getLangSysTable(c,e,n);if(a){for(var r,s=a.featureIndexes,i=this.font.tables[this.tableName].features,l=0;l<s.length;l++)if(r=i[s[l]],r.tag===t)return r.feature;if(n){var o=i.length;return W.assert(o===0||t>=i[o-1].tag,"Features must be added in alphabetical order."),r={tag:t,feature:{params:0,lookupListIndexes:[]}},i.push(r),s.push(o),r.feature}}},getLookupTables:function(c,e,t,n,a){var r=this.getFeatureTable(c,e,t,a),s=[];if(r){for(var i,l=r.lookupListIndexes,o=this.font.tables[this.tableName].lookups,h=0;h<l.length;h++)i=o[l[h]],i.lookupType===n&&s.push(i);if(s.length===0&&a){i={lookupType:n,lookupFlag:0,subtables:[],markFilteringSet:void 0};var f=o.length;return o.push(i),l.push(f),[i]}}return s},getGlyphClass:function(c,e){switch(c.format){case 1:return c.startGlyph<=e&&e<c.startGlyph+c.classes.length?c.classes[e-c.startGlyph]:0;case 2:var t=T6(c.ranges,e);return t?t.classId:0}},getCoverageIndex:function(c,e){switch(c.format){case 1:var t=E6(c.glyphs,e);return t>=0?t:-1;case 2:var n=T6(c.ranges,e);return n?n.index+e-n.start:-1}},expandCoverage:function(c){if(c.format===1)return c.glyphs;for(var e=[],t=c.ranges,n=0;n<t.length;n++)for(var a=t[n],r=a.start,s=a.end,i=r;i<=s;i++)e.push(i);return e}};function W2(c){j2.call(this,c,"gpos")}W2.prototype=j2.prototype;W2.prototype.init=function(){var c=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(c)};W2.prototype.getKerningValue=function(c,e,t){for(var n=0;n<c.length;n++)for(var a=c[n].subtables,r=0;r<a.length;r++){var s=a[r],i=this.getCoverageIndex(s.coverage,e);if(!(i<0))switch(s.posFormat){case 1:for(var l=s.pairSets[i],o=0;o<l.length;o++){var h=l[o];if(h.secondGlyph===t)return h.value1&&h.value1.xAdvance||0}break;case 2:var f=this.getGlyphClass(s.classDef1,e),u=this.getGlyphClass(s.classDef2,t),d=s.classRecords[f][u];return d.value1&&d.value1.xAdvance||0}}return 0};W2.prototype.getKerningTables=function(c,e){if(this.font.tables.gpos)return this.getLookupTables(c,e,"kern",2)};function e0(c){j2.call(this,c,"gsub")}function nt(c,e){var t=c.length;if(t!==e.length)return!1;for(var n=0;n<t;n++)if(c[n]!==e[n])return!1;return!0}function Y5(c,e,t){for(var n=c.subtables,a=0;a<n.length;a++){var r=n[a];if(r.substFormat===e)return r}if(t)return n.push(t),t}e0.prototype=j2.prototype;e0.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}};e0.prototype.getSingle=function(c,e,t){for(var n=[],a=this.getLookupTables(e,t,c,1),r=0;r<a.length;r++)for(var s=a[r].subtables,i=0;i<s.length;i++){var l=s[i],o=this.expandCoverage(l.coverage),h=void 0;if(l.substFormat===1){var f=l.deltaGlyphId;for(h=0;h<o.length;h++){var u=o[h];n.push({sub:u,by:u+f})}}else{var d=l.substitute;for(h=0;h<o.length;h++)n.push({sub:o[h],by:d[h]})}}return n};e0.prototype.getMultiple=function(c,e,t){for(var n=[],a=this.getLookupTables(e,t,c,2),r=0;r<a.length;r++)for(var s=a[r].subtables,i=0;i<s.length;i++){var l=s[i],o=this.expandCoverage(l.coverage),h=void 0;for(h=0;h<o.length;h++){var f=o[h],u=l.sequences[h];n.push({sub:f,by:u})}}return n};e0.prototype.getAlternates=function(c,e,t){for(var n=[],a=this.getLookupTables(e,t,c,3),r=0;r<a.length;r++)for(var s=a[r].subtables,i=0;i<s.length;i++)for(var l=s[i],o=this.expandCoverage(l.coverage),h=l.alternateSets,f=0;f<o.length;f++)n.push({sub:o[f],by:h[f]});return n};e0.prototype.getLigatures=function(c,e,t){for(var n=[],a=this.getLookupTables(e,t,c,4),r=0;r<a.length;r++)for(var s=a[r].subtables,i=0;i<s.length;i++)for(var l=s[i],o=this.expandCoverage(l.coverage),h=l.ligatureSets,f=0;f<o.length;f++)for(var u=o[f],d=h[f],p=0;p<d.length;p++){var m=d[p];n.push({sub:[u].concat(m.components),by:m.ligGlyph})}return n};e0.prototype.addSingle=function(c,e,t,n){var a=this.getLookupTables(t,n,c,1,!0)[0],r=Y5(a,2,{substFormat:2,coverage:{format:1,glyphs:[]},substitute:[]});W.assert(r.coverage.format===1,"Single: unable to modify coverage table format "+r.coverage.format);var s=e.sub,i=this.binSearch(r.coverage.glyphs,s);i<0&&(i=-1-i,r.coverage.glyphs.splice(i,0,s),r.substitute.splice(i,0,0)),r.substitute[i]=e.by};e0.prototype.addMultiple=function(c,e,t,n){W.assert(e.by instanceof Array&&e.by.length>1,'Multiple: "by" must be an array of two or more ids');var a=this.getLookupTables(t,n,c,2,!0)[0],r=Y5(a,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});W.assert(r.coverage.format===1,"Multiple: unable to modify coverage table format "+r.coverage.format);var s=e.sub,i=this.binSearch(r.coverage.glyphs,s);i<0&&(i=-1-i,r.coverage.glyphs.splice(i,0,s),r.sequences.splice(i,0,0)),r.sequences[i]=e.by};e0.prototype.addAlternate=function(c,e,t,n){var a=this.getLookupTables(t,n,c,3,!0)[0],r=Y5(a,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});W.assert(r.coverage.format===1,"Alternate: unable to modify coverage table format "+r.coverage.format);var s=e.sub,i=this.binSearch(r.coverage.glyphs,s);i<0&&(i=-1-i,r.coverage.glyphs.splice(i,0,s),r.alternateSets.splice(i,0,0)),r.alternateSets[i]=e.by};e0.prototype.addLigature=function(c,e,t,n){var a=this.getLookupTables(t,n,c,4,!0)[0],r=a.subtables[0];r||(r={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},a.subtables[0]=r),W.assert(r.coverage.format===1,"Ligature: unable to modify coverage table format "+r.coverage.format);var s=e.sub[0],i=e.sub.slice(1),l={ligGlyph:e.by,components:i},o=this.binSearch(r.coverage.glyphs,s);if(o>=0){for(var h=r.ligatureSets[o],f=0;f<h.length;f++)if(nt(h[f].components,i))return;h.push(l)}else o=-1-o,r.coverage.glyphs.splice(o,0,s),r.ligatureSets.splice(o,0,[l])};e0.prototype.getFeature=function(c,e,t){if(/ss\d\d/.test(c))return this.getSingle(c,e,t);switch(c){case"aalt":case"salt":return this.getSingle(c,e,t).concat(this.getAlternates(c,e,t));case"dlig":case"liga":case"rlig":return this.getLigatures(c,e,t);case"ccmp":return this.getMultiple(c,e,t).concat(this.getLigatures(c,e,t));case"stch":return this.getMultiple(c,e,t)}};e0.prototype.add=function(c,e,t,n){if(/ss\d\d/.test(c))return this.addSingle(c,e,t,n);switch(c){case"aalt":case"salt":return typeof e.by=="number"?this.addSingle(c,e,t,n):this.addAlternate(c,e,t,n);case"dlig":case"liga":case"rlig":return this.addLigature(c,e,t,n);case"ccmp":return e.by instanceof Array?this.addMultiple(c,e,t,n):this.addLigature(c,e,t,n)}};function at(){return typeof window<"u"}function rt(c){for(var e=new Buffer(c.byteLength),t=new Uint8Array(c),n=0;n<e.length;++n)e[n]=t[n];return e}function q2(c,e){if(!c)throw e}function I6(c,e,t,n,a){var r;return(e&n)>0?(r=c.parseByte(),(e&a)===0&&(r=-r),r=t+r):(e&a)>0?r=t:r=t+c.parseShort(),r}function I7(c,e,t){var n=new U.Parser(e,t);c.numberOfContours=n.parseShort(),c._xMin=n.parseShort(),c._yMin=n.parseShort(),c._xMax=n.parseShort(),c._yMax=n.parseShort();var a,r;if(c.numberOfContours>0){for(var s=c.endPointIndices=[],i=0;i<c.numberOfContours;i+=1)s.push(n.parseUShort());c.instructionLength=n.parseUShort(),c.instructions=[];for(var l=0;l<c.instructionLength;l+=1)c.instructions.push(n.parseByte());var o=s[s.length-1]+1;a=[];for(var h=0;h<o;h+=1)if(r=n.parseByte(),a.push(r),(r&8)>0)for(var f=n.parseByte(),u=0;u<f;u+=1)a.push(r),h+=1;if(W.argument(a.length===o,"Bad flags."),s.length>0){var d=[],p;if(o>0){for(var m=0;m<o;m+=1)r=a[m],p={},p.onCurve=!!(r&1),p.lastPointOfContour=s.indexOf(m)>=0,d.push(p);for(var v=0,g=0;g<o;g+=1)r=a[g],p=d[g],p.x=I6(n,r,v,2,16),v=p.x;for(var y=0,M=0;M<o;M+=1)r=a[M],p=d[M],p.y=I6(n,r,y,4,32),y=p.y}c.points=d}else c.points=[]}else if(c.numberOfContours===0)c.points=[];else{c.isComposite=!0,c.points=[],c.components=[];for(var A=!0;A;){a=n.parseUShort();var z={glyphIndex:n.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(a&1)>0?(a&2)>0?(z.dx=n.parseShort(),z.dy=n.parseShort()):z.matchedPoints=[n.parseUShort(),n.parseUShort()]:(a&2)>0?(z.dx=n.parseChar(),z.dy=n.parseChar()):z.matchedPoints=[n.parseByte(),n.parseByte()],(a&8)>0?z.xScale=z.yScale=n.parseF2Dot14():(a&64)>0?(z.xScale=n.parseF2Dot14(),z.yScale=n.parseF2Dot14()):(a&128)>0&&(z.xScale=n.parseF2Dot14(),z.scale01=n.parseF2Dot14(),z.scale10=n.parseF2Dot14(),z.yScale=n.parseF2Dot14()),c.components.push(z),A=!!(a&32)}if(a&256){c.instructionLength=n.parseUShort(),c.instructions=[];for(var E=0;E<c.instructionLength;E+=1)c.instructions.push(n.parseByte())}}}function C5(c,e){for(var t=[],n=0;n<c.length;n+=1){var a=c[n],r={x:e.xScale*a.x+e.scale01*a.y+e.dx,y:e.scale10*a.x+e.yScale*a.y+e.dy,onCurve:a.onCurve,lastPointOfContour:a.lastPointOfContour};t.push(r)}return t}function st(c){for(var e=[],t=[],n=0;n<c.length;n+=1){var a=c[n];t.push(a),a.lastPointOfContour&&(e.push(t),t=[])}return W.argument(t.length===0,"There are still points left in the current contour."),e}function H7(c){var e=new P1;if(!c)return e;for(var t=st(c),n=0;n<t.length;++n){var a=t[n],r=null,s=a[a.length-1],i=a[0];if(s.onCurve)e.moveTo(s.x,s.y);else if(i.onCurve)e.moveTo(i.x,i.y);else{var l={x:(s.x+i.x)*.5,y:(s.y+i.y)*.5};e.moveTo(l.x,l.y)}for(var o=0;o<a.length;++o)if(r=s,s=i,i=a[(o+1)%a.length],s.onCurve)e.lineTo(s.x,s.y);else{var h=r,f=i;r.onCurve||(h={x:(s.x+r.x)*.5,y:(s.y+r.y)*.5}),i.onCurve||(f={x:(s.x+i.x)*.5,y:(s.y+i.y)*.5}),e.quadraticCurveTo(s.x,s.y,f.x,f.y)}e.closePath()}return e}function V7(c,e){if(e.isComposite)for(var t=0;t<e.components.length;t+=1){var n=e.components[t],a=c.get(n.glyphIndex);if(a.getPath(),a.points){var r=void 0;if(n.matchedPoints===void 0)r=C5(a.points,n);else{if(n.matchedPoints[0]>e.points.length-1||n.matchedPoints[1]>a.points.length-1)throw Error("Matched points out of range in "+e.name);var s=e.points[n.matchedPoints[0]],i=a.points[n.matchedPoints[1]],l={xScale:n.xScale,scale01:n.scale01,scale10:n.scale10,yScale:n.yScale,dx:0,dy:0};i=C5([i],l)[0],l.dx=s.x-i.x,l.dy=s.y-i.y,r=C5(a.points,l)}e.points=e.points.concat(r)}}return H7(e.points)}function it(c,e,t,n){for(var a=new k0.GlyphSet(n),r=0;r<t.length-1;r+=1){var s=t[r],i=t[r+1];s!==i?a.push(r,k0.ttfGlyphLoader(n,r,I7,c,e+s,V7)):a.push(r,k0.glyphLoader(n,r))}return a}function lt(c,e,t,n){var a=new k0.GlyphSet(n);return n._push=function(r){var s=t[r],i=t[r+1];s!==i?a.push(r,k0.ttfGlyphLoader(n,r,I7,c,e+s,V7)):a.push(r,k0.glyphLoader(n,r))},a}function ot(c,e,t,n,a){return a.lowMemory?lt(c,e,t,n):it(c,e,t,n)}var O7={getPath:H7,parse:ot},F7,n2,D7,B5;function R7(c){this.font=c,this.getCommands=function(e){return O7.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function ht(c){return c}function U7(c){return Math.sign(c)*Math.round(Math.abs(c))}function ut(c){return Math.sign(c)*Math.round(Math.abs(c*2))/2}function ft(c){return Math.sign(c)*(Math.round(Math.abs(c)+.5)-.5)}function dt(c){return Math.sign(c)*Math.ceil(Math.abs(c))}function pt(c){return Math.sign(c)*Math.floor(Math.abs(c))}var q7=function(c){var e=this.srPeriod,t=this.srPhase,n=this.srThreshold,a=1;return c<0&&(c=-c,a=-1),c+=n-t,c=Math.trunc(c/e)*e,c+=t,c<0?t*a:c*a},w0={x:1,y:0,axis:"x",distance:function(c,e,t,n){return(t?c.xo:c.x)-(n?e.xo:e.x)},interpolate:function(c,e,t,n){var a,r,s,i,l,o,h;if(!n||n===this){if(a=c.xo-e.xo,r=c.xo-t.xo,l=e.x-e.xo,o=t.x-t.xo,s=Math.abs(a),i=Math.abs(r),h=s+i,h===0){c.x=c.xo+(l+o)/2;return}c.x=c.xo+(l*i+o*s)/h;return}if(a=n.distance(c,e,!0,!0),r=n.distance(c,t,!0,!0),l=n.distance(e,e,!1,!0),o=n.distance(t,t,!1,!0),s=Math.abs(a),i=Math.abs(r),h=s+i,h===0){w0.setRelative(c,c,(l+o)/2,n,!0);return}w0.setRelative(c,c,(l*i+o*s)/h,n,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(c,e,t,n,a){if(!n||n===this){c.x=(a?e.xo:e.x)+t;return}var r=a?e.xo:e.x,s=a?e.yo:e.y,i=r+t*n.x,l=s+t*n.y;c.x=i+(c.y-l)/n.normalSlope},slope:0,touch:function(c){c.xTouched=!0},touched:function(c){return c.xTouched},untouch:function(c){c.xTouched=!1}},H0={x:0,y:1,axis:"y",distance:function(c,e,t,n){return(t?c.yo:c.y)-(n?e.yo:e.y)},interpolate:function(c,e,t,n){var a,r,s,i,l,o,h;if(!n||n===this){if(a=c.yo-e.yo,r=c.yo-t.yo,l=e.y-e.yo,o=t.y-t.yo,s=Math.abs(a),i=Math.abs(r),h=s+i,h===0){c.y=c.yo+(l+o)/2;return}c.y=c.yo+(l*i+o*s)/h;return}if(a=n.distance(c,e,!0,!0),r=n.distance(c,t,!0,!0),l=n.distance(e,e,!1,!0),o=n.distance(t,t,!1,!0),s=Math.abs(a),i=Math.abs(r),h=s+i,h===0){H0.setRelative(c,c,(l+o)/2,n,!0);return}H0.setRelative(c,c,(l*i+o*s)/h,n,!0)},normalSlope:0,setRelative:function(c,e,t,n,a){if(!n||n===this){c.y=(a?e.yo:e.y)+t;return}var r=a?e.xo:e.x,s=a?e.yo:e.y,i=r+t*n.x,l=s+t*n.y;c.y=l+n.normalSlope*(c.x-i)},slope:Number.POSITIVE_INFINITY,touch:function(c){c.yTouched=!0},touched:function(c){return c.yTouched},untouch:function(c){c.yTouched=!1}};Object.freeze(w0);Object.freeze(H0);function X2(c,e){this.x=c,this.y=e,this.axis=void 0,this.slope=e/c,this.normalSlope=-c/e,Object.freeze(this)}X2.prototype.distance=function(c,e,t,n){return this.x*w0.distance(c,e,t,n)+this.y*H0.distance(c,e,t,n)};X2.prototype.interpolate=function(c,e,t,n){var a,r,s,i,l,o,h;if(s=n.distance(c,e,!0,!0),i=n.distance(c,t,!0,!0),a=n.distance(e,e,!1,!0),r=n.distance(t,t,!1,!0),l=Math.abs(s),o=Math.abs(i),h=l+o,h===0){this.setRelative(c,c,(a+r)/2,n,!0);return}this.setRelative(c,c,(a*o+r*l)/h,n,!0)};X2.prototype.setRelative=function(c,e,t,n,a){n=n||this;var r=a?e.xo:e.x,s=a?e.yo:e.y,i=r+t*n.x,l=s+t*n.y,o=n.normalSlope,h=this.slope,f=c.x,u=c.y;c.x=(h*f-o*i+l-u)/(h-o),c.y=h*(c.x-f)+u};X2.prototype.touch=function(c){c.xTouched=!0,c.yTouched=!0};function Z2(c,e){var t=Math.sqrt(c*c+e*e);return c/=t,e/=t,c===1&&e===0?w0:c===0&&e===1?H0:new X2(c,e)}function V0(c,e,t,n){this.x=this.xo=Math.round(c*64)/64,this.y=this.yo=Math.round(e*64)/64,this.lastPointOfContour=t,this.onCurve=n,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}V0.prototype.nextTouched=function(c){for(var e=this.nextPointOnContour;!c.touched(e)&&e!==this;)e=e.nextPointOnContour;return e};V0.prototype.prevTouched=function(c){for(var e=this.prevPointOnContour;!c.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};var _2=Object.freeze(new V0(0,0)),mt={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function $0(c,e){switch(this.env=c,this.stack=[],this.prog=e,c){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=w0,this.round=U7}}R7.prototype.exec=function(c,e){if(typeof e!="number")throw new Error("Point size is not a number!");if(!(this._errorState>2)){var t=this.font,n=this._prepState;if(!n||n.ppem!==e){var a=this._fpgmState;if(!a){$0.prototype=mt,a=this._fpgmState=new $0("fpgm",t.tables.fpgm),a.funcs=[],a.font=t,exports.DEBUG&&(console.log("---EXEC FPGM---"),a.step=-1);try{n2(a)}catch(o){console.log("Hinting error in FPGM:"+o),this._errorState=3;return}}$0.prototype=a,n=this._prepState=new $0("prep",t.tables.prep),n.ppem=e;var r=t.tables.cvt;if(r)for(var s=n.cvt=new Array(r.length),i=e/t.unitsPerEm,l=0;l<r.length;l++)s[l]=r[l]*i;else n.cvt=[];exports.DEBUG&&(console.log("---EXEC PREP---"),n.step=-1);try{n2(n)}catch(o){this._errorState<2&&console.log("Hinting error in PREP:"+o),this._errorState=2}}if(!(this._errorState>1))try{return D7(c,n)}catch(o){this._errorState<1&&(console.log("Hinting error:"+o),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}}};D7=function(c,e){var t=e.ppem/e.font.unitsPerEm,n=t,a=c.components,r,s,i;if($0.prototype=e,!a)i=new $0("glyf",c.instructions),exports.DEBUG&&(console.log("---EXEC GLYPH---"),i.step=-1),B5(c,i,t,n),s=i.gZone;else{var l=e.font;s=[],r=[];for(var o=0;o<a.length;o++){var h=a[o],f=l.glyphs.get(h.glyphIndex);i=new $0("glyf",f.instructions),exports.DEBUG&&(console.log("---EXEC COMP "+o+"---"),i.step=-1),B5(f,i,t,n);for(var u=Math.round(h.dx*t),d=Math.round(h.dy*n),p=i.gZone,m=i.contours,v=0;v<p.length;v++){var g=p[v];g.xTouched=g.yTouched=!1,g.xo=g.x=g.x+u,g.yo=g.y=g.y+d}var y=s.length;s.push.apply(s,p);for(var M=0;M<m.length;M++)r.push(m[M]+y)}c.instructions&&!i.inhibitGridFit&&(i=new $0("glyf",c.instructions),i.gZone=i.z0=i.z1=i.z2=s,i.contours=r,s.push(new V0(0,0),new V0(Math.round(c.advanceWidth*t),0)),exports.DEBUG&&(console.log("---EXEC COMPOSITE---"),i.step=-1),n2(i),s.length-=2)}return s};B5=function(c,e,t,n){for(var a=c.points||[],r=a.length,s=e.gZone=e.z0=e.z1=e.z2=[],i=e.contours=[],l,o=0;o<r;o++)l=a[o],s[o]=new V0(l.x*t,l.y*n,l.lastPointOfContour,l.onCurve);for(var h,f,u=0;u<r;u++)l=s[u],h||(h=l,i.push(u)),l.lastPointOfContour?(l.nextPointOnContour=h,h.prevPointOnContour=l,h=void 0):(f=s[u+1],l.nextPointOnContour=f,f.prevPointOnContour=l);if(!e.inhibitGridFit){if(exports.DEBUG){console.log("PROCESSING GLYPH",e.stack);for(var d=0;d<r;d++)console.log(d,s[d].x,s[d].y)}if(s.push(new V0(0,0),new V0(Math.round(c.advanceWidth*t),0)),n2(e),s.length-=2,exports.DEBUG){console.log("FINISHED GLYPH",e.stack);for(var p=0;p<r;p++)console.log(p,s[p].x,s[p].y)}}};n2=function(c){var e=c.prog;if(e){var t=e.length,n;for(c.ip=0;c.ip<t;c.ip++){if(exports.DEBUG&&c.step++,n=F7[e[c.ip]],!n)throw new Error("unknown instruction: 0x"+Number(e[c.ip]).toString(16));n(c)}}};function R3(c){for(var e=c.tZone=new Array(c.gZone.length),t=0;t<e.length;t++)e[t]=new V0(0,0)}function N7(c,e){var t=c.prog,n=c.ip,a=1,r;do if(r=t[++n],r===88)a++;else if(r===89)a--;else if(r===64)n+=t[n+1]+1;else if(r===65)n+=2*t[n+1]+1;else if(r>=176&&r<=183)n+=r-176+1;else if(r>=184&&r<=191)n+=(r-184+1)*2;else if(e&&a===1&&r===27)break;while(a>0);c.ip=n}function H6(c,e){exports.DEBUG&&console.log(e.step,"SVTCA["+c.axis+"]"),e.fv=e.pv=e.dpv=c}function V6(c,e){exports.DEBUG&&console.log(e.step,"SPVTCA["+c.axis+"]"),e.pv=e.dpv=c}function O6(c,e){exports.DEBUG&&console.log(e.step,"SFVTCA["+c.axis+"]"),e.fv=c}function F6(c,e){var t=e.stack,n=t.pop(),a=t.pop(),r=e.z2[n],s=e.z1[a];exports.DEBUG&&console.log("SPVTL["+c+"]",n,a);var i,l;c?(i=r.y-s.y,l=s.x-r.x):(i=s.x-r.x,l=s.y-r.y),e.pv=e.dpv=Z2(i,l)}function D6(c,e){var t=e.stack,n=t.pop(),a=t.pop(),r=e.z2[n],s=e.z1[a];exports.DEBUG&&console.log("SFVTL["+c+"]",n,a);var i,l;c?(i=r.y-s.y,l=s.x-r.x):(i=s.x-r.x,l=s.y-r.y),e.fv=Z2(i,l)}function vt(c){var e=c.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(c.step,"SPVFS[]",t,n),c.pv=c.dpv=Z2(n,t)}function gt(c){var e=c.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(c.step,"SPVFS[]",t,n),c.fv=Z2(n,t)}function yt(c){var e=c.stack,t=c.pv;exports.DEBUG&&console.log(c.step,"GPV[]"),e.push(t.x*16384),e.push(t.y*16384)}function Mt(c){var e=c.stack,t=c.fv;exports.DEBUG&&console.log(c.step,"GFV[]"),e.push(t.x*16384),e.push(t.y*16384)}function xt(c){c.fv=c.pv,exports.DEBUG&&console.log(c.step,"SFVTPV[]")}function bt(c){var e=c.stack,t=e.pop(),n=e.pop(),a=e.pop(),r=e.pop(),s=e.pop(),i=c.z0,l=c.z1,o=i[t],h=i[n],f=l[a],u=l[r],d=c.z2[s];exports.DEBUG&&console.log("ISECT[], ",t,n,a,r,s);var p=o.x,m=o.y,v=h.x,g=h.y,y=f.x,M=f.y,A=u.x,z=u.y,E=(p-v)*(M-z)-(m-g)*(y-A),k=p*g-m*v,C=y*z-M*A;d.x=(k*(y-A)-C*(p-v))/E,d.y=(k*(M-z)-C*(m-g))/E}function zt(c){c.rp0=c.stack.pop(),exports.DEBUG&&console.log(c.step,"SRP0[]",c.rp0)}function wt(c){c.rp1=c.stack.pop(),exports.DEBUG&&console.log(c.step,"SRP1[]",c.rp1)}function kt(c){c.rp2=c.stack.pop(),exports.DEBUG&&console.log(c.step,"SRP2[]",c.rp2)}function Lt(c){var e=c.stack.pop();switch(exports.DEBUG&&console.log(c.step,"SZP0[]",e),c.zp0=e,e){case 0:c.tZone||R3(c),c.z0=c.tZone;break;case 1:c.z0=c.gZone;break;default:throw new Error("Invalid zone pointer")}}function St(c){var e=c.stack.pop();switch(exports.DEBUG&&console.log(c.step,"SZP1[]",e),c.zp1=e,e){case 0:c.tZone||R3(c),c.z1=c.tZone;break;case 1:c.z1=c.gZone;break;default:throw new Error("Invalid zone pointer")}}function At(c){var e=c.stack.pop();switch(exports.DEBUG&&console.log(c.step,"SZP2[]",e),c.zp2=e,e){case 0:c.tZone||R3(c),c.z2=c.tZone;break;case 1:c.z2=c.gZone;break;default:throw new Error("Invalid zone pointer")}}function Ct(c){var e=c.stack.pop();switch(exports.DEBUG&&console.log(c.step,"SZPS[]",e),c.zp0=c.zp1=c.zp2=e,e){case 0:c.tZone||R3(c),c.z0=c.z1=c.z2=c.tZone;break;case 1:c.z0=c.z1=c.z2=c.gZone;break;default:throw new Error("Invalid zone pointer")}}function Pt(c){c.loop=c.stack.pop(),exports.DEBUG&&console.log(c.step,"SLOOP[]",c.loop)}function Et(c){exports.DEBUG&&console.log(c.step,"RTG[]"),c.round=U7}function Tt(c){exports.DEBUG&&console.log(c.step,"RTHG[]"),c.round=ft}function It(c){var e=c.stack.pop();exports.DEBUG&&console.log(c.step,"SMD[]",e),c.minDis=e/64}function Ht(c){exports.DEBUG&&console.log(c.step,"ELSE[]"),N7(c,!1)}function Vt(c){var e=c.stack.pop();exports.DEBUG&&console.log(c.step,"JMPR[]",e),c.ip+=e-1}function Ot(c){var e=c.stack.pop();exports.DEBUG&&console.log(c.step,"SCVTCI[]",e),c.cvCutIn=e/64}function Ft(c){var e=c.stack;exports.DEBUG&&console.log(c.step,"DUP[]"),e.push(e[e.length-1])}function P5(c){exports.DEBUG&&console.log(c.step,"POP[]"),c.stack.pop()}function Dt(c){exports.DEBUG&&console.log(c.step,"CLEAR[]"),c.stack.length=0}function Rt(c){var e=c.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(c.step,"SWAP[]"),e.push(t),e.push(n)}function Ut(c){var e=c.stack;exports.DEBUG&&console.log(c.step,"DEPTH[]"),e.push(e.length)}function qt(c){var e=c.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(c.step,"LOOPCALL[]",t,n);var a=c.ip,r=c.prog;c.prog=c.funcs[t];for(var s=0;s<n;s++)n2(c),exports.DEBUG&&console.log(++c.step,s+1<n?"next loopcall":"done loopcall",s);c.ip=a,c.prog=r}function Nt(c){var e=c.stack.pop();exports.DEBUG&&console.log(c.step,"CALL[]",e);var t=c.ip,n=c.prog;c.prog=c.funcs[e],n2(c),c.ip=t,c.prog=n,exports.DEBUG&&console.log(++c.step,"returning from",e)}function Bt(c){var e=c.stack,t=e.pop();exports.DEBUG&&console.log(c.step,"CINDEX[]",t),e.push(e[e.length-t])}function $t(c){var e=c.stack,t=e.pop();exports.DEBUG&&console.log(c.step,"MINDEX[]",t),e.push(e.splice(e.length-t,1)[0])}function Gt(c){if(c.env!=="fpgm")throw new Error("FDEF not allowed here");var e=c.stack,t=c.prog,n=c.ip,a=e.pop(),r=n;for(exports.DEBUG&&console.log(c.step,"FDEF[]",a);t[++n]!==45;);c.ip=n,c.funcs[a]=t.slice(r+1,n)}function R6(c,e){var t=e.stack.pop(),n=e.z0[t],a=e.fv,r=e.pv;exports.DEBUG&&console.log(e.step,"MDAP["+c+"]",t);var s=r.distance(n,_2);c&&(s=e.round(s)),a.setRelative(n,_2,s,r),a.touch(n),e.rp0=e.rp1=t}function U6(c,e){var t=e.z2,n=t.length-2,a,r,s;exports.DEBUG&&console.log(e.step,"IUP["+c.axis+"]");for(var i=0;i<n;i++)a=t[i],!c.touched(a)&&(r=a.prevTouched(c),r!==a&&(s=a.nextTouched(c),r===s&&c.setRelative(a,a,c.distance(r,r,!1,!0),c,!0),c.interpolate(a,r,s,c)))}function q6(c,e){for(var t=e.stack,n=c?e.rp1:e.rp2,a=(c?e.z0:e.z1)[n],r=e.fv,s=e.pv,i=e.loop,l=e.z2;i--;){var o=t.pop(),h=l[o],f=s.distance(a,a,!1,!0);r.setRelative(h,h,f,s),r.touch(h),exports.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-i)+": ":"")+"SHP["+(c?"rp1":"rp2")+"]",o)}e.loop=1}function N6(c,e){var t=e.stack,n=c?e.rp1:e.rp2,a=(c?e.z0:e.z1)[n],r=e.fv,s=e.pv,i=t.pop(),l=e.z2[e.contours[i]],o=l;exports.DEBUG&&console.log(e.step,"SHC["+c+"]",i);var h=s.distance(a,a,!1,!0);do o!==a&&r.setRelative(o,o,h,s),o=o.nextPointOnContour;while(o!==l)}function B6(c,e){var t=e.stack,n=c?e.rp1:e.rp2,a=(c?e.z0:e.z1)[n],r=e.fv,s=e.pv,i=t.pop();exports.DEBUG&&console.log(e.step,"SHZ["+c+"]",i);var l;switch(i){case 0:l=e.tZone;break;case 1:l=e.gZone;break;default:throw new Error("Invalid zone")}for(var o,h=s.distance(a,a,!1,!0),f=l.length-2,u=0;u<f;u++)o=l[u],r.setRelative(o,o,h,s)}function _t(c){for(var e=c.stack,t=c.loop,n=c.fv,a=e.pop()/64,r=c.z2;t--;){var s=e.pop(),i=r[s];exports.DEBUG&&console.log(c.step,(c.loop>1?"loop "+(c.loop-t)+": ":"")+"SHPIX[]",s,a),n.setRelative(i,i,a),n.touch(i)}c.loop=1}function jt(c){for(var e=c.stack,t=c.rp1,n=c.rp2,a=c.loop,r=c.z0[t],s=c.z1[n],i=c.fv,l=c.dpv,o=c.z2;a--;){var h=e.pop(),f=o[h];exports.DEBUG&&console.log(c.step,(c.loop>1?"loop "+(c.loop-a)+": ":"")+"IP[]",h,t,"<->",n),i.interpolate(f,r,s,l),i.touch(f)}c.loop=1}function $6(c,e){var t=e.stack,n=t.pop()/64,a=t.pop(),r=e.z1[a],s=e.z0[e.rp0],i=e.fv,l=e.pv;i.setRelative(r,s,n,l),i.touch(r),exports.DEBUG&&console.log(e.step,"MSIRP["+c+"]",n,a),e.rp1=e.rp0,e.rp2=a,c&&(e.rp0=a)}function Wt(c){for(var e=c.stack,t=c.rp0,n=c.z0[t],a=c.loop,r=c.fv,s=c.pv,i=c.z1;a--;){var l=e.pop(),o=i[l];exports.DEBUG&&console.log(c.step,(c.loop>1?"loop "+(c.loop-a)+": ":"")+"ALIGNRP[]",l),r.setRelative(o,n,0,s),r.touch(o)}c.loop=1}function Xt(c){exports.DEBUG&&console.log(c.step,"RTDG[]"),c.round=ut}function G6(c,e){var t=e.stack,n=t.pop(),a=t.pop(),r=e.z0[a],s=e.fv,i=e.pv,l=e.cvt[n];exports.DEBUG&&console.log(e.step,"MIAP["+c+"]",n,"(",l,")",a);var o=i.distance(r,_2);c&&(Math.abs(o-l)<e.cvCutIn&&(o=l),o=e.round(o)),s.setRelative(r,_2,o,i),e.zp0===0&&(r.xo=r.x,r.yo=r.y),s.touch(r),e.rp0=e.rp1=a}function Zt(c){var e=c.prog,t=c.ip,n=c.stack,a=e[++t];exports.DEBUG&&console.log(c.step,"NPUSHB[]",a);for(var r=0;r<a;r++)n.push(e[++t]);c.ip=t}function Yt(c){var e=c.ip,t=c.prog,n=c.stack,a=t[++e];exports.DEBUG&&console.log(c.step,"NPUSHW[]",a);for(var r=0;r<a;r++){var s=t[++e]<<8|t[++e];s&32768&&(s=-((s^65535)+1)),n.push(s)}c.ip=e}function Kt(c){var e=c.stack,t=c.store;t||(t=c.store=[]);var n=e.pop(),a=e.pop();exports.DEBUG&&console.log(c.step,"WS",n,a),t[a]=n}function Jt(c){var e=c.stack,t=c.store,n=e.pop();exports.DEBUG&&console.log(c.step,"RS",n);var a=t&&t[n]||0;e.push(a)}function Qt(c){var e=c.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(c.step,"WCVTP",t,n),c.cvt[n]=t/64}function ec(c){var e=c.stack,t=e.pop();exports.DEBUG&&console.log(c.step,"RCVT",t),e.push(c.cvt[t]*64)}function _6(c,e){var t=e.stack,n=t.pop(),a=e.z2[n];exports.DEBUG&&console.log(e.step,"GC["+c+"]",n),t.push(e.dpv.distance(a,_2,c,!1)*64)}function j6(c,e){var t=e.stack,n=t.pop(),a=t.pop(),r=e.z1[n],s=e.z0[a],i=e.dpv.distance(s,r,c,c);exports.DEBUG&&console.log(e.step,"MD["+c+"]",n,a,"->",i),e.stack.push(Math.round(i*64))}function tc(c){exports.DEBUG&&console.log(c.step,"MPPEM[]"),c.stack.push(c.ppem)}function cc(c){exports.DEBUG&&console.log(c.step,"FLIPON[]"),c.autoFlip=!0}function nc(c){var e=c.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(c.step,"LT[]",t,n),e.push(n<t?1:0)}function ac(c){var e=c.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(c.step,"LTEQ[]",t,n),e.push(n<=t?1:0)}function rc(c){var e=c.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(c.step,"GT[]",t,n),e.push(n>t?1:0)}function sc(c){var e=c.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(c.step,"GTEQ[]",t,n),e.push(n>=t?1:0)}function ic(c){var e=c.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(c.step,"EQ[]",t,n),e.push(t===n?1:0)}function lc(c){var e=c.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(c.step,"NEQ[]",t,n),e.push(t!==n?1:0)}function oc(c){var e=c.stack,t=e.pop();exports.DEBUG&&console.log(c.step,"ODD[]",t),e.push(Math.trunc(t)%2?1:0)}function hc(c){var e=c.stack,t=e.pop();exports.DEBUG&&console.log(c.step,"EVEN[]",t),e.push(Math.trunc(t)%2?0:1)}function uc(c){var e=c.stack.pop();exports.DEBUG&&console.log(c.step,"IF[]",e),e||(N7(c,!0),exports.DEBUG&&console.log(c.step,"EIF[]"))}function fc(c){exports.DEBUG&&console.log(c.step,"EIF[]")}function dc(c){var e=c.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(c.step,"AND[]",t,n),e.push(t&&n?1:0)}function pc(c){var e=c.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(c.step,"OR[]",t,n),e.push(t||n?1:0)}function mc(c){var e=c.stack,t=e.pop();exports.DEBUG&&console.log(c.step,"NOT[]",t),e.push(t?0:1)}function E5(c,e){var t=e.stack,n=t.pop(),a=e.fv,r=e.pv,s=e.ppem,i=e.deltaBase+(c-1)*16,l=e.deltaShift,o=e.z0;exports.DEBUG&&console.log(e.step,"DELTAP["+c+"]",n,t);for(var h=0;h<n;h++){var f=t.pop(),u=t.pop(),d=i+((u&240)>>4);if(d===s){var p=(u&15)-8;p>=0&&p++,exports.DEBUG&&console.log(e.step,"DELTAPFIX",f,"by",p*l);var m=o[f];a.setRelative(m,m,p*l,r)}}}function vc(c){var e=c.stack,t=e.pop();exports.DEBUG&&console.log(c.step,"SDB[]",t),c.deltaBase=t}function gc(c){var e=c.stack,t=e.pop();exports.DEBUG&&console.log(c.step,"SDS[]",t),c.deltaShift=Math.pow(.5,t)}function yc(c){var e=c.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(c.step,"ADD[]",t,n),e.push(n+t)}function Mc(c){var e=c.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(c.step,"SUB[]",t,n),e.push(n-t)}function xc(c){var e=c.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(c.step,"DIV[]",t,n),e.push(n*64/t)}function bc(c){var e=c.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(c.step,"MUL[]",t,n),e.push(n*t/64)}function zc(c){var e=c.stack,t=e.pop();exports.DEBUG&&console.log(c.step,"ABS[]",t),e.push(Math.abs(t))}function wc(c){var e=c.stack,t=e.pop();exports.DEBUG&&console.log(c.step,"NEG[]",t),e.push(-t)}function kc(c){var e=c.stack,t=e.pop();exports.DEBUG&&console.log(c.step,"FLOOR[]",t),e.push(Math.floor(t/64)*64)}function Lc(c){var e=c.stack,t=e.pop();exports.DEBUG&&console.log(c.step,"CEILING[]",t),e.push(Math.ceil(t/64)*64)}function P3(c,e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"ROUND[]"),t.push(e.round(n/64)*64)}function Sc(c){var e=c.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(c.step,"WCVTF[]",t,n),c.cvt[n]=t*c.ppem/c.font.unitsPerEm}function T5(c,e){var t=e.stack,n=t.pop(),a=e.ppem,r=e.deltaBase+(c-1)*16,s=e.deltaShift;exports.DEBUG&&console.log(e.step,"DELTAC["+c+"]",n,t);for(var i=0;i<n;i++){var l=t.pop(),o=t.pop(),h=r+((o&240)>>4);if(h===a){var f=(o&15)-8;f>=0&&f++;var u=f*s;exports.DEBUG&&console.log(e.step,"DELTACFIX",l,"by",u),e.cvt[l]+=u}}}function Ac(c){var e=c.stack.pop();exports.DEBUG&&console.log(c.step,"SROUND[]",e),c.round=q7;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(c.srPeriod=t,e&48){case 0:c.srPhase=0;break;case 16:c.srPhase=.25*t;break;case 32:c.srPhase=.5*t;break;case 48:c.srPhase=.75*t;break;default:throw new Error("invalid SROUND value")}e&=15,e===0?c.srThreshold=0:c.srThreshold=(e/8-.5)*t}function Cc(c){var e=c.stack.pop();exports.DEBUG&&console.log(c.step,"S45ROUND[]",e),c.round=q7;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(c.srPeriod=t,e&48){case 0:c.srPhase=0;break;case 16:c.srPhase=.25*t;break;case 32:c.srPhase=.5*t;break;case 48:c.srPhase=.75*t;break;default:throw new Error("invalid S45ROUND value")}e&=15,e===0?c.srThreshold=0:c.srThreshold=(e/8-.5)*t}function Pc(c){exports.DEBUG&&console.log(c.step,"ROFF[]"),c.round=ht}function Ec(c){exports.DEBUG&&console.log(c.step,"RUTG[]"),c.round=dt}function Tc(c){exports.DEBUG&&console.log(c.step,"RDTG[]"),c.round=pt}function Ic(c){var e=c.stack.pop();exports.DEBUG&&console.log(c.step,"SCANCTRL[]",e)}function W6(c,e){var t=e.stack,n=t.pop(),a=t.pop(),r=e.z2[n],s=e.z1[a];exports.DEBUG&&console.log(e.step,"SDPVTL["+c+"]",n,a);var i,l;c?(i=r.y-s.y,l=s.x-r.x):(i=s.x-r.x,l=s.y-r.y),e.dpv=Z2(i,l)}function Hc(c){var e=c.stack,t=e.pop(),n=0;exports.DEBUG&&console.log(c.step,"GETINFO[]",t),t&1&&(n=35),t&32&&(n|=4096),e.push(n)}function Vc(c){var e=c.stack,t=e.pop(),n=e.pop(),a=e.pop();exports.DEBUG&&console.log(c.step,"ROLL[]"),e.push(n),e.push(t),e.push(a)}function Oc(c){var e=c.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(c.step,"MAX[]",t,n),e.push(Math.max(n,t))}function Fc(c){var e=c.stack,t=e.pop(),n=e.pop();exports.DEBUG&&console.log(c.step,"MIN[]",t,n),e.push(Math.min(n,t))}function Dc(c){var e=c.stack.pop();exports.DEBUG&&console.log(c.step,"SCANTYPE[]",e)}function Rc(c){var e=c.stack.pop(),t=c.stack.pop();switch(exports.DEBUG&&console.log(c.step,"INSTCTRL[]",e,t),e){case 1:c.inhibitGridFit=!!t;return;case 2:c.ignoreCvt=!!t;return;default:throw new Error("invalid INSTCTRL[] selector")}}function q0(c,e){var t=e.stack,n=e.prog,a=e.ip;exports.DEBUG&&console.log(e.step,"PUSHB["+c+"]");for(var r=0;r<c;r++)t.push(n[++a]);e.ip=a}function N0(c,e){var t=e.ip,n=e.prog,a=e.stack;exports.DEBUG&&console.log(e.ip,"PUSHW["+c+"]");for(var r=0;r<c;r++){var s=n[++t]<<8|n[++t];s&32768&&(s=-((s^65535)+1)),a.push(s)}e.ip=t}function R(c,e,t,n,a,r){var s=r.stack,i=c&&s.pop(),l=s.pop(),o=r.rp0,h=r.z0[o],f=r.z1[l],u=r.minDis,d=r.fv,p=r.dpv,m,v,g,y;v=m=p.distance(f,h,!0,!0),g=v>=0?1:-1,v=Math.abs(v),c&&(y=r.cvt[i],n&&Math.abs(v-y)<r.cvCutIn&&(v=y)),t&&v<u&&(v=u),n&&(v=r.round(v)),d.setRelative(f,h,g*v,p),d.touch(f),exports.DEBUG&&console.log(r.step,(c?"MIRP[":"MDRP[")+(e?"M":"m")+(t?">":"_")+(n?"R":"_")+(a===0?"Gr":a===1?"Bl":a===2?"Wh":"")+"]",c?i+"("+r.cvt[i]+","+y+")":"",l,"(d =",m,"->",g*v,")"),r.rp1=r.rp0,r.rp2=l,e&&(r.rp0=l)}F7=[H6.bind(void 0,H0),H6.bind(void 0,w0),V6.bind(void 0,H0),V6.bind(void 0,w0),O6.bind(void 0,H0),O6.bind(void 0,w0),F6.bind(void 0,0),F6.bind(void 0,1),D6.bind(void 0,0),D6.bind(void 0,1),vt,gt,yt,Mt,xt,bt,zt,wt,kt,Lt,St,At,Ct,Pt,Et,Tt,It,Ht,Vt,Ot,void 0,void 0,Ft,P5,Dt,Rt,Ut,Bt,$t,void 0,void 0,void 0,qt,Nt,Gt,void 0,R6.bind(void 0,0),R6.bind(void 0,1),U6.bind(void 0,H0),U6.bind(void 0,w0),q6.bind(void 0,0),q6.bind(void 0,1),N6.bind(void 0,0),N6.bind(void 0,1),B6.bind(void 0,0),B6.bind(void 0,1),_t,jt,$6.bind(void 0,0),$6.bind(void 0,1),Wt,Xt,G6.bind(void 0,0),G6.bind(void 0,1),Zt,Yt,Kt,Jt,Qt,ec,_6.bind(void 0,0),_6.bind(void 0,1),void 0,j6.bind(void 0,0),j6.bind(void 0,1),tc,void 0,cc,void 0,void 0,nc,ac,rc,sc,ic,lc,oc,hc,uc,fc,dc,pc,mc,E5.bind(void 0,1),vc,gc,yc,Mc,xc,bc,zc,wc,kc,Lc,P3.bind(void 0,0),P3.bind(void 0,1),P3.bind(void 0,2),P3.bind(void 0,3),void 0,void 0,void 0,void 0,Sc,E5.bind(void 0,2),E5.bind(void 0,3),T5.bind(void 0,1),T5.bind(void 0,2),T5.bind(void 0,3),Ac,Cc,void 0,void 0,Pc,void 0,Ec,Tc,P5,P5,void 0,void 0,void 0,void 0,void 0,Ic,W6.bind(void 0,0),W6.bind(void 0,1),Hc,void 0,Vc,Oc,Fc,Dc,Rc,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,q0.bind(void 0,1),q0.bind(void 0,2),q0.bind(void 0,3),q0.bind(void 0,4),q0.bind(void 0,5),q0.bind(void 0,6),q0.bind(void 0,7),q0.bind(void 0,8),N0.bind(void 0,1),N0.bind(void 0,2),N0.bind(void 0,3),N0.bind(void 0,4),N0.bind(void 0,5),N0.bind(void 0,6),N0.bind(void 0,7),N0.bind(void 0,8),R.bind(void 0,0,0,0,0,0),R.bind(void 0,0,0,0,0,1),R.bind(void 0,0,0,0,0,2),R.bind(void 0,0,0,0,0,3),R.bind(void 0,0,0,0,1,0),R.bind(void 0,0,0,0,1,1),R.bind(void 0,0,0,0,1,2),R.bind(void 0,0,0,0,1,3),R.bind(void 0,0,0,1,0,0),R.bind(void 0,0,0,1,0,1),R.bind(void 0,0,0,1,0,2),R.bind(void 0,0,0,1,0,3),R.bind(void 0,0,0,1,1,0),R.bind(void 0,0,0,1,1,1),R.bind(void 0,0,0,1,1,2),R.bind(void 0,0,0,1,1,3),R.bind(void 0,0,1,0,0,0),R.bind(void 0,0,1,0,0,1),R.bind(void 0,0,1,0,0,2),R.bind(void 0,0,1,0,0,3),R.bind(void 0,0,1,0,1,0),R.bind(void 0,0,1,0,1,1),R.bind(void 0,0,1,0,1,2),R.bind(void 0,0,1,0,1,3),R.bind(void 0,0,1,1,0,0),R.bind(void 0,0,1,1,0,1),R.bind(void 0,0,1,1,0,2),R.bind(void 0,0,1,1,0,3),R.bind(void 0,0,1,1,1,0),R.bind(void 0,0,1,1,1,1),R.bind(void 0,0,1,1,1,2),R.bind(void 0,0,1,1,1,3),R.bind(void 0,1,0,0,0,0),R.bind(void 0,1,0,0,0,1),R.bind(void 0,1,0,0,0,2),R.bind(void 0,1,0,0,0,3),R.bind(void 0,1,0,0,1,0),R.bind(void 0,1,0,0,1,1),R.bind(void 0,1,0,0,1,2),R.bind(void 0,1,0,0,1,3),R.bind(void 0,1,0,1,0,0),R.bind(void 0,1,0,1,0,1),R.bind(void 0,1,0,1,0,2),R.bind(void 0,1,0,1,0,3),R.bind(void 0,1,0,1,1,0),R.bind(void 0,1,0,1,1,1),R.bind(void 0,1,0,1,1,2),R.bind(void 0,1,0,1,1,3),R.bind(void 0,1,1,0,0,0),R.bind(void 0,1,1,0,0,1),R.bind(void 0,1,1,0,0,2),R.bind(void 0,1,1,0,0,3),R.bind(void 0,1,1,0,1,0),R.bind(void 0,1,1,0,1,1),R.bind(void 0,1,1,0,1,2),R.bind(void 0,1,1,0,1,3),R.bind(void 0,1,1,1,0,0),R.bind(void 0,1,1,1,0,1),R.bind(void 0,1,1,1,0,2),R.bind(void 0,1,1,1,0,3),R.bind(void 0,1,1,1,1,0),R.bind(void 0,1,1,1,1,1),R.bind(void 0,1,1,1,1,2),R.bind(void 0,1,1,1,1,3)];function M2(c){this.char=c,this.state={},this.activeState=null}function K5(c,e,t){this.contextName=t,this.startIndex=c,this.endOffset=e}function Uc(c,e,t){this.contextName=c,this.openRange=null,this.ranges=[],this.checkStart=e,this.checkEnd=t}function f0(c,e){this.context=c,this.index=e,this.length=c.length,this.current=c[e],this.backtrack=c.slice(0,e),this.lookahead=c.slice(e+1)}function U3(c){this.eventId=c,this.subscribers=[]}function qc(c){var e=this,t=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];t.forEach(function(a){Object.defineProperty(e.events,a,{value:new U3(a)})}),c&&t.forEach(function(a){var r=c[a];typeof r=="function"&&e.events[a].subscribe(r)});var n=["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"];n.forEach(function(a){e.events[a].subscribe(e.updateContextsRanges)})}function L1(c){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],qc.call(this,c)}M2.prototype.setState=function(c,e){return this.state[c]=e,this.activeState={key:c,value:this.state[c]},this.activeState};M2.prototype.getState=function(c){return this.state[c]||null};L1.prototype.inboundIndex=function(c){return c>=0&&c<this.tokens.length};L1.prototype.composeRUD=function(c){var e=this,t=!0,n=c.map(function(r){return e[r[0]].apply(e,r.slice(1).concat(t))}),a=function(r){return typeof r=="object"&&r.hasOwnProperty("FAIL")};if(n.every(a))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:n.filter(a)};this.dispatch("composeRUD",[n.filter(function(r){return!a(r)})])};L1.prototype.replaceRange=function(c,e,t,n){e=e!==null?e:this.tokens.length;var a=t.every(function(s){return s instanceof M2});if(!isNaN(c)&&this.inboundIndex(c)&&a){var r=this.tokens.splice.apply(this.tokens,[c,e].concat(t));return n||this.dispatch("replaceToken",[c,e,t]),[r,t]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}};L1.prototype.replaceToken=function(c,e,t){if(!isNaN(c)&&this.inboundIndex(c)&&e instanceof M2){var n=this.tokens.splice(c,1,e);return t||this.dispatch("replaceToken",[c,e]),[n[0],e]}else return{FAIL:"replaceToken: invalid token or index."}};L1.prototype.removeRange=function(c,e,t){e=isNaN(e)?this.tokens.length:e;var n=this.tokens.splice(c,e);return t||this.dispatch("removeRange",[n,c,e]),n};L1.prototype.removeToken=function(c,e){if(!isNaN(c)&&this.inboundIndex(c)){var t=this.tokens.splice(c,1);return e||this.dispatch("removeToken",[t,c]),t}else return{FAIL:"removeToken: invalid token index."}};L1.prototype.insertToken=function(c,e,t){var n=c.every(function(a){return a instanceof M2});return n?(this.tokens.splice.apply(this.tokens,[e,0].concat(c)),t||this.dispatch("insertToken",[c,e]),c):{FAIL:"insertToken: invalid token(s)."}};L1.prototype.registerModifier=function(c,e,t){this.events.newToken.subscribe(function(n,a){var r=[n,a],s=e===null||e.apply(this,r)===!0,i=[n,a];if(s){var l=t.apply(this,i);n.setState(c,l)}}),this.registeredModifiers.push(c)};U3.prototype.subscribe=function(c){return typeof c=="function"?this.subscribers.push(c)-1:{FAIL:"invalid '"+this.eventId+"' event handler"}};U3.prototype.unsubscribe=function(c){this.subscribers.splice(c,1)};f0.prototype.setCurrentIndex=function(c){this.index=c,this.current=this.context[c],this.backtrack=this.context.slice(0,c),this.lookahead=this.context.slice(c+1)};f0.prototype.get=function(c){switch(!0){case c===0:return this.current;case(c<0&&Math.abs(c)<=this.backtrack.length):return this.backtrack.slice(c)[0];case(c>0&&c<=this.lookahead.length):return this.lookahead[c-1];default:return null}};L1.prototype.rangeToText=function(c){if(c instanceof K5)return this.getRangeTokens(c).map(function(e){return e.char}).join("")};L1.prototype.getText=function(){return this.tokens.map(function(c){return c.char}).join("")};L1.prototype.getContext=function(c){var e=this.registeredContexts[c];return e||null};L1.prototype.on=function(c,e){var t=this.events[c];return t?t.subscribe(e):null};L1.prototype.dispatch=function(c,e){var t=this,n=this.events[c];n instanceof U3&&n.subscribers.forEach(function(a){a.apply(t,e||[])})};L1.prototype.registerContextChecker=function(c,e,t){if(this.getContext(c))return{FAIL:"context name '"+c+"' is already registered."};if(typeof e!="function")return{FAIL:"missing context start check."};if(typeof t!="function")return{FAIL:"missing context end check."};var n=new Uc(c,e,t);return this.registeredContexts[c]=n,this.contextCheckers.push(n),n};L1.prototype.getRangeTokens=function(c){var e=c.startIndex+c.endOffset;return[].concat(this.tokens.slice(c.startIndex,e))};L1.prototype.getContextRanges=function(c){var e=this.getContext(c);return e?e.ranges:{FAIL:"context checker '"+c+"' is not registered."}};L1.prototype.resetContextsRanges=function(){var c=this.registeredContexts;for(var e in c)if(c.hasOwnProperty(e)){var t=c[e];t.ranges=[]}};L1.prototype.updateContextsRanges=function(){this.resetContextsRanges();for(var c=this.tokens.map(function(n){return n.char}),e=0;e<c.length;e++){var t=new f0(c,e);this.runContextCheck(t)}this.dispatch("updateContextsRanges",[this.registeredContexts])};L1.prototype.setEndOffset=function(c,e){var t=this.getContext(e).openRange.startIndex,n=new K5(t,c,e),a=this.getContext(e).ranges;return n.rangeId=e+"."+a.length,a.push(n),this.getContext(e).openRange=null,n};L1.prototype.runContextCheck=function(c){var e=this,t=c.index;this.contextCheckers.forEach(function(n){var a=n.contextName,r=e.getContext(a).openRange;if(!r&&n.checkStart(c)&&(r=new K5(t,null,a),e.getContext(a).openRange=r,e.dispatch("contextStart",[a,t])),r&&n.checkEnd(c)){var s=t-r.startIndex+1,i=e.setEndOffset(s,a);e.dispatch("contextEnd",[a,i])}})};L1.prototype.tokenize=function(c){this.tokens=[],this.resetContextsRanges();var e=Array.from(c);this.dispatch("start");for(var t=0;t<e.length;t++){var n=e[t],a=new f0(e,t);this.dispatch("next",[a]),this.runContextCheck(a);var r=new M2(n);this.tokens.push(r),this.dispatch("newToken",[r,a])}return this.dispatch("end",[this.tokens]),this.tokens};function G0(c){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(c)}function B7(c){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(c)}function _0(c){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(c)}function T3(c){return/[A-z]/.test(c)}function Nc(c){return/\s/.test(c)}function t0(c){this.font=c,this.features={}}function c2(c){this.id=c.id,this.tag=c.tag,this.substitution=c.substitution}function Y2(c,e){if(!c)return-1;switch(e.format){case 1:return e.glyphs.indexOf(c);case 2:for(var t=e.ranges,n=0;n<t.length;n++){var a=t[n];if(c>=a.start&&c<=a.end){var r=c-a.start;return a.index+r}}break;default:return-1}return-1}function Bc(c,e){var t=Y2(c,e.coverage);return t===-1?null:c+e.deltaGlyphId}function $c(c,e){var t=Y2(c,e.coverage);return t===-1?null:e.substitute[t]}function I5(c,e){for(var t=[],n=0;n<c.length;n++){var a=c[n],r=e.current;r=Array.isArray(r)?r[0]:r;var s=Y2(r,a);s!==-1&&t.push(s)}return t.length!==c.length?-1:t}function Gc(c,e){var t=e.inputCoverage.length+e.lookaheadCoverage.length+e.backtrackCoverage.length;if(c.context.length<t)return[];var n=I5(e.inputCoverage,c);if(n===-1)return[];var a=e.inputCoverage.length-1;if(c.lookahead.length<e.lookaheadCoverage.length)return[];for(var r=c.lookahead.slice(a);r.length&&_0(r[0].char);)r.shift();var s=new f0(r,0),i=I5(e.lookaheadCoverage,s),l=[].concat(c.backtrack);for(l.reverse();l.length&&_0(l[0].char);)l.shift();if(l.length<e.backtrackCoverage.length)return[];var o=new f0(l,0),h=I5(e.backtrackCoverage,o),f=n.length===e.inputCoverage.length&&i.length===e.lookaheadCoverage.length&&h.length===e.backtrackCoverage.length,u=[];if(f)for(var d=0;d<e.lookupRecords.length;d++)for(var p=e.lookupRecords[d],m=p.lookupListIndex,v=this.getLookupByIndex(m),g=0;g<v.subtables.length;g++){var y=v.subtables[g],M=this.getLookupMethod(v,y),A=this.getSubstitutionType(v,y);if(A==="12")for(var z=0;z<n.length;z++){var E=c.get(z),k=M(E);k&&u.push(k)}}return u}function _c(c,e){var t=c.current,n=Y2(t,e.coverage);if(n===-1)return null;for(var a,r=e.ligatureSets[n],s=0;s<r.length;s++){a=r[s];for(var i=0;i<a.components.length;i++){var l=c.lookahead[i],o=a.components[i];if(l!==o)break;if(i===a.components.length-1)return a}}return null}function jc(c,e){var t=Y2(c,e.coverage);return t===-1?null:e.sequences[t]}t0.prototype.getDefaultScriptFeaturesIndexes=function(){for(var c=this.font.tables.gsub.scripts,e=0;e<c.length;e++){var t=c[e];if(t.tag==="DFLT")return t.script.defaultLangSys.featureIndexes}return[]};t0.prototype.getScriptFeaturesIndexes=function(c){var e=this.font.tables;if(!e.gsub)return[];if(!c)return this.getDefaultScriptFeaturesIndexes();for(var t=this.font.tables.gsub.scripts,n=0;n<t.length;n++){var a=t[n];if(a.tag===c&&a.script.defaultLangSys)return a.script.defaultLangSys.featureIndexes;var r=a.langSysRecords;if(r)for(var s=0;s<r.length;s++){var i=r[s];if(i.tag===c){var l=i.langSys;return l.featureIndexes}}}return this.getDefaultScriptFeaturesIndexes()};t0.prototype.mapTagsToFeatures=function(c,e){for(var t={},n=0;n<c.length;n++){var a=c[n].tag,r=c[n].feature;t[a]=r}this.features[e].tags=t};t0.prototype.getScriptFeatures=function(c){var e=this.features[c];if(this.features.hasOwnProperty(c))return e;var t=this.getScriptFeaturesIndexes(c);if(!t)return null;var n=this.font.tables.gsub;return e=t.map(function(a){return n.features[a]}),this.features[c]=e,this.mapTagsToFeatures(e,c),e};t0.prototype.getSubstitutionType=function(c,e){var t=c.lookupType.toString(),n=e.substFormat.toString();return t+n};t0.prototype.getLookupMethod=function(c,e){var t=this,n=this.getSubstitutionType(c,e);switch(n){case"11":return function(a){return Bc.apply(t,[a,e])};case"12":return function(a){return $c.apply(t,[a,e])};case"63":return function(a){return Gc.apply(t,[a,e])};case"41":return function(a){return _c.apply(t,[a,e])};case"21":return function(a){return jc.apply(t,[a,e])};default:throw new Error("lookupType: "+c.lookupType+" - substFormat: "+e.substFormat+" is not yet supported")}};t0.prototype.lookupFeature=function(c){var e=c.contextParams,t=e.index,n=this.getFeature({tag:c.tag,script:c.script});if(!n)return new Error("font '"+this.font.names.fullName.en+"' doesn't support feature '"+c.tag+"' for script '"+c.script+"'.");for(var a=this.getFeatureLookups(n),r=[].concat(e.context),s=0;s<a.length;s++)for(var i=a[s],l=this.getLookupSubtables(i),o=0;o<l.length;o++){var h=l[o],f=this.getSubstitutionType(i,h),u=this.getLookupMethod(i,h),d=void 0;switch(f){case"11":d=u(e.current),d&&r.splice(t,1,new c2({id:11,tag:c.tag,substitution:d}));break;case"12":d=u(e.current),d&&r.splice(t,1,new c2({id:12,tag:c.tag,substitution:d}));break;case"63":d=u(e),Array.isArray(d)&&d.length&&r.splice(t,1,new c2({id:63,tag:c.tag,substitution:d}));break;case"41":d=u(e),d&&r.splice(t,1,new c2({id:41,tag:c.tag,substitution:d}));break;case"21":d=u(e.current),d&&r.splice(t,1,new c2({id:21,tag:c.tag,substitution:d}));break}e=new f0(r,t),!(Array.isArray(d)&&!d.length)&&(d=null)}return r.length?r:null};t0.prototype.supports=function(c){if(!c.script)return!1;this.getScriptFeatures(c.script);var e=this.features.hasOwnProperty(c.script);if(!c.tag)return e;var t=this.features[c.script].some(function(n){return n.tag===c.tag});return e&&t};t0.prototype.getLookupSubtables=function(c){return c.subtables||null};t0.prototype.getLookupByIndex=function(c){var e=this.font.tables.gsub.lookups;return e[c]||null};t0.prototype.getFeatureLookups=function(c){return c.lookupListIndexes.map(this.getLookupByIndex.bind(this))};t0.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 Wc(c){var e=c.current,t=c.get(-1);return t===null&&G0(e)||!G0(t)&&G0(e)}function Xc(c){var e=c.get(1);return e===null||!G0(e)}var Zc={startCheck:Wc,endCheck:Xc};function Yc(c){var e=c.current,t=c.get(-1);return(G0(e)||_0(e))&&!G0(t)}function Kc(c){var e=c.get(1);switch(!0){case e===null:return!0;case(!G0(e)&&!_0(e)):var t=Nc(e);if(!t)return!0;if(t){var n=!1;if(n=c.lookahead.some(function(a){return G0(a)||_0(a)}),!n)return!0}break;default:return!1}}var Jc={startCheck:Yc,endCheck:Kc};function Qc(c,e,t){e[t].setState(c.tag,c.substitution)}function en(c,e,t){e[t].setState(c.tag,c.substitution)}function tn(c,e,t){c.substitution.forEach(function(n,a){var r=e[t+a];r.setState(c.tag,n)})}function cn(c,e,t){var n=e[t];n.setState(c.tag,c.substitution.ligGlyph);for(var a=c.substitution.components.length,r=0;r<a;r++)n=e[t+r+1],n.setState("deleted",!0)}var X6={11:Qc,12:en,63:tn,41:cn};function J5(c,e,t){c instanceof c2&&X6[c.id]&&X6[c.id](c,e,t)}function nn(c){for(var e=[].concat(c.backtrack),t=e.length-1;t>=0;t--){var n=e[t],a=B7(n),r=_0(n);if(!a&&!r)return!0;if(a)return!1}return!1}function an(c){if(B7(c.current))return!1;for(var e=0;e<c.lookahead.length;e++){var t=c.lookahead[e],n=_0(t);if(!n)return!0}return!1}function rn(c){var e=this,t="arab",n=this.featuresTags[t],a=this.tokenizer.getRangeTokens(c);if(a.length!==1){var r=new f0(a.map(function(i){return i.getState("glyphIndex")}),0),s=new f0(a.map(function(i){return i.char}),0);a.forEach(function(i,l){if(!_0(i.char)){r.setCurrentIndex(l),s.setCurrentIndex(l);var o=0;nn(s)&&(o|=1),an(s)&&(o|=2);var h;switch(o){case 1:h="fina";break;case 2:h="init";break;case 3:h="medi";break}if(n.indexOf(h)!==-1){var f=e.query.lookupFeature({tag:h,script:t,contextParams:r});if(f instanceof Error)return console.info(f.message);f.forEach(function(u,d){u instanceof c2&&(J5(u,a,d),r.context[d]=u.substitution)})}}})}}function Z6(c,e){var t=c.map(function(n){return n.activeState.value});return new f0(t,e||0)}function sn(c){var e=this,t="arab",n=this.tokenizer.getRangeTokens(c),a=Z6(n);a.context.forEach(function(r,s){a.setCurrentIndex(s);var i=e.query.lookupFeature({tag:"rlig",script:t,contextParams:a});i.length&&(i.forEach(function(l){return J5(l,n,s)}),a=Z6(n))})}function ln(c){var e=c.current,t=c.get(-1);return t===null&&T3(e)||!T3(t)&&T3(e)}function on(c){var e=c.get(1);return e===null||!T3(e)}var hn={startCheck:ln,endCheck:on};function Y6(c,e){var t=c.map(function(n){return n.activeState.value});return new f0(t,e||0)}function un(c){var e=this,t="latn",n=this.tokenizer.getRangeTokens(c),a=Y6(n);a.context.forEach(function(r,s){a.setCurrentIndex(s);var i=e.query.lookupFeature({tag:"liga",script:t,contextParams:a});i.length&&(i.forEach(function(l){return J5(l,n,s)}),a=Y6(n))})}function m0(c){this.baseDir=c||"ltr",this.tokenizer=new L1,this.featuresTags={}}m0.prototype.setText=function(c){this.text=c};m0.prototype.contextChecks={latinWordCheck:hn,arabicWordCheck:Zc,arabicSentenceCheck:Jc};function H5(c){var e=this.contextChecks[c+"Check"];return this.tokenizer.registerContextChecker(c,e.startCheck,e.endCheck)}function fn(){return H5.call(this,"latinWord"),H5.call(this,"arabicWord"),H5.call(this,"arabicSentence"),this.tokenizer.tokenize(this.text)}function dn(){var c=this,e=this.tokenizer.getContextRanges("arabicSentence");e.forEach(function(t){var n=c.tokenizer.getRangeTokens(t);c.tokenizer.replaceRange(t.startIndex,t.endOffset,n.reverse())})}m0.prototype.registerFeatures=function(c,e){var t=this,n=e.filter(function(a){return t.query.supports({script:c,tag:a})});this.featuresTags.hasOwnProperty(c)?this.featuresTags[c]=this.featuresTags[c].concat(n):this.featuresTags[c]=n};m0.prototype.applyFeatures=function(c,e){if(!c)throw new Error("No valid font was provided to apply features");this.query||(this.query=new t0(c));for(var t=0;t<e.length;t++){var n=e[t];this.query.supports({script:n.script})&&this.registerFeatures(n.script,n.tags)}};m0.prototype.registerModifier=function(c,e,t){this.tokenizer.registerModifier(c,e,t)};function Q5(){if(this.tokenizer.registeredModifiers.indexOf("glyphIndex")===-1)throw new Error("glyphIndex modifier is required to apply arabic presentation features.")}function pn(){var c=this,e="arab";if(this.featuresTags.hasOwnProperty(e)){Q5.call(this);var t=this.tokenizer.getContextRanges("arabicWord");t.forEach(function(n){rn.call(c,n)})}}function mn(){var c=this,e="arab";if(this.featuresTags.hasOwnProperty(e)){var t=this.featuresTags[e];if(t.indexOf("rlig")!==-1){Q5.call(this);var n=this.tokenizer.getContextRanges("arabicWord");n.forEach(function(a){sn.call(c,a)})}}}function vn(){var c=this,e="latn";if(this.featuresTags.hasOwnProperty(e)){var t=this.featuresTags[e];if(t.indexOf("liga")!==-1){Q5.call(this);var n=this.tokenizer.getContextRanges("latinWord");n.forEach(function(a){un.call(c,a)})}}}m0.prototype.checkContextReady=function(c){return!!this.tokenizer.getContext(c)};m0.prototype.applyFeaturesToContexts=function(){this.checkContextReady("arabicWord")&&(pn.call(this),mn.call(this)),this.checkContextReady("latinWord")&&vn.call(this),this.checkContextReady("arabicSentence")&&dn.call(this)};m0.prototype.processText=function(c){(!this.text||this.text!==c)&&(this.setText(c),fn.call(this),this.applyFeaturesToContexts())};m0.prototype.getBidiText=function(c){return this.processText(c),this.tokenizer.getText()};m0.prototype.getTextGlyphs=function(c){this.processText(c);for(var e=[],t=0;t<this.tokenizer.tokens.length;t++){var n=this.tokenizer.tokens[t];if(!n.state.deleted){var a=n.activeState.value;e.push(Array.isArray(a)?a[0]:a)}}return e};function x1(c){c=c||{},c.tables=c.tables||{},c.empty||(q2(c.familyName,"When creating a new Font object, familyName is required."),q2(c.styleName,"When creating a new Font object, styleName is required."),q2(c.unitsPerEm,"When creating a new Font object, unitsPerEm is required."),q2(c.ascender,"When creating a new Font object, ascender is required."),q2(c.descender<=0,"When creating a new Font object, negative descender value is required."),this.names={fontFamily:{en:c.familyName||" "},fontSubfamily:{en:c.styleName||" "},fullName:{en:c.fullName||c.familyName+" "+c.styleName},postScriptName:{en:c.postScriptName||(c.familyName+c.styleName).replace(/\s/g,"")},designer:{en:c.designer||" "},designerURL:{en:c.designerURL||" "},manufacturer:{en:c.manufacturer||" "},manufacturerURL:{en:c.manufacturerURL||" "},license:{en:c.license||" "},licenseURL:{en:c.licenseURL||" "},version:{en:c.version||"Version 0.1"},description:{en:c.description||" "},copyright:{en:c.copyright||" "},trademark:{en:c.trademark||" "}},this.unitsPerEm=c.unitsPerEm||1e3,this.ascender=c.ascender,this.descender=c.descender,this.createdTimestamp=c.createdTimestamp,this.tables=Object.assign(c.tables,{os2:Object.assign({usWeightClass:c.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:c.widthClass||this.usWidthClasses.MEDIUM,fsSelection:c.fsSelection||this.fsSelectionValues.REGULAR},c.tables.os2)})),this.supported=!0,this.glyphs=new k0.GlyphSet(this,c.glyphs||[]),this.encoding=new i7(this),this.position=new W2(this),this.substitution=new e0(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 R7(this)}})}x1.prototype.hasChar=function(c){return this.encoding.charToGlyphIndex(c)!==null};x1.prototype.charToGlyphIndex=function(c){return this.encoding.charToGlyphIndex(c)};x1.prototype.charToGlyph=function(c){var e=this.charToGlyphIndex(c),t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t};x1.prototype.updateFeatures=function(c){return this.defaultRenderOptions.features.map(function(e){return e.script==="latn"?{script:"latn",tags:e.tags.filter(function(t){return c[t]})}:e})};x1.prototype.stringToGlyphs=function(c,e){var t=this,n=new m0,a=function(f){return t.charToGlyphIndex(f.char)};n.registerModifier("glyphIndex",null,a);var r=e?this.updateFeatures(e.features):this.defaultRenderOptions.features;n.applyFeatures(this,r);for(var s=n.getTextGlyphs(c),i=s.length,l=new Array(i),o=this.glyphs.get(0),h=0;h<i;h+=1)l[h]=this.glyphs.get(s[h])||o;return l};x1.prototype.nameToGlyphIndex=function(c){return this.glyphNames.nameToGlyphIndex(c)};x1.prototype.nameToGlyph=function(c){var e=this.nameToGlyphIndex(c),t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t};x1.prototype.glyphIndexToName=function(c){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(c):""};x1.prototype.getKerningValue=function(c,e){c=c.index||c,e=e.index||e;var t=this.position.defaultKerningTables;return t?this.position.getKerningValue(t,c,e):this.kerningPairs[c+","+e]||0};x1.prototype.defaultRenderOptions={kerning:!0,features:[{script:"arab",tags:["init","medi","fina","rlig"]},{script:"latn",tags:["liga","rlig"]}]};x1.prototype.forEachGlyph=function(c,e,t,n,a,r){e=e!==void 0?e:0,t=t!==void 0?t:0,n=n!==void 0?n:72,a=Object.assign({},this.defaultRenderOptions,a);var s=1/this.unitsPerEm*n,i=this.stringToGlyphs(c,a),l;if(a.kerning){var o=a.script||this.position.getDefaultScriptName();l=this.position.getKerningTables(o,a.language)}for(var h=0;h<i.length;h+=1){var f=i[h];if(r.call(this,f,e,t,n,a),f.advanceWidth&&(e+=f.advanceWidth*s),a.kerning&&h<i.length-1){var u=l?this.position.getKerningValue(l,f.index,i[h+1].index):this.getKerningValue(f,i[h+1]);e+=u*s}a.letterSpacing?e+=a.letterSpacing*n:a.tracking&&(e+=a.tracking/1e3*n)}return e};x1.prototype.getPath=function(c,e,t,n,a){var r=new P1;return this.forEachGlyph(c,e,t,n,a,function(s,i,l,o){var h=s.getPath(i,l,o,a,this);r.extend(h)}),r};x1.prototype.getPaths=function(c,e,t,n,a){var r=[];return this.forEachGlyph(c,e,t,n,a,function(s,i,l,o){var h=s.getPath(i,l,o,a,this);r.push(h)}),r};x1.prototype.getAdvanceWidth=function(c,e,t){return this.forEachGlyph(c,0,0,e,t,function(){})};x1.prototype.draw=function(c,e,t,n,a,r){this.getPath(e,t,n,a,r).draw(c)};x1.prototype.drawPoints=function(c,e,t,n,a,r){this.forEachGlyph(e,t,n,a,r,function(s,i,l,o){s.drawPoints(c,i,l,o)})};x1.prototype.drawMetrics=function(c,e,t,n,a,r){this.forEachGlyph(e,t,n,a,r,function(s,i,l,o){s.drawMetrics(c,i,l,o)})};x1.prototype.getEnglishName=function(c){var e=this.names[c];if(e)return e.en};x1.prototype.validate=function(){var c=this;function e(n,a){}function t(n){var a=c.getEnglishName(n);a&&a.trim().length>0}t("fontFamily"),t("weightName"),t("manufacturer"),t("copyright"),t("version"),this.unitsPerEm>0};x1.prototype.toTables=function(){return ct.fontToTable(this)};x1.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()};x1.prototype.toArrayBuffer=function(){for(var c=this.toTables(),e=c.encode(),t=new ArrayBuffer(e.length),n=new Uint8Array(t),a=0;a<e.length;a++)n[a]=e[a];return t};x1.prototype.download=function(c){var e=this.getEnglishName("fontFamily"),t=this.getEnglishName("fontSubfamily");c=c||e.replace(/\s/g,"")+"-"+t+".otf";var n=this.toArrayBuffer();if(at())if(window.URL=window.URL||window.webkitURL,window.URL){var a=new DataView(n),r=new Blob([a],{type:"font/opentype"}),s=document.createElement("a");s.href=window.URL.createObjectURL(r),s.download=c;var i=document.createEvent("MouseEvents");i.initEvent("click",!0,!1),s.dispatchEvent(i)}else console.warn("Font file could not be downloaded. Try using a different browser.");else{var l=f6(),o=rt(n);l.writeFileSync(c,o)}};x1.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512};x1.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};x1.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};function $7(c,e){var t=JSON.stringify(c),n=256;for(var a in e){var r=parseInt(a);if(!(!r||r<256)){if(JSON.stringify(e[a])===t)return r;n<=r&&(n=r+1)}}return e[n]=c,n}function gn(c,e,t){var n=$7(e.name,t);return[{name:"tag_"+c,type:"TAG",value:e.tag},{name:"minValue_"+c,type:"FIXED",value:e.minValue<<16},{name:"defaultValue_"+c,type:"FIXED",value:e.defaultValue<<16},{name:"maxValue_"+c,type:"FIXED",value:e.maxValue<<16},{name:"flags_"+c,type:"USHORT",value:0},{name:"nameID_"+c,type:"USHORT",value:n}]}function yn(c,e,t){var n={},a=new U.Parser(c,e);return n.tag=a.parseTag(),n.minValue=a.parseFixed(),n.defaultValue=a.parseFixed(),n.maxValue=a.parseFixed(),a.skip("uShort",1),n.name=t[a.parseUShort()]||{},n}function Mn(c,e,t,n){for(var a=$7(e.name,n),r=[{name:"nameID_"+c,type:"USHORT",value:a},{name:"flags_"+c,type:"USHORT",value:0}],s=0;s<t.length;++s){var i=t[s].tag;r.push({name:"axis_"+c+" "+i,type:"FIXED",value:e.coordinates[i]<<16})}return r}function xn(c,e,t,n){var a={},r=new U.Parser(c,e);a.name=n[r.parseUShort()]||{},r.skip("uShort",1),a.coordinates={};for(var s=0;s<t.length;++s)a.coordinates[t[s].tag]=r.parseFixed();return a}function bn(c,e){var t=new O.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:c.axes.length},{name:"axisSize",type:"USHORT",value:20},{name:"instanceCount",type:"USHORT",value:c.instances.length},{name:"instanceSize",type:"USHORT",value:4+c.axes.length*4}]);t.offsetToData=t.sizeOf();for(var n=0;n<c.axes.length;n++)t.fields=t.fields.concat(gn(n,c.axes[n],e));for(var a=0;a<c.instances.length;a++)t.fields=t.fields.concat(Mn(a,c.instances[a],c.axes,e));return t}function zn(c,e,t){var n=new U.Parser(c,e),a=n.parseULong();W.argument(a===65536,"Unsupported fvar table version.");var r=n.parseOffset16();n.skip("uShort",1);for(var s=n.parseUShort(),i=n.parseUShort(),l=n.parseUShort(),o=n.parseUShort(),h=[],f=0;f<s;f++)h.push(yn(c,e+r+f*i,t));for(var u=[],d=e+r+s*i,p=0;p<l;p++)u.push(xn(c,d+p*o,h,t));return{axes:h,instances:u}}var wn={make:bn,parse:zn},kn=function(){return{coverage:this.parsePointer(L.coverage),attachPoints:this.parseList(L.pointer(L.uShortList))}},Ln=function(){var c=this.parseUShort();if(W.argument(c===1||c===2||c===3,"Unsupported CaretValue table version."),c===1)return{coordinate:this.parseShort()};if(c===2)return{pointindex:this.parseShort()};if(c===3)return{coordinate:this.parseShort()}},Sn=function(){return this.parseList(L.pointer(Ln))},An=function(){return{coverage:this.parsePointer(L.coverage),ligGlyphs:this.parseList(L.pointer(Sn))}},Cn=function(){return this.parseUShort(),this.parseList(L.pointer(L.coverage))};function Pn(c,e){e=e||0;var t=new L(c,e),n=t.parseVersion(1);W.argument(n===1||n===1.2||n===1.3,"Unsupported GDEF table version.");var a={version:n,classDef:t.parsePointer(L.classDef),attachList:t.parsePointer(kn),ligCaretList:t.parsePointer(An),markAttachClassDef:t.parsePointer(L.classDef)};return n>=1.2&&(a.markGlyphSets=t.parsePointer(Cn)),a}var En={parse:Pn},d0=new Array(10);d0[1]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{posFormat:1,coverage:this.parsePointer(L.coverage),value:this.parseValueRecord()};if(t===2)return{posFormat:2,coverage:this.parsePointer(L.coverage),values:this.parseValueRecordList()};W.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")};d0[2]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();W.assert(t===1||t===2,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");var n=this.parsePointer(L.coverage),a=this.parseUShort(),r=this.parseUShort();if(t===1)return{posFormat:t,coverage:n,valueFormat1:a,valueFormat2:r,pairSets:this.parseList(L.pointer(L.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(a),value2:this.parseValueRecord(r)}})))};if(t===2){var s=this.parsePointer(L.classDef),i=this.parsePointer(L.classDef),l=this.parseUShort(),o=this.parseUShort();return{posFormat:t,coverage:n,valueFormat1:a,valueFormat2:r,classDef1:s,classDef2:i,class1Count:l,class2Count:o,classRecords:this.parseList(l,L.list(o,function(){return{value1:this.parseValueRecord(a),value2:this.parseValueRecord(r)}}))}}};d0[3]=function(){return{error:"GPOS Lookup 3 not supported"}};d0[4]=function(){return{error:"GPOS Lookup 4 not supported"}};d0[5]=function(){return{error:"GPOS Lookup 5 not supported"}};d0[6]=function(){return{error:"GPOS Lookup 6 not supported"}};d0[7]=function(){return{error:"GPOS Lookup 7 not supported"}};d0[8]=function(){return{error:"GPOS Lookup 8 not supported"}};d0[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function Tn(c,e){e=e||0;var t=new L(c,e),n=t.parseVersion(1);return W.argument(n===1||n===1.1,"Unsupported GPOS table version "+n),n===1?{version:n,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(d0)}:{version:n,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(d0),variations:t.parseFeatureVariationsList()}}var In=new Array(10);function Hn(c){return new O.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new O.ScriptList(c.scripts)},{name:"features",type:"TABLE",value:new O.FeatureList(c.features)},{name:"lookups",type:"TABLE",value:new O.LookupList(c.lookups,In)}])}var Vn={parse:Tn,make:Hn};function On(c){var e={};c.skip("uShort");var t=c.parseUShort();W.argument(t===0,"Unsupported kern sub-table version."),c.skip("uShort",2);var n=c.parseUShort();c.skip("uShort",3);for(var a=0;a<n;a+=1){var r=c.parseUShort(),s=c.parseUShort(),i=c.parseShort();e[r+","+s]=i}return e}function Fn(c){var e={};c.skip("uShort");var t=c.parseULong();t>1&&console.warn("Only the first kern subtable is supported."),c.skip("uLong");var n=c.parseUShort(),a=n&255;if(c.skip("uShort"),a===0){var r=c.parseUShort();c.skip("uShort",3);for(var s=0;s<r;s+=1){var i=c.parseUShort(),l=c.parseUShort(),o=c.parseShort();e[i+","+l]=o}}return e}function Dn(c,e){var t=new U.Parser(c,e),n=t.parseUShort();if(n===0)return On(t);if(n===1)return Fn(t);throw new Error("Unsupported kern table version ("+n+").")}var Rn={parse:Dn};function Un(c,e,t,n){for(var a=new U.Parser(c,e),r=n?a.parseUShort:a.parseULong,s=[],i=0;i<t+1;i+=1){var l=r.call(a);n&&(l*=2),s.push(l)}return s}var qn={parse:Un};function K6(c,e){for(var t=[],n=12,a=0;a<e;a+=1){var r=U.getTag(c,n),s=U.getULong(c,n+4),i=U.getULong(c,n+8),l=U.getULong(c,n+12);t.push({tag:r,checksum:s,offset:i,length:l,compression:!1}),n+=16}return t}function Nn(c,e){for(var t=[],n=44,a=0;a<e;a+=1){var r=U.getTag(c,n),s=U.getULong(c,n+4),i=U.getULong(c,n+8),l=U.getULong(c,n+12),o=void 0;i<l?o="WOFF":o=!1,t.push({tag:r,offset:s,compression:o,compressedLength:i,length:l}),n+=20}return t}function A1(c,e){if(e.compression==="WOFF"){var t=new Uint8Array(c.buffer,e.offset+2,e.compressedLength-2),n=new Uint8Array(e.length);if(H9(t,n),n.byteLength!==e.length)throw new Error("Decompression error: "+e.tag+" decompressed length doesn't match recorded length");var a=new DataView(n.buffer,0);return{data:a,offset:0}}else return{data:c,offset:e.offset}}function G7(c,e){e=e??{};var t,n,a=new x1({empty:!0}),r=new DataView(c,0),s,i=[],l=U.getTag(r,0);if(l==="\0\0\0"||l==="true"||l==="typ1")a.outlinesFormat="truetype",s=U.getUShort(r,4),i=K6(r,s);else if(l==="OTTO")a.outlinesFormat="cff",s=U.getUShort(r,4),i=K6(r,s);else if(l==="wOFF"){var o=U.getTag(r,4);if(o==="\0\0\0")a.outlinesFormat="truetype";else if(o==="OTTO")a.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+l);s=U.getUShort(r,12),i=Nn(r,s)}else throw new Error("Unsupported OpenType signature "+l);for(var h,f,u,d,p,m,v,g,y,M,A,z,E=0;E<s;E+=1){var k=i[E],C=void 0;switch(k.tag){case"cmap":C=A1(r,k),a.tables.cmap=s7.parse(C.data,C.offset),a.encoding=new l7(a.tables.cmap);break;case"cvt ":C=A1(r,k),z=new U.Parser(C.data,C.offset),a.tables.cvt=z.parseShortList(k.length/2);break;case"fvar":f=k;break;case"fpgm":C=A1(r,k),z=new U.Parser(C.data,C.offset),a.tables.fpgm=z.parseByteList(k.length);break;case"head":C=A1(r,k),a.tables.head=y7.parse(C.data,C.offset),a.unitsPerEm=a.tables.head.unitsPerEm,t=a.tables.head.indexToLocFormat;break;case"hhea":C=A1(r,k),a.tables.hhea=M7.parse(C.data,C.offset),a.ascender=a.tables.hhea.ascender,a.descender=a.tables.hhea.descender,a.numberOfHMetrics=a.tables.hhea.numberOfHMetrics;break;case"hmtx":v=k;break;case"ltag":C=A1(r,k),n=b7.parse(C.data,C.offset);break;case"maxp":C=A1(r,k),a.tables.maxp=z7.parse(C.data,C.offset),a.numGlyphs=a.tables.maxp.numGlyphs;break;case"name":M=k;break;case"OS/2":C=A1(r,k),a.tables.os2=N5.parse(C.data,C.offset);break;case"post":C=A1(r,k),a.tables.post=C7.parse(C.data,C.offset),a.glyphNames=new W5(a.tables.post);break;case"prep":C=A1(r,k),z=new U.Parser(C.data,C.offset),a.tables.prep=z.parseByteList(k.length);break;case"glyf":u=k;break;case"loca":y=k;break;case"CFF ":h=k;break;case"kern":g=k;break;case"GDEF":d=k;break;case"GPOS":p=k;break;case"GSUB":m=k;break;case"meta":A=k;break}}var P=A1(r,M);if(a.tables.name=A7.parse(P.data,P.offset,n),a.names=a.tables.name,u&&y){var w=t===0,I=A1(r,y),B=qn.parse(I.data,I.offset,a.numGlyphs,w),F=A1(r,u);a.glyphs=O7.parse(F.data,F.offset,B,a,e)}else if(h){var G=A1(r,h);g7.parse(G.data,G.offset,a,e)}else throw new Error("Font doesn't contain TrueType or CFF outlines.");var X=A1(r,v);if(x7.parse(a,X.data,X.offset,a.numberOfHMetrics,a.numGlyphs,a.glyphs,e),ee(a,e),g){var q=A1(r,g);a.kerningPairs=Rn.parse(q.data,q.offset)}else a.kerningPairs={};if(d){var o1=A1(r,d);a.tables.gdef=En.parse(o1.data,o1.offset)}if(p){var N=A1(r,p);a.tables.gpos=Vn.parse(N.data,N.offset),a.position.init()}if(m){var Z=A1(r,m);a.tables.gsub=P7.parse(Z.data,Z.offset)}if(f){var e1=A1(r,f);a.tables.fvar=wn.parse(e1.data,e1.offset,a.names)}if(A){var t1=A1(r,A);a.tables.meta=E7.parse(t1.data,t1.offset),a.metas=a.tables.meta}return a}var q3=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 n=this.parsed.get(t);if(n)return n;let a=Y1(this.sources,t);if(!a)throw this.missing.add(t),new Error(`Font "${t}" is not available.${this.names().length?` Available fonts: ${this.names().join(", ")}`:""}`);let r=a instanceof Uint8Array?a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength):a,s=G7(r);return this.parsed.set(t,s),s}};function Bn(c,e,t){let n={kerning:!0};if(t.spacing===1)return{cmds:c.getPath(e,0,0,t.size,n).commands,advance:c.getAdvanceWidth(e,t.size,n)};let a=[],r=0,s=[...e];return s.forEach((i,l)=>{a.push(...c.getPath(i,r,0,t.size,n).commands),r+=c.getAdvanceWidth(i,t.size,n)*(l<s.length-1?t.spacing:1)}),{cmds:a,advance:r}}function _7(c,e,t){let{cmds:n,advance:a}=Bn(c,e,t),r=n.map(i=>i.type==="Z"?i:i.type==="C"?{...i,y1:-i.y1,y2:-i.y2,y:-i.y}:i.type==="Q"?{...i,y1:-i.y1,y:-i.y}:{...i,y:-i.y}),s=o2(r,Math.max(.005,t.size/2e3));return{polys:[...s.closed,...s.open.filter(i=>i.length>=3)],advance:a}}function N3(c,e,t){if(!e)return[];let n=c.get(t.font),{polys:a,advance:r}=_7(n,e,t),s=s1(a),i=x0(s);if(!i)return[];let l=t.halign==="center"?-r/2:t.halign==="right"?-r:0,o=t.valign==="top"?-i[3]:t.valign==="center"?-(i[1]+i[3])/2:t.valign==="bottom"?-i[1]:0;return s.map(h=>h.map(([f,u])=>[f+l,u+o]))}function e4(c,e,t){let n=c.get(t.font),{polys:a,advance:r}=_7(n,e,t),s=x0(a)??[0,0,0,0];return{advance:r,bounds:[[s[0],s[1]],[s[2],s[3]]],ascent:n.ascender/n.unitsPerEm*t.size,descent:n.descender/n.unitsPerEm*t.size}}var j7=128,a4=[{name:"engrave",mode:"fill",color:"#000000"},{name:"score",mode:"line",color:"#0000ff"},{name:"cut",mode:"cut",color:"#ff0000"},{name:"guide",mode:"guide",color:"#00a0ff"}],$n={maxParts:1e4,maxSegments:1e4,maxListLength:1e6,maxListItems:3e6,maxTextLength:2e3,maxPoints:2e6,maxOutputPoints:1e6,maxSheets:200,maxCollisionPairs:2e4};function r4(c,e){if(!c||Y1(n4,c)!==void 0||e.startsWith("/"))return;let t=c.lastIndexOf("/");if(t<0)return;let n=[...c.slice(0,t).split("/"),...e.split("/")],a=[];for(let r of n)r===".."&&a.length&&a[a.length-1]!==".."?a.pop():r!=="."&&r!==""&&a.push(r);return(c.startsWith("/")?"/":"")+a.join("/")}var Gn=100,_n={mm:1,cm:10,m:1e3,in:25.4,ft:304.8},x2=4,W7=8,jn=c=>{let e=Gn,t=n=>{for(let a of n.values()){for(let r of a.regions)e+=r.length;for(let r of a.lines)e+=r.length}};t(c.layers);for(let n of c.parts)t(n.layers);return e},R1=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,n=e.startsWith("$");for(;t;){if(t.vars.has(e))return{found:!0,value:t.vars.get(e)};t=n?t.caller??t.parent:t.parent}return{found:!1}}fn(e){for(let t=this;t;t=t.parent){let n=t.fns.get(e);if(n)return n}}mod(e){for(let t=this;t;t=t.parent){let n=t.mods.get(e);if(n)return n}}childCtx(){for(let e=this;e;e=e.parent)if(e.children)return e.children}names(e){let t=[];for(let n=this;n;n=n.parent)t.push(...n[e].keys());return t}},t4=c=>c?`.${c}`:"",c4=["echo","assert","text_width","text_metrics","finger_count"];function a2(c,e){let t="",n=Math.min(2,Math.floor(c.length/3))+.5;for(let a of new Set(e)){if(a===c)continue;let r=a.toLowerCase()===c.toLowerCase()?0:Wn(c,a);r<n&&([t,n]=[a,r])}return t?` Did you mean "${t}"?`:""}function Wn(c,e){if(Math.abs(c.length-e.length)>2)return 3;let t=Array.from({length:c.length+1},(n,a)=>[a,...Array(e.length).fill(0)]);for(let n=1;n<=e.length;n++)t[0][n]=n;for(let n=1;n<=c.length;n++)for(let a=1;a<=e.length;a++)t[n][a]=Math.min(t[n-1][a]+1,t[n][a-1]+1,t[n-1][a-1]+(c[n-1]===e[a-1]?0:1)),n>1&&a>1&&c[n-1]===e[a-2]&&c[n-2]===e[a-1]&&(t[n][a]=Math.min(t[n][a],t[n-2][a-2]+1));return t[c.length][e.length]}var n4=v0,B3=class{constructor(e={}){this.opts=e;this.steps=0;this.depth=0;this.pointCount=0;this.itemCount=0;this.copies=0;this.frame=b5;this.step=0;this.stepNames=[];this.stepFolded=!1;this.hardware=[];this.echoes=[];this.warnings=[];this.layers=new Map(a4.map(e=>[e.name,e]));this.loaded=new Map;this.childCache=new WeakMap;this.using=[];this.including=[];this.maxSteps=e.maxSteps??5e6,this.limits={...$n,...e.limits},this.builtins=this.makeBuiltins()}run(e){let t=new R1,n={$fn:0,$fa:2,$fs:.2,$thickness:3,$kerf:0,$material:"material",$sheet:[600,400],$gap:3,$layout:"pack",$scale:1,PI:Math.PI};for(let[i,l]of Object.entries(n))t.vars.set(i,l);let a=new R1(t),r=this.block(e.body,a,!0),s=a.vars.get("$scale");return this.unscaled&&s!==void 0&&s!==1&&this.warn(`A length with a unit comes before $scale is set, so it is not scaled; set $scale first (${S0(this.unscaled,!1)})`),{shape:r,globals:a,layers:this.layers,echoes:this.echoes,warnings:this.warnings,hardware:this.hardware,steps:this.stepNames}}tick(e,t=1){if(!((this.steps+=t)<=this.maxSteps))throw new D(`Stopped after ${this.maxSteps} steps. Is there an endless loop?`,e)}load(e,t){let n=r4(t.file,e),a=e,r=Y1(n4,e);if(r===void 0&&n!==void 0){let i=this.loaded.get(n);if(i)return i;r=this.opts.resolve?.(n),typeof r=="string"&&(a=n)}if(a===e){let i=this.loaded.get(e);if(i)return i;r??(r=this.opts.resolve?.(e))}if(typeof r!="string")throw new D(`Library <${e}> not found`,t);this.loaded.set(a,{body:[]});let{program:s}=D0(r,a);return this.loaded.set(a,s),s}hoist(e,t){for(let n of e)if((n.kind==="module"||n.kind==="function")&&(n.pos.file===void 0||Y1(n4,n.pos.file)===void 0)&&(n.kind==="module"?Y1(this.builtins,n.name)!==void 0:Y1(A2,n.name)!==void 0||c4.includes(n.name))&&this.warn(`${n.kind} ${n.name} hides the built-in ${n.name}(); rename it to use both (${S0(n.pos,!1)})`),n.kind==="module")t.mods.set(n.name,{params:n.params,body:n.body,env:t});else if(n.kind==="function")t.fns.set(n.name,{params:n.params,body:n.body,env:t});else if(n.kind==="use"&&!n.include){this.enter(this.using,n.path,n.pos,"use");try{let a=this.included(this.load(n.path,n.pos).body,new Set([n.path])),r=new R1(t);this.hoist(a,r);for(let s of a)s.kind==="assign"&&this.assign(s.name,this.expr(s.value,r),r);for(let[s,i]of r.mods)t.mods.set(s,i);for(let[s,i]of r.fns)t.fns.set(s,i)}finally{this.using.pop()}}}childKey(e){let t=new Map;((o,h)=>{for(;o&&h<200;o=o.caller??o.parent,h++)for(let[f,u]of o.vars)f.startsWith("$")&&!t.has(f)&&t.set(f,u)})(e,0);let a=[...t].sort(([o],[h])=>o<h?-1:1),r=[],s=0,i=[];for(let o=a.length-1;o>=0;o--)i.push({text:";"},a[o][1],{text:`${a[o][0]}=`});for(;i.length;){if(s>2e4)return"";let o=i.pop(),h;if(o&&typeof o=="object"&&"text"in o&&!Array.isArray(o))h=o.text;else if(typeof o=="number")h=Object.is(o,-0)?"-0":String(o);else if(typeof o=="string")h=JSON.stringify(o);else if(o===void 0||typeof o=="boolean")h=String(o);else if(Array.isArray(o)){i.push({text:"]"});for(let f=o.length-1;f>=0;f--)i.push(o[f],{text:","});h="["}else if(c0(o))h=`[${o.start}:${o.step}:${o.end}]`;else if(B1(o)){i.push({text:"}"});let f=[...o.fields];for(let u=f.length-1;u>=0;u--)i.push(f[u][1],{text:`${f[u][0]}=`});h="{"}else return"";r.push(h),s+=h.length}let l=r.join("");return`${this.frame.join(",")}|${this.step}|${this.stepFolded}|${l}`}effects(){return`${this.echoes.length},${this.hardware.length},${this.stepNames.length},${this.warnings.length},${this.copies}`}enter(e,t,n,a){if(e.includes(t)){let r=[...e.slice(e.indexOf(t)),t].map(s=>`<${s}>`);throw new D(r.length===2?`Library ${r[0]} ${a}s itself`:`Libraries ${a} each other in a loop: ${r.join(" \u2192 ")}`,n)}e.push(t)}included(e,t){let n=[];for(let a of e)if(a.kind!=="use"||!a.include)n.push(a);else if(!t.has(a.path)){t.add(a.path);for(let r of this.included(this.load(a.path,a.pos).body,t))n.push(r)}return n}assign(e,t,n){n.vars.set(e,t)}block(e,t,n=!1){this.hoist(e,t);let a=[];for(let r of e){let s=this.stmt(r,t,n);s&&!j4(s)&&a.push(s)}return a.length===1?a[0]:U0(a)}stmt(e,t,n=!1){switch(this.tick(e.pos),e.kind){case"assign":{let a=this.opts.overrides,r=n&&a&&Object.prototype.hasOwnProperty.call(a,e.name)?a[e.name]:this.expr(e.value,t);return this.assign(e.name,r,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 R1(t));case"if":return k1(this.expr(e.cond,t))?this.block(e.then,new R1(t)):this.block(e.else,new R1(t));case"let":{let a=new R1(t);return this.bindSeq(e.assigns,a),this.block(e.body,a)}case"for":{let a=[];return this.loop(e.assigns,t,r=>a.push(this.block(e.body,r))),U0(a)}case"call":if(e.modifier==="*")return null;{let a=this.callModule(e,t);return e.modifier==="#"||e.modifier==="%"?D2(a,"guide"):a}}}bindSeq(e,t){for(let n of e)this.assign(n.name,this.expr(n.value,t),t)}iterable(e,t){if(c0(e))try{return n3(e,this.limits.maxListLength)}catch(n){throw new D(n.message,t)}return Array.isArray(e)?e:typeof e=="string"?[...e]:e===void 0?[]:[e]}loop(e,t,n,a=0,r=new R1(t)){if(a===e.length)return n(r);let s=e[a];for(let i of this.iterable(this.expr(s.value,r),s.pos)){this.tick(s.pos);let l=new R1(r);l.vars.set(s.name,i),this.loop(e,t,n,a+1,l)}}evalArgs(e,t,n){let a=[],r=new Map,s=[];for(let i of e){let l=this.expr(i.value,t);i.name===null?a.push(l):r.set(i.name,l),s.push({name:i.name,value:l})}return{pos:a,named:r,all:s,at:n}}bindParams(e,t,n,a,r){let s=e.map(i=>i.name);e.forEach((i,l)=>{let o;t.named.has(i.name)?o=t.named.get(i.name):l<t.pos.length?o=t.pos[l]:o=i.default?this.expr(i.default,n):void 0,n.vars.set(i.name,o)});for(let i of t.named.keys())i.startsWith("$")?n.vars.set(i,t.named.get(i)):s.includes(i)||this.unknownArg(r,i,t.at,s);this.checkCount(r,e.length,t)}checkArgs(e,t){let n=s2(e);if(!n)return;let a=n.params.map(r=>r.name);if(!n.anyNamed)for(let r of t.named.keys())!r.startsWith("$")&&!a.includes(r)&&this.unknownArg(`${e}()`,r,t.at,a);n.rest||this.checkCount(`${e}()`,n.params.filter(r=>!r.named).length,t)}checkCount(e,t,n){n.pos.length>t&&this.warn(`${e}: takes ${t===0?"no":`at most ${t}`} positional argument${t===1?"":"s"}, got ${n.pos.length}; the rest are ignored (${S0(n.at,!1)})`)}unknownArg(e,t,n,a){this.warn(`${e}: unknown argument "${t}"${t4(a2(t,a))} (${S0(n,!1)})`)}warn(e){this.warnings.includes(e)||this.warnings.push(e)}callByName(e,t){let n=e.args.findIndex(s=>s.name==="name"),a=n>=0?n:e.args.findIndex(s=>s.name===null);if(a<0)throw new D("call() needs the name of a module",e.pos);let r=this.expr(e.args[a].value,t);if(typeof r!="string")throw new D(`call() needs a module's name as a string, got ${K1(r)}`,e.pos);if(r==="call")throw new D("call() can't call itself",e.pos);return this.callModule({...e,name:r,args:e.args.filter((s,i)=>i!==a)},t)}callModule(e,t){if(e.name==="call"&&!t.mod("call"))return this.callByName(e,t);let n=this.evalArgs(e.args,t,e.pos),a=t.mod(e.name);if(a){if(++this.depth>1e3)throw new D(`Recursion too deep in module ${e.name}(): it calls itself without stopping`,e.pos);try{let u=new R1(a.env,t);return this.bindParams(a.params,n,u,a.env,`${e.name}()`),u.children={stmts:e.children,env:t},u.vars.set("$children",this.childStmts(e.children).length),this.block(a.body,u)}catch(u){throw this.inCall(u,"module",e.name,e.pos)}finally{this.depth--}}let r=Y1(this.builtins,e.name);if(!r){let u=e.name==="color"?" Use layer(), cut(), score() or engrave() instead.":a2(e.name,[...t.names("mods"),...Object.keys(this.builtins)]);throw new D(`Unknown module ${e.name}().${u}`,e.pos)}this.checkArgs(e.name,n);let s=new R1(t,t);for(let[u,d]of n.named)u.startsWith("$")&&s.vars.set(u,d);let i=this.childStmts(e.children),l=()=>new R1(t,s),o={args:n,env:s,children:()=>e.children.length?this.block(e.children,l()):a0(),childList:()=>{let u=l();this.hoist(e.children,u);let d=[];for(let p of e.children){let m=this.stmt(p,u);i.includes(p)&&d.push(m??a0())}return d},childSeq:u=>{let d=l();this.hoist(e.children,d);let p=[];for(let m of e.children){let v=this.stmt(m,d);i.includes(m)&&(p.push(v??a0()),u(p.length-1,v??a0()))}return p}},h;try{h=r(o)}catch(u){if(u instanceof D||u instanceof RangeError)throw u;let d=new D(`${e.name}(): ${u.message}`,e.pos);throw d.call=e.name,d}let f=jn(h);if(e.name!=="children"&&(this.pointCount+=f),f>this.limits.maxPoints||this.pointCount>this.limits.maxPoints*10)throw new D(f>this.limits.maxPoints?`The shapes have more than ${this.limits.maxPoints} points, the limit. Use fewer or simpler shapes, or a lower $fn.`:`Making the shapes took more than ${this.limits.maxPoints*10} points of work, the limit. Use fewer or simpler shapes, or a lower $fn.`,e.pos);return h}childStmts(e){return e.filter(t=>t.kind!=="assign"&&t.kind!=="module"&&t.kind!=="function"&&t.kind!=="use")}callFunction(e,t,n,a){if(++this.depth>2e3)throw new D(`Recursion too deep in ${a}(): it calls itself without stopping`,t.at);try{this.tick(t.at);let r=C0(e)?e.scope:e.env,s=new R1(r,n);return this.bindParams(e.params,t,s,r,`${a}()`),this.expr(e.body,s)}catch(r){throw this.inCall(r,"function",a,t.at)}finally{this.depth--}}inCall(e,t,n,a){return e instanceof Error&&!(e instanceof D)&&e.message.includes("call stack")?new D(`Recursion too deep in ${t==="module"?"module ":""}${n}(): it calls itself without stopping`,a):(e instanceof D&&e.addFrame(t,n,a),e)}expr(e,t){switch(e.kind){case"num":return e.unit?this.length(e,t):e.value;case"str":case"bool":return e.value;case"undef":return;case"var":{let n=t.get(e.name);if(n.found)return n.value;let a=t.fn(e.name);if(a)return{type:"function",params:a.params,body:a.body,scope:a.env,name:e.name};if(e.name.startsWith("$"))return;throw new D(`Unknown variable "${e.name}"${t4(a2(e.name,[...t.names("vars"),...t.names("fns")]))}`,e.pos)}case"list":{let n=[];for(let a of e.items)this.listItem(a,t,n,e.pos);return this.charge(x2,e.pos),n}case"range":{let n=this.expr(e.start,t),a=this.expr(e.end,t),r=e.step?this.expr(e.step,t):1;if(typeof n!="number"||typeof a!="number"||typeof r!="number")throw new D("Range values must be numbers",e.pos);return{type:"range",start:n,step:r,end:a}}case"unary":{let n=this.expr(e.arg,t);return e.op==="!"?!k1(n):e.op==="+"?n:this.arith("*",-1,n,e.pos)}case"binary":{if(e.op==="&&")return k1(this.expr(e.left,t))&&k1(this.expr(e.right,t));if(e.op==="||")return k1(this.expr(e.left,t))||k1(this.expr(e.right,t));let n=this.expr(e.left,t),a=this.expr(e.right,t);if(e.op==="=="||e.op==="!=")return i2(n,a,()=>this.tick(e.pos))===(e.op==="==");if(e.op==="<"||e.op==="<="||e.op===">"||e.op===">="){if(!(typeof n=="number"&&typeof a=="number"||typeof n=="string"&&typeof a=="string"))throw new D(`Can't compare ${K1(n)} ${e.op} ${K1(a)}`,e.pos);return e.op==="<"?n<a:e.op==="<="?n<=a:e.op===">"?n>a:n>=a}return this.arith(e.op,n,a,e.pos)}case"ternary":return k1(this.expr(e.cond,t))?this.expr(e.then,t):this.expr(e.else,t);case"index":{let n=this.expr(e.target,t),a=this.expr(e.index,t);if(B1(n)&&typeof a=="string")return n.fields.get(a);if(typeof a!="number")throw new D(`List index must be a number, got ${K1(a)}`,e.pos);return Array.isArray(n)?n[Math.floor(a)]:typeof n=="string"?[...n][Math.floor(a)]:c0(n)?[n.start,n.step,n.end][Math.floor(a)]:void 0}case"record":return this.record(e,t);case"member":{let n=this.expr(e.target,t);if(B1(n))return n.fields.get(e.name);let a={x:0,y:1,z:2}[e.name];return Array.isArray(n)&&a!==void 0?n[a]:c0(n)&&(e.name==="begin"||e.name==="step"||e.name==="end")?e.name==="begin"?n.start:e.name==="step"?n.step:n.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 n=new R1(t);return this.bindSeq(e.assigns,n),this.expr(e.body,n)}}}listItem(e,t,n,a){switch(e.kind){case"item":{let r=this.expr(e.expr,t);this.grow(n,1,a),n.push(r);return}case"each":{let r=this.iterable(this.expr(e.expr,t),a);this.grow(n,r.length,a);for(let s of r)n.push(s);return}case"for":this.loop(e.assigns,t,r=>this.listItem(e.body,r,n,a));return;case"if":k1(this.expr(e.cond,t))?this.listItem(e.then,t,n,a):e.else&&this.listItem(e.else,t,n,a);return;case"let":{let r=new R1(t);this.bindSeq(e.assigns,r),this.listItem(e.body,r,n,a)}}}grow(e,t,n){if(e.length+t>this.limits.maxListLength)throw new D(`a list of ${e.length+t} items is more than the limit of ${this.limits.maxListLength}`,n);this.charge(t,n)}charge(e,t){if(this.itemCount+=e,!(this.itemCount<=this.limits.maxListItems))throw new D(`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 a=e.callee.name,r=t.get(a),s=r.found&&!C0(r.value);if(!r.found||s&&this.callable(a,t)){let i=t.fn(a);if(i)return this.callFunction(i,this.evalArgs(e.args,t,e.pos),t,a);let l=this.specialFunction(a,e,t);if(l.handled)return l.value;let o=Y1(A2,a);if(o){let h=this.evalArgs(e.args,t,e.pos);this.checkArgs(a,h);for(let p of T4(o,h.pos,h.named))this.warn(`${a}(): "${p}" is given by position and by name; the named value is used (${S0(e.pos,!1)})`);let f={maxLength:this.limits.maxListLength,step:p=>this.tick(e.pos,p),given:h.pos.length+o.params.filter(p=>h.named.has(p)).length},u=I4(o,h.pos,h.named);this.tick(e.pos,H4(a,u,this.limits.maxListLength));let d;try{d=o.run(u,f)}catch(p){if(p instanceof D)throw p;let m=new D(p instanceof RangeError?`${a}(): the result is too large`:p.message,e.pos);throw m.call=a,m}return this.checkValue(d,e.pos,a),d}throw new D(`Unknown function ${a}()${t4(a2(a,[...t.names("fns"),...t.names("vars"),...Object.keys(A2),...c4]))}`,e.pos)}if(!C0(r.value))throw new D(`"${a}" is a ${K1(r.value)}, not a function`,e.pos);return this.callFunction(r.value,this.evalArgs(e.args,t,e.pos),t,a)}let n=this.expr(e.callee,t);if(!C0(n))throw new D(`Can't call a ${K1(n)}`,e.pos);return this.callFunction(n,this.evalArgs(e.args,t,e.pos),t,"function")}invisiblePaint(e,t,n,a){let r=s=>Array.isArray(n)?String(n[s]??""):[...e[s].layers.keys()].sort().join(",");for(let s=1;s<e.length;s++){if(!t[s]?.length)continue;let i=r(s),l=s1(e.flatMap((h,f)=>f<s&&r(f)===i?t[f]:[]));!l.length||Q1(t[s],l).reduce((h,f)=>h+Math.abs(g1(f)),0)>.001||this.warn(`paint(): child ${s+1} lies wholly on an area of the same layer${Array.isArray(n)&&i?` "${i}"`:""} under it, so it can't be seen (${S0(a,!1)})`)}}record(e,t){let n=new Map;for(let a of e.fields)n.set(a.name,this.expr(a.value,t));return{type:"record",fields:n}}length(e,t){let n=H1(t.get("$scale").value??1);if(!(n>0))throw new D("$scale must be a number more than 0",e.pos);return n===1&&e.unit!=="mm"&&(this.unscaled??(this.unscaled=e.pos)),e.value*_n[e.unit]/n}callable(e,t){return!!t.fn(e)||c4.includes(e)||!!Y1(A2,e)}specialFunction(e,t,n){if(e==="echo"){let a=this.evalArgs(t.args,n,t.pos);return this.echo(this.echoText(a),t.pos),{handled:!0,value:void 0}}if(e==="assert"){let a=this.evalArgs(t.args,n,t.pos);return this.checkArgs(e,a),this.assert(a),{handled:!0,value:!0}}if(e==="text_width"||e==="text_metrics"){let a=this.evalArgs(t.args,n,t.pos);this.checkArgs(e,a);let r=this.measure(a,n);return e==="text_width"?{handled:!0,value:r.advance}:{handled:!0,value:[r.advance,r.bounds,r.ascent,r.descent]}}if(e==="finger_count"){let a=this.evalArgs(t.args,n,t.pos);this.checkArgs(e,a);let r=this.num(this.arg(a,"length",0),"finger_count","length");return{handled:!0,value:g3(r,this.fingerWidth(a,n,1))}}return{handled:!1}}assert(e){if(k1(this.arg(e,"condition",0)))return;let t=this.arg(e,"message",1);throw new D(`Assertion failed${t===void 0?"":": "+I1(t)}`,e.at)}echo(e,t){this.charge(Math.ceil(e.length/W7),t),this.echoes.push(e)}echoText(e){let t=this.limits.maxListLength,n=[],a=0,r=(s,i,l)=>{n.length&&(a+=2);let o=l2(i,t-a-s.length,l);if(a+=s.length+o.text.length,!o.whole)throw new D(`echo(): the text would be longer than the limit of ${t} characters`,e.at);n.push(s+o.text)};for(let{name:s,value:i}of e.all)s===null?r("",i,!1):r(`${s} = `,i,!0);return n.join(", ")}arith(e,t,n,a){if(typeof t=="number"&&typeof n=="number")switch(e){case"+":return t+n;case"-":return t-n;case"*":return t*n;case"/":return t/n;case"%":return t%n;case"^":return Math.pow(t,n)}if(e==="+"&&typeof t=="string"&&typeof n=="string")return this.checkSize(t.length+n.length,!0,a),t+n;if(Array.isArray(t)&&Array.isArray(n)){if(e==="+"||e==="-"){if(t.length!==n.length)throw new D(`Can't ${e==="+"?"add":"subtract"} lists of length ${t.length} and ${n.length}`,a);return this.charge(t.length+x2,a),t.map((s,i)=>this.arith(e,s,n[i],a))}if(e==="*"){if(Array.isArray(t[0]))return this.charge(t.length+x2,a),t.map(i=>this.arith("*",i,n,a));let s=(i,l)=>{let o=this.arith("*",i,l,a);if(typeof o!="number")throw new D("Can't multiply these lists: an item times an item is not a number",a);return o};if(Array.isArray(n[0])){let i=n[0].length;if(t.length!==n.length||n.some(l=>!Array.isArray(l)||l.length!==i))throw new D(`Can't multiply a list of length ${t.length} by a matrix: it needs ${t.length} rows of the same length`,a);return this.checkSize(i,!1,a),this.tick(a,i*t.length),Array.from({length:i},(l,o)=>t.reduce((h,f,u)=>h+s(f,n[u][o]),0))}if(t.length!==n.length)throw new D(`Can't multiply lists of length ${t.length} and ${n.length}`,a);return this.tick(a,t.length),t.reduce((i,l,o)=>i+s(l,n[o]),0)}}if(Array.isArray(t)&&typeof n=="number"&&(e==="*"||e==="/"))return this.charge(t.length+x2,a),t.map(s=>this.arith(e,s,n,a));if(typeof t=="number"&&Array.isArray(n)&&e==="*")return this.charge(n.length+x2,a),n.map(s=>this.arith(e,t,s,a));let r={"+":"add","-":"subtract","*":"multiply","/":"divide","%":"take remainder of","^":"raise"};throw new D(`Can't ${r[e]??e} ${K1(t)} and ${K1(n)}`,a)}arg(e,t,n,a){return e.named.has(t)?e.named.get(t):n>=0&&n<e.pos.length?e.pos[n]:a}num(e,t,n){if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${n} must be a finite number, got ${J1(e)}`);return e}vec2(e,t,n=!0){let a=r=>typeof r=="number"&&Number.isFinite(r);if(a(e)&&n)return[e,e];if(Array.isArray(e)&&a(e[0])&&(e[1]===void 0||a(e[1])))return[e[0],e[1]??0];throw new Error(`${t} must be a number or [x, y], got ${J1(e)}`)}vec3(e,t){let n=a=>typeof a=="number"&&Number.isFinite(a);if(Array.isArray(e)&&(e.length===2||e.length===3)&&e.every(n))return[e[0],e[1],e[2]??0];throw new Error(`${t} must be [x, y, z], got ${J1(e)}`)}placements(e,t,n){let a=(i,l)=>i===void 0?[[0,0,0]]:Array.isArray(i)&&i.length>0&&Array.isArray(i[0])?i.map((o,h)=>this.vec3(o,`${l}[${h}]`)):[this.vec3(i,l)],r=a(e,"at"),s=a(t,"rotate");for(let[i,l]of[[r,"at"],[s,"rotate"]])if(i.length!==1&&i.length!==n)throw new Error(`${l} needs one placement per copy: qty is ${n} but ${l} has ${i.length}`);return Array.from({length:n},(i,l)=>({at:r[r.length===1?0:l],rotate:s[s.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((n,a)=>{if(!Array.isArray(n)||!Number.isFinite(n[0])||!Number.isFinite(n[1]))throw new Error(`${t}[${a}] must be an [x, y] point, got ${J1(n)}`);return[n[0],n[1]]})}dyn(e,t){return e.get(t).value}spend(e){if(this.pointCount+=e,!(e<=this.limits.maxPoints&&this.pointCount<=this.limits.maxPoints*10))throw new Error(`the shapes need more than ${this.limits.maxPoints} points, the limit. Use fewer or simpler shapes.`)}checkValue(e,t,n){(Array.isArray(e)||typeof e=="string")&&this.checkSize(e.length,typeof e=="string",t,n)}checkSize(e,t,n,a){if(e>this.limits.maxListLength)throw new D(`${a?`${a}(): `:""}${t?`a string of ${e} characters`:`a list of ${e} items`} is more than the limit of ${this.limits.maxListLength}`,n);this.charge(t?Math.ceil(e/W7):e+x2,n)}segs(e){let t=H1(this.dyn(e,"$fn"))||0,n=H1(this.dyn(e,"$fa"))||2,a=H1(this.dyn(e,"$fs"))||.2,r=this.limits.maxSegments;return s=>{let i=Y4(s,t,n,a);if(!(i<=r))throw new Error(`a circle with ${i} segments is more than the limit of ${r}. Lower $fn, or raise $fa or $fs.`);return i}}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,n){let a=this.arg(e,"finger",n);return typeof a=="number"&&a>0?a:Math.max(3*this.thickness(t),6)}measure(e,t){if(!this.opts.fonts)throw new D("text needs a font. Pass fonts to render(), or --font on the command line.",e.at);let n=l2(this.arg(e,"text",0,""),this.limits.maxTextLength);if(!n.whole)throw new D(`the text is more than ${this.limits.maxTextLength} characters, the limit for one text()`,e.at);this.tick(e.at,n.text.length);try{return e4(this.opts.fonts,n.text,this.textOpts(e,t,n.text))}catch(a){throw a instanceof D?a:new D(a.message,e.at)}}textOpts(e,t,n){let a={size:this.num(this.arg(e,"size",1,10),"text","size"),font:I1(this.arg(e,"font",2,this.dyn(t,"$font")??"")),halign:I1(this.arg(e,"halign",-1,"left")),valign:I1(this.arg(e,"valign",-1,"baseline")),spacing:H1(this.arg(e,"spacing",-1,1))},r=this.arg(e,"fit",-1);if(r!==void 0&&n!==void 0&&this.opts.fonts){let s=this.num(r,"text","fit");if(!(s>0))throw new Error("fit must be a width more than 0");let i=e4(this.opts.fonts,n,{...a,size:1}).advance;if(i>0){let l=this.arg(e,"size",1);a.size=l===void 0?s/i:Math.min(a.size,s/i)}}return a}edges(e){let t=n=>{if(n==="out"||n==="in"||n==="flat")return n;throw new Error(`edges must be "out", "in" or "flat", got ${J1(n)}`)};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]")}backLayer(e){let t=`${e}-back`,n=this.layers.get(t);if(n&&n.side!=="back")throw new Error(`the back of layer "${e}" is the layer "${t}", which this program already uses for the front. Rename that layer.`);if(!n){let a=this.layers.get(e)??{name:e,mode:"line",color:"#00aa00"};this.layers.set(t,{...a,name:t,side:"back"})}return t}bends(e){if(e===void 0)return[];let t=Array.isArray(e)&&Array.isArray(e[0])?e:[e];return t.map((n,a)=>{if(!Array.isArray(n)||n.length!==3||!n.every(l=>typeof l=="number"&&Number.isFinite(l)))throw new Error(`bend must be [x0, x1, angle] or a list of them, got ${J1(n)}${t.length>1?` at ${a}`:""}`);let[r,s,i]=n;if(!(s>r))throw new Error(`a bend's x1 must be more than its x0, got ${J1(n)}`);return{x0:r,x1:s,angle:i}})}makeBuiltins(){let e=(s,i)=>f2(s.children(),i),t=s=>i=>D2(i.children(),s),n=s=>i=>{let l=this.arg(i.args,"side",0,"front");if(l!=="front"&&l!=="back")throw new Error(`side must be "front" or "back", got ${J1(l)}`);return l==="back"&&i.env.vars.set("$mirrored",!k1(this.dyn(i.env,"$mirrored"))),D2(i.children(),l==="back"?this.backLayer(s):s)};return{rect:s=>{let[i,l]=this.vec2(this.arg(s.args,"size",0,1),"size"),o=H1(this.arg(s.args,"r",-1,0))||0,h=k1(this.arg(s.args,"center",1,!1)),f=K4(i,l,o,this.segs(s.env));return O1(s1([h?f.map(([u,d])=>[u-i/2,d-l/2]):f]))},square:s=>this.builtins.rect(s),circle:s=>{let i=this.arg(s.args,"d",-1),l=i!==void 0?this.num(i,"circle","d")/2:this.num(this.arg(s.args,"r",0,1),"circle","r");return O1([v3(l,l,this.segs(s.env)(l))])},ellipse:s=>{let[i,l]=this.vec2(this.arg(s.args,"r",0,1),"r");return O1([v3(i,l,this.segs(s.env)(Math.max(i,l)))])},regular_polygon:s=>{let i=Math.max(3,Math.floor(this.num(this.arg(s.args,"n",0,6),"regular_polygon","n"))),l=this.num(this.arg(s.args,"r",1,10),"regular_polygon","r");if(!(i<=this.limits.maxSegments))throw new Error(`${i} corners is more than the limit of ${this.limits.maxSegments}`);return O1([v3(l,l,i)])},star:s=>{let i=Math.max(2,Math.floor(this.num(this.arg(s.args,"n",0,5),"star","n"))),l=this.num(this.arg(s.args,"r",1,10),"star","r"),o=this.num(this.arg(s.args,"inner",2,l*.45),"star","inner");if(!(i*2<=this.limits.maxSegments))throw new Error(`${i} points is more than the limit of ${this.limits.maxSegments/2}`);let h=[];for(let f=0;f<i*2;f++){let u=Math.PI/2+Math.PI*f/i,d=f%2?o:l;h.push([d*Math.cos(u),d*Math.sin(u)])}return O1(s1([h]))},polygon:s=>{let i=this.points(this.arg(s.args,"points",0),"points"),l=this.arg(s.args,"paths",1),o=Array.isArray(l)?l.map(h=>(Array.isArray(h)?h:[]).map(f=>i[H1(f)]).filter(Boolean)):[i];return O1(s1(o,"evenodd"))},path:s=>{let i=this.arg(s.args,"d",0);if(typeof i!="string")throw new Error('path() needs SVG path data, like path("M0 0 L10 0 L5 8 Z")');let l=o2(a3(i),.01),o=this.arg(s.args,"fill",-1,"evenodd")==="nonzero"?"nonzero":"evenodd";return k1(this.arg(s.args,"close",-1,!1))?O1(s1([...l.closed,...l.open.filter(h=>h.length>2)],o)):U0([O1(s1(l.closed,o)),R0(l.open)])},line:s=>{let i=this.vec2(this.arg(s.args,"from",0,[0,0]),"from",!1),l=this.vec2(this.arg(s.args,"to",1,[10,0]),"to",!1),o=this.arg(s.args,"width",2);if(o===void 0)return R0([[i,l]]);let h=this.num(o,"line","width");if(!(h>0))throw new Error("width must be more than 0");let f=Math.hypot(l[0]-i[0],l[1]-i[1]);if(!f)return a0();let u=-(l[1]-i[1])/f*(h/2),d=(l[0]-i[0])/f*(h/2);return O1(s1([[[i[0]+u,i[1]+d],[i[0]-u,i[1]-d],[l[0]-u,l[1]-d],[l[0]+u,l[1]+d]]]))},polyline:s=>{let i=this.points(this.arg(s.args,"points",0),"points"),l=k1(this.arg(s.args,"closed",1,!1));return R0([l&&i.length?[...i,i[0]]:i])},arc:s=>{let i=this.num(this.arg(s.args,"r",0,10),"arc","r"),l=this.num(this.arg(s.args,"start",1,0),"arc","start"),o=this.num(this.arg(s.args,"end",2,90),"arc","end"),h=Math.max(2,Math.ceil(this.segs(s.env)(i)*Math.abs(o-l)/360));if(!(h<=this.limits.maxSegments))throw new Error(`an arc with ${h} segments is more than the limit of ${this.limits.maxSegments}`);let f=[];for(let u=0;u<=h;u++){let d=(l+(o-l)*u/h)*Math.PI/180;f.push([i*Math.cos(d),i*Math.sin(d)])}return R0([f])},text:s=>{if(!this.opts.fonts)throw new Error("text() needs a font. Pass fonts to render(), or --font on the command line.");let i=this.arg(s.args,"text",0,""),l=l2(i,this.limits.maxTextLength);if(!l.whole)throw new Error(`the text is more than ${this.limits.maxTextLength} characters, the limit for one text()`);this.tick(s.args.at,l.text.length);let o=N3(this.opts.fonts,l.text,this.textOpts(s.args,s.env,l.text));if(k1(this.dyn(s.env,"$mirrored"))){let[h,f]=[1/0,-1/0];for(let u of o)for(let[d]of u)[h,f]=[Math.min(h,d),Math.max(f,d)];return O1(s1(o.map(u=>u.map(([d,p])=>[h+f-d,p]))))}return O1(o)},translate:s=>{let[i,l]=this.vec2(this.arg(s.args,"v",0,[0,0]),"v",!1);return e(s,[1,0,0,1,i,l])},rotate:s=>{let i=this.arg(s.args,"a",0,0),o=(Array.isArray(i)?H1(i[2]??0):this.num(i,"rotate","a"))*Math.PI/180,h=Math.cos(o),f=Math.sin(o),u=this.arg(s.args,"center",-1),d=[h,f,-f,h,0,0];if(u!==void 0){let[p,m]=this.vec2(u,"center",!1);d=[h,f,-f,h,p-h*p+f*m,m-f*p-h*m]}return e(s,d)},scale:s=>{let[i,l]=this.vec2(this.arg(s.args,"v",0,1),"v");return e(s,[i,0,0,l,0,0])},mirror:s=>{let[i,l]=this.vec2(this.arg(s.args,"v",0,[1,0]),"v",!1),o=Math.hypot(i,l)||1,h=i/o,f=l/o;return e(s,[1-2*h*h,-2*h*f,-2*h*f,1-2*f*f,0,0])},multmatrix:s=>{let i=this.arg(s.args,"m",0);if(!Array.isArray(i)||i.length<2)throw new Error("m must be a 2x3 or 3x3 matrix");let l=i[0],o=i[1];return e(s,[l[0],o[0],l[1],o[1],l[2]??0,o[2]??0])},union:s=>s.children(),group:s=>s.children(),difference:s=>{let[i,...l]=s.childList();if(!i)return a0();let o=a(l,"difference");return r(i,h=>({regions:Q1(h.regions,o.regions),lines:M0(h.lines,s1(o.regions),"outside")}))},intersection:s=>{let i=s.childList();if(!i.length)return a0();let l=p=>[...p.layers.values()].some(m=>m.regions.length),o=p=>{let m;for(let v of i){if(v===p||!l(v))continue;let g=s1(a([v],"intersection").regions);m=m?Z1(m,g):g}return m},h=i[0],f=i.every(l),u=o(h),d=r(h,p=>({regions:f?u?Z1(p.regions,u):p.regions:[],lines:u?M0(p.lines,u,"inside"):p.lines}));for(let p of i){if(p===h)continue;if(p.parts.length)throw new Error("part() can only be the first child of intersection()");let m=o(p),v=new Map;for(let[g,y]of p.layers)y.lines.length&&v.set(g,{regions:[],lines:m?M0(y.lines,m,"inside"):y.lines});v.size&&(d=U0([d,{layers:v,parts:[]}]))}return d},hull:s=>{let i=s.children(),l=o=>{let h=[],f="cut",u=!0;for(let[p,m]of o){u&&(m.regions.length||m.lines.length)&&(f=p,u=!1);for(let v of[...m.regions,...m.lines])for(let g of v)h.push(g)}let d=Z4(h);return new Map([[f,{regions:d.length>=3?[d]:[],lines:[]}]])};return{layers:l(i.layers),parts:i.parts.map(o=>({...o,layers:l(o.layers)}))}},offset:s=>{let i=this.arg(s.args,"r",0),l=this.arg(s.args,"delta",-1),o=k1(this.arg(s.args,"chamfer",-1,!1)),h=i!==void 0?this.num(i,"offset","r"):this.num(l??0,"offset","delta"),f=i!==void 0?"round":o?"square":"miter";return r(s.children(),u=>({regions:N1(u.regions,h,f),lines:u.lines}))},pattern:s=>{let[i,l]=this.vec2(this.arg(s.args,"spacing",0,10),"spacing"),o=this.num(this.arg(s.args,"stagger",1,0),"pattern","stagger");if(!(i>0&&l>0))throw new Error("spacing must be more than 0");let[h,...f]=s.childList();if(!h||!f.length)throw new Error("pattern() needs a tile and then the area to fill: pattern(10) { tile(); area(); }");if(h.parts.length)throw new Error("part() cannot be the tile of pattern()");let u=s1(a(f,"pattern").regions),d=r0(h.layers),p=x0(u);if(!d||!p)return a0();let m=Math.floor((p[1]-d[3])/l),v=Math.ceil((p[3]-d[1])/l),g=Math.floor((p[0]-d[2])/i)-1,y=Math.ceil((p[2]-d[0])/i)+1,M=(v-m+1)*(y-g+1);if(!(M<=this.limits.maxParts*10))throw new Error(`the pattern would have ${M} copies, more than the limit of ${this.limits.maxParts*10}`);this.tick(s.args.at,M);let A=T0(u).map(P=>({polys:P,box:x0(P)})),z=u,E=(P,w)=>{let I=0;for(let B of z)for(let F=0,G=B.length-1;F<B.length;G=F++){let[X,q]=B[G],[o1,N]=B[F];q<=w?N>w&&(o1-X)*(w-q)-(P-X)*(N-q)>0&&I++:N<=w&&(o1-X)*(w-q)-(P-X)*(N-q)<0&&I--}return I!==0},k=new Map,C=(P,w)=>{let I=k.get(P)??{regions:[],lines:[]};for(let B of w.regions)I.regions.push(B);for(let B of w.lines)I.lines.push(B);k.set(P,I)};for(let P=m;P<=v;P++)for(let w=g;w<=y;w++){let I=w*i+(P%2?o*i:0),B=P*l,F=[d[0]+I,d[1]+B,d[2]+I,d[3]+B];if(F[2]<p[0]||F[0]>p[2]||F[3]<p[1]||F[1]>p[3])continue;let G=A.filter(Z=>!(F[2]<Z.box[0]||F[0]>Z.box[2]||F[3]<Z.box[1]||F[1]>Z.box[3]));if(!G.length)continue;z=G.length===A.length?u:G.flatMap(Z=>Z.polys);let X=[E(F[0],F[1]),E(F[2],F[1]),E(F[2],F[3]),E(F[0],F[3])],q=z.some(Z=>Z.some(([e1,t1])=>e1>F[0]&&e1<F[2]&&t1>F[1]&&t1<F[3])),o1=X.every(Boolean)&&!q,N=[1,0,0,1,I,B];for(let[Z,e1]of f2({layers:h.layers,parts:[]},N).layers)C(Z,o1?e1:{regions:Z1(e1.regions,z),lines:M0(e1.lines,z,"inside")})}return{layers:k,parts:[]}},spline:s=>{let i=this.points(this.arg(s.args,"points",0),"points"),l=this.arg(s.args,"width",1),o=Math.max(1,Math.floor(this.num(this.arg(s.args,"steps",-1,8),"spline","steps"))),h=k1(this.arg(s.args,"closed",-1,!1));if(!(i.length*o<=this.limits.maxSegments*10))throw new Error("too many points: use fewer points or steps");let f=n5(i,o,h);if(l===void 0)return R0([f]);let u=this.num(l,"spline","width");if(!(u>0))throw new Error("width must be more than 0");return O1(s1(m3([f],u)))},hatch:s=>{let i=this.num(this.arg(s.args,"angle",0,45),"hatch","angle"),l=this.num(this.arg(s.args,"pitch",1,5),"hatch","pitch"),o=this.arg(s.args,"width",2);if(!(l>0))throw new Error("pitch must be more than 0");let h=s1(a([s.children()],"hatch").regions),f=x0(h);if(!f)return a0();let[u,d]=[(f[0]+f[2])/2,(f[1]+f[3])/2],p=Math.hypot(f[2]-f[0],f[3]-f[1])/2+l,m=i*Math.PI/180,[v,g]=[Math.cos(m),Math.sin(m)],[y,M]=[-g,v],A=Math.ceil(p/l);if(!(2*A+1<=this.limits.maxSegments*10))throw new Error("pitch is too small for the area");this.tick(s.args.at,2*A+1);let z=[],E=Math.round((u*y+d*M)/l);for(let C=E-A;C<=E+A;C++){let P=C*l-(u*y+d*M),[w,I]=[u+y*P,d+M*P];z.push([[w-v*p,I-g*p],[w+v*p,I+g*p]])}if(o===void 0)return R0(M0(z,h,"inside"));let k=this.num(o,"hatch","width");if(!(k>0))throw new Error("width must be more than 0");return O1(Z1(s1(m3(z,k).map(C=>C)),h))},paint:s=>{let i=this.arg(s.args,"layers",0);if(i!==void 0&&(!Array.isArray(i)||i.some(u=>typeof u!="string")))throw new Error("layers must be a list of layer names");let l=s.childList(),o=[],h=[],f=[];for(let u=l.length-1;u>=0;u--){let d=l[u];if(d.parts.length)throw new Error("part() cannot go inside paint()");let p=h,m=s1(a([d],"paint").regions);f[u]=m,h=p.length?s1([...p,...m]):m;let v=Array.isArray(i)?i[u]:void 0;v!==""&&(v!==void 0?(this.layers.has(v)||this.layers.set(v,{name:v,mode:"fill",color:"#000000"}),o.push(O1(p.length?Q1(m,p):m,v))):o.push(p.length?r(d,g=>({regions:Q1(g.regions,p),lines:M0(g.lines,p,"outside")})):d))}return this.invisiblePaint(l,f,i,s.args.at),U0(o.reverse())},measure:s=>{let i=k1(this.arg(s.args,"draw",0,!1)),l=s.childSeq((o,h)=>{if(o!==0)return;let f=r0(h.layers)??x0(h.parts.flatMap(u=>[...u.layers.values()].flatMap(d=>[...d.regions,...d.lines])));s.env.vars.set("$bounds",f?[...f]:void 0)});return U0(i?l:l.slice(1))},fill_holes:s=>{let i=this.arg(s.args,"min_area",0),l=i===void 0?1/0:this.num(i,"fill_holes","min_area");return r(s.children(),o=>({regions:s1(o.regions).filter(h=>!(g1(h)<0&&-g1(h)<l)),lines:o.lines}))},close:s=>{let i=this.num(this.arg(s.args,"r",0,.5),"close","r");return r(s.children(),l=>({regions:N1(N1(l.regions,i,"round"),-i,"round"),lines:l.lines}))},stroke:s=>{let i=this.num(this.arg(s.args,"width",0,1),"stroke","width");return r(s.children(),l=>({regions:s1([...l.regions,...m3(l.lines,i)]),lines:[]}))},outline:s=>r(s.children(),i=>({regions:[],lines:[...i.lines,...s1(i.regions).map(l=>[...l,l[0]])]})),cut:t("cut"),score:n("score"),engrave:n("engrave"),guide:t("guide"),layer:s=>{let i=this.arg(s.args,"name",0);if(typeof i!="string"||!i)throw new Error("layer() needs a name");let l=this.arg(s.args,"mode",1),o=this.arg(s.args,"color",2),h=this.layers.get(i),f=this.arg(s.args,"order",-1),u=this.arg(s.args,"bleed",-1);if(l!==void 0||o!==void 0||f!==void 0||u!==void 0||!h){if(h?.side==="back")throw new Error(`the layer "${i}" is the back of layer "${i.slice(0,-5)}"; set its mode and colour on that layer, or give this one another name`);let p=l??h?.mode??"line";if(!["cut","line","fill","guide"].includes(p))throw new Error('mode must be "cut", "line", "fill" or "guide"');let m=I1(o??h?.color??"#00aa00");if(!/^#[0-9a-fA-F]{6}$/.test(m))throw new Error('color must look like "#00aa00"');let v=f===void 0?h?.order:this.num(f,"layer","order"),g=u===void 0?h?.bleed:this.num(u,"layer","bleed");if(g!==void 0&&!(g>=0))throw new Error("bleed must be 0 or more");if(g&&p==="cut")throw new Error("a cut layer has no bleed");this.layers.set(i,{name:i,mode:p,color:m,...v!==void 0&&{order:v},...g!==void 0&&{bleed:g}})}let d=this.arg(s.args,"side",-1,"front");if(d!=="front"&&d!=="back")throw new Error(`side must be "front" or "back", got ${J1(d)}`);if(d==="back"&&this.layers.get(i)?.mode==="cut")throw new Error("a cut layer has no back: only marks go on the back face");return d==="back"&&s.env.vars.set("$mirrored",!k1(this.dyn(s.env,"$mirrored"))),D2(s.children(),d==="back"?this.backLayer(i):i)},part:s=>{let i=I1(this.arg(s.args,"name",0,"part")),l=Math.max(1,Math.floor(H1(this.arg(s.args,"qty",1,1))||1)),o=this.arg(s.args,"stack",-1),h=o===void 0?1:Math.floor(this.num(o,"part","stack"));if(!(h>=1))throw new Error("stack must be 1 or more");if(this.copies+=l*h,!(this.copies<=this.limits.maxParts))throw new Error(`more than ${this.limits.maxParts} part copies in total, the limit`);let f=this.arg(s.args,"at",-1),u=this.arg(s.args,"rotate",-1),d=this.arg(s.args,"glue",-1),p=d===void 0?void 0:I1(d),m=I1(this.arg(s.args,"face",-1,"top"));if(m!=="top"&&m!=="bottom")throw new Error(`face must be "top" or "bottom", got ${J1(m)}`);let v=this.frame!==b5&&p===void 0,g=this.arg(s.args,"bend",-1),y=f===void 0&&u===void 0&&!v&&p===void 0&&g===void 0?void 0:this.placements(f,u,l),M=this.thickness(s.env);y&&(v||h>1)&&(y=y.flatMap(N=>{let Z=p===void 0?F1(this.frame,h0(N)):h0(N),e1=p!==void 0&&m==="bottom"?-M:M;return Array.from({length:h},(t1,d1)=>({...N,matrix:F1(Z,I0(0,0,d1*e1))}))}));let A=this.arg(s.args,"mirror",-1,!1),z;if(Array.isArray(A)){if(A.length!==l)throw new Error(`mirror needs one true or false per copy: qty is ${l} but mirror has ${A.length}`);z=A.map(N=>k1(N))}else z=Array.from({length:l},()=>k1(A));let E=z.some(N=>N)&&!z.every(N=>N);if(E&&p!==void 0)throw new Error("mirror per copy cannot go with glue: make the mirrored copies a part of their own");let k=z[0],C=N=>{let Z=s.env.vars.get("$mirrored"),e1=s.env.vars.has("$mirrored");N&&s.env.vars.set("$mirrored",!0);try{let t1=s.children();return N?f2(t1,[-1,0,0,1,0,0]):t1}finally{N&&(e1?s.env.vars.set("$mirrored",Z):s.env.vars.delete("$mirrored"))}},P=C(k),w=this.bends(g),I=this.arg(s.args,"on",-1),B=this.arg(s.args,"slots",-1),F=B===void 0?void 0:(Array.isArray(B)?B:[B]).map(N=>{if(typeof N!="string")throw new Error("slots must be part names");return N}),G=this.num(this.arg(s.args,"clearance",-1,.1),"part","clearance"),X=(N,Z,e1)=>{let t1=e1.length===l,d1=y?.filter((_1,M1)=>e1.includes(Math.floor(M1/h)+1));return{name:i,qty:e1.length*h,layers:N,thickness:M,kerf:H1(this.dyn(s.env,"$kerf"))||0,material:I1(this.dyn(s.env,"$material")??"material"),...d1?{placements:d1}:{},...h>1?{stack:h}:{},...w.length?{bends:w}:{},...I!==void 0?{on:I1(I)}:{},...F?{slots:F,clearance:G}:{},...this.step?{step:this.step}:{},...p!==void 0&&{glue:{host:p,face:m}},...Z&&{mirrored:!0},...!t1&&{copies:e1}}},q=N=>z.flatMap((Z,e1)=>Z===N?[e1+1]:[]),o1=E?[X(P.layers,k,q(k)),X(C(!k).layers,!k,q(!k))]:[X(P.layers,k,q(k))];return{layers:new Map,parts:[...P.parts,...o1]}},place:s=>{let i=this.vec3(this.arg(s.args,"at",0,[0,0,0]),"at"),l=this.vec3(this.arg(s.args,"rotate",1,[0,0,0]),"rotate"),o=this.frame;this.frame=F1(o,h0({at:i,rotate:l}));try{return s.children()}finally{this.frame=o}},step:s=>{let i=I1(this.arg(s.args,"text",0,"")),l=k1(this.arg(s.args,"substeps",1,!0));if(this.stepFolded)return s.children();let o=this.step,h=o&&i?`${this.stepNames[o-1]}: ${i}`:i,f=this.stepNames.indexOf(h)+1;f||(this.stepNames.push(h),f=this.stepNames.length),this.step=f,this.stepFolded=!l;try{return s.children()}finally{this.step=o,this.stepFolded=!1}},hardware:s=>{let i=I1(this.arg(s.args,"kind",0,"dowel"));Y1(k5,i)===void 0&&Y1(h6,i)===void 0&&this.warn(`hardware(): unknown kind "${i}"; the 3D view shows it grey (${S0(s.args.at,!1)})${a2(i,Object.keys(k5))}`);let l=this.vec3(this.arg(s.args,"from",1),"from"),o=this.vec3(this.arg(s.args,"to",2),"to"),h=this.arg(s.args,"size",3,6),f=typeof h=="number"?h:this.vec2(h,"size",!1),u=[o[0]-l[0],o[1]-l[1],o[2]-l[2]],d=Math.abs(u[2])>.9*Math.hypot(...u),p=this.arg(s.args,"up",-1),m=p===void 0?d?[0,1,0]:[0,0,1]:this.vec3(p,"up"),v=Math.floor(this.num(this.arg(s.args,"sides",-1,24),"hardware","sides"));if(!(v>=3&&v<=j7))throw new Error(`sides must be from 3 to ${j7}, got ${J1(v)}`);if(this.pointCount+=v*2,this.pointCount>this.limits.maxPoints*10)throw new Error(`making the shapes and hardware took more than ${this.limits.maxPoints*10} points of work, the limit`);let g=this.arg(s.args,"label",-1),y=this.frame,M=z=>[y[0]*z[0]+y[1]*z[1]+y[2]*z[2]+y[3],y[4]*z[0]+y[5]*z[1]+y[6]*z[2]+y[7],y[8]*z[0]+y[9]*z[1]+y[10]*z[2]+y[11]],A=z=>[y[0]*z[0]+y[1]*z[1]+y[2]*z[2],y[4]*z[0]+y[5]*z[1]+y[6]*z[2],y[8]*z[0]+y[9]*z[1]+y[10]*z[2]];if(this.hardware.length>=this.limits.maxParts)throw new Error(`more than ${this.limits.maxParts} pieces of hardware, the limit`);return this.hardware.push({kind:i,from:M(l),to:M(o),size:f,up:A(m),sides:v,step:this.step,...g!==void 0?{label:I1(g)}:{}}),s.children()},material:s=>{let i=this.arg(s.args,"thickness",0),l=this.arg(s.args,"kerf",1),o=this.arg(s.args,"name",2);return i!==void 0&&s.env.vars.set("$thickness",this.num(i,"material","thickness")),l!==void 0&&s.env.vars.set("$kerf",this.num(l,"material","kerf")),o!==void 0&&s.env.vars.set("$material",I1(o)),s.children()},children:s=>{let i=s.env.childCtx();if(!i)return a0();let l=this.childStmts(i.stmts),o=this.arg(s.args,"index",0),h=new R1(i.env,s.env);this.hoist(i.stmts,h);let f=new Set;if(o===void 0)l.forEach(m=>f.add(m));else for(let m of this.iterable(o,s.args.at))l[H1(m)]&&f.add(l[H1(m)]);let u=[],d=this.childCache.get(i)??new Map;this.childCache.set(i,d);let p=this.childKey(h);for(let m of i.stmts)if(m.kind==="assign")this.stmt(m,h);else if(f.has(m)){let v=p&&d.get(m);if(v&&v.key===p){v.shape&&u.push(v.shape);continue}let g=this.effects(),y=this.stmt(m,h);y&&u.push(y),p&&this.effects()===g&&!y?.parts.length&&d.set(m,{key:p,shape:y})}return U0(u)},echo:s=>(this.echo(this.echoText(s.args),s.args.at),s.children()),assert:s=>(this.assert(s.args),s.children()),finger_rect:s=>{let[i,l]=this.vec2(this.arg(s.args,"size",0),"size"),o=this.edges(this.arg(s.args,"edges",1,"out")),h=this.thickness(s.env),f=this.fingerWidth(s.args,s.env,2);return this.spend(2*(Math.abs(i)+Math.abs(l))/f*4),O1(J4(i,l,o,h,f))},finger_holes:s=>{let i=this.num(this.arg(s.args,"length",0),"finger_holes","length"),l=this.edges(this.arg(s.args,"edge",1,"out"))[0];if(l==="flat")throw new Error('edge must be "out" or "in"');let o=this.fingerWidth(s.args,s.env,2);return this.spend(Math.abs(i)/o*4),O1(Q4(i,l,this.thickness(s.env),o))},tslot:s=>{let i=this.num(this.arg(s.args,"d",0,3),"tslot","d"),l=this.num(this.arg(s.args,"length",1,12),"tslot","length"),[o,h]=this.vec2(this.arg(s.args,"nut",2,[i*1.85,i*.8]),"nut",!1),f=this.num(this.arg(s.args,"nut_at",3,l/2),"tslot","nut_at");return O1(s1(e6(i,l,o,h,f)))},living_hinge:s=>{let[i,l]=this.vec2(this.arg(s.args,"size",0),"size"),o=this.num(this.arg(s.args,"spacing",1,1.5),"living_hinge","spacing"),h=this.num(this.arg(s.args,"bridge",2,3),"living_hinge","bridge"),f=this.num(this.arg(s.args,"cut",3,Math.max(h*2,(l-3*h)/2)),"living_hinge","cut");if(o<=0||h<=0||f<=0)throw new Error("spacing, bridge and cut must be positive");return this.spend((Math.abs(i)/o+1)*(Math.abs(l)/(f+h)+2)*2),R0(t6(i,l,o,h,f))}};function a(s,i){let l={regions:[],lines:[]};for(let o of s){if(o.parts.length)throw new Error(`part() can only be the first child of ${i}()`);for(let h of o.layers.values())for(let f of h.regions)l.regions.push(f)}return l}function r(s,i){let l=o=>{let h=new Map;for(let[f,u]of o)h.set(f,i(u));return h};return{layers:l(s.layers),parts:s.parts.map(o=>({...o,layers:l(o.layers)}))}}}};var W0=1e6,$3=.01,X7=c=>g1(c)<0?[...c].reverse():c;function Xn(c,e){let t=F1(w3(c.matrix),e.matrix),[n,a]=[t[8],t[9]],r=Math.hypot(n,a);if(r<1e-9)return[];let s=0,i=e.thickness,l=k=>(-t[11]-Math.max(t[10]*s,t[10]*i)+k)/r,o=k=>(c.thickness-t[11]-Math.min(t[10]*s,t[10]*i)-k)/r;if(!(o($3)>l($3)))return[];let[h,f]=[n/r,a/r],[u,d]=[-f,h],p=(k,C)=>[[h*k-u*W0,f*k-d*W0],[h*C-u*W0,f*C-d*W0],[h*C+u*W0,f*C+d*W0],[h*k+u*W0,f*k+d*W0]],m=1/0,v=-1/0;for(let k of e.outline)for(let[C,P]of k)for(let w of[s,i]){let I=t[8]*C+t[9]*P+t[10]*w+t[11];I<m&&(m=I),I>v&&(v=I)}if(Math.min(c.thickness,v)-Math.max(0,m)<Math.min(1,c.thickness/2))return[];let g=(k,C)=>Z1(e.outline,[X7(p(k,C))]).filter(P=>Math.abs(g1(P))>1e-6);if(!g(l($3),o($3)).length)return[];let y=g(l(0),o(0));if(!y.length)return[];let M=k=>([C,P])=>[t[0]*C+t[1]*P+t[2]*k+t[3],t[4]*C+t[5]*P+t[6]*k+t[7]],A=t[0]*t[5]-t[1]*t[4]<0,z=k=>y.map(C=>{let P=C.map(M(k));return A?P.reverse():P}),E=[];for(let k of y)for(let C=0;C<k.length;C++){let P=k[C],w=k[(C+1)%k.length],I=[M(s)(P),M(s)(w),M(i)(w),M(i)(P)];Math.abs(g1(I))>1e-9&&E.push(X7(I))}return s1([...z(s),...z(i),...E],"nonzero")}function Z7(c,e,t){let n=[];for(let r of e)for(let s of Xn(c,r))n.push(s);if(!n.length)return[];let a=T0(Z1(s1(n),c.outline)).filter(r=>r.reduce((s,i)=>s+g1(i),0)>1e-4);return a.length?N1(a.flat(),t/2,"miter"):[]}var b2=c=>{let e=Math.round(c*1e3)/1e3;return Object.is(e,-0)?"0":String(e)},s4=c=>c.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;");function i4(c,e){let t=[];for(let[n,a]of c){let r=[b2(n),b2(a)],s=t[t.length-1];(!s||s[0]!==r[0]||s[1]!==r[1])&&t.push(r)}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 z2=(c,e)=>`M${i4(c,e).map(([t,n])=>`${t} ${n}`).join("L")}${e?"Z":""}`;function G3(c,e){let t=[];for(let n of e){let a=[],r=[],s=[];for(let i of c){let l=i.layers.get(n.name);if(l){for(let o of l.lines)a.push(z2(o,!1));for(let o of l.regions)(g1(o)<0?r:s).push(z2(o,!0))}}(a.length||r.length||s.length)&&t.push({name:n.name,mode:n.mode,color:n.color,d:[...a,...r,...s].join(""),regions:[...r,...s].join(""),lines:a.join("")})}return t}function _3(c,e,t,n){let a=['<?xml version="1.0" encoding="UTF-8"?>',`<svg xmlns="http://www.w3.org/2000/svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="${b2(e)}mm" height="${b2(t)}mm" viewBox="0 0 ${b2(e)} ${b2(t)}">`];for(let r of n){let s=[],i=[];for(let o of c){let h=o.layers.get(r.name);if(!h)continue;let f=` data-part="${s4(o.part)}"`;if(r.mode==="fill"){h.regions.length&&i.push(`<path${f} d="${h.regions.map(u=>z2(u,!0)).join("")}"/>`);for(let u of h.lines)i.push(`<path${f} fill="none" stroke="${r.color}" stroke-width="0.1" d="${z2(u,!1)}"/>`);continue}for(let u of h.lines)s.push(`<path${f} d="${z2(u,!1)}"/>`);for(let u of h.regions)(g1(u)<0?s:i).push(`<path${f} d="${z2(u,!0)}"/>`)}if(!s.length&&!i.length)continue;let l=r.mode==="fill"?`fill="${r.color}" fill-rule="evenodd" stroke="none"`:`fill="none" stroke="${r.color}" stroke-width="0.1"${r.mode==="guide"?' stroke-dasharray="1 1"':""}`;a.push(`<g id="${s4(r.name)}" inkscape:groupmode="layer" inkscape:label="${s4(r.name)}" data-mode="${r.mode}" ${l}>`,...s,...i,"</g>")}return a.push("</svg>",""),a.join(`
2227
- `)}var Zn={"#ff0000":1,"#ffff00":2,"#00ff00":3,"#00ffff":4,"#0000ff":5,"#ff00ff":6,"#000000":7},Yn=c=>{let e=Zn[c.toLowerCase()];if(e)return e;let[t,n,a]=[1,3,5].map(r=>parseInt(c.slice(r,r+2),16));return t>n&&t>a?1:n>t&&n>a?3:a>t&&a>n?5:7};function Kn(c){let e=i=>i.toUpperCase().replace(/[^A-Z0-9_-]/g,"_"),t=new Set(a4.map(i=>i.name)),n=new Set(c.map(i=>e(i.name))),a=new Set,r=new Map,s=[...c.filter(i=>t.has(i.name)),...c.filter(i=>!t.has(i.name))];for(let i of s){let l=e(i.name);if(a.has(l)){let o=2;for(;n.has(`${l}_${o}`)||a.has(`${l}_${o}`);)o++;l=`${l}_${o}`}a.add(l),r.set(i.name,l)}return r}function l4(c,e,t,n){let a=[],r=(l,o)=>a.push(String(l),String(o)),s=Kn(n);r(0,"SECTION"),r(2,"HEADER"),r(9,"$ACADVER"),r(1,"AC1009"),r(9,"$INSUNITS"),r(70,4),r(0,"ENDSEC"),r(0,"SECTION"),r(2,"TABLES"),r(0,"TABLE"),r(2,"LAYER"),r(70,n.length);for(let l of n)r(0,"LAYER"),r(2,s.get(l.name)),r(70,0),r(62,Yn(l.color)),r(6,"CONTINUOUS");r(0,"ENDTAB"),r(0,"ENDSEC"),r(0,"SECTION"),r(2,"ENTITIES");let i=(l,o,h)=>{r(0,"POLYLINE"),r(8,l),r(66,1),r(10,0),r(20,0),r(30,0),r(70,h?1:0);for(let[f,u]of i4(o.map(([d,p])=>[d,t-p]),h))r(0,"VERTEX"),r(8,l),r(10,f),r(20,u),r(30,0);r(0,"SEQEND"),r(8,l)};for(let l of n){let o=s.get(l.name),h=[];for(let f of c){let u=f.layers.get(l.name);if(u){for(let d of u.lines)i(o,d,!1);for(let d of u.regions)g1(d)<0?i(o,d,!0):h.push(d)}}for(let f of h)i(o,f,!0)}return r(0,"ENDSEC"),r(0,"EOF"),a.join(`
2559
+ `};var H8=/^(?:[A-Za-z_$][A-Za-z0-9_]*|(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?|"(?:[^"\\]|\\.)*"?|<=|>=|==|!=|&&|\|\|)/,w4=(n,e)=>Math.max(1,H8.exec(n.slice(e-1))?.[0].length??1);var n0=n=>typeof n=="object"&&n!==null&&!Array.isArray(n)&&n.type==="range",P0=n=>typeof n=="object"&&n!==null&&!Array.isArray(n)&&n.type==="function",L4=n=>typeof n=="number",$1=n=>typeof n=="object"&&n!==null&&!Array.isArray(n)&&n.type==="record",K1=(n,e)=>n&&Object.prototype.hasOwnProperty.call(n,e)?n[e]:void 0;function e5(n,e,t=0){if(!(e==null||["number","string","boolean"].includes(typeof e))){if(Array.isArray(e)&&t<32){for(let c of e)e5(n,c,t+1);return}throw new Error(`Setting "${n}" must be a number, string, boolean or list`)}}function r3(n,e){let t=[];if(n.step===0||(n.step>0?n.start>n.end:n.start<n.end))return t;let c=Math.floor((n.end-n.start)/n.step+1e-9)+1;if(c>e)throw new Error(`a range of ${c} items is more than the limit of ${e}`);for(let a=0;a<c;a++)t.push(n.start+a*n.step);return t}function k1(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 k4=(n,e,t)=>n0(n)&&n0(e)?n.start===e.start&&n.step===e.step&&n.end===e.end:$1(n)&&$1(e)?n.fields.size===e.fields.size&&[...n.fields].every(([c,a])=>e.fields.has(c)&&i2(a,e.fields.get(c),t)):n===e;function i2(n,e,t){if(t?.(),!Array.isArray(n)||!Array.isArray(e))return k4(n,e,t);let c=new Map,a=[],r=(s,i)=>{let l=c.get(s);return l?.has(i)?!0:s.length!==i.length?!1:(l||c.set(s,l=new Set),l.add(i),a.push([s,i,0]),!0)};if(!r(n,e))return!1;for(;a.length;){let s=a[a.length-1];if(s[2]===s[0].length){a.pop();continue}let i=s[0][s[2]],l=s[1][s[2]++];if(t?.(),Array.isArray(i)&&Array.isArray(l)?!r(i,l):!k4(i,l,t))return!1}return!0}function J1(n){return n===void 0?"undef":Array.isArray(n)?"list":n0(n)?"range":P0(n)?"function":$1(n)?"record":typeof n}function V8(n){return n===void 0?"undef":typeof n=="string"?JSON.stringify(n):typeof n=="number"?C0(n):n0(n)?`[${C0(n.start)}:${C0(n.step)}:${C0(n.end)}]`:P0(n)?`function(${n.params.map(e=>e.name).join(", ")})`:$1(n)?"{}":String(n)}function l2(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 c=[],a=0,r=o=>{c.push(o),a+=o.length},s=[],i=n;for(;;){Array.isArray(i)?(r("["),s.push({items:i,i:0,close:"]"})):$1(i)&&i.fields.size?(r("{"),s.push({items:[...i.fields.values()],keys:[...i.fields.keys()],i:0,close:"}"})):r(V8(i));let o=!1;for(;s.length&&!o&&a<=e;){let h=s[s.length-1];h.i<h.items.length?(h.i&&r(", "),h.keys&&r(`${h.keys[h.i]} = `),i=h.items[h.i++],o=!0):(s.pop(),r(h.close))}if(!o||a>e)break}let l=c.join("");return a>e?{text:l.slice(0,Math.max(e,0)),whole:!1}:{text:l,whole:!0}}function S4(n,e,t){let c=[],a=0;for(let r of n){c.length&&(a+=e.length);let s=l2(r,t-a);if(!s.whole)return;a+=s.text.length,c.push(s.text)}return c.join(e)}function X1(n){let e=l2(n,200,!0);return e.whole?e.text:e.text+"..."}var C1=n=>typeof n=="string"?n:X1(n);function V1(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 C0(n){return Number.isInteger(n)?String(n):String(Number(n.toPrecision(10)))}function o2(n,e=.02){let t=[],c=[],a=[],r=[0,0],s=[0,0],i=o=>{a.length>=2&&(o?t:c).push(a),a=[]},l=o=>Math.max(2,Math.min(256,Math.ceil(Math.sqrt(o/e))));for(let o of n)if(o.type==="M")i(!1),r=s=[o.x,o.y],a=[s];else if(o.type==="L")s=[o.x,o.y],a.push(s);else if(o.type==="Q"){let[h,f]=s,u=l(Math.hypot(o.x1-h,o.y1-f)+Math.hypot(o.x-o.x1,o.y-o.y1));for(let d=1;d<=u;d++){let p=d/u,m=1-p;a.push([m*m*h+2*m*p*o.x1+p*p*o.x,m*m*f+2*m*p*o.y1+p*p*o.y])}s=[o.x,o.y]}else if(o.type==="C"){let[h,f]=s,u=l(Math.hypot(o.x1-h,o.y1-f)+Math.hypot(o.x2-o.x1,o.y2-o.y1)+Math.hypot(o.x-o.x2,o.y-o.y2));for(let d=1;d<=u;d++){let p=d/u,m=1-p;a.push([m*m*m*h+3*m*m*p*o.x1+3*m*p*p*o.x2+p*p*p*o.x,m*m*m*f+3*m*m*p*o.y1+3*m*p*p*o.y2+p*p*p*o.y])}s=[o.x,o.y]}else i(!0),s=r,a=[r];return i(!1),{closed:t,open:c}}function s3(n,e=Math.PI/2,t){let c=w=>/^[a-zA-Z]$/.test(w),a=n.match(/[a-zA-Z]|[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/g)??[],r=[],s=0,i="",l=0,o=0,h=0,f=0,u=0,d=0,p=0,m=0,v="",g=()=>{let w=a[s++];if(w===void 0||c(w))throw new Error(`Bad path data near "${w??"end"}"`);return Number(w)},b=()=>{let w=a[s];if(w===void 0)throw new Error("Bad path data: missing arc flag");return w.length>1&&(w[0]==="0"||w[0]==="1")&&!w.includes(".")?(a[s]=w.slice(1),Number(w[0])):(s++,Number(w))};try{y()}catch(w){if(!t)throw w;t(w.message)}return r;function y(){for(;s<a.length;){if(c(a[s]))i=a[s++];else if(i){if(i==="Z"||i==="z")throw new Error(`Bad path data near "${a[s]}": Z takes no numbers`)}else throw new Error("Path data must start with a command");let w=i===i.toLowerCase(),k=i.toUpperCase(),P=w?l:0,S=w?o:0;if(k==="M")l=P+g(),o=S+g(),h=l,f=o,r.push({type:"M",x:l,y:o}),i=w?"l":"L";else if(k==="L")l=P+g(),o=S+g(),r.push({type:"L",x:l,y:o});else if(k==="H")l=P+g(),r.push({type:"L",x:l,y:o});else if(k==="V")o=S+g(),r.push({type:"L",x:l,y:o});else if(k==="C"||k==="S"){let A,E;if(k==="C")A=P+g(),E=S+g();else{let $=v==="C"||v==="S";A=$?2*l-u:l,E=$?2*o-d:o}let z=P+g(),I=S+g();l=P+g(),o=S+g(),u=z,d=I,r.push({type:"C",x1:A,y1:E,x2:z,y2:I,x:l,y:o})}else if(k==="Q"||k==="T"){let A,E;if(k==="Q")A=P+g(),E=S+g();else{let z=v==="Q"||v==="T";A=z?2*l-p:l,E=z?2*o-m:o}l=P+g(),o=S+g(),p=A,m=E,r.push({type:"Q",x1:A,y1:E,x:l,y:o})}else if(k==="A"){let A=g(),E=g(),z=g(),I=b(),$=b(),F=P+g(),_=S+g();r.push(...O8(l,o,A,E,z,I,$,F,_,e)),l=F,o=_}else if(k==="Z")r.push({type:"Z"}),l=h,o=f;else throw new Error(`Unknown path command "${i}"`);v=k}}}function O8(n,e,t,c,a,r,s,i,l,o=Math.PI/2){if(t===0||c===0||n===i&&e===l)return[{type:"L",x:i,y:l}];t=Math.abs(t),c=Math.abs(c);let h=a*Math.PI/180,f=Math.cos(h),u=Math.sin(h),d=(n-i)/2,p=(e-l)/2,m=f*d+u*p,v=-u*d+f*p,g=m*m/(t*t)+v*v/(c*c);g>1&&(t*=Math.sqrt(g),c*=Math.sqrt(g));let b=t*t*c*c-t*t*v*v-c*c*m*m,y=t*t*v*v+c*c*m*m,w=Math.sqrt(Math.max(0,b/y));r===s&&(w=-w);let k=w*t*v/c,P=-w*c*m/t,S=f*k-u*P+(n+i)/2,A=u*k+f*P+(e+l)/2,E=(N,i1,h1,U)=>Math.atan2(N*U-i1*h1,N*h1+i1*U),z=E(1,0,(m-k)/t,(v-P)/c),I=E((m-k)/t,(v-P)/c,(-m-k)/t,(-v-P)/c);!s&&I>0&&(I-=2*Math.PI),s&&I<0&&(I+=2*Math.PI);let $=Math.ceil(Math.abs(I)/o),F=[],_=N=>[S+t*Math.cos(N)*f-c*Math.sin(N)*u,A+t*Math.cos(N)*u+c*Math.sin(N)*f],Y=N=>[-t*Math.sin(N)*f-c*Math.cos(N)*u,-t*Math.sin(N)*u+c*Math.cos(N)*f];for(let N=0;N<$;N++){let i1=z+I*N/$,h1=z+I*(N+1)/$,U=4/3*Math.tan((h1-i1)/4),c1=_(i1),X=_(h1),f1=Y(i1),I1=Y(h1);F.push({type:"C",x1:c1[0]+U*f1[0],y1:c1[1]+U*f1[1],x2:X[0]-U*I1[0],y2:X[1]-U*I1[1],x:X[0],y:X[1]})}return F}var O1=Math.PI/180,K=(n,e,t)=>({params:n.replace("...","").split(",").map(c=>c.trim()).filter(Boolean),rest:n.endsWith("..."),order:t,run:e});function I4(n,e,t){return n.order?[]:n.params.filter((c,a)=>a<e.length&&t.has(c))}function H4(n,e,t){if(n.rest){let r=[...e];return n.params.forEach((s,i)=>{t.has(s)&&(r[i]=t.get(s))}),r}if(!n.order)return n.params.map((r,s)=>t.has(r)?t.get(r):e[s]);let c=e.length+n.params.filter(r=>t.has(r)).length,a=n.order(c).filter(r=>!t.has(r));return n.params.map(r=>t.has(r)?t.get(r):e[a.indexOf(r)])}function t5(n,e,t,c){let a=S4(n,e,t.maxLength);if(a===void 0)throw new Error(`${c}(): the text would be longer than the limit of ${t.maxLength} characters`);return t.step(Math.ceil(a.length/8)),a}function a1(n,e){if(typeof n!="number")throw new Error(`${e}() needs a number, got ${J1(n)}`);return n}function l0(n,e,t){if(Array.isArray(n))return n;if(n0(n))return r3(n,t.maxLength);if(typeof n=="string")return[...n];throw new Error(`${e}() needs a list, got ${J1(n)}`)}var F8=new Set(["is_num","is_string","is_bool","is_list","is_undef","is_function","type_of","ord"]);function V4(n,e,t){if(F8.has(n))return 0;let c=0;for(let a of e)if(typeof a=="string")c+=a.length;else if(Array.isArray(a))c+=n==="len"?0:a.length;else if(n0(a)&&a.step!==0){let r=Math.floor((a.end-a.start)/a.step)+1;r>0&&(c+=Math.min(r,t+1))}return c}var Z1=n=>K("x",e=>typeof e[0]=="number"?o0(n(e[0])):void 0);function o0(n){let e=Math.round(n);return Math.abs(n-e)<1e-12?e:n}function D8(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 A4(n,e,t){let c=n.length===1&&Array.isArray(n[0])?n[0]:n;if(c.length)return e(c.map(a=>a1(a,t)))}var P2={abs:Z1(Math.abs),sign:Z1(Math.sign),floor:Z1(Math.floor),ceil:Z1(Math.ceil),round:Z1(n=>n<0?-Math.round(-n):Math.round(n)),sqrt:Z1(Math.sqrt),exp:Z1(Math.exp),ln:Z1(Math.log),log:K("x, base",(n,e)=>e.given<2?o0(Math.log10(a1(n[0],"log"))):Math.log(a1(n[0],"log"))/Math.log(a1(n[1],"log")),n=>n>=2?["base","x"]:["x","base"]),sin:Z1(n=>Math.sin(n*O1)),cos:Z1(n=>Math.cos(n*O1)),tan:Z1(n=>Math.tan(n*O1)),asin:Z1(n=>Math.asin(n)/O1),acos:Z1(n=>Math.acos(n)/O1),atan:Z1(n=>Math.atan(n)/O1),atan2:K("y, x",n=>o0(Math.atan2(a1(n[0],"atan2"),a1(n[1],"atan2"))/O1)),pow:K("x, y",n=>Math.pow(a1(n[0],"pow"),a1(n[1],"pow"))),min:K("values...",n=>A4(n,e=>e.reduce((t,c)=>c<t?c:t,1/0),"min")),max:K("values...",n=>A4(n,e=>e.reduce((t,c)=>c>t?c:t,-1/0),"max")),clamp:K("x, low, high",n=>Math.min(Math.max(a1(n[0],"clamp"),a1(n[1],"clamp")),a1(n[2],"clamp"))),lerp:K("a, b, t",n=>{let e=a1(n[2],"lerp");if(Array.isArray(n[0])&&Array.isArray(n[1])){let t=n[1];return n[0].map((c,a)=>a1(c,"lerp")+(a1(t[a],"lerp")-a1(c,"lerp"))*e)}return a1(n[0],"lerp")+(a1(n[1],"lerp")-a1(n[0],"lerp"))*e}),norm:K("v",(n,e)=>Math.sqrt(l0(n[0],"norm",e).reduce((t,c)=>t+a1(c,"norm")**2,0))),cross:K("a, b",(n,e)=>{let t=l0(n[0],"cross",e).map(a=>a1(a,"cross")),c=l0(n[1],"cross",e).map(a=>a1(a,"cross"));return t.length===2?t[0]*c[1]-t[1]*c[0]:[t[1]*c[2]-t[2]*c[1],t[2]*c[0]-t[0]*c[2],t[0]*c[1]-t[1]*c[0]]}),len:K("value",n=>typeof n[0]=="string"?[...n[0]].length:Array.isArray(n[0])?n[0].length:$1(n[0])?n[0].fields.size:void 0),keys:K("record",n=>$1(n[0])?[...n[0].fields.keys()]:void 0),merge:K("a, b",n=>{if(!$1(n[0])||!$1(n[1]))throw new Error("merge() takes two records");return{type:"record",fields:new Map([...n[0].fields,...n[1].fields])}}),concat:K("...",(n,e)=>{let t=n.reduce((c,a)=>c+(Array.isArray(a)?a.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(c=>Array.isArray(c)?c:[c])}),reverse:K("value",(n,e)=>typeof n[0]=="string"?[...n[0]].reverse().join(""):[...l0(n[0],"reverse",e)].reverse()),sum:K("values",(n,e)=>l0(n[0],"sum",e).reduce((t,c)=>t+a1(c,"sum"),0)),slice:K("value, start, end",(n,e)=>{let c=(typeof n[0]=="string"?[...n[0]]:l0(n[0],"slice",e)).slice(a1(n[1]??0,"slice"),n[2]===void 0?void 0:a1(n[2],"slice"));return typeof n[0]=="string"?c.join(""):c}),str:K("...",(n,e)=>t5(n,"",e,"str")),chr:K("...",n=>n.flatMap(e=>Array.isArray(e)?e:[e]).map(e=>String.fromCodePoint(a1(e,"chr"))).join("")),ord:K("text",n=>typeof n[0]=="string"&&n[0].length?n[0].codePointAt(0):void 0),upper:K("text",n=>typeof n[0]=="string"?n[0].toUpperCase():void 0),lower:K("text",n=>typeof n[0]=="string"?n[0].toLowerCase():void 0),split:K("text, separator",n=>typeof n[0]=="string"?n[0].split(typeof n[1]=="string"?n[1]:" "):void 0),join:K("values, separator",(n,e)=>t5(l0(n[0],"join",e),typeof n[1]=="string"?n[1]:"",e,"join")),search:K("value, list",(n,e)=>{let c=(typeof n[1]=="string"?[...n[1]]:l0(n[1],"search",e)).findIndex(a=>i2(a,n[0],e.step));return c<0?void 0:c}),contains:K("value, item",(n,e)=>typeof n[0]=="string"?n[0].includes(t5([n[1]],"",e,"contains")):l0(n[0],"contains",e).some(t=>i2(t,n[1],e.step))),lookup:K("x, table",(n,e)=>{let t=a1(n[0],"lookup"),c=l0(n[1],"lookup",e);if(!c.length)return;let a=c.map(r=>[a1(r[0],"lookup"),a1(r[1],"lookup")]).sort((r,s)=>r[0]-s[0]);if(t<=a[0][0])return a[0][1];for(let r=1;r<a.length;r++)if(t<=a[r][0]){let[s,i]=a[r-1],[l,o]=a[r];return i+(t-s)/(l-s)*(o-i)}return a[a.length-1][1]}),rands:K("min, max, count, seed",n=>{let e=a1(n[0],"rands"),t=a1(n[1],"rands"),c=a1(n[2],"rands"),a=D8(n[3]===void 0?1:a1(n[3],"rands"));return Array.from({length:Math.min(Math.max(0,Math.floor(c)),1e6)},()=>e+(t-e)*a())}),is_num:K("value",n=>L4(n[0])&&!Number.isNaN(n[0])),is_string:K("value",n=>typeof n[0]=="string"),is_bool:K("value",n=>typeof n[0]=="boolean"),is_list:K("value",n=>Array.isArray(n[0])),is_record:K("value",n=>$1(n[0])),is_undef:K("value",n=>n[0]===void 0),is_function:K("value",n=>P0(n[0])),type_of:K("value",n=>J1(n[0])),path_length:K("points",(n,e)=>{let t=C2(n[0],"path_length",e),c=0;for(let a=1;a<t.length;a++)c+=Math.hypot(t[a][0]-t[a-1][0],t[a][1]-t[a-1][1]);return c}),point_at:K("points, s",(n,e)=>C4(C2(n[0],"point_at",e),a1(n[1],"point_at")).point),heading_at:K("points, s",(n,e)=>o0(C4(C2(n[0],"heading_at",e),a1(n[1],"heading_at")).heading)),offset_path:K("points, d, closed",(n,e)=>{let t=C2(n[0],"offset_path",e).filter(([o,h],f,u)=>f===0||o!==u[f-1][0]||h!==u[f-1][1]),c=a1(n[1],"offset_path"),a=n[2]===!0,r=a&&t.length>1&&t[0][0]===t.at(-1)[0]&&t[0][1]===t.at(-1)[1];if(r&&t.pop(),t.length<2)throw new Error("offset_path(): a path needs at least two points");e.step(t.length);let s=t.length,i=o=>{let[h,f]=t[o%s],[u,d]=t[(o+1)%s],p=Math.hypot(u-h,d-f);return[-(d-f)/p,(u-h)/p]},l=t.map(([o,h],f)=>{let u=!a&&f===0,d=!a&&f===s-1,p=i(u?0:(f-1+s)%s),m=i(d?s-2:f),[v,g]=[p[0]+m[0],p[1]+m[1]],b=Math.hypot(v,g);if(b<1e-9)[v,g]=p;else{let y=Math.min(2/(b*b),4/b);[v,g]=[v*y,g*y]}return[o0(o+c*v),o0(h+c*g)]});return r?[...l,l[0]]:l}),train_for:K("ratio, stages, pinion, wheel",(n,e)=>{let t=a1(n[0],"train_for");if(!(t>0)||!Number.isFinite(t))throw new Error("train_for(): ratio must be more than 0");let c=n[1]===void 0?2:a1(n[1],"train_for");if(!(c===1||c===2||c===3))throw new Error("train_for(): stages must be 1, 2 or 3");let a=(g,b,y)=>{if(g===void 0)return b;if(!Array.isArray(g)||g.length!==2||!g.every(P=>typeof P=="number"))throw new Error(`train_for(): ${y} must be [fewest, most] teeth`);let[w,k]=[Math.ceil(g[0]),Math.floor(g[1])];if(!(w>=6&&k>=w&&k<=400))throw new Error(`train_for(): ${y} teeth must be from 6 to 400, fewest first`);return[w,k]},[r,s]=a(n[2],[10,20],"pinion"),[i,l]=a(n[3],[20,80],"wheel"),o=t<1,h=o?1/t:t,f=[];for(let g=r;g<=s;g++)for(let b=Math.max(i,g);b<=l;b++)f.push([g,b]);let u,d=g=>{let b=g.reduce((k,[P,S])=>k*S/P,1),y=Math.abs(b/h-1),w=g.reduce((k,[P,S])=>k+P+S,0);(!u||y<u.err-1e-12||Math.abs(y-u.err)<=1e-12&&w<u.teeth)&&(u={stages:g.map(k=>[...k]),err:y,teeth:w})},p=(g,b)=>{e.step();for(let y=r;y<=s;y++)for(let w of[Math.floor(b*y),Math.ceil(b*y)])w>=Math.max(i,y)&&w<=l&&d([...g,[y,w]])};if(c===1)p([],h);else for(let g=0;g<f.length;g++){let b=f[g][1]/f[g][0];if(c===2)p([f[g]],h/b);else for(let y=g;y<f.length;y++)p([f[g],f[y]],h/b/(f[y][1]/f[y][0]))}if(!u)throw new Error(`train_for(): no train of ${c} stages reaches a ratio of ${t}`);let m=u.stages.map(([g,b])=>o?[b,g]:[g,b]),v=m.reduce((g,[b,y])=>g*y/b,1);return{type:"record",fields:new Map([["stages",m],["ratio",v],["error",v/t-1]])}}),path_points:K("d, tolerance",(n,e)=>{if(typeof n[0]!="string")throw new Error("path_points() needs SVG path data");let t=n[1]===void 0?.05:a1(n[1],"path_points");if(!(t>0))throw new Error("path_points(): tolerance must be more than 0");let c=o2(s3(n[0]),t),a=[...c.closed.map(r=>[...r,r[0]]),...c.open];return e.step(a.reduce((r,s)=>r+s.length,0)),a.map(r=>r.map(([s,i])=>[s,i]))}),spline_points:K("points, steps, closed",(n,e)=>{let t=C2(n[0],"spline_points",e),c=n[1]===void 0?8:Math.floor(a1(n[1],"spline_points"));if(!(c>=1))throw new Error("spline_points(): steps must be 1 or more");if(t.length*c>e.maxLength)throw new Error("spline_points(): the result would be too long");return e.step(t.length*c),c5(t,c,n[2]===!0)}),rotation:K("angles",n=>{let[e,t,c]=n5(n[0],"rotation");return B8(E4(N8(c),E4(U8(t),q8(e))))}),euler:K("matrix",n=>T4(R8(n[0],"euler"))),orient:K("x, z",n=>{let e=P4(n5(n[0],"orient"),"orient"),t=n5(n[1]??[0,0,1],"orient"),c=t[0]*e[0]+t[1]*e[1]+t[2]*e[2];t=P4([t[0]-c*e[0],t[1]-c*e[1],t[2]-c*e[2]],"orient");let a=[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]];return T4([[e[0],a[0],t[0]],[e[1],a[1],t[1]],[e[2],a[2],t[2]]])})};function C2(n,e,t){return l0(n,e,t).map((a,r)=>{if(!Array.isArray(a)||typeof a[0]!="number"||typeof a[1]!="number")throw new Error(`${e}(): points[${r}] must be an [x, y] point`);return[a[0],a[1]]})}function C4(n,e){if(n.length<2)throw new Error("a path needs at least two points");let t=n.filter(([l,o],h)=>h===0||l!==n[h-1][0]||o!==n[h-1][1]);if(t.length<2)return{point:[t[0][0],t[0][1]],heading:0};let c=0,a=0;for(;c<t.length-2;c++){let l=Math.hypot(t[c+1][0]-t[c][0],t[c+1][1]-t[c][1]);if(a+l>=e)break;a+=l}let[r,s]=[t[c],t[c+1]],i=(e-a)/Math.hypot(s[0]-r[0],s[1]-r[1]);return{point:[r[0]+(s[0]-r[0])*i,r[1]+(s[1]-r[1])*i],heading:Math.atan2(s[1]-r[1],s[0]-r[0])/O1}}function n5(n,e){if(!Array.isArray(n)||n.length<2||n.length>3||!n.every(t=>typeof t=="number"))throw new Error(`${e}() needs [x, y, z]`);return[n[0],n[1],n[2]??0]}function P4(n,e){let t=Math.hypot(...n);if(!(t>1e-12))throw new Error(`${e}(): a direction can't be [0, 0, 0], or x and z the same way`);return[n[0]/t,n[1]/t,n[2]/t]}function R8(n,e){if(!Array.isArray(n)||n.length<3||!n.slice(0,3).every(t=>Array.isArray(t)&&t.length>=3&&t.slice(0,3).every(c=>typeof c=="number")))throw new Error(`${e}() needs a 3x3 matrix`);return n.slice(0,3).map(t=>t.slice(0,3))}var q8=n=>{let[e,t]=[Math.cos(n*O1),Math.sin(n*O1)];return[[1,0,0],[0,e,-t],[0,t,e]]},U8=n=>{let[e,t]=[Math.cos(n*O1),Math.sin(n*O1)];return[[e,0,t],[0,1,0],[-t,0,e]]},N8=n=>{let[e,t]=[Math.cos(n*O1),Math.sin(n*O1)];return[[e,-t,0],[t,e,0],[0,0,1]]},E4=(n,e)=>n.map(t=>[0,1,2].map(c=>t[0]*e[0][c]+t[1]*e[1][c]+t[2]*e[2][c])),B8=n=>n.map(e=>e.map(o0));function T4(n){let e=-n[2][0];if(Math.abs(e)>1-1e-12){let t=e>0?90:-90,c=Math.atan2(-n[0][1],n[1][1])/O1;return[0,t,o0(c)]}return[o0(Math.atan2(n[2][1],n[2][2])/O1),o0(Math.asin(e)/O1),o0(Math.atan2(n[1][0],n[0][0])/O1)]}function c5(n,e,t=!1){if(n.length<3)return n.map(([s,i])=>[s,i]);let c=s=>{if(t)return n[(s%n.length+n.length)%n.length];if(s<0)return[2*n[0][0]-n[1][0],2*n[0][1]-n[1][1]];if(s>=n.length){let[i,l]=[n[n.length-1],n[n.length-2]];return[2*i[0]-l[0],2*i[1]-l[1]]}return n[s]},a=[],r=t?n.length:n.length-1;for(let s=0;s<r;s++){let[i,l,o,h]=[c(s-1),c(s),c(s+1),c(s+2)];for(let f=0;f<e;f++){let u=f/e,d=u*u,p=d*u;a.push([0,1].map(m=>.5*(2*l[m]+(-i[m]+o[m])*u+(2*i[m]-5*l[m]+4*o[m]-h[m])*d+(-i[m]+3*l[m]-3*o[m]+h[m])*p)))}}return a.push(t?a[0]:[n[n.length-1][0],n[n.length-1][1]]),a}var y1;(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"})(y1||(y1={}));var N1;(function(n){n[n.Subject=0]="Subject",n[n.Clip=1]="Clip"})(N1||(N1={}));var s1;(function(n){n[n.EvenOdd=0]="EvenOdd",n[n.NonZero=1]="NonZero",n[n.Positive=2]="Positive",n[n.Negative=3]="Negative"})(s1||(s1={}));var l1;(function(n){n[n.IsOn=0]="IsOn",n[n.IsInside=1]="IsInside",n[n.IsOutside=2]="IsOutside"})(l1||(l1={}));var h2=Number.MAX_SAFE_INTEGER,S1=Math.floor(Math.sqrt(h2));function i3(n,e){return!Number.isSafeInteger(n)||!Number.isSafeInteger(e)?!1:n===0||e===0?!0:Math.abs(n)<=h2/Math.abs(e)}function O4(n,e){return Math.abs(n)+Math.abs(e)<=h2}function a5(n,e,t,c){if(i3(n,e)&&i3(t,c)){let a=n*e,r=t*c;if(O4(a,r))return a-r}return Number.isSafeInteger(n)&&Number.isSafeInteger(e)&&Number.isSafeInteger(t)&&Number.isSafeInteger(c)?Number(BigInt(n)*BigInt(e)-BigInt(t)*BigInt(c)):n*e-t*c}function r5(n,e,t,c){if(i3(n,e)&&i3(t,c)){let a=n*e,r=t*c;if(O4(a,r))return a+r}return Number.isSafeInteger(n)&&Number.isSafeInteger(e)&&Number.isSafeInteger(t)&&Number.isSafeInteger(c)?Number(BigInt(n)*BigInt(e)+BigInt(t)*BigInt(c)):n*e+t*c}var s5=BigInt(0),l3=BigInt(2),$8=BigInt(4),_8=BigInt(64),G8=BigInt("0xFFFFFFFFFFFFFFFF"),o5=BigInt("9223372036854775807"),E2=Number(o5/$8),F4=Number(o5),D4=1e-12,j8=.1,i5=Math.floor(S1/2),W8=Math.floor(Math.sqrt(Math.sqrt(h2/4)));function X8(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:h2/e}function Z8(n,e,t){if(!Number.isFinite(n)||Math.abs(n)>e)throw new RangeError(`Scaled coordinate exceeds Number.MAX_SAFE_INTEGER in ${t}`)}function Y8(n,e){if(!Number.isFinite(n)||Math.abs(n)>h2)throw new RangeError(`Coordinate exceeds Number.MAX_SAFE_INTEGER in ${e}`)}function K8(n,e,t){let c=e.x-n.x,a=t.y-e.y,r=e.y-n.y,s=t.x-e.x;return Math.abs(c)<S1&&Math.abs(a)<S1&&Math.abs(r)<S1&&Math.abs(s)<S1?c*a-r*s:a5(c,a,r,s)}function c0(n,e,t){let c=e.x-n.x,a=t.y-e.y,r=e.y-n.y,s=t.x-e.x;if(Math.abs(c)<S1&&Math.abs(a)<S1&&Math.abs(r)<S1&&Math.abs(s)<S1){let o=c*a,h=r*s;return o>h?1:o<h?-1:0}if(!Number.isSafeInteger(c)||!Number.isSafeInteger(a)||!Number.isSafeInteger(r)||!Number.isSafeInteger(s)){let o=c*a,h=r*s;return o>h?1:o<h?-1:0}let i=BigInt(c)*BigInt(a),l=BigInt(r)*BigInt(s);return i===l?0:i>l?1:-1}function J8(n){if(n<-8||n>8)throw new Error("Error: Precision is out of range.")}function Q8(n){return Math.abs(n)<=D4}function e9(n){return n<0?-1:n>0?1:0}function t9(n,e){let t=BigInt(n),c=BigInt(e),a=t*c;return{lo64:a&G8,hi64:a>>_8}}function R4(n,e,t,c){let a=Math.abs(n),r=Math.abs(e),s=Math.abs(t),i=Math.abs(c);if(a<S1&&r<S1&&s<S1&&i<S1)return n*e===t*c;let l=(n<0?-1:n>0?1:0)*(e<0?-1:e>0?1:0),o=(t<0?-1:t>0?1:0)*(c<0?-1:c>0?1:0);if(l!==o)return!1;if(l===0)return!0;if(!Number.isSafeInteger(a)||!Number.isSafeInteger(r)||!Number.isSafeInteger(s)||!Number.isSafeInteger(i))return n*e===t*c;let h=BigInt(a),f=BigInt(r),u=BigInt(s),d=BigInt(i);return h*f===u*d}function n9(n,e,t){let c=e.x-n.x,a=t.y-e.y,r=e.y-n.y,s=t.x-e.x;return R4(c,a,r,s)}function c9(n,e,t){let c=e.x-n.x,a=t.x-e.x,r=e.y-n.y,s=t.y-e.y;return Math.abs(c)<S1&&Math.abs(a)<S1&&Math.abs(r)<S1&&Math.abs(s)<S1?c*a+r*s:r5(c,a,r,s)}function a9(n,e,t){let c=e.x-n.x,a=t.x-e.x,r=e.y-n.y,s=t.y-e.y;if(Math.abs(c)<S1&&Math.abs(a)<S1&&Math.abs(r)<S1&&Math.abs(s)<S1){let l=c*a+r*s;return l>0?1:l<0?-1:0}if(!Number.isSafeInteger(c)||!Number.isSafeInteger(a)||!Number.isSafeInteger(r)||!Number.isSafeInteger(s)){let l=c*a+r*s;return l>0?1:l<0?-1:0}let i=BigInt(c)*BigInt(a)+BigInt(r)*BigInt(s);return i===s5?0:i>s5?1:-1}function r9(n){let e=n.length;if(e<3)return 0;let t=!0;for(let r=0;r<e&&t;r++){let s=n[r];(Math.abs(s.x)>=i5||Math.abs(s.y)>=i5)&&(t=!1)}let c=n[e-1];if(t){let r=0;for(let s of n)r+=(c.y+s.y)*(c.x-s.x),c=s;return r*.5}let a=s5;for(let r of n){let s=c.y+r.y,i=c.x-r.x;if(Number.isSafeInteger(s)&&Number.isSafeInteger(i))a+=BigInt(s)*BigInt(i);else if(Number.isSafeInteger(c.y)&&Number.isSafeInteger(r.y)&&Number.isSafeInteger(c.x)&&Number.isSafeInteger(r.x)){let l=BigInt(c.y)+BigInt(r.y),o=BigInt(c.x)-BigInt(r.x);a+=l*o}else a+=BigInt(Math.round(s*i));c=r}return Number(a)*.5}function s9(n,e){return n.y*e.x-e.y*n.x}function i9(n,e){return n.x*e.x+n.y*e.y}function l9(n){let e=Math.round(n);return n===e-.5&&(e&1)!==0?e-1:e}function o9(n){return n>=E2||n<=-E2?F4:Math.round(n)}function h9(n,e,t,c){let a=e.y-n.y,r=e.x-n.x,s=c.y-t.y,i=c.x-t.x,l=a5(a,i,s,r);if(l===0)return null;let o=a5(n.x-t.x,s,n.y-t.y,i)/l;return o<=0?{x:n.x,y:n.y,z:n.z||0}:o>=1?{x:e.x,y:e.y,z:e.z||0}:{x:Math.trunc(n.x+o*r),y:Math.trunc(n.y+o*a),z:0}}function u9(n,e,t,c){let a=e.y-n.y,r=e.x-n.x,s=c.y-t.y,i=c.x-t.x,l=a*i-s*r;if(l===0)return{success:!1,ip:{x:0,y:0,z:0}};let o=((n.x-t.x)*s-(n.y-t.y)*i)/l,h;return o<=0?h={...n,z:0}:o>=1?h={...e,z:0}:h={x:n.x+o*r,y:n.y+o*a,z:0},{success:!0,ip:h}}function f9(n,e,t,c,a=!1){if(!a){let o=c0(n,t,c),h=c0(e,t,c),f=c0(t,n,e),u=c0(c,n,e);return o!==0&&h!==0&&o!==h&&f!==0&&u!==0&&f!==u}let r=c0(n,t,c),s=c0(e,t,c);if(r!==0&&r===s)return!1;let i=c0(t,n,e),l=c0(c,n,e);return i!==0&&i===l?!1:r!==0||s!==0||i!==0||l!==0}function q4(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 d9(n,e,t){if(e.x===t.x&&e.y===t.y)return{x:e.x,y:e.y,z:0};let c=t.x-e.x,a=t.y-e.y,r=r5(n.x-e.x,c,n.y-e.y,a)/r5(c,c,a,a),s=r<0?0:r>1?1:r;return{x:Math.round(e.x+s*c),y:Math.round(e.y+s*a),z:0}}function l5(n,e){let t=e.length,c=0;if(t<3)return l1.IsOutside;for(;c<t&&e[c].y===n.y;)c++;if(c===t)return l1.IsOutside;let a=e[c].y<n.y,r=a,s=0,i=c+1,l=t;for(;;){if(i===l){if(l===0||c===0)break;l=c,i=0}if(a)for(;i<l&&e[i].y<n.y;)i++;else for(;i<l&&e[i].y>n.y;)i++;if(i===l)continue;let h=e[i],f=i>0?e[i-1]:e[t-1];if(h.y===n.y){if(h.x===n.x||h.y===f.y&&n.x<f.x!=n.x<h.x)return l1.IsOn;if(i++,i===c)break;continue}if(!(n.x<h.x&&n.x<f.x))if(n.x>f.x&&n.x>h.x)s=1-s;else{let u=c0(f,h,n);if(u===0)return l1.IsOn;u<0===a&&(s=1-s)}a=!a,i++}if(a===r)return s===0?l1.IsOutside:l1.IsInside;i===t&&(i=0);let o=i===0?c0(e[t-1],e[0],n):c0(e[i-1],e[i],n);return o===0?l1.IsOn:(o<0===a&&(s=1-s),s===0?l1.IsOutside:l1.IsInside)}function p9(n,e){let t=l1.IsOn;for(let i of n)switch(l5(i,e)){case l1.IsOutside:if(t===l1.IsOutside)return!1;t=l1.IsOutside;break;case l1.IsInside:if(t===l1.IsInside)return!0;t=l1.IsInside;break;default:break}let c=q4(n),a,r;return Number.isSafeInteger(c.left)&&Number.isSafeInteger(c.right)&&Math.abs(c.left)+Math.abs(c.right)>Number.MAX_SAFE_INTEGER?(a=Number((BigInt(c.left)+BigInt(c.right))/l3),r=Number((BigInt(c.top)+BigInt(c.bottom))/l3)):(a=Math.round((c.left+c.right)/2),r=Math.round((c.top+c.bottom)/2)),l5({x:a,y:r},e)!==l1.IsOutside}var Q={MaxInt64:o5,MaxCoord:E2,max_coord:E2,min_coord:-E2,Invalid64:F4,floatingPointTolerance:D4,defaultMinimumEdgeLength:j8,maxCoordForSafeAreaProduct:i5,maxCoordForSafeCrossSq:W8,maxSafeCoordinateForScale:X8,checkSafeScaleValue:Z8,ensureSafeInteger:Y8,crossProduct:K8,crossProductSign:c0,checkPrecision:J8,isAlmostZero:Q8,triSign:e9,multiplyUInt64:t9,productsAreEqual:R4,isCollinear:n9,dotProduct:c9,dotProductSign:a9,area:r9,crossProductD:s9,dotProductD:i9,roundToEven:l9,checkCastInt64:o9,getLineIntersectPt:h9,getLineIntersectPtD:u9,segsIntersect:f9,getBounds:q4,getClosestPtOnSegment:d9,pointInPolygon:l5,path2ContainsPath1:p9},y0={create(n=0,e=0,t=0){return{x:Math.round(n),y:Math.round(e),z:t}},fromPointD(n){return Q.ensureSafeInteger(n.x,"Point64Utils.fromPointD"),Q.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,c=n.y+e.y;return Number.isSafeInteger(t)&&Number.isSafeInteger(c)?{x:t,y:c,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} `}},o3={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 Q.isAlmostZero(n.x-e.x)&&Q.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)}`}},J0={create(n=0,e=0,t=0,c=0){return{left:n,top:e,right:t,bottom:c}},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))/l3),t=Number((BigInt(n.top)+BigInt(n.bottom))/l3);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}]}},h5={create(n=0,e=0,t=0,c=0){return{left:n,top:e,right:t,bottom:c}},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 U4=Object.freeze(J0.createInvalid()),N4=Object.freeze(h5.createInvalid());var T2=BigInt(0),m9=BigInt(2),B4=BigInt(4),m1;(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"})(m1||(m1={}));var u5=class{constructor(){T(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 c=e-1>>1;if(this.data[c]>=t)break;this.data[e]=this.data[c],e=c}this.data[e]=t}siftDown(e){let t=this.data.length,c=this.data[e];for(;;){let a=(e<<1)+1;if(a>=t)break;let r=a+1,s=a;if(r<t&&this.data[r]>this.data[a]&&(s=r),this.data[s]<=c)break;this.data[e]=this.data[s],e=s}this.data[e]=c}},I2=class{constructor(e,t,c){T(this,"pt");T(this,"next",null);T(this,"prev",null);T(this,"flags");this.pt=e,this.flags=t,this.prev=c}},H2=class{constructor(e,t,c=!1){T(this,"vertex");T(this,"polytype");T(this,"isOpen");this.vertex=e,this.polytype=t,this.isOpen=c}equals(e){return e!==null&&this.vertex===e.vertex}};function $4(n,e,t){return{pt:n,edge1:e,edge2:t}}var E0=class{constructor(e,t){T(this,"pt");T(this,"next");T(this,"prev");T(this,"outrec");T(this,"horz");this.pt=e,this.outrec=t,this.next=this,this.prev=this,this.horz=null}},_1;(function(n){n[n.None=0]="None",n[n.Left=1]="Left",n[n.Right=2]="Right"})(_1||(_1={}));var f5;(function(n){n[n.Bottom=0]="Bottom",n[n.Middle=1]="Middle",n[n.Top=2]="Top"})(f5||(f5={}));var h3=class{constructor(){T(this,"idx",0);T(this,"owner",null);T(this,"frontEdge",null);T(this,"backEdge",null);T(this,"pts",null);T(this,"polypath",null);T(this,"bounds",{left:0,top:0,right:0,bottom:0});T(this,"path",[]);T(this,"isOpen",!1);T(this,"splits",null);T(this,"recursiveSplit",null)}},u3=class{constructor(e){T(this,"leftOp");T(this,"rightOp");T(this,"leftToRight");this.leftOp=e,this.rightOp=null,this.leftToRight=!0}},V2=class{constructor(e,t){T(this,"op1");T(this,"op2");this.op1=e,this.op2=t}};function v9(n,e){return n.rightOp===null?e.rightOp===null?0:1:e.rightOp===null?-1:n.leftOp.pt.x-e.leftOp.pt.x}function g9(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 O2=class{constructor(){T(this,"bot",{x:0,y:0});T(this,"top",{x:0,y:0});T(this,"curX",0);T(this,"dx",0);T(this,"windDx",0);T(this,"windCount",0);T(this,"windCount2",0);T(this,"outrec",null);T(this,"prevInAEL",null);T(this,"nextInAEL",null);T(this,"prevInSEL",null);T(this,"nextInSEL",null);T(this,"jump",null);T(this,"vertexTop",null);T(this,"localMin",null);T(this,"isLeftBound",!1);T(this,"joinWith",_1.None)}},u2={addLocMin(n,e,t,c){if((n.flags&m1.LocalMin)!==m1.None)return;n.flags|=m1.LocalMin;let a=new H2(n,e,t);c.push(a)},addPathsToVertexList(n,e,t,c,a){for(let r=0,s=n.length;r<s;r++){let i=n[r],l=null,o=null,h=null;for(let p=0,m=i.length;p<m;p++){let v=i[p];if(l===null)l=new I2(v,m1.None,null),a.push(l),o=l,h=v;else if(!(h.x===v.x&&h.y===v.y)){let g=new I2(v,m1.None,o);o.next=g,o=g,h=v}}if(o?.prev==null||(!t&&o.pt.x===l.pt.x&&o.pt.y===l.pt.y&&(o=o.prev),o.next=l,l.prev=o,!t&&o.next===o))continue;let f;if(t){let p=l.next;for(;p!==l&&p.pt.y===l.pt.y;)p=p.next;f=p.pt.y<=l.pt.y,f?(l.flags=m1.OpenStart,u2.addLocMin(l,e,!0,c)):l.flags=m1.OpenStart|m1.LocalMax}else{for(o=l.prev;o!==l&&o.pt.y===l.pt.y;)o=o.prev;if(o===l)continue;f=o.pt.y>l.pt.y}let u=f;o=l;let d=l.next;for(;d!==l;)d.pt.y>o.pt.y&&f?(o.flags|=m1.LocalMax,f=!1):d.pt.y<o.pt.y&&!f&&(f=!0,u2.addLocMin(o,e,t,c)),o=d,d=d.next;t?(o.flags|=m1.OpenEnd,f?o.flags|=m1.LocalMax:u2.addLocMin(o,e,t,c)):f!==u&&(u?u2.addLocMin(o,e,!1,c):o.flags|=m1.LocalMax)}}};var f3=class{constructor(e=null){T(this,"parent");T(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 c="",a=" ".repeat(t),r=this.children.length===1?"":"s";(t&1)===0?c+=`${a}+- hole (${e}) contains ${this.children.length} nested polygon${r}.
2560
+ `:c+=`${a}+- polygon (${e}) contains ${this.children.length} hole${r}.
2561
+ `;for(let s=0;s<this.count;s++)this.children[s].count>0&&(c+=this.children[s].toStringInternal(s,t+1));return c}toString(){if(this.level>0)return"";let e=this.children.length===1?"":"s",t=`Polytree with ${this.children.length} polygon${e}.
2562
+ `;for(let c=0;c<this.count;c++)this.children[c].count>0&&(t+=this.children[c].toStringInternal(c,1));return t+`
2563
+ `}},d3=class n extends f3{constructor(t=null){super(t);T(this,"polygon",null)}get poly(){return this.polygon}addChild(t){let c=new n(this);return c.polygon=t,this.children.push(c),c}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:d5.area(this.polygon);for(let c of this.children)t+=c.area();return t}};var F2=class extends d3{};var M=class M{constructor(){T(this,"cliptype",y1.NoClip);T(this,"fillrule",s1.EvenOdd);T(this,"actives",null);T(this,"sel",null);T(this,"minimaList",[]);T(this,"intersectList",[]);T(this,"vertexList",[]);T(this,"outrecList",[]);T(this,"scanlineHeap",new u5);T(this,"scanlineSet",new Set);T(this,"scanlineArr",[]);T(this,"useScanlineArray",!1);T(this,"horzSegList",[]);T(this,"horzJoinList",[]);T(this,"currentLocMin",0);T(this,"currentBotY",0);T(this,"curXValidAtTop",!1);T(this,"isSortedMinimaList",!1);T(this,"hasOpenPaths",!1);T(this,"usingPolytree",!1);T(this,"succeeded",!1);T(this,"zCallbackInternal");T(this,"preserveCollinear",!0);T(this,"reverseSolution",!1)}getZCallback(){}xyEqual(e,t){return e.x===t.x&&e.y===t.y}setZ(e,t,c){let a=this.zCallbackInternal;a&&(M.getPolyType(e)===N1.Subject?(this.xyEqual(c,e.bot)?c.z=e.bot.z??0:this.xyEqual(c,e.top)?c.z=e.top.z??0:this.xyEqual(c,t.bot)?c.z=t.bot.z??0:this.xyEqual(c,t.top)?c.z=t.top.z??0:c.z=0,a(e.bot,e.top,t.bot,t.top,c)):(this.xyEqual(c,t.bot)?c.z=t.bot.z??0:this.xyEqual(c,t.top)?c.z=t.top.z??0:this.xyEqual(c,e.bot)?c.z=e.bot.z??0:this.xyEqual(c,e.top)?c.z=e.top.z??0:c.z=0,a(t.bot,t.top,e.bot,e.top,c)))}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&(m1.OpenStart|m1.OpenEnd))!==m1.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 c=t.y-e.y;return c!==0?(t.x-e.x)/c: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:Q.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&m1.LocalMax)!==m1.None}static isMaximaEdge(e){return(e.vertexTop.flags&m1.LocalMax)!==m1.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,c,a){let r=e.x<t.x?e.x:t.x;if((c.x>a.x?c.x:a.x)<r)return!1;let i=e.x>t.x?e.x:t.x,l=c.x<a.x?c.x:a.x;if(i<l)return!1;let o=e.y<t.y?e.y:t.y;if((c.y>a.y?c.y:a.y)<o)return!1;let f=e.y>t.y?e.y:t.y,u=c.y<a.y?c.y:a.y;return f>=u}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,c=e.length;t<c;t++){let a=e[t];this.scanlineSet.add(a),this.scanlineHeap.push(a)}e.length=0,this.useScanlineArray=!1}insertScanline(e){if(this.useScanlineArray){let t=this.scanlineArr;for(let c=0,a=t.length;c<a;c++)if(t[c]===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,c=t.length;if(c===0)return null;let a=0,r=t[0];for(let s=1;s<c;s++){let i=t[s];i>r&&(r=i,a=s)}return t[a]=t[c-1],t.pop(),r}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,c=!1){let a=[e];this.addPaths(a,t,c)}addPaths(e,t,c=!1){c&&(this.hasOpenPaths=!0),this.isSortedMinimaList=!1,u2.addPathsToVertexList(e,t,c,this.minimaList,this.vertexList)}addReuseableData(e){if(e.minimaList.length!==0){this.isSortedMinimaList=!1;for(let t of e.minimaList)this.minimaList.push(new H2(t.vertex,t.polytype,t.isOpen)),t.isOpen&&(this.hasOpenPaths=!0)}}deleteFromAEL(e){let t=e.prevInAEL,c=e.nextInAEL;t===null&&c===null&&e!==this.actives||(t!==null?t.nextInAEL=c:this.actives=c,c!==null&&(c.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 c=t;do c.pt.x<e.left&&(e.left=c.pt.x),c.pt.x>e.right&&(e.right=c.pt.x),c.pt.y<e.top&&(e.top=c.pt.y),c.pt.y>e.bottom&&(e.bottom=c.pt.y),c=c.next;while(c!==t)}return J0.isEmpty(e)?{left:0,top:0,right:0,bottom:0}:e}executeInternal(e,t){if(e===y1.NoClip)return;M.openPathsEnabled=this.hasOpenPaths,this.zCallbackInternal=this.getZCallback(),this.fillrule=t,this.cliptype=e,this.reset();let c=this.popScanline();if(c!==null){for(;this.succeeded;){this.insertLocalMinimaIntoAEL(c);let a;for(;(a=this.popHorz())!==null;)this.doHorizontal(a);this.horzSegList.length>0&&(this.convertHorzSegsToJoins(),this.horzSegList.length=0),this.currentBotY=c;let r=this.popScanline();if(r===null)break;for(c=r,this.doIntersections(c),this.doTopOfScanbeam(c);(a=this.popHorz())!==null;)this.doHorizontal(a)}this.succeeded&&this.processHorzJoins()}}insertLocalMinimaIntoAEL(e){for(;this.hasLocMinAtY(e);){let t=this.popLocalMinima(),c;(t.vertex.flags&m1.OpenStart)!==m1.None?c=null:(c=new O2,c.bot=t.vertex.pt,c.curX=t.vertex.pt.x,c.windDx=-1,c.vertexTop=t.vertex.prev,c.top=t.vertex.prev.pt,c.outrec=null,c.localMin=t,M.setDx(c));let a;if((t.vertex.flags&m1.OpenEnd)!==m1.None?a=null:(a=new O2,a.bot=t.vertex.pt,a.curX=t.vertex.pt.x,a.windDx=1,a.vertexTop=t.vertex.next,a.top=t.vertex.next.pt,a.outrec=null,a.localMin=t,M.setDx(a)),c!==null&&a!==null){if(M.isHorizontal(c)){if(M.isHeadingRightHorz(c)){let s=c;c=a,a=s}}else if(M.isHorizontal(a)){if(M.isHeadingLeftHorz(a)){let s=c;c=a,a=s}}else if(c.dx<a.dx){let s=c;c=a,a=s}}else c===null&&(c=a,a=null);let r;if(c.isLeftBound=!0,this.insertLeftEdge(c),M.openPathsEnabled?M.isOpen(c)?(this.setWindCountForOpenPathEdge(c),r=this.isContributingOpen(c)):(this.setWindCountForClosedPathEdge(c),r=this.isContributingClosed(c)):(this.setWindCountForClosedPathEdge(c),r=this.isContributingClosed(c)),a!==null){for(a.windCount=c.windCount,a.windCount2=c.windCount2,this.insertRightEdge(c,a),r&&(this.addLocalMinPoly(c,a,c.bot,!0),M.isHorizontal(c)||this.checkJoinLeft(c,c.bot));a.nextInAEL!==null&&this.isValidAelOrder(a.nextInAEL,a);)this.intersectEdges(a,a.nextInAEL,a.bot),this.swapPositionsInAEL(a,a.nextInAEL);M.isHorizontal(a)?this.pushHorz(a):(this.checkJoinRight(a,a.bot),this.insertScanline(a.top.y))}else r&&M.openPathsEnabled&&this.startOpenPath(c,c.bot);M.isHorizontal(c)?this.pushHorz(c):this.insertScanline(c.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),c=e.bot.y,a=t?this.getCurrYMaximaVertexOpen(e):this.getCurrYMaximaVertex(e),{isLeftToRight:r,leftX:s,rightX:i}=this.resetHorzDirection(e,a),l=s,o=i;if(M.isHotEdge(e)){let h=this.addOutPt(e,{x:e.curX,y:c});this.addToHorzSegList(h)}for(;;){let h=r?e.nextInAEL:e.prevInAEL;for(;h!==null;){if(h.vertexTop===a){if(M.isHotEdge(e)&&this.isJoined(h)&&this.split(h,h.top),M.isHotEdge(e)){for(;e.vertexTop!==a;)this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);r?this.addLocalMaxPoly(e,h,e.top):this.addLocalMaxPoly(h,e,e.top)}this.deleteFromAEL(h),this.deleteFromAEL(e);return}if(a!==e.vertexTop||M.isOpenEnd(e)){if(r&&h.curX>o||!r&&h.curX<l)break;if(h.curX===e.top.x&&!M.isHorizontal(h)){let d=M.nextVertex(e).pt;if(M.isOpen(h)&&!M.isSamePolyType(h,e)&&!M.isHotEdge(h)){if(r&&M.topX(h,d.y)>d.x||!r&&M.topX(h,d.y)<d.x)break}else if(r&&M.topX(h,d.y)>=d.x||!r&&M.topX(h,d.y)<=d.x)break}}let u={x:h.curX,y:c};r?(this.intersectEdges(e,h,u),this.swapPositionsInAEL(e,h),this.checkJoinLeft(h,u),e.curX=h.curX,h=e.nextInAEL):(this.intersectEdges(h,e,u),this.swapPositionsInAEL(h,e),this.checkJoinRight(h,u),e.curX=h.curX,h=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 f=this.resetHorzDirection(e,a);l=f.leftX,o=f.rightX}if(M.isHotEdge(e)){let h=this.addOutPt(e,e.top);this.addToHorzSegList(h)}this.updateEdgeIntoAEL(e)}doHorizontalClosed(e){let t=e.bot.y,c=this.getCurrYMaximaVertex(e),{isLeftToRight:a,leftX:r,rightX:s}=this.resetHorzDirection(e,c),i=r,l=s;if(M.isHotEdge(e)){let o=this.addOutPt(e,{x:e.curX,y:t});this.addToHorzSegList(o)}for(;;){let o=a?e.nextInAEL:e.prevInAEL;for(;o!==null;){if(o.vertexTop===c){if(M.isHotEdge(e)&&this.isJoined(o)&&this.split(o,o.top),M.isHotEdge(e)){for(;e.vertexTop!==c;)this.addOutPt(e,e.top),this.updateEdgeIntoAEL(e);a?this.addLocalMaxPoly(e,o,e.top):this.addLocalMaxPoly(o,e,e.top)}this.deleteFromAEL(o),this.deleteFromAEL(e);return}if(c!==e.vertexTop){if(a&&o.curX>l||!a&&o.curX<i)break;if(o.curX===e.top.x&&!M.isHorizontal(o)){let u=M.nextVertex(e).pt,d=M.topX(o,u.y);if(a&&d>=u.x||!a&&d<=u.x)break}}let f={x:o.curX,y:t};a?(this.intersectEdges(e,o,f),this.swapPositionsInAEL(e,o),this.checkJoinLeft(o,f),e.curX=o.curX,o=e.nextInAEL):(this.intersectEdges(o,e,f),this.swapPositionsInAEL(o,e),this.checkJoinRight(o,f),e.curX=o.curX,o=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 h=this.resetHorzDirection(e,c);i=h.leftX,l=h.rightX}if(M.isHotEdge(e)){let o=this.addOutPt(e,e.top);this.addToHorzSegList(o)}this.updateEdgeIntoAEL(e)}convertHorzSegsToJoins(){let e=this.horzSegList,t=0;for(let c=0,a=e.length;c<a;c++){let r=e[c];this.updateHorzSegment(r)&&(e[t++]=r)}if(!(t<2)){e.length=t,this.horzSegList.sort(v9);for(let c=0;c<t-1;c++){let a=this.horzSegList[c];for(let r=c+1;r<t;r++){let s=this.horzSegList[r];if(s.leftOp.pt.x>=a.rightOp.pt.x||s.leftToRight===a.leftToRight||s.rightOp.pt.x<=a.leftOp.pt.x)continue;let i=a.leftOp.pt.y;if(a.leftToRight){for(;a.leftOp.next.pt.y===i&&a.leftOp.next.pt.x<=s.leftOp.pt.x;)a.leftOp=a.leftOp.next;for(;s.leftOp.prev.pt.y===i&&s.leftOp.prev.pt.x<=a.leftOp.pt.x;)s.leftOp=s.leftOp.prev;let l=new V2(this.duplicateOp(a.leftOp,!0),this.duplicateOp(s.leftOp,!1));this.horzJoinList.push(l)}else{for(;a.leftOp.prev.pt.y===i&&a.leftOp.prev.pt.x<=s.leftOp.pt.x;)a.leftOp=a.leftOp.prev;for(;s.leftOp.next.pt.y===i&&s.leftOp.next.pt.x<=a.leftOp.pt.x;)s.leftOp=s.leftOp.next;let l=new V2(this.duplicateOp(s.leftOp,!0),this.duplicateOp(a.leftOp,!1));this.horzJoinList.push(l)}}}}}updateHorzSegment(e){let t=e.leftOp,c=this.getRealOutRec(t.outrec),a=c.frontEdge!==null,r=t.pt.y,s=t,i=t;if(a){let o=c.pts,h=o.next;for(;s!==h&&s.prev.pt.y===r;)s=s.prev;for(;i!==o&&i.next.pt.y===r;)i=i.next}else{for(;s.prev!==i&&s.prev.pt.y===r;)s=s.prev;for(;i.next!==s&&i.next.pt.y===r;)i=i.next}let l=this.setHorzSegHeadingForward(e,s,i)&&e.leftOp.horz===null;return l?e.leftOp.horz=e:e.rightOp=null,l}setHorzSegHeadingForward(e,t,c){return t.pt.x===c.pt.x?!1:(t.pt.x<c.pt.x?(e.leftOp=t,e.rightOp=c,e.leftToRight=!0):(e.leftOp=c,e.rightOp=t,e.leftToRight=!1),!0)}duplicateOp(e,t){let c=new E0(e.pt,e.outrec);return t?(c.next=e.next,c.next.prev=c,c.prev=e,e.next=c):(c.prev=e.prev,c.prev.next=c,c.next=e,e.prev=c),c}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 c=this.actives;for(;c!==null;){if(c.top.y===e)if(c.curX=c.top.x,M.isMaximaEdge(c)){c=this.doMaxima(c);continue}else M.isHotEdge(c)&&this.addOutPt(c,c.top),this.updateEdgeIntoAEL(c),M.isHorizontal(c)&&this.pushHorz(c);else t||(c.curX=M.topX(c,e));c=c.nextInAEL}}processHorzJoins(){for(let e of this.horzJoinList){let t=this.getRealOutRec(e.op1.outrec),c=this.getRealOutRec(e.op2.outrec),a=e.op1.next,r=e.op2.prev;if(e.op1.next=e.op2,e.op2.prev=e.op1,a.prev=r,r.next=a,t===c){let s=this.newOutRec();s.pts=a,this.fixOutRecPts(s),t.pts.outrec===s&&(t.pts=e.op1,t.pts.outrec=t),this.usingPolytree?(this.path1InsidePath2(t.pts,s.pts)?([s.pts,t.pts]=[t.pts,s.pts],this.fixOutRecPts(t),this.fixOutRecPts(s),s.owner=t):this.path1InsidePath2(s.pts,t.pts)?s.owner=t:s.owner=t.owner,t.splits===null&&(t.splits=[]),t.splits.push(s.idx)):s.owner=t}else c.pts=null,this.usingPolytree?(this.setOwner(c,t),this.moveSplits(c,t)):c.owner=t}}fixOutRecPts(e){let t=e.pts;do t.outrec=e,t=t.next;while(t!==e.pts)}path1InsidePath2(e,t){let c=l1.IsOn,a=e;do{switch(this.pointInOpPolygon(a.pt,t)){case l1.IsOutside:if(c===l1.IsOutside)return!1;c=l1.IsOutside;break;case l1.IsInside:if(c===l1.IsInside)return!0;c=l1.IsInside;break;default:break}a=a.next}while(a!==e);return Q.path2ContainsPath1(this.getCleanPath(e),this.getCleanPath(t))}pointInOpPolygon(e,t){if(t===t.next||t.prev===t.next)return l1.IsOutside;let c=t;do{if(t.pt.y!==e.y)break;t=t.next}while(t!==c);if(t.pt.y===e.y)return l1.IsOutside;let a=t.pt.y<e.y,r=a,s=0;for(c=t.next;c!==t;){if(a)for(;c!==t&&c.pt.y<e.y;)c=c.next;else for(;c!==t&&c.pt.y>e.y;)c=c.next;if(c===t)break;if(c.pt.y===e.y){if(c.pt.x===e.x||c.pt.y===c.prev.pt.y&&e.x<c.prev.pt.x!=e.x<c.pt.x)return l1.IsOn;if(c=c.next,c===t)break;continue}if(c.pt.x<=e.x||c.prev.pt.x<=e.x)if(c.prev.pt.x<e.x&&c.pt.x<e.x)s=1-s;else{let i=Q.crossProductSign(c.prev.pt,c.pt,e);if(i===0)return l1.IsOn;i<0===a&&(s=1-s)}a=!a,c=c.next}if(a===r)return s===0?l1.IsOutside:l1.IsInside;{let i=Q.crossProductSign(c.prev.pt,c.pt,e);if(i===0)return l1.IsOn;i<0===a&&(s=1-s)}return s===0?l1.IsOutside:l1.IsInside}getCleanPath(e){let t=[],c=e;for(;c.next!==e&&(c.pt.x===c.next.pt.x&&c.pt.x===c.prev.pt.x||c.pt.y===c.next.pt.y&&c.pt.y===c.prev.pt.y);)c=c.next;t.push(c.pt);let a=c;for(c=c.next;c!==e;)(c.pt.x!==c.next.pt.x||c.pt.x!==a.pt.x)&&(c.pt.y!==c.next.pt.y||c.pt.y!==a.pt.y)&&(t.push(c.pt),a=c),c=c.next;return t}moveSplits(e,t){if(e.splits!==null){t.splits===null&&(t.splits=[]);for(let c of e.splits)c!==t.idx&&t.splits.push(c);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 c=null;for(;t!==null&&t.jump!==null;){let a=t,r=t.jump,s=r,i=r?.jump||null;for(t.jump=i;t!==s&&r!==i;)if(r.curX<t.curX){let l=r.prevInSEL;for(;this.addNewIntersectNode(l,r,e),l!==t;)l=l.prevInSEL;if(l=r,r=this.extractFromSEL(l),s=r,t!==null&&this.insert1Before2InSEL(l,t),t!==a)continue;a=l,a.jump=i,c===null?this.sel=a:c.jump=a}else t=t.nextInSEL;c=a,t=i}t=this.sel}return this.intersectList.length>0}processIntersectList(){this.intersectList.sort(g9);for(let e=0;e<this.intersectList.length;++e){if(!this.edgesAdjacentInAEL(this.intersectList[e])){let c=e+1;for(;!this.edgesAdjacentInAEL(this.intersectList[c]);)c++;[this.intersectList[c],this.intersectList[e]]=[this.intersectList[e],this.intersectList[c]]}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 c=Number.NEGATIVE_INFINITY,a=!1;for(;t!==null;){t.prevInSEL=t.prevInAEL,t.nextInSEL=t.nextInAEL,t.jump=t.nextInSEL;let r=M.topX(t,e);t.curX=r,r<c&&(a=!0),c=r,t=t.nextInAEL}return a}doMaxima(e){let t=e.prevInAEL,c=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)),c;let a=M.getMaximaPair(e);if(a===null)return c;for(this.isJoined(e)&&this.split(e,e.top),this.isJoined(a)&&this.split(a,a.top);c!==a;)this.intersectEdges(e,c,e.top),this.swapPositionsInAEL(e,c),c=e.nextInAEL;return M.isOpen(e)?(M.isHotEdge(e)&&this.addLocalMaxPoly(e,a,e.top),this.deleteFromAEL(a),this.deleteFromAEL(e),t!==null?t.nextInAEL:this.actives):(M.isHotEdge(e)&&this.addLocalMaxPoly(e,a,e.top),this.deleteFromAEL(e),this.deleteFromAEL(a),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 c=!1,a=M.nextVertex(e).pt;for(;a.y===e.top.y&&!(t&&a.x<e.top.x!=e.bot.x<e.top.x||(e.vertexTop=M.nextVertex(e),e.top=a,c=!0,M.isMaximaVertex(e.vertexTop)));)a=M.nextVertex(e).pt;c&&M.setDx(e)}addToHorzSegList(e){e.outrec.isOpen||this.horzSegList.push(new u3(e))}addNewIntersectNode(e,t,c){let a=Q.getLineIntersectPt(e.bot,e.top,t.bot,t.top);if(a===null&&(a={x:e.curX,y:c}),a.y>this.currentBotY||a.y<c){let s=Math.abs(e.dx),i=Math.abs(t.dx);s>100&&i>100?s>i?a=Q.getClosestPtOnSegment(a,e.bot,e.top):a=Q.getClosestPtOnSegment(a,t.bot,t.top):s>100?a=Q.getClosestPtOnSegment(a,e.bot,e.top):i>100?a=Q.getClosestPtOnSegment(a,t.bot,t.top):(a.y<c?a.y=c:a.y=this.currentBotY,s<i?a.x=M.topX(e,a.y):a.x=M.topX(t,a.y))}let r=$4(a,e,t);this.intersectList.push(r)}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&(m1.OpenEnd|m1.LocalMax))===m1.None;)t=t.next;else for(;t.prev.pt.y===t.pt.y&&(t.flags&(m1.OpenEnd|m1.LocalMax))===m1.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 c=e.curX,a=e.curX,r=e.nextInAEL;for(;r!==null&&r.vertexTop!==t;)r=r.nextInAEL;return{isLeftToRight:r!==null,leftX:c,rightX:a}}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===_1.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===s1.EvenOdd){let c=0,a=0;for(;t!==e;)M.getPolyType(t)===N1.Clip?a++:M.isOpen(t)||c++,t=t.nextInAEL;e.windCount=M.isOdd(c)?1:0,e.windCount2=M.isOdd(a)?1:0}else for(;t!==e;)M.getPolyType(t)===N1.Clip?e.windCount2+=t.windDx:M.isOpen(t)||(e.windCount+=t.windDx),t=t.nextInAEL}setWindCountForClosedPathEdge(e){let t=e.prevInAEL,c=M.getPolyType(e);if(!M.openPathsEnabled){for(;t!==null&&M.getPolyType(t)!==c;)t=t.prevInAEL;if(t===null?(e.windCount=e.windDx,t=this.actives):this.fillrule===s1.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===s1.EvenOdd)for(;t!==e;)M.getPolyType(t)!==c&&(e.windCount2=e.windCount2===0?1:0),t=t.nextInAEL;else for(;t!==e;)M.getPolyType(t)!==c&&(e.windCount2+=t.windDx),t=t.nextInAEL;return}for(;t!==null&&(M.getPolyType(t)!==c||M.isOpen(t));)t=t.prevInAEL;if(t===null?(e.windCount=e.windDx,t=this.actives):this.fillrule===s1.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===s1.EvenOdd)for(;t!==e;)M.getPolyType(t)!==c&&!M.isOpen(t)&&(e.windCount2=e.windCount2===0?1:0),t=t.nextInAEL;else for(;t!==e;)M.getPolyType(t)!==c&&!M.isOpen(t)&&(e.windCount2+=t.windDx),t=t.nextInAEL}isContributingOpen(e){let t,c;switch(this.fillrule){case s1.Positive:c=e.windCount>0,t=e.windCount2>0;break;case s1.Negative:c=e.windCount<0,t=e.windCount2<0;break;default:c=e.windCount!==0,t=e.windCount2!==0;break}switch(this.cliptype){case y1.Intersection:return t;case y1.Union:return!c&&!t;default:return!t}}isContributingClosed(e){switch(this.fillrule){case s1.Positive:if(e.windCount!==1)return!1;break;case s1.Negative:if(e.windCount!==-1)return!1;break;case s1.NonZero:if(Math.abs(e.windCount)!==1)return!1;break}switch(this.cliptype){case y1.Intersection:return this.fillrule===s1.Positive?e.windCount2>0:this.fillrule===s1.Negative?e.windCount2<0:e.windCount2!==0;case y1.Union:return this.fillrule===s1.Positive?e.windCount2<=0:this.fillrule===s1.Negative?e.windCount2>=0:e.windCount2===0;case y1.Difference:{let t=this.fillrule===s1.Positive?e.windCount2<=0:this.fillrule===s1.Negative?e.windCount2>=0:e.windCount2===0;return M.getPolyType(e)===N1.Subject?t:!t}case y1.Xor:return!0;default:return!1}}addLocalMinPoly(e,t,c,a=!1){let r=this.newOutRec();if(e.outrec=r,t.outrec=r,M.isOpen(e))r.owner=null,r.isOpen=!0,e.windDx>0?this.setSides(r,e,t):this.setSides(r,t,e);else{r.isOpen=!1;let i=M.getPrevHotEdge(e);i!==null?(this.usingPolytree&&this.setOwner(r,i.outrec),r.owner=i.outrec,this.outrecIsAscending(i)===a?this.setSides(r,t,e):this.setSides(r,e,t)):(r.owner=null,a?this.setSides(r,e,t):this.setSides(r,t,e))}let s=new E0(c,r);return r.pts=s,s}outrecIsAscending(e){return e===e.outrec.frontEdge}newOutRec(){let e=new h3;return e.idx=this.outrecList.length,this.outrecList.push(e),e}startOpenPath(e,t){let c=this.newOutRec();c.isOpen=!0,e.windDx>0?(c.frontEdge=e,c.backEdge=null):(c.frontEdge=null,c.backEdge=e),e.outrec=c;let a=new E0(t,c);return c.pts=a,a}checkJoinLeft(e,t,c=!1){let a=e.prevInAEL;a!==null&&(!c&&e.curX!==a.curX||!M.isHotEdge(e)||!M.isHotEdge(a)||M.isHorizontal(e)||M.isHorizontal(a)||M.isOpen(e)||M.isOpen(a)||(t.y<e.top.y+2||t.y<a.top.y+2)&&(e.bot.y>t.y||a.bot.y>t.y)||c&&this.perpendicDistFromLineSqrdGreaterThanQuarter(t,a.bot,a.top)||Q.isCollinear(e.top,t,a.top)&&(e.outrec.idx===a.outrec.idx?this.addLocalMaxPoly(a,e,t):e.outrec.idx<a.outrec.idx?this.joinOutrecPaths(e,a):this.joinOutrecPaths(a,e),a.joinWith=_1.Right,e.joinWith=_1.Left))}checkJoinRight(e,t,c=!1){let a=e.nextInAEL;a!==null&&(!c&&e.curX!==a.curX||!M.isHotEdge(e)||!M.isHotEdge(a)||M.isHorizontal(e)||M.isHorizontal(a)||M.isOpen(e)||M.isOpen(a)||(t.y<e.top.y+2||t.y<a.top.y+2)&&(e.bot.y>t.y||a.bot.y>t.y)||c&&this.perpendicDistFromLineSqrdGreaterThanQuarter(t,a.bot,a.top)||Q.isCollinear(e.top,t,a.top)&&(e.outrec.idx===a.outrec.idx?this.addLocalMaxPoly(e,a,t):e.outrec.idx<a.outrec.idx?this.joinOutrecPaths(e,a):this.joinOutrecPaths(a,e),e.joinWith=_1.Right,a.joinWith=_1.Left))}perpendicDistFromLineSqrdGreaterThanQuarter(e,t,c){let a=e.x-t.x,r=e.y-t.y,s=c.x-t.x,i=c.y-t.y;if(s===0&&i===0)return!1;let l=Q.maxCoordForSafeCrossSq;if(Math.abs(a)<l&&Math.abs(r)<l&&Math.abs(s)<l&&Math.abs(i)<l){let h=a*i-s*r;return h*h/(s*s+i*i)>.25}if(Number.isSafeInteger(a)&&Number.isSafeInteger(r)&&Number.isSafeInteger(s)&&Number.isSafeInteger(i)){let h=BigInt(a)*BigInt(i)-BigInt(s)*BigInt(r),f=h*h,u=BigInt(s)*BigInt(s)+BigInt(i)*BigInt(i);return B4*f>u}let o=a*i-s*r;return o*o/(s*s+i*i)>.25}intersectEdges(e,t,c){let a;if(this.hasOpenPaths&&(M.isOpen(e)||M.isOpen(t))){if(M.isOpen(e)&&M.isOpen(t))return;if(M.isOpen(t)){let o=e;e=t,t=o}if(this.isJoined(t)&&this.split(t,c),this.cliptype===y1.Union){if(!M.isHotEdge(t))return}else if(t.localMin.polytype===N1.Subject)return;switch(this.fillrule){case s1.Positive:if(t.windCount!==1)return;break;case s1.Negative:if(t.windCount!==-1)return;break;default:if(Math.abs(t.windCount)!==1)return;break}if(M.isHotEdge(e))a=this.addOutPt(e,c),this.setZ(e,t,a.pt),M.isFront(e)?e.outrec.frontEdge=null:e.outrec.backEdge=null,e.outrec=null;else if(c.x===e.localMin.vertex.pt.x&&c.y===e.localMin.vertex.pt.y&&!M.isOpenEndVertex(e.localMin.vertex)){let o=this.findEdgeWithMatchingLocMin(e);if(o!==null&&M.isHotEdge(o)){e.outrec=o.outrec,e.windDx>0?this.setSides(o.outrec,e,o):this.setSides(o.outrec,o,e);return}a=this.startOpenPath(e,c)}else a=this.startOpenPath(e,c);this.setZ(e,t,a.pt);return}this.isJoined(e)&&this.split(e,c),this.isJoined(t)&&this.split(t,c);let r,s;switch(e.localMin.polytype===t.localMin.polytype?this.fillrule===s1.EvenOdd?(r=e.windCount,e.windCount=t.windCount,t.windCount=r):(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!==s1.EvenOdd?e.windCount2+=t.windDx:e.windCount2=e.windCount2===0?1:0,this.fillrule!==s1.EvenOdd?t.windCount2-=e.windDx:t.windCount2=t.windCount2===0?1:0),this.fillrule){case s1.Positive:r=e.windCount,s=t.windCount;break;case s1.Negative:r=-e.windCount,s=-t.windCount;break;default:r=Math.abs(e.windCount),s=Math.abs(t.windCount);break}let i=r===0||r===1,l=s===0||s===1;if(!(!M.isHotEdge(e)&&!i||!M.isHotEdge(t)&&!l))if(M.isHotEdge(e)&&M.isHotEdge(t))if(r!==0&&r!==1||s!==0&&s!==1||e.localMin.polytype!==t.localMin.polytype&&this.cliptype!==y1.Xor)a=this.addLocalMaxPoly(e,t,c),a&&this.setZ(e,t,a.pt);else if(M.isFront(e)||e.outrec===t.outrec){a=this.addLocalMaxPoly(e,t,c),a&&this.setZ(e,t,a.pt);let o=this.addLocalMinPoly(e,t,c);this.setZ(e,t,o.pt)}else{a=this.addOutPt(e,c),this.setZ(e,t,a.pt);let o=this.addOutPt(t,c);this.setZ(e,t,o.pt),this.swapOutrecs(e,t)}else if(M.isHotEdge(e))a=this.addOutPt(e,c),this.setZ(e,t,a.pt),this.swapOutrecs(e,t);else if(M.isHotEdge(t))a=this.addOutPt(t,c),this.setZ(e,t,a.pt),this.swapOutrecs(e,t);else{let o,h;switch(this.fillrule){case s1.Positive:o=e.windCount2,h=t.windCount2;break;case s1.Negative:o=-e.windCount2,h=-t.windCount2;break;default:o=Math.abs(e.windCount2),h=Math.abs(t.windCount2);break}if(!M.isSamePolyType(e,t))a=this.addLocalMinPoly(e,t,c),this.setZ(e,t,a.pt);else if(r===1&&s===1){switch(a=null,this.cliptype){case y1.Union:if(o>0&&h>0)return;a=this.addLocalMinPoly(e,t,c);break;case y1.Difference:(M.getPolyType(e)===N1.Clip&&o>0&&h>0||M.getPolyType(e)===N1.Subject&&o<=0&&h<=0)&&(a=this.addLocalMinPoly(e,t,c));break;case y1.Xor:a=this.addLocalMinPoly(e,t,c);break;default:if(o<=0||h<=0)return;a=this.addLocalMinPoly(e,t,c);break}a&&this.setZ(e,t,a.pt)}}}swapPositionsInAEL(e,t){let c=t.nextInAEL;c!==null&&(c.prevInAEL=e);let a=e.prevInAEL;a!==null&&(a.nextInAEL=t),t.prevInAEL=a,t.nextInAEL=e,e.prevInAEL=t,e.nextInAEL=c,t.prevInAEL===null&&(this.actives=t)}isValidAelOrder(e,t){if(t.curX!==e.curX)return t.curX>e.curX;let c=Q.crossProductSign(e.top,t.bot,t.top);if(c!==0)return c<0;if(!M.isMaximaEdge(e)&&e.top.y>t.top.y)return Q.crossProductSign(t.bot,e.top,M.nextVertex(e).pt)<=0;if(!M.isMaximaEdge(t)&&t.top.y>e.top.y)return Q.crossProductSign(t.bot,t.top,M.nextVertex(t).pt)>=0;let a=t.bot.y,r=t.isLeftBound;return e.bot.y!==a||e.localMin.vertex.pt.y!==a?t.isLeftBound:e.isLeftBound!==r?r:Q.isCollinear(M.prevPrevVertex(e).pt,e.bot,e.top)?!0:Q.crossProductSign(M.prevPrevVertex(e).pt,t.bot,M.prevPrevVertex(t).pt)>0===r}isJoined(e){return e.joinWith!==_1.None}split(e,t){e.joinWith===_1.Right?(e.joinWith=_1.None,e.nextInAEL.joinWith=_1.None,this.addLocalMinPoly(e,e.nextInAEL,t,!0)):(e.joinWith=_1.None,e.prevInAEL.joinWith=_1.None,this.addLocalMinPoly(e.prevInAEL,e,t,!0))}setSides(e,t,c){e.frontEdge=t,e.backEdge=c}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 c=e.outrec,a=M.isFront(e),r=c.pts,s=r.next;if(a&&t.x===r.pt.x&&t.y===r.pt.y)return r;if(!a&&t.x===s.pt.x&&t.y===s.pt.y)return s;let i=new E0(t,c);return s.prev=i,i.prev=r,i.next=s,r.next=i,a&&(c.pts=i),i}addLocalMaxPoly(e,t,c){if(this.isJoined(e)&&this.split(e,c),this.isJoined(t)&&this.split(t,c),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 a=this.addOutPt(e,c);if(e.outrec===t.outrec){let r=e.outrec;if(r.pts=a,this.usingPolytree){let s=M.getPrevHotEdge(e);s===null?r.owner=null:this.setOwner(r,s.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 a}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 c=t;for(;c!==null&&c!==e;)c=c.owner;c!==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 c=e.outrec.pts,a=t.outrec.pts,r=c.next,s=a.next;M.isFront(e)?(s.prev=c,c.next=s,a.next=r,r.prev=a,e.outrec.pts=a,e.outrec.frontEdge=t.outrec.frontEdge,e.outrec.frontEdge!==null&&(e.outrec.frontEdge.outrec=e.outrec)):(r.prev=a,a.next=r,c.next=s,s.prev=c,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 c=e.outrec,a=t.outrec;if(c===a){let r=c.frontEdge;c.frontEdge=c.backEdge,c.backEdge=r;return}c!==null&&(e===c.frontEdge?c.frontEdge=t:c.backEdge=t),a!==null&&(t===a.frontEdge?a.frontEdge=e:a.backEdge=e),e.outrec=a,t.outrec=c}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,c,a){if(e===null||e.next===e||!c&&e.next===e.prev)return!1;a.length=0;let r,s;for(t?(r=e.pt,s=e.prev):(e=e.next,r=e.pt,s=e.next),a.push(r);s!==e;)s.pt.x===r.x&&s.pt.y===r.y||(r=s.pt,a.push(r)),t?s=s.prev:s=s.next;return a.length!==3||c||!M.isVerySmallTriangle(s)}buildPaths(e,t){e.length=0,t.length=0;let c=0;for(;c<this.outrecList.length;){let a=this.outrecList[c++];if(a.pts===null)continue;let r=[];a.isOpen?M.buildPath(a.pts,this.reverseSolution,!0,r)&&t.push(r):(this.cleanCollinear(a),M.buildPath(a.pts,this.reverseSolution,!1,r)&&e.push(r))}return!0}buildTree(e,t){e.clear(),t.length=0;let c=0;for(;c<this.outrecList.length;){let a=this.outrecList[c++];if(a.pts!==null){if(a.isOpen){let r=[];M.buildPath(a.pts,this.reverseSolution,!0,r)&&t.push(r);continue}this.checkBounds(a)&&this.recursiveCheckOwners(a,e)}}}checkBounds(e){return e.pts===null?!1:J0.isEmpty(e.bounds)?(this.cleanCollinear(e),e.pts===null||!M.buildPath(e.pts,this.reverseSolution,!1,e.path)?!1:(e.bounds=Q.getBounds(e.path),!0)):!0}recursiveCheckOwners(e,t){if(!(e.polypath!==null||J0.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,c=t;for(;;){if(c!==null&&Q.isCollinear(c.prev.pt,c.pt,c.next.pt)&&(c.pt.x===c.prev.pt.x&&c.pt.y===c.prev.pt.y||c.pt.x===c.next.pt.x&&c.pt.y===c.next.pt.y||!this.preserveCollinear||Q.dotProductSign(c.prev.pt,c.pt,c.next.pt)<0)){if(c===e.pts&&(e.pts=c.prev),c=this.disposeOutPt(c),!this.isValidClosedPath(c)){e.pts=null;return}t=c;continue}if(c===null||(c=c.next,c===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)&&Q.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 c=t.prev,a=t.next.next;e.pts=c;let r=Q.getLineIntersectPt(c.pt,t.pt,t.next.pt,a.pt);this.zCallbackInternal&&this.zCallbackInternal(c.pt,t.pt,t.next.pt,a.pt,r);let s=M.areaOutPt(c),i=s<T2?-s:s;if(i<B4){e.pts=null;return}let l=this.areaTriangle(r,t.pt,t.next.pt),o=l<T2?-l:l;if(r.x===c.pt.x&&r.y===c.pt.y||r.x===a.pt.x&&r.y===a.pt.y)a.prev=c,c.next=a;else{let u=new E0(r,e);u.prev=c,u.next=a,a.prev=u,c.next=u}if(!(o>m9)||!(o>i)&&l>T2!=s>T2)return;let h=this.newOutRec();h.owner=e.owner,t.outrec=h,t.next.outrec=h;let f=new E0(r,h);f.prev=t.next,f.next=t,h.pts=f,t.prev=f,t.next.next=f,this.usingPolytree&&(this.path1InsidePath2(c,f)?(h.splits===null&&(h.splits=[]),h.splits.push(e.idx)):(e.splits===null&&(e.splits=[]),e.splits.push(h.idx)))}static areaOutPt(e){let t=Q.maxCoordForSafeAreaProduct,c=0,a=!0,r=e;do{let i=r.prev,l=r.pt;if(Math.abs(i.pt.x)>=t||Math.abs(i.pt.y)>=t||Math.abs(l.x)>=t||Math.abs(l.y)>=t){a=!1;break}c+=(i.pt.y+l.y)*(i.pt.x-l.x),r=r.next}while(r!==e);if(a)return BigInt(Math.round(c));let s=T2;r=e;do{let i=r.prev;if(Number.isSafeInteger(i.pt.y)&&Number.isSafeInteger(r.pt.y)&&Number.isSafeInteger(i.pt.x)&&Number.isSafeInteger(r.pt.x)){let l=BigInt(i.pt.y)+BigInt(r.pt.y),o=BigInt(i.pt.x)-BigInt(r.pt.x);s+=l*o}else{let l=i.pt.y+r.pt.y,o=i.pt.x-r.pt.x;s+=BigInt(Math.round(l*o))}r=r.next}while(r!==e);return s}areaTriangle(e,t,c){let a=Q.maxCoordForSafeAreaProduct;if(Math.abs(e.x)<a&&Math.abs(e.y)<a&&Math.abs(t.x)<a&&Math.abs(t.y)<a&&Math.abs(c.x)<a&&Math.abs(c.y)<a){let s=(c.y+e.y)*(c.x-e.x)+(e.y+t.y)*(e.x-t.x)+(t.y+c.y)*(t.x-c.x);return BigInt(Math.round(s))}if(Number.isSafeInteger(e.x)&&Number.isSafeInteger(e.y)&&Number.isSafeInteger(t.x)&&Number.isSafeInteger(t.y)&&Number.isSafeInteger(c.x)&&Number.isSafeInteger(c.y)){let s=(BigInt(c.y)+BigInt(e.y))*(BigInt(c.x)-BigInt(e.x)),i=(BigInt(e.y)+BigInt(t.y))*(BigInt(e.x)-BigInt(t.x)),l=(BigInt(t.y)+BigInt(c.y))*(BigInt(t.x)-BigInt(c.x));return s+i+l}let r=(c.y+e.y)*(c.x-e.x)+(e.y+t.y)*(e.x-t.x)+(t.y+c.y)*(t.x-c.x);return BigInt(Math.round(r))}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 c=0;c<t.length;c++){let a=this.outrecList[t[c]];if(a.pts===null&&a.splits!==null&&this.checkSplitOwner(e,a.splits))return!0;if(a=this.getRealOutRec(a),!(a===null||a===e||a.recursiveSplit===e)){if(a.recursiveSplit=e,a.splits!==null&&this.checkSplitOwner(e,a.splits))return!0;if(!(!this.checkBounds(a)||!this.containsRect(a.bounds,e.bounds)||!this.path1InsidePath2(e.pts,a.pts)))return this.isValidOwner(e,a)||(a.owner=e.owner),e.owner=a,!0}}return!1}};T(M,"openPathsEnabled",!0);var p3=M,b0=class extends p3{constructor(){super(...arguments);T(this,"zCallback")}getZCallback(){return this.zCallback}addPath(t,c,a=!1){super.addPath(t,c,a)}addReuseableData(t){super.addReuseableData(t)}addPaths(t,c,a=!1){super.addPaths(t,c,a)}addSubject(t){this.addPaths(t,N1.Subject)}addOpenSubject(t){this.addPaths(t,N1.Subject,!0)}addClip(t){this.addPaths(t,N1.Clip)}execute(t,c,a,r){if(Array.isArray(a)){let s=a,i=r;s.length=0,i&&(i.length=0);try{this.executeInternal(t,c),this.buildPaths(s,i||[])}catch{this.succeeded=!1}return this.clearSolutionOnly(),this.succeeded}else{let s=a,i=r;s.clear(),i&&(i.length=0),this.usingPolytree=!0;try{this.executeInternal(t,c),this.buildTree(s,i||[])}catch{this.succeeded=!1}return this.clearSolutionOnly(),this.succeeded}}};var d5={area(n){return Q.area(n)},areaD(n){let e=0,t=n.length;if(t<3)return 0;let c=n[t-1];for(let a of n)e+=(c.y+a.y)*(c.x-a.x),c=a;return e*.5},scalePath64(n,e){let t=Q.maxSafeCoordinateForScale(e),c=[];for(let a of n)Q.checkSafeScaleValue(a.x,t,"scalePath64"),Q.checkSafeScaleValue(a.y,t,"scalePath64"),c.push({x:Math.round(a.x*e),y:Math.round(a.y*e)});return c},scalePaths64(n,e){let t=[];for(let c of n)t.push(d5.scalePath64(c,e));return t},scalePathD(n,e){let t=[];for(let c of n)t.push({x:c.x*e,y:c.y*e});return t},scalePathsD(n,e){let t=[];for(let c of n)t.push(d5.scalePathD(c,e));return t}};var G1;(function(n){n[n.Miter=0]="Miter",n[n.Square=1]="Square",n[n.Bevel=2]="Bevel",n[n.Round=3]="Round"})(G1||(G1={}));var w1;(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"})(w1||(w1={}));var p5=class{constructor(e,t,c=w1.Polygon){T(this,"inPaths");T(this,"joinType");T(this,"endType");T(this,"pathsReversed");T(this,"lowestPathIdx");this.joinType=t,this.endType=c;let a=c===w1.Polygon||c===w1.Joined;this.inPaths=[];for(let r of e)this.inPaths.push(Q0.stripDuplicates(r,a));if(c===w1.Polygon){let r=Q0.getLowestPathInfo(this.inPaths);this.lowestPathIdx=r.idx,this.pathsReversed=this.lowestPathIdx>=0&&r.isNegArea}else this.lowestPathIdx=-1,this.pathsReversed=!1}},z1=class z1{constructor(e=2,t=0,c=!1,a=!1){T(this,"groupList",[]);T(this,"pathOut",[]);T(this,"normals",[]);T(this,"solution",[]);T(this,"solutionTree",null);T(this,"groupDelta",0);T(this,"delta",0);T(this,"mitLimSqr",0);T(this,"stepsPerRad",0);T(this,"stepSin",0);T(this,"stepCos",0);T(this,"joinType",G1.Bevel);T(this,"endType",w1.Polygon);T(this,"arcTolerance",0);T(this,"mergeGroups",!0);T(this,"miterLimit",2);T(this,"preserveCollinear",!1);T(this,"reverseSolution",!1);T(this,"zCallback");T(this,"deltaCallback",null);T(this,"ZCB",(e,t,c,a,r)=>{(e.z||0)!==0&&(e.z===c.z||e.z===a.z)?r.z=e.z:(c.z||0)!==0&&c.z===t.z?r.z=c.z:(t.z||0)!==0&&t.z===a.z?r.z=t.z:this.zCallback&&this.zCallback(e,t,c,a,r)});this.miterLimit=e,this.arcTolerance=t,this.mergeGroups=!0,this.preserveCollinear=c,this.reverseSolution=a}clear(){this.groupList.length=0}addPath(e,t,c){if(e.length===0)return;let a=[e];this.addPaths(a,t,c)}addPaths(e,t,c){e.length!==0&&this.groupList.push(new p5(e,t,c))}calcSolutionCapacity(){let e=0;for(let t of this.groupList)e+=t.endType===w1.Joined?t.inPaths.length*2:t.inPaths.length;return e}checkPathsReversed(){let e=!1;for(let t of this.groupList)if(t.endType===w1.Polygon){e=t.pathsReversed;break}return e}executeInternal(e){if(this.groupList.length===0)return;if(Math.abs(e)<.5){for(let r of this.groupList)for(let s of r.inPaths)this.solution.push(s);return}this.delta=e,this.mitLimSqr=this.miterLimit<=1?2:2/z1.sqr(this.miterLimit);for(let r of this.groupList)this.doGroupOffset(r);if(this.groupList.length===0)return;let t=this.checkPathsReversed(),c=t?s1.Negative:s1.Positive,a=new b0;a.preserveCollinear=this.preserveCollinear,a.reverseSolution=this.reverseSolution!==t,a.zCallback=this.ZCB,a.addSubject(this.solution),this.solutionTree!==null?a.execute(y1.Union,c,this.solutionTree):a.execute(y1.Union,c,this.solution)}execute(e,t){if(Array.isArray(t)){let c=t;c.length=0,this.solution=c,this.executeInternal(e)}else{let c=t;c.clear(),this.solutionTree=c,this.solution=[],this.executeInternal(e)}}executeWithCallback(e,t){this.deltaCallback=e,this.execute(1,t)}static getUnitNormal(e,t){let c=t.x-e.x,a=t.y-e.y;if(c===0&&a===0)return{x:0,y:0};let r=1/Math.sqrt(c*c+a*a);return{x:a*r,y:-c*r}}static getLowestPathInfo(e){let t=-1,c=!1,a={x:Number.MAX_SAFE_INTEGER,y:Number.MIN_SAFE_INTEGER};for(let r=0;r<e.length;++r){let s=Number.MAX_VALUE;for(let i of e[r])if(!(i.y<a.y||i.y===a.y&&i.x>=a.x)){if(s===Number.MAX_VALUE){if(s=z1.area(e[r]),s===0)break;c=s<0}t=r,a.x=i.x,a.y=i.y}}return{idx:t,isNegArea:c}}static translatePoint(e,t,c){return{x:e.x+t,y:e.y+c,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=z1.hypotenuse(e.x,e.y);if(z1.almostZero(t))return{x:0,y:0};let c=1/t;return{x:e.x*c,y:e.y*c}}static getAvgUnitVector(e,t){return z1.normalizeVector({x:e.x+t.x,y:e.y+t.y})}static intersectPoint(e,t,c,a){if(Q.isAlmostZero(e.x-t.x)){if(Q.isAlmostZero(c.x-a.x))return{x:0,y:0};let r=(a.y-c.y)/(a.x-c.x),s=c.y-r*c.x;return{x:e.x,y:r*e.x+s}}if(Q.isAlmostZero(c.x-a.x)){let r=(t.y-e.y)/(t.x-e.x),s=e.y-r*e.x;return{x:c.x,y:r*c.x+s}}else{let r=(t.y-e.y)/(t.x-e.x),s=e.y-r*e.x,i=(a.y-c.y)/(a.x-c.x),l=c.y-i*c.x;if(Q.isAlmostZero(r-i))return{x:0,y:0};let o=(l-s)/(r-i);return{x:o,y:r*o+s}}}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,c){let a,r,s=e[t].z||0;if(t===c){let i=Math.abs(this.groupDelta);a={x:Math.round(e[t].x-i*this.normals[t].x),y:Math.round(e[t].y-i*this.normals[t].y),z:s},r={x:Math.round(e[t].x+i*this.normals[t].x),y:Math.round(e[t].y+i*this.normals[t].y),z:s}}else a={x:Math.round(e[t].x+this.groupDelta*this.normals[c].x),y:Math.round(e[t].y+this.groupDelta*this.normals[c].y),z:s},r={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:s};this.pathOut.push(a),this.pathOut.push(r)}doSquare(e,t,c){let a;t===c?a={x:this.normals[t].y,y:-this.normals[t].x}:a=z1.getAvgUnitVector({x:-this.normals[c].y,y:this.normals[c].x},{x:this.normals[t].y,y:-this.normals[t].x});let r=Math.abs(this.groupDelta),s={x:e[t].x,y:e[t].y,z:e[t].z||0};s=z1.translatePoint(s,r*a.x,r*a.y);let i=z1.translatePoint(s,this.groupDelta*a.y,this.groupDelta*-a.x),l=z1.translatePoint(s,this.groupDelta*-a.y,this.groupDelta*a.x),o=this.getPerpendicD(e[c],this.normals[c]);if(t===c){let h={x:o.x+a.x*this.groupDelta,y:o.y+a.y*this.groupDelta},f=z1.intersectPoint(i,l,o,h);f.z=s.z,this.pathOut.push(y0.fromPointD(z1.reflectPoint(f,s))),this.pathOut.push(y0.fromPointD(f))}else{let h=this.getPerpendicD(e[t],this.normals[c]),f=z1.intersectPoint(i,l,o,h);f.z=s.z,this.pathOut.push(y0.fromPointD(f)),this.pathOut.push(y0.fromPointD(z1.reflectPoint(f,s)))}}doMiter(e,t,c,a){let r=this.groupDelta/(a+1);this.pathOut.push({x:Math.round(e[t].x+(this.normals[c].x+this.normals[t].x)*r),y:Math.round(e[t].y+(this.normals[c].y+this.normals[t].y)*r),z:e[t].z||0})}doRound(e,t,c,a){if(this.deltaCallback!==null){let o=Math.abs(this.groupDelta),h=this.arcTolerance>.01?this.arcTolerance:o*z1.arc_const,f=Math.PI/Math.acos(1-h/o);this.stepSin=Math.sin(2*Math.PI/f),this.stepCos=Math.cos(2*Math.PI/f),this.groupDelta<0&&(this.stepSin=-this.stepSin),this.stepsPerRad=f/(2*Math.PI)}let r=e[t],s=r.z||0,i={x:this.normals[c].x*this.groupDelta,y:this.normals[c].y*this.groupDelta};t===c&&o3.negate(i),this.pathOut.push({x:Math.round(r.x+i.x),y:Math.round(r.y+i.y),z:s});let l=Math.ceil(this.stepsPerRad*Math.abs(a));for(let o=1;o<l;o++)i={x:i.x*this.stepCos-this.stepSin*i.y,y:i.x*this.stepSin+i.y*this.stepCos},this.pathOut.push({x:Math.round(r.x+i.x),y:Math.round(r.y+i.y),z:s});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 c=0;c<t-1;c++)this.normals.push(z1.getUnitNormal(e[c],e[c+1]));this.normals.push(z1.getUnitNormal(e[t-1],e[0]))}}offsetPoint(e,t,c,a){if(y0.equals(t[c],t[a]))return;let r=Q.crossProductD(this.normals[c],this.normals[a]),s=Q.dotProductD(this.normals[c],this.normals[a]);if(r>1?r=1:r<-1&&(r=-1),this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(t,this.normals,c,a),e.pathsReversed&&(this.groupDelta=-this.groupDelta)),Math.abs(this.groupDelta)<z1.Tolerance){this.pathOut.push(t[c]);return}if(s>-.999&&r*this.groupDelta<0)this.pathOut.push(this.getPerpendic(t[c],this.normals[a])),this.pathOut.push(t[c]),this.pathOut.push(this.getPerpendic(t[c],this.normals[c]));else if(s>.999&&this.joinType!==G1.Round)this.doMiter(t,c,a,s);else switch(this.joinType){case G1.Miter:s>this.mitLimSqr-1?this.doMiter(t,c,a,s):this.doSquare(t,c,a);break;case G1.Round:this.doRound(t,c,a,Math.atan2(r,s));break;case G1.Bevel:this.doBevel(t,c,a);break;default:this.doSquare(t,c,a);break}}offsetPolygon(e,t){this.pathOut=[];let c=t.length,a=c-1;for(let r=0;r<c;r++)this.offsetPoint(e,t,r,a),a=r;this.solution.push(this.pathOut)}offsetOpenJoined(e,t){this.offsetPolygon(e,t);let c=[...t].reverse();this.buildNormals(c),this.offsetPolygon(e,c)}offsetOpenPath(e,t){this.pathOut=[];let c=t.length-1;if(this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(t,this.normals,0,0)),Math.abs(this.groupDelta)<z1.Tolerance)this.pathOut.push(t[0]);else switch(this.endType){case w1.Butt:this.doBevel(t,0,0);break;case w1.Round:this.doRound(t,0,0,Math.PI);break;default:this.doSquare(t,0,0);break}for(let a=1,r=0;a<c;a++)this.offsetPoint(e,t,a,r),r=a;for(let a=c;a>0;a--)this.normals[a]={x:-this.normals[a-1].x,y:-this.normals[a-1].y};if(this.normals[0]=this.normals[c],this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(t,this.normals,c,c)),Math.abs(this.groupDelta)<z1.Tolerance)this.pathOut.push(t[c]);else switch(this.endType){case w1.Butt:this.doBevel(t,c,c);break;case w1.Round:this.doRound(t,c,c,Math.PI);break;default:this.doSquare(t,c,c);break}for(let a=c-1,r=c;a>0;a--)this.offsetPoint(e,t,a,r),r=a;this.solution.push(this.pathOut)}doGroupOffset(e){e.endType===w1.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===G1.Round||e.endType===w1.Round){let c=this.arcTolerance>.01?this.arcTolerance:t*z1.arc_const,a=Math.PI/Math.acos(1-c/t);this.stepSin=Math.sin(2*Math.PI/a),this.stepCos=Math.cos(2*Math.PI/a),this.groupDelta<0&&(this.stepSin=-this.stepSin),this.stepsPerRad=a/(2*Math.PI)}for(let c of e.inPaths){this.pathOut=[];let a=c.length;if(a===1){let r=c[0];this.deltaCallback!==null&&(this.groupDelta=this.deltaCallback(c,this.normals,0,0),e.pathsReversed&&(this.groupDelta=-this.groupDelta));let s=r.z||0;if(e.endType===w1.Round){let i=Math.ceil(this.stepsPerRad*2*Math.PI);if(this.pathOut=z1.ellipse(r,Math.abs(this.groupDelta),Math.abs(this.groupDelta),i),s!==0)for(let l=0;l<this.pathOut.length;l++)this.pathOut[l].z=s}else{let i=Math.ceil(Math.abs(this.groupDelta)),l={left:r.x-i,top:r.y-i,right:r.x+i,bottom:r.y+i};this.pathOut=[{x:l.left,y:l.top,z:s},{x:l.right,y:l.top,z:s},{x:l.right,y:l.bottom,z:s},{x:l.left,y:l.bottom,z:s}]}this.solution.push(this.pathOut);continue}switch(a===2&&e.endType===w1.Joined&&(this.endType=e.joinType===G1.Round?w1.Round:w1.Square),this.buildNormals(c),this.endType){case w1.Polygon:this.offsetPolygon(e,c);break;case w1.Joined:this.offsetOpenJoined(e,c);break;default:this.offsetOpenPath(e,c);break}}}static stripDuplicates(e,t){let c=e.length,a=[];if(c===0)return a;let r=e[0];a.push(r);for(let s=1;s<c;s++)y0.equals(r,e[s])||(r=e[s],a.push(r));return t&&y0.equals(r,a[0])&&a.pop(),a}static area(e){return Q.area(e)}static sqr(e){return e*e}static ellipse(e,t,c=0,a=0){if(t<=0)return[];c<=0&&(c=t),a<=2&&(a=Math.ceil(Math.PI*Math.sqrt((t+c)/2)));let r=Math.sin(2*Math.PI/a),s=Math.cos(2*Math.PI/a),i=s,l=r,o=[{x:Math.round(e.x+t),y:e.y}];for(let h=1;h<a;++h){o.push({x:Math.round(e.x+t*i),y:Math.round(e.y+c*l)});let f=i*s-l*r;l=l*s+i*r,i=f}return o}};T(z1,"Tolerance",1e-12),T(z1,"arc_const",.002);var Q0=z1;var Xa=BigInt(2);function v5(n,e,t){return typeof e=="number"?m5(y1.Union,n,null,e):m5(y1.Union,n,e,t)}function m5(n,e,t,c){let a=[];if(e===null)return a;let r=new b0;return r.addPaths(e,N1.Subject),t!==null&&r.addPaths(t,N1.Clip),r.execute(n,c,a),a}function m3(n,e,t,c,a=2,r=0){let s=new Q0(a,r);s.addPaths(n,t,c);let i=[];return s.execute(e,i),i}var h0=1e4;function a0(){return{layers:new Map,parts:[]}}function F1(n,e="cut"){return{layers:new Map([[e,{regions:n,lines:[]}]]),parts:[]}}function R0(n,e="cut"){return{layers:new Map([[e,{regions:[],lines:n}]]),parts:[]}}function W4(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 X4=n=>n.map(e=>e.map(([t,c])=>({x:Math.round(t*h0),y:Math.round(c*h0)})));function M9(n){let e=(c,a,r)=>(a.x-c.x)*(r.y-a.y)-(a.y-c.y)*(r.x-a.x)===0,t=[];for(let c of n){for(;t.length>=2&&e(t[t.length-2],t[t.length-1],c);)t.pop();let a=t[t.length-1];(!a||a.x!==c.x||a.y!==c.y)&&t.push(c)}for(let c=!0;c&&t.length>=3;){let a=t.length;c=!0,t[a-1].x===t[0].x&&t[a-1].y===t[0].y||e(t[a-2],t[a-1],t[0])?t.pop():e(t[a-1],t[0],t[1])?t.shift():c=!1}return t}var D2=n=>X4(n).map(M9),R2=n=>n.filter(e=>e.length>=2).map(e=>e.map(t=>[t.x/h0,t.y/h0]));function r1(n,e="nonzero"){if(!n.length)return[];let t=e==="evenodd"?s1.EvenOdd:s1.NonZero;return R2(v5(D2(n),t)).filter(c=>c.length>=3)}function g5(n,e,t){if(!e.length)return[];let c=new b0;c.addSubject(D2(e)),t.length&&c.addClip(D2(t));let a=[];return c.execute(n,s1.NonZero,a),R2(a).filter(r=>r.length>=3)}var Q1=(n,e)=>e.length?g5(y1.Difference,n,e):r1(n),Y1=(n,e)=>g5(y1.Intersection,n,e),Z4=(n,e)=>g5(y1.Xor,n,e);function M0(n,e,t){if(!n.length)return[];if(!e.length)return t==="outside"?n:[];let c=[];for(let m of e)for(let v=0;v<m.length;v++){let g=m[v],b=m[(v+1)%m.length];(g[0]!==b[0]||g[1]!==b[1])&&c.push([g,b])}if(!c.length)return t==="outside"?n:[];let a=x0(e),r=Math.max(a[2]-a[0],a[3]-a[1],1e-6)/Math.max(1,Math.sqrt(c.length)),s=m=>Math.floor(m/r),i=new Map,l=new Map,o=(m,v,g)=>{let b=m.get(v);b?b[b.length-1]!==g&&b.push(g):m.set(v,[g])};c.forEach(([m,v],g)=>{let b=Math.max(1,Math.ceil(Math.hypot(v[0]-m[0],v[1]-m[1])/r*2));for(let y=0;y<=b;y++){let w=m[0]+(v[0]-m[0])*y/b,k=m[1]+(v[1]-m[1])*y/b;for(let P of[-1,0,1])for(let S of[-1,0,1])o(i,`${s(w)+P},${s(k)+S}`,g)}for(let y=s(Math.min(m[1],v[1]));y<=s(Math.max(m[1],v[1]));y++)o(l,y,g)});let h=(m,v)=>{let g=new Set,b=Math.max(1,Math.ceil(Math.hypot(v[0]-m[0],v[1]-m[1])/r*2));for(let y=0;y<=b;y++){let w=m[0]+(v[0]-m[0])*y/b,k=m[1]+(v[1]-m[1])*y/b;for(let P of i.get(`${s(w)},${s(k)}`)??[])g.add(P)}return g},f=.5/h0,u=m=>{for(let g of i.get(`${s(m[0])},${s(m[1])}`)??[]){let[b,y]=c[g],w=y[0]-b[0],k=y[1]-b[1],P=Math.max(0,Math.min(1,((m[0]-b[0])*w+(m[1]-b[1])*k)/(w*w+k*k)));if(Math.hypot(m[0]-b[0]-P*w,m[1]-b[1]-P*k)<=f)return}let v=0;for(let g of l.get(s(m[1]))??[]){let[b,y]=c[g],w=(y[0]-b[0])*(m[1]-b[1])-(m[0]-b[0])*(y[1]-b[1]);b[1]<=m[1]?y[1]>m[1]&&w>0&&v++:y[1]<=m[1]&&w<0&&v--}return v!==0},d=m=>Math.round(m*h0)/h0,p=[];for(let m of n){let v=null,g=()=>{v&&v.length>=2&&p.push(v),v=null};for(let b=1;b<m.length;b++){let y=m[b-1],w=m[b],k=w[0]-y[0],P=w[1]-y[1];if(!k&&!P)continue;let S=[0,1];for(let A of h(y,w)){let[E,z]=c[A],I=z[0]-E[0],$=z[1]-E[1],F=k*$-P*I;if(Math.abs(F)>1e-15){let _=((E[0]-y[0])*$-(E[1]-y[1])*I)/F,Y=((E[0]-y[0])*P-(E[1]-y[1])*k)/F;_>0&&_<1&&Y>=0&&Y<=1&&S.push(_)}else{let _=k*k+P*P;for(let Y of[E,z]){let N=((Y[0]-y[0])*k+(Y[1]-y[1])*P)/_,i1=Math.abs((Y[0]-y[0])*P-(Y[1]-y[1])*k)/Math.sqrt(_);N>0&&N<1&&i1<=f&&S.push(N)}}}S.sort((A,E)=>A-E);for(let A=1;A<S.length;A++){if(S[A]-S[A-1]<1e-12)continue;let E=[d(y[0]+k*S[A-1]),d(y[1]+P*S[A-1])],z=[d(y[0]+k*S[A]),d(y[1]+P*S[A])],I=(S[A-1]+S[A])/2,$=u([y[0]+k*I,y[1]+P*I]);if($!==void 0&&$===(t==="inside")){let F=v?v[v.length-1]:void 0;v&&F&&F[0]===E[0]&&F[1]===E[1]?(z[0]!==F[0]||z[1]!==F[1])&&v.push(z):(g(),v=[E,z])}else g()}}g()}return p}function B1(n,e,t="round",c=.01){if(!n.length)return[];if(e===0)return r1(n);let a=t==="round"?G1.Round:t==="square"?G1.Square:G1.Miter,r=m3(D2(r1(n)),e*h0,a,w1.Polygon,2,c*h0);return R2(r).filter(s=>s.length>=3)}function v3(n,e){if(!n.length||e<=0)return[];let t=m3(X4(n),e/2*h0,G1.Round,w1.Round,2,.01*h0);return R2(t)}function T0(n){if(!n.length)return[];let e=new F2,t=new b0;t.addSubject(D2(n)),t.execute(y1.Union,s1.NonZero,e);let c=[],a=r=>{for(let s=0;s<r.count;s++){let i=r.child(s),l=[i.poly];for(let o=0;o<i.count;o++){let h=i.child(o);l.push(h.poly),a(h)}c.push(R2(l))}};return a(e),c}function g1(n){let e=0;for(let t=0,c=n.length-1;t<n.length;c=t++)e+=(n[c][0]+n[t][0])*(n[c][1]-n[t][1]);return-e/2}function Y4(n){let e=0,t=0,c=0;for(let a of n){if(a.length<3)continue;let[r,s]=a[0];for(let i=0,l=a.length-1;i<a.length;l=i++){let o=a[l][0]-r,h=a[l][1]-s,f=a[i][0]-r,u=a[i][1]-s,d=o*u-f*h;e+=d/2,t+=(o+f)*d/6+r*d/2,c+=(h+u)*d/6+s*d/2}}return Math.abs(e)<1e-12?{area:0,centroid:[0,0]}:{area:Math.abs(e),centroid:[t/e,c/e]}}function _4(n,[e,t]){return[n[0]*e+n[2]*t+n[4],n[1]*e+n[3]*t+n[5]]}function G4(n,e){let t=e[0]*e[3]-e[1]*e[2]<0,c=new Map;for(let[a,r]of n)c.set(a,{regions:r.regions.map(s=>{let i=s.map(l=>_4(e,l));return t?i.reverse():i}),lines:r.lines.map(s=>s.map(i=>_4(e,i)))});return c}function f2(n,e){return{layers:G4(n.layers,e),parts:n.parts.map(t=>({...t,layers:G4(t.layers,e)}))}}function q0(n){let e=a0();for(let t of n){for(let[c,a]of t.layers){let r=e.layers.get(c)??{regions:[],lines:[]};for(let s of a.regions)r.regions.push(s);for(let s of a.lines)r.lines.push(s);e.layers.set(c,r)}for(let c of t.parts)e.parts.push(c)}return e}function j4(n,e){let t={regions:[],lines:[]};for(let c of n.values()){for(let a of c.regions)t.regions.push(a);for(let a of c.lines)t.lines.push(a)}return new Map([[e,t]])}function q2(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:j4(n.layers,e),parts:n.parts.map(t=>({...t,layers:j4(t.layers,e)}))}}function x0(n){let e=1/0,t=1/0,c=-1/0,a=-1/0;for(let r of n)for(let[s,i]of r)s<e&&(e=s),i<t&&(t=i),s>c&&(c=s),i>a&&(a=i);return e===1/0?null:[e,t,c,a]}function r0(n,e){let t=[];for(let[c,a]of n)if(!e?.(c))for(let r of[...a.regions,...a.lines])t.push(r);return x0(t)}function K4(n){let e=[...n].sort((r,s)=>r[0]-s[0]||r[1]-s[1]);if(e.length<3)return e;let t=(r,s,i)=>(s[0]-r[0])*(i[1]-r[1])-(s[1]-r[1])*(i[0]-r[0]),c=[];for(let r of e){for(;c.length>=2&&t(c[c.length-2],c[c.length-1],r)<=0;)c.pop();c.push(r)}let a=[];for(let r=e.length-1;r>=0;r--){let s=e[r];for(;a.length>=2&&t(a[a.length-2],a[a.length-1],s)<=0;)a.pop();a.push(s)}return a.pop(),c.pop(),c.concat(a)}function J4(n,e,t,c){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/c)),5)}function g3(n,e,t){let c=[];for(let a=0;a<t;a++){let r=2*Math.PI*a/t;c.push([n*Math.cos(r),e*Math.sin(r)])}return c}function Q4(n,e,t,c){if(t=Math.min(t,n/2,e/2),t<=0)return[[0,0],[n,0],[n,e],[0,e]];let a=Math.max(1,Math.ceil(c(t)/4)),r=[],s=[[n-t,t,-90],[n-t,e-t,0],[t,e-t,90],[t,t,180]];for(let[i,l,o]of s)for(let h=0;h<=a;h++){let f=(o+90*h/a)*Math.PI/180;r.push([i+t*Math.cos(f),l+t*Math.sin(f)])}return r}function y3(n,e){let t=Math.round(n/e);return t%2===0&&(t+=n/e>t?1:-1),Math.max(3,t)}var U2=(n,e,t,c)=>[[n,e],[t,e],[t,c],[n,c]];function x9(n,e,t,c){if(e==="flat")return[];let a=y3(n,c),r=n/a,s=[];for(let i=0;i<a;i++)(e==="out"?i%2===1:i%2===0)&&s.push(U2(i*r,-1,(i+1)*r,t));return s}function e6(n,e,t,c,a){let r=[([l,o])=>[l,o],([l,o])=>[n-o,l],([l,o])=>[n-l,e-o],([l,o])=>[o,e-l]],s=[n,e,n,e],i=[];return t.forEach((l,o)=>{for(let h of x9(s[o],l,c,a))i.push(h.map(r[o]))}),Q1([U2(0,0,n,e)],i)}function t6(n,e,t,c){let a=y3(n,c),r=n/a,s=[];for(let i=0;i<a;i++)(e==="out"?i%2===0:i%2===1)&&s.push(U2(i*r,-t/2,(i+1)*r,t/2));return s}function n6(n,e,t,c,a){let r=U2(-n/2,-1,n/2,e),s=U2(-t/2,a,t/2,a+c);return[r,s]}function c6(n,e,t,c,a){let r=[],s=a+c,i=Math.floor(n/t),l=(n-i*t)/2;for(let o=0;o<=i;o++){let h=l+o*t,f=o%2===0?c:c-s/2;for(let u=f;u<e;u+=s){let d=Math.max(u,o%2===0?c:0),p=Math.min(u+a,e-(o%2===0?c:0));p-d>=c/2&&r.push([[h,d],[h,p]])}}return r}var a6=Math.PI/180;function D1(n,e){let t=new Array(16).fill(0);for(let c=0;c<4;c++)for(let a=0;a<4;a++)for(let r=0;r<4;r++)t[c*4+a]+=n[c*4+r]*e[r*4+a];return t}function b3(n,e){let t=Math.cos(e*a6),c=Math.sin(e*a6);return n===0?[1,0,0,0,0,t,-c,0,0,c,t,0,0,0,0,1]:n===1?[t,0,c,0,0,1,0,0,-c,0,t,0,0,0,0,1]:[t,-c,0,0,c,t,0,0,0,0,1,0,0,0,0,1]}var y5=n=>Math.abs(n)<1e-12?0:n;function u0(n){if(n.matrix)return n.matrix.map(y5);let[e,t,c]=n.rotate,a=D1(b3(2,c),D1(b3(1,t),b3(0,e)));return a[3]=n.at[0],a[7]=n.at[1],a[11]=n.at[2],a.map(y5)}function M3(n,e,t,c){return[n[0]*e+n[1]*t+n[2]*c+n[3],n[4]*e+n[5]*t+n[6]*c+n[7],n[8]*e+n[9]*t+n[10]*c+n[11]]}function l6(n){let[e,t,c]=[n[3],n[7],n[11]],a=[n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]];return[a[0],a[1],a[2],-(a[0]*e+a[1]*t+a[2]*c),a[3],a[4],a[5],-(a[3]*e+a[4]*t+a[5]*c),a[6],a[7],a[8],-(a[6]*e+a[7]*t+a[8]*c),0,0,0,1]}function x3(n){let[e,t,c,a]=[1/0,1/0,-1/0,-1/0];for(let r of n)for(let[s,i]of r)e=Math.min(e,s),t=Math.min(t,i),c=Math.max(c,s),a=Math.max(a,i);return[e,t,c,a]}function N2(n){let[e,t,c,a]=x3(n.outline),r=[1/0,1/0,1/0],s=[-1/0,-1/0,-1/0];for(let i of[e,c])for(let l of[t,a])for(let o of[0,n.thickness]){let h=M3(n.matrix,i,l,o);for(let f=0;f<3;f++)r[f]=Math.min(r[f],h[f]),s[f]=Math.max(s[f],h[f])}return[r,s]}function o6(n,e,t=10){let c=[1/0,1/0,1/0],a=[-1/0,-1/0,-1/0];for(let[h,f]of n.map(N2))for(let u=0;u<3;u++)c[u]=Math.min(c[u],h[u]),a[u]=Math.max(a[u],f[u]);let r=e.map(h=>x3(h.outline)),s=r.reduce((h,[f,,u])=>Math.max(h,u-f),a[0]-c[0]),i=0,l=0,o=0;return e.map((h,f)=>{let[u,d,p,m]=r[f];i>0&&i+p-u>s&&(i=0,l+=o+t,o=0);let v=[1,0,0,a[0]+t+i-u,0,1,0,c[1]+l-d,0,0,1,c[2],0,0,0,1];return i+=p-u+t,o=Math.max(o,m-d),{...h,matrix:v.map(y5)}})}var z9=(n,e,t)=>[0,1,2].every(c=>n[0][c]<e[1][c]-t&&e[0][c]<n[1][c]-t),d2=(n,e)=>n[0]*e[0]+n[1]*e[1]+n[2]*e[2],b5=(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]],r6=(n,e,t=1)=>[n[0]+e[0]*t,n[1]+e[1]*t,n[2]+e[2]*t],z3=n=>[n[2],n[6],n[10]],s6=n=>[n[3],n[7],n[11]],w9=(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 p2(n,e,t){let c=t[0]*t[0]+t[1]*t[1],a=[];for(let r of n)for(let s=0,i=r.length-1;s<r.length;i=s++){let l=r[i],o=r[s],h=t[0]*(l[1]-e[1])-t[1]*(l[0]-e[0]),f=t[0]*(o[1]-e[1])-t[1]*(o[0]-e[0]);if(h>0==f>0)continue;let u=h/(h-f),d=l[0]+(o[0]-l[0])*u-e[0],p=l[1]+(o[1]-l[1])*u-e[1];a.push((d*t[0]+p*t[1])/c)}return a.sort((r,s)=>r-s)}function M5(n,e,t){let c=0,a=0,r=0;for(;a+1<n.length&&r+1<e.length;){let s=Math.min(n[a+1],e[r+1])-Math.max(n[a],e[r]);s>t&&(c+=s),n[a+1]<e[r+1]?a+=2:r+=2}return c}function w3(n,e,t,c){let a=n+t,r=e-t;if(r<=a)return{at:[],size:0};let s=Math.max(4,Math.ceil((r-a)/c));return{at:Array.from({length:s},(i,l)=>a+(r-a)*(l+.5)/s),size:(r-a)/s}}function i6(n,e,t){let c=M3(n,e[0],e[1],e[2]),a=w9(n,t);return[[c[0],c[1]],[a[0],a[1]]]}function k9(n,e,t,c,a,r,s){let i=z3(n.matrix),l=z3(e.matrix),o=b5(i,l),h=Math.hypot(...o),f=[o[0]/h,o[1]/h,o[2]/h],u=b5(f,i),d=d2(l,u),p=s6(n.matrix),m=d2(l,s6(e.matrix)),v=1/0,g=-1/0;for(let P of e.outline)for(let[S,A]of P)for(let E of[0,e.thickness]){let z=M3(e.matrix,S,A,E),I=d2(i,[z[0]-p[0],z[1]-p[1],z[2]-p[2]]);I<v&&(v=I),I>g&&(g=I)}let b=w3(Math.max(0,v),Math.min(n.thickness,g),a,r),y=1/0,w=-1/0;for(let P of n.outline)for(let[S,A]of P){let E=M3(n.matrix,S,A,0),z=d2(u,[E[0]-p[0],E[1]-p[1],E[2]-p[2]]);z<y&&(y=z),z>w&&(w=z)}let k=0;for(let P of b.at){let S=r6(p,i,P),A=(m-d2(l,S))/d,E=(m+e.thickness-d2(l,S))/d,z=w3(Math.max(y,Math.min(A,E)),Math.min(w,Math.max(A,E)),a,r);for(let I of z.at){let $=r6(S,u,I),[F,_]=i6(t,$,f),[Y,N]=i6(c,$,f);if(k+=M5(p2(n.outline,F,_),p2(e.outline,Y,N),a)*b.size*z.size,k>s)return!0}}return!1}function L9(n,e,t,c,a,r){let s=[0,1,2,3].flatMap(S=>[0,1,2,3].map(A=>{let E=0;for(let z=0;z<4;z++)E+=t[S*4+z]*e.matrix[z*4+A];return E})),i=s[11],l=s[11]+s[10]*e.thickness,o=Math.min(n.thickness,Math.max(i,l))-Math.max(0,Math.min(i,l));if(o<=c)return!1;let h=e.outline.map(S=>S.map(([A,E])=>[s[0]*A+s[1]*E+s[3],s[4]*A+s[5]*E+s[7]])),[f,u,d,p]=x3(n.outline),[m,v,g,b]=x3(h),y=w3(Math.max(u,v),Math.min(p,b),c,a),w=0;for(let S of y.at)if(w+=M5(p2(n.outline,[0,S],[1,0]),p2(h,[0,S],[1,0]),c)*y.size*o,w>r)return!0;let k=w3(Math.max(f,m),Math.min(d,g),c,a),P=0;for(let S of k.at)if(P+=M5(p2(n.outline,[S,0],[0,1]),p2(h,[S,0],[0,1]),c)*k.size*o,P>r)return!0;return!1}function h6(n,e=1/0,t=.05,c=.25,a=.1){let r=n.map(N2),s=n.map(h=>l6(h.matrix)),i=n.map((h,f)=>f).sort((h,f)=>r[h][0][0]-r[f][0][0]),l=[],o=0;for(let h=0;h<i.length;h++)for(let f=h+1;f<i.length;f++){let u=i[h],d=i[f];if(r[d][0][0]>=r[u][1][0]-t)break;if(!z9(r[u],r[d],t))continue;if(++o>e)return{found:l,complete:!1};let[p,m]=u<d?[n[u],n[d]]:[n[d],n[u]],[v,g]=u<d?[s[u],s[d]]:[s[d],s[u]];(Math.hypot(...b5(z3(p.matrix),z3(m.matrix)))<1e-9?L9(p,m,v,t,c,a):k9(p,m,v,g,t,c,a))&&l.push([p,m])}return{found:l,complete:!0}}function I0(n,e,t){return[1,0,0,n,0,1,0,e,0,0,1,t,0,0,0,1]}var x5=I0(0,0,0);function k3(n){return l6(n)}function S9(n,e,t=n.angle,c=n.x1){let a=c-n.x0;if(!t||!(a>0))return I0(0,0,0);let r=(n.x1-n.x0)/(n.angle*Math.PI/180),s=e/2+r;return D1(I0(n.x0,0,s),D1(b3(1,-t),I0(-n.x0-a,0,-s)))}function z5(n){return[...n].sort((e,t)=>e.x0-t.x0)}function w5(n,e){let t=[I0(0,0,0)];for(let c of z5(n))t.push(D1(t[t.length-1],S9(c,e)));return t}function u6(n,e){return z5(n).filter(t=>(t.x0+t.x1)/2<e).length}function L3(n){if(!n.bends?.length)return[n];let e=z5(n.bends),t=w5(e,n.thickness),c=1e7,a=[];for(let r=0;r<=e.length;r++){let s=r===0?-c:e[r-1].x1,i=r===e.length?c:e[r].x0;if(!(i>s))continue;let l=[[s,-c],[i,-c],[i,c],[s,c]],o=Y1(n.outline,[l]);o.length&&a.push({...n,outline:o,bends:void 0,matrix:D1(n.matrix,t[r])})}return a}var k5={dowel:{color:"#e2c48f",doc:"a wooden dowel or axle"},steel:{color:"#a7adb3",metal:!0,doc:"a steel rod, pin or axle"},brass:{color:"#c9a227",metal:!0,doc:"a brass rod, tube or pin"},screw:{color:"#9aa0a6",metal:!0,doc:"a screw"},bolt:{color:"#9aa0a6",metal:!0,doc:"a bolt"},nut:{color:"#9aa0a6",metal:!0,doc:"a nut"},magnet:{color:"#55585c",metal:!0,doc:"a disc or block magnet"},paper:{color:"#fbfaf6",doc:"a sheet or strip of paper"},card:{color:"#f4f1e8",doc:"card stock"},felt:{color:"#6f6a64",doc:"felt pads or lining"},elastic:{color:"#262626",doc:"an elastic band or cord"},cord:{color:"#b23a3a",doc:"cord, string or thread"},ribbon:{color:"#c2485a",doc:"ribbon or tape"},wire:{color:"#b87333",metal:!0,doc:"wire"},led:{color:"#fff4c2",glow:!0,doc:"an LED or a strip of them"},bulb:{color:"#fff4c2",glow:!0,doc:'a light bulb; give it shape = "ball"'},ball:{color:"#8fb8d8",doc:'a marble, ball or bead; give it shape = "ball"'},tube:{color:"#c9a227",metal:!0,doc:"a tube, as a hollow arbor or a sleeve"},lens:{color:"#d6ecf3",doc:"a lens, a thin disc of glass or acrylic"},mirror:{color:"#c8d3da",metal:!0,doc:"a mirror"},movement:{color:"#3d3d3d",doc:"a bought movement, as a clock, music box or motor: a labelled block"},white:{color:"#f7f7f4",doc:"anything white"}},f6={pink:"#f2a7c3",yellow:"#f5d76e",red:"#d9534f",green:"#6dbb6d",blue:"#5b8fd9",orange:"#f0a04b",purple:"#9b72cf",black:"#222222",grey:"#9a9a9a",gray:"#9a9a9a"};String.prototype.codePointAt||(function(){var n=(function(){try{var t={},c=Object.defineProperty,a=c(t,t,t)&&c}catch{}return a})(),e=function(t){if(this==null)throw TypeError();var c=String(this),a=c.length,r=t?Number(t):0;if(r!=r&&(r=0),!(r<0||r>=a)){var s=c.charCodeAt(r),i;return s>=55296&&s<=56319&&a>r+1&&(i=c.charCodeAt(r+1),i>=56320&&i<=57343)?(s-55296)*1024+i-56320+65536:s}};n?n(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e})();var $5=0,e7=-3;function _2(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function A9(n,e){this.source=n,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=e,this.destLen=0,this.ltree=new _2,this.dtree=new _2}var t7=new _2,n7=new _2,_5=new Uint8Array(30),G5=new Uint16Array(30),c7=new Uint8Array(30),a7=new Uint16Array(30),C9=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),m6=new _2,z0=new Uint8Array(320);function r7(n,e,t,c){var a,r;for(a=0;a<t;++a)n[a]=0;for(a=0;a<30-t;++a)n[a+t]=a/t|0;for(r=c,a=0;a<30;++a)e[a]=r,r+=1<<n[a]}function P9(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 v6=new Uint16Array(16);function L5(n,e,t,c){var a,r;for(a=0;a<16;++a)n.table[a]=0;for(a=0;a<c;++a)n.table[e[t+a]]++;for(n.table[0]=0,r=0,a=0;a<16;++a)v6[a]=r,r+=n.table[a];for(a=0;a<c;++a)e[t+a]&&(n.trans[v6[e[t+a]]++]=a)}function E9(n){n.bitcount--||(n.tag=n.source[n.sourceIndex++],n.bitcount=7);var e=n.tag&1;return n.tag>>>=1,e}function w0(n,e,t){if(!e)return t;for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<<n.bitcount,n.bitcount+=8;var c=n.tag&65535>>>16-e;return n.tag>>>=e,n.bitcount-=e,c+t}function V5(n,e){for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<<n.bitcount,n.bitcount+=8;var t=0,c=0,a=0,r=n.tag;do c=2*c+(r&1),r>>>=1,++a,t+=e.table[a],c-=e.table[a];while(c>=0);return n.tag=r,n.bitcount-=a,e.trans[t+c]}function T9(n,e,t){var c,a,r,s,i,l;for(c=w0(n,5,257),a=w0(n,5,1),r=w0(n,4,4),s=0;s<19;++s)z0[s]=0;for(s=0;s<r;++s){var o=w0(n,3,0);z0[C9[s]]=o}for(L5(m6,z0,0,19),i=0;i<c+a;){var h=V5(n,m6);switch(h){case 16:var f=z0[i-1];for(l=w0(n,2,3);l;--l)z0[i++]=f;break;case 17:for(l=w0(n,3,3);l;--l)z0[i++]=0;break;case 18:for(l=w0(n,7,11);l;--l)z0[i++]=0;break;default:z0[i++]=h;break}}L5(e,z0,0,c),L5(t,z0,c,a)}function g6(n,e,t){for(;;){var c=V5(n,e);if(c===256)return $5;if(c<256)n.dest[n.destLen++]=c;else{var a,r,s,i;for(c-=257,a=w0(n,_5[c],G5[c]),r=V5(n,t),s=n.destLen-w0(n,c7[r],a7[r]),i=s;i<s+a;++i)n.dest[n.destLen++]=n.dest[i]}}}function I9(n){for(var e,t,c;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 e7;for(n.sourceIndex+=4,c=e;c;--c)n.dest[n.destLen++]=n.source[n.sourceIndex++];return n.bitcount=0,$5}function H9(n,e){var t=new A9(n,e),c,a,r;do{switch(c=E9(t),a=w0(t,2,0),a){case 0:r=I9(t);break;case 1:r=g6(t,t7,n7);break;case 2:T9(t,t.ltree,t.dtree),r=g6(t,t.ltree,t.dtree);break;default:r=e7}if(r!==$5)throw new Error("Data error")}while(!c);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}P9(t7,n7);r7(_5,G5,4,3);r7(c7,a7,2,1);_5[28]=0;G5[28]=258;var V9=H9;function m2(n,e,t,c,a){return Math.pow(1-a,3)*n+3*Math.pow(1-a,2)*a*e+3*(1-a)*Math.pow(a,2)*t+Math.pow(a,3)*c}function j0(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}j0.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)};j0.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))};j0.prototype.addX=function(n){this.addPoint(n,null)};j0.prototype.addY=function(n){this.addPoint(null,n)};j0.prototype.addBezier=function(n,e,t,c,a,r,s,i){var l=[n,e],o=[t,c],h=[a,r],f=[s,i];this.addPoint(n,e),this.addPoint(s,i);for(var u=0;u<=1;u++){var d=6*l[u]-12*o[u]+6*h[u],p=-3*l[u]+9*o[u]-9*h[u]+3*f[u],m=3*o[u]-3*l[u];if(p===0){if(d===0)continue;var v=-m/d;0<v&&v<1&&(u===0&&this.addX(m2(l[u],o[u],h[u],f[u],v)),u===1&&this.addY(m2(l[u],o[u],h[u],f[u],v)));continue}var g=Math.pow(d,2)-4*m*p;if(!(g<0)){var b=(-d+Math.sqrt(g))/(2*p);0<b&&b<1&&(u===0&&this.addX(m2(l[u],o[u],h[u],f[u],b)),u===1&&this.addY(m2(l[u],o[u],h[u],f[u],b)));var y=(-d-Math.sqrt(g))/(2*p);0<y&&y<1&&(u===0&&this.addX(m2(l[u],o[u],h[u],f[u],y)),u===1&&this.addY(m2(l[u],o[u],h[u],f[u],y)))}}};j0.prototype.addQuad=function(n,e,t,c,a,r){var s=n+.6666666666666666*(t-n),i=e+2/3*(c-e),l=s+1/3*(a-n),o=i+1/3*(r-e);this.addBezier(n,e,s,i,l,o,a,r)};function E1(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}E1.prototype.moveTo=function(n,e){this.commands.push({type:"M",x:n,y:e})};E1.prototype.lineTo=function(n,e){this.commands.push({type:"L",x:n,y:e})};E1.prototype.curveTo=E1.prototype.bezierCurveTo=function(n,e,t,c,a,r){this.commands.push({type:"C",x1:n,y1:e,x2:t,y2:c,x:a,y:r})};E1.prototype.quadTo=E1.prototype.quadraticCurveTo=function(n,e,t,c){this.commands.push({type:"Q",x1:n,y1:e,x:t,y:c})};E1.prototype.close=E1.prototype.closePath=function(){this.commands.push({type:"Z"})};E1.prototype.extend=function(n){if(n.commands)n=n.commands;else if(n instanceof j0){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)};E1.prototype.getBoundingBox=function(){for(var n=new j0,e=0,t=0,c=0,a=0,r=0;r<this.commands.length;r++){var s=this.commands[r];switch(s.type){case"M":n.addPoint(s.x,s.y),e=c=s.x,t=a=s.y;break;case"L":n.addPoint(s.x,s.y),c=s.x,a=s.y;break;case"Q":n.addQuad(c,a,s.x1,s.y1,s.x,s.y),c=s.x,a=s.y;break;case"C":n.addBezier(c,a,s.x1,s.y1,s.x2,s.y2,s.x,s.y),c=s.x,a=s.y;break;case"Z":c=e,a=t;break;default:throw new Error("Unexpected path command "+s.type)}}return n.isEmpty()&&n.addPoint(0,0),n};E1.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())};E1.prototype.toPathData=function(n){n=n!==void 0?n:2;function e(s){return Math.round(s)===s?""+Math.round(s):s.toFixed(n)}function t(){for(var s=arguments,i="",l=0;l<arguments.length;l+=1){var o=s[l];o>=0&&l>0&&(i+=" "),i+=e(o)}return i}for(var c="",a=0;a<this.commands.length;a+=1){var r=this.commands[a];r.type==="M"?c+="M"+t(r.x,r.y):r.type==="L"?c+="L"+t(r.x,r.y):r.type==="C"?c+="C"+t(r.x1,r.y1,r.x2,r.y2,r.x,r.y):r.type==="Q"?c+="Q"+t(r.x1,r.y1,r.x,r.y):r.type==="Z"&&(c+="Z")}return c};E1.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};E1.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 s7(n){throw new Error(n)}function y6(n,e){n||s7(e)}var W={fail:s7,argument:y6,assert:y6},b6=32768,M6=2147483648,g2={},H={},Z={};function m0(n){return function(){return n}}H.BYTE=function(n){return W.argument(n>=0&&n<=255,"Byte value should be between 0 and 255."),[n]};Z.BYTE=m0(1);H.CHAR=function(n){return[n.charCodeAt(0)]};Z.CHAR=m0(1);H.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};H.USHORT=function(n){return[n>>8&255,n&255]};Z.USHORT=m0(2);H.SHORT=function(n){return n>=b6&&(n=-(2*b6-n)),[n>>8&255,n&255]};Z.SHORT=m0(2);H.UINT24=function(n){return[n>>16&255,n>>8&255,n&255]};Z.UINT24=m0(3);H.ULONG=function(n){return[n>>24&255,n>>16&255,n>>8&255,n&255]};Z.ULONG=m0(4);H.LONG=function(n){return n>=M6&&(n=-(2*M6-n)),[n>>24&255,n>>16&255,n>>8&255,n&255]};Z.LONG=m0(4);H.FIXED=H.ULONG;Z.FIXED=Z.ULONG;H.FWORD=H.SHORT;Z.FWORD=Z.SHORT;H.UFWORD=H.USHORT;Z.UFWORD=Z.USHORT;H.LONGDATETIME=function(n){return[0,0,0,0,n>>24&255,n>>16&255,n>>8&255,n&255]};Z.LONGDATETIME=m0(8);H.TAG=function(n){return W.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=m0(4);H.Card8=H.BYTE;Z.Card8=Z.BYTE;H.Card16=H.USHORT;Z.Card16=Z.USHORT;H.OffSize=H.BYTE;Z.OffSize=Z.BYTE;H.SID=H.USHORT;Z.SID=Z.USHORT;H.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?H.NUMBER16(n):H.NUMBER32(n)};Z.NUMBER=function(n){return H.NUMBER(n).length};H.NUMBER16=function(n){return[28,n>>8&255,n&255]};Z.NUMBER16=m0(3);H.NUMBER32=function(n){return[29,n>>24&255,n>>16&255,n>>8&255,n&255]};Z.NUMBER32=m0(5);H.REAL=function(n){var e=n.toString(),t=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(e);if(t){var c=parseFloat("1e"+((t[2]?+t[2]:0)+t[1].length));e=(Math.round(n*c)/c).toString()}for(var a="",r=0,s=e.length;r<s;r+=1){var i=e[r];i==="e"?a+=e[++r]==="-"?"c":"b":i==="."?a+="a":i==="-"?a+="e":a+=i}a+=a.length&1?"f":"ff";for(var l=[30],o=0,h=a.length;o<h;o+=2)l.push(parseInt(a.substr(o,2),16));return l};Z.REAL=function(n){return H.REAL(n).length};H.NAME=H.CHARARRAY;Z.NAME=Z.CHARARRAY;H.STRING=H.CHARARRAY;Z.STRING=Z.CHARARRAY;g2.UTF8=function(n,e,t){for(var c=[],a=t,r=0;r<a;r++,e+=1)c[r]=n.getUint8(e);return String.fromCharCode.apply(null,c)};g2.UTF16=function(n,e,t){for(var c=[],a=t/2,r=0;r<a;r++,e+=2)c[r]=n.getUint16(e);return String.fromCharCode.apply(null,c)};H.UTF16=function(n){for(var e=[],t=0;t<n.length;t+=1){var c=n.charCodeAt(t);e[e.length]=c>>8&255,e[e.length]=c&255}return e};Z.UTF16=function(n){return n.length*2};var O5={"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"};g2.MACSTRING=function(n,e,t,c){var a=O5[c];if(a!==void 0){for(var r="",s=0;s<t;s++){var i=n.getUint8(e+s);i<=127?r+=String.fromCharCode(i):r+=a[i&127]}return r}};var S3=typeof WeakMap=="function"&&new WeakMap,A3,O9=function(n){if(!A3){A3={};for(var e in O5)A3[e]=new String(e)}var t=A3[n];if(t!==void 0){if(S3){var c=S3.get(t);if(c!==void 0)return c}var a=O5[n];if(a!==void 0){for(var r={},s=0;s<a.length;s++)r[a.charCodeAt(s)]=s+128;return S3&&S3.set(t,r),r}}};H.MACSTRING=function(n,e){var t=O9(e);if(t!==void 0){for(var c=[],a=0;a<n.length;a++){var r=n.charCodeAt(a);if(r>=128&&(r=t[r],r===void 0))return;c[a]=r}return c}};Z.MACSTRING=function(n,e){var t=H.MACSTRING(n,e);return t!==void 0?t.length:0};function F5(n){return n>=-128&&n<=127}function F9(n,e,t){for(var c=0,a=n.length;e<a&&c<64&&n[e]===0;)++e,++c;return t.push(128|c-1),e}function D9(n,e,t){for(var c=0,a=n.length,r=e;r<a&&c<64;){var s=n[r];if(!F5(s)||s===0&&r+1<a&&n[r+1]===0)break;++r,++c}t.push(c-1);for(var i=e;i<r;++i)t.push(n[i]+256&255);return r}function R9(n,e,t){for(var c=0,a=n.length,r=e;r<a&&c<64;){var s=n[r];if(s===0||F5(s)&&r+1<a&&F5(n[r+1]))break;++r,++c}t.push(64|c-1);for(var i=e;i<r;++i){var l=n[i];t.push(l+65536>>8&255,l+256&255)}return r}H.VARDELTAS=function(n){for(var e=0,t=[];e<n.length;){var c=n[e];c===0?e=F9(n,e,t):c>=-128&&c<=127?e=D9(n,e,t):e=R9(n,e,t)}return t};H.INDEX=function(n){for(var e=1,t=[e],c=[],a=0;a<n.length;a+=1){var r=H.OBJECT(n[a]);Array.prototype.push.apply(c,r),e+=r.length,t.push(e)}if(c.length===0)return[0,0];for(var s=[],i=1+Math.floor(Math.log(e)/Math.log(2))/8|0,l=[void 0,H.BYTE,H.USHORT,H.UINT24,H.ULONG][i],o=0;o<t.length;o+=1){var h=l(t[o]);Array.prototype.push.apply(s,h)}return Array.prototype.concat(H.Card16(n.length),H.OffSize(i),s,c)};Z.INDEX=function(n){return H.INDEX(n).length};H.DICT=function(n){for(var e=[],t=Object.keys(n),c=t.length,a=0;a<c;a+=1){var r=parseInt(t[a],0),s=n[r];e=e.concat(H.OPERAND(s.value,s.type)),e=e.concat(H.OPERATOR(r))}return e};Z.DICT=function(n){return H.DICT(n).length};H.OPERATOR=function(n){return n<1200?[n]:[12,n-1200]};H.OPERAND=function(n,e){var t=[];if(Array.isArray(e))for(var c=0;c<e.length;c+=1)W.argument(n.length===e.length,"Not enough arguments given for type"+e),t=t.concat(H.OPERAND(n[c],e[c]));else if(e==="SID")t=t.concat(H.NUMBER(n));else if(e==="offset")t=t.concat(H.NUMBER32(n));else if(e==="number")t=t.concat(H.NUMBER(n));else if(e==="real")t=t.concat(H.REAL(n));else throw new Error("Unknown operand type "+e);return t};H.OP=H.BYTE;Z.OP=Z.BYTE;var C3=typeof WeakMap=="function"&&new WeakMap;H.CHARSTRING=function(n){if(C3){var e=C3.get(n);if(e!==void 0)return e}for(var t=[],c=n.length,a=0;a<c;a+=1){var r=n[a];t=t.concat(H[r.type](r.value))}return C3&&C3.set(n,t),t};Z.CHARSTRING=function(n){return H.CHARSTRING(n).length};H.OBJECT=function(n){var e=H[n.type];return W.argument(e!==void 0,"No encoding function for type "+n.type),e(n.value)};Z.OBJECT=function(n){var e=Z[n.type];return W.argument(e!==void 0,"No sizeOf function for type "+n.type),e(n.value)};H.TABLE=function(n){for(var e=[],t=n.fields.length,c=[],a=[],r=0;r<t;r+=1){var s=n.fields[r],i=H[s.type];W.argument(i!==void 0,"No encoding function for field type "+s.type+" ("+s.name+")");var l=n[s.name];l===void 0&&(l=s.value);var o=i(l);s.type==="TABLE"?(a.push(e.length),e=e.concat([0,0]),c.push(o)):e=e.concat(o)}for(var h=0;h<c.length;h+=1){var f=a[h],u=e.length;W.argument(u<65536,"Table "+n.tableName+" too big."),e[f]=u>>8,e[f+1]=u&255,e=e.concat(c[h])}return e};Z.TABLE=function(n){for(var e=0,t=n.fields.length,c=0;c<t;c+=1){var a=n.fields[c],r=Z[a.type];W.argument(r!==void 0,"No sizeOf function for field type "+a.type+" ("+a.name+")");var s=n[a.name];s===void 0&&(s=a.value),e+=r(s),a.type==="TABLE"&&(e+=2)}return e};H.RECORD=H.TABLE;Z.RECORD=Z.TABLE;H.LITERAL=function(n){return n};Z.LITERAL=function(n){return n.length};function R1(n,e,t){if(e.length&&(e[0].name!=="coverageFormat"||e[0].value===1))for(var c=0;c<e.length;c+=1){var a=e[c];this[a.name]=a.value}if(this.tableName=n,this.fields=e,t)for(var r=Object.keys(t),s=0;s<r.length;s+=1){var i=r[s],l=t[i];this[i]!==void 0&&(this[i]=l)}}R1.prototype.encode=function(){return H.TABLE(this)};R1.prototype.sizeOf=function(){return Z.TABLE(this)};function G2(n,e,t){t===void 0&&(t=e.length);var c=new Array(e.length+1);c[0]={name:n+"Count",type:"USHORT",value:t};for(var a=0;a<e.length;a++)c[a+1]={name:n+a,type:"USHORT",value:e[a]};return c}function D5(n,e,t){var c=e.length,a=new Array(c+1);a[0]={name:n+"Count",type:"USHORT",value:c};for(var r=0;r<c;r++)a[r+1]={name:n+r,type:"TABLE",value:t(e[r],r)};return a}function j2(n,e,t){var c=e.length,a=[];a[0]={name:n+"Count",type:"USHORT",value:c};for(var r=0;r<c;r++)a=a.concat(t(e[r],r));return a}function H3(n){n.format===1?R1.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(G2("glyph",n.glyphs))):n.format===2?R1.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:2}].concat(j2("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}]}))):W.assert(!1,"Coverage format must be 1 or 2.")}H3.prototype=Object.create(R1.prototype);H3.prototype.constructor=H3;function V3(n){R1.call(this,"scriptListTable",j2("scriptRecord",n,function(e,t){var c=e.script,a=c.defaultLangSys;return W.assert(!!a,"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 R1("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new R1("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:a.reqFeatureIndex}].concat(G2("featureIndex",a.featureIndexes)))}].concat(j2("langSys",c.langSysRecords,function(r,s){var i=r.langSys;return[{name:"langSysTag"+s,type:"TAG",value:r.tag},{name:"langSys"+s,type:"TABLE",value:new R1("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:i.reqFeatureIndex}].concat(G2("featureIndex",i.featureIndexes)))}]})))}]}))}V3.prototype=Object.create(R1.prototype);V3.prototype.constructor=V3;function O3(n){R1.call(this,"featureListTable",j2("featureRecord",n,function(e,t){var c=e.feature;return[{name:"featureTag"+t,type:"TAG",value:e.tag},{name:"feature"+t,type:"TABLE",value:new R1("featureTable",[{name:"featureParams",type:"USHORT",value:c.featureParams}].concat(G2("lookupListIndex",c.lookupListIndexes)))}]}))}O3.prototype=Object.create(R1.prototype);O3.prototype.constructor=O3;function F3(n,e){R1.call(this,"lookupListTable",D5("lookup",n,function(t){var c=e[t.lookupType];return W.assert(!!c,"Unable to write GSUB lookup type "+t.lookupType+" tables."),new R1("lookupTable",[{name:"lookupType",type:"USHORT",value:t.lookupType},{name:"lookupFlag",type:"USHORT",value:t.lookupFlag}].concat(D5("subtable",t.subtables,c)))}))}F3.prototype=Object.create(R1.prototype);F3.prototype.constructor=F3;var O={Table:R1,Record:R1,Coverage:H3,ScriptList:V3,FeatureList:O3,LookupList:F3,ushortList:G2,tableList:D5,recordList:j2};function x6(n,e){return n.getUint8(e)}function D3(n,e){return n.getUint16(e,!1)}function q9(n,e){return n.getInt16(e,!1)}function j5(n,e){return n.getUint32(e,!1)}function i7(n,e){var t=n.getInt16(e,!1),c=n.getUint16(e+2,!1);return t+c/65535}function U9(n,e){for(var t="",c=e;c<e+4;c+=1)t+=String.fromCharCode(n.getInt8(c));return t}function N9(n,e,t){for(var c=0,a=0;a<t;a+=1)c<<=8,c+=n.getUint8(e+a);return c}function B9(n,e,t){for(var c=[],a=e;a<t;a+=1)c.push(n.getUint8(a));return c}function $9(n){for(var e="",t=0;t<n.length;t+=1)e+=String.fromCharCode(n[t]);return e}var _9={byte:1,uShort:2,short:2,uLong:4,fixed:4,longDateTime:8,tag:4};function C(n,e){this.data=n,this.offset=e,this.relativeOffset=0}C.prototype.parseByte=function(){var n=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,n};C.prototype.parseChar=function(){var n=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,n};C.prototype.parseCard8=C.prototype.parseByte;C.prototype.parseUShort=function(){var n=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,n};C.prototype.parseCard16=C.prototype.parseUShort;C.prototype.parseSID=C.prototype.parseUShort;C.prototype.parseOffset16=C.prototype.parseUShort;C.prototype.parseShort=function(){var n=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,n};C.prototype.parseF2Dot14=function(){var n=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,n};C.prototype.parseULong=function(){var n=j5(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,n};C.prototype.parseOffset32=C.prototype.parseULong;C.prototype.parseFixed=function(){var n=i7(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,n};C.prototype.parseString=function(n){var e=this.data,t=this.offset+this.relativeOffset,c="";this.relativeOffset+=n;for(var a=0;a<n;a++)c+=String.fromCharCode(e.getUint8(t+a));return c};C.prototype.parseTag=function(){return this.parseString(4)};C.prototype.parseLongDateTime=function(){var n=j5(this.data,this.offset+this.relativeOffset+4);return n-=2082844800,this.relativeOffset+=8,n};C.prototype.parseVersion=function(n){var e=D3(this.data,this.offset+this.relativeOffset),t=D3(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,n===void 0&&(n=4096),e+t/n/10};C.prototype.skip=function(n,e){e===void 0&&(e=1),this.relativeOffset+=_9[n]*e};C.prototype.parseULongList=function(n){n===void 0&&(n=this.parseULong());for(var e=new Array(n),t=this.data,c=this.offset+this.relativeOffset,a=0;a<n;a++)e[a]=t.getUint32(c),c+=4;return this.relativeOffset+=n*4,e};C.prototype.parseOffset16List=C.prototype.parseUShortList=function(n){n===void 0&&(n=this.parseUShort());for(var e=new Array(n),t=this.data,c=this.offset+this.relativeOffset,a=0;a<n;a++)e[a]=t.getUint16(c),c+=2;return this.relativeOffset+=n*2,e};C.prototype.parseShortList=function(n){for(var e=new Array(n),t=this.data,c=this.offset+this.relativeOffset,a=0;a<n;a++)e[a]=t.getInt16(c),c+=2;return this.relativeOffset+=n*2,e};C.prototype.parseByteList=function(n){for(var e=new Array(n),t=this.data,c=this.offset+this.relativeOffset,a=0;a<n;a++)e[a]=t.getUint8(c++);return this.relativeOffset+=n,e};C.prototype.parseList=function(n,e){e||(e=n,n=this.parseUShort());for(var t=new Array(n),c=0;c<n;c++)t[c]=e.call(this);return t};C.prototype.parseList32=function(n,e){e||(e=n,n=this.parseULong());for(var t=new Array(n),c=0;c<n;c++)t[c]=e.call(this);return t};C.prototype.parseRecordList=function(n,e){e||(e=n,n=this.parseUShort());for(var t=new Array(n),c=Object.keys(e),a=0;a<n;a++){for(var r={},s=0;s<c.length;s++){var i=c[s],l=e[i];r[i]=l.call(this)}t[a]=r}return t};C.prototype.parseRecordList32=function(n,e){e||(e=n,n=this.parseULong());for(var t=new Array(n),c=Object.keys(e),a=0;a<n;a++){for(var r={},s=0;s<c.length;s++){var i=c[s],l=e[i];r[i]=l.call(this)}t[a]=r}return t};C.prototype.parseStruct=function(n){if(typeof n=="function")return n.call(this);for(var e=Object.keys(n),t={},c=0;c<e.length;c++){var a=e[c],r=n[a];t[a]=r.call(this)}return t};C.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}};C.prototype.parseValueRecordList=function(){for(var n=this.parseUShort(),e=this.parseUShort(),t=new Array(e),c=0;c<e;c++)t[c]=this.parseValueRecord(n);return t};C.prototype.parsePointer=function(n){var e=this.parseOffset16();if(e>0)return new C(this.data,this.offset+e).parseStruct(n)};C.prototype.parsePointer32=function(n){var e=this.parseOffset32();if(e>0)return new C(this.data,this.offset+e).parseStruct(n)};C.prototype.parseListOfLists=function(n){for(var e=this.parseOffset16List(),t=e.length,c=this.relativeOffset,a=new Array(t),r=0;r<t;r++){var s=e[r];if(s===0){a[r]=void 0;continue}if(this.relativeOffset=s,n){for(var i=this.parseOffset16List(),l=new Array(i.length),o=0;o<i.length;o++)this.relativeOffset=s+i[o],l[o]=n.call(this);a[r]=l}else a[r]=this.parseUShortList()}return this.relativeOffset=c,a};C.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 c=new Array(t),a=0;a<t;a++)c[a]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:c}}throw new Error("0x"+n.toString(16)+": Coverage format must be 1 or 2.")};C.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:C.uShort,end:C.uShort,classId:C.uShort})};throw new Error("0x"+n.toString(16)+": ClassDef format must be 1 or 2.")};C.list=function(n,e){return function(){return this.parseList(n,e)}};C.list32=function(n,e){return function(){return this.parseList32(n,e)}};C.recordList=function(n,e){return function(){return this.parseRecordList(n,e)}};C.recordList32=function(n,e){return function(){return this.parseRecordList32(n,e)}};C.pointer=function(n){return function(){return this.parsePointer(n)}};C.pointer32=function(n){return function(){return this.parsePointer32(n)}};C.tag=C.prototype.parseTag;C.byte=C.prototype.parseByte;C.uShort=C.offset16=C.prototype.parseUShort;C.uShortList=C.prototype.parseUShortList;C.uLong=C.offset32=C.prototype.parseULong;C.uLongList=C.prototype.parseULongList;C.struct=C.prototype.parseStruct;C.coverage=C.prototype.parseCoverage;C.classDef=C.prototype.parseClassDef;var z6={reserved:C.uShort,reqFeatureIndex:C.uShort,featureIndexes:C.uShortList};C.prototype.parseScriptList=function(){return this.parsePointer(C.recordList({tag:C.tag,script:C.pointer({defaultLangSys:C.pointer(z6),langSysRecords:C.recordList({tag:C.tag,langSys:C.pointer(z6)})})}))||[]};C.prototype.parseFeatureList=function(){return this.parsePointer(C.recordList({tag:C.tag,feature:C.pointer({featureParams:C.offset16,lookupListIndexes:C.uShortList})}))||[]};C.prototype.parseLookupList=function(n){return this.parsePointer(C.list(C.pointer(function(){var e=this.parseUShort();W.argument(1<=e&&e<=9,"GPOS/GSUB lookup type "+e+" unknown.");var t=this.parseUShort(),c=t&16;return{lookupType:e,lookupFlag:t,subtables:this.parseList(C.pointer(n[e])),markFilteringSet:c?this.parseUShort():void 0}})))||[]};C.prototype.parseFeatureVariationsList=function(){return this.parsePointer32(function(){var n=this.parseUShort(),e=this.parseUShort();W.argument(n===1&&e<1,"GPOS/GSUB feature variations table unknown.");var t=this.parseRecordList32({conditionSetOffset:C.offset32,featureTableSubstitutionOffset:C.offset32});return t})||[]};var q={getByte:x6,getCard8:x6,getUShort:D3,getCard16:D3,getShort:q9,getULong:j5,getFixed:i7,getTag:U9,getOffset:N9,getBytes:B9,bytesToString:$9,Parser:C};function G9(n,e){e.parseUShort(),n.length=e.parseULong(),n.language=e.parseULong();var t;n.groupCount=t=e.parseULong(),n.glyphIndexMap={};for(var c=0;c<t;c+=1)for(var a=e.parseULong(),r=e.parseULong(),s=e.parseULong(),i=a;i<=r;i+=1)n.glyphIndexMap[i]=s,s++}function j9(n,e,t,c,a){n.length=e.parseUShort(),n.language=e.parseUShort();var r;n.segCount=r=e.parseUShort()>>1,e.skip("uShort",3),n.glyphIndexMap={};for(var s=new q.Parser(t,c+a+14),i=new q.Parser(t,c+a+16+r*2),l=new q.Parser(t,c+a+16+r*4),o=new q.Parser(t,c+a+16+r*6),h=c+a+16+r*8,f=0;f<r-1;f+=1)for(var u=void 0,d=s.parseUShort(),p=i.parseUShort(),m=l.parseShort(),v=o.parseUShort(),g=p;g<=d;g+=1)v!==0?(h=o.offset+o.relativeOffset-2,h+=v,h+=(g-p)*2,u=q.getUShort(t,h),u!==0&&(u=u+m&65535)):u=g+m&65535,n.glyphIndexMap[g]=u}function W9(n,e){var t={};t.version=q.getUShort(n,e),W.argument(t.version===0,"cmap table version should be 0."),t.numTables=q.getUShort(n,e+2);for(var c=-1,a=t.numTables-1;a>=0;a-=1){var r=q.getUShort(n,e+4+a*8),s=q.getUShort(n,e+4+a*8+2);if(r===3&&(s===0||s===1||s===10)||r===0&&(s===0||s===1||s===2||s===3||s===4)){c=q.getULong(n,e+4+a*8+4);break}}if(c===-1)throw new Error("No valid cmap sub-tables found.");var i=new q.Parser(n,e+c);if(t.format=i.parseUShort(),t.format===12)G9(t,i);else if(t.format===4)j9(t,i,n,e,c);else throw new Error("Only format 4 and 12 cmap tables are supported (found format "+t.format+").");return t}function X9(n,e,t){n.segments.push({end:e,start:e,delta:-(e-t),offset:0,glyphIndex:t})}function Z9(n){n.segments.push({end:65535,start:65535,delta:1,offset:0})}function Y9(n){var e=!0,t;for(t=n.length-1;t>0;t-=1){var c=n.get(t);if(c.unicode>65535){console.log("Adding CMAP format 12 (needed!)"),e=!1;break}}var a=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:e?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:e?12:20}];e||(a=a.concat([{name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}])),a=a.concat([{name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);var r=new O.Table("cmap",a);for(r.segments=[],t=0;t<n.length;t+=1){for(var s=n.get(t),i=0;i<s.unicodes.length;i+=1)X9(r,s.unicodes[i],t);r.segments=r.segments.sort(function(b,y){return b.start-y.start})}Z9(r);var l=r.segments.length,o=0,h=[],f=[],u=[],d=[],p=[],m=[];for(t=0;t<l;t+=1){var v=r.segments[t];v.end<=65535&&v.start<=65535?(h=h.concat({name:"end_"+t,type:"USHORT",value:v.end}),f=f.concat({name:"start_"+t,type:"USHORT",value:v.start}),u=u.concat({name:"idDelta_"+t,type:"SHORT",value:v.delta}),d=d.concat({name:"idRangeOffset_"+t,type:"USHORT",value:v.offset}),v.glyphId!==void 0&&(p=p.concat({name:"glyph_"+t,type:"USHORT",value:v.glyphId}))):o+=1,!e&&v.glyphIndex!==void 0&&(m=m.concat({name:"cmap12Start_"+t,type:"ULONG",value:v.start}),m=m.concat({name:"cmap12End_"+t,type:"ULONG",value:v.end}),m=m.concat({name:"cmap12Glyph_"+t,type:"ULONG",value:v.glyphIndex}))}if(r.segCountX2=(l-o)*2,r.searchRange=Math.pow(2,Math.floor(Math.log(l-o)/Math.log(2)))*2,r.entrySelector=Math.log(r.searchRange/2)/Math.log(2),r.rangeShift=r.segCountX2-r.searchRange,r.fields=r.fields.concat(h),r.fields.push({name:"reservedPad",type:"USHORT",value:0}),r.fields=r.fields.concat(f),r.fields=r.fields.concat(u),r.fields=r.fields.concat(d),r.fields=r.fields.concat(p),r.cmap4Length=14+h.length*2+2+f.length*2+u.length*2+d.length*2+p.length*2,!e){var g=16+m.length*4;r.cmap12Offset=20+r.cmap4Length,r.fields=r.fields.concat([{name:"cmap12Format",type:"USHORT",value:12},{name:"cmap12Reserved",type:"USHORT",value:0},{name:"cmap12Length",type:"ULONG",value:g},{name:"cmap12Language",type:"ULONG",value:0},{name:"cmap12nGroups",type:"ULONG",value:m.length/3}]),r.fields=r.fields.concat(m)}return r}var l7={parse:W9,make:Y9},T3=[".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"],K9=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],J9=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],t2=[".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 o7(n){this.font=n}o7.prototype.charToGlyphIndex=function(n){var e=n.codePointAt(0),t=this.font.glyphs;if(t){for(var c=0;c<t.length;c+=1)for(var a=t.get(c),r=0;r<a.unicodes.length;r+=1)if(a.unicodes[r]===e)return c}return null};function h7(n){this.cmap=n}h7.prototype.charToGlyphIndex=function(n){return this.cmap.glyphIndexMap[n.codePointAt(0)]||0};function R3(n,e){this.encoding=n,this.charset=e}R3.prototype.charToGlyphIndex=function(n){var e=n.codePointAt(0),t=this.encoding[e];return this.charset.indexOf(t)};function W5(n){switch(n.version){case 1:this.names=t2.slice();break;case 2:this.names=new Array(n.numberOfGlyphs);for(var e=0;e<n.numberOfGlyphs;e++)n.glyphNameIndex[e]<t2.length?this.names[e]=t2[n.glyphNameIndex[e]]:this.names[e]=n.names[n.glyphNameIndex[e]-t2.length];break;case 2.5:this.names=new Array(n.numberOfGlyphs);for(var t=0;t<n.numberOfGlyphs;t++)this.names[t]=t2[t+n.glyphNameIndex[t]];break;case 3:this.names=[];break;default:this.names=[];break}}W5.prototype.nameToGlyphIndex=function(n){return this.names.indexOf(n)};W5.prototype.glyphIndexToName=function(n){return this.names[n]};function Q9(n){for(var e,t=n.tables.cmap.glyphIndexMap,c=Object.keys(t),a=0;a<c.length;a+=1){var r=c[a],s=t[r];e=n.glyphs.get(s),e.addUnicode(parseInt(r))}for(var i=0;i<n.glyphs.length;i+=1)e=n.glyphs.get(i),n.cffEncoding?n.isCIDFont?e.name="gid"+i:e.name=n.cffEncoding.charset[i]:n.glyphNames.names&&(e.name=n.glyphNames.glyphIndexToName(i))}function ee(n){n._IndexToUnicodeMap={};for(var e=n.tables.cmap.glyphIndexMap,t=Object.keys(e),c=0;c<t.length;c+=1){var a=t[c],r=e[a];n._IndexToUnicodeMap[r]===void 0?n._IndexToUnicodeMap[r]={unicodes:[parseInt(a)]}:n._IndexToUnicodeMap[r].unicodes.push(parseInt(a))}}function te(n,e){e.lowMemory?ee(n):Q9(n)}function ne(n,e,t,c,a){n.beginPath(),n.moveTo(e,t),n.lineTo(c,a),n.stroke()}var e2={line:ne};function ce(n,e){var t=e||new E1;return{configurable:!0,get:function(){return typeof t=="function"&&(t=t()),t},set:function(c){t=c}}}function s0(n){this.bindConstructorValues(n)}s0.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",ce(this,n.path))};s0.prototype.addUnicode=function(n){this.unicodes.length===0&&(this.unicode=n),this.unicodes.push(n)};s0.prototype.getBoundingBox=function(){return this.path.getBoundingBox()};s0.prototype.getPath=function(n,e,t,c,a){n=n!==void 0?n:0,e=e!==void 0?e:0,t=t!==void 0?t:72;var r,s;c||(c={});var i=c.xScale,l=c.yScale;if(c.hinting&&a&&a.hinting&&(s=this.path&&a.hinting.exec(this,t)),s)r=a.hinting.getCommands(s),n=Math.round(n),e=Math.round(e),i=l=1;else{r=this.path.commands;var o=1/(this.path.unitsPerEm||1e3)*t;i===void 0&&(i=o),l===void 0&&(l=o)}for(var h=new E1,f=0;f<r.length;f+=1){var u=r[f];u.type==="M"?h.moveTo(n+u.x*i,e+-u.y*l):u.type==="L"?h.lineTo(n+u.x*i,e+-u.y*l):u.type==="Q"?h.quadraticCurveTo(n+u.x1*i,e+-u.y1*l,n+u.x*i,e+-u.y*l):u.type==="C"?h.curveTo(n+u.x1*i,e+-u.y1*l,n+u.x2*i,e+-u.y2*l,n+u.x*i,e+-u.y*l):u.type==="Z"&&h.closePath()}return h};s0.prototype.getContours=function(){if(this.points===void 0)return[];for(var n=[],e=[],t=0;t<this.points.length;t+=1){var c=this.points[t];e.push(c),c.lastPointOfContour&&(n.push(e),e=[])}return W.argument(e.length===0,"There are still points left in the current contour."),n};s0.prototype.getMetrics=function(){for(var n=this.path.commands,e=[],t=[],c=0;c<n.length;c+=1){var a=n[c];a.type!=="Z"&&(e.push(a.x),t.push(a.y)),(a.type==="Q"||a.type==="C")&&(e.push(a.x1),t.push(a.y1)),a.type==="C"&&(e.push(a.x2),t.push(a.y2))}var r={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(r.xMin)||(r.xMin=0),isFinite(r.xMax)||(r.xMax=this.advanceWidth),isFinite(r.yMin)||(r.yMin=0),isFinite(r.yMax)||(r.yMax=0),r.rightSideBearing=this.advanceWidth-r.leftSideBearing-(r.xMax-r.xMin),r};s0.prototype.draw=function(n,e,t,c,a){this.getPath(e,t,c,a).draw(n)};s0.prototype.drawPoints=function(n,e,t,c){function a(f,u,d,p){n.beginPath();for(var m=0;m<f.length;m+=1)n.moveTo(u+f[m].x*p,d+f[m].y*p),n.arc(u+f[m].x*p,d+f[m].y*p,2,0,Math.PI*2,!1);n.closePath(),n.fill()}e=e!==void 0?e:0,t=t!==void 0?t:0,c=c!==void 0?c:24;for(var r=1/this.path.unitsPerEm*c,s=[],i=[],l=this.path,o=0;o<l.commands.length;o+=1){var h=l.commands[o];h.x!==void 0&&s.push({x:h.x,y:-h.y}),h.x1!==void 0&&i.push({x:h.x1,y:-h.y1}),h.x2!==void 0&&i.push({x:h.x2,y:-h.y2})}n.fillStyle="blue",a(s,e,t,r),n.fillStyle="red",a(i,e,t,r)};s0.prototype.drawMetrics=function(n,e,t,c){var a;e=e!==void 0?e:0,t=t!==void 0?t:0,c=c!==void 0?c:24,a=1/this.path.unitsPerEm*c,n.lineWidth=1,n.strokeStyle="black",e2.line(n,e,-1e4,e,1e4),e2.line(n,-1e4,t,1e4,t);var r=this.xMin||0,s=this.yMin||0,i=this.xMax||0,l=this.yMax||0,o=this.advanceWidth||0;n.strokeStyle="blue",e2.line(n,e+r*a,-1e4,e+r*a,1e4),e2.line(n,e+i*a,-1e4,e+i*a,1e4),e2.line(n,-1e4,t+-s*a,1e4,t+-s*a),e2.line(n,-1e4,t+-l*a,1e4,t+-l*a),n.strokeStyle="green",e2.line(n,e+o*a,-1e4,e+o*a,1e4)};function P3(n,e,t){Object.defineProperty(n,e,{get:function(){return n.path,n[t]},set:function(c){n[t]=c},enumerable:!0,configurable:!0})}function X5(n,e){if(this.font=n,this.glyphs={},Array.isArray(e))for(var t=0;t<e.length;t++){var c=e[t];c.path.unitsPerEm=n.unitsPerEm,this.glyphs[t]=c}this.length=e&&e.length||0}X5.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 c=0;c<t.unicodes.length;c++)e.addUnicode(t.unicodes[c]);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]};X5.prototype.push=function(n,e){this.glyphs[n]=e,this.length++};function ae(n,e){return new s0({index:e,font:n})}function re(n,e,t,c,a,r){return function(){var s=new s0({index:e,font:n});return s.path=function(){t(s,c,a);var i=r(n.glyphs,s);return i.unitsPerEm=n.unitsPerEm,i},P3(s,"xMin","_xMin"),P3(s,"xMax","_xMax"),P3(s,"yMin","_yMin"),P3(s,"yMax","_yMax"),s}}function se(n,e,t,c){return function(){var a=new s0({index:e,font:n});return a.path=function(){var r=t(n,a,c);return r.unitsPerEm=n.unitsPerEm,r},a}}var L0={GlyphSet:X5,glyphLoader:ae,ttfGlyphLoader:re,cffGlyphLoader:se};function u7(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(!u7(n[t],e[t]))return!1;return!0}else return!1}function R5(n){var e;return n.length<1240?e=107:n.length<33900?e=1131:e=32768,e}function B0(n,e,t){var c=[],a=[],r=q.getCard16(n,e),s,i;if(r!==0){var l=q.getByte(n,e+2);s=e+(r+1)*l+2;for(var o=e+3,h=0;h<r+1;h+=1)c.push(q.getOffset(n,o,l)),o+=l;i=s+c[r]}else i=e+2;for(var f=0;f<c.length-1;f+=1){var u=q.getBytes(n,s+c[f],s+c[f+1]);t&&(u=t(u)),a.push(u)}return{objects:a,startOffset:e,endOffset:i}}function ie(n,e){var t=[],c=q.getCard16(n,e),a,r;if(c!==0){var s=q.getByte(n,e+2);a=e+(c+1)*s+2;for(var i=e+3,l=0;l<c+1;l+=1)t.push(q.getOffset(n,i,s)),i+=s;r=a+t[c]}else r=e+2;return{offsets:t,startOffset:e,endOffset:r}}function le(n,e,t,c,a){var r=q.getCard16(t,c),s=0;if(r!==0){var i=q.getByte(t,c+2);s=c+(r+1)*i+2}var l=q.getBytes(t,s+e[n],s+e[n+1]);return a&&(l=a(l)),l}function oe(n){for(var e="",t=15,c=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];;){var a=n.parseByte(),r=a>>4,s=a&15;if(r===t||(e+=c[r],s===t))break;e+=c[s]}return parseFloat(e)}function he(n,e){var t,c,a,r;if(e===28)return t=n.parseByte(),c=n.parseByte(),t<<8|c;if(e===29)return t=n.parseByte(),c=n.parseByte(),a=n.parseByte(),r=n.parseByte(),t<<24|c<<16|a<<8|r;if(e===30)return oe(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 ue(n){for(var e={},t=0;t<n.length;t+=1){var c=n[t][0],a=n[t][1],r=void 0;if(a.length===1?r=a[0]:r=a,e.hasOwnProperty(c)&&!isNaN(e[c]))throw new Error("Object "+e+" already has key "+c);e[c]=r}return e}function f7(n,e,t){e=e!==void 0?e:0;var c=new q.Parser(n,e),a=[],r=[];for(t=t!==void 0?t:n.length;c.relativeOffset<t;){var s=c.parseByte();s<=21?(s===12&&(s=1200+c.parseByte()),a.push([s,r]),r=[]):r.push(he(c,s))}return ue(a)}function $2(n,e){return e<=390?e=T3[e]:e=n[e-391],e}function d7(n,e,t){for(var c={},a,r=0;r<e.length;r+=1){var s=e[r];if(Array.isArray(s.type)){var i=[];i.length=s.type.length;for(var l=0;l<s.type.length;l++)a=n[s.op]!==void 0?n[s.op][l]:void 0,a===void 0&&(a=s.value!==void 0&&s.value[l]!==void 0?s.value[l]:null),s.type[l]==="SID"&&(a=$2(t,a)),i[l]=a;c[s.name]=i}else a=n[s.op],a===void 0&&(a=s.value!==void 0?s.value:null),s.type==="SID"&&(a=$2(t,a)),c[s.name]=a}return c}function fe(n,e){var t={};return t.formatMajor=q.getCard8(n,e),t.formatMinor=q.getCard8(n,e+1),t.size=q.getCard8(n,e+2),t.offsetSize=q.getCard8(n,e+3),t.startOffset=e,t.endOffset=e+4,t}var p7=[{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"}],m7=[{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 de(n,e){var t=f7(n,0,n.byteLength);return d7(t,p7,e)}function v7(n,e,t,c){var a=f7(n,e,t);return d7(a,m7,c)}function w6(n,e,t,c){for(var a=[],r=0;r<t.length;r+=1){var s=new DataView(new Uint8Array(t[r]).buffer),i=de(s,c);i._subrs=[],i._subrsBias=0,i._defaultWidthX=0,i._nominalWidthX=0;var l=i.private[0],o=i.private[1];if(l!==0&&o!==0){var h=v7(n,o+e,l,c);if(i._defaultWidthX=h.defaultWidthX,i._nominalWidthX=h.nominalWidthX,h.subrs!==0){var f=o+h.subrs,u=B0(n,f+e);i._subrs=u.objects,i._subrsBias=R5(i._subrs)}i._privateDict=h}a.push(i)}return a}function pe(n,e,t,c){var a,r,s=new q.Parser(n,e);t-=1;var i=[".notdef"],l=s.parseCard8();if(l===0)for(var o=0;o<t;o+=1)a=s.parseSID(),i.push($2(c,a));else if(l===1)for(;i.length<=t;){a=s.parseSID(),r=s.parseCard8();for(var h=0;h<=r;h+=1)i.push($2(c,a)),a+=1}else if(l===2)for(;i.length<=t;){a=s.parseSID(),r=s.parseCard16();for(var f=0;f<=r;f+=1)i.push($2(c,a)),a+=1}else throw new Error("Unknown charset format "+l);return i}function me(n,e,t){var c,a={},r=new q.Parser(n,e),s=r.parseCard8();if(s===0)for(var i=r.parseCard8(),l=0;l<i;l+=1)c=r.parseCard8(),a[c]=l;else if(s===1){var o=r.parseCard8();c=1;for(var h=0;h<o;h+=1)for(var f=r.parseCard8(),u=r.parseCard8(),d=f;d<=f+u;d+=1)a[d]=c,c+=1}else throw new Error("Unknown encoding format "+s);return new R3(a,t)}function k6(n,e,t){var c,a,r,s,i=new E1,l=[],o=0,h=!1,f=!1,u=0,d=0,p,m,v,g;if(n.isCIDFont){var b=n.tables.cff.topDict._fdSelect[e.index],y=n.tables.cff.topDict._fdArray[b];p=y._subrs,m=y._subrsBias,v=y._defaultWidthX,g=y._nominalWidthX}else p=n.tables.cff.topDict._subrs,m=n.tables.cff.topDict._subrsBias,v=n.tables.cff.topDict._defaultWidthX,g=n.tables.cff.topDict._nominalWidthX;var w=v;function k(A,E){f&&i.closePath(),i.moveTo(A,E),f=!0}function P(){var A;A=l.length%2!==0,A&&!h&&(w=l.shift()+g),o+=l.length>>1,l.length=0,h=!0}function S(A){for(var E,z,I,$,F,_,Y,N,i1,h1,U,c1,X=0;X<A.length;){var f1=A[X];switch(X+=1,f1){case 1:P();break;case 3:P();break;case 4:l.length>1&&!h&&(w=l.shift()+g,h=!0),d+=l.pop(),k(u,d);break;case 5:for(;l.length>0;)u+=l.shift(),d+=l.shift(),i.lineTo(u,d);break;case 6:for(;l.length>0&&(u+=l.shift(),i.lineTo(u,d),l.length!==0);)d+=l.shift(),i.lineTo(u,d);break;case 7:for(;l.length>0&&(d+=l.shift(),i.lineTo(u,d),l.length!==0);)u+=l.shift(),i.lineTo(u,d);break;case 8:for(;l.length>0;)c=u+l.shift(),a=d+l.shift(),r=c+l.shift(),s=a+l.shift(),u=r+l.shift(),d=s+l.shift(),i.curveTo(c,a,r,s,u,d);break;case 10:F=l.pop()+m,_=p[F],_&&S(_);break;case 11:return;case 12:switch(f1=A[X],X+=1,f1){case 35:c=u+l.shift(),a=d+l.shift(),r=c+l.shift(),s=a+l.shift(),Y=r+l.shift(),N=s+l.shift(),i1=Y+l.shift(),h1=N+l.shift(),U=i1+l.shift(),c1=h1+l.shift(),u=U+l.shift(),d=c1+l.shift(),l.shift(),i.curveTo(c,a,r,s,Y,N),i.curveTo(i1,h1,U,c1,u,d);break;case 34:c=u+l.shift(),a=d,r=c+l.shift(),s=a+l.shift(),Y=r+l.shift(),N=s,i1=Y+l.shift(),h1=s,U=i1+l.shift(),c1=d,u=U+l.shift(),i.curveTo(c,a,r,s,Y,N),i.curveTo(i1,h1,U,c1,u,d);break;case 36:c=u+l.shift(),a=d+l.shift(),r=c+l.shift(),s=a+l.shift(),Y=r+l.shift(),N=s,i1=Y+l.shift(),h1=s,U=i1+l.shift(),c1=h1+l.shift(),u=U+l.shift(),i.curveTo(c,a,r,s,Y,N),i.curveTo(i1,h1,U,c1,u,d);break;case 37:c=u+l.shift(),a=d+l.shift(),r=c+l.shift(),s=a+l.shift(),Y=r+l.shift(),N=s+l.shift(),i1=Y+l.shift(),h1=N+l.shift(),U=i1+l.shift(),c1=h1+l.shift(),Math.abs(U-u)>Math.abs(c1-d)?u=U+l.shift():d=c1+l.shift(),i.curveTo(c,a,r,s,Y,N),i.curveTo(i1,h1,U,c1,u,d);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+f1),l.length=0}break;case 14:l.length>0&&!h&&(w=l.shift()+g,h=!0),f&&(i.closePath(),f=!1);break;case 18:P();break;case 19:case 20:P(),X+=o+7>>3;break;case 21:l.length>2&&!h&&(w=l.shift()+g,h=!0),d+=l.pop(),u+=l.pop(),k(u,d);break;case 22:l.length>1&&!h&&(w=l.shift()+g,h=!0),u+=l.pop(),k(u,d);break;case 23:P();break;case 24:for(;l.length>2;)c=u+l.shift(),a=d+l.shift(),r=c+l.shift(),s=a+l.shift(),u=r+l.shift(),d=s+l.shift(),i.curveTo(c,a,r,s,u,d);u+=l.shift(),d+=l.shift(),i.lineTo(u,d);break;case 25:for(;l.length>6;)u+=l.shift(),d+=l.shift(),i.lineTo(u,d);c=u+l.shift(),a=d+l.shift(),r=c+l.shift(),s=a+l.shift(),u=r+l.shift(),d=s+l.shift(),i.curveTo(c,a,r,s,u,d);break;case 26:for(l.length%2&&(u+=l.shift());l.length>0;)c=u,a=d+l.shift(),r=c+l.shift(),s=a+l.shift(),u=r,d=s+l.shift(),i.curveTo(c,a,r,s,u,d);break;case 27:for(l.length%2&&(d+=l.shift());l.length>0;)c=u+l.shift(),a=d,r=c+l.shift(),s=a+l.shift(),u=r+l.shift(),d=s,i.curveTo(c,a,r,s,u,d);break;case 28:E=A[X],z=A[X+1],l.push((E<<24|z<<16)>>16),X+=2;break;case 29:F=l.pop()+n.gsubrsBias,_=n.gsubrs[F],_&&S(_);break;case 30:for(;l.length>0&&(c=u,a=d+l.shift(),r=c+l.shift(),s=a+l.shift(),u=r+l.shift(),d=s+(l.length===1?l.shift():0),i.curveTo(c,a,r,s,u,d),l.length!==0);)c=u+l.shift(),a=d,r=c+l.shift(),s=a+l.shift(),d=s+l.shift(),u=r+(l.length===1?l.shift():0),i.curveTo(c,a,r,s,u,d);break;case 31:for(;l.length>0&&(c=u+l.shift(),a=d,r=c+l.shift(),s=a+l.shift(),d=s+l.shift(),u=r+(l.length===1?l.shift():0),i.curveTo(c,a,r,s,u,d),l.length!==0);)c=u,a=d+l.shift(),r=c+l.shift(),s=a+l.shift(),u=r+l.shift(),d=s+(l.length===1?l.shift():0),i.curveTo(c,a,r,s,u,d);break;default:f1<32?console.log("Glyph "+e.index+": unknown operator "+f1):f1<247?l.push(f1-139):f1<251?(E=A[X],X+=1,l.push((f1-247)*256+E+108)):f1<255?(E=A[X],X+=1,l.push(-(f1-251)*256-E-108)):(E=A[X],z=A[X+1],I=A[X+2],$=A[X+3],X+=4,l.push((E<<24|z<<16|I<<8|$)/65536))}}}return S(t),e.advanceWidth=w,i}function ve(n,e,t,c){var a=[],r,s=new q.Parser(n,e),i=s.parseCard8();if(i===0)for(var l=0;l<t;l++){if(r=s.parseCard8(),r>=c)throw new Error("CFF table CID Font FDSelect has bad FD index value "+r+" (FD count "+c+")");a.push(r)}else if(i===3){var o=s.parseCard16(),h=s.parseCard16();if(h!==0)throw new Error("CFF Table CID Font FDSelect format 3 range has bad initial GID "+h);for(var f,u=0;u<o;u++){if(r=s.parseCard8(),f=s.parseCard16(),r>=c)throw new Error("CFF table CID Font FDSelect has bad FD index value "+r+" (FD count "+c+")");if(f>t)throw new Error("CFF Table CID Font FDSelect format 3 range has bad GID "+f);for(;h<f;h++)a.push(r);h=f}if(f!==t)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final GID "+f)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+i);return a}function ge(n,e,t,c){t.tables.cff={};var a=fe(n,e),r=B0(n,a.endOffset,q.bytesToString),s=B0(n,r.endOffset),i=B0(n,s.endOffset,q.bytesToString),l=B0(n,i.endOffset);t.gsubrs=l.objects,t.gsubrsBias=R5(t.gsubrs);var o=w6(n,e,s.objects,i.objects);if(o.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+o.length);var h=o[0];if(t.tables.cff.topDict=h,h._privateDict&&(t.defaultWidthX=h._privateDict.defaultWidthX,t.nominalWidthX=h._privateDict.nominalWidthX),h.ros[0]!==void 0&&h.ros[1]!==void 0&&(t.isCIDFont=!0),t.isCIDFont){var f=h.fdArray,u=h.fdSelect;if(f===0||u===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");f+=e;var d=B0(n,f),p=w6(n,e,d.objects,i.objects);h._fdArray=p,u+=e,h._fdSelect=ve(n,u,t.numGlyphs,p.length)}var m=e+h.private[1],v=v7(n,m,h.private[0],i.objects);if(t.defaultWidthX=v.defaultWidthX,t.nominalWidthX=v.nominalWidthX,v.subrs!==0){var g=m+v.subrs,b=B0(n,g);t.subrs=b.objects,t.subrsBias=R5(t.subrs)}else t.subrs=[],t.subrsBias=0;var y;c.lowMemory?(y=ie(n,e+h.charStrings),t.nGlyphs=y.offsets.length):(y=B0(n,e+h.charStrings),t.nGlyphs=y.objects.length);var w=pe(n,e+h.charset,t.nGlyphs,i.objects);if(h.encoding===0?t.cffEncoding=new R3(K9,w):h.encoding===1?t.cffEncoding=new R3(J9,w):t.cffEncoding=me(n,e+h.encoding,w),t.encoding=t.encoding||t.cffEncoding,t.glyphs=new L0.GlyphSet(t),c.lowMemory)t._push=function(S){var A=le(S,y.offsets,n,e+h.charStrings);t.glyphs.push(S,L0.cffGlyphLoader(t,S,k6,A))};else for(var k=0;k<t.nGlyphs;k+=1){var P=y.objects[k];t.glyphs.push(k,L0.cffGlyphLoader(t,k,k6,P))}}function g7(n,e){var t,c=T3.indexOf(n);return c>=0&&(t=c),c=e.indexOf(n),c>=0?t=c+T3.length:(t=T3.length+e.length,e.push(n)),t}function ye(){return new O.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 be(n){var e=new O.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 y7(n,e,t){for(var c={},a=0;a<n.length;a+=1){var r=n[a],s=e[r.name];s!==void 0&&!u7(s,r.value)&&(r.type==="SID"&&(s=g7(s,t)),c[r.op]={name:r.name,type:r.type,value:s})}return c}function L6(n,e){var t=new O.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return t.dict=y7(p7,n,e),t}function S6(n){var e=new O.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return e.topDicts=[{name:"topDict_0",type:"TABLE",value:n}],e}function Me(n){var e=new O.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 xe(){return new O.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function ze(n,e){for(var t=new O.Record("Charsets",[{name:"format",type:"Card8",value:0}]),c=0;c<n.length;c+=1){var a=n[c],r=g7(a,e);t.fields.push({name:"glyph_"+c,type:"SID",value:r})}return t}function we(n){var e=[],t=n.path;e.push({name:"width",type:"NUMBER",value:n.advanceWidth});for(var c=0,a=0,r=0;r<t.commands.length;r+=1){var s=void 0,i=void 0,l=t.commands[r];if(l.type==="Q"){var o=.3333333333333333,h=2/3;l={type:"C",x:l.x,y:l.y,x1:Math.round(o*c+h*l.x1),y1:Math.round(o*a+h*l.y1),x2:Math.round(o*l.x+h*l.x1),y2:Math.round(o*l.y+h*l.y1)}}if(l.type==="M")s=Math.round(l.x-c),i=Math.round(l.y-a),e.push({name:"dx",type:"NUMBER",value:s}),e.push({name:"dy",type:"NUMBER",value:i}),e.push({name:"rmoveto",type:"OP",value:21}),c=Math.round(l.x),a=Math.round(l.y);else if(l.type==="L")s=Math.round(l.x-c),i=Math.round(l.y-a),e.push({name:"dx",type:"NUMBER",value:s}),e.push({name:"dy",type:"NUMBER",value:i}),e.push({name:"rlineto",type:"OP",value:5}),c=Math.round(l.x),a=Math.round(l.y);else if(l.type==="C"){var f=Math.round(l.x1-c),u=Math.round(l.y1-a),d=Math.round(l.x2-l.x1),p=Math.round(l.y2-l.y1);s=Math.round(l.x-l.x2),i=Math.round(l.y-l.y2),e.push({name:"dx1",type:"NUMBER",value:f}),e.push({name:"dy1",type:"NUMBER",value:u}),e.push({name:"dx2",type:"NUMBER",value:d}),e.push({name:"dy2",type:"NUMBER",value:p}),e.push({name:"dx",type:"NUMBER",value:s}),e.push({name:"dy",type:"NUMBER",value:i}),e.push({name:"rrcurveto",type:"OP",value:8}),c=Math.round(l.x),a=Math.round(l.y)}}return e.push({name:"endchar",type:"OP",value:14}),e}function ke(n){for(var e=new O.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]),t=0;t<n.length;t+=1){var c=n.get(t),a=we(c);e.charStrings.push({name:c.name,type:"CHARSTRING",value:a})}return e}function Le(n,e){var t=new O.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return t.dict=y7(m7,n,e),t}function Se(n,e){for(var t=new O.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"}]),c=1/e.unitsPerEm,a={version:e.version,fullName:e.fullName,familyName:e.familyName,weight:e.weightName,fontBBox:e.fontBBox||[0,0,0,0],fontMatrix:[c,0,0,c,0,0],charset:999,encoding:0,charStrings:999,private:[0,999]},r={},s=[],i,l=1;l<n.length;l+=1)i=n.get(l),s.push(i.name);var o=[];t.header=ye(),t.nameIndex=be([e.postScriptName]);var h=L6(a,o);t.topDictIndex=S6(h),t.globalSubrIndex=xe(),t.charsets=ze(s,o),t.charStringsIndex=ke(n),t.privateDict=Le(r,o),t.stringIndex=Me(o);var f=t.header.sizeOf()+t.nameIndex.sizeOf()+t.topDictIndex.sizeOf()+t.stringIndex.sizeOf()+t.globalSubrIndex.sizeOf();return a.charset=f,a.encoding=0,a.charStrings=a.charset+t.charsets.sizeOf(),a.private[1]=a.charStrings+t.charStringsIndex.sizeOf(),h=L6(a,o),t.topDictIndex=S6(h),t}var b7={parse:ge,make:Se};function Ae(n,e){var t={},c=new q.Parser(n,e);return t.version=c.parseVersion(),t.fontRevision=Math.round(c.parseFixed()*1e3)/1e3,t.checkSumAdjustment=c.parseULong(),t.magicNumber=c.parseULong(),W.argument(t.magicNumber===1594834165,"Font header has wrong magic number."),t.flags=c.parseUShort(),t.unitsPerEm=c.parseUShort(),t.created=c.parseLongDateTime(),t.modified=c.parseLongDateTime(),t.xMin=c.parseShort(),t.yMin=c.parseShort(),t.xMax=c.parseShort(),t.yMax=c.parseShort(),t.macStyle=c.parseUShort(),t.lowestRecPPEM=c.parseUShort(),t.fontDirectionHint=c.parseShort(),t.indexToLocFormat=c.parseShort(),t.glyphDataFormat=c.parseShort(),t}function Ce(n){var e=Math.round(new Date().getTime()/1e3)+2082844800,t=e;return n.createdTimestamp&&(t=n.createdTimestamp+2082844800),new O.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 M7={parse:Ae,make:Ce};function Pe(n,e){var t={},c=new q.Parser(n,e);return t.version=c.parseVersion(),t.ascender=c.parseShort(),t.descender=c.parseShort(),t.lineGap=c.parseShort(),t.advanceWidthMax=c.parseUShort(),t.minLeftSideBearing=c.parseShort(),t.minRightSideBearing=c.parseShort(),t.xMaxExtent=c.parseShort(),t.caretSlopeRise=c.parseShort(),t.caretSlopeRun=c.parseShort(),t.caretOffset=c.parseShort(),c.relativeOffset+=8,t.metricDataFormat=c.parseShort(),t.numberOfHMetrics=c.parseUShort(),t}function Ee(n){return new O.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 x7={parse:Pe,make:Ee};function Te(n,e,t,c,a){for(var r,s,i=new q.Parser(n,e),l=0;l<c;l+=1){l<t&&(r=i.parseUShort(),s=i.parseShort());var o=a.get(l);o.advanceWidth=r,o.leftSideBearing=s}}function Ie(n,e,t,c,a){n._hmtxTableData={};for(var r,s,i=new q.Parser(e,t),l=0;l<a;l+=1)l<c&&(r=i.parseUShort(),s=i.parseShort()),n._hmtxTableData[l]={advanceWidth:r,leftSideBearing:s}}function He(n,e,t,c,a,r,s){s.lowMemory?Ie(n,e,t,c,a):Te(e,t,c,a,r)}function Ve(n){for(var e=new O.Table("hmtx",[]),t=0;t<n.length;t+=1){var c=n.get(t),a=c.advanceWidth||0,r=c.leftSideBearing||0;e.fields.push({name:"advanceWidth_"+t,type:"USHORT",value:a}),e.fields.push({name:"leftSideBearing_"+t,type:"SHORT",value:r})}return e}var z7={parse:He,make:Ve};function Oe(n){for(var e=new O.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:n.length}]),t="",c=12+n.length*4,a=0;a<n.length;++a){var r=t.indexOf(n[a]);r<0&&(r=t.length,t+=n[a]),e.fields.push({name:"offset "+a,type:"USHORT",value:c+r}),e.fields.push({name:"length "+a,type:"USHORT",value:n[a].length})}return e.fields.push({name:"stringPool",type:"CHARARRAY",value:t}),e}function Fe(n,e){var t=new q.Parser(n,e),c=t.parseULong();W.argument(c===1,"Unsupported ltag table version."),t.skip("uLong",1);for(var a=t.parseULong(),r=[],s=0;s<a;s++){for(var i="",l=e+t.parseUShort(),o=t.parseUShort(),h=l;h<l+o;++h)i+=String.fromCharCode(n.getInt8(h));r.push(i)}return r}var w7={make:Oe,parse:Fe};function De(n,e){var t={},c=new q.Parser(n,e);return t.version=c.parseVersion(),t.numGlyphs=c.parseUShort(),t.version===1&&(t.maxPoints=c.parseUShort(),t.maxContours=c.parseUShort(),t.maxCompositePoints=c.parseUShort(),t.maxCompositeContours=c.parseUShort(),t.maxZones=c.parseUShort(),t.maxTwilightPoints=c.parseUShort(),t.maxStorage=c.parseUShort(),t.maxFunctionDefs=c.parseUShort(),t.maxInstructionDefs=c.parseUShort(),t.maxStackElements=c.parseUShort(),t.maxSizeOfInstructions=c.parseUShort(),t.maxComponentElements=c.parseUShort(),t.maxComponentDepth=c.parseUShort()),t}function Re(n){return new O.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:n}])}var k7={parse:De,make:Re},L7=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],S7={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"},qe={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},A7={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 Ue(n,e,t){switch(n){case 0:if(e===65535)return"und";if(t)return t[e];break;case 1:return S7[e];case 3:return A7[e]}}var q5="utf-16",Ne={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"},Be={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 C7(n,e,t){switch(n){case 0:return q5;case 1:return Be[t]||Ne[e];case 3:if(e===1||e===10)return q5;break}}function $e(n,e,t){for(var c={},a=new q.Parser(n,e),r=a.parseUShort(),s=a.parseUShort(),i=a.offset+a.parseUShort(),l=0;l<s;l++){var o=a.parseUShort(),h=a.parseUShort(),f=a.parseUShort(),u=a.parseUShort(),d=L7[u]||u,p=a.parseUShort(),m=a.parseUShort(),v=Ue(o,f,t),g=C7(o,h,f);if(g!==void 0&&v!==void 0){var b=void 0;if(g===q5?b=g2.UTF16(n,i+m,p):b=g2.MACSTRING(n,i+m,p,g),b){var y=c[d];y===void 0&&(y=c[d]={}),y[v]=b}}}var w=0;return r===1&&(w=a.parseUShort()),c}function S5(n){var e={};for(var t in n)e[n[t]]=parseInt(t);return e}function A6(n,e,t,c,a,r){return new O.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:c},{name:"length",type:"USHORT",value:a},{name:"offset",type:"USHORT",value:r}])}function _e(n,e){var t=n.length,c=e.length-t+1;e:for(var a=0;a<c;a++)for(;a<c;a++){for(var r=0;r<t;r++)if(e[a+r]!==n[r])continue e;return a}return-1}function C6(n,e){var t=_e(n,e);if(t<0){t=e.length;for(var c=0,a=n.length;c<a;++c)e.push(n[c])}return t}function Ge(n,e){var t,c=[],a={},r=S5(L7);for(var s in n){var i=r[s];if(i===void 0&&(i=s),t=parseInt(i),isNaN(t))throw new Error('Name table entry "'+s+'" does not exist, see nameTableNames for complete list.');a[t]=n[s],c.push(t)}for(var l=S5(S7),o=S5(A7),h=[],f=[],u=0;u<c.length;u++){t=c[u];var d=a[t];for(var p in d){var m=d[p],v=1,g=l[p],b=qe[g],y=C7(v,b,g),w=H.MACSTRING(m,y);w===void 0&&(v=0,g=e.indexOf(p),g<0&&(g=e.length,e.push(p)),b=4,w=H.UTF16(m));var k=C6(w,f);h.push(A6(v,b,g,t,w.length,k));var P=o[p];if(P!==void 0){var S=H.UTF16(m),A=C6(S,f);h.push(A6(3,1,P,t,S.length,A))}}}h.sort(function(I,$){return I.platformID-$.platformID||I.encodingID-$.encodingID||I.languageID-$.languageID||I.nameID-$.nameID});for(var E=new O.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:h.length},{name:"stringOffset",type:"USHORT",value:6+h.length*12}]),z=0;z<h.length;z++)E.fields.push({name:"record_"+z,type:"RECORD",value:h[z]});return E.fields.push({name:"strings",type:"LITERAL",value:f}),E}var P7={parse:$e,make:Ge},U5=[{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 je(n){for(var e=0;e<U5.length;e+=1){var t=U5[e];if(n>=t.begin&&n<t.end)return e}return-1}function We(n,e){var t={},c=new q.Parser(n,e);t.version=c.parseUShort(),t.xAvgCharWidth=c.parseShort(),t.usWeightClass=c.parseUShort(),t.usWidthClass=c.parseUShort(),t.fsType=c.parseUShort(),t.ySubscriptXSize=c.parseShort(),t.ySubscriptYSize=c.parseShort(),t.ySubscriptXOffset=c.parseShort(),t.ySubscriptYOffset=c.parseShort(),t.ySuperscriptXSize=c.parseShort(),t.ySuperscriptYSize=c.parseShort(),t.ySuperscriptXOffset=c.parseShort(),t.ySuperscriptYOffset=c.parseShort(),t.yStrikeoutSize=c.parseShort(),t.yStrikeoutPosition=c.parseShort(),t.sFamilyClass=c.parseShort(),t.panose=[];for(var a=0;a<10;a++)t.panose[a]=c.parseByte();return t.ulUnicodeRange1=c.parseULong(),t.ulUnicodeRange2=c.parseULong(),t.ulUnicodeRange3=c.parseULong(),t.ulUnicodeRange4=c.parseULong(),t.achVendID=String.fromCharCode(c.parseByte(),c.parseByte(),c.parseByte(),c.parseByte()),t.fsSelection=c.parseUShort(),t.usFirstCharIndex=c.parseUShort(),t.usLastCharIndex=c.parseUShort(),t.sTypoAscender=c.parseShort(),t.sTypoDescender=c.parseShort(),t.sTypoLineGap=c.parseShort(),t.usWinAscent=c.parseUShort(),t.usWinDescent=c.parseUShort(),t.version>=1&&(t.ulCodePageRange1=c.parseULong(),t.ulCodePageRange2=c.parseULong()),t.version>=2&&(t.sxHeight=c.parseShort(),t.sCapHeight=c.parseShort(),t.usDefaultChar=c.parseUShort(),t.usBreakChar=c.parseUShort(),t.usMaxContent=c.parseUShort()),t}function Xe(n){return new O.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 N5={parse:We,make:Xe,unicodeRanges:U5,getUnicodeRange:je};function Ze(n,e){var t={},c=new q.Parser(n,e);switch(t.version=c.parseVersion(),t.italicAngle=c.parseFixed(),t.underlinePosition=c.parseShort(),t.underlineThickness=c.parseShort(),t.isFixedPitch=c.parseULong(),t.minMemType42=c.parseULong(),t.maxMemType42=c.parseULong(),t.minMemType1=c.parseULong(),t.maxMemType1=c.parseULong(),t.version){case 1:t.names=t2.slice();break;case 2:t.numberOfGlyphs=c.parseUShort(),t.glyphNameIndex=new Array(t.numberOfGlyphs);for(var a=0;a<t.numberOfGlyphs;a++)t.glyphNameIndex[a]=c.parseUShort();t.names=[];for(var r=0;r<t.numberOfGlyphs;r++)if(t.glyphNameIndex[r]>=t2.length){var s=c.parseChar();t.names.push(c.parseString(s))}break;case 2.5:t.numberOfGlyphs=c.parseUShort(),t.offset=new Array(t.numberOfGlyphs);for(var i=0;i<t.numberOfGlyphs;i++)t.offset[i]=c.parseChar();break}return t}function Ye(){return new O.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 E7={parse:Ze,make:Ye},f0=new Array(9);f0[1]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:1,coverage:this.parsePointer(C.coverage),deltaGlyphId:this.parseUShort()};if(t===2)return{substFormat:2,coverage:this.parsePointer(C.coverage),substitute:this.parseOffset16List()};W.assert(!1,"0x"+e.toString(16)+": lookup type 1 format must be 1 or 2.")};f0[2]=function(){var e=this.parseUShort();return W.argument(e===1,"GSUB Multiple Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(C.coverage),sequences:this.parseListOfLists()}};f0[3]=function(){var e=this.parseUShort();return W.argument(e===1,"GSUB Alternate Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(C.coverage),alternateSets:this.parseListOfLists()}};f0[4]=function(){var e=this.parseUShort();return W.argument(e===1,"GSUB ligature table identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(C.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};var v2={sequenceIndex:C.uShort,lookupListIndex:C.uShort};f0[5]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:t,coverage:this.parsePointer(C.coverage),ruleSets:this.parseListOfLists(function(){var r=this.parseUShort(),s=this.parseUShort();return{input:this.parseUShortList(r-1),lookupRecords:this.parseRecordList(s,v2)}})};if(t===2)return{substFormat:t,coverage:this.parsePointer(C.coverage),classDef:this.parsePointer(C.classDef),classSets:this.parseListOfLists(function(){var r=this.parseUShort(),s=this.parseUShort();return{classes:this.parseUShortList(r-1),lookupRecords:this.parseRecordList(s,v2)}})};if(t===3){var c=this.parseUShort(),a=this.parseUShort();return{substFormat:t,coverages:this.parseList(c,C.pointer(C.coverage)),lookupRecords:this.parseRecordList(a,v2)}}W.assert(!1,"0x"+e.toString(16)+": lookup type 5 format must be 1, 2 or 3.")};f0[6]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{substFormat:1,coverage:this.parsePointer(C.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(v2)}})};if(t===2)return{substFormat:2,coverage:this.parsePointer(C.coverage),backtrackClassDef:this.parsePointer(C.classDef),inputClassDef:this.parsePointer(C.classDef),lookaheadClassDef:this.parsePointer(C.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(v2)}})};if(t===3)return{substFormat:3,backtrackCoverage:this.parseList(C.pointer(C.coverage)),inputCoverage:this.parseList(C.pointer(C.coverage)),lookaheadCoverage:this.parseList(C.pointer(C.coverage)),lookupRecords:this.parseRecordList(v2)};W.assert(!1,"0x"+e.toString(16)+": lookup type 6 format must be 1, 2 or 3.")};f0[7]=function(){var e=this.parseUShort();W.argument(e===1,"GSUB Extension Substitution subtable identifier-format must be 1");var t=this.parseUShort(),c=new C(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:t,extension:f0[t].call(c)}};f0[8]=function(){var e=this.parseUShort();return W.argument(e===1,"GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(C.coverage),backtrackCoverage:this.parseList(C.pointer(C.coverage)),lookaheadCoverage:this.parseList(C.pointer(C.coverage)),substitutes:this.parseUShortList()}};function Ke(n,e){e=e||0;var t=new C(n,e),c=t.parseVersion(1);return W.argument(c===1||c===1.1,"Unsupported GSUB table version."),c===1?{version:c,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(f0)}:{version:c,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(f0),variations:t.parseFeatureVariationsList()}}var y2=new Array(9);y2[1]=function(e){return e.substFormat===1?new O.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new O.Coverage(e.coverage)},{name:"deltaGlyphID",type:"USHORT",value:e.deltaGlyphId}]):new O.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new O.Coverage(e.coverage)}].concat(O.ushortList("substitute",e.substitute)))};y2[2]=function(e){return W.assert(e.substFormat===1,"Lookup type 2 substFormat must be 1."),new O.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new O.Coverage(e.coverage)}].concat(O.tableList("seqSet",e.sequences,function(t){return new O.Table("sequenceSetTable",O.ushortList("sequence",t))})))};y2[3]=function(e){return W.assert(e.substFormat===1,"Lookup type 3 substFormat must be 1."),new O.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new O.Coverage(e.coverage)}].concat(O.tableList("altSet",e.alternateSets,function(t){return new O.Table("alternateSetTable",O.ushortList("alternate",t))})))};y2[4]=function(e){return W.assert(e.substFormat===1,"Lookup type 4 substFormat must be 1."),new O.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new O.Coverage(e.coverage)}].concat(O.tableList("ligSet",e.ligatureSets,function(t){return new O.Table("ligatureSetTable",O.tableList("ligature",t,function(c){return new O.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:c.ligGlyph}].concat(O.ushortList("component",c.components,c.components.length+1)))}))})))};y2[6]=function(e){if(e.substFormat===1){var t=new O.Table("chainContextTable",[{name:"substFormat",type:"USHORT",value:e.substFormat},{name:"coverage",type:"TABLE",value:new O.Coverage(e.coverage)}].concat(O.tableList("chainRuleSet",e.chainRuleSets,function(r){return new O.Table("chainRuleSetTable",O.tableList("chainRule",r,function(s){var i=O.ushortList("backtrackGlyph",s.backtrack,s.backtrack.length).concat(O.ushortList("inputGlyph",s.input,s.input.length+1)).concat(O.ushortList("lookaheadGlyph",s.lookahead,s.lookahead.length)).concat(O.ushortList("substitution",[],s.lookupRecords.length));return s.lookupRecords.forEach(function(l,o){i=i.concat({name:"sequenceIndex"+o,type:"USHORT",value:l.sequenceIndex}).concat({name:"lookupListIndex"+o,type:"USHORT",value:l.lookupListIndex})}),new O.Table("chainRuleTable",i)}))})));return t}else if(e.substFormat===2)W.assert(!1,"lookup type 6 format 2 is not yet supported.");else if(e.substFormat===3){var c=[{name:"substFormat",type:"USHORT",value:e.substFormat}];c.push({name:"backtrackGlyphCount",type:"USHORT",value:e.backtrackCoverage.length}),e.backtrackCoverage.forEach(function(r,s){c.push({name:"backtrackCoverage"+s,type:"TABLE",value:new O.Coverage(r)})}),c.push({name:"inputGlyphCount",type:"USHORT",value:e.inputCoverage.length}),e.inputCoverage.forEach(function(r,s){c.push({name:"inputCoverage"+s,type:"TABLE",value:new O.Coverage(r)})}),c.push({name:"lookaheadGlyphCount",type:"USHORT",value:e.lookaheadCoverage.length}),e.lookaheadCoverage.forEach(function(r,s){c.push({name:"lookaheadCoverage"+s,type:"TABLE",value:new O.Coverage(r)})}),c.push({name:"substitutionCount",type:"USHORT",value:e.lookupRecords.length}),e.lookupRecords.forEach(function(r,s){c=c.concat({name:"sequenceIndex"+s,type:"USHORT",value:r.sequenceIndex}).concat({name:"lookupListIndex"+s,type:"USHORT",value:r.lookupListIndex})});var a=new O.Table("chainContextTable",c);return a}W.assert(!1,"lookup type 6 format must be 1, 2 or 3.")};function Je(n){return new O.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new O.ScriptList(n.scripts)},{name:"features",type:"TABLE",value:new O.FeatureList(n.features)},{name:"lookups",type:"TABLE",value:new O.LookupList(n.lookups,y2)}])}var T7={parse:Ke,make:Je};function Qe(n,e){var t=new q.Parser(n,e),c=t.parseULong();W.argument(c===1,"Unsupported META table version."),t.parseULong(),t.parseULong();for(var a=t.parseULong(),r={},s=0;s<a;s++){var i=t.parseTag(),l=t.parseULong(),o=t.parseULong(),h=g2.UTF8(n,e+l,o);r[i]=h}return r}function et(n){var e=Object.keys(n).length,t="",c=16+e*12,a=new O.Table("meta",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"offset",type:"ULONG",value:c},{name:"numTags",type:"ULONG",value:e}]);for(var r in n){var s=t.length;t+=n[r],a.fields.push({name:"tag "+r,type:"TAG",value:r}),a.fields.push({name:"offset "+r,type:"ULONG",value:c+s}),a.fields.push({name:"length "+r,type:"ULONG",value:n[r].length})}return a.fields.push({name:"stringPool",type:"CHARARRAY",value:t}),a}var I7={parse:Qe,make:et};function P6(n){return Math.log(n)/Math.log(2)|0}function Z5(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 E6(n,e,t,c){return new O.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:c!==void 0?c:0}])}function H7(n){var e=new O.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,P6(e.numTables));e.searchRange=16*t,e.entrySelector=P6(t),e.rangeShift=e.numTables*16-e.searchRange;for(var c=[],a=[],r=e.sizeOf()+E6().sizeOf()*e.numTables;r%4!==0;)r+=1,a.push({name:"padding",type:"BYTE",value:0});for(var s=0;s<n.length;s+=1){var i=n[s];W.argument(i.tableName.length===4,"Table name"+i.tableName+" is invalid.");var l=i.sizeOf(),o=E6(i.tableName,Z5(i.encode()),r,l);for(c.push({name:o.tag+" Table Record",type:"RECORD",value:o}),a.push({name:i.tableName+" table",type:"RECORD",value:i}),r+=l,W.argument(!isNaN(r),"Something went wrong calculating the offset.");r%4!==0;)r+=1,a.push({name:"padding",type:"BYTE",value:0})}return c.sort(function(h,f){return h.value.tag>f.value.tag?1:-1}),e.fields=e.fields.concat(c),e.fields=e.fields.concat(a),e}function T6(n,e,t){for(var c=0;c<e.length;c+=1){var a=n.charToGlyphIndex(e[c]);if(a>0){var r=n.glyphs.get(a);return r.getMetrics()}}return t}function tt(n){for(var e=0,t=0;t<n.length;t+=1)e+=n[t];return e/n.length}function nt(n){for(var e=[],t=[],c=[],a=[],r=[],s=[],i=[],l,o=0,h=0,f=0,u=0,d=0,p=0;p<n.glyphs.length;p+=1){var m=n.glyphs.get(p),v=m.unicode|0;if(isNaN(m.advanceWidth))throw new Error("Glyph "+m.name+" ("+p+"): advanceWidth is not a number.");(l>v||l===void 0)&&v>0&&(l=v),o<v&&(o=v);var g=N5.getUnicodeRange(v);if(g<32)h|=1<<g;else if(g<64)f|=1<<g-32;else if(g<96)u|=1<<g-64;else if(g<123)d|=1<<g-96;else throw new Error("Unicode ranges bits > 123 are reserved for internal usage");if(m.name!==".notdef"){var b=m.getMetrics();e.push(b.xMin),t.push(b.yMin),c.push(b.xMax),a.push(b.yMax),s.push(b.leftSideBearing),i.push(b.rightSideBearing),r.push(m.advanceWidth)}}var y={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,t),xMax:Math.max.apply(null,c),yMax:Math.max.apply(null,a),advanceWidthMax:Math.max.apply(null,r),advanceWidthAvg:tt(r),minLeftSideBearing:Math.min.apply(null,s),maxLeftSideBearing:Math.max.apply(null,s),minRightSideBearing:Math.min.apply(null,i)};y.ascender=n.ascender,y.descender=n.descender;var w=M7.make({flags:3,unitsPerEm:n.unitsPerEm,xMin:y.xMin,yMin:y.yMin,xMax:y.xMax,yMax:y.yMax,lowestRecPPEM:3,createdTimestamp:n.createdTimestamp}),k=x7.make({ascender:y.ascender,descender:y.descender,advanceWidthMax:y.advanceWidthMax,minLeftSideBearing:y.minLeftSideBearing,minRightSideBearing:y.minRightSideBearing,xMaxExtent:y.maxLeftSideBearing+(y.xMax-y.xMin),numberOfHMetrics:n.glyphs.length}),P=k7.make(n.glyphs.length),S=N5.make(Object.assign({xAvgCharWidth:Math.round(y.advanceWidthAvg),usFirstCharIndex:l,usLastCharIndex:o,ulUnicodeRange1:h,ulUnicodeRange2:f,ulUnicodeRange3:u,ulUnicodeRange4:d,sTypoAscender:y.ascender,sTypoDescender:y.descender,sTypoLineGap:0,usWinAscent:y.yMax,usWinDescent:Math.abs(y.yMin),ulCodePageRange1:1,sxHeight:T6(n,"xyvw",{yMax:Math.round(y.ascender/2)}).yMax,sCapHeight:T6(n,"HIKLEFJMNTZBDPRAGOQSUVWXY",y).yMax,usDefaultChar:n.hasChar(" ")?32:0,usBreakChar:n.hasChar(" ")?32:0},n.tables.os2)),A=z7.make(n.glyphs),E=l7.make(n.glyphs),z=n.getEnglishName("fontFamily"),I=n.getEnglishName("fontSubfamily"),$=z+" "+I,F=n.getEnglishName("postScriptName");F||(F=z.replace(/\s/g,"")+"-"+I);var _={};for(var Y in n.names)_[Y]=n.names[Y];_.uniqueID||(_.uniqueID={en:n.getEnglishName("manufacturer")+":"+$}),_.postScriptName||(_.postScriptName={en:F}),_.preferredFamily||(_.preferredFamily=n.names.fontFamily),_.preferredSubfamily||(_.preferredSubfamily=n.names.fontSubfamily);var N=[],i1=P7.make(_,N),h1=N.length>0?w7.make(N):void 0,U=E7.make(),c1=b7.make(n.glyphs,{version:n.getEnglishName("version"),fullName:$,familyName:z,weightName:I,postScriptName:F,unitsPerEm:n.unitsPerEm,fontBBox:[0,y.yMin,y.ascender,y.advanceWidthMax]}),X=n.metas&&Object.keys(n.metas).length>0?I7.make(n.metas):void 0,f1=[w,k,P,S,i1,E,U,c1,A];h1&&f1.push(h1),n.tables.gsub&&f1.push(T7.make(n.tables.gsub)),X&&f1.push(X);for(var I1=H7(f1),M1=I1.encode(),k2=Z5(M1),L2=I1.fields,e3=!1,X0=0;X0<L2.length;X0+=1)if(L2[X0].name==="head table"){L2[X0].value.checkSumAdjustment=2981146554-k2,e3=!0;break}if(!e3)throw new Error("Could not find head table with checkSum to adjust.");return I1}var ct={make:H7,fontToTable:nt,computeCheckSum:Z5};function A5(n,e){for(var t=0,c=n.length-1;t<=c;){var a=t+c>>>1,r=n[a].tag;if(r===e)return a;r<e?t=a+1:c=a-1}return-t-1}function I6(n,e){for(var t=0,c=n.length-1;t<=c;){var a=t+c>>>1,r=n[a];if(r===e)return a;r<e?t=a+1:c=a-1}return-t-1}function H6(n,e){for(var t,c=0,a=n.length-1;c<=a;){var r=c+a>>>1;t=n[r];var s=t.start;if(s===e)return t;s<e?c=r+1:a=r-1}if(c>0)return t=n[c-1],e>t.end?0:t}function X2(n,e){this.font=n,this.tableName=e}X2.prototype={searchTag:A5,binSearch:I6,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 c=n.scripts[t].tag;if(c==="DFLT")return c;c==="latn"&&(e=!0)}if(e)return"latn"}},getScriptTable:function(n,e){var t=this.getTable(e);if(t){n=n||"DFLT";var c=t.scripts,a=A5(t.scripts,n);if(a>=0)return c[a].script;if(e){var r={tag:n,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return c.splice(-1-a,0,r),r.script}}},getLangSysTable:function(n,e,t){var c=this.getScriptTable(n,t);if(c){if(!e||e==="dflt"||e==="DFLT")return c.defaultLangSys;var a=A5(c.langSysRecords,e);if(a>=0)return c.langSysRecords[a].langSys;if(t){var r={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return c.langSysRecords.splice(-1-a,0,r),r.langSys}}},getFeatureTable:function(n,e,t,c){var a=this.getLangSysTable(n,e,c);if(a){for(var r,s=a.featureIndexes,i=this.font.tables[this.tableName].features,l=0;l<s.length;l++)if(r=i[s[l]],r.tag===t)return r.feature;if(c){var o=i.length;return W.assert(o===0||t>=i[o-1].tag,"Features must be added in alphabetical order."),r={tag:t,feature:{params:0,lookupListIndexes:[]}},i.push(r),s.push(o),r.feature}}},getLookupTables:function(n,e,t,c,a){var r=this.getFeatureTable(n,e,t,a),s=[];if(r){for(var i,l=r.lookupListIndexes,o=this.font.tables[this.tableName].lookups,h=0;h<l.length;h++)i=o[l[h]],i.lookupType===c&&s.push(i);if(s.length===0&&a){i={lookupType:c,lookupFlag:0,subtables:[],markFilteringSet:void 0};var f=o.length;return o.push(i),l.push(f),[i]}}return s},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=H6(n.ranges,e);return t?t.classId:0}},getCoverageIndex:function(n,e){switch(n.format){case 1:var t=I6(n.glyphs,e);return t>=0?t:-1;case 2:var c=H6(n.ranges,e);return c?c.index+e-c.start:-1}},expandCoverage:function(n){if(n.format===1)return n.glyphs;for(var e=[],t=n.ranges,c=0;c<t.length;c++)for(var a=t[c],r=a.start,s=a.end,i=r;i<=s;i++)e.push(i);return e}};function Z2(n){X2.call(this,n,"gpos")}Z2.prototype=X2.prototype;Z2.prototype.init=function(){var n=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(n)};Z2.prototype.getKerningValue=function(n,e,t){for(var c=0;c<n.length;c++)for(var a=n[c].subtables,r=0;r<a.length;r++){var s=a[r],i=this.getCoverageIndex(s.coverage,e);if(!(i<0))switch(s.posFormat){case 1:for(var l=s.pairSets[i],o=0;o<l.length;o++){var h=l[o];if(h.secondGlyph===t)return h.value1&&h.value1.xAdvance||0}break;case 2:var f=this.getGlyphClass(s.classDef1,e),u=this.getGlyphClass(s.classDef2,t),d=s.classRecords[f][u];return d.value1&&d.value1.xAdvance||0}}return 0};Z2.prototype.getKerningTables=function(n,e){if(this.font.tables.gpos)return this.getLookupTables(n,e,"kern",2)};function e0(n){X2.call(this,n,"gsub")}function at(n,e){var t=n.length;if(t!==e.length)return!1;for(var c=0;c<t;c++)if(n[c]!==e[c])return!1;return!0}function Y5(n,e,t){for(var c=n.subtables,a=0;a<c.length;a++){var r=c[a];if(r.substFormat===e)return r}if(t)return c.push(t),t}e0.prototype=X2.prototype;e0.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}};e0.prototype.getSingle=function(n,e,t){for(var c=[],a=this.getLookupTables(e,t,n,1),r=0;r<a.length;r++)for(var s=a[r].subtables,i=0;i<s.length;i++){var l=s[i],o=this.expandCoverage(l.coverage),h=void 0;if(l.substFormat===1){var f=l.deltaGlyphId;for(h=0;h<o.length;h++){var u=o[h];c.push({sub:u,by:u+f})}}else{var d=l.substitute;for(h=0;h<o.length;h++)c.push({sub:o[h],by:d[h]})}}return c};e0.prototype.getMultiple=function(n,e,t){for(var c=[],a=this.getLookupTables(e,t,n,2),r=0;r<a.length;r++)for(var s=a[r].subtables,i=0;i<s.length;i++){var l=s[i],o=this.expandCoverage(l.coverage),h=void 0;for(h=0;h<o.length;h++){var f=o[h],u=l.sequences[h];c.push({sub:f,by:u})}}return c};e0.prototype.getAlternates=function(n,e,t){for(var c=[],a=this.getLookupTables(e,t,n,3),r=0;r<a.length;r++)for(var s=a[r].subtables,i=0;i<s.length;i++)for(var l=s[i],o=this.expandCoverage(l.coverage),h=l.alternateSets,f=0;f<o.length;f++)c.push({sub:o[f],by:h[f]});return c};e0.prototype.getLigatures=function(n,e,t){for(var c=[],a=this.getLookupTables(e,t,n,4),r=0;r<a.length;r++)for(var s=a[r].subtables,i=0;i<s.length;i++)for(var l=s[i],o=this.expandCoverage(l.coverage),h=l.ligatureSets,f=0;f<o.length;f++)for(var u=o[f],d=h[f],p=0;p<d.length;p++){var m=d[p];c.push({sub:[u].concat(m.components),by:m.ligGlyph})}return c};e0.prototype.addSingle=function(n,e,t,c){var a=this.getLookupTables(t,c,n,1,!0)[0],r=Y5(a,2,{substFormat:2,coverage:{format:1,glyphs:[]},substitute:[]});W.assert(r.coverage.format===1,"Single: unable to modify coverage table format "+r.coverage.format);var s=e.sub,i=this.binSearch(r.coverage.glyphs,s);i<0&&(i=-1-i,r.coverage.glyphs.splice(i,0,s),r.substitute.splice(i,0,0)),r.substitute[i]=e.by};e0.prototype.addMultiple=function(n,e,t,c){W.assert(e.by instanceof Array&&e.by.length>1,'Multiple: "by" must be an array of two or more ids');var a=this.getLookupTables(t,c,n,2,!0)[0],r=Y5(a,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});W.assert(r.coverage.format===1,"Multiple: unable to modify coverage table format "+r.coverage.format);var s=e.sub,i=this.binSearch(r.coverage.glyphs,s);i<0&&(i=-1-i,r.coverage.glyphs.splice(i,0,s),r.sequences.splice(i,0,0)),r.sequences[i]=e.by};e0.prototype.addAlternate=function(n,e,t,c){var a=this.getLookupTables(t,c,n,3,!0)[0],r=Y5(a,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});W.assert(r.coverage.format===1,"Alternate: unable to modify coverage table format "+r.coverage.format);var s=e.sub,i=this.binSearch(r.coverage.glyphs,s);i<0&&(i=-1-i,r.coverage.glyphs.splice(i,0,s),r.alternateSets.splice(i,0,0)),r.alternateSets[i]=e.by};e0.prototype.addLigature=function(n,e,t,c){var a=this.getLookupTables(t,c,n,4,!0)[0],r=a.subtables[0];r||(r={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},a.subtables[0]=r),W.assert(r.coverage.format===1,"Ligature: unable to modify coverage table format "+r.coverage.format);var s=e.sub[0],i=e.sub.slice(1),l={ligGlyph:e.by,components:i},o=this.binSearch(r.coverage.glyphs,s);if(o>=0){for(var h=r.ligatureSets[o],f=0;f<h.length;f++)if(at(h[f].components,i))return;h.push(l)}else o=-1-o,r.coverage.glyphs.splice(o,0,s),r.ligatureSets.splice(o,0,[l])};e0.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)}};e0.prototype.add=function(n,e,t,c){if(/ss\d\d/.test(n))return this.addSingle(n,e,t,c);switch(n){case"aalt":case"salt":return typeof e.by=="number"?this.addSingle(n,e,t,c):this.addAlternate(n,e,t,c);case"dlig":case"liga":case"rlig":return this.addLigature(n,e,t,c);case"ccmp":return e.by instanceof Array?this.addMultiple(n,e,t,c):this.addLigature(n,e,t,c)}};function rt(){return typeof window<"u"}function st(n){for(var e=new Buffer(n.byteLength),t=new Uint8Array(n),c=0;c<e.length;++c)e[c]=t[c];return e}function B2(n,e){if(!n)throw e}function V6(n,e,t,c,a){var r;return(e&c)>0?(r=n.parseByte(),(e&a)===0&&(r=-r),r=t+r):(e&a)>0?r=t:r=t+n.parseShort(),r}function V7(n,e,t){var c=new q.Parser(e,t);n.numberOfContours=c.parseShort(),n._xMin=c.parseShort(),n._yMin=c.parseShort(),n._xMax=c.parseShort(),n._yMax=c.parseShort();var a,r;if(n.numberOfContours>0){for(var s=n.endPointIndices=[],i=0;i<n.numberOfContours;i+=1)s.push(c.parseUShort());n.instructionLength=c.parseUShort(),n.instructions=[];for(var l=0;l<n.instructionLength;l+=1)n.instructions.push(c.parseByte());var o=s[s.length-1]+1;a=[];for(var h=0;h<o;h+=1)if(r=c.parseByte(),a.push(r),(r&8)>0)for(var f=c.parseByte(),u=0;u<f;u+=1)a.push(r),h+=1;if(W.argument(a.length===o,"Bad flags."),s.length>0){var d=[],p;if(o>0){for(var m=0;m<o;m+=1)r=a[m],p={},p.onCurve=!!(r&1),p.lastPointOfContour=s.indexOf(m)>=0,d.push(p);for(var v=0,g=0;g<o;g+=1)r=a[g],p=d[g],p.x=V6(c,r,v,2,16),v=p.x;for(var b=0,y=0;y<o;y+=1)r=a[y],p=d[y],p.y=V6(c,r,b,4,32),b=p.y}n.points=d}else n.points=[]}else if(n.numberOfContours===0)n.points=[];else{n.isComposite=!0,n.points=[],n.components=[];for(var w=!0;w;){a=c.parseUShort();var k={glyphIndex:c.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(a&1)>0?(a&2)>0?(k.dx=c.parseShort(),k.dy=c.parseShort()):k.matchedPoints=[c.parseUShort(),c.parseUShort()]:(a&2)>0?(k.dx=c.parseChar(),k.dy=c.parseChar()):k.matchedPoints=[c.parseByte(),c.parseByte()],(a&8)>0?k.xScale=k.yScale=c.parseF2Dot14():(a&64)>0?(k.xScale=c.parseF2Dot14(),k.yScale=c.parseF2Dot14()):(a&128)>0&&(k.xScale=c.parseF2Dot14(),k.scale01=c.parseF2Dot14(),k.scale10=c.parseF2Dot14(),k.yScale=c.parseF2Dot14()),n.components.push(k),w=!!(a&32)}if(a&256){n.instructionLength=c.parseUShort(),n.instructions=[];for(var P=0;P<n.instructionLength;P+=1)n.instructions.push(c.parseByte())}}}function C5(n,e){for(var t=[],c=0;c<n.length;c+=1){var a=n[c],r={x:e.xScale*a.x+e.scale01*a.y+e.dx,y:e.scale10*a.x+e.yScale*a.y+e.dy,onCurve:a.onCurve,lastPointOfContour:a.lastPointOfContour};t.push(r)}return t}function it(n){for(var e=[],t=[],c=0;c<n.length;c+=1){var a=n[c];t.push(a),a.lastPointOfContour&&(e.push(t),t=[])}return W.argument(t.length===0,"There are still points left in the current contour."),e}function O7(n){var e=new E1;if(!n)return e;for(var t=it(n),c=0;c<t.length;++c){var a=t[c],r=null,s=a[a.length-1],i=a[0];if(s.onCurve)e.moveTo(s.x,s.y);else if(i.onCurve)e.moveTo(i.x,i.y);else{var l={x:(s.x+i.x)*.5,y:(s.y+i.y)*.5};e.moveTo(l.x,l.y)}for(var o=0;o<a.length;++o)if(r=s,s=i,i=a[(o+1)%a.length],s.onCurve)e.lineTo(s.x,s.y);else{var h=r,f=i;r.onCurve||(h={x:(s.x+r.x)*.5,y:(s.y+r.y)*.5}),i.onCurve||(f={x:(s.x+i.x)*.5,y:(s.y+i.y)*.5}),e.quadraticCurveTo(s.x,s.y,f.x,f.y)}e.closePath()}return e}function F7(n,e){if(e.isComposite)for(var t=0;t<e.components.length;t+=1){var c=e.components[t],a=n.get(c.glyphIndex);if(a.getPath(),a.points){var r=void 0;if(c.matchedPoints===void 0)r=C5(a.points,c);else{if(c.matchedPoints[0]>e.points.length-1||c.matchedPoints[1]>a.points.length-1)throw Error("Matched points out of range in "+e.name);var s=e.points[c.matchedPoints[0]],i=a.points[c.matchedPoints[1]],l={xScale:c.xScale,scale01:c.scale01,scale10:c.scale10,yScale:c.yScale,dx:0,dy:0};i=C5([i],l)[0],l.dx=s.x-i.x,l.dy=s.y-i.y,r=C5(a.points,l)}e.points=e.points.concat(r)}}return O7(e.points)}function lt(n,e,t,c){for(var a=new L0.GlyphSet(c),r=0;r<t.length-1;r+=1){var s=t[r],i=t[r+1];s!==i?a.push(r,L0.ttfGlyphLoader(c,r,V7,n,e+s,F7)):a.push(r,L0.glyphLoader(c,r))}return a}function ot(n,e,t,c){var a=new L0.GlyphSet(c);return c._push=function(r){var s=t[r],i=t[r+1];s!==i?a.push(r,L0.ttfGlyphLoader(c,r,V7,n,e+s,F7)):a.push(r,L0.glyphLoader(c,r))},a}function ht(n,e,t,c,a){return a.lowMemory?ot(n,e,t,c):lt(n,e,t,c)}var D7={getPath:O7,parse:ht},R7,c2,q7,B5;function U7(n){this.font=n,this.getCommands=function(e){return D7.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function ut(n){return n}function N7(n){return Math.sign(n)*Math.round(Math.abs(n))}function ft(n){return Math.sign(n)*Math.round(Math.abs(n*2))/2}function dt(n){return Math.sign(n)*(Math.round(Math.abs(n)+.5)-.5)}function pt(n){return Math.sign(n)*Math.ceil(Math.abs(n))}function mt(n){return Math.sign(n)*Math.floor(Math.abs(n))}var B7=function(n){var e=this.srPeriod,t=this.srPhase,c=this.srThreshold,a=1;return n<0&&(n=-n,a=-1),n+=c-t,n=Math.trunc(n/e)*e,n+=t,n<0?t*a:n*a},k0={x:1,y:0,axis:"x",distance:function(n,e,t,c){return(t?n.xo:n.x)-(c?e.xo:e.x)},interpolate:function(n,e,t,c){var a,r,s,i,l,o,h;if(!c||c===this){if(a=n.xo-e.xo,r=n.xo-t.xo,l=e.x-e.xo,o=t.x-t.xo,s=Math.abs(a),i=Math.abs(r),h=s+i,h===0){n.x=n.xo+(l+o)/2;return}n.x=n.xo+(l*i+o*s)/h;return}if(a=c.distance(n,e,!0,!0),r=c.distance(n,t,!0,!0),l=c.distance(e,e,!1,!0),o=c.distance(t,t,!1,!0),s=Math.abs(a),i=Math.abs(r),h=s+i,h===0){k0.setRelative(n,n,(l+o)/2,c,!0);return}k0.setRelative(n,n,(l*i+o*s)/h,c,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(n,e,t,c,a){if(!c||c===this){n.x=(a?e.xo:e.x)+t;return}var r=a?e.xo:e.x,s=a?e.yo:e.y,i=r+t*c.x,l=s+t*c.y;n.x=i+(n.y-l)/c.normalSlope},slope:0,touch:function(n){n.xTouched=!0},touched:function(n){return n.xTouched},untouch:function(n){n.xTouched=!1}},H0={x:0,y:1,axis:"y",distance:function(n,e,t,c){return(t?n.yo:n.y)-(c?e.yo:e.y)},interpolate:function(n,e,t,c){var a,r,s,i,l,o,h;if(!c||c===this){if(a=n.yo-e.yo,r=n.yo-t.yo,l=e.y-e.yo,o=t.y-t.yo,s=Math.abs(a),i=Math.abs(r),h=s+i,h===0){n.y=n.yo+(l+o)/2;return}n.y=n.yo+(l*i+o*s)/h;return}if(a=c.distance(n,e,!0,!0),r=c.distance(n,t,!0,!0),l=c.distance(e,e,!1,!0),o=c.distance(t,t,!1,!0),s=Math.abs(a),i=Math.abs(r),h=s+i,h===0){H0.setRelative(n,n,(l+o)/2,c,!0);return}H0.setRelative(n,n,(l*i+o*s)/h,c,!0)},normalSlope:0,setRelative:function(n,e,t,c,a){if(!c||c===this){n.y=(a?e.yo:e.y)+t;return}var r=a?e.xo:e.x,s=a?e.yo:e.y,i=r+t*c.x,l=s+t*c.y;n.y=l+c.normalSlope*(n.x-i)},slope:Number.POSITIVE_INFINITY,touch:function(n){n.yTouched=!0},touched:function(n){return n.yTouched},untouch:function(n){n.yTouched=!1}};Object.freeze(k0);Object.freeze(H0);function Y2(n,e){this.x=n,this.y=e,this.axis=void 0,this.slope=e/n,this.normalSlope=-n/e,Object.freeze(this)}Y2.prototype.distance=function(n,e,t,c){return this.x*k0.distance(n,e,t,c)+this.y*H0.distance(n,e,t,c)};Y2.prototype.interpolate=function(n,e,t,c){var a,r,s,i,l,o,h;if(s=c.distance(n,e,!0,!0),i=c.distance(n,t,!0,!0),a=c.distance(e,e,!1,!0),r=c.distance(t,t,!1,!0),l=Math.abs(s),o=Math.abs(i),h=l+o,h===0){this.setRelative(n,n,(a+r)/2,c,!0);return}this.setRelative(n,n,(a*o+r*l)/h,c,!0)};Y2.prototype.setRelative=function(n,e,t,c,a){c=c||this;var r=a?e.xo:e.x,s=a?e.yo:e.y,i=r+t*c.x,l=s+t*c.y,o=c.normalSlope,h=this.slope,f=n.x,u=n.y;n.x=(h*f-o*i+l-u)/(h-o),n.y=h*(n.x-f)+u};Y2.prototype.touch=function(n){n.xTouched=!0,n.yTouched=!0};function K2(n,e){var t=Math.sqrt(n*n+e*e);return n/=t,e/=t,n===1&&e===0?k0:n===0&&e===1?H0:new Y2(n,e)}function V0(n,e,t,c){this.x=this.xo=Math.round(n*64)/64,this.y=this.yo=Math.round(e*64)/64,this.lastPointOfContour=t,this.onCurve=c,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}V0.prototype.nextTouched=function(n){for(var e=this.nextPointOnContour;!n.touched(e)&&e!==this;)e=e.nextPointOnContour;return e};V0.prototype.prevTouched=function(n){for(var e=this.prevPointOnContour;!n.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};var W2=Object.freeze(new V0(0,0)),vt={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function $0(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=k0,this.round=N7}}U7.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,c=this._prepState;if(!c||c.ppem!==e){var a=this._fpgmState;if(!a){$0.prototype=vt,a=this._fpgmState=new $0("fpgm",t.tables.fpgm),a.funcs=[],a.font=t,exports.DEBUG&&(console.log("---EXEC FPGM---"),a.step=-1);try{c2(a)}catch(o){console.log("Hinting error in FPGM:"+o),this._errorState=3;return}}$0.prototype=a,c=this._prepState=new $0("prep",t.tables.prep),c.ppem=e;var r=t.tables.cvt;if(r)for(var s=c.cvt=new Array(r.length),i=e/t.unitsPerEm,l=0;l<r.length;l++)s[l]=r[l]*i;else c.cvt=[];exports.DEBUG&&(console.log("---EXEC PREP---"),c.step=-1);try{c2(c)}catch(o){this._errorState<2&&console.log("Hinting error in PREP:"+o),this._errorState=2}}if(!(this._errorState>1))try{return q7(n,c)}catch(o){this._errorState<1&&(console.log("Hinting error:"+o),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}}};q7=function(n,e){var t=e.ppem/e.font.unitsPerEm,c=t,a=n.components,r,s,i;if($0.prototype=e,!a)i=new $0("glyf",n.instructions),exports.DEBUG&&(console.log("---EXEC GLYPH---"),i.step=-1),B5(n,i,t,c),s=i.gZone;else{var l=e.font;s=[],r=[];for(var o=0;o<a.length;o++){var h=a[o],f=l.glyphs.get(h.glyphIndex);i=new $0("glyf",f.instructions),exports.DEBUG&&(console.log("---EXEC COMP "+o+"---"),i.step=-1),B5(f,i,t,c);for(var u=Math.round(h.dx*t),d=Math.round(h.dy*c),p=i.gZone,m=i.contours,v=0;v<p.length;v++){var g=p[v];g.xTouched=g.yTouched=!1,g.xo=g.x=g.x+u,g.yo=g.y=g.y+d}var b=s.length;s.push.apply(s,p);for(var y=0;y<m.length;y++)r.push(m[y]+b)}n.instructions&&!i.inhibitGridFit&&(i=new $0("glyf",n.instructions),i.gZone=i.z0=i.z1=i.z2=s,i.contours=r,s.push(new V0(0,0),new V0(Math.round(n.advanceWidth*t),0)),exports.DEBUG&&(console.log("---EXEC COMPOSITE---"),i.step=-1),c2(i),s.length-=2)}return s};B5=function(n,e,t,c){for(var a=n.points||[],r=a.length,s=e.gZone=e.z0=e.z1=e.z2=[],i=e.contours=[],l,o=0;o<r;o++)l=a[o],s[o]=new V0(l.x*t,l.y*c,l.lastPointOfContour,l.onCurve);for(var h,f,u=0;u<r;u++)l=s[u],h||(h=l,i.push(u)),l.lastPointOfContour?(l.nextPointOnContour=h,h.prevPointOnContour=l,h=void 0):(f=s[u+1],l.nextPointOnContour=f,f.prevPointOnContour=l);if(!e.inhibitGridFit){if(exports.DEBUG){console.log("PROCESSING GLYPH",e.stack);for(var d=0;d<r;d++)console.log(d,s[d].x,s[d].y)}if(s.push(new V0(0,0),new V0(Math.round(n.advanceWidth*t),0)),c2(e),s.length-=2,exports.DEBUG){console.log("FINISHED GLYPH",e.stack);for(var p=0;p<r;p++)console.log(p,s[p].x,s[p].y)}}};c2=function(n){var e=n.prog;if(e){var t=e.length,c;for(n.ip=0;n.ip<t;n.ip++){if(exports.DEBUG&&n.step++,c=R7[e[n.ip]],!c)throw new Error("unknown instruction: 0x"+Number(e[n.ip]).toString(16));c(n)}}};function q3(n){for(var e=n.tZone=new Array(n.gZone.length),t=0;t<e.length;t++)e[t]=new V0(0,0)}function $7(n,e){var t=n.prog,c=n.ip,a=1,r;do if(r=t[++c],r===88)a++;else if(r===89)a--;else if(r===64)c+=t[c+1]+1;else if(r===65)c+=2*t[c+1]+1;else if(r>=176&&r<=183)c+=r-176+1;else if(r>=184&&r<=191)c+=(r-184+1)*2;else if(e&&a===1&&r===27)break;while(a>0);n.ip=c}function O6(n,e){exports.DEBUG&&console.log(e.step,"SVTCA["+n.axis+"]"),e.fv=e.pv=e.dpv=n}function F6(n,e){exports.DEBUG&&console.log(e.step,"SPVTCA["+n.axis+"]"),e.pv=e.dpv=n}function D6(n,e){exports.DEBUG&&console.log(e.step,"SFVTCA["+n.axis+"]"),e.fv=n}function R6(n,e){var t=e.stack,c=t.pop(),a=t.pop(),r=e.z2[c],s=e.z1[a];exports.DEBUG&&console.log("SPVTL["+n+"]",c,a);var i,l;n?(i=r.y-s.y,l=s.x-r.x):(i=s.x-r.x,l=s.y-r.y),e.pv=e.dpv=K2(i,l)}function q6(n,e){var t=e.stack,c=t.pop(),a=t.pop(),r=e.z2[c],s=e.z1[a];exports.DEBUG&&console.log("SFVTL["+n+"]",c,a);var i,l;n?(i=r.y-s.y,l=s.x-r.x):(i=s.x-r.x,l=s.y-r.y),e.fv=K2(i,l)}function gt(n){var e=n.stack,t=e.pop(),c=e.pop();exports.DEBUG&&console.log(n.step,"SPVFS[]",t,c),n.pv=n.dpv=K2(c,t)}function yt(n){var e=n.stack,t=e.pop(),c=e.pop();exports.DEBUG&&console.log(n.step,"SPVFS[]",t,c),n.fv=K2(c,t)}function bt(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 Mt(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 xt(n){n.fv=n.pv,exports.DEBUG&&console.log(n.step,"SFVTPV[]")}function zt(n){var e=n.stack,t=e.pop(),c=e.pop(),a=e.pop(),r=e.pop(),s=e.pop(),i=n.z0,l=n.z1,o=i[t],h=i[c],f=l[a],u=l[r],d=n.z2[s];exports.DEBUG&&console.log("ISECT[], ",t,c,a,r,s);var p=o.x,m=o.y,v=h.x,g=h.y,b=f.x,y=f.y,w=u.x,k=u.y,P=(p-v)*(y-k)-(m-g)*(b-w),S=p*g-m*v,A=b*k-y*w;d.x=(S*(b-w)-A*(p-v))/P,d.y=(S*(y-k)-A*(m-g))/P}function wt(n){n.rp0=n.stack.pop(),exports.DEBUG&&console.log(n.step,"SRP0[]",n.rp0)}function kt(n){n.rp1=n.stack.pop(),exports.DEBUG&&console.log(n.step,"SRP1[]",n.rp1)}function Lt(n){n.rp2=n.stack.pop(),exports.DEBUG&&console.log(n.step,"SRP2[]",n.rp2)}function St(n){var e=n.stack.pop();switch(exports.DEBUG&&console.log(n.step,"SZP0[]",e),n.zp0=e,e){case 0:n.tZone||q3(n),n.z0=n.tZone;break;case 1:n.z0=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function At(n){var e=n.stack.pop();switch(exports.DEBUG&&console.log(n.step,"SZP1[]",e),n.zp1=e,e){case 0:n.tZone||q3(n),n.z1=n.tZone;break;case 1:n.z1=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function Ct(n){var e=n.stack.pop();switch(exports.DEBUG&&console.log(n.step,"SZP2[]",e),n.zp2=e,e){case 0:n.tZone||q3(n),n.z2=n.tZone;break;case 1:n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function Pt(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||q3(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 Et(n){n.loop=n.stack.pop(),exports.DEBUG&&console.log(n.step,"SLOOP[]",n.loop)}function Tt(n){exports.DEBUG&&console.log(n.step,"RTG[]"),n.round=N7}function It(n){exports.DEBUG&&console.log(n.step,"RTHG[]"),n.round=dt}function Ht(n){var e=n.stack.pop();exports.DEBUG&&console.log(n.step,"SMD[]",e),n.minDis=e/64}function Vt(n){exports.DEBUG&&console.log(n.step,"ELSE[]"),$7(n,!1)}function Ot(n){var e=n.stack.pop();exports.DEBUG&&console.log(n.step,"JMPR[]",e),n.ip+=e-1}function Ft(n){var e=n.stack.pop();exports.DEBUG&&console.log(n.step,"SCVTCI[]",e),n.cvCutIn=e/64}function Dt(n){var e=n.stack;exports.DEBUG&&console.log(n.step,"DUP[]"),e.push(e[e.length-1])}function P5(n){exports.DEBUG&&console.log(n.step,"POP[]"),n.stack.pop()}function Rt(n){exports.DEBUG&&console.log(n.step,"CLEAR[]"),n.stack.length=0}function qt(n){var e=n.stack,t=e.pop(),c=e.pop();exports.DEBUG&&console.log(n.step,"SWAP[]"),e.push(t),e.push(c)}function Ut(n){var e=n.stack;exports.DEBUG&&console.log(n.step,"DEPTH[]"),e.push(e.length)}function Nt(n){var e=n.stack,t=e.pop(),c=e.pop();exports.DEBUG&&console.log(n.step,"LOOPCALL[]",t,c);var a=n.ip,r=n.prog;n.prog=n.funcs[t];for(var s=0;s<c;s++)c2(n),exports.DEBUG&&console.log(++n.step,s+1<c?"next loopcall":"done loopcall",s);n.ip=a,n.prog=r}function Bt(n){var e=n.stack.pop();exports.DEBUG&&console.log(n.step,"CALL[]",e);var t=n.ip,c=n.prog;n.prog=n.funcs[e],c2(n),n.ip=t,n.prog=c,exports.DEBUG&&console.log(++n.step,"returning from",e)}function $t(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"CINDEX[]",t),e.push(e[e.length-t])}function _t(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 Gt(n){if(n.env!=="fpgm")throw new Error("FDEF not allowed here");var e=n.stack,t=n.prog,c=n.ip,a=e.pop(),r=c;for(exports.DEBUG&&console.log(n.step,"FDEF[]",a);t[++c]!==45;);n.ip=c,n.funcs[a]=t.slice(r+1,c)}function U6(n,e){var t=e.stack.pop(),c=e.z0[t],a=e.fv,r=e.pv;exports.DEBUG&&console.log(e.step,"MDAP["+n+"]",t);var s=r.distance(c,W2);n&&(s=e.round(s)),a.setRelative(c,W2,s,r),a.touch(c),e.rp0=e.rp1=t}function N6(n,e){var t=e.z2,c=t.length-2,a,r,s;exports.DEBUG&&console.log(e.step,"IUP["+n.axis+"]");for(var i=0;i<c;i++)a=t[i],!n.touched(a)&&(r=a.prevTouched(n),r!==a&&(s=a.nextTouched(n),r===s&&n.setRelative(a,a,n.distance(r,r,!1,!0),n,!0),n.interpolate(a,r,s,n)))}function B6(n,e){for(var t=e.stack,c=n?e.rp1:e.rp2,a=(n?e.z0:e.z1)[c],r=e.fv,s=e.pv,i=e.loop,l=e.z2;i--;){var o=t.pop(),h=l[o],f=s.distance(a,a,!1,!0);r.setRelative(h,h,f,s),r.touch(h),exports.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-i)+": ":"")+"SHP["+(n?"rp1":"rp2")+"]",o)}e.loop=1}function $6(n,e){var t=e.stack,c=n?e.rp1:e.rp2,a=(n?e.z0:e.z1)[c],r=e.fv,s=e.pv,i=t.pop(),l=e.z2[e.contours[i]],o=l;exports.DEBUG&&console.log(e.step,"SHC["+n+"]",i);var h=s.distance(a,a,!1,!0);do o!==a&&r.setRelative(o,o,h,s),o=o.nextPointOnContour;while(o!==l)}function _6(n,e){var t=e.stack,c=n?e.rp1:e.rp2,a=(n?e.z0:e.z1)[c],r=e.fv,s=e.pv,i=t.pop();exports.DEBUG&&console.log(e.step,"SHZ["+n+"]",i);var l;switch(i){case 0:l=e.tZone;break;case 1:l=e.gZone;break;default:throw new Error("Invalid zone")}for(var o,h=s.distance(a,a,!1,!0),f=l.length-2,u=0;u<f;u++)o=l[u],r.setRelative(o,o,h,s)}function jt(n){for(var e=n.stack,t=n.loop,c=n.fv,a=e.pop()/64,r=n.z2;t--;){var s=e.pop(),i=r[s];exports.DEBUG&&console.log(n.step,(n.loop>1?"loop "+(n.loop-t)+": ":"")+"SHPIX[]",s,a),c.setRelative(i,i,a),c.touch(i)}n.loop=1}function Wt(n){for(var e=n.stack,t=n.rp1,c=n.rp2,a=n.loop,r=n.z0[t],s=n.z1[c],i=n.fv,l=n.dpv,o=n.z2;a--;){var h=e.pop(),f=o[h];exports.DEBUG&&console.log(n.step,(n.loop>1?"loop "+(n.loop-a)+": ":"")+"IP[]",h,t,"<->",c),i.interpolate(f,r,s,l),i.touch(f)}n.loop=1}function G6(n,e){var t=e.stack,c=t.pop()/64,a=t.pop(),r=e.z1[a],s=e.z0[e.rp0],i=e.fv,l=e.pv;i.setRelative(r,s,c,l),i.touch(r),exports.DEBUG&&console.log(e.step,"MSIRP["+n+"]",c,a),e.rp1=e.rp0,e.rp2=a,n&&(e.rp0=a)}function Xt(n){for(var e=n.stack,t=n.rp0,c=n.z0[t],a=n.loop,r=n.fv,s=n.pv,i=n.z1;a--;){var l=e.pop(),o=i[l];exports.DEBUG&&console.log(n.step,(n.loop>1?"loop "+(n.loop-a)+": ":"")+"ALIGNRP[]",l),r.setRelative(o,c,0,s),r.touch(o)}n.loop=1}function Zt(n){exports.DEBUG&&console.log(n.step,"RTDG[]"),n.round=ft}function j6(n,e){var t=e.stack,c=t.pop(),a=t.pop(),r=e.z0[a],s=e.fv,i=e.pv,l=e.cvt[c];exports.DEBUG&&console.log(e.step,"MIAP["+n+"]",c,"(",l,")",a);var o=i.distance(r,W2);n&&(Math.abs(o-l)<e.cvCutIn&&(o=l),o=e.round(o)),s.setRelative(r,W2,o,i),e.zp0===0&&(r.xo=r.x,r.yo=r.y),s.touch(r),e.rp0=e.rp1=a}function Yt(n){var e=n.prog,t=n.ip,c=n.stack,a=e[++t];exports.DEBUG&&console.log(n.step,"NPUSHB[]",a);for(var r=0;r<a;r++)c.push(e[++t]);n.ip=t}function Kt(n){var e=n.ip,t=n.prog,c=n.stack,a=t[++e];exports.DEBUG&&console.log(n.step,"NPUSHW[]",a);for(var r=0;r<a;r++){var s=t[++e]<<8|t[++e];s&32768&&(s=-((s^65535)+1)),c.push(s)}n.ip=e}function Jt(n){var e=n.stack,t=n.store;t||(t=n.store=[]);var c=e.pop(),a=e.pop();exports.DEBUG&&console.log(n.step,"WS",c,a),t[a]=c}function Qt(n){var e=n.stack,t=n.store,c=e.pop();exports.DEBUG&&console.log(n.step,"RS",c);var a=t&&t[c]||0;e.push(a)}function en(n){var e=n.stack,t=e.pop(),c=e.pop();exports.DEBUG&&console.log(n.step,"WCVTP",t,c),n.cvt[c]=t/64}function tn(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"RCVT",t),e.push(n.cvt[t]*64)}function W6(n,e){var t=e.stack,c=t.pop(),a=e.z2[c];exports.DEBUG&&console.log(e.step,"GC["+n+"]",c),t.push(e.dpv.distance(a,W2,n,!1)*64)}function X6(n,e){var t=e.stack,c=t.pop(),a=t.pop(),r=e.z1[c],s=e.z0[a],i=e.dpv.distance(s,r,n,n);exports.DEBUG&&console.log(e.step,"MD["+n+"]",c,a,"->",i),e.stack.push(Math.round(i*64))}function nn(n){exports.DEBUG&&console.log(n.step,"MPPEM[]"),n.stack.push(n.ppem)}function cn(n){exports.DEBUG&&console.log(n.step,"FLIPON[]"),n.autoFlip=!0}function an(n){var e=n.stack,t=e.pop(),c=e.pop();exports.DEBUG&&console.log(n.step,"LT[]",t,c),e.push(c<t?1:0)}function rn(n){var e=n.stack,t=e.pop(),c=e.pop();exports.DEBUG&&console.log(n.step,"LTEQ[]",t,c),e.push(c<=t?1:0)}function sn(n){var e=n.stack,t=e.pop(),c=e.pop();exports.DEBUG&&console.log(n.step,"GT[]",t,c),e.push(c>t?1:0)}function ln(n){var e=n.stack,t=e.pop(),c=e.pop();exports.DEBUG&&console.log(n.step,"GTEQ[]",t,c),e.push(c>=t?1:0)}function on(n){var e=n.stack,t=e.pop(),c=e.pop();exports.DEBUG&&console.log(n.step,"EQ[]",t,c),e.push(t===c?1:0)}function hn(n){var e=n.stack,t=e.pop(),c=e.pop();exports.DEBUG&&console.log(n.step,"NEQ[]",t,c),e.push(t!==c?1:0)}function un(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 fn(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 dn(n){var e=n.stack.pop();exports.DEBUG&&console.log(n.step,"IF[]",e),e||($7(n,!0),exports.DEBUG&&console.log(n.step,"EIF[]"))}function pn(n){exports.DEBUG&&console.log(n.step,"EIF[]")}function mn(n){var e=n.stack,t=e.pop(),c=e.pop();exports.DEBUG&&console.log(n.step,"AND[]",t,c),e.push(t&&c?1:0)}function vn(n){var e=n.stack,t=e.pop(),c=e.pop();exports.DEBUG&&console.log(n.step,"OR[]",t,c),e.push(t||c?1:0)}function gn(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"NOT[]",t),e.push(t?0:1)}function E5(n,e){var t=e.stack,c=t.pop(),a=e.fv,r=e.pv,s=e.ppem,i=e.deltaBase+(n-1)*16,l=e.deltaShift,o=e.z0;exports.DEBUG&&console.log(e.step,"DELTAP["+n+"]",c,t);for(var h=0;h<c;h++){var f=t.pop(),u=t.pop(),d=i+((u&240)>>4);if(d===s){var p=(u&15)-8;p>=0&&p++,exports.DEBUG&&console.log(e.step,"DELTAPFIX",f,"by",p*l);var m=o[f];a.setRelative(m,m,p*l,r)}}}function yn(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"SDB[]",t),n.deltaBase=t}function bn(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"SDS[]",t),n.deltaShift=Math.pow(.5,t)}function Mn(n){var e=n.stack,t=e.pop(),c=e.pop();exports.DEBUG&&console.log(n.step,"ADD[]",t,c),e.push(c+t)}function xn(n){var e=n.stack,t=e.pop(),c=e.pop();exports.DEBUG&&console.log(n.step,"SUB[]",t,c),e.push(c-t)}function zn(n){var e=n.stack,t=e.pop(),c=e.pop();exports.DEBUG&&console.log(n.step,"DIV[]",t,c),e.push(c*64/t)}function wn(n){var e=n.stack,t=e.pop(),c=e.pop();exports.DEBUG&&console.log(n.step,"MUL[]",t,c),e.push(c*t/64)}function kn(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"ABS[]",t),e.push(Math.abs(t))}function Ln(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"NEG[]",t),e.push(-t)}function Sn(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"FLOOR[]",t),e.push(Math.floor(t/64)*64)}function An(n){var e=n.stack,t=e.pop();exports.DEBUG&&console.log(n.step,"CEILING[]",t),e.push(Math.ceil(t/64)*64)}function E3(n,e){var t=e.stack,c=t.pop();exports.DEBUG&&console.log(e.step,"ROUND[]"),t.push(e.round(c/64)*64)}function Cn(n){var e=n.stack,t=e.pop(),c=e.pop();exports.DEBUG&&console.log(n.step,"WCVTF[]",t,c),n.cvt[c]=t*n.ppem/n.font.unitsPerEm}function T5(n,e){var t=e.stack,c=t.pop(),a=e.ppem,r=e.deltaBase+(n-1)*16,s=e.deltaShift;exports.DEBUG&&console.log(e.step,"DELTAC["+n+"]",c,t);for(var i=0;i<c;i++){var l=t.pop(),o=t.pop(),h=r+((o&240)>>4);if(h===a){var f=(o&15)-8;f>=0&&f++;var u=f*s;exports.DEBUG&&console.log(e.step,"DELTACFIX",l,"by",u),e.cvt[l]+=u}}}function Pn(n){var e=n.stack.pop();exports.DEBUG&&console.log(n.step,"SROUND[]",e),n.round=B7;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 En(n){var e=n.stack.pop();exports.DEBUG&&console.log(n.step,"S45ROUND[]",e),n.round=B7;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 Tn(n){exports.DEBUG&&console.log(n.step,"ROFF[]"),n.round=ut}function In(n){exports.DEBUG&&console.log(n.step,"RUTG[]"),n.round=pt}function Hn(n){exports.DEBUG&&console.log(n.step,"RDTG[]"),n.round=mt}function Vn(n){var e=n.stack.pop();exports.DEBUG&&console.log(n.step,"SCANCTRL[]",e)}function Z6(n,e){var t=e.stack,c=t.pop(),a=t.pop(),r=e.z2[c],s=e.z1[a];exports.DEBUG&&console.log(e.step,"SDPVTL["+n+"]",c,a);var i,l;n?(i=r.y-s.y,l=s.x-r.x):(i=s.x-r.x,l=s.y-r.y),e.dpv=K2(i,l)}function On(n){var e=n.stack,t=e.pop(),c=0;exports.DEBUG&&console.log(n.step,"GETINFO[]",t),t&1&&(c=35),t&32&&(c|=4096),e.push(c)}function Fn(n){var e=n.stack,t=e.pop(),c=e.pop(),a=e.pop();exports.DEBUG&&console.log(n.step,"ROLL[]"),e.push(c),e.push(t),e.push(a)}function Dn(n){var e=n.stack,t=e.pop(),c=e.pop();exports.DEBUG&&console.log(n.step,"MAX[]",t,c),e.push(Math.max(c,t))}function Rn(n){var e=n.stack,t=e.pop(),c=e.pop();exports.DEBUG&&console.log(n.step,"MIN[]",t,c),e.push(Math.min(c,t))}function qn(n){var e=n.stack.pop();exports.DEBUG&&console.log(n.step,"SCANTYPE[]",e)}function Un(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 U0(n,e){var t=e.stack,c=e.prog,a=e.ip;exports.DEBUG&&console.log(e.step,"PUSHB["+n+"]");for(var r=0;r<n;r++)t.push(c[++a]);e.ip=a}function N0(n,e){var t=e.ip,c=e.prog,a=e.stack;exports.DEBUG&&console.log(e.ip,"PUSHW["+n+"]");for(var r=0;r<n;r++){var s=c[++t]<<8|c[++t];s&32768&&(s=-((s^65535)+1)),a.push(s)}e.ip=t}function R(n,e,t,c,a,r){var s=r.stack,i=n&&s.pop(),l=s.pop(),o=r.rp0,h=r.z0[o],f=r.z1[l],u=r.minDis,d=r.fv,p=r.dpv,m,v,g,b;v=m=p.distance(f,h,!0,!0),g=v>=0?1:-1,v=Math.abs(v),n&&(b=r.cvt[i],c&&Math.abs(v-b)<r.cvCutIn&&(v=b)),t&&v<u&&(v=u),c&&(v=r.round(v)),d.setRelative(f,h,g*v,p),d.touch(f),exports.DEBUG&&console.log(r.step,(n?"MIRP[":"MDRP[")+(e?"M":"m")+(t?">":"_")+(c?"R":"_")+(a===0?"Gr":a===1?"Bl":a===2?"Wh":"")+"]",n?i+"("+r.cvt[i]+","+b+")":"",l,"(d =",m,"->",g*v,")"),r.rp1=r.rp0,r.rp2=l,e&&(r.rp0=l)}R7=[O6.bind(void 0,H0),O6.bind(void 0,k0),F6.bind(void 0,H0),F6.bind(void 0,k0),D6.bind(void 0,H0),D6.bind(void 0,k0),R6.bind(void 0,0),R6.bind(void 0,1),q6.bind(void 0,0),q6.bind(void 0,1),gt,yt,bt,Mt,xt,zt,wt,kt,Lt,St,At,Ct,Pt,Et,Tt,It,Ht,Vt,Ot,Ft,void 0,void 0,Dt,P5,Rt,qt,Ut,$t,_t,void 0,void 0,void 0,Nt,Bt,Gt,void 0,U6.bind(void 0,0),U6.bind(void 0,1),N6.bind(void 0,H0),N6.bind(void 0,k0),B6.bind(void 0,0),B6.bind(void 0,1),$6.bind(void 0,0),$6.bind(void 0,1),_6.bind(void 0,0),_6.bind(void 0,1),jt,Wt,G6.bind(void 0,0),G6.bind(void 0,1),Xt,Zt,j6.bind(void 0,0),j6.bind(void 0,1),Yt,Kt,Jt,Qt,en,tn,W6.bind(void 0,0),W6.bind(void 0,1),void 0,X6.bind(void 0,0),X6.bind(void 0,1),nn,void 0,cn,void 0,void 0,an,rn,sn,ln,on,hn,un,fn,dn,pn,mn,vn,gn,E5.bind(void 0,1),yn,bn,Mn,xn,zn,wn,kn,Ln,Sn,An,E3.bind(void 0,0),E3.bind(void 0,1),E3.bind(void 0,2),E3.bind(void 0,3),void 0,void 0,void 0,void 0,Cn,E5.bind(void 0,2),E5.bind(void 0,3),T5.bind(void 0,1),T5.bind(void 0,2),T5.bind(void 0,3),Pn,En,void 0,void 0,Tn,void 0,In,Hn,P5,P5,void 0,void 0,void 0,void 0,void 0,Vn,Z6.bind(void 0,0),Z6.bind(void 0,1),On,void 0,Fn,Dn,Rn,qn,Un,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,U0.bind(void 0,1),U0.bind(void 0,2),U0.bind(void 0,3),U0.bind(void 0,4),U0.bind(void 0,5),U0.bind(void 0,6),U0.bind(void 0,7),U0.bind(void 0,8),N0.bind(void 0,1),N0.bind(void 0,2),N0.bind(void 0,3),N0.bind(void 0,4),N0.bind(void 0,5),N0.bind(void 0,6),N0.bind(void 0,7),N0.bind(void 0,8),R.bind(void 0,0,0,0,0,0),R.bind(void 0,0,0,0,0,1),R.bind(void 0,0,0,0,0,2),R.bind(void 0,0,0,0,0,3),R.bind(void 0,0,0,0,1,0),R.bind(void 0,0,0,0,1,1),R.bind(void 0,0,0,0,1,2),R.bind(void 0,0,0,0,1,3),R.bind(void 0,0,0,1,0,0),R.bind(void 0,0,0,1,0,1),R.bind(void 0,0,0,1,0,2),R.bind(void 0,0,0,1,0,3),R.bind(void 0,0,0,1,1,0),R.bind(void 0,0,0,1,1,1),R.bind(void 0,0,0,1,1,2),R.bind(void 0,0,0,1,1,3),R.bind(void 0,0,1,0,0,0),R.bind(void 0,0,1,0,0,1),R.bind(void 0,0,1,0,0,2),R.bind(void 0,0,1,0,0,3),R.bind(void 0,0,1,0,1,0),R.bind(void 0,0,1,0,1,1),R.bind(void 0,0,1,0,1,2),R.bind(void 0,0,1,0,1,3),R.bind(void 0,0,1,1,0,0),R.bind(void 0,0,1,1,0,1),R.bind(void 0,0,1,1,0,2),R.bind(void 0,0,1,1,0,3),R.bind(void 0,0,1,1,1,0),R.bind(void 0,0,1,1,1,1),R.bind(void 0,0,1,1,1,2),R.bind(void 0,0,1,1,1,3),R.bind(void 0,1,0,0,0,0),R.bind(void 0,1,0,0,0,1),R.bind(void 0,1,0,0,0,2),R.bind(void 0,1,0,0,0,3),R.bind(void 0,1,0,0,1,0),R.bind(void 0,1,0,0,1,1),R.bind(void 0,1,0,0,1,2),R.bind(void 0,1,0,0,1,3),R.bind(void 0,1,0,1,0,0),R.bind(void 0,1,0,1,0,1),R.bind(void 0,1,0,1,0,2),R.bind(void 0,1,0,1,0,3),R.bind(void 0,1,0,1,1,0),R.bind(void 0,1,0,1,1,1),R.bind(void 0,1,0,1,1,2),R.bind(void 0,1,0,1,1,3),R.bind(void 0,1,1,0,0,0),R.bind(void 0,1,1,0,0,1),R.bind(void 0,1,1,0,0,2),R.bind(void 0,1,1,0,0,3),R.bind(void 0,1,1,0,1,0),R.bind(void 0,1,1,0,1,1),R.bind(void 0,1,1,0,1,2),R.bind(void 0,1,1,0,1,3),R.bind(void 0,1,1,1,0,0),R.bind(void 0,1,1,1,0,1),R.bind(void 0,1,1,1,0,2),R.bind(void 0,1,1,1,0,3),R.bind(void 0,1,1,1,1,0),R.bind(void 0,1,1,1,1,1),R.bind(void 0,1,1,1,1,2),R.bind(void 0,1,1,1,1,3)];function b2(n){this.char=n,this.state={},this.activeState=null}function K5(n,e,t){this.contextName=t,this.startIndex=n,this.endOffset=e}function Nn(n,e,t){this.contextName=n,this.openRange=null,this.ranges=[],this.checkStart=e,this.checkEnd=t}function d0(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 U3(n){this.eventId=n,this.subscribers=[]}function Bn(n){var e=this,t=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];t.forEach(function(a){Object.defineProperty(e.events,a,{value:new U3(a)})}),n&&t.forEach(function(a){var r=n[a];typeof r=="function"&&e.events[a].subscribe(r)});var c=["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"];c.forEach(function(a){e.events[a].subscribe(e.updateContextsRanges)})}function L1(n){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],Bn.call(this,n)}b2.prototype.setState=function(n,e){return this.state[n]=e,this.activeState={key:n,value:this.state[n]},this.activeState};b2.prototype.getState=function(n){return this.state[n]||null};L1.prototype.inboundIndex=function(n){return n>=0&&n<this.tokens.length};L1.prototype.composeRUD=function(n){var e=this,t=!0,c=n.map(function(r){return e[r[0]].apply(e,r.slice(1).concat(t))}),a=function(r){return typeof r=="object"&&r.hasOwnProperty("FAIL")};if(c.every(a))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:c.filter(a)};this.dispatch("composeRUD",[c.filter(function(r){return!a(r)})])};L1.prototype.replaceRange=function(n,e,t,c){e=e!==null?e:this.tokens.length;var a=t.every(function(s){return s instanceof b2});if(!isNaN(n)&&this.inboundIndex(n)&&a){var r=this.tokens.splice.apply(this.tokens,[n,e].concat(t));return c||this.dispatch("replaceToken",[n,e,t]),[r,t]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}};L1.prototype.replaceToken=function(n,e,t){if(!isNaN(n)&&this.inboundIndex(n)&&e instanceof b2){var c=this.tokens.splice(n,1,e);return t||this.dispatch("replaceToken",[n,e]),[c[0],e]}else return{FAIL:"replaceToken: invalid token or index."}};L1.prototype.removeRange=function(n,e,t){e=isNaN(e)?this.tokens.length:e;var c=this.tokens.splice(n,e);return t||this.dispatch("removeRange",[c,n,e]),c};L1.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."}};L1.prototype.insertToken=function(n,e,t){var c=n.every(function(a){return a instanceof b2});return c?(this.tokens.splice.apply(this.tokens,[e,0].concat(n)),t||this.dispatch("insertToken",[n,e]),n):{FAIL:"insertToken: invalid token(s)."}};L1.prototype.registerModifier=function(n,e,t){this.events.newToken.subscribe(function(c,a){var r=[c,a],s=e===null||e.apply(this,r)===!0,i=[c,a];if(s){var l=t.apply(this,i);c.setState(n,l)}}),this.registeredModifiers.push(n)};U3.prototype.subscribe=function(n){return typeof n=="function"?this.subscribers.push(n)-1:{FAIL:"invalid '"+this.eventId+"' event handler"}};U3.prototype.unsubscribe=function(n){this.subscribers.splice(n,1)};d0.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)};d0.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}};L1.prototype.rangeToText=function(n){if(n instanceof K5)return this.getRangeTokens(n).map(function(e){return e.char}).join("")};L1.prototype.getText=function(){return this.tokens.map(function(n){return n.char}).join("")};L1.prototype.getContext=function(n){var e=this.registeredContexts[n];return e||null};L1.prototype.on=function(n,e){var t=this.events[n];return t?t.subscribe(e):null};L1.prototype.dispatch=function(n,e){var t=this,c=this.events[n];c instanceof U3&&c.subscribers.forEach(function(a){a.apply(t,e||[])})};L1.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 c=new Nn(n,e,t);return this.registeredContexts[n]=c,this.contextCheckers.push(c),c};L1.prototype.getRangeTokens=function(n){var e=n.startIndex+n.endOffset;return[].concat(this.tokens.slice(n.startIndex,e))};L1.prototype.getContextRanges=function(n){var e=this.getContext(n);return e?e.ranges:{FAIL:"context checker '"+n+"' is not registered."}};L1.prototype.resetContextsRanges=function(){var n=this.registeredContexts;for(var e in n)if(n.hasOwnProperty(e)){var t=n[e];t.ranges=[]}};L1.prototype.updateContextsRanges=function(){this.resetContextsRanges();for(var n=this.tokens.map(function(c){return c.char}),e=0;e<n.length;e++){var t=new d0(n,e);this.runContextCheck(t)}this.dispatch("updateContextsRanges",[this.registeredContexts])};L1.prototype.setEndOffset=function(n,e){var t=this.getContext(e).openRange.startIndex,c=new K5(t,n,e),a=this.getContext(e).ranges;return c.rangeId=e+"."+a.length,a.push(c),this.getContext(e).openRange=null,c};L1.prototype.runContextCheck=function(n){var e=this,t=n.index;this.contextCheckers.forEach(function(c){var a=c.contextName,r=e.getContext(a).openRange;if(!r&&c.checkStart(n)&&(r=new K5(t,null,a),e.getContext(a).openRange=r,e.dispatch("contextStart",[a,t])),r&&c.checkEnd(n)){var s=t-r.startIndex+1,i=e.setEndOffset(s,a);e.dispatch("contextEnd",[a,i])}})};L1.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 c=e[t],a=new d0(e,t);this.dispatch("next",[a]),this.runContextCheck(a);var r=new b2(c);this.tokens.push(r),this.dispatch("newToken",[r,a])}return this.dispatch("end",[this.tokens]),this.tokens};function _0(n){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(n)}function _7(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 G0(n){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(n)}function I3(n){return/[A-z]/.test(n)}function $n(n){return/\s/.test(n)}function t0(n){this.font=n,this.features={}}function n2(n){this.id=n.id,this.tag=n.tag,this.substitution=n.substitution}function J2(n,e){if(!n)return-1;switch(e.format){case 1:return e.glyphs.indexOf(n);case 2:for(var t=e.ranges,c=0;c<t.length;c++){var a=t[c];if(n>=a.start&&n<=a.end){var r=n-a.start;return a.index+r}}break;default:return-1}return-1}function _n(n,e){var t=J2(n,e.coverage);return t===-1?null:n+e.deltaGlyphId}function Gn(n,e){var t=J2(n,e.coverage);return t===-1?null:e.substitute[t]}function I5(n,e){for(var t=[],c=0;c<n.length;c++){var a=n[c],r=e.current;r=Array.isArray(r)?r[0]:r;var s=J2(r,a);s!==-1&&t.push(s)}return t.length!==n.length?-1:t}function jn(n,e){var t=e.inputCoverage.length+e.lookaheadCoverage.length+e.backtrackCoverage.length;if(n.context.length<t)return[];var c=I5(e.inputCoverage,n);if(c===-1)return[];var a=e.inputCoverage.length-1;if(n.lookahead.length<e.lookaheadCoverage.length)return[];for(var r=n.lookahead.slice(a);r.length&&G0(r[0].char);)r.shift();var s=new d0(r,0),i=I5(e.lookaheadCoverage,s),l=[].concat(n.backtrack);for(l.reverse();l.length&&G0(l[0].char);)l.shift();if(l.length<e.backtrackCoverage.length)return[];var o=new d0(l,0),h=I5(e.backtrackCoverage,o),f=c.length===e.inputCoverage.length&&i.length===e.lookaheadCoverage.length&&h.length===e.backtrackCoverage.length,u=[];if(f)for(var d=0;d<e.lookupRecords.length;d++)for(var p=e.lookupRecords[d],m=p.lookupListIndex,v=this.getLookupByIndex(m),g=0;g<v.subtables.length;g++){var b=v.subtables[g],y=this.getLookupMethod(v,b),w=this.getSubstitutionType(v,b);if(w==="12")for(var k=0;k<c.length;k++){var P=n.get(k),S=y(P);S&&u.push(S)}}return u}function Wn(n,e){var t=n.current,c=J2(t,e.coverage);if(c===-1)return null;for(var a,r=e.ligatureSets[c],s=0;s<r.length;s++){a=r[s];for(var i=0;i<a.components.length;i++){var l=n.lookahead[i],o=a.components[i];if(l!==o)break;if(i===a.components.length-1)return a}}return null}function Xn(n,e){var t=J2(n,e.coverage);return t===-1?null:e.sequences[t]}t0.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[]};t0.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,c=0;c<t.length;c++){var a=t[c];if(a.tag===n&&a.script.defaultLangSys)return a.script.defaultLangSys.featureIndexes;var r=a.langSysRecords;if(r)for(var s=0;s<r.length;s++){var i=r[s];if(i.tag===n){var l=i.langSys;return l.featureIndexes}}}return this.getDefaultScriptFeaturesIndexes()};t0.prototype.mapTagsToFeatures=function(n,e){for(var t={},c=0;c<n.length;c++){var a=n[c].tag,r=n[c].feature;t[a]=r}this.features[e].tags=t};t0.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 c=this.font.tables.gsub;return e=t.map(function(a){return c.features[a]}),this.features[n]=e,this.mapTagsToFeatures(e,n),e};t0.prototype.getSubstitutionType=function(n,e){var t=n.lookupType.toString(),c=e.substFormat.toString();return t+c};t0.prototype.getLookupMethod=function(n,e){var t=this,c=this.getSubstitutionType(n,e);switch(c){case"11":return function(a){return _n.apply(t,[a,e])};case"12":return function(a){return Gn.apply(t,[a,e])};case"63":return function(a){return jn.apply(t,[a,e])};case"41":return function(a){return Wn.apply(t,[a,e])};case"21":return function(a){return Xn.apply(t,[a,e])};default:throw new Error("lookupType: "+n.lookupType+" - substFormat: "+e.substFormat+" is not yet supported")}};t0.prototype.lookupFeature=function(n){var e=n.contextParams,t=e.index,c=this.getFeature({tag:n.tag,script:n.script});if(!c)return new Error("font '"+this.font.names.fullName.en+"' doesn't support feature '"+n.tag+"' for script '"+n.script+"'.");for(var a=this.getFeatureLookups(c),r=[].concat(e.context),s=0;s<a.length;s++)for(var i=a[s],l=this.getLookupSubtables(i),o=0;o<l.length;o++){var h=l[o],f=this.getSubstitutionType(i,h),u=this.getLookupMethod(i,h),d=void 0;switch(f){case"11":d=u(e.current),d&&r.splice(t,1,new n2({id:11,tag:n.tag,substitution:d}));break;case"12":d=u(e.current),d&&r.splice(t,1,new n2({id:12,tag:n.tag,substitution:d}));break;case"63":d=u(e),Array.isArray(d)&&d.length&&r.splice(t,1,new n2({id:63,tag:n.tag,substitution:d}));break;case"41":d=u(e),d&&r.splice(t,1,new n2({id:41,tag:n.tag,substitution:d}));break;case"21":d=u(e.current),d&&r.splice(t,1,new n2({id:21,tag:n.tag,substitution:d}));break}e=new d0(r,t),!(Array.isArray(d)&&!d.length)&&(d=null)}return r.length?r:null};t0.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(c){return c.tag===n.tag});return e&&t};t0.prototype.getLookupSubtables=function(n){return n.subtables||null};t0.prototype.getLookupByIndex=function(n){var e=this.font.tables.gsub.lookups;return e[n]||null};t0.prototype.getFeatureLookups=function(n){return n.lookupListIndexes.map(this.getLookupByIndex.bind(this))};t0.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 Zn(n){var e=n.current,t=n.get(-1);return t===null&&_0(e)||!_0(t)&&_0(e)}function Yn(n){var e=n.get(1);return e===null||!_0(e)}var Kn={startCheck:Zn,endCheck:Yn};function Jn(n){var e=n.current,t=n.get(-1);return(_0(e)||G0(e))&&!_0(t)}function Qn(n){var e=n.get(1);switch(!0){case e===null:return!0;case(!_0(e)&&!G0(e)):var t=$n(e);if(!t)return!0;if(t){var c=!1;if(c=n.lookahead.some(function(a){return _0(a)||G0(a)}),!c)return!0}break;default:return!1}}var ec={startCheck:Jn,endCheck:Qn};function tc(n,e,t){e[t].setState(n.tag,n.substitution)}function nc(n,e,t){e[t].setState(n.tag,n.substitution)}function cc(n,e,t){n.substitution.forEach(function(c,a){var r=e[t+a];r.setState(n.tag,c)})}function ac(n,e,t){var c=e[t];c.setState(n.tag,n.substitution.ligGlyph);for(var a=n.substitution.components.length,r=0;r<a;r++)c=e[t+r+1],c.setState("deleted",!0)}var Y6={11:tc,12:nc,63:cc,41:ac};function J5(n,e,t){n instanceof n2&&Y6[n.id]&&Y6[n.id](n,e,t)}function rc(n){for(var e=[].concat(n.backtrack),t=e.length-1;t>=0;t--){var c=e[t],a=_7(c),r=G0(c);if(!a&&!r)return!0;if(a)return!1}return!1}function sc(n){if(_7(n.current))return!1;for(var e=0;e<n.lookahead.length;e++){var t=n.lookahead[e],c=G0(t);if(!c)return!0}return!1}function ic(n){var e=this,t="arab",c=this.featuresTags[t],a=this.tokenizer.getRangeTokens(n);if(a.length!==1){var r=new d0(a.map(function(i){return i.getState("glyphIndex")}),0),s=new d0(a.map(function(i){return i.char}),0);a.forEach(function(i,l){if(!G0(i.char)){r.setCurrentIndex(l),s.setCurrentIndex(l);var o=0;rc(s)&&(o|=1),sc(s)&&(o|=2);var h;switch(o){case 1:h="fina";break;case 2:h="init";break;case 3:h="medi";break}if(c.indexOf(h)!==-1){var f=e.query.lookupFeature({tag:h,script:t,contextParams:r});if(f instanceof Error)return console.info(f.message);f.forEach(function(u,d){u instanceof n2&&(J5(u,a,d),r.context[d]=u.substitution)})}}})}}function K6(n,e){var t=n.map(function(c){return c.activeState.value});return new d0(t,e||0)}function lc(n){var e=this,t="arab",c=this.tokenizer.getRangeTokens(n),a=K6(c);a.context.forEach(function(r,s){a.setCurrentIndex(s);var i=e.query.lookupFeature({tag:"rlig",script:t,contextParams:a});i.length&&(i.forEach(function(l){return J5(l,c,s)}),a=K6(c))})}function oc(n){var e=n.current,t=n.get(-1);return t===null&&I3(e)||!I3(t)&&I3(e)}function hc(n){var e=n.get(1);return e===null||!I3(e)}var uc={startCheck:oc,endCheck:hc};function J6(n,e){var t=n.map(function(c){return c.activeState.value});return new d0(t,e||0)}function fc(n){var e=this,t="latn",c=this.tokenizer.getRangeTokens(n),a=J6(c);a.context.forEach(function(r,s){a.setCurrentIndex(s);var i=e.query.lookupFeature({tag:"liga",script:t,contextParams:a});i.length&&(i.forEach(function(l){return J5(l,c,s)}),a=J6(c))})}function v0(n){this.baseDir=n||"ltr",this.tokenizer=new L1,this.featuresTags={}}v0.prototype.setText=function(n){this.text=n};v0.prototype.contextChecks={latinWordCheck:uc,arabicWordCheck:Kn,arabicSentenceCheck:ec};function H5(n){var e=this.contextChecks[n+"Check"];return this.tokenizer.registerContextChecker(n,e.startCheck,e.endCheck)}function dc(){return H5.call(this,"latinWord"),H5.call(this,"arabicWord"),H5.call(this,"arabicSentence"),this.tokenizer.tokenize(this.text)}function pc(){var n=this,e=this.tokenizer.getContextRanges("arabicSentence");e.forEach(function(t){var c=n.tokenizer.getRangeTokens(t);n.tokenizer.replaceRange(t.startIndex,t.endOffset,c.reverse())})}v0.prototype.registerFeatures=function(n,e){var t=this,c=e.filter(function(a){return t.query.supports({script:n,tag:a})});this.featuresTags.hasOwnProperty(n)?this.featuresTags[n]=this.featuresTags[n].concat(c):this.featuresTags[n]=c};v0.prototype.applyFeatures=function(n,e){if(!n)throw new Error("No valid font was provided to apply features");this.query||(this.query=new t0(n));for(var t=0;t<e.length;t++){var c=e[t];this.query.supports({script:c.script})&&this.registerFeatures(c.script,c.tags)}};v0.prototype.registerModifier=function(n,e,t){this.tokenizer.registerModifier(n,e,t)};function Q5(){if(this.tokenizer.registeredModifiers.indexOf("glyphIndex")===-1)throw new Error("glyphIndex modifier is required to apply arabic presentation features.")}function mc(){var n=this,e="arab";if(this.featuresTags.hasOwnProperty(e)){Q5.call(this);var t=this.tokenizer.getContextRanges("arabicWord");t.forEach(function(c){ic.call(n,c)})}}function vc(){var n=this,e="arab";if(this.featuresTags.hasOwnProperty(e)){var t=this.featuresTags[e];if(t.indexOf("rlig")!==-1){Q5.call(this);var c=this.tokenizer.getContextRanges("arabicWord");c.forEach(function(a){lc.call(n,a)})}}}function gc(){var n=this,e="latn";if(this.featuresTags.hasOwnProperty(e)){var t=this.featuresTags[e];if(t.indexOf("liga")!==-1){Q5.call(this);var c=this.tokenizer.getContextRanges("latinWord");c.forEach(function(a){fc.call(n,a)})}}}v0.prototype.checkContextReady=function(n){return!!this.tokenizer.getContext(n)};v0.prototype.applyFeaturesToContexts=function(){this.checkContextReady("arabicWord")&&(mc.call(this),vc.call(this)),this.checkContextReady("latinWord")&&gc.call(this),this.checkContextReady("arabicSentence")&&pc.call(this)};v0.prototype.processText=function(n){(!this.text||this.text!==n)&&(this.setText(n),dc.call(this),this.applyFeaturesToContexts())};v0.prototype.getBidiText=function(n){return this.processText(n),this.tokenizer.getText()};v0.prototype.getTextGlyphs=function(n){this.processText(n);for(var e=[],t=0;t<this.tokenizer.tokens.length;t++){var c=this.tokenizer.tokens[t];if(!c.state.deleted){var a=c.activeState.value;e.push(Array.isArray(a)?a[0]:a)}}return e};function b1(n){n=n||{},n.tables=n.tables||{},n.empty||(B2(n.familyName,"When creating a new Font object, familyName is required."),B2(n.styleName,"When creating a new Font object, styleName is required."),B2(n.unitsPerEm,"When creating a new Font object, unitsPerEm is required."),B2(n.ascender,"When creating a new Font object, ascender is required."),B2(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 L0.GlyphSet(this,n.glyphs||[]),this.encoding=new o7(this),this.position=new Z2(this),this.substitution=new e0(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 U7(this)}})}b1.prototype.hasChar=function(n){return this.encoding.charToGlyphIndex(n)!==null};b1.prototype.charToGlyphIndex=function(n){return this.encoding.charToGlyphIndex(n)};b1.prototype.charToGlyph=function(n){var e=this.charToGlyphIndex(n),t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t};b1.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})};b1.prototype.stringToGlyphs=function(n,e){var t=this,c=new v0,a=function(f){return t.charToGlyphIndex(f.char)};c.registerModifier("glyphIndex",null,a);var r=e?this.updateFeatures(e.features):this.defaultRenderOptions.features;c.applyFeatures(this,r);for(var s=c.getTextGlyphs(n),i=s.length,l=new Array(i),o=this.glyphs.get(0),h=0;h<i;h+=1)l[h]=this.glyphs.get(s[h])||o;return l};b1.prototype.nameToGlyphIndex=function(n){return this.glyphNames.nameToGlyphIndex(n)};b1.prototype.nameToGlyph=function(n){var e=this.nameToGlyphIndex(n),t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t};b1.prototype.glyphIndexToName=function(n){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(n):""};b1.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};b1.prototype.defaultRenderOptions={kerning:!0,features:[{script:"arab",tags:["init","medi","fina","rlig"]},{script:"latn",tags:["liga","rlig"]}]};b1.prototype.forEachGlyph=function(n,e,t,c,a,r){e=e!==void 0?e:0,t=t!==void 0?t:0,c=c!==void 0?c:72,a=Object.assign({},this.defaultRenderOptions,a);var s=1/this.unitsPerEm*c,i=this.stringToGlyphs(n,a),l;if(a.kerning){var o=a.script||this.position.getDefaultScriptName();l=this.position.getKerningTables(o,a.language)}for(var h=0;h<i.length;h+=1){var f=i[h];if(r.call(this,f,e,t,c,a),f.advanceWidth&&(e+=f.advanceWidth*s),a.kerning&&h<i.length-1){var u=l?this.position.getKerningValue(l,f.index,i[h+1].index):this.getKerningValue(f,i[h+1]);e+=u*s}a.letterSpacing?e+=a.letterSpacing*c:a.tracking&&(e+=a.tracking/1e3*c)}return e};b1.prototype.getPath=function(n,e,t,c,a){var r=new E1;return this.forEachGlyph(n,e,t,c,a,function(s,i,l,o){var h=s.getPath(i,l,o,a,this);r.extend(h)}),r};b1.prototype.getPaths=function(n,e,t,c,a){var r=[];return this.forEachGlyph(n,e,t,c,a,function(s,i,l,o){var h=s.getPath(i,l,o,a,this);r.push(h)}),r};b1.prototype.getAdvanceWidth=function(n,e,t){return this.forEachGlyph(n,0,0,e,t,function(){})};b1.prototype.draw=function(n,e,t,c,a,r){this.getPath(e,t,c,a,r).draw(n)};b1.prototype.drawPoints=function(n,e,t,c,a,r){this.forEachGlyph(e,t,c,a,r,function(s,i,l,o){s.drawPoints(n,i,l,o)})};b1.prototype.drawMetrics=function(n,e,t,c,a,r){this.forEachGlyph(e,t,c,a,r,function(s,i,l,o){s.drawMetrics(n,i,l,o)})};b1.prototype.getEnglishName=function(n){var e=this.names[n];if(e)return e.en};b1.prototype.validate=function(){var n=this;function e(c,a){}function t(c){var a=n.getEnglishName(c);a&&a.trim().length>0}t("fontFamily"),t("weightName"),t("manufacturer"),t("copyright"),t("version"),this.unitsPerEm>0};b1.prototype.toTables=function(){return ct.fontToTable(this)};b1.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()};b1.prototype.toArrayBuffer=function(){for(var n=this.toTables(),e=n.encode(),t=new ArrayBuffer(e.length),c=new Uint8Array(t),a=0;a<e.length;a++)c[a]=e[a];return t};b1.prototype.download=function(n){var e=this.getEnglishName("fontFamily"),t=this.getEnglishName("fontSubfamily");n=n||e.replace(/\s/g,"")+"-"+t+".otf";var c=this.toArrayBuffer();if(rt())if(window.URL=window.URL||window.webkitURL,window.URL){var a=new DataView(c),r=new Blob([a],{type:"font/opentype"}),s=document.createElement("a");s.href=window.URL.createObjectURL(r),s.download=n;var i=document.createEvent("MouseEvents");i.initEvent("click",!0,!1),s.dispatchEvent(i)}else console.warn("Font file could not be downloaded. Try using a different browser.");else{var l=p6(),o=st(c);l.writeFileSync(n,o)}};b1.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512};b1.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};b1.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};function G7(n,e){var t=JSON.stringify(n),c=256;for(var a in e){var r=parseInt(a);if(!(!r||r<256)){if(JSON.stringify(e[a])===t)return r;c<=r&&(c=r+1)}}return e[c]=n,c}function yc(n,e,t){var c=G7(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:c}]}function bc(n,e,t){var c={},a=new q.Parser(n,e);return c.tag=a.parseTag(),c.minValue=a.parseFixed(),c.defaultValue=a.parseFixed(),c.maxValue=a.parseFixed(),a.skip("uShort",1),c.name=t[a.parseUShort()]||{},c}function Mc(n,e,t,c){for(var a=G7(e.name,c),r=[{name:"nameID_"+n,type:"USHORT",value:a},{name:"flags_"+n,type:"USHORT",value:0}],s=0;s<t.length;++s){var i=t[s].tag;r.push({name:"axis_"+n+" "+i,type:"FIXED",value:e.coordinates[i]<<16})}return r}function xc(n,e,t,c){var a={},r=new q.Parser(n,e);a.name=c[r.parseUShort()]||{},r.skip("uShort",1),a.coordinates={};for(var s=0;s<t.length;++s)a.coordinates[t[s].tag]=r.parseFixed();return a}function zc(n,e){var t=new O.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 c=0;c<n.axes.length;c++)t.fields=t.fields.concat(yc(c,n.axes[c],e));for(var a=0;a<n.instances.length;a++)t.fields=t.fields.concat(Mc(a,n.instances[a],n.axes,e));return t}function wc(n,e,t){var c=new q.Parser(n,e),a=c.parseULong();W.argument(a===65536,"Unsupported fvar table version.");var r=c.parseOffset16();c.skip("uShort",1);for(var s=c.parseUShort(),i=c.parseUShort(),l=c.parseUShort(),o=c.parseUShort(),h=[],f=0;f<s;f++)h.push(bc(n,e+r+f*i,t));for(var u=[],d=e+r+s*i,p=0;p<l;p++)u.push(xc(n,d+p*o,h,t));return{axes:h,instances:u}}var kc={make:zc,parse:wc},Lc=function(){return{coverage:this.parsePointer(C.coverage),attachPoints:this.parseList(C.pointer(C.uShortList))}},Sc=function(){var n=this.parseUShort();if(W.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()}},Ac=function(){return this.parseList(C.pointer(Sc))},Cc=function(){return{coverage:this.parsePointer(C.coverage),ligGlyphs:this.parseList(C.pointer(Ac))}},Pc=function(){return this.parseUShort(),this.parseList(C.pointer(C.coverage))};function Ec(n,e){e=e||0;var t=new C(n,e),c=t.parseVersion(1);W.argument(c===1||c===1.2||c===1.3,"Unsupported GDEF table version.");var a={version:c,classDef:t.parsePointer(C.classDef),attachList:t.parsePointer(Lc),ligCaretList:t.parsePointer(Cc),markAttachClassDef:t.parsePointer(C.classDef)};return c>=1.2&&(a.markGlyphSets=t.parsePointer(Pc)),a}var Tc={parse:Ec},p0=new Array(10);p0[1]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{posFormat:1,coverage:this.parsePointer(C.coverage),value:this.parseValueRecord()};if(t===2)return{posFormat:2,coverage:this.parsePointer(C.coverage),values:this.parseValueRecordList()};W.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")};p0[2]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();W.assert(t===1||t===2,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");var c=this.parsePointer(C.coverage),a=this.parseUShort(),r=this.parseUShort();if(t===1)return{posFormat:t,coverage:c,valueFormat1:a,valueFormat2:r,pairSets:this.parseList(C.pointer(C.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(a),value2:this.parseValueRecord(r)}})))};if(t===2){var s=this.parsePointer(C.classDef),i=this.parsePointer(C.classDef),l=this.parseUShort(),o=this.parseUShort();return{posFormat:t,coverage:c,valueFormat1:a,valueFormat2:r,classDef1:s,classDef2:i,class1Count:l,class2Count:o,classRecords:this.parseList(l,C.list(o,function(){return{value1:this.parseValueRecord(a),value2:this.parseValueRecord(r)}}))}}};p0[3]=function(){return{error:"GPOS Lookup 3 not supported"}};p0[4]=function(){return{error:"GPOS Lookup 4 not supported"}};p0[5]=function(){return{error:"GPOS Lookup 5 not supported"}};p0[6]=function(){return{error:"GPOS Lookup 6 not supported"}};p0[7]=function(){return{error:"GPOS Lookup 7 not supported"}};p0[8]=function(){return{error:"GPOS Lookup 8 not supported"}};p0[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function Ic(n,e){e=e||0;var t=new C(n,e),c=t.parseVersion(1);return W.argument(c===1||c===1.1,"Unsupported GPOS table version "+c),c===1?{version:c,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(p0)}:{version:c,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(p0),variations:t.parseFeatureVariationsList()}}var Hc=new Array(10);function Vc(n){return new O.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new O.ScriptList(n.scripts)},{name:"features",type:"TABLE",value:new O.FeatureList(n.features)},{name:"lookups",type:"TABLE",value:new O.LookupList(n.lookups,Hc)}])}var Oc={parse:Ic,make:Vc};function Fc(n){var e={};n.skip("uShort");var t=n.parseUShort();W.argument(t===0,"Unsupported kern sub-table version."),n.skip("uShort",2);var c=n.parseUShort();n.skip("uShort",3);for(var a=0;a<c;a+=1){var r=n.parseUShort(),s=n.parseUShort(),i=n.parseShort();e[r+","+s]=i}return e}function Dc(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 c=n.parseUShort(),a=c&255;if(n.skip("uShort"),a===0){var r=n.parseUShort();n.skip("uShort",3);for(var s=0;s<r;s+=1){var i=n.parseUShort(),l=n.parseUShort(),o=n.parseShort();e[i+","+l]=o}}return e}function Rc(n,e){var t=new q.Parser(n,e),c=t.parseUShort();if(c===0)return Fc(t);if(c===1)return Dc(t);throw new Error("Unsupported kern table version ("+c+").")}var qc={parse:Rc};function Uc(n,e,t,c){for(var a=new q.Parser(n,e),r=c?a.parseUShort:a.parseULong,s=[],i=0;i<t+1;i+=1){var l=r.call(a);c&&(l*=2),s.push(l)}return s}var Nc={parse:Uc};function Q6(n,e){for(var t=[],c=12,a=0;a<e;a+=1){var r=q.getTag(n,c),s=q.getULong(n,c+4),i=q.getULong(n,c+8),l=q.getULong(n,c+12);t.push({tag:r,checksum:s,offset:i,length:l,compression:!1}),c+=16}return t}function Bc(n,e){for(var t=[],c=44,a=0;a<e;a+=1){var r=q.getTag(n,c),s=q.getULong(n,c+4),i=q.getULong(n,c+8),l=q.getULong(n,c+12),o=void 0;i<l?o="WOFF":o=!1,t.push({tag:r,offset:s,compression:o,compressedLength:i,length:l}),c+=20}return t}function A1(n,e){if(e.compression==="WOFF"){var t=new Uint8Array(n.buffer,e.offset+2,e.compressedLength-2),c=new Uint8Array(e.length);if(V9(t,c),c.byteLength!==e.length)throw new Error("Decompression error: "+e.tag+" decompressed length doesn't match recorded length");var a=new DataView(c.buffer,0);return{data:a,offset:0}}else return{data:n,offset:e.offset}}function j7(n,e){e=e??{};var t,c,a=new b1({empty:!0}),r=new DataView(n,0),s,i=[],l=q.getTag(r,0);if(l==="\0\0\0"||l==="true"||l==="typ1")a.outlinesFormat="truetype",s=q.getUShort(r,4),i=Q6(r,s);else if(l==="OTTO")a.outlinesFormat="cff",s=q.getUShort(r,4),i=Q6(r,s);else if(l==="wOFF"){var o=q.getTag(r,4);if(o==="\0\0\0")a.outlinesFormat="truetype";else if(o==="OTTO")a.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+l);s=q.getUShort(r,12),i=Bc(r,s)}else throw new Error("Unsupported OpenType signature "+l);for(var h,f,u,d,p,m,v,g,b,y,w,k,P=0;P<s;P+=1){var S=i[P],A=void 0;switch(S.tag){case"cmap":A=A1(r,S),a.tables.cmap=l7.parse(A.data,A.offset),a.encoding=new h7(a.tables.cmap);break;case"cvt ":A=A1(r,S),k=new q.Parser(A.data,A.offset),a.tables.cvt=k.parseShortList(S.length/2);break;case"fvar":f=S;break;case"fpgm":A=A1(r,S),k=new q.Parser(A.data,A.offset),a.tables.fpgm=k.parseByteList(S.length);break;case"head":A=A1(r,S),a.tables.head=M7.parse(A.data,A.offset),a.unitsPerEm=a.tables.head.unitsPerEm,t=a.tables.head.indexToLocFormat;break;case"hhea":A=A1(r,S),a.tables.hhea=x7.parse(A.data,A.offset),a.ascender=a.tables.hhea.ascender,a.descender=a.tables.hhea.descender,a.numberOfHMetrics=a.tables.hhea.numberOfHMetrics;break;case"hmtx":v=S;break;case"ltag":A=A1(r,S),c=w7.parse(A.data,A.offset);break;case"maxp":A=A1(r,S),a.tables.maxp=k7.parse(A.data,A.offset),a.numGlyphs=a.tables.maxp.numGlyphs;break;case"name":y=S;break;case"OS/2":A=A1(r,S),a.tables.os2=N5.parse(A.data,A.offset);break;case"post":A=A1(r,S),a.tables.post=E7.parse(A.data,A.offset),a.glyphNames=new W5(a.tables.post);break;case"prep":A=A1(r,S),k=new q.Parser(A.data,A.offset),a.tables.prep=k.parseByteList(S.length);break;case"glyf":u=S;break;case"loca":b=S;break;case"CFF ":h=S;break;case"kern":g=S;break;case"GDEF":d=S;break;case"GPOS":p=S;break;case"GSUB":m=S;break;case"meta":w=S;break}}var E=A1(r,y);if(a.tables.name=P7.parse(E.data,E.offset,c),a.names=a.tables.name,u&&b){var z=t===0,I=A1(r,b),$=Nc.parse(I.data,I.offset,a.numGlyphs,z),F=A1(r,u);a.glyphs=D7.parse(F.data,F.offset,$,a,e)}else if(h){var _=A1(r,h);b7.parse(_.data,_.offset,a,e)}else throw new Error("Font doesn't contain TrueType or CFF outlines.");var Y=A1(r,v);if(z7.parse(a,Y.data,Y.offset,a.numberOfHMetrics,a.numGlyphs,a.glyphs,e),te(a,e),g){var N=A1(r,g);a.kerningPairs=qc.parse(N.data,N.offset)}else a.kerningPairs={};if(d){var i1=A1(r,d);a.tables.gdef=Tc.parse(i1.data,i1.offset)}if(p){var h1=A1(r,p);a.tables.gpos=Oc.parse(h1.data,h1.offset),a.position.init()}if(m){var U=A1(r,m);a.tables.gsub=T7.parse(U.data,U.offset)}if(f){var c1=A1(r,f);a.tables.fvar=kc.parse(c1.data,c1.offset,a.names)}if(w){var X=A1(r,w);a.tables.meta=I7.parse(X.data,X.offset),a.metas=a.tables.meta}return a}var N3=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 c=this.parsed.get(t);if(c)return c;let a=K1(this.sources,t);if(!a)throw this.missing.add(t),new Error(`Font "${t}" is not available.${this.names().length?` Available fonts: ${this.names().join(", ")}`:""}`);let r=a instanceof Uint8Array?a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength):a,s=j7(r);return this.parsed.set(t,s),s}};function $c(n,e,t){let c={kerning:!0};if(t.spacing===1)return{cmds:n.getPath(e,0,0,t.size,c).commands,advance:n.getAdvanceWidth(e,t.size,c)};let a=[],r=0,s=[...e];return s.forEach((i,l)=>{a.push(...n.getPath(i,r,0,t.size,c).commands),r+=n.getAdvanceWidth(i,t.size,c)*(l<s.length-1?t.spacing:1)}),{cmds:a,advance:r}}function W7(n,e,t){let{cmds:c,advance:a}=$c(n,e,t),r=c.map(i=>i.type==="Z"?i:i.type==="C"?{...i,y1:-i.y1,y2:-i.y2,y:-i.y}:i.type==="Q"?{...i,y1:-i.y1,y:-i.y}:{...i,y:-i.y}),s=o2(r,Math.max(.005,t.size/2e3));return{polys:[...s.closed,...s.open.filter(i=>i.length>=3)],advance:a}}function B3(n,e,t){if(!e)return[];let c=n.get(t.font),{polys:a,advance:r}=W7(c,e,t),s=r1(a),i=x0(s);if(!i)return[];let l=t.halign==="center"?-r/2:t.halign==="right"?-r:0,o=t.valign==="top"?-i[3]:t.valign==="center"?-(i[1]+i[3])/2:t.valign==="bottom"?-i[1]:0;return s.map(h=>h.map(([f,u])=>[f+l,u+o]))}function e4(n,e,t){let c=n.get(t.font),{polys:a,advance:r}=W7(c,e,t),s=x0(a)??[0,0,0,0];return{advance:r,bounds:[[s[0],s[1]],[s[2],s[3]]],ascent:c.ascender/c.unitsPerEm*t.size,descent:c.descender/c.unitsPerEm*t.size}}var t4=128,r4=[{name:"engrave",mode:"fill",color:"#000000"},{name:"score",mode:"line",color:"#0000ff"},{name:"cut",mode:"cut",color:"#ff0000"},{name:"guide",mode:"guide",color:"#00a0ff"}],_c={maxParts:1e4,maxSegments:1e4,maxListLength:1e6,maxListItems:3e6,maxTextLength:2e3,maxPoints:2e6,maxOutputPoints:1e6,maxSheets:200,maxCollisionPairs:2e4};function s4(n,e){if(!n||K1(a4,n)!==void 0||e.startsWith("/"))return;let t=n.lastIndexOf("/");if(t<0)return;let c=[...n.slice(0,t).split("/"),...e.split("/")],a=[];for(let r of c)r===".."&&a.length&&a[a.length-1]!==".."?a.pop():r!=="."&&r!==""&&a.push(r);return(n.startsWith("/")?"/":"")+a.join("/")}var Gc=100,jc={mm:1,cm:10,m:1e3,in:25.4,ft:304.8},M2=4,X7=8,Wc=n=>{let e=Gc,t=c=>{for(let a of c.values()){for(let r of a.regions)e+=r.length;for(let r of a.lines)e+=r.length}};t(n.layers);for(let c of n.parts)t(c.layers);return e},q1=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,c=e.startsWith("$");for(;t;){if(t.vars.has(e))return{found:!0,value:t.vars.get(e)};t=c?t.caller??t.parent:t.parent}return{found:!1}}fn(e){for(let t=this;t;t=t.parent){let c=t.fns.get(e);if(c)return c}}mod(e){for(let t=this;t;t=t.parent){let c=t.mods.get(e);if(c)return c}}childCtx(){for(let e=this;e;e=e.parent)if(e.children)return e.children}names(e){let t=[];for(let c=this;c;c=c.parent)t.push(...c[e].keys());return t}},n4=n=>n?`.${n}`:"",c4=["echo","assert","text_width","text_metrics","finger_count"];function a2(n,e){let t="",c=Math.min(2,Math.floor(n.length/3))+.5;for(let a of new Set(e)){if(a===n)continue;let r=a.toLowerCase()===n.toLowerCase()?0:Xc(n,a);r<c&&([t,c]=[a,r])}return t?` Did you mean "${t}"?`:""}function Xc(n,e){if(Math.abs(n.length-e.length)>2)return 3;let t=Array.from({length:n.length+1},(c,a)=>[a,...Array(e.length).fill(0)]);for(let c=1;c<=e.length;c++)t[0][c]=c;for(let c=1;c<=n.length;c++)for(let a=1;a<=e.length;a++)t[c][a]=Math.min(t[c-1][a]+1,t[c][a-1]+1,t[c-1][a-1]+(n[c-1]===e[a-1]?0:1)),c>1&&a>1&&n[c-1]===e[a-2]&&n[c-2]===e[a-1]&&(t[c][a]=Math.min(t[c][a],t[c-2][a-2]+1));return t[n.length][e.length]}var a4=g0,$3=class{constructor(e={}){this.opts=e;this.steps=0;this.depth=0;this.pointCount=0;this.itemCount=0;this.copies=0;this.frame=x5;this.step=0;this.stepNames=[];this.stepFolded=!1;this.hardware=[];this.echoes=[];this.warnings=[];this.layers=new Map(r4.map(e=>[e.name,e]));this.loaded=new Map;this.childCache=new WeakMap;this.using=[];this.including=[];this.maxSteps=e.maxSteps??5e6,this.limits={..._c,...e.limits},this.builtins=this.makeBuiltins()}run(e){let t=new q1,c={$fn:0,$fa:2,$fs:.2,$thickness:3,$kerf:0,$material:"material",$sheet:[600,400],$gap:3,$layout:"pack",$scale:1,PI:Math.PI};for(let[i,l]of Object.entries(c))t.vars.set(i,l);let a=new q1(t),r=this.block(e.body,a,!0),s=a.vars.get("$scale");return this.unscaled&&s!==void 0&&s!==1&&this.warn(`A length with a unit comes before $scale is set, so it is not scaled; set $scale first (${A0(this.unscaled,!1)})`),{shape:r,globals:a,layers:this.layers,echoes:this.echoes,warnings:this.warnings,hardware:this.hardware,steps:this.stepNames}}tick(e,t=1){if(!((this.steps+=t)<=this.maxSteps))throw new D(`Stopped after ${this.maxSteps} steps. Is there an endless loop?`,e)}load(e,t){let c=s4(t.file,e),a=e,r=K1(a4,e);if(r===void 0&&c!==void 0){let i=this.loaded.get(c);if(i)return i;r=this.opts.resolve?.(c),typeof r=="string"&&(a=c)}if(a===e){let i=this.loaded.get(e);if(i)return i;r??(r=this.opts.resolve?.(e))}if(typeof r!="string")throw new D(`Library <${e}> not found`,t);this.loaded.set(a,{body:[]});let{program:s}=D0(r,a);return this.loaded.set(a,s),s}hoist(e,t){for(let c of e)if((c.kind==="module"||c.kind==="function")&&(c.pos.file===void 0||K1(a4,c.pos.file)===void 0)&&(c.kind==="module"?K1(this.builtins,c.name)!==void 0:K1(P2,c.name)!==void 0||c4.includes(c.name))&&this.warn(`${c.kind} ${c.name} hides the built-in ${c.name}(); rename it to use both (${A0(c.pos,!1)})`),c.kind==="module")t.mods.set(c.name,{params:c.params,body:c.body,env:t});else if(c.kind==="function")t.fns.set(c.name,{params:c.params,body:c.body,env:t});else if(c.kind==="use"&&!c.include){this.enter(this.using,c.path,c.pos,"use");try{let a=this.included(this.load(c.path,c.pos).body,new Set([c.path])),r=new q1(t);this.hoist(a,r);for(let s of a)s.kind==="assign"&&this.assign(s.name,this.expr(s.value,r),r);for(let[s,i]of r.mods)t.mods.set(s,i);for(let[s,i]of r.fns)t.fns.set(s,i)}finally{this.using.pop()}}}childKey(e){let t=new Map;((o,h)=>{for(;o&&h<200;o=o.caller??o.parent,h++)for(let[f,u]of o.vars)f.startsWith("$")&&!t.has(f)&&t.set(f,u)})(e,0);let a=[...t].sort(([o],[h])=>o<h?-1:1),r=[],s=0,i=[];for(let o=a.length-1;o>=0;o--)i.push({text:";"},a[o][1],{text:`${a[o][0]}=`});for(;i.length;){if(s>2e4)return"";let o=i.pop(),h;if(o&&typeof o=="object"&&"text"in o&&!Array.isArray(o))h=o.text;else if(typeof o=="number")h=Object.is(o,-0)?"-0":String(o);else if(typeof o=="string")h=JSON.stringify(o);else if(o===void 0||typeof o=="boolean")h=String(o);else if(Array.isArray(o)){i.push({text:"]"});for(let f=o.length-1;f>=0;f--)i.push(o[f],{text:","});h="["}else if(n0(o))h=`[${o.start}:${o.step}:${o.end}]`;else if($1(o)){i.push({text:"}"});let f=[...o.fields];for(let u=f.length-1;u>=0;u--)i.push(f[u][1],{text:`${f[u][0]}=`});h="{"}else return"";r.push(h),s+=h.length}let l=r.join("");return`${this.frame.join(",")}|${this.step}|${this.stepFolded}|${l}`}effects(){return`${this.echoes.length},${this.hardware.length},${this.stepNames.length},${this.warnings.length},${this.copies}`}enter(e,t,c,a){if(e.includes(t)){let r=[...e.slice(e.indexOf(t)),t].map(s=>`<${s}>`);throw new D(r.length===2?`Library ${r[0]} ${a}s itself`:`Libraries ${a} each other in a loop: ${r.join(" \u2192 ")}`,c)}e.push(t)}included(e,t){let c=[];for(let a of e)if(a.kind!=="use"||!a.include)c.push(a);else if(!t.has(a.path)){t.add(a.path);for(let r of this.included(this.load(a.path,a.pos).body,t))c.push(r)}return c}assign(e,t,c){c.vars.set(e,t)}block(e,t,c=!1){this.hoist(e,t);let a=[];for(let r of e){let s=this.stmt(r,t,c);s&&!W4(s)&&a.push(s)}return a.length===1?a[0]:q0(a)}stmt(e,t,c=!1){switch(this.tick(e.pos),e.kind){case"assign":{let a=this.opts.overrides,r=c&&a&&Object.prototype.hasOwnProperty.call(a,e.name)?a[e.name]:this.expr(e.value,t);return this.assign(e.name,r,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 q1(t));case"if":return k1(this.expr(e.cond,t))?this.block(e.then,new q1(t)):this.block(e.else,new q1(t));case"let":{let a=new q1(t);return this.bindSeq(e.assigns,a),this.block(e.body,a)}case"for":{let a=[];return this.loop(e.assigns,t,r=>a.push(this.block(e.body,r))),q0(a)}case"call":if(e.modifier==="*")return null;{let a=this.callModule(e,t);return e.modifier==="#"||e.modifier==="%"?q2(a,"guide"):a}}}bindSeq(e,t){for(let c of e)this.assign(c.name,this.expr(c.value,t),t)}iterable(e,t){if(n0(e))try{return r3(e,this.limits.maxListLength)}catch(c){throw new D(c.message,t)}return Array.isArray(e)?e:typeof e=="string"?[...e]:e===void 0?[]:[e]}loop(e,t,c,a=0,r=new q1(t)){if(a===e.length)return c(r);let s=e[a];for(let i of this.iterable(this.expr(s.value,r),s.pos)){this.tick(s.pos);let l=new q1(r);l.vars.set(s.name,i),this.loop(e,t,c,a+1,l)}}evalArgs(e,t,c){let a=[],r=new Map,s=[];for(let i of e){let l=this.expr(i.value,t);i.name===null?a.push(l):r.set(i.name,l),s.push({name:i.name,value:l})}return{pos:a,named:r,all:s,at:c}}bindParams(e,t,c,a,r){let s=e.map(i=>i.name);e.forEach((i,l)=>{let o;t.named.has(i.name)?o=t.named.get(i.name):l<t.pos.length?o=t.pos[l]:o=i.default?this.expr(i.default,c):void 0,c.vars.set(i.name,o)});for(let i of t.named.keys())i.startsWith("$")?c.vars.set(i,t.named.get(i)):s.includes(i)||this.unknownArg(r,i,t.at,s);this.checkCount(r,e.length,t)}checkArgs(e,t){let c=s2(e);if(!c)return;let a=c.params.map(r=>r.name);if(!c.anyNamed)for(let r of t.named.keys())!r.startsWith("$")&&!a.includes(r)&&this.unknownArg(`${e}()`,r,t.at,a);c.rest||this.checkCount(`${e}()`,c.params.filter(r=>!r.named).length,t)}checkCount(e,t,c){c.pos.length>t&&this.warn(`${e}: takes ${t===0?"no":`at most ${t}`} positional argument${t===1?"":"s"}, got ${c.pos.length}; the rest are ignored (${A0(c.at,!1)})`)}unknownArg(e,t,c,a){this.warn(`${e}: unknown argument "${t}"${n4(a2(t,a))} (${A0(c,!1)})`)}warn(e){this.warnings.includes(e)||this.warnings.push(e)}callByName(e,t){let c=e.args.findIndex(s=>s.name==="name"),a=c>=0?c:e.args.findIndex(s=>s.name===null);if(a<0)throw new D("call() needs the name of a module",e.pos);let r=this.expr(e.args[a].value,t);if(typeof r!="string")throw new D(`call() needs a module's name as a string, got ${J1(r)}`,e.pos);if(r==="call")throw new D("call() can't call itself",e.pos);return this.callModule({...e,name:r,args:e.args.filter((s,i)=>i!==a)},t)}callModule(e,t){if(e.name==="call"&&!t.mod("call"))return this.callByName(e,t);let c=this.evalArgs(e.args,t,e.pos),a=t.mod(e.name);if(a){if(++this.depth>1e3)throw new D(`Recursion too deep in module ${e.name}(): it calls itself without stopping`,e.pos);try{let u=new q1(a.env,t);return this.bindParams(a.params,c,u,a.env,`${e.name}()`),u.children={stmts:e.children,env:t},u.vars.set("$children",this.childStmts(e.children).length),this.block(a.body,u)}catch(u){throw this.inCall(u,"module",e.name,e.pos)}finally{this.depth--}}let r=K1(this.builtins,e.name);if(!r){let u=e.name==="color"?" Use layer(), cut(), score() or engrave() instead.":a2(e.name,[...t.names("mods"),...Object.keys(this.builtins)]);throw new D(`Unknown module ${e.name}().${u}`,e.pos)}this.checkArgs(e.name,c);let s=new q1(t,t);for(let[u,d]of c.named)u.startsWith("$")&&s.vars.set(u,d);let i=this.childStmts(e.children),l=()=>new q1(t,s),o={args:c,env:s,children:()=>e.children.length?this.block(e.children,l()):a0(),childList:()=>{let u=l();this.hoist(e.children,u);let d=[];for(let p of e.children){let m=this.stmt(p,u);i.includes(p)&&d.push(m??a0())}return d},childSeq:u=>{let d=l();this.hoist(e.children,d);let p=[];for(let m of e.children){let v=this.stmt(m,d);i.includes(m)&&(p.push(v??a0()),u(p.length-1,v??a0()))}return p}},h;try{h=r(o)}catch(u){if(u instanceof D||u instanceof RangeError)throw u;let d=new D(`${e.name}(): ${u.message}`,e.pos);throw d.call=e.name,d}let f=Wc(h);if(e.name!=="children"&&(this.pointCount+=f),f>this.limits.maxPoints||this.pointCount>this.limits.maxPoints*10)throw new D(f>this.limits.maxPoints?`The shapes have more than ${this.limits.maxPoints} points, the limit. Use fewer or simpler shapes, or a lower $fn.`:`Making the shapes took more than ${this.limits.maxPoints*10} points of work, the limit. Use fewer or simpler shapes, or a lower $fn.`,e.pos);return h}childStmts(e){return e.filter(t=>t.kind!=="assign"&&t.kind!=="module"&&t.kind!=="function"&&t.kind!=="use")}callFunction(e,t,c,a){if(++this.depth>2e3)throw new D(`Recursion too deep in ${a}(): it calls itself without stopping`,t.at);try{this.tick(t.at);let r=P0(e)?e.scope:e.env,s=new q1(r,c);return this.bindParams(e.params,t,s,r,`${a}()`),this.expr(e.body,s)}catch(r){throw this.inCall(r,"function",a,t.at)}finally{this.depth--}}inCall(e,t,c,a){return e instanceof Error&&!(e instanceof D)&&e.message.includes("call stack")?new D(`Recursion too deep in ${t==="module"?"module ":""}${c}(): it calls itself without stopping`,a):(e instanceof D&&e.addFrame(t,c,a),e)}expr(e,t){switch(e.kind){case"num":return e.unit?this.length(e,t):e.value;case"str":case"bool":return e.value;case"undef":return;case"var":{let c=t.get(e.name);if(c.found)return c.value;let a=t.fn(e.name);if(a)return{type:"function",params:a.params,body:a.body,scope:a.env,name:e.name};if(e.name.startsWith("$"))return;throw new D(`Unknown variable "${e.name}"${n4(a2(e.name,[...t.names("vars"),...t.names("fns")]))}`,e.pos)}case"list":{let c=[];for(let a of e.items)this.listItem(a,t,c,e.pos);return this.charge(M2,e.pos),c}case"range":{let c=this.expr(e.start,t),a=this.expr(e.end,t),r=e.step?this.expr(e.step,t):1;if(typeof c!="number"||typeof a!="number"||typeof r!="number")throw new D("Range values must be numbers",e.pos);return{type:"range",start:c,step:r,end:a}}case"unary":{let c=this.expr(e.arg,t);return e.op==="!"?!k1(c):e.op==="+"?c:this.arith("*",-1,c,e.pos)}case"binary":{if(e.op==="&&")return k1(this.expr(e.left,t))&&k1(this.expr(e.right,t));if(e.op==="||")return k1(this.expr(e.left,t))||k1(this.expr(e.right,t));let c=this.expr(e.left,t),a=this.expr(e.right,t);if(e.op==="=="||e.op==="!=")return i2(c,a,()=>this.tick(e.pos))===(e.op==="==");if(e.op==="<"||e.op==="<="||e.op===">"||e.op===">="){if(!(typeof c=="number"&&typeof a=="number"||typeof c=="string"&&typeof a=="string"))throw new D(`Can't compare ${J1(c)} ${e.op} ${J1(a)}`,e.pos);return e.op==="<"?c<a:e.op==="<="?c<=a:e.op===">"?c>a:c>=a}return this.arith(e.op,c,a,e.pos)}case"ternary":return k1(this.expr(e.cond,t))?this.expr(e.then,t):this.expr(e.else,t);case"index":{let c=this.expr(e.target,t),a=this.expr(e.index,t);if($1(c)&&typeof a=="string")return c.fields.get(a);if(typeof a!="number")throw new D(`List index must be a number, got ${J1(a)}`,e.pos);return Array.isArray(c)?c[Math.floor(a)]:typeof c=="string"?[...c][Math.floor(a)]:n0(c)?[c.start,c.step,c.end][Math.floor(a)]:void 0}case"record":return this.record(e,t);case"member":{let c=this.expr(e.target,t);if($1(c))return c.fields.get(e.name);let a={x:0,y:1,z:2}[e.name];return Array.isArray(c)&&a!==void 0?c[a]:n0(c)&&(e.name==="begin"||e.name==="step"||e.name==="end")?e.name==="begin"?c.start:e.name==="step"?c.step:c.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 c=new q1(t);return this.bindSeq(e.assigns,c),this.expr(e.body,c)}}}listItem(e,t,c,a){switch(e.kind){case"item":{let r=this.expr(e.expr,t);this.grow(c,1,a),c.push(r);return}case"each":{let r=this.iterable(this.expr(e.expr,t),a);this.grow(c,r.length,a);for(let s of r)c.push(s);return}case"for":this.loop(e.assigns,t,r=>this.listItem(e.body,r,c,a));return;case"if":k1(this.expr(e.cond,t))?this.listItem(e.then,t,c,a):e.else&&this.listItem(e.else,t,c,a);return;case"let":{let r=new q1(t);this.bindSeq(e.assigns,r),this.listItem(e.body,r,c,a)}}}grow(e,t,c){if(e.length+t>this.limits.maxListLength)throw new D(`a list of ${e.length+t} items is more than the limit of ${this.limits.maxListLength}`,c);this.charge(t,c)}charge(e,t){if(this.itemCount+=e,!(this.itemCount<=this.limits.maxListItems))throw new D(`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 a=e.callee.name,r=t.get(a),s=r.found&&!P0(r.value);if(!r.found||s&&this.callable(a,t)){let i=t.fn(a);if(i)return this.callFunction(i,this.evalArgs(e.args,t,e.pos),t,a);let l=this.specialFunction(a,e,t);if(l.handled)return l.value;let o=K1(P2,a);if(o){let h=this.evalArgs(e.args,t,e.pos);this.checkArgs(a,h);for(let p of I4(o,h.pos,h.named))this.warn(`${a}(): "${p}" is given by position and by name; the named value is used (${A0(e.pos,!1)})`);let f={maxLength:this.limits.maxListLength,step:p=>this.tick(e.pos,p),given:h.pos.length+o.params.filter(p=>h.named.has(p)).length},u=H4(o,h.pos,h.named);this.tick(e.pos,V4(a,u,this.limits.maxListLength));let d;try{d=o.run(u,f)}catch(p){if(p instanceof D)throw p;let m=new D(p instanceof RangeError?`${a}(): the result is too large`:p.message,e.pos);throw m.call=a,m}return this.checkValue(d,e.pos,a),d}throw new D(`Unknown function ${a}()${n4(a2(a,[...t.names("fns"),...t.names("vars"),...Object.keys(P2),...c4]))}`,e.pos)}if(!P0(r.value))throw new D(`"${a}" is a ${J1(r.value)}, not a function`,e.pos);return this.callFunction(r.value,this.evalArgs(e.args,t,e.pos),t,a)}let c=this.expr(e.callee,t);if(!P0(c))throw new D(`Can't call a ${J1(c)}`,e.pos);return this.callFunction(c,this.evalArgs(e.args,t,e.pos),t,"function")}invisiblePaint(e,t,c,a){let r=s=>Array.isArray(c)?String(c[s]??""):[...e[s].layers.keys()].sort().join(",");for(let s=1;s<e.length;s++){if(!t[s]?.length)continue;let i=r(s),l=r1(e.flatMap((h,f)=>f<s&&r(f)===i?t[f]:[]));!l.length||Q1(t[s],l).reduce((h,f)=>h+Math.abs(g1(f)),0)>.001||this.warn(`paint(): child ${s+1} lies wholly on an area of the same layer${Array.isArray(c)&&i?` "${i}"`:""} under it, so it can't be seen (${A0(a,!1)})`)}}record(e,t){let c=new Map;for(let a of e.fields)c.set(a.name,this.expr(a.value,t));return{type:"record",fields:c}}length(e,t){let c=V1(t.get("$scale").value??1);if(!(c>0))throw new D("$scale must be a number more than 0",e.pos);return c===1&&e.unit!=="mm"&&(this.unscaled??(this.unscaled=e.pos)),e.value*jc[e.unit]/c}callable(e,t){return!!t.fn(e)||c4.includes(e)||!!K1(P2,e)}specialFunction(e,t,c){if(e==="echo"){let a=this.evalArgs(t.args,c,t.pos);return this.echo(this.echoText(a),t.pos),{handled:!0,value:void 0}}if(e==="assert"){let a=this.evalArgs(t.args,c,t.pos);return this.checkArgs(e,a),this.assert(a),{handled:!0,value:!0}}if(e==="text_width"||e==="text_metrics"){let a=this.evalArgs(t.args,c,t.pos);this.checkArgs(e,a);let r=this.measure(a,c);return e==="text_width"?{handled:!0,value:r.advance}:{handled:!0,value:[r.advance,r.bounds,r.ascent,r.descent]}}if(e==="finger_count"){let a=this.evalArgs(t.args,c,t.pos);this.checkArgs(e,a);let r=this.num(this.arg(a,"length",0),"finger_count","length");return{handled:!0,value:y3(r,this.fingerWidth(a,c,1))}}return{handled:!1}}assert(e){if(k1(this.arg(e,"condition",0)))return;let t=this.arg(e,"message",1);throw new D(`Assertion failed${t===void 0?"":": "+C1(t)}`,e.at)}echo(e,t){this.charge(Math.ceil(e.length/X7),t),this.echoes.push(e)}echoText(e){let t=this.limits.maxListLength,c=[],a=0,r=(s,i,l)=>{c.length&&(a+=2);let o=l2(i,t-a-s.length,l);if(a+=s.length+o.text.length,!o.whole)throw new D(`echo(): the text would be longer than the limit of ${t} characters`,e.at);c.push(s+o.text)};for(let{name:s,value:i}of e.all)s===null?r("",i,!1):r(`${s} = `,i,!0);return c.join(", ")}arith(e,t,c,a){if(typeof t=="number"&&typeof c=="number")switch(e){case"+":return t+c;case"-":return t-c;case"*":return t*c;case"/":return t/c;case"%":return t%c;case"^":return Math.pow(t,c)}if(e==="+"&&typeof t=="string"&&typeof c=="string")return this.checkSize(t.length+c.length,!0,a),t+c;if(Array.isArray(t)&&Array.isArray(c)){if(e==="+"||e==="-"){if(t.length!==c.length)throw new D(`Can't ${e==="+"?"add":"subtract"} lists of length ${t.length} and ${c.length}`,a);return this.charge(t.length+M2,a),t.map((s,i)=>this.arith(e,s,c[i],a))}if(e==="*"){if(Array.isArray(t[0]))return this.charge(t.length+M2,a),t.map(i=>this.arith("*",i,c,a));let s=(i,l)=>{let o=this.arith("*",i,l,a);if(typeof o!="number")throw new D("Can't multiply these lists: an item times an item is not a number",a);return o};if(Array.isArray(c[0])){let i=c[0].length;if(t.length!==c.length||c.some(l=>!Array.isArray(l)||l.length!==i))throw new D(`Can't multiply a list of length ${t.length} by a matrix: it needs ${t.length} rows of the same length`,a);return this.checkSize(i,!1,a),this.tick(a,i*t.length),Array.from({length:i},(l,o)=>t.reduce((h,f,u)=>h+s(f,c[u][o]),0))}if(t.length!==c.length)throw new D(`Can't multiply lists of length ${t.length} and ${c.length}`,a);return this.tick(a,t.length),t.reduce((i,l,o)=>i+s(l,c[o]),0)}}if(Array.isArray(t)&&typeof c=="number"&&(e==="*"||e==="/"))return this.charge(t.length+M2,a),t.map(s=>this.arith(e,s,c,a));if(typeof t=="number"&&Array.isArray(c)&&e==="*")return this.charge(c.length+M2,a),c.map(s=>this.arith(e,t,s,a));let r={"+":"add","-":"subtract","*":"multiply","/":"divide","%":"take remainder of","^":"raise"};throw new D(`Can't ${r[e]??e} ${J1(t)} and ${J1(c)}`,a)}arg(e,t,c,a){return e.named.has(t)?e.named.get(t):c>=0&&c<e.pos.length?e.pos[c]:a}num(e,t,c){if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${c} must be a finite number, got ${X1(e)}`);return e}vec2(e,t,c=!0){let a=r=>typeof r=="number"&&Number.isFinite(r);if(a(e)&&c)return[e,e];if(Array.isArray(e)&&a(e[0])&&(e[1]===void 0||a(e[1])))return[e[0],e[1]??0];throw new Error(`${t} must be a number or [x, y], got ${X1(e)}`)}vec3(e,t){let c=a=>typeof a=="number"&&Number.isFinite(a);if(Array.isArray(e)&&(e.length===2||e.length===3)&&e.every(c))return[e[0],e[1],e[2]??0];throw new Error(`${t} must be [x, y, z], got ${X1(e)}`)}placements(e,t,c){let a=(i,l)=>i===void 0?[[0,0,0]]:Array.isArray(i)&&i.length>0&&Array.isArray(i[0])?i.map((o,h)=>this.vec3(o,`${l}[${h}]`)):[this.vec3(i,l)],r=a(e,"at"),s=a(t,"rotate");for(let[i,l]of[[r,"at"],[s,"rotate"]])if(i.length!==1&&i.length!==c)throw new Error(`${l} needs one placement per copy: qty is ${c} but ${l} has ${i.length}`);return Array.from({length:c},(i,l)=>({at:r[r.length===1?0:l],rotate:s[s.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((c,a)=>{if(!Array.isArray(c)||!Number.isFinite(c[0])||!Number.isFinite(c[1]))throw new Error(`${t}[${a}] must be an [x, y] point, got ${X1(c)}`);return[c[0],c[1]]})}dyn(e,t){return e.get(t).value}spend(e){if(this.pointCount+=e,!(e<=this.limits.maxPoints&&this.pointCount<=this.limits.maxPoints*10))throw new Error(`the shapes need more than ${this.limits.maxPoints} points, the limit. Use fewer or simpler shapes.`)}checkValue(e,t,c){(Array.isArray(e)||typeof e=="string")&&this.checkSize(e.length,typeof e=="string",t,c)}checkSize(e,t,c,a){if(e>this.limits.maxListLength)throw new D(`${a?`${a}(): `:""}${t?`a string of ${e} characters`:`a list of ${e} items`} is more than the limit of ${this.limits.maxListLength}`,c);this.charge(t?Math.ceil(e/X7):e+M2,c)}segs(e){let t=V1(this.dyn(e,"$fn"))||0,c=V1(this.dyn(e,"$fa"))||2,a=V1(this.dyn(e,"$fs"))||.2,r=this.limits.maxSegments;return s=>{let i=J4(s,t,c,a);if(!(i<=r))throw new Error(`a circle with ${i} segments is more than the limit of ${r}. Lower $fn, or raise $fa or $fs.`);return i}}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,c){let a=this.arg(e,"finger",c);return typeof a=="number"&&a>0?a:Math.max(3*this.thickness(t),6)}measure(e,t){if(!this.opts.fonts)throw new D("text needs a font. Pass fonts to render(), or --font on the command line.",e.at);let c=l2(this.arg(e,"text",0,""),this.limits.maxTextLength);if(!c.whole)throw new D(`the text is more than ${this.limits.maxTextLength} characters, the limit for one text()`,e.at);this.tick(e.at,c.text.length);try{return e4(this.opts.fonts,c.text,this.textOpts(e,t,c.text))}catch(a){throw a instanceof D?a:new D(a.message,e.at)}}textOpts(e,t,c){let a={size:this.num(this.arg(e,"size",1,10),"text","size"),font:C1(this.arg(e,"font",2,this.dyn(t,"$font")??"")),halign:C1(this.arg(e,"halign",-1,"left")),valign:C1(this.arg(e,"valign",-1,"baseline")),spacing:V1(this.arg(e,"spacing",-1,1))},r=this.arg(e,"fit",-1);if(r!==void 0&&c!==void 0&&this.opts.fonts){let s=this.num(r,"text","fit");if(!(s>0))throw new Error("fit must be a width more than 0");let i=e4(this.opts.fonts,c,{...a,size:1}).advance;if(i>0){let l=this.arg(e,"size",1);a.size=l===void 0?s/i:Math.min(a.size,s/i)}}return a}edges(e){let t=c=>{if(c==="out"||c==="in"||c==="flat")return c;throw new Error(`edges must be "out", "in" or "flat", got ${X1(c)}`)};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]")}backLayer(e){let t=`${e}-back`,c=this.layers.get(t);if(c&&c.side!=="back")throw new Error(`the back of layer "${e}" is the layer "${t}", which this program already uses for the front. Rename that layer.`);if(!c){let a=this.layers.get(e)??{name:e,mode:"line",color:"#00aa00"};this.layers.set(t,{...a,name:t,side:"back"})}return t}bends(e){if(e===void 0)return[];let t=Array.isArray(e)&&Array.isArray(e[0])?e:[e];return t.map((c,a)=>{if(!Array.isArray(c)||c.length!==3||!c.every(l=>typeof l=="number"&&Number.isFinite(l)))throw new Error(`bend must be [x0, x1, angle] or a list of them, got ${X1(c)}${t.length>1?` at ${a}`:""}`);let[r,s,i]=c;if(!(s>r))throw new Error(`a bend's x1 must be more than its x0, got ${X1(c)}`);return{x0:r,x1:s,angle:i}})}makeBuiltins(){let e=(s,i)=>f2(s.children(),i),t=s=>i=>q2(i.children(),s),c=s=>i=>{let l=this.arg(i.args,"side",0,"front");if(l!=="front"&&l!=="back")throw new Error(`side must be "front" or "back", got ${X1(l)}`);return l==="back"&&i.env.vars.set("$mirrored",!k1(this.dyn(i.env,"$mirrored"))),q2(i.children(),l==="back"?this.backLayer(s):s)};return{rect:s=>{let[i,l]=this.vec2(this.arg(s.args,"size",0,1),"size"),o=V1(this.arg(s.args,"r",-1,0))||0,h=k1(this.arg(s.args,"center",1,!1)),f=Q4(i,l,o,this.segs(s.env));return F1(r1([h?f.map(([u,d])=>[u-i/2,d-l/2]):f]))},square:s=>this.builtins.rect(s),circle:s=>{let i=this.arg(s.args,"d",-1),l=i!==void 0?this.num(i,"circle","d")/2:this.num(this.arg(s.args,"r",0,1),"circle","r");return F1([g3(l,l,this.segs(s.env)(l))])},ellipse:s=>{let[i,l]=this.vec2(this.arg(s.args,"r",0,1),"r");return F1([g3(i,l,this.segs(s.env)(Math.max(i,l)))])},regular_polygon:s=>{let i=Math.max(3,Math.floor(this.num(this.arg(s.args,"n",0,6),"regular_polygon","n"))),l=this.num(this.arg(s.args,"r",1,10),"regular_polygon","r");if(!(i<=this.limits.maxSegments))throw new Error(`${i} corners is more than the limit of ${this.limits.maxSegments}`);return F1([g3(l,l,i)])},star:s=>{let i=Math.max(2,Math.floor(this.num(this.arg(s.args,"n",0,5),"star","n"))),l=this.num(this.arg(s.args,"r",1,10),"star","r"),o=this.num(this.arg(s.args,"inner",2,l*.45),"star","inner");if(!(i*2<=this.limits.maxSegments))throw new Error(`${i} points is more than the limit of ${this.limits.maxSegments/2}`);let h=[];for(let f=0;f<i*2;f++){let u=Math.PI/2+Math.PI*f/i,d=f%2?o:l;h.push([d*Math.cos(u),d*Math.sin(u)])}return F1(r1([h]))},polygon:s=>{let i=this.points(this.arg(s.args,"points",0),"points"),l=this.arg(s.args,"paths",1),o=Array.isArray(l)?l.map(h=>(Array.isArray(h)?h:[]).map(f=>i[V1(f)]).filter(Boolean)):[i];return F1(r1(o,"evenodd"))},path:s=>{let i=this.arg(s.args,"d",0);if(typeof i!="string")throw new Error('path() needs SVG path data, like path("M0 0 L10 0 L5 8 Z")');let l=o2(s3(i),.01),o=this.arg(s.args,"fill",-1,"evenodd")==="nonzero"?"nonzero":"evenodd";return k1(this.arg(s.args,"close",-1,!1))?F1(r1([...l.closed,...l.open.filter(h=>h.length>2)],o)):q0([F1(r1(l.closed,o)),R0(l.open)])},line:s=>{let i=this.vec2(this.arg(s.args,"from",0,[0,0]),"from",!1),l=this.vec2(this.arg(s.args,"to",1,[10,0]),"to",!1),o=this.arg(s.args,"width",2);if(o===void 0)return R0([[i,l]]);let h=this.num(o,"line","width");if(!(h>0))throw new Error("width must be more than 0");let f=Math.hypot(l[0]-i[0],l[1]-i[1]);if(!f)return a0();let u=-(l[1]-i[1])/f*(h/2),d=(l[0]-i[0])/f*(h/2);return F1(r1([[[i[0]+u,i[1]+d],[i[0]-u,i[1]-d],[l[0]-u,l[1]-d],[l[0]+u,l[1]+d]]]))},polyline:s=>{let i=this.points(this.arg(s.args,"points",0),"points"),l=k1(this.arg(s.args,"closed",1,!1));return R0([l&&i.length?[...i,i[0]]:i])},arc:s=>{let i=this.num(this.arg(s.args,"r",0,10),"arc","r"),l=this.num(this.arg(s.args,"start",1,0),"arc","start"),o=this.num(this.arg(s.args,"end",2,90),"arc","end"),h=Math.max(2,Math.ceil(this.segs(s.env)(i)*Math.abs(o-l)/360));if(!(h<=this.limits.maxSegments))throw new Error(`an arc with ${h} segments is more than the limit of ${this.limits.maxSegments}`);let f=[];for(let u=0;u<=h;u++){let d=(l+(o-l)*u/h)*Math.PI/180;f.push([i*Math.cos(d),i*Math.sin(d)])}return R0([f])},text:s=>{if(!this.opts.fonts)throw new Error("text() needs a font. Pass fonts to render(), or --font on the command line.");let i=this.arg(s.args,"text",0,""),l=l2(i,this.limits.maxTextLength);if(!l.whole)throw new Error(`the text is more than ${this.limits.maxTextLength} characters, the limit for one text()`);this.tick(s.args.at,l.text.length);let o=B3(this.opts.fonts,l.text,this.textOpts(s.args,s.env,l.text));if(k1(this.dyn(s.env,"$mirrored"))){let[h,f]=[1/0,-1/0];for(let u of o)for(let[d]of u)[h,f]=[Math.min(h,d),Math.max(f,d)];return F1(r1(o.map(u=>u.map(([d,p])=>[h+f-d,p]))))}return F1(o)},translate:s=>{let[i,l]=this.vec2(this.arg(s.args,"v",0,[0,0]),"v",!1);return e(s,[1,0,0,1,i,l])},rotate:s=>{let i=this.arg(s.args,"a",0,0),o=(Array.isArray(i)?V1(i[2]??0):this.num(i,"rotate","a"))*Math.PI/180,h=Math.cos(o),f=Math.sin(o),u=this.arg(s.args,"center",-1),d=[h,f,-f,h,0,0];if(u!==void 0){let[p,m]=this.vec2(u,"center",!1);d=[h,f,-f,h,p-h*p+f*m,m-f*p-h*m]}return e(s,d)},scale:s=>{let[i,l]=this.vec2(this.arg(s.args,"v",0,1),"v");return e(s,[i,0,0,l,0,0])},mirror:s=>{let[i,l]=this.vec2(this.arg(s.args,"v",0,[1,0]),"v",!1),o=Math.hypot(i,l)||1,h=i/o,f=l/o;return e(s,[1-2*h*h,-2*h*f,-2*h*f,1-2*f*f,0,0])},multmatrix:s=>{let i=this.arg(s.args,"m",0);if(!Array.isArray(i)||i.length<2)throw new Error("m must be a 2x3 or 3x3 matrix");let l=i[0],o=i[1];return e(s,[l[0],o[0],l[1],o[1],l[2]??0,o[2]??0])},union:s=>s.children(),group:s=>s.children(),difference:s=>{let[i,...l]=s.childList();if(!i)return a0();let o=a(l,"difference");return r(i,h=>({regions:Q1(h.regions,o.regions),lines:M0(h.lines,r1(o.regions),"outside")}))},intersection:s=>{let i=s.childList();if(!i.length)return a0();let l=p=>[...p.layers.values()].some(m=>m.regions.length),o=p=>{let m;for(let v of i){if(v===p||!l(v))continue;let g=r1(a([v],"intersection").regions);m=m?Y1(m,g):g}return m},h=i[0],f=i.every(l),u=o(h),d=r(h,p=>({regions:f?u?Y1(p.regions,u):p.regions:[],lines:u?M0(p.lines,u,"inside"):p.lines}));for(let p of i){if(p===h)continue;if(p.parts.length)throw new Error("part() can only be the first child of intersection()");let m=o(p),v=new Map;for(let[g,b]of p.layers)b.lines.length&&v.set(g,{regions:[],lines:m?M0(b.lines,m,"inside"):b.lines});v.size&&(d=q0([d,{layers:v,parts:[]}]))}return d},hull:s=>{let i=s.children(),l=o=>{let h=[],f="cut",u=!0;for(let[p,m]of o){u&&(m.regions.length||m.lines.length)&&(f=p,u=!1);for(let v of[...m.regions,...m.lines])for(let g of v)h.push(g)}let d=K4(h);return new Map([[f,{regions:d.length>=3?[d]:[],lines:[]}]])};return{layers:l(i.layers),parts:i.parts.map(o=>({...o,layers:l(o.layers)}))}},offset:s=>{let i=this.arg(s.args,"r",0),l=this.arg(s.args,"delta",-1),o=k1(this.arg(s.args,"chamfer",-1,!1)),h=i!==void 0?this.num(i,"offset","r"):this.num(l??0,"offset","delta"),f=i!==void 0?"round":o?"square":"miter";return r(s.children(),u=>({regions:B1(u.regions,h,f),lines:u.lines}))},pattern:s=>{let[i,l]=this.vec2(this.arg(s.args,"spacing",0,10),"spacing"),o=this.num(this.arg(s.args,"stagger",1,0),"pattern","stagger");if(!(i>0&&l>0))throw new Error("spacing must be more than 0");let[h,...f]=s.childList();if(!h||!f.length)throw new Error("pattern() needs a tile and then the area to fill: pattern(10) { tile(); area(); }");if(h.parts.length)throw new Error("part() cannot be the tile of pattern()");let u=r1(a(f,"pattern").regions),d=r0(h.layers),p=x0(u);if(!d||!p)return a0();let m=Math.floor((p[1]-d[3])/l),v=Math.ceil((p[3]-d[1])/l),g=Math.floor((p[0]-d[2])/i)-1,b=Math.ceil((p[2]-d[0])/i)+1,y=(v-m+1)*(b-g+1);if(!(y<=this.limits.maxParts*10))throw new Error(`the pattern would have ${y} copies, more than the limit of ${this.limits.maxParts*10}`);this.tick(s.args.at,y);let w=T0(u).map(E=>({polys:E,box:x0(E)})),k=u,P=(E,z)=>{let I=0;for(let $ of k)for(let F=0,_=$.length-1;F<$.length;_=F++){let[Y,N]=$[_],[i1,h1]=$[F];N<=z?h1>z&&(i1-Y)*(z-N)-(E-Y)*(h1-N)>0&&I++:h1<=z&&(i1-Y)*(z-N)-(E-Y)*(h1-N)<0&&I--}return I!==0},S=new Map,A=(E,z)=>{let I=S.get(E)??{regions:[],lines:[]};for(let $ of z.regions)I.regions.push($);for(let $ of z.lines)I.lines.push($);S.set(E,I)};for(let E=m;E<=v;E++)for(let z=g;z<=b;z++){let I=z*i+(E%2?o*i:0),$=E*l,F=[d[0]+I,d[1]+$,d[2]+I,d[3]+$];if(F[2]<p[0]||F[0]>p[2]||F[3]<p[1]||F[1]>p[3])continue;let _=w.filter(U=>!(F[2]<U.box[0]||F[0]>U.box[2]||F[3]<U.box[1]||F[1]>U.box[3]));if(!_.length)continue;k=_.length===w.length?u:_.flatMap(U=>U.polys);let Y=[P(F[0],F[1]),P(F[2],F[1]),P(F[2],F[3]),P(F[0],F[3])],N=k.some(U=>U.some(([c1,X])=>c1>F[0]&&c1<F[2]&&X>F[1]&&X<F[3])),i1=Y.every(Boolean)&&!N,h1=[1,0,0,1,I,$];for(let[U,c1]of f2({layers:h.layers,parts:[]},h1).layers)A(U,i1?c1:{regions:Y1(c1.regions,k),lines:M0(c1.lines,k,"inside")})}return{layers:S,parts:[]}},spline:s=>{let i=this.points(this.arg(s.args,"points",0),"points"),l=this.arg(s.args,"width",1),o=Math.max(1,Math.floor(this.num(this.arg(s.args,"steps",-1,8),"spline","steps"))),h=k1(this.arg(s.args,"closed",-1,!1));if(!(i.length*o<=this.limits.maxSegments*10))throw new Error("too many points: use fewer points or steps");let f=c5(i,o,h);if(l===void 0)return R0([f]);let u=this.num(l,"spline","width");if(!(u>0))throw new Error("width must be more than 0");return F1(r1(v3([f],u)))},hatch:s=>{let i=this.num(this.arg(s.args,"angle",0,45),"hatch","angle"),l=this.num(this.arg(s.args,"pitch",1,5),"hatch","pitch"),o=this.arg(s.args,"width",2);if(!(l>0))throw new Error("pitch must be more than 0");let h=r1(a([s.children()],"hatch").regions),f=x0(h);if(!f)return a0();let[u,d]=[(f[0]+f[2])/2,(f[1]+f[3])/2],p=Math.hypot(f[2]-f[0],f[3]-f[1])/2+l,m=i*Math.PI/180,[v,g]=[Math.cos(m),Math.sin(m)],[b,y]=[-g,v],w=Math.ceil(p/l);if(!(2*w+1<=this.limits.maxSegments*10))throw new Error("pitch is too small for the area");this.tick(s.args.at,2*w+1);let k=[],P=Math.round((u*b+d*y)/l);for(let A=P-w;A<=P+w;A++){let E=A*l-(u*b+d*y),[z,I]=[u+b*E,d+y*E];k.push([[z-v*p,I-g*p],[z+v*p,I+g*p]])}if(o===void 0)return R0(M0(k,h,"inside"));let S=this.num(o,"hatch","width");if(!(S>0))throw new Error("width must be more than 0");return F1(Y1(r1(v3(k,S).map(A=>A)),h))},paint:s=>{let i=this.arg(s.args,"layers",0);if(i!==void 0&&(!Array.isArray(i)||i.some(u=>typeof u!="string")))throw new Error("layers must be a list of layer names");let l=s.childList(),o=[],h=[],f=[];for(let u=l.length-1;u>=0;u--){let d=l[u];if(d.parts.length)throw new Error("part() cannot go inside paint()");let p=h,m=r1(a([d],"paint").regions);f[u]=m,h=p.length?r1([...p,...m]):m;let v=Array.isArray(i)?i[u]:void 0;v!==""&&(v!==void 0?(this.layers.has(v)||this.layers.set(v,{name:v,mode:"fill",color:"#000000"}),o.push(F1(p.length?Q1(m,p):m,v))):o.push(p.length?r(d,g=>({regions:Q1(g.regions,p),lines:M0(g.lines,p,"outside")})):d))}return this.invisiblePaint(l,f,i,s.args.at),q0(o.reverse())},measure:s=>{let i=k1(this.arg(s.args,"draw",0,!1)),l=s.childSeq((o,h)=>{if(o!==0)return;let f=r0(h.layers)??x0(h.parts.flatMap(v=>[...v.layers.values()].flatMap(g=>[...g.regions,...g.lines])));s.env.vars.set("$bounds",f?[...f]:void 0);let u=[h.layers,...h.parts.map(v=>v.layers)],d=u.flatMap(v=>v.get("cut")?.regions??[]),p=d.length?d:u.flatMap(v=>[...v].filter(([g])=>g!=="guide").flatMap(([,g])=>g.regions)),m=Y4(r1(p));s.env.vars.set("$area",m.area),s.env.vars.set("$centroid",m.area>0?m.centroid:void 0)});return q0(i?l:l.slice(1))},fill_holes:s=>{let i=this.arg(s.args,"min_area",0),l=i===void 0?1/0:this.num(i,"fill_holes","min_area");return r(s.children(),o=>({regions:r1(o.regions).filter(h=>!(g1(h)<0&&-g1(h)<l)),lines:o.lines}))},close:s=>{let i=this.num(this.arg(s.args,"r",0,.5),"close","r");return r(s.children(),l=>({regions:B1(B1(l.regions,i,"round"),-i,"round"),lines:l.lines}))},stroke:s=>{let i=this.num(this.arg(s.args,"width",0,1),"stroke","width");return r(s.children(),l=>({regions:r1([...l.regions,...v3(l.lines,i)]),lines:[]}))},outline:s=>r(s.children(),i=>({regions:[],lines:[...i.lines,...r1(i.regions).map(l=>[...l,l[0]])]})),cut:t("cut"),score:c("score"),engrave:c("engrave"),guide:t("guide"),layer:s=>{let i=this.arg(s.args,"name",0);if(typeof i!="string"||!i)throw new Error("layer() needs a name");let l=this.arg(s.args,"mode",1),o=this.arg(s.args,"color",2),h=this.layers.get(i),f=this.arg(s.args,"order",-1),u=this.arg(s.args,"bleed",-1);if(l!==void 0||o!==void 0||f!==void 0||u!==void 0||!h){if(h?.side==="back")throw new Error(`the layer "${i}" is the back of layer "${i.slice(0,-5)}"; set its mode and colour on that layer, or give this one another name`);let p=l??h?.mode??"line";if(!["cut","line","fill","guide"].includes(p))throw new Error('mode must be "cut", "line", "fill" or "guide"');let m=C1(o??h?.color??"#00aa00");if(!/^#[0-9a-fA-F]{6}$/.test(m))throw new Error('color must look like "#00aa00"');let v=f===void 0?h?.order:this.num(f,"layer","order"),g=u===void 0?h?.bleed:this.num(u,"layer","bleed");if(g!==void 0&&!(g>=0))throw new Error("bleed must be 0 or more");if(g&&p==="cut")throw new Error("a cut layer has no bleed");this.layers.set(i,{name:i,mode:p,color:m,...v!==void 0&&{order:v},...g!==void 0&&{bleed:g}})}let d=this.arg(s.args,"side",-1,"front");if(d!=="front"&&d!=="back")throw new Error(`side must be "front" or "back", got ${X1(d)}`);if(d==="back"&&this.layers.get(i)?.mode==="cut")throw new Error("a cut layer has no back: only marks go on the back face");return d==="back"&&s.env.vars.set("$mirrored",!k1(this.dyn(s.env,"$mirrored"))),q2(s.children(),d==="back"?this.backLayer(i):i)},part:s=>{let i=C1(this.arg(s.args,"name",0,"part")),l=Math.max(1,Math.floor(V1(this.arg(s.args,"qty",1,1))||1)),o=this.arg(s.args,"stack",-1),h=o===void 0?1:Math.floor(this.num(o,"part","stack"));if(!(h>=1))throw new Error("stack must be 1 or more");if(this.copies+=l*h,!(this.copies<=this.limits.maxParts))throw new Error(`more than ${this.limits.maxParts} part copies in total, the limit`);let f=this.arg(s.args,"at",-1),u=this.arg(s.args,"rotate",-1),d=this.arg(s.args,"glue",-1),p=d===void 0?void 0:C1(d),m=C1(this.arg(s.args,"face",-1,"top"));if(m!=="top"&&m!=="bottom")throw new Error(`face must be "top" or "bottom", got ${X1(m)}`);let v=this.frame!==x5&&p===void 0,g=this.arg(s.args,"bend",-1),b=f===void 0&&u===void 0&&!v&&p===void 0&&g===void 0?void 0:this.placements(f,u,l),y=this.arg(s.args,"material",-1);y!==void 0&&s.env.vars.set("$material",C1(y));let w=this.thickness(s.env);b&&(v||h>1)&&(b=b.flatMap(U=>{let c1=p===void 0?D1(this.frame,u0(U)):u0(U),X=p!==void 0&&m==="bottom"?-w:w;return Array.from({length:h},(f1,I1)=>({...U,matrix:D1(c1,I0(0,0,I1*X))}))}));let k=this.arg(s.args,"mirror",-1,!1),P;if(Array.isArray(k)){if(k.length!==l)throw new Error(`mirror needs one true or false per copy: qty is ${l} but mirror has ${k.length}`);P=k.map(U=>k1(U))}else P=Array.from({length:l},()=>k1(k));let S=P.some(U=>U)&&!P.every(U=>U);if(S&&p!==void 0)throw new Error("mirror per copy cannot go with glue: make the mirrored copies a part of their own");let A=P[0],E=U=>{let c1=s.env.vars.get("$mirrored"),X=s.env.vars.has("$mirrored");U&&s.env.vars.set("$mirrored",!0);try{let f1=s.children();return U?f2(f1,[-1,0,0,1,0,0]):f1}finally{U&&(X?s.env.vars.set("$mirrored",c1):s.env.vars.delete("$mirrored"))}},z=E(A),I=this.bends(g),$=this.arg(s.args,"on",-1),F=this.arg(s.args,"slots",-1),_=F===void 0?void 0:(Array.isArray(F)?F:[F]).map(U=>{if(typeof U!="string")throw new Error("slots must be part names");return U}),Y=this.num(this.arg(s.args,"clearance",-1,.1),"part","clearance"),N=(U,c1,X)=>{let f1=X.length===l,I1=b?.filter((M1,k2)=>X.includes(Math.floor(k2/h)+1));return{name:i,qty:X.length*h,layers:U,thickness:w,kerf:V1(this.dyn(s.env,"$kerf"))||0,material:C1(this.dyn(s.env,"$material")??"material"),...I1?{placements:I1}:{},...h>1?{stack:h}:{},...I.length?{bends:I}:{},...$!==void 0?{on:C1($)}:{},..._?{slots:_,clearance:Y}:{},...this.step?{step:this.step}:{},...p!==void 0&&{glue:{host:p,face:m}},...c1&&{mirrored:!0},...!f1&&{copies:X}}},i1=U=>P.flatMap((c1,X)=>c1===U?[X+1]:[]),h1=S?[N(z.layers,A,i1(A)),N(E(!A).layers,!A,i1(!A))]:[N(z.layers,A,i1(A))];return{layers:new Map,parts:[...z.parts,...h1]}},place:s=>{let i=this.vec3(this.arg(s.args,"at",0,[0,0,0]),"at"),l=this.vec3(this.arg(s.args,"rotate",1,[0,0,0]),"rotate"),o=this.frame;this.frame=D1(o,u0({at:i,rotate:l}));try{return s.children()}finally{this.frame=o}},step:s=>{let i=C1(this.arg(s.args,"text",0,"")),l=k1(this.arg(s.args,"substeps",1,!0));if(this.stepFolded)return s.children();let o=this.step,h=o&&i?`${this.stepNames[o-1]}: ${i}`:i,f=this.stepNames.indexOf(h)+1;f||(this.stepNames.push(h),f=this.stepNames.length),this.step=f,this.stepFolded=!l;try{return s.children()}finally{this.step=o,this.stepFolded=!1}},hardware:s=>{let i=C1(this.arg(s.args,"kind",0,"dowel"));K1(k5,i)===void 0&&K1(f6,i)===void 0&&this.warn(`hardware(): unknown kind "${i}"; the 3D view shows it grey (${A0(s.args.at,!1)})${a2(i,Object.keys(k5))}`);let l=C1(this.arg(s.args,"shape",-1,"rod"));if(l!=="rod"&&l!=="ball")throw new Error(`shape must be "rod" or "ball", got ${X1(l)}`);let o=this.arg(s.args,"sides",-1),h=l==="ball"||o===0,f=this.vec3(this.arg(s.args,"from",1),"from"),u=this.arg(s.args,"to",2),d=h&&u===void 0?f:this.vec3(u,"to"),p=this.arg(s.args,"size",3,6),m=typeof p=="number"?p:this.vec2(p,"size",!1);if(h){if(typeof m!="number"||!(m>0))throw new Error("a ball's size is its diameter, a number more than 0");f=d=[(f[0]+d[0])/2,(f[1]+d[1])/2,(f[2]+d[2])/2]}let v=[d[0]-f[0],d[1]-f[1],d[2]-f[2]],g=Math.abs(v[2])>.9*Math.hypot(...v),b=this.arg(s.args,"up",-1),y=b===void 0?g?[0,1,0]:[0,0,1]:this.vec3(b,"up"),w=h?0:Math.floor(this.num(o??24,"hardware","sides"));if(!h&&!(w>=3&&w<=t4))throw new Error(`sides must be from 3 to ${t4} (or 0 for a ball), got ${X1(w)}`);if(this.pointCount+=h?2*t4:w*2,this.pointCount>this.limits.maxPoints*10)throw new Error(`making the shapes and hardware took more than ${this.limits.maxPoints*10} points of work, the limit`);let k=this.arg(s.args,"label",-1),P=this.frame,S=E=>[P[0]*E[0]+P[1]*E[1]+P[2]*E[2]+P[3],P[4]*E[0]+P[5]*E[1]+P[6]*E[2]+P[7],P[8]*E[0]+P[9]*E[1]+P[10]*E[2]+P[11]],A=E=>[P[0]*E[0]+P[1]*E[1]+P[2]*E[2],P[4]*E[0]+P[5]*E[1]+P[6]*E[2],P[8]*E[0]+P[9]*E[1]+P[10]*E[2]];if(this.hardware.length>=this.limits.maxParts)throw new Error(`more than ${this.limits.maxParts} pieces of hardware, the limit`);return this.hardware.push({kind:i,from:S(f),to:S(d),size:m,up:A(y),sides:w,step:this.step,...k!==void 0?{label:C1(k)}:{}}),s.children()},material:s=>{let i=this.arg(s.args,"thickness",0),l=this.arg(s.args,"kerf",1),o=this.arg(s.args,"name",2);return i!==void 0&&s.env.vars.set("$thickness",this.num(i,"material","thickness")),l!==void 0&&s.env.vars.set("$kerf",this.num(l,"material","kerf")),o!==void 0&&s.env.vars.set("$material",C1(o)),s.children()},children:s=>{let i=s.env.childCtx();if(!i)return a0();let l=this.childStmts(i.stmts),o=this.arg(s.args,"index",0),h=new q1(i.env,s.env);this.hoist(i.stmts,h);let f=new Set;if(o===void 0)l.forEach(m=>f.add(m));else for(let m of this.iterable(o,s.args.at))l[V1(m)]&&f.add(l[V1(m)]);let u=[],d=this.childCache.get(i)??new Map;this.childCache.set(i,d);let p=this.childKey(h);for(let m of i.stmts)if(m.kind==="assign")this.stmt(m,h);else if(f.has(m)){let v=p&&d.get(m);if(v&&v.key===p){v.shape&&u.push(v.shape);continue}let g=this.effects(),b=this.stmt(m,h);b&&u.push(b),p&&this.effects()===g&&!b?.parts.length&&d.set(m,{key:p,shape:b})}return q0(u)},echo:s=>(this.echo(this.echoText(s.args),s.args.at),s.children()),assert:s=>(this.assert(s.args),s.children()),finger_rect:s=>{let[i,l]=this.vec2(this.arg(s.args,"size",0),"size"),o=this.edges(this.arg(s.args,"edges",1,"out")),h=this.thickness(s.env),f=this.fingerWidth(s.args,s.env,2);return this.spend(2*(Math.abs(i)+Math.abs(l))/f*4),F1(e6(i,l,o,h,f))},finger_holes:s=>{let i=this.num(this.arg(s.args,"length",0),"finger_holes","length"),l=this.edges(this.arg(s.args,"edge",1,"out"))[0];if(l==="flat")throw new Error('edge must be "out" or "in"');let o=this.fingerWidth(s.args,s.env,2);return this.spend(Math.abs(i)/o*4),F1(t6(i,l,this.thickness(s.env),o))},tslot:s=>{let i=this.num(this.arg(s.args,"d",0,3),"tslot","d"),l=this.num(this.arg(s.args,"length",1,12),"tslot","length"),[o,h]=this.vec2(this.arg(s.args,"nut",2,[i*1.85,i*.8]),"nut",!1),f=this.num(this.arg(s.args,"nut_at",3,l/2),"tslot","nut_at");return F1(r1(n6(i,l,o,h,f)))},living_hinge:s=>{let[i,l]=this.vec2(this.arg(s.args,"size",0),"size"),o=this.num(this.arg(s.args,"spacing",1,1.5),"living_hinge","spacing"),h=this.num(this.arg(s.args,"bridge",2,3),"living_hinge","bridge"),f=this.num(this.arg(s.args,"cut",3,Math.max(h*2,(l-3*h)/2)),"living_hinge","cut");if(o<=0||h<=0||f<=0)throw new Error("spacing, bridge and cut must be positive");return this.spend((Math.abs(i)/o+1)*(Math.abs(l)/(f+h)+2)*2),R0(c6(i,l,o,h,f))}};function a(s,i){let l={regions:[],lines:[]};for(let o of s){if(o.parts.length)throw new Error(`part() can only be the first child of ${i}()`);for(let h of o.layers.values())for(let f of h.regions)l.regions.push(f)}return l}function r(s,i){let l=o=>{let h=new Map;for(let[f,u]of o)h.set(f,i(u));return h};return{layers:l(s.layers),parts:s.parts.map(o=>({...o,layers:l(o.layers)}))}}}};var W0=1e6,_3=.01,Z7=n=>g1(n)<0?[...n].reverse():n;function Zc(n,e){let t=D1(k3(n.matrix),e.matrix),[c,a]=[t[8],t[9]],r=Math.hypot(c,a);if(r<1e-9)return[];let s=0,i=e.thickness,l=S=>(-t[11]-Math.max(t[10]*s,t[10]*i)+S)/r,o=S=>(n.thickness-t[11]-Math.min(t[10]*s,t[10]*i)-S)/r;if(!(o(_3)>l(_3)))return[];let[h,f]=[c/r,a/r],[u,d]=[-f,h],p=(S,A)=>[[h*S-u*W0,f*S-d*W0],[h*A-u*W0,f*A-d*W0],[h*A+u*W0,f*A+d*W0],[h*S+u*W0,f*S+d*W0]],m=1/0,v=-1/0;for(let S of e.outline)for(let[A,E]of S)for(let z of[s,i]){let I=t[8]*A+t[9]*E+t[10]*z+t[11];I<m&&(m=I),I>v&&(v=I)}if(Math.min(n.thickness,v)-Math.max(0,m)<Math.min(1,n.thickness/2))return[];let g=(S,A)=>Y1(e.outline,[Z7(p(S,A))]).filter(E=>Math.abs(g1(E))>1e-6);if(!g(l(_3),o(_3)).length)return[];let b=g(l(0),o(0));if(!b.length)return[];let y=S=>([A,E])=>[t[0]*A+t[1]*E+t[2]*S+t[3],t[4]*A+t[5]*E+t[6]*S+t[7]],w=t[0]*t[5]-t[1]*t[4]<0,k=S=>b.map(A=>{let E=A.map(y(S));return w?E.reverse():E}),P=[];for(let S of b)for(let A=0;A<S.length;A++){let E=S[A],z=S[(A+1)%S.length],I=[y(s)(E),y(s)(z),y(i)(z),y(i)(E)];Math.abs(g1(I))>1e-9&&P.push(Z7(I))}return r1([...k(s),...k(i),...P],"nonzero")}function Y7(n,e,t){let c=[];for(let r of e)for(let s of Zc(n,r))c.push(s);if(!c.length)return[];let a=T0(Y1(r1(c),n.outline)).filter(r=>r.reduce((s,i)=>s+g1(i),0)>1e-4);return a.length?B1(a.flat(),t/2,"miter"):[]}var x2=n=>{let e=Math.round(n*1e3)/1e3;return Object.is(e,-0)?"0":String(e)},i4=n=>n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;");function l4(n,e){let t=[];for(let[c,a]of n){let r=[x2(c),x2(a)],s=t[t.length-1];(!s||s[0]!==r[0]||s[1]!==r[1])&&t.push(r)}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 z2=(n,e)=>`M${l4(n,e).map(([t,c])=>`${t} ${c}`).join("L")}${e?"Z":""}`;function G3(n,e){let t=[];for(let c of e){let a=[],r=[],s=[];for(let i of n){let l=i.layers.get(c.name);if(l){for(let o of l.lines)a.push(z2(o,!1));for(let o of l.regions)(g1(o)<0?r:s).push(z2(o,!0))}}(a.length||r.length||s.length)&&t.push({name:c.name,mode:c.mode,color:c.color,d:[...a,...r,...s].join(""),regions:[...r,...s].join(""),lines:a.join("")})}return t}function j3(n,e,t,c){let a=['<?xml version="1.0" encoding="UTF-8"?>',`<svg xmlns="http://www.w3.org/2000/svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="${x2(e)}mm" height="${x2(t)}mm" viewBox="0 0 ${x2(e)} ${x2(t)}">`];for(let r of c){let s=[],i=[];for(let o of n){let h=o.layers.get(r.name);if(!h)continue;let f=` data-part="${i4(o.part)}"`;if(r.mode==="fill"){h.regions.length&&i.push(`<path${f} d="${h.regions.map(u=>z2(u,!0)).join("")}"/>`);for(let u of h.lines)i.push(`<path${f} fill="none" stroke="${r.color}" stroke-width="0.1" d="${z2(u,!1)}"/>`);continue}for(let u of h.lines)s.push(`<path${f} d="${z2(u,!1)}"/>`);for(let u of h.regions)(g1(u)<0?s:i).push(`<path${f} d="${z2(u,!0)}"/>`)}if(!s.length&&!i.length)continue;let l=r.mode==="fill"?`fill="${r.color}" fill-rule="evenodd" stroke="none"`:`fill="none" stroke="${r.color}" stroke-width="0.1"${r.mode==="guide"?' stroke-dasharray="1 1"':""}`;a.push(`<g id="${i4(r.name)}" inkscape:groupmode="layer" inkscape:label="${i4(r.name)}" data-mode="${r.mode}" ${l}>`,...s,...i,"</g>")}return a.push("</svg>",""),a.join(`
2564
+ `)}var Yc={"#ff0000":1,"#ffff00":2,"#00ff00":3,"#00ffff":4,"#0000ff":5,"#ff00ff":6,"#000000":7},Kc=n=>{let e=Yc[n.toLowerCase()];if(e)return e;let[t,c,a]=[1,3,5].map(r=>parseInt(n.slice(r,r+2),16));return t>c&&t>a?1:c>t&&c>a?3:a>t&&a>c?5:7};function Jc(n){let e=i=>i.toUpperCase().replace(/[^A-Z0-9_-]/g,"_"),t=new Set(r4.map(i=>i.name)),c=new Set(n.map(i=>e(i.name))),a=new Set,r=new Map,s=[...n.filter(i=>t.has(i.name)),...n.filter(i=>!t.has(i.name))];for(let i of s){let l=e(i.name);if(a.has(l)){let o=2;for(;c.has(`${l}_${o}`)||a.has(`${l}_${o}`);)o++;l=`${l}_${o}`}a.add(l),r.set(i.name,l)}return r}function o4(n,e,t,c){let a=[],r=(l,o)=>a.push(String(l),String(o)),s=Jc(c);r(0,"SECTION"),r(2,"HEADER"),r(9,"$ACADVER"),r(1,"AC1009"),r(9,"$INSUNITS"),r(70,4),r(0,"ENDSEC"),r(0,"SECTION"),r(2,"TABLES"),r(0,"TABLE"),r(2,"LAYER"),r(70,c.length);for(let l of c)r(0,"LAYER"),r(2,s.get(l.name)),r(70,0),r(62,Kc(l.color)),r(6,"CONTINUOUS");r(0,"ENDTAB"),r(0,"ENDSEC"),r(0,"SECTION"),r(2,"ENTITIES");let i=(l,o,h)=>{r(0,"POLYLINE"),r(8,l),r(66,1),r(10,0),r(20,0),r(30,0),r(70,h?1:0);for(let[f,u]of l4(o.map(([d,p])=>[d,t-p]),h))r(0,"VERTEX"),r(8,l),r(10,f),r(20,u),r(30,0);r(0,"SEQEND"),r(8,l)};for(let l of c){let o=s.get(l.name),h=[];for(let f of n){let u=f.layers.get(l.name);if(u){for(let d of u.lines)i(o,d,!1);for(let d of u.regions)g1(d)<0?i(o,d,!0):h.push(d)}}for(let f of h)i(o,f,!0)}return r(0,"ENDSEC"),r(0,"EOF"),a.join(`
2228
2565
  `)+`
2229
- `}var Y7=(c,e)=>{let t=0;for(let n=1;n<c.length;n++)t+=Math.hypot(c[n][0]-c[n-1][0],c[n][1]-c[n-1][1]);return e&&c.length>2&&(t+=Math.hypot(c[0][0]-c[c.length-1][0],c[0][1]-c[c.length-1][1])),t},E1=c=>Math.round(c*100)/100;function J7(c,e={}){for(let[b,V]of Object.entries(e.params??{}))try{e5(b,V)}catch(c1){throw new D(c1.message)}let{program:t}=D0(c),n=new Set(t.body.flatMap(b=>b.kind==="assign"?[b.name]:[])),a=Object.keys(e.params??{}).filter(b=>!b.startsWith("$")&&!n.has(b)),r=e.fonts?new q3(e.fonts,e.defaultFont):void 0,s=new B3({overrides:e.params,resolve:e.resolve,fonts:r,maxSteps:e.maxSteps,limits:e.limits}),i=s.limits,l;try{l=s.run(t)}catch(b){let V=b instanceof RangeError?new D(/call stack/i.test(b.message)?"Recursion too deep: the program calls itself without stopping":"A value grew too large. Is a list or string doubling without end?"):b;throw V instanceof D&&(V.echoes=s.echoes,V.warnings=[...s.warnings],r?.missing.size&&(V.missingFonts=[...r.missing])),V}let o=b=>l.globals.get(b).value,h=l.warnings;for(let b of a)h.push(`Setting "${b}" is not a variable of the program, so it is ignored.${a2(b,n)}`);let f=l.layers,u=b=>f.get(b)?.mode??"line",d=[...l.shape.parts];[...l.shape.layers.values()].some(b=>b.regions.length||b.lines.length)&&d.unshift({name:"part",qty:1,layers:l.shape.layers,thickness:H1(o("$thickness"))||3,kerf:H1(o("$kerf"))||0,material:I1(o("$material")??"material")}),d.length||h.push("Nothing to cut: the program made no shapes.");let m=b=>JSON.stringify([b.thickness,b.material,[...b.layers].map(([V,c1])=>[V,c1.regions.map(a1=>a1.map(([h1,v1])=>[Math.round(h1*100),Math.round(v1*100)])),c1.lines.map(a1=>a1.map(([h1,v1])=>[Math.round(h1*100),Math.round(v1*100)]))])]),v=new Map,g=new Set;for(let b of d){let V=m(b),c1=b.mirrored?`${b.name}\0mirrored`:b.name,a1=v.get(c1);a1===void 0?v.set(c1,V):a1!==V&&g.add(b.name)}for(let b of g)h.push(`Two different parts are named "${b}"; slots, glue and on = find parts by name, so give each its own.`);aa(d,h),Qn(d,u,h);let y=[],M=e.analysis?{schemaVersion:1,relations:!0,parts:[]}:void 0,A=[],z=new Map,E=[],k=new Set,C=[],P=o("$min_width"),w=P===void 0?1.5:H1(P),I=o("$label_parts")===!0,B=0;I&&!r&&h.push("$label_parts needs a font for the numbers. Pass fonts to render().");let F=f.get("engrave-back");I&&r&&F&&F.side!=="back"&&h.push('$label_parts engraves the numbers on the layer "engrave-back", which this program uses for the front; rename that layer to number the parts.');let G=I&&!!r&&(!F||F.side==="back");if(G){let b=f.get("engrave");f.has("engrave-back")||f.set("engrave-back",{name:"engrave-back",mode:"fill",color:b?.color??"#000000",side:"back"})}let X=[];for(let b of d){let V=s1([...b.layers].filter(([j])=>u(j)==="cut").flatMap(([,j])=>j.regions)),c1;if(b.bends&&V.length){let j=1/0,n1=-1/0;for(let K of V)for(let[$]of K)j=Math.min(j,$),n1=Math.max(n1,$);for(let K of b.bends)(K.x0<j-.001||K.x1>n1+.001)&&h.push(`Part "${b.name}" bends from x = ${A0(K.x0)} to ${A0(K.x1)}, beyond the part (x = ${A0(j)} to ${A0(n1)}); only the part itself bends.`)}if(G&&V.length){c1=++B;let j=ra(V,String(c1),r,I1(o("$font")??""));if(j.length){let n1=b.layers.get("engrave-back")??{regions:[],lines:[]};b.layers=new Map(b.layers).set("engrave-back",{regions:[...n1.regions,...j],lines:n1.lines})}else h.push(`Part "${b.name}" is too small to take its number ${c1}.`)}if(w>0&&V.length){let j=N1(N1(V,-w/2,"round"),w/2,"round"),n1=T0(Q1(V,j)).filter(K=>K.reduce(($,_)=>$+g1(_),0)>2*w*w);if(n1.length){let K=n1.slice(0,3).map($=>{let[_,f1,U1,T1]=r0(new Map([["cut",{regions:$,lines:[]}]]));return`[${E1((_+U1)/2)}, ${E1((f1+T1)/2)}]`});h.push(`Part "${b.name}" is narrower than ${w} mm ($min_width) in ${n1.length} place${n1.length>1?"s":""}, at ${K.join(", ")}${n1.length>3?" and more":""} in the part's coordinates.`)}}let a1=new Map;for(let[j,n1]of b.layers){if(u(j)==="guide"&&!e.guides)continue;let K=s1(n1.regions),$=n1.lines.filter(_=>_.length>=2);if((u(j)==="line"||u(j)==="guide")&&($=[...$,...K.map(_=>[..._,_[0]])],K=[]),V.length&&u(j)!=="guide"){let _=f.get(j)?.bleed??0,f1=_>0?N1(V,_,"round"):V;u(j)!=="cut"&&(K=Z1(K,f1)),$=M0($,f1,"inside")}(K.length||$.length)&&a1.set(j,{regions:K,lines:$})}if(X.push(...ca(b.name,a1,f)),V.length){let j=[];for(let[K,$]of a1){let _=f.get(K);if(_?.mode==="cut"&&$.lines.length)for(let f1 of["front","back"])j.push({layer:K,mode:"line",color:"#000000",side:f1,regions:[],lines:$.lines});!_||_.mode!=="fill"&&_.mode!=="line"||j.push({layer:K,mode:_.mode,color:_.color,side:_.side??"front",regions:$.regions,lines:$.lines})}let n1={name:b.name,thickness:b.thickness,material:b.material,outline:V,...j.length&&{marks:j}};if(b.placements){let K=new Set;b.placements.forEach(($,_)=>{let f1={...n1,copy:K7(b,_),matrix:h0($),placed:!0,...b.bends&&{bends:b.bends},...b.step&&{step:b.step},...b.stack&&{stack:b.stack}};A.push(f1),b.on!==void 0&&z.set(f1,b.on);let U1=f1.matrix.map(T1=>T1.toFixed(6)).join(",");K.has(U1)&&k.add(f1),K.add(U1)}),K.size<b.placements.length&&h.push(`Copies of part "${b.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 K=0;K<b.qty;K++)E.push({...n1,copy:K7(b,K),matrix:h0({at:[0,0,0],rotate:[0,0,0]}),placed:!1,...b.step&&{step:b.step}})}let h1=T0(V),v1=h1.length;if(v1>1){let j=$=>$.reduce((_,f1)=>_+g1(f1),0),K=[...h1].sort(($,_)=>j(_)-j($)).slice(1,4).map($=>{let[_,f1,U1,T1]=r0(new Map([["cut",{regions:$,lines:[]}]]));return`[${E1(_)}, ${E1(f1)}] to [${E1(U1)}, ${E1(T1)}]`}).join(", ");h.push(`Part "${b.name}" cuts into ${v1} separate pieces. Join them, or make them separate parts. The smaller ${v1===2?"one is":"ones are"} at ${K}${v1>4?" and more":""}, in the part's coordinates.`)}let C1=0;for(let[j,n1]of a1)if(u(j)==="cut"){for(let K of n1.regions)C1+=Y7(K,!0);for(let K of n1.lines)C1+=Y7(K,!1)}let b1=r0(a1)??[0,0,0,0],p1=e.kerf??b.kerf;if(!(Number.isFinite(p1)&&p1>=0))throw new D("$kerf must be a number, 0 or more");let j1={name:b.name,qty:b.qty,width:E1(b1[2]-b1[0]),height:E1(b1[3]-b1[1]),pieces:v1,cutLength:Math.round(C1),thickness:b.thickness,kerf:p1,material:b.material,...b.stack&&{stack:b.stack},...b.glue&&{glued:b.glue.host},...b.mirrored&&{mirrored:!0},...c1!==void 0&&{label:c1}};if(M&&M.parts.push({name:b.name,kerf:p1,qty:b.qty,...b.stack&&{stack:b.stack},...b.glue&&{glue:b.glue},...b.on&&{on:b.on},cutRegions:V.map(j=>j.map(([n1,K])=>[n1,K])),cutLines:[...a1].filter(([j])=>u(j)==="cut").flatMap(([,j])=>j.lines.map(n1=>n1.map(([K,$])=>[K,$])))}),p1>0){for(let[j,n1]of a1)if(u(j)==="cut"){let K=n1.regions.filter(f1=>g1(f1)<0);n1.regions=N1(n1.regions,p1/2,"round",Math.min(.01,p1/20));let $=n1.regions.filter(f1=>g1(f1)<0),_=K.length-$.length;if(_>0){let f1=T1=>{let[F0,Y0,M8,x8]=r0(new Map([["cut",{regions:[T1],lines:[]}]]));return[(F0+M8)/2,(Y0+x8)/2]},U1=K.map(f1).filter(([T1,F0])=>!$.some(Y0=>Q7(Y0,T1,F0))).slice(0,3).map(([T1,F0])=>`[${E1(T1)}, ${E1(F0)}]`);h.push(`Part "${b.name}": ${_} hole${_===1?" is":"s are"} narrower than the ${p1} mm kerf and will not be cut${U1.length?`, at ${U1.join(", ")}${_>U1.length?" and more":""} in the part's coordinates`:""}.`)}}}y.push(j1),C.push({info:j1,layers:a1})}ea(A,z,h);let q=new Map,o1=A.filter(b=>!k.has(b)).flatMap(b=>{let V=k3(b);for(let c1 of V)q.set(c1,b);return V}),{found:N,complete:Z}=l6(o1,i.maxCollisionPairs),e1=N.filter(([b,V])=>q.get(b)!==q.get(V)).map(([b,V])=>[q.get(b)??b,q.get(V)??V]).filter(([b,V],c1,a1)=>a1.findIndex(([h1,v1])=>h1===b&&v1===V)===c1);Z||h.push(`The assembly has more than ${i.maxCollisionPairs} pairs of touching parts, the limit, so only those were checked for collisions.`);for(let[b,V]of e1.slice(0,5)){let[c1,a1]=U2(b),[h1,v1]=U2(V),C1=[0,1,2].map(b1=>E1((Math.max(c1[b1],h1[b1])+Math.min(a1[b1],v1[b1]))/2));h.push(`Parts "${b.name}"${b.copy>1?` (copy ${b.copy})`:""} and "${V.name}"${V.copy>1?` (copy ${V.copy})`:""} collide in the assembly, around [${C1.join(", ")}]. Check their edges and where they are placed.`)}if(e1.length>5&&h.push(`${e1.length-5} more pairs of parts collide in the assembly.`),na(X,h),A.length&&E.length){let b=[...new Set(E.map(V=>`"${V.name}"`))];h.push(`${b.length===1?"Part":"Parts"} ${b.slice(0,5).join(", ")}${b.length>5?` and ${b.length-5} more`:""} ${b.length===1?"has":"have"} no at or rotate, so ${b.length===1?"it lies":"they lie"} flat beside the assembly.`),A.push(...i6(A,E))}let t1=0;for(let b of C){let V=0;for(let c1 of b.layers.values()){for(let a1 of c1.regions)V+=a1.length;for(let a1 of c1.lines)V+=a1.length}t1+=V*b.info.qty}if(t1>i.maxOutputPoints)throw new D(`The files would have ${t1} points, more than the limit of ${i.maxOutputPoints}. Use fewer copies or simpler shapes.`);let d1=e.sheet??(l.globals.vars.has("$sheet")?o("$sheet"):e.defaultSheet??o("$sheet"));if(!Array.isArray(d1)||!(Number.isFinite(d1[0])&&d1[0]>0)||!(Number.isFinite(d1[1])&&d1[1]>0))throw new D("$sheet must be [width, height], both more than 0");let _1=e.gap??H1(o("$gap")??3),M1=e.margin??_1;if(!(Number.isFinite(_1)&&_1>=0))throw new D("$gap must be a number, 0 or more");if(!(Number.isFinite(M1)&&M1>=0))throw new D("margin must be a number, 0 or more");let X3=e.nest??o("$nest")===!0,k2=e.layout??(o("$layout")==="none"?"none":"pack"),J2=[...f.keys()].filter(b=>!["engrave","score","cut","guide"].includes(b)),X0=b=>(f.get(b)?.order??0)*2+(u(b)==="fill"?0:1),f4=["engrave",...J2.map((b,V)=>[b,V]).sort((b,V)=>X0(b[0])-X0(V[0])||b[1]-V[1]).map(([b])=>b),"score","cut","guide"].map(b=>f.get(b)).filter(Boolean),O0=f4.filter(b=>b.side!=="back"),L2=[...f4.filter(b=>b.side==="back")],Z3=o("$registration")===!0;Z3&&!f.has("registration")&&f.set("registration",{name:"registration",mode:"fill",color:"#000000"}),Z3&&!O0.some(b=>b.name==="registration")&&O0.push(f.get("registration"));let i0=[],d4=[1,0,0,-1,0,0],Y3=b=>r0(b)??[0,0,0,0],L0=(b,V)=>f2({layers:b,parts:[]},V).layers;if(k2==="none"){let b=[];for(let h1 of C)for(let v1=0;v1<h1.info.qty;v1++)b.push({part:h1.info.name,copy:v1+1,layers:L0(h1.layers,d4),rotated:!1});let V=new Map;for(let h1 of b)for(let[v1,C1]of h1.layers){let b1=V.get(v1)??{regions:[],lines:[]};for(let p1 of C1.regions)b1.regions.push(p1);for(let p1 of C1.lines)b1.lines.push(p1);V.set(v1,b1)}let c1=Y3(V),a1=[1,0,0,1,M1-c1[0],M1-c1[1]];for(let h1 of b)h1.layers=L0(h1.layers,a1),h1.offset=[a1[4],a1[5]];i0.push(p4(b,c1[2]-c1[0]+2*M1,c1[3]-c1[1]+2*M1,C[0]?.info))}else{let b=new Map;for(let V of C){let c1=`${V.info.material}|${V.info.thickness}`;b.set(c1,[...b.get(c1)??[],V])}for(let V of b.values()){let[c1,a1]=d1,h1=[];for(let $ of V){let _=L0($.layers,d4),f1=Y3(_),U1=f1[2]-f1[0],T1=f1[3]-f1[1],F0=!1;(U1>c1-2*M1||T1>a1-2*M1)&&T1<=c1-2*M1&&U1<=a1-2*M1&&(_=L0(_,[0,1,-1,0,0,0]),f1=Y3(_),U1=f1[2]-f1[0],T1=f1[3]-f1[1],F0=!0),(U1>c1-2*M1||T1>a1-2*M1)&&h.push(`Part "${$.info.name}" (${E1(U1)} x ${E1(T1)} mm) is bigger than the ${c1} x ${a1} mm sheet.`),_=L0(_,[1,0,0,1,-f1[0],-f1[1]]);for(let Y0=0;Y0<$.info.qty;Y0++)h1.push({info:$.info,layers:_,w:U1,h:T1,copy:Y0+1,rotated:F0})}h1.sort(($,_)=>_.h-$.h||_.w-$.w);let v1=X3?ta(h1,_1,$=>u($)==="cut"):h1,C1=[],b1=M1,p1=M1,j1=0,j=0,n1=0,K=()=>{if(C1.length&&i0.length>=i.maxSheets)throw new D(`The parts need more than ${i.maxSheets} sheets, the limit. Use fewer copies or a bigger $sheet.`);C1.length&&i0.push(p4(C1,Math.max(j+M1,1),Math.max(n1+M1,1),V[0].info)),C1=[],b1=M1,p1=M1,j1=0,j=0,n1=0};for(let $ of v1){b1>M1&&b1+$.w>c1-M1&&(b1=M1,p1+=j1+_1,j1=0),C1.length&&p1+$.h>a1-M1&&K(),C1.push({part:$.info.name,copy:$.copy,layers:L0($.layers,[1,0,0,1,b1,p1]),rotated:$.rotated});for(let _ of $.inner??[])C1.push({part:_.item.info.name,copy:_.item.copy,layers:L0(_.item.layers,[1,0,0,1,b1+_.dx,p1+_.dy]),rotated:_.item.rotated});j=Math.max(j,b1+$.w),n1=Math.max(n1,p1+$.h),b1+=$.w+_1,j1=Math.max(j1,$.h)}K()}}function p4(b,V,c1,a1){let h1=E1(V),v1=E1(c1);if(Z3){let p1=Math.min(5,M1-1);if(!(p1>=2))h.push("Registration marks need $gap of 3 or more round the sheet.");else{let j1=(j,n1)=>[[j,n1],[j+p1,n1],[j+p1,n1+p1],[j,n1+p1]];b=[...b,{part:"registration",copy:1,layers:new Map([["registration",{regions:[j1(.5,.5),j1(h1-.5-p1,.5),j1(.5,v1-.5-p1)],lines:[]}]]),rotated:!1}]}}let C1=b.some(p1=>L2.some(j1=>p1.layers.has(j1.name))),b1=C1?b.map(p1=>({...p1,layers:L0(p1.layers,[-1,0,0,1,h1,0])})):[];return{width:h1,height:v1,material:a1?.material??"material",thickness:a1?.thickness??0,items:b,paths:G3(b,O0),svg:_3(b,h1,v1,O0),dxf:l4(b,h1,v1,O0),...C1&&{back:{paths:G3(b1,L2),svg:_3(b1,h1,v1,L2),dxf:l4(b1,h1,v1,L2)}}}}let Z0=i0.length===1?i0[0]:void 0,m4=Z0?[]:i0.flatMap((b,V)=>{let c1=i0.slice(0,V).reduce((a1,h1)=>a1+h1.height+10,0);return b.items.map(a1=>({...a1,layers:L0(a1.layers,[1,0,0,1,0,c1])}))}),v4=E1(Math.max(1,...i0.map(b=>b.width))),g4=E1(Math.max(1,i0.reduce((b,V)=>b+V.height,0)+10*Math.max(0,i0.length-1))),g8=Z0?Z0.svg:_3(m4,v4,g4,O0),y8=Z0?Z0.paths:G3(m4,O0);return{sheets:i0,width:Z0?.width??v4,height:Z0?.height??g4,paths:y8,svg:g8,parts:y,assembly:A,layers:[...O0,...L2],warnings:h,echoes:l.echoes,...M&&{analysis:M},hardware:l.hardware,steps:l.steps}}function Jn(c){if(!c.includes("*"))return t=>t===c;let e=new RegExp(`^${c.split("*").map(t=>t.replace(/[.+?^${}()|[\]\\]/g,"\\$&")).join(".*")}$`);return t=>e.test(t)}function Qn(c,e,t){if(!c.some(o=>o.slots))return;let n=new Map,a=o=>{let h=n.get(o);return h||(h=s1([...o.layers].filter(([f])=>e(f)==="cut").flatMap(([,f])=>f.regions)),n.set(o,h)),h},r=o=>(o.placements??[]).flatMap(h=>k3({name:o.name,copy:0,placed:!0,matrix:h0(h),thickness:o.thickness,outline:a(o),...o.bends&&{bends:o.bends}}).map(f=>({matrix:f.matrix,thickness:f.thickness,outline:f.outline}))),s=new Map,i=new Map;for(let o of c){if(!o.slots)continue;if(!o.placements){t.push(`Part "${o.name}" has slots but no at or rotate, so they can't be found.`);continue}let h=new Set;for(let v of o.slots){let g=v.startsWith("!"),y=Jn(g?v.slice(1):v),M=c.filter(A=>A!==o&&y(A.name));!M.length&&!g&&t.push(`Part "${o.name}": no part "${v}" to cut slots for.`);for(let A of M)g?h.delete(A):h.add(A)}let f=[...h].flatMap(r),u=(o.placements??[]).map(v=>s1(k3({name:o.name,copy:0,placed:!0,matrix:h0(v),thickness:o.thickness,outline:a(o),...o.bends&&{bends:o.bends}}).flatMap(g=>{let y=Z7(g,f,o.clearance??.1);return o.bends?Z1(y,N1(g.outline,1,"miter")):y}))),d=(v,g)=>X4(v,g).reduce((y,M)=>y+Math.abs(g1(M)),0)>.001,p=o.stack??1;if(p>1){let v=y=>u.filter((M,A)=>A%p===y),g=Array.from({length:p},(y,M)=>s1(v(M).flat()));if(g.slice(1).some(y=>d(g[0],y))){Array.from({length:p},(y,M)=>v(M)).some(y=>y.slice(1).some(M=>d(y[0],M)))&&t.push(`Copies of part "${o.name}" meet the parts in slots in different places; they all get every slot. Make them separate parts to cut each its own.`),i.set(o,g);continue}}u.slice(1).some(v=>d(u[0],v))&&t.push(`Copies of part "${o.name}" meet the parts in slots in different places; they all get every slot. Make them separate parts to cut each its own.`);let m=s1(u.flat());if(!m.length){o.slots.some(v=>v.includes("*"))||t.push(`Part "${o.name}": none of ${o.slots.map(v=>`"${v}"`).join(", ")} pass through it, so it has no slots.`);continue}s.set(o,m)}let l=(o,h)=>{let f=new Map(o);for(let[u,d]of o)f.set(u,{regions:Q1(d.regions,h),lines:M0(d.lines,h,"outside")});return f};for(let[o,h]of s)o.layers=l(o.layers,h);for(let[o,h]of i){let f=h.length,u=h.map((d,p)=>({...o,name:`${o.name}, layer ${p+1}`,qty:o.qty/f,layers:d.length?l(o.layers,d):o.layers,placements:o.placements.filter((m,v)=>v%f===p),stack:void 0}));c.splice(c.indexOf(o),1,...u)}}function ea(c,e,t){let n=new Map;for(let[a,r]of e){let s=c.filter(z=>z.name===r&&z.placed);if(!s.length){n.has(r)||t.push(`Part "${a.name}" is on "${r}", which is not a placed part.`),n.set(r,0);continue}let i=[...e].filter(([z,E])=>z.name===a.name&&E===r).length,l=s.length===i?s[a.copy-1]:s[0];if(!l?.bends?.length)continue;let[o,h,f,u]=[1/0,1/0,-1/0,-1/0];for(let z of a.outline)for(let[E,k]of z)o=Math.min(o,E),h=Math.min(h,k),f=Math.max(f,E),u=Math.max(u,k);let d=a.matrix,[p,m,v]=[(o+f)/2,(h+u)/2,a.thickness/2],g=[d[0]*p+d[1]*m+d[2]*v+d[3],d[4]*p+d[5]*m+d[6]*v+d[7],d[8]*p+d[9]*m+d[10]*v+d[11]],y=w3(l.matrix),M=y[0]*g[0]+y[1]*g[1]+y[2]*g[2]+y[3],A=w5(l.bends,l.thickness)[o6(l.bends,M)];a.matrix=F1(l.matrix,F1(A,F1(y,a.matrix)))}}function ta(c,e,t){var o;let n=[],a=h=>{let f=[];for(let[u,d]of h.layers)if(t(u))for(let p of d.regions)g1(p)<0&&f.push([...p].reverse());return f.length?N1(s1(f),-e,"miter"):[]},r=(h,f,u)=>{let d=0;for(let p of h)for(let m=0,v=p.length-1;m<p.length;v=m++){let[g,y]=p[v],[M,A]=p[m];y<=u?A>u&&(M-g)*(u-y)-(f-g)*(A-y)>0&&d++:A<=u&&(M-g)*(u-y)-(f-g)*(A-y)<0&&d--}return d!==0},s=h=>{let f=[];for(let[u,d]of h.layers)if(t(u))for(let p of d.regions)g1(p)>0&&f.push(p);return s1(f)},i=(h,f)=>{let{w:u,h:d}=f,p=s(f),m=[];for(let v of p)for(let g=0;g<v.length;g+=Math.max(1,Math.floor(v.length/12)))m.push(v[g]);for(let v of h){if(g1(v)<=0)continue;let[g,y,M,A]=[1/0,1/0,-1/0,-1/0];for(let[E,k]of v)g=Math.min(g,E),y=Math.min(y,k),M=Math.max(M,E),A=Math.max(A,k);if(M-g<u||A-y<d)continue;let z=Math.max(.5,Math.min(u,d,M-g-u+1,A-y-d+1)/4);for(let E=y;E<=A-d+1e-9;E+=z)for(let k=g;k<=M-u+1e-9;k+=z){if(!m.every(([P,w])=>r(h,P+k,w+E)))continue;let C=p.map(P=>P.map(([w,I])=>[w+k,I+E]));if(Q1(C,h).reduce((P,w)=>P+Math.abs(g1(w)),0)<.01)return[k,E]}}},l=[];for(let h of c){let f=!1;for(let d of n){let p=i(d.region,h);if(!p)continue;let[m,v]=p;((o=d.host).inner??(o.inner=[])).push({item:h,dx:d.ox+m,dy:d.oy+v}),d.region=Q1(d.region,N1(s(h).map(y=>y.map(([M,A])=>[M+m,A+v])),e,"miter"));let g=a(h);g.length&&n.push({host:d.host,ox:d.ox+m,oy:d.oy+v,region:g}),f=!0;break}if(f)continue;l.push(h);let u=a(h);u.length&&n.push({host:h,ox:0,oy:0,region:u})}return l}function K7(c,e){if(!c.copies)return e+1;let t=c.stack??1;return(c.copies[Math.floor(e/t)]-1)*t+e%t+1}function ca(c,e,t){let n=[...t.keys()],a=[...e.keys()].filter(i=>t.get(i)?.mode==="fill"&&e.get(i).regions.length&&!["score","cut","guide"].includes(i)),r=[];if(a.length<2)return r;let s=i=>i==="engrave"?-1/0:(t.get(i)?.order??0)*2+n.indexOf(i)/n.length;a.sort((i,l)=>s(i)-s(l));for(let i=0;i<a.length-1;i++){let l=t.get(a[i]).side??"front",o=a.slice(i+1).filter(f=>(t.get(f).side??"front")===l);if(!o.length)continue;let h;for(let f of T0(e.get(a[i]).regions)){let u=f.reduce((z,E)=>z+g1(E),0);if(!(u>.001)||!N1(f,-.5,"round").length)continue;let d=f;for(let z of o)d.length&&(d=Q1(d,e.get(z).regions));if(d.reduce((z,E)=>z+g1(E),0)>.001*Math.max(1,u))continue;let m=o.filter(z=>Z1(f,e.get(z).regions).length),v=m.length?m:o;if(h){h.count++;for(let z of v)h.under.includes(z)||h.under.push(z);continue}let[g,y,M,A]=r0(new Map([["f",{regions:f,lines:[]}]]));h={part:c,layer:a[i],under:v,count:1,at:[E1((g+M)/2),E1((y+A)/2)]}}h&&r.push(h)}return r}function na(c,e){for(let t of c.slice(0,5)){let n=t.under.map(r=>`"${r}"`),a=n.length>1?`${n.slice(0,-1).join(", ")} and ${n.at(-1)}`:n[0];e.push(`Part "${t.part}": ${t.count>1?`${t.count} fills`:"a fill"} on layer "${t.layer}" (${t.count>1?"the first ":""}at [${t.at.join(", ")}]) ${t.count>1?"lie":"lies"} wholly under ${a}, stacked above it in the files: printed, ${t.count>1?"they":"it"} won't show, and engraved, ${t.count>1?"they burn":"it burns"} twice. Draw them in one paint(), or give "${t.layer}" a higher order.`)}if(c.length>5){let t=c.slice(5),n=new Set(t.map(r=>r.part)).size,a=[...new Set(t.map(r=>`"${r.layer}"`))];e.push(`Fills are hidden the same way in ${t.length} more place${t.length>1?"s":""}, on ${n} part${n>1?"s":""} (layer${a.length>1?"s":""} ${a.slice(0,5).join(", ")}${a.length>5?" and more":""}).`)}}function aa(c,e){let t=new Set,n=(a,r)=>{if(!a.glue||t.has(a))return;if(r.includes(a)){e.push(`Part "${a.name}" is glued in a loop of parts; it is left where it is.`),t.add(a);return}let s=c.find(h=>h.name===a.glue.host&&h!==a);if(!s?.placements){e.push(`Part "${a.name}" is glued to "${a.glue.host}", which is not a placed part.`),t.add(a);return}n(s,[...r,a]);let i=s.placements.map(h0),l=a.glue.face==="top"?s.thickness:-a.thickness,o=a.placements.length/(a.stack??1);a.placements=a.placements.map((h,f)=>{let u=i.length===o?i[Math.floor(f/(a.stack??1))]:i[0];return{...h,matrix:F1(u,F1(I0(0,0,l),h0(h)))}}),t.add(a)};for(let a of c)n(a,[])}function ra(c,e,t,n){let a=0,r=50;for(let m=0;m<14;m++){let v=(a+r)/2;N1(c,-v,"round").length?a=v:r=v}if(a<1)return[];let s=N1(c,-a*.98,"round"),i=r0(new Map([["cut",{regions:s,lines:[]}]]));if(!i)return[];let[l,o]=[(i[0]+i[2])/2,(i[1]+i[3])/2];((m,v)=>s.reduce((g,y)=>g+(Q7(y,m,v)?g1(y)>0?1:-1:0),0)>0)(l,o)||([l,o]=s.reduce((m,v)=>g1(v)>g1(m)?v:m)[0]);let f=Math.min(6,Math.max(2,a*.9)),u=N3(t,e,{size:f,font:n,halign:"center",valign:"center",spacing:1}),d=r0(new Map([["t",{regions:u,lines:[]}]])),p=d?Math.min(1,1.6*a/Math.max(d[2]-d[0],1e-9)):1;return u.map(m=>m.map(([v,g])=>[l-v*p,o+g*p]).reverse())}function Q7(c,e,t){let n=!1;for(let a=0,r=c.length-1;a<c.length;r=a++){let[s,i]=c[a],[l,o]=c[r];i>t!=o>t&&e<(l-s)*(t-i)/(o-i)+s&&(n=!n)}return n}var s8=new WeakMap,o4=new WeakSet,i8=new Set(["module","function","if","else","for","let","each","use","include","true","false","undef"]),l8={$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"},$scale:{value:"1",doc:"The model's scale: `140cm` is 1400 mm divided by `$scale`"},$nest:{value:"false",doc:"Pack small parts into the holes of bigger ones"},$registration:{value:"false",doc:"Print-and-cut marks in three corners of every sheet"},$label_parts:{value:"false",doc:"Engrave each part's number on its back face, the same number as in the parts list and the steps"},$min_width:{value:"1.5",doc:"Warn where a part's material is narrower than this; `0` turns it off"},$mirrored:{doc:"True inside a mirrored part and on the back face, so `text()` reads right"},$bounds:{doc:"Set by `measure()` for the children after the one it measures"},PI:{value:"3.141592653589793",doc:"\u03C0, half a turn in radians"}},sa=["true","false","undef"],ia="https://kerfscript.mylasertools.com/docs/reference/",la=c=>c.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),w2=(c,e)=>Object.prototype.hasOwnProperty.call(c,e)?c[e]:void 0;function e8(c){let t=c.split(`
2566
+ `}var K7=(n,e)=>{let t=0;for(let c=1;c<n.length;c++)t+=Math.hypot(n[c][0]-n[c-1][0],n[c][1]-n[c-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},T1=n=>Math.round(n*100)/100;function Q7(n,e={}){for(let[x,V]of Object.entries(e.params??{}))try{e5(x,V)}catch(e1){throw new D(e1.message)}let{program:t}=D0(n),c=new Set(t.body.flatMap(x=>x.kind==="assign"?[x.name]:[])),a=Object.keys(e.params??{}).filter(x=>!x.startsWith("$")&&!c.has(x)),r=e.fonts?new N3(e.fonts,e.defaultFont):void 0,s=new $3({overrides:e.params,resolve:e.resolve,fonts:r,maxSteps:e.maxSteps,limits:e.limits}),i=s.limits,l;try{l=s.run(t)}catch(x){let V=x instanceof RangeError?new D(/call stack/i.test(x.message)?"Recursion too deep: the program calls itself without stopping":"A value grew too large. Is a list or string doubling without end?"):x;throw V instanceof D&&(V.echoes=s.echoes,V.warnings=[...s.warnings],r?.missing.size&&(V.missingFonts=[...r.missing])),V}let o=x=>l.globals.get(x).value,h=l.warnings;for(let x of a)h.push(`Setting "${x}" is not a variable of the program, so it is ignored.${a2(x,c)}`);let f=l.layers,u=x=>f.get(x)?.mode??"line",d=[...l.shape.parts];[...l.shape.layers.values()].some(x=>x.regions.length||x.lines.length)&&d.unshift({name:"part",qty:1,layers:l.shape.layers,thickness:V1(o("$thickness"))||3,kerf:V1(o("$kerf"))||0,material:C1(o("$material")??"material")}),d.length||h.push("Nothing to cut: the program made no shapes.");let m=x=>JSON.stringify([x.thickness,x.material,[...x.layers].map(([V,e1])=>[V,e1.regions.map(n1=>n1.map(([u1,v1])=>[Math.round(u1*100),Math.round(v1*100)])),e1.lines.map(n1=>n1.map(([u1,v1])=>[Math.round(u1*100),Math.round(v1*100)]))])]),v=new Map,g=new Set;for(let x of d){let V=m(x),e1=x.mirrored?`${x.name}\0mirrored`:x.name,n1=v.get(e1);n1===void 0?v.set(e1,V):n1!==V&&g.add(x.name)}for(let x of g)h.push(`Two different parts are named "${x}"; slots, glue and on = find parts by name, so give each its own.`);ra(d,h),ea(d,u,h);let b=[],y=e.analysis?{schemaVersion:1,relations:!0,parts:[]}:void 0,w=[],k=new Map,P=[],S=new Set,A=[],E=o("$min_width"),z=E===void 0?1.5:V1(E),I=o("$label_parts")===!0,$=0;I&&!r&&h.push("$label_parts needs a font for the numbers. Pass fonts to render().");let F=f.get("engrave-back");I&&r&&F&&F.side!=="back"&&h.push('$label_parts engraves the numbers on the layer "engrave-back", which this program uses for the front; rename that layer to number the parts.');let _=I&&!!r&&(!F||F.side==="back");if(_){let x=f.get("engrave");f.has("engrave-back")||f.set("engrave-back",{name:"engrave-back",mode:"fill",color:x?.color??"#000000",side:"back"})}let Y=[];for(let x of d){let V=r1([...x.layers].filter(([j])=>u(j)==="cut").flatMap(([,j])=>j.regions)),e1;if(x.bends&&V.length){let j=1/0,t1=-1/0;for(let J of V)for(let[B]of J)j=Math.min(j,B),t1=Math.max(t1,B);for(let J of x.bends)(J.x0<j-.001||J.x1>t1+.001)&&h.push(`Part "${x.name}" bends from x = ${C0(J.x0)} to ${C0(J.x1)}, beyond the part (x = ${C0(j)} to ${C0(t1)}); only the part itself bends.`)}if(_&&V.length){e1=++$;let j=sa(V,String(e1),r,C1(o("$font")??""));if(j.length){let t1=x.layers.get("engrave-back")??{regions:[],lines:[]};x.layers=new Map(x.layers).set("engrave-back",{regions:[...t1.regions,...j],lines:t1.lines})}else h.push(`Part "${x.name}" is too small to take its number ${e1}.`)}if(z>0&&V.length){let j=B1(B1(V,-z/2,"round"),z/2,"round"),t1=T0(Q1(V,j)).filter(J=>J.reduce((B,G)=>B+g1(G),0)>2*z*z);if(t1.length){let J=t1.slice(0,3).map(B=>{let[G,d1,U1,H1]=r0(new Map([["cut",{regions:B,lines:[]}]]));return`[${T1((G+U1)/2)}, ${T1((d1+H1)/2)}]`});h.push(`Part "${x.name}" is narrower than ${z} mm ($min_width) in ${t1.length} place${t1.length>1?"s":""}, at ${J.join(", ")}${t1.length>3?" and more":""} in the part's coordinates.`)}}let n1=new Map;for(let[j,t1]of x.layers){if(u(j)==="guide"&&!e.guides)continue;let J=r1(t1.regions),B=t1.lines.filter(G=>G.length>=2);if((u(j)==="line"||u(j)==="guide")&&(B=[...B,...J.map(G=>[...G,G[0]])],J=[]),V.length&&u(j)!=="guide"){let G=f.get(j)?.bleed??0,d1=G>0?B1(V,G,"round"):V;u(j)!=="cut"&&(J=Y1(J,d1)),B=M0(B,d1,"inside")}(J.length||B.length)&&n1.set(j,{regions:J,lines:B})}if(Y.push(...ca(x.name,n1,f)),V.length){let j=[];for(let[J,B]of n1){let G=f.get(J);if(G?.mode==="cut"&&B.lines.length)for(let d1 of["front","back"])j.push({layer:J,mode:"line",color:"#000000",side:d1,regions:[],lines:B.lines});!G||G.mode!=="fill"&&G.mode!=="line"||j.push({layer:J,mode:G.mode,color:G.color,side:G.side??"front",regions:B.regions,lines:B.lines})}let t1={name:x.name,thickness:x.thickness,material:x.material,outline:V,...j.length&&{marks:j}};if(x.placements){let J=new Set;x.placements.forEach((B,G)=>{let d1={...t1,copy:J7(x,G),matrix:u0(B),placed:!0,...x.bends&&{bends:x.bends},...x.step&&{step:x.step},...x.stack&&{stack:x.stack}};w.push(d1),x.on!==void 0&&k.set(d1,x.on);let U1=d1.matrix.map(H1=>H1.toFixed(6)).join(",");J.has(U1)&&S.add(d1),J.add(U1)}),J.size<x.placements.length&&h.push(`Copies of part "${x.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 J=0;J<x.qty;J++)P.push({...t1,copy:J7(x,J),matrix:u0({at:[0,0,0],rotate:[0,0,0]}),placed:!1,...x.step&&{step:x.step}})}let u1=T0(V),v1=u1.length;if(v1>1){let j=B=>B.reduce((G,d1)=>G+g1(d1),0),J=[...u1].sort((B,G)=>j(G)-j(B)).slice(1,4).map(B=>{let[G,d1,U1,H1]=r0(new Map([["cut",{regions:B,lines:[]}]]));return`[${T1(G)}, ${T1(d1)}] to [${T1(U1)}, ${T1(H1)}]`}).join(", ");h.push(`Part "${x.name}" cuts into ${v1} separate pieces. Join them, or make them separate parts. The smaller ${v1===2?"one is":"ones are"} at ${J}${v1>4?" and more":""}, in the part's coordinates.`)}let P1=0;for(let[j,t1]of n1)if(u(j)==="cut"){for(let J of t1.regions)P1+=K7(J,!0);for(let J of t1.lines)P1+=K7(J,!1)}let x1=r0(n1)??[0,0,0,0],p1=e.kerf??x.kerf;if(!(Number.isFinite(p1)&&p1>=0))throw new D("$kerf must be a number, 0 or more");let j1={name:x.name,qty:x.qty,width:T1(x1[2]-x1[0]),height:T1(x1[3]-x1[1]),pieces:v1,cutLength:Math.round(P1),thickness:x.thickness,kerf:p1,material:x.material,...x.stack&&{stack:x.stack},...x.glue&&{glued:x.glue.host},...x.mirrored&&{mirrored:!0},...e1!==void 0&&{label:e1}};if(y&&y.parts.push({name:x.name,kerf:p1,qty:x.qty,...x.stack&&{stack:x.stack},...x.glue&&{glue:x.glue},...x.on&&{on:x.on},cutRegions:V.map(j=>j.map(([t1,J])=>[t1,J])),cutLines:[...n1].filter(([j])=>u(j)==="cut").flatMap(([,j])=>j.lines.map(t1=>t1.map(([J,B])=>[J,B])))}),p1>0){for(let[j,t1]of n1)if(u(j)==="cut"){let J=t1.regions.filter(d1=>g1(d1)<0);t1.regions=B1(t1.regions,p1/2,"round",Math.min(.01,p1/20));let B=t1.regions.filter(d1=>g1(d1)<0),G=J.length-B.length;if(G>0){let d1=H1=>{let[F0,Y0,M8,x8]=r0(new Map([["cut",{regions:[H1],lines:[]}]]));return[(F0+M8)/2,(Y0+x8)/2]},U1=J.map(d1).filter(([H1,F0])=>!B.some(Y0=>e8(Y0,H1,F0))).slice(0,3).map(([H1,F0])=>`[${T1(H1)}, ${T1(F0)}]`);h.push(`Part "${x.name}": ${G} hole${G===1?" is":"s are"} narrower than the ${p1} mm kerf and will not be cut${U1.length?`, at ${U1.join(", ")}${G>U1.length?" and more":""} in the part's coordinates`:""}.`)}}}b.push(j1),A.push({info:j1,layers:n1})}ta(w,k,h);let N=new Map,i1=w.filter(x=>!S.has(x)).flatMap(x=>{let V=L3(x);for(let e1 of V)N.set(e1,x);return V}),{found:h1,complete:U}=h6(i1,i.maxCollisionPairs),c1=h1.filter(([x,V])=>N.get(x)!==N.get(V)).map(([x,V])=>[N.get(x)??x,N.get(V)??V]).filter(([x,V],e1,n1)=>n1.findIndex(([u1,v1])=>u1===x&&v1===V)===e1);U||h.push(`The assembly has more than ${i.maxCollisionPairs} pairs of touching parts, the limit, so only those were checked for collisions.`);for(let[x,V]of c1.slice(0,5)){let[e1,n1]=N2(x),[u1,v1]=N2(V),P1=[0,1,2].map(x1=>T1((Math.max(e1[x1],u1[x1])+Math.min(n1[x1],v1[x1]))/2));h.push(`Parts "${x.name}"${x.copy>1?` (copy ${x.copy})`:""} and "${V.name}"${V.copy>1?` (copy ${V.copy})`:""} collide in the assembly, around [${P1.join(", ")}]. Check their edges and where they are placed.`)}if(c1.length>5&&h.push(`${c1.length-5} more pairs of parts collide in the assembly.`),aa(Y,h),w.length&&P.length){let x=[...new Set(P.map(V=>`"${V.name}"`))];h.push(`${x.length===1?"Part":"Parts"} ${x.slice(0,5).join(", ")}${x.length>5?` and ${x.length-5} more`:""} ${x.length===1?"has":"have"} no at or rotate, so ${x.length===1?"it lies":"they lie"} flat beside the assembly.`),w.push(...o6(w,P))}let X=0;for(let x of A){let V=0;for(let e1 of x.layers.values()){for(let n1 of e1.regions)V+=n1.length;for(let n1 of e1.lines)V+=n1.length}X+=V*x.info.qty}if(X>i.maxOutputPoints)throw new D(`The files would have ${X} points, more than the limit of ${i.maxOutputPoints}. Use fewer copies or simpler shapes.`);let f1=e.sheet??(l.globals.vars.has("$sheet")?o("$sheet"):e.defaultSheet??o("$sheet"));if(!Array.isArray(f1)||!(Number.isFinite(f1[0])&&f1[0]>0)||!(Number.isFinite(f1[1])&&f1[1]>0))throw new D("$sheet must be [width, height], both more than 0");let I1=e.gap??V1(o("$gap")??3),M1=e.margin??I1;if(!(Number.isFinite(I1)&&I1>=0))throw new D("$gap must be a number, 0 or more");if(!(Number.isFinite(M1)&&M1>=0))throw new D("margin must be a number, 0 or more");let k2=e.nest??o("$nest")===!0,L2=e.layout??(o("$layout")==="none"?"none":"pack"),e3=[...f.keys()].filter(x=>!["engrave","score","cut","guide"].includes(x)),X0=x=>(f.get(x)?.order??0)*2+(u(x)==="fill"?0:1),d4=["engrave",...e3.map((x,V)=>[x,V]).sort((x,V)=>X0(x[0])-X0(V[0])||x[1]-V[1]).map(([x])=>x),"score","cut","guide"].map(x=>f.get(x)).filter(Boolean),O0=d4.filter(x=>x.side!=="back"),S2=[...d4.filter(x=>x.side==="back")],Z3=o("$registration")===!0;Z3&&!f.has("registration")&&f.set("registration",{name:"registration",mode:"fill",color:"#000000"}),Z3&&!O0.some(x=>x.name==="registration")&&O0.push(f.get("registration"));let i0=[],p4=[1,0,0,-1,0,0],Y3=x=>r0(x)??[0,0,0,0],S0=(x,V)=>f2({layers:x,parts:[]},V).layers;if(L2==="none"){let x=[];for(let u1 of A)for(let v1=0;v1<u1.info.qty;v1++)x.push({part:u1.info.name,copy:v1+1,layers:S0(u1.layers,p4),rotated:!1});let V=new Map;for(let u1 of x)for(let[v1,P1]of u1.layers){let x1=V.get(v1)??{regions:[],lines:[]};for(let p1 of P1.regions)x1.regions.push(p1);for(let p1 of P1.lines)x1.lines.push(p1);V.set(v1,x1)}let e1=Y3(V),n1=[1,0,0,1,M1-e1[0],M1-e1[1]];for(let u1 of x)u1.layers=S0(u1.layers,n1),u1.offset=[n1[4],n1[5]];i0.push(m4(x,e1[2]-e1[0]+2*M1,e1[3]-e1[1]+2*M1,A[0]?.info))}else{let x=new Map;for(let V of A){let e1=`${V.info.material}|${V.info.thickness}`;x.set(e1,[...x.get(e1)??[],V])}for(let V of x.values()){let[e1,n1]=f1,u1=[];for(let B of V){let G=S0(B.layers,p4),d1=Y3(G),U1=d1[2]-d1[0],H1=d1[3]-d1[1],F0=!1;(U1>e1-2*M1||H1>n1-2*M1)&&H1<=e1-2*M1&&U1<=n1-2*M1&&(G=S0(G,[0,1,-1,0,0,0]),d1=Y3(G),U1=d1[2]-d1[0],H1=d1[3]-d1[1],F0=!0),(U1>e1-2*M1||H1>n1-2*M1)&&h.push(`Part "${B.info.name}" (${T1(U1)} x ${T1(H1)} mm) is bigger than the ${e1} x ${n1} mm sheet.`),G=S0(G,[1,0,0,1,-d1[0],-d1[1]]);for(let Y0=0;Y0<B.info.qty;Y0++)u1.push({info:B.info,layers:G,w:U1,h:H1,copy:Y0+1,rotated:F0})}u1.sort((B,G)=>G.h-B.h||G.w-B.w);let v1=k2?na(u1,I1,B=>u(B)==="cut"):u1,P1=[],x1=M1,p1=M1,j1=0,j=0,t1=0,J=()=>{if(P1.length&&i0.length>=i.maxSheets)throw new D(`The parts need more than ${i.maxSheets} sheets, the limit. Use fewer copies or a bigger $sheet.`);P1.length&&i0.push(m4(P1,Math.max(j+M1,1),Math.max(t1+M1,1),V[0].info)),P1=[],x1=M1,p1=M1,j1=0,j=0,t1=0};for(let B of v1){x1>M1&&x1+B.w>e1-M1&&(x1=M1,p1+=j1+I1,j1=0),P1.length&&p1+B.h>n1-M1&&J(),P1.push({part:B.info.name,copy:B.copy,layers:S0(B.layers,[1,0,0,1,x1,p1]),rotated:B.rotated});for(let G of B.inner??[])P1.push({part:G.item.info.name,copy:G.item.copy,layers:S0(G.item.layers,[1,0,0,1,x1+G.dx,p1+G.dy]),rotated:G.item.rotated});j=Math.max(j,x1+B.w),t1=Math.max(t1,p1+B.h),x1+=B.w+I1,j1=Math.max(j1,B.h)}J()}}function m4(x,V,e1,n1){let u1=T1(V),v1=T1(e1);if(Z3){let p1=Math.min(5,M1-1);if(!(p1>=2))h.push("Registration marks need $gap of 3 or more round the sheet.");else{let j1=(j,t1)=>[[j,t1],[j+p1,t1],[j+p1,t1+p1],[j,t1+p1]];x=[...x,{part:"registration",copy:1,layers:new Map([["registration",{regions:[j1(.5,.5),j1(u1-.5-p1,.5),j1(.5,v1-.5-p1)],lines:[]}]]),rotated:!1}]}}let P1=x.some(p1=>S2.some(j1=>p1.layers.has(j1.name))),x1=P1?x.map(p1=>({...p1,layers:S0(p1.layers,[-1,0,0,1,u1,0])})):[];return{width:u1,height:v1,material:n1?.material??"material",thickness:n1?.thickness??0,items:x,paths:G3(x,O0),svg:j3(x,u1,v1,O0),dxf:o4(x,u1,v1,O0),...P1&&{back:{paths:G3(x1,S2),svg:j3(x1,u1,v1,S2),dxf:o4(x1,u1,v1,S2)}}}}let Z0=i0.length===1?i0[0]:void 0,v4=Z0?[]:i0.flatMap((x,V)=>{let e1=i0.slice(0,V).reduce((n1,u1)=>n1+u1.height+10,0);return x.items.map(n1=>({...n1,layers:S0(n1.layers,[1,0,0,1,0,e1])}))}),g4=T1(Math.max(1,...i0.map(x=>x.width))),y4=T1(Math.max(1,i0.reduce((x,V)=>x+V.height,0)+10*Math.max(0,i0.length-1))),y8=Z0?Z0.svg:j3(v4,g4,y4,O0),b8=Z0?Z0.paths:G3(v4,O0);return{sheets:i0,width:Z0?.width??g4,height:Z0?.height??y4,paths:b8,svg:y8,parts:b,assembly:w,layers:[...O0,...S2],warnings:h,echoes:l.echoes,...y&&{analysis:y},hardware:l.hardware,steps:l.steps}}function Qc(n){if(!n.includes("*"))return t=>t===n;let e=new RegExp(`^${n.split("*").map(t=>t.replace(/[.+?^${}()|[\]\\]/g,"\\$&")).join(".*")}$`);return t=>e.test(t)}function ea(n,e,t){if(!n.some(o=>o.slots))return;let c=new Map,a=o=>{let h=c.get(o);return h||(h=r1([...o.layers].filter(([f])=>e(f)==="cut").flatMap(([,f])=>f.regions)),c.set(o,h)),h},r=o=>(o.placements??[]).flatMap(h=>L3({name:o.name,copy:0,placed:!0,matrix:u0(h),thickness:o.thickness,outline:a(o),...o.bends&&{bends:o.bends}}).map(f=>({matrix:f.matrix,thickness:f.thickness,outline:f.outline}))),s=new Map,i=new Map;for(let o of n){if(!o.slots)continue;if(!o.placements){t.push(`Part "${o.name}" has slots but no at or rotate, so they can't be found.`);continue}let h=new Set;for(let v of o.slots){let g=v.startsWith("!"),b=Qc(g?v.slice(1):v),y=n.filter(w=>w!==o&&b(w.name));!y.length&&!g&&t.push(`Part "${o.name}": no part "${v}" to cut slots for.`);for(let w of y)g?h.delete(w):h.add(w)}let f=[...h].flatMap(r),u=(o.placements??[]).map(v=>r1(L3({name:o.name,copy:0,placed:!0,matrix:u0(v),thickness:o.thickness,outline:a(o),...o.bends&&{bends:o.bends}}).flatMap(g=>{let b=Y7(g,f,o.clearance??.1);return o.bends?Y1(b,B1(g.outline,1,"miter")):b}))),d=(v,g)=>Z4(v,g).reduce((b,y)=>b+Math.abs(g1(y)),0)>.001,p=o.stack??1;if(p>1){let v=b=>u.filter((y,w)=>w%p===b),g=Array.from({length:p},(b,y)=>r1(v(y).flat()));if(g.slice(1).some(b=>d(g[0],b))){Array.from({length:p},(b,y)=>v(y)).some(b=>b.slice(1).some(y=>d(b[0],y)))&&t.push(`Copies of part "${o.name}" meet the parts in slots in different places; they all get every slot. Make them separate parts to cut each its own.`),i.set(o,g);continue}}u.slice(1).some(v=>d(u[0],v))&&t.push(`Copies of part "${o.name}" meet the parts in slots in different places; they all get every slot. Make them separate parts to cut each its own.`);let m=r1(u.flat());if(!m.length){o.slots.some(v=>v.includes("*"))||t.push(`Part "${o.name}": none of ${o.slots.map(v=>`"${v}"`).join(", ")} pass through it, so it has no slots.`);continue}s.set(o,m)}let l=(o,h)=>{let f=new Map(o);for(let[u,d]of o)f.set(u,{regions:Q1(d.regions,h),lines:M0(d.lines,h,"outside")});return f};for(let[o,h]of s)o.layers=l(o.layers,h);for(let[o,h]of i){let f=h.length,u=h.map((d,p)=>({...o,name:`${o.name}, layer ${p+1}`,qty:o.qty/f,layers:d.length?l(o.layers,d):o.layers,placements:o.placements.filter((m,v)=>v%f===p),stack:void 0}));n.splice(n.indexOf(o),1,...u)}}function ta(n,e,t){let c=new Map;for(let[a,r]of e){let s=n.filter(k=>k.name===r&&k.placed);if(!s.length){c.has(r)||t.push(`Part "${a.name}" is on "${r}", which is not a placed part.`),c.set(r,0);continue}let i=[...e].filter(([k,P])=>k.name===a.name&&P===r).length,l=s.length===i?s[a.copy-1]:s[0];if(!l?.bends?.length)continue;let[o,h,f,u]=[1/0,1/0,-1/0,-1/0];for(let k of a.outline)for(let[P,S]of k)o=Math.min(o,P),h=Math.min(h,S),f=Math.max(f,P),u=Math.max(u,S);let d=a.matrix,[p,m,v]=[(o+f)/2,(h+u)/2,a.thickness/2],g=[d[0]*p+d[1]*m+d[2]*v+d[3],d[4]*p+d[5]*m+d[6]*v+d[7],d[8]*p+d[9]*m+d[10]*v+d[11]],b=k3(l.matrix),y=b[0]*g[0]+b[1]*g[1]+b[2]*g[2]+b[3],w=w5(l.bends,l.thickness)[u6(l.bends,y)];a.matrix=D1(l.matrix,D1(w,D1(b,a.matrix)))}}function na(n,e,t){var o;let c=[],a=h=>{let f=[];for(let[u,d]of h.layers)if(t(u))for(let p of d.regions)g1(p)<0&&f.push([...p].reverse());return f.length?B1(r1(f),-e,"miter"):[]},r=(h,f,u)=>{let d=0;for(let p of h)for(let m=0,v=p.length-1;m<p.length;v=m++){let[g,b]=p[v],[y,w]=p[m];b<=u?w>u&&(y-g)*(u-b)-(f-g)*(w-b)>0&&d++:w<=u&&(y-g)*(u-b)-(f-g)*(w-b)<0&&d--}return d!==0},s=h=>{let f=[];for(let[u,d]of h.layers)if(t(u))for(let p of d.regions)g1(p)>0&&f.push(p);return r1(f)},i=(h,f)=>{let{w:u,h:d}=f,p=s(f),m=[];for(let v of p)for(let g=0;g<v.length;g+=Math.max(1,Math.floor(v.length/12)))m.push(v[g]);for(let v of h){if(g1(v)<=0)continue;let[g,b,y,w]=[1/0,1/0,-1/0,-1/0];for(let[P,S]of v)g=Math.min(g,P),b=Math.min(b,S),y=Math.max(y,P),w=Math.max(w,S);if(y-g<u||w-b<d)continue;let k=Math.max(.5,Math.min(u,d,y-g-u+1,w-b-d+1)/4);for(let P=b;P<=w-d+1e-9;P+=k)for(let S=g;S<=y-u+1e-9;S+=k){if(!m.every(([E,z])=>r(h,E+S,z+P)))continue;let A=p.map(E=>E.map(([z,I])=>[z+S,I+P]));if(Q1(A,h).reduce((E,z)=>E+Math.abs(g1(z)),0)<.01)return[S,P]}}},l=[];for(let h of n){let f=!1;for(let d of c){let p=i(d.region,h);if(!p)continue;let[m,v]=p;((o=d.host).inner??(o.inner=[])).push({item:h,dx:d.ox+m,dy:d.oy+v}),d.region=Q1(d.region,B1(s(h).map(b=>b.map(([y,w])=>[y+m,w+v])),e,"miter"));let g=a(h);g.length&&c.push({host:d.host,ox:d.ox+m,oy:d.oy+v,region:g}),f=!0;break}if(f)continue;l.push(h);let u=a(h);u.length&&c.push({host:h,ox:0,oy:0,region:u})}return l}function J7(n,e){if(!n.copies)return e+1;let t=n.stack??1;return(n.copies[Math.floor(e/t)]-1)*t+e%t+1}function ca(n,e,t){let c=[...t.keys()],a=[...e.keys()].filter(i=>t.get(i)?.mode==="fill"&&e.get(i).regions.length&&!["score","cut","guide"].includes(i)),r=[];if(a.length<2)return r;let s=i=>i==="engrave"?-1/0:(t.get(i)?.order??0)*2+c.indexOf(i)/c.length;a.sort((i,l)=>s(i)-s(l));for(let i=0;i<a.length-1;i++){let l=t.get(a[i]).side??"front",o=a.slice(i+1).filter(f=>(t.get(f).side??"front")===l);if(!o.length)continue;let h;for(let f of T0(e.get(a[i]).regions)){let u=f.reduce((k,P)=>k+g1(P),0);if(!(u>.001)||!B1(f,-.5,"round").length)continue;let d=f;for(let k of o)d.length&&(d=Q1(d,e.get(k).regions));if(d.reduce((k,P)=>k+g1(P),0)>.001*Math.max(1,u))continue;let m=o.filter(k=>Y1(f,e.get(k).regions).length),v=m.length?m:o;if(h){h.count++;for(let k of v)h.under.includes(k)||h.under.push(k);continue}let[g,b,y,w]=r0(new Map([["f",{regions:f,lines:[]}]]));h={part:n,layer:a[i],under:v,count:1,at:[T1((g+y)/2),T1((b+w)/2)]}}h&&r.push(h)}return r}function aa(n,e){for(let t of n.slice(0,5)){let c=t.under.map(r=>`"${r}"`),a=c.length>1?`${c.slice(0,-1).join(", ")} and ${c.at(-1)}`:c[0];e.push(`Part "${t.part}": ${t.count>1?`${t.count} fills`:"a fill"} on layer "${t.layer}" (${t.count>1?"the first ":""}at [${t.at.join(", ")}]) ${t.count>1?"lie":"lies"} wholly under ${a}, stacked above it in the files: printed, ${t.count>1?"they":"it"} won't show, and engraved, ${t.count>1?"they burn":"it burns"} twice. Draw them in one paint(), or give "${t.layer}" a higher order.`)}if(n.length>5){let t=n.slice(5),c=new Set(t.map(r=>r.part)).size,a=[...new Set(t.map(r=>`"${r.layer}"`))];e.push(`Fills are hidden the same way in ${t.length} more place${t.length>1?"s":""}, on ${c} part${c>1?"s":""} (layer${a.length>1?"s":""} ${a.slice(0,5).join(", ")}${a.length>5?" and more":""}).`)}}function ra(n,e){let t=new Set,c=(a,r)=>{if(!a.glue||t.has(a))return;if(r.includes(a)){e.push(`Part "${a.name}" is glued in a loop of parts; it is left where it is.`),t.add(a);return}let s=n.find(h=>h.name===a.glue.host&&h!==a);if(!s?.placements){e.push(`Part "${a.name}" is glued to "${a.glue.host}", which is not a placed part.`),t.add(a);return}c(s,[...r,a]);let i=s.placements.map(u0),l=a.glue.face==="top"?s.thickness:-a.thickness,o=a.placements.length/(a.stack??1);a.placements=a.placements.map((h,f)=>{let u=i.length===o?i[Math.floor(f/(a.stack??1))]:i[0];return{...h,matrix:D1(u,D1(I0(0,0,l),u0(h)))}}),t.add(a)};for(let a of n)c(a,[])}function sa(n,e,t,c){let a=0,r=50;for(let m=0;m<14;m++){let v=(a+r)/2;B1(n,-v,"round").length?a=v:r=v}if(a<1)return[];let s=B1(n,-a*.98,"round"),i=r0(new Map([["cut",{regions:s,lines:[]}]]));if(!i)return[];let[l,o]=[(i[0]+i[2])/2,(i[1]+i[3])/2];((m,v)=>s.reduce((g,b)=>g+(e8(b,m,v)?g1(b)>0?1:-1:0),0)>0)(l,o)||([l,o]=s.reduce((m,v)=>g1(v)>g1(m)?v:m)[0]);let f=Math.min(6,Math.max(2,a*.9)),u=B3(t,e,{size:f,font:c,halign:"center",valign:"center",spacing:1}),d=r0(new Map([["t",{regions:u,lines:[]}]])),p=d?Math.min(1,1.6*a/Math.max(d[2]-d[0],1e-9)):1;return u.map(m=>m.map(([v,g])=>[l-v*p,o+g*p]).reverse())}function e8(n,e,t){let c=!1;for(let a=0,r=n.length-1;a<n.length;r=a++){let[s,i]=n[a],[l,o]=n[r];i>t!=o>t&&e<(l-s)*(t-i)/(o-i)+s&&(c=!c)}return c}var i8=new WeakMap,h4=new WeakSet,l8=new Set(["module","function","if","else","for","let","each","use","include","true","false","undef"]),o8={$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"},$scale:{value:"1",doc:"The model's scale: `140cm` is 1400 mm divided by `$scale`"},$nest:{value:"false",doc:"Pack small parts into the holes of bigger ones"},$registration:{value:"false",doc:"Print-and-cut marks in three corners of every sheet"},$label_parts:{value:"false",doc:"Engrave each part's number on its back face, the same number as in the parts list and the steps"},$min_width:{value:"1.5",doc:"Warn where a part's material is narrower than this; `0` turns it off"},$mirrored:{doc:"True inside a mirrored part and on the back face, so `text()` reads right"},$bounds:{doc:"Set by `measure()` for the children after the one it measures"},$area:{doc:"Set by `measure()`: the area of material the measured child cuts, holes taken out, in square millimetres"},$centroid:{doc:"Set by `measure()`: the measured child's balance point `[x, y]`, the centroid of its material"},PI:{value:"3.141592653589793",doc:"\u03C0, half a turn in radians"}},ia=["true","false","undef"],la="https://kerfscript.mylasertools.com/docs/reference/",oa=n=>n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),w2=(n,e)=>Object.prototype.hasOwnProperty.call(n,e)?n[e]:void 0;function t8(n){let t=n.split(`
2230
2567
  `).slice(0,8).join(`
2231
- `);return t.length>400&&(t=t.slice(0,400)),t.length<c.length?t+" \u2026":t}var j3=class{constructor(e,t,n,a,r){this.src=e;this.tokens=t;this.comments=n;this.file=a;this.load=r;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((s,i)=>this.tokenAt.set(s.pos.offset,i))}run(e){let t=this.scope(void 0,0,this.src.length);this.block(e,t);for(let n of this.pending)this.resolve(n);return t}scope(e,t,n){let a={start:t,end:n,parent:e,vars:new Map,fns:new Map,mods:new Map};return this.scopes.push(a),a}define(e,t,n){let a=e[t].get(n.name);a?a.push(n):e[t].set(n.name,[n]),this.order.set(n,this.seq++),n.file===this.file&&(this.definitions.push(n),s8.set(n,{scope:e,ns:t}))}def(e,t,n,a){return{name:t,kind:e,start:n.offset,end:n.offset+t.length,range:a,...this.file!==void 0&&{file:this.file}}}ref(e,t,n,a,r,s){let i={name:e,start:t.offset,end:t.offset+e.length};return this.references.push(i),this.pending.push({ref:i,scope:n,ns:a,builtin:r,callee:s,seq:this.seq++}),i}find(e,t,n,a){for(let r=e;r;r=r.parent){let s=r[t].get(n);if(!s)continue;if(t!=="vars")return s[s.length-1];let i=s.filter(l=>this.order.get(l)<a);if(i.length)return i[i.length-1]}if(t==="vars")for(let r=e;r;r=r.parent){let s=r.vars.get(n);if(s)return s[s.length-1]}}resolve(e){let{ref:t}=e;if(e.callee){let a=e.callee.def?.params,r=e.callee.builtin,s=a?.find(i=>i.name===t.name);s?t.def=s:r?.params.some(i=>i.name===t.name)&&(t.builtin=r,t.arg=t.name);return}for(let a of e.ns){let r=this.find(e.scope,a,t.name,e.seq);if(r){t.def=r;return}}let n=e.builtin&&s2(t.name);n&&(n.kind===e.builtin||n.kind==="both")&&(t.builtin=n)}docAbove(e){let t=[],n=e-1;for(let a=this.comments.length-1;a>=0;a--){let r=this.comments[a];if(r.line>n)continue;let s=r.line+(this.src.slice(r.start,r.end).match(/\n/g)?.length??0);if(!r.own||s!==n||/^\[[^\]]*\]$/.test(r.text))break;t.unshift(r.block?r.text.replace(/^[ \t]*\* ?/gm,""):r.text),n=r.line-1}return t.length?t.join(`
2232
- `):void 0}valueAfter(e){let t=this.tokenAt.get(e);if(t===void 0||this.tokens[t+1]?.value!=="=")return;let n=0,a=t+2;for(;a<this.tokens.length;a++){let r=this.tokens[a];if(r.type==="eof")break;if(r.type==="punct"){if(r.value==="("||r.value==="["||r.value==="{")n++;else if(r.value===")"||r.value==="]"||r.value==="}"){if(!n)break;n--}else if((r.value===","||r.value===";")&&!n)break}}if(a!==t+2)return e8(this.src.slice(this.tokens[t+2].pos.offset,this.tokens[a-1].end))}end(e){return e.end??e.pos.offset}block(e,t){for(let n of e)if(n.kind==="module"||n.kind==="function"){let a=this.def(n.kind,n.name,n.namePos??n.pos,[n.pos.offset,this.end(n)]),r=this.docAbove(n.pos.line);r&&(a.doc=r),o4.add(a),this.stmtDefs.set(n,a),this.define(t,n.kind==="module"?"mods":"fns",a)}else n.kind==="use"&&!n.include&&this.library(n,t);for(let n of e)this.stmt(n,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 n=this.def("variable",e.name,e.pos,[e.pos.offset,this.end(e)]);n.value=e8(this.src.slice(e.span[0],e.span[1]));let a=this.docAbove(e.pos.line);a&&(n.doc=a),o4.add(n),this.define(t,"vars",n);return}case"module":{let n=this.inner(t,e),a=this.stmtDefs.get(e);a.params=this.params(e.params,n,a),this.block(e.body,n);return}case"function":{let n=this.inner(t,e),a=this.stmtDefs.get(e);a.params=this.params(e.params,n,a),this.expr(e.body,n);return}case"use":e.include&&this.library(e,t);return;case"call":{let n=this.ref(e.name,e.pos,t,["mods"],"module");this.args(e.args,t,n),e.children.length&&this.block(e.children,this.inner(t,e));return}case"for":case"let":{let n=this.inner(t,e);this.assigns(e.assigns,n),this.block(e.body,n);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 n=this.tokenAt.get(e.pos.offset),a=n===void 0?void 0:this.tokens[n+1],r=this.load(e.path);if(a?.type==="str"&&this.libraries.push({path:e.path,include:e.include,start:a.pos.offset,end:a.end,found:!!r}),!!r){for(let s of r.mods)this.define(t,"mods",s);for(let s of r.fns)this.define(t,"fns",s);if(e.include)for(let s of r.vars)this.define(t,"vars",s)}}params(e,t,n){let a=e.map(r=>{let s=r.pos??{line:0,col:0,offset:n?.range[0]??0},i=this.def("parameter",r.name,s,[s.offset,s.offset+r.name.length]);if(r.default&&r.pos){let l=this.valueAfter(r.pos.offset);l!==void 0&&(i.value=l)}return n&&(i.owner=n),this.define(t,"vars",i),i});for(let r of e)r.default&&this.expr(r.default,t);return a}assigns(e,t){for(let n of e){this.expr(n.value,t);let a=this.def("variable",n.name,n.pos,[n.pos.offset,n.pos.offset+n.name.length]),r=this.valueAfter(n.pos.offset);r!==void 0&&(a.value=r),this.define(t,"vars",a)}}args(e,t,n){for(let a of e)a.name&&a.pos&&this.ref(a.name,a.pos,t,[],void 0,n),this.expr(a.value,t)}expr(e,t){switch(e.kind){case"var":this.ref(e.name,e.pos,t,["vars"]);return;case"list":for(let n of e.items)this.item(n,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"record":for(let n of e.fields)this.expr(n.value,t);return;case"call":{let n;e.callee.kind==="var"?n=this.ref(e.callee.name,e.callee.pos,t,["vars","fns"],"function"):this.expr(e.callee,t),this.args(e.args,t,n);return}case"lambda":{let n=this.inner(t,e);this.params(e.params,n),this.expr(e.body,n);return}case"let":{let n=this.inner(t,e);this.assigns(e.assigns,n),this.expr(e.body,n);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 n=e.pos?this.scope(t,e.pos.offset,e.end??e.pos.offset):t;this.assigns(e.assigns,n),this.item(e.body,n);return}}}};function o8(c){let e=c,t=!1;for(let n=0;n<12;n++)try{let{tokens:a,comments:r}=r2(e),{program:s}=D0(e);return{text:e,tokens:a,comments:r,body:s.body,parsed:n===0}}catch(a){if(!(a instanceof D)||a.line===void 0)return;if(a.reason==="Unclosed block comment"){e+="*/";continue}let r=/found end of file$/.test(a.reason);if(t&&(r||a.line>t8(c))){e=e.slice(0,c.length),t=!1;let i=e.trimEnd().split(`
2233
- `).length;e=c8(e,i);continue}if(r){let i=oa(e);if(i){e+=`
2234
- `+i+";",t=!0;continue}}let s=c8(e,Math.min(a.line,t8(e)));if(s===e)return;e=s}}var t8=c=>c.split(`
2235
- `).length;function c8(c,e){let t=0;for(let a=1;a<e;a++)t=c.indexOf(`
2236
- `,t)+1;let n=c.indexOf(`
2237
- `,t);return n<0&&(n=c.length),c.slice(0,t)+c.slice(t,n).replace(/\S/g," ")+c.slice(n)}function oa(c){let e;try{e=r2(c).tokens}catch{return""}let t=[];for(let n of e)n.type==="punct"&&(n.value==="("||n.value==="["||n.value==="{"?t.push(n.value):(n.value===")"||n.value==="]"||n.value==="}")&&t.pop());return t.reverse().map(n=>n==="("?")":n==="["?"]":";}").join("")}var n8=new Map;function h8(c,e){return t=>{let n=r4(e[e.length-1],t),a=n!==void 0&&w2(v0,t)===void 0?c?.(n):void 0,r=typeof a=="string"?n:t;if(e.includes(r))return;let s=w2(v0,r),i=s??(typeof a=="string"?a:c?.(r));if(typeof i!="string")return;let l=s!==void 0?n8.get(r):void 0;if(l)return l;let o=o8(i),h={mods:[],fns:[],vars:[]};if(o){let u=new j3(o.text,o.tokens,o.comments,r,h8(c,[...e,r])).run(o.body),d=p=>[...p.values()].map(m=>m[m.length-1]);h.mods=d(u.mods),h.fns=d(u.fns),h.vars=d(u.vars)}return s!==void 0&&n8.set(r,h),h}}function ha(c,e={}){let t=o8(c),n=[...Object.keys(v0),...e.libraries??[]];if(!t){let s={start:0,end:c.length,vars:new Map,fns:new Map,mods:new Map};return{source:c,parsed:!1,definitions:[],references:[],scopes:[s],libraries:[],available:n,settings:[]}}let a=new j3(t.text,t.tokens,t.comments,void 0,h8(e.resolve,[]));a.run(t.body);let r=[];if(t.parsed)try{r=x4(c).parameters}catch{}return{source:c,parsed:t.parsed,definitions:a.definitions,references:a.references,scopes:a.scopes,libraries:a.libraries,available:n,settings:r}}function h4(c,e){let t=[...c.references,...c.definitions].filter(n=>n.start<=e&&e<=n.end);return t.find(n=>e<n.end)??t[0]}var W3=c=>"kind"in c;function u8(c,e){let t=h4(c,e);if(t)return W3(t)?t:t.def}function f8(c,e,t=!0){let n=u8(c,e);if(!n)return[];let a=s8.get(n),r=new Set(a?a.scope[a.ns].get(n.name):[n]),s=[];if(t)for(let i of r)i.file===void 0&&c.definitions.includes(i)&&s.push({start:i.start,end:i.end,definition:!0});for(let i of c.references)i.def&&r.has(i.def)&&s.push({start:i.start,end:i.end,definition:!1});return s.sort((i,l)=>i.start-l.start)}function d8(c,e){let t=h4(c,e),n=t&&(W3(t)?t:t.def);return!t||!n?t&&!W3(t)&&t.builtin?{error:`${t.name} is built in`}:{error:"There is no name here that the program defines"}:n.file!==void 0?{error:`${n.name} is defined in <${n.file}>`}:{start:t.start,end:t.end,name:t.name}}function ua(c,e,t){let n=d8(c,e);return"error"in n?n:!/^\$?[A-Za-z_][A-Za-z0-9_]*$/.test(t)||i8.has(t)?{error:`"${t}" is not a name`}:t.startsWith("$")!==n.name.startsWith("$")?{error:"Names with $ are special variables, seen by every module called, so $ stays or goes"}:f8(c,e).map(({start:a,end:r})=>({start:a,end:r}))}function u4(c){let e=(c.params??[]).map(t=>t.value?`${t.name} = ${t.value}`:t.name);return`${c.kind} ${c.name}(${e.join(", ")})`}var K2=c=>"```kerfscript\n"+c+"\n```";function fa(c){let e=["Setting"];return c.group&&(e[0]+=` in **${c.group}**`),c.options?e.push(c.options.map(t=>`\`${t.name}\``).join(", ")):c.min!==void 0&&c.max!==void 0&&e.push(`${c.min} to ${c.max}${c.step!==void 0?`, in steps of ${c.step}`:""}`),e.join(": ")}function a8(c,e){let t=[];e.kind==="module"||e.kind==="function"?t.push(K2(u4(e))):t.push(K2(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 n=e.file===void 0&&c.settings.find(a=>a.name===e.name&&a.span[0]>=e.start);return n&&e.kind==="variable"&&t.push(fa(n)),e.file!==void 0&&t.push(`From \`<${e.file}>\``),t.join(`
2238
-
2239
- `)}function da(c,e){let t=`[Reference](${ia}#${la(c.section)})`;if(e){let r=c.params.find(s=>s.name===e);return[K2(r.default!==void 0?`${r.name} = ${r.default}`:r.name),`Parameter of \`${c.name}()\`${r.doc?`: ${r.doc}`:""}`].join(`
2240
-
2241
- `)}let n=[c3(c),...c.forms??[]],a=c.params.filter(r=>r.doc).map(r=>`- \`${r.name}\`: ${r.doc}${r.named?" (by name only)":""}`);return[K2(n.join(`
2242
- `)),c.doc,a.join(`
2568
+ `);return t.length>400&&(t=t.slice(0,400)),t.length<n.length?t+" \u2026":t}var W3=class{constructor(e,t,c,a,r){this.src=e;this.tokens=t;this.comments=c;this.file=a;this.load=r;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((s,i)=>this.tokenAt.set(s.pos.offset,i))}run(e){let t=this.scope(void 0,0,this.src.length);this.block(e,t);for(let c of this.pending)this.resolve(c);return t}scope(e,t,c){let a={start:t,end:c,parent:e,vars:new Map,fns:new Map,mods:new Map};return this.scopes.push(a),a}define(e,t,c){let a=e[t].get(c.name);a?a.push(c):e[t].set(c.name,[c]),this.order.set(c,this.seq++),c.file===this.file&&(this.definitions.push(c),i8.set(c,{scope:e,ns:t}))}def(e,t,c,a){return{name:t,kind:e,start:c.offset,end:c.offset+t.length,range:a,...this.file!==void 0&&{file:this.file}}}ref(e,t,c,a,r,s){let i={name:e,start:t.offset,end:t.offset+e.length};return this.references.push(i),this.pending.push({ref:i,scope:c,ns:a,builtin:r,callee:s,seq:this.seq++}),i}find(e,t,c,a){for(let r=e;r;r=r.parent){let s=r[t].get(c);if(!s)continue;if(t!=="vars")return s[s.length-1];let i=s.filter(l=>this.order.get(l)<a);if(i.length)return i[i.length-1]}if(t==="vars")for(let r=e;r;r=r.parent){let s=r.vars.get(c);if(s)return s[s.length-1]}}resolve(e){let{ref:t}=e;if(e.callee){let a=e.callee.def?.params,r=e.callee.builtin,s=a?.find(i=>i.name===t.name);s?t.def=s:r?.params.some(i=>i.name===t.name)&&(t.builtin=r,t.arg=t.name);return}for(let a of e.ns){let r=this.find(e.scope,a,t.name,e.seq);if(r){t.def=r;return}}let c=e.builtin&&s2(t.name);c&&(c.kind===e.builtin||c.kind==="both")&&(t.builtin=c)}docAbove(e){let t=[],c=e-1;for(let a=this.comments.length-1;a>=0;a--){let r=this.comments[a];if(r.line>c)continue;let s=r.line+(this.src.slice(r.start,r.end).match(/\n/g)?.length??0);if(!r.own||s!==c||/^\[[^\]]*\]$/.test(r.text))break;t.unshift(r.block?r.text.replace(/^[ \t]*\* ?/gm,""):r.text),c=r.line-1}return t.length?t.join(`
2569
+ `):void 0}valueAfter(e){let t=this.tokenAt.get(e);if(t===void 0||this.tokens[t+1]?.value!=="=")return;let c=0,a=t+2;for(;a<this.tokens.length;a++){let r=this.tokens[a];if(r.type==="eof")break;if(r.type==="punct"){if(r.value==="("||r.value==="["||r.value==="{")c++;else if(r.value===")"||r.value==="]"||r.value==="}"){if(!c)break;c--}else if((r.value===","||r.value===";")&&!c)break}}if(a!==t+2)return t8(this.src.slice(this.tokens[t+2].pos.offset,this.tokens[a-1].end))}end(e){return e.end??e.pos.offset}block(e,t){for(let c of e)if(c.kind==="module"||c.kind==="function"){let a=this.def(c.kind,c.name,c.namePos??c.pos,[c.pos.offset,this.end(c)]),r=this.docAbove(c.pos.line);r&&(a.doc=r),h4.add(a),this.stmtDefs.set(c,a),this.define(t,c.kind==="module"?"mods":"fns",a)}else c.kind==="use"&&!c.include&&this.library(c,t);for(let c of e)this.stmt(c,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 c=this.def("variable",e.name,e.pos,[e.pos.offset,this.end(e)]);c.value=t8(this.src.slice(e.span[0],e.span[1]));let a=this.docAbove(e.pos.line);a&&(c.doc=a),h4.add(c),this.define(t,"vars",c);return}case"module":{let c=this.inner(t,e),a=this.stmtDefs.get(e);a.params=this.params(e.params,c,a),this.block(e.body,c);return}case"function":{let c=this.inner(t,e),a=this.stmtDefs.get(e);a.params=this.params(e.params,c,a),this.expr(e.body,c);return}case"use":e.include&&this.library(e,t);return;case"call":{let c=this.ref(e.name,e.pos,t,["mods"],"module");this.args(e.args,t,c),e.children.length&&this.block(e.children,this.inner(t,e));return}case"for":case"let":{let c=this.inner(t,e);this.assigns(e.assigns,c),this.block(e.body,c);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 c=this.tokenAt.get(e.pos.offset),a=c===void 0?void 0:this.tokens[c+1],r=this.load(e.path);if(a?.type==="str"&&this.libraries.push({path:e.path,include:e.include,start:a.pos.offset,end:a.end,found:!!r}),!!r){for(let s of r.mods)this.define(t,"mods",s);for(let s of r.fns)this.define(t,"fns",s);if(e.include)for(let s of r.vars)this.define(t,"vars",s)}}params(e,t,c){let a=e.map(r=>{let s=r.pos??{line:0,col:0,offset:c?.range[0]??0},i=this.def("parameter",r.name,s,[s.offset,s.offset+r.name.length]);if(r.default&&r.pos){let l=this.valueAfter(r.pos.offset);l!==void 0&&(i.value=l)}return c&&(i.owner=c),this.define(t,"vars",i),i});for(let r of e)r.default&&this.expr(r.default,t);return a}assigns(e,t){for(let c of e){this.expr(c.value,t);let a=this.def("variable",c.name,c.pos,[c.pos.offset,c.pos.offset+c.name.length]),r=this.valueAfter(c.pos.offset);r!==void 0&&(a.value=r),this.define(t,"vars",a)}}args(e,t,c){for(let a of e)a.name&&a.pos&&this.ref(a.name,a.pos,t,[],void 0,c),this.expr(a.value,t)}expr(e,t){switch(e.kind){case"var":this.ref(e.name,e.pos,t,["vars"]);return;case"list":for(let c of e.items)this.item(c,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"record":for(let c of e.fields)this.expr(c.value,t);return;case"call":{let c;e.callee.kind==="var"?c=this.ref(e.callee.name,e.callee.pos,t,["vars","fns"],"function"):this.expr(e.callee,t),this.args(e.args,t,c);return}case"lambda":{let c=this.inner(t,e);this.params(e.params,c),this.expr(e.body,c);return}case"let":{let c=this.inner(t,e);this.assigns(e.assigns,c),this.expr(e.body,c);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 c=e.pos?this.scope(t,e.pos.offset,e.end??e.pos.offset):t;this.assigns(e.assigns,c),this.item(e.body,c);return}}}};function h8(n){let e=n,t=!1;for(let c=0;c<12;c++)try{let{tokens:a,comments:r}=r2(e),{program:s}=D0(e);return{text:e,tokens:a,comments:r,body:s.body,parsed:c===0}}catch(a){if(!(a instanceof D)||a.line===void 0)return;if(a.reason==="Unclosed block comment"){e+="*/";continue}let r=/found end of file$/.test(a.reason);if(t&&(r||a.line>n8(n))){e=e.slice(0,n.length),t=!1;let i=e.trimEnd().split(`
2570
+ `).length;e=c8(e,i);continue}if(r){let i=ha(e);if(i){e+=`
2571
+ `+i+";",t=!0;continue}}let s=c8(e,Math.min(a.line,n8(e)));if(s===e)return;e=s}}var n8=n=>n.split(`
2572
+ `).length;function c8(n,e){let t=0;for(let a=1;a<e;a++)t=n.indexOf(`
2573
+ `,t)+1;let c=n.indexOf(`
2574
+ `,t);return c<0&&(c=n.length),n.slice(0,t)+n.slice(t,c).replace(/\S/g," ")+n.slice(c)}function ha(n){let e;try{e=r2(n).tokens}catch{return""}let t=[];for(let c of e)c.type==="punct"&&(c.value==="("||c.value==="["||c.value==="{"?t.push(c.value):(c.value===")"||c.value==="]"||c.value==="}")&&t.pop());return t.reverse().map(c=>c==="("?")":c==="["?"]":";}").join("")}var a8=new Map;function u8(n,e){return t=>{let c=s4(e[e.length-1],t),a=c!==void 0&&w2(g0,t)===void 0?n?.(c):void 0,r=typeof a=="string"?c:t;if(e.includes(r))return;let s=w2(g0,r),i=s??(typeof a=="string"?a:n?.(r));if(typeof i!="string")return;let l=s!==void 0?a8.get(r):void 0;if(l)return l;let o=h8(i),h={mods:[],fns:[],vars:[]};if(o){let u=new W3(o.text,o.tokens,o.comments,r,u8(n,[...e,r])).run(o.body),d=p=>[...p.values()].map(m=>m[m.length-1]);h.mods=d(u.mods),h.fns=d(u.fns),h.vars=d(u.vars)}return s!==void 0&&a8.set(r,h),h}}function ua(n,e={}){let t=h8(n),c=[...Object.keys(g0),...e.libraries??[]];if(!t){let s={start:0,end:n.length,vars:new Map,fns:new Map,mods:new Map};return{source:n,parsed:!1,definitions:[],references:[],scopes:[s],libraries:[],available:c,settings:[]}}let a=new W3(t.text,t.tokens,t.comments,void 0,u8(e.resolve,[]));a.run(t.body);let r=[];if(t.parsed)try{r=x4(n).parameters}catch{}return{source:n,parsed:t.parsed,definitions:a.definitions,references:a.references,scopes:a.scopes,libraries:a.libraries,available:c,settings:r}}function u4(n,e){let t=[...n.references,...n.definitions].filter(c=>c.start<=e&&e<=c.end);return t.find(c=>e<c.end)??t[0]}var X3=n=>"kind"in n;function f8(n,e){let t=u4(n,e);if(t)return X3(t)?t:t.def}function d8(n,e,t=!0){let c=f8(n,e);if(!c)return[];let a=i8.get(c),r=new Set(a?a.scope[a.ns].get(c.name):[c]),s=[];if(t)for(let i of r)i.file===void 0&&n.definitions.includes(i)&&s.push({start:i.start,end:i.end,definition:!0});for(let i of n.references)i.def&&r.has(i.def)&&s.push({start:i.start,end:i.end,definition:!1});return s.sort((i,l)=>i.start-l.start)}function p8(n,e){let t=u4(n,e),c=t&&(X3(t)?t:t.def);return!t||!c?t&&!X3(t)&&t.builtin?{error:`${t.name} is built in`}:{error:"There is no name here that the program defines"}:c.file!==void 0?{error:`${c.name} is defined in <${c.file}>`}:{start:t.start,end:t.end,name:t.name}}function fa(n,e,t){let c=p8(n,e);return"error"in c?c:!/^\$?[A-Za-z_][A-Za-z0-9_]*$/.test(t)||l8.has(t)?{error:`"${t}" is not a name`}:t.startsWith("$")!==c.name.startsWith("$")?{error:"Names with $ are special variables, seen by every module called, so $ stays or goes"}:d8(n,e).map(({start:a,end:r})=>({start:a,end:r}))}function f4(n){let e=(n.params??[]).map(t=>t.value?`${t.name} = ${t.value}`:t.name);return`${n.kind} ${n.name}(${e.join(", ")})`}var Q2=n=>"```kerfscript\n"+n+"\n```";function da(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 r8(n,e){let t=[];e.kind==="module"||e.kind==="function"?t.push(Q2(f4(e))):t.push(Q2(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 c=e.file===void 0&&n.settings.find(a=>a.name===e.name&&a.span[0]>=e.start);return c&&e.kind==="variable"&&t.push(da(c)),e.file!==void 0&&t.push(`From \`<${e.file}>\``),t.join(`
2575
+
2576
+ `)}function pa(n,e){let t=`[Reference](${la}#${oa(n.section)})`;if(e){let r=n.params.find(s=>s.name===e);return[Q2(r.default!==void 0?`${r.name} = ${r.default}`:r.name),`Parameter of \`${n.name}()\`${r.doc?`: ${r.doc}`:""}`].join(`
2577
+
2578
+ `)}let c=[a3(n),...n.forms??[]],a=n.params.filter(r=>r.doc).map(r=>`- \`${r.name}\`: ${r.doc}${r.named?" (by name only)":""}`);return[Q2(c.join(`
2579
+ `)),n.doc,a.join(`
2243
2580
  `),t].filter(Boolean).join(`
2244
2581
 
2245
- `)}function p8(c){let e=[];for(let t of c.split(`
2246
- `)){let n=/^\s*\/\/\s?(.*)$/.exec(t);if(!n)break;/copyright|spdx/i.test(n[1])||e.push(n[1])}return e.join(`
2247
- `).trim()}function pa(c,e,t={}){let n=c.libraries.find(i=>i.start<=e&&e<=i.end);if(n){let i=w2(v0,n.path)??t.resolve?.(n.path),l=w2(v0,n.path)?"Standard library":"Library",o=i===void 0?`Library <${n.path}> not found`:p8(i)||l;return{start:n.start,end:n.end,text:o}}let a=h4(c,e);if(!a)return;let r={start:a.start,end:a.end};if(W3(a))return{...r,text:a8(c,a)};if(a.def)return{...r,text:a8(c,a.def)};if(a.builtin)return{...r,text:da(a.builtin,a.arg)};let s=w2(l8,a.name);if(s)return{...r,text:[K2(s.value!==void 0?`${a.name} = ${s.value}`:a.name),s.doc].join(`
2582
+ `)}function m8(n){let e=[];for(let t of n.split(`
2583
+ `)){let c=/^\s*\/\/\s?(.*)$/.exec(t);if(!c)break;/copyright|spdx/i.test(c[1])||e.push(c[1])}return e.join(`
2584
+ `).trim()}function ma(n,e,t={}){let c=n.libraries.find(i=>i.start<=e&&e<=i.end);if(c){let i=w2(g0,c.path)??t.resolve?.(c.path),l=w2(g0,c.path)?"Standard library":"Library",o=i===void 0?`Library <${c.path}> not found`:m8(i)||l;return{start:c.start,end:c.end,text:o}}let a=u4(n,e);if(!a)return;let r={start:a.start,end:a.end};if(X3(a))return{...r,text:r8(n,a)};if(a.def)return{...r,text:r8(n,a.def)};if(a.builtin)return{...r,text:pa(a.builtin,a.arg)};let s=w2(o8,a.name);if(s)return{...r,text:[Q2(s.value!==void 0?`${a.name} = ${s.value}`:a.name),s.doc].join(`
2248
2585
 
2249
- `)}}function m8(c,e){let t=/[A-Za-z0-9_$]*$/.exec(c.slice(0,e))[0],n=e-t.length,a;try{a=r2(c.slice(0,n)).tokens.slice(0,-1)}catch{return}let r=a.length?a[a.length-1].end:0;if(/\/\/[^\n]*$/.test(c.slice(r,n)))return;let s=[],i=0;return a.forEach((l,o)=>{if(l.type!=="punct")return;let h=s[s.length-1];if(l.value==="("||l.value==="["||l.value==="{"){let f={token:l,index:o,commas:[]},u=a[o-1];if(l.value==="("&&u?.type==="id"){let d=a[o-2];u.value==="for"||u.value==="if"||u.value==="let"?f.header=!0:u.value==="function"?f.params=!0:i8.has(u.value)||(f.callee=u,d?.type==="id"&&(d.value==="module"||d.value==="function")&&(f.params=!0))}s.push(f),l.value==="{"&&(i=o+1)}else l.value===")"||l.value==="]"||l.value==="}"?(s.pop(),l.value==="}"&&(i=o+1)):l.value===","&&h?h.commas.push(o):l.value===";"&&(!h||h.token.value==="{")&&(i=o+1)}),{word:t,from:n,tokens:a,stack:s,stmtStart:i,prev:a[a.length-1]}}function v8(c,e){let t=c.references.find(a=>a.start===e.pos.offset);if(t?.def?.params)return{def:t.def};if(t?.builtin)return{sig:t.builtin};let n=s2(e.value);return n?{sig:n}:void 0}function ma(c,e){let t=c.scopes.filter(a=>a.start<=e&&e<=a.end).sort((a,r)=>a.end-a.start-(r.end-r.start))[0],n=[];for(let a=t??c.scopes[0];a;a=a.parent)n.push(a);return n}function va(c,e){let t=c.source,n=t.slice(t.lastIndexOf(`
2250
- `,e-1)+1,e),a=/\b(?:use|include)\s*<([A-Za-z0-9_./-]*)$/.exec(n);if(a){let w=[...new Set(c.available)].map(I=>({label:I,kind:"library",...w2(v0,I)!==void 0&&{detail:"Standard library",doc:p8(v0[I])}}));return{from:e-a[1].length,to:e,items:w}}let r={from:e,to:e,items:[]},s=m8(t,e);if(!s||/^\d/.test(s.word))return r;let{tokens:i,stack:l,stmtStart:o,prev:h,from:f}=s,u=w=>({from:f,to:e,items:w});if(h?.type==="punct"&&h.value===".")return u(["x","y","z"].map(w=>({label:w,kind:"property",detail:`item ${w}`})));if(h?.type==="id"&&(h.value==="module"||h.value==="function"))return r;let d=l[l.length-1],p=d&&h&&(h===d.token||h.type==="punct"&&h.value===",");if(d?.params&&p)return r;let m=[],v=new Set,g=w=>{v.has(w.kind+" "+w.label)||(v.add(w.kind+" "+w.label),m.push(w))};if(d?.callee&&p){let w=v8(c,d.callee);if(w?.def)for(let I of w.def.params)g({label:I.name,kind:"argument",insert:`${I.name} = `,...I.value!==void 0&&{detail:`${I.name} = ${I.value}`},...I.doc&&{doc:I.doc},first:!0});if(w?.sig)for(let I of w.sig.params)g({label:I.name,kind:"argument",insert:`${I.name} = `,...I.default!==void 0&&{detail:`${I.name} = ${I.default}`},...I.doc&&{doc:I.doc},first:!0})}let y=!d||d.token.value==="{",A=i[o]?.type==="id"&&i[o+1]?.value==="="&&i.length>o+1,z=y&&!A&&(!h||h.type==="punct"&&[";","{","}",")","*","#","%","!"].includes(h.value)||h.type==="id"&&h.value==="else"),E=ma(c,f),k=w=>{let I=[],B=new Set;for(let F of E)for(let[G,X]of F[w])B.has(G)||(B.add(G),I.push(X[X.length-1]));return I},C=w=>({label:w.name,kind:w.kind,detail:w.kind==="module"||w.kind==="function"?u4(w):w.value!==void 0?`${w.name} = ${w.value.split(`
2251
- `)[0]}`:w.name,...(w.doc||w.file)&&{doc:[w.doc,w.file!==void 0&&`From \`<${w.file}>\``].filter(Boolean).join(`
2586
+ `)}}function v8(n,e){let t=/[A-Za-z0-9_$]*$/.exec(n.slice(0,e))[0],c=e-t.length,a;try{a=r2(n.slice(0,c)).tokens.slice(0,-1)}catch{return}let r=a.length?a[a.length-1].end:0;if(/\/\/[^\n]*$/.test(n.slice(r,c)))return;let s=[],i=0;return a.forEach((l,o)=>{if(l.type!=="punct")return;let h=s[s.length-1];if(l.value==="("||l.value==="["||l.value==="{"){let f={token:l,index:o,commas:[]},u=a[o-1];if(l.value==="("&&u?.type==="id"){let d=a[o-2];u.value==="for"||u.value==="if"||u.value==="let"?f.header=!0:u.value==="function"?f.params=!0:l8.has(u.value)||(f.callee=u,d?.type==="id"&&(d.value==="module"||d.value==="function")&&(f.params=!0))}s.push(f),l.value==="{"&&(i=o+1)}else l.value===")"||l.value==="]"||l.value==="}"?(s.pop(),l.value==="}"&&(i=o+1)):l.value===","&&h?h.commas.push(o):l.value===";"&&(!h||h.token.value==="{")&&(i=o+1)}),{word:t,from:c,tokens:a,stack:s,stmtStart:i,prev:a[a.length-1]}}function g8(n,e){let t=n.references.find(a=>a.start===e.pos.offset);if(t?.def?.params)return{def:t.def};if(t?.builtin)return{sig:t.builtin};let c=s2(e.value);return c?{sig:c}:void 0}function va(n,e){let t=n.scopes.filter(a=>a.start<=e&&e<=a.end).sort((a,r)=>a.end-a.start-(r.end-r.start))[0],c=[];for(let a=t??n.scopes[0];a;a=a.parent)c.push(a);return c}function ga(n,e){let t=n.source,c=t.slice(t.lastIndexOf(`
2587
+ `,e-1)+1,e),a=/\b(?:use|include)\s*<([A-Za-z0-9_./-]*)$/.exec(c);if(a){let z=[...new Set(n.available)].map(I=>({label:I,kind:"library",...w2(g0,I)!==void 0&&{detail:"Standard library",doc:m8(g0[I])}}));return{from:e-a[1].length,to:e,items:z}}let r={from:e,to:e,items:[]},s=v8(t,e);if(!s||/^\d/.test(s.word))return r;let{tokens:i,stack:l,stmtStart:o,prev:h,from:f}=s,u=z=>({from:f,to:e,items:z});if(h?.type==="punct"&&h.value===".")return u(["x","y","z"].map(z=>({label:z,kind:"property",detail:`item ${z}`})));if(h?.type==="id"&&(h.value==="module"||h.value==="function"))return r;let d=l[l.length-1],p=d&&h&&(h===d.token||h.type==="punct"&&h.value===",");if(d?.params&&p)return r;let m=[],v=new Set,g=z=>{v.has(z.kind+" "+z.label)||(v.add(z.kind+" "+z.label),m.push(z))};if(d?.callee&&p){let z=g8(n,d.callee);if(z?.def)for(let I of z.def.params)g({label:I.name,kind:"argument",insert:`${I.name} = `,...I.value!==void 0&&{detail:`${I.name} = ${I.value}`},...I.doc&&{doc:I.doc},first:!0});if(z?.sig)for(let I of z.sig.params)g({label:I.name,kind:"argument",insert:`${I.name} = `,...I.default!==void 0&&{detail:`${I.name} = ${I.default}`},...I.doc&&{doc:I.doc},first:!0})}let b=!d||d.token.value==="{",w=i[o]?.type==="id"&&i[o+1]?.value==="="&&i.length>o+1,k=b&&!w&&(!h||h.type==="punct"&&[";","{","}",")","*","#","%","!"].includes(h.value)||h.type==="id"&&h.value==="else"),P=va(n,f),S=z=>{let I=[],$=new Set;for(let F of P)for(let[_,Y]of F[z])$.has(_)||($.add(_),I.push(Y[Y.length-1]));return I},A=z=>({label:z.name,kind:z.kind,detail:z.kind==="module"||z.kind==="function"?f4(z):z.value!==void 0?`${z.name} = ${z.value.split(`
2588
+ `)[0]}`:z.name,...(z.doc||z.file)&&{doc:[z.doc,z.file!==void 0&&`From \`<${z.file}>\``].filter(Boolean).join(`
2252
2589
 
2253
- `)}}),P=w=>({label:w.name,kind:z?"module":"function",detail:c3(w),doc:w.doc,builtin:!0});for(let w of k("vars"))(w.name!==s.word||w.start<f)&&g(C(w));for(let[w,I]of Object.entries(l8))g({label:w,kind:w==="PI"?"constant":"variable",detail:I.value!==void 0?`${w} = ${I.value}`:w,doc:I.doc,builtin:!0});if(z){for(let w of k("mods"))g(C(w));for(let w of t3)w.kind!=="function"&&g(P(w));for(let w of["module","function","for","if","let","use","include"])g({label:w,kind:"keyword"});h?.type==="punct"&&h.value==="}"&&g({label:"else",kind:"keyword"})}else{for(let w of k("fns"))g(C(w));for(let w of t3)w.kind!=="module"&&g(P(w));for(let w of sa)g({label:w,kind:"constant",builtin:!0});if(g({label:"let",kind:"keyword"}),g({label:"function",kind:"keyword"}),d?.token.value==="[")for(let w of["for","if","else","each"])g({label:w,kind:"keyword"})}return u(m)}function ga(c,e){let t=m8(c.source,e);if(!t)return;let n;for(let p=t.stack.length-1;p>=0;p--){let m=t.stack[p];if(m.token.value==="{"||m.params)return;if(m.callee){n=m;break}}if(!n)return;let a=v8(c,n.callee);if(!a)return;let r=n.callee.value,s=a.def?a.def.params.map(p=>({text:p.value!==void 0?`${p.name} = ${p.value.split(`
2254
- `)[0]}`:p.name,name:p.name,doc:p.doc})):a.sig.params.map(p=>({text:p.default!==void 0?`${p.name} = ${p.default}`:p.name,name:p.name,doc:p.doc}));a.sig?.rest&&s.push({text:"...",name:"...",doc:"Any number of values"});let i=`${r}(`,l=s.map((p,m)=>{m&&(i+=", ");let v=i.length;return i+=p.text,{start:v,end:i.length,...p.doc&&{doc:p.doc}}});i+=")";let o=n.commas.length,h=o?n.commas[o-1]+1:n.index+1,f=t.tokens.slice(h),u=o;f[0]?.type==="id"&&f[1]?.value==="="?u=s.findIndex(p=>p.name===f[0].value):t.tokens.slice(n.index+1).some((p,m,v)=>p.type==="id"&&v[m+1]?.value==="="&&(m===0||v[m-1].value===","))&&(u=-1),a.sig?.rest&&u>=s.length&&(u=s.length-1),u>=s.length&&(u=-1);let d=a.def?[a.def.doc,a.def.file!==void 0&&`From \`<${a.def.file}>\``].filter(Boolean).join(`
2590
+ `)}}),E=z=>({label:z.name,kind:k?"module":"function",detail:a3(z),doc:z.doc,builtin:!0});for(let z of S("vars"))(z.name!==s.word||z.start<f)&&g(A(z));for(let[z,I]of Object.entries(o8))g({label:z,kind:z==="PI"?"constant":"variable",detail:I.value!==void 0?`${z} = ${I.value}`:z,doc:I.doc,builtin:!0});if(k){for(let z of S("mods"))g(A(z));for(let z of c3)z.kind!=="function"&&g(E(z));for(let z of["module","function","for","if","let","use","include"])g({label:z,kind:"keyword"});h?.type==="punct"&&h.value==="}"&&g({label:"else",kind:"keyword"})}else{for(let z of S("fns"))g(A(z));for(let z of c3)z.kind!=="module"&&g(E(z));for(let z of ia)g({label:z,kind:"constant",builtin:!0});if(g({label:"let",kind:"keyword"}),g({label:"function",kind:"keyword"}),d?.token.value==="[")for(let z of["for","if","else","each"])g({label:z,kind:"keyword"})}return u(m)}function ya(n,e){let t=v8(n.source,e);if(!t)return;let c;for(let p=t.stack.length-1;p>=0;p--){let m=t.stack[p];if(m.token.value==="{"||m.params)return;if(m.callee){c=m;break}}if(!c)return;let a=g8(n,c.callee);if(!a)return;let r=c.callee.value,s=a.def?a.def.params.map(p=>({text:p.value!==void 0?`${p.name} = ${p.value.split(`
2591
+ `)[0]}`:p.name,name:p.name,doc:p.doc})):a.sig.params.map(p=>({text:p.default!==void 0?`${p.name} = ${p.default}`:p.name,name:p.name,doc:p.doc}));a.sig?.rest&&s.push({text:"...",name:"...",doc:"Any number of values"});let i=`${r}(`,l=s.map((p,m)=>{m&&(i+=", ");let v=i.length;return i+=p.text,{start:v,end:i.length,...p.doc&&{doc:p.doc}}});i+=")";let o=c.commas.length,h=o?c.commas[o-1]+1:c.index+1,f=t.tokens.slice(h),u=o;f[0]?.type==="id"&&f[1]?.value==="="?u=s.findIndex(p=>p.name===f[0].value):t.tokens.slice(c.index+1).some((p,m,v)=>p.type==="id"&&v[m+1]?.value==="="&&(m===0||v[m-1].value===","))&&(u=-1),a.sig?.rest&&u>=s.length&&(u=s.length-1),u>=s.length&&(u=-1);let d=a.def?[a.def.doc,a.def.file!==void 0&&`From \`<${a.def.file}>\``].filter(Boolean).join(`
2255
2592
 
2256
- `):a.sig.doc;return{label:i,...d&&{doc:d},params:l,active:u}}function ya(c){let e=c.definitions.filter(a=>o4.has(a)).sort((a,r)=>a.range[0]-r.range[0]),t=[],n=[];for(let a of e){let r={name:a.name,kind:a.kind,...a.kind==="variable"&&a.value!==void 0?{detail:a.value.split(`
2257
- `)[0]}:a.kind!=="variable"&&{detail:u4(a)},range:a.range,start:a.start,end:a.end,children:[]};for(;n.length&&n[n.length-1].range[1]<a.range[0];)n.pop();(n.length?n[n.length-1].children:t).push(r),a.kind!=="variable"&&n.push(r)}return t}var r8=/\s*\(line (\d+)(?:, column (\d+))?(?: in <([^>]+)>)?\)/;function Ma(c,e={}){let t=[0];for(let l=c.indexOf(`
2258
- `);l>=0;l=c.indexOf(`
2259
- `,l+1))t.push(l+1);let n=l=>c.slice(t[l-1],(t[l]??c.length+1)-1).replace(/\r$/,""),a=(l,o)=>{if(l<1||l>t.length)return{start:0,end:0};let h=n(l);if(o===void 0){let u=h.length-h.trimStart().length;return{start:t[l-1]+u,end:t[l-1]+h.trimEnd().length}}let f=t[l-1]+Math.min(o-1,h.length);return{start:f,end:Math.min(f+z4(h,o),t[l-1]+h.length)}},r=l=>{let o=new RegExp(`\\b(?:use|include)\\s*<${l.replace(/[.*+?^${}()|[\]\\/]/g,"\\$&")}>`).exec(c);return o?{start:o.index,end:o.index+o[0].length}:{start:0,end:0}},s=[],i=l=>{if(l.startsWith("Nothing to cut"))return;let o=r8.exec(l);o?o[3]?s.push({severity:"warning",message:l,...r(o[3])}):s.push({severity:"warning",message:l.replace(r8,""),...a(Number(o[1]),o[2]===void 0?void 0:Number(o[2]))}):s.push({severity:"warning",message:l,start:0,end:0})};try{J7(c,e).warnings.forEach(i)}catch(l){if(!(l instanceof D))return s.push({severity:"error",message:l instanceof Error?l.message:String(l),start:0,end:0}),s;l.warnings.forEach(i);let o=l.trace.filter(p=>p.file===void 0),h=l.reason,f={start:0,end:0};if(l.file===void 0&&l.line!==void 0)f=a(l.line,l.col);else if(l.file!==void 0){h+=` (in <${l.file}>${l.line!==void 0?`, line ${l.line}`:""})`;let p=o.shift();f=p?a(p.line,p.col):r(l.file)}let u=l.call?s2(l.call):void 0;u&&(h+=`
2260
- ${c3(u)}: ${u.doc}`);let d=o.map(p=>({message:`in ${p.kind==="module"?"module ":""}${p.name}(), called here${p.count>1?` (${p.count} times)`:""}`,...a(p.line,p.col)}));s.push({severity:"error",message:h,...f,...d.length&&{related:d}})}return s}
2593
+ `):a.sig.doc;return{label:i,...d&&{doc:d},params:l,active:u}}function ba(n){let e=n.definitions.filter(a=>h4.has(a)).sort((a,r)=>a.range[0]-r.range[0]),t=[],c=[];for(let a of e){let r={name:a.name,kind:a.kind,...a.kind==="variable"&&a.value!==void 0?{detail:a.value.split(`
2594
+ `)[0]}:a.kind!=="variable"&&{detail:f4(a)},range:a.range,start:a.start,end:a.end,children:[]};for(;c.length&&c[c.length-1].range[1]<a.range[0];)c.pop();(c.length?c[c.length-1].children:t).push(r),a.kind!=="variable"&&c.push(r)}return t}var s8=/\s*\(line (\d+)(?:, column (\d+))?(?: in <([^>]+)>)?\)/;function Ma(n,e={}){let t=[0];for(let l=n.indexOf(`
2595
+ `);l>=0;l=n.indexOf(`
2596
+ `,l+1))t.push(l+1);let c=l=>n.slice(t[l-1],(t[l]??n.length+1)-1).replace(/\r$/,""),a=(l,o)=>{if(l<1||l>t.length)return{start:0,end:0};let h=c(l);if(o===void 0){let u=h.length-h.trimStart().length;return{start:t[l-1]+u,end:t[l-1]+h.trimEnd().length}}let f=t[l-1]+Math.min(o-1,h.length);return{start:f,end:Math.min(f+w4(h,o),t[l-1]+h.length)}},r=l=>{let o=new RegExp(`\\b(?:use|include)\\s*<${l.replace(/[.*+?^${}()|[\]\\/]/g,"\\$&")}>`).exec(n);return o?{start:o.index,end:o.index+o[0].length}:{start:0,end:0}},s=[],i=l=>{if(l.startsWith("Nothing to cut"))return;let o=s8.exec(l);o?o[3]?s.push({severity:"warning",message:l,...r(o[3])}):s.push({severity:"warning",message:l.replace(s8,""),...a(Number(o[1]),o[2]===void 0?void 0:Number(o[2]))}):s.push({severity:"warning",message:l,start:0,end:0})};try{Q7(n,e).warnings.forEach(i)}catch(l){if(!(l instanceof D))return s.push({severity:"error",message:l instanceof Error?l.message:String(l),start:0,end:0}),s;l.warnings.forEach(i);let o=l.trace.filter(p=>p.file===void 0),h=l.reason,f={start:0,end:0};if(l.file===void 0&&l.line!==void 0)f=a(l.line,l.col);else if(l.file!==void 0){h+=` (in <${l.file}>${l.line!==void 0?`, line ${l.line}`:""})`;let p=o.shift();f=p?a(p.line,p.col):r(l.file)}let u=l.call?s2(l.call):void 0;u&&(h+=`
2597
+ ${a3(u)}: ${u.doc}`);let d=o.map(p=>({message:`in ${p.kind==="module"?"module ":""}${p.name}(), called here${p.count>1?` (${p.count} times)`:""}`,...a(p.line,p.col)}));s.push({severity:"error",message:h,...f,...d.length&&{related:d}})}return s}
2261
2598
  /*! Bundled license information:
2262
2599
 
2263
2600
  opentype.js/dist/opentype.module.js: