@mlightcad/cad-simple-viewer 1.0.15 → 1.0.18

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.
@@ -1,4 +1,4 @@
1
- (function(b,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("@mlightcad/data-model"),require("lodash-es"),require("three"),require("three/examples/jsm/utils/BufferGeometryUtils.js"),require("three/examples/jsm/controls/OrbitControls"),require("three/examples/jsm/libs/stats.module")):typeof define=="function"&&define.amd?define(["exports","@mlightcad/data-model","lodash-es","three","three/examples/jsm/utils/BufferGeometryUtils.js","three/examples/jsm/controls/OrbitControls","three/examples/jsm/libs/stats.module"],S):(b=typeof globalThis<"u"?globalThis:b||self,S(b["cad-simple-viewer"]={},b.dataModel,b.lodashEs,b.h,b.BufferGeometryUtils_js,b.OrbitControls,b.Stats))})(this,function(b,S,gn,ke,eo,to,no){"use strict";function ro(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const g=ro(ke);class xr{constructor(e,t){this._view=e,this._doc=t,t.database.events.entityAppended.addEventListener(r=>{this.view.addEntity(r.entity)}),t.database.events.entityModified.addEventListener(r=>{this.view.updateEntity(r.entity)}),t.database.events.layerModified.addEventListener(r=>{this._view.setLayerVisibility(r.layer.name,!r.layer.isOff)}),t.database.events.headerSysVarChanged.addEventListener(r=>{r.name=="pdmode"&&this._view.rerenderPoints(r.database.pdmode)}),e.selectionSet.events.selectionAdded.addEventListener(r=>{e.highlight(r.ids)}),e.selectionSet.events.selectionRemoved.addEventListener(r=>{e.unhighlight(r.ids)})}get view(){return this._view}get doc(){return this._doc}}class Be{constructor(){this.events={commandWillStart:new S.AcCmEventManager,commandEnded:new S.AcCmEventManager},this._globalName="",this._localName=""}get globalName(){return this._globalName}set globalName(e){this._globalName=e}get localName(){return this._localName}set localName(e){this._localName=e}tirgger(e){this.events.commandWillStart.dispatch({command:this}),this.execute(e),this.events.commandEnded.dispatch({command:this})}execute(e){}}class io{constructor(e){this._index=0,this._commands=[],e.forEach(t=>{const r=t.groupName;t.commandsByGlobalName.forEach(i=>{this._commands.push({command:i,commandGroup:r})})})}[Symbol.iterator](){return this}get command(){return this._index<this._commands.length?this._commands[this._index].command:null}get commandGroup(){return this._index<this._commands.length?this._commands[this._index].commandGroup:null}next(){for(;this._index<this._commands.length;){const e=this._commands[this._index];return this._index+=1,{value:e,done:!1}}return{value:null,done:!0}}}const _e=class _e{constructor(){this._commandsByGroup=[],this._systemCommandGroup={groupName:_e.SYSTEMT_COMMAND_GROUP_NAME,commandsByGlobalName:new Map,commandsByLocalName:new Map},this._defaultCommandGroup={groupName:_e.DEFAUT_COMMAND_GROUP_NAME,commandsByGlobalName:new Map,commandsByLocalName:new Map},this._commandsByGroup.push(this._systemCommandGroup),this._commandsByGroup.push(this._defaultCommandGroup)}static get instance(){return _e._instance||(_e._instance=new _e),_e._instance}addCommand(e,t,r,i){if(!t)throw new Error("[AcEdCommandStack] The global name of the command is required!");r||(r=t);let s=this._defaultCommandGroup;if(e){const o=this._commandsByGroup.find(a=>a.groupName==e);o?s=o:s={groupName:e,commandsByGlobalName:new Map,commandsByLocalName:new Map}}if(s.commandsByGlobalName.has(t))throw new Error(`[AcEdCommandStack] The command with global name '${t}' already exists!`);if(s.commandsByLocalName.has(r))throw new Error(`[AcEdCommandStack] The command with local name '${r}' already exists!`);s.commandsByGlobalName.set(t,i),s.commandsByLocalName.set(r,i),i.globalName=t,i.localName=r}iterator(){return new io(this._commandsByGroup)}lookupGlobalCmd(e){let t;for(const r of this._commandsByGroup)if(t=r.commandsByGlobalName.get(e),t)break;return t}lookupLocalCmd(e){let t;for(const r of this._commandsByGroup)if(t=r.commandsByLocalName.get(e),t)break;return t}removeCmd(e,t){for(const r of this._commandsByGroup)if(r.groupName==e)return r.commandsByGlobalName.delete(t);return!1}removeGroup(e){let t=-1;return this._commandsByGroup.some((r,i)=>(t=i,r.groupName==e)),t>=0?(this._commandsByGroup.splice(t,1),!0):!1}};_e.SYSTEMT_COMMAND_GROUP_NAME="ACAD",_e.DEFAUT_COMMAND_GROUP_NAME="USER";let oe=_e;function so(n){return{all:n=n||new Map,on:function(e,t){var r=n.get(e);r?r.push(t):n.set(e,[t])},off:function(e,t){var r=n.get(e);r&&(t?r.splice(r.indexOf(t)>>>0,1):n.set(e,[]))},emit:function(e,t){var r=n.get(e);r&&r.slice().map(function(i){i(t)}),(r=n.get("*"))&&r.slice().map(function(i){i(e,t)})}}}const Ce=so();function oo(n){Ce.emit("message",{message:n,type:"warning"})}var qe=(n=>(n[n.NoSpecialCursor=-1]="NoSpecialCursor",n[n.Crosshair=0]="Crosshair",n[n.RectCursor=1]="RectCursor",n[n.RubberBand=2]="RubberBand",n[n.NotRotated=3]="NotRotated",n[n.TargetBox=4]="TargetBox",n[n.RotatedCrosshair=5]="RotatedCrosshair",n[n.CrosshairNoRotate=6]="CrosshairNoRotate",n[n.Invisible=7]="Invisible",n[n.EntitySelect=8]="EntitySelect",n[n.Parallelogram=9]="Parallelogram",n[n.EntitySelectNoPersp=10]="EntitySelectNoPersp",n[n.PkfirstOrGrips=11]="PkfirstOrGrips",n[n.CrosshairDashed=12]="CrosshairDashed",n[n.Grab=13]="Grab",n))(qe||{});class Sr{constructor(){this._cursorMap=new Map,this._cursorMap.set(0,this.createRectCrossIcon(10,10))}setCursor(e,t){if(e<=-1)t.style.cursor="default";else if(e==13)t.style.cursor="grab";else{const r=this._cursorMap.get(e);r&&(t.style.cursor=r)}}encodeSvgToCursor(e,t,r){return`url('data:image/svg+xml;base64,${btoa(e)}') ${t} ${r}, auto`}createRectCrossIcon(e,t,r="white"){const i=e/2,s=e+2*t,o=`
1
+ (function(b,x){typeof exports=="object"&&typeof module<"u"?x(exports,require("@mlightcad/data-model"),require("lodash-es"),require("three"),require("three/examples/jsm/utils/BufferGeometryUtils.js"),require("three/examples/jsm/controls/OrbitControls"),require("three/examples/jsm/libs/stats.module")):typeof define=="function"&&define.amd?define(["exports","@mlightcad/data-model","lodash-es","three","three/examples/jsm/utils/BufferGeometryUtils.js","three/examples/jsm/controls/OrbitControls","three/examples/jsm/libs/stats.module"],x):(b=typeof globalThis<"u"?globalThis:b||self,x(b["cad-simple-viewer"]={},b.dataModel,b.lodashEs,b.h,b.BufferGeometryUtils_js,b.OrbitControls,b.Stats))})(this,function(b,x,gn,ke,eo,to,no){"use strict";function ro(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const g=ro(ke);class xr{constructor(e,t){this._view=e,this._doc=t,t.database.events.entityAppended.addEventListener(r=>{this.view.addEntity(r.entity)}),t.database.events.entityModified.addEventListener(r=>{this.view.updateEntity(r.entity)}),t.database.events.layerModified.addEventListener(r=>{this._view.setLayerVisibility(r.layer.name,!r.layer.isOff)}),t.database.events.headerSysVarChanged.addEventListener(r=>{r.name=="pdmode"&&this._view.rerenderPoints(r.database.pdmode)}),t.database.events.dictObjetSet.addEventListener(r=>{r.object instanceof x.AcDbLayout&&this._view.addLayout(r.object)}),e.selectionSet.events.selectionAdded.addEventListener(r=>{e.highlight(r.ids)}),e.selectionSet.events.selectionRemoved.addEventListener(r=>{e.unhighlight(r.ids)})}get view(){return this._view}get doc(){return this._doc}}class Be{constructor(){this.events={commandWillStart:new x.AcCmEventManager,commandEnded:new x.AcCmEventManager},this._globalName="",this._localName=""}get globalName(){return this._globalName}set globalName(e){this._globalName=e}get localName(){return this._localName}set localName(e){this._localName=e}tirgger(e){this.events.commandWillStart.dispatch({command:this}),this.execute(e),this.events.commandEnded.dispatch({command:this})}execute(e){}}class io{constructor(e){this._index=0,this._commands=[],e.forEach(t=>{const r=t.groupName;t.commandsByGlobalName.forEach(i=>{this._commands.push({command:i,commandGroup:r})})})}[Symbol.iterator](){return this}get command(){return this._index<this._commands.length?this._commands[this._index].command:null}get commandGroup(){return this._index<this._commands.length?this._commands[this._index].commandGroup:null}next(){for(;this._index<this._commands.length;){const e=this._commands[this._index];return this._index+=1,{value:e,done:!1}}return{value:null,done:!0}}}const _e=class _e{constructor(){this._commandsByGroup=[],this._systemCommandGroup={groupName:_e.SYSTEMT_COMMAND_GROUP_NAME,commandsByGlobalName:new Map,commandsByLocalName:new Map},this._defaultCommandGroup={groupName:_e.DEFAUT_COMMAND_GROUP_NAME,commandsByGlobalName:new Map,commandsByLocalName:new Map},this._commandsByGroup.push(this._systemCommandGroup),this._commandsByGroup.push(this._defaultCommandGroup)}static get instance(){return _e._instance||(_e._instance=new _e),_e._instance}addCommand(e,t,r,i){if(!t)throw new Error("[AcEdCommandStack] The global name of the command is required!");r||(r=t);let s=this._defaultCommandGroup;if(e){const o=this._commandsByGroup.find(a=>a.groupName==e);o?s=o:s={groupName:e,commandsByGlobalName:new Map,commandsByLocalName:new Map}}if(s.commandsByGlobalName.has(t))throw new Error(`[AcEdCommandStack] The command with global name '${t}' already exists!`);if(s.commandsByLocalName.has(r))throw new Error(`[AcEdCommandStack] The command with local name '${r}' already exists!`);s.commandsByGlobalName.set(t,i),s.commandsByLocalName.set(r,i),i.globalName=t,i.localName=r}iterator(){return new io(this._commandsByGroup)}lookupGlobalCmd(e){let t;for(const r of this._commandsByGroup)if(t=r.commandsByGlobalName.get(e),t)break;return t}lookupLocalCmd(e){let t;for(const r of this._commandsByGroup)if(t=r.commandsByLocalName.get(e),t)break;return t}removeCmd(e,t){for(const r of this._commandsByGroup)if(r.groupName==e)return r.commandsByGlobalName.delete(t);return!1}removeGroup(e){let t=-1;return this._commandsByGroup.some((r,i)=>(t=i,r.groupName==e)),t>=0?(this._commandsByGroup.splice(t,1),!0):!1}};_e.SYSTEMT_COMMAND_GROUP_NAME="ACAD",_e.DEFAUT_COMMAND_GROUP_NAME="USER";let oe=_e;function so(n){return{all:n=n||new Map,on:function(e,t){var r=n.get(e);r?r.push(t):n.set(e,[t])},off:function(e,t){var r=n.get(e);r&&(t?r.splice(r.indexOf(t)>>>0,1):n.set(e,[]))},emit:function(e,t){var r=n.get(e);r&&r.slice().map(function(i){i(t)}),(r=n.get("*"))&&r.slice().map(function(i){i(e,t)})}}}const Ce=so();function oo(n){Ce.emit("message",{message:n,type:"warning"})}var qe=(n=>(n[n.NoSpecialCursor=-1]="NoSpecialCursor",n[n.Crosshair=0]="Crosshair",n[n.RectCursor=1]="RectCursor",n[n.RubberBand=2]="RubberBand",n[n.NotRotated=3]="NotRotated",n[n.TargetBox=4]="TargetBox",n[n.RotatedCrosshair=5]="RotatedCrosshair",n[n.CrosshairNoRotate=6]="CrosshairNoRotate",n[n.Invisible=7]="Invisible",n[n.EntitySelect=8]="EntitySelect",n[n.Parallelogram=9]="Parallelogram",n[n.EntitySelectNoPersp=10]="EntitySelectNoPersp",n[n.PkfirstOrGrips=11]="PkfirstOrGrips",n[n.CrosshairDashed=12]="CrosshairDashed",n[n.Grab=13]="Grab",n))(qe||{});class Sr{constructor(){this._cursorMap=new Map,this._cursorMap.set(0,this.createRectCrossIcon(10,10))}setCursor(e,t){if(e<=-1)t.style.cursor="default";else if(e==13)t.style.cursor="grab";else{const r=this._cursorMap.get(e);r&&(t.style.cursor=r)}}encodeSvgToCursor(e,t,r){return`url('data:image/svg+xml;base64,${btoa(e)}') ${t} ${r}, auto`}createRectCrossIcon(e,t,r="white"){const i=e/2,s=e+2*t,o=`
2
2
  <svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${s}" viewBox="0 0 ${s} ${s}">
3
3
  <rect x="${t}" y="${t}" width="${e}" height="${e}" fill="none" stroke="${r}" />
4
4
  <line x1="${i+t}" y1="0" x2="${i+t}" y2="${t}" stroke="${r}" />
@@ -6,11 +6,11 @@
6
6
  <line x1="${i+t}" y1="${e+t}" x2="${i+t}" y2="${e+2*t}" stroke="${r}" />
7
7
  <line x1="0" y1="${i+t}" x2="${t}" y2="${i+t}" stroke="${r}" />
8
8
  </svg>
9
- `;return this.encodeSvgToCursor(o,i+t,i+t)}}class mn{constructor(e){this.active=!1,this.isResolvedOrRejected=!1,this.onKeyDown=t=>{t.code==="Escape"&&this.reject("Canceled by user!")},this.view=e}get isActive(){return this.active}activate(){this.isActive&&console.warn("Something wrong here!"),this.active=!0,this.view.canvas.addEventListener("keydown",this.onKeyDown)}deactivate(){this.active=!1,this.view.canvas.removeEventListener("keydown",this.onKeyDown)}resolve(e){this.deactivate(),this._resolve&&!this.isResolvedOrRejected&&(this._resolve(e),this.isResolvedOrRejected=!0)}reject(e){this.deactivate(),this._reject&&!this.isResolvedOrRejected&&(this._reject(e),this.isResolvedOrRejected=!0)}async start(){return this.isResolvedOrRejected=!1,new Promise((e,t)=>{this._resolve=e,this._reject=t,this.activate()})}}class ao extends mn{constructor(e){super(e),this.events={update:new S.AcCmEventManager},this.onMouseMove=t=>{this.curPos.set(t.clientX,t.clientY),this.events.update.dispatch()},this.curPos=new S.AcGePoint2d}activate(){super.activate(),this.view.canvas.addEventListener("mousemove",this.onMouseMove)}deactivate(){super.deactivate(),this.view.canvas.removeEventListener("mousemove",this.onMouseMove)}}class wr{constructor(e){this.onUpdate=()=>{this.update()},this._view=e,this._jigLoop=new ao(e),this._jigLoop.events.update.addEventListener(this.onUpdate)}get view(){return this._view}resolve(e){this._jigLoop.events.update.removeEventListener(this.onUpdate),this._jigLoop.resolve(e)}reject(e){this._jigLoop.events.update.removeEventListener(this.onUpdate),this._jigLoop.reject(e)}async drag(){const e=this._jigLoop.start(),t=this.sampler();await Promise.allSettled([e,t])}async sampler(){}update(){}}const co=16777215,lo="1px";class ho extends mn{constructor(e){super(e),this.mouseDown=!1,this.mouseMove=!1,this.mouseDownPositionX=-1,this.mouseDownPositionY=-1,this.mousedown=t=>{if(t.button===0){this.mouseDown=!0;const r=new S.AcGePoint2d(t.x,t.y);this.mouseDownPositionX=r.x,this.mouseDownPositionY=r.y}},this.mousemove=t=>{if(!this.mouseDown)return;const r=new S.AcGePoint2d(t.x,t.y);if(this.mouseDownPositionX>=0&&this.mouseDownPositionY>=0&&(Math.abs(r.x-this.mouseDownPositionX)>=5||Math.abs(r.y-this.mouseDownPositionY)>=5)){this.mouseMove=!0;const s=new S.AcGePoint2d(Math.min(this.mouseDownPositionX,r.x),Math.min(this.mouseDownPositionY,r.y)),o=new S.AcGePoint2d(Math.max(this.mouseDownPositionX,r.x),Math.max(this.mouseDownPositionY,r.y));this.drawRect(s,o)}},this.mouseup=t=>{if(this.mouseDown&&this.mouseMove){const r=new S.AcGePoint2d(t.x,t.y),i=new S.AcGePoint2d(Math.min(this.mouseDownPositionX,r.x),Math.min(this.mouseDownPositionY,r.y)),s=new S.AcGePoint2d(Math.max(this.mouseDownPositionX,r.x),Math.max(this.mouseDownPositionY,r.y)),o=new S.AcGeBox2d(i,s);this.resolve(this.toWcs(o))}this.mouseDown=!1,this.mouseMove=!1,this.mouseDownPositionX=-1,this.mouseDownPositionY=-1},this.container=e.canvas,this.color=co}activate(){super.activate(),this.active=!0,this.container.addEventListener("pointerdown",this.mousedown),this.container.addEventListener("pointermove",this.mousemove),this.container.addEventListener("pointerup",this.mouseup)}deactivate(){super.deactivate(),this.container.removeEventListener("pointerdown",this.mousedown),this.container.removeEventListener("pointermove",this.mousemove),this.container.removeEventListener("pointerup",this.mouseup),this.setRectDomVisible(!1)}reject(e){var t;super.reject(e),(t=this.boxDom)==null||t.remove(),this.boxDom=void 0}drawRect(e,t){if(!this.boxDom){const s=new S.AcCmColor;s.color=this.color,this.boxDom=document.createElement("div"),this.boxDom.style.cssText=`position: absolute;border: ${lo} solid ${s.cssColor};`,document.body.appendChild(this.boxDom)}this.setRectDomVisible(!0),e.x<=0&&(e.x=0),e.y<=0&&(e.y=0),t.x>=this.container.clientWidth-2&&(t.x=this.container.clientWidth-2),t.y>=this.container.clientHeight-2&&(t.y=this.container.clientHeight-2),this.boxDom.style.left=`${e.x}px`,this.boxDom.style.top=`${e.y}px`;const r=Math.abs(t.x-e.x),i=Math.abs(t.y-e.y);this.boxDom.style.width=`${r}px`,this.boxDom.style.height=`${i}px`}setRectDomVisible(e){this.boxDom&&(this.boxDom.style.display=e?"inline-block":"none")}toWcs(e){const t=new S.AcGeBox2d,r=new S.AcGePoint2d(e.min.x,e.min.y),i=new S.AcGePoint2d(e.max.x,e.max.y);return t.expandByPoint(this.view.cwcs2Wcs(r)),t.expandByPoint(this.view.cwcs2Wcs(i)),t}}class uo extends mn{constructor(e){super(e),this.onClick=t=>{this.resolve(this.view.cwcs2Wcs({x:t.clientX,y:t.clientY}))}}activate(){super.activate(),this.view.canvas.addEventListener("click",this.onClick)}deactivate(){super.deactivate(),this.view.canvas.removeEventListener("click",this.onClick)}}class _r{constructor(e){this._view=e,this._cursorManager=new Sr}get currentCursor(){return this._currentCursor}restoreCursor(){this._previousCursor!=null&&this.setCursor(this._previousCursor)}setCursor(e){this._cursorManager.setCursor(e,this._view.canvas),this._previousCursor=this._currentCursor,this._currentCursor=e}async getPoint(){return await new uo(this._view).start()}async getSelection(){return await new ho(this._view).start()}}class Tr{constructor(e=[]){this.events={selectionAdded:new S.AcCmEventManager,selectionRemoved:new S.AcCmEventManager},this._ids=new Set(e)}get ids(){return Array.from(this._ids)}get count(){return this._ids.size}add(e){Array.isArray(e)?(e.forEach(t=>this._ids.add(t)),this.events.selectionAdded.dispatch({ids:e})):(this._ids.add(e),this.events.selectionAdded.dispatch({ids:[e]}))}delete(e){Array.isArray(e)?(e.forEach(t=>this._ids.delete(t)),this.events.selectionRemoved.dispatch({ids:e})):(this._ids.delete(e),this.events.selectionRemoved.dispatch({ids:[e]}))}has(e){return this._ids.has(e)}clear(){if(this._ids.size>0){const e=Array.from(this._ids);this._ids.clear(),this.events.selectionRemoved.dispatch({ids:e})}}}var Ie=(n=>(n[n.SELECTION=0]="SELECTION",n[n.PAN=1]="PAN",n))(Ie||{});class Cr{constructor(e){this.events={mouseMove:new S.AcCmEventManager,viewResize:new S.AcCmEventManager,hover:new S.AcCmEventManager,unhover:new S.AcCmEventManager},this._canvas=e;const t=e.getBoundingClientRect();this._bbox=new S.AcGeBox3d,this._width=t.width,this._height=t.height,this._curPos=new S.AcGePoint2d,this._curScreenPos=new S.AcGePoint2d,this._selectionSet=new Tr,this._editor=new _r(this),this._canvas.addEventListener("mousemove",r=>this.onMouseMove(r)),this._canvas.addEventListener("mousedown",r=>{r.button===1&&this._editor.setCursor(qe.Grab)}),this._canvas.addEventListener("mouseup",r=>{r.button===1&&this._editor.restoreCursor()}),window.addEventListener("resize",this.onWindowResize.bind(this)),this._selectionBoxSize=4,this._hoverTimer=null,this._pauseTimer=null,this._hoveredObjectId=null}get editor(){return this._editor}get selectionBoxSize(){return this._selectionBoxSize}set selectionBoxSize(e){this._selectionBoxSize=e}setCursor(e){this._editor.setCursor(e)}setCalculateSizeCallback(e){this._calculateSizeCallback=e}get width(){return this._width}set width(e){this._width=e}get height(){return this._height}set height(e){this._height=e}get bbox(){return this._bbox}get canvas(){return this._canvas}get aspect(){return this._width/this._height}get curPos(){return this._curPos}get curScreenPos(){return this._curScreenPos}get selectionSet(){return this._selectionSet}onWindowResize(){if(this._calculateSizeCallback){const{width:e,height:t}=this._calculateSizeCallback();this._width=e,this._height=t}else this._width=this._canvas.clientWidth,this._height=this._canvas.clientHeight;this.events.viewResize.dispatch({width:this._width,height:this._height})}onMouseMove(e){this._curScreenPos=new S.AcGePoint2d(e.clientX,e.clientY);const t=this.cwcs2Wcs(this._curScreenPos);this._curPos.copy(t),this.events.mouseMove.dispatch({x:t.x,y:t.y}),this.mode==0&&this.startHoverTimer(t.x,t.y)}setHoveredObjectId(e){this._hoveredObjectId&&(this.events.unhover.dispatch({id:this._hoveredObjectId,x:this.curScreenPos.x,y:this.curScreenPos.y}),this.onUnhover(this._hoveredObjectId)),this._hoveredObjectId=e,e&&(this.startPauseTimer(e),this.onHover(e))}hoverAt(e,t){const r=this.pick({x:e,y:t});r.length>0?this.setHoveredObjectId(r[0]):(this.setHoveredObjectId(null),this.clearPauseTimer())}clearHoverTimer(){this._hoverTimer&&clearTimeout(this._hoverTimer)}clearPauseTimer(){this._pauseTimer&&clearTimeout(this._pauseTimer)}startHoverTimer(e,t){this.clearHoverTimer(),this._hoverTimer=setTimeout(()=>{this.hoverAt(e,t)},50)}startPauseTimer(e){this._pauseTimer=setTimeout(()=>{this.events.hover.dispatch({id:e,x:this.curScreenPos.x,y:this.curScreenPos.y})},500)}}class Ir{constructor(){this._fileName="",this._docTitle="",this._isReadOnly=!0,this._database=new S.AcDbDatabase,this.docTitle="Untitled"}async openUri(e,t){this._uri=e,this._isReadOnly=t&&t.readOnly||!1,this._fileName=this.getFileNameFromUri(e);let r=!0;try{await this._database.openUri(e,t),this.docTitle=this._fileName}catch{r=!1,Ce.emit("failed-to-open-file",{fileName:e})}return r}async openDocument(e,t,r){var s;let i=!0;this._fileName=e;try{const o=(s=e.split(".").pop())==null?void 0:s.toLocaleLowerCase();await this._database.read(t,r,o=="dwg"?S.AcDbFileType.DWG:S.AcDbFileType.DXF),this.docTitle=this._fileName}catch(o){i=!1,Ce.emit("failed-to-open-file",{fileName:e}),console.error(o)}return i}get uri(){return this._uri}get database(){return this._database}get docTitle(){return this._docTitle}set docTitle(e){this._docTitle=e,typeof document<"u"&&(document.title=e)}get isReadOnly(){return this._isReadOnly}getFileNameFromUri(e){try{const r=new URL(e).pathname.split("/");return r[r.length-1]||""}catch(t){return console.error("Invalid URI:",t),""}}}class Pt{constructor(){this._objectId="",this._ownerId="",this._layerName="",this._visible=!0,this._userData={},this._box=new S.AcGeBox2d,this._svg=""}get box(){return this._box}set box(e){this._box.copy(e)}get svg(){return this._svg}set svg(e){this._svg=e}get objectId(){return this._objectId}set objectId(e){this._objectId=e}get ownerId(){return this._ownerId}set ownerId(e){this._ownerId=e}get layerName(){return this._layerName}set layerName(e){this._layerName=e}get visible(){return this._visible}set visible(e){this._visible=e}get userData(){return this._userData}set userData(e){this._userData=e}applyMatrix(e){}recomputeBoundingBox(){}highlight(){}unhighlight(){}fastDeepClone(){return this}}class po extends Pt{constructor(e){if(super(),e.closed)this.svg=`
9
+ `;return this.encodeSvgToCursor(o,i+t,i+t)}}class mn{constructor(e){this.active=!1,this.isResolvedOrRejected=!1,this.onKeyDown=t=>{t.code==="Escape"&&this.reject("Canceled by user!")},this.view=e}get isActive(){return this.active}activate(){this.isActive&&console.warn("Something wrong here!"),this.active=!0,this.view.canvas.addEventListener("keydown",this.onKeyDown)}deactivate(){this.active=!1,this.view.canvas.removeEventListener("keydown",this.onKeyDown)}resolve(e){this.deactivate(),this._resolve&&!this.isResolvedOrRejected&&(this._resolve(e),this.isResolvedOrRejected=!0)}reject(e){this.deactivate(),this._reject&&!this.isResolvedOrRejected&&(this._reject(e),this.isResolvedOrRejected=!0)}async start(){return this.isResolvedOrRejected=!1,new Promise((e,t)=>{this._resolve=e,this._reject=t,this.activate()})}}class ao extends mn{constructor(e){super(e),this.events={update:new x.AcCmEventManager},this.onMouseMove=t=>{this.curPos.set(t.clientX,t.clientY),this.events.update.dispatch()},this.curPos=new x.AcGePoint2d}activate(){super.activate(),this.view.canvas.addEventListener("mousemove",this.onMouseMove)}deactivate(){super.deactivate(),this.view.canvas.removeEventListener("mousemove",this.onMouseMove)}}class wr{constructor(e){this.onUpdate=()=>{this.update()},this._view=e,this._jigLoop=new ao(e),this._jigLoop.events.update.addEventListener(this.onUpdate)}get view(){return this._view}resolve(e){this._jigLoop.events.update.removeEventListener(this.onUpdate),this._jigLoop.resolve(e)}reject(e){this._jigLoop.events.update.removeEventListener(this.onUpdate),this._jigLoop.reject(e)}async drag(){const e=this._jigLoop.start(),t=this.sampler();await Promise.allSettled([e,t])}async sampler(){}update(){}}const co=16777215,lo="1px";class ho extends mn{constructor(e){super(e),this.mouseDown=!1,this.mouseMove=!1,this.mouseDownPositionX=-1,this.mouseDownPositionY=-1,this.mousedown=t=>{if(t.button===0){this.mouseDown=!0;const r=new x.AcGePoint2d(t.x,t.y);this.mouseDownPositionX=r.x,this.mouseDownPositionY=r.y}},this.mousemove=t=>{if(!this.mouseDown)return;const r=new x.AcGePoint2d(t.x,t.y);if(this.mouseDownPositionX>=0&&this.mouseDownPositionY>=0&&(Math.abs(r.x-this.mouseDownPositionX)>=5||Math.abs(r.y-this.mouseDownPositionY)>=5)){this.mouseMove=!0;const s=new x.AcGePoint2d(Math.min(this.mouseDownPositionX,r.x),Math.min(this.mouseDownPositionY,r.y)),o=new x.AcGePoint2d(Math.max(this.mouseDownPositionX,r.x),Math.max(this.mouseDownPositionY,r.y));this.drawRect(s,o)}},this.mouseup=t=>{if(this.mouseDown&&this.mouseMove){const r=new x.AcGePoint2d(t.x,t.y),i=new x.AcGePoint2d(Math.min(this.mouseDownPositionX,r.x),Math.min(this.mouseDownPositionY,r.y)),s=new x.AcGePoint2d(Math.max(this.mouseDownPositionX,r.x),Math.max(this.mouseDownPositionY,r.y)),o=new x.AcGeBox2d(i,s);this.resolve(this.toWcs(o))}this.mouseDown=!1,this.mouseMove=!1,this.mouseDownPositionX=-1,this.mouseDownPositionY=-1},this.container=e.canvas,this.color=co}activate(){super.activate(),this.active=!0,this.container.addEventListener("pointerdown",this.mousedown),this.container.addEventListener("pointermove",this.mousemove),this.container.addEventListener("pointerup",this.mouseup)}deactivate(){super.deactivate(),this.container.removeEventListener("pointerdown",this.mousedown),this.container.removeEventListener("pointermove",this.mousemove),this.container.removeEventListener("pointerup",this.mouseup),this.setRectDomVisible(!1)}reject(e){var t;super.reject(e),(t=this.boxDom)==null||t.remove(),this.boxDom=void 0}drawRect(e,t){if(!this.boxDom){const s=new x.AcCmColor;s.color=this.color,this.boxDom=document.createElement("div"),this.boxDom.style.cssText=`position: absolute;border: ${lo} solid ${s.cssColor};`,document.body.appendChild(this.boxDom)}this.setRectDomVisible(!0),e.x<=0&&(e.x=0),e.y<=0&&(e.y=0),t.x>=this.container.clientWidth-2&&(t.x=this.container.clientWidth-2),t.y>=this.container.clientHeight-2&&(t.y=this.container.clientHeight-2),this.boxDom.style.left=`${e.x}px`,this.boxDom.style.top=`${e.y}px`;const r=Math.abs(t.x-e.x),i=Math.abs(t.y-e.y);this.boxDom.style.width=`${r}px`,this.boxDom.style.height=`${i}px`}setRectDomVisible(e){this.boxDom&&(this.boxDom.style.display=e?"inline-block":"none")}toWcs(e){const t=new x.AcGeBox2d,r=new x.AcGePoint2d(e.min.x,e.min.y),i=new x.AcGePoint2d(e.max.x,e.max.y);return t.expandByPoint(this.view.cwcs2Wcs(r)),t.expandByPoint(this.view.cwcs2Wcs(i)),t}}class uo extends mn{constructor(e){super(e),this.onClick=t=>{this.resolve(this.view.cwcs2Wcs({x:t.clientX,y:t.clientY}))}}activate(){super.activate(),this.view.canvas.addEventListener("click",this.onClick)}deactivate(){super.deactivate(),this.view.canvas.removeEventListener("click",this.onClick)}}class _r{constructor(e){this._view=e,this._cursorManager=new Sr}get currentCursor(){return this._currentCursor}restoreCursor(){this._previousCursor!=null&&this.setCursor(this._previousCursor)}setCursor(e){this._cursorManager.setCursor(e,this._view.canvas),this._previousCursor=this._currentCursor,this._currentCursor=e}async getPoint(){return await new uo(this._view).start()}async getSelection(){return await new ho(this._view).start()}}class Tr{constructor(e=[]){this.events={selectionAdded:new x.AcCmEventManager,selectionRemoved:new x.AcCmEventManager},this._ids=new Set(e)}get ids(){return Array.from(this._ids)}get count(){return this._ids.size}add(e){Array.isArray(e)?(e.forEach(t=>this._ids.add(t)),this.events.selectionAdded.dispatch({ids:e})):(this._ids.add(e),this.events.selectionAdded.dispatch({ids:[e]}))}delete(e){Array.isArray(e)?(e.forEach(t=>this._ids.delete(t)),this.events.selectionRemoved.dispatch({ids:e})):(this._ids.delete(e),this.events.selectionRemoved.dispatch({ids:[e]}))}has(e){return this._ids.has(e)}clear(){if(this._ids.size>0){const e=Array.from(this._ids);this._ids.clear(),this.events.selectionRemoved.dispatch({ids:e})}}}var Ie=(n=>(n[n.SELECTION=0]="SELECTION",n[n.PAN=1]="PAN",n))(Ie||{});class Cr{constructor(e){this.events={mouseMove:new x.AcCmEventManager,viewResize:new x.AcCmEventManager,hover:new x.AcCmEventManager,unhover:new x.AcCmEventManager},this._canvas=e;const t=e.getBoundingClientRect();this._bbox=new x.AcGeBox3d,this._width=t.width,this._height=t.height,this._curPos=new x.AcGePoint2d,this._curScreenPos=new x.AcGePoint2d,this._selectionSet=new Tr,this._editor=new _r(this),this._canvas.addEventListener("mousemove",r=>this.onMouseMove(r)),this._canvas.addEventListener("mousedown",r=>{r.button===1&&this._editor.setCursor(qe.Grab)}),this._canvas.addEventListener("mouseup",r=>{r.button===1&&this._editor.restoreCursor()}),window.addEventListener("resize",this.onWindowResize.bind(this)),this._selectionBoxSize=4,this._hoverTimer=null,this._pauseTimer=null,this._hoveredObjectId=null}get editor(){return this._editor}get selectionBoxSize(){return this._selectionBoxSize}set selectionBoxSize(e){this._selectionBoxSize=e}setCursor(e){this._editor.setCursor(e)}setCalculateSizeCallback(e){this._calculateSizeCallback=e}get width(){return this._width}set width(e){this._width=e}get height(){return this._height}set height(e){this._height=e}get bbox(){return this._bbox}get canvas(){return this._canvas}get aspect(){return this._width/this._height}get curPos(){return this._curPos}get curScreenPos(){return this._curScreenPos}get selectionSet(){return this._selectionSet}onWindowResize(){if(this._calculateSizeCallback){const{width:e,height:t}=this._calculateSizeCallback();this._width=e,this._height=t}else this._width=this._canvas.clientWidth,this._height=this._canvas.clientHeight;this.events.viewResize.dispatch({width:this._width,height:this._height})}onMouseMove(e){this._curScreenPos=new x.AcGePoint2d(e.clientX,e.clientY);const t=this.cwcs2Wcs(this._curScreenPos);this._curPos.copy(t),this.events.mouseMove.dispatch({x:t.x,y:t.y}),this.mode==0&&this.startHoverTimer(t.x,t.y)}setHoveredObjectId(e){this._hoveredObjectId&&(this.events.unhover.dispatch({id:this._hoveredObjectId,x:this.curScreenPos.x,y:this.curScreenPos.y}),this.onUnhover(this._hoveredObjectId)),this._hoveredObjectId=e,e&&(this.startPauseTimer(e),this.onHover(e))}hoverAt(e,t){const r=this.pick({x:e,y:t});r.length>0?this.setHoveredObjectId(r[0]):(this.setHoveredObjectId(null),this.clearPauseTimer())}clearHoverTimer(){this._hoverTimer&&clearTimeout(this._hoverTimer)}clearPauseTimer(){this._pauseTimer&&clearTimeout(this._pauseTimer)}startHoverTimer(e,t){this.clearHoverTimer(),this._hoverTimer=setTimeout(()=>{this.hoverAt(e,t)},50)}startPauseTimer(e){this._pauseTimer=setTimeout(()=>{this.events.hover.dispatch({id:e,x:this.curScreenPos.x,y:this.curScreenPos.y})},500)}}class Ir{constructor(){this._fileName="",this._docTitle="",this._isReadOnly=!0,this._database=new x.AcDbDatabase,this.docTitle="Untitled"}async openUri(e,t){this._uri=e,this._isReadOnly=t&&t.readOnly||!1,this._fileName=this.getFileNameFromUri(e);let r=!0;try{await this._database.openUri(e,t),this.docTitle=this._fileName}catch{r=!1,Ce.emit("failed-to-open-file",{fileName:e})}return r}async openDocument(e,t,r){var s;let i=!0;this._fileName=e;try{const o=(s=e.split(".").pop())==null?void 0:s.toLocaleLowerCase();await this._database.read(t,r,o=="dwg"?x.AcDbFileType.DWG:x.AcDbFileType.DXF),this.docTitle=this._fileName}catch(o){i=!1,Ce.emit("failed-to-open-file",{fileName:e}),console.error(o)}return i}get uri(){return this._uri}get database(){return this._database}get docTitle(){return this._docTitle}set docTitle(e){this._docTitle=e,typeof document<"u"&&(document.title=e)}get isReadOnly(){return this._isReadOnly}getFileNameFromUri(e){try{const r=new URL(e).pathname.split("/");return r[r.length-1]||""}catch(t){return console.error("Invalid URI:",t),""}}}class Pt{constructor(){this._objectId="",this._ownerId="",this._layerName="",this._visible=!0,this._userData={},this._box=new x.AcGeBox2d,this._svg=""}get box(){return this._box}set box(e){this._box.copy(e)}get svg(){return this._svg}set svg(e){this._svg=e}get objectId(){return this._objectId}set objectId(e){this._objectId=e}get ownerId(){return this._ownerId}set ownerId(e){this._ownerId=e}get layerName(){return this._layerName}set layerName(e){this._layerName=e}get visible(){return this._visible}set visible(e){this._visible=e}get userData(){return this._userData}set userData(e){this._userData=e}applyMatrix(e){}recomputeBoundingBox(){}highlight(){}unhighlight(){}fastDeepClone(){return this}}class po extends Pt{constructor(e){if(super(),e.closed)this.svg=`
10
10
  <circle cx="${e.center.x}" cy="${e.center.y}" r="${e.radius}"/>`;else{const r=e.startPoint,i=e.endPoint,s=e.clockwise?0:1;this.svg=`
11
11
  <path d="M${r.x},${r.y} A${e.radius},${e.radius} 0 ${e.isLargeArc},${s} ${i.x},${i.y}"/>`}const t=e.box;this._box.min.copy(t.min),this._box.max.copy(t.max)}}class fo extends Pt{constructor(e){if(super(),e.closed)this.svg=`
12
- <epllise cx="${e.center.x}" cy="${e.center.y}" rx="${e.majorAxisRadius}" ry="${e.minorAxisRadius}"/>`;else{const r=e.startPoint,i=e.endPoint,s=S.AcGeMathUtil.radToDeg(e.majorAxis.angleTo(S.AcGeVector3d.X_AXIS)),o=e.clockwise?0:1;this.svg=`
13
- <path d="M${r.x},${r.y} A${e.majorAxisRadius},${e.minorAxisRadius} ${s} ${e.isLargeArc},${o} ${i.x},${i.y}"/>`}const t=e.box;this._box.min.copy(t.min),this._box.max.copy(t.max)}}let go=class extends Pt{constructor(e){super();const t=e.reduce((r,i,s)=>(r+=s===0?"M":"L",r+=i.x+","+i.y,this.box.expandByPoint(i),r),"");t&&(this.svg=`<path d="${t}" />`)}};class mo{constructor(){this._container=new Array,this._bbox=new S.AcGeBox2d}setFontMapping(e){}group(e){return Ye}point(e){return Ye}circularArc(e){const t=new po(e);return this._container.push(t.svg),this._bbox.union(t.box),t}ellipticalArc(e){const t=new fo(e);return this._container.push(t.svg),this._bbox.union(t.box),t}lines(e,t){const r=new go(e);return this._container.push(r.svg),this._bbox.union(r.box),r}lineSegments(e,t,r,i){return Ye}area(e){return Ye}mtext(e,t){return Ye}image(e,t){return Ye}export(){const e=this._container.join(`
12
+ <epllise cx="${e.center.x}" cy="${e.center.y}" rx="${e.majorAxisRadius}" ry="${e.minorAxisRadius}"/>`;else{const r=e.startPoint,i=e.endPoint,s=x.AcGeMathUtil.radToDeg(e.majorAxis.angleTo(x.AcGeVector3d.X_AXIS)),o=e.clockwise?0:1;this.svg=`
13
+ <path d="M${r.x},${r.y} A${e.majorAxisRadius},${e.minorAxisRadius} ${s} ${e.isLargeArc},${o} ${i.x},${i.y}"/>`}const t=e.box;this._box.min.copy(t.min),this._box.max.copy(t.max)}}let go=class extends Pt{constructor(e){super();const t=e.reduce((r,i,s)=>(r+=s===0?"M":"L",r+=i.x+","+i.y,this.box.expandByPoint(i),r),"");t&&(this.svg=`<path d="${t}" />`)}};class mo{constructor(){this._container=new Array,this._bbox=new x.AcGeBox2d}setFontMapping(e){}group(e){return Ye}point(e){return Ye}circularArc(e){const t=new po(e);return this._container.push(t.svg),this._bbox.union(t.box),t}ellipticalArc(e){const t=new fo(e);return this._container.push(t.svg),this._bbox.union(t.box),t}lines(e,t){const r=new go(e);return this._container.push(r.svg),this._bbox.union(r.box),r}lineSegments(e,t,r,i){return Ye}area(e){return Ye}mtext(e,t){return Ye}image(e,t){return Ye}export(){const e=this._container.join(`
14
14
  `),t=this._bbox.isEmpty()?{x:0,y:0,width:0,height:0}:{x:this._bbox.min.x,y:-this._bbox.max.y,width:this._bbox.max.x-this._bbox.min.x,height:this._bbox.max.y-this._bbox.min.y};return`<?xml version="1.0"?>
15
15
  <svg
16
16
  xmlns="http://www.w3.org/2000/svg"
@@ -22,10 +22,10 @@
22
22
  <g stroke="#000000" stroke-width="0.1%" fill="none" transform="matrix(1,0,0,-1,0,0)">
23
23
  ${e}
24
24
  </g>
25
- </svg>`}}const Ye=new Pt;class yo{convert(){const e=ce.instance.curDocument.database.tables.blockTable.modelSpace.newIterator(),t=new mo;for(const r of e)r.draw(t);this.createFileAndDownloadIt(t.export())}createFileAndDownloadIt(e){const t=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),r=URL.createObjectURL(t),i=document.createElement("a");i.href=r,i.download="example.svg",document.body.appendChild(i),i.click()}}class Ar extends Be{execute(e){new yo().convert()}}class Er extends Be{execute(e){Ce.emit("open-file",{})}}class kr extends Be{execute(e){ce.instance.openUrl("https://cdn.jsdelivr.net/gh/mlight-lee/cad-data/templates/"+"acadiso.dxf")}}class Br extends Be{execute(e){e.view.mode=Ie.SELECTION,e.view.setCursor(qe.Crosshair)}}class Lr extends Be{execute(e){const t=e.doc.database;e.view.zoomTo(new S.AcGeBox2d(t.extmin,t.extmax),1.1)}}class Or extends wr{constructor(e){super(e)}async sampler(){await ce.instance.editor.getSelection().then(e=>this.view.zoomTo(e,1))}}class Mr extends Be{async execute(e){await new Or(e.view).drag()}}class Dr extends Be{execute(e){e.view.mode=Ie.PAN,e.view.setCursor(qe.Grab)}}class Rr{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}removeEventListener(e){this.listeners=this.listeners.filter(t=>t!==e)}replaceEventListener(e){this.removeEventListener(e),this.addEventListener(e)}dispatch(e,...t){for(const r of this.listeners)r.call(null,e,...t)}}class vo{constructor(){this.cache=new Map}hasGeometry(e,t){const r=this.generateKey(e,t);return this.cache.has(r)}getGeometry(e,t){const r=this.generateKey(e,t);if(this.cache.has(r))return this.cache.get(r)}setGeometry(e,t,r){const i=this.generateKey(e,t);this.cache.set(i,r)}dispose(){for(const e of this.cache.values())e.dispose();this.cache.clear()}generateKey(e,t){return`${e}_${t}`}}class Ur{constructor(){this.unsupportedChars={},this.cache=new vo}addUnsupportedChar(e){this.unsupportedChars[e]||(this.unsupportedChars[e]=0),this.unsupportedChars[e]++}}class Fr extends g.Shape{constructor(e){super(),this.width=0,this.char=e}}const yn=(n,e)=>e.some(t=>n instanceof t);let Pr,Gr;function bo(){return Pr||(Pr=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function xo(){return Gr||(Gr=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const vn=new WeakMap,bn=new WeakMap,Gt=new WeakMap;function So(n){const e=new Promise((t,r)=>{const i=()=>{n.removeEventListener("success",s),n.removeEventListener("error",o)},s=()=>{t(Ne(n.result)),i()},o=()=>{r(n.error),i()};n.addEventListener("success",s),n.addEventListener("error",o)});return Gt.set(e,n),e}function wo(n){if(vn.has(n))return;const e=new Promise((t,r)=>{const i=()=>{n.removeEventListener("complete",s),n.removeEventListener("error",o),n.removeEventListener("abort",o)},s=()=>{t(),i()},o=()=>{r(n.error||new DOMException("AbortError","AbortError")),i()};n.addEventListener("complete",s),n.addEventListener("error",o),n.addEventListener("abort",o)});vn.set(n,e)}let xn={get(n,e,t){if(n instanceof IDBTransaction){if(e==="done")return vn.get(n);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return Ne(n[e])},set(n,e,t){return n[e]=t,!0},has(n,e){return n instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in n}};function Nr(n){xn=n(xn)}function _o(n){return xo().includes(n)?function(...e){return n.apply(Sn(this),e),Ne(this.request)}:function(...e){return Ne(n.apply(Sn(this),e))}}function To(n){return typeof n=="function"?_o(n):(n instanceof IDBTransaction&&wo(n),yn(n,bo())?new Proxy(n,xn):n)}function Ne(n){if(n instanceof IDBRequest)return So(n);if(bn.has(n))return bn.get(n);const e=To(n);return e!==n&&(bn.set(n,e),Gt.set(e,n)),e}const Sn=n=>Gt.get(n);function Co(n,e,{blocked:t,upgrade:r,blocking:i,terminated:s}={}){const o=indexedDB.open(n,e),a=Ne(o);return r&&o.addEventListener("upgradeneeded",c=>{r(Ne(o.result),c.oldVersion,c.newVersion,Ne(o.transaction),c)}),t&&o.addEventListener("blocked",c=>t(c.oldVersion,c.newVersion,c)),a.then(c=>{s&&c.addEventListener("close",()=>s()),i&&c.addEventListener("versionchange",l=>i(l.oldVersion,l.newVersion,l))}).catch(()=>{}),a}const Io=["get","getKey","getAll","getAllKeys","count"],Ao=["put","add","delete","clear"],wn=new Map;function zr(n,e){if(!(n instanceof IDBDatabase&&!(e in n)&&typeof e=="string"))return;if(wn.get(e))return wn.get(e);const t=e.replace(/FromIndex$/,""),r=e!==t,i=Ao.includes(t);if(!(t in(r?IDBIndex:IDBObjectStore).prototype)||!(i||Io.includes(t)))return;const s=async function(o,...a){const c=this.transaction(o,i?"readwrite":"readonly");let l=c.store;return r&&(l=l.index(a.shift())),(await Promise.all([l[t](...a),i&&c.done]))[0]};return wn.set(e,s),s}Nr(n=>({...n,get:(e,t,r)=>zr(e,t)||n.get(e,t,r),has:(e,t)=>!!zr(e,t)||n.has(e,t)}));const Eo=["continue","continuePrimaryKey","advance"],Vr={},_n=new WeakMap,Hr=new WeakMap,ko={get(n,e){if(!Eo.includes(e))return n[e];let t=Vr[e];return t||(t=Vr[e]=function(...r){_n.set(this,Hr.get(this)[e](...r))}),t}};async function*Bo(...n){let e=this;if(e instanceof IDBCursor||(e=await e.openCursor(...n)),!e)return;e=e;const t=new Proxy(e,ko);for(Hr.set(t,e),Gt.set(t,Sn(e));e;)yield t,e=await(_n.get(t)||e.continue()),_n.delete(t)}function jr(n,e){return e===Symbol.asyncIterator&&yn(n,[IDBIndex,IDBObjectStore,IDBCursor])||e==="iterate"&&yn(n,[IDBIndex,IDBObjectStore])}Nr(n=>({...n,get(e,t,r){return jr(e,t)?Bo:n.get(e,t,r)},has(e,t){return jr(e,t)||n.has(e,t)}}));const $e={fonts:"fonts"},Tn=[{version:1,stores:[{name:$e.fonts,keyPath:"name"}]}],Cn=class Te{constructor(){this.isClosing=!1,typeof window<"u"&&window.addEventListener("unload",()=>{this.close()})}static get instance(){return Te._instance||(Te._instance=new Te),Te._instance}async set(e,t){await(await this.getDatabase()).put($e.fonts,{...t,name:e})}async get(e){return await(await this.getDatabase()).get($e.fonts,e)}async delete(e){await(await this.getDatabase()).delete($e.fonts,e)}async getAll(){return await(await this.getDatabase()).getAll($e.fonts)}async clear(){await(await this.getDatabase()).clear($e.fonts)}async has(e){return await this.get(e)!==void 0}close(){if(!this.isClosing){this.isClosing=!0;try{this.db&&(this.db.close(),this.db=void 0)}finally{this.isClosing=!1}}}async destroy(){this.close(),await indexedDB.deleteDatabase(Te.DATABASE_NAME),Te._instance=void 0}async getDatabase(){if(this.isClosing)throw new Error("Cannot perform operation while database is closing");return this.db?this.db:(this.db=await Co(Te.DATABASE_NAME,Te.DATABASE_VERSION,{upgrade:(e,t,r)=>this.handleUpgrade(e,t,r),blocked(){console.warn("Database upgrade blocked - please close other tabs using the application")},blocking(){console.warn("Database blocking newer version - closing connection"),Te.instance.close()}}),this.db)}handleUpgrade(e,t,r){const i=Tn.filter(s=>s.version>t&&(!r||s.version<=r));for(const s of i)this.applySchemaVersion(e,s)}applySchemaVersion(e,t){for(const r of t.stores)e.objectStoreNames.contains(r.name)||e.createObjectStore(r.name,{keyPath:r.keyPath})}};Cn.DATABASE_NAME="mlightcad",Cn.DATABASE_VERSION=Tn[Tn.length-1].version;let In=Cn;const Lo=n=>n.substring(n.lastIndexOf(".")+1),Wr=n=>n.split("/").pop(),Xr=n=>{const e=Wr(n);if(e){const t=e.lastIndexOf(".");return t===-1?e:e.substring(0,t)}return n},Oo=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215,0],Mo=n=>Oo[n];let Do=class{constructor(n){this.isFont=!0,this.type="Font",this.data=n}generateShapes(n,e=100){const t=[],r=Ro(n,e,this.data);for(let i=0,s=r.length;i<s;i++)t.push(...r[i].toShapes());return t}};function Ro(n,e,t){const r=Array.from(n),i=e/t.resolution,s=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*i,o=[];let a=0,c=0;for(let l=0;l<r.length;l++){const h=r[l];if(h===`
26
- `)a=0,c-=s;else{const d=Uo(h,i,a,c,t);a+=d.offsetX,o.push(d.path)}}return o}function Uo(n,e,t,r,i){const s=i.glyphs[n]||i.glyphs["?"];if(!s){console.error('THREE.Font: character "'+n+'" does not exists in font family '+i.familyName+".");return}const o=new ke.ShapePath;let a,c,l,h,d,u,p,f;if(s.o){const m=s._cachedOutline||(s._cachedOutline=s.o.split(" "));for(let y=0,v=m.length;y<v;)switch(m[y++]){case"m":a=m[y++]*e+t,c=m[y++]*e+r,o.moveTo(a,c);break;case"l":a=m[y++]*e+t,c=m[y++]*e+r,o.lineTo(a,c);break;case"q":l=m[y++]*e+t,h=m[y++]*e+r,d=m[y++]*e+t,u=m[y++]*e+r,o.quadraticCurveTo(d,u,l,h);break;case"b":l=m[y++]*e+t,h=m[y++]*e+r,d=m[y++]*e+t,u=m[y++]*e+r,p=m[y++]*e+t,f=m[y++]*e+r,o.bezierCurveTo(d,u,p,f,l,h);break}}return{offsetX:s.ha*e,path:o}}function qr(n,e=!1){const t=n[0].index!==null,r=new Set(Object.keys(n[0].attributes)),i=new Set(Object.keys(n[0].morphAttributes)),s={},o={},a=n[0].morphTargetsRelative,c=new ke.BufferGeometry;let l=0;for(let h=0;h<n.length;++h){const d=n[h];let u=0;if(t!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const p in d.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;s[p]===void 0&&(s[p]=[]),s[p].push(d.attributes[p]),u++}if(u!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(a!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const p in d.morphAttributes){if(!i.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;o[p]===void 0&&(o[p]=[]),o[p].push(d.morphAttributes[p])}if(e){let p;if(t)p=d.index.count;else if(d.attributes.position!==void 0)p=d.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;c.addGroup(l,p,h),l+=p}}if(t){let h=0;const d=[];for(let u=0;u<n.length;++u){const p=n[u].index;for(let f=0;f<p.count;++f)d.push(p.getX(f)+h);h+=n[u].attributes.position.count}c.setIndex(d)}for(const h in s){const d=Yr(s[h]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" attribute."),null;c.setAttribute(h,d)}for(const h in o){const d=o[h][0].length;if(d===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[h]=[];for(let u=0;u<d;++u){const p=[];for(let m=0;m<o[h].length;++m)p.push(o[h][m][u]);const f=Yr(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;c.morphAttributes[h].push(f)}}return c}function Yr(n){let e,t,r,i=-1,s=0;for(let l=0;l<n.length;++l){const h=n[l];if(e===void 0&&(e=h.array.constructor),e!==h.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=h.itemSize),t!==h.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=h.normalized),r!==h.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=h.gpuType),i!==h.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=h.count*t}const o=new e(s),a=new ke.BufferAttribute(o,t,r);let c=0;for(let l=0;l<n.length;++l){const h=n[l];if(h.isInterleavedBufferAttribute){const d=c/t;for(let u=0,p=h.count;u<p;u++)for(let f=0;f<t;f++){const m=h.getComponent(u,f);a.setComponent(u+d,f,m)}}else o.set(h.array,c);c+=h.count*t}return i!==void 0&&(a.gpuType=i),a}function Fo(n,e=1e-4){e=Math.max(e,Number.EPSILON);const t={},r=n.getIndex(),i=n.getAttribute("position"),s=r?r.count:i.count;let o=0;const a=Object.keys(n.attributes),c={},l={},h=[],d=["getX","getY","getZ","getW"],u=["setX","setY","setZ","setW"];for(let _=0,w=a.length;_<w;_++){const C=a[_],T=n.attributes[C];c[C]=new T.constructor(new T.array.constructor(T.count*T.itemSize),T.itemSize,T.normalized);const D=n.morphAttributes[C];D&&(l[C]||(l[C]=[]),D.forEach((I,E)=>{const U=new I.array.constructor(I.count*I.itemSize);l[C][E]=new I.constructor(U,I.itemSize,I.normalized)}))}const p=e*.5,f=Math.log10(1/e),m=Math.pow(10,f),y=p*m;for(let _=0;_<s;_++){const w=r?r.getX(_):_;let C="";for(let T=0,D=a.length;T<D;T++){const I=a[T],E=n.getAttribute(I),U=E.itemSize;for(let V=0;V<U;V++)C+=`${~~(E[d[V]](w)*m+y)},`}if(C in t)h.push(t[C]);else{for(let T=0,D=a.length;T<D;T++){const I=a[T],E=n.getAttribute(I),U=n.morphAttributes[I],V=E.itemSize,J=c[I],te=l[I];for(let $=0;$<V;$++){const P=d[$],H=u[$];if(J[H](o,E[P](w)),U)for(let N=0,X=U.length;N<X;N++)te[N][H](o,U[N][P](w))}}t[C]=o,h.push(o),o++}}const v=n.clone();for(const _ in n.attributes){const w=c[_];if(v.setAttribute(_,new w.constructor(w.array.slice(0,o*w.itemSize),w.itemSize,w.normalized)),_ in l)for(let C=0;C<l[_].length;C++){const T=l[_][C];v.morphAttributes[_][C]=new T.constructor(T.array.slice(0,o*T.itemSize),T.itemSize,T.normalized)}}return v.setIndex(h),v}class Po extends ke.ExtrudeGeometry{constructor(e,t={}){const r=t.font;if(r===void 0)super();else{const i=r.generateShapes(e,t.size);t.depth===void 0&&t.height!==void 0&&console.warn("THREE.TextGeometry: .height is now depreciated. Please use .depth instead"),t.depth=t.depth!==void 0?t.depth:t.height!==void 0?t.height:50,t.bevelThickness===void 0&&(t.bevelThickness=10),t.bevelSize===void 0&&(t.bevelSize=8),t.bevelEnabled===void 0&&(t.bevelEnabled=!1),super(i,t)}this.type="TextGeometry"}}const $r=class{static dummyComputeVertexNormals(){}static disable(){ke.BufferGeometry.prototype.computeVertexNormals=this.dummyComputeVertexNormals}static restore(){ke.BufferGeometry.prototype.computeVertexNormals=this.originalComputeVertexNormals}static runWithoutNormals(e){this.disable();try{return e()}finally{this.restore()}}};$r.originalComputeVertexNormals=ke.BufferGeometry.prototype.computeVertexNormals;let Go=$r;const ze=new g.Vector2;class Zr extends Fr{constructor(e,t,r){super(e),this.isFound=!1,this.fontSize=t,this.font=r,this.width=this.getCharWidth(e,t,r)}toGeometry(){let e=this.font.cache.getGeometry(this.char,this.fontSize);return e==null&&(e=Go.runWithoutNormals(()=>{const t=new Po(this.char,{font:this.font.font,depth:0,size:this.fontSize,curveSegments:3,bevelSegments:3,UVGenerator:{generateTopUV:()=>[ze,ze,ze],generateSideWallUV:()=>[ze,ze,ze,ze]}});return t.hasAttribute("uv")&&t.deleteAttribute("uv"),t.hasAttribute("normal")&&t.deleteAttribute("normal"),Fo(t,1e-6)})),e}getCharWidth(e,t,r){const i=r.data.glyphs[e];return i?(this.isFound=!0,i.ha*t/r.data.resolution):(this.isFound=!1,0)}}/*! https://mths.be/codepointat v0.2.0 by @mathias */String.prototype.codePointAt||function(){var n=function(){try{var t={},r=Object.defineProperty,i=r(t,t,t)&&r}catch{}return i}(),e=function(t){if(this==null)throw TypeError();var r=String(this),i=r.length,s=t?Number(t):0;if(s!=s&&(s=0),!(s<0||s>=i)){var o=r.charCodeAt(s),a;return o>=55296&&o<=56319&&i>s+1&&(a=r.charCodeAt(s+1),a>=56320&&a<=57343)?(o-55296)*1024+a-56320+65536:o}};n?n(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e}();var An=0,Qr=-3;function ft(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function No(n,e){this.source=n,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=e,this.destLen=0,this.ltree=new ft,this.dtree=new ft}var Jr=new ft,Kr=new ft,En=new Uint8Array(30),kn=new Uint16Array(30),ei=new Uint8Array(30),ti=new Uint16Array(30),zo=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ni=new ft,ye=new Uint8Array(320);function ri(n,e,t,r){var i,s;for(i=0;i<t;++i)n[i]=0;for(i=0;i<30-t;++i)n[i+t]=i/t|0;for(s=r,i=0;i<30;++i)e[i]=s,s+=1<<n[i]}function Vo(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 ii=new Uint16Array(16);function Bn(n,e,t,r){var i,s;for(i=0;i<16;++i)n.table[i]=0;for(i=0;i<r;++i)n.table[e[t+i]]++;for(n.table[0]=0,s=0,i=0;i<16;++i)ii[i]=s,s+=n.table[i];for(i=0;i<r;++i)e[t+i]&&(n.trans[ii[e[t+i]]++]=i)}function Ho(n){n.bitcount--||(n.tag=n.source[n.sourceIndex++],n.bitcount=7);var e=n.tag&1;return n.tag>>>=1,e}function ve(n,e,t){if(!e)return t;for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<<n.bitcount,n.bitcount+=8;var r=n.tag&65535>>>16-e;return n.tag>>>=e,n.bitcount-=e,r+t}function Ln(n,e){for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<<n.bitcount,n.bitcount+=8;var t=0,r=0,i=0,s=n.tag;do r=2*r+(s&1),s>>>=1,++i,t+=e.table[i],r-=e.table[i];while(r>=0);return n.tag=s,n.bitcount-=i,e.trans[t+r]}function jo(n,e,t){var r,i,s,o,a,c;for(r=ve(n,5,257),i=ve(n,5,1),s=ve(n,4,4),o=0;o<19;++o)ye[o]=0;for(o=0;o<s;++o){var l=ve(n,3,0);ye[zo[o]]=l}for(Bn(ni,ye,0,19),a=0;a<r+i;){var h=Ln(n,ni);switch(h){case 16:var d=ye[a-1];for(c=ve(n,2,3);c;--c)ye[a++]=d;break;case 17:for(c=ve(n,3,3);c;--c)ye[a++]=0;break;case 18:for(c=ve(n,7,11);c;--c)ye[a++]=0;break;default:ye[a++]=h;break}}Bn(e,ye,0,r),Bn(t,ye,r,i)}function si(n,e,t){for(;;){var r=Ln(n,e);if(r===256)return An;if(r<256)n.dest[n.destLen++]=r;else{var i,s,o,a;for(r-=257,i=ve(n,En[r],kn[r]),s=Ln(n,t),o=n.destLen-ve(n,ei[s],ti[s]),a=o;a<o+i;++a)n.dest[n.destLen++]=n.dest[a]}}}function Wo(n){for(var e,t,r;n.bitcount>8;)n.sourceIndex--,n.bitcount-=8;if(e=n.source[n.sourceIndex+1],e=256*e+n.source[n.sourceIndex],t=n.source[n.sourceIndex+3],t=256*t+n.source[n.sourceIndex+2],e!==(~t&65535))return Qr;for(n.sourceIndex+=4,r=e;r;--r)n.dest[n.destLen++]=n.source[n.sourceIndex++];return n.bitcount=0,An}function Xo(n,e){var t=new No(n,e),r,i,s;do{switch(r=Ho(t),i=ve(t,2,0),i){case 0:s=Wo(t);break;case 1:s=si(t,Jr,Kr);break;case 2:jo(t,t.ltree,t.dtree),s=si(t,t.ltree,t.dtree);break;default:s=Qr}if(s!==An)throw new Error("Data error")}while(!r);return t.destLen<t.dest.length?typeof t.dest.slice=="function"?t.dest.slice(0,t.destLen):t.dest.subarray(0,t.destLen):t.dest}Vo(Jr,Kr),ri(En,kn,4,3),ri(ei,ti,2,1),En[28]=0,kn[28]=258;var qo=Xo;function Ze(n,e,t,r,i){return Math.pow(1-i,3)*n+3*Math.pow(1-i,2)*i*e+3*(1-i)*Math.pow(i,2)*t+Math.pow(i,3)*r}function Le(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}Le.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)},Le.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))},Le.prototype.addX=function(n){this.addPoint(n,null)},Le.prototype.addY=function(n){this.addPoint(null,n)},Le.prototype.addBezier=function(n,e,t,r,i,s,o,a){var c=[n,e],l=[t,r],h=[i,s],d=[o,a];this.addPoint(n,e),this.addPoint(o,a);for(var u=0;u<=1;u++){var p=6*c[u]-12*l[u]+6*h[u],f=-3*c[u]+9*l[u]-9*h[u]+3*d[u],m=3*l[u]-3*c[u];if(f===0){if(p===0)continue;var y=-m/p;0<y&&y<1&&(u===0&&this.addX(Ze(c[u],l[u],h[u],d[u],y)),u===1&&this.addY(Ze(c[u],l[u],h[u],d[u],y)));continue}var v=Math.pow(p,2)-4*m*f;if(!(v<0)){var _=(-p+Math.sqrt(v))/(2*f);0<_&&_<1&&(u===0&&this.addX(Ze(c[u],l[u],h[u],d[u],_)),u===1&&this.addY(Ze(c[u],l[u],h[u],d[u],_)));var w=(-p-Math.sqrt(v))/(2*f);0<w&&w<1&&(u===0&&this.addX(Ze(c[u],l[u],h[u],d[u],w)),u===1&&this.addY(Ze(c[u],l[u],h[u],d[u],w)))}}},Le.prototype.addQuad=function(n,e,t,r,i,s){var o=n+.6666666666666666*(t-n),a=e+2/3*(r-e),c=o+1/3*(i-n),l=a+1/3*(s-e);this.addBezier(n,e,o,a,c,l,i,s)};function j(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}j.prototype.moveTo=function(n,e){this.commands.push({type:"M",x:n,y:e})},j.prototype.lineTo=function(n,e){this.commands.push({type:"L",x:n,y:e})},j.prototype.curveTo=j.prototype.bezierCurveTo=function(n,e,t,r,i,s){this.commands.push({type:"C",x1:n,y1:e,x2:t,y2:r,x:i,y:s})},j.prototype.quadTo=j.prototype.quadraticCurveTo=function(n,e,t,r){this.commands.push({type:"Q",x1:n,y1:e,x:t,y:r})},j.prototype.close=j.prototype.closePath=function(){this.commands.push({type:"Z"})},j.prototype.extend=function(n){if(n.commands)n=n.commands;else if(n instanceof Le){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)},j.prototype.getBoundingBox=function(){for(var n=new Le,e=0,t=0,r=0,i=0,s=0;s<this.commands.length;s++){var o=this.commands[s];switch(o.type){case"M":n.addPoint(o.x,o.y),e=r=o.x,t=i=o.y;break;case"L":n.addPoint(o.x,o.y),r=o.x,i=o.y;break;case"Q":n.addQuad(r,i,o.x1,o.y1,o.x,o.y),r=o.x,i=o.y;break;case"C":n.addBezier(r,i,o.x1,o.y1,o.x2,o.y2,o.x,o.y),r=o.x,i=o.y;break;case"Z":r=e,i=t;break;default:throw new Error("Unexpected path command "+o.type)}}return n.isEmpty()&&n.addPoint(0,0),n},j.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())},j.prototype.toPathData=function(n){n=n!==void 0?n:2;function e(o){return Math.round(o)===o?""+Math.round(o):o.toFixed(n)}function t(){for(var o=arguments,a="",c=0;c<arguments.length;c+=1){var l=o[c];l>=0&&c>0&&(a+=" "),a+=e(l)}return a}for(var r="",i=0;i<this.commands.length;i+=1){var s=this.commands[i];s.type==="M"?r+="M"+t(s.x,s.y):s.type==="L"?r+="L"+t(s.x,s.y):s.type==="C"?r+="C"+t(s.x1,s.y1,s.x2,s.y2,s.x,s.y):s.type==="Q"?r+="Q"+t(s.x1,s.y1,s.x,s.y):s.type==="Z"&&(r+="Z")}return r},j.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},j.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 oi(n){throw new Error(n)}function ai(n,e){n||oi(e)}var O={fail:oi,argument:ai,assert:ai},ci=32768,li=2147483648,Qe={},A={},M={};function le(n){return function(){return n}}A.BYTE=function(n){return O.argument(n>=0&&n<=255,"Byte value should be between 0 and 255."),[n]},M.BYTE=le(1),A.CHAR=function(n){return[n.charCodeAt(0)]},M.CHAR=le(1),A.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},M.CHARARRAY=function(n){return typeof n>"u"?0:n.length},A.USHORT=function(n){return[n>>8&255,n&255]},M.USHORT=le(2),A.SHORT=function(n){return n>=ci&&(n=-(2*ci-n)),[n>>8&255,n&255]},M.SHORT=le(2),A.UINT24=function(n){return[n>>16&255,n>>8&255,n&255]},M.UINT24=le(3),A.ULONG=function(n){return[n>>24&255,n>>16&255,n>>8&255,n&255]},M.ULONG=le(4),A.LONG=function(n){return n>=li&&(n=-(2*li-n)),[n>>24&255,n>>16&255,n>>8&255,n&255]},M.LONG=le(4),A.FIXED=A.ULONG,M.FIXED=M.ULONG,A.FWORD=A.SHORT,M.FWORD=M.SHORT,A.UFWORD=A.USHORT,M.UFWORD=M.USHORT,A.LONGDATETIME=function(n){return[0,0,0,0,n>>24&255,n>>16&255,n>>8&255,n&255]},M.LONGDATETIME=le(8),A.TAG=function(n){return O.argument(n.length===4,"Tag should be exactly 4 ASCII characters."),[n.charCodeAt(0),n.charCodeAt(1),n.charCodeAt(2),n.charCodeAt(3)]},M.TAG=le(4),A.Card8=A.BYTE,M.Card8=M.BYTE,A.Card16=A.USHORT,M.Card16=M.USHORT,A.OffSize=A.BYTE,M.OffSize=M.BYTE,A.SID=A.USHORT,M.SID=M.USHORT,A.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?A.NUMBER16(n):A.NUMBER32(n)},M.NUMBER=function(n){return A.NUMBER(n).length},A.NUMBER16=function(n){return[28,n>>8&255,n&255]},M.NUMBER16=le(3),A.NUMBER32=function(n){return[29,n>>24&255,n>>16&255,n>>8&255,n&255]},M.NUMBER32=le(5),A.REAL=function(n){var e=n.toString(),t=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(e);if(t){var r=parseFloat("1e"+((t[2]?+t[2]:0)+t[1].length));e=(Math.round(n*r)/r).toString()}for(var i="",s=0,o=e.length;s<o;s+=1){var a=e[s];a==="e"?i+=e[++s]==="-"?"c":"b":a==="."?i+="a":a==="-"?i+="e":i+=a}i+=i.length&1?"f":"ff";for(var c=[30],l=0,h=i.length;l<h;l+=2)c.push(parseInt(i.substr(l,2),16));return c},M.REAL=function(n){return A.REAL(n).length},A.NAME=A.CHARARRAY,M.NAME=M.CHARARRAY,A.STRING=A.CHARARRAY,M.STRING=M.CHARARRAY,Qe.UTF8=function(n,e,t){for(var r=[],i=t,s=0;s<i;s++,e+=1)r[s]=n.getUint8(e);return String.fromCharCode.apply(null,r)},Qe.UTF16=function(n,e,t){for(var r=[],i=t/2,s=0;s<i;s++,e+=2)r[s]=n.getUint16(e);return String.fromCharCode.apply(null,r)},A.UTF16=function(n){for(var e=[],t=0;t<n.length;t+=1){var r=n.charCodeAt(t);e[e.length]=r>>8&255,e[e.length]=r&255}return e},M.UTF16=function(n){return n.length*2};var On={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈ƫȅ ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-cyrillic":"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ­","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüݰ¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ",macintosh:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};Qe.MACSTRING=function(n,e,t,r){var i=On[r];if(i!==void 0){for(var s="",o=0;o<t;o++){var a=n.getUint8(e+o);a<=127?s+=String.fromCharCode(a):s+=i[a&127]}return s}};var Nt=typeof WeakMap=="function"&&new WeakMap,zt,Yo=function(n){if(!zt){zt={};for(var e in On)zt[e]=new String(e)}var t=zt[n];if(t!==void 0){if(Nt){var r=Nt.get(t);if(r!==void 0)return r}var i=On[n];if(i!==void 0){for(var s={},o=0;o<i.length;o++)s[i.charCodeAt(o)]=o+128;return Nt&&Nt.set(t,s),s}}};A.MACSTRING=function(n,e){var t=Yo(e);if(t!==void 0){for(var r=[],i=0;i<n.length;i++){var s=n.charCodeAt(i);if(s>=128&&(s=t[s],s===void 0))return;r[i]=s}return r}},M.MACSTRING=function(n,e){var t=A.MACSTRING(n,e);return t!==void 0?t.length:0};function Mn(n){return n>=-128&&n<=127}function $o(n,e,t){for(var r=0,i=n.length;e<i&&r<64&&n[e]===0;)++e,++r;return t.push(128|r-1),e}function Zo(n,e,t){for(var r=0,i=n.length,s=e;s<i&&r<64;){var o=n[s];if(!Mn(o)||o===0&&s+1<i&&n[s+1]===0)break;++s,++r}t.push(r-1);for(var a=e;a<s;++a)t.push(n[a]+256&255);return s}function Qo(n,e,t){for(var r=0,i=n.length,s=e;s<i&&r<64;){var o=n[s];if(o===0||Mn(o)&&s+1<i&&Mn(n[s+1]))break;++s,++r}t.push(64|r-1);for(var a=e;a<s;++a){var c=n[a];t.push(c+65536>>8&255,c+256&255)}return s}A.VARDELTAS=function(n){for(var e=0,t=[];e<n.length;){var r=n[e];r===0?e=$o(n,e,t):r>=-128&&r<=127?e=Zo(n,e,t):e=Qo(n,e,t)}return t},A.INDEX=function(n){for(var e=1,t=[e],r=[],i=0;i<n.length;i+=1){var s=A.OBJECT(n[i]);Array.prototype.push.apply(r,s),e+=s.length,t.push(e)}if(r.length===0)return[0,0];for(var o=[],a=1+Math.floor(Math.log(e)/Math.log(2))/8|0,c=[void 0,A.BYTE,A.USHORT,A.UINT24,A.ULONG][a],l=0;l<t.length;l+=1){var h=c(t[l]);Array.prototype.push.apply(o,h)}return Array.prototype.concat(A.Card16(n.length),A.OffSize(a),o,r)},M.INDEX=function(n){return A.INDEX(n).length},A.DICT=function(n){for(var e=[],t=Object.keys(n),r=t.length,i=0;i<r;i+=1){var s=parseInt(t[i],0),o=n[s];e=e.concat(A.OPERAND(o.value,o.type)),e=e.concat(A.OPERATOR(s))}return e},M.DICT=function(n){return A.DICT(n).length},A.OPERATOR=function(n){return n<1200?[n]:[12,n-1200]},A.OPERAND=function(n,e){var t=[];if(Array.isArray(e))for(var r=0;r<e.length;r+=1)O.argument(n.length===e.length,"Not enough arguments given for type"+e),t=t.concat(A.OPERAND(n[r],e[r]));else if(e==="SID")t=t.concat(A.NUMBER(n));else if(e==="offset")t=t.concat(A.NUMBER32(n));else if(e==="number")t=t.concat(A.NUMBER(n));else if(e==="real")t=t.concat(A.REAL(n));else throw new Error("Unknown operand type "+e);return t},A.OP=A.BYTE,M.OP=M.BYTE;var Vt=typeof WeakMap=="function"&&new WeakMap;A.CHARSTRING=function(n){if(Vt){var e=Vt.get(n);if(e!==void 0)return e}for(var t=[],r=n.length,i=0;i<r;i+=1){var s=n[i];t=t.concat(A[s.type](s.value))}return Vt&&Vt.set(n,t),t},M.CHARSTRING=function(n){return A.CHARSTRING(n).length},A.OBJECT=function(n){var e=A[n.type];return O.argument(e!==void 0,"No encoding function for type "+n.type),e(n.value)},M.OBJECT=function(n){var e=M[n.type];return O.argument(e!==void 0,"No sizeOf function for type "+n.type),e(n.value)},A.TABLE=function(n){for(var e=[],t=n.fields.length,r=[],i=[],s=0;s<t;s+=1){var o=n.fields[s],a=A[o.type];O.argument(a!==void 0,"No encoding function for field type "+o.type+" ("+o.name+")");var c=n[o.name];c===void 0&&(c=o.value);var l=a(c);o.type==="TABLE"?(i.push(e.length),e=e.concat([0,0]),r.push(l)):e=e.concat(l)}for(var h=0;h<r.length;h+=1){var d=i[h],u=e.length;O.argument(u<65536,"Table "+n.tableName+" too big."),e[d]=u>>8,e[d+1]=u&255,e=e.concat(r[h])}return e},M.TABLE=function(n){for(var e=0,t=n.fields.length,r=0;r<t;r+=1){var i=n.fields[r],s=M[i.type];O.argument(s!==void 0,"No sizeOf function for field type "+i.type+" ("+i.name+")");var o=n[i.name];o===void 0&&(o=i.value),e+=s(o),i.type==="TABLE"&&(e+=2)}return e},A.RECORD=A.TABLE,M.RECORD=M.TABLE,A.LITERAL=function(n){return n},M.LITERAL=function(n){return n.length};function q(n,e,t){if(e.length&&(e[0].name!=="coverageFormat"||e[0].value===1))for(var r=0;r<e.length;r+=1){var i=e[r];this[i.name]=i.value}if(this.tableName=n,this.fields=e,t)for(var s=Object.keys(t),o=0;o<s.length;o+=1){var a=s[o],c=t[a];this[a]!==void 0&&(this[a]=c)}}q.prototype.encode=function(){return A.TABLE(this)},q.prototype.sizeOf=function(){return M.TABLE(this)};function gt(n,e,t){t===void 0&&(t=e.length);var r=new Array(e.length+1);r[0]={name:n+"Count",type:"USHORT",value:t};for(var i=0;i<e.length;i++)r[i+1]={name:n+i,type:"USHORT",value:e[i]};return r}function Dn(n,e,t){var r=e.length,i=new Array(r+1);i[0]={name:n+"Count",type:"USHORT",value:r};for(var s=0;s<r;s++)i[s+1]={name:n+s,type:"TABLE",value:t(e[s],s)};return i}function mt(n,e,t){var r=e.length,i=[];i[0]={name:n+"Count",type:"USHORT",value:r};for(var s=0;s<r;s++)i=i.concat(t(e[s],s));return i}function Ht(n){n.format===1?q.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(gt("glyph",n.glyphs))):n.format===2?q.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:2}].concat(mt("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}]}))):O.assert(!1,"Coverage format must be 1 or 2.")}Ht.prototype=Object.create(q.prototype),Ht.prototype.constructor=Ht;function jt(n){q.call(this,"scriptListTable",mt("scriptRecord",n,function(e,t){var r=e.script,i=r.defaultLangSys;return O.assert(!!i,"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 q("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new q("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:i.reqFeatureIndex}].concat(gt("featureIndex",i.featureIndexes)))}].concat(mt("langSys",r.langSysRecords,function(s,o){var a=s.langSys;return[{name:"langSysTag"+o,type:"TAG",value:s.tag},{name:"langSys"+o,type:"TABLE",value:new q("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:a.reqFeatureIndex}].concat(gt("featureIndex",a.featureIndexes)))}]})))}]}))}jt.prototype=Object.create(q.prototype),jt.prototype.constructor=jt;function Wt(n){q.call(this,"featureListTable",mt("featureRecord",n,function(e,t){var r=e.feature;return[{name:"featureTag"+t,type:"TAG",value:e.tag},{name:"feature"+t,type:"TABLE",value:new q("featureTable",[{name:"featureParams",type:"USHORT",value:r.featureParams}].concat(gt("lookupListIndex",r.lookupListIndexes)))}]}))}Wt.prototype=Object.create(q.prototype),Wt.prototype.constructor=Wt;function Xt(n,e){q.call(this,"lookupListTable",Dn("lookup",n,function(t){var r=e[t.lookupType];return O.assert(!!r,"Unable to write GSUB lookup type "+t.lookupType+" tables."),new q("lookupTable",[{name:"lookupType",type:"USHORT",value:t.lookupType},{name:"lookupFlag",type:"USHORT",value:t.lookupFlag}].concat(Dn("subtable",t.subtables,r)))}))}Xt.prototype=Object.create(q.prototype),Xt.prototype.constructor=Xt;var k={Table:q,Record:q,Coverage:Ht,ScriptList:jt,FeatureList:Wt,LookupList:Xt,ushortList:gt,tableList:Dn,recordList:mt};function hi(n,e){return n.getUint8(e)}function qt(n,e){return n.getUint16(e,!1)}function Jo(n,e){return n.getInt16(e,!1)}function Rn(n,e){return n.getUint32(e,!1)}function ui(n,e){var t=n.getInt16(e,!1),r=n.getUint16(e+2,!1);return t+r/65535}function Ko(n,e){for(var t="",r=e;r<e+4;r+=1)t+=String.fromCharCode(n.getInt8(r));return t}function ea(n,e,t){for(var r=0,i=0;i<t;i+=1)r<<=8,r+=n.getUint8(e+i);return r}function ta(n,e,t){for(var r=[],i=e;i<t;i+=1)r.push(n.getUint8(i));return r}function na(n){for(var e="",t=0;t<n.length;t+=1)e+=String.fromCharCode(n[t]);return e}var ra={byte:1,uShort:2,short:2,uLong:4,fixed:4,longDateTime:8,tag:4};function x(n,e){this.data=n,this.offset=e,this.relativeOffset=0}x.prototype.parseByte=function(){var n=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,n},x.prototype.parseChar=function(){var n=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,n},x.prototype.parseCard8=x.prototype.parseByte,x.prototype.parseUShort=function(){var n=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,n},x.prototype.parseCard16=x.prototype.parseUShort,x.prototype.parseSID=x.prototype.parseUShort,x.prototype.parseOffset16=x.prototype.parseUShort,x.prototype.parseShort=function(){var n=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,n},x.prototype.parseF2Dot14=function(){var n=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,n},x.prototype.parseULong=function(){var n=Rn(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,n},x.prototype.parseOffset32=x.prototype.parseULong,x.prototype.parseFixed=function(){var n=ui(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,n},x.prototype.parseString=function(n){var e=this.data,t=this.offset+this.relativeOffset,r="";this.relativeOffset+=n;for(var i=0;i<n;i++)r+=String.fromCharCode(e.getUint8(t+i));return r},x.prototype.parseTag=function(){return this.parseString(4)},x.prototype.parseLongDateTime=function(){var n=Rn(this.data,this.offset+this.relativeOffset+4);return n-=2082844800,this.relativeOffset+=8,n},x.prototype.parseVersion=function(n){var e=qt(this.data,this.offset+this.relativeOffset),t=qt(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,n===void 0&&(n=4096),e+t/n/10},x.prototype.skip=function(n,e){e===void 0&&(e=1),this.relativeOffset+=ra[n]*e},x.prototype.parseULongList=function(n){n===void 0&&(n=this.parseULong());for(var e=new Array(n),t=this.data,r=this.offset+this.relativeOffset,i=0;i<n;i++)e[i]=t.getUint32(r),r+=4;return this.relativeOffset+=n*4,e},x.prototype.parseOffset16List=x.prototype.parseUShortList=function(n){n===void 0&&(n=this.parseUShort());for(var e=new Array(n),t=this.data,r=this.offset+this.relativeOffset,i=0;i<n;i++)e[i]=t.getUint16(r),r+=2;return this.relativeOffset+=n*2,e},x.prototype.parseShortList=function(n){for(var e=new Array(n),t=this.data,r=this.offset+this.relativeOffset,i=0;i<n;i++)e[i]=t.getInt16(r),r+=2;return this.relativeOffset+=n*2,e},x.prototype.parseByteList=function(n){for(var e=new Array(n),t=this.data,r=this.offset+this.relativeOffset,i=0;i<n;i++)e[i]=t.getUint8(r++);return this.relativeOffset+=n,e},x.prototype.parseList=function(n,e){e||(e=n,n=this.parseUShort());for(var t=new Array(n),r=0;r<n;r++)t[r]=e.call(this);return t},x.prototype.parseList32=function(n,e){e||(e=n,n=this.parseULong());for(var t=new Array(n),r=0;r<n;r++)t[r]=e.call(this);return t},x.prototype.parseRecordList=function(n,e){e||(e=n,n=this.parseUShort());for(var t=new Array(n),r=Object.keys(e),i=0;i<n;i++){for(var s={},o=0;o<r.length;o++){var a=r[o],c=e[a];s[a]=c.call(this)}t[i]=s}return t},x.prototype.parseRecordList32=function(n,e){e||(e=n,n=this.parseULong());for(var t=new Array(n),r=Object.keys(e),i=0;i<n;i++){for(var s={},o=0;o<r.length;o++){var a=r[o],c=e[a];s[a]=c.call(this)}t[i]=s}return t},x.prototype.parseStruct=function(n){if(typeof n=="function")return n.call(this);for(var e=Object.keys(n),t={},r=0;r<e.length;r++){var i=e[r],s=n[i];t[i]=s.call(this)}return t},x.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}},x.prototype.parseValueRecordList=function(){for(var n=this.parseUShort(),e=this.parseUShort(),t=new Array(e),r=0;r<e;r++)t[r]=this.parseValueRecord(n);return t},x.prototype.parsePointer=function(n){var e=this.parseOffset16();if(e>0)return new x(this.data,this.offset+e).parseStruct(n)},x.prototype.parsePointer32=function(n){var e=this.parseOffset32();if(e>0)return new x(this.data,this.offset+e).parseStruct(n)},x.prototype.parseListOfLists=function(n){for(var e=this.parseOffset16List(),t=e.length,r=this.relativeOffset,i=new Array(t),s=0;s<t;s++){var o=e[s];if(o===0){i[s]=void 0;continue}if(this.relativeOffset=o,n){for(var a=this.parseOffset16List(),c=new Array(a.length),l=0;l<a.length;l++)this.relativeOffset=o+a[l],c[l]=n.call(this);i[s]=c}else i[s]=this.parseUShortList()}return this.relativeOffset=r,i},x.prototype.parseCoverage=function(){var n=this.offset+this.relativeOffset,e=this.parseUShort(),t=this.parseUShort();if(e===1)return{format:1,glyphs:this.parseUShortList(t)};if(e===2){for(var r=new Array(t),i=0;i<t;i++)r[i]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:r}}throw new Error("0x"+n.toString(16)+": Coverage format must be 1 or 2.")},x.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:x.uShort,end:x.uShort,classId:x.uShort})};throw new Error("0x"+n.toString(16)+": ClassDef format must be 1 or 2.")},x.list=function(n,e){return function(){return this.parseList(n,e)}},x.list32=function(n,e){return function(){return this.parseList32(n,e)}},x.recordList=function(n,e){return function(){return this.parseRecordList(n,e)}},x.recordList32=function(n,e){return function(){return this.parseRecordList32(n,e)}},x.pointer=function(n){return function(){return this.parsePointer(n)}},x.pointer32=function(n){return function(){return this.parsePointer32(n)}},x.tag=x.prototype.parseTag,x.byte=x.prototype.parseByte,x.uShort=x.offset16=x.prototype.parseUShort,x.uShortList=x.prototype.parseUShortList,x.uLong=x.offset32=x.prototype.parseULong,x.uLongList=x.prototype.parseULongList,x.struct=x.prototype.parseStruct,x.coverage=x.prototype.parseCoverage,x.classDef=x.prototype.parseClassDef;var di={reserved:x.uShort,reqFeatureIndex:x.uShort,featureIndexes:x.uShortList};x.prototype.parseScriptList=function(){return this.parsePointer(x.recordList({tag:x.tag,script:x.pointer({defaultLangSys:x.pointer(di),langSysRecords:x.recordList({tag:x.tag,langSys:x.pointer(di)})})}))||[]},x.prototype.parseFeatureList=function(){return this.parsePointer(x.recordList({tag:x.tag,feature:x.pointer({featureParams:x.offset16,lookupListIndexes:x.uShortList})}))||[]},x.prototype.parseLookupList=function(n){return this.parsePointer(x.list(x.pointer(function(){var e=this.parseUShort();O.argument(1<=e&&e<=9,"GPOS/GSUB lookup type "+e+" unknown.");var t=this.parseUShort(),r=t&16;return{lookupType:e,lookupFlag:t,subtables:this.parseList(x.pointer(n[e])),markFilteringSet:r?this.parseUShort():void 0}})))||[]},x.prototype.parseFeatureVariationsList=function(){return this.parsePointer32(function(){var n=this.parseUShort(),e=this.parseUShort();O.argument(n===1&&e<1,"GPOS/GSUB feature variations table unknown.");var t=this.parseRecordList32({conditionSetOffset:x.offset32,featureTableSubstitutionOffset:x.offset32});return t})||[]};var L={getByte:hi,getCard8:hi,getUShort:qt,getCard16:qt,getShort:Jo,getULong:Rn,getFixed:ui,getTag:Ko,getOffset:ea,getBytes:ta,bytesToString:na,Parser:x};function ia(n,e){e.parseUShort(),n.length=e.parseULong(),n.language=e.parseULong();var t;n.groupCount=t=e.parseULong(),n.glyphIndexMap={};for(var r=0;r<t;r+=1)for(var i=e.parseULong(),s=e.parseULong(),o=e.parseULong(),a=i;a<=s;a+=1)n.glyphIndexMap[a]=o,o++}function sa(n,e,t,r,i){n.length=e.parseUShort(),n.language=e.parseUShort();var s;n.segCount=s=e.parseUShort()>>1,e.skip("uShort",3),n.glyphIndexMap={};for(var o=new L.Parser(t,r+i+14),a=new L.Parser(t,r+i+16+s*2),c=new L.Parser(t,r+i+16+s*4),l=new L.Parser(t,r+i+16+s*6),h=r+i+16+s*8,d=0;d<s-1;d+=1)for(var u=void 0,p=o.parseUShort(),f=a.parseUShort(),m=c.parseShort(),y=l.parseUShort(),v=f;v<=p;v+=1)y!==0?(h=l.offset+l.relativeOffset-2,h+=y,h+=(v-f)*2,u=L.getUShort(t,h),u!==0&&(u=u+m&65535)):u=v+m&65535,n.glyphIndexMap[v]=u}function oa(n,e){var t={};t.version=L.getUShort(n,e),O.argument(t.version===0,"cmap table version should be 0."),t.numTables=L.getUShort(n,e+2);for(var r=-1,i=t.numTables-1;i>=0;i-=1){var s=L.getUShort(n,e+4+i*8),o=L.getUShort(n,e+4+i*8+2);if(s===3&&(o===0||o===1||o===10)||s===0&&(o===0||o===1||o===2||o===3||o===4)){r=L.getULong(n,e+4+i*8+4);break}}if(r===-1)throw new Error("No valid cmap sub-tables found.");var a=new L.Parser(n,e+r);if(t.format=a.parseUShort(),t.format===12)ia(t,a);else if(t.format===4)sa(t,a,n,e,r);else throw new Error("Only format 4 and 12 cmap tables are supported (found format "+t.format+").");return t}function aa(n,e,t){n.segments.push({end:e,start:e,delta:-(e-t),offset:0,glyphIndex:t})}function ca(n){n.segments.push({end:65535,start:65535,delta:1,offset:0})}function la(n){var e=!0,t;for(t=n.length-1;t>0;t-=1){var r=n.get(t);if(r.unicode>65535){console.log("Adding CMAP format 12 (needed!)"),e=!1;break}}var i=[{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||(i=i.concat([{name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}])),i=i.concat([{name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);var s=new k.Table("cmap",i);for(s.segments=[],t=0;t<n.length;t+=1){for(var o=n.get(t),a=0;a<o.unicodes.length;a+=1)aa(s,o.unicodes[a],t);s.segments=s.segments.sort(function(_,w){return _.start-w.start})}ca(s);var c=s.segments.length,l=0,h=[],d=[],u=[],p=[],f=[],m=[];for(t=0;t<c;t+=1){var y=s.segments[t];y.end<=65535&&y.start<=65535?(h=h.concat({name:"end_"+t,type:"USHORT",value:y.end}),d=d.concat({name:"start_"+t,type:"USHORT",value:y.start}),u=u.concat({name:"idDelta_"+t,type:"SHORT",value:y.delta}),p=p.concat({name:"idRangeOffset_"+t,type:"USHORT",value:y.offset}),y.glyphId!==void 0&&(f=f.concat({name:"glyph_"+t,type:"USHORT",value:y.glyphId}))):l+=1,!e&&y.glyphIndex!==void 0&&(m=m.concat({name:"cmap12Start_"+t,type:"ULONG",value:y.start}),m=m.concat({name:"cmap12End_"+t,type:"ULONG",value:y.end}),m=m.concat({name:"cmap12Glyph_"+t,type:"ULONG",value:y.glyphIndex}))}if(s.segCountX2=(c-l)*2,s.searchRange=Math.pow(2,Math.floor(Math.log(c-l)/Math.log(2)))*2,s.entrySelector=Math.log(s.searchRange/2)/Math.log(2),s.rangeShift=s.segCountX2-s.searchRange,s.fields=s.fields.concat(h),s.fields.push({name:"reservedPad",type:"USHORT",value:0}),s.fields=s.fields.concat(d),s.fields=s.fields.concat(u),s.fields=s.fields.concat(p),s.fields=s.fields.concat(f),s.cmap4Length=14+h.length*2+2+d.length*2+u.length*2+p.length*2+f.length*2,!e){var v=16+m.length*4;s.cmap12Offset=12+2*2+4+s.cmap4Length,s.fields=s.fields.concat([{name:"cmap12Format",type:"USHORT",value:12},{name:"cmap12Reserved",type:"USHORT",value:0},{name:"cmap12Length",type:"ULONG",value:v},{name:"cmap12Language",type:"ULONG",value:0},{name:"cmap12nGroups",type:"ULONG",value:m.length/3}]),s.fields=s.fields.concat(m)}return s}var pi={parse:oa,make:la},Yt=[".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"],ha=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],ua=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],Ve=[".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 fi(n){this.font=n}fi.prototype.charToGlyphIndex=function(n){var e=n.codePointAt(0),t=this.font.glyphs;if(t){for(var r=0;r<t.length;r+=1)for(var i=t.get(r),s=0;s<i.unicodes.length;s+=1)if(i.unicodes[s]===e)return r}return null};function gi(n){this.cmap=n}gi.prototype.charToGlyphIndex=function(n){return this.cmap.glyphIndexMap[n.codePointAt(0)]||0};function $t(n,e){this.encoding=n,this.charset=e}$t.prototype.charToGlyphIndex=function(n){var e=n.codePointAt(0),t=this.encoding[e];return this.charset.indexOf(t)};function Un(n){switch(n.version){case 1:this.names=Ve.slice();break;case 2:this.names=new Array(n.numberOfGlyphs);for(var e=0;e<n.numberOfGlyphs;e++)n.glyphNameIndex[e]<Ve.length?this.names[e]=Ve[n.glyphNameIndex[e]]:this.names[e]=n.names[n.glyphNameIndex[e]-Ve.length];break;case 2.5:this.names=new Array(n.numberOfGlyphs);for(var t=0;t<n.numberOfGlyphs;t++)this.names[t]=Ve[t+n.glyphNameIndex[t]];break;case 3:this.names=[];break;default:this.names=[];break}}Un.prototype.nameToGlyphIndex=function(n){return this.names.indexOf(n)},Un.prototype.glyphIndexToName=function(n){return this.names[n]};function da(n){for(var e,t=n.tables.cmap.glyphIndexMap,r=Object.keys(t),i=0;i<r.length;i+=1){var s=r[i],o=t[s];e=n.glyphs.get(o),e.addUnicode(parseInt(s))}for(var a=0;a<n.glyphs.length;a+=1)e=n.glyphs.get(a),n.cffEncoding?n.isCIDFont?e.name="gid"+a:e.name=n.cffEncoding.charset[a]:n.glyphNames.names&&(e.name=n.glyphNames.glyphIndexToName(a))}function pa(n){n._IndexToUnicodeMap={};for(var e=n.tables.cmap.glyphIndexMap,t=Object.keys(e),r=0;r<t.length;r+=1){var i=t[r],s=e[i];n._IndexToUnicodeMap[s]===void 0?n._IndexToUnicodeMap[s]={unicodes:[parseInt(i)]}:n._IndexToUnicodeMap[s].unicodes.push(parseInt(i))}}function fa(n,e){e.lowMemory?pa(n):da(n)}function ga(n,e,t,r,i){n.beginPath(),n.moveTo(e,t),n.lineTo(r,i),n.stroke()}var He={line:ga};function ma(n,e){var t=e||new j;return{configurable:!0,get:function(){return typeof t=="function"&&(t=t()),t},set:function(r){t=r}}}function ae(n){this.bindConstructorValues(n)}ae.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",ma(this,n.path))},ae.prototype.addUnicode=function(n){this.unicodes.length===0&&(this.unicode=n),this.unicodes.push(n)},ae.prototype.getBoundingBox=function(){return this.path.getBoundingBox()},ae.prototype.getPath=function(n,e,t,r,i){n=n!==void 0?n:0,e=e!==void 0?e:0,t=t!==void 0?t:72;var s,o;r||(r={});var a=r.xScale,c=r.yScale;if(r.hinting&&i&&i.hinting&&(o=this.path&&i.hinting.exec(this,t)),o)s=i.hinting.getCommands(o),n=Math.round(n),e=Math.round(e),a=c=1;else{s=this.path.commands;var l=1/(this.path.unitsPerEm||1e3)*t;a===void 0&&(a=l),c===void 0&&(c=l)}for(var h=new j,d=0;d<s.length;d+=1){var u=s[d];u.type==="M"?h.moveTo(n+u.x*a,e+-u.y*c):u.type==="L"?h.lineTo(n+u.x*a,e+-u.y*c):u.type==="Q"?h.quadraticCurveTo(n+u.x1*a,e+-u.y1*c,n+u.x*a,e+-u.y*c):u.type==="C"?h.curveTo(n+u.x1*a,e+-u.y1*c,n+u.x2*a,e+-u.y2*c,n+u.x*a,e+-u.y*c):u.type==="Z"&&h.closePath()}return h},ae.prototype.getContours=function(){if(this.points===void 0)return[];for(var n=[],e=[],t=0;t<this.points.length;t+=1){var r=this.points[t];e.push(r),r.lastPointOfContour&&(n.push(e),e=[])}return O.argument(e.length===0,"There are still points left in the current contour."),n},ae.prototype.getMetrics=function(){for(var n=this.path.commands,e=[],t=[],r=0;r<n.length;r+=1){var i=n[r];i.type!=="Z"&&(e.push(i.x),t.push(i.y)),(i.type==="Q"||i.type==="C")&&(e.push(i.x1),t.push(i.y1)),i.type==="C"&&(e.push(i.x2),t.push(i.y2))}var s={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(s.xMin)||(s.xMin=0),isFinite(s.xMax)||(s.xMax=this.advanceWidth),isFinite(s.yMin)||(s.yMin=0),isFinite(s.yMax)||(s.yMax=0),s.rightSideBearing=this.advanceWidth-s.leftSideBearing-(s.xMax-s.xMin),s},ae.prototype.draw=function(n,e,t,r,i){this.getPath(e,t,r,i).draw(n)},ae.prototype.drawPoints=function(n,e,t,r){function i(d,u,p,f){n.beginPath();for(var m=0;m<d.length;m+=1)n.moveTo(u+d[m].x*f,p+d[m].y*f),n.arc(u+d[m].x*f,p+d[m].y*f,2,0,Math.PI*2,!1);n.closePath(),n.fill()}e=e!==void 0?e:0,t=t!==void 0?t:0,r=r!==void 0?r:24;for(var s=1/this.path.unitsPerEm*r,o=[],a=[],c=this.path,l=0;l<c.commands.length;l+=1){var h=c.commands[l];h.x!==void 0&&o.push({x:h.x,y:-h.y}),h.x1!==void 0&&a.push({x:h.x1,y:-h.y1}),h.x2!==void 0&&a.push({x:h.x2,y:-h.y2})}n.fillStyle="blue",i(o,e,t,s),n.fillStyle="red",i(a,e,t,s)},ae.prototype.drawMetrics=function(n,e,t,r){var i;e=e!==void 0?e:0,t=t!==void 0?t:0,r=r!==void 0?r:24,i=1/this.path.unitsPerEm*r,n.lineWidth=1,n.strokeStyle="black",He.line(n,e,-1e4,e,1e4),He.line(n,-1e4,t,1e4,t);var s=this.xMin||0,o=this.yMin||0,a=this.xMax||0,c=this.yMax||0,l=this.advanceWidth||0;n.strokeStyle="blue",He.line(n,e+s*i,-1e4,e+s*i,1e4),He.line(n,e+a*i,-1e4,e+a*i,1e4),He.line(n,-1e4,t+-o*i,1e4,t+-o*i),He.line(n,-1e4,t+-c*i,1e4,t+-c*i),n.strokeStyle="green",He.line(n,e+l*i,-1e4,e+l*i,1e4)};function Zt(n,e,t){Object.defineProperty(n,e,{get:function(){return n.path,n[t]},set:function(r){n[t]=r},enumerable:!0,configurable:!0})}function Fn(n,e){if(this.font=n,this.glyphs={},Array.isArray(e))for(var t=0;t<e.length;t++){var r=e[t];r.path.unitsPerEm=n.unitsPerEm,this.glyphs[t]=r}this.length=e&&e.length||0}Fn.prototype.get=function(n){if(this.glyphs[n]===void 0){this.font._push(n),typeof this.glyphs[n]=="function"&&(this.glyphs[n]=this.glyphs[n]());var e=this.glyphs[n],t=this.font._IndexToUnicodeMap[n];if(t)for(var r=0;r<t.unicodes.length;r++)e.addUnicode(t.unicodes[r]);this.font.cffEncoding?this.font.isCIDFont?e.name="gid"+n:e.name=this.font.cffEncoding.charset[n]:this.font.glyphNames.names&&(e.name=this.font.glyphNames.glyphIndexToName(n)),this.glyphs[n].advanceWidth=this.font._hmtxTableData[n].advanceWidth,this.glyphs[n].leftSideBearing=this.font._hmtxTableData[n].leftSideBearing}else typeof this.glyphs[n]=="function"&&(this.glyphs[n]=this.glyphs[n]());return this.glyphs[n]},Fn.prototype.push=function(n,e){this.glyphs[n]=e,this.length++};function ya(n,e){return new ae({index:e,font:n})}function va(n,e,t,r,i,s){return function(){var o=new ae({index:e,font:n});return o.path=function(){t(o,r,i);var a=s(n.glyphs,o);return a.unitsPerEm=n.unitsPerEm,a},Zt(o,"xMin","_xMin"),Zt(o,"xMax","_xMax"),Zt(o,"yMin","_yMin"),Zt(o,"yMax","_yMax"),o}}function ba(n,e,t,r){return function(){var i=new ae({index:e,font:n});return i.path=function(){var s=t(n,i,r);return s.unitsPerEm=n.unitsPerEm,s},i}}var be={GlyphSet:Fn,glyphLoader:ya,ttfGlyphLoader:va,cffGlyphLoader:ba};function mi(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(!mi(n[t],e[t]))return!1;return!0}else return!1}function Pn(n){var e;return n.length<1240?e=107:n.length<33900?e=1131:e=32768,e}function Oe(n,e,t){var r=[],i=[],s=L.getCard16(n,e),o,a;if(s!==0){var c=L.getByte(n,e+2);o=e+(s+1)*c+2;for(var l=e+3,h=0;h<s+1;h+=1)r.push(L.getOffset(n,l,c)),l+=c;a=o+r[s]}else a=e+2;for(var d=0;d<r.length-1;d+=1){var u=L.getBytes(n,o+r[d],o+r[d+1]);t&&(u=t(u)),i.push(u)}return{objects:i,startOffset:e,endOffset:a}}function xa(n,e){var t=[],r=L.getCard16(n,e),i,s;if(r!==0){var o=L.getByte(n,e+2);i=e+(r+1)*o+2;for(var a=e+3,c=0;c<r+1;c+=1)t.push(L.getOffset(n,a,o)),a+=o;s=i+t[r]}else s=e+2;return{offsets:t,startOffset:e,endOffset:s}}function Sa(n,e,t,r,i){var s=L.getCard16(t,r),o=0;if(s!==0){var a=L.getByte(t,r+2);o=r+(s+1)*a+2}var c=L.getBytes(t,o+e[n],o+e[n+1]);return c}function wa(n){for(var e="",t=15,r=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];;){var i=n.parseByte(),s=i>>4,o=i&15;if(s===t||(e+=r[s],o===t))break;e+=r[o]}return parseFloat(e)}function _a(n,e){var t,r,i,s;if(e===28)return t=n.parseByte(),r=n.parseByte(),t<<8|r;if(e===29)return t=n.parseByte(),r=n.parseByte(),i=n.parseByte(),s=n.parseByte(),t<<24|r<<16|i<<8|s;if(e===30)return wa(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 Ta(n){for(var e={},t=0;t<n.length;t+=1){var r=n[t][0],i=n[t][1],s=void 0;if(i.length===1?s=i[0]:s=i,e.hasOwnProperty(r)&&!isNaN(e[r]))throw new Error("Object "+e+" already has key "+r);e[r]=s}return e}function yi(n,e,t){e=e!==void 0?e:0;var r=new L.Parser(n,e),i=[],s=[];for(t=t!==void 0?t:n.length;r.relativeOffset<t;){var o=r.parseByte();o<=21?(o===12&&(o=1200+r.parseByte()),i.push([o,s]),s=[]):s.push(_a(r,o))}return Ta(i)}function yt(n,e){return e<=390?e=Yt[e]:e=n[e-391],e}function vi(n,e,t){for(var r={},i,s=0;s<e.length;s+=1){var o=e[s];if(Array.isArray(o.type)){var a=[];a.length=o.type.length;for(var c=0;c<o.type.length;c++)i=n[o.op]!==void 0?n[o.op][c]:void 0,i===void 0&&(i=o.value!==void 0&&o.value[c]!==void 0?o.value[c]:null),o.type[c]==="SID"&&(i=yt(t,i)),a[c]=i;r[o.name]=a}else i=n[o.op],i===void 0&&(i=o.value!==void 0?o.value:null),o.type==="SID"&&(i=yt(t,i)),r[o.name]=i}return r}function Ca(n,e){var t={};return t.formatMajor=L.getCard8(n,e),t.formatMinor=L.getCard8(n,e+1),t.size=L.getCard8(n,e+2),t.offsetSize=L.getCard8(n,e+3),t.startOffset=e,t.endOffset=e+4,t}var bi=[{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"}],xi=[{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 Ia(n,e){var t=yi(n,0,n.byteLength);return vi(t,bi,e)}function Si(n,e,t,r){var i=yi(n,e,t);return vi(i,xi,r)}function wi(n,e,t,r){for(var i=[],s=0;s<t.length;s+=1){var o=new DataView(new Uint8Array(t[s]).buffer),a=Ia(o,r);a._subrs=[],a._subrsBias=0,a._defaultWidthX=0,a._nominalWidthX=0;var c=a.private[0],l=a.private[1];if(c!==0&&l!==0){var h=Si(n,l+e,c,r);if(a._defaultWidthX=h.defaultWidthX,a._nominalWidthX=h.nominalWidthX,h.subrs!==0){var d=l+h.subrs,u=Oe(n,d+e);a._subrs=u.objects,a._subrsBias=Pn(a._subrs)}a._privateDict=h}i.push(a)}return i}function Aa(n,e,t,r){var i,s,o=new L.Parser(n,e);t-=1;var a=[".notdef"],c=o.parseCard8();if(c===0)for(var l=0;l<t;l+=1)i=o.parseSID(),a.push(yt(r,i));else if(c===1)for(;a.length<=t;){i=o.parseSID(),s=o.parseCard8();for(var h=0;h<=s;h+=1)a.push(yt(r,i)),i+=1}else if(c===2)for(;a.length<=t;){i=o.parseSID(),s=o.parseCard16();for(var d=0;d<=s;d+=1)a.push(yt(r,i)),i+=1}else throw new Error("Unknown charset format "+c);return a}function Ea(n,e,t){var r,i={},s=new L.Parser(n,e),o=s.parseCard8();if(o===0)for(var a=s.parseCard8(),c=0;c<a;c+=1)r=s.parseCard8(),i[r]=c;else if(o===1){var l=s.parseCard8();r=1;for(var h=0;h<l;h+=1)for(var d=s.parseCard8(),u=s.parseCard8(),p=d;p<=d+u;p+=1)i[p]=r,r+=1}else throw new Error("Unknown encoding format "+o);return new $t(i,t)}function _i(n,e,t){var r,i,s,o,a=new j,c=[],l=0,h=!1,d=!1,u=0,p=0,f,m,y,v;if(n.isCIDFont){var _=n.tables.cff.topDict._fdSelect[e.index],w=n.tables.cff.topDict._fdArray[_];f=w._subrs,m=w._subrsBias,y=w._defaultWidthX,v=w._nominalWidthX}else f=n.tables.cff.topDict._subrs,m=n.tables.cff.topDict._subrsBias,y=n.tables.cff.topDict._defaultWidthX,v=n.tables.cff.topDict._nominalWidthX;var C=y;function T(E,U){d&&a.closePath(),a.moveTo(E,U),d=!0}function D(){var E;E=c.length%2!==0,E&&!h&&(C=c.shift()+v),l+=c.length>>1,c.length=0,h=!0}function I(E){for(var U,V,J,te,$,P,H,N,X,Z,Y,K,F=0;F<E.length;){var Q=E[F];switch(F+=1,Q){case 1:D();break;case 3:D();break;case 4:c.length>1&&!h&&(C=c.shift()+v,h=!0),p+=c.pop(),T(u,p);break;case 5:for(;c.length>0;)u+=c.shift(),p+=c.shift(),a.lineTo(u,p);break;case 6:for(;c.length>0&&(u+=c.shift(),a.lineTo(u,p),c.length!==0);)p+=c.shift(),a.lineTo(u,p);break;case 7:for(;c.length>0&&(p+=c.shift(),a.lineTo(u,p),c.length!==0);)u+=c.shift(),a.lineTo(u,p);break;case 8:for(;c.length>0;)r=u+c.shift(),i=p+c.shift(),s=r+c.shift(),o=i+c.shift(),u=s+c.shift(),p=o+c.shift(),a.curveTo(r,i,s,o,u,p);break;case 10:$=c.pop()+m,P=f[$],P&&I(P);break;case 11:return;case 12:switch(Q=E[F],F+=1,Q){case 35:r=u+c.shift(),i=p+c.shift(),s=r+c.shift(),o=i+c.shift(),H=s+c.shift(),N=o+c.shift(),X=H+c.shift(),Z=N+c.shift(),Y=X+c.shift(),K=Z+c.shift(),u=Y+c.shift(),p=K+c.shift(),c.shift(),a.curveTo(r,i,s,o,H,N),a.curveTo(X,Z,Y,K,u,p);break;case 34:r=u+c.shift(),i=p,s=r+c.shift(),o=i+c.shift(),H=s+c.shift(),N=o,X=H+c.shift(),Z=o,Y=X+c.shift(),K=p,u=Y+c.shift(),a.curveTo(r,i,s,o,H,N),a.curveTo(X,Z,Y,K,u,p);break;case 36:r=u+c.shift(),i=p+c.shift(),s=r+c.shift(),o=i+c.shift(),H=s+c.shift(),N=o,X=H+c.shift(),Z=o,Y=X+c.shift(),K=Z+c.shift(),u=Y+c.shift(),a.curveTo(r,i,s,o,H,N),a.curveTo(X,Z,Y,K,u,p);break;case 37:r=u+c.shift(),i=p+c.shift(),s=r+c.shift(),o=i+c.shift(),H=s+c.shift(),N=o+c.shift(),X=H+c.shift(),Z=N+c.shift(),Y=X+c.shift(),K=Z+c.shift(),Math.abs(Y-u)>Math.abs(K-p)?u=Y+c.shift():p=K+c.shift(),a.curveTo(r,i,s,o,H,N),a.curveTo(X,Z,Y,K,u,p);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+Q),c.length=0}break;case 14:c.length>0&&!h&&(C=c.shift()+v,h=!0),d&&(a.closePath(),d=!1);break;case 18:D();break;case 19:case 20:D(),F+=l+7>>3;break;case 21:c.length>2&&!h&&(C=c.shift()+v,h=!0),p+=c.pop(),u+=c.pop(),T(u,p);break;case 22:c.length>1&&!h&&(C=c.shift()+v,h=!0),u+=c.pop(),T(u,p);break;case 23:D();break;case 24:for(;c.length>2;)r=u+c.shift(),i=p+c.shift(),s=r+c.shift(),o=i+c.shift(),u=s+c.shift(),p=o+c.shift(),a.curveTo(r,i,s,o,u,p);u+=c.shift(),p+=c.shift(),a.lineTo(u,p);break;case 25:for(;c.length>6;)u+=c.shift(),p+=c.shift(),a.lineTo(u,p);r=u+c.shift(),i=p+c.shift(),s=r+c.shift(),o=i+c.shift(),u=s+c.shift(),p=o+c.shift(),a.curveTo(r,i,s,o,u,p);break;case 26:for(c.length%2&&(u+=c.shift());c.length>0;)r=u,i=p+c.shift(),s=r+c.shift(),o=i+c.shift(),u=s,p=o+c.shift(),a.curveTo(r,i,s,o,u,p);break;case 27:for(c.length%2&&(p+=c.shift());c.length>0;)r=u+c.shift(),i=p,s=r+c.shift(),o=i+c.shift(),u=s+c.shift(),p=o,a.curveTo(r,i,s,o,u,p);break;case 28:U=E[F],V=E[F+1],c.push((U<<24|V<<16)>>16),F+=2;break;case 29:$=c.pop()+n.gsubrsBias,P=n.gsubrs[$],P&&I(P);break;case 30:for(;c.length>0&&(r=u,i=p+c.shift(),s=r+c.shift(),o=i+c.shift(),u=s+c.shift(),p=o+(c.length===1?c.shift():0),a.curveTo(r,i,s,o,u,p),c.length!==0);)r=u+c.shift(),i=p,s=r+c.shift(),o=i+c.shift(),p=o+c.shift(),u=s+(c.length===1?c.shift():0),a.curveTo(r,i,s,o,u,p);break;case 31:for(;c.length>0&&(r=u+c.shift(),i=p,s=r+c.shift(),o=i+c.shift(),p=o+c.shift(),u=s+(c.length===1?c.shift():0),a.curveTo(r,i,s,o,u,p),c.length!==0);)r=u,i=p+c.shift(),s=r+c.shift(),o=i+c.shift(),u=s+c.shift(),p=o+(c.length===1?c.shift():0),a.curveTo(r,i,s,o,u,p);break;default:Q<32?console.log("Glyph "+e.index+": unknown operator "+Q):Q<247?c.push(Q-139):Q<251?(U=E[F],F+=1,c.push((Q-247)*256+U+108)):Q<255?(U=E[F],F+=1,c.push(-(Q-251)*256-U-108)):(U=E[F],V=E[F+1],J=E[F+2],te=E[F+3],F+=4,c.push((U<<24|V<<16|J<<8|te)/65536))}}}return I(t),e.advanceWidth=C,a}function ka(n,e,t,r){var i=[],s,o=new L.Parser(n,e),a=o.parseCard8();if(a===0)for(var c=0;c<t;c++){if(s=o.parseCard8(),s>=r)throw new Error("CFF table CID Font FDSelect has bad FD index value "+s+" (FD count "+r+")");i.push(s)}else if(a===3){var l=o.parseCard16(),h=o.parseCard16();if(h!==0)throw new Error("CFF Table CID Font FDSelect format 3 range has bad initial GID "+h);for(var d,u=0;u<l;u++){if(s=o.parseCard8(),d=o.parseCard16(),s>=r)throw new Error("CFF table CID Font FDSelect has bad FD index value "+s+" (FD count "+r+")");if(d>t)throw new Error("CFF Table CID Font FDSelect format 3 range has bad GID "+d);for(;h<d;h++)i.push(s);h=d}if(d!==t)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final GID "+d)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+a);return i}function Ba(n,e,t,r){t.tables.cff={};var i=Ca(n,e),s=Oe(n,i.endOffset,L.bytesToString),o=Oe(n,s.endOffset),a=Oe(n,o.endOffset,L.bytesToString),c=Oe(n,a.endOffset);t.gsubrs=c.objects,t.gsubrsBias=Pn(t.gsubrs);var l=wi(n,e,o.objects,a.objects);if(l.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+l.length);var h=l[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 d=h.fdArray,u=h.fdSelect;if(d===0||u===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");d+=e;var p=Oe(n,d),f=wi(n,e,p.objects,a.objects);h._fdArray=f,u+=e,h._fdSelect=ka(n,u,t.numGlyphs,f.length)}var m=e+h.private[1],y=Si(n,m,h.private[0],a.objects);if(t.defaultWidthX=y.defaultWidthX,t.nominalWidthX=y.nominalWidthX,y.subrs!==0){var v=m+y.subrs,_=Oe(n,v);t.subrs=_.objects,t.subrsBias=Pn(t.subrs)}else t.subrs=[],t.subrsBias=0;var w;r.lowMemory?(w=xa(n,e+h.charStrings),t.nGlyphs=w.offsets.length):(w=Oe(n,e+h.charStrings),t.nGlyphs=w.objects.length);var C=Aa(n,e+h.charset,t.nGlyphs,a.objects);if(h.encoding===0?t.cffEncoding=new $t(ha,C):h.encoding===1?t.cffEncoding=new $t(ua,C):t.cffEncoding=Ea(n,e+h.encoding,C),t.encoding=t.encoding||t.cffEncoding,t.glyphs=new be.GlyphSet(t),r.lowMemory)t._push=function(I){var E=Sa(I,w.offsets,n,e+h.charStrings);t.glyphs.push(I,be.cffGlyphLoader(t,I,_i,E))};else for(var T=0;T<t.nGlyphs;T+=1){var D=w.objects[T];t.glyphs.push(T,be.cffGlyphLoader(t,T,_i,D))}}function Ti(n,e){var t,r=Yt.indexOf(n);return r>=0&&(t=r),r=e.indexOf(n),r>=0?t=r+Yt.length:(t=Yt.length+e.length,e.push(n)),t}function La(){return new k.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 Oa(n){var e=new k.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 Ci(n,e,t){for(var r={},i=0;i<n.length;i+=1){var s=n[i],o=e[s.name];o!==void 0&&!mi(o,s.value)&&(s.type==="SID"&&(o=Ti(o,t)),r[s.op]={name:s.name,type:s.type,value:o})}return r}function Ii(n,e){var t=new k.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return t.dict=Ci(bi,n,e),t}function Ai(n){var e=new k.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return e.topDicts=[{name:"topDict_0",type:"TABLE",value:n}],e}function Ma(n){var e=new k.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 Da(){return new k.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function Ra(n,e){for(var t=new k.Record("Charsets",[{name:"format",type:"Card8",value:0}]),r=0;r<n.length;r+=1){var i=n[r],s=Ti(i,e);t.fields.push({name:"glyph_"+r,type:"SID",value:s})}return t}function Ua(n){var e=[],t=n.path;e.push({name:"width",type:"NUMBER",value:n.advanceWidth});for(var r=0,i=0,s=0;s<t.commands.length;s+=1){var o=void 0,a=void 0,c=t.commands[s];if(c.type==="Q"){var l=.3333333333333333,h=2/3;c={type:"C",x:c.x,y:c.y,x1:Math.round(l*r+h*c.x1),y1:Math.round(l*i+h*c.y1),x2:Math.round(l*c.x+h*c.x1),y2:Math.round(l*c.y+h*c.y1)}}if(c.type==="M")o=Math.round(c.x-r),a=Math.round(c.y-i),e.push({name:"dx",type:"NUMBER",value:o}),e.push({name:"dy",type:"NUMBER",value:a}),e.push({name:"rmoveto",type:"OP",value:21}),r=Math.round(c.x),i=Math.round(c.y);else if(c.type==="L")o=Math.round(c.x-r),a=Math.round(c.y-i),e.push({name:"dx",type:"NUMBER",value:o}),e.push({name:"dy",type:"NUMBER",value:a}),e.push({name:"rlineto",type:"OP",value:5}),r=Math.round(c.x),i=Math.round(c.y);else if(c.type==="C"){var d=Math.round(c.x1-r),u=Math.round(c.y1-i),p=Math.round(c.x2-c.x1),f=Math.round(c.y2-c.y1);o=Math.round(c.x-c.x2),a=Math.round(c.y-c.y2),e.push({name:"dx1",type:"NUMBER",value:d}),e.push({name:"dy1",type:"NUMBER",value:u}),e.push({name:"dx2",type:"NUMBER",value:p}),e.push({name:"dy2",type:"NUMBER",value:f}),e.push({name:"dx",type:"NUMBER",value:o}),e.push({name:"dy",type:"NUMBER",value:a}),e.push({name:"rrcurveto",type:"OP",value:8}),r=Math.round(c.x),i=Math.round(c.y)}}return e.push({name:"endchar",type:"OP",value:14}),e}function Fa(n){for(var e=new k.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]),t=0;t<n.length;t+=1){var r=n.get(t),i=Ua(r);e.charStrings.push({name:r.name,type:"CHARSTRING",value:i})}return e}function Pa(n,e){var t=new k.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return t.dict=Ci(xi,n,e),t}function Ga(n,e){for(var t=new k.Table("CFF ",[{name:"header",type:"RECORD"},{name:"nameIndex",type:"RECORD"},{name:"topDictIndex",type:"RECORD"},{name:"stringIndex",type:"RECORD"},{name:"globalSubrIndex",type:"RECORD"},{name:"charsets",type:"RECORD"},{name:"charStringsIndex",type:"RECORD"},{name:"privateDict",type:"RECORD"}]),r=1/e.unitsPerEm,i={version:e.version,fullName:e.fullName,familyName:e.familyName,weight:e.weightName,fontBBox:e.fontBBox||[0,0,0,0],fontMatrix:[r,0,0,r,0,0],charset:999,encoding:0,charStrings:999,private:[0,999]},s={},o=[],a,c=1;c<n.length;c+=1)a=n.get(c),o.push(a.name);var l=[];t.header=La(),t.nameIndex=Oa([e.postScriptName]);var h=Ii(i,l);t.topDictIndex=Ai(h),t.globalSubrIndex=Da(),t.charsets=Ra(o,l),t.charStringsIndex=Fa(n),t.privateDict=Pa(s,l),t.stringIndex=Ma(l);var d=t.header.sizeOf()+t.nameIndex.sizeOf()+t.topDictIndex.sizeOf()+t.stringIndex.sizeOf()+t.globalSubrIndex.sizeOf();return i.charset=d,i.encoding=0,i.charStrings=i.charset+t.charsets.sizeOf(),i.private[1]=i.charStrings+t.charStringsIndex.sizeOf(),h=Ii(i,l),t.topDictIndex=Ai(h),t}var Ei={parse:Ba,make:Ga};function Na(n,e){var t={},r=new L.Parser(n,e);return t.version=r.parseVersion(),t.fontRevision=Math.round(r.parseFixed()*1e3)/1e3,t.checkSumAdjustment=r.parseULong(),t.magicNumber=r.parseULong(),O.argument(t.magicNumber===1594834165,"Font header has wrong magic number."),t.flags=r.parseUShort(),t.unitsPerEm=r.parseUShort(),t.created=r.parseLongDateTime(),t.modified=r.parseLongDateTime(),t.xMin=r.parseShort(),t.yMin=r.parseShort(),t.xMax=r.parseShort(),t.yMax=r.parseShort(),t.macStyle=r.parseUShort(),t.lowestRecPPEM=r.parseUShort(),t.fontDirectionHint=r.parseShort(),t.indexToLocFormat=r.parseShort(),t.glyphDataFormat=r.parseShort(),t}function za(n){var e=Math.round(new Date().getTime()/1e3)+2082844800,t=e;return n.createdTimestamp&&(t=n.createdTimestamp+2082844800),new k.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 ki={parse:Na,make:za};function Va(n,e){var t={},r=new L.Parser(n,e);return t.version=r.parseVersion(),t.ascender=r.parseShort(),t.descender=r.parseShort(),t.lineGap=r.parseShort(),t.advanceWidthMax=r.parseUShort(),t.minLeftSideBearing=r.parseShort(),t.minRightSideBearing=r.parseShort(),t.xMaxExtent=r.parseShort(),t.caretSlopeRise=r.parseShort(),t.caretSlopeRun=r.parseShort(),t.caretOffset=r.parseShort(),r.relativeOffset+=8,t.metricDataFormat=r.parseShort(),t.numberOfHMetrics=r.parseUShort(),t}function Ha(n){return new k.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 Bi={parse:Va,make:Ha};function ja(n,e,t,r,i){for(var s,o,a=new L.Parser(n,e),c=0;c<r;c+=1){c<t&&(s=a.parseUShort(),o=a.parseShort());var l=i.get(c);l.advanceWidth=s,l.leftSideBearing=o}}function Wa(n,e,t,r,i){n._hmtxTableData={};for(var s,o,a=new L.Parser(e,t),c=0;c<i;c+=1)c<r&&(s=a.parseUShort(),o=a.parseShort()),n._hmtxTableData[c]={advanceWidth:s,leftSideBearing:o}}function Xa(n,e,t,r,i,s,o){o.lowMemory?Wa(n,e,t,r,i):ja(e,t,r,i,s)}function qa(n){for(var e=new k.Table("hmtx",[]),t=0;t<n.length;t+=1){var r=n.get(t),i=r.advanceWidth||0,s=r.leftSideBearing||0;e.fields.push({name:"advanceWidth_"+t,type:"USHORT",value:i}),e.fields.push({name:"leftSideBearing_"+t,type:"SHORT",value:s})}return e}var Li={parse:Xa,make:qa};function Ya(n){for(var e=new k.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:n.length}]),t="",r=12+n.length*4,i=0;i<n.length;++i){var s=t.indexOf(n[i]);s<0&&(s=t.length,t+=n[i]),e.fields.push({name:"offset "+i,type:"USHORT",value:r+s}),e.fields.push({name:"length "+i,type:"USHORT",value:n[i].length})}return e.fields.push({name:"stringPool",type:"CHARARRAY",value:t}),e}function $a(n,e){var t=new L.Parser(n,e),r=t.parseULong();O.argument(r===1,"Unsupported ltag table version."),t.skip("uLong",1);for(var i=t.parseULong(),s=[],o=0;o<i;o++){for(var a="",c=e+t.parseUShort(),l=t.parseUShort(),h=c;h<c+l;++h)a+=String.fromCharCode(n.getInt8(h));s.push(a)}return s}var Oi={make:Ya,parse:$a};function Za(n,e){var t={},r=new L.Parser(n,e);return t.version=r.parseVersion(),t.numGlyphs=r.parseUShort(),t.version===1&&(t.maxPoints=r.parseUShort(),t.maxContours=r.parseUShort(),t.maxCompositePoints=r.parseUShort(),t.maxCompositeContours=r.parseUShort(),t.maxZones=r.parseUShort(),t.maxTwilightPoints=r.parseUShort(),t.maxStorage=r.parseUShort(),t.maxFunctionDefs=r.parseUShort(),t.maxInstructionDefs=r.parseUShort(),t.maxStackElements=r.parseUShort(),t.maxSizeOfInstructions=r.parseUShort(),t.maxComponentElements=r.parseUShort(),t.maxComponentDepth=r.parseUShort()),t}function Qa(n){return new k.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:n}])}var Mi={parse:Za,make:Qa},Di=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],Ri={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"},Ja={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},Ui={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 Ka(n,e,t){switch(n){case 0:if(e===65535)return"und";if(t)return t[e];break;case 1:return Ri[e];case 3:return Ui[e]}}var Gn="utf-16",ec={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"},tc={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 Fi(n,e,t){switch(n){case 0:return Gn;case 1:return tc[t]||ec[e];case 3:if(e===1||e===10)return Gn;break}}function nc(n,e,t){for(var r={},i=new L.Parser(n,e),s=i.parseUShort(),o=i.parseUShort(),a=i.offset+i.parseUShort(),c=0;c<o;c++){var l=i.parseUShort(),h=i.parseUShort(),d=i.parseUShort(),u=i.parseUShort(),p=Di[u]||u,f=i.parseUShort(),m=i.parseUShort(),y=Ka(l,d,t),v=Fi(l,h,d);if(v!==void 0&&y!==void 0){var _=void 0;if(v===Gn?_=Qe.UTF16(n,a+m,f):_=Qe.MACSTRING(n,a+m,f,v),_){var w=r[p];w===void 0&&(w=r[p]={}),w[y]=_}}}return s===1&&i.parseUShort(),r}function Nn(n){var e={};for(var t in n)e[n[t]]=parseInt(t);return e}function Pi(n,e,t,r,i,s){return new k.Record("NameRecord",[{name:"platformID",type:"USHORT",value:n},{name:"encodingID",type:"USHORT",value:e},{name:"languageID",type:"USHORT",value:t},{name:"nameID",type:"USHORT",value:r},{name:"length",type:"USHORT",value:i},{name:"offset",type:"USHORT",value:s}])}function rc(n,e){var t=n.length,r=e.length-t+1;e:for(var i=0;i<r;i++)for(;i<r;i++){for(var s=0;s<t;s++)if(e[i+s]!==n[s])continue e;return i}return-1}function Gi(n,e){var t=rc(n,e);if(t<0){t=e.length;for(var r=0,i=n.length;r<i;++r)e.push(n[r])}return t}function ic(n,e){var t,r=[],i={},s=Nn(Di);for(var o in n){var a=s[o];if(a===void 0&&(a=o),t=parseInt(a),isNaN(t))throw new Error('Name table entry "'+o+'" does not exist, see nameTableNames for complete list.');i[t]=n[o],r.push(t)}for(var c=Nn(Ri),l=Nn(Ui),h=[],d=[],u=0;u<r.length;u++){t=r[u];var p=i[t];for(var f in p){var m=p[f],y=1,v=c[f],_=Ja[v],w=Fi(y,_,v),C=A.MACSTRING(m,w);C===void 0&&(y=0,v=e.indexOf(f),v<0&&(v=e.length,e.push(f)),_=4,C=A.UTF16(m));var T=Gi(C,d);h.push(Pi(y,_,v,t,C.length,T));var D=l[f];if(D!==void 0){var I=A.UTF16(m),E=Gi(I,d);h.push(Pi(3,1,D,t,I.length,E))}}}h.sort(function(J,te){return J.platformID-te.platformID||J.encodingID-te.encodingID||J.languageID-te.languageID||J.nameID-te.nameID});for(var U=new k.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:h.length},{name:"stringOffset",type:"USHORT",value:6+h.length*12}]),V=0;V<h.length;V++)U.fields.push({name:"record_"+V,type:"RECORD",value:h[V]});return U.fields.push({name:"strings",type:"LITERAL",value:d}),U}var Ni={parse:nc,make:ic},zn=[{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 sc(n){for(var e=0;e<zn.length;e+=1){var t=zn[e];if(n>=t.begin&&n<t.end)return e}return-1}function oc(n,e){var t={},r=new L.Parser(n,e);t.version=r.parseUShort(),t.xAvgCharWidth=r.parseShort(),t.usWeightClass=r.parseUShort(),t.usWidthClass=r.parseUShort(),t.fsType=r.parseUShort(),t.ySubscriptXSize=r.parseShort(),t.ySubscriptYSize=r.parseShort(),t.ySubscriptXOffset=r.parseShort(),t.ySubscriptYOffset=r.parseShort(),t.ySuperscriptXSize=r.parseShort(),t.ySuperscriptYSize=r.parseShort(),t.ySuperscriptXOffset=r.parseShort(),t.ySuperscriptYOffset=r.parseShort(),t.yStrikeoutSize=r.parseShort(),t.yStrikeoutPosition=r.parseShort(),t.sFamilyClass=r.parseShort(),t.panose=[];for(var i=0;i<10;i++)t.panose[i]=r.parseByte();return t.ulUnicodeRange1=r.parseULong(),t.ulUnicodeRange2=r.parseULong(),t.ulUnicodeRange3=r.parseULong(),t.ulUnicodeRange4=r.parseULong(),t.achVendID=String.fromCharCode(r.parseByte(),r.parseByte(),r.parseByte(),r.parseByte()),t.fsSelection=r.parseUShort(),t.usFirstCharIndex=r.parseUShort(),t.usLastCharIndex=r.parseUShort(),t.sTypoAscender=r.parseShort(),t.sTypoDescender=r.parseShort(),t.sTypoLineGap=r.parseShort(),t.usWinAscent=r.parseUShort(),t.usWinDescent=r.parseUShort(),t.version>=1&&(t.ulCodePageRange1=r.parseULong(),t.ulCodePageRange2=r.parseULong()),t.version>=2&&(t.sxHeight=r.parseShort(),t.sCapHeight=r.parseShort(),t.usDefaultChar=r.parseUShort(),t.usBreakChar=r.parseUShort(),t.usMaxContent=r.parseUShort()),t}function ac(n){return new k.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 Vn={parse:oc,make:ac,unicodeRanges:zn,getUnicodeRange:sc};function cc(n,e){var t={},r=new L.Parser(n,e);switch(t.version=r.parseVersion(),t.italicAngle=r.parseFixed(),t.underlinePosition=r.parseShort(),t.underlineThickness=r.parseShort(),t.isFixedPitch=r.parseULong(),t.minMemType42=r.parseULong(),t.maxMemType42=r.parseULong(),t.minMemType1=r.parseULong(),t.maxMemType1=r.parseULong(),t.version){case 1:t.names=Ve.slice();break;case 2:t.numberOfGlyphs=r.parseUShort(),t.glyphNameIndex=new Array(t.numberOfGlyphs);for(var i=0;i<t.numberOfGlyphs;i++)t.glyphNameIndex[i]=r.parseUShort();t.names=[];for(var s=0;s<t.numberOfGlyphs;s++)if(t.glyphNameIndex[s]>=Ve.length){var o=r.parseChar();t.names.push(r.parseString(o))}break;case 2.5:t.numberOfGlyphs=r.parseUShort(),t.offset=new Array(t.numberOfGlyphs);for(var a=0;a<t.numberOfGlyphs;a++)t.offset[a]=r.parseChar();break}return t}function lc(){return new k.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 zi={parse:cc,make:lc},he=new Array(9);he[1]=function(){var n=this.offset+this.relativeOffset,e=this.parseUShort();if(e===1)return{substFormat:1,coverage:this.parsePointer(x.coverage),deltaGlyphId:this.parseUShort()};if(e===2)return{substFormat:2,coverage:this.parsePointer(x.coverage),substitute:this.parseOffset16List()};O.assert(!1,"0x"+n.toString(16)+": lookup type 1 format must be 1 or 2.")},he[2]=function(){var n=this.parseUShort();return O.argument(n===1,"GSUB Multiple Substitution Subtable identifier-format must be 1"),{substFormat:n,coverage:this.parsePointer(x.coverage),sequences:this.parseListOfLists()}},he[3]=function(){var n=this.parseUShort();return O.argument(n===1,"GSUB Alternate Substitution Subtable identifier-format must be 1"),{substFormat:n,coverage:this.parsePointer(x.coverage),alternateSets:this.parseListOfLists()}},he[4]=function(){var n=this.parseUShort();return O.argument(n===1,"GSUB ligature table identifier-format must be 1"),{substFormat:n,coverage:this.parsePointer(x.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};var Je={sequenceIndex:x.uShort,lookupListIndex:x.uShort};he[5]=function(){var n=this.offset+this.relativeOffset,e=this.parseUShort();if(e===1)return{substFormat:e,coverage:this.parsePointer(x.coverage),ruleSets:this.parseListOfLists(function(){var i=this.parseUShort(),s=this.parseUShort();return{input:this.parseUShortList(i-1),lookupRecords:this.parseRecordList(s,Je)}})};if(e===2)return{substFormat:e,coverage:this.parsePointer(x.coverage),classDef:this.parsePointer(x.classDef),classSets:this.parseListOfLists(function(){var i=this.parseUShort(),s=this.parseUShort();return{classes:this.parseUShortList(i-1),lookupRecords:this.parseRecordList(s,Je)}})};if(e===3){var t=this.parseUShort(),r=this.parseUShort();return{substFormat:e,coverages:this.parseList(t,x.pointer(x.coverage)),lookupRecords:this.parseRecordList(r,Je)}}O.assert(!1,"0x"+n.toString(16)+": lookup type 5 format must be 1, 2 or 3.")},he[6]=function(){var n=this.offset+this.relativeOffset,e=this.parseUShort();if(e===1)return{substFormat:1,coverage:this.parsePointer(x.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Je)}})};if(e===2)return{substFormat:2,coverage:this.parsePointer(x.coverage),backtrackClassDef:this.parsePointer(x.classDef),inputClassDef:this.parsePointer(x.classDef),lookaheadClassDef:this.parsePointer(x.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Je)}})};if(e===3)return{substFormat:3,backtrackCoverage:this.parseList(x.pointer(x.coverage)),inputCoverage:this.parseList(x.pointer(x.coverage)),lookaheadCoverage:this.parseList(x.pointer(x.coverage)),lookupRecords:this.parseRecordList(Je)};O.assert(!1,"0x"+n.toString(16)+": lookup type 6 format must be 1, 2 or 3.")},he[7]=function(){var n=this.parseUShort();O.argument(n===1,"GSUB Extension Substitution subtable identifier-format must be 1");var e=this.parseUShort(),t=new x(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:e,extension:he[e].call(t)}},he[8]=function(){var n=this.parseUShort();return O.argument(n===1,"GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1"),{substFormat:n,coverage:this.parsePointer(x.coverage),backtrackCoverage:this.parseList(x.pointer(x.coverage)),lookaheadCoverage:this.parseList(x.pointer(x.coverage)),substitutes:this.parseUShortList()}};function hc(n,e){e=e||0;var t=new x(n,e),r=t.parseVersion(1);return O.argument(r===1||r===1.1,"Unsupported GSUB table version."),r===1?{version:r,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(he)}:{version:r,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(he),variations:t.parseFeatureVariationsList()}}var Ke=new Array(9);Ke[1]=function(n){return n.substFormat===1?new k.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new k.Coverage(n.coverage)},{name:"deltaGlyphID",type:"USHORT",value:n.deltaGlyphId}]):new k.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new k.Coverage(n.coverage)}].concat(k.ushortList("substitute",n.substitute)))},Ke[2]=function(n){return O.assert(n.substFormat===1,"Lookup type 2 substFormat must be 1."),new k.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new k.Coverage(n.coverage)}].concat(k.tableList("seqSet",n.sequences,function(e){return new k.Table("sequenceSetTable",k.ushortList("sequence",e))})))},Ke[3]=function(n){return O.assert(n.substFormat===1,"Lookup type 3 substFormat must be 1."),new k.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new k.Coverage(n.coverage)}].concat(k.tableList("altSet",n.alternateSets,function(e){return new k.Table("alternateSetTable",k.ushortList("alternate",e))})))},Ke[4]=function(n){return O.assert(n.substFormat===1,"Lookup type 4 substFormat must be 1."),new k.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new k.Coverage(n.coverage)}].concat(k.tableList("ligSet",n.ligatureSets,function(e){return new k.Table("ligatureSetTable",k.tableList("ligature",e,function(t){return new k.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:t.ligGlyph}].concat(k.ushortList("component",t.components,t.components.length+1)))}))})))},Ke[6]=function(n){if(n.substFormat===1){var e=new k.Table("chainContextTable",[{name:"substFormat",type:"USHORT",value:n.substFormat},{name:"coverage",type:"TABLE",value:new k.Coverage(n.coverage)}].concat(k.tableList("chainRuleSet",n.chainRuleSets,function(i){return new k.Table("chainRuleSetTable",k.tableList("chainRule",i,function(s){var o=k.ushortList("backtrackGlyph",s.backtrack,s.backtrack.length).concat(k.ushortList("inputGlyph",s.input,s.input.length+1)).concat(k.ushortList("lookaheadGlyph",s.lookahead,s.lookahead.length)).concat(k.ushortList("substitution",[],s.lookupRecords.length));return s.lookupRecords.forEach(function(a,c){o=o.concat({name:"sequenceIndex"+c,type:"USHORT",value:a.sequenceIndex}).concat({name:"lookupListIndex"+c,type:"USHORT",value:a.lookupListIndex})}),new k.Table("chainRuleTable",o)}))})));return e}else if(n.substFormat===2)O.assert(!1,"lookup type 6 format 2 is not yet supported.");else if(n.substFormat===3){var t=[{name:"substFormat",type:"USHORT",value:n.substFormat}];t.push({name:"backtrackGlyphCount",type:"USHORT",value:n.backtrackCoverage.length}),n.backtrackCoverage.forEach(function(i,s){t.push({name:"backtrackCoverage"+s,type:"TABLE",value:new k.Coverage(i)})}),t.push({name:"inputGlyphCount",type:"USHORT",value:n.inputCoverage.length}),n.inputCoverage.forEach(function(i,s){t.push({name:"inputCoverage"+s,type:"TABLE",value:new k.Coverage(i)})}),t.push({name:"lookaheadGlyphCount",type:"USHORT",value:n.lookaheadCoverage.length}),n.lookaheadCoverage.forEach(function(i,s){t.push({name:"lookaheadCoverage"+s,type:"TABLE",value:new k.Coverage(i)})}),t.push({name:"substitutionCount",type:"USHORT",value:n.lookupRecords.length}),n.lookupRecords.forEach(function(i,s){t=t.concat({name:"sequenceIndex"+s,type:"USHORT",value:i.sequenceIndex}).concat({name:"lookupListIndex"+s,type:"USHORT",value:i.lookupListIndex})});var r=new k.Table("chainContextTable",t);return r}O.assert(!1,"lookup type 6 format must be 1, 2 or 3.")};function uc(n){return new k.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new k.ScriptList(n.scripts)},{name:"features",type:"TABLE",value:new k.FeatureList(n.features)},{name:"lookups",type:"TABLE",value:new k.LookupList(n.lookups,Ke)}])}var Vi={parse:hc,make:uc};function dc(n,e){var t=new L.Parser(n,e),r=t.parseULong();O.argument(r===1,"Unsupported META table version."),t.parseULong(),t.parseULong();for(var i=t.parseULong(),s={},o=0;o<i;o++){var a=t.parseTag(),c=t.parseULong(),l=t.parseULong(),h=Qe.UTF8(n,e+c,l);s[a]=h}return s}function pc(n){var e=Object.keys(n).length,t="",r=16+e*12,i=new k.Table("meta",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"offset",type:"ULONG",value:r},{name:"numTags",type:"ULONG",value:e}]);for(var s in n){var o=t.length;t+=n[s],i.fields.push({name:"tag "+s,type:"TAG",value:s}),i.fields.push({name:"offset "+s,type:"ULONG",value:r+o}),i.fields.push({name:"length "+s,type:"ULONG",value:n[s].length})}return i.fields.push({name:"stringPool",type:"CHARARRAY",value:t}),i}var Hi={parse:dc,make:pc};function ji(n){return Math.log(n)/Math.log(2)|0}function Hn(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 Wi(n,e,t,r){return new k.Record("Table Record",[{name:"tag",type:"TAG",value:n!==void 0?n:""},{name:"checkSum",type:"ULONG",value:e!==void 0?e:0},{name:"offset",type:"ULONG",value:t!==void 0?t:0},{name:"length",type:"ULONG",value:r!==void 0?r:0}])}function Xi(n){var e=new k.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,ji(e.numTables));e.searchRange=16*t,e.entrySelector=ji(t),e.rangeShift=e.numTables*16-e.searchRange;for(var r=[],i=[],s=e.sizeOf()+Wi().sizeOf()*e.numTables;s%4!==0;)s+=1,i.push({name:"padding",type:"BYTE",value:0});for(var o=0;o<n.length;o+=1){var a=n[o];O.argument(a.tableName.length===4,"Table name"+a.tableName+" is invalid.");var c=a.sizeOf(),l=Wi(a.tableName,Hn(a.encode()),s,c);for(r.push({name:l.tag+" Table Record",type:"RECORD",value:l}),i.push({name:a.tableName+" table",type:"RECORD",value:a}),s+=c,O.argument(!isNaN(s),"Something went wrong calculating the offset.");s%4!==0;)s+=1,i.push({name:"padding",type:"BYTE",value:0})}return r.sort(function(h,d){return h.value.tag>d.value.tag?1:-1}),e.fields=e.fields.concat(r),e.fields=e.fields.concat(i),e}function qi(n,e,t){for(var r=0;r<e.length;r+=1){var i=n.charToGlyphIndex(e[r]);if(i>0){var s=n.glyphs.get(i);return s.getMetrics()}}return t}function fc(n){for(var e=0,t=0;t<n.length;t+=1)e+=n[t];return e/n.length}function gc(n){for(var e=[],t=[],r=[],i=[],s=[],o=[],a=[],c,l=0,h=0,d=0,u=0,p=0,f=0;f<n.glyphs.length;f+=1){var m=n.glyphs.get(f),y=m.unicode|0;if(isNaN(m.advanceWidth))throw new Error("Glyph "+m.name+" ("+f+"): advanceWidth is not a number.");(c>y||c===void 0)&&y>0&&(c=y),l<y&&(l=y);var v=Vn.getUnicodeRange(y);if(v<32)h|=1<<v;else if(v<64)d|=1<<v-32;else if(v<96)u|=1<<v-64;else if(v<123)p|=1<<v-96;else throw new Error("Unicode ranges bits > 123 are reserved for internal usage");if(m.name!==".notdef"){var _=m.getMetrics();e.push(_.xMin),t.push(_.yMin),r.push(_.xMax),i.push(_.yMax),o.push(_.leftSideBearing),a.push(_.rightSideBearing),s.push(m.advanceWidth)}}var w={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,t),xMax:Math.max.apply(null,r),yMax:Math.max.apply(null,i),advanceWidthMax:Math.max.apply(null,s),advanceWidthAvg:fc(s),minLeftSideBearing:Math.min.apply(null,o),maxLeftSideBearing:Math.max.apply(null,o),minRightSideBearing:Math.min.apply(null,a)};w.ascender=n.ascender,w.descender=n.descender;var C=ki.make({flags:3,unitsPerEm:n.unitsPerEm,xMin:w.xMin,yMin:w.yMin,xMax:w.xMax,yMax:w.yMax,lowestRecPPEM:3,createdTimestamp:n.createdTimestamp}),T=Bi.make({ascender:w.ascender,descender:w.descender,advanceWidthMax:w.advanceWidthMax,minLeftSideBearing:w.minLeftSideBearing,minRightSideBearing:w.minRightSideBearing,xMaxExtent:w.maxLeftSideBearing+(w.xMax-w.xMin),numberOfHMetrics:n.glyphs.length}),D=Mi.make(n.glyphs.length),I=Vn.make(Object.assign({xAvgCharWidth:Math.round(w.advanceWidthAvg),usFirstCharIndex:c,usLastCharIndex:l,ulUnicodeRange1:h,ulUnicodeRange2:d,ulUnicodeRange3:u,ulUnicodeRange4:p,sTypoAscender:w.ascender,sTypoDescender:w.descender,sTypoLineGap:0,usWinAscent:w.yMax,usWinDescent:Math.abs(w.yMin),ulCodePageRange1:1,sxHeight:qi(n,"xyvw",{yMax:Math.round(w.ascender/2)}).yMax,sCapHeight:qi(n,"HIKLEFJMNTZBDPRAGOQSUVWXY",w).yMax,usDefaultChar:n.hasChar(" ")?32:0,usBreakChar:n.hasChar(" ")?32:0},n.tables.os2)),E=Li.make(n.glyphs),U=pi.make(n.glyphs),V=n.getEnglishName("fontFamily"),J=n.getEnglishName("fontSubfamily"),te=V+" "+J,$=n.getEnglishName("postScriptName");$||($=V.replace(/\s/g,"")+"-"+J);var P={};for(var H in n.names)P[H]=n.names[H];P.uniqueID||(P.uniqueID={en:n.getEnglishName("manufacturer")+":"+te}),P.postScriptName||(P.postScriptName={en:$}),P.preferredFamily||(P.preferredFamily=n.names.fontFamily),P.preferredSubfamily||(P.preferredSubfamily=n.names.fontSubfamily);var N=[],X=Ni.make(P,N),Z=N.length>0?Oi.make(N):void 0,Y=zi.make(),K=Ei.make(n.glyphs,{version:n.getEnglishName("version"),fullName:te,familyName:V,weightName:J,postScriptName:$,unitsPerEm:n.unitsPerEm,fontBBox:[0,w.yMin,w.ascender,w.advanceWidthMax]}),F=n.metas&&Object.keys(n.metas).length>0?Hi.make(n.metas):void 0,Q=[C,T,D,I,X,U,Y,K,E];Z&&Q.push(Z),n.tables.gsub&&Q.push(Vi.make(n.tables.gsub)),F&&Q.push(F);for(var vr=Xi(Q),ld=vr.encode(),hd=Hn(ld),br=vr.fields,Qs=!1,fn=0;fn<br.length;fn+=1)if(br[fn].name==="head table"){br[fn].value.checkSumAdjustment=2981146554-hd,Qs=!0;break}if(!Qs)throw new Error("Could not find head table with checkSum to adjust.");return vr}var mc={make:Xi,fontToTable:gc,computeCheckSum:Hn};function jn(n,e){for(var t=0,r=n.length-1;t<=r;){var i=t+r>>>1,s=n[i].tag;if(s===e)return i;s<e?t=i+1:r=i-1}return-t-1}function Yi(n,e){for(var t=0,r=n.length-1;t<=r;){var i=t+r>>>1,s=n[i];if(s===e)return i;s<e?t=i+1:r=i-1}return-t-1}function $i(n,e){for(var t,r=0,i=n.length-1;r<=i;){var s=r+i>>>1;t=n[s];var o=t.start;if(o===e)return t;o<e?r=s+1:i=s-1}if(r>0)return t=n[r-1],e>t.end?0:t}function vt(n,e){this.font=n,this.tableName=e}vt.prototype={searchTag:jn,binSearch:Yi,getTable:function(n){var e=this.font.tables[this.tableName];return!e&&n&&(e=this.font.tables[this.tableName]=this.createDefaultTable()),e},getScriptNames:function(){var n=this.getTable();return n?n.scripts.map(function(e){return e.tag}):[]},getDefaultScriptName:function(){var n=this.getTable();if(n){for(var e=!1,t=0;t<n.scripts.length;t++){var r=n.scripts[t].tag;if(r==="DFLT")return r;r==="latn"&&(e=!0)}if(e)return"latn"}},getScriptTable:function(n,e){var t=this.getTable(e);if(t){n=n||"DFLT";var r=t.scripts,i=jn(t.scripts,n);if(i>=0)return r[i].script;if(e){var s={tag:n,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return r.splice(-1-i,0,s),s.script}}},getLangSysTable:function(n,e,t){var r=this.getScriptTable(n,t);if(r){if(!e||e==="dflt"||e==="DFLT")return r.defaultLangSys;var i=jn(r.langSysRecords,e);if(i>=0)return r.langSysRecords[i].langSys;if(t){var s={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return r.langSysRecords.splice(-1-i,0,s),s.langSys}}},getFeatureTable:function(n,e,t,r){var i=this.getLangSysTable(n,e,r);if(i){for(var s,o=i.featureIndexes,a=this.font.tables[this.tableName].features,c=0;c<o.length;c++)if(s=a[o[c]],s.tag===t)return s.feature;if(r){var l=a.length;return O.assert(l===0||t>=a[l-1].tag,"Features must be added in alphabetical order."),s={tag:t,feature:{params:0,lookupListIndexes:[]}},a.push(s),o.push(l),s.feature}}},getLookupTables:function(n,e,t,r,i){var s=this.getFeatureTable(n,e,t,i),o=[];if(s){for(var a,c=s.lookupListIndexes,l=this.font.tables[this.tableName].lookups,h=0;h<c.length;h++)a=l[c[h]],a.lookupType===r&&o.push(a);if(o.length===0&&i){a={lookupType:r,lookupFlag:0,subtables:[],markFilteringSet:void 0};var d=l.length;return l.push(a),c.push(d),[a]}}return o},getGlyphClass:function(n,e){switch(n.format){case 1:return n.startGlyph<=e&&e<n.startGlyph+n.classes.length?n.classes[e-n.startGlyph]:0;case 2:var t=$i(n.ranges,e);return t?t.classId:0}},getCoverageIndex:function(n,e){switch(n.format){case 1:var t=Yi(n.glyphs,e);return t>=0?t:-1;case 2:var r=$i(n.ranges,e);return r?r.index+e-r.start:-1}},expandCoverage:function(n){if(n.format===1)return n.glyphs;for(var e=[],t=n.ranges,r=0;r<t.length;r++)for(var i=t[r],s=i.start,o=i.end,a=s;a<=o;a++)e.push(a);return e}};function bt(n){vt.call(this,n,"gpos")}bt.prototype=vt.prototype,bt.prototype.init=function(){var n=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(n)},bt.prototype.getKerningValue=function(n,e,t){for(var r=0;r<n.length;r++)for(var i=n[r].subtables,s=0;s<i.length;s++){var o=i[s],a=this.getCoverageIndex(o.coverage,e);if(!(a<0))switch(o.posFormat){case 1:for(var c=o.pairSets[a],l=0;l<c.length;l++){var h=c[l];if(h.secondGlyph===t)return h.value1&&h.value1.xAdvance||0}break;case 2:var d=this.getGlyphClass(o.classDef1,e),u=this.getGlyphClass(o.classDef2,t),p=o.classRecords[d][u];return p.value1&&p.value1.xAdvance||0}}return 0},bt.prototype.getKerningTables=function(n,e){if(this.font.tables.gpos)return this.getLookupTables(n,e,"kern",2)};function ne(n){vt.call(this,n,"gsub")}function yc(n,e){var t=n.length;if(t!==e.length)return!1;for(var r=0;r<t;r++)if(n[r]!==e[r])return!1;return!0}function Wn(n,e,t){for(var r=n.subtables,i=0;i<r.length;i++){var s=r[i];if(s.substFormat===e)return s}if(t)return r.push(t),t}ne.prototype=vt.prototype,ne.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}},ne.prototype.getSingle=function(n,e,t){for(var r=[],i=this.getLookupTables(e,t,n,1),s=0;s<i.length;s++)for(var o=i[s].subtables,a=0;a<o.length;a++){var c=o[a],l=this.expandCoverage(c.coverage),h=void 0;if(c.substFormat===1){var d=c.deltaGlyphId;for(h=0;h<l.length;h++){var u=l[h];r.push({sub:u,by:u+d})}}else{var p=c.substitute;for(h=0;h<l.length;h++)r.push({sub:l[h],by:p[h]})}}return r},ne.prototype.getMultiple=function(n,e,t){for(var r=[],i=this.getLookupTables(e,t,n,2),s=0;s<i.length;s++)for(var o=i[s].subtables,a=0;a<o.length;a++){var c=o[a],l=this.expandCoverage(c.coverage),h=void 0;for(h=0;h<l.length;h++){var d=l[h],u=c.sequences[h];r.push({sub:d,by:u})}}return r},ne.prototype.getAlternates=function(n,e,t){for(var r=[],i=this.getLookupTables(e,t,n,3),s=0;s<i.length;s++)for(var o=i[s].subtables,a=0;a<o.length;a++)for(var c=o[a],l=this.expandCoverage(c.coverage),h=c.alternateSets,d=0;d<l.length;d++)r.push({sub:l[d],by:h[d]});return r},ne.prototype.getLigatures=function(n,e,t){for(var r=[],i=this.getLookupTables(e,t,n,4),s=0;s<i.length;s++)for(var o=i[s].subtables,a=0;a<o.length;a++)for(var c=o[a],l=this.expandCoverage(c.coverage),h=c.ligatureSets,d=0;d<l.length;d++)for(var u=l[d],p=h[d],f=0;f<p.length;f++){var m=p[f];r.push({sub:[u].concat(m.components),by:m.ligGlyph})}return r},ne.prototype.addSingle=function(n,e,t,r){var i=this.getLookupTables(t,r,n,1,!0)[0],s=Wn(i,2,{substFormat:2,coverage:{format:1,glyphs:[]},substitute:[]});O.assert(s.coverage.format===1,"Single: unable to modify coverage table format "+s.coverage.format);var o=e.sub,a=this.binSearch(s.coverage.glyphs,o);a<0&&(a=-1-a,s.coverage.glyphs.splice(a,0,o),s.substitute.splice(a,0,0)),s.substitute[a]=e.by},ne.prototype.addMultiple=function(n,e,t,r){O.assert(e.by instanceof Array&&e.by.length>1,'Multiple: "by" must be an array of two or more ids');var i=this.getLookupTables(t,r,n,2,!0)[0],s=Wn(i,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});O.assert(s.coverage.format===1,"Multiple: unable to modify coverage table format "+s.coverage.format);var o=e.sub,a=this.binSearch(s.coverage.glyphs,o);a<0&&(a=-1-a,s.coverage.glyphs.splice(a,0,o),s.sequences.splice(a,0,0)),s.sequences[a]=e.by},ne.prototype.addAlternate=function(n,e,t,r){var i=this.getLookupTables(t,r,n,3,!0)[0],s=Wn(i,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});O.assert(s.coverage.format===1,"Alternate: unable to modify coverage table format "+s.coverage.format);var o=e.sub,a=this.binSearch(s.coverage.glyphs,o);a<0&&(a=-1-a,s.coverage.glyphs.splice(a,0,o),s.alternateSets.splice(a,0,0)),s.alternateSets[a]=e.by},ne.prototype.addLigature=function(n,e,t,r){var i=this.getLookupTables(t,r,n,4,!0)[0],s=i.subtables[0];s||(s={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},i.subtables[0]=s),O.assert(s.coverage.format===1,"Ligature: unable to modify coverage table format "+s.coverage.format);var o=e.sub[0],a=e.sub.slice(1),c={ligGlyph:e.by,components:a},l=this.binSearch(s.coverage.glyphs,o);if(l>=0){for(var h=s.ligatureSets[l],d=0;d<h.length;d++)if(yc(h[d].components,a))return;h.push(c)}else l=-1-l,s.coverage.glyphs.splice(l,0,o),s.ligatureSets.splice(l,0,[c])},ne.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)}},ne.prototype.add=function(n,e,t,r){if(/ss\d\d/.test(n))return this.addSingle(n,e,t,r);switch(n){case"aalt":case"salt":return typeof e.by=="number"?this.addSingle(n,e,t,r):this.addAlternate(n,e,t,r);case"dlig":case"liga":case"rlig":return this.addLigature(n,e,t,r);case"ccmp":return e.by instanceof Array?this.addMultiple(n,e,t,r):this.addLigature(n,e,t,r)}};function vc(){return typeof window<"u"}function bc(n){for(var e=new Buffer(n.byteLength),t=new Uint8Array(n),r=0;r<e.length;++r)e[r]=t[r];return e}function xt(n,e){if(!n)throw e}function Zi(n,e,t,r,i){var s;return(e&r)>0?(s=n.parseByte(),e&i||(s=-s),s=t+s):(e&i)>0?s=t:s=t+n.parseShort(),s}function Qi(n,e,t){var r=new L.Parser(e,t);n.numberOfContours=r.parseShort(),n._xMin=r.parseShort(),n._yMin=r.parseShort(),n._xMax=r.parseShort(),n._yMax=r.parseShort();var i,s;if(n.numberOfContours>0){for(var o=n.endPointIndices=[],a=0;a<n.numberOfContours;a+=1)o.push(r.parseUShort());n.instructionLength=r.parseUShort(),n.instructions=[];for(var c=0;c<n.instructionLength;c+=1)n.instructions.push(r.parseByte());var l=o[o.length-1]+1;i=[];for(var h=0;h<l;h+=1)if(s=r.parseByte(),i.push(s),(s&8)>0)for(var d=r.parseByte(),u=0;u<d;u+=1)i.push(s),h+=1;if(O.argument(i.length===l,"Bad flags."),o.length>0){var p=[],f;if(l>0){for(var m=0;m<l;m+=1)s=i[m],f={},f.onCurve=!!(s&1),f.lastPointOfContour=o.indexOf(m)>=0,p.push(f);for(var y=0,v=0;v<l;v+=1)s=i[v],f=p[v],f.x=Zi(r,s,y,2,16),y=f.x;for(var _=0,w=0;w<l;w+=1)s=i[w],f=p[w],f.y=Zi(r,s,_,4,32),_=f.y}n.points=p}else n.points=[]}else if(n.numberOfContours===0)n.points=[];else{n.isComposite=!0,n.points=[],n.components=[];for(var C=!0;C;){i=r.parseUShort();var T={glyphIndex:r.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(i&1)>0?(i&2)>0?(T.dx=r.parseShort(),T.dy=r.parseShort()):T.matchedPoints=[r.parseUShort(),r.parseUShort()]:(i&2)>0?(T.dx=r.parseChar(),T.dy=r.parseChar()):T.matchedPoints=[r.parseByte(),r.parseByte()],(i&8)>0?T.xScale=T.yScale=r.parseF2Dot14():(i&64)>0?(T.xScale=r.parseF2Dot14(),T.yScale=r.parseF2Dot14()):(i&128)>0&&(T.xScale=r.parseF2Dot14(),T.scale01=r.parseF2Dot14(),T.scale10=r.parseF2Dot14(),T.yScale=r.parseF2Dot14()),n.components.push(T),C=!!(i&32)}if(i&256){n.instructionLength=r.parseUShort(),n.instructions=[];for(var D=0;D<n.instructionLength;D+=1)n.instructions.push(r.parseByte())}}}function Xn(n,e){for(var t=[],r=0;r<n.length;r+=1){var i=n[r],s={x:e.xScale*i.x+e.scale01*i.y+e.dx,y:e.scale10*i.x+e.yScale*i.y+e.dy,onCurve:i.onCurve,lastPointOfContour:i.lastPointOfContour};t.push(s)}return t}function xc(n){for(var e=[],t=[],r=0;r<n.length;r+=1){var i=n[r];t.push(i),i.lastPointOfContour&&(e.push(t),t=[])}return O.argument(t.length===0,"There are still points left in the current contour."),e}function Ji(n){var e=new j;if(!n)return e;for(var t=xc(n),r=0;r<t.length;++r){var i=t[r],s=null,o=i[i.length-1],a=i[0];if(o.onCurve)e.moveTo(o.x,o.y);else if(a.onCurve)e.moveTo(a.x,a.y);else{var c={x:(o.x+a.x)*.5,y:(o.y+a.y)*.5};e.moveTo(c.x,c.y)}for(var l=0;l<i.length;++l)if(s=o,o=a,a=i[(l+1)%i.length],o.onCurve)e.lineTo(o.x,o.y);else{var h=a;s.onCurve||((o.x+s.x)*.5,(o.y+s.y)*.5),a.onCurve||(h={x:(o.x+a.x)*.5,y:(o.y+a.y)*.5}),e.quadraticCurveTo(o.x,o.y,h.x,h.y)}e.closePath()}return e}function Ki(n,e){if(e.isComposite)for(var t=0;t<e.components.length;t+=1){var r=e.components[t],i=n.get(r.glyphIndex);if(i.getPath(),i.points){var s=void 0;if(r.matchedPoints===void 0)s=Xn(i.points,r);else{if(r.matchedPoints[0]>e.points.length-1||r.matchedPoints[1]>i.points.length-1)throw Error("Matched points out of range in "+e.name);var o=e.points[r.matchedPoints[0]],a=i.points[r.matchedPoints[1]],c={xScale:r.xScale,scale01:r.scale01,scale10:r.scale10,yScale:r.yScale,dx:0,dy:0};a=Xn([a],c)[0],c.dx=o.x-a.x,c.dy=o.y-a.y,s=Xn(i.points,c)}e.points=e.points.concat(s)}}return Ji(e.points)}function Sc(n,e,t,r){for(var i=new be.GlyphSet(r),s=0;s<t.length-1;s+=1){var o=t[s],a=t[s+1];o!==a?i.push(s,be.ttfGlyphLoader(r,s,Qi,n,e+o,Ki)):i.push(s,be.glyphLoader(r,s))}return i}function wc(n,e,t,r){var i=new be.GlyphSet(r);return r._push=function(s){var o=t[s],a=t[s+1];o!==a?i.push(s,be.ttfGlyphLoader(r,s,Qi,n,e+o,Ki)):i.push(s,be.glyphLoader(r,s))},i}function _c(n,e,t,r,i){return i.lowMemory?wc(n,e,t,r):Sc(n,e,t,r)}var es={getPath:Ji,parse:_c},ts,je,ns,qn;function rs(n){this.font=n,this.getCommands=function(e){return es.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function Tc(n){return n}function is(n){return Math.sign(n)*Math.round(Math.abs(n))}function Cc(n){return Math.sign(n)*Math.round(Math.abs(n*2))/2}function Ic(n){return Math.sign(n)*(Math.round(Math.abs(n)+.5)-.5)}function Ac(n){return Math.sign(n)*Math.ceil(Math.abs(n))}function Ec(n){return Math.sign(n)*Math.floor(Math.abs(n))}var ss=function(n){var e=this.srPeriod,t=this.srPhase,r=this.srThreshold,i=1;return n<0&&(n=-n,i=-1),n+=r-t,n=Math.trunc(n/e)*e,n+=t,n<0?t*i:n*i},xe={x:1,y:0,axis:"x",distance:function(n,e,t,r){return(t?n.xo:n.x)-(r?e.xo:e.x)},interpolate:function(n,e,t,r){var i,s,o,a,c,l,h;if(!r||r===this){if(i=n.xo-e.xo,s=n.xo-t.xo,c=e.x-e.xo,l=t.x-t.xo,o=Math.abs(i),a=Math.abs(s),h=o+a,h===0){n.x=n.xo+(c+l)/2;return}n.x=n.xo+(c*a+l*o)/h;return}if(i=r.distance(n,e,!0,!0),s=r.distance(n,t,!0,!0),c=r.distance(e,e,!1,!0),l=r.distance(t,t,!1,!0),o=Math.abs(i),a=Math.abs(s),h=o+a,h===0){xe.setRelative(n,n,(c+l)/2,r,!0);return}xe.setRelative(n,n,(c*a+l*o)/h,r,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(n,e,t,r,i){if(!r||r===this){n.x=(i?e.xo:e.x)+t;return}var s=i?e.xo:e.x,o=i?e.yo:e.y,a=s+t*r.x,c=o+t*r.y;n.x=a+(n.y-c)/r.normalSlope},slope:0,touch:function(n){n.xTouched=!0},touched:function(n){return n.xTouched},untouch:function(n){n.xTouched=!1}},Ae={x:0,y:1,axis:"y",distance:function(n,e,t,r){return(t?n.yo:n.y)-(r?e.yo:e.y)},interpolate:function(n,e,t,r){var i,s,o,a,c,l,h;if(!r||r===this){if(i=n.yo-e.yo,s=n.yo-t.yo,c=e.y-e.yo,l=t.y-t.yo,o=Math.abs(i),a=Math.abs(s),h=o+a,h===0){n.y=n.yo+(c+l)/2;return}n.y=n.yo+(c*a+l*o)/h;return}if(i=r.distance(n,e,!0,!0),s=r.distance(n,t,!0,!0),c=r.distance(e,e,!1,!0),l=r.distance(t,t,!1,!0),o=Math.abs(i),a=Math.abs(s),h=o+a,h===0){Ae.setRelative(n,n,(c+l)/2,r,!0);return}Ae.setRelative(n,n,(c*a+l*o)/h,r,!0)},normalSlope:0,setRelative:function(n,e,t,r,i){if(!r||r===this){n.y=(i?e.yo:e.y)+t;return}var s=i?e.xo:e.x,o=i?e.yo:e.y,a=s+t*r.x,c=o+t*r.y;n.y=c+r.normalSlope*(n.x-a)},slope:Number.POSITIVE_INFINITY,touch:function(n){n.yTouched=!0},touched:function(n){return n.yTouched},untouch:function(n){n.yTouched=!1}};Object.freeze(xe),Object.freeze(Ae);function St(n,e){this.x=n,this.y=e,this.axis=void 0,this.slope=e/n,this.normalSlope=-n/e,Object.freeze(this)}St.prototype.distance=function(n,e,t,r){return this.x*xe.distance(n,e,t,r)+this.y*Ae.distance(n,e,t,r)},St.prototype.interpolate=function(n,e,t,r){var i,s,o,a,c,l,h;if(o=r.distance(n,e,!0,!0),a=r.distance(n,t,!0,!0),i=r.distance(e,e,!1,!0),s=r.distance(t,t,!1,!0),c=Math.abs(o),l=Math.abs(a),h=c+l,h===0){this.setRelative(n,n,(i+s)/2,r,!0);return}this.setRelative(n,n,(i*l+s*c)/h,r,!0)},St.prototype.setRelative=function(n,e,t,r,i){r=r||this;var s=i?e.xo:e.x,o=i?e.yo:e.y,a=s+t*r.x,c=o+t*r.y,l=r.normalSlope,h=this.slope,d=n.x,u=n.y;n.x=(h*d-l*a+c-u)/(h-l),n.y=h*(n.x-d)+u},St.prototype.touch=function(n){n.xTouched=!0,n.yTouched=!0};function wt(n,e){var t=Math.sqrt(n*n+e*e);return n/=t,e/=t,n===1&&e===0?xe:n===0&&e===1?Ae:new St(n,e)}function Ee(n,e,t,r){this.x=this.xo=Math.round(n*64)/64,this.y=this.yo=Math.round(e*64)/64,this.lastPointOfContour=t,this.onCurve=r,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}Ee.prototype.nextTouched=function(n){for(var e=this.nextPointOnContour;!n.touched(e)&&e!==this;)e=e.nextPointOnContour;return e},Ee.prototype.prevTouched=function(n){for(var e=this.prevPointOnContour;!n.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};var _t=Object.freeze(new Ee(0,0)),kc={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function Me(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=xe,this.round=is}}rs.prototype.exec=function(n,e){if(typeof e!="number")throw new Error("Point size is not a number!");if(!(this._errorState>2)){var t=this.font,r=this._prepState;if(!r||r.ppem!==e){var i=this._fpgmState;if(!i){Me.prototype=kc,i=this._fpgmState=new Me("fpgm",t.tables.fpgm),i.funcs=[],i.font=t,b.DEBUG&&(console.log("---EXEC FPGM---"),i.step=-1);try{je(i)}catch(l){console.log("Hinting error in FPGM:"+l),this._errorState=3;return}}Me.prototype=i,r=this._prepState=new Me("prep",t.tables.prep),r.ppem=e;var s=t.tables.cvt;if(s)for(var o=r.cvt=new Array(s.length),a=e/t.unitsPerEm,c=0;c<s.length;c++)o[c]=s[c]*a;else r.cvt=[];b.DEBUG&&(console.log("---EXEC PREP---"),r.step=-1);try{je(r)}catch(l){this._errorState<2&&console.log("Hinting error in PREP:"+l),this._errorState=2}}if(!(this._errorState>1))try{return ns(n,r)}catch(l){this._errorState<1&&(console.log("Hinting error:"+l),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}}},ns=function(n,e){var t=e.ppem/e.font.unitsPerEm,r=t,i=n.components,s,o,a;if(Me.prototype=e,!i)a=new Me("glyf",n.instructions),b.DEBUG&&(console.log("---EXEC GLYPH---"),a.step=-1),qn(n,a,t,r),o=a.gZone;else{var c=e.font;o=[],s=[];for(var l=0;l<i.length;l++){var h=i[l],d=c.glyphs.get(h.glyphIndex);a=new Me("glyf",d.instructions),b.DEBUG&&(console.log("---EXEC COMP "+l+"---"),a.step=-1),qn(d,a,t,r);for(var u=Math.round(h.dx*t),p=Math.round(h.dy*r),f=a.gZone,m=a.contours,y=0;y<f.length;y++){var v=f[y];v.xTouched=v.yTouched=!1,v.xo=v.x=v.x+u,v.yo=v.y=v.y+p}var _=o.length;o.push.apply(o,f);for(var w=0;w<m.length;w++)s.push(m[w]+_)}n.instructions&&!a.inhibitGridFit&&(a=new Me("glyf",n.instructions),a.gZone=a.z0=a.z1=a.z2=o,a.contours=s,o.push(new Ee(0,0),new Ee(Math.round(n.advanceWidth*t),0)),b.DEBUG&&(console.log("---EXEC COMPOSITE---"),a.step=-1),je(a),o.length-=2)}return o},qn=function(n,e,t,r){for(var i=n.points||[],s=i.length,o=e.gZone=e.z0=e.z1=e.z2=[],a=e.contours=[],c,l=0;l<s;l++)c=i[l],o[l]=new Ee(c.x*t,c.y*r,c.lastPointOfContour,c.onCurve);for(var h,d,u=0;u<s;u++)c=o[u],h||(h=c,a.push(u)),c.lastPointOfContour?(c.nextPointOnContour=h,h.prevPointOnContour=c,h=void 0):(d=o[u+1],c.nextPointOnContour=d,d.prevPointOnContour=c);if(!e.inhibitGridFit){if(b.DEBUG){console.log("PROCESSING GLYPH",e.stack);for(var p=0;p<s;p++)console.log(p,o[p].x,o[p].y)}if(o.push(new Ee(0,0),new Ee(Math.round(n.advanceWidth*t),0)),je(e),o.length-=2,b.DEBUG){console.log("FINISHED GLYPH",e.stack);for(var f=0;f<s;f++)console.log(f,o[f].x,o[f].y)}}},je=function(n){var e=n.prog;if(e){var t=e.length,r;for(n.ip=0;n.ip<t;n.ip++){if(b.DEBUG&&n.step++,r=ts[e[n.ip]],!r)throw new Error("unknown instruction: 0x"+Number(e[n.ip]).toString(16));r(n)}}};function Qt(n){for(var e=n.tZone=new Array(n.gZone.length),t=0;t<e.length;t++)e[t]=new Ee(0,0)}function os(n,e){var t=n.prog,r=n.ip,i=1,s;do if(s=t[++r],s===88)i++;else if(s===89)i--;else if(s===64)r+=t[r+1]+1;else if(s===65)r+=2*t[r+1]+1;else if(s>=176&&s<=183)r+=s-176+1;else if(s>=184&&s<=191)r+=(s-184+1)*2;else if(e&&i===1&&s===27)break;while(i>0);n.ip=r}function as(n,e){b.DEBUG&&console.log(e.step,"SVTCA["+n.axis+"]"),e.fv=e.pv=e.dpv=n}function cs(n,e){b.DEBUG&&console.log(e.step,"SPVTCA["+n.axis+"]"),e.pv=e.dpv=n}function ls(n,e){b.DEBUG&&console.log(e.step,"SFVTCA["+n.axis+"]"),e.fv=n}function hs(n,e){var t=e.stack,r=t.pop(),i=t.pop(),s=e.z2[r],o=e.z1[i];b.DEBUG&&console.log("SPVTL["+n+"]",r,i);var a,c;n?(a=s.y-o.y,c=o.x-s.x):(a=o.x-s.x,c=o.y-s.y),e.pv=e.dpv=wt(a,c)}function us(n,e){var t=e.stack,r=t.pop(),i=t.pop(),s=e.z2[r],o=e.z1[i];b.DEBUG&&console.log("SFVTL["+n+"]",r,i);var a,c;n?(a=s.y-o.y,c=o.x-s.x):(a=o.x-s.x,c=o.y-s.y),e.fv=wt(a,c)}function Bc(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"SPVFS[]",t,r),n.pv=n.dpv=wt(r,t)}function Lc(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"SPVFS[]",t,r),n.fv=wt(r,t)}function Oc(n){var e=n.stack,t=n.pv;b.DEBUG&&console.log(n.step,"GPV[]"),e.push(t.x*16384),e.push(t.y*16384)}function Mc(n){var e=n.stack,t=n.fv;b.DEBUG&&console.log(n.step,"GFV[]"),e.push(t.x*16384),e.push(t.y*16384)}function Dc(n){n.fv=n.pv,b.DEBUG&&console.log(n.step,"SFVTPV[]")}function Rc(n){var e=n.stack,t=e.pop(),r=e.pop(),i=e.pop(),s=e.pop(),o=e.pop(),a=n.z0,c=n.z1,l=a[t],h=a[r],d=c[i],u=c[s],p=n.z2[o];b.DEBUG&&console.log("ISECT[], ",t,r,i,s,o);var f=l.x,m=l.y,y=h.x,v=h.y,_=d.x,w=d.y,C=u.x,T=u.y,D=(f-y)*(w-T)-(m-v)*(_-C),I=f*v-m*y,E=_*T-w*C;p.x=(I*(_-C)-E*(f-y))/D,p.y=(I*(w-T)-E*(m-v))/D}function Uc(n){n.rp0=n.stack.pop(),b.DEBUG&&console.log(n.step,"SRP0[]",n.rp0)}function Fc(n){n.rp1=n.stack.pop(),b.DEBUG&&console.log(n.step,"SRP1[]",n.rp1)}function Pc(n){n.rp2=n.stack.pop(),b.DEBUG&&console.log(n.step,"SRP2[]",n.rp2)}function Gc(n){var e=n.stack.pop();switch(b.DEBUG&&console.log(n.step,"SZP0[]",e),n.zp0=e,e){case 0:n.tZone||Qt(n),n.z0=n.tZone;break;case 1:n.z0=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function Nc(n){var e=n.stack.pop();switch(b.DEBUG&&console.log(n.step,"SZP1[]",e),n.zp1=e,e){case 0:n.tZone||Qt(n),n.z1=n.tZone;break;case 1:n.z1=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function zc(n){var e=n.stack.pop();switch(b.DEBUG&&console.log(n.step,"SZP2[]",e),n.zp2=e,e){case 0:n.tZone||Qt(n),n.z2=n.tZone;break;case 1:n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function Vc(n){var e=n.stack.pop();switch(b.DEBUG&&console.log(n.step,"SZPS[]",e),n.zp0=n.zp1=n.zp2=e,e){case 0:n.tZone||Qt(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 Hc(n){n.loop=n.stack.pop(),b.DEBUG&&console.log(n.step,"SLOOP[]",n.loop)}function jc(n){b.DEBUG&&console.log(n.step,"RTG[]"),n.round=is}function Wc(n){b.DEBUG&&console.log(n.step,"RTHG[]"),n.round=Ic}function Xc(n){var e=n.stack.pop();b.DEBUG&&console.log(n.step,"SMD[]",e),n.minDis=e/64}function qc(n){b.DEBUG&&console.log(n.step,"ELSE[]"),os(n,!1)}function Yc(n){var e=n.stack.pop();b.DEBUG&&console.log(n.step,"JMPR[]",e),n.ip+=e-1}function $c(n){var e=n.stack.pop();b.DEBUG&&console.log(n.step,"SCVTCI[]",e),n.cvCutIn=e/64}function Zc(n){var e=n.stack;b.DEBUG&&console.log(n.step,"DUP[]"),e.push(e[e.length-1])}function Yn(n){b.DEBUG&&console.log(n.step,"POP[]"),n.stack.pop()}function Qc(n){b.DEBUG&&console.log(n.step,"CLEAR[]"),n.stack.length=0}function Jc(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"SWAP[]"),e.push(t),e.push(r)}function Kc(n){var e=n.stack;b.DEBUG&&console.log(n.step,"DEPTH[]"),e.push(e.length)}function el(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"LOOPCALL[]",t,r);var i=n.ip,s=n.prog;n.prog=n.funcs[t];for(var o=0;o<r;o++)je(n),b.DEBUG&&console.log(++n.step,o+1<r?"next loopcall":"done loopcall",o);n.ip=i,n.prog=s}function tl(n){var e=n.stack.pop();b.DEBUG&&console.log(n.step,"CALL[]",e);var t=n.ip,r=n.prog;n.prog=n.funcs[e],je(n),n.ip=t,n.prog=r,b.DEBUG&&console.log(++n.step,"returning from",e)}function nl(n){var e=n.stack,t=e.pop();b.DEBUG&&console.log(n.step,"CINDEX[]",t),e.push(e[e.length-t])}function rl(n){var e=n.stack,t=e.pop();b.DEBUG&&console.log(n.step,"MINDEX[]",t),e.push(e.splice(e.length-t,1)[0])}function il(n){if(n.env!=="fpgm")throw new Error("FDEF not allowed here");var e=n.stack,t=n.prog,r=n.ip,i=e.pop(),s=r;for(b.DEBUG&&console.log(n.step,"FDEF[]",i);t[++r]!==45;);n.ip=r,n.funcs[i]=t.slice(s+1,r)}function ds(n,e){var t=e.stack.pop(),r=e.z0[t],i=e.fv,s=e.pv;b.DEBUG&&console.log(e.step,"MDAP["+n+"]",t);var o=s.distance(r,_t);n&&(o=e.round(o)),i.setRelative(r,_t,o,s),i.touch(r),e.rp0=e.rp1=t}function ps(n,e){var t=e.z2,r=t.length-2,i,s,o;b.DEBUG&&console.log(e.step,"IUP["+n.axis+"]");for(var a=0;a<r;a++)i=t[a],!n.touched(i)&&(s=i.prevTouched(n),s!==i&&(o=i.nextTouched(n),s===o&&n.setRelative(i,i,n.distance(s,s,!1,!0),n,!0),n.interpolate(i,s,o,n)))}function fs(n,e){for(var t=e.stack,r=n?e.rp1:e.rp2,i=(n?e.z0:e.z1)[r],s=e.fv,o=e.pv,a=e.loop,c=e.z2;a--;){var l=t.pop(),h=c[l],d=o.distance(i,i,!1,!0);s.setRelative(h,h,d,o),s.touch(h),b.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-a)+": ":"")+"SHP["+(n?"rp1":"rp2")+"]",l)}e.loop=1}function gs(n,e){var t=e.stack,r=n?e.rp1:e.rp2,i=(n?e.z0:e.z1)[r],s=e.fv,o=e.pv,a=t.pop(),c=e.z2[e.contours[a]],l=c;b.DEBUG&&console.log(e.step,"SHC["+n+"]",a);var h=o.distance(i,i,!1,!0);do l!==i&&s.setRelative(l,l,h,o),l=l.nextPointOnContour;while(l!==c)}function ms(n,e){var t=e.stack,r=n?e.rp1:e.rp2,i=(n?e.z0:e.z1)[r],s=e.fv,o=e.pv,a=t.pop();b.DEBUG&&console.log(e.step,"SHZ["+n+"]",a);var c;switch(a){case 0:c=e.tZone;break;case 1:c=e.gZone;break;default:throw new Error("Invalid zone")}for(var l,h=o.distance(i,i,!1,!0),d=c.length-2,u=0;u<d;u++)l=c[u],s.setRelative(l,l,h,o)}function sl(n){for(var e=n.stack,t=n.loop,r=n.fv,i=e.pop()/64,s=n.z2;t--;){var o=e.pop(),a=s[o];b.DEBUG&&console.log(n.step,(n.loop>1?"loop "+(n.loop-t)+": ":"")+"SHPIX[]",o,i),r.setRelative(a,a,i),r.touch(a)}n.loop=1}function ol(n){for(var e=n.stack,t=n.rp1,r=n.rp2,i=n.loop,s=n.z0[t],o=n.z1[r],a=n.fv,c=n.dpv,l=n.z2;i--;){var h=e.pop(),d=l[h];b.DEBUG&&console.log(n.step,(n.loop>1?"loop "+(n.loop-i)+": ":"")+"IP[]",h,t,"<->",r),a.interpolate(d,s,o,c),a.touch(d)}n.loop=1}function ys(n,e){var t=e.stack,r=t.pop()/64,i=t.pop(),s=e.z1[i],o=e.z0[e.rp0],a=e.fv,c=e.pv;a.setRelative(s,o,r,c),a.touch(s),b.DEBUG&&console.log(e.step,"MSIRP["+n+"]",r,i),e.rp1=e.rp0,e.rp2=i,n&&(e.rp0=i)}function al(n){for(var e=n.stack,t=n.rp0,r=n.z0[t],i=n.loop,s=n.fv,o=n.pv,a=n.z1;i--;){var c=e.pop(),l=a[c];b.DEBUG&&console.log(n.step,(n.loop>1?"loop "+(n.loop-i)+": ":"")+"ALIGNRP[]",c),s.setRelative(l,r,0,o),s.touch(l)}n.loop=1}function cl(n){b.DEBUG&&console.log(n.step,"RTDG[]"),n.round=Cc}function vs(n,e){var t=e.stack,r=t.pop(),i=t.pop(),s=e.z0[i],o=e.fv,a=e.pv,c=e.cvt[r];b.DEBUG&&console.log(e.step,"MIAP["+n+"]",r,"(",c,")",i);var l=a.distance(s,_t);n&&(Math.abs(l-c)<e.cvCutIn&&(l=c),l=e.round(l)),o.setRelative(s,_t,l,a),e.zp0===0&&(s.xo=s.x,s.yo=s.y),o.touch(s),e.rp0=e.rp1=i}function ll(n){var e=n.prog,t=n.ip,r=n.stack,i=e[++t];b.DEBUG&&console.log(n.step,"NPUSHB[]",i);for(var s=0;s<i;s++)r.push(e[++t]);n.ip=t}function hl(n){var e=n.ip,t=n.prog,r=n.stack,i=t[++e];b.DEBUG&&console.log(n.step,"NPUSHW[]",i);for(var s=0;s<i;s++){var o=t[++e]<<8|t[++e];o&32768&&(o=-((o^65535)+1)),r.push(o)}n.ip=e}function ul(n){var e=n.stack,t=n.store;t||(t=n.store=[]);var r=e.pop(),i=e.pop();b.DEBUG&&console.log(n.step,"WS",r,i),t[i]=r}function dl(n){var e=n.stack,t=n.store,r=e.pop();b.DEBUG&&console.log(n.step,"RS",r);var i=t&&t[r]||0;e.push(i)}function pl(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"WCVTP",t,r),n.cvt[r]=t/64}function fl(n){var e=n.stack,t=e.pop();b.DEBUG&&console.log(n.step,"RCVT",t),e.push(n.cvt[t]*64)}function bs(n,e){var t=e.stack,r=t.pop(),i=e.z2[r];b.DEBUG&&console.log(e.step,"GC["+n+"]",r),t.push(e.dpv.distance(i,_t,n,!1)*64)}function xs(n,e){var t=e.stack,r=t.pop(),i=t.pop(),s=e.z1[r],o=e.z0[i],a=e.dpv.distance(o,s,n,n);b.DEBUG&&console.log(e.step,"MD["+n+"]",r,i,"->",a),e.stack.push(Math.round(a*64))}function gl(n){b.DEBUG&&console.log(n.step,"MPPEM[]"),n.stack.push(n.ppem)}function ml(n){b.DEBUG&&console.log(n.step,"FLIPON[]"),n.autoFlip=!0}function yl(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"LT[]",t,r),e.push(r<t?1:0)}function vl(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"LTEQ[]",t,r),e.push(r<=t?1:0)}function bl(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"GT[]",t,r),e.push(r>t?1:0)}function xl(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"GTEQ[]",t,r),e.push(r>=t?1:0)}function Sl(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"EQ[]",t,r),e.push(t===r?1:0)}function wl(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"NEQ[]",t,r),e.push(t!==r?1:0)}function _l(n){var e=n.stack,t=e.pop();b.DEBUG&&console.log(n.step,"ODD[]",t),e.push(Math.trunc(t)%2?1:0)}function Tl(n){var e=n.stack,t=e.pop();b.DEBUG&&console.log(n.step,"EVEN[]",t),e.push(Math.trunc(t)%2?0:1)}function Cl(n){var e=n.stack.pop();b.DEBUG&&console.log(n.step,"IF[]",e),e||(os(n,!0),b.DEBUG&&console.log(n.step,"EIF[]"))}function Il(n){b.DEBUG&&console.log(n.step,"EIF[]")}function Al(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"AND[]",t,r),e.push(t&&r?1:0)}function El(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"OR[]",t,r),e.push(t||r?1:0)}function kl(n){var e=n.stack,t=e.pop();b.DEBUG&&console.log(n.step,"NOT[]",t),e.push(t?0:1)}function $n(n,e){var t=e.stack,r=t.pop(),i=e.fv,s=e.pv,o=e.ppem,a=e.deltaBase+(n-1)*16,c=e.deltaShift,l=e.z0;b.DEBUG&&console.log(e.step,"DELTAP["+n+"]",r,t);for(var h=0;h<r;h++){var d=t.pop(),u=t.pop(),p=a+((u&240)>>4);if(p===o){var f=(u&15)-8;f>=0&&f++,b.DEBUG&&console.log(e.step,"DELTAPFIX",d,"by",f*c);var m=l[d];i.setRelative(m,m,f*c,s)}}}function Bl(n){var e=n.stack,t=e.pop();b.DEBUG&&console.log(n.step,"SDB[]",t),n.deltaBase=t}function Ll(n){var e=n.stack,t=e.pop();b.DEBUG&&console.log(n.step,"SDS[]",t),n.deltaShift=Math.pow(.5,t)}function Ol(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"ADD[]",t,r),e.push(r+t)}function Ml(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"SUB[]",t,r),e.push(r-t)}function Dl(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"DIV[]",t,r),e.push(r*64/t)}function Rl(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"MUL[]",t,r),e.push(r*t/64)}function Ul(n){var e=n.stack,t=e.pop();b.DEBUG&&console.log(n.step,"ABS[]",t),e.push(Math.abs(t))}function Fl(n){var e=n.stack,t=e.pop();b.DEBUG&&console.log(n.step,"NEG[]",t),e.push(-t)}function Pl(n){var e=n.stack,t=e.pop();b.DEBUG&&console.log(n.step,"FLOOR[]",t),e.push(Math.floor(t/64)*64)}function Gl(n){var e=n.stack,t=e.pop();b.DEBUG&&console.log(n.step,"CEILING[]",t),e.push(Math.ceil(t/64)*64)}function Jt(n,e){var t=e.stack,r=t.pop();b.DEBUG&&console.log(e.step,"ROUND[]"),t.push(e.round(r/64)*64)}function Nl(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"WCVTF[]",t,r),n.cvt[r]=t*n.ppem/n.font.unitsPerEm}function Zn(n,e){var t=e.stack,r=t.pop(),i=e.ppem,s=e.deltaBase+(n-1)*16,o=e.deltaShift;b.DEBUG&&console.log(e.step,"DELTAC["+n+"]",r,t);for(var a=0;a<r;a++){var c=t.pop(),l=t.pop(),h=s+((l&240)>>4);if(h===i){var d=(l&15)-8;d>=0&&d++;var u=d*o;b.DEBUG&&console.log(e.step,"DELTACFIX",c,"by",u),e.cvt[c]+=u}}}function zl(n){var e=n.stack.pop();b.DEBUG&&console.log(n.step,"SROUND[]",e),n.round=ss;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 Vl(n){var e=n.stack.pop();b.DEBUG&&console.log(n.step,"S45ROUND[]",e),n.round=ss;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 Hl(n){b.DEBUG&&console.log(n.step,"ROFF[]"),n.round=Tc}function jl(n){b.DEBUG&&console.log(n.step,"RUTG[]"),n.round=Ac}function Wl(n){b.DEBUG&&console.log(n.step,"RDTG[]"),n.round=Ec}function Xl(n){var e=n.stack.pop();b.DEBUG&&console.log(n.step,"SCANCTRL[]",e)}function Ss(n,e){var t=e.stack,r=t.pop(),i=t.pop(),s=e.z2[r],o=e.z1[i];b.DEBUG&&console.log(e.step,"SDPVTL["+n+"]",r,i);var a,c;n?(a=s.y-o.y,c=o.x-s.x):(a=o.x-s.x,c=o.y-s.y),e.dpv=wt(a,c)}function ql(n){var e=n.stack,t=e.pop(),r=0;b.DEBUG&&console.log(n.step,"GETINFO[]",t),t&1&&(r=35),t&32&&(r|=4096),e.push(r)}function Yl(n){var e=n.stack,t=e.pop(),r=e.pop(),i=e.pop();b.DEBUG&&console.log(n.step,"ROLL[]"),e.push(r),e.push(t),e.push(i)}function $l(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"MAX[]",t,r),e.push(Math.max(r,t))}function Zl(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"MIN[]",t,r),e.push(Math.min(r,t))}function Ql(n){var e=n.stack.pop();b.DEBUG&&console.log(n.step,"SCANTYPE[]",e)}function Jl(n){var e=n.stack.pop(),t=n.stack.pop();switch(b.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 De(n,e){var t=e.stack,r=e.prog,i=e.ip;b.DEBUG&&console.log(e.step,"PUSHB["+n+"]");for(var s=0;s<n;s++)t.push(r[++i]);e.ip=i}function Re(n,e){var t=e.ip,r=e.prog,i=e.stack;b.DEBUG&&console.log(e.ip,"PUSHW["+n+"]");for(var s=0;s<n;s++){var o=r[++t]<<8|r[++t];o&32768&&(o=-((o^65535)+1)),i.push(o)}e.ip=t}function B(n,e,t,r,i,s){var o=s.stack,a=n&&o.pop(),c=o.pop(),l=s.rp0,h=s.z0[l],d=s.z1[c],u=s.minDis,p=s.fv,f=s.dpv,m,y,v,_;y=m=f.distance(d,h,!0,!0),v=y>=0?1:-1,y=Math.abs(y),n&&(_=s.cvt[a],r&&Math.abs(y-_)<s.cvCutIn&&(y=_)),t&&y<u&&(y=u),r&&(y=s.round(y)),p.setRelative(d,h,v*y,f),p.touch(d),b.DEBUG&&console.log(s.step,(n?"MIRP[":"MDRP[")+(e?"M":"m")+(t?">":"_")+(r?"R":"_")+(i===0?"Gr":i===1?"Bl":i===2?"Wh":"")+"]",n?a+"("+s.cvt[a]+","+_+")":"",c,"(d =",m,"->",v*y,")"),s.rp1=s.rp0,s.rp2=c,e&&(s.rp0=c)}ts=[as.bind(void 0,Ae),as.bind(void 0,xe),cs.bind(void 0,Ae),cs.bind(void 0,xe),ls.bind(void 0,Ae),ls.bind(void 0,xe),hs.bind(void 0,0),hs.bind(void 0,1),us.bind(void 0,0),us.bind(void 0,1),Bc,Lc,Oc,Mc,Dc,Rc,Uc,Fc,Pc,Gc,Nc,zc,Vc,Hc,jc,Wc,Xc,qc,Yc,$c,void 0,void 0,Zc,Yn,Qc,Jc,Kc,nl,rl,void 0,void 0,void 0,el,tl,il,void 0,ds.bind(void 0,0),ds.bind(void 0,1),ps.bind(void 0,Ae),ps.bind(void 0,xe),fs.bind(void 0,0),fs.bind(void 0,1),gs.bind(void 0,0),gs.bind(void 0,1),ms.bind(void 0,0),ms.bind(void 0,1),sl,ol,ys.bind(void 0,0),ys.bind(void 0,1),al,cl,vs.bind(void 0,0),vs.bind(void 0,1),ll,hl,ul,dl,pl,fl,bs.bind(void 0,0),bs.bind(void 0,1),void 0,xs.bind(void 0,0),xs.bind(void 0,1),gl,void 0,ml,void 0,void 0,yl,vl,bl,xl,Sl,wl,_l,Tl,Cl,Il,Al,El,kl,$n.bind(void 0,1),Bl,Ll,Ol,Ml,Dl,Rl,Ul,Fl,Pl,Gl,Jt.bind(void 0,0),Jt.bind(void 0,1),Jt.bind(void 0,2),Jt.bind(void 0,3),void 0,void 0,void 0,void 0,Nl,$n.bind(void 0,2),$n.bind(void 0,3),Zn.bind(void 0,1),Zn.bind(void 0,2),Zn.bind(void 0,3),zl,Vl,void 0,void 0,Hl,void 0,jl,Wl,Yn,Yn,void 0,void 0,void 0,void 0,void 0,Xl,Ss.bind(void 0,0),Ss.bind(void 0,1),ql,void 0,Yl,$l,Zl,Ql,Jl,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,De.bind(void 0,1),De.bind(void 0,2),De.bind(void 0,3),De.bind(void 0,4),De.bind(void 0,5),De.bind(void 0,6),De.bind(void 0,7),De.bind(void 0,8),Re.bind(void 0,1),Re.bind(void 0,2),Re.bind(void 0,3),Re.bind(void 0,4),Re.bind(void 0,5),Re.bind(void 0,6),Re.bind(void 0,7),Re.bind(void 0,8),B.bind(void 0,0,0,0,0,0),B.bind(void 0,0,0,0,0,1),B.bind(void 0,0,0,0,0,2),B.bind(void 0,0,0,0,0,3),B.bind(void 0,0,0,0,1,0),B.bind(void 0,0,0,0,1,1),B.bind(void 0,0,0,0,1,2),B.bind(void 0,0,0,0,1,3),B.bind(void 0,0,0,1,0,0),B.bind(void 0,0,0,1,0,1),B.bind(void 0,0,0,1,0,2),B.bind(void 0,0,0,1,0,3),B.bind(void 0,0,0,1,1,0),B.bind(void 0,0,0,1,1,1),B.bind(void 0,0,0,1,1,2),B.bind(void 0,0,0,1,1,3),B.bind(void 0,0,1,0,0,0),B.bind(void 0,0,1,0,0,1),B.bind(void 0,0,1,0,0,2),B.bind(void 0,0,1,0,0,3),B.bind(void 0,0,1,0,1,0),B.bind(void 0,0,1,0,1,1),B.bind(void 0,0,1,0,1,2),B.bind(void 0,0,1,0,1,3),B.bind(void 0,0,1,1,0,0),B.bind(void 0,0,1,1,0,1),B.bind(void 0,0,1,1,0,2),B.bind(void 0,0,1,1,0,3),B.bind(void 0,0,1,1,1,0),B.bind(void 0,0,1,1,1,1),B.bind(void 0,0,1,1,1,2),B.bind(void 0,0,1,1,1,3),B.bind(void 0,1,0,0,0,0),B.bind(void 0,1,0,0,0,1),B.bind(void 0,1,0,0,0,2),B.bind(void 0,1,0,0,0,3),B.bind(void 0,1,0,0,1,0),B.bind(void 0,1,0,0,1,1),B.bind(void 0,1,0,0,1,2),B.bind(void 0,1,0,0,1,3),B.bind(void 0,1,0,1,0,0),B.bind(void 0,1,0,1,0,1),B.bind(void 0,1,0,1,0,2),B.bind(void 0,1,0,1,0,3),B.bind(void 0,1,0,1,1,0),B.bind(void 0,1,0,1,1,1),B.bind(void 0,1,0,1,1,2),B.bind(void 0,1,0,1,1,3),B.bind(void 0,1,1,0,0,0),B.bind(void 0,1,1,0,0,1),B.bind(void 0,1,1,0,0,2),B.bind(void 0,1,1,0,0,3),B.bind(void 0,1,1,0,1,0),B.bind(void 0,1,1,0,1,1),B.bind(void 0,1,1,0,1,2),B.bind(void 0,1,1,0,1,3),B.bind(void 0,1,1,1,0,0),B.bind(void 0,1,1,1,0,1),B.bind(void 0,1,1,1,0,2),B.bind(void 0,1,1,1,0,3),B.bind(void 0,1,1,1,1,0),B.bind(void 0,1,1,1,1,1),B.bind(void 0,1,1,1,1,2),B.bind(void 0,1,1,1,1,3)];function et(n){this.char=n,this.state={},this.activeState=null}function Qn(n,e,t){this.contextName=t,this.startIndex=n,this.endOffset=e}function Kl(n,e,t){this.contextName=n,this.openRange=null,this.ranges=[],this.checkStart=e,this.checkEnd=t}function ue(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 Kt(n){this.eventId=n,this.subscribers=[]}function eh(n){var e=this,t=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];t.forEach(function(i){Object.defineProperty(e.events,i,{value:new Kt(i)})}),n&&t.forEach(function(i){var s=n[i];typeof s=="function"&&e.events[i].subscribe(s)});var r=["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"];r.forEach(function(i){e.events[i].subscribe(e.updateContextsRanges)})}function G(n){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],eh.call(this,n)}et.prototype.setState=function(n,e){return this.state[n]=e,this.activeState={key:n,value:this.state[n]},this.activeState},et.prototype.getState=function(n){return this.state[n]||null},G.prototype.inboundIndex=function(n){return n>=0&&n<this.tokens.length},G.prototype.composeRUD=function(n){var e=this,t=!0,r=n.map(function(s){return e[s[0]].apply(e,s.slice(1).concat(t))}),i=function(s){return typeof s=="object"&&s.hasOwnProperty("FAIL")};if(r.every(i))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:r.filter(i)};this.dispatch("composeRUD",[r.filter(function(s){return!i(s)})])},G.prototype.replaceRange=function(n,e,t,r){e=e!==null?e:this.tokens.length;var i=t.every(function(o){return o instanceof et});if(!isNaN(n)&&this.inboundIndex(n)&&i){var s=this.tokens.splice.apply(this.tokens,[n,e].concat(t));return r||this.dispatch("replaceToken",[n,e,t]),[s,t]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}},G.prototype.replaceToken=function(n,e,t){if(!isNaN(n)&&this.inboundIndex(n)&&e instanceof et){var r=this.tokens.splice(n,1,e);return t||this.dispatch("replaceToken",[n,e]),[r[0],e]}else return{FAIL:"replaceToken: invalid token or index."}},G.prototype.removeRange=function(n,e,t){e=isNaN(e)?this.tokens.length:e;var r=this.tokens.splice(n,e);return t||this.dispatch("removeRange",[r,n,e]),r},G.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."}},G.prototype.insertToken=function(n,e,t){var r=n.every(function(i){return i instanceof et});return r?(this.tokens.splice.apply(this.tokens,[e,0].concat(n)),t||this.dispatch("insertToken",[n,e]),n):{FAIL:"insertToken: invalid token(s)."}},G.prototype.registerModifier=function(n,e,t){this.events.newToken.subscribe(function(r,i){var s=[r,i],o=e===null||e.apply(this,s)===!0,a=[r,i];if(o){var c=t.apply(this,a);r.setState(n,c)}}),this.registeredModifiers.push(n)},Kt.prototype.subscribe=function(n){return typeof n=="function"?this.subscribers.push(n)-1:{FAIL:"invalid '"+this.eventId+"' event handler"}},Kt.prototype.unsubscribe=function(n){this.subscribers.splice(n,1)},ue.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)},ue.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}},G.prototype.rangeToText=function(n){if(n instanceof Qn)return this.getRangeTokens(n).map(function(e){return e.char}).join("")},G.prototype.getText=function(){return this.tokens.map(function(n){return n.char}).join("")},G.prototype.getContext=function(n){var e=this.registeredContexts[n];return e||null},G.prototype.on=function(n,e){var t=this.events[n];return t?t.subscribe(e):null},G.prototype.dispatch=function(n,e){var t=this,r=this.events[n];r instanceof Kt&&r.subscribers.forEach(function(i){i.apply(t,e||[])})},G.prototype.registerContextChecker=function(n,e,t){if(this.getContext(n))return{FAIL:"context name '"+n+"' is already registered."};if(typeof e!="function")return{FAIL:"missing context start check."};if(typeof t!="function")return{FAIL:"missing context end check."};var r=new Kl(n,e,t);return this.registeredContexts[n]=r,this.contextCheckers.push(r),r},G.prototype.getRangeTokens=function(n){var e=n.startIndex+n.endOffset;return[].concat(this.tokens.slice(n.startIndex,e))},G.prototype.getContextRanges=function(n){var e=this.getContext(n);return e?e.ranges:{FAIL:"context checker '"+n+"' is not registered."}},G.prototype.resetContextsRanges=function(){var n=this.registeredContexts;for(var e in n)if(n.hasOwnProperty(e)){var t=n[e];t.ranges=[]}},G.prototype.updateContextsRanges=function(){this.resetContextsRanges();for(var n=this.tokens.map(function(r){return r.char}),e=0;e<n.length;e++){var t=new ue(n,e);this.runContextCheck(t)}this.dispatch("updateContextsRanges",[this.registeredContexts])},G.prototype.setEndOffset=function(n,e){var t=this.getContext(e).openRange.startIndex,r=new Qn(t,n,e),i=this.getContext(e).ranges;return r.rangeId=e+"."+i.length,i.push(r),this.getContext(e).openRange=null,r},G.prototype.runContextCheck=function(n){var e=this,t=n.index;this.contextCheckers.forEach(function(r){var i=r.contextName,s=e.getContext(i).openRange;if(!s&&r.checkStart(n)&&(s=new Qn(t,null,i),e.getContext(i).openRange=s,e.dispatch("contextStart",[i,t])),s&&r.checkEnd(n)){var o=t-s.startIndex+1,a=e.setEndOffset(o,i);e.dispatch("contextEnd",[i,a])}})},G.prototype.tokenize=function(n){this.tokens=[],this.resetContextsRanges();var e=Array.from(n);this.dispatch("start");for(var t=0;t<e.length;t++){var r=e[t],i=new ue(e,t);this.dispatch("next",[i]),this.runContextCheck(i);var s=new et(r);this.tokens.push(s),this.dispatch("newToken",[s,i])}return this.dispatch("end",[this.tokens]),this.tokens};function Ue(n){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(n)}function ws(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 Fe(n){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(n)}function en(n){return/[A-z]/.test(n)}function th(n){return/\s/.test(n)}function re(n){this.font=n,this.features={}}function We(n){this.id=n.id,this.tag=n.tag,this.substitution=n.substitution}function Tt(n,e){if(!n)return-1;switch(e.format){case 1:return e.glyphs.indexOf(n);case 2:for(var t=e.ranges,r=0;r<t.length;r++){var i=t[r];if(n>=i.start&&n<=i.end){var s=n-i.start;return i.index+s}}break;default:return-1}return-1}function nh(n,e){var t=Tt(n,e.coverage);return t===-1?null:n+e.deltaGlyphId}function rh(n,e){var t=Tt(n,e.coverage);return t===-1?null:e.substitute[t]}function Jn(n,e){for(var t=[],r=0;r<n.length;r++){var i=n[r],s=e.current;s=Array.isArray(s)?s[0]:s;var o=Tt(s,i);o!==-1&&t.push(o)}return t.length!==n.length?-1:t}function ih(n,e){var t=e.inputCoverage.length+e.lookaheadCoverage.length+e.backtrackCoverage.length;if(n.context.length<t)return[];var r=Jn(e.inputCoverage,n);if(r===-1)return[];var i=e.inputCoverage.length-1;if(n.lookahead.length<e.lookaheadCoverage.length)return[];for(var s=n.lookahead.slice(i);s.length&&Fe(s[0].char);)s.shift();var o=new ue(s,0),a=Jn(e.lookaheadCoverage,o),c=[].concat(n.backtrack);for(c.reverse();c.length&&Fe(c[0].char);)c.shift();if(c.length<e.backtrackCoverage.length)return[];var l=new ue(c,0),h=Jn(e.backtrackCoverage,l),d=r.length===e.inputCoverage.length&&a.length===e.lookaheadCoverage.length&&h.length===e.backtrackCoverage.length,u=[];if(d)for(var p=0;p<e.lookupRecords.length;p++)for(var f=e.lookupRecords[p],m=f.lookupListIndex,y=this.getLookupByIndex(m),v=0;v<y.subtables.length;v++){var _=y.subtables[v],w=this.getLookupMethod(y,_),C=this.getSubstitutionType(y,_);if(C==="12")for(var T=0;T<r.length;T++){var D=n.get(T),I=w(D);I&&u.push(I)}}return u}function sh(n,e){var t=n.current,r=Tt(t,e.coverage);if(r===-1)return null;for(var i,s=e.ligatureSets[r],o=0;o<s.length;o++){i=s[o];for(var a=0;a<i.components.length;a++){var c=n.lookahead[a],l=i.components[a];if(c!==l)break;if(a===i.components.length-1)return i}}return null}function oh(n,e){var t=Tt(n,e.coverage);return t===-1?null:e.sequences[t]}re.prototype.getDefaultScriptFeaturesIndexes=function(){for(var n=this.font.tables.gsub.scripts,e=0;e<n.length;e++){var t=n[e];if(t.tag==="DFLT")return t.script.defaultLangSys.featureIndexes}return[]},re.prototype.getScriptFeaturesIndexes=function(n){var e=this.font.tables;if(!e.gsub)return[];if(!n)return this.getDefaultScriptFeaturesIndexes();for(var t=this.font.tables.gsub.scripts,r=0;r<t.length;r++){var i=t[r];if(i.tag===n&&i.script.defaultLangSys)return i.script.defaultLangSys.featureIndexes;var s=i.langSysRecords;if(s)for(var o=0;o<s.length;o++){var a=s[o];if(a.tag===n){var c=a.langSys;return c.featureIndexes}}}return this.getDefaultScriptFeaturesIndexes()},re.prototype.mapTagsToFeatures=function(n,e){for(var t={},r=0;r<n.length;r++){var i=n[r].tag,s=n[r].feature;t[i]=s}this.features[e].tags=t},re.prototype.getScriptFeatures=function(n){var e=this.features[n];if(this.features.hasOwnProperty(n))return e;var t=this.getScriptFeaturesIndexes(n);if(!t)return null;var r=this.font.tables.gsub;return e=t.map(function(i){return r.features[i]}),this.features[n]=e,this.mapTagsToFeatures(e,n),e},re.prototype.getSubstitutionType=function(n,e){var t=n.lookupType.toString(),r=e.substFormat.toString();return t+r},re.prototype.getLookupMethod=function(n,e){var t=this,r=this.getSubstitutionType(n,e);switch(r){case"11":return function(i){return nh.apply(t,[i,e])};case"12":return function(i){return rh.apply(t,[i,e])};case"63":return function(i){return ih.apply(t,[i,e])};case"41":return function(i){return sh.apply(t,[i,e])};case"21":return function(i){return oh.apply(t,[i,e])};default:throw new Error("lookupType: "+n.lookupType+" - substFormat: "+e.substFormat+" is not yet supported")}},re.prototype.lookupFeature=function(n){var e=n.contextParams,t=e.index,r=this.getFeature({tag:n.tag,script:n.script});if(!r)return new Error("font '"+this.font.names.fullName.en+"' doesn't support feature '"+n.tag+"' for script '"+n.script+"'.");for(var i=this.getFeatureLookups(r),s=[].concat(e.context),o=0;o<i.length;o++)for(var a=i[o],c=this.getLookupSubtables(a),l=0;l<c.length;l++){var h=c[l],d=this.getSubstitutionType(a,h),u=this.getLookupMethod(a,h),p=void 0;switch(d){case"11":p=u(e.current),p&&s.splice(t,1,new We({id:11,tag:n.tag,substitution:p}));break;case"12":p=u(e.current),p&&s.splice(t,1,new We({id:12,tag:n.tag,substitution:p}));break;case"63":p=u(e),Array.isArray(p)&&p.length&&s.splice(t,1,new We({id:63,tag:n.tag,substitution:p}));break;case"41":p=u(e),p&&s.splice(t,1,new We({id:41,tag:n.tag,substitution:p}));break;case"21":p=u(e.current),p&&s.splice(t,1,new We({id:21,tag:n.tag,substitution:p}));break}e=new ue(s,t),!(Array.isArray(p)&&!p.length)&&(p=null)}return s.length?s:null},re.prototype.supports=function(n){if(!n.script)return!1;this.getScriptFeatures(n.script);var e=this.features.hasOwnProperty(n.script);if(!n.tag)return e;var t=this.features[n.script].some(function(r){return r.tag===n.tag});return e&&t},re.prototype.getLookupSubtables=function(n){return n.subtables||null},re.prototype.getLookupByIndex=function(n){var e=this.font.tables.gsub.lookups;return e[n]||null},re.prototype.getFeatureLookups=function(n){return n.lookupListIndexes.map(this.getLookupByIndex.bind(this))},re.prototype.getFeature=function(n){if(!this.font)return{FAIL:"No font was found"};this.features.hasOwnProperty(n.script)||this.getScriptFeatures(n.script);var e=this.features[n.script];return e?e.tags[n.tag]?this.features[n.script].tags[n.tag]:null:{FAIL:"No feature for script "+n.script}};function ah(n){var e=n.current,t=n.get(-1);return t===null&&Ue(e)||!Ue(t)&&Ue(e)}function ch(n){var e=n.get(1);return e===null||!Ue(e)}var lh={startCheck:ah,endCheck:ch};function hh(n){var e=n.current,t=n.get(-1);return(Ue(e)||Fe(e))&&!Ue(t)}function uh(n){var e=n.get(1);switch(!0){case e===null:return!0;case(!Ue(e)&&!Fe(e)):var t=th(e);if(!t)return!0;if(t){var r=!1;if(r=n.lookahead.some(function(i){return Ue(i)||Fe(i)}),!r)return!0}break;default:return!1}}var dh={startCheck:hh,endCheck:uh};function ph(n,e,t){e[t].setState(n.tag,n.substitution)}function fh(n,e,t){e[t].setState(n.tag,n.substitution)}function gh(n,e,t){n.substitution.forEach(function(r,i){var s=e[t+i];s.setState(n.tag,r)})}function mh(n,e,t){var r=e[t];r.setState(n.tag,n.substitution.ligGlyph);for(var i=n.substitution.components.length,s=0;s<i;s++)r=e[t+s+1],r.setState("deleted",!0)}var _s={11:ph,12:fh,63:gh,41:mh};function Kn(n,e,t){n instanceof We&&_s[n.id]&&_s[n.id](n,e,t)}function yh(n){for(var e=[].concat(n.backtrack),t=e.length-1;t>=0;t--){var r=e[t],i=ws(r),s=Fe(r);if(!i&&!s)return!0;if(i)return!1}return!1}function vh(n){if(ws(n.current))return!1;for(var e=0;e<n.lookahead.length;e++){var t=n.lookahead[e],r=Fe(t);if(!r)return!0}return!1}function bh(n){var e=this,t="arab",r=this.featuresTags[t],i=this.tokenizer.getRangeTokens(n);if(i.length!==1){var s=new ue(i.map(function(a){return a.getState("glyphIndex")}),0),o=new ue(i.map(function(a){return a.char}),0);i.forEach(function(a,c){if(!Fe(a.char)){s.setCurrentIndex(c),o.setCurrentIndex(c);var l=0;yh(o)&&(l|=1),vh(o)&&(l|=2);var h;switch(l){case 1:h="fina";break;case 2:h="init";break;case 3:h="medi";break}if(r.indexOf(h)!==-1){var d=e.query.lookupFeature({tag:h,script:t,contextParams:s});if(d instanceof Error)return console.info(d.message);d.forEach(function(u,p){u instanceof We&&(Kn(u,i,p),s.context[p]=u.substitution)})}}})}}function Ts(n,e){var t=n.map(function(r){return r.activeState.value});return new ue(t,0)}function xh(n){var e=this,t="arab",r=this.tokenizer.getRangeTokens(n),i=Ts(r);i.context.forEach(function(s,o){i.setCurrentIndex(o);var a=e.query.lookupFeature({tag:"rlig",script:t,contextParams:i});a.length&&(a.forEach(function(c){return Kn(c,r,o)}),i=Ts(r))})}function Sh(n){var e=n.current,t=n.get(-1);return t===null&&en(e)||!en(t)&&en(e)}function wh(n){var e=n.get(1);return e===null||!en(e)}var _h={startCheck:Sh,endCheck:wh};function Cs(n,e){var t=n.map(function(r){return r.activeState.value});return new ue(t,0)}function Th(n){var e=this,t="latn",r=this.tokenizer.getRangeTokens(n),i=Cs(r);i.context.forEach(function(s,o){i.setCurrentIndex(o);var a=e.query.lookupFeature({tag:"liga",script:t,contextParams:i});a.length&&(a.forEach(function(c){return Kn(c,r,o)}),i=Cs(r))})}function de(n){this.baseDir=n||"ltr",this.tokenizer=new G,this.featuresTags={}}de.prototype.setText=function(n){this.text=n},de.prototype.contextChecks={latinWordCheck:_h,arabicWordCheck:lh,arabicSentenceCheck:dh};function er(n){var e=this.contextChecks[n+"Check"];return this.tokenizer.registerContextChecker(n,e.startCheck,e.endCheck)}function Ch(){return er.call(this,"latinWord"),er.call(this,"arabicWord"),er.call(this,"arabicSentence"),this.tokenizer.tokenize(this.text)}function Ih(){var n=this,e=this.tokenizer.getContextRanges("arabicSentence");e.forEach(function(t){var r=n.tokenizer.getRangeTokens(t);n.tokenizer.replaceRange(t.startIndex,t.endOffset,r.reverse())})}de.prototype.registerFeatures=function(n,e){var t=this,r=e.filter(function(i){return t.query.supports({script:n,tag:i})});this.featuresTags.hasOwnProperty(n)?this.featuresTags[n]=this.featuresTags[n].concat(r):this.featuresTags[n]=r},de.prototype.applyFeatures=function(n,e){if(!n)throw new Error("No valid font was provided to apply features");this.query||(this.query=new re(n));for(var t=0;t<e.length;t++){var r=e[t];this.query.supports({script:r.script})&&this.registerFeatures(r.script,r.tags)}},de.prototype.registerModifier=function(n,e,t){this.tokenizer.registerModifier(n,e,t)};function tr(){if(this.tokenizer.registeredModifiers.indexOf("glyphIndex")===-1)throw new Error("glyphIndex modifier is required to apply arabic presentation features.")}function Ah(){var n=this,e="arab";if(this.featuresTags.hasOwnProperty(e)){tr.call(this);var t=this.tokenizer.getContextRanges("arabicWord");t.forEach(function(r){bh.call(n,r)})}}function Eh(){var n=this,e="arab";if(this.featuresTags.hasOwnProperty(e)){var t=this.featuresTags[e];if(t.indexOf("rlig")!==-1){tr.call(this);var r=this.tokenizer.getContextRanges("arabicWord");r.forEach(function(i){xh.call(n,i)})}}}function kh(){var n=this,e="latn";if(this.featuresTags.hasOwnProperty(e)){var t=this.featuresTags[e];if(t.indexOf("liga")!==-1){tr.call(this);var r=this.tokenizer.getContextRanges("latinWord");r.forEach(function(i){Th.call(n,i)})}}}de.prototype.checkContextReady=function(n){return!!this.tokenizer.getContext(n)},de.prototype.applyFeaturesToContexts=function(){this.checkContextReady("arabicWord")&&(Ah.call(this),Eh.call(this)),this.checkContextReady("latinWord")&&kh.call(this),this.checkContextReady("arabicSentence")&&Ih.call(this)},de.prototype.processText=function(n){(!this.text||this.text!==n)&&(this.setText(n),Ch.call(this),this.applyFeaturesToContexts())},de.prototype.getBidiText=function(n){return this.processText(n),this.tokenizer.getText()},de.prototype.getTextGlyphs=function(n){this.processText(n);for(var e=[],t=0;t<this.tokenizer.tokens.length;t++){var r=this.tokenizer.tokens[t];if(!r.state.deleted){var i=r.activeState.value;e.push(Array.isArray(i)?i[0]:i)}}return e};function R(n){n=n||{},n.tables=n.tables||{},n.empty||(xt(n.familyName,"When creating a new Font object, familyName is required."),xt(n.styleName,"When creating a new Font object, styleName is required."),xt(n.unitsPerEm,"When creating a new Font object, unitsPerEm is required."),xt(n.ascender,"When creating a new Font object, ascender is required."),xt(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 be.GlyphSet(this,n.glyphs||[]),this.encoding=new fi(this),this.position=new bt(this),this.substitution=new ne(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 rs(this)}})}R.prototype.hasChar=function(n){return this.encoding.charToGlyphIndex(n)!==null},R.prototype.charToGlyphIndex=function(n){return this.encoding.charToGlyphIndex(n)},R.prototype.charToGlyph=function(n){var e=this.charToGlyphIndex(n),t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t},R.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})},R.prototype.stringToGlyphs=function(n,e){var t=this,r=new de,i=function(d){return t.charToGlyphIndex(d.char)};r.registerModifier("glyphIndex",null,i);var s=e?this.updateFeatures(e.features):this.defaultRenderOptions.features;r.applyFeatures(this,s);for(var o=r.getTextGlyphs(n),a=o.length,c=new Array(a),l=this.glyphs.get(0),h=0;h<a;h+=1)c[h]=this.glyphs.get(o[h])||l;return c},R.prototype.nameToGlyphIndex=function(n){return this.glyphNames.nameToGlyphIndex(n)},R.prototype.nameToGlyph=function(n){var e=this.nameToGlyphIndex(n),t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t},R.prototype.glyphIndexToName=function(n){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(n):""},R.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},R.prototype.defaultRenderOptions={kerning:!0,features:[{script:"arab",tags:["init","medi","fina","rlig"]},{script:"latn",tags:["liga","rlig"]}]},R.prototype.forEachGlyph=function(n,e,t,r,i,s){e=e!==void 0?e:0,t=t!==void 0?t:0,r=r!==void 0?r:72,i=Object.assign({},this.defaultRenderOptions,i);var o=1/this.unitsPerEm*r,a=this.stringToGlyphs(n,i),c;if(i.kerning){var l=i.script||this.position.getDefaultScriptName();c=this.position.getKerningTables(l,i.language)}for(var h=0;h<a.length;h+=1){var d=a[h];if(s.call(this,d,e,t,r,i),d.advanceWidth&&(e+=d.advanceWidth*o),i.kerning&&h<a.length-1){var u=c?this.position.getKerningValue(c,d.index,a[h+1].index):this.getKerningValue(d,a[h+1]);e+=u*o}i.letterSpacing?e+=i.letterSpacing*r:i.tracking&&(e+=i.tracking/1e3*r)}return e},R.prototype.getPath=function(n,e,t,r,i){var s=new j;return this.forEachGlyph(n,e,t,r,i,function(o,a,c,l){var h=o.getPath(a,c,l,i,this);s.extend(h)}),s},R.prototype.getPaths=function(n,e,t,r,i){var s=[];return this.forEachGlyph(n,e,t,r,i,function(o,a,c,l){var h=o.getPath(a,c,l,i,this);s.push(h)}),s},R.prototype.getAdvanceWidth=function(n,e,t){return this.forEachGlyph(n,0,0,e,t,function(){})},R.prototype.draw=function(n,e,t,r,i,s){this.getPath(e,t,r,i,s).draw(n)},R.prototype.drawPoints=function(n,e,t,r,i,s){this.forEachGlyph(e,t,r,i,s,function(o,a,c,l){o.drawPoints(n,a,c,l)})},R.prototype.drawMetrics=function(n,e,t,r,i,s){this.forEachGlyph(e,t,r,i,s,function(o,a,c,l){o.drawMetrics(n,a,c,l)})},R.prototype.getEnglishName=function(n){var e=this.names[n];if(e)return e.en},R.prototype.validate=function(){var n=this;function e(t){var r=n.getEnglishName(t);r&&r.trim().length>0}e("fontFamily"),e("weightName"),e("manufacturer"),e("copyright"),e("version"),this.unitsPerEm>0},R.prototype.toTables=function(){return mc.fontToTable(this)},R.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()},R.prototype.toArrayBuffer=function(){for(var n=this.toTables(),e=n.encode(),t=new ArrayBuffer(e.length),r=new Uint8Array(t),i=0;i<e.length;i++)r[i]=e[i];return t},R.prototype.download=function(n){var e=this.getEnglishName("fontFamily"),t=this.getEnglishName("fontSubfamily");n=n||e.replace(/\s/g,"")+"-"+t+".otf";var r=this.toArrayBuffer();if(vc())if(window.URL=window.URL||window.webkitURL,window.URL){var i=new DataView(r),s=new Blob([i],{type:"font/opentype"}),o=document.createElement("a");o.href=window.URL.createObjectURL(s),o.download=n;var a=document.createEvent("MouseEvents");a.initEvent("click",!0,!1),o.dispatchEvent(a)}else console.warn("Font file could not be downloaded. Try using a different browser.");else{var c=require("fs"),l=bc(r);c.writeFileSync(n,l)}},R.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512},R.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},R.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};function Is(n,e){var t=JSON.stringify(n),r=256;for(var i in e){var s=parseInt(i);if(!(!s||s<256)){if(JSON.stringify(e[i])===t)return s;r<=s&&(r=s+1)}}return e[r]=n,r}function Bh(n,e,t){var r=Is(e.name,t);return[{name:"tag_"+n,type:"TAG",value:e.tag},{name:"minValue_"+n,type:"FIXED",value:e.minValue<<16},{name:"defaultValue_"+n,type:"FIXED",value:e.defaultValue<<16},{name:"maxValue_"+n,type:"FIXED",value:e.maxValue<<16},{name:"flags_"+n,type:"USHORT",value:0},{name:"nameID_"+n,type:"USHORT",value:r}]}function Lh(n,e,t){var r={},i=new L.Parser(n,e);return r.tag=i.parseTag(),r.minValue=i.parseFixed(),r.defaultValue=i.parseFixed(),r.maxValue=i.parseFixed(),i.skip("uShort",1),r.name=t[i.parseUShort()]||{},r}function Oh(n,e,t,r){for(var i=Is(e.name,r),s=[{name:"nameID_"+n,type:"USHORT",value:i},{name:"flags_"+n,type:"USHORT",value:0}],o=0;o<t.length;++o){var a=t[o].tag;s.push({name:"axis_"+n+" "+a,type:"FIXED",value:e.coordinates[a]<<16})}return s}function Mh(n,e,t,r){var i={},s=new L.Parser(n,e);i.name=r[s.parseUShort()]||{},s.skip("uShort",1),i.coordinates={};for(var o=0;o<t.length;++o)i.coordinates[t[o].tag]=s.parseFixed();return i}function Dh(n,e){var t=new k.Table("fvar",[{name:"version",type:"ULONG",value:65536},{name:"offsetToData",type:"USHORT",value:0},{name:"countSizePairs",type:"USHORT",value:2},{name:"axisCount",type:"USHORT",value:n.axes.length},{name:"axisSize",type:"USHORT",value:20},{name:"instanceCount",type:"USHORT",value:n.instances.length},{name:"instanceSize",type:"USHORT",value:4+n.axes.length*4}]);t.offsetToData=t.sizeOf();for(var r=0;r<n.axes.length;r++)t.fields=t.fields.concat(Bh(r,n.axes[r],e));for(var i=0;i<n.instances.length;i++)t.fields=t.fields.concat(Oh(i,n.instances[i],n.axes,e));return t}function Rh(n,e,t){var r=new L.Parser(n,e),i=r.parseULong();O.argument(i===65536,"Unsupported fvar table version.");var s=r.parseOffset16();r.skip("uShort",1);for(var o=r.parseUShort(),a=r.parseUShort(),c=r.parseUShort(),l=r.parseUShort(),h=[],d=0;d<o;d++)h.push(Lh(n,e+s+d*a,t));for(var u=[],p=e+s+o*a,f=0;f<c;f++)u.push(Mh(n,p+f*l,h,t));return{axes:h,instances:u}}var Uh={make:Dh,parse:Rh},Fh=function(){return{coverage:this.parsePointer(x.coverage),attachPoints:this.parseList(x.pointer(x.uShortList))}},Ph=function(){var n=this.parseUShort();if(O.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()}},Gh=function(){return this.parseList(x.pointer(Ph))},Nh=function(){return{coverage:this.parsePointer(x.coverage),ligGlyphs:this.parseList(x.pointer(Gh))}},zh=function(){return this.parseUShort(),this.parseList(x.pointer(x.coverage))};function Vh(n,e){e=e||0;var t=new x(n,e),r=t.parseVersion(1);O.argument(r===1||r===1.2||r===1.3,"Unsupported GDEF table version.");var i={version:r,classDef:t.parsePointer(x.classDef),attachList:t.parsePointer(Fh),ligCaretList:t.parsePointer(Nh),markAttachClassDef:t.parsePointer(x.classDef)};return r>=1.2&&(i.markGlyphSets=t.parsePointer(zh)),i}var Hh={parse:Vh},pe=new Array(10);pe[1]=function(){var n=this.offset+this.relativeOffset,e=this.parseUShort();if(e===1)return{posFormat:1,coverage:this.parsePointer(x.coverage),value:this.parseValueRecord()};if(e===2)return{posFormat:2,coverage:this.parsePointer(x.coverage),values:this.parseValueRecordList()};O.assert(!1,"0x"+n.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")},pe[2]=function(){var n=this.offset+this.relativeOffset,e=this.parseUShort();O.assert(e===1||e===2,"0x"+n.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");var t=this.parsePointer(x.coverage),r=this.parseUShort(),i=this.parseUShort();if(e===1)return{posFormat:e,coverage:t,valueFormat1:r,valueFormat2:i,pairSets:this.parseList(x.pointer(x.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(r),value2:this.parseValueRecord(i)}})))};if(e===2){var s=this.parsePointer(x.classDef),o=this.parsePointer(x.classDef),a=this.parseUShort(),c=this.parseUShort();return{posFormat:e,coverage:t,valueFormat1:r,valueFormat2:i,classDef1:s,classDef2:o,class1Count:a,class2Count:c,classRecords:this.parseList(a,x.list(c,function(){return{value1:this.parseValueRecord(r),value2:this.parseValueRecord(i)}}))}}},pe[3]=function(){return{error:"GPOS Lookup 3 not supported"}},pe[4]=function(){return{error:"GPOS Lookup 4 not supported"}},pe[5]=function(){return{error:"GPOS Lookup 5 not supported"}},pe[6]=function(){return{error:"GPOS Lookup 6 not supported"}},pe[7]=function(){return{error:"GPOS Lookup 7 not supported"}},pe[8]=function(){return{error:"GPOS Lookup 8 not supported"}},pe[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function jh(n,e){e=e||0;var t=new x(n,e),r=t.parseVersion(1);return O.argument(r===1||r===1.1,"Unsupported GPOS table version "+r),r===1?{version:r,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(pe)}:{version:r,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(pe),variations:t.parseFeatureVariationsList()}}var Wh=new Array(10);function Xh(n){return new k.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new k.ScriptList(n.scripts)},{name:"features",type:"TABLE",value:new k.FeatureList(n.features)},{name:"lookups",type:"TABLE",value:new k.LookupList(n.lookups,Wh)}])}var qh={parse:jh,make:Xh};function Yh(n){var e={};n.skip("uShort");var t=n.parseUShort();O.argument(t===0,"Unsupported kern sub-table version."),n.skip("uShort",2);var r=n.parseUShort();n.skip("uShort",3);for(var i=0;i<r;i+=1){var s=n.parseUShort(),o=n.parseUShort(),a=n.parseShort();e[s+","+o]=a}return e}function $h(n){var e={};n.skip("uShort");var t=n.parseULong();t>1&&console.warn("Only the first kern subtable is supported."),n.skip("uLong");var r=n.parseUShort(),i=r&255;if(n.skip("uShort"),i===0){var s=n.parseUShort();n.skip("uShort",3);for(var o=0;o<s;o+=1){var a=n.parseUShort(),c=n.parseUShort(),l=n.parseShort();e[a+","+c]=l}}return e}function Zh(n,e){var t=new L.Parser(n,e),r=t.parseUShort();if(r===0)return Yh(t);if(r===1)return $h(t);throw new Error("Unsupported kern table version ("+r+").")}var Qh={parse:Zh};function Jh(n,e,t,r){for(var i=new L.Parser(n,e),s=r?i.parseUShort:i.parseULong,o=[],a=0;a<t+1;a+=1){var c=s.call(i);r&&(c*=2),o.push(c)}return o}var Kh={parse:Jh};function As(n,e){for(var t=[],r=12,i=0;i<e;i+=1){var s=L.getTag(n,r),o=L.getULong(n,r+4),a=L.getULong(n,r+8),c=L.getULong(n,r+12);t.push({tag:s,checksum:o,offset:a,length:c,compression:!1}),r+=16}return t}function eu(n,e){for(var t=[],r=44,i=0;i<e;i+=1){var s=L.getTag(n,r),o=L.getULong(n,r+4),a=L.getULong(n,r+8),c=L.getULong(n,r+12),l=void 0;a<c?l="WOFF":l=!1,t.push({tag:s,offset:o,compression:l,compressedLength:a,length:c}),r+=20}return t}function z(n,e){if(e.compression==="WOFF"){var t=new Uint8Array(n.buffer,e.offset+2,e.compressedLength-2),r=new Uint8Array(e.length);if(qo(t,r),r.byteLength!==e.length)throw new Error("Decompression error: "+e.tag+" decompressed length doesn't match recorded length");var i=new DataView(r.buffer,0);return{data:i,offset:0}}else return{data:n,offset:e.offset}}function tu(n,e){e=e??{};var t,r,i=new R({empty:!0}),s=new DataView(n,0),o,a=[],c=L.getTag(s,0);if(c==="\0\0\0"||c==="true"||c==="typ1")i.outlinesFormat="truetype",o=L.getUShort(s,4),a=As(s,o);else if(c==="OTTO")i.outlinesFormat="cff",o=L.getUShort(s,4),a=As(s,o);else if(c==="wOFF"){var l=L.getTag(s,4);if(l==="\0\0\0")i.outlinesFormat="truetype";else if(l==="OTTO")i.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+c);o=L.getUShort(s,12),a=eu(s,o)}else throw new Error("Unsupported OpenType signature "+c);for(var h,d,u,p,f,m,y,v,_,w,C,T,D=0;D<o;D+=1){var I=a[D],E=void 0;switch(I.tag){case"cmap":E=z(s,I),i.tables.cmap=pi.parse(E.data,E.offset),i.encoding=new gi(i.tables.cmap);break;case"cvt ":E=z(s,I),T=new L.Parser(E.data,E.offset),i.tables.cvt=T.parseShortList(I.length/2);break;case"fvar":d=I;break;case"fpgm":E=z(s,I),T=new L.Parser(E.data,E.offset),i.tables.fpgm=T.parseByteList(I.length);break;case"head":E=z(s,I),i.tables.head=ki.parse(E.data,E.offset),i.unitsPerEm=i.tables.head.unitsPerEm,t=i.tables.head.indexToLocFormat;break;case"hhea":E=z(s,I),i.tables.hhea=Bi.parse(E.data,E.offset),i.ascender=i.tables.hhea.ascender,i.descender=i.tables.hhea.descender,i.numberOfHMetrics=i.tables.hhea.numberOfHMetrics;break;case"hmtx":y=I;break;case"ltag":E=z(s,I),r=Oi.parse(E.data,E.offset);break;case"maxp":E=z(s,I),i.tables.maxp=Mi.parse(E.data,E.offset),i.numGlyphs=i.tables.maxp.numGlyphs;break;case"name":w=I;break;case"OS/2":E=z(s,I),i.tables.os2=Vn.parse(E.data,E.offset);break;case"post":E=z(s,I),i.tables.post=zi.parse(E.data,E.offset),i.glyphNames=new Un(i.tables.post);break;case"prep":E=z(s,I),T=new L.Parser(E.data,E.offset),i.tables.prep=T.parseByteList(I.length);break;case"glyf":u=I;break;case"loca":_=I;break;case"CFF ":h=I;break;case"kern":v=I;break;case"GDEF":p=I;break;case"GPOS":f=I;break;case"GSUB":m=I;break;case"meta":C=I;break}}var U=z(s,w);if(i.tables.name=Ni.parse(U.data,U.offset,r),i.names=i.tables.name,u&&_){var V=t===0,J=z(s,_),te=Kh.parse(J.data,J.offset,i.numGlyphs,V),$=z(s,u);i.glyphs=es.parse($.data,$.offset,te,i,e)}else if(h){var P=z(s,h);Ei.parse(P.data,P.offset,i,e)}else throw new Error("Font doesn't contain TrueType or CFF outlines.");var H=z(s,y);if(Li.parse(i,H.data,H.offset,i.numberOfHMetrics,i.numGlyphs,i.glyphs,e),fa(i,e),v){var N=z(s,v);i.kerningPairs=Qh.parse(N.data,N.offset)}else i.kerningPairs={};if(p){var X=z(s,p);i.tables.gdef=Hh.parse(X.data,X.offset)}if(f){var Z=z(s,f);i.tables.gpos=qh.parse(Z.data,Z.offset),i.position.init()}if(m){var Y=z(s,m);i.tables.gsub=Vi.parse(Y.data,Y.offset)}if(d){var K=z(s,d);i.tables.fvar=Uh.parse(K.data,K.offset,i.names)}if(C){var F=z(s,C);i.tables.meta=Hi.parse(F.data,F.offset),i.metas=i.tables.meta}return i}function nu(n){return((e,t)=>{const r=Math.round,i={},s=e.encoding.cmap.glyphIndexMap,o=Object.keys(s),a=e.glyphs.glyphs[s[65]];let c=1;a&&(c=e.unitsPerEm/a.yMax);for(let l=0;l<o.length;l++){const h=o[l],d=e.glyphs.glyphs[s[h]];if(h!==void 0){const u={ha:r(d.advanceWidth),x_min:r(d.xMin),x_max:r(d.xMax),o:""};d.path.commands.forEach(function(p){p.type.toLowerCase()==="c"&&(p.type="b"),u.o+=p.type.toLowerCase()+" ",p.x!==void 0&&p.y!==void 0&&(u.o+=r(p.x)+" "+r(p.y)+" "),p.x1!==void 0&&p.y1!==void 0&&(u.o+=r(p.x1)+" "+r(p.y1)+" "),p.x2!==void 0&&p.y2!==void 0&&(u.o+=r(p.x2)+" "+r(p.y2)+" ")}),i[String.fromCodePoint(d.unicode)]=u}}return{glyphs:i,familyName:e.getEnglishName("fullName"),ascender:r(e.ascender),descender:r(e.descender),underlinePosition:e.tables.post.underlinePosition,underlineThickness:e.tables.post.underlineThickness,boundingBox:{xMin:e.tables.head.xMin,xMax:e.tables.head.xMax,yMin:e.tables.head.yMin,yMax:e.tables.head.yMax},resolution:e.unitsPerEm||1e3,scaleFactor:c,original_font_information:e.tables.name}})(tu(n))}class Es extends Ur{constructor(e){super(),this.type="mesh",e instanceof ArrayBuffer?this.data=nu(e):this.data=e,this.font=new Do(this.data)}hasChar(e){return this.data.glyphs[e]!=null}generateShapes(e,t){return this.font.generateShapes(e,t)}getCharShape(e,t){if(!this.data.glyphs[e]){this.addUnsupportedChar(e);return}return new Zr(e,t,this)}getScaleFactor(){return this.scaleFactor==null?(this.scaleFactor=this.data.scaleFactor,this.scaleFactor):this.scaleFactor}getNotFoundTextShape(e){return new Zr("?",e,this)}}let ie=class{static byteToSByte(e){return(e&127)-(e&128?128:0)}constructor(e){this.position=0,this.data=new DataView(e)}readBytes(e=1){this.data.byteLength<this.position+e&&this.throwOutOfRangeError(this.position+e);const t=new Uint8Array(this.data.buffer,this.position,e);return this.position+=e,t}skip(e){this.data.byteLength<this.position+e&&this.throwOutOfRangeError(this.position+e),this.position+=e}readUint8(){this.data.byteLength<this.position+1&&this.throwOutOfRangeError(this.position+1);const e=this.data.getUint8(this.position);return this.position+=1,e}readInt8(){this.data.byteLength<this.position+1&&this.throwOutOfRangeError(this.position+1);const e=this.data.getInt8(this.position);return this.position+=1,e}readUint16(e=!0){this.data.byteLength<this.position+2&&this.throwOutOfRangeError(this.position+2);const t=this.data.getUint16(this.position,e);return this.position+=2,t}readInt16(){this.data.byteLength<this.position+2&&this.throwOutOfRangeError(this.position+2);const e=this.data.getInt16(this.position,!0);return this.position+=2,e}readUint32(){this.data.byteLength<this.position+4&&this.throwOutOfRangeError(this.position+4);const e=this.data.getUint32(this.position,!0);return this.position+=4,e}readInt32(){this.data.byteLength<this.position+4&&this.throwOutOfRangeError(this.position+4);const e=this.data.getInt32(this.position,!0);return this.position+=4,e}readFloat32(){this.data.byteLength<this.position+4&&this.throwOutOfRangeError(this.position+4);const e=this.data.getFloat32(this.position,!0);return this.position+=4,e}readFloat64(){this.data.byteLength<this.position+8&&this.throwOutOfRangeError(this.position+8);const e=this.data.getFloat64(this.position,!0);return this.position+=8,e}setPosition(e){this.data.byteLength<e&&this.throwOutOfRangeError(e),this.position=e}isEnd(){return this.position===this.data.byteLength-1}get currentPosition(){return this.position}get length(){return this.data.byteLength}throwOutOfRangeError(e){throw new Error(`Position ${e} is out of range for the data length ${this.data.byteLength}!`)}};var se=(n=>(n.SHAPES="shapes",n.BIGFONT="bigfont",n.UNIFONT="unifont",n))(se||{});let ru=class{parse(n){const e=this.parseHeader(n).split(" "),t=e[1].toLocaleLowerCase();if(!Object.values(se).includes(t))throw new Error(`Invalid font type: ${t}`);return{fileHeader:e[0],fontType:t,fileVersion:e[2]}}parseHeader(n){let e="",t=0;for(;n.currentPosition<n.length-2&&t<1024;){const r=n.readUint8();if(r===13){const i=n.currentPosition,s=n.readUint8(),o=n.readUint8();if(s===10&&o===26)break;n.setPosition(i),e+=String.fromCharCode(r)}else e+=String.fromCharCode(r);t++}return e.trim()}};class iu{parse(e){try{e.readBytes(4);const t=e.readInt16();if(t<=0)throw new Error("Invalid shape count in font file");const r=[];for(let o=0;o<t;o++){const a=e.readUint16(),c=e.readUint16();c>0&&r.push({code:a,length:c})}const i={};for(const o of r)try{const a=e.readBytes(o.length);a.length===o.length&&(i[o.code]=a)}catch{console.warn(`Failed to read shape data for code ${o.code}`)}const s={data:i,info:"",baseUp:8,baseDown:2,orientation:"horizontal",isExtended:!1};if(0 in i){const o=i[0];try{const a=new TextDecoder().decode(o);let c=a.indexOf("\0");c>=0&&(s.info=a.substring(0,c),c+3<o.length&&(s.baseUp=o[c+1],s.baseDown=o[c+2],s.orientation=o[c+3]===0?"horizontal":"vertical"))}catch{console.warn("Failed to parse font info block")}}return s}catch(t){return console.error("Error parsing shape font:",t),{data:{},info:"Failed to parse font file",baseUp:8,baseDown:2,orientation:"horizontal",isExtended:!1}}}}class su{parse(e){try{e.readInt16();const t=e.readInt16(),r=e.readInt16();if(t<=0)throw new Error("Invalid character count in font file");e.skip(r*4);const i=[];for(let a=0;a<t;a++){const c=e.readUint16(!1),l=e.readUint16(),h=e.readUint32();(c!==0||l!==0||h!==0)&&i.push({code:c,length:l,offset:h})}const s={};for(const a of i)try{e.setPosition(a.offset);const c=e.readBytes(a.length);c.length===a.length&&(s[a.code]=c)}catch{console.warn(`Failed to read bigfont data for code ${a.code}`)}const o={data:s,info:"",baseUp:8,baseDown:2,orientation:"horizontal",isExtended:!1};if(0 in s){const a=s[0];try{const c=this.utf8ArrayToStr(a);let l=c.indexOf("\0");l>=0&&(o.info=c.substring(0,l),l++,l+3<a.length&&(a.length-l===4?(o.baseUp=a[l++],o.baseDown=a[l++],o.orientation=a[l++]===0?"horizontal":"vertical"):(o.baseUp=a[l++],l++,o.orientation=a[l++]===0?"horizontal":"vertical",o.baseDown=a[l++],o.isExtended=!0)))}catch{console.warn("Failed to parse bigfont info block")}}return o}catch(t){return console.error("Error parsing big font:",t),{data:{},info:"Failed to parse font file",baseUp:8,baseDown:2,orientation:"horizontal",isExtended:!1}}}utf8ArrayToStr(e){let t="",r=0;for(;r<e.length;){const i=e[r++];switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:t+=String.fromCharCode(i);break;case 12:case 13:{const s=e[r++];t+=String.fromCharCode((i&31)<<6|s&63);break}case 14:{const s=e[r++],o=e[r++];t+=String.fromCharCode((i&15)<<12|(s&63)<<6|(o&63)<<0);break}}}return t}}class ou{parse(e){try{const t=e.readInt32();if(t<=0)throw new Error("Invalid character count in font file");const r=e.readInt16(),i=e.readBytes(r),s={data:{},info:"",baseUp:8,baseDown:2,orientation:"horizontal",isExtended:!1};try{const a=new TextDecoder().decode(i);let c=a.indexOf("\0");c>=0&&(s.info=a.substring(0,c),c+3<i.length&&(s.baseUp=i[c+1],s.baseDown=i[c+2],s.orientation=i[c+3]===0?"horizontal":"vertical"))}catch{console.warn("Failed to parse unifont info block")}const o={};for(let a=0;a<t-1;a++)try{const c=e.readUint16(),l=e.readUint16();if(l>0){const h=e.readBytes(l);h.length===l&&(o[c]=h)}}catch{console.warn("Failed to read unifont character data");break}return s.data=o,s}catch(t){return console.error("Error parsing unifont:",t),{data:{},info:"Failed to parse font file",baseUp:8,baseDown:2,orientation:"horizontal",isExtended:!1}}}}class au{static createParser(e){switch(e){case se.SHAPES:return new iu;case se.BIGFONT:return new su;case se.UNIFONT:return new ou;default:throw new Error(`Unsupported font type: ${e}`)}}}let W=class Js{constructor(e=0,t=0){this.x=e,this.y=t}set(e,t){return this.x=e,this.y=t,this}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}normalize(){const e=this.length();return e!==0&&(this.x/=e,this.y/=e),this}clone(){return new Js(this.x,this.y)}add(e){return this.x+=e.x,this.y+=e.y,this}subtract(e){return this.x-=e.x,this.y-=e.y,this}multiply(e){return this.x*=e,this.y*=e,this}divide(e){return e!==0&&(this.x/=e,this.y/=e),this}multiplyScalars(e,t){return this.x*=e,this.y*=t,this}divideScalars(e,t){return e!==0&&(this.x/=e),t!==0&&(this.y/=t),this}distanceTo(e){const t=this.x-e.x,r=this.y-e.y;return Math.sqrt(t*t+r*r)}};const ks=Math.PI/4;class Ct{static fromBulge(e,t,r){const i=Math.max(-1,Math.min(1,r));return new Ct({start:e,end:t,bulge:i})}static fromOctant(e,t,r,i,s){return new Ct({center:e,radius:t,startOctant:r,octantCount:i,isClockwise:s})}constructor(e){if(e.start&&e.end&&e.bulge!==void 0){this.start=e.start.clone(),this.end=e.end.clone(),this.bulge=e.bulge,this.isClockwise=e.bulge<0;const t=this.end.clone().subtract(this.start),r=t.length();if(Math.abs(this.bulge)*r/2===0){this.radius=0,this.center=this.start.clone(),this.startAngle=Math.atan2(t.y,t.x),this.endAngle=this.startAngle;return}const i=4*Math.atan(Math.abs(this.bulge));this.radius=r/(2*Math.sin(i/2));const s=this.start.clone().add(t.clone().divide(2)),o=new W(-t.y,t.x);o.normalize(),o.multiply(Math.abs(this.radius*Math.cos(i/2))),this.center=s.clone(),this.isClockwise?this.center.subtract(o):this.center.add(o),this.startAngle=Math.atan2(this.start.y-this.center.y,this.start.x-this.center.x),this.endAngle=Math.atan2(this.end.y-this.center.y,this.end.x-this.center.x),this.isClockwise?this.endAngle>=this.startAngle&&(this.endAngle-=2*Math.PI):this.endAngle<=this.startAngle&&(this.endAngle+=2*Math.PI)}else if(e.center&&e.radius!==void 0&&e.startOctant!==void 0&&e.octantCount!==void 0&&e.isClockwise!==void 0){this.center=e.center.clone(),this.radius=e.radius,this.isClockwise=e.isClockwise,this.startAngle=e.startOctant*ks;const t=(e.octantCount===0?8:e.octantCount)*ks;this.endAngle=this.startAngle+(this.isClockwise?-t:t),this.start=this.center.clone().add(new W(this.radius*Math.cos(this.startAngle),this.radius*Math.sin(this.startAngle))),this.end=this.center.clone().add(new W(this.radius*Math.cos(this.endAngle),this.radius*Math.sin(this.endAngle)))}else throw new Error("Invalid arc parameters")}tessellate(e=Math.PI/18){if(this.radius===0)return[this.start.clone(),this.end.clone()];const t=[this.start.clone()],r=Math.abs(this.endAngle-this.startAngle),i=Math.max(1,Math.floor(r/e));for(let s=1;s<i;s++){const o=s/i,a=this.isClockwise?this.startAngle-o*r:this.startAngle+o*r;t.push(this.center.clone().add(new W(this.radius*Math.cos(a),this.radius*Math.sin(a))))}return t.push(this.end?this.end.clone():this.center.clone().add(new W(this.radius*Math.cos(this.endAngle),this.radius*Math.sin(this.endAngle)))),t}}let nr=class Ks{constructor(e,t=[]){this.lastPoint=e,this.polylines=t}get bbox(){let e=1/0,t=-1/0,r=1/0,i=-1/0;return this.polylines.forEach(s=>{s.forEach(o=>{e=Math.min(e,o.x),t=Math.max(t,o.x),r=Math.min(r,o.y),i=Math.max(i,o.y)})}),{minX:e,minY:r,maxX:t,maxY:i}}offset(e,t=!0){var r,i;return t?new Ks((r=this.lastPoint)==null?void 0:r.clone().add(e),this.polylines.map(s=>s.map(o=>o.clone().add(e)))):((i=this.lastPoint)==null||i.add(e),this.polylines.forEach(s=>s.forEach(o=>o.add(e))),this)}toSVG(e={}){const{strokeWidth:t="0.5%",strokeColor:r="black",isAutoFit:i=!1}=e;let s,o;if(i){const a=this.bbox,c=.2,l=a.maxX-a.minX,h=a.maxY-a.minY,d=a.minX-l*c,u=a.maxX+l*c,p=a.minY-h*c,f=a.maxY+h*c;o=this.polylines.map(m=>{let y="";return m.forEach((v,_)=>{const w=v.x,C=-v.y;y+=_===0?`M ${w} ${C} `:`L ${w} ${C} `}),`<path d="${y}" stroke="${r}" stroke-width="${t}" fill="none"/>`}).join(""),s=`${d} ${-f} ${u-d} ${f-p}`}else s="0 0 20 20",o=this.polylines.map(a=>{let c="";return a.forEach((l,h)=>{const d=l.x+5,u=-l.y+15;c+=h===0?`M ${d} ${u} `:`L ${d} ${u} `}),`<path d="${c}" stroke="${r}" stroke-width="${t}" fill="none"/>`}).join("");return`<svg width="100%" height="100%" viewBox="${s}" preserveAspectRatio="xMidYMid meet">${o}</svg>`}};const cu=Math.PI/18,Bs=12;let lu=class{constructor(n){this.shapeCache=new Map,this.shapeData=new Map,this.fontData=n}release(){this.shapeCache.clear(),this.shapeData.clear()}parse(n,e){var t;const r=`${n}_${e}`;if(this.shapeCache.has(r))return this.shapeCache.get(r);if(n===0)return;const i=this.fontData.content.data;let s;if(!this.shapeData.has(n)&&i[n]){const o=i[n],a=Bs/this.fontData.content.baseUp;s=this.parseShape(o,a),this.shapeData.set(n,s)}if(this.shapeData.has(n)){const o=e/Bs,a=this.shapeData.get(n);s=new nr((t=a.lastPoint)==null?void 0:t.clone().multiply(o),a.polylines.map(c=>c.map(l=>l.clone().multiply(o))))}return s}parseShape(n,e){const t={currentPoint:new W,polylines:[],currentPolyline:[],sp:[],isPenDown:!1,scale:e};for(let r=0;r<n.length;r++){const i=n[r];i<=15?r=this.handleSpecialCommand(i,n,r,t):this.handleVectorCommand(i,t)}return new nr(t.currentPoint,t.polylines)}handleSpecialCommand(n,e,t,r){let i=t;switch(n){case 0:r.currentPolyline=[],r.isPenDown=!1;break;case 1:r.isPenDown=!0,r.currentPolyline.push(r.currentPoint.clone());break;case 2:r.isPenDown=!1,r.currentPolyline.length>1&&r.polylines.push(r.currentPolyline.slice()),r.currentPolyline=[];break;case 3:i++,r.scale/=e[i];break;case 4:i++,r.scale*=e[i];break;case 5:if(r.sp.length===4)throw new Error("The position stack is only four locations deep");r.sp.push(r.currentPoint.clone());break;case 6:r.currentPoint=r.sp.pop()??r.currentPoint;break;case 7:i=this.handleSubshapeCommand(e,i,r);break;case 8:i=this.handleXYDisplacement(e,i,r);break;case 9:i=this.handleMultipleXYDisplacements(e,i,r);break;case 10:i=this.handleOctantArc(e,i,r);break;case 11:i=this.handleFractionalArc(e,i,r);break;case 12:i=this.handleBulgeArc(e,i,r);break;case 13:i=this.handleMultipleBulgeArcs(e,i,r);break;case 14:i=this.skipCode(e,++i);break}return i}handleVectorCommand(n,e){const t=(n&240)>>4,r=n&15,i=this.getVectorForDirection(r);e.currentPoint.add(i.multiply(t*e.scale)),e.isPenDown&&e.currentPolyline.push(e.currentPoint.clone())}getVectorForDirection(n){const e=new W;switch(n){case 0:e.x=1;break;case 1:e.x=1,e.y=.5;break;case 2:e.x=1,e.y=1;break;case 3:e.x=.5,e.y=1;break;case 4:e.y=1;break;case 5:e.x=-.5,e.y=1;break;case 6:e.x=-1,e.y=1;break;case 7:e.x=-1,e.y=.5;break;case 8:e.x=-1;break;case 9:e.x=-1,e.y=-.5;break;case 10:e.x=-1,e.y=-1;break;case 11:e.x=-.5,e.y=-1;break;case 12:e.y=-1;break;case 13:e.x=.5,e.y=-1;break;case 14:e.x=1,e.y=-1;break;case 15:e.x=1,e.y=-.5;break}return e}handleSubshapeCommand(n,e,t){let r=e,i=0,s,o=t.scale*this.fontData.content.baseUp,a=o;const c=t.currentPoint.clone();switch(t.currentPolyline.length>1&&(t.polylines.push(t.currentPolyline.slice()),t.currentPolyline=[]),this.fontData.header.fontType){case se.SHAPES:r++,i=n[r];break;case se.BIGFONT:r++,i=n[r],i===0&&(r++,i=n[r++]|n[r++]<<8,c.x=n[r++]*t.scale,c.y=n[r++]*t.scale,this.fontData.content.isExtended&&(a=n[r++]*t.scale),o=n[r]*t.scale);break;case se.UNIFONT:r++,i=n[r++]|n[r++]<<8;break}return i!==0&&(s=this.getShapeByCodeWithOffset(i,a,o,c),s&&(t.polylines.push(...s.polylines.slice()),t.currentPoint=s.lastPoint?s.lastPoint.clone():c.clone())),t.currentPolyline=[],r}handleXYDisplacement(n,e,t){let r=e;const i=new W;return i.x=ie.byteToSByte(n[++r]),i.y=ie.byteToSByte(n[++r]),t.currentPoint.add(i.multiply(t.scale)),t.isPenDown&&t.currentPolyline.push(t.currentPoint.clone()),r}handleMultipleXYDisplacements(n,e,t){let r=e;for(;;){const i=new W;if(i.x=ie.byteToSByte(n[++r]),i.y=ie.byteToSByte(n[++r]),i.x===0&&i.y===0)break;t.currentPoint.add(i.multiply(t.scale)),t.isPenDown&&t.currentPolyline.push(t.currentPoint.clone())}return r}handleOctantArc(n,e,t){var r;let i=e;const s=n[++i]*t.scale,o=ie.byteToSByte(n[++i]),a=(o&112)>>4;let c=o&7;const l=o<0,h=Math.PI/4*a,d=t.currentPoint.clone().subtract(new W(Math.cos(h)*s,Math.sin(h)*s)),u=Ct.fromOctant(d,s,a,c,l);if(t.isPenDown){const p=u.tessellate();t.currentPolyline.pop(),t.currentPolyline.push(...p.slice())}return t.currentPoint=(r=u.tessellate().pop())==null?void 0:r.clone(),i}handleFractionalArc(n,e,t){let r=e;const i=n[++r],s=n[++r],o=n[++r],a=n[++r],c=(o*255+a)*t.scale,l=ie.byteToSByte(n[++r]),h=(l&112)>>4;let d=l&7;d===0&&(d=8),s!==0&&d--;const u=Math.PI/4;let p=u*d,f=cu,m=1;l<0&&(f=-f,p=-p,m=-1);let y=u*h,v=y+p;y+=u*i/256*m,v+=u*s/256*m;const _=t.currentPoint.clone().subtract(new W(c*Math.cos(y),c*Math.sin(y)));if(t.currentPoint=_.clone().add(new W(c*Math.cos(v),c*Math.sin(v))),t.isPenDown){let w=y;const C=[];if(C.push(_.clone().add(new W(c*Math.cos(w),c*Math.sin(w)))),f>0)for(;w+f<v;)w+=f,C.push(_.clone().add(new W(c*Math.cos(w),c*Math.sin(w))));else for(;w+f>v;)w+=f,C.push(_.clone().add(new W(c*Math.cos(w),c*Math.sin(w))));C.push(_.clone().add(new W(c*Math.cos(v),c*Math.sin(v)))),t.currentPolyline.push(...C)}return r}handleBulgeArc(n,e,t){let r=e;const i=new W;i.x=ie.byteToSByte(n[++r]),i.y=ie.byteToSByte(n[++r]);const s=ie.byteToSByte(n[++r]);return t.currentPoint=this.handleArcSegment(t.currentPoint,i,s,t.scale,t.isPenDown,t.currentPolyline),r}handleMultipleBulgeArcs(n,e,t){let r=e;for(;;){const i=new W;if(i.x=ie.byteToSByte(n[++r]),i.y=ie.byteToSByte(n[++r]),i.x===0&&i.y===0)break;const s=ie.byteToSByte(n[++r]);t.currentPoint=this.handleArcSegment(t.currentPoint,i,s,t.scale,t.isPenDown,t.currentPolyline)}return r}skipCode(n,e){switch(n[e]){case 0:break;case 1:break;case 2:break;case 3:case 4:e++;break;case 5:break;case 6:break;case 7:switch(this.fontData.header.fontType){case se.SHAPES:e++;break;case se.BIGFONT:e++,n[e]===0&&(e+=5);break;case se.UNIFONT:e+=2;break}break;case 8:e+=2;break;case 9:for(;;){const t=n[++e],r=n[++e];if(t===0&&r===0)break}break;case 10:e+=2;break;case 11:e+=5;break;case 12:e+=3;break;case 13:for(;;){const t=n[++e],r=n[++e];if(t===0&&r===0)break;e++}break}return e}getShapeByCodeWithOffset(n,e,t,r){var i;const s=this.parse(n,t);if(s){if(e===t)return s.offset(r);{const o=(i=s.lastPoint)==null?void 0:i.clone();o&&(o.x*=e/t);const a=s.polylines.map(c=>c.map(l=>l.clone()));return a.forEach(c=>c.forEach(l=>l.x*=e/t)),new nr(o==null?void 0:o.add(r),a.map(c=>c.map(l=>l.add(r))))}}}handleArcSegment(n,e,t,r,i,s){e.x*=r,e.y*=r,t<-127&&(t=-127);const o=n.clone();if(i)if(t===0)s.push(o.clone().add(e));else{const a=o.clone().add(e),c=Ct.fromBulge(o,a,t/127).tessellate();s.push(...c.slice(1))}return o.add(e),o}};class hu{constructor(e){if(e instanceof ArrayBuffer){const t=new ie(e),r=new ru().parse(t),i=au.createParser(r.fontType).parse(t);this.fontData={header:r,content:i}}else this.fontData=e;this.shapeParser=new lu(this.fontData)}hasChar(e){return this.fontData.content.data[e]!==void 0}getCharShape(e,t){return this.shapeParser.parse(e,t)}release(){this.shapeParser.release()}}class rr extends Fr{constructor(e,t,r,i){super(e),this.fontSize=t,this.shape=r,this.font=i,this.width=this.calcWidth()}calcWidth(){const e=this.shape.bbox;return e.maxX-e.minX}offset(e){return new rr(this.char,this.fontSize,this.shape.offset(e),this.font)}toGeometry(){let e=this.font.cache.getGeometry(this.char,this.fontSize);if(e==null){const t=this.shape.polylines,r=[],i=[];let s=0;e=new g.BufferGeometry;for(let o=0;o<t.length;o++){const a=t[o];for(let c=0;c<a.length;c++){const l=a[c];r.push(l.x,l.y,0),c===a.length-1||i.push(s,s+1),s++}}e.setAttribute("position",new g.Float32BufferAttribute(r,3)),e.setIndex(i)}return e}}class Ls extends Ur{constructor(e){super(),this.type="shx",this.font=new hu(e),this.data=this.font.fontData}hasChar(e){const t=e.charCodeAt(0);return this.font.hasChar(t)}generateShapes(e,t){const r=[];let i=0;for(let s=0;s<e.length;s++){const o=e[s];if(o===" "){i+=t;continue}const a=this.getCharShape(o,t);if(!a){i+=t,this.addUnsupportedChar(o);continue}r.push(a.offset(new W(i,0))),i+=a.width}return r}getScaleFactor(){return 1}getCharShape(e,t){let r=this.getCode(e);const i=this.font.getCharShape(r,t);return i?new rr(e,t,i,this):void 0}getNotFoundTextShape(e){let t=this.font.fontData.header.fontType===se.BIGFONT?"?":"?";return this.getCharShape(t,e)}getCode(e){if(this.font.fontData.header.fontType===se.BIGFONT)throw new Error(`Can't get font glyph for '${e}' because big font is not supported yet!`);return e.charCodeAt(0)}}class Pe{constructor(){}static get instance(){return Pe._instance||(Pe._instance=new Pe),Pe._instance}createFont(e){if(e.type==="shx")return new Ls(e.data);if(e.type==="mesh")return new Es(e.data);throw new Error("Unsupported font data type")}createFontFromBuffer(e,t){const r=Lo(e).toLowerCase();if(r==="shx")return new Ls(t);if(["ttf","otf","woff"].includes(r))return new Es(t);throw new Error(`Unsupported font file type: ${r}`)}}class fe{constructor(){this.fontMapping={},this.fontMap=new Map,this.unsupportedChars={},this.missedFonts={},this.enableFontCache=!0,this.defaultFont="simsun",this.events={fontNotFound:new Rr,fontLoaded:new Rr},this.loader=new g.FileLoader,this.loader.setResponseType("arraybuffer"),this.fileNames=[]}static get instance(){return fe._instance||(fe._instance=new fe),fe._instance}setFontMapping(e){this.fontMapping=e}async loadFonts(e){e=Array.isArray(e)?e:[e];const t=[];for(let i=0;i<e.length;i++){const s=e[i];t.push(this.loadFont(s))}const r=[];return await Promise.allSettled(t).then(i=>{i.forEach((s,o)=>{const a=s.status==="fulfilled",c=e[o],l=Xr(c.toLowerCase());r.push({fontName:l,url:c,status:a}),a&&this.fileNames.push(l)})}),r}findAndReplaceFont(e){let t=this.fontMap.get(e.toLowerCase());if(t==null){const r=this.fontMapping[e];if(r)return t=this.fontMap.get(r.toLowerCase()),r}return t?e:this.defaultFont}getFontByName(e,t=!0){if(this.fontMap.size===0)return;e==null&&(e="");let r=this.fontMap.get(e.toLowerCase());if(!r){t&&this.recordMissedFonts(e);return}return r}getFontByChar(e){for(const[,t]of this.fontMap)if(t.hasChar(e))return t}getCharShape(e,t,r){let i=this.getFontByName(t);return i||(i=this.getFontByChar(e)),i==null?void 0:i.getCharShape(e,r)}getFontScaleFactor(e){const t=this.fontMap.get(e.toLowerCase());return t?t.getScaleFactor():1}getFontType(e){const t=this.fontMap.get(e.toLowerCase());return t==null?void 0:t.type}getNotFoundTextShape(e){for(const[,t]of this.fontMap){const r=t.getNotFoundTextShape(e);if(r)return r}}isFontLoaded(e){return this.fontMap.has(e.toLowerCase())}recordMissedFonts(e){e&&(this.missedFonts[e]||(this.missedFonts[e]=0),this.missedFonts[e]++,this.events.fontNotFound.dispatch({fontName:e,count:this.missedFonts[e]}))}async loadFont(e){const t=Wr(e);if(!t)throw new Error(`Invalid font url: ${e}`);const r=Xr(e).toLowerCase(),i=await In.instance.get(r);if(i){const s=Pe.instance.createFont(i);this.fontMap.set(r,s)}else{const s=await this.loader.loadAsync(e),o=Pe.instance.createFontFromBuffer(t,s);o&&(this.fontMap.set(r,o),this.enableFontCache&&await In.instance.set(r,{name:r,type:o.type,data:o.data}))}this.events.fontLoaded.dispatch({fontName:r})}async getAllFontsFromCache(){if(this.fontMap.size!==0)return;const e=await In.instance.getAll();for(const t of e){const{name:r}=t;if(this.fileNames&&!this.fileNames.includes(r))continue;const i=Pe.instance.createFont(t);this.fontMap.set(r,i)}}getUnsupportedChar(){for(const[,e]of this.fontMap)Object.assign(this.unsupportedChars,e.unsupportedChars);return this.unsupportedChars}release(e){return e==null?(this.fontMap.clear(),!0):this.fontMap.delete(e)}}var It=(n=>(n[n.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",n[n.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",n[n.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",n[n.BOTTOM_TO_TOP=4]="BOTTOM_TO_TOP",n[n.BY_STYLE=5]="BY_STYLE",n))(It||{}),tt=(n=>(n[n.NONE=0]="NONE",n[n.WORD=1]="WORD",n[n.STACK=2]="STACK",n[n.SPACE=3]="SPACE",n[n.NBSP=4]="NBSP",n[n.TABULATOR=5]="TABULATOR",n[n.NEW_PARAGRAPH=6]="NEW_PARAGRAPH",n[n.NEW_COLUMN=7]="NEW_COLUMN",n[n.WRAP_AT_DIMLINE=8]="WRAP_AT_DIMLINE",n[n.PROPERTIES_CHANGED=9]="PROPERTIES_CHANGED",n))(tt||{}),At=(n=>(n[n.BOTTOM=0]="BOTTOM",n[n.MIDDLE=1]="MIDDLE",n[n.TOP=2]="TOP",n))(At||{}),ge=(n=>(n[n.DEFAULT=0]="DEFAULT",n[n.LEFT=1]="LEFT",n[n.RIGHT=2]="RIGHT",n[n.CENTER=3]="CENTER",n[n.JUSTIFIED=4]="JUSTIFIED",n[n.DISTRIBUTED=5]="DISTRIBUTED",n))(ge||{});const uu={c:"Ø",d:"°",p:"±"},du={l:1,r:2,c:3,j:4,d:5};function pu(n,e=!1){const t=new Set,r=/\\[fF](.*?)[;|]/g;return[...n.matchAll(r)].forEach(i=>{let s=i[1].toLowerCase();e&&(s=s.replace(/\.(ttf|otf|woff|shx)$/,"")),t.add(s)}),t}class fu{constructor(e){this.stack=[],this.stack.push(e)}push(e){this.stack.push(e)}pop(){if(this.stack.length<=1)return;const e=this.stack.pop(),t=this.stack[this.stack.length-1];return JSON.stringify(t.paragraph)!==JSON.stringify(e.paragraph)&&(t.paragraph={...e.paragraph}),e}get current(){return this.stack[this.stack.length-1]}get depth(){return this.stack.length-1}get root(){return this.stack[0]}setCurrent(e){this.stack[this.stack.length-1]=e}}class gu{constructor(e,t,r={}){this.continueStroke=!1,this.inStackContext=!1,this.scanner=new ir(e);const i=t??new Et;this.ctxStack=new fu(i),this.yieldPropertyCommands=r.yieldPropertyCommands??!1,this.resetParagraphParameters=r.resetParagraphParameters??!1}decodeMultiByteChar(e){try{const t=new Uint8Array([parseInt(e.substr(0,2),16),parseInt(e.substr(2,2),16)]),r=new TextDecoder("gbk").decode(t);if(r!=="▯")return r;const i=new TextDecoder("big5").decode(t);return i!=="▯"?i:"▯"}catch{return"▯"}}pushCtx(){this.ctxStack.push(this.ctxStack.current)}popCtx(){this.ctxStack.pop()}parseStacking(){const e=new ir(this.extractExpression(!0));let t="",r="",i="";const s=()=>{let c=e.peek(),l=!1;return c.charCodeAt(0)<32&&(c=" "),c==="\\"&&(l=!0,e.consume(1),c=e.peek()),e.consume(1),[c,l]},o=()=>{let c="";for(;e.hasData;){const[l,h]=s();if(!h&&(l==="/"||l==="#"||l==="^"))return[c,l];c+=l}return[c,""]},a=c=>{let l="",h=c;for(;e.hasData;){const[d,u]=s();if(!(h&&d===" ")){if(h=!1,!u&&d===";")break;l+=d}}return l};return[t,i]=o(),i&&(r=a(i==="^")),t===""&&r.includes("I/")?[2,[" "," ","/"]]:i==="^"?[2,[t,r,"^"]]:[2,[t,r,i]]}parseProperties(e){const t=this.ctxStack.current.copy(),r=this.ctxStack.current.copy();switch(e){case"L":r.underline=!0,this.continueStroke=!0;break;case"l":r.underline=!1,r.hasAnyStroke||(this.continueStroke=!1);break;case"O":r.overline=!0,this.continueStroke=!0;break;case"o":r.overline=!1,r.hasAnyStroke||(this.continueStroke=!1);break;case"K":r.strikeThrough=!0,this.continueStroke=!0;break;case"k":r.strikeThrough=!1,r.hasAnyStroke||(this.continueStroke=!1);break;case"A":this.parseAlign(r);break;case"C":this.parseAciColor(r);break;case"c":this.parseRgbColor(r);break;case"H":this.parseHeight(r);break;case"W":this.parseWidth(r);break;case"Q":this.parseOblique(r);break;case"T":this.parseCharTracking(r);break;case"p":this.parseParagraphProperties(r);break;case"f":case"F":this.parseFontProperties(r);break;default:throw new Error(`Unknown command: ${e}`)}if(this.continueStroke=r.hasAnyStroke,r.continueStroke=this.continueStroke,this.ctxStack.setCurrent(r),this.yieldPropertyCommands){const i=this.getPropertyChanges(t,r);if(Object.keys(i).length>0)return{command:e,changes:i,depth:this.ctxStack.depth}}}getPropertyChanges(e,t){const r={};if(e.underline!==t.underline&&(r.underline=t.underline),e.overline!==t.overline&&(r.overline=t.overline),e.strikeThrough!==t.strikeThrough&&(r.strikeThrough=t.strikeThrough),e.color.aci!==t.color.aci&&(r.aci=t.color.aci),e.color.rgbValue!==t.color.rgbValue&&(r.rgb=t.color.rgb),e.align!==t.align&&(r.align=t.align),JSON.stringify(e.fontFace)!==JSON.stringify(t.fontFace)&&(r.fontFace=t.fontFace),(e.capHeight.value!==t.capHeight.value||e.capHeight.isRelative!==t.capHeight.isRelative)&&(r.capHeight=t.capHeight),(e.widthFactor.value!==t.widthFactor.value||e.widthFactor.isRelative!==t.widthFactor.isRelative)&&(r.widthFactor=t.widthFactor),(e.charTrackingFactor.value!==t.charTrackingFactor.value||e.charTrackingFactor.isRelative!==t.charTrackingFactor.isRelative)&&(r.charTrackingFactor=t.charTrackingFactor),e.oblique!==t.oblique&&(r.oblique=t.oblique),JSON.stringify(e.paragraph)!==JSON.stringify(t.paragraph)){const i={};e.paragraph.indent!==t.paragraph.indent&&(i.indent=t.paragraph.indent),e.paragraph.align!==t.paragraph.align&&(i.align=t.paragraph.align),e.paragraph.left!==t.paragraph.left&&(i.left=t.paragraph.left),e.paragraph.right!==t.paragraph.right&&(i.right=t.paragraph.right),JSON.stringify(e.paragraph.tabs)!==JSON.stringify(t.paragraph.tabs)&&(i.tabs=t.paragraph.tabs),Object.keys(i).length>0&&(r.paragraph=i)}return r}parseAlign(e){const t=this.scanner.get();"012".includes(t)?e.align=parseInt(t):e.align=0,this.consumeOptionalTerminator()}parseHeight(e){const t=this.extractFloatExpression(!0);if(t)try{t.endsWith("x")?e.capHeight={value:parseFloat(t.slice(0,-1)),isRelative:!0}:e.capHeight={value:parseFloat(t),isRelative:!1}}catch{this.scanner.consume(-t.length);return}this.consumeOptionalTerminator()}parseWidth(e){const t=this.extractFloatExpression(!0);if(t)try{t.endsWith("x")?e.widthFactor={value:parseFloat(t.slice(0,-1)),isRelative:!0}:e.widthFactor={value:parseFloat(t),isRelative:!1}}catch{this.scanner.consume(-t.length);return}this.consumeOptionalTerminator()}parseCharTracking(e){const t=this.extractFloatExpression(!0);if(t)try{t.endsWith("x")?e.charTrackingFactor={value:Math.abs(parseFloat(t.slice(0,-1))),isRelative:!0}:e.charTrackingFactor={value:Math.abs(parseFloat(t)),isRelative:!1}}catch{this.scanner.consume(-t.length);return}this.consumeOptionalTerminator()}parseFloatValueOrFactor(e){const t=this.extractFloatExpression(!0);if(t)if(t.endsWith("x")){const r=parseFloat(t.slice(0,-1));e*=r}else e=parseFloat(t);return e}parseOblique(e){const t=this.extractFloatExpression(!1);t&&(e.oblique=parseFloat(t)),this.consumeOptionalTerminator()}parseAciColor(e){const t=this.extractIntExpression();if(t){const r=parseInt(t);r<257&&(e.color.aci=r)}this.consumeOptionalTerminator()}parseRgbColor(e){const t=this.extractIntExpression();if(t){const r=parseInt(t)&16777215;e.color.rgbValue=r}this.consumeOptionalTerminator()}extractFloatExpression(e=!1){const t=e?/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?x?/:/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/,r=this.scanner.tail.match(t);if(r){const i=r[0];return this.scanner.consume(i.length),i}return""}extractIntExpression(){const e=this.scanner.tail.match(/^\d+/);if(e){const t=e[0];return this.scanner.consume(t.length),t}return""}extractExpression(e=!1){const t=this.scanner.find(";",e);if(t<0){const s=this.scanner.tail;return this.scanner.consume(s.length),s}const r=this.scanner.peek(t-this.scanner.currentIndex-1)==="\\",i=this.scanner.tail.slice(0,t-this.scanner.currentIndex+(r?1:0));return this.scanner.consume(i.length+1),i}parseFontProperties(e){const t=this.extractExpression().split("|");if(t.length>0&&t[0]){const r=t[0];let i="Regular",s=400;for(const o of t.slice(1))o.startsWith("b1")?s=700:o==="i"||o.startsWith("i1")?i="Italic":(o==="i0"||o.startsWith("i0"))&&(i="Regular");e.fontFace={family:r,style:i,weight:s}}}parseParagraphProperties(e){const t=new ir(this.extractExpression());let r=e.paragraph.indent,i=e.paragraph.left,s=e.paragraph.right,o=e.paragraph.align,a=[];const c=()=>{const l=t.tail.match(/^[+-]?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/);if(l){const h=parseFloat(l[0]);for(t.consume(l[0].length);t.peek()===",";)t.consume(1);return h}return 0};for(;t.hasData;)switch(t.get()){case"i":r=c();break;case"l":i=c();break;case"r":s=c();break;case"x":break;case"q":{const l=t.get();for(o=du[l]||0;t.peek()===",";)t.consume(1);break}case"t":for(a=[];t.hasData;){const l=t.peek();if(l==="r"||l==="c"){t.consume(1);const h=c();a.push(l+h.toString())}else{const h=c();isNaN(h)?t.consume(1):a.push(h)}}break}e.paragraph={indent:r,left:i,right:s,align:o,tabs:a}}consumeOptionalTerminator(){this.scanner.peek()===";"&&this.scanner.consume(1)}*parse(){let e=null;function t(i){const s={...i.paragraph};i.paragraph={indent:0,left:0,right:0,align:0,tabs:[]};const o={};return s.indent!==0&&(o.indent=0),s.left!==0&&(o.left=0),s.right!==0&&(o.right=0),s.align!==0&&(o.align=0),JSON.stringify(s.tabs)!==JSON.stringify([])&&(o.tabs=[]),o}const r=()=>{var i;let s="";for(;this.scanner.hasData;){let o=!1,a=this.scanner.peek();const c=this.scanner.currentIndex;if(a.charCodeAt(0)<32){if(this.scanner.consume(1),a===" ")return[5,null];if(a===`
25
+ </svg>`}}const Ye=new Pt;class yo{convert(){const e=ce.instance.curDocument.database.tables.blockTable.modelSpace.newIterator(),t=new mo;for(const r of e)r.draw(t);this.createFileAndDownloadIt(t.export())}createFileAndDownloadIt(e){const t=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),r=URL.createObjectURL(t),i=document.createElement("a");i.href=r,i.download="example.svg",document.body.appendChild(i),i.click()}}class Ar extends Be{execute(e){new yo().convert()}}class Er extends Be{execute(e){Ce.emit("open-file",{})}}class kr extends Be{execute(e){ce.instance.openUrl("https://cdn.jsdelivr.net/gh/mlight-lee/cad-data/templates/"+"acadiso.dxf")}}class Br extends Be{execute(e){e.view.mode=Ie.SELECTION,e.view.setCursor(qe.Crosshair)}}class Lr extends Be{execute(e){const t=e.doc.database;e.view.zoomTo(new x.AcGeBox2d(t.extmin,t.extmax),1.1)}}class Or extends wr{constructor(e){super(e)}async sampler(){await ce.instance.editor.getSelection().then(e=>this.view.zoomTo(e,1))}}class Mr extends Be{async execute(e){await new Or(e.view).drag()}}class Dr extends Be{execute(e){e.view.mode=Ie.PAN,e.view.setCursor(qe.Grab)}}class Rr{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}removeEventListener(e){this.listeners=this.listeners.filter(t=>t!==e)}replaceEventListener(e){this.removeEventListener(e),this.addEventListener(e)}dispatch(e,...t){for(const r of this.listeners)r.call(null,e,...t)}}class vo{constructor(){this.cache=new Map}hasGeometry(e,t){const r=this.generateKey(e,t);return this.cache.has(r)}getGeometry(e,t){const r=this.generateKey(e,t);if(this.cache.has(r))return this.cache.get(r)}setGeometry(e,t,r){const i=this.generateKey(e,t);this.cache.set(i,r)}dispose(){for(const e of this.cache.values())e.dispose();this.cache.clear()}generateKey(e,t){return`${e}_${t}`}}class Ur{constructor(){this.unsupportedChars={},this.cache=new vo}addUnsupportedChar(e){this.unsupportedChars[e]||(this.unsupportedChars[e]=0),this.unsupportedChars[e]++}}class Fr extends g.Shape{constructor(e){super(),this.width=0,this.char=e}}const yn=(n,e)=>e.some(t=>n instanceof t);let Pr,Gr;function bo(){return Pr||(Pr=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function xo(){return Gr||(Gr=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const vn=new WeakMap,bn=new WeakMap,Gt=new WeakMap;function So(n){const e=new Promise((t,r)=>{const i=()=>{n.removeEventListener("success",s),n.removeEventListener("error",o)},s=()=>{t(Ne(n.result)),i()},o=()=>{r(n.error),i()};n.addEventListener("success",s),n.addEventListener("error",o)});return Gt.set(e,n),e}function wo(n){if(vn.has(n))return;const e=new Promise((t,r)=>{const i=()=>{n.removeEventListener("complete",s),n.removeEventListener("error",o),n.removeEventListener("abort",o)},s=()=>{t(),i()},o=()=>{r(n.error||new DOMException("AbortError","AbortError")),i()};n.addEventListener("complete",s),n.addEventListener("error",o),n.addEventListener("abort",o)});vn.set(n,e)}let xn={get(n,e,t){if(n instanceof IDBTransaction){if(e==="done")return vn.get(n);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return Ne(n[e])},set(n,e,t){return n[e]=t,!0},has(n,e){return n instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in n}};function Nr(n){xn=n(xn)}function _o(n){return xo().includes(n)?function(...e){return n.apply(Sn(this),e),Ne(this.request)}:function(...e){return Ne(n.apply(Sn(this),e))}}function To(n){return typeof n=="function"?_o(n):(n instanceof IDBTransaction&&wo(n),yn(n,bo())?new Proxy(n,xn):n)}function Ne(n){if(n instanceof IDBRequest)return So(n);if(bn.has(n))return bn.get(n);const e=To(n);return e!==n&&(bn.set(n,e),Gt.set(e,n)),e}const Sn=n=>Gt.get(n);function Co(n,e,{blocked:t,upgrade:r,blocking:i,terminated:s}={}){const o=indexedDB.open(n,e),a=Ne(o);return r&&o.addEventListener("upgradeneeded",c=>{r(Ne(o.result),c.oldVersion,c.newVersion,Ne(o.transaction),c)}),t&&o.addEventListener("blocked",c=>t(c.oldVersion,c.newVersion,c)),a.then(c=>{s&&c.addEventListener("close",()=>s()),i&&c.addEventListener("versionchange",l=>i(l.oldVersion,l.newVersion,l))}).catch(()=>{}),a}const Io=["get","getKey","getAll","getAllKeys","count"],Ao=["put","add","delete","clear"],wn=new Map;function zr(n,e){if(!(n instanceof IDBDatabase&&!(e in n)&&typeof e=="string"))return;if(wn.get(e))return wn.get(e);const t=e.replace(/FromIndex$/,""),r=e!==t,i=Ao.includes(t);if(!(t in(r?IDBIndex:IDBObjectStore).prototype)||!(i||Io.includes(t)))return;const s=async function(o,...a){const c=this.transaction(o,i?"readwrite":"readonly");let l=c.store;return r&&(l=l.index(a.shift())),(await Promise.all([l[t](...a),i&&c.done]))[0]};return wn.set(e,s),s}Nr(n=>({...n,get:(e,t,r)=>zr(e,t)||n.get(e,t,r),has:(e,t)=>!!zr(e,t)||n.has(e,t)}));const Eo=["continue","continuePrimaryKey","advance"],Vr={},_n=new WeakMap,Hr=new WeakMap,ko={get(n,e){if(!Eo.includes(e))return n[e];let t=Vr[e];return t||(t=Vr[e]=function(...r){_n.set(this,Hr.get(this)[e](...r))}),t}};async function*Bo(...n){let e=this;if(e instanceof IDBCursor||(e=await e.openCursor(...n)),!e)return;e=e;const t=new Proxy(e,ko);for(Hr.set(t,e),Gt.set(t,Sn(e));e;)yield t,e=await(_n.get(t)||e.continue()),_n.delete(t)}function jr(n,e){return e===Symbol.asyncIterator&&yn(n,[IDBIndex,IDBObjectStore,IDBCursor])||e==="iterate"&&yn(n,[IDBIndex,IDBObjectStore])}Nr(n=>({...n,get(e,t,r){return jr(e,t)?Bo:n.get(e,t,r)},has(e,t){return jr(e,t)||n.has(e,t)}}));const $e={fonts:"fonts"},Tn=[{version:1,stores:[{name:$e.fonts,keyPath:"name"}]}],Cn=class Te{constructor(){this.isClosing=!1,typeof window<"u"&&window.addEventListener("unload",()=>{this.close()})}static get instance(){return Te._instance||(Te._instance=new Te),Te._instance}async set(e,t){await(await this.getDatabase()).put($e.fonts,{...t,name:e})}async get(e){return await(await this.getDatabase()).get($e.fonts,e)}async delete(e){await(await this.getDatabase()).delete($e.fonts,e)}async getAll(){return await(await this.getDatabase()).getAll($e.fonts)}async clear(){await(await this.getDatabase()).clear($e.fonts)}async has(e){return await this.get(e)!==void 0}close(){if(!this.isClosing){this.isClosing=!0;try{this.db&&(this.db.close(),this.db=void 0)}finally{this.isClosing=!1}}}async destroy(){this.close(),await indexedDB.deleteDatabase(Te.DATABASE_NAME),Te._instance=void 0}async getDatabase(){if(this.isClosing)throw new Error("Cannot perform operation while database is closing");return this.db?this.db:(this.db=await Co(Te.DATABASE_NAME,Te.DATABASE_VERSION,{upgrade:(e,t,r)=>this.handleUpgrade(e,t,r),blocked(){console.warn("Database upgrade blocked - please close other tabs using the application")},blocking(){console.warn("Database blocking newer version - closing connection"),Te.instance.close()}}),this.db)}handleUpgrade(e,t,r){const i=Tn.filter(s=>s.version>t&&(!r||s.version<=r));for(const s of i)this.applySchemaVersion(e,s)}applySchemaVersion(e,t){for(const r of t.stores)e.objectStoreNames.contains(r.name)||e.createObjectStore(r.name,{keyPath:r.keyPath})}};Cn.DATABASE_NAME="mlightcad",Cn.DATABASE_VERSION=Tn[Tn.length-1].version;let In=Cn;const Lo=n=>n.substring(n.lastIndexOf(".")+1),Wr=n=>n.split("/").pop(),Xr=n=>{const e=Wr(n);if(e){const t=e.lastIndexOf(".");return t===-1?e:e.substring(0,t)}return n},Oo=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215,0],Mo=n=>Oo[n];let Do=class{constructor(n){this.isFont=!0,this.type="Font",this.data=n}generateShapes(n,e=100){const t=[],r=Ro(n,e,this.data);for(let i=0,s=r.length;i<s;i++)t.push(...r[i].toShapes());return t}};function Ro(n,e,t){const r=Array.from(n),i=e/t.resolution,s=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*i,o=[];let a=0,c=0;for(let l=0;l<r.length;l++){const h=r[l];if(h===`
26
+ `)a=0,c-=s;else{const d=Uo(h,i,a,c,t);a+=d.offsetX,o.push(d.path)}}return o}function Uo(n,e,t,r,i){const s=i.glyphs[n]||i.glyphs["?"];if(!s){console.error('THREE.Font: character "'+n+'" does not exists in font family '+i.familyName+".");return}const o=new ke.ShapePath;let a,c,l,h,d,u,p,f;if(s.o){const m=s._cachedOutline||(s._cachedOutline=s.o.split(" "));for(let y=0,v=m.length;y<v;)switch(m[y++]){case"m":a=m[y++]*e+t,c=m[y++]*e+r,o.moveTo(a,c);break;case"l":a=m[y++]*e+t,c=m[y++]*e+r,o.lineTo(a,c);break;case"q":l=m[y++]*e+t,h=m[y++]*e+r,d=m[y++]*e+t,u=m[y++]*e+r,o.quadraticCurveTo(d,u,l,h);break;case"b":l=m[y++]*e+t,h=m[y++]*e+r,d=m[y++]*e+t,u=m[y++]*e+r,p=m[y++]*e+t,f=m[y++]*e+r,o.bezierCurveTo(d,u,p,f,l,h);break}}return{offsetX:s.ha*e,path:o}}function qr(n,e=!1){const t=n[0].index!==null,r=new Set(Object.keys(n[0].attributes)),i=new Set(Object.keys(n[0].morphAttributes)),s={},o={},a=n[0].morphTargetsRelative,c=new ke.BufferGeometry;let l=0;for(let h=0;h<n.length;++h){const d=n[h];let u=0;if(t!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const p in d.attributes){if(!r.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;s[p]===void 0&&(s[p]=[]),s[p].push(d.attributes[p]),u++}if(u!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(a!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const p in d.morphAttributes){if(!i.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;o[p]===void 0&&(o[p]=[]),o[p].push(d.morphAttributes[p])}if(e){let p;if(t)p=d.index.count;else if(d.attributes.position!==void 0)p=d.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;c.addGroup(l,p,h),l+=p}}if(t){let h=0;const d=[];for(let u=0;u<n.length;++u){const p=n[u].index;for(let f=0;f<p.count;++f)d.push(p.getX(f)+h);h+=n[u].attributes.position.count}c.setIndex(d)}for(const h in s){const d=Yr(s[h]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" attribute."),null;c.setAttribute(h,d)}for(const h in o){const d=o[h][0].length;if(d===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[h]=[];for(let u=0;u<d;++u){const p=[];for(let m=0;m<o[h].length;++m)p.push(o[h][m][u]);const f=Yr(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;c.morphAttributes[h].push(f)}}return c}function Yr(n){let e,t,r,i=-1,s=0;for(let l=0;l<n.length;++l){const h=n[l];if(e===void 0&&(e=h.array.constructor),e!==h.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=h.itemSize),t!==h.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=h.normalized),r!==h.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=h.gpuType),i!==h.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=h.count*t}const o=new e(s),a=new ke.BufferAttribute(o,t,r);let c=0;for(let l=0;l<n.length;++l){const h=n[l];if(h.isInterleavedBufferAttribute){const d=c/t;for(let u=0,p=h.count;u<p;u++)for(let f=0;f<t;f++){const m=h.getComponent(u,f);a.setComponent(u+d,f,m)}}else o.set(h.array,c);c+=h.count*t}return i!==void 0&&(a.gpuType=i),a}function Fo(n,e=1e-4){e=Math.max(e,Number.EPSILON);const t={},r=n.getIndex(),i=n.getAttribute("position"),s=r?r.count:i.count;let o=0;const a=Object.keys(n.attributes),c={},l={},h=[],d=["getX","getY","getZ","getW"],u=["setX","setY","setZ","setW"];for(let _=0,w=a.length;_<w;_++){const C=a[_],T=n.attributes[C];c[C]=new T.constructor(new T.array.constructor(T.count*T.itemSize),T.itemSize,T.normalized);const D=n.morphAttributes[C];D&&(l[C]||(l[C]=[]),D.forEach((I,E)=>{const U=new I.array.constructor(I.count*I.itemSize);l[C][E]=new I.constructor(U,I.itemSize,I.normalized)}))}const p=e*.5,f=Math.log10(1/e),m=Math.pow(10,f),y=p*m;for(let _=0;_<s;_++){const w=r?r.getX(_):_;let C="";for(let T=0,D=a.length;T<D;T++){const I=a[T],E=n.getAttribute(I),U=E.itemSize;for(let V=0;V<U;V++)C+=`${~~(E[d[V]](w)*m+y)},`}if(C in t)h.push(t[C]);else{for(let T=0,D=a.length;T<D;T++){const I=a[T],E=n.getAttribute(I),U=n.morphAttributes[I],V=E.itemSize,J=c[I],te=l[I];for(let $=0;$<V;$++){const P=d[$],H=u[$];if(J[H](o,E[P](w)),U)for(let N=0,X=U.length;N<X;N++)te[N][H](o,U[N][P](w))}}t[C]=o,h.push(o),o++}}const v=n.clone();for(const _ in n.attributes){const w=c[_];if(v.setAttribute(_,new w.constructor(w.array.slice(0,o*w.itemSize),w.itemSize,w.normalized)),_ in l)for(let C=0;C<l[_].length;C++){const T=l[_][C];v.morphAttributes[_][C]=new T.constructor(T.array.slice(0,o*T.itemSize),T.itemSize,T.normalized)}}return v.setIndex(h),v}class Po extends ke.ExtrudeGeometry{constructor(e,t={}){const r=t.font;if(r===void 0)super();else{const i=r.generateShapes(e,t.size);t.depth===void 0&&t.height!==void 0&&console.warn("THREE.TextGeometry: .height is now depreciated. Please use .depth instead"),t.depth=t.depth!==void 0?t.depth:t.height!==void 0?t.height:50,t.bevelThickness===void 0&&(t.bevelThickness=10),t.bevelSize===void 0&&(t.bevelSize=8),t.bevelEnabled===void 0&&(t.bevelEnabled=!1),super(i,t)}this.type="TextGeometry"}}const $r=class{static dummyComputeVertexNormals(){}static disable(){ke.BufferGeometry.prototype.computeVertexNormals=this.dummyComputeVertexNormals}static restore(){ke.BufferGeometry.prototype.computeVertexNormals=this.originalComputeVertexNormals}static runWithoutNormals(e){this.disable();try{return e()}finally{this.restore()}}};$r.originalComputeVertexNormals=ke.BufferGeometry.prototype.computeVertexNormals;let Go=$r;const ze=new g.Vector2;class Zr extends Fr{constructor(e,t,r){super(e),this.isFound=!1,this.fontSize=t,this.font=r,this.width=this.getCharWidth(e,t,r)}toGeometry(){let e=this.font.cache.getGeometry(this.char,this.fontSize);return e==null&&(e=Go.runWithoutNormals(()=>{const t=new Po(this.char,{font:this.font.font,depth:0,size:this.fontSize,curveSegments:3,bevelSegments:3,UVGenerator:{generateTopUV:()=>[ze,ze,ze],generateSideWallUV:()=>[ze,ze,ze,ze]}});return t.hasAttribute("uv")&&t.deleteAttribute("uv"),t.hasAttribute("normal")&&t.deleteAttribute("normal"),Fo(t,1e-6)})),e}getCharWidth(e,t,r){const i=r.data.glyphs[e];return i?(this.isFound=!0,i.ha*t/r.data.resolution):(this.isFound=!1,0)}}/*! https://mths.be/codepointat v0.2.0 by @mathias */String.prototype.codePointAt||function(){var n=function(){try{var t={},r=Object.defineProperty,i=r(t,t,t)&&r}catch{}return i}(),e=function(t){if(this==null)throw TypeError();var r=String(this),i=r.length,s=t?Number(t):0;if(s!=s&&(s=0),!(s<0||s>=i)){var o=r.charCodeAt(s),a;return o>=55296&&o<=56319&&i>s+1&&(a=r.charCodeAt(s+1),a>=56320&&a<=57343)?(o-55296)*1024+a-56320+65536:o}};n?n(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e}();var An=0,Qr=-3;function ft(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function No(n,e){this.source=n,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=e,this.destLen=0,this.ltree=new ft,this.dtree=new ft}var Jr=new ft,Kr=new ft,En=new Uint8Array(30),kn=new Uint16Array(30),ei=new Uint8Array(30),ti=new Uint16Array(30),zo=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ni=new ft,ye=new Uint8Array(320);function ri(n,e,t,r){var i,s;for(i=0;i<t;++i)n[i]=0;for(i=0;i<30-t;++i)n[i+t]=i/t|0;for(s=r,i=0;i<30;++i)e[i]=s,s+=1<<n[i]}function Vo(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 ii=new Uint16Array(16);function Bn(n,e,t,r){var i,s;for(i=0;i<16;++i)n.table[i]=0;for(i=0;i<r;++i)n.table[e[t+i]]++;for(n.table[0]=0,s=0,i=0;i<16;++i)ii[i]=s,s+=n.table[i];for(i=0;i<r;++i)e[t+i]&&(n.trans[ii[e[t+i]]++]=i)}function Ho(n){n.bitcount--||(n.tag=n.source[n.sourceIndex++],n.bitcount=7);var e=n.tag&1;return n.tag>>>=1,e}function ve(n,e,t){if(!e)return t;for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<<n.bitcount,n.bitcount+=8;var r=n.tag&65535>>>16-e;return n.tag>>>=e,n.bitcount-=e,r+t}function Ln(n,e){for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<<n.bitcount,n.bitcount+=8;var t=0,r=0,i=0,s=n.tag;do r=2*r+(s&1),s>>>=1,++i,t+=e.table[i],r-=e.table[i];while(r>=0);return n.tag=s,n.bitcount-=i,e.trans[t+r]}function jo(n,e,t){var r,i,s,o,a,c;for(r=ve(n,5,257),i=ve(n,5,1),s=ve(n,4,4),o=0;o<19;++o)ye[o]=0;for(o=0;o<s;++o){var l=ve(n,3,0);ye[zo[o]]=l}for(Bn(ni,ye,0,19),a=0;a<r+i;){var h=Ln(n,ni);switch(h){case 16:var d=ye[a-1];for(c=ve(n,2,3);c;--c)ye[a++]=d;break;case 17:for(c=ve(n,3,3);c;--c)ye[a++]=0;break;case 18:for(c=ve(n,7,11);c;--c)ye[a++]=0;break;default:ye[a++]=h;break}}Bn(e,ye,0,r),Bn(t,ye,r,i)}function si(n,e,t){for(;;){var r=Ln(n,e);if(r===256)return An;if(r<256)n.dest[n.destLen++]=r;else{var i,s,o,a;for(r-=257,i=ve(n,En[r],kn[r]),s=Ln(n,t),o=n.destLen-ve(n,ei[s],ti[s]),a=o;a<o+i;++a)n.dest[n.destLen++]=n.dest[a]}}}function Wo(n){for(var e,t,r;n.bitcount>8;)n.sourceIndex--,n.bitcount-=8;if(e=n.source[n.sourceIndex+1],e=256*e+n.source[n.sourceIndex],t=n.source[n.sourceIndex+3],t=256*t+n.source[n.sourceIndex+2],e!==(~t&65535))return Qr;for(n.sourceIndex+=4,r=e;r;--r)n.dest[n.destLen++]=n.source[n.sourceIndex++];return n.bitcount=0,An}function Xo(n,e){var t=new No(n,e),r,i,s;do{switch(r=Ho(t),i=ve(t,2,0),i){case 0:s=Wo(t);break;case 1:s=si(t,Jr,Kr);break;case 2:jo(t,t.ltree,t.dtree),s=si(t,t.ltree,t.dtree);break;default:s=Qr}if(s!==An)throw new Error("Data error")}while(!r);return t.destLen<t.dest.length?typeof t.dest.slice=="function"?t.dest.slice(0,t.destLen):t.dest.subarray(0,t.destLen):t.dest}Vo(Jr,Kr),ri(En,kn,4,3),ri(ei,ti,2,1),En[28]=0,kn[28]=258;var qo=Xo;function Ze(n,e,t,r,i){return Math.pow(1-i,3)*n+3*Math.pow(1-i,2)*i*e+3*(1-i)*Math.pow(i,2)*t+Math.pow(i,3)*r}function Le(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}Le.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)},Le.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))},Le.prototype.addX=function(n){this.addPoint(n,null)},Le.prototype.addY=function(n){this.addPoint(null,n)},Le.prototype.addBezier=function(n,e,t,r,i,s,o,a){var c=[n,e],l=[t,r],h=[i,s],d=[o,a];this.addPoint(n,e),this.addPoint(o,a);for(var u=0;u<=1;u++){var p=6*c[u]-12*l[u]+6*h[u],f=-3*c[u]+9*l[u]-9*h[u]+3*d[u],m=3*l[u]-3*c[u];if(f===0){if(p===0)continue;var y=-m/p;0<y&&y<1&&(u===0&&this.addX(Ze(c[u],l[u],h[u],d[u],y)),u===1&&this.addY(Ze(c[u],l[u],h[u],d[u],y)));continue}var v=Math.pow(p,2)-4*m*f;if(!(v<0)){var _=(-p+Math.sqrt(v))/(2*f);0<_&&_<1&&(u===0&&this.addX(Ze(c[u],l[u],h[u],d[u],_)),u===1&&this.addY(Ze(c[u],l[u],h[u],d[u],_)));var w=(-p-Math.sqrt(v))/(2*f);0<w&&w<1&&(u===0&&this.addX(Ze(c[u],l[u],h[u],d[u],w)),u===1&&this.addY(Ze(c[u],l[u],h[u],d[u],w)))}}},Le.prototype.addQuad=function(n,e,t,r,i,s){var o=n+.6666666666666666*(t-n),a=e+2/3*(r-e),c=o+1/3*(i-n),l=a+1/3*(s-e);this.addBezier(n,e,o,a,c,l,i,s)};function j(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}j.prototype.moveTo=function(n,e){this.commands.push({type:"M",x:n,y:e})},j.prototype.lineTo=function(n,e){this.commands.push({type:"L",x:n,y:e})},j.prototype.curveTo=j.prototype.bezierCurveTo=function(n,e,t,r,i,s){this.commands.push({type:"C",x1:n,y1:e,x2:t,y2:r,x:i,y:s})},j.prototype.quadTo=j.prototype.quadraticCurveTo=function(n,e,t,r){this.commands.push({type:"Q",x1:n,y1:e,x:t,y:r})},j.prototype.close=j.prototype.closePath=function(){this.commands.push({type:"Z"})},j.prototype.extend=function(n){if(n.commands)n=n.commands;else if(n instanceof Le){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)},j.prototype.getBoundingBox=function(){for(var n=new Le,e=0,t=0,r=0,i=0,s=0;s<this.commands.length;s++){var o=this.commands[s];switch(o.type){case"M":n.addPoint(o.x,o.y),e=r=o.x,t=i=o.y;break;case"L":n.addPoint(o.x,o.y),r=o.x,i=o.y;break;case"Q":n.addQuad(r,i,o.x1,o.y1,o.x,o.y),r=o.x,i=o.y;break;case"C":n.addBezier(r,i,o.x1,o.y1,o.x2,o.y2,o.x,o.y),r=o.x,i=o.y;break;case"Z":r=e,i=t;break;default:throw new Error("Unexpected path command "+o.type)}}return n.isEmpty()&&n.addPoint(0,0),n},j.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())},j.prototype.toPathData=function(n){n=n!==void 0?n:2;function e(o){return Math.round(o)===o?""+Math.round(o):o.toFixed(n)}function t(){for(var o=arguments,a="",c=0;c<arguments.length;c+=1){var l=o[c];l>=0&&c>0&&(a+=" "),a+=e(l)}return a}for(var r="",i=0;i<this.commands.length;i+=1){var s=this.commands[i];s.type==="M"?r+="M"+t(s.x,s.y):s.type==="L"?r+="L"+t(s.x,s.y):s.type==="C"?r+="C"+t(s.x1,s.y1,s.x2,s.y2,s.x,s.y):s.type==="Q"?r+="Q"+t(s.x1,s.y1,s.x,s.y):s.type==="Z"&&(r+="Z")}return r},j.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},j.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 oi(n){throw new Error(n)}function ai(n,e){n||oi(e)}var O={fail:oi,argument:ai,assert:ai},ci=32768,li=2147483648,Qe={},A={},M={};function le(n){return function(){return n}}A.BYTE=function(n){return O.argument(n>=0&&n<=255,"Byte value should be between 0 and 255."),[n]},M.BYTE=le(1),A.CHAR=function(n){return[n.charCodeAt(0)]},M.CHAR=le(1),A.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},M.CHARARRAY=function(n){return typeof n>"u"?0:n.length},A.USHORT=function(n){return[n>>8&255,n&255]},M.USHORT=le(2),A.SHORT=function(n){return n>=ci&&(n=-(2*ci-n)),[n>>8&255,n&255]},M.SHORT=le(2),A.UINT24=function(n){return[n>>16&255,n>>8&255,n&255]},M.UINT24=le(3),A.ULONG=function(n){return[n>>24&255,n>>16&255,n>>8&255,n&255]},M.ULONG=le(4),A.LONG=function(n){return n>=li&&(n=-(2*li-n)),[n>>24&255,n>>16&255,n>>8&255,n&255]},M.LONG=le(4),A.FIXED=A.ULONG,M.FIXED=M.ULONG,A.FWORD=A.SHORT,M.FWORD=M.SHORT,A.UFWORD=A.USHORT,M.UFWORD=M.USHORT,A.LONGDATETIME=function(n){return[0,0,0,0,n>>24&255,n>>16&255,n>>8&255,n&255]},M.LONGDATETIME=le(8),A.TAG=function(n){return O.argument(n.length===4,"Tag should be exactly 4 ASCII characters."),[n.charCodeAt(0),n.charCodeAt(1),n.charCodeAt(2),n.charCodeAt(3)]},M.TAG=le(4),A.Card8=A.BYTE,M.Card8=M.BYTE,A.Card16=A.USHORT,M.Card16=M.USHORT,A.OffSize=A.BYTE,M.OffSize=M.BYTE,A.SID=A.USHORT,M.SID=M.USHORT,A.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?A.NUMBER16(n):A.NUMBER32(n)},M.NUMBER=function(n){return A.NUMBER(n).length},A.NUMBER16=function(n){return[28,n>>8&255,n&255]},M.NUMBER16=le(3),A.NUMBER32=function(n){return[29,n>>24&255,n>>16&255,n>>8&255,n&255]},M.NUMBER32=le(5),A.REAL=function(n){var e=n.toString(),t=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(e);if(t){var r=parseFloat("1e"+((t[2]?+t[2]:0)+t[1].length));e=(Math.round(n*r)/r).toString()}for(var i="",s=0,o=e.length;s<o;s+=1){var a=e[s];a==="e"?i+=e[++s]==="-"?"c":"b":a==="."?i+="a":a==="-"?i+="e":i+=a}i+=i.length&1?"f":"ff";for(var c=[30],l=0,h=i.length;l<h;l+=2)c.push(parseInt(i.substr(l,2),16));return c},M.REAL=function(n){return A.REAL(n).length},A.NAME=A.CHARARRAY,M.NAME=M.CHARARRAY,A.STRING=A.CHARARRAY,M.STRING=M.CHARARRAY,Qe.UTF8=function(n,e,t){for(var r=[],i=t,s=0;s<i;s++,e+=1)r[s]=n.getUint8(e);return String.fromCharCode.apply(null,r)},Qe.UTF16=function(n,e,t){for(var r=[],i=t/2,s=0;s<i;s++,e+=2)r[s]=n.getUint16(e);return String.fromCharCode.apply(null,r)},A.UTF16=function(n){for(var e=[],t=0;t<n.length;t+=1){var r=n.charCodeAt(t);e[e.length]=r>>8&255,e[e.length]=r&255}return e},M.UTF16=function(n){return n.length*2};var On={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈ƫȅ ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-cyrillic":"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ­","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüݰ¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ",macintosh:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};Qe.MACSTRING=function(n,e,t,r){var i=On[r];if(i!==void 0){for(var s="",o=0;o<t;o++){var a=n.getUint8(e+o);a<=127?s+=String.fromCharCode(a):s+=i[a&127]}return s}};var Nt=typeof WeakMap=="function"&&new WeakMap,zt,Yo=function(n){if(!zt){zt={};for(var e in On)zt[e]=new String(e)}var t=zt[n];if(t!==void 0){if(Nt){var r=Nt.get(t);if(r!==void 0)return r}var i=On[n];if(i!==void 0){for(var s={},o=0;o<i.length;o++)s[i.charCodeAt(o)]=o+128;return Nt&&Nt.set(t,s),s}}};A.MACSTRING=function(n,e){var t=Yo(e);if(t!==void 0){for(var r=[],i=0;i<n.length;i++){var s=n.charCodeAt(i);if(s>=128&&(s=t[s],s===void 0))return;r[i]=s}return r}},M.MACSTRING=function(n,e){var t=A.MACSTRING(n,e);return t!==void 0?t.length:0};function Mn(n){return n>=-128&&n<=127}function $o(n,e,t){for(var r=0,i=n.length;e<i&&r<64&&n[e]===0;)++e,++r;return t.push(128|r-1),e}function Zo(n,e,t){for(var r=0,i=n.length,s=e;s<i&&r<64;){var o=n[s];if(!Mn(o)||o===0&&s+1<i&&n[s+1]===0)break;++s,++r}t.push(r-1);for(var a=e;a<s;++a)t.push(n[a]+256&255);return s}function Qo(n,e,t){for(var r=0,i=n.length,s=e;s<i&&r<64;){var o=n[s];if(o===0||Mn(o)&&s+1<i&&Mn(n[s+1]))break;++s,++r}t.push(64|r-1);for(var a=e;a<s;++a){var c=n[a];t.push(c+65536>>8&255,c+256&255)}return s}A.VARDELTAS=function(n){for(var e=0,t=[];e<n.length;){var r=n[e];r===0?e=$o(n,e,t):r>=-128&&r<=127?e=Zo(n,e,t):e=Qo(n,e,t)}return t},A.INDEX=function(n){for(var e=1,t=[e],r=[],i=0;i<n.length;i+=1){var s=A.OBJECT(n[i]);Array.prototype.push.apply(r,s),e+=s.length,t.push(e)}if(r.length===0)return[0,0];for(var o=[],a=1+Math.floor(Math.log(e)/Math.log(2))/8|0,c=[void 0,A.BYTE,A.USHORT,A.UINT24,A.ULONG][a],l=0;l<t.length;l+=1){var h=c(t[l]);Array.prototype.push.apply(o,h)}return Array.prototype.concat(A.Card16(n.length),A.OffSize(a),o,r)},M.INDEX=function(n){return A.INDEX(n).length},A.DICT=function(n){for(var e=[],t=Object.keys(n),r=t.length,i=0;i<r;i+=1){var s=parseInt(t[i],0),o=n[s];e=e.concat(A.OPERAND(o.value,o.type)),e=e.concat(A.OPERATOR(s))}return e},M.DICT=function(n){return A.DICT(n).length},A.OPERATOR=function(n){return n<1200?[n]:[12,n-1200]},A.OPERAND=function(n,e){var t=[];if(Array.isArray(e))for(var r=0;r<e.length;r+=1)O.argument(n.length===e.length,"Not enough arguments given for type"+e),t=t.concat(A.OPERAND(n[r],e[r]));else if(e==="SID")t=t.concat(A.NUMBER(n));else if(e==="offset")t=t.concat(A.NUMBER32(n));else if(e==="number")t=t.concat(A.NUMBER(n));else if(e==="real")t=t.concat(A.REAL(n));else throw new Error("Unknown operand type "+e);return t},A.OP=A.BYTE,M.OP=M.BYTE;var Vt=typeof WeakMap=="function"&&new WeakMap;A.CHARSTRING=function(n){if(Vt){var e=Vt.get(n);if(e!==void 0)return e}for(var t=[],r=n.length,i=0;i<r;i+=1){var s=n[i];t=t.concat(A[s.type](s.value))}return Vt&&Vt.set(n,t),t},M.CHARSTRING=function(n){return A.CHARSTRING(n).length},A.OBJECT=function(n){var e=A[n.type];return O.argument(e!==void 0,"No encoding function for type "+n.type),e(n.value)},M.OBJECT=function(n){var e=M[n.type];return O.argument(e!==void 0,"No sizeOf function for type "+n.type),e(n.value)},A.TABLE=function(n){for(var e=[],t=n.fields.length,r=[],i=[],s=0;s<t;s+=1){var o=n.fields[s],a=A[o.type];O.argument(a!==void 0,"No encoding function for field type "+o.type+" ("+o.name+")");var c=n[o.name];c===void 0&&(c=o.value);var l=a(c);o.type==="TABLE"?(i.push(e.length),e=e.concat([0,0]),r.push(l)):e=e.concat(l)}for(var h=0;h<r.length;h+=1){var d=i[h],u=e.length;O.argument(u<65536,"Table "+n.tableName+" too big."),e[d]=u>>8,e[d+1]=u&255,e=e.concat(r[h])}return e},M.TABLE=function(n){for(var e=0,t=n.fields.length,r=0;r<t;r+=1){var i=n.fields[r],s=M[i.type];O.argument(s!==void 0,"No sizeOf function for field type "+i.type+" ("+i.name+")");var o=n[i.name];o===void 0&&(o=i.value),e+=s(o),i.type==="TABLE"&&(e+=2)}return e},A.RECORD=A.TABLE,M.RECORD=M.TABLE,A.LITERAL=function(n){return n},M.LITERAL=function(n){return n.length};function q(n,e,t){if(e.length&&(e[0].name!=="coverageFormat"||e[0].value===1))for(var r=0;r<e.length;r+=1){var i=e[r];this[i.name]=i.value}if(this.tableName=n,this.fields=e,t)for(var s=Object.keys(t),o=0;o<s.length;o+=1){var a=s[o],c=t[a];this[a]!==void 0&&(this[a]=c)}}q.prototype.encode=function(){return A.TABLE(this)},q.prototype.sizeOf=function(){return M.TABLE(this)};function gt(n,e,t){t===void 0&&(t=e.length);var r=new Array(e.length+1);r[0]={name:n+"Count",type:"USHORT",value:t};for(var i=0;i<e.length;i++)r[i+1]={name:n+i,type:"USHORT",value:e[i]};return r}function Dn(n,e,t){var r=e.length,i=new Array(r+1);i[0]={name:n+"Count",type:"USHORT",value:r};for(var s=0;s<r;s++)i[s+1]={name:n+s,type:"TABLE",value:t(e[s],s)};return i}function mt(n,e,t){var r=e.length,i=[];i[0]={name:n+"Count",type:"USHORT",value:r};for(var s=0;s<r;s++)i=i.concat(t(e[s],s));return i}function Ht(n){n.format===1?q.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(gt("glyph",n.glyphs))):n.format===2?q.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:2}].concat(mt("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}]}))):O.assert(!1,"Coverage format must be 1 or 2.")}Ht.prototype=Object.create(q.prototype),Ht.prototype.constructor=Ht;function jt(n){q.call(this,"scriptListTable",mt("scriptRecord",n,function(e,t){var r=e.script,i=r.defaultLangSys;return O.assert(!!i,"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 q("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new q("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:i.reqFeatureIndex}].concat(gt("featureIndex",i.featureIndexes)))}].concat(mt("langSys",r.langSysRecords,function(s,o){var a=s.langSys;return[{name:"langSysTag"+o,type:"TAG",value:s.tag},{name:"langSys"+o,type:"TABLE",value:new q("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:a.reqFeatureIndex}].concat(gt("featureIndex",a.featureIndexes)))}]})))}]}))}jt.prototype=Object.create(q.prototype),jt.prototype.constructor=jt;function Wt(n){q.call(this,"featureListTable",mt("featureRecord",n,function(e,t){var r=e.feature;return[{name:"featureTag"+t,type:"TAG",value:e.tag},{name:"feature"+t,type:"TABLE",value:new q("featureTable",[{name:"featureParams",type:"USHORT",value:r.featureParams}].concat(gt("lookupListIndex",r.lookupListIndexes)))}]}))}Wt.prototype=Object.create(q.prototype),Wt.prototype.constructor=Wt;function Xt(n,e){q.call(this,"lookupListTable",Dn("lookup",n,function(t){var r=e[t.lookupType];return O.assert(!!r,"Unable to write GSUB lookup type "+t.lookupType+" tables."),new q("lookupTable",[{name:"lookupType",type:"USHORT",value:t.lookupType},{name:"lookupFlag",type:"USHORT",value:t.lookupFlag}].concat(Dn("subtable",t.subtables,r)))}))}Xt.prototype=Object.create(q.prototype),Xt.prototype.constructor=Xt;var k={Table:q,Record:q,Coverage:Ht,ScriptList:jt,FeatureList:Wt,LookupList:Xt,ushortList:gt,tableList:Dn,recordList:mt};function hi(n,e){return n.getUint8(e)}function qt(n,e){return n.getUint16(e,!1)}function Jo(n,e){return n.getInt16(e,!1)}function Rn(n,e){return n.getUint32(e,!1)}function ui(n,e){var t=n.getInt16(e,!1),r=n.getUint16(e+2,!1);return t+r/65535}function Ko(n,e){for(var t="",r=e;r<e+4;r+=1)t+=String.fromCharCode(n.getInt8(r));return t}function ea(n,e,t){for(var r=0,i=0;i<t;i+=1)r<<=8,r+=n.getUint8(e+i);return r}function ta(n,e,t){for(var r=[],i=e;i<t;i+=1)r.push(n.getUint8(i));return r}function na(n){for(var e="",t=0;t<n.length;t+=1)e+=String.fromCharCode(n[t]);return e}var ra={byte:1,uShort:2,short:2,uLong:4,fixed:4,longDateTime:8,tag:4};function S(n,e){this.data=n,this.offset=e,this.relativeOffset=0}S.prototype.parseByte=function(){var n=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,n},S.prototype.parseChar=function(){var n=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,n},S.prototype.parseCard8=S.prototype.parseByte,S.prototype.parseUShort=function(){var n=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,n},S.prototype.parseCard16=S.prototype.parseUShort,S.prototype.parseSID=S.prototype.parseUShort,S.prototype.parseOffset16=S.prototype.parseUShort,S.prototype.parseShort=function(){var n=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,n},S.prototype.parseF2Dot14=function(){var n=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,n},S.prototype.parseULong=function(){var n=Rn(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,n},S.prototype.parseOffset32=S.prototype.parseULong,S.prototype.parseFixed=function(){var n=ui(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,n},S.prototype.parseString=function(n){var e=this.data,t=this.offset+this.relativeOffset,r="";this.relativeOffset+=n;for(var i=0;i<n;i++)r+=String.fromCharCode(e.getUint8(t+i));return r},S.prototype.parseTag=function(){return this.parseString(4)},S.prototype.parseLongDateTime=function(){var n=Rn(this.data,this.offset+this.relativeOffset+4);return n-=2082844800,this.relativeOffset+=8,n},S.prototype.parseVersion=function(n){var e=qt(this.data,this.offset+this.relativeOffset),t=qt(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,n===void 0&&(n=4096),e+t/n/10},S.prototype.skip=function(n,e){e===void 0&&(e=1),this.relativeOffset+=ra[n]*e},S.prototype.parseULongList=function(n){n===void 0&&(n=this.parseULong());for(var e=new Array(n),t=this.data,r=this.offset+this.relativeOffset,i=0;i<n;i++)e[i]=t.getUint32(r),r+=4;return this.relativeOffset+=n*4,e},S.prototype.parseOffset16List=S.prototype.parseUShortList=function(n){n===void 0&&(n=this.parseUShort());for(var e=new Array(n),t=this.data,r=this.offset+this.relativeOffset,i=0;i<n;i++)e[i]=t.getUint16(r),r+=2;return this.relativeOffset+=n*2,e},S.prototype.parseShortList=function(n){for(var e=new Array(n),t=this.data,r=this.offset+this.relativeOffset,i=0;i<n;i++)e[i]=t.getInt16(r),r+=2;return this.relativeOffset+=n*2,e},S.prototype.parseByteList=function(n){for(var e=new Array(n),t=this.data,r=this.offset+this.relativeOffset,i=0;i<n;i++)e[i]=t.getUint8(r++);return this.relativeOffset+=n,e},S.prototype.parseList=function(n,e){e||(e=n,n=this.parseUShort());for(var t=new Array(n),r=0;r<n;r++)t[r]=e.call(this);return t},S.prototype.parseList32=function(n,e){e||(e=n,n=this.parseULong());for(var t=new Array(n),r=0;r<n;r++)t[r]=e.call(this);return t},S.prototype.parseRecordList=function(n,e){e||(e=n,n=this.parseUShort());for(var t=new Array(n),r=Object.keys(e),i=0;i<n;i++){for(var s={},o=0;o<r.length;o++){var a=r[o],c=e[a];s[a]=c.call(this)}t[i]=s}return t},S.prototype.parseRecordList32=function(n,e){e||(e=n,n=this.parseULong());for(var t=new Array(n),r=Object.keys(e),i=0;i<n;i++){for(var s={},o=0;o<r.length;o++){var a=r[o],c=e[a];s[a]=c.call(this)}t[i]=s}return t},S.prototype.parseStruct=function(n){if(typeof n=="function")return n.call(this);for(var e=Object.keys(n),t={},r=0;r<e.length;r++){var i=e[r],s=n[i];t[i]=s.call(this)}return t},S.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}},S.prototype.parseValueRecordList=function(){for(var n=this.parseUShort(),e=this.parseUShort(),t=new Array(e),r=0;r<e;r++)t[r]=this.parseValueRecord(n);return t},S.prototype.parsePointer=function(n){var e=this.parseOffset16();if(e>0)return new S(this.data,this.offset+e).parseStruct(n)},S.prototype.parsePointer32=function(n){var e=this.parseOffset32();if(e>0)return new S(this.data,this.offset+e).parseStruct(n)},S.prototype.parseListOfLists=function(n){for(var e=this.parseOffset16List(),t=e.length,r=this.relativeOffset,i=new Array(t),s=0;s<t;s++){var o=e[s];if(o===0){i[s]=void 0;continue}if(this.relativeOffset=o,n){for(var a=this.parseOffset16List(),c=new Array(a.length),l=0;l<a.length;l++)this.relativeOffset=o+a[l],c[l]=n.call(this);i[s]=c}else i[s]=this.parseUShortList()}return this.relativeOffset=r,i},S.prototype.parseCoverage=function(){var n=this.offset+this.relativeOffset,e=this.parseUShort(),t=this.parseUShort();if(e===1)return{format:1,glyphs:this.parseUShortList(t)};if(e===2){for(var r=new Array(t),i=0;i<t;i++)r[i]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:r}}throw new Error("0x"+n.toString(16)+": Coverage format must be 1 or 2.")},S.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:S.uShort,end:S.uShort,classId:S.uShort})};throw new Error("0x"+n.toString(16)+": ClassDef format must be 1 or 2.")},S.list=function(n,e){return function(){return this.parseList(n,e)}},S.list32=function(n,e){return function(){return this.parseList32(n,e)}},S.recordList=function(n,e){return function(){return this.parseRecordList(n,e)}},S.recordList32=function(n,e){return function(){return this.parseRecordList32(n,e)}},S.pointer=function(n){return function(){return this.parsePointer(n)}},S.pointer32=function(n){return function(){return this.parsePointer32(n)}},S.tag=S.prototype.parseTag,S.byte=S.prototype.parseByte,S.uShort=S.offset16=S.prototype.parseUShort,S.uShortList=S.prototype.parseUShortList,S.uLong=S.offset32=S.prototype.parseULong,S.uLongList=S.prototype.parseULongList,S.struct=S.prototype.parseStruct,S.coverage=S.prototype.parseCoverage,S.classDef=S.prototype.parseClassDef;var di={reserved:S.uShort,reqFeatureIndex:S.uShort,featureIndexes:S.uShortList};S.prototype.parseScriptList=function(){return this.parsePointer(S.recordList({tag:S.tag,script:S.pointer({defaultLangSys:S.pointer(di),langSysRecords:S.recordList({tag:S.tag,langSys:S.pointer(di)})})}))||[]},S.prototype.parseFeatureList=function(){return this.parsePointer(S.recordList({tag:S.tag,feature:S.pointer({featureParams:S.offset16,lookupListIndexes:S.uShortList})}))||[]},S.prototype.parseLookupList=function(n){return this.parsePointer(S.list(S.pointer(function(){var e=this.parseUShort();O.argument(1<=e&&e<=9,"GPOS/GSUB lookup type "+e+" unknown.");var t=this.parseUShort(),r=t&16;return{lookupType:e,lookupFlag:t,subtables:this.parseList(S.pointer(n[e])),markFilteringSet:r?this.parseUShort():void 0}})))||[]},S.prototype.parseFeatureVariationsList=function(){return this.parsePointer32(function(){var n=this.parseUShort(),e=this.parseUShort();O.argument(n===1&&e<1,"GPOS/GSUB feature variations table unknown.");var t=this.parseRecordList32({conditionSetOffset:S.offset32,featureTableSubstitutionOffset:S.offset32});return t})||[]};var L={getByte:hi,getCard8:hi,getUShort:qt,getCard16:qt,getShort:Jo,getULong:Rn,getFixed:ui,getTag:Ko,getOffset:ea,getBytes:ta,bytesToString:na,Parser:S};function ia(n,e){e.parseUShort(),n.length=e.parseULong(),n.language=e.parseULong();var t;n.groupCount=t=e.parseULong(),n.glyphIndexMap={};for(var r=0;r<t;r+=1)for(var i=e.parseULong(),s=e.parseULong(),o=e.parseULong(),a=i;a<=s;a+=1)n.glyphIndexMap[a]=o,o++}function sa(n,e,t,r,i){n.length=e.parseUShort(),n.language=e.parseUShort();var s;n.segCount=s=e.parseUShort()>>1,e.skip("uShort",3),n.glyphIndexMap={};for(var o=new L.Parser(t,r+i+14),a=new L.Parser(t,r+i+16+s*2),c=new L.Parser(t,r+i+16+s*4),l=new L.Parser(t,r+i+16+s*6),h=r+i+16+s*8,d=0;d<s-1;d+=1)for(var u=void 0,p=o.parseUShort(),f=a.parseUShort(),m=c.parseShort(),y=l.parseUShort(),v=f;v<=p;v+=1)y!==0?(h=l.offset+l.relativeOffset-2,h+=y,h+=(v-f)*2,u=L.getUShort(t,h),u!==0&&(u=u+m&65535)):u=v+m&65535,n.glyphIndexMap[v]=u}function oa(n,e){var t={};t.version=L.getUShort(n,e),O.argument(t.version===0,"cmap table version should be 0."),t.numTables=L.getUShort(n,e+2);for(var r=-1,i=t.numTables-1;i>=0;i-=1){var s=L.getUShort(n,e+4+i*8),o=L.getUShort(n,e+4+i*8+2);if(s===3&&(o===0||o===1||o===10)||s===0&&(o===0||o===1||o===2||o===3||o===4)){r=L.getULong(n,e+4+i*8+4);break}}if(r===-1)throw new Error("No valid cmap sub-tables found.");var a=new L.Parser(n,e+r);if(t.format=a.parseUShort(),t.format===12)ia(t,a);else if(t.format===4)sa(t,a,n,e,r);else throw new Error("Only format 4 and 12 cmap tables are supported (found format "+t.format+").");return t}function aa(n,e,t){n.segments.push({end:e,start:e,delta:-(e-t),offset:0,glyphIndex:t})}function ca(n){n.segments.push({end:65535,start:65535,delta:1,offset:0})}function la(n){var e=!0,t;for(t=n.length-1;t>0;t-=1){var r=n.get(t);if(r.unicode>65535){console.log("Adding CMAP format 12 (needed!)"),e=!1;break}}var i=[{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||(i=i.concat([{name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}])),i=i.concat([{name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);var s=new k.Table("cmap",i);for(s.segments=[],t=0;t<n.length;t+=1){for(var o=n.get(t),a=0;a<o.unicodes.length;a+=1)aa(s,o.unicodes[a],t);s.segments=s.segments.sort(function(_,w){return _.start-w.start})}ca(s);var c=s.segments.length,l=0,h=[],d=[],u=[],p=[],f=[],m=[];for(t=0;t<c;t+=1){var y=s.segments[t];y.end<=65535&&y.start<=65535?(h=h.concat({name:"end_"+t,type:"USHORT",value:y.end}),d=d.concat({name:"start_"+t,type:"USHORT",value:y.start}),u=u.concat({name:"idDelta_"+t,type:"SHORT",value:y.delta}),p=p.concat({name:"idRangeOffset_"+t,type:"USHORT",value:y.offset}),y.glyphId!==void 0&&(f=f.concat({name:"glyph_"+t,type:"USHORT",value:y.glyphId}))):l+=1,!e&&y.glyphIndex!==void 0&&(m=m.concat({name:"cmap12Start_"+t,type:"ULONG",value:y.start}),m=m.concat({name:"cmap12End_"+t,type:"ULONG",value:y.end}),m=m.concat({name:"cmap12Glyph_"+t,type:"ULONG",value:y.glyphIndex}))}if(s.segCountX2=(c-l)*2,s.searchRange=Math.pow(2,Math.floor(Math.log(c-l)/Math.log(2)))*2,s.entrySelector=Math.log(s.searchRange/2)/Math.log(2),s.rangeShift=s.segCountX2-s.searchRange,s.fields=s.fields.concat(h),s.fields.push({name:"reservedPad",type:"USHORT",value:0}),s.fields=s.fields.concat(d),s.fields=s.fields.concat(u),s.fields=s.fields.concat(p),s.fields=s.fields.concat(f),s.cmap4Length=14+h.length*2+2+d.length*2+u.length*2+p.length*2+f.length*2,!e){var v=16+m.length*4;s.cmap12Offset=12+2*2+4+s.cmap4Length,s.fields=s.fields.concat([{name:"cmap12Format",type:"USHORT",value:12},{name:"cmap12Reserved",type:"USHORT",value:0},{name:"cmap12Length",type:"ULONG",value:v},{name:"cmap12Language",type:"ULONG",value:0},{name:"cmap12nGroups",type:"ULONG",value:m.length/3}]),s.fields=s.fields.concat(m)}return s}var pi={parse:oa,make:la},Yt=[".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"],ha=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],ua=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],Ve=[".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 fi(n){this.font=n}fi.prototype.charToGlyphIndex=function(n){var e=n.codePointAt(0),t=this.font.glyphs;if(t){for(var r=0;r<t.length;r+=1)for(var i=t.get(r),s=0;s<i.unicodes.length;s+=1)if(i.unicodes[s]===e)return r}return null};function gi(n){this.cmap=n}gi.prototype.charToGlyphIndex=function(n){return this.cmap.glyphIndexMap[n.codePointAt(0)]||0};function $t(n,e){this.encoding=n,this.charset=e}$t.prototype.charToGlyphIndex=function(n){var e=n.codePointAt(0),t=this.encoding[e];return this.charset.indexOf(t)};function Un(n){switch(n.version){case 1:this.names=Ve.slice();break;case 2:this.names=new Array(n.numberOfGlyphs);for(var e=0;e<n.numberOfGlyphs;e++)n.glyphNameIndex[e]<Ve.length?this.names[e]=Ve[n.glyphNameIndex[e]]:this.names[e]=n.names[n.glyphNameIndex[e]-Ve.length];break;case 2.5:this.names=new Array(n.numberOfGlyphs);for(var t=0;t<n.numberOfGlyphs;t++)this.names[t]=Ve[t+n.glyphNameIndex[t]];break;case 3:this.names=[];break;default:this.names=[];break}}Un.prototype.nameToGlyphIndex=function(n){return this.names.indexOf(n)},Un.prototype.glyphIndexToName=function(n){return this.names[n]};function da(n){for(var e,t=n.tables.cmap.glyphIndexMap,r=Object.keys(t),i=0;i<r.length;i+=1){var s=r[i],o=t[s];e=n.glyphs.get(o),e.addUnicode(parseInt(s))}for(var a=0;a<n.glyphs.length;a+=1)e=n.glyphs.get(a),n.cffEncoding?n.isCIDFont?e.name="gid"+a:e.name=n.cffEncoding.charset[a]:n.glyphNames.names&&(e.name=n.glyphNames.glyphIndexToName(a))}function pa(n){n._IndexToUnicodeMap={};for(var e=n.tables.cmap.glyphIndexMap,t=Object.keys(e),r=0;r<t.length;r+=1){var i=t[r],s=e[i];n._IndexToUnicodeMap[s]===void 0?n._IndexToUnicodeMap[s]={unicodes:[parseInt(i)]}:n._IndexToUnicodeMap[s].unicodes.push(parseInt(i))}}function fa(n,e){e.lowMemory?pa(n):da(n)}function ga(n,e,t,r,i){n.beginPath(),n.moveTo(e,t),n.lineTo(r,i),n.stroke()}var He={line:ga};function ma(n,e){var t=e||new j;return{configurable:!0,get:function(){return typeof t=="function"&&(t=t()),t},set:function(r){t=r}}}function ae(n){this.bindConstructorValues(n)}ae.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",ma(this,n.path))},ae.prototype.addUnicode=function(n){this.unicodes.length===0&&(this.unicode=n),this.unicodes.push(n)},ae.prototype.getBoundingBox=function(){return this.path.getBoundingBox()},ae.prototype.getPath=function(n,e,t,r,i){n=n!==void 0?n:0,e=e!==void 0?e:0,t=t!==void 0?t:72;var s,o;r||(r={});var a=r.xScale,c=r.yScale;if(r.hinting&&i&&i.hinting&&(o=this.path&&i.hinting.exec(this,t)),o)s=i.hinting.getCommands(o),n=Math.round(n),e=Math.round(e),a=c=1;else{s=this.path.commands;var l=1/(this.path.unitsPerEm||1e3)*t;a===void 0&&(a=l),c===void 0&&(c=l)}for(var h=new j,d=0;d<s.length;d+=1){var u=s[d];u.type==="M"?h.moveTo(n+u.x*a,e+-u.y*c):u.type==="L"?h.lineTo(n+u.x*a,e+-u.y*c):u.type==="Q"?h.quadraticCurveTo(n+u.x1*a,e+-u.y1*c,n+u.x*a,e+-u.y*c):u.type==="C"?h.curveTo(n+u.x1*a,e+-u.y1*c,n+u.x2*a,e+-u.y2*c,n+u.x*a,e+-u.y*c):u.type==="Z"&&h.closePath()}return h},ae.prototype.getContours=function(){if(this.points===void 0)return[];for(var n=[],e=[],t=0;t<this.points.length;t+=1){var r=this.points[t];e.push(r),r.lastPointOfContour&&(n.push(e),e=[])}return O.argument(e.length===0,"There are still points left in the current contour."),n},ae.prototype.getMetrics=function(){for(var n=this.path.commands,e=[],t=[],r=0;r<n.length;r+=1){var i=n[r];i.type!=="Z"&&(e.push(i.x),t.push(i.y)),(i.type==="Q"||i.type==="C")&&(e.push(i.x1),t.push(i.y1)),i.type==="C"&&(e.push(i.x2),t.push(i.y2))}var s={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(s.xMin)||(s.xMin=0),isFinite(s.xMax)||(s.xMax=this.advanceWidth),isFinite(s.yMin)||(s.yMin=0),isFinite(s.yMax)||(s.yMax=0),s.rightSideBearing=this.advanceWidth-s.leftSideBearing-(s.xMax-s.xMin),s},ae.prototype.draw=function(n,e,t,r,i){this.getPath(e,t,r,i).draw(n)},ae.prototype.drawPoints=function(n,e,t,r){function i(d,u,p,f){n.beginPath();for(var m=0;m<d.length;m+=1)n.moveTo(u+d[m].x*f,p+d[m].y*f),n.arc(u+d[m].x*f,p+d[m].y*f,2,0,Math.PI*2,!1);n.closePath(),n.fill()}e=e!==void 0?e:0,t=t!==void 0?t:0,r=r!==void 0?r:24;for(var s=1/this.path.unitsPerEm*r,o=[],a=[],c=this.path,l=0;l<c.commands.length;l+=1){var h=c.commands[l];h.x!==void 0&&o.push({x:h.x,y:-h.y}),h.x1!==void 0&&a.push({x:h.x1,y:-h.y1}),h.x2!==void 0&&a.push({x:h.x2,y:-h.y2})}n.fillStyle="blue",i(o,e,t,s),n.fillStyle="red",i(a,e,t,s)},ae.prototype.drawMetrics=function(n,e,t,r){var i;e=e!==void 0?e:0,t=t!==void 0?t:0,r=r!==void 0?r:24,i=1/this.path.unitsPerEm*r,n.lineWidth=1,n.strokeStyle="black",He.line(n,e,-1e4,e,1e4),He.line(n,-1e4,t,1e4,t);var s=this.xMin||0,o=this.yMin||0,a=this.xMax||0,c=this.yMax||0,l=this.advanceWidth||0;n.strokeStyle="blue",He.line(n,e+s*i,-1e4,e+s*i,1e4),He.line(n,e+a*i,-1e4,e+a*i,1e4),He.line(n,-1e4,t+-o*i,1e4,t+-o*i),He.line(n,-1e4,t+-c*i,1e4,t+-c*i),n.strokeStyle="green",He.line(n,e+l*i,-1e4,e+l*i,1e4)};function Zt(n,e,t){Object.defineProperty(n,e,{get:function(){return n.path,n[t]},set:function(r){n[t]=r},enumerable:!0,configurable:!0})}function Fn(n,e){if(this.font=n,this.glyphs={},Array.isArray(e))for(var t=0;t<e.length;t++){var r=e[t];r.path.unitsPerEm=n.unitsPerEm,this.glyphs[t]=r}this.length=e&&e.length||0}Fn.prototype.get=function(n){if(this.glyphs[n]===void 0){this.font._push(n),typeof this.glyphs[n]=="function"&&(this.glyphs[n]=this.glyphs[n]());var e=this.glyphs[n],t=this.font._IndexToUnicodeMap[n];if(t)for(var r=0;r<t.unicodes.length;r++)e.addUnicode(t.unicodes[r]);this.font.cffEncoding?this.font.isCIDFont?e.name="gid"+n:e.name=this.font.cffEncoding.charset[n]:this.font.glyphNames.names&&(e.name=this.font.glyphNames.glyphIndexToName(n)),this.glyphs[n].advanceWidth=this.font._hmtxTableData[n].advanceWidth,this.glyphs[n].leftSideBearing=this.font._hmtxTableData[n].leftSideBearing}else typeof this.glyphs[n]=="function"&&(this.glyphs[n]=this.glyphs[n]());return this.glyphs[n]},Fn.prototype.push=function(n,e){this.glyphs[n]=e,this.length++};function ya(n,e){return new ae({index:e,font:n})}function va(n,e,t,r,i,s){return function(){var o=new ae({index:e,font:n});return o.path=function(){t(o,r,i);var a=s(n.glyphs,o);return a.unitsPerEm=n.unitsPerEm,a},Zt(o,"xMin","_xMin"),Zt(o,"xMax","_xMax"),Zt(o,"yMin","_yMin"),Zt(o,"yMax","_yMax"),o}}function ba(n,e,t,r){return function(){var i=new ae({index:e,font:n});return i.path=function(){var s=t(n,i,r);return s.unitsPerEm=n.unitsPerEm,s},i}}var be={GlyphSet:Fn,glyphLoader:ya,ttfGlyphLoader:va,cffGlyphLoader:ba};function mi(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(!mi(n[t],e[t]))return!1;return!0}else return!1}function Pn(n){var e;return n.length<1240?e=107:n.length<33900?e=1131:e=32768,e}function Oe(n,e,t){var r=[],i=[],s=L.getCard16(n,e),o,a;if(s!==0){var c=L.getByte(n,e+2);o=e+(s+1)*c+2;for(var l=e+3,h=0;h<s+1;h+=1)r.push(L.getOffset(n,l,c)),l+=c;a=o+r[s]}else a=e+2;for(var d=0;d<r.length-1;d+=1){var u=L.getBytes(n,o+r[d],o+r[d+1]);t&&(u=t(u)),i.push(u)}return{objects:i,startOffset:e,endOffset:a}}function xa(n,e){var t=[],r=L.getCard16(n,e),i,s;if(r!==0){var o=L.getByte(n,e+2);i=e+(r+1)*o+2;for(var a=e+3,c=0;c<r+1;c+=1)t.push(L.getOffset(n,a,o)),a+=o;s=i+t[r]}else s=e+2;return{offsets:t,startOffset:e,endOffset:s}}function Sa(n,e,t,r,i){var s=L.getCard16(t,r),o=0;if(s!==0){var a=L.getByte(t,r+2);o=r+(s+1)*a+2}var c=L.getBytes(t,o+e[n],o+e[n+1]);return c}function wa(n){for(var e="",t=15,r=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];;){var i=n.parseByte(),s=i>>4,o=i&15;if(s===t||(e+=r[s],o===t))break;e+=r[o]}return parseFloat(e)}function _a(n,e){var t,r,i,s;if(e===28)return t=n.parseByte(),r=n.parseByte(),t<<8|r;if(e===29)return t=n.parseByte(),r=n.parseByte(),i=n.parseByte(),s=n.parseByte(),t<<24|r<<16|i<<8|s;if(e===30)return wa(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 Ta(n){for(var e={},t=0;t<n.length;t+=1){var r=n[t][0],i=n[t][1],s=void 0;if(i.length===1?s=i[0]:s=i,e.hasOwnProperty(r)&&!isNaN(e[r]))throw new Error("Object "+e+" already has key "+r);e[r]=s}return e}function yi(n,e,t){e=e!==void 0?e:0;var r=new L.Parser(n,e),i=[],s=[];for(t=t!==void 0?t:n.length;r.relativeOffset<t;){var o=r.parseByte();o<=21?(o===12&&(o=1200+r.parseByte()),i.push([o,s]),s=[]):s.push(_a(r,o))}return Ta(i)}function yt(n,e){return e<=390?e=Yt[e]:e=n[e-391],e}function vi(n,e,t){for(var r={},i,s=0;s<e.length;s+=1){var o=e[s];if(Array.isArray(o.type)){var a=[];a.length=o.type.length;for(var c=0;c<o.type.length;c++)i=n[o.op]!==void 0?n[o.op][c]:void 0,i===void 0&&(i=o.value!==void 0&&o.value[c]!==void 0?o.value[c]:null),o.type[c]==="SID"&&(i=yt(t,i)),a[c]=i;r[o.name]=a}else i=n[o.op],i===void 0&&(i=o.value!==void 0?o.value:null),o.type==="SID"&&(i=yt(t,i)),r[o.name]=i}return r}function Ca(n,e){var t={};return t.formatMajor=L.getCard8(n,e),t.formatMinor=L.getCard8(n,e+1),t.size=L.getCard8(n,e+2),t.offsetSize=L.getCard8(n,e+3),t.startOffset=e,t.endOffset=e+4,t}var bi=[{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"}],xi=[{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 Ia(n,e){var t=yi(n,0,n.byteLength);return vi(t,bi,e)}function Si(n,e,t,r){var i=yi(n,e,t);return vi(i,xi,r)}function wi(n,e,t,r){for(var i=[],s=0;s<t.length;s+=1){var o=new DataView(new Uint8Array(t[s]).buffer),a=Ia(o,r);a._subrs=[],a._subrsBias=0,a._defaultWidthX=0,a._nominalWidthX=0;var c=a.private[0],l=a.private[1];if(c!==0&&l!==0){var h=Si(n,l+e,c,r);if(a._defaultWidthX=h.defaultWidthX,a._nominalWidthX=h.nominalWidthX,h.subrs!==0){var d=l+h.subrs,u=Oe(n,d+e);a._subrs=u.objects,a._subrsBias=Pn(a._subrs)}a._privateDict=h}i.push(a)}return i}function Aa(n,e,t,r){var i,s,o=new L.Parser(n,e);t-=1;var a=[".notdef"],c=o.parseCard8();if(c===0)for(var l=0;l<t;l+=1)i=o.parseSID(),a.push(yt(r,i));else if(c===1)for(;a.length<=t;){i=o.parseSID(),s=o.parseCard8();for(var h=0;h<=s;h+=1)a.push(yt(r,i)),i+=1}else if(c===2)for(;a.length<=t;){i=o.parseSID(),s=o.parseCard16();for(var d=0;d<=s;d+=1)a.push(yt(r,i)),i+=1}else throw new Error("Unknown charset format "+c);return a}function Ea(n,e,t){var r,i={},s=new L.Parser(n,e),o=s.parseCard8();if(o===0)for(var a=s.parseCard8(),c=0;c<a;c+=1)r=s.parseCard8(),i[r]=c;else if(o===1){var l=s.parseCard8();r=1;for(var h=0;h<l;h+=1)for(var d=s.parseCard8(),u=s.parseCard8(),p=d;p<=d+u;p+=1)i[p]=r,r+=1}else throw new Error("Unknown encoding format "+o);return new $t(i,t)}function _i(n,e,t){var r,i,s,o,a=new j,c=[],l=0,h=!1,d=!1,u=0,p=0,f,m,y,v;if(n.isCIDFont){var _=n.tables.cff.topDict._fdSelect[e.index],w=n.tables.cff.topDict._fdArray[_];f=w._subrs,m=w._subrsBias,y=w._defaultWidthX,v=w._nominalWidthX}else f=n.tables.cff.topDict._subrs,m=n.tables.cff.topDict._subrsBias,y=n.tables.cff.topDict._defaultWidthX,v=n.tables.cff.topDict._nominalWidthX;var C=y;function T(E,U){d&&a.closePath(),a.moveTo(E,U),d=!0}function D(){var E;E=c.length%2!==0,E&&!h&&(C=c.shift()+v),l+=c.length>>1,c.length=0,h=!0}function I(E){for(var U,V,J,te,$,P,H,N,X,Z,Y,K,F=0;F<E.length;){var Q=E[F];switch(F+=1,Q){case 1:D();break;case 3:D();break;case 4:c.length>1&&!h&&(C=c.shift()+v,h=!0),p+=c.pop(),T(u,p);break;case 5:for(;c.length>0;)u+=c.shift(),p+=c.shift(),a.lineTo(u,p);break;case 6:for(;c.length>0&&(u+=c.shift(),a.lineTo(u,p),c.length!==0);)p+=c.shift(),a.lineTo(u,p);break;case 7:for(;c.length>0&&(p+=c.shift(),a.lineTo(u,p),c.length!==0);)u+=c.shift(),a.lineTo(u,p);break;case 8:for(;c.length>0;)r=u+c.shift(),i=p+c.shift(),s=r+c.shift(),o=i+c.shift(),u=s+c.shift(),p=o+c.shift(),a.curveTo(r,i,s,o,u,p);break;case 10:$=c.pop()+m,P=f[$],P&&I(P);break;case 11:return;case 12:switch(Q=E[F],F+=1,Q){case 35:r=u+c.shift(),i=p+c.shift(),s=r+c.shift(),o=i+c.shift(),H=s+c.shift(),N=o+c.shift(),X=H+c.shift(),Z=N+c.shift(),Y=X+c.shift(),K=Z+c.shift(),u=Y+c.shift(),p=K+c.shift(),c.shift(),a.curveTo(r,i,s,o,H,N),a.curveTo(X,Z,Y,K,u,p);break;case 34:r=u+c.shift(),i=p,s=r+c.shift(),o=i+c.shift(),H=s+c.shift(),N=o,X=H+c.shift(),Z=o,Y=X+c.shift(),K=p,u=Y+c.shift(),a.curveTo(r,i,s,o,H,N),a.curveTo(X,Z,Y,K,u,p);break;case 36:r=u+c.shift(),i=p+c.shift(),s=r+c.shift(),o=i+c.shift(),H=s+c.shift(),N=o,X=H+c.shift(),Z=o,Y=X+c.shift(),K=Z+c.shift(),u=Y+c.shift(),a.curveTo(r,i,s,o,H,N),a.curveTo(X,Z,Y,K,u,p);break;case 37:r=u+c.shift(),i=p+c.shift(),s=r+c.shift(),o=i+c.shift(),H=s+c.shift(),N=o+c.shift(),X=H+c.shift(),Z=N+c.shift(),Y=X+c.shift(),K=Z+c.shift(),Math.abs(Y-u)>Math.abs(K-p)?u=Y+c.shift():p=K+c.shift(),a.curveTo(r,i,s,o,H,N),a.curveTo(X,Z,Y,K,u,p);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+Q),c.length=0}break;case 14:c.length>0&&!h&&(C=c.shift()+v,h=!0),d&&(a.closePath(),d=!1);break;case 18:D();break;case 19:case 20:D(),F+=l+7>>3;break;case 21:c.length>2&&!h&&(C=c.shift()+v,h=!0),p+=c.pop(),u+=c.pop(),T(u,p);break;case 22:c.length>1&&!h&&(C=c.shift()+v,h=!0),u+=c.pop(),T(u,p);break;case 23:D();break;case 24:for(;c.length>2;)r=u+c.shift(),i=p+c.shift(),s=r+c.shift(),o=i+c.shift(),u=s+c.shift(),p=o+c.shift(),a.curveTo(r,i,s,o,u,p);u+=c.shift(),p+=c.shift(),a.lineTo(u,p);break;case 25:for(;c.length>6;)u+=c.shift(),p+=c.shift(),a.lineTo(u,p);r=u+c.shift(),i=p+c.shift(),s=r+c.shift(),o=i+c.shift(),u=s+c.shift(),p=o+c.shift(),a.curveTo(r,i,s,o,u,p);break;case 26:for(c.length%2&&(u+=c.shift());c.length>0;)r=u,i=p+c.shift(),s=r+c.shift(),o=i+c.shift(),u=s,p=o+c.shift(),a.curveTo(r,i,s,o,u,p);break;case 27:for(c.length%2&&(p+=c.shift());c.length>0;)r=u+c.shift(),i=p,s=r+c.shift(),o=i+c.shift(),u=s+c.shift(),p=o,a.curveTo(r,i,s,o,u,p);break;case 28:U=E[F],V=E[F+1],c.push((U<<24|V<<16)>>16),F+=2;break;case 29:$=c.pop()+n.gsubrsBias,P=n.gsubrs[$],P&&I(P);break;case 30:for(;c.length>0&&(r=u,i=p+c.shift(),s=r+c.shift(),o=i+c.shift(),u=s+c.shift(),p=o+(c.length===1?c.shift():0),a.curveTo(r,i,s,o,u,p),c.length!==0);)r=u+c.shift(),i=p,s=r+c.shift(),o=i+c.shift(),p=o+c.shift(),u=s+(c.length===1?c.shift():0),a.curveTo(r,i,s,o,u,p);break;case 31:for(;c.length>0&&(r=u+c.shift(),i=p,s=r+c.shift(),o=i+c.shift(),p=o+c.shift(),u=s+(c.length===1?c.shift():0),a.curveTo(r,i,s,o,u,p),c.length!==0);)r=u,i=p+c.shift(),s=r+c.shift(),o=i+c.shift(),u=s+c.shift(),p=o+(c.length===1?c.shift():0),a.curveTo(r,i,s,o,u,p);break;default:Q<32?console.log("Glyph "+e.index+": unknown operator "+Q):Q<247?c.push(Q-139):Q<251?(U=E[F],F+=1,c.push((Q-247)*256+U+108)):Q<255?(U=E[F],F+=1,c.push(-(Q-251)*256-U-108)):(U=E[F],V=E[F+1],J=E[F+2],te=E[F+3],F+=4,c.push((U<<24|V<<16|J<<8|te)/65536))}}}return I(t),e.advanceWidth=C,a}function ka(n,e,t,r){var i=[],s,o=new L.Parser(n,e),a=o.parseCard8();if(a===0)for(var c=0;c<t;c++){if(s=o.parseCard8(),s>=r)throw new Error("CFF table CID Font FDSelect has bad FD index value "+s+" (FD count "+r+")");i.push(s)}else if(a===3){var l=o.parseCard16(),h=o.parseCard16();if(h!==0)throw new Error("CFF Table CID Font FDSelect format 3 range has bad initial GID "+h);for(var d,u=0;u<l;u++){if(s=o.parseCard8(),d=o.parseCard16(),s>=r)throw new Error("CFF table CID Font FDSelect has bad FD index value "+s+" (FD count "+r+")");if(d>t)throw new Error("CFF Table CID Font FDSelect format 3 range has bad GID "+d);for(;h<d;h++)i.push(s);h=d}if(d!==t)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final GID "+d)}else throw new Error("CFF Table CID Font FDSelect table has unsupported format "+a);return i}function Ba(n,e,t,r){t.tables.cff={};var i=Ca(n,e),s=Oe(n,i.endOffset,L.bytesToString),o=Oe(n,s.endOffset),a=Oe(n,o.endOffset,L.bytesToString),c=Oe(n,a.endOffset);t.gsubrs=c.objects,t.gsubrsBias=Pn(t.gsubrs);var l=wi(n,e,o.objects,a.objects);if(l.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+l.length);var h=l[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 d=h.fdArray,u=h.fdSelect;if(d===0||u===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");d+=e;var p=Oe(n,d),f=wi(n,e,p.objects,a.objects);h._fdArray=f,u+=e,h._fdSelect=ka(n,u,t.numGlyphs,f.length)}var m=e+h.private[1],y=Si(n,m,h.private[0],a.objects);if(t.defaultWidthX=y.defaultWidthX,t.nominalWidthX=y.nominalWidthX,y.subrs!==0){var v=m+y.subrs,_=Oe(n,v);t.subrs=_.objects,t.subrsBias=Pn(t.subrs)}else t.subrs=[],t.subrsBias=0;var w;r.lowMemory?(w=xa(n,e+h.charStrings),t.nGlyphs=w.offsets.length):(w=Oe(n,e+h.charStrings),t.nGlyphs=w.objects.length);var C=Aa(n,e+h.charset,t.nGlyphs,a.objects);if(h.encoding===0?t.cffEncoding=new $t(ha,C):h.encoding===1?t.cffEncoding=new $t(ua,C):t.cffEncoding=Ea(n,e+h.encoding,C),t.encoding=t.encoding||t.cffEncoding,t.glyphs=new be.GlyphSet(t),r.lowMemory)t._push=function(I){var E=Sa(I,w.offsets,n,e+h.charStrings);t.glyphs.push(I,be.cffGlyphLoader(t,I,_i,E))};else for(var T=0;T<t.nGlyphs;T+=1){var D=w.objects[T];t.glyphs.push(T,be.cffGlyphLoader(t,T,_i,D))}}function Ti(n,e){var t,r=Yt.indexOf(n);return r>=0&&(t=r),r=e.indexOf(n),r>=0?t=r+Yt.length:(t=Yt.length+e.length,e.push(n)),t}function La(){return new k.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 Oa(n){var e=new k.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 Ci(n,e,t){for(var r={},i=0;i<n.length;i+=1){var s=n[i],o=e[s.name];o!==void 0&&!mi(o,s.value)&&(s.type==="SID"&&(o=Ti(o,t)),r[s.op]={name:s.name,type:s.type,value:o})}return r}function Ii(n,e){var t=new k.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return t.dict=Ci(bi,n,e),t}function Ai(n){var e=new k.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return e.topDicts=[{name:"topDict_0",type:"TABLE",value:n}],e}function Ma(n){var e=new k.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 Da(){return new k.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function Ra(n,e){for(var t=new k.Record("Charsets",[{name:"format",type:"Card8",value:0}]),r=0;r<n.length;r+=1){var i=n[r],s=Ti(i,e);t.fields.push({name:"glyph_"+r,type:"SID",value:s})}return t}function Ua(n){var e=[],t=n.path;e.push({name:"width",type:"NUMBER",value:n.advanceWidth});for(var r=0,i=0,s=0;s<t.commands.length;s+=1){var o=void 0,a=void 0,c=t.commands[s];if(c.type==="Q"){var l=.3333333333333333,h=2/3;c={type:"C",x:c.x,y:c.y,x1:Math.round(l*r+h*c.x1),y1:Math.round(l*i+h*c.y1),x2:Math.round(l*c.x+h*c.x1),y2:Math.round(l*c.y+h*c.y1)}}if(c.type==="M")o=Math.round(c.x-r),a=Math.round(c.y-i),e.push({name:"dx",type:"NUMBER",value:o}),e.push({name:"dy",type:"NUMBER",value:a}),e.push({name:"rmoveto",type:"OP",value:21}),r=Math.round(c.x),i=Math.round(c.y);else if(c.type==="L")o=Math.round(c.x-r),a=Math.round(c.y-i),e.push({name:"dx",type:"NUMBER",value:o}),e.push({name:"dy",type:"NUMBER",value:a}),e.push({name:"rlineto",type:"OP",value:5}),r=Math.round(c.x),i=Math.round(c.y);else if(c.type==="C"){var d=Math.round(c.x1-r),u=Math.round(c.y1-i),p=Math.round(c.x2-c.x1),f=Math.round(c.y2-c.y1);o=Math.round(c.x-c.x2),a=Math.round(c.y-c.y2),e.push({name:"dx1",type:"NUMBER",value:d}),e.push({name:"dy1",type:"NUMBER",value:u}),e.push({name:"dx2",type:"NUMBER",value:p}),e.push({name:"dy2",type:"NUMBER",value:f}),e.push({name:"dx",type:"NUMBER",value:o}),e.push({name:"dy",type:"NUMBER",value:a}),e.push({name:"rrcurveto",type:"OP",value:8}),r=Math.round(c.x),i=Math.round(c.y)}}return e.push({name:"endchar",type:"OP",value:14}),e}function Fa(n){for(var e=new k.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]),t=0;t<n.length;t+=1){var r=n.get(t),i=Ua(r);e.charStrings.push({name:r.name,type:"CHARSTRING",value:i})}return e}function Pa(n,e){var t=new k.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return t.dict=Ci(xi,n,e),t}function Ga(n,e){for(var t=new k.Table("CFF ",[{name:"header",type:"RECORD"},{name:"nameIndex",type:"RECORD"},{name:"topDictIndex",type:"RECORD"},{name:"stringIndex",type:"RECORD"},{name:"globalSubrIndex",type:"RECORD"},{name:"charsets",type:"RECORD"},{name:"charStringsIndex",type:"RECORD"},{name:"privateDict",type:"RECORD"}]),r=1/e.unitsPerEm,i={version:e.version,fullName:e.fullName,familyName:e.familyName,weight:e.weightName,fontBBox:e.fontBBox||[0,0,0,0],fontMatrix:[r,0,0,r,0,0],charset:999,encoding:0,charStrings:999,private:[0,999]},s={},o=[],a,c=1;c<n.length;c+=1)a=n.get(c),o.push(a.name);var l=[];t.header=La(),t.nameIndex=Oa([e.postScriptName]);var h=Ii(i,l);t.topDictIndex=Ai(h),t.globalSubrIndex=Da(),t.charsets=Ra(o,l),t.charStringsIndex=Fa(n),t.privateDict=Pa(s,l),t.stringIndex=Ma(l);var d=t.header.sizeOf()+t.nameIndex.sizeOf()+t.topDictIndex.sizeOf()+t.stringIndex.sizeOf()+t.globalSubrIndex.sizeOf();return i.charset=d,i.encoding=0,i.charStrings=i.charset+t.charsets.sizeOf(),i.private[1]=i.charStrings+t.charStringsIndex.sizeOf(),h=Ii(i,l),t.topDictIndex=Ai(h),t}var Ei={parse:Ba,make:Ga};function Na(n,e){var t={},r=new L.Parser(n,e);return t.version=r.parseVersion(),t.fontRevision=Math.round(r.parseFixed()*1e3)/1e3,t.checkSumAdjustment=r.parseULong(),t.magicNumber=r.parseULong(),O.argument(t.magicNumber===1594834165,"Font header has wrong magic number."),t.flags=r.parseUShort(),t.unitsPerEm=r.parseUShort(),t.created=r.parseLongDateTime(),t.modified=r.parseLongDateTime(),t.xMin=r.parseShort(),t.yMin=r.parseShort(),t.xMax=r.parseShort(),t.yMax=r.parseShort(),t.macStyle=r.parseUShort(),t.lowestRecPPEM=r.parseUShort(),t.fontDirectionHint=r.parseShort(),t.indexToLocFormat=r.parseShort(),t.glyphDataFormat=r.parseShort(),t}function za(n){var e=Math.round(new Date().getTime()/1e3)+2082844800,t=e;return n.createdTimestamp&&(t=n.createdTimestamp+2082844800),new k.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 ki={parse:Na,make:za};function Va(n,e){var t={},r=new L.Parser(n,e);return t.version=r.parseVersion(),t.ascender=r.parseShort(),t.descender=r.parseShort(),t.lineGap=r.parseShort(),t.advanceWidthMax=r.parseUShort(),t.minLeftSideBearing=r.parseShort(),t.minRightSideBearing=r.parseShort(),t.xMaxExtent=r.parseShort(),t.caretSlopeRise=r.parseShort(),t.caretSlopeRun=r.parseShort(),t.caretOffset=r.parseShort(),r.relativeOffset+=8,t.metricDataFormat=r.parseShort(),t.numberOfHMetrics=r.parseUShort(),t}function Ha(n){return new k.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 Bi={parse:Va,make:Ha};function ja(n,e,t,r,i){for(var s,o,a=new L.Parser(n,e),c=0;c<r;c+=1){c<t&&(s=a.parseUShort(),o=a.parseShort());var l=i.get(c);l.advanceWidth=s,l.leftSideBearing=o}}function Wa(n,e,t,r,i){n._hmtxTableData={};for(var s,o,a=new L.Parser(e,t),c=0;c<i;c+=1)c<r&&(s=a.parseUShort(),o=a.parseShort()),n._hmtxTableData[c]={advanceWidth:s,leftSideBearing:o}}function Xa(n,e,t,r,i,s,o){o.lowMemory?Wa(n,e,t,r,i):ja(e,t,r,i,s)}function qa(n){for(var e=new k.Table("hmtx",[]),t=0;t<n.length;t+=1){var r=n.get(t),i=r.advanceWidth||0,s=r.leftSideBearing||0;e.fields.push({name:"advanceWidth_"+t,type:"USHORT",value:i}),e.fields.push({name:"leftSideBearing_"+t,type:"SHORT",value:s})}return e}var Li={parse:Xa,make:qa};function Ya(n){for(var e=new k.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:n.length}]),t="",r=12+n.length*4,i=0;i<n.length;++i){var s=t.indexOf(n[i]);s<0&&(s=t.length,t+=n[i]),e.fields.push({name:"offset "+i,type:"USHORT",value:r+s}),e.fields.push({name:"length "+i,type:"USHORT",value:n[i].length})}return e.fields.push({name:"stringPool",type:"CHARARRAY",value:t}),e}function $a(n,e){var t=new L.Parser(n,e),r=t.parseULong();O.argument(r===1,"Unsupported ltag table version."),t.skip("uLong",1);for(var i=t.parseULong(),s=[],o=0;o<i;o++){for(var a="",c=e+t.parseUShort(),l=t.parseUShort(),h=c;h<c+l;++h)a+=String.fromCharCode(n.getInt8(h));s.push(a)}return s}var Oi={make:Ya,parse:$a};function Za(n,e){var t={},r=new L.Parser(n,e);return t.version=r.parseVersion(),t.numGlyphs=r.parseUShort(),t.version===1&&(t.maxPoints=r.parseUShort(),t.maxContours=r.parseUShort(),t.maxCompositePoints=r.parseUShort(),t.maxCompositeContours=r.parseUShort(),t.maxZones=r.parseUShort(),t.maxTwilightPoints=r.parseUShort(),t.maxStorage=r.parseUShort(),t.maxFunctionDefs=r.parseUShort(),t.maxInstructionDefs=r.parseUShort(),t.maxStackElements=r.parseUShort(),t.maxSizeOfInstructions=r.parseUShort(),t.maxComponentElements=r.parseUShort(),t.maxComponentDepth=r.parseUShort()),t}function Qa(n){return new k.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:n}])}var Mi={parse:Za,make:Qa},Di=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],Ri={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"},Ja={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},Ui={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 Ka(n,e,t){switch(n){case 0:if(e===65535)return"und";if(t)return t[e];break;case 1:return Ri[e];case 3:return Ui[e]}}var Gn="utf-16",ec={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"},tc={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 Fi(n,e,t){switch(n){case 0:return Gn;case 1:return tc[t]||ec[e];case 3:if(e===1||e===10)return Gn;break}}function nc(n,e,t){for(var r={},i=new L.Parser(n,e),s=i.parseUShort(),o=i.parseUShort(),a=i.offset+i.parseUShort(),c=0;c<o;c++){var l=i.parseUShort(),h=i.parseUShort(),d=i.parseUShort(),u=i.parseUShort(),p=Di[u]||u,f=i.parseUShort(),m=i.parseUShort(),y=Ka(l,d,t),v=Fi(l,h,d);if(v!==void 0&&y!==void 0){var _=void 0;if(v===Gn?_=Qe.UTF16(n,a+m,f):_=Qe.MACSTRING(n,a+m,f,v),_){var w=r[p];w===void 0&&(w=r[p]={}),w[y]=_}}}return s===1&&i.parseUShort(),r}function Nn(n){var e={};for(var t in n)e[n[t]]=parseInt(t);return e}function Pi(n,e,t,r,i,s){return new k.Record("NameRecord",[{name:"platformID",type:"USHORT",value:n},{name:"encodingID",type:"USHORT",value:e},{name:"languageID",type:"USHORT",value:t},{name:"nameID",type:"USHORT",value:r},{name:"length",type:"USHORT",value:i},{name:"offset",type:"USHORT",value:s}])}function rc(n,e){var t=n.length,r=e.length-t+1;e:for(var i=0;i<r;i++)for(;i<r;i++){for(var s=0;s<t;s++)if(e[i+s]!==n[s])continue e;return i}return-1}function Gi(n,e){var t=rc(n,e);if(t<0){t=e.length;for(var r=0,i=n.length;r<i;++r)e.push(n[r])}return t}function ic(n,e){var t,r=[],i={},s=Nn(Di);for(var o in n){var a=s[o];if(a===void 0&&(a=o),t=parseInt(a),isNaN(t))throw new Error('Name table entry "'+o+'" does not exist, see nameTableNames for complete list.');i[t]=n[o],r.push(t)}for(var c=Nn(Ri),l=Nn(Ui),h=[],d=[],u=0;u<r.length;u++){t=r[u];var p=i[t];for(var f in p){var m=p[f],y=1,v=c[f],_=Ja[v],w=Fi(y,_,v),C=A.MACSTRING(m,w);C===void 0&&(y=0,v=e.indexOf(f),v<0&&(v=e.length,e.push(f)),_=4,C=A.UTF16(m));var T=Gi(C,d);h.push(Pi(y,_,v,t,C.length,T));var D=l[f];if(D!==void 0){var I=A.UTF16(m),E=Gi(I,d);h.push(Pi(3,1,D,t,I.length,E))}}}h.sort(function(J,te){return J.platformID-te.platformID||J.encodingID-te.encodingID||J.languageID-te.languageID||J.nameID-te.nameID});for(var U=new k.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:h.length},{name:"stringOffset",type:"USHORT",value:6+h.length*12}]),V=0;V<h.length;V++)U.fields.push({name:"record_"+V,type:"RECORD",value:h[V]});return U.fields.push({name:"strings",type:"LITERAL",value:d}),U}var Ni={parse:nc,make:ic},zn=[{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 sc(n){for(var e=0;e<zn.length;e+=1){var t=zn[e];if(n>=t.begin&&n<t.end)return e}return-1}function oc(n,e){var t={},r=new L.Parser(n,e);t.version=r.parseUShort(),t.xAvgCharWidth=r.parseShort(),t.usWeightClass=r.parseUShort(),t.usWidthClass=r.parseUShort(),t.fsType=r.parseUShort(),t.ySubscriptXSize=r.parseShort(),t.ySubscriptYSize=r.parseShort(),t.ySubscriptXOffset=r.parseShort(),t.ySubscriptYOffset=r.parseShort(),t.ySuperscriptXSize=r.parseShort(),t.ySuperscriptYSize=r.parseShort(),t.ySuperscriptXOffset=r.parseShort(),t.ySuperscriptYOffset=r.parseShort(),t.yStrikeoutSize=r.parseShort(),t.yStrikeoutPosition=r.parseShort(),t.sFamilyClass=r.parseShort(),t.panose=[];for(var i=0;i<10;i++)t.panose[i]=r.parseByte();return t.ulUnicodeRange1=r.parseULong(),t.ulUnicodeRange2=r.parseULong(),t.ulUnicodeRange3=r.parseULong(),t.ulUnicodeRange4=r.parseULong(),t.achVendID=String.fromCharCode(r.parseByte(),r.parseByte(),r.parseByte(),r.parseByte()),t.fsSelection=r.parseUShort(),t.usFirstCharIndex=r.parseUShort(),t.usLastCharIndex=r.parseUShort(),t.sTypoAscender=r.parseShort(),t.sTypoDescender=r.parseShort(),t.sTypoLineGap=r.parseShort(),t.usWinAscent=r.parseUShort(),t.usWinDescent=r.parseUShort(),t.version>=1&&(t.ulCodePageRange1=r.parseULong(),t.ulCodePageRange2=r.parseULong()),t.version>=2&&(t.sxHeight=r.parseShort(),t.sCapHeight=r.parseShort(),t.usDefaultChar=r.parseUShort(),t.usBreakChar=r.parseUShort(),t.usMaxContent=r.parseUShort()),t}function ac(n){return new k.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 Vn={parse:oc,make:ac,unicodeRanges:zn,getUnicodeRange:sc};function cc(n,e){var t={},r=new L.Parser(n,e);switch(t.version=r.parseVersion(),t.italicAngle=r.parseFixed(),t.underlinePosition=r.parseShort(),t.underlineThickness=r.parseShort(),t.isFixedPitch=r.parseULong(),t.minMemType42=r.parseULong(),t.maxMemType42=r.parseULong(),t.minMemType1=r.parseULong(),t.maxMemType1=r.parseULong(),t.version){case 1:t.names=Ve.slice();break;case 2:t.numberOfGlyphs=r.parseUShort(),t.glyphNameIndex=new Array(t.numberOfGlyphs);for(var i=0;i<t.numberOfGlyphs;i++)t.glyphNameIndex[i]=r.parseUShort();t.names=[];for(var s=0;s<t.numberOfGlyphs;s++)if(t.glyphNameIndex[s]>=Ve.length){var o=r.parseChar();t.names.push(r.parseString(o))}break;case 2.5:t.numberOfGlyphs=r.parseUShort(),t.offset=new Array(t.numberOfGlyphs);for(var a=0;a<t.numberOfGlyphs;a++)t.offset[a]=r.parseChar();break}return t}function lc(){return new k.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 zi={parse:cc,make:lc},he=new Array(9);he[1]=function(){var n=this.offset+this.relativeOffset,e=this.parseUShort();if(e===1)return{substFormat:1,coverage:this.parsePointer(S.coverage),deltaGlyphId:this.parseUShort()};if(e===2)return{substFormat:2,coverage:this.parsePointer(S.coverage),substitute:this.parseOffset16List()};O.assert(!1,"0x"+n.toString(16)+": lookup type 1 format must be 1 or 2.")},he[2]=function(){var n=this.parseUShort();return O.argument(n===1,"GSUB Multiple Substitution Subtable identifier-format must be 1"),{substFormat:n,coverage:this.parsePointer(S.coverage),sequences:this.parseListOfLists()}},he[3]=function(){var n=this.parseUShort();return O.argument(n===1,"GSUB Alternate Substitution Subtable identifier-format must be 1"),{substFormat:n,coverage:this.parsePointer(S.coverage),alternateSets:this.parseListOfLists()}},he[4]=function(){var n=this.parseUShort();return O.argument(n===1,"GSUB ligature table identifier-format must be 1"),{substFormat:n,coverage:this.parsePointer(S.coverage),ligatureSets:this.parseListOfLists(function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}})}};var Je={sequenceIndex:S.uShort,lookupListIndex:S.uShort};he[5]=function(){var n=this.offset+this.relativeOffset,e=this.parseUShort();if(e===1)return{substFormat:e,coverage:this.parsePointer(S.coverage),ruleSets:this.parseListOfLists(function(){var i=this.parseUShort(),s=this.parseUShort();return{input:this.parseUShortList(i-1),lookupRecords:this.parseRecordList(s,Je)}})};if(e===2)return{substFormat:e,coverage:this.parsePointer(S.coverage),classDef:this.parsePointer(S.classDef),classSets:this.parseListOfLists(function(){var i=this.parseUShort(),s=this.parseUShort();return{classes:this.parseUShortList(i-1),lookupRecords:this.parseRecordList(s,Je)}})};if(e===3){var t=this.parseUShort(),r=this.parseUShort();return{substFormat:e,coverages:this.parseList(t,S.pointer(S.coverage)),lookupRecords:this.parseRecordList(r,Je)}}O.assert(!1,"0x"+n.toString(16)+": lookup type 5 format must be 1, 2 or 3.")},he[6]=function(){var n=this.offset+this.relativeOffset,e=this.parseUShort();if(e===1)return{substFormat:1,coverage:this.parsePointer(S.coverage),chainRuleSets:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Je)}})};if(e===2)return{substFormat:2,coverage:this.parsePointer(S.coverage),backtrackClassDef:this.parsePointer(S.classDef),inputClassDef:this.parsePointer(S.classDef),lookaheadClassDef:this.parsePointer(S.classDef),chainClassSet:this.parseListOfLists(function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Je)}})};if(e===3)return{substFormat:3,backtrackCoverage:this.parseList(S.pointer(S.coverage)),inputCoverage:this.parseList(S.pointer(S.coverage)),lookaheadCoverage:this.parseList(S.pointer(S.coverage)),lookupRecords:this.parseRecordList(Je)};O.assert(!1,"0x"+n.toString(16)+": lookup type 6 format must be 1, 2 or 3.")},he[7]=function(){var n=this.parseUShort();O.argument(n===1,"GSUB Extension Substitution subtable identifier-format must be 1");var e=this.parseUShort(),t=new S(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:e,extension:he[e].call(t)}},he[8]=function(){var n=this.parseUShort();return O.argument(n===1,"GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1"),{substFormat:n,coverage:this.parsePointer(S.coverage),backtrackCoverage:this.parseList(S.pointer(S.coverage)),lookaheadCoverage:this.parseList(S.pointer(S.coverage)),substitutes:this.parseUShortList()}};function hc(n,e){e=e||0;var t=new S(n,e),r=t.parseVersion(1);return O.argument(r===1||r===1.1,"Unsupported GSUB table version."),r===1?{version:r,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(he)}:{version:r,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(he),variations:t.parseFeatureVariationsList()}}var Ke=new Array(9);Ke[1]=function(n){return n.substFormat===1?new k.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new k.Coverage(n.coverage)},{name:"deltaGlyphID",type:"USHORT",value:n.deltaGlyphId}]):new k.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new k.Coverage(n.coverage)}].concat(k.ushortList("substitute",n.substitute)))},Ke[2]=function(n){return O.assert(n.substFormat===1,"Lookup type 2 substFormat must be 1."),new k.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new k.Coverage(n.coverage)}].concat(k.tableList("seqSet",n.sequences,function(e){return new k.Table("sequenceSetTable",k.ushortList("sequence",e))})))},Ke[3]=function(n){return O.assert(n.substFormat===1,"Lookup type 3 substFormat must be 1."),new k.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new k.Coverage(n.coverage)}].concat(k.tableList("altSet",n.alternateSets,function(e){return new k.Table("alternateSetTable",k.ushortList("alternate",e))})))},Ke[4]=function(n){return O.assert(n.substFormat===1,"Lookup type 4 substFormat must be 1."),new k.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new k.Coverage(n.coverage)}].concat(k.tableList("ligSet",n.ligatureSets,function(e){return new k.Table("ligatureSetTable",k.tableList("ligature",e,function(t){return new k.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:t.ligGlyph}].concat(k.ushortList("component",t.components,t.components.length+1)))}))})))},Ke[6]=function(n){if(n.substFormat===1){var e=new k.Table("chainContextTable",[{name:"substFormat",type:"USHORT",value:n.substFormat},{name:"coverage",type:"TABLE",value:new k.Coverage(n.coverage)}].concat(k.tableList("chainRuleSet",n.chainRuleSets,function(i){return new k.Table("chainRuleSetTable",k.tableList("chainRule",i,function(s){var o=k.ushortList("backtrackGlyph",s.backtrack,s.backtrack.length).concat(k.ushortList("inputGlyph",s.input,s.input.length+1)).concat(k.ushortList("lookaheadGlyph",s.lookahead,s.lookahead.length)).concat(k.ushortList("substitution",[],s.lookupRecords.length));return s.lookupRecords.forEach(function(a,c){o=o.concat({name:"sequenceIndex"+c,type:"USHORT",value:a.sequenceIndex}).concat({name:"lookupListIndex"+c,type:"USHORT",value:a.lookupListIndex})}),new k.Table("chainRuleTable",o)}))})));return e}else if(n.substFormat===2)O.assert(!1,"lookup type 6 format 2 is not yet supported.");else if(n.substFormat===3){var t=[{name:"substFormat",type:"USHORT",value:n.substFormat}];t.push({name:"backtrackGlyphCount",type:"USHORT",value:n.backtrackCoverage.length}),n.backtrackCoverage.forEach(function(i,s){t.push({name:"backtrackCoverage"+s,type:"TABLE",value:new k.Coverage(i)})}),t.push({name:"inputGlyphCount",type:"USHORT",value:n.inputCoverage.length}),n.inputCoverage.forEach(function(i,s){t.push({name:"inputCoverage"+s,type:"TABLE",value:new k.Coverage(i)})}),t.push({name:"lookaheadGlyphCount",type:"USHORT",value:n.lookaheadCoverage.length}),n.lookaheadCoverage.forEach(function(i,s){t.push({name:"lookaheadCoverage"+s,type:"TABLE",value:new k.Coverage(i)})}),t.push({name:"substitutionCount",type:"USHORT",value:n.lookupRecords.length}),n.lookupRecords.forEach(function(i,s){t=t.concat({name:"sequenceIndex"+s,type:"USHORT",value:i.sequenceIndex}).concat({name:"lookupListIndex"+s,type:"USHORT",value:i.lookupListIndex})});var r=new k.Table("chainContextTable",t);return r}O.assert(!1,"lookup type 6 format must be 1, 2 or 3.")};function uc(n){return new k.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new k.ScriptList(n.scripts)},{name:"features",type:"TABLE",value:new k.FeatureList(n.features)},{name:"lookups",type:"TABLE",value:new k.LookupList(n.lookups,Ke)}])}var Vi={parse:hc,make:uc};function dc(n,e){var t=new L.Parser(n,e),r=t.parseULong();O.argument(r===1,"Unsupported META table version."),t.parseULong(),t.parseULong();for(var i=t.parseULong(),s={},o=0;o<i;o++){var a=t.parseTag(),c=t.parseULong(),l=t.parseULong(),h=Qe.UTF8(n,e+c,l);s[a]=h}return s}function pc(n){var e=Object.keys(n).length,t="",r=16+e*12,i=new k.Table("meta",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"offset",type:"ULONG",value:r},{name:"numTags",type:"ULONG",value:e}]);for(var s in n){var o=t.length;t+=n[s],i.fields.push({name:"tag "+s,type:"TAG",value:s}),i.fields.push({name:"offset "+s,type:"ULONG",value:r+o}),i.fields.push({name:"length "+s,type:"ULONG",value:n[s].length})}return i.fields.push({name:"stringPool",type:"CHARARRAY",value:t}),i}var Hi={parse:dc,make:pc};function ji(n){return Math.log(n)/Math.log(2)|0}function Hn(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 Wi(n,e,t,r){return new k.Record("Table Record",[{name:"tag",type:"TAG",value:n!==void 0?n:""},{name:"checkSum",type:"ULONG",value:e!==void 0?e:0},{name:"offset",type:"ULONG",value:t!==void 0?t:0},{name:"length",type:"ULONG",value:r!==void 0?r:0}])}function Xi(n){var e=new k.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,ji(e.numTables));e.searchRange=16*t,e.entrySelector=ji(t),e.rangeShift=e.numTables*16-e.searchRange;for(var r=[],i=[],s=e.sizeOf()+Wi().sizeOf()*e.numTables;s%4!==0;)s+=1,i.push({name:"padding",type:"BYTE",value:0});for(var o=0;o<n.length;o+=1){var a=n[o];O.argument(a.tableName.length===4,"Table name"+a.tableName+" is invalid.");var c=a.sizeOf(),l=Wi(a.tableName,Hn(a.encode()),s,c);for(r.push({name:l.tag+" Table Record",type:"RECORD",value:l}),i.push({name:a.tableName+" table",type:"RECORD",value:a}),s+=c,O.argument(!isNaN(s),"Something went wrong calculating the offset.");s%4!==0;)s+=1,i.push({name:"padding",type:"BYTE",value:0})}return r.sort(function(h,d){return h.value.tag>d.value.tag?1:-1}),e.fields=e.fields.concat(r),e.fields=e.fields.concat(i),e}function qi(n,e,t){for(var r=0;r<e.length;r+=1){var i=n.charToGlyphIndex(e[r]);if(i>0){var s=n.glyphs.get(i);return s.getMetrics()}}return t}function fc(n){for(var e=0,t=0;t<n.length;t+=1)e+=n[t];return e/n.length}function gc(n){for(var e=[],t=[],r=[],i=[],s=[],o=[],a=[],c,l=0,h=0,d=0,u=0,p=0,f=0;f<n.glyphs.length;f+=1){var m=n.glyphs.get(f),y=m.unicode|0;if(isNaN(m.advanceWidth))throw new Error("Glyph "+m.name+" ("+f+"): advanceWidth is not a number.");(c>y||c===void 0)&&y>0&&(c=y),l<y&&(l=y);var v=Vn.getUnicodeRange(y);if(v<32)h|=1<<v;else if(v<64)d|=1<<v-32;else if(v<96)u|=1<<v-64;else if(v<123)p|=1<<v-96;else throw new Error("Unicode ranges bits > 123 are reserved for internal usage");if(m.name!==".notdef"){var _=m.getMetrics();e.push(_.xMin),t.push(_.yMin),r.push(_.xMax),i.push(_.yMax),o.push(_.leftSideBearing),a.push(_.rightSideBearing),s.push(m.advanceWidth)}}var w={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,t),xMax:Math.max.apply(null,r),yMax:Math.max.apply(null,i),advanceWidthMax:Math.max.apply(null,s),advanceWidthAvg:fc(s),minLeftSideBearing:Math.min.apply(null,o),maxLeftSideBearing:Math.max.apply(null,o),minRightSideBearing:Math.min.apply(null,a)};w.ascender=n.ascender,w.descender=n.descender;var C=ki.make({flags:3,unitsPerEm:n.unitsPerEm,xMin:w.xMin,yMin:w.yMin,xMax:w.xMax,yMax:w.yMax,lowestRecPPEM:3,createdTimestamp:n.createdTimestamp}),T=Bi.make({ascender:w.ascender,descender:w.descender,advanceWidthMax:w.advanceWidthMax,minLeftSideBearing:w.minLeftSideBearing,minRightSideBearing:w.minRightSideBearing,xMaxExtent:w.maxLeftSideBearing+(w.xMax-w.xMin),numberOfHMetrics:n.glyphs.length}),D=Mi.make(n.glyphs.length),I=Vn.make(Object.assign({xAvgCharWidth:Math.round(w.advanceWidthAvg),usFirstCharIndex:c,usLastCharIndex:l,ulUnicodeRange1:h,ulUnicodeRange2:d,ulUnicodeRange3:u,ulUnicodeRange4:p,sTypoAscender:w.ascender,sTypoDescender:w.descender,sTypoLineGap:0,usWinAscent:w.yMax,usWinDescent:Math.abs(w.yMin),ulCodePageRange1:1,sxHeight:qi(n,"xyvw",{yMax:Math.round(w.ascender/2)}).yMax,sCapHeight:qi(n,"HIKLEFJMNTZBDPRAGOQSUVWXY",w).yMax,usDefaultChar:n.hasChar(" ")?32:0,usBreakChar:n.hasChar(" ")?32:0},n.tables.os2)),E=Li.make(n.glyphs),U=pi.make(n.glyphs),V=n.getEnglishName("fontFamily"),J=n.getEnglishName("fontSubfamily"),te=V+" "+J,$=n.getEnglishName("postScriptName");$||($=V.replace(/\s/g,"")+"-"+J);var P={};for(var H in n.names)P[H]=n.names[H];P.uniqueID||(P.uniqueID={en:n.getEnglishName("manufacturer")+":"+te}),P.postScriptName||(P.postScriptName={en:$}),P.preferredFamily||(P.preferredFamily=n.names.fontFamily),P.preferredSubfamily||(P.preferredSubfamily=n.names.fontSubfamily);var N=[],X=Ni.make(P,N),Z=N.length>0?Oi.make(N):void 0,Y=zi.make(),K=Ei.make(n.glyphs,{version:n.getEnglishName("version"),fullName:te,familyName:V,weightName:J,postScriptName:$,unitsPerEm:n.unitsPerEm,fontBBox:[0,w.yMin,w.ascender,w.advanceWidthMax]}),F=n.metas&&Object.keys(n.metas).length>0?Hi.make(n.metas):void 0,Q=[C,T,D,I,X,U,Y,K,E];Z&&Q.push(Z),n.tables.gsub&&Q.push(Vi.make(n.tables.gsub)),F&&Q.push(F);for(var vr=Xi(Q),ld=vr.encode(),hd=Hn(ld),br=vr.fields,Qs=!1,fn=0;fn<br.length;fn+=1)if(br[fn].name==="head table"){br[fn].value.checkSumAdjustment=2981146554-hd,Qs=!0;break}if(!Qs)throw new Error("Could not find head table with checkSum to adjust.");return vr}var mc={make:Xi,fontToTable:gc,computeCheckSum:Hn};function jn(n,e){for(var t=0,r=n.length-1;t<=r;){var i=t+r>>>1,s=n[i].tag;if(s===e)return i;s<e?t=i+1:r=i-1}return-t-1}function Yi(n,e){for(var t=0,r=n.length-1;t<=r;){var i=t+r>>>1,s=n[i];if(s===e)return i;s<e?t=i+1:r=i-1}return-t-1}function $i(n,e){for(var t,r=0,i=n.length-1;r<=i;){var s=r+i>>>1;t=n[s];var o=t.start;if(o===e)return t;o<e?r=s+1:i=s-1}if(r>0)return t=n[r-1],e>t.end?0:t}function vt(n,e){this.font=n,this.tableName=e}vt.prototype={searchTag:jn,binSearch:Yi,getTable:function(n){var e=this.font.tables[this.tableName];return!e&&n&&(e=this.font.tables[this.tableName]=this.createDefaultTable()),e},getScriptNames:function(){var n=this.getTable();return n?n.scripts.map(function(e){return e.tag}):[]},getDefaultScriptName:function(){var n=this.getTable();if(n){for(var e=!1,t=0;t<n.scripts.length;t++){var r=n.scripts[t].tag;if(r==="DFLT")return r;r==="latn"&&(e=!0)}if(e)return"latn"}},getScriptTable:function(n,e){var t=this.getTable(e);if(t){n=n||"DFLT";var r=t.scripts,i=jn(t.scripts,n);if(i>=0)return r[i].script;if(e){var s={tag:n,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return r.splice(-1-i,0,s),s.script}}},getLangSysTable:function(n,e,t){var r=this.getScriptTable(n,t);if(r){if(!e||e==="dflt"||e==="DFLT")return r.defaultLangSys;var i=jn(r.langSysRecords,e);if(i>=0)return r.langSysRecords[i].langSys;if(t){var s={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return r.langSysRecords.splice(-1-i,0,s),s.langSys}}},getFeatureTable:function(n,e,t,r){var i=this.getLangSysTable(n,e,r);if(i){for(var s,o=i.featureIndexes,a=this.font.tables[this.tableName].features,c=0;c<o.length;c++)if(s=a[o[c]],s.tag===t)return s.feature;if(r){var l=a.length;return O.assert(l===0||t>=a[l-1].tag,"Features must be added in alphabetical order."),s={tag:t,feature:{params:0,lookupListIndexes:[]}},a.push(s),o.push(l),s.feature}}},getLookupTables:function(n,e,t,r,i){var s=this.getFeatureTable(n,e,t,i),o=[];if(s){for(var a,c=s.lookupListIndexes,l=this.font.tables[this.tableName].lookups,h=0;h<c.length;h++)a=l[c[h]],a.lookupType===r&&o.push(a);if(o.length===0&&i){a={lookupType:r,lookupFlag:0,subtables:[],markFilteringSet:void 0};var d=l.length;return l.push(a),c.push(d),[a]}}return o},getGlyphClass:function(n,e){switch(n.format){case 1:return n.startGlyph<=e&&e<n.startGlyph+n.classes.length?n.classes[e-n.startGlyph]:0;case 2:var t=$i(n.ranges,e);return t?t.classId:0}},getCoverageIndex:function(n,e){switch(n.format){case 1:var t=Yi(n.glyphs,e);return t>=0?t:-1;case 2:var r=$i(n.ranges,e);return r?r.index+e-r.start:-1}},expandCoverage:function(n){if(n.format===1)return n.glyphs;for(var e=[],t=n.ranges,r=0;r<t.length;r++)for(var i=t[r],s=i.start,o=i.end,a=s;a<=o;a++)e.push(a);return e}};function bt(n){vt.call(this,n,"gpos")}bt.prototype=vt.prototype,bt.prototype.init=function(){var n=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(n)},bt.prototype.getKerningValue=function(n,e,t){for(var r=0;r<n.length;r++)for(var i=n[r].subtables,s=0;s<i.length;s++){var o=i[s],a=this.getCoverageIndex(o.coverage,e);if(!(a<0))switch(o.posFormat){case 1:for(var c=o.pairSets[a],l=0;l<c.length;l++){var h=c[l];if(h.secondGlyph===t)return h.value1&&h.value1.xAdvance||0}break;case 2:var d=this.getGlyphClass(o.classDef1,e),u=this.getGlyphClass(o.classDef2,t),p=o.classRecords[d][u];return p.value1&&p.value1.xAdvance||0}}return 0},bt.prototype.getKerningTables=function(n,e){if(this.font.tables.gpos)return this.getLookupTables(n,e,"kern",2)};function ne(n){vt.call(this,n,"gsub")}function yc(n,e){var t=n.length;if(t!==e.length)return!1;for(var r=0;r<t;r++)if(n[r]!==e[r])return!1;return!0}function Wn(n,e,t){for(var r=n.subtables,i=0;i<r.length;i++){var s=r[i];if(s.substFormat===e)return s}if(t)return r.push(t),t}ne.prototype=vt.prototype,ne.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}},ne.prototype.getSingle=function(n,e,t){for(var r=[],i=this.getLookupTables(e,t,n,1),s=0;s<i.length;s++)for(var o=i[s].subtables,a=0;a<o.length;a++){var c=o[a],l=this.expandCoverage(c.coverage),h=void 0;if(c.substFormat===1){var d=c.deltaGlyphId;for(h=0;h<l.length;h++){var u=l[h];r.push({sub:u,by:u+d})}}else{var p=c.substitute;for(h=0;h<l.length;h++)r.push({sub:l[h],by:p[h]})}}return r},ne.prototype.getMultiple=function(n,e,t){for(var r=[],i=this.getLookupTables(e,t,n,2),s=0;s<i.length;s++)for(var o=i[s].subtables,a=0;a<o.length;a++){var c=o[a],l=this.expandCoverage(c.coverage),h=void 0;for(h=0;h<l.length;h++){var d=l[h],u=c.sequences[h];r.push({sub:d,by:u})}}return r},ne.prototype.getAlternates=function(n,e,t){for(var r=[],i=this.getLookupTables(e,t,n,3),s=0;s<i.length;s++)for(var o=i[s].subtables,a=0;a<o.length;a++)for(var c=o[a],l=this.expandCoverage(c.coverage),h=c.alternateSets,d=0;d<l.length;d++)r.push({sub:l[d],by:h[d]});return r},ne.prototype.getLigatures=function(n,e,t){for(var r=[],i=this.getLookupTables(e,t,n,4),s=0;s<i.length;s++)for(var o=i[s].subtables,a=0;a<o.length;a++)for(var c=o[a],l=this.expandCoverage(c.coverage),h=c.ligatureSets,d=0;d<l.length;d++)for(var u=l[d],p=h[d],f=0;f<p.length;f++){var m=p[f];r.push({sub:[u].concat(m.components),by:m.ligGlyph})}return r},ne.prototype.addSingle=function(n,e,t,r){var i=this.getLookupTables(t,r,n,1,!0)[0],s=Wn(i,2,{substFormat:2,coverage:{format:1,glyphs:[]},substitute:[]});O.assert(s.coverage.format===1,"Single: unable to modify coverage table format "+s.coverage.format);var o=e.sub,a=this.binSearch(s.coverage.glyphs,o);a<0&&(a=-1-a,s.coverage.glyphs.splice(a,0,o),s.substitute.splice(a,0,0)),s.substitute[a]=e.by},ne.prototype.addMultiple=function(n,e,t,r){O.assert(e.by instanceof Array&&e.by.length>1,'Multiple: "by" must be an array of two or more ids');var i=this.getLookupTables(t,r,n,2,!0)[0],s=Wn(i,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});O.assert(s.coverage.format===1,"Multiple: unable to modify coverage table format "+s.coverage.format);var o=e.sub,a=this.binSearch(s.coverage.glyphs,o);a<0&&(a=-1-a,s.coverage.glyphs.splice(a,0,o),s.sequences.splice(a,0,0)),s.sequences[a]=e.by},ne.prototype.addAlternate=function(n,e,t,r){var i=this.getLookupTables(t,r,n,3,!0)[0],s=Wn(i,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});O.assert(s.coverage.format===1,"Alternate: unable to modify coverage table format "+s.coverage.format);var o=e.sub,a=this.binSearch(s.coverage.glyphs,o);a<0&&(a=-1-a,s.coverage.glyphs.splice(a,0,o),s.alternateSets.splice(a,0,0)),s.alternateSets[a]=e.by},ne.prototype.addLigature=function(n,e,t,r){var i=this.getLookupTables(t,r,n,4,!0)[0],s=i.subtables[0];s||(s={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},i.subtables[0]=s),O.assert(s.coverage.format===1,"Ligature: unable to modify coverage table format "+s.coverage.format);var o=e.sub[0],a=e.sub.slice(1),c={ligGlyph:e.by,components:a},l=this.binSearch(s.coverage.glyphs,o);if(l>=0){for(var h=s.ligatureSets[l],d=0;d<h.length;d++)if(yc(h[d].components,a))return;h.push(c)}else l=-1-l,s.coverage.glyphs.splice(l,0,o),s.ligatureSets.splice(l,0,[c])},ne.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)}},ne.prototype.add=function(n,e,t,r){if(/ss\d\d/.test(n))return this.addSingle(n,e,t,r);switch(n){case"aalt":case"salt":return typeof e.by=="number"?this.addSingle(n,e,t,r):this.addAlternate(n,e,t,r);case"dlig":case"liga":case"rlig":return this.addLigature(n,e,t,r);case"ccmp":return e.by instanceof Array?this.addMultiple(n,e,t,r):this.addLigature(n,e,t,r)}};function vc(){return typeof window<"u"}function bc(n){for(var e=new Buffer(n.byteLength),t=new Uint8Array(n),r=0;r<e.length;++r)e[r]=t[r];return e}function xt(n,e){if(!n)throw e}function Zi(n,e,t,r,i){var s;return(e&r)>0?(s=n.parseByte(),e&i||(s=-s),s=t+s):(e&i)>0?s=t:s=t+n.parseShort(),s}function Qi(n,e,t){var r=new L.Parser(e,t);n.numberOfContours=r.parseShort(),n._xMin=r.parseShort(),n._yMin=r.parseShort(),n._xMax=r.parseShort(),n._yMax=r.parseShort();var i,s;if(n.numberOfContours>0){for(var o=n.endPointIndices=[],a=0;a<n.numberOfContours;a+=1)o.push(r.parseUShort());n.instructionLength=r.parseUShort(),n.instructions=[];for(var c=0;c<n.instructionLength;c+=1)n.instructions.push(r.parseByte());var l=o[o.length-1]+1;i=[];for(var h=0;h<l;h+=1)if(s=r.parseByte(),i.push(s),(s&8)>0)for(var d=r.parseByte(),u=0;u<d;u+=1)i.push(s),h+=1;if(O.argument(i.length===l,"Bad flags."),o.length>0){var p=[],f;if(l>0){for(var m=0;m<l;m+=1)s=i[m],f={},f.onCurve=!!(s&1),f.lastPointOfContour=o.indexOf(m)>=0,p.push(f);for(var y=0,v=0;v<l;v+=1)s=i[v],f=p[v],f.x=Zi(r,s,y,2,16),y=f.x;for(var _=0,w=0;w<l;w+=1)s=i[w],f=p[w],f.y=Zi(r,s,_,4,32),_=f.y}n.points=p}else n.points=[]}else if(n.numberOfContours===0)n.points=[];else{n.isComposite=!0,n.points=[],n.components=[];for(var C=!0;C;){i=r.parseUShort();var T={glyphIndex:r.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(i&1)>0?(i&2)>0?(T.dx=r.parseShort(),T.dy=r.parseShort()):T.matchedPoints=[r.parseUShort(),r.parseUShort()]:(i&2)>0?(T.dx=r.parseChar(),T.dy=r.parseChar()):T.matchedPoints=[r.parseByte(),r.parseByte()],(i&8)>0?T.xScale=T.yScale=r.parseF2Dot14():(i&64)>0?(T.xScale=r.parseF2Dot14(),T.yScale=r.parseF2Dot14()):(i&128)>0&&(T.xScale=r.parseF2Dot14(),T.scale01=r.parseF2Dot14(),T.scale10=r.parseF2Dot14(),T.yScale=r.parseF2Dot14()),n.components.push(T),C=!!(i&32)}if(i&256){n.instructionLength=r.parseUShort(),n.instructions=[];for(var D=0;D<n.instructionLength;D+=1)n.instructions.push(r.parseByte())}}}function Xn(n,e){for(var t=[],r=0;r<n.length;r+=1){var i=n[r],s={x:e.xScale*i.x+e.scale01*i.y+e.dx,y:e.scale10*i.x+e.yScale*i.y+e.dy,onCurve:i.onCurve,lastPointOfContour:i.lastPointOfContour};t.push(s)}return t}function xc(n){for(var e=[],t=[],r=0;r<n.length;r+=1){var i=n[r];t.push(i),i.lastPointOfContour&&(e.push(t),t=[])}return O.argument(t.length===0,"There are still points left in the current contour."),e}function Ji(n){var e=new j;if(!n)return e;for(var t=xc(n),r=0;r<t.length;++r){var i=t[r],s=null,o=i[i.length-1],a=i[0];if(o.onCurve)e.moveTo(o.x,o.y);else if(a.onCurve)e.moveTo(a.x,a.y);else{var c={x:(o.x+a.x)*.5,y:(o.y+a.y)*.5};e.moveTo(c.x,c.y)}for(var l=0;l<i.length;++l)if(s=o,o=a,a=i[(l+1)%i.length],o.onCurve)e.lineTo(o.x,o.y);else{var h=a;s.onCurve||((o.x+s.x)*.5,(o.y+s.y)*.5),a.onCurve||(h={x:(o.x+a.x)*.5,y:(o.y+a.y)*.5}),e.quadraticCurveTo(o.x,o.y,h.x,h.y)}e.closePath()}return e}function Ki(n,e){if(e.isComposite)for(var t=0;t<e.components.length;t+=1){var r=e.components[t],i=n.get(r.glyphIndex);if(i.getPath(),i.points){var s=void 0;if(r.matchedPoints===void 0)s=Xn(i.points,r);else{if(r.matchedPoints[0]>e.points.length-1||r.matchedPoints[1]>i.points.length-1)throw Error("Matched points out of range in "+e.name);var o=e.points[r.matchedPoints[0]],a=i.points[r.matchedPoints[1]],c={xScale:r.xScale,scale01:r.scale01,scale10:r.scale10,yScale:r.yScale,dx:0,dy:0};a=Xn([a],c)[0],c.dx=o.x-a.x,c.dy=o.y-a.y,s=Xn(i.points,c)}e.points=e.points.concat(s)}}return Ji(e.points)}function Sc(n,e,t,r){for(var i=new be.GlyphSet(r),s=0;s<t.length-1;s+=1){var o=t[s],a=t[s+1];o!==a?i.push(s,be.ttfGlyphLoader(r,s,Qi,n,e+o,Ki)):i.push(s,be.glyphLoader(r,s))}return i}function wc(n,e,t,r){var i=new be.GlyphSet(r);return r._push=function(s){var o=t[s],a=t[s+1];o!==a?i.push(s,be.ttfGlyphLoader(r,s,Qi,n,e+o,Ki)):i.push(s,be.glyphLoader(r,s))},i}function _c(n,e,t,r,i){return i.lowMemory?wc(n,e,t,r):Sc(n,e,t,r)}var es={getPath:Ji,parse:_c},ts,je,ns,qn;function rs(n){this.font=n,this.getCommands=function(e){return es.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function Tc(n){return n}function is(n){return Math.sign(n)*Math.round(Math.abs(n))}function Cc(n){return Math.sign(n)*Math.round(Math.abs(n*2))/2}function Ic(n){return Math.sign(n)*(Math.round(Math.abs(n)+.5)-.5)}function Ac(n){return Math.sign(n)*Math.ceil(Math.abs(n))}function Ec(n){return Math.sign(n)*Math.floor(Math.abs(n))}var ss=function(n){var e=this.srPeriod,t=this.srPhase,r=this.srThreshold,i=1;return n<0&&(n=-n,i=-1),n+=r-t,n=Math.trunc(n/e)*e,n+=t,n<0?t*i:n*i},xe={x:1,y:0,axis:"x",distance:function(n,e,t,r){return(t?n.xo:n.x)-(r?e.xo:e.x)},interpolate:function(n,e,t,r){var i,s,o,a,c,l,h;if(!r||r===this){if(i=n.xo-e.xo,s=n.xo-t.xo,c=e.x-e.xo,l=t.x-t.xo,o=Math.abs(i),a=Math.abs(s),h=o+a,h===0){n.x=n.xo+(c+l)/2;return}n.x=n.xo+(c*a+l*o)/h;return}if(i=r.distance(n,e,!0,!0),s=r.distance(n,t,!0,!0),c=r.distance(e,e,!1,!0),l=r.distance(t,t,!1,!0),o=Math.abs(i),a=Math.abs(s),h=o+a,h===0){xe.setRelative(n,n,(c+l)/2,r,!0);return}xe.setRelative(n,n,(c*a+l*o)/h,r,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(n,e,t,r,i){if(!r||r===this){n.x=(i?e.xo:e.x)+t;return}var s=i?e.xo:e.x,o=i?e.yo:e.y,a=s+t*r.x,c=o+t*r.y;n.x=a+(n.y-c)/r.normalSlope},slope:0,touch:function(n){n.xTouched=!0},touched:function(n){return n.xTouched},untouch:function(n){n.xTouched=!1}},Ae={x:0,y:1,axis:"y",distance:function(n,e,t,r){return(t?n.yo:n.y)-(r?e.yo:e.y)},interpolate:function(n,e,t,r){var i,s,o,a,c,l,h;if(!r||r===this){if(i=n.yo-e.yo,s=n.yo-t.yo,c=e.y-e.yo,l=t.y-t.yo,o=Math.abs(i),a=Math.abs(s),h=o+a,h===0){n.y=n.yo+(c+l)/2;return}n.y=n.yo+(c*a+l*o)/h;return}if(i=r.distance(n,e,!0,!0),s=r.distance(n,t,!0,!0),c=r.distance(e,e,!1,!0),l=r.distance(t,t,!1,!0),o=Math.abs(i),a=Math.abs(s),h=o+a,h===0){Ae.setRelative(n,n,(c+l)/2,r,!0);return}Ae.setRelative(n,n,(c*a+l*o)/h,r,!0)},normalSlope:0,setRelative:function(n,e,t,r,i){if(!r||r===this){n.y=(i?e.yo:e.y)+t;return}var s=i?e.xo:e.x,o=i?e.yo:e.y,a=s+t*r.x,c=o+t*r.y;n.y=c+r.normalSlope*(n.x-a)},slope:Number.POSITIVE_INFINITY,touch:function(n){n.yTouched=!0},touched:function(n){return n.yTouched},untouch:function(n){n.yTouched=!1}};Object.freeze(xe),Object.freeze(Ae);function St(n,e){this.x=n,this.y=e,this.axis=void 0,this.slope=e/n,this.normalSlope=-n/e,Object.freeze(this)}St.prototype.distance=function(n,e,t,r){return this.x*xe.distance(n,e,t,r)+this.y*Ae.distance(n,e,t,r)},St.prototype.interpolate=function(n,e,t,r){var i,s,o,a,c,l,h;if(o=r.distance(n,e,!0,!0),a=r.distance(n,t,!0,!0),i=r.distance(e,e,!1,!0),s=r.distance(t,t,!1,!0),c=Math.abs(o),l=Math.abs(a),h=c+l,h===0){this.setRelative(n,n,(i+s)/2,r,!0);return}this.setRelative(n,n,(i*l+s*c)/h,r,!0)},St.prototype.setRelative=function(n,e,t,r,i){r=r||this;var s=i?e.xo:e.x,o=i?e.yo:e.y,a=s+t*r.x,c=o+t*r.y,l=r.normalSlope,h=this.slope,d=n.x,u=n.y;n.x=(h*d-l*a+c-u)/(h-l),n.y=h*(n.x-d)+u},St.prototype.touch=function(n){n.xTouched=!0,n.yTouched=!0};function wt(n,e){var t=Math.sqrt(n*n+e*e);return n/=t,e/=t,n===1&&e===0?xe:n===0&&e===1?Ae:new St(n,e)}function Ee(n,e,t,r){this.x=this.xo=Math.round(n*64)/64,this.y=this.yo=Math.round(e*64)/64,this.lastPointOfContour=t,this.onCurve=r,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}Ee.prototype.nextTouched=function(n){for(var e=this.nextPointOnContour;!n.touched(e)&&e!==this;)e=e.nextPointOnContour;return e},Ee.prototype.prevTouched=function(n){for(var e=this.prevPointOnContour;!n.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};var _t=Object.freeze(new Ee(0,0)),kc={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function Me(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=xe,this.round=is}}rs.prototype.exec=function(n,e){if(typeof e!="number")throw new Error("Point size is not a number!");if(!(this._errorState>2)){var t=this.font,r=this._prepState;if(!r||r.ppem!==e){var i=this._fpgmState;if(!i){Me.prototype=kc,i=this._fpgmState=new Me("fpgm",t.tables.fpgm),i.funcs=[],i.font=t,b.DEBUG&&(console.log("---EXEC FPGM---"),i.step=-1);try{je(i)}catch(l){console.log("Hinting error in FPGM:"+l),this._errorState=3;return}}Me.prototype=i,r=this._prepState=new Me("prep",t.tables.prep),r.ppem=e;var s=t.tables.cvt;if(s)for(var o=r.cvt=new Array(s.length),a=e/t.unitsPerEm,c=0;c<s.length;c++)o[c]=s[c]*a;else r.cvt=[];b.DEBUG&&(console.log("---EXEC PREP---"),r.step=-1);try{je(r)}catch(l){this._errorState<2&&console.log("Hinting error in PREP:"+l),this._errorState=2}}if(!(this._errorState>1))try{return ns(n,r)}catch(l){this._errorState<1&&(console.log("Hinting error:"+l),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}}},ns=function(n,e){var t=e.ppem/e.font.unitsPerEm,r=t,i=n.components,s,o,a;if(Me.prototype=e,!i)a=new Me("glyf",n.instructions),b.DEBUG&&(console.log("---EXEC GLYPH---"),a.step=-1),qn(n,a,t,r),o=a.gZone;else{var c=e.font;o=[],s=[];for(var l=0;l<i.length;l++){var h=i[l],d=c.glyphs.get(h.glyphIndex);a=new Me("glyf",d.instructions),b.DEBUG&&(console.log("---EXEC COMP "+l+"---"),a.step=-1),qn(d,a,t,r);for(var u=Math.round(h.dx*t),p=Math.round(h.dy*r),f=a.gZone,m=a.contours,y=0;y<f.length;y++){var v=f[y];v.xTouched=v.yTouched=!1,v.xo=v.x=v.x+u,v.yo=v.y=v.y+p}var _=o.length;o.push.apply(o,f);for(var w=0;w<m.length;w++)s.push(m[w]+_)}n.instructions&&!a.inhibitGridFit&&(a=new Me("glyf",n.instructions),a.gZone=a.z0=a.z1=a.z2=o,a.contours=s,o.push(new Ee(0,0),new Ee(Math.round(n.advanceWidth*t),0)),b.DEBUG&&(console.log("---EXEC COMPOSITE---"),a.step=-1),je(a),o.length-=2)}return o},qn=function(n,e,t,r){for(var i=n.points||[],s=i.length,o=e.gZone=e.z0=e.z1=e.z2=[],a=e.contours=[],c,l=0;l<s;l++)c=i[l],o[l]=new Ee(c.x*t,c.y*r,c.lastPointOfContour,c.onCurve);for(var h,d,u=0;u<s;u++)c=o[u],h||(h=c,a.push(u)),c.lastPointOfContour?(c.nextPointOnContour=h,h.prevPointOnContour=c,h=void 0):(d=o[u+1],c.nextPointOnContour=d,d.prevPointOnContour=c);if(!e.inhibitGridFit){if(b.DEBUG){console.log("PROCESSING GLYPH",e.stack);for(var p=0;p<s;p++)console.log(p,o[p].x,o[p].y)}if(o.push(new Ee(0,0),new Ee(Math.round(n.advanceWidth*t),0)),je(e),o.length-=2,b.DEBUG){console.log("FINISHED GLYPH",e.stack);for(var f=0;f<s;f++)console.log(f,o[f].x,o[f].y)}}},je=function(n){var e=n.prog;if(e){var t=e.length,r;for(n.ip=0;n.ip<t;n.ip++){if(b.DEBUG&&n.step++,r=ts[e[n.ip]],!r)throw new Error("unknown instruction: 0x"+Number(e[n.ip]).toString(16));r(n)}}};function Qt(n){for(var e=n.tZone=new Array(n.gZone.length),t=0;t<e.length;t++)e[t]=new Ee(0,0)}function os(n,e){var t=n.prog,r=n.ip,i=1,s;do if(s=t[++r],s===88)i++;else if(s===89)i--;else if(s===64)r+=t[r+1]+1;else if(s===65)r+=2*t[r+1]+1;else if(s>=176&&s<=183)r+=s-176+1;else if(s>=184&&s<=191)r+=(s-184+1)*2;else if(e&&i===1&&s===27)break;while(i>0);n.ip=r}function as(n,e){b.DEBUG&&console.log(e.step,"SVTCA["+n.axis+"]"),e.fv=e.pv=e.dpv=n}function cs(n,e){b.DEBUG&&console.log(e.step,"SPVTCA["+n.axis+"]"),e.pv=e.dpv=n}function ls(n,e){b.DEBUG&&console.log(e.step,"SFVTCA["+n.axis+"]"),e.fv=n}function hs(n,e){var t=e.stack,r=t.pop(),i=t.pop(),s=e.z2[r],o=e.z1[i];b.DEBUG&&console.log("SPVTL["+n+"]",r,i);var a,c;n?(a=s.y-o.y,c=o.x-s.x):(a=o.x-s.x,c=o.y-s.y),e.pv=e.dpv=wt(a,c)}function us(n,e){var t=e.stack,r=t.pop(),i=t.pop(),s=e.z2[r],o=e.z1[i];b.DEBUG&&console.log("SFVTL["+n+"]",r,i);var a,c;n?(a=s.y-o.y,c=o.x-s.x):(a=o.x-s.x,c=o.y-s.y),e.fv=wt(a,c)}function Bc(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"SPVFS[]",t,r),n.pv=n.dpv=wt(r,t)}function Lc(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"SPVFS[]",t,r),n.fv=wt(r,t)}function Oc(n){var e=n.stack,t=n.pv;b.DEBUG&&console.log(n.step,"GPV[]"),e.push(t.x*16384),e.push(t.y*16384)}function Mc(n){var e=n.stack,t=n.fv;b.DEBUG&&console.log(n.step,"GFV[]"),e.push(t.x*16384),e.push(t.y*16384)}function Dc(n){n.fv=n.pv,b.DEBUG&&console.log(n.step,"SFVTPV[]")}function Rc(n){var e=n.stack,t=e.pop(),r=e.pop(),i=e.pop(),s=e.pop(),o=e.pop(),a=n.z0,c=n.z1,l=a[t],h=a[r],d=c[i],u=c[s],p=n.z2[o];b.DEBUG&&console.log("ISECT[], ",t,r,i,s,o);var f=l.x,m=l.y,y=h.x,v=h.y,_=d.x,w=d.y,C=u.x,T=u.y,D=(f-y)*(w-T)-(m-v)*(_-C),I=f*v-m*y,E=_*T-w*C;p.x=(I*(_-C)-E*(f-y))/D,p.y=(I*(w-T)-E*(m-v))/D}function Uc(n){n.rp0=n.stack.pop(),b.DEBUG&&console.log(n.step,"SRP0[]",n.rp0)}function Fc(n){n.rp1=n.stack.pop(),b.DEBUG&&console.log(n.step,"SRP1[]",n.rp1)}function Pc(n){n.rp2=n.stack.pop(),b.DEBUG&&console.log(n.step,"SRP2[]",n.rp2)}function Gc(n){var e=n.stack.pop();switch(b.DEBUG&&console.log(n.step,"SZP0[]",e),n.zp0=e,e){case 0:n.tZone||Qt(n),n.z0=n.tZone;break;case 1:n.z0=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function Nc(n){var e=n.stack.pop();switch(b.DEBUG&&console.log(n.step,"SZP1[]",e),n.zp1=e,e){case 0:n.tZone||Qt(n),n.z1=n.tZone;break;case 1:n.z1=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function zc(n){var e=n.stack.pop();switch(b.DEBUG&&console.log(n.step,"SZP2[]",e),n.zp2=e,e){case 0:n.tZone||Qt(n),n.z2=n.tZone;break;case 1:n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function Vc(n){var e=n.stack.pop();switch(b.DEBUG&&console.log(n.step,"SZPS[]",e),n.zp0=n.zp1=n.zp2=e,e){case 0:n.tZone||Qt(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 Hc(n){n.loop=n.stack.pop(),b.DEBUG&&console.log(n.step,"SLOOP[]",n.loop)}function jc(n){b.DEBUG&&console.log(n.step,"RTG[]"),n.round=is}function Wc(n){b.DEBUG&&console.log(n.step,"RTHG[]"),n.round=Ic}function Xc(n){var e=n.stack.pop();b.DEBUG&&console.log(n.step,"SMD[]",e),n.minDis=e/64}function qc(n){b.DEBUG&&console.log(n.step,"ELSE[]"),os(n,!1)}function Yc(n){var e=n.stack.pop();b.DEBUG&&console.log(n.step,"JMPR[]",e),n.ip+=e-1}function $c(n){var e=n.stack.pop();b.DEBUG&&console.log(n.step,"SCVTCI[]",e),n.cvCutIn=e/64}function Zc(n){var e=n.stack;b.DEBUG&&console.log(n.step,"DUP[]"),e.push(e[e.length-1])}function Yn(n){b.DEBUG&&console.log(n.step,"POP[]"),n.stack.pop()}function Qc(n){b.DEBUG&&console.log(n.step,"CLEAR[]"),n.stack.length=0}function Jc(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"SWAP[]"),e.push(t),e.push(r)}function Kc(n){var e=n.stack;b.DEBUG&&console.log(n.step,"DEPTH[]"),e.push(e.length)}function el(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"LOOPCALL[]",t,r);var i=n.ip,s=n.prog;n.prog=n.funcs[t];for(var o=0;o<r;o++)je(n),b.DEBUG&&console.log(++n.step,o+1<r?"next loopcall":"done loopcall",o);n.ip=i,n.prog=s}function tl(n){var e=n.stack.pop();b.DEBUG&&console.log(n.step,"CALL[]",e);var t=n.ip,r=n.prog;n.prog=n.funcs[e],je(n),n.ip=t,n.prog=r,b.DEBUG&&console.log(++n.step,"returning from",e)}function nl(n){var e=n.stack,t=e.pop();b.DEBUG&&console.log(n.step,"CINDEX[]",t),e.push(e[e.length-t])}function rl(n){var e=n.stack,t=e.pop();b.DEBUG&&console.log(n.step,"MINDEX[]",t),e.push(e.splice(e.length-t,1)[0])}function il(n){if(n.env!=="fpgm")throw new Error("FDEF not allowed here");var e=n.stack,t=n.prog,r=n.ip,i=e.pop(),s=r;for(b.DEBUG&&console.log(n.step,"FDEF[]",i);t[++r]!==45;);n.ip=r,n.funcs[i]=t.slice(s+1,r)}function ds(n,e){var t=e.stack.pop(),r=e.z0[t],i=e.fv,s=e.pv;b.DEBUG&&console.log(e.step,"MDAP["+n+"]",t);var o=s.distance(r,_t);n&&(o=e.round(o)),i.setRelative(r,_t,o,s),i.touch(r),e.rp0=e.rp1=t}function ps(n,e){var t=e.z2,r=t.length-2,i,s,o;b.DEBUG&&console.log(e.step,"IUP["+n.axis+"]");for(var a=0;a<r;a++)i=t[a],!n.touched(i)&&(s=i.prevTouched(n),s!==i&&(o=i.nextTouched(n),s===o&&n.setRelative(i,i,n.distance(s,s,!1,!0),n,!0),n.interpolate(i,s,o,n)))}function fs(n,e){for(var t=e.stack,r=n?e.rp1:e.rp2,i=(n?e.z0:e.z1)[r],s=e.fv,o=e.pv,a=e.loop,c=e.z2;a--;){var l=t.pop(),h=c[l],d=o.distance(i,i,!1,!0);s.setRelative(h,h,d,o),s.touch(h),b.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-a)+": ":"")+"SHP["+(n?"rp1":"rp2")+"]",l)}e.loop=1}function gs(n,e){var t=e.stack,r=n?e.rp1:e.rp2,i=(n?e.z0:e.z1)[r],s=e.fv,o=e.pv,a=t.pop(),c=e.z2[e.contours[a]],l=c;b.DEBUG&&console.log(e.step,"SHC["+n+"]",a);var h=o.distance(i,i,!1,!0);do l!==i&&s.setRelative(l,l,h,o),l=l.nextPointOnContour;while(l!==c)}function ms(n,e){var t=e.stack,r=n?e.rp1:e.rp2,i=(n?e.z0:e.z1)[r],s=e.fv,o=e.pv,a=t.pop();b.DEBUG&&console.log(e.step,"SHZ["+n+"]",a);var c;switch(a){case 0:c=e.tZone;break;case 1:c=e.gZone;break;default:throw new Error("Invalid zone")}for(var l,h=o.distance(i,i,!1,!0),d=c.length-2,u=0;u<d;u++)l=c[u],s.setRelative(l,l,h,o)}function sl(n){for(var e=n.stack,t=n.loop,r=n.fv,i=e.pop()/64,s=n.z2;t--;){var o=e.pop(),a=s[o];b.DEBUG&&console.log(n.step,(n.loop>1?"loop "+(n.loop-t)+": ":"")+"SHPIX[]",o,i),r.setRelative(a,a,i),r.touch(a)}n.loop=1}function ol(n){for(var e=n.stack,t=n.rp1,r=n.rp2,i=n.loop,s=n.z0[t],o=n.z1[r],a=n.fv,c=n.dpv,l=n.z2;i--;){var h=e.pop(),d=l[h];b.DEBUG&&console.log(n.step,(n.loop>1?"loop "+(n.loop-i)+": ":"")+"IP[]",h,t,"<->",r),a.interpolate(d,s,o,c),a.touch(d)}n.loop=1}function ys(n,e){var t=e.stack,r=t.pop()/64,i=t.pop(),s=e.z1[i],o=e.z0[e.rp0],a=e.fv,c=e.pv;a.setRelative(s,o,r,c),a.touch(s),b.DEBUG&&console.log(e.step,"MSIRP["+n+"]",r,i),e.rp1=e.rp0,e.rp2=i,n&&(e.rp0=i)}function al(n){for(var e=n.stack,t=n.rp0,r=n.z0[t],i=n.loop,s=n.fv,o=n.pv,a=n.z1;i--;){var c=e.pop(),l=a[c];b.DEBUG&&console.log(n.step,(n.loop>1?"loop "+(n.loop-i)+": ":"")+"ALIGNRP[]",c),s.setRelative(l,r,0,o),s.touch(l)}n.loop=1}function cl(n){b.DEBUG&&console.log(n.step,"RTDG[]"),n.round=Cc}function vs(n,e){var t=e.stack,r=t.pop(),i=t.pop(),s=e.z0[i],o=e.fv,a=e.pv,c=e.cvt[r];b.DEBUG&&console.log(e.step,"MIAP["+n+"]",r,"(",c,")",i);var l=a.distance(s,_t);n&&(Math.abs(l-c)<e.cvCutIn&&(l=c),l=e.round(l)),o.setRelative(s,_t,l,a),e.zp0===0&&(s.xo=s.x,s.yo=s.y),o.touch(s),e.rp0=e.rp1=i}function ll(n){var e=n.prog,t=n.ip,r=n.stack,i=e[++t];b.DEBUG&&console.log(n.step,"NPUSHB[]",i);for(var s=0;s<i;s++)r.push(e[++t]);n.ip=t}function hl(n){var e=n.ip,t=n.prog,r=n.stack,i=t[++e];b.DEBUG&&console.log(n.step,"NPUSHW[]",i);for(var s=0;s<i;s++){var o=t[++e]<<8|t[++e];o&32768&&(o=-((o^65535)+1)),r.push(o)}n.ip=e}function ul(n){var e=n.stack,t=n.store;t||(t=n.store=[]);var r=e.pop(),i=e.pop();b.DEBUG&&console.log(n.step,"WS",r,i),t[i]=r}function dl(n){var e=n.stack,t=n.store,r=e.pop();b.DEBUG&&console.log(n.step,"RS",r);var i=t&&t[r]||0;e.push(i)}function pl(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"WCVTP",t,r),n.cvt[r]=t/64}function fl(n){var e=n.stack,t=e.pop();b.DEBUG&&console.log(n.step,"RCVT",t),e.push(n.cvt[t]*64)}function bs(n,e){var t=e.stack,r=t.pop(),i=e.z2[r];b.DEBUG&&console.log(e.step,"GC["+n+"]",r),t.push(e.dpv.distance(i,_t,n,!1)*64)}function xs(n,e){var t=e.stack,r=t.pop(),i=t.pop(),s=e.z1[r],o=e.z0[i],a=e.dpv.distance(o,s,n,n);b.DEBUG&&console.log(e.step,"MD["+n+"]",r,i,"->",a),e.stack.push(Math.round(a*64))}function gl(n){b.DEBUG&&console.log(n.step,"MPPEM[]"),n.stack.push(n.ppem)}function ml(n){b.DEBUG&&console.log(n.step,"FLIPON[]"),n.autoFlip=!0}function yl(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"LT[]",t,r),e.push(r<t?1:0)}function vl(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"LTEQ[]",t,r),e.push(r<=t?1:0)}function bl(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"GT[]",t,r),e.push(r>t?1:0)}function xl(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"GTEQ[]",t,r),e.push(r>=t?1:0)}function Sl(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"EQ[]",t,r),e.push(t===r?1:0)}function wl(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"NEQ[]",t,r),e.push(t!==r?1:0)}function _l(n){var e=n.stack,t=e.pop();b.DEBUG&&console.log(n.step,"ODD[]",t),e.push(Math.trunc(t)%2?1:0)}function Tl(n){var e=n.stack,t=e.pop();b.DEBUG&&console.log(n.step,"EVEN[]",t),e.push(Math.trunc(t)%2?0:1)}function Cl(n){var e=n.stack.pop();b.DEBUG&&console.log(n.step,"IF[]",e),e||(os(n,!0),b.DEBUG&&console.log(n.step,"EIF[]"))}function Il(n){b.DEBUG&&console.log(n.step,"EIF[]")}function Al(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"AND[]",t,r),e.push(t&&r?1:0)}function El(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"OR[]",t,r),e.push(t||r?1:0)}function kl(n){var e=n.stack,t=e.pop();b.DEBUG&&console.log(n.step,"NOT[]",t),e.push(t?0:1)}function $n(n,e){var t=e.stack,r=t.pop(),i=e.fv,s=e.pv,o=e.ppem,a=e.deltaBase+(n-1)*16,c=e.deltaShift,l=e.z0;b.DEBUG&&console.log(e.step,"DELTAP["+n+"]",r,t);for(var h=0;h<r;h++){var d=t.pop(),u=t.pop(),p=a+((u&240)>>4);if(p===o){var f=(u&15)-8;f>=0&&f++,b.DEBUG&&console.log(e.step,"DELTAPFIX",d,"by",f*c);var m=l[d];i.setRelative(m,m,f*c,s)}}}function Bl(n){var e=n.stack,t=e.pop();b.DEBUG&&console.log(n.step,"SDB[]",t),n.deltaBase=t}function Ll(n){var e=n.stack,t=e.pop();b.DEBUG&&console.log(n.step,"SDS[]",t),n.deltaShift=Math.pow(.5,t)}function Ol(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"ADD[]",t,r),e.push(r+t)}function Ml(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"SUB[]",t,r),e.push(r-t)}function Dl(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"DIV[]",t,r),e.push(r*64/t)}function Rl(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"MUL[]",t,r),e.push(r*t/64)}function Ul(n){var e=n.stack,t=e.pop();b.DEBUG&&console.log(n.step,"ABS[]",t),e.push(Math.abs(t))}function Fl(n){var e=n.stack,t=e.pop();b.DEBUG&&console.log(n.step,"NEG[]",t),e.push(-t)}function Pl(n){var e=n.stack,t=e.pop();b.DEBUG&&console.log(n.step,"FLOOR[]",t),e.push(Math.floor(t/64)*64)}function Gl(n){var e=n.stack,t=e.pop();b.DEBUG&&console.log(n.step,"CEILING[]",t),e.push(Math.ceil(t/64)*64)}function Jt(n,e){var t=e.stack,r=t.pop();b.DEBUG&&console.log(e.step,"ROUND[]"),t.push(e.round(r/64)*64)}function Nl(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"WCVTF[]",t,r),n.cvt[r]=t*n.ppem/n.font.unitsPerEm}function Zn(n,e){var t=e.stack,r=t.pop(),i=e.ppem,s=e.deltaBase+(n-1)*16,o=e.deltaShift;b.DEBUG&&console.log(e.step,"DELTAC["+n+"]",r,t);for(var a=0;a<r;a++){var c=t.pop(),l=t.pop(),h=s+((l&240)>>4);if(h===i){var d=(l&15)-8;d>=0&&d++;var u=d*o;b.DEBUG&&console.log(e.step,"DELTACFIX",c,"by",u),e.cvt[c]+=u}}}function zl(n){var e=n.stack.pop();b.DEBUG&&console.log(n.step,"SROUND[]",e),n.round=ss;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 Vl(n){var e=n.stack.pop();b.DEBUG&&console.log(n.step,"S45ROUND[]",e),n.round=ss;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 Hl(n){b.DEBUG&&console.log(n.step,"ROFF[]"),n.round=Tc}function jl(n){b.DEBUG&&console.log(n.step,"RUTG[]"),n.round=Ac}function Wl(n){b.DEBUG&&console.log(n.step,"RDTG[]"),n.round=Ec}function Xl(n){var e=n.stack.pop();b.DEBUG&&console.log(n.step,"SCANCTRL[]",e)}function Ss(n,e){var t=e.stack,r=t.pop(),i=t.pop(),s=e.z2[r],o=e.z1[i];b.DEBUG&&console.log(e.step,"SDPVTL["+n+"]",r,i);var a,c;n?(a=s.y-o.y,c=o.x-s.x):(a=o.x-s.x,c=o.y-s.y),e.dpv=wt(a,c)}function ql(n){var e=n.stack,t=e.pop(),r=0;b.DEBUG&&console.log(n.step,"GETINFO[]",t),t&1&&(r=35),t&32&&(r|=4096),e.push(r)}function Yl(n){var e=n.stack,t=e.pop(),r=e.pop(),i=e.pop();b.DEBUG&&console.log(n.step,"ROLL[]"),e.push(r),e.push(t),e.push(i)}function $l(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"MAX[]",t,r),e.push(Math.max(r,t))}function Zl(n){var e=n.stack,t=e.pop(),r=e.pop();b.DEBUG&&console.log(n.step,"MIN[]",t,r),e.push(Math.min(r,t))}function Ql(n){var e=n.stack.pop();b.DEBUG&&console.log(n.step,"SCANTYPE[]",e)}function Jl(n){var e=n.stack.pop(),t=n.stack.pop();switch(b.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 De(n,e){var t=e.stack,r=e.prog,i=e.ip;b.DEBUG&&console.log(e.step,"PUSHB["+n+"]");for(var s=0;s<n;s++)t.push(r[++i]);e.ip=i}function Re(n,e){var t=e.ip,r=e.prog,i=e.stack;b.DEBUG&&console.log(e.ip,"PUSHW["+n+"]");for(var s=0;s<n;s++){var o=r[++t]<<8|r[++t];o&32768&&(o=-((o^65535)+1)),i.push(o)}e.ip=t}function B(n,e,t,r,i,s){var o=s.stack,a=n&&o.pop(),c=o.pop(),l=s.rp0,h=s.z0[l],d=s.z1[c],u=s.minDis,p=s.fv,f=s.dpv,m,y,v,_;y=m=f.distance(d,h,!0,!0),v=y>=0?1:-1,y=Math.abs(y),n&&(_=s.cvt[a],r&&Math.abs(y-_)<s.cvCutIn&&(y=_)),t&&y<u&&(y=u),r&&(y=s.round(y)),p.setRelative(d,h,v*y,f),p.touch(d),b.DEBUG&&console.log(s.step,(n?"MIRP[":"MDRP[")+(e?"M":"m")+(t?">":"_")+(r?"R":"_")+(i===0?"Gr":i===1?"Bl":i===2?"Wh":"")+"]",n?a+"("+s.cvt[a]+","+_+")":"",c,"(d =",m,"->",v*y,")"),s.rp1=s.rp0,s.rp2=c,e&&(s.rp0=c)}ts=[as.bind(void 0,Ae),as.bind(void 0,xe),cs.bind(void 0,Ae),cs.bind(void 0,xe),ls.bind(void 0,Ae),ls.bind(void 0,xe),hs.bind(void 0,0),hs.bind(void 0,1),us.bind(void 0,0),us.bind(void 0,1),Bc,Lc,Oc,Mc,Dc,Rc,Uc,Fc,Pc,Gc,Nc,zc,Vc,Hc,jc,Wc,Xc,qc,Yc,$c,void 0,void 0,Zc,Yn,Qc,Jc,Kc,nl,rl,void 0,void 0,void 0,el,tl,il,void 0,ds.bind(void 0,0),ds.bind(void 0,1),ps.bind(void 0,Ae),ps.bind(void 0,xe),fs.bind(void 0,0),fs.bind(void 0,1),gs.bind(void 0,0),gs.bind(void 0,1),ms.bind(void 0,0),ms.bind(void 0,1),sl,ol,ys.bind(void 0,0),ys.bind(void 0,1),al,cl,vs.bind(void 0,0),vs.bind(void 0,1),ll,hl,ul,dl,pl,fl,bs.bind(void 0,0),bs.bind(void 0,1),void 0,xs.bind(void 0,0),xs.bind(void 0,1),gl,void 0,ml,void 0,void 0,yl,vl,bl,xl,Sl,wl,_l,Tl,Cl,Il,Al,El,kl,$n.bind(void 0,1),Bl,Ll,Ol,Ml,Dl,Rl,Ul,Fl,Pl,Gl,Jt.bind(void 0,0),Jt.bind(void 0,1),Jt.bind(void 0,2),Jt.bind(void 0,3),void 0,void 0,void 0,void 0,Nl,$n.bind(void 0,2),$n.bind(void 0,3),Zn.bind(void 0,1),Zn.bind(void 0,2),Zn.bind(void 0,3),zl,Vl,void 0,void 0,Hl,void 0,jl,Wl,Yn,Yn,void 0,void 0,void 0,void 0,void 0,Xl,Ss.bind(void 0,0),Ss.bind(void 0,1),ql,void 0,Yl,$l,Zl,Ql,Jl,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,De.bind(void 0,1),De.bind(void 0,2),De.bind(void 0,3),De.bind(void 0,4),De.bind(void 0,5),De.bind(void 0,6),De.bind(void 0,7),De.bind(void 0,8),Re.bind(void 0,1),Re.bind(void 0,2),Re.bind(void 0,3),Re.bind(void 0,4),Re.bind(void 0,5),Re.bind(void 0,6),Re.bind(void 0,7),Re.bind(void 0,8),B.bind(void 0,0,0,0,0,0),B.bind(void 0,0,0,0,0,1),B.bind(void 0,0,0,0,0,2),B.bind(void 0,0,0,0,0,3),B.bind(void 0,0,0,0,1,0),B.bind(void 0,0,0,0,1,1),B.bind(void 0,0,0,0,1,2),B.bind(void 0,0,0,0,1,3),B.bind(void 0,0,0,1,0,0),B.bind(void 0,0,0,1,0,1),B.bind(void 0,0,0,1,0,2),B.bind(void 0,0,0,1,0,3),B.bind(void 0,0,0,1,1,0),B.bind(void 0,0,0,1,1,1),B.bind(void 0,0,0,1,1,2),B.bind(void 0,0,0,1,1,3),B.bind(void 0,0,1,0,0,0),B.bind(void 0,0,1,0,0,1),B.bind(void 0,0,1,0,0,2),B.bind(void 0,0,1,0,0,3),B.bind(void 0,0,1,0,1,0),B.bind(void 0,0,1,0,1,1),B.bind(void 0,0,1,0,1,2),B.bind(void 0,0,1,0,1,3),B.bind(void 0,0,1,1,0,0),B.bind(void 0,0,1,1,0,1),B.bind(void 0,0,1,1,0,2),B.bind(void 0,0,1,1,0,3),B.bind(void 0,0,1,1,1,0),B.bind(void 0,0,1,1,1,1),B.bind(void 0,0,1,1,1,2),B.bind(void 0,0,1,1,1,3),B.bind(void 0,1,0,0,0,0),B.bind(void 0,1,0,0,0,1),B.bind(void 0,1,0,0,0,2),B.bind(void 0,1,0,0,0,3),B.bind(void 0,1,0,0,1,0),B.bind(void 0,1,0,0,1,1),B.bind(void 0,1,0,0,1,2),B.bind(void 0,1,0,0,1,3),B.bind(void 0,1,0,1,0,0),B.bind(void 0,1,0,1,0,1),B.bind(void 0,1,0,1,0,2),B.bind(void 0,1,0,1,0,3),B.bind(void 0,1,0,1,1,0),B.bind(void 0,1,0,1,1,1),B.bind(void 0,1,0,1,1,2),B.bind(void 0,1,0,1,1,3),B.bind(void 0,1,1,0,0,0),B.bind(void 0,1,1,0,0,1),B.bind(void 0,1,1,0,0,2),B.bind(void 0,1,1,0,0,3),B.bind(void 0,1,1,0,1,0),B.bind(void 0,1,1,0,1,1),B.bind(void 0,1,1,0,1,2),B.bind(void 0,1,1,0,1,3),B.bind(void 0,1,1,1,0,0),B.bind(void 0,1,1,1,0,1),B.bind(void 0,1,1,1,0,2),B.bind(void 0,1,1,1,0,3),B.bind(void 0,1,1,1,1,0),B.bind(void 0,1,1,1,1,1),B.bind(void 0,1,1,1,1,2),B.bind(void 0,1,1,1,1,3)];function et(n){this.char=n,this.state={},this.activeState=null}function Qn(n,e,t){this.contextName=t,this.startIndex=n,this.endOffset=e}function Kl(n,e,t){this.contextName=n,this.openRange=null,this.ranges=[],this.checkStart=e,this.checkEnd=t}function ue(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 Kt(n){this.eventId=n,this.subscribers=[]}function eh(n){var e=this,t=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];t.forEach(function(i){Object.defineProperty(e.events,i,{value:new Kt(i)})}),n&&t.forEach(function(i){var s=n[i];typeof s=="function"&&e.events[i].subscribe(s)});var r=["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"];r.forEach(function(i){e.events[i].subscribe(e.updateContextsRanges)})}function G(n){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],eh.call(this,n)}et.prototype.setState=function(n,e){return this.state[n]=e,this.activeState={key:n,value:this.state[n]},this.activeState},et.prototype.getState=function(n){return this.state[n]||null},G.prototype.inboundIndex=function(n){return n>=0&&n<this.tokens.length},G.prototype.composeRUD=function(n){var e=this,t=!0,r=n.map(function(s){return e[s[0]].apply(e,s.slice(1).concat(t))}),i=function(s){return typeof s=="object"&&s.hasOwnProperty("FAIL")};if(r.every(i))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:r.filter(i)};this.dispatch("composeRUD",[r.filter(function(s){return!i(s)})])},G.prototype.replaceRange=function(n,e,t,r){e=e!==null?e:this.tokens.length;var i=t.every(function(o){return o instanceof et});if(!isNaN(n)&&this.inboundIndex(n)&&i){var s=this.tokens.splice.apply(this.tokens,[n,e].concat(t));return r||this.dispatch("replaceToken",[n,e,t]),[s,t]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}},G.prototype.replaceToken=function(n,e,t){if(!isNaN(n)&&this.inboundIndex(n)&&e instanceof et){var r=this.tokens.splice(n,1,e);return t||this.dispatch("replaceToken",[n,e]),[r[0],e]}else return{FAIL:"replaceToken: invalid token or index."}},G.prototype.removeRange=function(n,e,t){e=isNaN(e)?this.tokens.length:e;var r=this.tokens.splice(n,e);return t||this.dispatch("removeRange",[r,n,e]),r},G.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."}},G.prototype.insertToken=function(n,e,t){var r=n.every(function(i){return i instanceof et});return r?(this.tokens.splice.apply(this.tokens,[e,0].concat(n)),t||this.dispatch("insertToken",[n,e]),n):{FAIL:"insertToken: invalid token(s)."}},G.prototype.registerModifier=function(n,e,t){this.events.newToken.subscribe(function(r,i){var s=[r,i],o=e===null||e.apply(this,s)===!0,a=[r,i];if(o){var c=t.apply(this,a);r.setState(n,c)}}),this.registeredModifiers.push(n)},Kt.prototype.subscribe=function(n){return typeof n=="function"?this.subscribers.push(n)-1:{FAIL:"invalid '"+this.eventId+"' event handler"}},Kt.prototype.unsubscribe=function(n){this.subscribers.splice(n,1)},ue.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)},ue.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}},G.prototype.rangeToText=function(n){if(n instanceof Qn)return this.getRangeTokens(n).map(function(e){return e.char}).join("")},G.prototype.getText=function(){return this.tokens.map(function(n){return n.char}).join("")},G.prototype.getContext=function(n){var e=this.registeredContexts[n];return e||null},G.prototype.on=function(n,e){var t=this.events[n];return t?t.subscribe(e):null},G.prototype.dispatch=function(n,e){var t=this,r=this.events[n];r instanceof Kt&&r.subscribers.forEach(function(i){i.apply(t,e||[])})},G.prototype.registerContextChecker=function(n,e,t){if(this.getContext(n))return{FAIL:"context name '"+n+"' is already registered."};if(typeof e!="function")return{FAIL:"missing context start check."};if(typeof t!="function")return{FAIL:"missing context end check."};var r=new Kl(n,e,t);return this.registeredContexts[n]=r,this.contextCheckers.push(r),r},G.prototype.getRangeTokens=function(n){var e=n.startIndex+n.endOffset;return[].concat(this.tokens.slice(n.startIndex,e))},G.prototype.getContextRanges=function(n){var e=this.getContext(n);return e?e.ranges:{FAIL:"context checker '"+n+"' is not registered."}},G.prototype.resetContextsRanges=function(){var n=this.registeredContexts;for(var e in n)if(n.hasOwnProperty(e)){var t=n[e];t.ranges=[]}},G.prototype.updateContextsRanges=function(){this.resetContextsRanges();for(var n=this.tokens.map(function(r){return r.char}),e=0;e<n.length;e++){var t=new ue(n,e);this.runContextCheck(t)}this.dispatch("updateContextsRanges",[this.registeredContexts])},G.prototype.setEndOffset=function(n,e){var t=this.getContext(e).openRange.startIndex,r=new Qn(t,n,e),i=this.getContext(e).ranges;return r.rangeId=e+"."+i.length,i.push(r),this.getContext(e).openRange=null,r},G.prototype.runContextCheck=function(n){var e=this,t=n.index;this.contextCheckers.forEach(function(r){var i=r.contextName,s=e.getContext(i).openRange;if(!s&&r.checkStart(n)&&(s=new Qn(t,null,i),e.getContext(i).openRange=s,e.dispatch("contextStart",[i,t])),s&&r.checkEnd(n)){var o=t-s.startIndex+1,a=e.setEndOffset(o,i);e.dispatch("contextEnd",[i,a])}})},G.prototype.tokenize=function(n){this.tokens=[],this.resetContextsRanges();var e=Array.from(n);this.dispatch("start");for(var t=0;t<e.length;t++){var r=e[t],i=new ue(e,t);this.dispatch("next",[i]),this.runContextCheck(i);var s=new et(r);this.tokens.push(s),this.dispatch("newToken",[s,i])}return this.dispatch("end",[this.tokens]),this.tokens};function Ue(n){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(n)}function ws(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 Fe(n){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(n)}function en(n){return/[A-z]/.test(n)}function th(n){return/\s/.test(n)}function re(n){this.font=n,this.features={}}function We(n){this.id=n.id,this.tag=n.tag,this.substitution=n.substitution}function Tt(n,e){if(!n)return-1;switch(e.format){case 1:return e.glyphs.indexOf(n);case 2:for(var t=e.ranges,r=0;r<t.length;r++){var i=t[r];if(n>=i.start&&n<=i.end){var s=n-i.start;return i.index+s}}break;default:return-1}return-1}function nh(n,e){var t=Tt(n,e.coverage);return t===-1?null:n+e.deltaGlyphId}function rh(n,e){var t=Tt(n,e.coverage);return t===-1?null:e.substitute[t]}function Jn(n,e){for(var t=[],r=0;r<n.length;r++){var i=n[r],s=e.current;s=Array.isArray(s)?s[0]:s;var o=Tt(s,i);o!==-1&&t.push(o)}return t.length!==n.length?-1:t}function ih(n,e){var t=e.inputCoverage.length+e.lookaheadCoverage.length+e.backtrackCoverage.length;if(n.context.length<t)return[];var r=Jn(e.inputCoverage,n);if(r===-1)return[];var i=e.inputCoverage.length-1;if(n.lookahead.length<e.lookaheadCoverage.length)return[];for(var s=n.lookahead.slice(i);s.length&&Fe(s[0].char);)s.shift();var o=new ue(s,0),a=Jn(e.lookaheadCoverage,o),c=[].concat(n.backtrack);for(c.reverse();c.length&&Fe(c[0].char);)c.shift();if(c.length<e.backtrackCoverage.length)return[];var l=new ue(c,0),h=Jn(e.backtrackCoverage,l),d=r.length===e.inputCoverage.length&&a.length===e.lookaheadCoverage.length&&h.length===e.backtrackCoverage.length,u=[];if(d)for(var p=0;p<e.lookupRecords.length;p++)for(var f=e.lookupRecords[p],m=f.lookupListIndex,y=this.getLookupByIndex(m),v=0;v<y.subtables.length;v++){var _=y.subtables[v],w=this.getLookupMethod(y,_),C=this.getSubstitutionType(y,_);if(C==="12")for(var T=0;T<r.length;T++){var D=n.get(T),I=w(D);I&&u.push(I)}}return u}function sh(n,e){var t=n.current,r=Tt(t,e.coverage);if(r===-1)return null;for(var i,s=e.ligatureSets[r],o=0;o<s.length;o++){i=s[o];for(var a=0;a<i.components.length;a++){var c=n.lookahead[a],l=i.components[a];if(c!==l)break;if(a===i.components.length-1)return i}}return null}function oh(n,e){var t=Tt(n,e.coverage);return t===-1?null:e.sequences[t]}re.prototype.getDefaultScriptFeaturesIndexes=function(){for(var n=this.font.tables.gsub.scripts,e=0;e<n.length;e++){var t=n[e];if(t.tag==="DFLT")return t.script.defaultLangSys.featureIndexes}return[]},re.prototype.getScriptFeaturesIndexes=function(n){var e=this.font.tables;if(!e.gsub)return[];if(!n)return this.getDefaultScriptFeaturesIndexes();for(var t=this.font.tables.gsub.scripts,r=0;r<t.length;r++){var i=t[r];if(i.tag===n&&i.script.defaultLangSys)return i.script.defaultLangSys.featureIndexes;var s=i.langSysRecords;if(s)for(var o=0;o<s.length;o++){var a=s[o];if(a.tag===n){var c=a.langSys;return c.featureIndexes}}}return this.getDefaultScriptFeaturesIndexes()},re.prototype.mapTagsToFeatures=function(n,e){for(var t={},r=0;r<n.length;r++){var i=n[r].tag,s=n[r].feature;t[i]=s}this.features[e].tags=t},re.prototype.getScriptFeatures=function(n){var e=this.features[n];if(this.features.hasOwnProperty(n))return e;var t=this.getScriptFeaturesIndexes(n);if(!t)return null;var r=this.font.tables.gsub;return e=t.map(function(i){return r.features[i]}),this.features[n]=e,this.mapTagsToFeatures(e,n),e},re.prototype.getSubstitutionType=function(n,e){var t=n.lookupType.toString(),r=e.substFormat.toString();return t+r},re.prototype.getLookupMethod=function(n,e){var t=this,r=this.getSubstitutionType(n,e);switch(r){case"11":return function(i){return nh.apply(t,[i,e])};case"12":return function(i){return rh.apply(t,[i,e])};case"63":return function(i){return ih.apply(t,[i,e])};case"41":return function(i){return sh.apply(t,[i,e])};case"21":return function(i){return oh.apply(t,[i,e])};default:throw new Error("lookupType: "+n.lookupType+" - substFormat: "+e.substFormat+" is not yet supported")}},re.prototype.lookupFeature=function(n){var e=n.contextParams,t=e.index,r=this.getFeature({tag:n.tag,script:n.script});if(!r)return new Error("font '"+this.font.names.fullName.en+"' doesn't support feature '"+n.tag+"' for script '"+n.script+"'.");for(var i=this.getFeatureLookups(r),s=[].concat(e.context),o=0;o<i.length;o++)for(var a=i[o],c=this.getLookupSubtables(a),l=0;l<c.length;l++){var h=c[l],d=this.getSubstitutionType(a,h),u=this.getLookupMethod(a,h),p=void 0;switch(d){case"11":p=u(e.current),p&&s.splice(t,1,new We({id:11,tag:n.tag,substitution:p}));break;case"12":p=u(e.current),p&&s.splice(t,1,new We({id:12,tag:n.tag,substitution:p}));break;case"63":p=u(e),Array.isArray(p)&&p.length&&s.splice(t,1,new We({id:63,tag:n.tag,substitution:p}));break;case"41":p=u(e),p&&s.splice(t,1,new We({id:41,tag:n.tag,substitution:p}));break;case"21":p=u(e.current),p&&s.splice(t,1,new We({id:21,tag:n.tag,substitution:p}));break}e=new ue(s,t),!(Array.isArray(p)&&!p.length)&&(p=null)}return s.length?s:null},re.prototype.supports=function(n){if(!n.script)return!1;this.getScriptFeatures(n.script);var e=this.features.hasOwnProperty(n.script);if(!n.tag)return e;var t=this.features[n.script].some(function(r){return r.tag===n.tag});return e&&t},re.prototype.getLookupSubtables=function(n){return n.subtables||null},re.prototype.getLookupByIndex=function(n){var e=this.font.tables.gsub.lookups;return e[n]||null},re.prototype.getFeatureLookups=function(n){return n.lookupListIndexes.map(this.getLookupByIndex.bind(this))},re.prototype.getFeature=function(n){if(!this.font)return{FAIL:"No font was found"};this.features.hasOwnProperty(n.script)||this.getScriptFeatures(n.script);var e=this.features[n.script];return e?e.tags[n.tag]?this.features[n.script].tags[n.tag]:null:{FAIL:"No feature for script "+n.script}};function ah(n){var e=n.current,t=n.get(-1);return t===null&&Ue(e)||!Ue(t)&&Ue(e)}function ch(n){var e=n.get(1);return e===null||!Ue(e)}var lh={startCheck:ah,endCheck:ch};function hh(n){var e=n.current,t=n.get(-1);return(Ue(e)||Fe(e))&&!Ue(t)}function uh(n){var e=n.get(1);switch(!0){case e===null:return!0;case(!Ue(e)&&!Fe(e)):var t=th(e);if(!t)return!0;if(t){var r=!1;if(r=n.lookahead.some(function(i){return Ue(i)||Fe(i)}),!r)return!0}break;default:return!1}}var dh={startCheck:hh,endCheck:uh};function ph(n,e,t){e[t].setState(n.tag,n.substitution)}function fh(n,e,t){e[t].setState(n.tag,n.substitution)}function gh(n,e,t){n.substitution.forEach(function(r,i){var s=e[t+i];s.setState(n.tag,r)})}function mh(n,e,t){var r=e[t];r.setState(n.tag,n.substitution.ligGlyph);for(var i=n.substitution.components.length,s=0;s<i;s++)r=e[t+s+1],r.setState("deleted",!0)}var _s={11:ph,12:fh,63:gh,41:mh};function Kn(n,e,t){n instanceof We&&_s[n.id]&&_s[n.id](n,e,t)}function yh(n){for(var e=[].concat(n.backtrack),t=e.length-1;t>=0;t--){var r=e[t],i=ws(r),s=Fe(r);if(!i&&!s)return!0;if(i)return!1}return!1}function vh(n){if(ws(n.current))return!1;for(var e=0;e<n.lookahead.length;e++){var t=n.lookahead[e],r=Fe(t);if(!r)return!0}return!1}function bh(n){var e=this,t="arab",r=this.featuresTags[t],i=this.tokenizer.getRangeTokens(n);if(i.length!==1){var s=new ue(i.map(function(a){return a.getState("glyphIndex")}),0),o=new ue(i.map(function(a){return a.char}),0);i.forEach(function(a,c){if(!Fe(a.char)){s.setCurrentIndex(c),o.setCurrentIndex(c);var l=0;yh(o)&&(l|=1),vh(o)&&(l|=2);var h;switch(l){case 1:h="fina";break;case 2:h="init";break;case 3:h="medi";break}if(r.indexOf(h)!==-1){var d=e.query.lookupFeature({tag:h,script:t,contextParams:s});if(d instanceof Error)return console.info(d.message);d.forEach(function(u,p){u instanceof We&&(Kn(u,i,p),s.context[p]=u.substitution)})}}})}}function Ts(n,e){var t=n.map(function(r){return r.activeState.value});return new ue(t,0)}function xh(n){var e=this,t="arab",r=this.tokenizer.getRangeTokens(n),i=Ts(r);i.context.forEach(function(s,o){i.setCurrentIndex(o);var a=e.query.lookupFeature({tag:"rlig",script:t,contextParams:i});a.length&&(a.forEach(function(c){return Kn(c,r,o)}),i=Ts(r))})}function Sh(n){var e=n.current,t=n.get(-1);return t===null&&en(e)||!en(t)&&en(e)}function wh(n){var e=n.get(1);return e===null||!en(e)}var _h={startCheck:Sh,endCheck:wh};function Cs(n,e){var t=n.map(function(r){return r.activeState.value});return new ue(t,0)}function Th(n){var e=this,t="latn",r=this.tokenizer.getRangeTokens(n),i=Cs(r);i.context.forEach(function(s,o){i.setCurrentIndex(o);var a=e.query.lookupFeature({tag:"liga",script:t,contextParams:i});a.length&&(a.forEach(function(c){return Kn(c,r,o)}),i=Cs(r))})}function de(n){this.baseDir=n||"ltr",this.tokenizer=new G,this.featuresTags={}}de.prototype.setText=function(n){this.text=n},de.prototype.contextChecks={latinWordCheck:_h,arabicWordCheck:lh,arabicSentenceCheck:dh};function er(n){var e=this.contextChecks[n+"Check"];return this.tokenizer.registerContextChecker(n,e.startCheck,e.endCheck)}function Ch(){return er.call(this,"latinWord"),er.call(this,"arabicWord"),er.call(this,"arabicSentence"),this.tokenizer.tokenize(this.text)}function Ih(){var n=this,e=this.tokenizer.getContextRanges("arabicSentence");e.forEach(function(t){var r=n.tokenizer.getRangeTokens(t);n.tokenizer.replaceRange(t.startIndex,t.endOffset,r.reverse())})}de.prototype.registerFeatures=function(n,e){var t=this,r=e.filter(function(i){return t.query.supports({script:n,tag:i})});this.featuresTags.hasOwnProperty(n)?this.featuresTags[n]=this.featuresTags[n].concat(r):this.featuresTags[n]=r},de.prototype.applyFeatures=function(n,e){if(!n)throw new Error("No valid font was provided to apply features");this.query||(this.query=new re(n));for(var t=0;t<e.length;t++){var r=e[t];this.query.supports({script:r.script})&&this.registerFeatures(r.script,r.tags)}},de.prototype.registerModifier=function(n,e,t){this.tokenizer.registerModifier(n,e,t)};function tr(){if(this.tokenizer.registeredModifiers.indexOf("glyphIndex")===-1)throw new Error("glyphIndex modifier is required to apply arabic presentation features.")}function Ah(){var n=this,e="arab";if(this.featuresTags.hasOwnProperty(e)){tr.call(this);var t=this.tokenizer.getContextRanges("arabicWord");t.forEach(function(r){bh.call(n,r)})}}function Eh(){var n=this,e="arab";if(this.featuresTags.hasOwnProperty(e)){var t=this.featuresTags[e];if(t.indexOf("rlig")!==-1){tr.call(this);var r=this.tokenizer.getContextRanges("arabicWord");r.forEach(function(i){xh.call(n,i)})}}}function kh(){var n=this,e="latn";if(this.featuresTags.hasOwnProperty(e)){var t=this.featuresTags[e];if(t.indexOf("liga")!==-1){tr.call(this);var r=this.tokenizer.getContextRanges("latinWord");r.forEach(function(i){Th.call(n,i)})}}}de.prototype.checkContextReady=function(n){return!!this.tokenizer.getContext(n)},de.prototype.applyFeaturesToContexts=function(){this.checkContextReady("arabicWord")&&(Ah.call(this),Eh.call(this)),this.checkContextReady("latinWord")&&kh.call(this),this.checkContextReady("arabicSentence")&&Ih.call(this)},de.prototype.processText=function(n){(!this.text||this.text!==n)&&(this.setText(n),Ch.call(this),this.applyFeaturesToContexts())},de.prototype.getBidiText=function(n){return this.processText(n),this.tokenizer.getText()},de.prototype.getTextGlyphs=function(n){this.processText(n);for(var e=[],t=0;t<this.tokenizer.tokens.length;t++){var r=this.tokenizer.tokens[t];if(!r.state.deleted){var i=r.activeState.value;e.push(Array.isArray(i)?i[0]:i)}}return e};function R(n){n=n||{},n.tables=n.tables||{},n.empty||(xt(n.familyName,"When creating a new Font object, familyName is required."),xt(n.styleName,"When creating a new Font object, styleName is required."),xt(n.unitsPerEm,"When creating a new Font object, unitsPerEm is required."),xt(n.ascender,"When creating a new Font object, ascender is required."),xt(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 be.GlyphSet(this,n.glyphs||[]),this.encoding=new fi(this),this.position=new bt(this),this.substitution=new ne(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 rs(this)}})}R.prototype.hasChar=function(n){return this.encoding.charToGlyphIndex(n)!==null},R.prototype.charToGlyphIndex=function(n){return this.encoding.charToGlyphIndex(n)},R.prototype.charToGlyph=function(n){var e=this.charToGlyphIndex(n),t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t},R.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})},R.prototype.stringToGlyphs=function(n,e){var t=this,r=new de,i=function(d){return t.charToGlyphIndex(d.char)};r.registerModifier("glyphIndex",null,i);var s=e?this.updateFeatures(e.features):this.defaultRenderOptions.features;r.applyFeatures(this,s);for(var o=r.getTextGlyphs(n),a=o.length,c=new Array(a),l=this.glyphs.get(0),h=0;h<a;h+=1)c[h]=this.glyphs.get(o[h])||l;return c},R.prototype.nameToGlyphIndex=function(n){return this.glyphNames.nameToGlyphIndex(n)},R.prototype.nameToGlyph=function(n){var e=this.nameToGlyphIndex(n),t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t},R.prototype.glyphIndexToName=function(n){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(n):""},R.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},R.prototype.defaultRenderOptions={kerning:!0,features:[{script:"arab",tags:["init","medi","fina","rlig"]},{script:"latn",tags:["liga","rlig"]}]},R.prototype.forEachGlyph=function(n,e,t,r,i,s){e=e!==void 0?e:0,t=t!==void 0?t:0,r=r!==void 0?r:72,i=Object.assign({},this.defaultRenderOptions,i);var o=1/this.unitsPerEm*r,a=this.stringToGlyphs(n,i),c;if(i.kerning){var l=i.script||this.position.getDefaultScriptName();c=this.position.getKerningTables(l,i.language)}for(var h=0;h<a.length;h+=1){var d=a[h];if(s.call(this,d,e,t,r,i),d.advanceWidth&&(e+=d.advanceWidth*o),i.kerning&&h<a.length-1){var u=c?this.position.getKerningValue(c,d.index,a[h+1].index):this.getKerningValue(d,a[h+1]);e+=u*o}i.letterSpacing?e+=i.letterSpacing*r:i.tracking&&(e+=i.tracking/1e3*r)}return e},R.prototype.getPath=function(n,e,t,r,i){var s=new j;return this.forEachGlyph(n,e,t,r,i,function(o,a,c,l){var h=o.getPath(a,c,l,i,this);s.extend(h)}),s},R.prototype.getPaths=function(n,e,t,r,i){var s=[];return this.forEachGlyph(n,e,t,r,i,function(o,a,c,l){var h=o.getPath(a,c,l,i,this);s.push(h)}),s},R.prototype.getAdvanceWidth=function(n,e,t){return this.forEachGlyph(n,0,0,e,t,function(){})},R.prototype.draw=function(n,e,t,r,i,s){this.getPath(e,t,r,i,s).draw(n)},R.prototype.drawPoints=function(n,e,t,r,i,s){this.forEachGlyph(e,t,r,i,s,function(o,a,c,l){o.drawPoints(n,a,c,l)})},R.prototype.drawMetrics=function(n,e,t,r,i,s){this.forEachGlyph(e,t,r,i,s,function(o,a,c,l){o.drawMetrics(n,a,c,l)})},R.prototype.getEnglishName=function(n){var e=this.names[n];if(e)return e.en},R.prototype.validate=function(){var n=this;function e(t){var r=n.getEnglishName(t);r&&r.trim().length>0}e("fontFamily"),e("weightName"),e("manufacturer"),e("copyright"),e("version"),this.unitsPerEm>0},R.prototype.toTables=function(){return mc.fontToTable(this)},R.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()},R.prototype.toArrayBuffer=function(){for(var n=this.toTables(),e=n.encode(),t=new ArrayBuffer(e.length),r=new Uint8Array(t),i=0;i<e.length;i++)r[i]=e[i];return t},R.prototype.download=function(n){var e=this.getEnglishName("fontFamily"),t=this.getEnglishName("fontSubfamily");n=n||e.replace(/\s/g,"")+"-"+t+".otf";var r=this.toArrayBuffer();if(vc())if(window.URL=window.URL||window.webkitURL,window.URL){var i=new DataView(r),s=new Blob([i],{type:"font/opentype"}),o=document.createElement("a");o.href=window.URL.createObjectURL(s),o.download=n;var a=document.createEvent("MouseEvents");a.initEvent("click",!0,!1),o.dispatchEvent(a)}else console.warn("Font file could not be downloaded. Try using a different browser.");else{var c=require("fs"),l=bc(r);c.writeFileSync(n,l)}},R.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512},R.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},R.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};function Is(n,e){var t=JSON.stringify(n),r=256;for(var i in e){var s=parseInt(i);if(!(!s||s<256)){if(JSON.stringify(e[i])===t)return s;r<=s&&(r=s+1)}}return e[r]=n,r}function Bh(n,e,t){var r=Is(e.name,t);return[{name:"tag_"+n,type:"TAG",value:e.tag},{name:"minValue_"+n,type:"FIXED",value:e.minValue<<16},{name:"defaultValue_"+n,type:"FIXED",value:e.defaultValue<<16},{name:"maxValue_"+n,type:"FIXED",value:e.maxValue<<16},{name:"flags_"+n,type:"USHORT",value:0},{name:"nameID_"+n,type:"USHORT",value:r}]}function Lh(n,e,t){var r={},i=new L.Parser(n,e);return r.tag=i.parseTag(),r.minValue=i.parseFixed(),r.defaultValue=i.parseFixed(),r.maxValue=i.parseFixed(),i.skip("uShort",1),r.name=t[i.parseUShort()]||{},r}function Oh(n,e,t,r){for(var i=Is(e.name,r),s=[{name:"nameID_"+n,type:"USHORT",value:i},{name:"flags_"+n,type:"USHORT",value:0}],o=0;o<t.length;++o){var a=t[o].tag;s.push({name:"axis_"+n+" "+a,type:"FIXED",value:e.coordinates[a]<<16})}return s}function Mh(n,e,t,r){var i={},s=new L.Parser(n,e);i.name=r[s.parseUShort()]||{},s.skip("uShort",1),i.coordinates={};for(var o=0;o<t.length;++o)i.coordinates[t[o].tag]=s.parseFixed();return i}function Dh(n,e){var t=new k.Table("fvar",[{name:"version",type:"ULONG",value:65536},{name:"offsetToData",type:"USHORT",value:0},{name:"countSizePairs",type:"USHORT",value:2},{name:"axisCount",type:"USHORT",value:n.axes.length},{name:"axisSize",type:"USHORT",value:20},{name:"instanceCount",type:"USHORT",value:n.instances.length},{name:"instanceSize",type:"USHORT",value:4+n.axes.length*4}]);t.offsetToData=t.sizeOf();for(var r=0;r<n.axes.length;r++)t.fields=t.fields.concat(Bh(r,n.axes[r],e));for(var i=0;i<n.instances.length;i++)t.fields=t.fields.concat(Oh(i,n.instances[i],n.axes,e));return t}function Rh(n,e,t){var r=new L.Parser(n,e),i=r.parseULong();O.argument(i===65536,"Unsupported fvar table version.");var s=r.parseOffset16();r.skip("uShort",1);for(var o=r.parseUShort(),a=r.parseUShort(),c=r.parseUShort(),l=r.parseUShort(),h=[],d=0;d<o;d++)h.push(Lh(n,e+s+d*a,t));for(var u=[],p=e+s+o*a,f=0;f<c;f++)u.push(Mh(n,p+f*l,h,t));return{axes:h,instances:u}}var Uh={make:Dh,parse:Rh},Fh=function(){return{coverage:this.parsePointer(S.coverage),attachPoints:this.parseList(S.pointer(S.uShortList))}},Ph=function(){var n=this.parseUShort();if(O.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()}},Gh=function(){return this.parseList(S.pointer(Ph))},Nh=function(){return{coverage:this.parsePointer(S.coverage),ligGlyphs:this.parseList(S.pointer(Gh))}},zh=function(){return this.parseUShort(),this.parseList(S.pointer(S.coverage))};function Vh(n,e){e=e||0;var t=new S(n,e),r=t.parseVersion(1);O.argument(r===1||r===1.2||r===1.3,"Unsupported GDEF table version.");var i={version:r,classDef:t.parsePointer(S.classDef),attachList:t.parsePointer(Fh),ligCaretList:t.parsePointer(Nh),markAttachClassDef:t.parsePointer(S.classDef)};return r>=1.2&&(i.markGlyphSets=t.parsePointer(zh)),i}var Hh={parse:Vh},pe=new Array(10);pe[1]=function(){var n=this.offset+this.relativeOffset,e=this.parseUShort();if(e===1)return{posFormat:1,coverage:this.parsePointer(S.coverage),value:this.parseValueRecord()};if(e===2)return{posFormat:2,coverage:this.parsePointer(S.coverage),values:this.parseValueRecordList()};O.assert(!1,"0x"+n.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")},pe[2]=function(){var n=this.offset+this.relativeOffset,e=this.parseUShort();O.assert(e===1||e===2,"0x"+n.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");var t=this.parsePointer(S.coverage),r=this.parseUShort(),i=this.parseUShort();if(e===1)return{posFormat:e,coverage:t,valueFormat1:r,valueFormat2:i,pairSets:this.parseList(S.pointer(S.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(r),value2:this.parseValueRecord(i)}})))};if(e===2){var s=this.parsePointer(S.classDef),o=this.parsePointer(S.classDef),a=this.parseUShort(),c=this.parseUShort();return{posFormat:e,coverage:t,valueFormat1:r,valueFormat2:i,classDef1:s,classDef2:o,class1Count:a,class2Count:c,classRecords:this.parseList(a,S.list(c,function(){return{value1:this.parseValueRecord(r),value2:this.parseValueRecord(i)}}))}}},pe[3]=function(){return{error:"GPOS Lookup 3 not supported"}},pe[4]=function(){return{error:"GPOS Lookup 4 not supported"}},pe[5]=function(){return{error:"GPOS Lookup 5 not supported"}},pe[6]=function(){return{error:"GPOS Lookup 6 not supported"}},pe[7]=function(){return{error:"GPOS Lookup 7 not supported"}},pe[8]=function(){return{error:"GPOS Lookup 8 not supported"}},pe[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function jh(n,e){e=e||0;var t=new S(n,e),r=t.parseVersion(1);return O.argument(r===1||r===1.1,"Unsupported GPOS table version "+r),r===1?{version:r,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(pe)}:{version:r,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(pe),variations:t.parseFeatureVariationsList()}}var Wh=new Array(10);function Xh(n){return new k.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new k.ScriptList(n.scripts)},{name:"features",type:"TABLE",value:new k.FeatureList(n.features)},{name:"lookups",type:"TABLE",value:new k.LookupList(n.lookups,Wh)}])}var qh={parse:jh,make:Xh};function Yh(n){var e={};n.skip("uShort");var t=n.parseUShort();O.argument(t===0,"Unsupported kern sub-table version."),n.skip("uShort",2);var r=n.parseUShort();n.skip("uShort",3);for(var i=0;i<r;i+=1){var s=n.parseUShort(),o=n.parseUShort(),a=n.parseShort();e[s+","+o]=a}return e}function $h(n){var e={};n.skip("uShort");var t=n.parseULong();t>1&&console.warn("Only the first kern subtable is supported."),n.skip("uLong");var r=n.parseUShort(),i=r&255;if(n.skip("uShort"),i===0){var s=n.parseUShort();n.skip("uShort",3);for(var o=0;o<s;o+=1){var a=n.parseUShort(),c=n.parseUShort(),l=n.parseShort();e[a+","+c]=l}}return e}function Zh(n,e){var t=new L.Parser(n,e),r=t.parseUShort();if(r===0)return Yh(t);if(r===1)return $h(t);throw new Error("Unsupported kern table version ("+r+").")}var Qh={parse:Zh};function Jh(n,e,t,r){for(var i=new L.Parser(n,e),s=r?i.parseUShort:i.parseULong,o=[],a=0;a<t+1;a+=1){var c=s.call(i);r&&(c*=2),o.push(c)}return o}var Kh={parse:Jh};function As(n,e){for(var t=[],r=12,i=0;i<e;i+=1){var s=L.getTag(n,r),o=L.getULong(n,r+4),a=L.getULong(n,r+8),c=L.getULong(n,r+12);t.push({tag:s,checksum:o,offset:a,length:c,compression:!1}),r+=16}return t}function eu(n,e){for(var t=[],r=44,i=0;i<e;i+=1){var s=L.getTag(n,r),o=L.getULong(n,r+4),a=L.getULong(n,r+8),c=L.getULong(n,r+12),l=void 0;a<c?l="WOFF":l=!1,t.push({tag:s,offset:o,compression:l,compressedLength:a,length:c}),r+=20}return t}function z(n,e){if(e.compression==="WOFF"){var t=new Uint8Array(n.buffer,e.offset+2,e.compressedLength-2),r=new Uint8Array(e.length);if(qo(t,r),r.byteLength!==e.length)throw new Error("Decompression error: "+e.tag+" decompressed length doesn't match recorded length");var i=new DataView(r.buffer,0);return{data:i,offset:0}}else return{data:n,offset:e.offset}}function tu(n,e){e=e??{};var t,r,i=new R({empty:!0}),s=new DataView(n,0),o,a=[],c=L.getTag(s,0);if(c==="\0\0\0"||c==="true"||c==="typ1")i.outlinesFormat="truetype",o=L.getUShort(s,4),a=As(s,o);else if(c==="OTTO")i.outlinesFormat="cff",o=L.getUShort(s,4),a=As(s,o);else if(c==="wOFF"){var l=L.getTag(s,4);if(l==="\0\0\0")i.outlinesFormat="truetype";else if(l==="OTTO")i.outlinesFormat="cff";else throw new Error("Unsupported OpenType flavor "+c);o=L.getUShort(s,12),a=eu(s,o)}else throw new Error("Unsupported OpenType signature "+c);for(var h,d,u,p,f,m,y,v,_,w,C,T,D=0;D<o;D+=1){var I=a[D],E=void 0;switch(I.tag){case"cmap":E=z(s,I),i.tables.cmap=pi.parse(E.data,E.offset),i.encoding=new gi(i.tables.cmap);break;case"cvt ":E=z(s,I),T=new L.Parser(E.data,E.offset),i.tables.cvt=T.parseShortList(I.length/2);break;case"fvar":d=I;break;case"fpgm":E=z(s,I),T=new L.Parser(E.data,E.offset),i.tables.fpgm=T.parseByteList(I.length);break;case"head":E=z(s,I),i.tables.head=ki.parse(E.data,E.offset),i.unitsPerEm=i.tables.head.unitsPerEm,t=i.tables.head.indexToLocFormat;break;case"hhea":E=z(s,I),i.tables.hhea=Bi.parse(E.data,E.offset),i.ascender=i.tables.hhea.ascender,i.descender=i.tables.hhea.descender,i.numberOfHMetrics=i.tables.hhea.numberOfHMetrics;break;case"hmtx":y=I;break;case"ltag":E=z(s,I),r=Oi.parse(E.data,E.offset);break;case"maxp":E=z(s,I),i.tables.maxp=Mi.parse(E.data,E.offset),i.numGlyphs=i.tables.maxp.numGlyphs;break;case"name":w=I;break;case"OS/2":E=z(s,I),i.tables.os2=Vn.parse(E.data,E.offset);break;case"post":E=z(s,I),i.tables.post=zi.parse(E.data,E.offset),i.glyphNames=new Un(i.tables.post);break;case"prep":E=z(s,I),T=new L.Parser(E.data,E.offset),i.tables.prep=T.parseByteList(I.length);break;case"glyf":u=I;break;case"loca":_=I;break;case"CFF ":h=I;break;case"kern":v=I;break;case"GDEF":p=I;break;case"GPOS":f=I;break;case"GSUB":m=I;break;case"meta":C=I;break}}var U=z(s,w);if(i.tables.name=Ni.parse(U.data,U.offset,r),i.names=i.tables.name,u&&_){var V=t===0,J=z(s,_),te=Kh.parse(J.data,J.offset,i.numGlyphs,V),$=z(s,u);i.glyphs=es.parse($.data,$.offset,te,i,e)}else if(h){var P=z(s,h);Ei.parse(P.data,P.offset,i,e)}else throw new Error("Font doesn't contain TrueType or CFF outlines.");var H=z(s,y);if(Li.parse(i,H.data,H.offset,i.numberOfHMetrics,i.numGlyphs,i.glyphs,e),fa(i,e),v){var N=z(s,v);i.kerningPairs=Qh.parse(N.data,N.offset)}else i.kerningPairs={};if(p){var X=z(s,p);i.tables.gdef=Hh.parse(X.data,X.offset)}if(f){var Z=z(s,f);i.tables.gpos=qh.parse(Z.data,Z.offset),i.position.init()}if(m){var Y=z(s,m);i.tables.gsub=Vi.parse(Y.data,Y.offset)}if(d){var K=z(s,d);i.tables.fvar=Uh.parse(K.data,K.offset,i.names)}if(C){var F=z(s,C);i.tables.meta=Hi.parse(F.data,F.offset),i.metas=i.tables.meta}return i}function nu(n){return((e,t)=>{const r=Math.round,i={},s=e.encoding.cmap.glyphIndexMap,o=Object.keys(s),a=e.glyphs.glyphs[s[65]];let c=1;a&&(c=e.unitsPerEm/a.yMax);for(let l=0;l<o.length;l++){const h=o[l],d=e.glyphs.glyphs[s[h]];if(h!==void 0){const u={ha:r(d.advanceWidth),x_min:r(d.xMin),x_max:r(d.xMax),o:""};d.path.commands.forEach(function(p){p.type.toLowerCase()==="c"&&(p.type="b"),u.o+=p.type.toLowerCase()+" ",p.x!==void 0&&p.y!==void 0&&(u.o+=r(p.x)+" "+r(p.y)+" "),p.x1!==void 0&&p.y1!==void 0&&(u.o+=r(p.x1)+" "+r(p.y1)+" "),p.x2!==void 0&&p.y2!==void 0&&(u.o+=r(p.x2)+" "+r(p.y2)+" ")}),i[String.fromCodePoint(d.unicode)]=u}}return{glyphs:i,familyName:e.getEnglishName("fullName"),ascender:r(e.ascender),descender:r(e.descender),underlinePosition:e.tables.post.underlinePosition,underlineThickness:e.tables.post.underlineThickness,boundingBox:{xMin:e.tables.head.xMin,xMax:e.tables.head.xMax,yMin:e.tables.head.yMin,yMax:e.tables.head.yMax},resolution:e.unitsPerEm||1e3,scaleFactor:c,original_font_information:e.tables.name}})(tu(n))}class Es extends Ur{constructor(e){super(),this.type="mesh",e instanceof ArrayBuffer?this.data=nu(e):this.data=e,this.font=new Do(this.data)}hasChar(e){return this.data.glyphs[e]!=null}generateShapes(e,t){return this.font.generateShapes(e,t)}getCharShape(e,t){if(!this.data.glyphs[e]){this.addUnsupportedChar(e);return}return new Zr(e,t,this)}getScaleFactor(){return this.scaleFactor==null?(this.scaleFactor=this.data.scaleFactor,this.scaleFactor):this.scaleFactor}getNotFoundTextShape(e){return new Zr("?",e,this)}}let ie=class{static byteToSByte(e){return(e&127)-(e&128?128:0)}constructor(e){this.position=0,this.data=new DataView(e)}readBytes(e=1){this.data.byteLength<this.position+e&&this.throwOutOfRangeError(this.position+e);const t=new Uint8Array(this.data.buffer,this.position,e);return this.position+=e,t}skip(e){this.data.byteLength<this.position+e&&this.throwOutOfRangeError(this.position+e),this.position+=e}readUint8(){this.data.byteLength<this.position+1&&this.throwOutOfRangeError(this.position+1);const e=this.data.getUint8(this.position);return this.position+=1,e}readInt8(){this.data.byteLength<this.position+1&&this.throwOutOfRangeError(this.position+1);const e=this.data.getInt8(this.position);return this.position+=1,e}readUint16(e=!0){this.data.byteLength<this.position+2&&this.throwOutOfRangeError(this.position+2);const t=this.data.getUint16(this.position,e);return this.position+=2,t}readInt16(){this.data.byteLength<this.position+2&&this.throwOutOfRangeError(this.position+2);const e=this.data.getInt16(this.position,!0);return this.position+=2,e}readUint32(){this.data.byteLength<this.position+4&&this.throwOutOfRangeError(this.position+4);const e=this.data.getUint32(this.position,!0);return this.position+=4,e}readInt32(){this.data.byteLength<this.position+4&&this.throwOutOfRangeError(this.position+4);const e=this.data.getInt32(this.position,!0);return this.position+=4,e}readFloat32(){this.data.byteLength<this.position+4&&this.throwOutOfRangeError(this.position+4);const e=this.data.getFloat32(this.position,!0);return this.position+=4,e}readFloat64(){this.data.byteLength<this.position+8&&this.throwOutOfRangeError(this.position+8);const e=this.data.getFloat64(this.position,!0);return this.position+=8,e}setPosition(e){this.data.byteLength<e&&this.throwOutOfRangeError(e),this.position=e}isEnd(){return this.position===this.data.byteLength-1}get currentPosition(){return this.position}get length(){return this.data.byteLength}throwOutOfRangeError(e){throw new Error(`Position ${e} is out of range for the data length ${this.data.byteLength}!`)}};var se=(n=>(n.SHAPES="shapes",n.BIGFONT="bigfont",n.UNIFONT="unifont",n))(se||{});let ru=class{parse(n){const e=this.parseHeader(n).split(" "),t=e[1].toLocaleLowerCase();if(!Object.values(se).includes(t))throw new Error(`Invalid font type: ${t}`);return{fileHeader:e[0],fontType:t,fileVersion:e[2]}}parseHeader(n){let e="",t=0;for(;n.currentPosition<n.length-2&&t<1024;){const r=n.readUint8();if(r===13){const i=n.currentPosition,s=n.readUint8(),o=n.readUint8();if(s===10&&o===26)break;n.setPosition(i),e+=String.fromCharCode(r)}else e+=String.fromCharCode(r);t++}return e.trim()}};class iu{parse(e){try{e.readBytes(4);const t=e.readInt16();if(t<=0)throw new Error("Invalid shape count in font file");const r=[];for(let o=0;o<t;o++){const a=e.readUint16(),c=e.readUint16();c>0&&r.push({code:a,length:c})}const i={};for(const o of r)try{const a=e.readBytes(o.length);a.length===o.length&&(i[o.code]=a)}catch{console.warn(`Failed to read shape data for code ${o.code}`)}const s={data:i,info:"",baseUp:8,baseDown:2,orientation:"horizontal",isExtended:!1};if(0 in i){const o=i[0];try{const a=new TextDecoder().decode(o);let c=a.indexOf("\0");c>=0&&(s.info=a.substring(0,c),c+3<o.length&&(s.baseUp=o[c+1],s.baseDown=o[c+2],s.orientation=o[c+3]===0?"horizontal":"vertical"))}catch{console.warn("Failed to parse font info block")}}return s}catch(t){return console.error("Error parsing shape font:",t),{data:{},info:"Failed to parse font file",baseUp:8,baseDown:2,orientation:"horizontal",isExtended:!1}}}}class su{parse(e){try{e.readInt16();const t=e.readInt16(),r=e.readInt16();if(t<=0)throw new Error("Invalid character count in font file");e.skip(r*4);const i=[];for(let a=0;a<t;a++){const c=e.readUint16(!1),l=e.readUint16(),h=e.readUint32();(c!==0||l!==0||h!==0)&&i.push({code:c,length:l,offset:h})}const s={};for(const a of i)try{e.setPosition(a.offset);const c=e.readBytes(a.length);c.length===a.length&&(s[a.code]=c)}catch{console.warn(`Failed to read bigfont data for code ${a.code}`)}const o={data:s,info:"",baseUp:8,baseDown:2,orientation:"horizontal",isExtended:!1};if(0 in s){const a=s[0];try{const c=this.utf8ArrayToStr(a);let l=c.indexOf("\0");l>=0&&(o.info=c.substring(0,l),l++,l+3<a.length&&(a.length-l===4?(o.baseUp=a[l++],o.baseDown=a[l++],o.orientation=a[l++]===0?"horizontal":"vertical"):(o.baseUp=a[l++],l++,o.orientation=a[l++]===0?"horizontal":"vertical",o.baseDown=a[l++],o.isExtended=!0)))}catch{console.warn("Failed to parse bigfont info block")}}return o}catch(t){return console.error("Error parsing big font:",t),{data:{},info:"Failed to parse font file",baseUp:8,baseDown:2,orientation:"horizontal",isExtended:!1}}}utf8ArrayToStr(e){let t="",r=0;for(;r<e.length;){const i=e[r++];switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:t+=String.fromCharCode(i);break;case 12:case 13:{const s=e[r++];t+=String.fromCharCode((i&31)<<6|s&63);break}case 14:{const s=e[r++],o=e[r++];t+=String.fromCharCode((i&15)<<12|(s&63)<<6|(o&63)<<0);break}}}return t}}class ou{parse(e){try{const t=e.readInt32();if(t<=0)throw new Error("Invalid character count in font file");const r=e.readInt16(),i=e.readBytes(r),s={data:{},info:"",baseUp:8,baseDown:2,orientation:"horizontal",isExtended:!1};try{const a=new TextDecoder().decode(i);let c=a.indexOf("\0");c>=0&&(s.info=a.substring(0,c),c+3<i.length&&(s.baseUp=i[c+1],s.baseDown=i[c+2],s.orientation=i[c+3]===0?"horizontal":"vertical"))}catch{console.warn("Failed to parse unifont info block")}const o={};for(let a=0;a<t-1;a++)try{const c=e.readUint16(),l=e.readUint16();if(l>0){const h=e.readBytes(l);h.length===l&&(o[c]=h)}}catch{console.warn("Failed to read unifont character data");break}return s.data=o,s}catch(t){return console.error("Error parsing unifont:",t),{data:{},info:"Failed to parse font file",baseUp:8,baseDown:2,orientation:"horizontal",isExtended:!1}}}}class au{static createParser(e){switch(e){case se.SHAPES:return new iu;case se.BIGFONT:return new su;case se.UNIFONT:return new ou;default:throw new Error(`Unsupported font type: ${e}`)}}}let W=class Js{constructor(e=0,t=0){this.x=e,this.y=t}set(e,t){return this.x=e,this.y=t,this}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}normalize(){const e=this.length();return e!==0&&(this.x/=e,this.y/=e),this}clone(){return new Js(this.x,this.y)}add(e){return this.x+=e.x,this.y+=e.y,this}subtract(e){return this.x-=e.x,this.y-=e.y,this}multiply(e){return this.x*=e,this.y*=e,this}divide(e){return e!==0&&(this.x/=e,this.y/=e),this}multiplyScalars(e,t){return this.x*=e,this.y*=t,this}divideScalars(e,t){return e!==0&&(this.x/=e),t!==0&&(this.y/=t),this}distanceTo(e){const t=this.x-e.x,r=this.y-e.y;return Math.sqrt(t*t+r*r)}};const ks=Math.PI/4;class Ct{static fromBulge(e,t,r){const i=Math.max(-1,Math.min(1,r));return new Ct({start:e,end:t,bulge:i})}static fromOctant(e,t,r,i,s){return new Ct({center:e,radius:t,startOctant:r,octantCount:i,isClockwise:s})}constructor(e){if(e.start&&e.end&&e.bulge!==void 0){this.start=e.start.clone(),this.end=e.end.clone(),this.bulge=e.bulge,this.isClockwise=e.bulge<0;const t=this.end.clone().subtract(this.start),r=t.length();if(Math.abs(this.bulge)*r/2===0){this.radius=0,this.center=this.start.clone(),this.startAngle=Math.atan2(t.y,t.x),this.endAngle=this.startAngle;return}const i=4*Math.atan(Math.abs(this.bulge));this.radius=r/(2*Math.sin(i/2));const s=this.start.clone().add(t.clone().divide(2)),o=new W(-t.y,t.x);o.normalize(),o.multiply(Math.abs(this.radius*Math.cos(i/2))),this.center=s.clone(),this.isClockwise?this.center.subtract(o):this.center.add(o),this.startAngle=Math.atan2(this.start.y-this.center.y,this.start.x-this.center.x),this.endAngle=Math.atan2(this.end.y-this.center.y,this.end.x-this.center.x),this.isClockwise?this.endAngle>=this.startAngle&&(this.endAngle-=2*Math.PI):this.endAngle<=this.startAngle&&(this.endAngle+=2*Math.PI)}else if(e.center&&e.radius!==void 0&&e.startOctant!==void 0&&e.octantCount!==void 0&&e.isClockwise!==void 0){this.center=e.center.clone(),this.radius=e.radius,this.isClockwise=e.isClockwise,this.startAngle=e.startOctant*ks;const t=(e.octantCount===0?8:e.octantCount)*ks;this.endAngle=this.startAngle+(this.isClockwise?-t:t),this.start=this.center.clone().add(new W(this.radius*Math.cos(this.startAngle),this.radius*Math.sin(this.startAngle))),this.end=this.center.clone().add(new W(this.radius*Math.cos(this.endAngle),this.radius*Math.sin(this.endAngle)))}else throw new Error("Invalid arc parameters")}tessellate(e=Math.PI/18){if(this.radius===0)return[this.start.clone(),this.end.clone()];const t=[this.start.clone()],r=Math.abs(this.endAngle-this.startAngle),i=Math.max(1,Math.floor(r/e));for(let s=1;s<i;s++){const o=s/i,a=this.isClockwise?this.startAngle-o*r:this.startAngle+o*r;t.push(this.center.clone().add(new W(this.radius*Math.cos(a),this.radius*Math.sin(a))))}return t.push(this.end?this.end.clone():this.center.clone().add(new W(this.radius*Math.cos(this.endAngle),this.radius*Math.sin(this.endAngle)))),t}}let nr=class Ks{constructor(e,t=[]){this.lastPoint=e,this.polylines=t}get bbox(){let e=1/0,t=-1/0,r=1/0,i=-1/0;return this.polylines.forEach(s=>{s.forEach(o=>{e=Math.min(e,o.x),t=Math.max(t,o.x),r=Math.min(r,o.y),i=Math.max(i,o.y)})}),{minX:e,minY:r,maxX:t,maxY:i}}offset(e,t=!0){var r,i;return t?new Ks((r=this.lastPoint)==null?void 0:r.clone().add(e),this.polylines.map(s=>s.map(o=>o.clone().add(e)))):((i=this.lastPoint)==null||i.add(e),this.polylines.forEach(s=>s.forEach(o=>o.add(e))),this)}toSVG(e={}){const{strokeWidth:t="0.5%",strokeColor:r="black",isAutoFit:i=!1}=e;let s,o;if(i){const a=this.bbox,c=.2,l=a.maxX-a.minX,h=a.maxY-a.minY,d=a.minX-l*c,u=a.maxX+l*c,p=a.minY-h*c,f=a.maxY+h*c;o=this.polylines.map(m=>{let y="";return m.forEach((v,_)=>{const w=v.x,C=-v.y;y+=_===0?`M ${w} ${C} `:`L ${w} ${C} `}),`<path d="${y}" stroke="${r}" stroke-width="${t}" fill="none"/>`}).join(""),s=`${d} ${-f} ${u-d} ${f-p}`}else s="0 0 20 20",o=this.polylines.map(a=>{let c="";return a.forEach((l,h)=>{const d=l.x+5,u=-l.y+15;c+=h===0?`M ${d} ${u} `:`L ${d} ${u} `}),`<path d="${c}" stroke="${r}" stroke-width="${t}" fill="none"/>`}).join("");return`<svg width="100%" height="100%" viewBox="${s}" preserveAspectRatio="xMidYMid meet">${o}</svg>`}};const cu=Math.PI/18,Bs=12;let lu=class{constructor(n){this.shapeCache=new Map,this.shapeData=new Map,this.fontData=n}release(){this.shapeCache.clear(),this.shapeData.clear()}parse(n,e){var t;const r=`${n}_${e}`;if(this.shapeCache.has(r))return this.shapeCache.get(r);if(n===0)return;const i=this.fontData.content.data;let s;if(!this.shapeData.has(n)&&i[n]){const o=i[n],a=Bs/this.fontData.content.baseUp;s=this.parseShape(o,a),this.shapeData.set(n,s)}if(this.shapeData.has(n)){const o=e/Bs,a=this.shapeData.get(n);s=new nr((t=a.lastPoint)==null?void 0:t.clone().multiply(o),a.polylines.map(c=>c.map(l=>l.clone().multiply(o))))}return s}parseShape(n,e){const t={currentPoint:new W,polylines:[],currentPolyline:[],sp:[],isPenDown:!1,scale:e};for(let r=0;r<n.length;r++){const i=n[r];i<=15?r=this.handleSpecialCommand(i,n,r,t):this.handleVectorCommand(i,t)}return new nr(t.currentPoint,t.polylines)}handleSpecialCommand(n,e,t,r){let i=t;switch(n){case 0:r.currentPolyline=[],r.isPenDown=!1;break;case 1:r.isPenDown=!0,r.currentPolyline.push(r.currentPoint.clone());break;case 2:r.isPenDown=!1,r.currentPolyline.length>1&&r.polylines.push(r.currentPolyline.slice()),r.currentPolyline=[];break;case 3:i++,r.scale/=e[i];break;case 4:i++,r.scale*=e[i];break;case 5:if(r.sp.length===4)throw new Error("The position stack is only four locations deep");r.sp.push(r.currentPoint.clone());break;case 6:r.currentPoint=r.sp.pop()??r.currentPoint;break;case 7:i=this.handleSubshapeCommand(e,i,r);break;case 8:i=this.handleXYDisplacement(e,i,r);break;case 9:i=this.handleMultipleXYDisplacements(e,i,r);break;case 10:i=this.handleOctantArc(e,i,r);break;case 11:i=this.handleFractionalArc(e,i,r);break;case 12:i=this.handleBulgeArc(e,i,r);break;case 13:i=this.handleMultipleBulgeArcs(e,i,r);break;case 14:i=this.skipCode(e,++i);break}return i}handleVectorCommand(n,e){const t=(n&240)>>4,r=n&15,i=this.getVectorForDirection(r);e.currentPoint.add(i.multiply(t*e.scale)),e.isPenDown&&e.currentPolyline.push(e.currentPoint.clone())}getVectorForDirection(n){const e=new W;switch(n){case 0:e.x=1;break;case 1:e.x=1,e.y=.5;break;case 2:e.x=1,e.y=1;break;case 3:e.x=.5,e.y=1;break;case 4:e.y=1;break;case 5:e.x=-.5,e.y=1;break;case 6:e.x=-1,e.y=1;break;case 7:e.x=-1,e.y=.5;break;case 8:e.x=-1;break;case 9:e.x=-1,e.y=-.5;break;case 10:e.x=-1,e.y=-1;break;case 11:e.x=-.5,e.y=-1;break;case 12:e.y=-1;break;case 13:e.x=.5,e.y=-1;break;case 14:e.x=1,e.y=-1;break;case 15:e.x=1,e.y=-.5;break}return e}handleSubshapeCommand(n,e,t){let r=e,i=0,s,o=t.scale*this.fontData.content.baseUp,a=o;const c=t.currentPoint.clone();switch(t.currentPolyline.length>1&&(t.polylines.push(t.currentPolyline.slice()),t.currentPolyline=[]),this.fontData.header.fontType){case se.SHAPES:r++,i=n[r];break;case se.BIGFONT:r++,i=n[r],i===0&&(r++,i=n[r++]|n[r++]<<8,c.x=n[r++]*t.scale,c.y=n[r++]*t.scale,this.fontData.content.isExtended&&(a=n[r++]*t.scale),o=n[r]*t.scale);break;case se.UNIFONT:r++,i=n[r++]|n[r++]<<8;break}return i!==0&&(s=this.getShapeByCodeWithOffset(i,a,o,c),s&&(t.polylines.push(...s.polylines.slice()),t.currentPoint=s.lastPoint?s.lastPoint.clone():c.clone())),t.currentPolyline=[],r}handleXYDisplacement(n,e,t){let r=e;const i=new W;return i.x=ie.byteToSByte(n[++r]),i.y=ie.byteToSByte(n[++r]),t.currentPoint.add(i.multiply(t.scale)),t.isPenDown&&t.currentPolyline.push(t.currentPoint.clone()),r}handleMultipleXYDisplacements(n,e,t){let r=e;for(;;){const i=new W;if(i.x=ie.byteToSByte(n[++r]),i.y=ie.byteToSByte(n[++r]),i.x===0&&i.y===0)break;t.currentPoint.add(i.multiply(t.scale)),t.isPenDown&&t.currentPolyline.push(t.currentPoint.clone())}return r}handleOctantArc(n,e,t){var r;let i=e;const s=n[++i]*t.scale,o=ie.byteToSByte(n[++i]),a=(o&112)>>4;let c=o&7;const l=o<0,h=Math.PI/4*a,d=t.currentPoint.clone().subtract(new W(Math.cos(h)*s,Math.sin(h)*s)),u=Ct.fromOctant(d,s,a,c,l);if(t.isPenDown){const p=u.tessellate();t.currentPolyline.pop(),t.currentPolyline.push(...p.slice())}return t.currentPoint=(r=u.tessellate().pop())==null?void 0:r.clone(),i}handleFractionalArc(n,e,t){let r=e;const i=n[++r],s=n[++r],o=n[++r],a=n[++r],c=(o*255+a)*t.scale,l=ie.byteToSByte(n[++r]),h=(l&112)>>4;let d=l&7;d===0&&(d=8),s!==0&&d--;const u=Math.PI/4;let p=u*d,f=cu,m=1;l<0&&(f=-f,p=-p,m=-1);let y=u*h,v=y+p;y+=u*i/256*m,v+=u*s/256*m;const _=t.currentPoint.clone().subtract(new W(c*Math.cos(y),c*Math.sin(y)));if(t.currentPoint=_.clone().add(new W(c*Math.cos(v),c*Math.sin(v))),t.isPenDown){let w=y;const C=[];if(C.push(_.clone().add(new W(c*Math.cos(w),c*Math.sin(w)))),f>0)for(;w+f<v;)w+=f,C.push(_.clone().add(new W(c*Math.cos(w),c*Math.sin(w))));else for(;w+f>v;)w+=f,C.push(_.clone().add(new W(c*Math.cos(w),c*Math.sin(w))));C.push(_.clone().add(new W(c*Math.cos(v),c*Math.sin(v)))),t.currentPolyline.push(...C)}return r}handleBulgeArc(n,e,t){let r=e;const i=new W;i.x=ie.byteToSByte(n[++r]),i.y=ie.byteToSByte(n[++r]);const s=ie.byteToSByte(n[++r]);return t.currentPoint=this.handleArcSegment(t.currentPoint,i,s,t.scale,t.isPenDown,t.currentPolyline),r}handleMultipleBulgeArcs(n,e,t){let r=e;for(;;){const i=new W;if(i.x=ie.byteToSByte(n[++r]),i.y=ie.byteToSByte(n[++r]),i.x===0&&i.y===0)break;const s=ie.byteToSByte(n[++r]);t.currentPoint=this.handleArcSegment(t.currentPoint,i,s,t.scale,t.isPenDown,t.currentPolyline)}return r}skipCode(n,e){switch(n[e]){case 0:break;case 1:break;case 2:break;case 3:case 4:e++;break;case 5:break;case 6:break;case 7:switch(this.fontData.header.fontType){case se.SHAPES:e++;break;case se.BIGFONT:e++,n[e]===0&&(e+=5);break;case se.UNIFONT:e+=2;break}break;case 8:e+=2;break;case 9:for(;;){const t=n[++e],r=n[++e];if(t===0&&r===0)break}break;case 10:e+=2;break;case 11:e+=5;break;case 12:e+=3;break;case 13:for(;;){const t=n[++e],r=n[++e];if(t===0&&r===0)break;e++}break}return e}getShapeByCodeWithOffset(n,e,t,r){var i;const s=this.parse(n,t);if(s){if(e===t)return s.offset(r);{const o=(i=s.lastPoint)==null?void 0:i.clone();o&&(o.x*=e/t);const a=s.polylines.map(c=>c.map(l=>l.clone()));return a.forEach(c=>c.forEach(l=>l.x*=e/t)),new nr(o==null?void 0:o.add(r),a.map(c=>c.map(l=>l.add(r))))}}}handleArcSegment(n,e,t,r,i,s){e.x*=r,e.y*=r,t<-127&&(t=-127);const o=n.clone();if(i)if(t===0)s.push(o.clone().add(e));else{const a=o.clone().add(e),c=Ct.fromBulge(o,a,t/127).tessellate();s.push(...c.slice(1))}return o.add(e),o}};class hu{constructor(e){if(e instanceof ArrayBuffer){const t=new ie(e),r=new ru().parse(t),i=au.createParser(r.fontType).parse(t);this.fontData={header:r,content:i}}else this.fontData=e;this.shapeParser=new lu(this.fontData)}hasChar(e){return this.fontData.content.data[e]!==void 0}getCharShape(e,t){return this.shapeParser.parse(e,t)}release(){this.shapeParser.release()}}class rr extends Fr{constructor(e,t,r,i){super(e),this.fontSize=t,this.shape=r,this.font=i,this.width=this.calcWidth()}calcWidth(){const e=this.shape.bbox;return e.maxX-e.minX}offset(e){return new rr(this.char,this.fontSize,this.shape.offset(e),this.font)}toGeometry(){let e=this.font.cache.getGeometry(this.char,this.fontSize);if(e==null){const t=this.shape.polylines,r=[],i=[];let s=0;e=new g.BufferGeometry;for(let o=0;o<t.length;o++){const a=t[o];for(let c=0;c<a.length;c++){const l=a[c];r.push(l.x,l.y,0),c===a.length-1||i.push(s,s+1),s++}}e.setAttribute("position",new g.Float32BufferAttribute(r,3)),e.setIndex(i)}return e}}class Ls extends Ur{constructor(e){super(),this.type="shx",this.font=new hu(e),this.data=this.font.fontData}hasChar(e){const t=e.charCodeAt(0);return this.font.hasChar(t)}generateShapes(e,t){const r=[];let i=0;for(let s=0;s<e.length;s++){const o=e[s];if(o===" "){i+=t;continue}const a=this.getCharShape(o,t);if(!a){i+=t,this.addUnsupportedChar(o);continue}r.push(a.offset(new W(i,0))),i+=a.width}return r}getScaleFactor(){return 1}getCharShape(e,t){let r=this.getCode(e);const i=this.font.getCharShape(r,t);return i?new rr(e,t,i,this):void 0}getNotFoundTextShape(e){let t=this.font.fontData.header.fontType===se.BIGFONT?"?":"?";return this.getCharShape(t,e)}getCode(e){if(this.font.fontData.header.fontType===se.BIGFONT)throw new Error(`Can't get font glyph for '${e}' because big font is not supported yet!`);return e.charCodeAt(0)}}class Pe{constructor(){}static get instance(){return Pe._instance||(Pe._instance=new Pe),Pe._instance}createFont(e){if(e.type==="shx")return new Ls(e.data);if(e.type==="mesh")return new Es(e.data);throw new Error("Unsupported font data type")}createFontFromBuffer(e,t){const r=Lo(e).toLowerCase();if(r==="shx")return new Ls(t);if(["ttf","otf","woff"].includes(r))return new Es(t);throw new Error(`Unsupported font file type: ${r}`)}}class fe{constructor(){this.fontMapping={},this.fontMap=new Map,this.unsupportedChars={},this.missedFonts={},this.enableFontCache=!0,this.defaultFont="simsun",this.events={fontNotFound:new Rr,fontLoaded:new Rr},this.loader=new g.FileLoader,this.loader.setResponseType("arraybuffer"),this.fileNames=[]}static get instance(){return fe._instance||(fe._instance=new fe),fe._instance}setFontMapping(e){this.fontMapping=e}async loadFonts(e){e=Array.isArray(e)?e:[e];const t=[];for(let i=0;i<e.length;i++){const s=e[i];t.push(this.loadFont(s))}const r=[];return await Promise.allSettled(t).then(i=>{i.forEach((s,o)=>{const a=s.status==="fulfilled",c=e[o],l=Xr(c.toLowerCase());r.push({fontName:l,url:c,status:a}),a&&this.fileNames.push(l)})}),r}findAndReplaceFont(e){let t=this.fontMap.get(e.toLowerCase());if(t==null){const r=this.fontMapping[e];if(r)return t=this.fontMap.get(r.toLowerCase()),r}return t?e:this.defaultFont}getFontByName(e,t=!0){if(this.fontMap.size===0)return;e==null&&(e="");let r=this.fontMap.get(e.toLowerCase());if(!r){t&&this.recordMissedFonts(e);return}return r}getFontByChar(e){for(const[,t]of this.fontMap)if(t.hasChar(e))return t}getCharShape(e,t,r){let i=this.getFontByName(t);return i||(i=this.getFontByChar(e)),i==null?void 0:i.getCharShape(e,r)}getFontScaleFactor(e){const t=this.fontMap.get(e.toLowerCase());return t?t.getScaleFactor():1}getFontType(e){const t=this.fontMap.get(e.toLowerCase());return t==null?void 0:t.type}getNotFoundTextShape(e){for(const[,t]of this.fontMap){const r=t.getNotFoundTextShape(e);if(r)return r}}isFontLoaded(e){return this.fontMap.has(e.toLowerCase())}recordMissedFonts(e){e&&(this.missedFonts[e]||(this.missedFonts[e]=0),this.missedFonts[e]++,this.events.fontNotFound.dispatch({fontName:e,count:this.missedFonts[e]}))}async loadFont(e){const t=Wr(e);if(!t)throw new Error(`Invalid font url: ${e}`);const r=Xr(e).toLowerCase(),i=await In.instance.get(r);if(i){const s=Pe.instance.createFont(i);this.fontMap.set(r,s)}else{const s=await this.loader.loadAsync(e),o=Pe.instance.createFontFromBuffer(t,s);o&&(this.fontMap.set(r,o),this.enableFontCache&&await In.instance.set(r,{name:r,type:o.type,data:o.data}))}this.events.fontLoaded.dispatch({fontName:r})}async getAllFontsFromCache(){if(this.fontMap.size!==0)return;const e=await In.instance.getAll();for(const t of e){const{name:r}=t;if(this.fileNames&&!this.fileNames.includes(r))continue;const i=Pe.instance.createFont(t);this.fontMap.set(r,i)}}getUnsupportedChar(){for(const[,e]of this.fontMap)Object.assign(this.unsupportedChars,e.unsupportedChars);return this.unsupportedChars}release(e){return e==null?(this.fontMap.clear(),!0):this.fontMap.delete(e)}}var It=(n=>(n[n.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",n[n.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",n[n.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",n[n.BOTTOM_TO_TOP=4]="BOTTOM_TO_TOP",n[n.BY_STYLE=5]="BY_STYLE",n))(It||{}),tt=(n=>(n[n.NONE=0]="NONE",n[n.WORD=1]="WORD",n[n.STACK=2]="STACK",n[n.SPACE=3]="SPACE",n[n.NBSP=4]="NBSP",n[n.TABULATOR=5]="TABULATOR",n[n.NEW_PARAGRAPH=6]="NEW_PARAGRAPH",n[n.NEW_COLUMN=7]="NEW_COLUMN",n[n.WRAP_AT_DIMLINE=8]="WRAP_AT_DIMLINE",n[n.PROPERTIES_CHANGED=9]="PROPERTIES_CHANGED",n))(tt||{}),At=(n=>(n[n.BOTTOM=0]="BOTTOM",n[n.MIDDLE=1]="MIDDLE",n[n.TOP=2]="TOP",n))(At||{}),ge=(n=>(n[n.DEFAULT=0]="DEFAULT",n[n.LEFT=1]="LEFT",n[n.RIGHT=2]="RIGHT",n[n.CENTER=3]="CENTER",n[n.JUSTIFIED=4]="JUSTIFIED",n[n.DISTRIBUTED=5]="DISTRIBUTED",n))(ge||{});const uu={c:"Ø",d:"°",p:"±"},du={l:1,r:2,c:3,j:4,d:5};function pu(n,e=!1){const t=new Set,r=/\\[fF](.*?)[;|]/g;return[...n.matchAll(r)].forEach(i=>{let s=i[1].toLowerCase();e&&(s=s.replace(/\.(ttf|otf|woff|shx)$/,"")),t.add(s)}),t}class fu{constructor(e){this.stack=[],this.stack.push(e)}push(e){this.stack.push(e)}pop(){if(this.stack.length<=1)return;const e=this.stack.pop(),t=this.stack[this.stack.length-1];return JSON.stringify(t.paragraph)!==JSON.stringify(e.paragraph)&&(t.paragraph={...e.paragraph}),e}get current(){return this.stack[this.stack.length-1]}get depth(){return this.stack.length-1}get root(){return this.stack[0]}setCurrent(e){this.stack[this.stack.length-1]=e}}class gu{constructor(e,t,r={}){this.continueStroke=!1,this.inStackContext=!1,this.scanner=new ir(e);const i=t??new Et;this.ctxStack=new fu(i),this.yieldPropertyCommands=r.yieldPropertyCommands??!1,this.resetParagraphParameters=r.resetParagraphParameters??!1}decodeMultiByteChar(e){try{const t=new Uint8Array([parseInt(e.substr(0,2),16),parseInt(e.substr(2,2),16)]),r=new TextDecoder("gbk").decode(t);if(r!=="▯")return r;const i=new TextDecoder("big5").decode(t);return i!=="▯"?i:"▯"}catch{return"▯"}}pushCtx(){this.ctxStack.push(this.ctxStack.current)}popCtx(){this.ctxStack.pop()}parseStacking(){const e=new ir(this.extractExpression(!0));let t="",r="",i="";const s=()=>{let c=e.peek(),l=!1;return c.charCodeAt(0)<32&&(c=" "),c==="\\"&&(l=!0,e.consume(1),c=e.peek()),e.consume(1),[c,l]},o=()=>{let c="";for(;e.hasData;){const[l,h]=s();if(!h&&(l==="/"||l==="#"||l==="^"))return[c,l];c+=l}return[c,""]},a=c=>{let l="",h=c;for(;e.hasData;){const[d,u]=s();if(!(h&&d===" ")){if(h=!1,!u&&d===";")break;l+=d}}return l};return[t,i]=o(),i&&(r=a(i==="^")),t===""&&r.includes("I/")?[2,[" "," ","/"]]:i==="^"?[2,[t,r,"^"]]:[2,[t,r,i]]}parseProperties(e){const t=this.ctxStack.current.copy(),r=this.ctxStack.current.copy();switch(e){case"L":r.underline=!0,this.continueStroke=!0;break;case"l":r.underline=!1,r.hasAnyStroke||(this.continueStroke=!1);break;case"O":r.overline=!0,this.continueStroke=!0;break;case"o":r.overline=!1,r.hasAnyStroke||(this.continueStroke=!1);break;case"K":r.strikeThrough=!0,this.continueStroke=!0;break;case"k":r.strikeThrough=!1,r.hasAnyStroke||(this.continueStroke=!1);break;case"A":this.parseAlign(r);break;case"C":this.parseAciColor(r);break;case"c":this.parseRgbColor(r);break;case"H":this.parseHeight(r);break;case"W":this.parseWidth(r);break;case"Q":this.parseOblique(r);break;case"T":this.parseCharTracking(r);break;case"p":this.parseParagraphProperties(r);break;case"f":case"F":this.parseFontProperties(r);break;default:throw new Error(`Unknown command: ${e}`)}if(this.continueStroke=r.hasAnyStroke,r.continueStroke=this.continueStroke,this.ctxStack.setCurrent(r),this.yieldPropertyCommands){const i=this.getPropertyChanges(t,r);if(Object.keys(i).length>0)return{command:e,changes:i,depth:this.ctxStack.depth}}}getPropertyChanges(e,t){const r={};if(e.underline!==t.underline&&(r.underline=t.underline),e.overline!==t.overline&&(r.overline=t.overline),e.strikeThrough!==t.strikeThrough&&(r.strikeThrough=t.strikeThrough),e.color.aci!==t.color.aci&&(r.aci=t.color.aci),e.color.rgbValue!==t.color.rgbValue&&(r.rgb=t.color.rgb),e.align!==t.align&&(r.align=t.align),JSON.stringify(e.fontFace)!==JSON.stringify(t.fontFace)&&(r.fontFace=t.fontFace),(e.capHeight.value!==t.capHeight.value||e.capHeight.isRelative!==t.capHeight.isRelative)&&(r.capHeight=t.capHeight),(e.widthFactor.value!==t.widthFactor.value||e.widthFactor.isRelative!==t.widthFactor.isRelative)&&(r.widthFactor=t.widthFactor),(e.charTrackingFactor.value!==t.charTrackingFactor.value||e.charTrackingFactor.isRelative!==t.charTrackingFactor.isRelative)&&(r.charTrackingFactor=t.charTrackingFactor),e.oblique!==t.oblique&&(r.oblique=t.oblique),JSON.stringify(e.paragraph)!==JSON.stringify(t.paragraph)){const i={};e.paragraph.indent!==t.paragraph.indent&&(i.indent=t.paragraph.indent),e.paragraph.align!==t.paragraph.align&&(i.align=t.paragraph.align),e.paragraph.left!==t.paragraph.left&&(i.left=t.paragraph.left),e.paragraph.right!==t.paragraph.right&&(i.right=t.paragraph.right),JSON.stringify(e.paragraph.tabs)!==JSON.stringify(t.paragraph.tabs)&&(i.tabs=t.paragraph.tabs),Object.keys(i).length>0&&(r.paragraph=i)}return r}parseAlign(e){const t=this.scanner.get();"012".includes(t)?e.align=parseInt(t):e.align=0,this.consumeOptionalTerminator()}parseHeight(e){const t=this.extractFloatExpression(!0);if(t)try{t.endsWith("x")?e.capHeight={value:parseFloat(t.slice(0,-1)),isRelative:!0}:e.capHeight={value:parseFloat(t),isRelative:!1}}catch{this.scanner.consume(-t.length);return}this.consumeOptionalTerminator()}parseWidth(e){const t=this.extractFloatExpression(!0);if(t)try{t.endsWith("x")?e.widthFactor={value:parseFloat(t.slice(0,-1)),isRelative:!0}:e.widthFactor={value:parseFloat(t),isRelative:!1}}catch{this.scanner.consume(-t.length);return}this.consumeOptionalTerminator()}parseCharTracking(e){const t=this.extractFloatExpression(!0);if(t)try{t.endsWith("x")?e.charTrackingFactor={value:Math.abs(parseFloat(t.slice(0,-1))),isRelative:!0}:e.charTrackingFactor={value:Math.abs(parseFloat(t)),isRelative:!1}}catch{this.scanner.consume(-t.length);return}this.consumeOptionalTerminator()}parseFloatValueOrFactor(e){const t=this.extractFloatExpression(!0);if(t)if(t.endsWith("x")){const r=parseFloat(t.slice(0,-1));e*=r}else e=parseFloat(t);return e}parseOblique(e){const t=this.extractFloatExpression(!1);t&&(e.oblique=parseFloat(t)),this.consumeOptionalTerminator()}parseAciColor(e){const t=this.extractIntExpression();if(t){const r=parseInt(t);r<257&&(e.color.aci=r)}this.consumeOptionalTerminator()}parseRgbColor(e){const t=this.extractIntExpression();if(t){const r=parseInt(t)&16777215;e.color.rgbValue=r}this.consumeOptionalTerminator()}extractFloatExpression(e=!1){const t=e?/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?x?/:/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/,r=this.scanner.tail.match(t);if(r){const i=r[0];return this.scanner.consume(i.length),i}return""}extractIntExpression(){const e=this.scanner.tail.match(/^\d+/);if(e){const t=e[0];return this.scanner.consume(t.length),t}return""}extractExpression(e=!1){const t=this.scanner.find(";",e);if(t<0){const s=this.scanner.tail;return this.scanner.consume(s.length),s}const r=this.scanner.peek(t-this.scanner.currentIndex-1)==="\\",i=this.scanner.tail.slice(0,t-this.scanner.currentIndex+(r?1:0));return this.scanner.consume(i.length+1),i}parseFontProperties(e){const t=this.extractExpression().split("|");if(t.length>0&&t[0]){const r=t[0];let i="Regular",s=400;for(const o of t.slice(1))o.startsWith("b1")?s=700:o==="i"||o.startsWith("i1")?i="Italic":(o==="i0"||o.startsWith("i0"))&&(i="Regular");e.fontFace={family:r,style:i,weight:s}}}parseParagraphProperties(e){const t=new ir(this.extractExpression());let r=e.paragraph.indent,i=e.paragraph.left,s=e.paragraph.right,o=e.paragraph.align,a=[];const c=()=>{const l=t.tail.match(/^[+-]?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/);if(l){const h=parseFloat(l[0]);for(t.consume(l[0].length);t.peek()===",";)t.consume(1);return h}return 0};for(;t.hasData;)switch(t.get()){case"i":r=c();break;case"l":i=c();break;case"r":s=c();break;case"x":break;case"q":{const l=t.get();for(o=du[l]||0;t.peek()===",";)t.consume(1);break}case"t":for(a=[];t.hasData;){const l=t.peek();if(l==="r"||l==="c"){t.consume(1);const h=c();a.push(l+h.toString())}else{const h=c();isNaN(h)?t.consume(1):a.push(h)}}break}e.paragraph={indent:r,left:i,right:s,align:o,tabs:a}}consumeOptionalTerminator(){this.scanner.peek()===";"&&this.scanner.consume(1)}*parse(){let e=null;function t(i){const s={...i.paragraph};i.paragraph={indent:0,left:0,right:0,align:0,tabs:[]};const o={};return s.indent!==0&&(o.indent=0),s.left!==0&&(o.left=0),s.right!==0&&(o.right=0),s.align!==0&&(o.align=0),JSON.stringify(s.tabs)!==JSON.stringify([])&&(o.tabs=[]),o}const r=()=>{var i;let s="";for(;this.scanner.hasData;){let o=!1,a=this.scanner.peek();const c=this.scanner.currentIndex;if(a.charCodeAt(0)<32){if(this.scanner.consume(1),a===" ")return[5,null];if(a===`
27
27
  `)return[6,null];a=" "}if(a==="\\")if("\\{}".includes(this.scanner.peek(1)))o=!0,this.scanner.consume(1),a=this.scanner.peek();else{if(s)return[1,s];this.scanner.consume(1);const l=this.scanner.get();switch(l){case"~":return[4,null];case"P":return[6,null];case"N":return[7,null];case"X":return[8,null];case"S":{this.inStackContext=!0;const h=this.parseStacking();return this.inStackContext=!1,h}case"m":case"M":if(this.scanner.peek()==="+"){this.scanner.consume(1);const h=(i=this.scanner.tail.match(/^[0-9A-Fa-f]{4}/))==null?void 0:i[0];if(h){this.scanner.consume(4);const d=this.decodeMultiByteChar(h);return s?[1,s]:[1,d]}this.scanner.consume(-1)}s+="\\M";continue;case"U":if(this.scanner.peek()==="+"){this.scanner.consume(1);const h=this.scanner.tail.match(/^[0-9A-Fa-f]{4,8}/);if(h){const d=h[0];this.scanner.consume(d.length);const u=parseInt(d,16);let p="";try{p=String.fromCodePoint(u)}catch{p="▯"}return s?[1,s]:[1,p]}this.scanner.consume(-1)}s+="\\U";continue;default:if(l)try{const h=this.parseProperties(l);if(this.yieldPropertyCommands&&h)return[9,h];continue}catch{const h=this.scanner.tail.slice(c,this.scanner.currentIndex);s+=h}}continue}if(a==="%"&&this.scanner.peek(1)==="%"){const l=this.scanner.peek(2).toLowerCase(),h=uu[l];if(h){this.scanner.consume(3),s+=h;continue}else{this.scanner.consume(3);continue}}if(a===" ")return s?(this.scanner.consume(1),e=3,[1,s]):(this.scanner.consume(1),[3,null]);if(!o){if(a==="{"){if(s)return[1,s];this.scanner.consume(1),this.pushCtx();continue}else if(a==="}"){if(s)return[1,s];if(this.scanner.consume(1),this.yieldPropertyCommands){const l=this.ctxStack.current;this.popCtx();const h=this.getPropertyChanges(l,this.ctxStack.current);if(Object.keys(h).length>0)return[9,{command:void 0,changes:h,depth:this.ctxStack.depth}]}else this.popCtx();continue}}if(!this.inStackContext&&a==="^"){const l=this.scanner.peek(1);if(l){const h=l.charCodeAt(0);if(this.scanner.consume(2),h===32)s+="^";else{if(h===73)return s?[1,s]:[5,null];if(h===74)return s?[1,s]:[6,null];if(h===77)continue;s+="▯"}continue}}this.scanner.consume(1),a.charCodeAt(0)>=32&&(s+=a)}return s?[1,s]:[0,null]};for(;;){const[i,s]=r.call(this);if(i){if(yield new or(i,this.ctxStack.current.copy(),s),i===6&&this.resetParagraphParameters){const o=this.ctxStack.current,a=t(o);this.yieldPropertyCommands&&Object.keys(a).length>0&&(yield new or(9,o.copy(),{command:void 0,changes:{paragraph:a},depth:this.ctxStack.depth}))}e&&(yield new or(e,this.ctxStack.current.copy(),null),e=null)}else break}}}let ir=class{constructor(e){this.text=e,this.textLen=e.length,this._index=0}get currentIndex(){return this._index}get isEmpty(){return this._index>=this.textLen}get hasData(){return this._index<this.textLen}get(){if(this.isEmpty)return"";const e=this.text[this._index];return this._index++,e}consume(e=1){this._index=Math.max(0,Math.min(this._index+e,this.textLen))}peek(e=0){const t=this._index+e;return t>=this.textLen||t<0?"":this.text[t]}find(e,t=!1){let r=this._index;for(;r<this.textLen;){if(t&&this.text[r]==="\\"){if(r+1<this.textLen){if(this.text[r+1]===e)return r+1;r+=2;continue}r++;continue}if(this.text[r]===e)return r;r++}return-1}get tail(){return this.text.slice(this._index)}isNextSpace(){return this.peek()===" "}consumeSpaces(){let e=0;for(;this.isNextSpace();)this.consume(),e++;return e}};class sr{constructor(e){this._aci=256,this._rgbValue=null,Array.isArray(e)?this.rgb=e:typeof e=="number"?this.aci=e:this.aci=256}get aci(){return this._aci}set aci(e){if(e===null)this._aci=null;else if(e>=0&&e<=256)this._aci=e,this._rgbValue=null;else throw new Error("ACI not in range [0, 256]")}get rgb(){if(this._rgbValue===null)return null;const e=this._rgbValue>>16&255,t=this._rgbValue>>8&255,r=this._rgbValue&255;return[e,t,r]}set rgb(e){if(e){const[t,r,i]=e;this._rgbValue=(t&255)<<16|(r&255)<<8|i&255,this._aci=null}else this._rgbValue=null}get isRgb(){return this._rgbValue!==null}get isAci(){return this._rgbValue===null&&this._aci!==null}get rgbValue(){return this._rgbValue}set rgbValue(e){e===null?this._rgbValue=null:(this._rgbValue=e&16777215,this._aci=null)}copy(){const e=new sr;return e._aci=this._aci,e._rgbValue=this._rgbValue,e}toObject(){return{aci:this._aci,rgb:this.rgb,rgbValue:this._rgbValue}}equals(e){return this._aci===e._aci&&this._rgbValue===e._rgbValue}}class Et{constructor(){this._stroke=0,this.continueStroke=!1,this.color=new sr,this.align=0,this.fontFace={family:"",style:"Regular",weight:400},this._capHeight={value:1,isRelative:!1},this._widthFactor={value:1,isRelative:!1},this._charTrackingFactor={value:1,isRelative:!1},this.oblique=0,this.paragraph={indent:0,left:0,right:0,align:0,tabs:[]}}get capHeight(){return this._capHeight}set capHeight(e){this._capHeight={value:Math.abs(e.value),isRelative:e.isRelative}}get widthFactor(){return this._widthFactor}set widthFactor(e){this._widthFactor={value:Math.abs(e.value),isRelative:e.isRelative}}get charTrackingFactor(){return this._charTrackingFactor}set charTrackingFactor(e){this._charTrackingFactor={value:Math.abs(e.value),isRelative:e.isRelative}}get aci(){return this.color.aci}set aci(e){this.color.aci=e}get rgb(){return this.color.rgb}set rgb(e){this.color.rgb=e}get italic(){return this.fontFace.style==="Italic"}set italic(e){this.fontFace.style=e?"Italic":"Regular"}get bold(){return(this.fontFace.weight||400)>=700}set bold(e){this.fontFace.weight=e?700:400}get underline(){return!!(this._stroke&1)}set underline(e){this._setStrokeState(1,e)}get strikeThrough(){return!!(this._stroke&4)}set strikeThrough(e){this._setStrokeState(4,e)}get overline(){return!!(this._stroke&2)}set overline(e){this._setStrokeState(2,e)}get hasAnyStroke(){return!!this._stroke}_setStrokeState(e,t=!0){t?this._stroke|=e:this._stroke&=~e}copy(){const e=new Et;return e._stroke=this._stroke,e.continueStroke=this.continueStroke,e.color=this.color.copy(),e.align=this.align,e.fontFace={...this.fontFace},e._capHeight={...this._capHeight},e._widthFactor={...this._widthFactor},e._charTrackingFactor={...this._charTrackingFactor},e.oblique=this.oblique,e.paragraph={...this.paragraph},e}}class or{constructor(e,t,r){this.type=e,this.ctx=t,this.data=r}}const mu=new g.Vector3,yu=1.666666;class ar extends Et{constructor(e){super(),this.fontScaleFactor=1,this.fontSize=1,this.fontSizeScaleFactor=1,this.blankWidth=0,e&&Object.assign(this,e)}clone(){const e=new ar;return e.continueStroke=this.continueStroke,e.color=this.color.copy(),e.align=this.align,e.fontFace={...this.fontFace},e.capHeight={...this.capHeight},e.widthFactor={...this.widthFactor},e.charTrackingFactor={...this.charTrackingFactor},e.oblique=this.oblique,e.paragraph={...this.paragraph},e.fontScaleFactor=this.fontScaleFactor,e.fontSize=this.fontSize,e.fontSizeScaleFactor=this.fontSizeScaleFactor,e.blankWidth=this.blankWidth,e}getColorAsHex(){return this.color.isRgb&&this.color.rgbValue!==null?this.color.rgbValue:this.color.isAci&&this.color.aci!==null?Mo(this.color.aci):16777215}setColorFromHex(e){const t=e>>16&255,r=e>>8&255,i=e&255;this.color.rgb=[t,r,i]}}class vu{constructor(e,t,r,i){this._contextStack=[],this._maxFontSize=0,this._currentIndent=0,this._currentLeftMargin=0,this._currentRightMargin=0,this._style=e,this._styleManager=t,this._fontManager=r,this._options=i,this._totalHeight=0,this._hOffset=0,this._vOffset=0,this._lineCount=1,this._currentLineObjects=[],this._currentContext=new ar({fontScaleFactor:this.fontManager.getFontScaleFactor(this.textStyle.font.toLowerCase()),fontSize:i.fontSize,fontSizeScaleFactor:1,italic:!1,bold:!1,blankWidth:this.calculateBlankWidthForFont(this.textStyle.font.toLowerCase(),i.fontSize)}),this._currentContext.setColorFromHex(e.color),this._currentContext.fontFace.family=this.textStyle.font.toLowerCase(),this._currentContext.widthFactor={value:i.widthFactor,isRelative:!0},this._currentContext.oblique=e.obliqueAngle||0,this._maxFontSize=0,this._currentHorizontalAlignment=i.horizontalAlignment,this._currentIndent=0,this._currentLeftMargin=0,this._currentRightMargin=0,this.initLineParams()}get fontManager(){return this._fontManager}get styleManager(){return this._styleManager}get textStyle(){return this._style}get totalHeight(){return this._lineCount==1?this.currentMaxFontSize:this._totalHeight+this.currentLineHeight}get maxWidth(){return this._options.maxWidth}get flowDirection(){return this._options.flowDirection}get defaultHorizontalAlignment(){return this._options.horizontalAlignment}get defaultWidthFactor(){return this._options.widthFactor}get defaultFontSize(){return this._options.fontSize}get defaultLineSpaceFactor(){return this._options.lineSpaceFactor}get currentFont(){return this._currentContext.fontFace.family}get currentHorizontalAlignment(){return this._currentHorizontalAlignment}get currentFontSize(){return this._currentContext.fontSize}get currentLineHeight(){return this.defaultLineSpaceFactor*this.currentFontSize*yu+this.currentMaxFontSize}get currentMaxFontSize(){return this._maxFontSize}get currentWordSpace(){return this._currentContext.charTrackingFactor.value}get currentWidthFactor(){return this._currentContext.widthFactor.value}get currentLineObjects(){return this._currentLineObjects}get hOffset(){return this._hOffset}set hOffset(e){this._hOffset=e}get vOffset(){return this._vOffset}set vOffset(e){this._vOffset=e}get currentIndent(){return this._currentIndent}get currentLeftMargin(){return this._currentLeftMargin}get currentRightMargin(){return this._currentRightMargin}get maxLineWidth(){return this.maxWidth-this._currentLeftMargin-this._currentRightMargin}processFormat(e){switch(e.command){case"f":case"F":if(e.changes.fontFace){this.changeFont(e.changes.fontFace.family),this.fontManager.getFontType(this._currentContext.fontFace.family)==="mesh"?(this._currentContext.italic=e.changes.fontFace.style==="Italic",this._currentContext.bold=(e.changes.fontFace.weight||400)>=700,this._currentContext.oblique=this.textStyle.obliqueAngle||0):(this._currentContext.italic=!1,this._currentContext.bold=!1,e.changes.fontFace.style==="Italic"?this._currentContext.oblique=15:this._currentContext.oblique=this.textStyle.obliqueAngle||0);break}case"c":case"C":e.changes.aci?e.changes.aci===0?this._currentContext.setColorFromHex(this._options.byBlockColor):e.changes.aci===256?this._currentContext.setColorFromHex(this._options.byLayerColor):this._currentContext.color.aci=e.changes.aci:e.changes.rgb&&(this._currentContext.color.rgb=e.changes.rgb);break;case"W":e.changes.widthFactor&&(e.changes.widthFactor.isRelative?this._currentContext.widthFactor={value:e.changes.widthFactor.value*this.maxWidth,isRelative:!1}:this._currentContext.widthFactor={value:e.changes.widthFactor.value*.93,isRelative:!1});break;case"H":e.changes.capHeight&&(e.changes.capHeight.isRelative?this.changeFontSizeScaleFactor(e.changes.capHeight.value):this.changeFontHeight(e.changes.capHeight.value));break;case"T":e.changes.charTrackingFactor&&(e.changes.charTrackingFactor.isRelative?this._currentContext.charTrackingFactor={value:e.changes.charTrackingFactor.value+1,isRelative:!1}:this._currentContext.charTrackingFactor={value:e.changes.charTrackingFactor.value,isRelative:!1});break;case"p":e.changes.paragraph&&(e.changes.paragraph.align&&(this._currentHorizontalAlignment=e.changes.paragraph.align),typeof e.changes.paragraph.indent=="number"&&(this._currentIndent=e.changes.paragraph.indent*this.defaultFontSize,this._hOffset+=this._currentIndent),typeof e.changes.paragraph.left=="number"&&(this._currentLeftMargin=e.changes.paragraph.left*this.defaultFontSize),typeof e.changes.paragraph.right=="number"&&(this._currentRightMargin=e.changes.paragraph.right*this.defaultFontSize));break;case"L":this._currentContext.underline=!0;break;case"l":this._currentContext.underline=!1;break;case"O":this._currentContext.overline=!0;break;case"o":this._currentContext.overline=!1;break;case"K":this._currentContext.strikeThrough=!0;break;case"k":this._currentContext.strikeThrough=!1;break;case"Q":e.changes.oblique!==void 0&&(this._currentContext.oblique=e.changes.oblique);break}}resetParagraphProperties(){this._currentIndent=0,this._currentLeftMargin=0,this._currentRightMargin=0,this._currentHorizontalAlignment=this._options.horizontalAlignment}startNewParagraph(e,t,r){this.processGeometries(e,t,r),this.startNewLine(),this.resetParagraphProperties()}processText(e){const t=[],r=[],i=new g.Group;for(const s of e)if(s.type===tt.NEW_PARAGRAPH)this.startNewParagraph(t,r,i);else if(s.type===tt.WORD){const o=s.data;Array.isArray(o)?o.forEach(a=>this.processWord(a,t,r)):typeof o=="string"&&o.length>0&&this.processWord(o,t,r)}else if(s.type===tt.SPACE)this.processBlank();else if(s.type===tt.PROPERTIES_CHANGED){this.processGeometries(t,r,i);const o=s.data;o.command===void 0?this._contextStack.length>0&&(this._currentContext=this._contextStack.pop()):(o.depth>0&&this._contextStack.push(this._currentContext.clone()),this.processFormat(o))}else s.type===tt.STACK&&(this.processStack(s.data,t,r),this.processGeometries(t,r,i));return(t.length>0||r.length>0)&&this.processGeometries(t,r,i),this.processLastLine(),i}processGeometries(e,t,r){if(e.length>0||t.length>0){const i=this.toThreeObject(e,t);r.add(i),this._currentLineObjects.push(i),e.length=0,t.length=0}}processWord(e,t,r){let i=0;for(let s=0;s<e.length;s++){const o=this.getCharShape(e[s]);o?this.currentHorizontalAlignment==ge.DISTRIBUTED?i+=o.width*this.currentWidthFactor:i+=o.width*this.currentWordSpace*this.currentWidthFactor:i+=this._currentContext.blankWidth}this.hOffset+i>(this.maxLineWidth||1/0)&&this.startNewLine();for(let s=0;s<e.length;s++)this.processChar(e[s],t,r)}processStack(e,t,r){const[i,s,o]=e,a=this._hOffset,c=this._vOffset,l=this._currentContext.charTrackingFactor.value,h=this._currentContext.fontSize,d=this._currentContext.fontSizeScaleFactor;this._hOffset=a,this._currentContext.charTrackingFactor={value:1,isRelative:!1};let u=0;for(let v=0;v<i.length;v++){const _=this.getCharShape(i[v]);_&&(u+=_.width*this.currentWidthFactor)}this._hOffset=a;let p=0;for(let v=0;v<s.length;v++){const _=this.getCharShape(s[v]);_&&(p+=_.width*this.currentWidthFactor)}const f=Math.max(u,p),m=(f-u)/2,y=(f-p)/2;if(o==="^"){if(this._currentContext.fontSizeScaleFactor=d*.7,this.calcuateLineParams(),i&&!s){const v=[],_=[];this._hOffset=a,this._vOffset=c+h*.1;for(let w=0;w<i.length;w++)this.processChar(i[w],v,_);t.push(...v),r.push(..._),this._hOffset=a+u}else if(!i&&s){const v=[],_=[];this._hOffset=a,this._vOffset=c-h*.6;for(let w=0;w<s.length;w++)this.processChar(s[w],v,_);t.push(...v),r.push(..._),this._hOffset=a+p}this._currentContext.fontSizeScaleFactor=d,this.calcuateLineParams()}else{const v=[],_=[];this._hOffset=a+m,this._vOffset=c+this.currentFontSize*.3;for(let T=0;T<i.length;T++)this.processChar(i[T],v,_);t.push(...v),r.push(..._);const w=[],C=[];this._hOffset=a+y,this._vOffset=c-this.currentFontSize*.6;for(let T=0;T<s.length;T++)this.processChar(s[T],w,C);if(t.push(...w),r.push(...C),o==="/"||o==="#"){const T=new g.BufferGeometry,D=new Float32Array([a,c-this.currentFontSize*.8,0,a+f,c-this.currentFontSize*.8,0]);T.setAttribute("position",new g.BufferAttribute(D,3)),T.setIndex(null),r.push(T)}this._hOffset=a+f}this._vOffset=c,this._currentContext.charTrackingFactor={value:l,isRelative:!1}}processBlank(){this._hOffset+=this._currentContext.blankWidth}processChar(e,t,r){const i=this.getCharShape(e);if(!i){this.processBlank();return}let s=i.toGeometry();s.scale(this.currentWidthFactor,1,1);let o=this._currentContext.oblique;if(this._currentContext.italic&&(o+=15),o){const f=o*Math.PI/180,m=new g.Matrix4;m.set(1,Math.tan(f),0,0,0,1,0,0,0,0,1,0,0,0,0,1),s.applyMatrix4(m)}const a=this.fontManager.getFontType(this.currentFont);this._currentContext.bold&&a==="mesh"&&s.scale(1.06,1.06,1),this.hOffset>(this.maxLineWidth||1/0)&&this.startNewLine();let c=this.hOffset,l=this.flowDirection==It.BOTTOM_TO_TOP?this.vOffset:this.vOffset-this.currentFontSize,h=i.width*this.currentWidthFactor,d=this.currentFontSize;s.translate(c,l,0),this.currentHorizontalAlignment==ge.DISTRIBUTED?this._hOffset+=i.width*this.currentWidthFactor:this._hOffset+=i.width*this.currentWordSpace*this.currentWidthFactor,t.push(s);const u=d*.05,p=.001;if(this._currentContext.underline){const f=new g.BufferGeometry,m=l-u;f.setAttribute("position",new g.BufferAttribute(new Float32Array([c,m,p,c+h,m,p]),3)),f.setIndex(null),r.push(f)}if(this._currentContext.overline){const f=new g.BufferGeometry,m=l+d+u;f.setAttribute("position",new g.BufferAttribute(new Float32Array([c,m,p,c+h,m,p]),3)),f.setIndex(null),r.push(f)}if(this._currentContext.strikeThrough){const f=new g.BufferGeometry,m=l+d/2-d*.2;f.setAttribute("position",new g.BufferAttribute(new Float32Array([c,m,p,c+h,m,p]),3)),f.setIndex(null),r.push(f)}}processLastLine(){this.processAlignment()}initLineParams(){this.calcuateLineParams()}changeFont(e){let t=e;this._options.removeFontExtension&&(t=e.replace(/\.(ttf|otf|woff|shx)$/,"")),this._currentContext.fontFace.family=this.fontManager.findAndReplaceFont(t),this._currentContext.blankWidth=this.calculateBlankWidthForFont(this._currentContext.fontFace.family,this._currentContext.fontSize),this.calcuateLineParams()}calcuateLineParams(e){this._currentContext.fontScaleFactor=this.fontManager.getFontScaleFactor(this.currentFont);const t=e||this.defaultFontSize||this.textStyle.fixedTextHeight;this._currentContext.fontSize=t*this._currentContext.fontScaleFactor*this._currentContext.fontSizeScaleFactor}getCharShape(e){let t=this.fontManager.getCharShape(e,this.currentFont,this.currentFontSize);return this.textStyle.bigFont&&!t&&(t=this.fontManager.getCharShape(e,this.textStyle.bigFont,this.currentFontSize)),t||(t=this.fontManager.getCharShape(e,"",this.currentFontSize)),t||(t=this.fontManager.getNotFoundTextShape(this.currentFontSize)),this.currentFontSize>this._maxFontSize&&(this._maxFontSize=this.currentFontSize),t}startNewLine(){this._hOffset=0,this.flowDirection==It.BOTTOM_TO_TOP?this._vOffset+=this.currentLineHeight:this._vOffset-=this.currentLineHeight,this._lineCount++,this.processAlignment(),this._currentLineObjects=[],this._lineCount==2?this._totalHeight=this.currentMaxFontSize:this._totalHeight=this._totalHeight+this.currentLineHeight,this._maxFontSize=0}processAlignment(){const e=[];if(this.currentLineObjects.forEach(r=>r.traverse(i=>{"geometry"in i&&e.push(i.geometry)})),e.length==0)return;let t;if(e.forEach((r,i)=>{r.boundingBox||r.computeBoundingBox(),i===0?t=r.boundingBox:t.union(r.boundingBox)}),t){const r=t.getSize(mu);switch(this.currentHorizontalAlignment){case ge.LEFT:e.forEach(i=>i.translate(this._currentLeftMargin-t.min.x,0,0));break;case ge.CENTER:e.forEach(i=>i.translate(this._currentLeftMargin+(this.maxLineWidth-r.x)/2-t.min.x,0,0));break;case ge.RIGHT:e.forEach(i=>i.translate(this._currentLeftMargin+this.maxLineWidth-r.x-t.min.x,0,0));break;case ge.DISTRIBUTED:if(e.length>1){const i=(this.maxLineWidth-r.x)/(e.length-1);for(let s=1;s<e.length;s++)e[s].translate(i*s,0,0)}e.forEach(i=>i.translate(this._currentLeftMargin-t.min.x,0,0));break}}}calculateBlankWidthForFont(e,t){return this.fontManager.getFontType(e)==="shx"?t*.5:t*.3}toThreeObject(e,t){const r=new g.Group,i=this._currentContext.getColorAsHex(),s=e.filter(a=>a instanceof g.ExtrudeGeometry);if(s.length>0){const a=new g.Mesh;a.geometry=qr(s),a.material=this.styleManager.getMeshBasicMaterial(i),a.userData.bboxIntersectionCheck=!0,r.add(a)}const o=[...t,...e.filter(a=>!(a instanceof g.ExtrudeGeometry))];if(o.length>0){const a=new g.LineSegments;a.geometry=qr(o),a.material=this.styleManager.getLineBasicMaterial(i),a.userData.bboxIntersectionCheck=!0,r.add(a)}return r.children.length===1?r.children[0]:r}changeFontSizeScaleFactor(e){this._currentContext.fontSizeScaleFactor*=e,this.calcuateLineParams()}changeFontHeight(e){this._currentContext.fontSize=e*this._currentContext.fontScaleFactor*this._currentContext.fontSizeScaleFactor,this.calcuateLineParams()}}const cr=new g.Vector3,Xe=new g.Vector3,lr=new g.Vector3,hr=new g.Quaternion,ur=new g.Matrix4,Os=new g.Matrix4,Ms=new g.Vector3(1,0,0);class bu extends g.Object3D{static getFonts(e,t=!1){return pu(e,t)}constructor(e,t,r,i,s={byLayerColor:16777215,byBlockColor:16777215}){super(),this._style=t,this._styleManager=r,this._fontManager=i,this._colorSettings={byLayerColor:s.byLayerColor,byBlockColor:s.byBlockColor},this._box=new g.Box3,this._boxes=[];const o=this.loadMText(e,t);o&&(this.getBoxes(o,this._boxes),this._boxes.forEach(a=>this.box.union(a)),this.add(o))}get fontManager(){return this._fontManager}get styleManager(){return this._styleManager}get textStyle(){return this._style}get box(){return this._box}set box(e){this._box.copy(e)}raycast(e,t){this._boxes.forEach(r=>{if(e.ray.intersectBox(r,cr)){const i=e.ray.origin.distanceTo(cr);t.push({distance:i,point:cr.clone(),object:this,face:null,faceIndex:void 0,uv:void 0})}})}loadMText(e,t){const{object:r,height:i}=this.createMTextGroup(e,t);if(!r)return;r.matrix.decompose(Xe,hr,lr),e.position&&(Xe.x+=e.position.x,Xe.y+=e.position.y,r.matrix.compose(Xe,hr,lr));const s=e.width,o=this.calculateAnchorPoint(s,i,e.attachmentPoint,e.drawingDirection);r.traverse(l=>{"geometry"in l&&l.geometry.translate(o.x,o.y,0),l.layers.enableAll()});let a=e.rotation||0;if(e.directionVector){const l=e.directionVector,h=new g.Vector3(l.x,l.y,l.z),d=h.clone().cross(Ms),u=Ms.angleTo(h);a=d.z>0?-u:u}r.matrix.compose(Xe,hr,lr);const c=e.position?Xe.clone().sub(e.position):Xe;return ur.makeTranslation(-c.x,-c.y,0),Os.makeRotationZ(a),r.matrix.multiply(ur),r.matrix.multiply(Os),r.matrix.multiply(ur.invert()),r.matrix.decompose(r.position,r.quaternion,r.scale),r}createMTextGroup(e,t){if(t&&t.font&&t.font.endsWith(".shx")){const p=`${t.font}_${t.name}`;this.styleManager.unsupportedTextStyles[p]||(this.styleManager.unsupportedTextStyles[p]=0),this.styleManager.unsupportedTextStyles[p]++}const r=e.width||0;let i=ge.LEFT;e.width&&e.attachmentPoint&&([1,4,7].includes(e.attachmentPoint)?i=ge.LEFT:[2,5,8].includes(e.attachmentPoint)?i=ge.CENTER:[3,6,9].includes(e.attachmentPoint)&&(i=ge.RIGHT));let s=At.BOTTOM;e.attachmentPoint&&([1,2,3].includes(e.attachmentPoint)?s=At.TOP:[4,5,6].includes(e.attachmentPoint)?s=At.MIDDLE:[7,8,9].includes(e.attachmentPoint)&&(s=At.BOTTOM));const o=e.height||0,a=e.lineSpaceFactor||.3,c=e.drawingDirection??It.LEFT_TO_RIGHT,l={fontSize:o,widthFactor:e.widthFactor??1,lineSpaceFactor:a,horizontalAlignment:i,maxWidth:r,flowDirection:c,byBlockColor:this._colorSettings.byBlockColor,byLayerColor:this._colorSettings.byLayerColor,removeFontExtension:!0},h=new Et;h.fontFace.family=t.font,h.capHeight={value:e.height||1,isRelative:!0},h.widthFactor={value:e.widthFactor??1,isRelative:!0},h.align=s,h.paragraph.align=i;const d=new vu(t,this.styleManager,this.fontManager,l),u=new gu(e.text,h,{resetParagraphParameters:!0,yieldPropertyCommands:!0}).parse();return{object:d.processText(u),height:d.totalHeight}}calculateAnchorPoint(e,t,r,i){let s=0,o=0;switch(r){case void 0:case 1:s=0,o=0;break;case 2:s-=e/2,o=0;break;case 3:s-=e,o=0;break;case 4:s=0,o+=t/2;break;case 5:s-=e/2,o+=t/2;break;case 6:s-=e,o+=t/2;break;case 7:s=0,o+=t;break;case 8:s-=e/2,o+=t;break;case 9:s-=e,o+=t;break}return i==It.BOTTOM_TO_TOP&&(o-=t),{x:s,y:o}}getBoxes(e,t){if(e.updateWorldMatrix(!1,!1),e instanceof g.Line||e instanceof g.Mesh){const i=e.geometry;i.boundingBox===null&&i.computeBoundingBox();const s=new g.Box3().copy(i.boundingBox);s.applyMatrix4(e.matrixWorld),t.push(s)}const r=e.children;for(let i=0,s=r.length;i<s;i++)this.getBoxes(r[i],t)}}var ee;(function(n){n[n.BeforeStart=0]="BeforeStart",n[n.EqualStart=1]="EqualStart",n[n.BetweenStartAndEnd=2]="BetweenStartAndEnd",n[n.EqualEnd=3]="EqualEnd",n[n.AfterEnd=4]="AfterEnd"})(ee||(ee={}));class xu{pointsSame(e,t){return this.pointsSameX(e,t)&&this.pointsSameY(e,t)}pointsCompare(e,t){return this.pointsSameX(e,t)?this.pointsSameY(e,t)?0:e[1]<t[1]?-1:1:e[0]<t[0]?-1:1}}class Ds extends xu{constructor(e=1e-10){super(),this.epsilon=e}pointAboveOrOnLine(e,t,r){const i=t[0],s=t[1],o=r[0],a=r[1],c=e[0],l=e[1];return(o-i)*(l-s)-(a-s)*(c-i)>=-this.epsilon}pointBetween(e,t,r){const i=e[1]-t[1],s=r[0]-t[0],o=e[0]-t[0],a=r[1]-t[1],c=o*s+i*a;if(c<this.epsilon)return!1;const l=s*s+a*a;return!(c-l>-this.epsilon)}pointsSameX(e,t){return Math.abs(e[0]-t[0])<this.epsilon}pointsSameY(e,t){return Math.abs(e[1]-t[1])<this.epsilon}pointsCollinear(e,t,r){const i=e[0]-t[0],s=e[1]-t[1],o=t[0]-r[0],a=t[1]-r[1];return Math.abs(i*a-o*s)<this.epsilon}linesIntersect(e,t,r,i){const s=t[0]-e[0],o=t[1]-e[1],a=i[0]-r[0],c=i[1]-r[1],l=s*c-o*a;if(Math.abs(l)<this.epsilon)return null;const h=e[0]-r[0],d=e[1]-r[1],u=(a*d-c*h)/l,p=(s*d-o*h)/l,f=y=>y<=-this.epsilon?ee.BeforeStart:y<this.epsilon?ee.EqualStart:y-1<=-this.epsilon?ee.BetweenStartAndEnd:y-1<this.epsilon?ee.EqualEnd:ee.AfterEnd,m=[e[0]+u*s,e[1]+u*o];return{alongA:f(u),alongB:f(p),p:m}}}class Rs{constructor(){this.nodes=[]}remove(e){const t=this.nodes.indexOf(e);t>=0&&this.nodes.splice(t,1)}getIndex(e){return this.nodes.indexOf(e)}isEmpty(){return this.nodes.length<=0}getHead(){return this.nodes[0]}removeHead(){this.nodes.shift()}insertBefore(e,t){this.findTransition(e,t).insert(e)}findTransition(e,t){var r,i;const s=(c,l)=>t(l)-t(c);let o=0,a=this.nodes.length;for(;o<a;){const c=o+a>>1;s(this.nodes[c],e)>0?a=c:o=c+1}return{before:o<=0?null:(r=this.nodes[o-1])!==null&&r!==void 0?r:null,after:(i=this.nodes[o])!==null&&i!==void 0?i:null,insert:c=>(this.nodes.splice(o,0,c),c)}}}class nt{constructor(e,t,r,i){var s;this.otherFill=null,this.id=(s=i==null?void 0:i.segmentId())!==null&&s!==void 0?s:-1,this.start=e,this.end=t,this.myFill={above:r?r.myFill.above:null,below:r?r.myFill.below:null}}}class Us{constructor(e,t,r,i){this.status=null,this.isStart=e,this.p=t,this.seg=r,this.primary=i}}class Fs{constructor(e,t,r=null){this.events=new Rs,this.status=new Rs,this.selfIntersection=e,this.geo=t,this.log=r}compareEvents(e,t,r,i,s,o){const a=this.geo.pointsCompare(t,s);return a!==0?a:this.geo.pointsSame(r,o)?0:e!==i?e?1:-1:this.geo.pointAboveOrOnLine(r,i?s:o,i?o:s)?1:-1}addEvent(e){this.events.insertBefore(e,t=>t===e?0:this.compareEvents(e.isStart,e.p,e.other.p,t.isStart,t.p,t.other.p))}divideEvent(e,t){var r;const i=new nt(t,e.seg.end,e.seg,this.log);return(r=this.log)===null||r===void 0||r.segmentChop(e.seg,t),this.events.remove(e.other),e.seg.end=t,e.other.p=t,this.addEvent(e.other),this.addSegment(i,e.primary)}newSegment(e,t){const r=this.geo.pointsCompare(e,t);return r===0?null:r<0?new nt(e,t,null,this.log):new nt(t,e,null,this.log)}addSegment(e,t){const r=new Us(!0,e.start,e,t),i=new Us(!1,e.end,e,t);return r.other=i,i.other=r,this.addEvent(r),this.addEvent(i),r}addRegion(e){let t,r=e[e.length-1];for(let i=0;i<e.length;i++){t=r,r=e[i];const s=this.newSegment(t,r);s&&this.addSegment(s,!0)}}compareStatus(e,t){const r=e.seg.start,i=e.seg.end,s=t.seg.start,o=t.seg.end;return this.geo.pointsCollinear(r,s,o)?this.geo.pointsCollinear(i,s,o)||this.geo.pointAboveOrOnLine(i,s,o)?1:-1:this.geo.pointAboveOrOnLine(r,s,o)?1:-1}statusFindSurrounding(e){return this.status.findTransition(e,t=>t===e?0:-this.compareStatus(e,t))}checkIntersection(e,t){var r;const i=e.seg,s=t.seg,o=i.start,a=i.end,c=s.start,l=s.end;(r=this.log)===null||r===void 0||r.checkIntersection(i,s);const h=this.geo.linesIntersect(o,a,c,l);if(h===null){if(!this.geo.pointsCollinear(o,a,c)||this.geo.pointsSame(o,l)||this.geo.pointsSame(a,c))return null;const d=this.geo.pointsSame(o,c),u=this.geo.pointsSame(a,l);if(d&&u)return t;const p=!d&&this.geo.pointBetween(o,c,l),f=!u&&this.geo.pointBetween(a,c,l);if(d)return f?this.divideEvent(t,a):this.divideEvent(e,l),t;p&&(u||(f?this.divideEvent(t,a):this.divideEvent(e,l)),this.divideEvent(t,o))}else h.alongA===ee.BetweenStartAndEnd&&(h.alongB===ee.EqualStart?this.divideEvent(e,c):h.alongB===ee.BetweenStartAndEnd?this.divideEvent(e,h.p):h.alongB===ee.EqualEnd&&this.divideEvent(e,l)),h.alongB===ee.BetweenStartAndEnd&&(h.alongA===ee.EqualStart?this.divideEvent(t,o):h.alongA===ee.BetweenStartAndEnd?this.divideEvent(t,h.p):h.alongA===ee.EqualEnd&&this.divideEvent(t,a));return null}calculate(e,t){var r,i,s,o,a,c,l,h;const d=[];for(;!this.events.isEmpty();){const u=this.events.getHead();if((r=this.log)===null||r===void 0||r.vert(u.p[0]),u.isStart){(i=this.log)===null||i===void 0||i.segmentNew(u.seg,u.primary);const p=this.statusFindSurrounding(u),f=p.before,m=p.after;(s=this.log)===null||s===void 0||s.tempStatus(u.seg,f?f.seg:!1,m?m.seg:!1);const v=(()=>{if(f){const _=this.checkIntersection(u,f);if(_)return _}return m?this.checkIntersection(u,m):null})();if(v){if(this.selfIntersection){let _;u.seg.myFill.below===null?_=!0:_=u.seg.myFill.above!==u.seg.myFill.below,_&&(v.seg.myFill.above=!v.seg.myFill.above)}else v.seg.otherFill=u.seg.myFill;(o=this.log)===null||o===void 0||o.segmentUpdate(v.seg),this.events.remove(u.other),this.events.remove(u)}if(this.events.getHead()!==u){(a=this.log)===null||a===void 0||a.rewind(u.seg);continue}if(this.selfIntersection){let _;u.seg.myFill.below===null?_=!0:_=u.seg.myFill.above!==u.seg.myFill.below,m?u.seg.myFill.below=m.seg.myFill.above:u.seg.myFill.below=e,_?u.seg.myFill.above=!u.seg.myFill.below:u.seg.myFill.above=u.seg.myFill.below}else if(u.seg.otherFill===null){let _;if(!m)_=u.primary?t:e;else if(u.primary===m.primary){if(m.seg.otherFill===null)throw new Error("otherFill is null");_=m.seg.otherFill.above}else _=m.seg.myFill.above;u.seg.otherFill={above:_,below:_}}(c=this.log)===null||c===void 0||c.status(u.seg,f?f.seg:!1,m?m.seg:!1),u.other.status=p.insert(u)}else{const p=u.status;if(p===null)throw new Error("PolyBool: Zero-length segment detected; your epsilon is probably too small or too large");const f=this.status.getIndex(p);if(f>0&&f<this.status.nodes.length-1){const m=this.status.nodes[f-1],y=this.status.nodes[f+1];this.checkIntersection(m,y)}if((l=this.log)===null||l===void 0||l.statusRemove(p.seg),this.status.remove(p),!u.primary){if(!u.seg.otherFill)throw new Error("otherFill is null");const m=u.seg.myFill;u.seg.myFill=u.seg.otherFill,u.seg.otherFill=m}d.push(u.seg)}this.events.removeHead()}return(h=this.log)===null||h===void 0||h.done(),d}}function kt(n,e,t){const r=[];for(const i of n){const s=(i.myFill.above?8:0)+(i.myFill.below?4:0)+(i.otherFill&&i.otherFill.above?2:0)+(i.otherFill&&i.otherFill.below?1:0);if(e[s]!==0){const o=new nt(i.start,i.end,null,t);o.myFill.above=e[s]===1,o.myFill.below=e[s]===2,r.push(o)}}return t==null||t.selected(r),r}class Bt{static union(e,t){return kt(e,[0,2,1,0,2,2,0,0,1,0,1,0,0,0,0,0],t)}static intersect(e,t){return kt(e,[0,0,0,0,0,2,0,2,0,0,1,1,0,2,1,0],t)}static difference(e,t){return kt(e,[0,0,0,0,2,0,2,0,1,1,0,0,0,1,2,0],t)}static differenceRev(e,t){return kt(e,[0,2,1,0,0,0,1,1,0,2,0,2,0,0,0,0],t)}static xor(e,t){return kt(e,[0,2,1,0,2,0,0,1,1,0,0,2,0,1,2,0],t)}}function Su(n,e,t){const r=[],i=[];for(const s of n){let d=function(v,_,w){return h&&(h.index=v,h.matches_head=_,h.matches_pt1=w),h===c?(h=l,!1):(h=null,!0)},u=function(v){t==null||t.chainReverse(v),r[v].reverse()},p=function(v,_){const w=r[v],C=r[_];let T=w[w.length-1];const D=w[w.length-2],I=C[0],E=C[1];e.pointsCollinear(D,T,I)&&(t==null||t.chainRemoveTail(v,T),w.pop(),T=D),e.pointsCollinear(T,I,E)&&(t==null||t.chainRemoveHead(_,I),C.shift()),t==null||t.chainJoin(v,_),r[v]=w.concat(C),r.splice(_,1)};const o=s.start,a=s.end;if(e.pointsSame(o,a)){console.warn("PolyBool: Warning: Zero-length segment detected; your epsilon is probably too small or too large");continue}t==null||t.chainStart(s);const c={index:0,matches_head:!1,matches_pt1:!1},l={index:0,matches_head:!1,matches_pt1:!1};let h=c;for(let v=0;v<r.length;v++){const _=r[v],w=_[0],C=_[_.length-1];if(e.pointsSame(w,o)){if(d(v,!0,!0))break}else if(e.pointsSame(w,a)){if(d(v,!0,!1))break}else if(e.pointsSame(C,o)){if(d(v,!1,!0))break}else if(e.pointsSame(C,a)&&d(v,!1,!1))break}if(h===c){r.push([o,a]),t==null||t.chainNew(o,a);continue}if(h===l){t==null||t.chainMatch(c.index);const v=c.index,_=c.matches_pt1?a:o,w=c.matches_head,C=r[v];let T=w?C[0]:C[C.length-1];const D=w?C[1]:C[C.length-2],I=w?C[C.length-1]:C[0],E=w?C[C.length-2]:C[1];if(e.pointsCollinear(D,T,_)&&(w?(t==null||t.chainRemoveHead(c.index,_),C.shift()):(t==null||t.chainRemoveTail(c.index,_),C.pop()),T=D),e.pointsSame(I,_)){r.splice(v,1),e.pointsCollinear(E,I,T)&&(w?(t==null||t.chainRemoveTail(c.index,T),C.pop()):(t==null||t.chainRemoveHead(c.index,T),C.shift())),t==null||t.chainClose(c.index),i.push(C);continue}w?(t==null||t.chainAddHead(c.index,_),C.unshift(_)):(t==null||t.chainAddTail(c.index,_),C.push(_));continue}const f=c.index,m=l.index;t==null||t.chainConnect(f,m);const y=r[f].length<r[m].length;c.matches_head?l.matches_head?y?(u(f),p(f,m)):(u(m),p(m,f)):p(m,f):l.matches_head?p(f,m):y?(u(f),p(m,f)):(u(m),p(f,m))}return i}class wu{constructor(){this.list=[],this.nextSegmentId=0,this.curVert=NaN}push(e,t){this.list.push({type:e,data:JSON.parse(JSON.stringify(t))})}segmentId(){return this.nextSegmentId++}checkIntersection(e,t){this.push("check",{seg1:e,seg2:t})}segmentChop(e,t){this.push("div_seg",{seg:e,p:t}),this.push("chop",{seg:e,p:t})}statusRemove(e){this.push("pop_seg",{seg:e})}segmentUpdate(e){this.push("seg_update",{seg:e})}segmentNew(e,t){this.push("new_seg",{seg:e,primary:t})}tempStatus(e,t,r){this.push("temp_status",{seg:e,above:t,below:r})}rewind(e){this.push("rewind",{seg:e})}status(e,t,r){this.push("status",{seg:e,above:t,below:r})}vert(e){e!==this.curVert&&(this.push("vert",{x:e}),this.curVert=e)}selected(e){this.push("selected",{segs:e})}chainStart(e){this.push("chain_start",{seg:e})}chainRemoveHead(e,t){this.push("chain_rem_head",{index:e,p:t})}chainRemoveTail(e,t){this.push("chain_rem_tail",{index:e,p:t})}chainNew(e,t){this.push("chain_new",{p1:e,p2:t})}chainMatch(e){this.push("chain_match",{index:e})}chainClose(e){this.push("chain_close",{index:e})}chainAddHead(e,t){this.push("chain_add_head",{index:e,p:t})}chainAddTail(e,t){this.push("chain_add_tail",{index:e,p:t})}chainConnect(e,t){this.push("chain_con",{index1:e,index2:t})}chainReverse(e){this.push("chain_rev",{index:e})}chainJoin(e,t){this.push("chain_join",{index1:e,index2:t})}done(){this.push("done",null)}}class Ps{constructor(e){this.log=null,this.geo=e}buildLog(e){var t;return this.log=e?new wu:null,(t=this.log)===null||t===void 0?void 0:t.list}segments(e){const t=new Fs(!0,this.geo,this.log);for(const r of e.regions)t.addRegion(r);return{segments:t.calculate(e.inverted,!1),inverted:e.inverted}}combine(e,t){const r=new Fs(!1,this.geo,this.log);for(const i of e.segments)r.addSegment(new nt(i.start,i.end,i,this.log),!0);for(const i of t.segments)r.addSegment(new nt(i.start,i.end,i,this.log),!1);return{combined:r.calculate(e.inverted,t.inverted),inverted1:e.inverted,inverted2:t.inverted}}selectUnion(e){return{segments:Bt.union(e.combined,this.log),inverted:e.inverted1||e.inverted2}}selectIntersect(e){return{segments:Bt.intersect(e.combined,this.log),inverted:e.inverted1&&e.inverted2}}selectDifference(e){return{segments:Bt.difference(e.combined,this.log),inverted:e.inverted1&&!e.inverted2}}selectDifferenceRev(e){return{segments:Bt.differenceRev(e.combined,this.log),inverted:!e.inverted1&&e.inverted2}}selectXor(e){return{segments:Bt.xor(e.combined,this.log),inverted:e.inverted1!==e.inverted2}}polygon(e){return{regions:Su(e.segments,this.geo,this.log),inverted:e.inverted}}union(e,t){const r=this.segments(e),i=this.segments(t),s=this.combine(r,i),o=this.selectUnion(s);return this.polygon(o)}intersect(e,t){const r=this.segments(e),i=this.segments(t),s=this.combine(r,i),o=this.selectIntersect(s);return this.polygon(o)}difference(e,t){const r=this.segments(e),i=this.segments(t),s=this.combine(r,i),o=this.selectDifference(s);return this.polygon(o)}differenceRev(e,t){const r=this.segments(e),i=this.segments(t),s=this.combine(r,i),o=this.selectDifferenceRev(s);return this.polygon(o)}xor(e,t){const r=this.segments(e),i=this.segments(t),s=this.combine(r,i),o=this.selectXor(s);return this.polygon(o)}}new Ps(new Ds);class tn extends g.Object3D{static flattenObject(e){const t=[];function r(s){s.position.set(0,0,0),s.rotation.set(0,0,0),s.scale.set(1,1,1),s.matrix.identity()}function i(s,o){const a=[...s.children];for(const c of a)c.applyMatrix4(o),r(c),c.children.length>0?i(c,c.matrixWorld):t.push(c);s.children=[]}e.updateMatrixWorld(!0),i(e,e.matrixWorld);for(const s of t)"geometry"in s&&(s.geometry.applyMatrix4(s.matrixWorld),s.matrixWorld.identity(),s.matrixWorldNeedsUpdate=!1,e.add(s));r(e),e.matrixWorld.identity(),e.matrixWorldNeedsUpdate=!1}static disposeObject(e,t=!0){t&&e.removeFromParent(),(e instanceof g.Mesh||e instanceof g.Line||e instanceof g.Points)&&e.geometry&&e.geometry.dispose(),(e instanceof g.Mesh||e instanceof g.Line||e instanceof g.Points)&&(Array.isArray(e.material)?e.material:[e.material]).forEach(r=>{var i,s,o,a,c,l,h,d;r.dispose(),(i=r.map)==null||i.dispose(),(s=r.envMap)==null||s.dispose(),(o=r.lightMap)==null||o.dispose(),(a=r.bumpMap)==null||a.dispose(),(c=r.normalMap)==null||c.dispose(),(l=r.roughnessMap)==null||l.dispose(),(h=r.metalnessMap)==null||h.dispose(),(d=r.alphaMap)==null||d.dispose()}),e.children.forEach(r=>this.disposeObject(r)),"geometry"in e&&(e.geometry=null),"material"in e&&(e.material=null),e.children=[]}flatten(){tn.flattenObject(this)}dispose(){tn.disposeObject(this)}}const Se=[.5,0,0,.48429158056431554,-.1243449435824274,0,.4381533400219318,-.24087683705085766,0,.3644843137107058,-.3422735529643443,0,.2679133974894983,-.42216396275100754,0,.15450849718747373,-.47552825814757677,0,.03139525976465676,-.4990133642141358,0,-.09369065729286241,-.4911436253643443,0,-.21288964578253636,-.45241352623300973,0,-.3187119948743449,-.3852566213878946,0,-.40450849718747367,-.2938926261462366,0,-.4648882429441257,-.18406227634233907,0,-.4960573506572389,-.06266661678215227,0,-.49605735065723894,.06266661678215214,0,-.4648882429441256,.18406227634233915,0,-.4045084971874738,.2938926261462365,0,-.31871199487434476,.3852566213878947,0,-.21288964578253608,.4524135262330099,0,-.09369065729286231,.49114362536434436,0,.031395259764656416,.4990133642141358,0,.15450849718747361,.4755282581475768,0,.267913397489498,.42216396275100776,0,.3644843137107056,.3422735529643445,0,.4381533400219318,.24087683705085766,0,.4842915805643155,.12434494358242767,0,.5,0,0],we=[0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25],_u=new Map([[2,{position:new Float32Array([-1,0,0,1,0,0,0,-1,0,0,1,0]),indices:new Uint16Array([0,1,2,3])}],[3,{position:new Float32Array([-Math.SQRT1_2,Math.SQRT1_2,0,Math.SQRT1_2,-Math.SQRT1_2,0,-Math.SQRT1_2,-Math.SQRT1_2,0,Math.SQRT1_2,Math.SQRT1_2,0]),indices:new Uint16Array([0,1,2,3])}],[4,{position:new Float32Array([0,0,0,0,.5,0]),indices:new Uint16Array([0,1,2,3])}],[32,{position:new Float32Array(Se),indices:new Uint16Array(we)}],[33,{position:new Float32Array(Se),indices:new Uint16Array(we)}],[34,{position:new Float32Array([...Se,-1,0,0,1,0,0,0,-1,0,0,1,0]),indices:new Uint16Array([...we,26,27,28,29])}],[35,{position:new Float32Array([...Se,-Math.SQRT1_2,Math.SQRT1_2,0,Math.SQRT1_2,-Math.SQRT1_2,0,-Math.SQRT1_2,-Math.SQRT1_2,0,Math.SQRT1_2,Math.SQRT1_2,0]),indices:new Uint16Array([...we,26,27,28,29])}],[36,{position:new Float32Array([...Se,0,0,0,0,.5,0]),indices:new Uint16Array([...we,26,27])}],[64,{position:new Float32Array([-.5,.5,0,.5,.5,0,.5,-.5,0,-.5,-.5,0,-.5,.5,0]),indices:new Uint16Array([0,1,1,2,2,3,3,4])}],[65,{position:new Float32Array([-.5,.5,0,.5,.5,0,.5,-.5,0,-.5,-.5,0,-.5,.5,0]),indices:new Uint16Array([0,1,1,2,2,3,3,4])}],[66,{position:new Float32Array([-.5,.5,0,.5,.5,0,.5,-.5,0,-.5,-.5,0,-.5,.5,0,-1,0,0,1,0,0,0,-1,0,0,1,0]),indices:new Uint16Array([0,1,1,2,2,3,3,4,5,6,7,8])}],[67,{position:new Float32Array([-.5,.5,0,.5,.5,0,.5,-.5,0,-.5,-.5,0,-Math.SQRT1_2,Math.SQRT1_2,0,Math.SQRT1_2,-Math.SQRT1_2,0,-Math.SQRT1_2,-Math.SQRT1_2,0,Math.SQRT1_2,Math.SQRT1_2,0]),indices:new Uint16Array([0,1,1,2,2,3,3,0,4,5,6,7])}],[68,{position:new Float32Array([-.5,.5,0,.5,.5,0,.5,-.5,0,-.5,-.5,0,-.5,.5,0,0,0,0,0,.5,0]),indices:new Uint16Array([0,1,1,2,2,3,3,4,5,6])}],[96,{position:new Float32Array([...Se,-.5,.5,0,.5,.5,0,.5,-.5,0,-.5,-.5,0]),indices:new Uint16Array([...we,26,27,27,28,28,29,29,26])}],[97,{position:new Float32Array([...Se,-.5,.5,0,.5,.5,0,.5,-.5,0,-.5,-.5,0,-.5,.5,0]),indices:new Uint16Array([...we,26,27,27,28,28,29,29,30])}],[98,{position:new Float32Array([...Se,-.5,.5,0,.5,.5,0,.5,-.5,0,-.5,-.5,0,-.5,.5,0,-1,0,0,1,0,0,0,-1,0,0,1,0]),indices:new Uint16Array([...we,26,27,27,28,28,29,29,30,31,32,33,34])}],[99,{position:new Float32Array([...Se,-.5,.5,0,.5,.5,0,.5,-.5,0,-.5,-.5,0,-Math.SQRT1_2,Math.SQRT1_2,0,Math.SQRT1_2,-Math.SQRT1_2,0,-Math.SQRT1_2,-Math.SQRT1_2,0,Math.SQRT1_2,Math.SQRT1_2,0]),indices:new Uint16Array([...we,26,27,27,28,28,29,29,26,30,31,32,33])}],[100,{position:new Float32Array([...Se,-.5,.5,0,.5,.5,0,.5,-.5,0,-.5,-.5,0,-.5,.5,0,0,0,0,0,.5,0]),indices:new Uint16Array([...we,26,27,27,28,28,29,29,30,31,32])}]]);class Ge{constructor(){this._symbols=this.initialize()}static get instance(){return Ge._instance||(Ge._instance=new Ge),Ge._instance}isShowPoint(e=null){return e==null||e==0||e==32||e==64||e==96}create(e=null,t={x:0,y:0,z:0}){const r={};if(e==null||e==0)Lt.copy(t),r.point=new g.BufferGeometry().setFromPoints([Lt]);else if(e!=1){const i=this._symbols.get(e);if(i==null)throw new Error(`[AcTrPointSymbolCreator] Invalid point type value: '${e}'!`);Lt.copy(t),Gs.identity().makeTranslation(Lt),r.line=i.clone().applyMatrix4(Gs),(e==32||e==64||e==96)&&(r.point=new g.BufferGeometry().setFromPoints([Lt]))}return r}initialize(){const e=new Map;return _u.forEach((t,r)=>{const i=new g.BufferGeometry;i.setAttribute("position",new g.BufferAttribute(t.position,3)),i.setIndex(new g.BufferAttribute(t.indices,1)),e.set(r,i)}),e}}const Gs=new g.Matrix4,Lt=new g.Vector3,Tu=new g.Color(583902);class nn{static cloneMaterial(e){if(!e)return e;if(Array.isArray(e)){const t=[];return e.forEach(r=>{t.push(r.clone())}),t}return e.clone()}static setMaterialColor(e,t=Tu){if(Array.isArray(e)){e.forEach(r=>this.setMaterialColor(r,t));return}this.hasColorProperty(e)&&(e.color.set(t),this.hasEmissiveProperty(e)&&e.emissive.set(t)),this.hasUniformsProperty(e)&&e.uniforms.u_color&&e.uniforms.u_color.value.set(t)}static hasColorProperty(e){return"color"in e&&e.color instanceof g.Color}static hasEmissiveProperty(e){return"emissive"in e&&e.emissive instanceof g.Color}static hasUniformsProperty(e){return"uniforms"in e&&e.uniforms!==void 0}}class Ot{static getExtension(e){return e.substring(e.lastIndexOf(".")+1)}static estimateObjectSize(e){const t=new WeakSet;function r(i){if(i==null)return 0;const s=typeof i;if(s==="boolean")return 4;if(s==="number")return 8;if(s==="string")return i.length*2;if(s==="symbol"||s==="function"||t.has(i))return 0;if(t.add(i),Array.isArray(i))return i.map(r).reduce((o,a)=>o+a,0);if(s==="object"){let o=0;for(const a in i)Object.prototype.hasOwnProperty.call(i,a)&&(o+=a.length*2,o+=r(i[a]));return o}return 0}return r(e)}static getFileName(e){return e.split("/").pop()}static getFileNameWithoutExtension(e){const t=Ot.getFileName(e);if(t){const r=t.lastIndexOf(".");return r===-1?t:t.substring(0,r)}return e}}function dr(n,e){return n-e}function pr(n,e,t=0){const r=e.itemSize;if(n.isInterleavedBufferAttribute||n.array.constructor!==e.array.constructor){const i=n.count;for(let s=0;s<i;s++)for(let o=0;o<r;o++)e.setComponent(s+t,o,n.getComponent(s,o))}else e.array.set(n.array,t*r);e.needsUpdate=!0}function rt(n,e){if(n.constructor!==e.constructor){const t=Math.min(n.length,e.length);for(let r=0;r<t;r++)e[r]=n[r]}else{const t=Math.min(n.length,e.length);e.set(new n.constructor(n.buffer,0,t))}}const Ns=new g.Box3,it=new g.Vector3,st=new g.LineSegments,rn=[];class Cu extends g.LineSegments{constructor(e=1e3,t=e*2,r){super(new g.BufferGeometry,r),this.boundingBox=null,this.boundingSphere=null,this._geometryInfo=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._geometryInitialized=!1,this.frustumCulled=!1,this._maxVertexCount=e,this._maxIndexCount=t}get geometryCount(){return this._geometryCount}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}get mappingStats(){const e=this._geometryInfo.length;let t=0;return e>0&&(t=Ot.estimateObjectSize(this._geometryInfo[0])),{count:e,size:e*t}}_initializeGeometry(e){const t=this.geometry,r=this._maxVertexCount,i=this._maxIndexCount;if(this._geometryInitialized===!1){for(const s in e.attributes){const o=e.getAttribute(s),{array:a,itemSize:c,normalized:l}=o,h=new a.constructor(r*c),d=new g.BufferAttribute(h,c,l);t.setAttribute(s,d)}if(e.getIndex()!==null){const s=r>65535?new Uint32Array(i):new Uint16Array(i);t.setIndex(new g.BufferAttribute(s,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('AcTrBatchedLine: All geometries must consistently have "index".');for(const r in t.attributes){if(!e.hasAttribute(r))throw new Error(`AcTrBatchedLine: Added geometry missing "${r}". All geometries must have consistent attributes.`);const i=e.getAttribute(r),s=t.getAttribute(r);if(i.itemSize!==s.itemSize||i.normalized!==s.normalized)throw new Error("AcTrBatchedLine: All attributes must have a consistent itemSize and normalized value.")}}_resizeSpaceIfNeeded(e){const t=e.getIndex(),r=t!==null;let i=this._maxIndexCount;r&&this.unusedIndexCount<t.count&&(i=(this._maxIndexCount+t.count)*1.5);const s=e.getAttribute("position");let o=this._maxVertexCount;s&&this.unusedVertexCount<s.count&&(o=(this._maxVertexCount+s.count)*1.5),(i>this._maxIndexCount||o>this._maxVertexCount)&&this.setGeometrySize(o,i)}validateGeometryId(e){const t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`AcTrBatchedLine: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}reset(){this.boundingBox=null,this.boundingSphere=null,this._geometryInfo=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._geometryInfo.length=0,this._geometryInitialized=!1,this.geometry.dispose()}getUserData(){const e=[];return this._geometryInfo.forEach(t=>{e.push({position:t.position,objectId:t.objectId,bboxIntersectionCheck:t.bboxIntersectionCheck})}),e}resetGeometry(e){const t=this.getUserData();this.reset();const r=Ge.instance;t.forEach(i=>{if(i.position){const s=r.create(e,i.position);if(s.line){const o=this.addGeometry(s.line);this.setGeometryInfo(o,i)}}})}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new g.Box3);const e=this.boundingBox,t=this._geometryInfo;e.makeEmpty();for(let r=0,i=t.length;r<i;r++){const s=t[r];s.active!==!1&&s.boundingBox!=null&&e.union(s.boundingBox)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new g.Sphere);const e=this.boundingSphere,t=this._geometryInfo;e.makeEmpty();for(let r=0,i=t.length;r<i;r++){const s=t[r];s.active!==!1&&s.boundingSphere!=null&&e.union(s.boundingSphere)}}addGeometry(e,t=-1,r=-1){this._initializeGeometry(e),this._validateGeometry(e),e.boundingBox==null&&e.computeBoundingBox(),e.boundingSphere==null&&e.computeBoundingSphere(),this._resizeSpaceIfNeeded(e);const i={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:e.boundingBox,boundingSphere:e.boundingSphere,active:!0,visible:!0},s=this._geometryInfo;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const o=e.getIndex();if(o!==null&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=r===-1?o.count:r),i.indexStart!==-1&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("AcTrBatchedLine: Reserved space request exceeds the maximum buffer size.");let a;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(dr),a=this._availableGeometryIds.shift(),s[a]=i):(a=this._geometryCount,this._geometryCount++,s.push(i)),this.setGeometryAt(a,e),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,a}setGeometryInfo(e,t){if(e>=this._geometryCount)throw new Error("AcTrBatchedLine: Maximum geometry count reached.");const r=this._geometryInfo[e],i=t.position;i&&(r.position={...i}),r.objectId=t.objectId,r.bboxIntersectionCheck=t.bboxIntersectionCheck}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("AcTrBatchedLine: Maximum geometry count reached.");this._validateGeometry(t);const r=this.geometry,i=r.getIndex()!==null,s=r.getIndex(),o=t.getIndex(),a=this._geometryInfo[e];if(i&&o.count>a.reservedIndexCount||t.attributes.position.count>a.reservedVertexCount)throw new Error("AcTrBatchedLine: Reserved space not large enough for provided geometry.");const c=a.vertexStart,l=a.reservedVertexCount;a.vertexCount=t.getAttribute("position").count;for(const h in r.attributes){const d=t.getAttribute(h),u=r.getAttribute(h);pr(d,u,c);const p=d.itemSize;for(let f=d.count,m=l;f<m;f++){const y=c+f;for(let v=0;v<p;v++)u.setComponent(y,v,0)}u.needsUpdate=!0,u.addUpdateRange(c*p,l*p)}if(i&&s){const h=a.indexStart,d=a.reservedIndexCount;a.indexCount=t.getIndex().count;for(let u=0;u<o.count;u++)s.setX(h+u,c+o.getX(u));for(let u=o.count,p=d;u<p;u++)s.setX(h+u,c);s.needsUpdate=!0,s.addUpdateRange(h,a.reservedIndexCount)}return a.start=i?a.indexStart:a.vertexStart,a.count=i?a.indexCount:a.vertexCount,a.boundingBox=null,t.boundingBox!==null&&(a.boundingBox=t.boundingBox.clone()),a.boundingSphere=null,t.boundingSphere!==null&&(a.boundingSphere=t.boundingSphere.clone()),e}deleteGeometry(e){const t=this._geometryInfo;return e>=t.length||t[e].active===!1?this:(t[e].active=!1,this._availableGeometryIds.push(e),this)}optimize(){let e=0,t=0;const r=this._geometryInfo,i=r.map((o,a)=>a).sort((o,a)=>r[o].vertexStart-r[a].vertexStart),s=this.geometry;for(let o=0,a=r.length;o<a;o++){const c=i[o],l=r[c];if(l.active!==!1){if(s.index!==null){if(l.indexStart!==t){const{indexStart:h,vertexStart:d,reservedIndexCount:u}=l,p=s.index,f=p.array,m=e-d;for(let y=h;y<h+u;y++)f[y]=f[y]+m;p.array.copyWithin(t,h,h+u),p.addUpdateRange(t,u),l.indexStart=t}t+=l.reservedIndexCount}if(l.vertexStart!==e){const{vertexStart:h,reservedVertexCount:d}=l,u=s.attributes;for(const p in u){const f=u[p],{array:m,itemSize:y}=f;m.copyWithin(e*y,h*y,(h+d)*y),f.addUpdateRange(e*y,d*y)}l.vertexStart=e}e+=l.reservedVertexCount,l.start=s.index?l.indexStart:l.vertexStart,this._nextIndexStart=s.index?l.indexStart+l.reservedIndexCount:0,this._nextVertexStart=l.vertexStart+l.reservedVertexCount}}return this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const r=this.geometry,i=this._geometryInfo[e];if(i.boundingBox===null){const s=new g.Box3,o=r.index,a=r.attributes.position;for(let c=i.start,l=i.start+i.count;c<l;c++){let h=c;o&&(h=o.getX(h)),s.expandByPoint(it.fromBufferAttribute(a,h))}i.boundingBox=s}return t.copy(i.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const r=this.geometry,i=this._geometryInfo[e];if(i.boundingSphere===null){const s=new g.Sphere;this.getBoundingBoxAt(e,Ns),Ns.getCenter(s.center);const o=r.index,a=r.attributes.position;let c=0;for(let l=i.start,h=i.start+i.count;l<h;l++){let d=l;o&&(d=o.getX(d)),it.fromBufferAttribute(a,d),c=Math.max(c,s.center.distanceToSquared(it))}s.radius=Math.sqrt(c),i.boundingSphere=s}return t.copy(i.boundingSphere),t}setVisibleAt(e,t){return this.validateGeometryId(e),this._geometryInfo[e].visible===t?this:(this._geometryInfo[e].visible=t,this)}getVisibleAt(e){return this.validateGeometryId(e),this._geometryInfo[e].visible}getGeometryAt(e){return this.validateGeometryId(e),this._geometryInfo[e]}setGeometrySize(e,t){const r=this.geometry;r.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new g.BufferGeometry,this._initializeGeometry(r));const i=this.geometry;r.index&&rt(r.index.array,i.index.array);for(const s in r.attributes)rt(r.attributes[s].array,i.attributes[s].array)}getObjectAt(e){const t=new g.LineSegments;this._initializeRaycastObject(t);const r=this._geometryInfo[e];return this._setRaycastObjectInfo(t,e,r.start,r.count),t}_initializeRaycastObject(e){const t=this.geometry;return e.material=this.material,e.geometry.index=t.index,e.geometry.attributes=t.attributes,e.geometry.boundingBox===null&&(e.geometry.boundingBox=new g.Box3),e.geometry.boundingSphere===null&&(e.geometry.boundingSphere=new g.Sphere),e}_setRaycastObjectInfo(e,t,r,i){e.geometry.setDrawRange(r,i),this.getBoundingBoxAt(t,e.geometry.boundingBox),this.getBoundingSphereAt(t,e.geometry.boundingSphere)}_resetRaycastObjectInfo(e){e.geometry.index=null,e.geometry.attributes={},e.geometry.setDrawRange(0,1/0)}intersectWith(e,t,r){this._initializeRaycastObject(st),this._intersectWith(e,t,r),this._resetRaycastObjectInfo(st)}_intersectWith(e,t,r){const i=this._geometryInfo[e];if(!(!i.visible||!i.active))if(i.bboxIntersectionCheck){const s=i.boundingBox;if(t.ray.intersectBox(s,it)){const o=t.ray.origin.distanceTo(it);r.push({distance:o,point:it.clone(),object:this,face:null,faceIndex:void 0,uv:void 0,batchId:e,objectId:i.objectId})}}else{this._setRaycastObjectInfo(st,e,i.start,i.count),st.raycast(t,rn);for(let s=0,o=rn.length;s<o;s++){const a=rn[s];a.object=this,a.batchId=e,a.objectId=i.objectId,r.push(a)}rn.length=0}}raycast(e,t){const r=this._geometryInfo;this._initializeRaycastObject(st);for(let i=0,s=r.length;i<s;i++)this._intersectWith(i,e,t);this._resetRaycastObjectInfo(st)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._geometryInfo=e._geometryInfo.map(t=>({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this}dispose(){return this.geometry.dispose(),this}}const zs=new g.Box3,ot=new g.Vector3,at=new g.Mesh,sn=[];class Iu extends g.Mesh{constructor(e=1e3,t=e*2,r){super(new g.BufferGeometry,r),this.boundingBox=null,this.boundingSphere=null,this._geometryInfo=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._geometryInitialized=!1,this.frustumCulled=!1,this._maxVertexCount=e,this._maxIndexCount=t}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}get mappingStats(){const e=this._geometryInfo.length;let t=0;return e>0&&(t=Ot.estimateObjectSize(this._geometryInfo[0])),{count:e,size:e*t}}_initializeGeometry(e){const t=this.geometry,r=this._maxVertexCount,i=this._maxIndexCount;if(this._geometryInitialized===!1){for(const s in e.attributes){const o=e.getAttribute(s),{array:a,itemSize:c,normalized:l}=o,h=new a.constructor(r*c),d=new g.BufferAttribute(h,c,l);t.setAttribute(s,d)}if(e.getIndex()!==null){const s=r>65535?new Uint32Array(i):new Uint16Array(i);t.setIndex(new g.BufferAttribute(s,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('AcTrBatchedMesh: All geometries must consistently have "index".');for(const r in t.attributes){if(!e.hasAttribute(r))throw new Error(`AcTrBatchedMesh: Added geometry missing "${r}". All geometries must have consistent attributes.`);const i=e.getAttribute(r),s=t.getAttribute(r);if(i.itemSize!==s.itemSize||i.normalized!==s.normalized)throw new Error("AcTrBatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}_resizeSpaceIfNeeded(e){const t=e.getIndex(),r=t!==null;let i=this._maxIndexCount;r&&this.unusedIndexCount<t.count&&(i=(this._maxIndexCount+t.count)*1.5);const s=e.getAttribute("position");let o=this._maxVertexCount;s&&this.unusedVertexCount<s.count&&(o=(this._maxVertexCount+s.count)*1.5),(i>this._maxIndexCount||o>this._maxVertexCount)&&this.setGeometrySize(o,i)}validateGeometryId(e){const t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`AcTrBatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new g.Box3);const e=this.boundingBox,t=this._geometryInfo;e.makeEmpty();for(let r=0,i=t.length;r<i;r++){const s=t[r];s.active!==!1&&s.boundingBox!=null&&e.union(s.boundingBox)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new g.Sphere);const e=this.boundingSphere,t=this._geometryInfo;e.makeEmpty();for(let r=0,i=t.length;r<i;r++){const s=t[r];s.active!==!1&&s.boundingSphere!=null&&e.union(s.boundingSphere)}}addGeometry(e,t=-1,r=-1){this._initializeGeometry(e),this._validateGeometry(e),e.boundingBox==null&&e.computeBoundingBox(),e.boundingSphere==null&&e.computeBoundingSphere(),this._resizeSpaceIfNeeded(e);const i={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:e.boundingBox,boundingSphere:e.boundingSphere,active:!0,visible:!0},s=this._geometryInfo;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const o=e.getIndex();if(o!==null&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=r===-1?o.count:r),i.indexStart!==-1&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("AcTrBatchedMesh: Reserved space request exceeds the maximum buffer size.");let a;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(dr),a=this._availableGeometryIds.shift(),s[a]=i):(a=this._geometryCount,this._geometryCount++,s.push(i)),this.setGeometryAt(a,e),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,a}setGeometryInfo(e,t){if(e>=this._geometryCount)throw new Error("AcTrBatchedMesh: Maximum geometry count reached.");const r=this._geometryInfo[e];r.objectId=t.objectId,r.bboxIntersectionCheck=t.bboxIntersectionCheck}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("AcTrBatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const r=this.geometry,i=r.getIndex()!==null,s=r.getIndex(),o=t.getIndex(),a=this._geometryInfo[e];if(i&&o.count>a.reservedIndexCount||t.attributes.position.count>a.reservedVertexCount)throw new Error("AcTrBatchedMesh: Reserved space not large enough for provided geometry.");const c=a.vertexStart,l=a.reservedVertexCount;a.vertexCount=t.getAttribute("position").count;for(const h in r.attributes){const d=t.getAttribute(h),u=r.getAttribute(h);pr(d,u,c);const p=d.itemSize;for(let f=d.count,m=l;f<m;f++){const y=c+f;for(let v=0;v<p;v++)u.setComponent(y,v,0)}u.needsUpdate=!0,u.addUpdateRange(c*p,l*p)}if(i&&s){const h=a.indexStart,d=a.reservedIndexCount;a.indexCount=t.getIndex().count;for(let u=0;u<o.count;u++)s.setX(h+u,c+o.getX(u));for(let u=o.count,p=d;u<p;u++)s.setX(h+u,c);s.needsUpdate=!0,s.addUpdateRange(h,a.reservedIndexCount)}return a.start=i?a.indexStart:a.vertexStart,a.count=i?a.indexCount:a.vertexCount,a.boundingBox=null,t.boundingBox!==null&&(a.boundingBox=t.boundingBox.clone()),a.boundingSphere=null,t.boundingSphere!==null&&(a.boundingSphere=t.boundingSphere.clone()),e}deleteGeometry(e){const t=this._geometryInfo;return e>=t.length||t[e].active===!1?this:(t[e].active=!1,this._availableGeometryIds.push(e),this)}optimize(){let e=0,t=0;const r=this._geometryInfo,i=r.map((o,a)=>a).sort((o,a)=>r[o].vertexStart-r[a].vertexStart),s=this.geometry;for(let o=0,a=r.length;o<a;o++){const c=i[o],l=r[c];if(l.active!==!1){if(s.index!==null){if(l.indexStart!==t){const{indexStart:h,vertexStart:d,reservedIndexCount:u}=l,p=s.index,f=p.array,m=e-d;for(let y=h;y<h+u;y++)f[y]=f[y]+m;p.array.copyWithin(t,h,h+u),p.addUpdateRange(t,u),l.indexStart=t}t+=l.reservedIndexCount}if(l.vertexStart!==e){const{vertexStart:h,reservedVertexCount:d}=l,u=s.attributes;for(const p in u){const f=u[p],{array:m,itemSize:y}=f;m.copyWithin(e*y,h*y,(h+d)*y),f.addUpdateRange(e*y,d*y)}l.vertexStart=e}e+=l.reservedVertexCount,l.start=s.index?l.indexStart:l.vertexStart,this._nextIndexStart=s.index?l.indexStart+l.reservedIndexCount:0,this._nextVertexStart=l.vertexStart+l.reservedVertexCount}}return this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const r=this.geometry,i=this._geometryInfo[e];if(i.boundingBox===null){const s=new g.Box3,o=r.index,a=r.attributes.position;for(let c=i.start,l=i.start+i.count;c<l;c++){let h=c;o&&(h=o.getX(h)),s.expandByPoint(ot.fromBufferAttribute(a,h))}i.boundingBox=s}return t.copy(i.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const r=this.geometry,i=this._geometryInfo[e];if(i.boundingSphere===null){const s=new g.Sphere;this.getBoundingBoxAt(e,zs),zs.getCenter(s.center);const o=r.index,a=r.attributes.position;let c=0;for(let l=i.start,h=i.start+i.count;l<h;l++){let d=l;o&&(d=o.getX(d)),ot.fromBufferAttribute(a,d),c=Math.max(c,s.center.distanceToSquared(ot))}s.radius=Math.sqrt(c),i.boundingSphere=s}return t.copy(i.boundingSphere),t}setVisibleAt(e,t){return this.validateGeometryId(e),this._geometryInfo[e].visible===t?this:(this._geometryInfo[e].visible=t,this)}getVisibleAt(e){return this.validateGeometryId(e),this._geometryInfo[e].visible}getGeometryRangeAt(e){return this.validateGeometryId(e),this._geometryInfo[e]}setGeometrySize(e,t){const r=this.geometry;r.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new g.BufferGeometry,this._initializeGeometry(r));const i=this.geometry;r.index&&rt(r.index.array,i.index.array);for(const s in r.attributes)rt(r.attributes[s].array,i.attributes[s].array)}getObjectAt(e){const t=new g.Mesh;this._initializeRaycastObject(t);const r=this._geometryInfo[e];return this._setRaycastObjectInfo(t,e,r.start,r.count),t}_initializeRaycastObject(e){const t=this.geometry;return e.material=this.material,e.geometry.index=t.index,e.geometry.attributes=t.attributes,e.geometry.boundingBox===null&&(e.geometry.boundingBox=new g.Box3),e.geometry.boundingSphere===null&&(e.geometry.boundingSphere=new g.Sphere),e}_setRaycastObjectInfo(e,t,r,i){e.geometry.setDrawRange(r,i),this.getBoundingBoxAt(t,e.geometry.boundingBox),this.getBoundingSphereAt(t,e.geometry.boundingSphere)}_resetRaycastObjectInfo(e){e.geometry.index=null,e.geometry.attributes={},e.geometry.setDrawRange(0,1/0)}intersectWith(e,t,r){this._initializeRaycastObject(at),this._intersectWith(e,t,r),this._resetRaycastObjectInfo(at)}_intersectWith(e,t,r){const i=this._geometryInfo[e];if(!(!i.visible||!i.active))if(i.bboxIntersectionCheck){const s=i.boundingBox;if(t.ray.intersectBox(s,ot)){const o=t.ray.origin.distanceTo(ot);r.push({distance:o,point:ot.clone(),object:this,face:null,faceIndex:void 0,uv:void 0,batchId:e,objectId:i.objectId})}}else{this._setRaycastObjectInfo(at,e,i.start,i.count),at.raycast(t,sn);for(let s=0,o=sn.length;s<o;s++){const a=sn[s];a.object=this,a.batchId=e,a.objectId=i.objectId,r.push(a)}sn.length=0}}raycast(e,t){const r=this._geometryInfo;this._initializeRaycastObject(at);for(let i=0,s=r.length;i<s;i++)this._intersectWith(i,e,t);this._resetRaycastObjectInfo(at)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._geometryInfo=e._geometryInfo.map(t=>({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this}dispose(){return this.geometry.dispose(),this}}const Vs=new g.Box3,ct=new g.Vector3,lt=new g.Points,on=[];class Au extends g.Points{constructor(e=1e3,t){super(new g.BufferGeometry,t),this.boundingBox=null,this.boundingSphere=null,this._geometryInfo=[],this._availableGeometryIds=[],this._nextVertexStart=0,this._geometryCount=0,this._geometryInitialized=!1,this.frustumCulled=!1,this._maxVertexCount=e}get geometryCount(){return this._geometryCount}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get mappingStats(){const e=this._geometryInfo.length;let t=0;return e>0&&(t=Ot.estimateObjectSize(this._geometryInfo[0])),{count:e,size:e*t}}_initializeGeometry(e){const t=this.geometry,r=this._maxVertexCount;if(this._geometryInitialized===!1){for(const i in e.attributes){const s=e.getAttribute(i),{array:o,itemSize:a,normalized:c}=s,l=new o.constructor(r*a),h=new g.BufferAttribute(l,a,c);t.setAttribute(i,h)}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;for(const r in t.attributes){if(!e.hasAttribute(r))throw new Error(`AcTrBatchedLine: Added geometry missing "${r}". All geometries must have consistent attributes.`);const i=e.getAttribute(r),s=t.getAttribute(r);if(i.itemSize!==s.itemSize||i.normalized!==s.normalized)throw new Error("AcTrBatchedLine: All attributes must have a consistent itemSize and normalized value.")}}_resizeSpaceIfNeeded(e){const t=e.getAttribute("position");let r=this._maxVertexCount;t&&this.unusedVertexCount<t.count&&(r=(this._maxVertexCount+t.count)*1.5),r>this._maxVertexCount&&this.setGeometrySize(r)}validateGeometryId(e){const t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`AcTrBatchedLine: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}reset(){this.boundingBox=null,this.boundingSphere=null,this._geometryInfo=[],this._availableGeometryIds=[],this._nextVertexStart=0,this._geometryCount=0,this._geometryInfo.length=0,this._geometryInitialized=!1,this.geometry.dispose()}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new g.Box3);const e=this.boundingBox,t=this._geometryInfo;e.makeEmpty();for(let r=0,i=t.length;r<i;r++){const s=t[r];s.active!==!1&&s.boundingBox!=null&&e.union(s.boundingBox)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new g.Sphere);const e=this.boundingSphere,t=this._geometryInfo;e.makeEmpty();for(let r=0,i=t.length;r<i;r++){const s=t[r];s.active!==!1&&s.boundingSphere!=null&&e.union(s.boundingSphere)}}addGeometry(e,t=-1){this._initializeGeometry(e),this._validateGeometry(e),e.boundingBox==null&&e.computeBoundingBox(),e.boundingSphere==null&&e.computeBoundingSphere(),this._resizeSpaceIfNeeded(e);const r={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,boundingBox:e.boundingBox,boundingSphere:e.boundingSphere,active:!0,visible:!0},i=this._geometryInfo;r.vertexStart=this._nextVertexStart,r.reservedVertexCount=t===-1?e.getAttribute("position").count:t;let s;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(dr),s=this._availableGeometryIds.shift(),i[s]=r):(s=this._geometryCount,this._geometryCount++,i.push(r)),this.setGeometryAt(s,e),this._nextVertexStart=r.vertexStart+r.reservedVertexCount,this.geometry.setDrawRange(0,this._nextVertexStart),s}setGeometryInfo(e,t){if(e>=this._geometryCount)throw new Error("AcTrBatchedLine: Maximum geometry count reached.");const r=this._geometryInfo[e],i=t.position;i&&(r.position={...i}),r.objectId=t.objectId,r.bboxIntersectionCheck=t.bboxIntersectionCheck}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("AcTrBatchedLine: Maximum geometry count reached.");this._validateGeometry(t);const r=this.geometry,i=this._geometryInfo[e],s=i.vertexStart,o=i.reservedVertexCount;i.vertexCount=t.getAttribute("position").count;for(const a in r.attributes){const c=t.getAttribute(a),l=r.getAttribute(a);pr(c,l,s);const h=c.itemSize;for(let d=c.count,u=o;d<u;d++){const p=s+d;for(let f=0;f<h;f++)l.setComponent(p,f,0)}l.needsUpdate=!0,l.addUpdateRange(s*h,o*h)}return i.boundingBox=null,t.boundingBox!==null&&(i.boundingBox=t.boundingBox.clone()),i.boundingSphere=null,t.boundingSphere!==null&&(i.boundingSphere=t.boundingSphere.clone()),e}deleteGeometry(e){const t=this._geometryInfo;return e>=t.length||t[e].active===!1?this:(t[e].active=!1,this._availableGeometryIds.push(e),this)}optimize(){let e=0;const t=this._geometryInfo,r=t.map((s,o)=>o).sort((s,o)=>t[s].vertexStart-t[o].vertexStart),i=this.geometry;for(let s=0,o=t.length;s<o;s++){const a=r[s],c=t[a];if(c.active!==!1){if(c.vertexStart!==e){const{vertexStart:l,reservedVertexCount:h}=c,d=i.attributes;for(const u in d){const p=d[u],{array:f,itemSize:m}=p;f.copyWithin(e*m,l*m,(l+h)*m),p.addUpdateRange(e*m,h*m)}c.vertexStart=e}e+=c.reservedVertexCount,this._nextVertexStart=c.vertexStart+c.reservedVertexCount}}return this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const r=this.geometry,i=this._geometryInfo[e];if(i.boundingBox===null){const s=new g.Box3,o=r.index,a=r.attributes.position;for(let c=i.vertexStart,l=i.vertexStart+i.vertexCount;c<l;c++){let h=c;o&&(h=o.getX(h)),s.expandByPoint(ct.fromBufferAttribute(a,h))}i.boundingBox=s}return t.copy(i.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const r=this.geometry,i=this._geometryInfo[e];if(i.boundingSphere===null){const s=new g.Sphere;this.getBoundingBoxAt(e,Vs),Vs.getCenter(s.center);const o=r.index,a=r.attributes.position;let c=0;for(let l=i.vertexStart,h=i.vertexStart+i.vertexCount;l<h;l++){let d=l;o&&(d=o.getX(d)),ct.fromBufferAttribute(a,d),c=Math.max(c,s.center.distanceToSquared(ct))}s.radius=Math.sqrt(c),i.boundingSphere=s}return t.copy(i.boundingSphere),t}setVisibleAt(e,t){return this.validateGeometryId(e),this._geometryInfo[e].visible===t?this:(this._geometryInfo[e].visible=t,this)}getVisibleAt(e){return this.validateGeometryId(e),this._geometryInfo[e].visible}getGeometryAt(e){return this.validateGeometryId(e),this._geometryInfo[e]}setGeometrySize(e){const t=this.geometry;t.dispose(),this._maxVertexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new g.BufferGeometry,this._initializeGeometry(t));const r=this.geometry;t.index&&rt(t.index.array,r.index.array);for(const i in t.attributes)rt(t.attributes[i].array,r.attributes[i].array)}getObjectAt(e){const t=new g.Points;this._initializeRaycastObject(t);const r=this._geometryInfo[e];return this._setRaycastObjectInfo(t,e,r.vertexStart,r.vertexCount),t}_initializeRaycastObject(e){const t=this.geometry;return e.material=this.material,e.geometry.index=t.index,e.geometry.attributes=t.attributes,e.geometry.boundingBox===null&&(e.geometry.boundingBox=new g.Box3),e.geometry.boundingSphere===null&&(e.geometry.boundingSphere=new g.Sphere),e}_setRaycastObjectInfo(e,t,r,i){e.geometry.setDrawRange(r,i),this.getBoundingBoxAt(t,e.geometry.boundingBox),this.getBoundingSphereAt(t,e.geometry.boundingSphere)}_resetRaycastObjectInfo(e){e.geometry.index=null,e.geometry.attributes={},e.geometry.setDrawRange(0,1/0)}intersectWith(e,t,r){this._initializeRaycastObject(lt),this._intersectWith(e,t,r),this._resetRaycastObjectInfo(lt)}_intersectWith(e,t,r){const i=this._geometryInfo[e];if(!(!i.visible||!i.active))if(i.bboxIntersectionCheck){const s=i.boundingBox;if(t.ray.intersectBox(s,ct)){const o=t.ray.origin.distanceTo(ct);r.push({distance:o,point:ct.clone(),object:this,face:null,faceIndex:void 0,uv:void 0,batchId:e,objectId:i.objectId})}}else{this._setRaycastObjectInfo(lt,e,i.vertexStart,i.vertexCount),lt.raycast(t,on);for(let s=0,o=on.length;s<o;s++){const a=on[s];a.object=this,a.batchId=e,a.objectId=i.objectId,r.push(a)}on.length=0}}raycast(e,t){const r=this._geometryInfo;this._initializeRaycastObject(lt);for(let i=0,s=r.length;i<s;i++)this._intersectWith(i,e,t);this._resetRaycastObjectInfo(lt)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._geometryInfo=e._geometryInfo.map(t=>({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._maxVertexCount=e._maxVertexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this}dispose(){return this.geometry.dispose(),this}}class Eu extends g.Group{constructor(){super(),this._pointBatches=new Map,this._pointSymbolBatches=new Map,this._lineBatches=new Map,this._lineWithIndexBatches=new Map,this._meshBatches=new Map,this._meshWithIndexBatches=new Map,this._entitiesMap=new Map,this._selectedObjects=new g.Group,this._hoverObjects=new g.Group,this.add(this._selectedObjects),this.add(this._hoverObjects)}get entityCount(){return this._entitiesMap.size}get stats(){const e={summary:{entityCount:this._entitiesMap.size,totalGeometrySize:0,totalMappingSize:0},mesh:{indexed:{count:this._meshWithIndexBatches.size,geometrySize:this.getBatchedGeometrySize(this._meshWithIndexBatches),mappingSize:this.getBatchedGeometryMappingSize(this._meshWithIndexBatches)},nonIndexed:{count:this._meshBatches.size,geometrySize:this.getBatchedGeometrySize(this._meshBatches),mappingSize:this.getBatchedGeometryMappingSize(this._meshBatches)}},line:{indexed:{count:this._lineWithIndexBatches.size,geometrySize:this.getBatchedGeometrySize(this._lineWithIndexBatches),mappingSize:this.getBatchedGeometryMappingSize(this._lineWithIndexBatches)},nonIndexed:{count:this._lineBatches.size,geometrySize:this.getBatchedGeometrySize(this._lineBatches),mappingSize:this.getBatchedGeometryMappingSize(this._lineBatches)}},point:{indexed:{count:this._pointSymbolBatches.size,geometrySize:this.getBatchedGeometrySize(this._pointSymbolBatches),mappingSize:this.getBatchedGeometryMappingSize(this._pointSymbolBatches)},nonIndexed:{count:this._pointBatches.size,geometrySize:this.getBatchedGeometrySize(this._pointBatches),mappingSize:this.getBatchedGeometryMappingSize(this._pointBatches)}}};return e.summary.totalGeometrySize=e.line.indexed.geometrySize+e.line.nonIndexed.geometrySize+e.mesh.indexed.geometrySize+e.mesh.nonIndexed.geometrySize+e.point.indexed.geometrySize+e.point.nonIndexed.geometrySize,e.summary.totalMappingSize=e.line.indexed.mappingSize+e.line.nonIndexed.mappingSize+e.mesh.indexed.mappingSize+e.mesh.nonIndexed.mappingSize+e.point.indexed.mappingSize+e.point.nonIndexed.mappingSize,e}rerenderPoints(e){const t=Ge.instance.create(e);t.line&&this._pointSymbolBatches.forEach(i=>{i.resetGeometry(e)});const r=t.point!=null;this._pointBatches.forEach(i=>{i.visible=r})}clear(){return this.clearPoint(),this.clearLine(),this.clearMesh(),this}clearPoint(){this.clearBatch(this._pointBatches),this.clearBatch(this._pointSymbolBatches)}clearLine(){this.clearBatch(this._lineBatches),this.clearBatch(this._lineWithIndexBatches)}clearMesh(){this.clearBatch(this._meshBatches),this.clearBatch(this._meshWithIndexBatches)}hasEntity(e){return this._entitiesMap.has(e)}addEntity(e){const t=[];this._entitiesMap.set(e.objectId,t),e.updateMatrixWorld(!0),e.traverse(r=>{const i=!!r.userData.bboxIntersectionCheck;r instanceof g.LineSegments?t.push(this.addLine(r,{position:r.userData.position,objectId:e.objectId,bboxIntersectionCheck:i})):r instanceof g.Mesh?t.push(this.addMesh(r,{objectId:e.objectId,bboxIntersectionCheck:i})):r instanceof g.Points&&t.push(this.addPoint(r,{objectId:e.objectId,bboxIntersectionCheck:i}))})}isIntersectWith(e,t){const r=this._entitiesMap.get(e);if(r){const i=[];for(let s=0,o=r.length;s<o;s++){const a=r[s];if(this.getObjectById(a.batchedObjectId).intersectWith(a.batchId,t,i),i.length>0)return!0}}return!1}hover(e){this.highlight(e,this._hoverObjects)}unhover(e){this.unhighlight(e,this._hoverObjects)}select(e){this.highlight(e,this._selectedObjects)}unselect(e){this.unhighlight(e,this._selectedObjects)}highlight(e,t){const r=this._entitiesMap.get(e);r&&r.forEach(i=>{const s=this.getObjectById(i.batchedObjectId).getObjectAt(i.batchId),o=nn.cloneMaterial(s.material);nn.setMaterialColor(o),s.material=o,s.userData.objectId=e,t.add(s)})}unhighlight(e,t){const r=[];t.children.forEach(i=>{i.userData.objectId===e&&r.push(i)}),t.remove(...r)}addLine(e,t){const r=e.material,i=this.getMatchedLineBatches(e);let s=i.get(r.id);s==null&&(s=new Cu(1e3,2e3,r),i.set(r.id,s),this.add(s)),e.geometry.applyMatrix4(e.matrixWorld);const o=s.addGeometry(e.geometry);return s.setGeometryInfo(o,t),{batchedObjectId:s.id,batchId:o}}addMesh(e,t){const r=e.material,i=this.getMatchedMeshBatches(e);let s=i.get(r.id);s==null&&(s=new Iu(1e3,2e3,r),i.set(r.id,s),this.add(s)),e.geometry.applyMatrix4(e.matrixWorld);const o=s.addGeometry(e.geometry);return s.setGeometryInfo(o,t),{batchedObjectId:s.id,batchId:o}}addPoint(e,t){const r=e.material;let i=this._pointBatches.get(r.id);i==null&&(i=new Au(100,r),i.visible=e.visible,this._pointBatches.set(r.id,i),this.add(i)),e.geometry.applyMatrix4(e.matrixWorld);const s=i.addGeometry(e.geometry);return i.setGeometryInfo(s,t),{batchedObjectId:i.id,batchId:s}}getMatchedLineBatches(e){if(e.userData.isPoint)return this._pointSymbolBatches;{const t=e.geometry.getIndex()!==null;let r=this._lineBatches;return t&&(r=this._lineWithIndexBatches),r}}getMatchedMeshBatches(e){const t=e.geometry.getIndex()!==null;let r=this._meshBatches;return t&&(r=this._meshWithIndexBatches),r}clearBatch(e){e.forEach(t=>{t.dispose()}),e.clear()}getBatchedGeometrySize(e){let t=0;return e.forEach(r=>{t+=this.getGeometrySize(r)}),t}getBatchedGeometryMappingSize(e){let t=0;return e.forEach(r=>{t+=r.mappingStats.size}),t}getGeometrySize(e){let t=0;if("geometry"in e){const r=e.geometry;r.attributes.position&&(t+=r.attributes.position.array.byteLength),r.attributes.normal&&(t+=r.attributes.normal.array.byteLength),r.attributes.uv&&(t+=r.attributes.uv.array.byteLength),r.index&&(t+=r.index.array.byteLength)}return t}}class Hs extends tn{constructor(e){super(),this._styleManager=e}get styleManager(){return this._styleManager}copy(e,t){return this._styleManager=e._styleManager,super.copy(e,t)}}class me extends Hs{constructor(e){super(e),this._objectId="",this._ownerId="",this._layerName="",this._box=new g.Box3}get box(){return this._box}set box(e){this._box.copy(e)}get objectId(){return this._objectId}set objectId(e){this._objectId=e}get ownerId(){return this._ownerId}set ownerId(e){this._ownerId=e}get layerName(){return this._layerName}set layerName(e){this._layerName=e}applyMatrix(e){const t=e.elements,r=new g.Matrix4(t[0],t[4],t[8],t[12],t[1],t[5],t[9],t[13],t[2],t[6],t[10],t[14],t[3],t[7],t[11],t[15]);this.applyMatrix4(r),this.updateMatrixWorld(!0),this._box.applyMatrix4(r)}highlight(){this.highlightObject(this)}highlightObject(e){if("material"in e){const t=e.material;if(e.userData.originalMaterial==null){const r=nn.cloneMaterial(t);nn.setMaterialColor(r),e.userData.originalMaterial=e.material,e.material=r}}else e.children.length>0&&e.children.forEach(t=>{this.highlightObject(t)})}unhighlight(){this.unhighlightObject(this)}fastDeepClone(){const e=new me(this.styleManager);return e.copy(this,!1),this.copyGeometry(this,e),e}copy(e,t){return this.objectId=e.objectId,this.ownerId=e.ownerId,this.layerName=e.layerName,this.box=e.box,super.copy(e,t)}copyGeometry(e,t){for(let r=0;r<e.children.length;r++){const i=e.children[r].clone(!1);"geometry"in i&&(i.geometry=i.geometry.clone()),t.add(i)}}unhighlightObject(e){if("material"in e){const t=e.material;e.material=e.userData.originalMaterial,delete e.userData.originalMaterial,Array.isArray(t)?t.forEach(r=>r.dispose()):t instanceof g.Material&&t.dispose()}else e.children.length>0&&e.children.forEach(t=>{this.unhighlightObject(t)})}createColorArray(e,t){const r=(e>>16&255)/256,i=(e>>8&255)/256,s=(e&255)/256,o=new Float32Array(t*3);for(let a=0,c=0;a<t;a++)o[c]=r,o[c+1]=i,o[c+2]=s,c+=3;return o}}class ku extends me{constructor(e,t){super(t),e.forEach(r=>{if(Array.isArray(r)){const i=new me(t);this.add(i),this.box.union(i.box)}else this.add(r),this.box.union(r.box)}),this.flatten()}}class Bu extends me{constructor(e,t,r){super(r);const i=URL.createObjectURL(e),s=new g.TextureLoader().load(i);s.colorSpace=g.SRGBColorSpace;const o=new g.MeshBasicMaterial({side:g.DoubleSide,map:s}),a=new g.Shape(t.boundary),c=new g.ShapeGeometry(a);this.generateUVs(c);const l=new g.Mesh(c,o);this.add(l)}generateUVs(e){const t=e.attributes.position.array,r=new Float32Array(t.length/3*2),i=Math.min(...t.filter((h,d)=>d%3===0)),s=Math.max(...t.filter((h,d)=>d%3===0)),o=Math.min(...t.filter((h,d)=>d%3===1)),a=Math.max(...t.filter((h,d)=>d%3===1)),c=s-i,l=a-o;for(let h=0;h<t.length;h+=3){const d=t[h],u=t[h+1];r[h/3*2]=(d-i)/c,r[h/3*2+1]=(u-o)/l}e.setAttribute("uv",new g.BufferAttribute(r,2))}}const an=new g.Vector3,cn=new g.Vector3;class Mt{static release(e){e.index=null,e.attributes={}}static toNonIndexed(e){if(!e.index)return e;const t=new g.BufferGeometry,r=e.index;for(const i in e.attributes)t.setAttribute(i,Mt.createGeometryAttributeByIndex(e.attributes[i],r));return t}static createGeometryAttributeByIndex(e,t){const r=t.count,i=e.itemSize,s=e.array.constructor,o=new s(r*i);for(let a=0;a<r;a++){const c=t.getX(a)*i;for(let l=0;l<i;l++)o[a*i+l]=e.array[c+l]}return new g.BufferAttribute(o,i,e.normalized)}static tryConvertInterleavedBufferAttributes(e){!e||!e.attributes||Object.keys(e.attributes).forEach(t=>{const r=e.attributes[t];if(r instanceof g.InterleavedBufferAttribute){const i=r.clone();e.attributes[t]=i}})}static createBufferGeometryByPoints(e){const t=new g.BufferGeometry,r=new Float32Array(e.length*3),i=new Uint16Array((e.length-1)*2);return e.forEach((s,o)=>{let a=o*3;r[a]=s.x,r[a+1]=s.y,r[a+2]=s.z,o>0&&(a=(o-1)*2,i[a]=o-1,i[a+1]=o)}),t.setAttribute("position",new g.Float32BufferAttribute(r,3)),t.setIndex(new g.Uint16BufferAttribute(i,1)),t}static computeLineDistance(e){const t=e.isLineSegments===!0;let r=e.geometry;const i=e.matrixWorld;if(r.index&&(r=Mt.toNonIndexed(r)),r.index===null){const s=r.attributes.position;if(!s||s.count===0)return;const o=[];if(t)for(let a=0,c=s.count;a<c;a+=2)an.fromBufferAttribute(s,a).applyMatrix4(i),cn.fromBufferAttribute(s,a+1).applyMatrix4(i),o[a]=a===0?0:o[a-1],o[a+1]=o[a]+an.distanceTo(cn);else{o[0]=0;for(let a=1,c=s.count;a<c;a++)an.fromBufferAttribute(s,a-1).applyMatrix4(i),cn.fromBufferAttribute(s,a).applyMatrix4(i),o[a]=o[a-1],o[a]+=an.distanceTo(cn)}r.setAttribute("lineDistance",new g.Float32BufferAttribute(o,1)),e.geometry.dispose(),e.geometry=r}}static computeLineDistances(e){e.traverse(t=>{let r=t;r.isLine&&r.material instanceof g.ShaderMaterial&&this.computeLineDistance(r)})}static apply2dTransform(e,t,r=0,i=1){const s=e.attributes.position,o=s.itemSize,a=s.array;if(r!=0){const c=Math.cos(r),l=Math.sin(r);for(let h=0;h<a.length;h+=o){const d=a[h],u=a[h+1],p=d*c-u*l,f=d*l+u*c;a[h]=p*i+t.x,a[h+1]=f*i+t.y}}else for(let c=0;c<a.length;c+=o)a[c]=a[c]*i+t.x,a[c+1]+=a[c+1]*i+t.y;return s.needsUpdate=!0,e}static apply3dTransform(e,t,r){const i=e.attributes.position,s=i.itemSize,o=i.array,a=Math.cos(r.x),c=Math.sin(r.x),l=Math.cos(r.y),h=Math.sin(r.y),d=Math.cos(r.z),u=Math.sin(r.z);for(let p=0;p<o.length;p+=s){let f=o[p],m=o[p+1],y=o[p+2],v=m*a-y*c,_=m*c+y*a;m=v,y=_;let w=f*l+y*h;_=-f*h+y*l,f=w,y=_,w=f*d-m*u,v=f*u+m*d,f=w,m=v,o[p]=f+t.x,o[p+1]=m+t.y,o[p+2]=y+t.z}return i.needsUpdate=!0,e}}class Lu extends me{constructor(e,t,r){super(r);let i;const s=t?t.color:16777215;t?i=this.styleManager.getLineShaderMaterial(t,1):i=new g.LineBasicMaterial({color:s});const o=e.length,a=new Float32Array(o*3),c=o*2>65535?new Uint32Array(o*2):new Uint16Array(o*2);for(let d=0,u=0;d<o;d++){const p=e[d];a[u++]=p.x,a[u++]=p.y,a[u++]=p.z??0}for(let d=0,u=0;d<o-1;d++)c[u++]=d,c[u++]=d+1;const l=new g.BufferGeometry;l.setAttribute("position",new g.BufferAttribute(a,3)),l.setIndex(new g.BufferAttribute(c,1)),this.setBoundingBox(l),this.geometry=l;const h=new g.LineSegments(l,i);Mt.computeLineDistances(h),this.add(h)}setBoundingBox(e){e.computeBoundingBox(),this.box=e.boundingBox}}class Ou extends me{constructor(e,t,r,i,s){super(s);let o;i?o=this.styleManager.getLineShaderMaterial(i,1):o=new g.LineBasicMaterial({color:16777215});const a=new g.BufferGeometry;a.setAttribute("position",new g.BufferAttribute(e,t)),a.setIndex(new g.BufferAttribute(r,1)),a.computeBoundingBox(),this.box=a.boundingBox;const c=new g.LineSegments(a,o);Mt.computeLineDistances(c),this.add(c)}}class Mu extends me{constructor(e,t,r){super(r);try{this._mtext=new bu(e,t,r,fe.instance,{byLayerColor:t.byLayerColor,byBlockColor:t.byBlockColor}),this.add(this._mtext),this.flatten(),this.traverse(i=>{i.userData.bboxIntersectionCheck=!0})}catch(i){console.log(`Failed to render mtext '${e.text}' with the following error:
28
- `,i)}}raycast(e,t){var r;(r=this._mtext)==null||r.raycast(e,t)}getTextEncoding(e){return e!=null&&e.bigFont&&e.bigFont.toUpperCase().startsWith("GB")?"gbk":"utf8"}}const Du=new g.Vector3;class Ru extends me{constructor(e,t,r){super(r);const i=Ge.instance.create(t.displayMode,e);this.isShowPoint=i.point!=null;const s=i.point??new g.BufferGeometry().setFromPoints([Du.copy(e)]);s.computeBoundingBox(),s.boundingBox&&this.box.union(s.boundingBox);const o=this.styleManager.getPointsMaterial(t.color),a=new g.Points(s,o);if(a.userData.bboxIntersectionCheck=!0,a.visible=this.isShowPoint,this.add(a),i.line){const c=i.line;c.computeBoundingBox(),c.boundingBox&&this.box.union(c.boundingBox);const l=this.styleManager.getLineBasicMaterial(t.color),h=new g.LineSegments(c,l);h.userData.bboxIntersectionCheck=!0,h.userData.isPoint=!0,h.userData.position={x:e.x,y:e.y,z:e.z},this.add(h)}}}class Uu extends me{constructor(e,t,r){var i;super(r);const s=e.getPoints(100),o=e.buildHierarchy(),a=[];this.buildHatchGeometry(s,o,a);let c;if(a.length>0&&(c=eo.mergeGeometries(a)),!c||!c.getIndex()||((i=c.getIndex())==null?void 0:i.count)===0)console.warn("Failed to convert hatch boundaries!");else{c.computeBoundingBox(),this.box=c.boundingBox;const l=this.styleManager.getHatchShaderMaterial(t,new g.Vector2(0,0));this.add(new g.Mesh(c,l))}}buildHatchGeometry(e,t,r){if(t.children.length===0)return;const i=[],s=new Map;t.children.forEach(c=>{c.children.length===0?i.push(c.index):s.set(c.index,c.children.map(l=>l.index))});const o=c=>{try{const l=new g.ShapeGeometry(c);l.hasAttribute("uv")&&l.deleteAttribute("uv"),l.hasAttribute("normal")&&l.deleteAttribute("normal"),r.push(l)}catch{console.warn(`Triangulate shape error: ${c.getPoints().map(l=>l.toArray()).toString()}`)}};i.forEach(c=>{const l=e[c];if(l.length===0)return;const h=new g.Shape(l);o(h)});const a=c=>c.map(l=>l.toArray());for(const c of s){const l=new g.Shape(e[c[0]]);let h={regions:[],inverted:!1};const d=this.findIntersectHole(e,c[1]);d.forEach(p=>{let f={segments:[],inverted:!1},m=1e-6;try{p.forEach((y,v)=>{m=Math.min(e[y][0].relativeEps(),1e-6);const _=new Ps(new Ds(m));if(v===0)f=_.segments({regions:[a(e[y])],inverted:!1});else{const w=_.segments({regions:[a(e[y])],inverted:!1}),C=_.combine(f,w);h=_.polygon(_.selectUnion(C)),h.regions.length>0?h.regions.forEach(T=>{if(T.length===0)return;const D=T.map(I=>new g.Vector2(I[0],I[1]));l.holes.push(new g.Path(D))}):console.warn("mergedHoles.regions is empty!")}})}catch(y){console.warn(`Polybool error: ${y}, epsilon is ${m}`)}});const u=d.flat(2);for(let p=0;p<c[1].length;p++){const f=c[1][p];u.includes(f)||l.holes.push(new g.Path(e[f]))}o(l)}t.children.forEach(c=>{c.children.forEach(l=>{this.buildHatchGeometry(e,l,r)})})}findIntersectHole(e,t){const r=t.length,i=[];for(let s=0;s<r;s++){const o=e[t[s]];let a=!1;const c=[];for(let l=s+1;l<r;l++){const h=e[t[l]];S.AcGeGeometryUtil.isPolygonIntersect(o,h)&&(a=!0,c.push(t[l]))}a&&(c.push(t[s]),i.push(c))}return i}}function Fu(n,e,t,r,i=0){const s={u_cameraZoom:t,u_patternLines:{value:n},u_patternAngle:{value:e},u_color:{value:r}},o=`
28
+ `,i)}}raycast(e,t){var r;(r=this._mtext)==null||r.raycast(e,t)}getTextEncoding(e){return e!=null&&e.bigFont&&e.bigFont.toUpperCase().startsWith("GB")?"gbk":"utf8"}}const Du=new g.Vector3;class Ru extends me{constructor(e,t,r){super(r);const i=Ge.instance.create(t.displayMode,e);this.isShowPoint=i.point!=null;const s=i.point??new g.BufferGeometry().setFromPoints([Du.copy(e)]);s.computeBoundingBox(),s.boundingBox&&this.box.union(s.boundingBox);const o=this.styleManager.getPointsMaterial(t.color),a=new g.Points(s,o);if(a.userData.bboxIntersectionCheck=!0,a.visible=this.isShowPoint,this.add(a),i.line){const c=i.line;c.computeBoundingBox(),c.boundingBox&&this.box.union(c.boundingBox);const l=this.styleManager.getLineBasicMaterial(t.color),h=new g.LineSegments(c,l);h.userData.bboxIntersectionCheck=!0,h.userData.isPoint=!0,h.userData.position={x:e.x,y:e.y,z:e.z},this.add(h)}}}class Uu extends me{constructor(e,t,r){var i;super(r);const s=e.getPoints(100),o=e.buildHierarchy(),a=[];this.buildHatchGeometry(s,o,a);let c;if(a.length>0&&(c=eo.mergeGeometries(a)),!c||!c.getIndex()||((i=c.getIndex())==null?void 0:i.count)===0)console.warn("Failed to convert hatch boundaries!");else{c.computeBoundingBox(),this.box=c.boundingBox;const l=this.styleManager.getHatchShaderMaterial(t,new g.Vector2(0,0));this.add(new g.Mesh(c,l))}}buildHatchGeometry(e,t,r){if(t.children.length===0)return;const i=[],s=new Map;t.children.forEach(c=>{c.children.length===0?i.push(c.index):s.set(c.index,c.children.map(l=>l.index))});const o=c=>{try{const l=new g.ShapeGeometry(c);l.hasAttribute("uv")&&l.deleteAttribute("uv"),l.hasAttribute("normal")&&l.deleteAttribute("normal"),r.push(l)}catch{console.warn(`Triangulate shape error: ${c.getPoints().map(l=>l.toArray()).toString()}`)}};i.forEach(c=>{const l=e[c];if(l.length===0)return;const h=new g.Shape(l);o(h)});const a=c=>c.map(l=>l.toArray());for(const c of s){const l=new g.Shape(e[c[0]]);let h={regions:[],inverted:!1};const d=this.findIntersectHole(e,c[1]);d.forEach(p=>{let f={segments:[],inverted:!1},m=1e-6;try{p.forEach((y,v)=>{m=Math.min(e[y][0].relativeEps(),1e-6);const _=new Ps(new Ds(m));if(v===0)f=_.segments({regions:[a(e[y])],inverted:!1});else{const w=_.segments({regions:[a(e[y])],inverted:!1}),C=_.combine(f,w);h=_.polygon(_.selectUnion(C)),h.regions.length>0?h.regions.forEach(T=>{if(T.length===0)return;const D=T.map(I=>new g.Vector2(I[0],I[1]));l.holes.push(new g.Path(D))}):console.warn("mergedHoles.regions is empty!")}})}catch(y){console.warn(`Polybool error: ${y}, epsilon is ${m}`)}});const u=d.flat(2);for(let p=0;p<c[1].length;p++){const f=c[1][p];u.includes(f)||l.holes.push(new g.Path(e[f]))}o(l)}t.children.forEach(c=>{c.children.forEach(l=>{this.buildHatchGeometry(e,l,r)})})}findIntersectHole(e,t){const r=t.length,i=[];for(let s=0;s<r;s++){const o=e[t[s]];let a=!1;const c=[];for(let l=s+1;l<r;l++){const h=e[t[l]];x.AcGeGeometryUtil.isPolygonIntersect(o,h)&&(a=!0,c.push(t[l]))}a&&(c.push(t[s]),i.push(c))}return i}}function Fu(n,e,t,r,i=0){const s={u_cameraZoom:t,u_patternLines:{value:n},u_patternAngle:{value:e},u_color:{value:r}},o=`
29
29
  varying vec3 v_pos;
30
30
 
31
31
  #include <clipping_planes_pars_vertex>
@@ -280,4 +280,4 @@
280
280
  }
281
281
  }
282
282
  #include <colorspace_fragment>
283
- }`;return new g.ShaderMaterial({uniforms:c,vertexShader:l,fragmentShader:h,clipping:!0})}}const ln=class Ft{constructor(){this.pointMaterials={},this.lineShaderMaterials={},this.lineBasicMaterials={},this.hatchShaderMaterials=[],this.meshBasicMaterials={},this.unsupportedTextStyles={}}getPointsMaterial(e,t=2){const r=`${e}_${t}`;return this.pointMaterials[r]||(this.pointMaterials[r]=new g.PointsMaterial({size:t,color:e})),this.pointMaterials[r]}getMeshBasicMaterial(e){return this.meshBasicMaterials[e]||(this.meshBasicMaterials[e]=new g.MeshBasicMaterial({color:e})),this.meshBasicMaterials[e]}getLineBasicMaterial(e){return this.lineBasicMaterials[e]||(this.lineBasicMaterials[e]=new g.LineBasicMaterial({color:e})),this.lineBasicMaterials[e]}getLineShaderMaterial(e,t){if(e.pattern&&e.pattern.length!==0){const r=`${e.name}_${e.color}_${t}`;return this.lineShaderMaterials[r]||(this.lineShaderMaterials[r]=Pu.createLineShaderMaterial(e.pattern,e.color,t,Ft.ViewportScaleUniform,Ft.CameraZoomUniform)),this.lineShaderMaterials[r]}else return this.getLineBasicMaterial(e.color)}getHatchShaderMaterial(e,t){if(!e.patternLines||e.patternLines.length<1)return this.getMeshBasicMaterial(e.color);let r=!1;if(e.patternLines.forEach(u=>{u.dashPattern||(r=!0,console.log("Invalid dash pattern: ",e))}),r)return;const i=this.findMatchedHatchShaderMaterial(e);if(i)return i;const s=.005,o=.05;let a=2;e.patternLines.forEach(u=>{a=Math.max(u.dashPattern.length,a)});let c=0;const l=[],h=new g.Vector2;for(const u of e.patternLines){const p=new g.Vector2(u.origin.x,u.origin.y).sub(t).rotateAround(h,-g.MathUtils.degToRad(e.patternAngle)),f=new g.Vector2(u.delta.x,u.delta.y).rotateAround(h,-g.MathUtils.degToRad(u.angle));if(f.y===0){console.warn("delta.y is equal to zero!");return}const m=u.dashPattern.length;let y=!0,v=0;for(let I=0;I<m;++I){const E=u.dashPattern[I];E>0&&(y=!1),v+=Math.abs(E)}const _=y?o:s,w=[],C=[];let T=0;C[0]=T;for(let I=0;I<m;++I)w[I]=u.dashPattern[I],w[I]===0&&(w[I]=_*v),T+=Math.abs(w[I]),C[I+1]=T;for(let I=m;I<a;++I)w[I]=0;for(let I=C.length;I<a+1;++I)C[I]=T;const D={origin:p,delta:f,angle:u.angle-e.patternAngle,pattern:w,patternSum:C,patternLength:T};if(c+=4,c+=a,c+=a+1,c>Ft.MaxFragmentUniforms){console.warn("There will be warning in fragment shader when number of uniforms exceeds 1024, so extra hatch line patterns are ignored here!");break}l.push(D)}const d=Fu(l,e.patternAngle,Ft.CameraZoomUniform,new g.Color(e.color));return d.defines={MAX_PATTERN_SEGMENT_COUNT:a},this.hatchShaderMaterials.push({patternLines:e.patternLines,patternAngle:e.patternAngle,color:e.color,material:d}),d}findMatchedHatchShaderMaterial(e){const t=e.patternLines;if(!t||t.length<1)return;const r=(c,l)=>Math.abs(c-l)<1e-5,i=(c,l)=>{if(c.length!==l.length)return!1;for(let h=0;h<c.length;++h)if(!r(c[h],l[h]))return!1;return!0},s=(c,l)=>r(c.angle,l.angle)&&r(c.delta.x,l.delta.x)&&r(c.delta.y,l.delta.y)&&r(c.origin.x,l.origin.x)&&r(c.origin.y,l.origin.y)&&i(c.dashPattern,l.dashPattern),o=(c,l)=>{if(c.length!==l.length)return!1;for(let h=0;h<c.length;++h)if(!s(c[h],l[h]))return!1;return!0},a=this.hatchShaderMaterials.find(c=>c.color===e.color&&c.patternAngle===e.patternAngle&&o(c.patternLines,t));return a==null?void 0:a.material}};ln.CameraZoomUniform={value:1},ln.ViewportScaleUniform={value:1},ln.MaxFragmentUniforms=1024;let Gu=ln;class Nu{constructor(e){this.events={fontNotFound:new S.AcCmEventManager},this._renderer=e,this._styleManager=new Gu,fe.instance.events.fontNotFound.addEventListener(t=>{this.events.fontNotFound.dispatch(t)})}get autoClear(){return this._renderer.autoClear}set autoClear(e){this._renderer.autoClear=e}get domElement(){return this._renderer.domElement}setSize(e,t){this._renderer.setSize(e,t)}getViewport(e){return this._renderer.getViewport(e)}setViewport(e,t,r,i){this._renderer.setViewport(e,t,r,i)}clear(){this._renderer.clear()}clearDepth(){this._renderer.clearDepth()}render(e,t){this._renderer.render(e,t.internalCamera)}get internalRenderer(){return this._renderer}async loadFonts(e){return await fe.instance.loadFonts(e)}setFontMapping(e){fe.instance.setFontMapping(e)}get missedFonts(){return fe.instance.missedFonts}clearMissedFonts(){fe.instance.missedFonts={}}createObject(){return new Hs(this._styleManager)}createEntity(){return new me(this._styleManager)}group(e){return new ku(e,this._styleManager)}point(e,t){return new Ru(e,t,this._styleManager)}circularArc(e,t){return this.linePoints(e.getPoints(100),t)}ellipticalArc(e,t){return this.linePoints(e.getPoints(100),t)}lines(e,t){return this.linePoints(e,t)}lineSegments(e,t,r,i){return new Ou(e,t,r,i,this._styleManager)}area(e,t){return new Uu(e,t,this._styleManager)}mtext(e,t){return new Mu(e,t,this._styleManager)}image(e,t){return new Bu(e,t,this._styleManager)}linePoints(e,t=void 0){return new Lu(e,t,this._styleManager)}}class zu{constructor(e){this._camera=e}get position(){return this._camera.position}get left(){return this._camera.left}set left(e){this._camera.left=e}get right(){return this._camera.right}set right(e){this._camera.right=e}get top(){return this._camera.top}set top(e){this._camera.top=e}get bottom(){return this._camera.bottom}set bottom(e){this._camera.bottom=e}get zoom(){return this._camera.zoom}set zoom(e){this._camera.zoom=e}get internalCamera(){return this._camera}lookAt(e){this._camera.lookAt(e)}setRotationFromEuler(e){this._camera.setRotationFromEuler(e)}updateProjectionMatrix(){this._camera.updateProjectionMatrix()}cwcs2Wcs(e,t,r){const i=new g.Vector3(e.x,e.y,0);i.x=e.x/t*2-1,i.y=-(e.y/r)*2+1;const s=i.unproject(this._camera);return new S.AcGePoint2d(s.x,s.y)}wcs2Cwcs(e,t,r){const i=new g.Vector3(e.x,e.y,0).project(this._camera);return new S.AcGePoint2d((i.x+1)/2*t,(-i.y+1)/2*r)}wcs2Ndc(e,t,r){const i=this.wcs2Cwcs(e,t,r);return this.cwcs2Ndc(i,t,r)}cwcs2Ndc(e,t,r){return new S.AcGePoint2d(e.x/t*2-1,-(e.y/r)*2+1)}}class js{constructor(e,t,r){this._frustum=400,this.events={viewChanged:new S.AcCmEventManager},this._renderer=e,this._width=t,this._height=r;const i=this.createCamera();this._camera=new zu(i),this._cameraControls=this.createCameraControls(),this._cameraControls.addEventListener("change",()=>{this.events.viewChanged.dispatch({view:this})}),this._raycaster=new g.Raycaster}get width(){return this._width}set width(e){this._width=e}get height(){return this._height}set height(e){this._height=e}get enabled(){return this._cameraControls.enabled}set enabled(e){this._cameraControls.enabled=e}get center(){return this._camera.cwcs2Wcs({x:this._width/2,y:this._height/2},this._width,this._height)}set center(e){this._camera.position.set(e.x,e.y,this._camera.position.z),this._camera.updateProjectionMatrix()}cwcs2Wcs(e){return this._camera.cwcs2Wcs(e,this._width,this._height)}wcs2Cwcs(e){return this._camera.wcs2Cwcs(e,this._width,this._height)}pointToBox(e,t){const r=this.wcs2Cwcs(e),i=this.cwcs2Wcs({x:r.x+t,y:r.y+t}),s=this.cwcs2Wcs({x:r.x-t,y:r.y-t});return new S.AcGeBox2d().setFromPoints([i,s])}resetRaycaster(e,t){const r=this._camera.wcs2Ndc(e,this._width,this._height);return this._raycaster.setFromCamera(new g.Vector2(r.x,r.y),this._camera.internalCamera),this._raycaster.params.Line.threshold=t,this._raycaster.params.Points.threshold=t,this._raycaster}zoomTo(e,t=1.1){const r=new S.AcGeVector2d;e.getSize(r);const i=new S.AcGeVector2d;e.getCenter(i);const s=new g.Vector3(i.x,i.y,0);this._camera.position.set(i.x,i.y,this._camera.position.z),this._camera.lookAt(s),this._camera.setRotationFromEuler(new g.Euler(0,0,0));const o=r.x*t,a=r.y*t,c=this._width/o,l=this._height/a;this._camera.zoom=Math.min(c,l),this._cameraControls.target=s,this.updateCameraFrustum()}updateCameraFrustum(e,t){const r=(e??this._width)/(t??this._height);this._camera.left=-r*this._frustum,this._camera.right=r*this._frustum,this._camera.top=this._frustum,this._camera.bottom=-this._frustum,this._camera.updateProjectionMatrix(),this._cameraControls.update()}createCamera(){const e=new g.OrthographicCamera(-this._width/2,this._width/2,this._height/2,-this._height/2,.1,1e3);return e.position.set(0,0,500),e.up.set(0,1,0),e.updateProjectionMatrix(),e}createCameraControls(){const e=new to.OrbitControls(this._camera.internalCamera,this._renderer.domElement);return e.enableDamping=!1,e.autoRotate=!1,e.enableRotate=!1,e.zoomSpeed=5,e.mouseButtons={MIDDLE:g.MOUSE.PAN},e.update(),e}}class hn extends js{static calculateViewportWindowBox(e,t){const r=t.box,i=new S.AcGeBox2d;return i.expandByPoint(e.wcs2Cwcs(r.min)),i.expandByPoint(e.wcs2Cwcs(r.max)),i}constructor(e,t,r){const i=hn.calculateViewportWindowBox(e,t).size;super(r,i.width,i.height),this._parentView=e,this._viewport=t.clone(),this._frustum*=t.height/e.height,this.zoomTo(this._viewport.viewBox),this.enabled=!1}get viewport(){return this._viewport}update(){this.zoomTo(this._viewport.viewBox)}render(e){const t=hn.calculateViewportWindowBox(this._parentView,this._viewport);if(!t.isEmpty()){const r=this._parentView.height-t.min.y-t.size.height;this._renderer.setViewport(t.min.x,r,t.size.width,t.size.height),this._renderer.internalRenderer.setScissor(t.min.x,r,t.size.width,t.size.height),this._renderer.internalRenderer.setScissorTest(!0),this._renderer.render(e,this._camera),this._renderer.internalRenderer.setScissorTest(!1)}}}const Vu={threeBo2dToGeBox2d:n=>new S.AcGeBox2d(n.min,n.max),geBox2dToThreeBox2d:n=>new g.Box2(n.min,n.max),threeBox3dToGeBox3d:n=>new S.AcGeBox3d(n.min,n.max),geBox3dToThreeBox3d:n=>new g.Box3(n.min,n.max),goBox3dToGeBox2d:n=>new S.AcGeBox2d(n.min,n.max),threeBox3dToGeBox2d:n=>new S.AcGeBox2d(n.min,n.max),geBox2dToThreeBox3d:n=>{const e=new g.Box3;return e.min.set(n.min.x,n.min.y,0),e.max.set(n.max.x,n.max.y,0),e}};var un=(n=>(n[n.LEFT_BOTTOM=0]="LEFT_BOTTOM",n[n.LEFT_TOP=1]="LEFT_TOP",n[n.RIGHT_TOP=2]="RIGHT_TOP",n[n.RIGHT_BOTTOM=4]="RIGHT_BOTTOM",n))(un||{});class Hu extends g.Object3D{constructor(e,t,r=150,i=2){super(),this.camera=e,this.renderer=t,this.gizmoCamera=new g.OrthographicCamera(-2,2,2,-2,0,4),this.gizmoCamera.position.set(0,0,2),this.gizmoDim=r,this.gizmoPos=i,this.initialize()}initialize(){}update(){this.updateOrientation();const e=this.renderer.autoClear;this.renderer.autoClear=!1,this.renderer.clearDepth();const t=new g.Vector4;this.renderer.getViewport(t);const r=this.calculateViewportPos();this.renderer.setViewport(r.x,r.y,this.gizmoDim,this.gizmoDim),this.renderer.render(this,this.gizmoCamera),this.renderer.setViewport(t.x,t.y,t.z,t.w),this.renderer.autoClear=e}dispose(){}updateOrientation(){this.quaternion.copy(this.camera.quaternion).invert(),this.updateMatrixWorld()}calculatePosInViewport(e,t,r){const i=(e-r.min.x)/this.gizmoDim*2-1,s=-((t-r.min.y)/this.gizmoDim)*2+1;return{x:i,y:s}}calculateViewportPos(){const e=this.renderer.domElement,t=e.offsetWidth,r=e.offsetHeight,i=this.gizmoPos,s=this.gizmoDim;let o=t-s,a=r-s;switch(i){case 0:o=0,a=0;break;case 1:o=0;break;case 4:a=0;break}return{x:o,y:a}}calculateViewportBbox(){const e=this.renderer.domElement,t=e.offsetWidth,r=e.offsetHeight,i=this.gizmoPos,s=this.gizmoDim,o=new g.Box2(new g.Vector2(t-s,0),new g.Vector2(t,s));switch(i){case 0:o.set(new g.Vector2(0,r-s),new g.Vector2(s,r));break;case 1:o.set(new g.Vector2(0,0),new g.Vector2(s,s));break;case 4:o.set(new g.Vector2(t-s,r-s),new g.Vector2(t,r));break}return o}}function ju(n,e){const t=e.font||"Helvetica",r=e.fontSize||30,i=e.width||200,s=e.height||200,o=e.bgColor?e.bgColor.join(", "):"255, 255, 255, 1.0",a=e.color?e.color.join(", "):"0, 0, 0, 1.0",c=document.createElement("canvas");c.width=i,c.height=s;const l=c.getContext("2d");if(l){l.font=`bold ${r}px ${t}`,l.fillStyle=`rgba(${o})`,l.fillRect(0,0,i,s);const u=l.measureText(n).width;l.fillStyle=`rgba(${a})`,l.fillText(n,i/2-u/2,s/2+r/2-2)}const h=new g.Texture(c);return h.minFilter=g.LinearFilter,h.needsUpdate=!0,h}function fr(n){const e=ju(n,{fontSize:100,font:"Arial Narrow, sans-serif",color:[255,255,255,1],bgColor:[0,0,0,0]}),t=new g.SpriteMaterial({map:e,transparent:!0});return new g.Sprite(t)}un.RIGHT_TOP;const Wu={pos:un.LEFT_BOTTOM,size:100,hasZAxis:!0};class Xu extends Hu{constructor(e,t,r){const i={...Wu,...r};super(e,t,i.size,r.pos),this.hasZAxis=i.hasZAxis;const s=[0,0,0,2,0,0,0,0,0,0,2,0],o=[1,0,0,1,.6,0,0,1,0,.6,1,0];this.hasZAxis&&(s.push(0,0,0,0,0,2),o.push(0,0,1,0,.6,1));const a=new g.BufferGeometry;a.setAttribute("position",new g.Float32BufferAttribute(s,3)),a.setAttribute("color",new g.Float32BufferAttribute(o,3));const c=new g.LineBasicMaterial({vertexColors:!0,toneMapped:!1});this.axes=new g.LineSegments(a,c),this.axes.position.set(-1,-1,-1),this.add(this.axes),this.xText=fr("X"),this.xText.position.set(1.5,-1,-1),this.add(this.xText),this.yText=fr("Y"),this.yText.position.set(-1,1.5,-1),this.add(this.yText),this.hasZAxis&&(this.zText=fr("Z"),this.zText.position.set(-1,-1,1.5),this.add(this.zText))}setLineColors(e,t){const r=new g.Color,i=this.axes.geometry.attributes.color.array;return r.set(e),r.toArray(i,0),r.toArray(i,3),r.set(t),r.toArray(i,6),r.toArray(i,9),this.axes.geometry.attributes.color.needsUpdate=!0,this}setTextColor(e){this.xText.material.color=e,this.yText.material.color=e}dispose(){var e,t;this.axes.geometry.dispose(),this.axes.material.dispose(),this.xText.geometry.dispose(),this.xText.material.dispose(),this.yText.geometry.dispose(),this.yText.material.dispose(),this.hasZAxis&&((e=this.zText)==null||e.geometry.dispose(),(t=this.zText)==null||t.material.dispose())}}class qu extends js{constructor(e,t,r,i){super(e,r,i),this._layoutBtrId=t,this._mode=Ie.SELECTION,this._axesGizmo=this.createAxesGizmo(),this._viewportViews=new Map}get layoutBtrId(){return this._layoutBtrId}get mode(){return this._mode}set mode(e){e==Ie.SELECTION?this._cameraControls.mouseButtons={MIDDLE:g.MOUSE.PAN}:e==Ie.PAN&&(this._cameraControls.mouseButtons={LEFT:g.MOUSE.PAN}),this._cameraControls.update(),this._mode=e}get viewportCount(){return this._viewportViews.size}addViewport(e){this._viewportViews.set(e.viewport.id,e)}removeViewport(e){this._viewportViews.delete(e)}resize(e,t){this._height=t,this._width=e,this.updateCameraFrustum(),this._viewportViews.forEach(r=>{r.update()})}render(e){var r;this._renderer.clear(),this._renderer.render(e.internalScene,this._camera);const t=e.modelSpaceLayout;t&&this.drawViewports(t.internalObject),(r=this._axesGizmo)==null||r.update()}createAxesGizmo(){return new Xu(this._camera.internalCamera,this._renderer.internalRenderer,{hasZAxis:!1,pos:un.LEFT_BOTTOM})}drawViewports(e){if(this._viewportViews.size>0){const t=this._renderer.autoClear;this._renderer.autoClear=!1;const r=new g.Vector4;this._renderer.getViewport(r),this._renderer.clearDepth();const i=e.visible;e.visible=!0,this._viewportViews.forEach(s=>{s.render(e)}),e.visible=i,this._renderer.setViewport(r.x,r.y,r.z,r.w),this._renderer.autoClear=t}}}class Yu{constructor(){this._activeLayoutBtrId="",this._layoutViews=new Map}get activeLayoutBtrId(){return this._activeLayoutBtrId}set activeLayoutBtrId(e){this._activeLayoutBtrId=e,this._layoutViews.forEach(t=>{t.enabled=t.layoutBtrId==e})}get activeLayoutView(){return this._layoutViews.get(this._activeLayoutBtrId)}has(e){return this._layoutViews.has(e)}getAt(e){return this._layoutViews.get(e)}resize(e,t){this._layoutViews.forEach(r=>{r.resize(e,t)})}add(e){this._layoutViews.set(e.layoutBtrId,e)}render(e){var t;(t=this.activeLayoutView)==null||t.render(e)}}function Ws(n,e,t=0,r=n.length-1,i=$u){for(;r>t;){if(r-t>600){const c=r-t+1,l=e-t+1,h=Math.log(c),d=.5*Math.exp(2*h/3),u=.5*Math.sqrt(h*d*(c-d)/c)*(l-c/2<0?-1:1),p=Math.max(t,Math.floor(e-l*d/c+u)),f=Math.min(r,Math.floor(e+(c-l)*d/c+u));Ws(n,e,p,f,i)}const s=n[e];let o=t,a=r;for(Dt(n,t,e),i(n[r],s)>0&&Dt(n,t,r);o<a;){for(Dt(n,o,a),o++,a--;i(n[o],s)<0;)o++;for(;i(n[a],s)>0;)a--}i(n[t],s)===0?Dt(n,t,a):(a++,Dt(n,a,r)),a<=e&&(t=a+1),e<=a&&(r=a-1)}}function Dt(n,e,t){const r=n[e];n[e]=n[t],n[t]=r}function $u(n,e){return n<e?-1:n>e?1:0}class Zu{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data;const r=[];if(!pn(e,t))return r;const i=this.toBBox,s=[];for(;t;){for(let o=0;o<t.children.length;o++){const a=t.children[o],c=t.leaf?i(a):a;pn(e,c)&&(t.leaf?r.push(a):mr(e,c)?this._all(a,r):s.push(a))}t=s.pop()}return r}collides(e){let t=this.data;if(!pn(e,t))return!1;const r=[];for(;t;){for(let i=0;i<t.children.length;i++){const s=t.children[i],o=t.leaf?this.toBBox(s):s;if(pn(e,o)){if(t.leaf||mr(e,o))return!0;r.push(s)}}t=r.pop()}return!1}load(e){if(!(e&&e.length))return this;if(e.length<this._minEntries){for(let r=0;r<e.length;r++)this.insert(e[r]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(!this.data.children.length)this.data=t;else if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){const r=this.data;this.data=t,t=r}this._insert(t,this.data.height-t.height-1,!0)}return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=ut([]),this}remove(e,t){if(!e)return this;let r=this.data;const i=this.toBBox(e),s=[],o=[];let a,c,l;for(;r||s.length;){if(r||(r=s.pop(),c=s[s.length-1],a=o.pop(),l=!0),r.leaf){const h=Qu(e,r.children,t);if(h!==-1)return r.children.splice(h,1),s.push(r),this._condense(s),this}!l&&!r.leaf&&mr(r,i)?(s.push(r),o.push(a),a=0,c=r,r=r.children[0]):c?(a++,r=c.children[a],l=!1):r=null}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){const r=[];for(;e;)e.leaf?t.push(...e.children):r.push(...e.children),e=r.pop();return t}_build(e,t,r,i){const s=r-t+1;let o=this._maxEntries,a;if(s<=o)return a=ut(e.slice(t,r+1)),ht(a,this.toBBox),a;i||(i=Math.ceil(Math.log(s)/Math.log(o)),o=Math.ceil(s/Math.pow(o,i-1))),a=ut([]),a.leaf=!1,a.height=i;const c=Math.ceil(s/o),l=c*Math.ceil(Math.sqrt(o));Xs(e,t,r,l,this.compareMinX);for(let h=t;h<=r;h+=l){const d=Math.min(h+l-1,r);Xs(e,h,d,c,this.compareMinY);for(let u=h;u<=d;u+=c){const p=Math.min(u+c-1,d);a.children.push(this._build(e,u,p,i-1))}}return ht(a,this.toBBox),a}_chooseSubtree(e,t,r,i){for(;i.push(t),!(t.leaf||i.length-1===r);){let s=1/0,o=1/0,a;for(let c=0;c<t.children.length;c++){const l=t.children[c],h=gr(l),d=ed(e,l)-h;d<o?(o=d,s=h<s?h:s,a=l):d===o&&h<s&&(s=h,a=l)}t=a||t.children[0]}return t}_insert(e,t,r){const i=r?e:this.toBBox(e),s=[],o=this._chooseSubtree(i,this.data,t,s);for(o.children.push(e),Ut(o,i);t>=0&&s[t].children.length>this._maxEntries;)this._split(s,t),t--;this._adjustParentBBoxes(i,s,t)}_split(e,t){const r=e[t],i=r.children.length,s=this._minEntries;this._chooseSplitAxis(r,s,i);const o=this._chooseSplitIndex(r,s,i),a=ut(r.children.splice(o,r.children.length-o));a.height=r.height,a.leaf=r.leaf,ht(r,this.toBBox),ht(a,this.toBBox),t?e[t-1].children.push(a):this._splitRoot(r,a)}_splitRoot(e,t){this.data=ut([e,t]),this.data.height=e.height+1,this.data.leaf=!1,ht(this.data,this.toBBox)}_chooseSplitIndex(e,t,r){let i,s=1/0,o=1/0;for(let a=t;a<=r-t;a++){const c=Rt(e,0,a,this.toBBox),l=Rt(e,a,r,this.toBBox),h=td(c,l),d=gr(c)+gr(l);h<s?(s=h,i=a,o=d<o?d:o):h===s&&d<o&&(o=d,i=a)}return i||r-t}_chooseSplitAxis(e,t,r){const i=e.leaf?this.compareMinX:Ju,s=e.leaf?this.compareMinY:Ku,o=this._allDistMargin(e,t,r,i),a=this._allDistMargin(e,t,r,s);o<a&&e.children.sort(i)}_allDistMargin(e,t,r,i){e.children.sort(i);const s=this.toBBox,o=Rt(e,0,t,s),a=Rt(e,r-t,r,s);let c=dn(o)+dn(a);for(let l=t;l<r-t;l++){const h=e.children[l];Ut(o,e.leaf?s(h):h),c+=dn(o)}for(let l=r-t-1;l>=t;l--){const h=e.children[l];Ut(a,e.leaf?s(h):h),c+=dn(a)}return c}_adjustParentBBoxes(e,t,r){for(let i=r;i>=0;i--)Ut(t[i],e)}_condense(e){for(let t=e.length-1,r;t>=0;t--)e[t].children.length===0?t>0?(r=e[t-1].children,r.splice(r.indexOf(e[t]),1)):this.clear():ht(e[t],this.toBBox)}}function Qu(n,e,t){if(!t)return e.indexOf(n);for(let r=0;r<e.length;r++)if(t(n,e[r]))return r;return-1}function ht(n,e){Rt(n,0,n.children.length,e,n)}function Rt(n,e,t,r,i){i||(i=ut(null)),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(let s=e;s<t;s++){const o=n.children[s];Ut(i,n.leaf?r(o):o)}return i}function Ut(n,e){return n.minX=Math.min(n.minX,e.minX),n.minY=Math.min(n.minY,e.minY),n.maxX=Math.max(n.maxX,e.maxX),n.maxY=Math.max(n.maxY,e.maxY),n}function Ju(n,e){return n.minX-e.minX}function Ku(n,e){return n.minY-e.minY}function gr(n){return(n.maxX-n.minX)*(n.maxY-n.minY)}function dn(n){return n.maxX-n.minX+(n.maxY-n.minY)}function ed(n,e){return(Math.max(e.maxX,n.maxX)-Math.min(e.minX,n.minX))*(Math.max(e.maxY,n.maxY)-Math.min(e.minY,n.minY))}function td(n,e){const t=Math.max(n.minX,e.minX),r=Math.max(n.minY,e.minY),i=Math.min(n.maxX,e.maxX),s=Math.min(n.maxY,e.maxY);return Math.max(0,i-t)*Math.max(0,s-r)}function mr(n,e){return n.minX<=e.minX&&n.minY<=e.minY&&e.maxX<=n.maxX&&e.maxY<=n.maxY}function pn(n,e){return e.minX<=n.maxX&&e.minY<=n.maxY&&e.maxX>=n.minX&&e.maxY>=n.minY}function ut(n){return{children:n,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Xs(n,e,t,r,i){const s=[e,t];for(;s.length;){if(t=s.pop(),e=s.pop(),t-e<=r)continue;const o=e+Math.ceil((t-e)/r/2)*r;Ws(n,o,e,t,i),s.push(e,o,o,t)}}class nd{constructor(e){this._group=new Eu,this._name=e}get name(){return this._name}set name(e){this._name=e}get visible(){return this._group.visible}set visible(e){this._group.visible=e}get internalObject(){return this._group}get stats(){const e=this._group.stats;return{name:this._name,...e}}get entityCount(){return this._group.entityCount}rerenderPoints(e){this._group.rerenderPoints(e)}hasEntity(e){return this._group.hasEntity(e)}addEntity(e){this._group.addEntity(e)}isIntersectWith(e,t){return this._group.isIntersectWith(e,t)}remove(e){throw new Error("Not implemented yet!")}update(e){return this._group.add(e),!0}hover(e){e.forEach(t=>{this._group.hover(t)})}unhover(e){e.forEach(t=>{this._group.unhover(t)})}select(e){e.forEach(t=>{this._group.select(t)})}unselect(e){e.forEach(t=>{this._group.unselect(t)})}}class rd{constructor(){this._group=new g.Group,this._indexTree=new Zu,this._box=new g.Box3,this._layers=new Map}get internalObject(){return this._group}get layers(){return this._layers}get box(){return this._box}get visible(){return this._group.visible}set visible(e){this._group.visible=e}get entityCount(){let e=0;return this._layers.forEach(t=>e+=t.entityCount),e}get stats(){const e=[];let t=0,r=0,i=0,s=0,o=0;return this._layers.forEach(a=>{const c=a.stats;e.push(c),i+=c.line.indexed.geometrySize+c.line.nonIndexed.geometrySize,s+=c.mesh.indexed.geometrySize+c.mesh.nonIndexed.geometrySize,o+=c.point.indexed.geometrySize+c.point.nonIndexed.geometrySize,t+=c.summary.totalGeometrySize,r+=c.summary.totalMappingSize}),{layers:e,summary:{entityCount:this.entityCount,totalSize:{line:i,mesh:s,point:o,geometry:t,mapping:r}}}}clear(){return this._layers.forEach(e=>{this._group.remove(e.internalObject)}),this._layers.clear(),this._box.makeEmpty(),this._indexTree.clear(),this}rerenderPoints(e){this._layers.forEach(t=>{t.rerenderPoints(e)})}isIntersectWith(e,t){const r=this.getLayerByObjectId(e);return r&&r.isIntersectWith(e,t)}addEntity(e,t=!0){if(!e.objectId)throw new Error("[AcTrEntity] Object id is required to add one entity!");if(!e.layerName)throw new Error("[AcTrEntity] Layer name is required to add one entity!");const r=this.getLayer(e.layerName,!0);if(r){r.addEntity(e);const i=e.box;t&&this._box.union(i),this._indexTree.insert({minX:i.min.x,minY:i.min.y,maxX:i.max.x,maxY:i.max.y,id:e.objectId})}return this}remove(e){for(const[t,r]of this._layers)if(r.remove(e))return!0;return!1}update(e){for(const[t,r]of this._layers)if(r.update(e))return!0;return!1}hover(e){e.forEach(t=>{const r=this.getLayerByObjectId(t);r&&r.hover([t])})}unhover(e){e.forEach(t=>{const r=this.getLayerByObjectId(t);r&&r.unhover([t])})}select(e){e.forEach(t=>{const r=this.getLayerByObjectId(t);r&&r.select([t])})}unselect(e){e.forEach(t=>{const r=this.getLayerByObjectId(t);r&&r.unselect([t])})}setSnapObject(e){this._snapPointsObject&&this._group.remove(this._snapPointsObject),this._snapPointsObject=e,this._group.add(e)}search(e){return this._indexTree.search({minX:e.min.x,minY:e.min.y,maxX:e.max.x,maxY:e.max.y})}getLayerByObjectId(e){for(const[t,r]of this._layers)if(r.hasEntity(e))return r}getLayer(e,t=!0){let r=this._layers.get(e);return r===void 0&&t&&(r=new nd(e),this._layers.set(e,r),this._group.add(r.internalObject)),r}}class id{constructor(){this._scene=new g.Scene,this._layouts=new Map,this._activeLayoutBtrId="",this._modelSpaceBtrId=""}get layouts(){return this._layouts}get box(){var e;return(e=this.activeLayout)==null?void 0:e.box}get internalScene(){return this._scene}get modelSpaceBtrId(){return this._modelSpaceBtrId}set modelSpaceBtrId(e){if(this._modelSpaceBtrId=e,!this._layouts.has(e))throw new Error(`[AcTrScene] No layout assiciated with the specified block table record id '${e}'!`)}get activeLayoutBtrId(){return this._activeLayoutBtrId}set activeLayoutBtrId(e){this._activeLayoutBtrId=e,this._layouts.forEach((t,r)=>{t.visible=e==r})}get activeLayout(){if(this._activeLayoutBtrId&&this._layouts.has(this._activeLayoutBtrId))return this._layouts.get(this._activeLayoutBtrId)}get modelSpaceLayout(){if(this._modelSpaceBtrId&&this._layouts.has(this._modelSpaceBtrId))return this._layouts.get(this._modelSpaceBtrId)}get stats(){const e=[];return this._layouts.forEach(t=>e.push(t.stats)),{layouts:e}}addEmptyLayout(e){const t=new rd;return this._layouts.set(e,t),this._scene.add(t.internalObject),t.visible=e==this._activeLayoutBtrId,t}clear(){return this._layouts.forEach(e=>{this._scene.remove(e.internalObject),e.clear()}),this._layouts.clear(),this._scene.clear(),this}setLayerVisibility(e,t){var i;let r=!1;return(i=this.activeLayout)==null||i.layers.forEach(s=>{s.name===e&&(s.visible=t,r=!0)}),r}hover(e){return this.activeLayout?(this.activeLayout.hover(e),!0):!1}unhover(e){return this.activeLayout?(this.activeLayout.unhover(e),!0):!1}select(e){return this.activeLayout?(this.activeLayout.select(e),!0):!1}unselect(e){return this.activeLayout?(this.activeLayout.unselect(e),!0):!1}search(e){const t=this.activeLayout;return t?t==null?void 0:t.search(e):[]}addEntity(e,t=!0){const r=e.ownerId;if(r){let i=this._layouts.get(r);i||(i=this.addEmptyLayout(r)),i.addEntity(e,t)}else console.warn("[AcTrSecene] The owner id of one entity cannot be empty!");return this}remove(e){for(const[t,r]of this._layouts)if(r.remove(e))return!0;return!1}update(e){for(const[t,r]of this._layouts)if(r.update(e))return!0;return!1}setSnapObject(e){return this._layouts.forEach(t=>{t.setSnapObject(e)}),this}}const yr={background:0};class qs extends Cr{constructor(e=yr){const t={...yr,...e},r=new g.WebGLRenderer({antialias:!0,alpha:!0,canvas:e.canvas});t.canvas==null&&(t.canvas=r.domElement),super(t.canvas),e.calculateSizeCallback&&this.setCalculateSizeCallback(e.calculateSizeCallback),r.setPixelRatio(Math.min(window.devicePixelRatio,2)),r.setSize(this.width,this.height),r.setClearColor(t.background||0),this._renderer=new Nu(r);const i=pt.instance.fontMapping;this._renderer.setFontMapping(i),this._renderer.events.fontNotFound.addEventListener(s=>{Ce.emit("font-not-found",{fontName:s.fontName,count:s.count??0})}),this._scene=this.createScene(),this._stats=this.createStats(pt.instance.isShowStats),pt.instance.events.modified.addEventListener(s=>{s.key=="isShowStats"&&this.toggleStatsVisibility(this._stats,s.value)}),this.canvas.addEventListener("click",()=>{this.mode==Ie.SELECTION&&this.select()}),document.addEventListener("keydown",s=>{s.code==="Escape"&&this.selectionSet.clear()}),S.acdbHostApplicationServices().layoutManager.events.layoutSwitched.addEventListener(s=>{this.activeLayoutBtrId=s.newLayout.blockTableRecordId}),this._missedImages=new Map,this._layoutViewManager=new Yu,this.initialize(),this.onWindowResize(),this.animate(),this._isDirty=!0}initialize(){this.setCursor(qe.Crosshair)}get mode(){const e=this.activeLayoutView;return e?e.mode:Ie.SELECTION}set mode(e){this.activeLayoutView.mode=e,this.editor.getPoint()}get renderer(){return this._renderer}get isDirty(){return this._isDirty}set isDirty(e){this._isDirty=e}get missedData(){return{fonts:this._renderer.missedFonts,images:this._missedImages}}get center(){return this.activeLayoutView.center}set center(e){this.activeLayoutView.center=e}get modelSpaceBtrId(){return this._scene.modelSpaceBtrId}set modelSpaceBtrId(e){this._scene.modelSpaceBtrId=e}get activeLayoutBtrId(){return this._scene.activeLayoutBtrId}set activeLayoutBtrId(e){this._layoutViewManager.activeLayoutBtrId=e,this._scene.activeLayoutBtrId=e,this._isDirty=!0}get activeLayoutView(){return this._layoutViewManager.activeLayoutView}get stats(){return this._scene.stats}animate(){var e;requestAnimationFrame(this.animate.bind(this)),this._isDirty&&(this._layoutViewManager.render(this._scene),(e=this._stats)==null||e.update(),this._isDirty=!1)}cwcs2Wcs(e){const t=this.activeLayoutView;return t?t.cwcs2Wcs(e):new S.AcGePoint2d(e)}wcs2Cwcs(e){const t=this.activeLayoutView;return t?t.wcs2Cwcs(e):new S.AcGePoint2d(e)}zoomTo(e,t=1.1){this.activeLayoutView.zoomTo(e,t),this._isDirty=!0}rerenderPoints(e){const t=this._scene.activeLayout;t&&(t.rerenderPoints(e),this._isDirty=!0)}zoomToFit(){if(this._scene.box){const e=Vu.threeBox3dToGeBox2d(this._scene.box);this.zoomTo(e),this._isDirty=!0}}pick(e){e==null&&(e=this.curPos);const t=[],r=this._scene.activeLayout;if(r){const i=this.activeLayoutView,s=i.pointToBox(e,this.selectionBoxSize),o=this._scene.search(s),a=Math.max(s.size.width/2,s.size.height/2),c=i.resetRaycaster(e,a);o.forEach(l=>{const h=l.id;r.isIntersectWith(h,c)&&t.push(h)})}return t}search(e){return this._scene.search(e)}select(e){const t=[];this.pick(e).forEach(i=>t.push(i)),t.length>0&&this.selectionSet.add(t)}selectByBox(e){const t=[];this._scene.search(e).forEach(i=>t.push(i.id)),this.selectionSet.add(t)}addEntity(e){const t=this.createLayoutViewIfNeeded(e.ownerId);let r=e.draw(this._renderer);if(r){r.objectId=e.objectId,r.ownerId=e.ownerId,r.layerName=e.layer,r.visible=e.visibility;const i=!(e instanceof S.AcDbRay||e instanceof S.AcDbXline);this._scene.addEntity(r,i),this._isDirty=!0,r.dispose(),r=null}if(e instanceof S.AcDbViewport){if(e.number>1){const i=new hn(t,e.toGiViewport(),this._renderer);t.addViewport(i)}}else if(e instanceof S.AcDbRasterImage){const i=e.imageFileName;i&&this._missedImages.set(e.objectId,i)}}removeEntity(e){this._scene.remove(e)}updateEntity(e){const t=e.draw(this._renderer);return t&&(t.objectId=e.objectId,t.ownerId=e.ownerId,t.layerName=e.layer,t.visible=e.visibility,this._scene.update(t),this._isDirty=!0,setTimeout(()=>{this._isDirty=!0},100)),t}clear(){this._scene.clear(),this._isDirty=!0,this._missedImages.clear(),this._renderer.clearMissedFonts()}highlight(e){this._isDirty=this._scene.select(e)}unhighlight(e){this._isDirty=this._scene.unselect(e)}setLayerVisibility(e,t){this._isDirty=this._scene.setLayerVisibility(e,t)}onHover(e){this._isDirty=this._scene.hover([e])}onUnhover(e){this._isDirty=this._scene.unhover([e])}createScene(){const e=new id;return e.layouts.forEach(t=>{t.setSnapObject(this.renderer.createObject())}),e}createStats(e){const t=new no;document.body.appendChild(t.dom);const r=t.dom;return r.style.position="fixed",r.style.inset="unset",r.style.bottom="30px",r.style.right="0px",this.toggleStatsVisibility(t,e),t}onWindowResize(){super.onWindowResize(),this._renderer.setSize(this.width,this.height),this._layoutViewManager.resize(this.width,this.height),this._isDirty=!0}createLayoutViewIfNeeded(e){let t=this._layoutViewManager.getAt(e);return t==null&&(t=new qu(this._renderer,e,this.width,this.height),t.events.viewChanged.addEventListener(()=>{this._isDirty=!0}),this._layoutViewManager.add(t)),t}toggleStatsVisibility(e,t){t?e.dom.style.display="block":e.dom.style.display="none"}}const Ys="simsun";class dt{static get instance(){return dt._instance||(dt._instance=new dt),dt._instance}createExampleDoc1(e){for(let i=0;i<2;++i)for(let s=0;s<2;++s){const o=new S.AcDbHatch,a=new S.AcGePolyline2d;a.addVertexAt(0,{x:s*100,y:i*100,bulge:1}),a.addVertexAt(1,{x:s*100+100,y:i*100,bulge:1}),a.closed=!0,o.add(a),e.tables.blockTable.modelSpace.appendEntity(o)}}createExampleDoc2(e){const t=e.tables.blockTable.modelSpace;t.appendEntity(this.createArc()),this.createLines().forEach(i=>{e.tables.blockTable.modelSpace.appendEntity(new S.AcDbLine(i.startPoint,i.endPoint))}),t.appendEntity(this.createHatch()),e.tables.textStyleTable.add(this.createTextStyle()),t.appendEntity(this.createMText())}createTextStyle(){const e={bigFont:"",color:16777215,extendedFont:Ys,fixedTextHeight:0,font:Ys,lastHeight:.2,name:"Standard",obliqueAngle:0,standardFlag:0,textGenerationFlag:0,widthFactor:.667};return new S.AcDbTextStyleTableRecord(e)}createMText(){const e=new S.AcDbMText;return e.attachmentPoint=S.AcGiMTextAttachmentPoint.MiddleLeft,e.color=new S.AcCmColor().setColorName("red"),e.layer="0",e.location=new S.AcGePoint3d(9850,86773,0),e.contents="{\\W0.667;\\T1.1;智慧8081}",e.height=200,e.width=1e3,e.styleName="Standard",e}createHatch(){const e=this.createLines(),t=new S.AcDbHatch,r=new S.AcGeLoop2d;return r.add(new S.AcGeCircArc2d({x:20241.23355899991,y:174118.6312674369},89258.30757455899,S.AcGeMathUtil.degToRad(262.2471115358437),S.AcGeMathUtil.degToRad(264.444541053754),!1)),e.forEach(i=>{r.add(new S.AcGeLine2d(i.startPoint,i.endPoint))}),t.add(r),t}createArc(){return new S.AcDbArc({x:20241.23355899991,y:174118.6312674369,z:0},89258.30757455899,S.AcGeMathUtil.degToRad(262.2471115358437),S.AcGeMathUtil.degToRad(264.444541053754))}createLines(){const e=[];return e.push(new S.AcGeLine3d({x:11600.20888122753,y:85279.57362051727,z:0},{x:11600.20890652924,y:86546.03982284805,z:0})),e.push(new S.AcGeLine3d({x:11600.20890652924,y:86546.03982284805,z:0},{x:10850.20885583921,y:86546.03980174381,z:0})),e.push(new S.AcGeLine3d({x:10850.2088602169,y:86546.03967292747,z:0},{x:9050.208860216895,y:86546.039672927,z:0})),e.push(new S.AcGeLine3d({x:9050.208855839213,y:86546.0397510943,z:0},{x:8200.209067034302,y:86546.039727177,z:0})),e.push(new S.AcGeLine3d({x:8200.209067034302,y:86546.039727177,z:0},{x:8200.209067033837,y:85676.22514764359,z:0})),e}}class sd{constructor(e){this._cadRenderer=e,this._avaiableFonts=[]}get avaiableFonts(){return this._avaiableFonts}async getAvaiableFonts(){if(this._avaiableFonts.length==0){const e="https://cdn.jsdelivr.net/gh/mlight-lee/cad-data/fonts/",t=e+"fonts.json";try{const r=await fetch(t);this._avaiableFonts=await r.json()}catch{Ce.emit("failed-to-get-avaiable-fonts",{url:t})}this._avaiableFonts.forEach(r=>{r.url=e+r.file})}return this._avaiableFonts}async load(e){await this.getAvaiableFonts();const t=[];e.forEach(i=>{const s=i.toLowerCase(),o=gn.find(this._avaiableFonts,a=>gn.findIndex(a.name,c=>c.toLowerCase()==s)>=0);o&&t.push(o.url)}),(await this._cadRenderer.loadFonts(t)).forEach(i=>{i.status||Ce.emit("font-not-loaded",{fontName:i.fontName,url:i.url})})}}class ce{constructor(e){this.events={documentCreated:new S.AcCmEventManager,documentActivated:new S.AcCmEventManager};const t=new Ir;t.database.events.openProgress.addEventListener(s=>{Ce.emit("open-file-progress",{database:t.database,percentage:s.percentage,stage:s.stage,subStage:s.subStage,stageStatus:s.stageStatus})});const r=()=>({width:window.innerWidth,height:window.innerHeight-30}),i=new qs({canvas:e,calculateSizeCallback:r});this._context=new xr(i,t),this._fontLoader=new sd(i.renderer),S.acdbHostApplicationServices().workingDatabase=t.database,this.registerCommands()}static createInstance(e){return ce._instance==null&&(ce._instance=new ce(e)),this._instance}static get instance(){return ce._instance||(ce._instance=new ce),ce._instance}get context(){return this._context}get curDocument(){return this._context.doc}get mdiActiveDocument(){return this._context.doc}get curView(){return this._context.view}get editor(){return this._context.view.editor}get avaiableFonts(){return this._fontLoader.avaiableFonts}async loadFonts(e){await this._fontLoader.load(e)}async loadDefaultFonts(e){e==null?await this._fontLoader.load(["simkai"]):await this._fontLoader.load(e)}createExampleDoc(){setTimeout(async()=>{await this.loadDefaultFonts(),dt.instance.createExampleDoc2(this.curDocument.database),this.setLayoutInfo(),this.curView.zoomToFit()})}async openUrl(e,t){this.onBeforeOpenDocument(),t=this.setOptions(t);const r=await this.context.doc.openUri(e,t);return this.onAfterOpenDocument(r),r}async openDocument(e,t,r){this.onBeforeOpenDocument(),r=this.setOptions(r);const i=await this.context.doc.openDocument(e,t,r);return this.onAfterOpenDocument(i),i}registerCommands(){const e=oe.instance;e.addCommand(oe.SYSTEMT_COMMAND_GROUP_NAME,"pan","pan",new Dr),e.addCommand(oe.SYSTEMT_COMMAND_GROUP_NAME,"select","select",new Br),e.addCommand(oe.SYSTEMT_COMMAND_GROUP_NAME,"zoom","zoom",new Lr),e.addCommand(oe.SYSTEMT_COMMAND_GROUP_NAME,"zoomw","zoomw",new Mr),e.addCommand(oe.SYSTEMT_COMMAND_GROUP_NAME,"csvg","csvg",new Ar),e.addCommand(oe.SYSTEMT_COMMAND_GROUP_NAME,"qnew","qnew",new kr),e.addCommand(oe.SYSTEMT_COMMAND_GROUP_NAME,"open","open",new Er)}sendStringToExecute(e){const r=oe.instance.lookupGlobalCmd(e);r==null||r.execute(this.context)}onBeforeOpenDocument(){this.curView.clear()}onAfterOpenDocument(e){if(e){const t=this.context.doc;this.events.documentActivated.dispatch({doc:t}),this.setLayoutInfo();const r=t.database;this.curView.zoomTo(new S.AcGeBox2d(r.extmin,r.extmax))}}setOptions(e){return e==null?e={fontLoader:this._fontLoader}:e.fontLoader==null&&(e.fontLoader=this._fontLoader),e}setLayoutInfo(){const e=this.curView;e.activeLayoutBtrId=this.curDocument.database.currentSpaceId,e.modelSpaceBtrId=this.curDocument.database.currentSpaceId}}class $s{convert(e){const t=this.createEntity(e);return t&&this.processCommonAttrs(e,t),t}createEntity(e){return e.type=="ARC"?this.convertArc(e):e.type=="CIRCLE"?this.convertCirle(e):e.type=="DIMENSION"?this.convertDimension(e):e.type=="ELLIPSE"?this.convertEllipse(e):e.type=="HATCH"?this.convertHatch(e):e.type=="IMAGE"?this.convertImage(e):e.type=="LEADER"?this.convertLeader(e):e.type=="LINE"?this.convertLine(e):e.type=="LWPOLYLINE"?this.convertLWPolyline(e):e.type=="MTEXT"?this.convertMText(e):e.type=="POINT"?this.convertPoint(e):e.type=="POLYLINE"?this.convertPolyline(e):e.type=="RAY"?this.convertRay(e):e.type=="SPLINE"?this.convertSpline(e):e.type=="ACAD_TABLE"?this.convertTable(e):e.type=="TEXT"?this.convertText(e):e.type=="SOLID"?this.convertSolid(e):e.type=="VIEWPORT"?this.convertViewport(e):e.type=="XLINE"?this.convertXline(e):e.type=="INSERT"?this.convertBlockReference(e):null}convertArc(e){return new S.AcDbArc(e.center,e.radius,e.startAngle,e.endAngle)}convertCirle(e){return new S.AcDbCircle(e.center,e.radius)}convertEllipse(e){const t=new S.AcGeVector3d(e.majorAxisEndPoint),r=t.length();return new S.AcDbEllipse(e.center,S.AcGeVector3d.Z_AXIS,t,r,r*e.axisRatio,e.startAngle,e.endAngle)}convertLine(e){const t=e.startPoint,r=e.endPoint;return new S.AcDbLine(new S.AcGePoint3d(t.x,t.y,t.z),new S.AcGePoint3d(r.x,r.y,r.z))}convertSpline(e){return e.numberOfControlPoints>0&&e.numberOfKnots>0?new S.AcDbSpline(e.controlPoints,e.knots,e.weights,e.degree,!!(e.flag&1)):e.numberOfFitPoints>0?new S.AcDbSpline(e.fitPoints,"Uniform",e.degree,!!(e.flag&1)):null}convertPoint(e){const t=new S.AcDbPoint;return t.position=e.position,t}convertSolid(e){const t=new S.AcDbTrace;return t.setPointAt(0,{...e.corner1,z:0}),t.setPointAt(1,{...e.corner2,z:0}),t.setPointAt(2,{...e.corner3,z:0}),t.setPointAt(3,e.corner4?{...e.corner4,z:0}:{...e.corner3,z:0}),t.thickness=e.thickness,t}convertLWPolyline(e){const t=new S.AcDbPolyline;return t.closed=!!(e.flag&512),e.vertices.forEach((r,i)=>{t.addVertexAt(i,new S.AcGePoint2d(r.x,r.y),r.bulge,r.startWidth,r.endWidth)}),t}convertPolyline(e){const t=new S.AcDbPolyline;return t.closed=!!(e.flag&1),e.vertices.forEach((r,i)=>{t.addVertexAt(i,new S.AcGePoint2d(r.x,r.y),r.bulge,r.startWidth,r.endWidth)}),t}convertHatch(e){var t;const r=new S.AcDbHatch;return(t=e.definitionLines)==null||t.forEach(i=>{r.definitionLines.push({angle:i.angle,origin:i.base,delta:i.offset,dashPattern:i.numberOfDashLengths>0?i.dashLengths:[]})}),r.hatchStyle=e.hatchStyle,r.patternName=e.patternName,r.patternType=e.patternType,r.patternAngle=e.patternAngle==null?0:e.patternAngle,r.patternScale=e.patternScale==null?0:e.patternScale,e.boundaryPaths.forEach(i=>{if(i.boundaryPathTypeFlag&2){const s=i,o=new S.AcGePolyline2d;o.closed=s.isClosed,s.vertices.forEach((a,c)=>{o.addVertexAt(c,{x:a.x,y:a.y,bulge:a.bulge})}),r.add(o)}else{const s=i,o=new S.AcGeLoop2d;s.edges.forEach(a=>{if(a.type==1){const c=a;o.add(new S.AcGeLine2d(c.start,c.end))}else if(a.type==2){const c=a;o.add(new S.AcGeCircArc2d(c.center,c.radius,c.startAngle,c.endAngle,!c.isCCW))}else if(a.type==3){const c=a;new S.AcGeVector2d().subVectors(c.end,c.center);const l=Math.sqrt(Math.pow(c.end.x,2)+Math.pow(c.end.y,2)),h=l*c.lengthOfMinorAxis;let d=c.startAngle,u=c.endAngle;const p=Math.atan2(c.end.y,c.end.x);c.isCCW||(d=Math.PI*2-d,u=Math.PI*2-u),o.add(new S.AcGeEllipseArc2d({...c.center,z:0},l,h,d,u,!c.isCCW,p))}else if(a.type==4){const c=a;if(c.numberOfControlPoints>0&&c.numberOfKnots>0){const l=c.controlPoints.map(u=>({x:u.x,y:u.y,z:0}));let h=!0;const d=c.controlPoints.map(u=>(u.weight==null&&(h=!1),u.weight||1));o.add(new S.AcGeSpline3d(l,c.knots,h?d:void 0))}else if(c.numberOfFitData>0){const l=c.fitDatum.map(h=>({x:h.x,y:h.y,z:0}));o.add(new S.AcGeSpline3d(l,"Uniform"))}}}),r.add(o)}}),r}convertTable(e){const t=new S.AcDbTable(e.name,e.rowCount,e.columnCount);return t.attachmentPoint=e.attachmentPoint,t.position.copy(e.startPoint),e.columnWidthArr.forEach((r,i)=>t.setColumnWidth(i,r)),e.rowHeightArr.forEach((r,i)=>t.setRowHeight(i,r)),e.cells.forEach((r,i)=>{t.setCell(i,r)}),t}convertText(e){const t=new S.AcDbText;return t.textString=e.text,t.styleName=e.styleName,t.height=e.textHeight,t.position.copy(e.startPoint),t.rotation=e.rotation,t.oblique=e.obliqueAngle??0,t.thickness=e.thickness,t.horizontalMode=e.halign,t.verticalMode=e.valign,t.widthFactor=e.xScale??1,t}convertMText(e){const t=new S.AcDbMText;return t.contents=e.text,e.styleName!=null&&(t.styleName=e.styleName),t.height=e.textHeight,t.width=e.rectWidth,t.rotation=e.rotation||0,t.location=e.insertionPoint,t.attachmentPoint=e.attachmentPoint,e.direction&&(t.direction=new S.AcGeVector3d(e.direction)),t.drawingDirection=e.drawingDirection,t}convertLeader(e){const t=new S.AcDbLeader;return e.vertices.forEach(r=>{t.appendVertex(r)}),t.hasArrowHead=e.isArrowheadEnabled,t.hasHookLine=e.isHooklineExists,t.isSplined=e.isSpline,t.dimensionStyle=e.styleName,t.annoType=e.leaderCreationFlag,t}convertDimension(e){if(e.subclassMarker=="AcDbAlignedDimension"||e.subclassMarker=="AcDbRotatedDimension"){const t=e,r=new S.AcDbAlignedDimension(t.subDefinitionPoint1,t.subDefinitionPoint2,t.definitionPoint);return r.rotation=t.rotationAngle,this.processDimensionCommonAttrs(e,r),r}else if(e.subclassMarker=="AcDb3PointAngularDimension"){const t=e,r=new S.AcDb3PointAngularDimension(t.centerPoint,t.subDefinitionPoint1,t.subDefinitionPoint2,t.definitionPoint);return this.processDimensionCommonAttrs(e,r),r}else if(e.subclassMarker=="AcDbOrdinateDimension"){const t=e,r=new S.AcDbOrdinateDimension(t.subDefinitionPoint1,t.subDefinitionPoint2);return this.processDimensionCommonAttrs(e,r),r}else if(e.subclassMarker=="AcDbRadialDimension"){const t=e,r=new S.AcDbRadialDimension(t.definitionPoint,t.centerPoint,t.leaderLength);return this.processDimensionCommonAttrs(e,r),r}else if(e.subclassMarker=="AcDbDiametricDimension"){const t=e,r=new S.AcDbDiametricDimension(t.definitionPoint,t.centerPoint,t.leaderLength);return this.processDimensionCommonAttrs(e,r),r}return null}processImage(e,t){t.position.copy(e.position),t.brightness=e.brightness,t.contrast=e.contrast,t.fade=e.fade,t.imageDefId=e.imageDefHandle.toString(),t.isClipped=(e.flags|4)>0,t.isImageShown=(e.flags|3)>0,t.isImageTransparent=(e.flags|8)>0,e.clippingBoundaryPath.forEach(r=>{t.clipBoundary.push(new S.AcGePoint2d(r))}),t.clipBoundaryType=e.clippingBoundaryType,t.width=Math.sqrt(e.uPixel.x**2+e.uPixel.y**2+e.uPixel.z**2)*e.imageSize.x,t.height=Math.sqrt(e.vPixel.x**2+e.vPixel.y**2+e.vPixel.z**2)*e.imageSize.y,t.rotation=Math.atan2(e.uPixel.y,e.uPixel.x)}convertImage(e){const t=new S.AcDbRasterImage;return this.processImage(e,t),t}convertViewport(e){const t=new S.AcDbViewport;return t.number=e.viewportId,t.centerPoint.copy(e.viewportCenter),t.height=e.height,t.width=e.width,t.viewCenter.copy(e.displayCenter),t.viewHeight=e.viewHeight,t}convertRay(e){const t=new S.AcDbRay;return t.basePoint.copy(e.firstPoint),t.unitDir.copy(e.unitDirection),t}convertXline(e){const t=new S.AcDbXline;return t.basePoint.copy(e.firstPoint),t.unitDir.copy(e.unitDirection),t}convertBlockReference(e){const t=new S.AcDbBlockReference(e.name);return e.insertionPoint&&t.position.copy(e.insertionPoint),t.scaleFactors.x=e.xScale,t.scaleFactors.y=e.yScale,t.scaleFactors.z=e.zScale,t.rotation=e.rotation,t.normal.copy(e.extrusionDirection),t}processDimensionCommonAttrs(e,t){t.dimBlockId=e.name,t.textPosition.copy(e.textPoint),t.textRotation=e.textRotation||0,e.textLineSpacingFactor&&(t.textLineSpacingFactor=e.textLineSpacingFactor),e.textLineSpacingStyle&&(t.textLineSpacingStyle=e.textLineSpacingStyle),t.dimensionStyleName=e.styleName,t.dimensionText=e.text||"",t.measurement=e.measurement}processCommonAttrs(e,t){t.layer=e.layer,t.objectId=e.handle.toString(),t.ownerId=e.ownerBlockRecordSoftId.toString(),e.lineType!=null&&(t.lineType=e.lineType),e.lineweight!=null&&(t.lineWeight=e.lineweight),e.lineTypeScale!=null&&(t.linetypeScale=e.lineTypeScale),e.color!=null&&(t.color.color=e.color),e.colorIndex!=null&&(t.color.colorIndex=e.colorIndex),e.colorName!=null&&(t.color.colorName=e.colorName),e.isVisible!=null&&(t.visibility=e.isVisible),e.transparency!=null&&(t.transparency=e.transparency)}}class od extends S.AcDbDatabaseConverter{constructor(e={}){super(e),e.useWorker=!0,e.parserWorkerUrl||(e.parserWorkerUrl="/assets/libredwg-parser-worker.js")}async parse(e){if(this.config.useWorker&&this.config.parserWorkerUrl)return(await S.createWorkerApi({workerUrl:this.config.parserWorkerUrl}).execute(e)).data;throw new Error("dwg converter can run in web worker only!")}getFonts(e){const t=new Map;e.tables.BLOCK_RECORD.entries.forEach(o=>{t.set(o.name,o)});const r=new Map,i=o=>{if(o){const a=o.lastIndexOf(".");return a>=0?o.substring(0,a).toLowerCase():o.toLowerCase()}};e.tables.STYLE.entries.forEach(o=>{const a=[];let c=i(o.font);c&&a.push(c),c=i(o.bigFont),c&&a.push(c),r.set(o.name,a)});const s=new Set;return this.getFontsInBlock(e.entities,t,r,s),Array.from(s)}getFontsInBlock(e,t,r,i){const s=/\\f(.*?)\|/g;e.forEach(o=>{if(o.type=="MTEXT"){const a=o;[...a.text.matchAll(s)].forEach(l=>{i.add(l[1].toLowerCase())});const c=r.get(a.styleName);c==null||c.forEach(l=>i.add(l))}else if(o.type=="TEXT"){const a=o,c=r.get(a.styleName);c==null||c.forEach(l=>i.add(l))}else if(o.type=="INSERT"){const a=o,c=t.get(a.name);c&&this.getFontsInBlock(c.entities,t,r,i)}})}processLineTypes(e,t){e.tables.LTYPE.entries.forEach(r=>{const i={name:r.name,description:r.description,standardFlag:r.standardFlag,totalPatternLength:r.totalPatternLength,pattern:r.pattern},s=new S.AcDbLinetypeTableRecord(i);this.processCommonTableEntryAttrs(r,s),s.name=r.name,t.tables.linetypeTable.add(s)})}processTextStyles(e,t){e.tables.STYLE.entries.forEach(r=>{const i=new S.AcDbTextStyleTableRecord(r);this.processCommonTableEntryAttrs(r,i),t.tables.textStyleTable.add(i)})}processDimStyles(e,t){e.tables.DIMSTYLE.entries.forEach(r=>{const i={name:r.name,ownerId:r.ownerHandle.toString(),dimpost:r.DIMPOST||"",dimapost:r.DIMAPOST||"",dimscale:r.DIMSCALE,dimasz:r.DIMASZ,dimexo:r.DIMEXO,dimdli:r.DIMDLI,dimexe:r.DIMEXE,dimrnd:r.DIMRND,dimdle:r.DIMDLE,dimtp:r.DIMTP,dimtm:r.DIMTM,dimtxt:r.DIMTXT,dimcen:r.DIMCEN,dimtsz:r.DIMTSZ,dimaltf:r.DIMALTF,dimlfac:r.DIMLFAC,dimtvp:r.DIMTVP,dimtfac:r.DIMTFAC,dimgap:r.DIMGAP,dimaltrnd:r.DIMALTRND,dimtol:r.DIMTOL==null||r.DIMTOL==0?0:1,dimlim:r.DIMLIM==null||r.DIMLIM==0?0:1,dimtih:r.DIMTIH==null||r.DIMTIH==0?0:1,dimtoh:r.DIMTOH==null||r.DIMTOH==0?0:1,dimse1:r.DIMSE1==null||r.DIMSE1==0?0:1,dimse2:r.DIMSE2==null||r.DIMSE2==0?0:1,dimtad:r.DIMTAD,dimzin:r.DIMZIN,dimazin:r.DIMAZIN,dimalt:r.DIMALT,dimaltd:r.DIMALTD,dimtofl:r.DIMTOFL,dimsah:r.DIMSAH,dimtix:r.DIMTIX,dimsoxd:r.DIMSOXD,dimclrd:r.DIMCLRD,dimclre:r.DIMCLRE,dimclrt:r.DIMCLRT,dimadec:r.DIMADEC||0,dimunit:r.DIMUNIT||2,dimdec:r.DIMDEC,dimtdec:r.DIMTDEC,dimaltu:r.DIMALTU,dimalttd:r.DIMALTTD,dimaunit:r.DIMAUNIT,dimfrac:r.DIMFRAC,dimlunit:r.DIMLUNIT,dimdsep:r.DIMDSEP,dimtmove:r.DIMTMOVE||0,dimjust:r.DIMJUST,dimsd1:r.DIMSD1,dimsd2:r.DIMSD2,dimtolj:r.DIMTOLJ,dimtzin:r.DIMTZIN,dimaltz:r.DIMALTZ,dimalttz:r.DIMALTTZ,dimfit:r.DIMFIT||0,dimupt:r.DIMUPT,dimatfit:r.DIMATFIT,dimtxsty:"Standard",dimldrblk:"",dimblk:r.DIMBLK||"",dimblk1:r.DIMBLK1||"",dimblk2:r.DIMBLK2||"",dimlwd:r.DIMLWD,dimlwe:r.DIMLWE},s=new S.AcDbDimStyleTableRecord(i);this.processCommonTableEntryAttrs(r,s),t.tables.dimStyleTable.add(s)})}processLayers(e,t){e.tables.LAYER.entries.forEach(r=>{const i=new S.AcCmColor;i.colorIndex=r.colorIndex;const s=new S.AcDbLayerTableRecord({name:r.name,standardFlags:r.standardFlag,linetype:r.lineType,lineWeight:r.lineweight,isOff:r.off,color:i,isPlottable:r.plotFlag!=0});this.processCommonTableEntryAttrs(r,s),t.tables.layerTable.add(s)})}processViewports(e,t){e.tables.VPORT.entries.forEach(r=>{const i=new S.AcDbViewportTableRecord;this.processCommonTableEntryAttrs(r,i),r.circleSides&&(i.circleSides=r.circleSides),i.standardFlag=r.standardFlag,i.center.copy(r.center),i.lowerLeftCorner.copy(r.lowerLeftCorner),i.upperRightCorner.copy(r.upperRightCorner),r.snapBasePoint&&i.snapBase.copy(r.snapBasePoint),r.snapRotationAngle&&(i.snapAngle=r.snapRotationAngle),r.snapSpacing&&i.snapIncrements.copy(r.snapSpacing),r.majorGridLines&&(i.gridMajor=r.majorGridLines),r.gridSpacing&&i.gridIncrements.copy(r.gridSpacing),r.backgroundObjectId&&(i.backgroundObjectId=r.backgroundObjectId),i.gsView.center.copy(r.center),i.gsView.viewDirectionFromTarget.copy(r.viewDirectionFromTarget),i.gsView.viewTarget.copy(r.viewTarget),r.lensLength&&(i.gsView.lensLength=r.lensLength),r.frontClippingPlane&&(i.gsView.frontClippingPlane=r.frontClippingPlane),r.backClippingPlane&&(i.gsView.backClippingPlane=r.backClippingPlane),r.viewHeight&&(i.gsView.viewHeight=r.viewHeight),r.viewTwistAngle&&(i.gsView.viewTwistAngle=r.viewTwistAngle),r.frozenLayers&&(i.gsView.frozenLayers=r.frozenLayers),r.styleSheet&&(i.gsView.styleSheet=r.styleSheet),r.renderMode&&(i.gsView.renderMode=r.renderMode),r.viewMode&&(i.gsView.viewMode=r.viewMode),r.ucsIconSetting&&(i.gsView.ucsIconSetting=r.ucsIconSetting),r.ucsOrigin&&i.gsView.ucsOrigin.copy(r.ucsOrigin),r.ucsXAxis&&i.gsView.ucsXAxis.copy(r.ucsXAxis),r.ucsYAxis&&i.gsView.ucsYAxis.copy(r.ucsYAxis),r.orthographicType&&(i.gsView.orthographicType=r.orthographicType),r.shadePlotSetting&&(i.gsView.shadePlotSetting=r.shadePlotSetting),r.shadePlotObjectId&&(i.gsView.shadePlotObjectId=r.shadePlotObjectId),r.visualStyleObjectId&&(i.gsView.visualStyleObjectId=r.visualStyleObjectId),r.isDefaultLightingOn&&(i.gsView.isDefaultLightingOn=r.isDefaultLightingOn),r.defaultLightingType&&(i.gsView.defaultLightingType=r.defaultLightingType),r.brightness&&(i.gsView.brightness=r.brightness),r.contrast&&(i.gsView.contrast=r.contrast),r.ambientColor&&(i.gsView.ambientColor=r.ambientColor),t.tables.viewportTable.add(i)})}processBlockTables(e,t){e.tables.BLOCK_RECORD.entries.forEach(r=>{let i=t.tables.blockTable.getAt(r.name);i||(i=new S.AcDbBlockTableRecord,i.objectId=r.handle.toString(),i.name=r.name,t.tables.blockTable.add(i)),!i.isModelSapce&&!i.isPaperSapce&&r.entities&&r.entities.length>0&&this.processEntitiesInBlock(r.entities,i)})}processBlocks(e,t){}async processEntitiesInBlock(e,t){const r=new $s,i=e.length;for(let s=0;s<i;s++){const o=e[s],a=r.convert(o);a&&t.appendEntity(a)}}async processEntities(e,t,r,i,s){const o=new $s,a=e.entities,c=a.length,l=new S.AcDbBatchProcessing(c,100-i.value,r),h=t.tables.blockTable.modelSpace;await l.processChunk(async(d,u)=>{for(let p=d;p<u;p++){const f=a[p],m=o.convert(f);m&&h.appendEntity(m)}if(s){let p=i.value+u/c*(100-i.value);p>100&&(p=100),await s(p,"ENTITY","IN-PROGRESS")}})}processHeader(e,t){const r=e.header;t.cecolor.colorIndex=r.CECOLOR||256,t.angBase=r.ANGBASE??0,t.angDir=r.ANGDIR??0,t.aunits=r.AUNITS??0,t.extmax=r.EXTMAX,t.extmin=r.EXTMIN,t.insunits=r.INSUNITS??1,t.pdmode=r.PDMODE??0,t.pdsize=r.PDSIZE??0}processCommonTableEntryAttrs(e,t){t.name=e.name,t.objectId=e.handle.toString(),t.ownerId=e.ownerHandle.toString()}processObjects(e,t){this.processLayouts(e,t),this.processImageDefs(e,t)}processLayouts(e,t){const r=t.dictionaries.layouts;e.objects.LAYOUT.forEach(i=>{const s=new S.AcDbLayout;s.layoutName=i.layoutName,s.tabOrder=i.tabOrder,s.blockTableRecordId=i.ownerHandle.toString(),s.limits.min.copy(i.minLimit),s.limits.max.copy(i.maxLimit),s.extents.min.copy(i.minExtent),s.extents.max.copy(i.maxExtent),this.processCommonObjectAttrs(i,s),r.setAt(s.layoutName,s)})}processImageDefs(e,t){const r=t.dictionaries.imageDefs;e.objects.IMAGEDEF.forEach(i=>{const s=new S.AcDbRasterImageDef;s.sourceFileName=i.fileName,this.processCommonObjectAttrs(i,s),r.setAt(s.objectId,s)})}processCommonObjectAttrs(e,t){t.objectId=e.handle.toString(),t.ownerId=e.ownerHandle.toString()}}async function ad(){try{const n=new S.AcDbDxfConverter({useWorker:!0,parserWorkerUrl:"./assets/dxf-parser-worker.js"});S.AcDbDatabaseConverterManager.instance.register(S.AcDbFileType.DXF,n)}catch(n){console.error("Failed to register dxf converter: ",n)}try{const n=new od({useWorker:!0,parserWorkerUrl:"./assets/libredwg-parser-worker.js"});S.AcDbDatabaseConverterManager.instance.register(S.AcDbFileType.DWG,n)}catch(n){console.error("Failed to register dwg converter: ",n)}}const cd={isDebug:!1,isShowCommandLine:!0,isShowCoordinate:!0,isShowToolbar:!0,isShowStats:!1,fontMapping:{}},Zs="settings";class pt{constructor(){this.events={modified:new S.AcCmEventManager}}static get instance(){return this._instance||(this._instance=new pt),this._instance}set(e,t){const r=this.settings;r[e]=t,localStorage.setItem(Zs,JSON.stringify(r)),this.events.modified.dispatch({key:e,value:t})}get(e){return this.settings[e]}toggle(e){const t=this.get(e);this.set(e,!t)}get isDebug(){return this.get("isDebug")}set isDebug(e){this.set("isDebug",e)}get isShowCommandLine(){return this.get("isShowCommandLine")}set isShowCommandLine(e){this.set("isShowCommandLine",e)}get isShowCoordinate(){return this.get("isShowCoordinate")}set isShowCoordinate(e){this.set("isShowCoordinate",e)}get isShowToolbar(){return this.get("isShowToolbar")}set isShowToolbar(e){this.set("isShowToolbar",e)}get isShowStats(){return this.get("isShowStats")}set isShowStats(e){this.set("isShowStats",e)}get fontMapping(){return this.get("fontMapping")}set fontMapping(e){this.set("fontMapping",e)}setFontMapping(e,t){const r=this.get("fontMapping");r[e]=t,this.set("fontMapping",r)}get settings(){const e=localStorage.getItem(Zs),t=e==null?{}:JSON.parse(e);return gn.defaults(t,cd)}}b.AcApContext=xr,b.AcApConvertToSvgCmd=Ar,b.AcApDocManager=ce,b.AcApDocument=Ir,b.AcApOpenCmd=Er,b.AcApPanCmd=Dr,b.AcApQNewCmd=kr,b.AcApSelectCmd=Br,b.AcApSettingManager=pt,b.AcApZoomCmd=Lr,b.AcApZoomToBoxCmd=Mr,b.AcApZoomToBoxJig=Or,b.AcEdBaseView=Cr,b.AcEdCommand=Be,b.AcEdCommandStack=oe,b.AcEdCorsorType=qe,b.AcEdCursorManager=Sr,b.AcEdJig=wr,b.AcEdSelectionSet=Tr,b.AcEdViewMode=Ie,b.AcEditor=_r,b.AcTrView2d=qs,b.DEFAULT_VIEW_2D_OPTIONS=yr,b.acedAlert=oo,b.eventBus=Ce,b.registerConverters=ad,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
283
+ }`;return new g.ShaderMaterial({uniforms:c,vertexShader:l,fragmentShader:h,clipping:!0})}}const ln=class Ft{constructor(){this.pointMaterials={},this.lineShaderMaterials={},this.lineBasicMaterials={},this.hatchShaderMaterials=[],this.meshBasicMaterials={},this.unsupportedTextStyles={}}getPointsMaterial(e,t=2){const r=`${e}_${t}`;return this.pointMaterials[r]||(this.pointMaterials[r]=new g.PointsMaterial({size:t,color:e})),this.pointMaterials[r]}getMeshBasicMaterial(e){return this.meshBasicMaterials[e]||(this.meshBasicMaterials[e]=new g.MeshBasicMaterial({color:e})),this.meshBasicMaterials[e]}getLineBasicMaterial(e){return this.lineBasicMaterials[e]||(this.lineBasicMaterials[e]=new g.LineBasicMaterial({color:e})),this.lineBasicMaterials[e]}getLineShaderMaterial(e,t){if(e.pattern&&e.pattern.length!==0){const r=`${e.name}_${e.color}_${t}`;return this.lineShaderMaterials[r]||(this.lineShaderMaterials[r]=Pu.createLineShaderMaterial(e.pattern,e.color,t,Ft.ViewportScaleUniform,Ft.CameraZoomUniform)),this.lineShaderMaterials[r]}else return this.getLineBasicMaterial(e.color)}getHatchShaderMaterial(e,t){if(!e.patternLines||e.patternLines.length<1)return this.getMeshBasicMaterial(e.color);let r=!1;if(e.patternLines.forEach(u=>{u.dashPattern||(r=!0,console.log("Invalid dash pattern: ",e))}),r)return;const i=this.findMatchedHatchShaderMaterial(e);if(i)return i;const s=.005,o=.05;let a=2;e.patternLines.forEach(u=>{a=Math.max(u.dashPattern.length,a)});let c=0;const l=[],h=new g.Vector2;for(const u of e.patternLines){const p=new g.Vector2(u.origin.x,u.origin.y).sub(t).rotateAround(h,-g.MathUtils.degToRad(e.patternAngle)),f=new g.Vector2(u.delta.x,u.delta.y).rotateAround(h,-g.MathUtils.degToRad(u.angle));if(f.y===0){console.warn("delta.y is equal to zero!");return}const m=u.dashPattern.length;let y=!0,v=0;for(let I=0;I<m;++I){const E=u.dashPattern[I];E>0&&(y=!1),v+=Math.abs(E)}const _=y?o:s,w=[],C=[];let T=0;C[0]=T;for(let I=0;I<m;++I)w[I]=u.dashPattern[I],w[I]===0&&(w[I]=_*v),T+=Math.abs(w[I]),C[I+1]=T;for(let I=m;I<a;++I)w[I]=0;for(let I=C.length;I<a+1;++I)C[I]=T;const D={origin:p,delta:f,angle:u.angle-e.patternAngle,pattern:w,patternSum:C,patternLength:T};if(c+=4,c+=a,c+=a+1,c>Ft.MaxFragmentUniforms){console.warn("There will be warning in fragment shader when number of uniforms exceeds 1024, so extra hatch line patterns are ignored here!");break}l.push(D)}const d=Fu(l,e.patternAngle,Ft.CameraZoomUniform,new g.Color(e.color));return d.defines={MAX_PATTERN_SEGMENT_COUNT:a},this.hatchShaderMaterials.push({patternLines:e.patternLines,patternAngle:e.patternAngle,color:e.color,material:d}),d}findMatchedHatchShaderMaterial(e){const t=e.patternLines;if(!t||t.length<1)return;const r=(c,l)=>Math.abs(c-l)<1e-5,i=(c,l)=>{if(c.length!==l.length)return!1;for(let h=0;h<c.length;++h)if(!r(c[h],l[h]))return!1;return!0},s=(c,l)=>r(c.angle,l.angle)&&r(c.delta.x,l.delta.x)&&r(c.delta.y,l.delta.y)&&r(c.origin.x,l.origin.x)&&r(c.origin.y,l.origin.y)&&i(c.dashPattern,l.dashPattern),o=(c,l)=>{if(c.length!==l.length)return!1;for(let h=0;h<c.length;++h)if(!s(c[h],l[h]))return!1;return!0},a=this.hatchShaderMaterials.find(c=>c.color===e.color&&c.patternAngle===e.patternAngle&&o(c.patternLines,t));return a==null?void 0:a.material}};ln.CameraZoomUniform={value:1},ln.ViewportScaleUniform={value:1},ln.MaxFragmentUniforms=1024;let Gu=ln;class Nu{constructor(e){this.events={fontNotFound:new x.AcCmEventManager},this._renderer=e,this._styleManager=new Gu,fe.instance.events.fontNotFound.addEventListener(t=>{this.events.fontNotFound.dispatch(t)})}get autoClear(){return this._renderer.autoClear}set autoClear(e){this._renderer.autoClear=e}get domElement(){return this._renderer.domElement}setSize(e,t){this._renderer.setSize(e,t)}getViewport(e){return this._renderer.getViewport(e)}setViewport(e,t,r,i){this._renderer.setViewport(e,t,r,i)}clear(){this._renderer.clear()}clearDepth(){this._renderer.clearDepth()}render(e,t){this._renderer.render(e,t.internalCamera)}setClearColor(e,t){this._renderer.setClearColor(e,t)}getClearColor(){const e=new g.Color;return this._renderer.getClearColor(e),e.getHex()}setClearAlpha(e){this._renderer.setClearAlpha(e)}getClearAlpha(){return this._renderer.getClearAlpha()}get internalRenderer(){return this._renderer}async loadFonts(e){return await fe.instance.loadFonts(e)}setFontMapping(e){fe.instance.setFontMapping(e)}get missedFonts(){return fe.instance.missedFonts}clearMissedFonts(){fe.instance.missedFonts={}}createObject(){return new Hs(this._styleManager)}createEntity(){return new me(this._styleManager)}group(e){return new ku(e,this._styleManager)}point(e,t){return new Ru(e,t,this._styleManager)}circularArc(e,t){return this.linePoints(e.getPoints(100),t)}ellipticalArc(e,t){return this.linePoints(e.getPoints(100),t)}lines(e,t){return this.linePoints(e,t)}lineSegments(e,t,r,i){return new Ou(e,t,r,i,this._styleManager)}area(e,t){return new Uu(e,t,this._styleManager)}mtext(e,t){return new Mu(e,t,this._styleManager)}image(e,t){return new Bu(e,t,this._styleManager)}linePoints(e,t=void 0){return new Lu(e,t,this._styleManager)}}class zu{constructor(e){this._camera=e}get position(){return this._camera.position}get left(){return this._camera.left}set left(e){this._camera.left=e}get right(){return this._camera.right}set right(e){this._camera.right=e}get top(){return this._camera.top}set top(e){this._camera.top=e}get bottom(){return this._camera.bottom}set bottom(e){this._camera.bottom=e}get zoom(){return this._camera.zoom}set zoom(e){this._camera.zoom=e}get internalCamera(){return this._camera}lookAt(e){this._camera.lookAt(e)}setRotationFromEuler(e){this._camera.setRotationFromEuler(e)}updateProjectionMatrix(){this._camera.updateProjectionMatrix()}cwcs2Wcs(e,t,r){const i=new g.Vector3(e.x,e.y,0);i.x=e.x/t*2-1,i.y=-(e.y/r)*2+1;const s=i.unproject(this._camera);return new x.AcGePoint2d(s.x,s.y)}wcs2Cwcs(e,t,r){const i=new g.Vector3(e.x,e.y,0).project(this._camera);return new x.AcGePoint2d((i.x+1)/2*t,(-i.y+1)/2*r)}wcs2Ndc(e,t,r){const i=this.wcs2Cwcs(e,t,r);return this.cwcs2Ndc(i,t,r)}cwcs2Ndc(e,t,r){return new x.AcGePoint2d(e.x/t*2-1,-(e.y/r)*2+1)}}class js{constructor(e,t,r){this._frustum=400,this.events={viewChanged:new x.AcCmEventManager},this._renderer=e,this._width=t,this._height=r;const i=this.createCamera();this._camera=new zu(i),this._cameraControls=this.createCameraControls(),this._cameraControls.addEventListener("change",()=>{this.events.viewChanged.dispatch({view:this})}),this._raycaster=new g.Raycaster}get width(){return this._width}set width(e){this._width=e}get height(){return this._height}set height(e){this._height=e}get enabled(){return this._cameraControls.enabled}set enabled(e){this._cameraControls.enabled=e}get center(){return this._camera.cwcs2Wcs({x:this._width/2,y:this._height/2},this._width,this._height)}set center(e){this._camera.position.set(e.x,e.y,this._camera.position.z),this._camera.updateProjectionMatrix()}cwcs2Wcs(e){return this._camera.cwcs2Wcs(e,this._width,this._height)}wcs2Cwcs(e){return this._camera.wcs2Cwcs(e,this._width,this._height)}pointToBox(e,t){const r=this.wcs2Cwcs(e),i=this.cwcs2Wcs({x:r.x+t,y:r.y+t}),s=this.cwcs2Wcs({x:r.x-t,y:r.y-t});return new x.AcGeBox2d().setFromPoints([i,s])}resetRaycaster(e,t){const r=this._camera.wcs2Ndc(e,this._width,this._height);return this._raycaster.setFromCamera(new g.Vector2(r.x,r.y),this._camera.internalCamera),this._raycaster.params.Line.threshold=t,this._raycaster.params.Points.threshold=t,this._raycaster}zoomTo(e,t=1.1){const r=new x.AcGeVector2d;e.getSize(r);const i=new x.AcGeVector2d;e.getCenter(i);const s=new g.Vector3(i.x,i.y,0);this._camera.position.set(i.x,i.y,this._camera.position.z),this._camera.lookAt(s),this._camera.setRotationFromEuler(new g.Euler(0,0,0));const o=r.x*t,a=r.y*t,c=this._width/o,l=this._height/a;this._camera.zoom=Math.min(c,l),this._cameraControls.target=s,this.updateCameraFrustum()}updateCameraFrustum(e,t){const r=(e??this._width)/(t??this._height);this._camera.left=-r*this._frustum,this._camera.right=r*this._frustum,this._camera.top=this._frustum,this._camera.bottom=-this._frustum,this._camera.updateProjectionMatrix(),this._cameraControls.update()}createCamera(){const e=new g.OrthographicCamera(-this._width/2,this._width/2,this._height/2,-this._height/2,.1,1e3);return e.position.set(0,0,500),e.up.set(0,1,0),e.updateProjectionMatrix(),e}createCameraControls(){const e=new to.OrbitControls(this._camera.internalCamera,this._renderer.domElement);return e.enableDamping=!1,e.autoRotate=!1,e.enableRotate=!1,e.zoomSpeed=5,e.mouseButtons={MIDDLE:g.MOUSE.PAN},e.update(),e}}class hn extends js{static calculateViewportWindowBox(e,t){const r=t.box,i=new x.AcGeBox2d;return i.expandByPoint(e.wcs2Cwcs(r.min)),i.expandByPoint(e.wcs2Cwcs(r.max)),i}constructor(e,t,r){const i=hn.calculateViewportWindowBox(e,t).size;super(r,i.width,i.height),this._parentView=e,this._viewport=t.clone(),this._frustum*=t.height/e.height,this.zoomTo(this._viewport.viewBox),this.enabled=!1}get viewport(){return this._viewport}update(){this.zoomTo(this._viewport.viewBox)}render(e){const t=hn.calculateViewportWindowBox(this._parentView,this._viewport);if(!t.isEmpty()){const r=this._parentView.height-t.min.y-t.size.height;this._renderer.setViewport(t.min.x,r,t.size.width,t.size.height),this._renderer.internalRenderer.setScissor(t.min.x,r,t.size.width,t.size.height),this._renderer.internalRenderer.setScissorTest(!0),this._renderer.render(e,this._camera),this._renderer.internalRenderer.setScissorTest(!1)}}}const Vu={threeBo2dToGeBox2d:n=>new x.AcGeBox2d(n.min,n.max),geBox2dToThreeBox2d:n=>new g.Box2(n.min,n.max),threeBox3dToGeBox3d:n=>new x.AcGeBox3d(n.min,n.max),geBox3dToThreeBox3d:n=>new g.Box3(n.min,n.max),goBox3dToGeBox2d:n=>new x.AcGeBox2d(n.min,n.max),threeBox3dToGeBox2d:n=>new x.AcGeBox2d(n.min,n.max),geBox2dToThreeBox3d:n=>{const e=new g.Box3;return e.min.set(n.min.x,n.min.y,0),e.max.set(n.max.x,n.max.y,0),e}};var un=(n=>(n[n.LEFT_BOTTOM=0]="LEFT_BOTTOM",n[n.LEFT_TOP=1]="LEFT_TOP",n[n.RIGHT_TOP=2]="RIGHT_TOP",n[n.RIGHT_BOTTOM=4]="RIGHT_BOTTOM",n))(un||{});class Hu extends g.Object3D{constructor(e,t,r=150,i=2){super(),this.camera=e,this.renderer=t,this.gizmoCamera=new g.OrthographicCamera(-2,2,2,-2,0,4),this.gizmoCamera.position.set(0,0,2),this.gizmoDim=r,this.gizmoPos=i,this.initialize()}initialize(){}update(){this.updateOrientation();const e=this.renderer.autoClear;this.renderer.autoClear=!1,this.renderer.clearDepth();const t=new g.Vector4;this.renderer.getViewport(t);const r=this.calculateViewportPos();this.renderer.setViewport(r.x,r.y,this.gizmoDim,this.gizmoDim),this.renderer.render(this,this.gizmoCamera),this.renderer.setViewport(t.x,t.y,t.z,t.w),this.renderer.autoClear=e}dispose(){}updateOrientation(){this.quaternion.copy(this.camera.quaternion).invert(),this.updateMatrixWorld()}calculatePosInViewport(e,t,r){const i=(e-r.min.x)/this.gizmoDim*2-1,s=-((t-r.min.y)/this.gizmoDim)*2+1;return{x:i,y:s}}calculateViewportPos(){const e=this.renderer.domElement,t=e.offsetWidth,r=e.offsetHeight,i=this.gizmoPos,s=this.gizmoDim;let o=t-s,a=r-s;switch(i){case 0:o=0,a=0;break;case 1:o=0;break;case 4:a=0;break}return{x:o,y:a}}calculateViewportBbox(){const e=this.renderer.domElement,t=e.offsetWidth,r=e.offsetHeight,i=this.gizmoPos,s=this.gizmoDim,o=new g.Box2(new g.Vector2(t-s,0),new g.Vector2(t,s));switch(i){case 0:o.set(new g.Vector2(0,r-s),new g.Vector2(s,r));break;case 1:o.set(new g.Vector2(0,0),new g.Vector2(s,s));break;case 4:o.set(new g.Vector2(t-s,r-s),new g.Vector2(t,r));break}return o}}function ju(n,e){const t=e.font||"Helvetica",r=e.fontSize||30,i=e.width||200,s=e.height||200,o=e.bgColor?e.bgColor.join(", "):"255, 255, 255, 1.0",a=e.color?e.color.join(", "):"0, 0, 0, 1.0",c=document.createElement("canvas");c.width=i,c.height=s;const l=c.getContext("2d");if(l){l.font=`bold ${r}px ${t}`,l.fillStyle=`rgba(${o})`,l.fillRect(0,0,i,s);const u=l.measureText(n).width;l.fillStyle=`rgba(${a})`,l.fillText(n,i/2-u/2,s/2+r/2-2)}const h=new g.Texture(c);return h.minFilter=g.LinearFilter,h.needsUpdate=!0,h}function fr(n){const e=ju(n,{fontSize:100,font:"Arial Narrow, sans-serif",color:[255,255,255,1],bgColor:[0,0,0,0]}),t=new g.SpriteMaterial({map:e,transparent:!0});return new g.Sprite(t)}un.RIGHT_TOP;const Wu={pos:un.LEFT_BOTTOM,size:100,hasZAxis:!0};class Xu extends Hu{constructor(e,t,r){const i={...Wu,...r};super(e,t,i.size,r.pos),this.hasZAxis=i.hasZAxis;const s=[0,0,0,2,0,0,0,0,0,0,2,0],o=[1,0,0,1,.6,0,0,1,0,.6,1,0];this.hasZAxis&&(s.push(0,0,0,0,0,2),o.push(0,0,1,0,.6,1));const a=new g.BufferGeometry;a.setAttribute("position",new g.Float32BufferAttribute(s,3)),a.setAttribute("color",new g.Float32BufferAttribute(o,3));const c=new g.LineBasicMaterial({vertexColors:!0,toneMapped:!1});this.axes=new g.LineSegments(a,c),this.axes.position.set(-1,-1,-1),this.add(this.axes),this.xText=fr("X"),this.xText.position.set(1.5,-1,-1),this.add(this.xText),this.yText=fr("Y"),this.yText.position.set(-1,1.5,-1),this.add(this.yText),this.hasZAxis&&(this.zText=fr("Z"),this.zText.position.set(-1,-1,1.5),this.add(this.zText))}setLineColors(e,t){const r=new g.Color,i=this.axes.geometry.attributes.color.array;return r.set(e),r.toArray(i,0),r.toArray(i,3),r.set(t),r.toArray(i,6),r.toArray(i,9),this.axes.geometry.attributes.color.needsUpdate=!0,this}setTextColor(e){this.xText.material.color=e,this.yText.material.color=e}dispose(){var e,t;this.axes.geometry.dispose(),this.axes.material.dispose(),this.xText.geometry.dispose(),this.xText.material.dispose(),this.yText.geometry.dispose(),this.yText.material.dispose(),this.hasZAxis&&((e=this.zText)==null||e.geometry.dispose(),(t=this.zText)==null||t.material.dispose())}}class qu extends js{constructor(e,t,r,i){super(e,r,i),this._layoutBtrId=t,this._mode=Ie.SELECTION,this._axesGizmo=this.createAxesGizmo(),this._viewportViews=new Map}get layoutBtrId(){return this._layoutBtrId}get mode(){return this._mode}set mode(e){e==Ie.SELECTION?this._cameraControls.mouseButtons={MIDDLE:g.MOUSE.PAN}:e==Ie.PAN&&(this._cameraControls.mouseButtons={LEFT:g.MOUSE.PAN}),this._cameraControls.update(),this._mode=e}get viewportCount(){return this._viewportViews.size}addViewport(e){this._viewportViews.set(e.viewport.id,e)}removeViewport(e){this._viewportViews.delete(e)}resize(e,t){this._height=t,this._width=e,this.updateCameraFrustum(),this._viewportViews.forEach(r=>{r.update()})}render(e){var r;this._renderer.clear(),this._renderer.render(e.internalScene,this._camera);const t=e.modelSpaceLayout;t&&this.drawViewports(t.internalObject),(r=this._axesGizmo)==null||r.update()}createAxesGizmo(){return new Xu(this._camera.internalCamera,this._renderer.internalRenderer,{hasZAxis:!1,pos:un.LEFT_BOTTOM})}drawViewports(e){if(this._viewportViews.size>0){const t=this._renderer.autoClear;this._renderer.autoClear=!1;const r=new g.Vector4;this._renderer.getViewport(r),this._renderer.clearDepth();const i=e.visible;e.visible=!0,this._viewportViews.forEach(s=>{s.render(e)}),e.visible=i,this._renderer.setViewport(r.x,r.y,r.z,r.w),this._renderer.autoClear=t}}}class Yu{constructor(){this._activeLayoutBtrId="",this._layoutViews=new Map}get activeLayoutBtrId(){return this._activeLayoutBtrId}set activeLayoutBtrId(e){this._activeLayoutBtrId=e,this._layoutViews.forEach(t=>{t.enabled=t.layoutBtrId==e})}get activeLayoutView(){return this._layoutViews.get(this._activeLayoutBtrId)}has(e){return this._layoutViews.has(e)}getAt(e){return this._layoutViews.get(e)}resize(e,t){this._layoutViews.forEach(r=>{r.resize(e,t)})}add(e){this._layoutViews.set(e.layoutBtrId,e)}render(e){var t;(t=this.activeLayoutView)==null||t.render(e)}}function Ws(n,e,t=0,r=n.length-1,i=$u){for(;r>t;){if(r-t>600){const c=r-t+1,l=e-t+1,h=Math.log(c),d=.5*Math.exp(2*h/3),u=.5*Math.sqrt(h*d*(c-d)/c)*(l-c/2<0?-1:1),p=Math.max(t,Math.floor(e-l*d/c+u)),f=Math.min(r,Math.floor(e+(c-l)*d/c+u));Ws(n,e,p,f,i)}const s=n[e];let o=t,a=r;for(Dt(n,t,e),i(n[r],s)>0&&Dt(n,t,r);o<a;){for(Dt(n,o,a),o++,a--;i(n[o],s)<0;)o++;for(;i(n[a],s)>0;)a--}i(n[t],s)===0?Dt(n,t,a):(a++,Dt(n,a,r)),a<=e&&(t=a+1),e<=a&&(r=a-1)}}function Dt(n,e,t){const r=n[e];n[e]=n[t],n[t]=r}function $u(n,e){return n<e?-1:n>e?1:0}class Zu{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data;const r=[];if(!pn(e,t))return r;const i=this.toBBox,s=[];for(;t;){for(let o=0;o<t.children.length;o++){const a=t.children[o],c=t.leaf?i(a):a;pn(e,c)&&(t.leaf?r.push(a):mr(e,c)?this._all(a,r):s.push(a))}t=s.pop()}return r}collides(e){let t=this.data;if(!pn(e,t))return!1;const r=[];for(;t;){for(let i=0;i<t.children.length;i++){const s=t.children[i],o=t.leaf?this.toBBox(s):s;if(pn(e,o)){if(t.leaf||mr(e,o))return!0;r.push(s)}}t=r.pop()}return!1}load(e){if(!(e&&e.length))return this;if(e.length<this._minEntries){for(let r=0;r<e.length;r++)this.insert(e[r]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(!this.data.children.length)this.data=t;else if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){const r=this.data;this.data=t,t=r}this._insert(t,this.data.height-t.height-1,!0)}return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=ut([]),this}remove(e,t){if(!e)return this;let r=this.data;const i=this.toBBox(e),s=[],o=[];let a,c,l;for(;r||s.length;){if(r||(r=s.pop(),c=s[s.length-1],a=o.pop(),l=!0),r.leaf){const h=Qu(e,r.children,t);if(h!==-1)return r.children.splice(h,1),s.push(r),this._condense(s),this}!l&&!r.leaf&&mr(r,i)?(s.push(r),o.push(a),a=0,c=r,r=r.children[0]):c?(a++,r=c.children[a],l=!1):r=null}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){const r=[];for(;e;)e.leaf?t.push(...e.children):r.push(...e.children),e=r.pop();return t}_build(e,t,r,i){const s=r-t+1;let o=this._maxEntries,a;if(s<=o)return a=ut(e.slice(t,r+1)),ht(a,this.toBBox),a;i||(i=Math.ceil(Math.log(s)/Math.log(o)),o=Math.ceil(s/Math.pow(o,i-1))),a=ut([]),a.leaf=!1,a.height=i;const c=Math.ceil(s/o),l=c*Math.ceil(Math.sqrt(o));Xs(e,t,r,l,this.compareMinX);for(let h=t;h<=r;h+=l){const d=Math.min(h+l-1,r);Xs(e,h,d,c,this.compareMinY);for(let u=h;u<=d;u+=c){const p=Math.min(u+c-1,d);a.children.push(this._build(e,u,p,i-1))}}return ht(a,this.toBBox),a}_chooseSubtree(e,t,r,i){for(;i.push(t),!(t.leaf||i.length-1===r);){let s=1/0,o=1/0,a;for(let c=0;c<t.children.length;c++){const l=t.children[c],h=gr(l),d=ed(e,l)-h;d<o?(o=d,s=h<s?h:s,a=l):d===o&&h<s&&(s=h,a=l)}t=a||t.children[0]}return t}_insert(e,t,r){const i=r?e:this.toBBox(e),s=[],o=this._chooseSubtree(i,this.data,t,s);for(o.children.push(e),Ut(o,i);t>=0&&s[t].children.length>this._maxEntries;)this._split(s,t),t--;this._adjustParentBBoxes(i,s,t)}_split(e,t){const r=e[t],i=r.children.length,s=this._minEntries;this._chooseSplitAxis(r,s,i);const o=this._chooseSplitIndex(r,s,i),a=ut(r.children.splice(o,r.children.length-o));a.height=r.height,a.leaf=r.leaf,ht(r,this.toBBox),ht(a,this.toBBox),t?e[t-1].children.push(a):this._splitRoot(r,a)}_splitRoot(e,t){this.data=ut([e,t]),this.data.height=e.height+1,this.data.leaf=!1,ht(this.data,this.toBBox)}_chooseSplitIndex(e,t,r){let i,s=1/0,o=1/0;for(let a=t;a<=r-t;a++){const c=Rt(e,0,a,this.toBBox),l=Rt(e,a,r,this.toBBox),h=td(c,l),d=gr(c)+gr(l);h<s?(s=h,i=a,o=d<o?d:o):h===s&&d<o&&(o=d,i=a)}return i||r-t}_chooseSplitAxis(e,t,r){const i=e.leaf?this.compareMinX:Ju,s=e.leaf?this.compareMinY:Ku,o=this._allDistMargin(e,t,r,i),a=this._allDistMargin(e,t,r,s);o<a&&e.children.sort(i)}_allDistMargin(e,t,r,i){e.children.sort(i);const s=this.toBBox,o=Rt(e,0,t,s),a=Rt(e,r-t,r,s);let c=dn(o)+dn(a);for(let l=t;l<r-t;l++){const h=e.children[l];Ut(o,e.leaf?s(h):h),c+=dn(o)}for(let l=r-t-1;l>=t;l--){const h=e.children[l];Ut(a,e.leaf?s(h):h),c+=dn(a)}return c}_adjustParentBBoxes(e,t,r){for(let i=r;i>=0;i--)Ut(t[i],e)}_condense(e){for(let t=e.length-1,r;t>=0;t--)e[t].children.length===0?t>0?(r=e[t-1].children,r.splice(r.indexOf(e[t]),1)):this.clear():ht(e[t],this.toBBox)}}function Qu(n,e,t){if(!t)return e.indexOf(n);for(let r=0;r<e.length;r++)if(t(n,e[r]))return r;return-1}function ht(n,e){Rt(n,0,n.children.length,e,n)}function Rt(n,e,t,r,i){i||(i=ut(null)),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(let s=e;s<t;s++){const o=n.children[s];Ut(i,n.leaf?r(o):o)}return i}function Ut(n,e){return n.minX=Math.min(n.minX,e.minX),n.minY=Math.min(n.minY,e.minY),n.maxX=Math.max(n.maxX,e.maxX),n.maxY=Math.max(n.maxY,e.maxY),n}function Ju(n,e){return n.minX-e.minX}function Ku(n,e){return n.minY-e.minY}function gr(n){return(n.maxX-n.minX)*(n.maxY-n.minY)}function dn(n){return n.maxX-n.minX+(n.maxY-n.minY)}function ed(n,e){return(Math.max(e.maxX,n.maxX)-Math.min(e.minX,n.minX))*(Math.max(e.maxY,n.maxY)-Math.min(e.minY,n.minY))}function td(n,e){const t=Math.max(n.minX,e.minX),r=Math.max(n.minY,e.minY),i=Math.min(n.maxX,e.maxX),s=Math.min(n.maxY,e.maxY);return Math.max(0,i-t)*Math.max(0,s-r)}function mr(n,e){return n.minX<=e.minX&&n.minY<=e.minY&&e.maxX<=n.maxX&&e.maxY<=n.maxY}function pn(n,e){return e.minX<=n.maxX&&e.minY<=n.maxY&&e.maxX>=n.minX&&e.maxY>=n.minY}function ut(n){return{children:n,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Xs(n,e,t,r,i){const s=[e,t];for(;s.length;){if(t=s.pop(),e=s.pop(),t-e<=r)continue;const o=e+Math.ceil((t-e)/r/2)*r;Ws(n,o,e,t,i),s.push(e,o,o,t)}}class nd{constructor(e){this._group=new Eu,this._name=e}get name(){return this._name}set name(e){this._name=e}get visible(){return this._group.visible}set visible(e){this._group.visible=e}get internalObject(){return this._group}get stats(){const e=this._group.stats;return{name:this._name,...e}}get entityCount(){return this._group.entityCount}rerenderPoints(e){this._group.rerenderPoints(e)}hasEntity(e){return this._group.hasEntity(e)}addEntity(e){this._group.addEntity(e)}isIntersectWith(e,t){return this._group.isIntersectWith(e,t)}remove(e){throw new Error("Not implemented yet!")}update(e){return this._group.add(e),!0}hover(e){e.forEach(t=>{this._group.hover(t)})}unhover(e){e.forEach(t=>{this._group.unhover(t)})}select(e){e.forEach(t=>{this._group.select(t)})}unselect(e){e.forEach(t=>{this._group.unselect(t)})}}class rd{constructor(){this._group=new g.Group,this._indexTree=new Zu,this._box=new g.Box3,this._layers=new Map}get internalObject(){return this._group}get layers(){return this._layers}get box(){return this._box}get visible(){return this._group.visible}set visible(e){this._group.visible=e}get entityCount(){let e=0;return this._layers.forEach(t=>e+=t.entityCount),e}get stats(){const e=[];let t=0,r=0,i=0,s=0,o=0;return this._layers.forEach(a=>{const c=a.stats;e.push(c),i+=c.line.indexed.geometrySize+c.line.nonIndexed.geometrySize,s+=c.mesh.indexed.geometrySize+c.mesh.nonIndexed.geometrySize,o+=c.point.indexed.geometrySize+c.point.nonIndexed.geometrySize,t+=c.summary.totalGeometrySize,r+=c.summary.totalMappingSize}),{layers:e,summary:{entityCount:this.entityCount,totalSize:{line:i,mesh:s,point:o,geometry:t,mapping:r}}}}clear(){return this._layers.forEach(e=>{this._group.remove(e.internalObject)}),this._layers.clear(),this._box.makeEmpty(),this._indexTree.clear(),this}rerenderPoints(e){this._layers.forEach(t=>{t.rerenderPoints(e)})}isIntersectWith(e,t){const r=this.getLayerByObjectId(e);return r&&r.isIntersectWith(e,t)}addEntity(e,t=!0){if(!e.objectId)throw new Error("[AcTrEntity] Object id is required to add one entity!");if(!e.layerName)throw new Error("[AcTrEntity] Layer name is required to add one entity!");const r=this.getLayer(e.layerName,!0);if(r){r.addEntity(e);const i=e.box;t&&this._box.union(i),this._indexTree.insert({minX:i.min.x,minY:i.min.y,maxX:i.max.x,maxY:i.max.y,id:e.objectId})}return this}remove(e){for(const[t,r]of this._layers)if(r.remove(e))return!0;return!1}update(e){for(const[t,r]of this._layers)if(r.update(e))return!0;return!1}hover(e){e.forEach(t=>{const r=this.getLayerByObjectId(t);r&&r.hover([t])})}unhover(e){e.forEach(t=>{const r=this.getLayerByObjectId(t);r&&r.unhover([t])})}select(e){e.forEach(t=>{const r=this.getLayerByObjectId(t);r&&r.select([t])})}unselect(e){e.forEach(t=>{const r=this.getLayerByObjectId(t);r&&r.unselect([t])})}setSnapObject(e){this._snapPointsObject&&this._group.remove(this._snapPointsObject),this._snapPointsObject=e,this._group.add(e)}search(e){return this._indexTree.search({minX:e.min.x,minY:e.min.y,maxX:e.max.x,maxY:e.max.y})}getLayerByObjectId(e){for(const[t,r]of this._layers)if(r.hasEntity(e))return r}getLayer(e,t=!0){let r=this._layers.get(e);return r===void 0&&t&&(r=new nd(e),this._layers.set(e,r),this._group.add(r.internalObject)),r}}class id{constructor(){this._scene=new g.Scene,this._layouts=new Map,this._activeLayoutBtrId="",this._modelSpaceBtrId=""}get layouts(){return this._layouts}get box(){var e;return(e=this.activeLayout)==null?void 0:e.box}get internalScene(){return this._scene}get modelSpaceBtrId(){return this._modelSpaceBtrId}set modelSpaceBtrId(e){if(this._modelSpaceBtrId=e,!this._layouts.has(e))throw new Error(`[AcTrScene] No layout assiciated with the specified block table record id '${e}'!`)}get activeLayoutBtrId(){return this._activeLayoutBtrId}set activeLayoutBtrId(e){this._activeLayoutBtrId=e,this._layouts.forEach((t,r)=>{t.visible=e==r})}get activeLayout(){if(this._activeLayoutBtrId&&this._layouts.has(this._activeLayoutBtrId))return this._layouts.get(this._activeLayoutBtrId)}get modelSpaceLayout(){if(this._modelSpaceBtrId&&this._layouts.has(this._modelSpaceBtrId))return this._layouts.get(this._modelSpaceBtrId)}get stats(){const e=[];return this._layouts.forEach(t=>e.push(t.stats)),{layouts:e}}addEmptyLayout(e){const t=new rd;return this._layouts.set(e,t),this._scene.add(t.internalObject),t.visible=e==this._activeLayoutBtrId,t}clear(){return this._layouts.forEach(e=>{this._scene.remove(e.internalObject),e.clear()}),this._layouts.clear(),this._scene.clear(),this}setLayerVisibility(e,t){var i;let r=!1;return(i=this.activeLayout)==null||i.layers.forEach(s=>{s.name===e&&(s.visible=t,r=!0)}),r}hover(e){return this.activeLayout?(this.activeLayout.hover(e),!0):!1}unhover(e){return this.activeLayout?(this.activeLayout.unhover(e),!0):!1}select(e){return this.activeLayout?(this.activeLayout.select(e),!0):!1}unselect(e){return this.activeLayout?(this.activeLayout.unselect(e),!0):!1}search(e){const t=this.activeLayout;return t?t==null?void 0:t.search(e):[]}addEntity(e,t=!0){const r=e.ownerId;if(r){let i=this._layouts.get(r);i||(i=this.addEmptyLayout(r)),i.addEntity(e,t)}else console.warn("[AcTrSecene] The owner id of one entity cannot be empty!");return this}remove(e){for(const[t,r]of this._layouts)if(r.remove(e))return!0;return!1}update(e){for(const[t,r]of this._layouts)if(r.update(e))return!0;return!1}setSnapObject(e){return this._layouts.forEach(t=>{t.setSnapObject(e)}),this}}const yr={background:0};class qs extends Cr{constructor(e=yr){const t={...yr,...e},r=new g.WebGLRenderer({antialias:!0,alpha:!0,canvas:e.canvas});t.canvas==null&&(t.canvas=r.domElement),super(t.canvas),e.calculateSizeCallback&&this.setCalculateSizeCallback(e.calculateSizeCallback),r.setPixelRatio(Math.min(window.devicePixelRatio,2)),r.setSize(this.width,this.height),this._renderer=new Nu(r);const i=pt.instance.fontMapping;this._renderer.setFontMapping(i),this._renderer.events.fontNotFound.addEventListener(s=>{Ce.emit("font-not-found",{fontName:s.fontName,count:s.count??0})}),this._scene=this.createScene(),this._renderer.setClearColor(t.background||0),this._stats=this.createStats(pt.instance.isShowStats),pt.instance.events.modified.addEventListener(s=>{s.key=="isShowStats"&&this.toggleStatsVisibility(this._stats,s.value)}),this.canvas.addEventListener("click",()=>{this.mode==Ie.SELECTION&&this.select()}),document.addEventListener("keydown",s=>{s.code==="Escape"&&this.selectionSet.clear()}),x.acdbHostApplicationServices().layoutManager.events.layoutSwitched.addEventListener(s=>{this.activeLayoutBtrId=s.layout.blockTableRecordId}),this._missedImages=new Map,this._layoutViewManager=new Yu,this.initialize(),this.onWindowResize(),this.animate(),this._isDirty=!0}initialize(){this.setCursor(qe.Crosshair)}get mode(){const e=this.activeLayoutView;return e?e.mode:Ie.SELECTION}set mode(e){this.activeLayoutView.mode=e,this.editor.getPoint()}get renderer(){return this._renderer}get isDirty(){return this._isDirty}set isDirty(e){this._isDirty=e}get missedData(){return{fonts:this._renderer.missedFonts,images:this._missedImages}}get center(){return this.activeLayoutView.center}set center(e){this.activeLayoutView.center=e}get backgroundColor(){return this._renderer.getClearColor()}set backgroundColor(e){this._renderer.setClearColor(e),this._isDirty=!0}get modelSpaceBtrId(){return this._scene.modelSpaceBtrId}set modelSpaceBtrId(e){this._scene.modelSpaceBtrId=e}get activeLayoutBtrId(){return this._scene.activeLayoutBtrId}set activeLayoutBtrId(e){this._layoutViewManager.activeLayoutBtrId=e,this._scene.activeLayoutBtrId=e,this._isDirty=!0}get activeLayoutView(){return this._layoutViewManager.activeLayoutView}get stats(){return this._scene.stats}animate(){var e;requestAnimationFrame(this.animate.bind(this)),this._isDirty&&(this._layoutViewManager.render(this._scene),(e=this._stats)==null||e.update(),this._isDirty=!1)}cwcs2Wcs(e){const t=this.activeLayoutView;return t?t.cwcs2Wcs(e):new x.AcGePoint2d(e)}wcs2Cwcs(e){const t=this.activeLayoutView;return t?t.wcs2Cwcs(e):new x.AcGePoint2d(e)}zoomTo(e,t=1.1){this.activeLayoutView.zoomTo(e,t),this._isDirty=!0}rerenderPoints(e){const t=this._scene.activeLayout;t&&(t.rerenderPoints(e),this._isDirty=!0)}zoomToFit(){if(this._scene.box){const e=Vu.threeBox3dToGeBox2d(this._scene.box);this.zoomTo(e),this._isDirty=!0}}pick(e){e==null&&(e=this.curPos);const t=[],r=this._scene.activeLayout;if(r){const i=this.activeLayoutView,s=i.pointToBox(e,this.selectionBoxSize),o=this._scene.search(s),a=Math.max(s.size.width/2,s.size.height/2),c=i.resetRaycaster(e,a);o.forEach(l=>{const h=l.id;r.isIntersectWith(h,c)&&t.push(h)})}return t}search(e){return this._scene.search(e)}select(e){const t=[];this.pick(e).forEach(i=>t.push(i)),t.length>0&&this.selectionSet.add(t)}selectByBox(e){const t=[];this._scene.search(e).forEach(i=>t.push(i.id)),this.selectionSet.add(t)}addEntity(e){let t=[];Array.isArray(e)?t=e:t.push(e);for(let r=0;r<t.length;++r){const i=t[r];let s=i.draw(this._renderer);if(s){s.objectId=i.objectId,s.ownerId=i.ownerId,s.layerName=i.layer,s.visible=i.visibility;const o=!(i instanceof x.AcDbRay||i instanceof x.AcDbXline);this._scene.addEntity(s,o),this._isDirty=!0,s.dispose(),s=null}if(i instanceof x.AcDbViewport){if(i.number>1){const o=this._layoutViewManager.getAt(i.ownerId);if(o){const a=new hn(o,i.toGiViewport(),this._renderer);o.addViewport(a)}}}else if(i instanceof x.AcDbRasterImage){const o=i.imageFileName;o&&this._missedImages.set(i.objectId,o)}}}removeEntity(e){this._scene.remove(e)}updateEntity(e){let t=[];Array.isArray(e)?t=e:t.push(e);for(let r=0;r<t.length;++r){const i=t[r],s=i.draw(this._renderer);s&&(s.objectId=i.objectId,s.ownerId=i.ownerId,s.layerName=i.layer,s.visible=i.visibility,this._scene.update(s))}this._isDirty=!0,setTimeout(()=>{this._isDirty=!0},100)}addLayout(e){this._scene.addEmptyLayout(e.blockTableRecordId),this.createLayoutViewIfNeeded(e.blockTableRecordId)}clear(){this._scene.clear(),this._isDirty=!0,this._missedImages.clear(),this._renderer.clearMissedFonts()}highlight(e){this._isDirty=this._scene.select(e)}unhighlight(e){this._isDirty=this._scene.unselect(e)}setLayerVisibility(e,t){this._isDirty=this._scene.setLayerVisibility(e,t)}onHover(e){this._isDirty=this._scene.hover([e])}onUnhover(e){this._isDirty=this._scene.unhover([e])}createScene(){const e=new id;return e.layouts.forEach(t=>{t.setSnapObject(this.renderer.createObject())}),e}createStats(e){const t=new no;document.body.appendChild(t.dom);const r=t.dom;return r.style.position="fixed",r.style.inset="unset",r.style.bottom="30px",r.style.right="0px",this.toggleStatsVisibility(t,e),t}onWindowResize(){super.onWindowResize(),this._renderer.setSize(this.width,this.height),this._layoutViewManager.resize(this.width,this.height),this._isDirty=!0}createLayoutViewIfNeeded(e){let t=this._layoutViewManager.getAt(e);return t==null&&(t=new qu(this._renderer,e,this.width,this.height),t.events.viewChanged.addEventListener(()=>{this._isDirty=!0}),this._layoutViewManager.add(t)),t}toggleStatsVisibility(e,t){t?e.dom.style.display="block":e.dom.style.display="none"}}const Ys="simsun";class dt{static get instance(){return dt._instance||(dt._instance=new dt),dt._instance}createExampleDoc1(e){for(let i=0;i<2;++i)for(let s=0;s<2;++s){const o=new x.AcDbHatch,a=new x.AcGePolyline2d;a.addVertexAt(0,{x:s*100,y:i*100,bulge:1}),a.addVertexAt(1,{x:s*100+100,y:i*100,bulge:1}),a.closed=!0,o.add(a),e.tables.blockTable.modelSpace.appendEntity(o)}}createExampleDoc2(e){const t=e.tables.blockTable.modelSpace;t.appendEntity(this.createArc()),this.createLines().forEach(i=>{e.tables.blockTable.modelSpace.appendEntity(new x.AcDbLine(i.startPoint,i.endPoint))}),t.appendEntity(this.createHatch()),e.tables.textStyleTable.add(this.createTextStyle()),t.appendEntity(this.createMText())}createTextStyle(){const e={bigFont:"",color:16777215,extendedFont:Ys,fixedTextHeight:0,font:Ys,lastHeight:.2,name:"Standard",obliqueAngle:0,standardFlag:0,textGenerationFlag:0,widthFactor:.667};return new x.AcDbTextStyleTableRecord(e)}createMText(){const e=new x.AcDbMText;return e.attachmentPoint=x.AcGiMTextAttachmentPoint.MiddleLeft,e.color=new x.AcCmColor().setColorName("red"),e.layer="0",e.location=new x.AcGePoint3d(9850,86773,0),e.contents="{\\W0.667;\\T1.1;智慧8081}",e.height=200,e.width=1e3,e.styleName="Standard",e}createHatch(){const e=this.createLines(),t=new x.AcDbHatch,r=new x.AcGeLoop2d;return r.add(new x.AcGeCircArc2d({x:20241.23355899991,y:174118.6312674369},89258.30757455899,x.AcGeMathUtil.degToRad(262.2471115358437),x.AcGeMathUtil.degToRad(264.444541053754),!1)),e.forEach(i=>{r.add(new x.AcGeLine2d(i.startPoint,i.endPoint))}),t.add(r),t}createArc(){return new x.AcDbArc({x:20241.23355899991,y:174118.6312674369,z:0},89258.30757455899,x.AcGeMathUtil.degToRad(262.2471115358437),x.AcGeMathUtil.degToRad(264.444541053754))}createLines(){const e=[];return e.push(new x.AcGeLine3d({x:11600.20888122753,y:85279.57362051727,z:0},{x:11600.20890652924,y:86546.03982284805,z:0})),e.push(new x.AcGeLine3d({x:11600.20890652924,y:86546.03982284805,z:0},{x:10850.20885583921,y:86546.03980174381,z:0})),e.push(new x.AcGeLine3d({x:10850.2088602169,y:86546.03967292747,z:0},{x:9050.208860216895,y:86546.039672927,z:0})),e.push(new x.AcGeLine3d({x:9050.208855839213,y:86546.0397510943,z:0},{x:8200.209067034302,y:86546.039727177,z:0})),e.push(new x.AcGeLine3d({x:8200.209067034302,y:86546.039727177,z:0},{x:8200.209067033837,y:85676.22514764359,z:0})),e}}class sd{constructor(e){this._cadRenderer=e,this._avaiableFonts=[]}get avaiableFonts(){return this._avaiableFonts}async getAvaiableFonts(){if(this._avaiableFonts.length==0){const e="https://cdn.jsdelivr.net/gh/mlight-lee/cad-data/fonts/",t=e+"fonts.json";try{const r=await fetch(t);this._avaiableFonts=await r.json()}catch{Ce.emit("failed-to-get-avaiable-fonts",{url:t})}this._avaiableFonts.forEach(r=>{r.url=e+r.file})}return this._avaiableFonts}async load(e){await this.getAvaiableFonts();const t=[];e.forEach(i=>{const s=i.toLowerCase(),o=gn.find(this._avaiableFonts,a=>gn.findIndex(a.name,c=>c.toLowerCase()==s)>=0);o&&t.push(o.url)}),(await this._cadRenderer.loadFonts(t)).forEach(i=>{i.status||Ce.emit("font-not-loaded",{fontName:i.fontName,url:i.url})})}}class ce{constructor(e){this.events={documentCreated:new x.AcCmEventManager,documentActivated:new x.AcCmEventManager};const t=new Ir;t.database.events.openProgress.addEventListener(s=>{Ce.emit("open-file-progress",{database:t.database,percentage:s.percentage,stage:s.stage,subStage:s.subStage,stageStatus:s.stageStatus})});const r=()=>({width:window.innerWidth,height:window.innerHeight-30}),i=new qs({canvas:e,calculateSizeCallback:r});this._context=new xr(i,t),this._fontLoader=new sd(i.renderer),x.acdbHostApplicationServices().workingDatabase=t.database,this.registerCommands()}static createInstance(e){return ce._instance==null&&(ce._instance=new ce(e)),this._instance}static get instance(){return ce._instance||(ce._instance=new ce),ce._instance}get context(){return this._context}get curDocument(){return this._context.doc}get mdiActiveDocument(){return this._context.doc}get curView(){return this._context.view}get editor(){return this._context.view.editor}get avaiableFonts(){return this._fontLoader.avaiableFonts}async loadFonts(e){await this._fontLoader.load(e)}async loadDefaultFonts(e){e==null?await this._fontLoader.load(["simkai"]):await this._fontLoader.load(e)}createExampleDoc(){setTimeout(async()=>{await this.loadDefaultFonts(),dt.instance.createExampleDoc2(this.curDocument.database),this.setLayoutInfo(),this.curView.zoomToFit()})}async openUrl(e,t){this.onBeforeOpenDocument(),t=this.setOptions(t);const r=await this.context.doc.openUri(e,t);return this.onAfterOpenDocument(r),r}async openDocument(e,t,r){this.onBeforeOpenDocument(),r=this.setOptions(r);const i=await this.context.doc.openDocument(e,t,r);return this.onAfterOpenDocument(i),i}registerCommands(){const e=oe.instance;e.addCommand(oe.SYSTEMT_COMMAND_GROUP_NAME,"pan","pan",new Dr),e.addCommand(oe.SYSTEMT_COMMAND_GROUP_NAME,"select","select",new Br),e.addCommand(oe.SYSTEMT_COMMAND_GROUP_NAME,"zoom","zoom",new Lr),e.addCommand(oe.SYSTEMT_COMMAND_GROUP_NAME,"zoomw","zoomw",new Mr),e.addCommand(oe.SYSTEMT_COMMAND_GROUP_NAME,"csvg","csvg",new Ar),e.addCommand(oe.SYSTEMT_COMMAND_GROUP_NAME,"qnew","qnew",new kr),e.addCommand(oe.SYSTEMT_COMMAND_GROUP_NAME,"open","open",new Er)}sendStringToExecute(e){const r=oe.instance.lookupGlobalCmd(e);r==null||r.execute(this.context)}onBeforeOpenDocument(){this.curView.clear()}onAfterOpenDocument(e){if(e){const t=this.context.doc;this.events.documentActivated.dispatch({doc:t}),this.setLayoutInfo();const r=t.database;this.curView.zoomTo(new x.AcGeBox2d(r.extmin,r.extmax))}}setOptions(e){return e==null?e={fontLoader:this._fontLoader}:e.fontLoader==null&&(e.fontLoader=this._fontLoader),e}setLayoutInfo(){const e=this.curView;e.activeLayoutBtrId=this.curDocument.database.currentSpaceId,e.modelSpaceBtrId=this.curDocument.database.currentSpaceId}}class $s{convert(e){const t=this.createEntity(e);return t&&this.processCommonAttrs(e,t),t}createEntity(e){return e.type=="ARC"?this.convertArc(e):e.type=="CIRCLE"?this.convertCirle(e):e.type=="DIMENSION"?this.convertDimension(e):e.type=="ELLIPSE"?this.convertEllipse(e):e.type=="HATCH"?this.convertHatch(e):e.type=="IMAGE"?this.convertImage(e):e.type=="LEADER"?this.convertLeader(e):e.type=="LINE"?this.convertLine(e):e.type=="LWPOLYLINE"?this.convertLWPolyline(e):e.type=="MTEXT"?this.convertMText(e):e.type=="POINT"?this.convertPoint(e):e.type=="POLYLINE"?this.convertPolyline(e):e.type=="RAY"?this.convertRay(e):e.type=="SPLINE"?this.convertSpline(e):e.type=="ACAD_TABLE"?this.convertTable(e):e.type=="TEXT"?this.convertText(e):e.type=="SOLID"?this.convertSolid(e):e.type=="VIEWPORT"?this.convertViewport(e):e.type=="XLINE"?this.convertXline(e):e.type=="INSERT"?this.convertBlockReference(e):null}convertArc(e){return new x.AcDbArc(e.center,e.radius,e.startAngle,e.endAngle)}convertCirle(e){return new x.AcDbCircle(e.center,e.radius)}convertEllipse(e){const t=new x.AcGeVector3d(e.majorAxisEndPoint),r=t.length();return new x.AcDbEllipse(e.center,x.AcGeVector3d.Z_AXIS,t,r,r*e.axisRatio,e.startAngle,e.endAngle)}convertLine(e){const t=e.startPoint,r=e.endPoint;return new x.AcDbLine(new x.AcGePoint3d(t.x,t.y,t.z),new x.AcGePoint3d(r.x,r.y,r.z))}convertSpline(e){return e.numberOfControlPoints>0&&e.numberOfKnots>0?new x.AcDbSpline(e.controlPoints,e.knots,e.weights,e.degree,!!(e.flag&1)):e.numberOfFitPoints>0?new x.AcDbSpline(e.fitPoints,"Uniform",e.degree,!!(e.flag&1)):null}convertPoint(e){const t=new x.AcDbPoint;return t.position=e.position,t}convertSolid(e){const t=new x.AcDbTrace;return t.setPointAt(0,{...e.corner1,z:0}),t.setPointAt(1,{...e.corner2,z:0}),t.setPointAt(2,{...e.corner3,z:0}),t.setPointAt(3,e.corner4?{...e.corner4,z:0}:{...e.corner3,z:0}),t.thickness=e.thickness,t}convertLWPolyline(e){const t=new x.AcDbPolyline;return t.closed=!!(e.flag&512),e.vertices.forEach((r,i)=>{t.addVertexAt(i,new x.AcGePoint2d(r.x,r.y),r.bulge,r.startWidth,r.endWidth)}),t}convertPolyline(e){const t=new x.AcDbPolyline;return t.closed=!!(e.flag&1),e.vertices.forEach((r,i)=>{t.addVertexAt(i,new x.AcGePoint2d(r.x,r.y),r.bulge,r.startWidth,r.endWidth)}),t}convertHatch(e){var t;const r=new x.AcDbHatch;return(t=e.definitionLines)==null||t.forEach(i=>{r.definitionLines.push({angle:i.angle,origin:i.base,delta:i.offset,dashPattern:i.numberOfDashLengths>0?i.dashLengths:[]})}),r.hatchStyle=e.hatchStyle,r.patternName=e.patternName,r.patternType=e.patternType,r.patternAngle=e.patternAngle==null?0:e.patternAngle,r.patternScale=e.patternScale==null?0:e.patternScale,e.boundaryPaths.forEach(i=>{if(i.boundaryPathTypeFlag&2){const s=i,o=new x.AcGePolyline2d;o.closed=s.isClosed,s.vertices.forEach((a,c)=>{o.addVertexAt(c,{x:a.x,y:a.y,bulge:a.bulge})}),r.add(o)}else{const s=i,o=new x.AcGeLoop2d;s.edges.forEach(a=>{if(a.type==1){const c=a;o.add(new x.AcGeLine2d(c.start,c.end))}else if(a.type==2){const c=a;o.add(new x.AcGeCircArc2d(c.center,c.radius,c.startAngle,c.endAngle,!c.isCCW))}else if(a.type==3){const c=a;new x.AcGeVector2d().subVectors(c.end,c.center);const l=Math.sqrt(Math.pow(c.end.x,2)+Math.pow(c.end.y,2)),h=l*c.lengthOfMinorAxis;let d=c.startAngle,u=c.endAngle;const p=Math.atan2(c.end.y,c.end.x);c.isCCW||(d=Math.PI*2-d,u=Math.PI*2-u),o.add(new x.AcGeEllipseArc2d({...c.center,z:0},l,h,d,u,!c.isCCW,p))}else if(a.type==4){const c=a;if(c.numberOfControlPoints>0&&c.numberOfKnots>0){const l=c.controlPoints.map(u=>({x:u.x,y:u.y,z:0}));let h=!0;const d=c.controlPoints.map(u=>(u.weight==null&&(h=!1),u.weight||1));o.add(new x.AcGeSpline3d(l,c.knots,h?d:void 0))}else if(c.numberOfFitData>0){const l=c.fitDatum.map(h=>({x:h.x,y:h.y,z:0}));o.add(new x.AcGeSpline3d(l,"Uniform"))}}}),r.add(o)}}),r}convertTable(e){const t=new x.AcDbTable(e.name,e.rowCount,e.columnCount);return t.attachmentPoint=e.attachmentPoint,t.position.copy(e.startPoint),e.columnWidthArr.forEach((r,i)=>t.setColumnWidth(i,r)),e.rowHeightArr.forEach((r,i)=>t.setRowHeight(i,r)),e.cells.forEach((r,i)=>{t.setCell(i,r)}),t}convertText(e){const t=new x.AcDbText;return t.textString=e.text,t.styleName=e.styleName,t.height=e.textHeight,t.position.copy(e.startPoint),t.rotation=e.rotation,t.oblique=e.obliqueAngle??0,t.thickness=e.thickness,t.horizontalMode=e.halign,t.verticalMode=e.valign,t.widthFactor=e.xScale??1,t}convertMText(e){const t=new x.AcDbMText;return t.contents=e.text,e.styleName!=null&&(t.styleName=e.styleName),t.height=e.textHeight,t.width=e.rectWidth,t.rotation=e.rotation||0,t.location=e.insertionPoint,t.attachmentPoint=e.attachmentPoint,e.direction&&(t.direction=new x.AcGeVector3d(e.direction)),t.drawingDirection=e.drawingDirection,t}convertLeader(e){const t=new x.AcDbLeader;return e.vertices.forEach(r=>{t.appendVertex(r)}),t.hasArrowHead=e.isArrowheadEnabled,t.hasHookLine=e.isHooklineExists,t.isSplined=e.isSpline,t.dimensionStyle=e.styleName,t.annoType=e.leaderCreationFlag,t}convertDimension(e){if(e.subclassMarker=="AcDbAlignedDimension"||e.subclassMarker=="AcDbRotatedDimension"){const t=e,r=new x.AcDbAlignedDimension(t.subDefinitionPoint1,t.subDefinitionPoint2,t.definitionPoint);return r.rotation=t.rotationAngle,this.processDimensionCommonAttrs(e,r),r}else if(e.subclassMarker=="AcDb3PointAngularDimension"){const t=e,r=new x.AcDb3PointAngularDimension(t.centerPoint,t.subDefinitionPoint1,t.subDefinitionPoint2,t.definitionPoint);return this.processDimensionCommonAttrs(e,r),r}else if(e.subclassMarker=="AcDbOrdinateDimension"){const t=e,r=new x.AcDbOrdinateDimension(t.subDefinitionPoint1,t.subDefinitionPoint2);return this.processDimensionCommonAttrs(e,r),r}else if(e.subclassMarker=="AcDbRadialDimension"){const t=e,r=new x.AcDbRadialDimension(t.definitionPoint,t.centerPoint,t.leaderLength);return this.processDimensionCommonAttrs(e,r),r}else if(e.subclassMarker=="AcDbDiametricDimension"){const t=e,r=new x.AcDbDiametricDimension(t.definitionPoint,t.centerPoint,t.leaderLength);return this.processDimensionCommonAttrs(e,r),r}return null}processImage(e,t){t.position.copy(e.position),t.brightness=e.brightness,t.contrast=e.contrast,t.fade=e.fade,t.imageDefId=e.imageDefHandle.toString(),t.isClipped=(e.flags|4)>0,t.isImageShown=(e.flags|3)>0,t.isImageTransparent=(e.flags|8)>0,e.clippingBoundaryPath.forEach(r=>{t.clipBoundary.push(new x.AcGePoint2d(r))}),t.clipBoundaryType=e.clippingBoundaryType,t.width=Math.sqrt(e.uPixel.x**2+e.uPixel.y**2+e.uPixel.z**2)*e.imageSize.x,t.height=Math.sqrt(e.vPixel.x**2+e.vPixel.y**2+e.vPixel.z**2)*e.imageSize.y,t.rotation=Math.atan2(e.uPixel.y,e.uPixel.x)}convertImage(e){const t=new x.AcDbRasterImage;return this.processImage(e,t),t}convertViewport(e){const t=new x.AcDbViewport;return t.number=e.viewportId,t.centerPoint.copy(e.viewportCenter),t.height=e.height,t.width=e.width,t.viewCenter.copy(e.displayCenter),t.viewHeight=e.viewHeight,t}convertRay(e){const t=new x.AcDbRay;return t.basePoint.copy(e.firstPoint),t.unitDir.copy(e.unitDirection),t}convertXline(e){const t=new x.AcDbXline;return t.basePoint.copy(e.firstPoint),t.unitDir.copy(e.unitDirection),t}convertBlockReference(e){const t=new x.AcDbBlockReference(e.name);return e.insertionPoint&&t.position.copy(e.insertionPoint),t.scaleFactors.x=e.xScale,t.scaleFactors.y=e.yScale,t.scaleFactors.z=e.zScale,t.rotation=e.rotation,t.normal.copy(e.extrusionDirection),t}processDimensionCommonAttrs(e,t){t.dimBlockId=e.name,t.textPosition.copy(e.textPoint),t.textRotation=e.textRotation||0,e.textLineSpacingFactor&&(t.textLineSpacingFactor=e.textLineSpacingFactor),e.textLineSpacingStyle&&(t.textLineSpacingStyle=e.textLineSpacingStyle),t.dimensionStyleName=e.styleName,t.dimensionText=e.text||"",t.measurement=e.measurement}processCommonAttrs(e,t){t.layer=e.layer,t.objectId=e.handle.toString(),t.ownerId=e.ownerBlockRecordSoftId.toString(),e.lineType!=null&&(t.lineType=e.lineType),e.lineweight!=null&&(t.lineWeight=e.lineweight),e.lineTypeScale!=null&&(t.linetypeScale=e.lineTypeScale),e.color!=null&&(t.color.color=e.color),e.colorIndex!=null&&(t.color.colorIndex=e.colorIndex),e.colorName!=null&&(t.color.colorName=e.colorName),e.isVisible!=null&&(t.visibility=e.isVisible),e.transparency!=null&&(t.transparency=e.transparency)}}class od extends x.AcDbDatabaseConverter{constructor(e={}){super(e),e.useWorker=!0,e.parserWorkerUrl||(e.parserWorkerUrl="/assets/libredwg-parser-worker.js")}async parse(e){if(this.config.useWorker&&this.config.parserWorkerUrl)return(await x.createWorkerApi({workerUrl:this.config.parserWorkerUrl}).execute(e)).data;throw new Error("dwg converter can run in web worker only!")}getFonts(e){const t=new Map;e.tables.BLOCK_RECORD.entries.forEach(o=>{t.set(o.name,o)});const r=new Map,i=o=>{if(o){const a=o.lastIndexOf(".");return a>=0?o.substring(0,a).toLowerCase():o.toLowerCase()}};e.tables.STYLE.entries.forEach(o=>{const a=[];let c=i(o.font);c&&a.push(c),c=i(o.bigFont),c&&a.push(c),r.set(o.name,a)});const s=new Set;return this.getFontsInBlock(e.entities,t,r,s),Array.from(s)}getFontsInBlock(e,t,r,i){const s=/\\f(.*?)\|/g;e.forEach(o=>{if(o.type=="MTEXT"){const a=o;[...a.text.matchAll(s)].forEach(l=>{i.add(l[1].toLowerCase())});const c=r.get(a.styleName);c==null||c.forEach(l=>i.add(l))}else if(o.type=="TEXT"){const a=o,c=r.get(a.styleName);c==null||c.forEach(l=>i.add(l))}else if(o.type=="INSERT"){const a=o,c=t.get(a.name);c&&this.getFontsInBlock(c.entities,t,r,i)}})}processLineTypes(e,t){e.tables.LTYPE.entries.forEach(r=>{const i={name:r.name,description:r.description,standardFlag:r.standardFlag,totalPatternLength:r.totalPatternLength,pattern:r.pattern},s=new x.AcDbLinetypeTableRecord(i);this.processCommonTableEntryAttrs(r,s),s.name=r.name,t.tables.linetypeTable.add(s)})}processTextStyles(e,t){e.tables.STYLE.entries.forEach(r=>{const i=new x.AcDbTextStyleTableRecord(r);this.processCommonTableEntryAttrs(r,i),t.tables.textStyleTable.add(i)})}processDimStyles(e,t){e.tables.DIMSTYLE.entries.forEach(r=>{const i={name:r.name,ownerId:r.ownerHandle.toString(),dimpost:r.DIMPOST||"",dimapost:r.DIMAPOST||"",dimscale:r.DIMSCALE,dimasz:r.DIMASZ,dimexo:r.DIMEXO,dimdli:r.DIMDLI,dimexe:r.DIMEXE,dimrnd:r.DIMRND,dimdle:r.DIMDLE,dimtp:r.DIMTP,dimtm:r.DIMTM,dimtxt:r.DIMTXT,dimcen:r.DIMCEN,dimtsz:r.DIMTSZ,dimaltf:r.DIMALTF,dimlfac:r.DIMLFAC,dimtvp:r.DIMTVP,dimtfac:r.DIMTFAC,dimgap:r.DIMGAP,dimaltrnd:r.DIMALTRND,dimtol:r.DIMTOL==null||r.DIMTOL==0?0:1,dimlim:r.DIMLIM==null||r.DIMLIM==0?0:1,dimtih:r.DIMTIH==null||r.DIMTIH==0?0:1,dimtoh:r.DIMTOH==null||r.DIMTOH==0?0:1,dimse1:r.DIMSE1==null||r.DIMSE1==0?0:1,dimse2:r.DIMSE2==null||r.DIMSE2==0?0:1,dimtad:r.DIMTAD,dimzin:r.DIMZIN,dimazin:r.DIMAZIN,dimalt:r.DIMALT,dimaltd:r.DIMALTD,dimtofl:r.DIMTOFL,dimsah:r.DIMSAH,dimtix:r.DIMTIX,dimsoxd:r.DIMSOXD,dimclrd:r.DIMCLRD,dimclre:r.DIMCLRE,dimclrt:r.DIMCLRT,dimadec:r.DIMADEC||0,dimunit:r.DIMUNIT||2,dimdec:r.DIMDEC,dimtdec:r.DIMTDEC,dimaltu:r.DIMALTU,dimalttd:r.DIMALTTD,dimaunit:r.DIMAUNIT,dimfrac:r.DIMFRAC,dimlunit:r.DIMLUNIT,dimdsep:r.DIMDSEP,dimtmove:r.DIMTMOVE||0,dimjust:r.DIMJUST,dimsd1:r.DIMSD1,dimsd2:r.DIMSD2,dimtolj:r.DIMTOLJ,dimtzin:r.DIMTZIN,dimaltz:r.DIMALTZ,dimalttz:r.DIMALTTZ,dimfit:r.DIMFIT||0,dimupt:r.DIMUPT,dimatfit:r.DIMATFIT,dimtxsty:"Standard",dimldrblk:"",dimblk:r.DIMBLK||"",dimblk1:r.DIMBLK1||"",dimblk2:r.DIMBLK2||"",dimlwd:r.DIMLWD,dimlwe:r.DIMLWE},s=new x.AcDbDimStyleTableRecord(i);this.processCommonTableEntryAttrs(r,s),t.tables.dimStyleTable.add(s)})}processLayers(e,t){e.tables.LAYER.entries.forEach(r=>{const i=new x.AcCmColor;i.colorIndex=r.colorIndex;const s=new x.AcDbLayerTableRecord({name:r.name,standardFlags:r.standardFlag,linetype:r.lineType,lineWeight:r.lineweight,isOff:r.off,color:i,isPlottable:r.plotFlag!=0});this.processCommonTableEntryAttrs(r,s),t.tables.layerTable.add(s)})}processViewports(e,t){e.tables.VPORT.entries.forEach(r=>{const i=new x.AcDbViewportTableRecord;this.processCommonTableEntryAttrs(r,i),r.circleSides&&(i.circleSides=r.circleSides),i.standardFlag=r.standardFlag,i.center.copy(r.center),i.lowerLeftCorner.copy(r.lowerLeftCorner),i.upperRightCorner.copy(r.upperRightCorner),r.snapBasePoint&&i.snapBase.copy(r.snapBasePoint),r.snapRotationAngle&&(i.snapAngle=r.snapRotationAngle),r.snapSpacing&&i.snapIncrements.copy(r.snapSpacing),r.majorGridLines&&(i.gridMajor=r.majorGridLines),r.gridSpacing&&i.gridIncrements.copy(r.gridSpacing),r.backgroundObjectId&&(i.backgroundObjectId=r.backgroundObjectId),i.gsView.center.copy(r.center),i.gsView.viewDirectionFromTarget.copy(r.viewDirectionFromTarget),i.gsView.viewTarget.copy(r.viewTarget),r.lensLength&&(i.gsView.lensLength=r.lensLength),r.frontClippingPlane&&(i.gsView.frontClippingPlane=r.frontClippingPlane),r.backClippingPlane&&(i.gsView.backClippingPlane=r.backClippingPlane),r.viewHeight&&(i.gsView.viewHeight=r.viewHeight),r.viewTwistAngle&&(i.gsView.viewTwistAngle=r.viewTwistAngle),r.frozenLayers&&(i.gsView.frozenLayers=r.frozenLayers),r.styleSheet&&(i.gsView.styleSheet=r.styleSheet),r.renderMode&&(i.gsView.renderMode=r.renderMode),r.viewMode&&(i.gsView.viewMode=r.viewMode),r.ucsIconSetting&&(i.gsView.ucsIconSetting=r.ucsIconSetting),r.ucsOrigin&&i.gsView.ucsOrigin.copy(r.ucsOrigin),r.ucsXAxis&&i.gsView.ucsXAxis.copy(r.ucsXAxis),r.ucsYAxis&&i.gsView.ucsYAxis.copy(r.ucsYAxis),r.orthographicType&&(i.gsView.orthographicType=r.orthographicType),r.shadePlotSetting&&(i.gsView.shadePlotSetting=r.shadePlotSetting),r.shadePlotObjectId&&(i.gsView.shadePlotObjectId=r.shadePlotObjectId),r.visualStyleObjectId&&(i.gsView.visualStyleObjectId=r.visualStyleObjectId),r.isDefaultLightingOn&&(i.gsView.isDefaultLightingOn=r.isDefaultLightingOn),r.defaultLightingType&&(i.gsView.defaultLightingType=r.defaultLightingType),r.brightness&&(i.gsView.brightness=r.brightness),r.contrast&&(i.gsView.contrast=r.contrast),r.ambientColor&&(i.gsView.ambientColor=r.ambientColor),t.tables.viewportTable.add(i)})}processBlockTables(e,t){e.tables.BLOCK_RECORD.entries.forEach(r=>{let i=t.tables.blockTable.getAt(r.name);i||(i=new x.AcDbBlockTableRecord,i.objectId=r.handle.toString(),i.name=r.name,i.ownerId=r.ownerHandle.toString(),i.origin.copy(r.basePoint),i.layoutId=r.layout.toString(),t.tables.blockTable.add(i)),!i.isModelSapce&&!i.isPaperSapce&&r.entities&&r.entities.length>0&&this.processEntitiesInBlock(r.entities,i)})}processBlocks(e,t){}async processEntitiesInBlock(e,t){const r=new $s,i=e.length,s=[];for(let o=0;o<i;o++){const a=e[o],c=r.convert(a);c&&s.push(c)}t.appendEntity(s)}async processEntities(e,t,r,i,s){const o=new $s,a=e.entities,c=a.length,l=new x.AcDbBatchProcessing(c,100-i.value,r),h=t.tables.blockTable.modelSpace;await l.processChunk(async(d,u)=>{const p=[];for(let f=d;f<u;f++){const m=a[f],y=o.convert(m);y&&p.push(y)}if(h.appendEntity(p),s){let f=i.value+u/c*(100-i.value);f>100&&(f=100),await s(f,"ENTITY","IN-PROGRESS")}})}processHeader(e,t){const r=e.header;t.cecolor.colorIndex=r.CECOLOR||256,t.angBase=r.ANGBASE??0,t.angDir=r.ANGDIR??0,t.aunits=r.AUNITS??0,t.extmax=r.EXTMAX,t.extmin=r.EXTMIN,t.insunits=r.INSUNITS??1,t.pdmode=r.PDMODE??0,t.pdsize=r.PDSIZE??0}processCommonTableEntryAttrs(e,t){t.name=e.name,t.objectId=e.handle.toString(),t.ownerId=e.ownerHandle.toString()}processObjects(e,t){this.processLayouts(e,t),this.processImageDefs(e,t)}processLayouts(e,t){const r=t.dictionaries.layouts;e.objects.LAYOUT.forEach(i=>{const s=new x.AcDbLayout;s.layoutName=i.layoutName,s.tabOrder=i.tabOrder;const o=t.tables.blockTable.newIterator();s.objectId=i.handle.toString();for(const a of o)if(a.layoutId===s.objectId){s.blockTableRecordId=a.objectId;break}s.limits.min.copy(i.minLimit),s.limits.max.copy(i.maxLimit),s.extents.min.copy(i.minExtent),s.extents.max.copy(i.maxExtent),this.processCommonObjectAttrs(i,s),r.setAt(s.layoutName,s)})}processImageDefs(e,t){const r=t.dictionaries.imageDefs;e.objects.IMAGEDEF.forEach(i=>{const s=new x.AcDbRasterImageDef;s.sourceFileName=i.fileName,this.processCommonObjectAttrs(i,s),r.setAt(s.objectId,s)})}processCommonObjectAttrs(e,t){t.objectId=e.handle.toString(),t.ownerId=e.ownerHandle.toString()}}async function ad(){try{const n=new x.AcDbDxfConverter({useWorker:!0,parserWorkerUrl:"./assets/dxf-parser-worker.js"});x.AcDbDatabaseConverterManager.instance.register(x.AcDbFileType.DXF,n)}catch(n){console.error("Failed to register dxf converter: ",n)}try{const n=new od({useWorker:!0,parserWorkerUrl:"./assets/libredwg-parser-worker.js"});x.AcDbDatabaseConverterManager.instance.register(x.AcDbFileType.DWG,n)}catch(n){console.error("Failed to register dwg converter: ",n)}}const cd={isDebug:!1,isShowCommandLine:!0,isShowCoordinate:!0,isShowToolbar:!0,isShowStats:!1,fontMapping:{}},Zs="settings";class pt{constructor(){this.events={modified:new x.AcCmEventManager}}static get instance(){return this._instance||(this._instance=new pt),this._instance}set(e,t){const r=this.settings;r[e]=t,localStorage.setItem(Zs,JSON.stringify(r)),this.events.modified.dispatch({key:e,value:t})}get(e){return this.settings[e]}toggle(e){const t=this.get(e);this.set(e,!t)}get isDebug(){return this.get("isDebug")}set isDebug(e){this.set("isDebug",e)}get isShowCommandLine(){return this.get("isShowCommandLine")}set isShowCommandLine(e){this.set("isShowCommandLine",e)}get isShowCoordinate(){return this.get("isShowCoordinate")}set isShowCoordinate(e){this.set("isShowCoordinate",e)}get isShowToolbar(){return this.get("isShowToolbar")}set isShowToolbar(e){this.set("isShowToolbar",e)}get isShowStats(){return this.get("isShowStats")}set isShowStats(e){this.set("isShowStats",e)}get fontMapping(){return this.get("fontMapping")}set fontMapping(e){this.set("fontMapping",e)}setFontMapping(e,t){const r=this.get("fontMapping");r[e]=t,this.set("fontMapping",r)}get settings(){const e=localStorage.getItem(Zs),t=e==null?{}:JSON.parse(e);return gn.defaults(t,cd)}}b.AcApContext=xr,b.AcApConvertToSvgCmd=Ar,b.AcApDocManager=ce,b.AcApDocument=Ir,b.AcApOpenCmd=Er,b.AcApPanCmd=Dr,b.AcApQNewCmd=kr,b.AcApSelectCmd=Br,b.AcApSettingManager=pt,b.AcApZoomCmd=Lr,b.AcApZoomToBoxCmd=Mr,b.AcApZoomToBoxJig=Or,b.AcEdBaseView=Cr,b.AcEdCommand=Be,b.AcEdCommandStack=oe,b.AcEdCorsorType=qe,b.AcEdCursorManager=Sr,b.AcEdJig=wr,b.AcEdSelectionSet=Tr,b.AcEdViewMode=Ie,b.AcEditor=_r,b.AcTrView2d=qs,b.DEFAULT_VIEW_2D_OPTIONS=yr,b.acedAlert=oo,b.eventBus=Ce,b.registerConverters=ad,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});