modern-canvas 0.12.3 → 0.12.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +19 -11
- package/dist/index.d.cts +2 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +19 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -145,7 +145,7 @@ uniform sampler2D sampler;
|
|
|
145
145
|
uniform vec4 tint;
|
|
146
146
|
void main(void) {
|
|
147
147
|
gl_FragColor = texture2D(sampler, vUv) * tint;
|
|
148
|
-
}`,uniforms:{sampler:0,projectionMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),modelViewMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),tint:new Float32Array([1,1,1,1])}})}}class Q extends Ii{static _instance;static get instance(){return this._instance??=new this}static draw(e,t=$r.instance,r){this.instance.draw(e,t,r)}constructor(){super({vertexAttributes:{position:new Ge({buffer:new St({data:new Float32Array([-1,-1,1,-1,1,1,-1,1]),dynamic:!1}),size:2,normalized:!1,type:"float"}),uv:new Ge({buffer:new St({data:new Float32Array([0,0,1,0,1,1,0,1]),dynamic:!1}),size:2,normalized:!1,type:"float"})},indexBuffer:new dr({data:new Uint16Array([0,1,2,0,2,3]),dynamic:!1})})}}class tf extends Ii{positionBuffer;uvBuffer;constructor(){const e=new St({data:new Float32Array,dynamic:!0}),t=new St({data:new Float32Array,dynamic:!0});super({vertexAttributes:{position:new Ge({buffer:e,size:2,normalized:!1,type:"float"}),uv:new Ge({buffer:t,size:2,normalized:!1,type:"float"})},indexBuffer:new dr({data:new Uint16Array,dynamic:!0})}),this.positionBuffer=e,this.uvBuffer=t}}var rf=Object.defineProperty,pr=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&rf(e,t,i),i};class le extends Pt{static get EMPTY(){return new this({width:1,height:1,pixels:null})}static get WHITE(){return new this({width:1,height:1,pixels:new Uint8Array([255,255,255,255])})}static get BLACK(){return new this({width:1,height:1,pixels:new Uint8Array([0,0,0,255])})}static get RED(){return new this({width:1,height:1,pixels:new Uint8Array([255,0,0,255])})}static get GREEN(){return new this({width:1,height:1,pixels:new Uint8Array([0,255,0,255])})}static get BLUE(){return new this({width:1,height:1,pixels:new Uint8Array([0,0,255,255])})}_isPowerOfTwo=!1;_needsUpload=!1;get realWidth(){return Math.round(this.width*this.pixelRatio)}get realHeight(){return Math.round(this.height*this.pixelRatio)}constructor(e){super(),this.source=e,this._updateSize()}isValid(){return!!(this.width&&this.height)}_glTextureOptions(e,t){let r=this.wrapMode;return e.version===1&&!this._isPowerOfTwo&&(r="clamp_to_edge"),{value:this.source,target:"texture_2d",location:0,filterMode:this.filterMode,wrapMode:r,...t}}_glTexture(e,t){return e.getRelated(this,()=>e.texture.create(this._glTextureOptions(e,t)))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"width":case"height":this._updatePOT();break;case"source":this._updateSize();break;case"filterMode":case"wrapMode":case"pixelRatio":this.requestUpload();break}}_updatePOT(){this._isPowerOfTwo=Ts(this.realWidth)&&Ts(this.realHeight),this.requestUpload()}_updateSize(){const e=this.source;"pixels"in e?(this.width=e.width/this.pixelRatio,this.height=e.height/this.pixelRatio):(this.width=Number(e.naturalWidth||e.videoWidth||e.width||0)/this.pixelRatio,this.height=Number(e.naturalHeight||e.videoHeight||e.height||0)/this.pixelRatio),this.requestUpload()}requestUpload(){this._needsUpload=!0}upload(e,t){return this._needsUpload&&this.isValid()?(this._needsUpload=!1,e.texture.update(this._glTexture(e,t),this._glTextureOptions(e,t)),!0):!1}activate(e,t=0){return this.isValid()?(e.texture.bind({target:"texture_2d",value:this._glTexture(e,{location:t}),location:t}),this.upload(e,{location:t}),!0):!1}inactivate(e){e.texture.unbind(this._glTexture(e))}destroy(){Ao&&this.source instanceof ImageBitmap&&this.source.close()}}pr([_({internal:!0})],le.prototype,"source"),pr([_({fallback:0})],le.prototype,"width"),pr([_({fallback:0})],le.prototype,"height"),pr([_({fallback:"linear"})],le.prototype,"filterMode"),pr([_({fallback:"clamp_to_edge"})],le.prototype,"wrapMode"),pr([_({fallback:1})],le.prototype,"pixelRatio");class Ri extends Pt{frames;frameIndex=0;get currentFrame(){return this.frames[this.frameIndex]}constructor(e){super();let t;if(Array.isArray(e))t=e;else if(e instanceof le)t=[{texture:e,duration:0}];else throw new TypeError("Failed new AnimatedTexture");this.frames=t,this.updateDuration()}updateDuration(){return this.duration=this.frames.reduce((e,t)=>t.duration+e,0),this}destroy(){this.frames.forEach(e=>{e.texture.destroy()})}}var sf=Object.defineProperty,nf=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&sf(e,t,i),i};class Ui extends le{constructor(e=document.createElement("canvas")){super(e)}_updateProperty(e,t,r){switch(e){case"width":this.source.width=Math.max(1,Math.ceil(t*this.pixelRatio));break;case"height":this.source.height=Math.max(1,Math.ceil(t*this.pixelRatio));break}super._updateProperty(e,t,r)}}nf([_({fallback:2})],Ui.prototype,"pixelRatio");class of extends le{static _cached=new Map;static get(e){const t=new Qe(e),r=t.toHex();let i=this._cached.get(r);return i||(i=new le({width:1,height:1,pixels:new Uint8Array([t.r8,t.g8,t.b8,t.a8])}),this._cached.set(r,i)),i}constructor(e){const t=new Qe(e);super({width:1,height:1,pixels:new Uint8Array([t.r8,t.g8,t.b8,t.a8])})}}class zr extends le{static test(e){return Ar(e)}static linearGradient(e,t,r){t=t||1,r=r||1;const i=document.createElement("canvas");i.width=t,i.height=r;const n=i.getContext("2d");if(!n)throw new Error("Failed to parse linear gradient, get canvas context is null.");const{angle:o=0,stops:a}=e,l=t,c=r,h=l/2,u=c/2,d=(o+90)*Math.PI/180,g=Math.sin(d),p=-Math.cos(d),y=Math.abs(l*Math.sin(d))+Math.abs(c*Math.cos(d)),m=h-g*(y/2),P=u-p*(y/2),E=h+g*(y/2),b=u+p*(y/2),S=n.createLinearGradient(m,P,E,b);for(const x of a)S.addColorStop(x.offset,x.color);n.fillStyle=S,n.fillRect(0,0,l,c);const w=n.getImageData(0,0,i.width,i.height);return{width:w.width,height:w.height,pixels:new Uint8Array(w.data.buffer)}}constructor(e,t,r){super(zr.linearGradient(e,t,r))}}function af(s){return{autoLoad:!!(s?.autoLoad??!0),useBitmap:!!(s?.useBitmap??!0)&&Es,crossorigin:s?.crossorigin??null}}class lf extends le{bitmap;useBitmap;preserveBitmap=!1;_loadSource;_loadBitmap;constructor(e,t){const r=af(t);super(e);const i=e.src,n=i.includes(".svg")||i.startsWith("data:image/svg+xml");this.useBitmap=r.useBitmap&&!n,r.autoLoad&&this.load()}async load(){return this._loadSource||(this._loadSource=new Promise(e=>{this._loadSource=void 0;const t=this.source,r=()=>{t.onload=null,t.onerror=null},i=()=>{r(),this.requestUpload(),this.useBitmap?this.genBitmap().finally(()=>e(this)):e(this)},n=o=>{r(),console.warn(`Failed to load ImageTexture, src: ${t.src}`,o),this.emit("error",o),e(this)};t.complete&&t.src?i():(t.onload=i,t.onerror=n)})),this._loadSource}genBitmap(){if(this._loadBitmap)return this._loadBitmap;if(this.bitmap||!Es)return Promise.resolve(this);const e=this.source,t=!e.crossOrigin||e.crossOrigin==="anonymous";return this._loadBitmap=fetch(e.src,{mode:t?"cors":"no-cors"}).then(r=>r.blob()).then(r=>createImageBitmap(r,0,0,e.width,e.height,{premultiplyAlpha:"premultiply"})).then(r=>(this.bitmap=r,this.requestUpload(),this._loadBitmap=void 0,this)).catch(r=>(console.warn("Failed to genBitmap",r),this)),this._loadBitmap}_glTextureOptions(e){return{...super._glTextureOptions(e),value:this.bitmap??this.source}}upload(e){if(this.useBitmap){if(!this.bitmap)return this.genBitmap(),!1}else{const r=this.source;if(Dr&&r instanceof HTMLImageElement&&(!r.complete||r.naturalWidth===0))return!1}const t=super.upload(e);return this.preserveBitmap&&this.bitmap&&(this.bitmap.close(),this.bitmap=void 0),t}}class Zs extends le{constructor(e,t=1,r=1){const i={width:t,height:r,pixels:null};e&&(ArrayBuffer.isView(e)?i.pixels=new Uint8Array(e.buffer):i.pixels=new Uint8Array(e)),super(i)}_updateProperty(e,t,r){switch(e){case"width":this.source.width=Math.round(this.width*this.pixelRatio);break;case"height":this.source.height=Math.round(this.height*this.pixelRatio);break;case"pixelRatio":this.source.width=Math.round(this.width*this.pixelRatio),this.source.height=Math.round(this.height*this.pixelRatio);break}super._updateProperty(e,t,r)}}var cf=Object.defineProperty,za=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&cf(e,t,i),i};function hf(s){return{autoLoad:!!(s?.autoLoad??!0),autoPlay:!!(s?.autoPlay??!1),fps:Number(s?.fps??0),crossorigin:s?.crossorigin??null,loop:!!(s?.loop??!1),muted:!!(s?.muted??!1),playsinline:!!(s?.playsinline??!0)}}const Js=class gc extends le{static mimeTypes=new Map(Object.entries({ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"}));get isReady(){return this.source.readyState>2}get isPlaying(){return!this.source.paused&&!this.source.ended&&this.isReady}get duration(){return this.source.duration}get seeking(){return this.source.seeking}get currentTime(){return this.source.currentTime}set currentTime(e){this.source.currentTime=e}_spf=0;_autoPlay=!1;_sourceLoad;_nextTime=0;_connected=!1;_requestId;_resolve;_reject;constructor(e,t){const r=hf(t);if(!Uo(e)){typeof e=="string"&&(e=[e]);const i=e[0].src||e[0],n=document.createElement("video");r.autoLoad&&n.setAttribute("preload","auto"),r.playsinline&&(n.setAttribute("webkit-playsinline",""),n.setAttribute("playsinline","")),r.muted&&(n.setAttribute("muted",""),n.muted=!0),r.loop&&n.setAttribute("loop",""),r.autoPlay&&n.setAttribute("autoplay",""),$o(n,i,r.crossorigin);for(let o=0;o<e.length;++o){let{src:a,mime:l}=e[o];if(a=a||e[o],a.startsWith("data:"))l=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){const h=a.split("?").shift().toLowerCase(),u=h.slice(h.lastIndexOf(".")+1);l=l||gc.mimeTypes.get(u)||`video/${u}`}const c=document.createElement("source");c.src=a,l&&(c.type=l),n.appendChild(c)}e=n}super(e),this.fps=r.fps,this._autoPlay=r.autoPlay,r.autoPlay&&this.load(),this._setupAutoUpdate()}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"fps":this._spf=t?Math.floor(1e3/t):0,this._setupAutoUpdate();break;case"autoUpdate":this._setupAutoUpdate();break}}_onPlayStart=()=>{this.isValid()||this._onCanPlay(),this._setupAutoUpdate()};_onPlayStop=()=>{this._setupAutoUpdate()};_onCanPlay=()=>{const e=this.source;e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay);const t=this.isValid();this._nextTime=0,this._updateSize(),this.requestUpload(),this._nextTime=0,!t&&this._resolve&&(this._resolve(this),this._sourceLoad=void 0,this._resolve=void 0,this._reject=void 0),this.isPlaying?this._onPlayStart():this._autoPlay&&e.play()};_onError=e=>{this.source.removeEventListener("error",this._onError,!0),this.emit("error",e),this._reject&&(this._reject(e),this._reject=void 0,this._resolve=void 0)};_onSeeked=()=>{this.autoUpdate&&!this.isPlaying&&(this._nextTime=0,this.requestUpload(),this._nextTime=0)};_setupAutoUpdate(){this.autoUpdate&&this.isPlaying?!this.fps&&this.source.requestVideoFrameCallback?(this._connected&&(Ce.off(this.requestUpload),this._connected=!1,this._nextTime=0),this._requestId===void 0&&(this._requestId=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected||(Ce.on(this.requestUpload),this._connected=!0,this._nextTime=0)):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected&&(Ce.off(this.requestUpload),this._connected=!1,this._nextTime=0))}_videoFrameRequestCallback=()=>{this.requestUpload(),this._requestId=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)};requestUpload=()=>{const e=Math.floor(Ce.elapsed*this.source.playbackRate);this._nextTime-=e,(!this._spf||this._nextTime<=0)&&(super.requestUpload(),this._nextTime=this._spf||0)};async load(){if(!this._sourceLoad){const e=this.source;(e.readyState===e.HAVE_ENOUGH_DATA||e.readyState===e.HAVE_FUTURE_DATA)&&e.width&&e.height&&(e.complete=!0),e.addEventListener("play",this._onPlayStart),e.addEventListener("pause",this._onPlayStop),e.addEventListener("seeked",this._onSeeked),this.isReady?this._onCanPlay():(e.addEventListener("canplay",this._onCanPlay),e.addEventListener("canplaythrough",this._onCanPlay),e.addEventListener("error",this._onError,!0)),this._sourceLoad=new Promise((t,r)=>{this.isValid()?(this._sourceLoad=void 0,t(this)):(this._resolve=t,this._reject=r,e.load())})}return this._sourceLoad}destroy(){this._setupAutoUpdate();const e=this.source;e&&(e.removeEventListener("play",this._onPlayStart),e.removeEventListener("pause",this._onPlayStop),e.removeEventListener("seeked",this._onSeeked),e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay),e.removeEventListener("error",this._onError,!0),e.pause(),e.src="",e.load())}};za([_({internal:!0,fallback:!0})],Js.prototype,"autoUpdate"),za([_({internal:!0,fallback:0})],Js.prototype,"fps");let Va=Js;class Qs extends Zs{}class Ga extends ge{fillStyle;strokeStyle;strokeAlignment;lineCap;lineJoin;lineWidth;miterLimit;uvTransform;vertTransform;_draws=[];_parseDrawStyle(e){return e?e instanceof le?{texture:e}:{backgroundColor:new Qe(e).toInt8Array()}:{}}stroke(e){if(!this.curves.length)return;let t=this.strokeStyle;if(!t&&this.style.stroke)switch(typeof this.style.stroke){case"string":t=this.style.stroke;break;case"object":xs(this.style.stroke)&&(t=this.style.stroke.color);break}this._draws.push({...e,...this._parseDrawStyle(t),type:"stroke",path:new ge(this),uvTransform:this.uvTransform,vertTransform:this.vertTransform,lineStyle:{alignment:this.strokeAlignment??.5,cap:this.lineCap??"butt",join:this.lineJoin??"miter",width:this.lineWidth??1,miterLimit:this.miterLimit??10}}),this.resetStatus()}fillRect(e,t,r,i){this.rect(e,t,r,i).fill()}strokeRect(e,t,r,i){this.rect(e,t,r,i).stroke()}fill(e){if(!this.curves.length)return;let t=this.fillStyle;if(!t&&this.style.fill)switch(typeof this.style.fill){case"string":t=this.style.fill;break;case"object":xs(this.style.fill)&&(t=this.style.fill.color);break}this._draws.push({...e,...this._parseDrawStyle(t),type:"fill",path:new ge(this),uvTransform:this.uvTransform,vertTransform:this.vertTransform}),this.resetStatus()}copy(e){return super.copy(e),this.strokeStyle=e.strokeStyle,this.fillStyle=e.fillStyle,this.uvTransform=e.uvTransform,this.vertTransform=e.vertTransform,this.strokeAlignment=e.strokeAlignment,this.lineCap=e.lineCap,this.lineJoin=e.lineJoin,this.lineWidth=e.lineWidth,this.miterLimit=e.miterLimit,this._draws=e._draws.slice(),this}resetStatus(){super.reset(),this.strokeStyle=void 0,this.fillStyle=void 0,this.uvTransform=void 0,this.vertTransform=void 0,this.strokeAlignment=void 0,this.lineCap=void 0,this.lineJoin=void 0,this.lineWidth=void 0,this.miterLimit=void 0}reset(){return this.resetStatus(),this._draws.length=0,this}buildUvs(e,t,r,i,n){if(i){const o=i.width,a=i.height;for(let l=t.length,c=e;c<l;c+=2){const h=t[c],u=t[c+1];let d,g;n?[d,g]=n.apply({x:h,y:u}).toArray():[d,g]=[h/o,u/a],r.push(d,g)}}else for(let o=t.length,a=e;a<o;a+=2)r.push(0,0)}toBatchables(){const e=[];for(let t=this._draws.length,r=0;r<t;r++){const i=this._draws[r],n=[],o=[],a=[];i.type==="fill"?i.path.fillTriangulate({vertices:n,indices:o}):i.path.strokeTriangulate({vertices:n,indices:o,lineStyle:i.lineStyle,flipAlignment:!1,closed:!0}),i.texture&&this.buildUvs(0,n,a,i.texture,i.uvTransform);const l=i.path.getBoundingBox();e.push({vertices:new Float32Array(n),indices:new Float32Array(o),uvs:new Float32Array(a),texture:i.texture,backgroundColor:i.backgroundColor,type:i.type,disableWrapMode:i.disableWrapMode,uvTransform:i.uvTransform,vertTransform:i.vertTransform,dimension:new Float32Array([l.width,l.height])})}return e}}class uf{front=[];default=[];back=[];get internal(){return this.getInternal()}constructor(...e){this.set(e)}set(e){return this.front.length=0,this.default.length=0,this.back.length=0,e.forEach(t=>{switch(t.internalMode){case"front":this.front.push(t);break;case"default":this.default.push(t);break;case"back":this.back.push(t);break}}),this}getInternal(e){if(e)switch(e){case"front":return this.front;case"default":return this.default;case"back":return this.back;default:throw new Error(`Unknown internal mode: ${e}`)}else return[...this.front,...this.default,...this.back]}toJSON(){return[...this.default]}}class ja extends xt{constructor(e){return super(),this.parent=e,new Proxy(this,{get:(t,r,i)=>Reflect.has(t,r)||String(r).startsWith("_")?Reflect.get(t,r,i):t.getProperty(String(r)),set:(t,r,i,n)=>Reflect.has(t,r)||String(r).startsWith("_")?Reflect.set(t,r,i,n):(t.setProperty(String(r),i),!0),deleteProperty:(t,r)=>Reflect.has(t,r)||String(r).startsWith("_")?Reflect.deleteProperty(t,r):(t.setProperty(String(r),void 0),!0)})}getPropertyDeclarations(){const e=new Map;return this._properties.forEach((t,r)=>{e.set(r,{internalKey:`____${r}`})}),e}getPropertyDeclaration(e){return{internalKey:`____${e}`}}}var ff=Object.defineProperty,df=Object.getOwnPropertyDescriptor,Et=(s,e,t,r)=>{for(var i=r>1?void 0:r?df(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&ff(e,t,i),i};const Wa={};function pf(s){let e=Wa[s]??0;return e++,Wa[s]=e,e}f.Node=class extends xt{_meta=new ja(this);get meta(){return this._meta}set meta(e){this._meta.resetProperties().setProperties(e)}_readyed=!1;constructor(e,t=[]){super(),this._onTreeEnter=this._onTreeEnter.bind(this),this._onTreeExit=this._onTreeExit.bind(this),this._onParented=this._onParented.bind(this),this._onUnparented=this._onUnparented.bind(this),this._onReady=this._onReady.bind(this),this._onProcess=this._onProcess.bind(this),this.setProperties({name:`${this.is}:${pf(this.is)}`,...e}).append(t),this.on("treeEnter",this._onTreeEnter).on("treeExit",this._onTreeExit).on("parented",this._onParented).on("unparented",this._onUnparented).on("ready",this._onReady).on("process",this._onProcess)}setProperties(e){if(e){const{meta:t,...r}=e;t&&(this.meta=t),super.setProperties(r)}return this}getName(){return this.name}setName(e){return this.name=e,this}_tree;get tree(){return this.getTree()}set tree(e){this.setTree(e)}getTree(){return this._tree}getViewport(){return this.parent?.getViewport()??this.getWindow()}getWindow(){return this._tree?.root}isInsideTree(){return!!this._tree}setTree(e){const t=this._tree;if(!e?.equal(t)){t&&this.emit("treeExit",t),this._tree=e,e&&this.emit("treeEnter",e);const r=this._children.internal;for(let i=r.length,n=0;n<i;n++){const o=r[n];!e&&this.emit("childExitingTree",o),o.setTree(e),e&&this.emit("childEnteredTree",o)}e&&(this.emit("treePostEnter",e),this._readyed||(this._readyed=!0,this.emit("ready")))}return this}_parent;get parent(){return this._parent}set parent(e){this.setParent(e)}hasParent(){return!!this._parent}getParent(){return this._parent}setParent(e){if(!this._parent?.equal(e)){const t=this._parent;t&&this.emit("unparented",t),this._parent=e,e&&this.emit("parented",e),this.setTree(e?._tree)}return this}_children=new uf;get children(){return this._children.default}set children(e){this._children.set(e)}getChildren(e="default"){return this._children.getInternal(e===!0?void 0:e)}getChild(e=0){return this.children[e]}get siblingIndex(){return this.getIndex()}set siblingIndex(e){this._parent?.moveChild(this,e)}get previousSibling(){return this._parent?.children[this.getIndex()-1]}get nextSibling(){return this._parent?.children[this.getIndex()+1]}get firstSibling(){return this._parent?.children[0]}get lastSibling(){const e=this._parent?.children;return e?e[e.length-1]:void 0}canProcess(){if(!this._tree)return!1;switch(this.processMode){case"inherit":return this._parent?.canProcess()??!0;case"pausable":return!this._tree.processPaused;case"when_paused":return this._tree.processPaused;case"always":return!0;case"disabled":default:return!1}}canInput(){if(!this._tree)return!1;switch(this.inputMode){case"inherit":return this._parent?.canInput()??!0;case"always":return!0;case"disabled":default:return!1}}canRender(){if(!this._tree)return!1;switch(this.renderMode){case"inherit":return this._parent?.canRender()??!0;case"always":return!0;case"disabled":default:return!1}}_onTreeEnter(e){this._treeEnter(e),this.emit("treeEntered",e)}_onTreeExit(e){this.emit("treeExiting",e),this._treeExit(e),this.emit("treeExited",e)}_onParented(e){this._parented(e)}_onUnparented(e){this._unparented(e)}_onReady(){this._ready()}_onProcess(e=0){const t=this._tree,r=this.canRender(),i=this.canProcess(),n=[],o=[];this._children.internal.forEach(l=>{switch(l.processSortMode){case"default":o.push(l);break;case"parent_before":n.push(l);break}}),n.forEach(l=>{l.emit("process",e)}),i&&(t?.emit("nodeProcessing",this),this.emit("processing",e),this._process(e));let a;if(r){const l=t.renderStack.push(this);a=t.renderStack.currentCall,t.renderStack.currentCall=l}if(this.mask instanceof f.Node)this.getNode("__$mask")||(this.mask.processMode="disabled",this.appendChild(this.mask,"front"));else{const l=this.getNode("__$mask");l&&this.removeChild(l)}o.forEach(l=>{l.emit("process",e)}),r&&(t.renderStack.currentCall=a),i&&(this.emit("processed",e),t?.emit("nodeProcessed",this))}render(e,t){const r=this.mask;r&&(e.flush(),e.mask.push(this,r)),this._render(e),t?.(),r&&(e.flush(),e.mask.pop(this))}input(e,t){if(e.propagationStopped)return;const r=this._children.internal;for(let i=r.length-1;i>=0;i--)r[i].input(e,t);e.propagationStopped||this.canInput()&&this._input(e,t)}getIndex(){return this._parent?.getChildren(this.internalMode).indexOf(this)??0}getNode(e){return this._children.internal.find(t=>t.name===e)}removeNode(e){this.getNode(e)?.remove()}addSibling(e){return this.equal(e)||!this.hasParent()||e.hasParent()?this:(e.internalMode=this.internalMode,this._parent.moveChild(e,this.getIndex()+1),this)}prepend(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(r=>{this.moveChild(r,0)})}append(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(r=>{this.appendChild(r)})}before(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(r=>{this._parent?.moveChild(r,this.getIndex())})}after(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(r=>{this._parent?.moveChild(r,this.getIndex()+1)})}insertBefore(e,t){return!t.hasParent()||!this.equal(t.parent)||this.moveChild(e,t.getIndex()),e}appendChild(e,t=e.internalMode){if(this.equal(e)||e.hasParent())return e;switch(t){case"front":this._children.front.push(e);break;case"default":this._children.default.push(e);break;case"back":this._children.back.push(e);break}return e.internalMode!==t&&(e.internalMode=t),e.setParent(this),this.emit("appendChild",e),e}moveChild(e,t,r=e.internalMode){if(this.equal(e)||e.hasParent()&&!this.equal(e.parent))return this;const i=this._children.getInternal(e.internalMode),n=i.indexOf(e),o=this._children.getInternal(r);return(e.internalMode!==r||t!==n)&&(n>-1&&i.splice(n,1),e.setParent(this),t>-1&&t<o.length?o.splice(t,0,e):o.push(e),n>-1?this.emit("moveChild",e,t,n):this.emit("appendChild",e)),e.internalMode!==r&&(e.internalMode=r),this}removeChild(e){const t=e.getIndex();return this.equal(e.parent)&&t>-1&&(this.getChildren(e.internalMode).splice(t,1),e.setParent(void 0),this.emit("removeChild",e,t)),e}removeChildren(){this.children.forEach(e=>this.removeChild(e))}remove(){this._parent?.removeChild(this)}findOne(e){for(const t of this._children.default){const r=e(t)||t.findOne(e);if(r)return r}}findAll(e){const t=[];for(const r of this._children.default){const i=e(r);i&&t.push(i),t.push(...r.findAll(e))}return t}findAncestor(e){const t=this._parent;if(t){const r=e(t)??t.findAncestor(e);if(r)return r}}_ready(){}_treeEnter(e){}_treeExit(e){}_parented(e){}_unparented(e){}_process(e){}_input(e,t){}_render(e){}destroy(){super.destroy(),this._children.internal.forEach(e=>this.removeChild(e))}clone(){return new this.constructor(this.toJSON(),this._children.internal)}toJSON(){return Ve({...super.toJSON(),children:this.children.length?[...this.children.map(e=>e.toJSON())]:void 0,meta:{...this.meta.toJSON(),inCanvasIs:this.is}})}static parse(e){if(Array.isArray(e))return e.map(l=>this.parse(l));const{meta:t={},children:r,...i}=e,{inCanvasIs:n="Node"}=t,o=xi.get(n)??f.Node,a=new o({...i,meta:t});return r?.forEach(l=>a.appendChild(this.parse(l))),a}},Et([_({fallback:bo()})],f.Node.prototype,"id",2),Et([_({fallback:bo()})],f.Node.prototype,"name",2),Et([_({internal:!0,fallback:"inherit"})],f.Node.prototype,"processMode",2),Et([_({internal:!0,fallback:"default"})],f.Node.prototype,"processSortMode",2),Et([_({internal:!0,fallback:"inherit"})],f.Node.prototype,"renderMode",2),Et([_({internal:!0,fallback:"inherit"})],f.Node.prototype,"inputMode",2),Et([_({internal:!0,fallback:"default"})],f.Node.prototype,"internalMode",2),Et([_({internal:!0})],f.Node.prototype,"mask",2),f.Node=Et([X("Node")],f.Node);var gf=Object.defineProperty,mf=Object.getOwnPropertyDescriptor,gr=(s,e,t,r)=>{for(var i=r>1?void 0:r?mf(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&gf(e,t,i),i};f.TimelineNode=class extends f.Node{constructor(e,t=[]){super(),this.setProperties(e).append(t)}computedDuration=0;_currentTime=0;_startTime=0;get timeline(){return this._tree?.timeline}get timelineCurrentTime(){return this.timeline?.currentTime??0}get parentStartTime(){return this._parent?.startTime??0}get currentTime(){return ut(this._currentTime,0,this.computedDuration)}get startTime(){return this._startTime}set startTime(e){this.delay=e-this.parentStartTime,this._updateCurrentTime(!0)}get endTime(){return this._startTime+this.computedDuration}get currentTimeProgress(){return this.computedDuration?ut(this._currentTime/this.computedDuration,0,1):0}isInsideTimeRange(){const e=this._currentTime;return this.computedDuration?e>=0&&e<=this.computedDuration:e>=0}_updateCurrentTime(e=!1){if(e||!this.paused){const t=this._parent,r=this.delay+this.parentStartTime,i=t?.computedDuration?Math.min(r+this.duration,t.endTime)-r:this.duration;let n=this.timelineCurrentTime-r;this.loop&&(n=n%i),this._startTime=r,this._currentTime=n,this.computedDuration=i,this.emit("updateCurrentTime",this._currentTime),this.insideTimeRange=this.isInsideTimeRange()}}_process(e){super._process(e),this._updateCurrentTime()}},gr([_({fallback:!1})],f.TimelineNode.prototype,"loop",2),gr([_({fallback:0})],f.TimelineNode.prototype,"delay",2),gr([_({fallback:0})],f.TimelineNode.prototype,"duration",2),gr([_({fallback:!1})],f.TimelineNode.prototype,"paused",2),gr([_({internal:!0,fallback:!1})],f.TimelineNode.prototype,"insideTimeRange",2),f.TimelineNode=gr([X("TimelineNode")],f.TimelineNode);var yf=Object.defineProperty,vf=Object.getOwnPropertyDescriptor,Vr=(s,e,t,r)=>{for(var i=r>1?void 0:r?vf(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&yf(e,t,i),i};f.CanvasItem=class extends f.TimelineNode{_parentGlobalVisible;_globalVisible;get globalVisible(){return this._globalVisible??!0}_parentGlobalOpacity;_globalOpacity;get globalOpacity(){return this._globalOpacity??1}_modulate=new Qe(4294967295);context=new Ga;_resetContext=!0;_redrawing=!0;_relayouting=!1;_repainting=!1;_originalBatchables=[];_layoutedBatchables=[];_batchables=[];constructor(e,t=[]){super(),this.setProperties(e).append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"modulate":this._modulate.value=t,this.requestRepaint();break;case"blendMode":this.requestRepaint();break;case"opacity":this._updateGlobalOpacity();break;case"visible":case"insideTimeRange":this._updateGlobalVisible();break}}show(){this.visible=!0}hide(){this.visible=!1}isVisibleInTree(){return this.globalOpacity>0&&this.globalVisible}canRender(){return super.canRender()&&this.isVisibleInTree()}requestRedraw(){this._redrawing=!0}requestRelayout(){this._relayouting=!0}requestRepaint(){this._repainting=!0}_updateGlobalVisible(){this._parentGlobalVisible=this.getParent()?.globalVisible,this._globalVisible=(this._parentGlobalVisible??!0)&&this.visible&&this.insideTimeRange}_updateGlobalOpacity(){this._parentGlobalOpacity=this.getParent()?.opacity;const e=ut(this.opacity,0,1)*(this._parentGlobalOpacity??1);this._globalOpacity!==e&&(this._globalOpacity=e,this.requestRepaint())}_draw(){this.emit("draw")}_redraw(){return this._tree?.log(this.name,"drawing"),this._draw(),this.context.toBatchables()}_relayout(e){return this._tree?.log(this.name,"layouting"),e}_repaint(e){this._tree?.log(this.name,"painting");const t=this.globalOpacity;return e.map(r=>({...r,modulate:this._modulate.toInt8Array().map(i=>i*t),blendMode:this.blendMode}))}_process(e){super._process(e);const t=this.getParent();this._parentGlobalVisible!==t?.globalVisible&&this._updateGlobalVisible(),this._parentGlobalOpacity!==t?.globalOpacity&&this._updateGlobalOpacity()}_updateBatchables(){const e=this._redrawing;let t=this._relayouting,r=this._repainting,i;e&&(this._originalBatchables=this._redraw(),t=!0),t&&(this._layoutedBatchables=this._relayout(this._originalBatchables),r=!0),r&&(i=this._repaint(this._layoutedBatchables)),e&&this._resetContext&&this.context.reset(),i&&(this._batchables=i,this._redrawing=!1,this._relayouting=!1,this._repainting=!1)}_render(e){this._updateBatchables(),this._batchables.forEach(t=>{t.texture?.upload(e),e.batch2D.render({...t,texture:t.texture?._glTexture(e)})}),super._render(e)}},Vr([_()],f.CanvasItem.prototype,"modulate",2),Vr([_()],f.CanvasItem.prototype,"blendMode",2),Vr([_({internal:!0,fallback:!0})],f.CanvasItem.prototype,"visible",2),Vr([_({internal:!0,fallback:1})],f.CanvasItem.prototype,"opacity",2),f.CanvasItem=Vr([X("CanvasItem")],f.CanvasItem);var _f=Object.defineProperty,bf=Object.getOwnPropertyDescriptor,mr=(s,e,t,r)=>{for(var i=r>1?void 0:r?bf(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&_f(e,t,i),i};f.Viewport=class extends f.Node{constructor(e=!1){super(),this.flipY=e,this.projection.flipY(e)}projection=new Yo;canvasTransform=new ke;_framebufferIndex=0;_framebuffers=[{texture:new Qs,needsUpload:!1},{texture:new Qs,needsUpload:!1}];get valid(){return!!(this.width&&this.height)}get framebuffer(){return this._framebuffers[this._framebufferIndex]}get texture(){return this.framebuffer.texture}getViewport(){return this}_glFramebufferOptions(e){const{width:t,height:r}=this,{pixelRatio:i}=e;return this._framebuffers.forEach(n=>{const o=n.texture;o.width=t,o.height=r,o.pixelRatio=i,o.upload(e)}),{width:t,height:r,msaa:this.msaa,colorTextures:[this.texture._glTexture(e)]}}_glFramebuffer(e){return e.getRelated(this.framebuffer,()=>e.framebuffer.create(this._glFramebufferOptions(e)))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"x":case"y":this.requestUpload(),this.projection.translate(this.x,this.y),this.emit("updateRect");break;case"width":case"height":this.requestUpload(),this.projection.resize(this.width,this.height),this.emit("updateRect");break;case"msaa":this.requestUpload();break}}requestUpload(){this._framebuffers.forEach(e=>e.needsUpload=!0)}resize(e,t){this.width=e,this.height=t}upload(e){const t=this.framebuffer;return t.needsUpload&&this.valid?(t.needsUpload=!1,e.framebuffer.update(this._glFramebuffer(e),this._glFramebufferOptions(e)),!0):!1}activate(e){return this.valid?(e.flush(),this._tree?.setCurrentViewport(this),this.upload(e),e.framebuffer.bind(this._glFramebuffer(e)),!0):!1}redraw(e,t){if(this.valid){e.flush();const r=this.framebuffer.texture;return this._framebufferIndex=(this._framebufferIndex+1)%this._framebuffers.length,this.activate(e),e.clear(),r.activate(e,0),t(),!0}return!1}activateWithCopy(e,t){this.resize(t.width,t.height),this.activate(e)&&(e.clear(),t.texture.activate(e,0),Q.draw(e,$r.instance,{sampler:0}))}render(e,t){const r=this._tree?.getCurrentViewport();e.program.uniforms.projectionMatrix=this.projection.toArray(!0),e.program.uniforms.viewMatrix=this.canvasTransform.toArray(!0),this.activate(e),e.clear(),super.render(e,t),e.flush(),r?r.activate(e):(e.framebuffer.bind(null),this._tree?.setCurrentViewport(void 0))}getRect(){return new It(this.x,this.y,this.width,this.height)}toCanvasGlobal(e,t){return this.canvasTransform.applyAffineInverse(e,t)}toCanvasScreen(e,t){return this.canvasTransform.apply(e,t)}},mr([_({fallback:0})],f.Viewport.prototype,"x",2),mr([_({fallback:0})],f.Viewport.prototype,"y",2),mr([_({fallback:0})],f.Viewport.prototype,"width",2),mr([_({fallback:0})],f.Viewport.prototype,"height",2),mr([_({internal:!0,fallback:!1})],f.Viewport.prototype,"msaa",2),f.Viewport=mr([X("Viewport")],f.Viewport);var wf=Object.defineProperty,xf=Object.getOwnPropertyDescriptor,Gr=(s,e,t,r)=>{for(var i=r>1?void 0:r?xf(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&wf(e,t,i),i};f.Effect=class extends f.TimelineNode{material;get _effectMode(){return this.effectMode??"parent"}viewport1=new f.Viewport;viewport2=new f.Viewport;_renderId=0;_renderViewport;_previousSibling;_nextSibling;constructor(e,t=[]){super(),this._onProcessing=this._onProcessing.bind(this),this._onNodeProcessed=this._onNodeProcessed.bind(this),this.setProperties(e).append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"glsl":{const i=new Nr(t);!this.effectMode&&i.has.transition&&(this.effectMode="transition"),this.material=i;break}case"glslSrc":{t?Ke.text.load(t).then(i=>this.glsl=i):this.glsl="";break}}}_treeEnter(e){e.on("processing",this._onProcessing),e.on("nodeProcessed",this._onNodeProcessed),this.viewport1.setTree(e),this.viewport2.setTree(e)}_treeExit(e){e.off("processing",this._onProcessing),e.off("nodeProcessed",this._onNodeProcessed),this.viewport1.setTree(void 0),this.viewport2.setTree(void 0)}_onProcessing(){if(this.canProcess())switch(this._updateCurrentTime(),this._effectMode){case"transition":this._previousSibling=this.previousSibling,this._nextSibling=this.nextSibling;break;default:this._previousSibling=void 0,this._nextSibling=void 0;break}}_onNodeProcessed(e){if(!this.canProcess()||!this.isInsideTimeRange())return;const t=this._tree?.renderStack;if(t)switch(this._effectMode){case"transition":e.equal(this._previousSibling)?(this._previousSibling=void 0,t.push(this)):e.equal(this._nextSibling)&&(this._nextSibling=void 0,t.push(this));break}}_processParent(){const e=this._tree?.renderStack;if(!e)return;const t=e.currentCall?.parentCall;if(!t)return;const r=t.calls;let i,n;r.forEach((o,a)=>{(o.renderable.equal(this._parent)||o.renderable.parent?.equal(this._parent))&&(i=i??a,n=a)}),!(i===void 0||n===void 0)&&(r.splice(n+1,0,e.createCall(this)),r.splice(i,0,e.createCall(this)))}_processChildren(){this.children.length&&(super.emit("process"),this._tree?.renderStack.push(this))}_onProcess(e=0){if(this.canProcess())switch(this._renderId=0,this._effectMode){case"before":super._onProcess(e);break;case"parent":this._processParent();break;case"children":this._processChildren();break}}_renderBefore(e){const t=this._tree?.getCurrentViewport();t&&this.apply(e,t,{redraw:!0})}_renderTransition(e){if(this._renderId%2===0)this._renderViewport=this._tree?.getCurrentViewport(),this._renderViewport&&(this.viewport1.activateWithCopy(e,this._renderViewport),this.viewport2.resize(this._renderViewport.width,this._renderViewport.height)),this.viewport2.activate(e),e.clear();else{const t=this._renderViewport;this._renderViewport=void 0,t&&(t.activate(e),e.clear(),this.viewport1.texture.activate(e,0),this.viewport2.texture.activate(e,1),this.apply(e,t,{from:this.viewport1,to:this.viewport2}),e.texture.unbind(0),e.texture.unbind(1))}}_renderParentOrChildren(e){if(this._renderId%2===0)this._renderViewport=this._tree?.getCurrentViewport(),this._renderViewport&&this.viewport1.resize(this._renderViewport.width,this._renderViewport.height),this.viewport1.activate(e),e.clear();else{const t=this._renderViewport;this._renderViewport=void 0,t&&(this.viewport1.activate(e),this.apply(e,this.viewport1,{redraw:!0,target:this._effectMode==="parent"?this._parent??void 0:void 0,targetArea:this._parseTargetArea()}),t.activate(e),this.viewport1.texture.activate(e,0),Q.draw(e))}}_parseTargetArea(){if(this._effectMode==="parent"&&this._parent&&"getRect"in this._parent){const e=this._parent.getRect();if(e)return[e.left/this.viewport1.width,e.top/this.viewport1.height,e.width/this.viewport1.width,e.height/this.viewport1.height]}}_render(e){switch(this._effectMode){case"before":this._renderBefore(e);break;case"transition":this._renderTransition(e);break;case"parent":case"children":default:this._renderParentOrChildren(e);break}this._renderId++}apply(e,t,r){this.material&&(r?.redraw?t.redraw(e,()=>{Q.draw(e,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:t.width/t.height})}):Q.draw(e,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:r?.from?r.from.width/r.from.height:0}))}},Gr([_({internal:!0})],f.Effect.prototype,"material",2),Gr([_()],f.Effect.prototype,"effectMode",2),Gr([_()],f.Effect.prototype,"glsl",2),Gr([_()],f.Effect.prototype,"glslSrc",2),f.Effect=Gr([X("Effect")],f.Effect);var Te=Uint8Array,je=Uint16Array,en=Int32Array,Bi=new Te([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Li=new Te([0,0,0,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,0,0]),tn=new Te([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),qa=function(s,e){for(var t=new je(31),r=0;r<31;++r)t[r]=e+=1<<s[r-1];for(var i=new en(t[30]),r=1;r<30;++r)for(var n=t[r];n<t[r+1];++n)i[n]=n-t[r]<<5|r;return{b:t,r:i}},Xa=qa(Bi,2),Ha=Xa.b,rn=Xa.r;Ha[28]=258,rn[258]=28;for(var Ya=qa(Li,0),Pf=Ya.b,Ka=Ya.r,sn=new je(32768),te=0;te<32768;++te){var Ut=(te&43690)>>1|(te&21845)<<1;Ut=(Ut&52428)>>2|(Ut&13107)<<2,Ut=(Ut&61680)>>4|(Ut&3855)<<4,sn[te]=((Ut&65280)>>8|(Ut&255)<<8)>>1}for(var pt=(function(s,e,t){for(var r=s.length,i=0,n=new je(e);i<r;++i)s[i]&&++n[s[i]-1];var o=new je(e);for(i=1;i<e;++i)o[i]=o[i-1]+n[i-1]<<1;var a;if(t){a=new je(1<<e);var l=15-e;for(i=0;i<r;++i)if(s[i])for(var c=i<<4|s[i],h=e-s[i],u=o[s[i]-1]++<<h,d=u|(1<<h)-1;u<=d;++u)a[sn[u]>>l]=c}else for(a=new je(r),i=0;i<r;++i)s[i]&&(a[i]=sn[o[s[i]-1]++]>>15-s[i]);return a}),Bt=new Te(288),te=0;te<144;++te)Bt[te]=8;for(var te=144;te<256;++te)Bt[te]=9;for(var te=256;te<280;++te)Bt[te]=7;for(var te=280;te<288;++te)Bt[te]=8;for(var jr=new Te(32),te=0;te<32;++te)jr[te]=5;var Cf=pt(Bt,9,0),Tf=pt(Bt,9,1),Sf=pt(jr,5,0),Ef=pt(jr,5,1),nn=function(s){for(var e=s[0],t=1;t<s.length;++t)s[t]>e&&(e=s[t]);return e},tt=function(s,e,t){var r=e/8|0;return(s[r]|s[r+1]<<8)>>(e&7)&t},on=function(s,e){var t=e/8|0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>(e&7)},an=function(s){return(s+7)/8|0},Za=function(s,e,t){return(t==null||t>s.length)&&(t=s.length),new Te(s.subarray(e,t))},Mf=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],rt=function(s,e,t){var r=new Error(e||Mf[s]);if(r.code=s,Error.captureStackTrace&&Error.captureStackTrace(r,rt),!t)throw r;return r},Af=function(s,e,t,r){var i=s.length,n=0;if(!i||e.f&&!e.l)return t||new Te(0);var o=!t,a=o||e.i!=2,l=e.i;o&&(t=new Te(i*3));var c=function(Be){var $e=t.length;if(Be>$e){var Pe=new Te(Math.max($e*2,Be));Pe.set(t),t=Pe}},h=e.f||0,u=e.p||0,d=e.b||0,g=e.l,p=e.d,y=e.m,m=e.n,P=i*8;do{if(!g){h=tt(s,u,1);var E=tt(s,u+1,3);if(u+=3,E)if(E==1)g=Tf,p=Ef,y=9,m=5;else if(E==2){var x=tt(s,u,31)+257,T=tt(s,u+10,15)+4,C=x+tt(s,u+5,31)+1;u+=14;for(var L=new Te(C),G=new Te(19),U=0;U<T;++U)G[tn[U]]=tt(s,u+U*3,7);u+=T*3;for(var R=nn(G),z=(1<<R)-1,B=pt(G,R,1),U=0;U<C;){var D=B[tt(s,u,z)];u+=D&15;var b=D>>4;if(b<16)L[U++]=b;else{var H=0,I=0;for(b==16?(I=3+tt(s,u,3),u+=2,H=L[U-1]):b==17?(I=3+tt(s,u,7),u+=3):b==18&&(I=11+tt(s,u,127),u+=7);I--;)L[U++]=H}}var F=L.subarray(0,x),j=L.subarray(x);y=nn(F),m=nn(j),g=pt(F,y,1),p=pt(j,m,1)}else rt(1);else{var b=an(u)+4,S=s[b-4]|s[b-3]<<8,w=b+S;if(w>i){l&&rt(0);break}a&&c(d+S),t.set(s.subarray(b,w),d),e.b=d+=S,e.p=u=w*8,e.f=h;continue}if(u>P){l&&rt(0);break}}a&&c(d+131072);for(var O=(1<<y)-1,$=(1<<m)-1,A=u;;A=u){var H=g[on(s,u)&O],M=H>>4;if(u+=H&15,u>P){l&&rt(0);break}if(H||rt(2),M<256)t[d++]=M;else if(M==256){A=u,g=null;break}else{var N=M-254;if(M>264){var U=M-257,V=Bi[U];N=tt(s,u,(1<<V)-1)+Ha[U],u+=V}var Y=p[on(s,u)&$],J=Y>>4;Y||rt(3),u+=Y&15;var j=Pf[J];if(J>3){var V=Li[J];j+=on(s,u)&(1<<V)-1,u+=V}if(u>P){l&&rt(0);break}a&&c(d+131072);var oe=d+N;if(d<j){var _t=n-j,Ze=Math.min(j,oe);for(_t+d<0&&rt(3);d<Ze;++d)t[d]=r[_t+d]}for(;d<oe;++d)t[d]=t[d-j]}}e.l=g,e.p=A,e.b=d,e.f=h,g&&(h=1,e.m=y,e.d=p,e.n=m)}while(!h);return d!=t.length&&o?Za(t,0,d):t.subarray(0,d)},Mt=function(s,e,t){t<<=e&7;var r=e/8|0;s[r]|=t,s[r+1]|=t>>8},Wr=function(s,e,t){t<<=e&7;var r=e/8|0;s[r]|=t,s[r+1]|=t>>8,s[r+2]|=t>>16},ln=function(s,e){for(var t=[],r=0;r<s.length;++r)s[r]&&t.push({s:r,f:s[r]});var i=t.length,n=t.slice();if(!i)return{t:tl,l:0};if(i==1){var o=new Te(t[0].s+1);return o[t[0].s]=1,{t:o,l:1}}t.sort(function(w,x){return w.f-x.f}),t.push({s:-1,f:25001});var a=t[0],l=t[1],c=0,h=1,u=2;for(t[0]={s:-1,f:a.f+l.f,l:a,r:l};h!=i-1;)a=t[t[c].f<t[u].f?c++:u++],l=t[c!=h&&t[c].f<t[u].f?c++:u++],t[h++]={s:-1,f:a.f+l.f,l:a,r:l};for(var d=n[0].s,r=1;r<i;++r)n[r].s>d&&(d=n[r].s);var g=new je(d+1),p=cn(t[h-1],g,0);if(p>e){var r=0,y=0,m=p-e,P=1<<m;for(n.sort(function(x,T){return g[T.s]-g[x.s]||x.f-T.f});r<i;++r){var E=n[r].s;if(g[E]>e)y+=P-(1<<p-g[E]),g[E]=e;else break}for(y>>=m;y>0;){var b=n[r].s;g[b]<e?y-=1<<e-g[b]++-1:++r}for(;r>=0&&y;--r){var S=n[r].s;g[S]==e&&(--g[S],++y)}p=e}return{t:new Te(g),l:p}},cn=function(s,e,t){return s.s==-1?Math.max(cn(s.l,e,t+1),cn(s.r,e,t+1)):e[s.s]=t},Ja=function(s){for(var e=s.length;e&&!s[--e];);for(var t=new je(++e),r=0,i=s[0],n=1,o=function(l){t[r++]=l},a=1;a<=e;++a)if(s[a]==i&&a!=e)++n;else{if(!i&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(i),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(i);n=1,i=s[a]}return{c:t.subarray(0,r),n:e}},qr=function(s,e){for(var t=0,r=0;r<e.length;++r)t+=s[r]*e[r];return t},Qa=function(s,e,t){var r=t.length,i=an(e+2);s[i]=r&255,s[i+1]=r>>8,s[i+2]=s[i]^255,s[i+3]=s[i+1]^255;for(var n=0;n<r;++n)s[i+n+4]=t[n];return(i+4+r)*8},el=function(s,e,t,r,i,n,o,a,l,c,h){Mt(e,h++,t),++i[256];for(var u=ln(i,15),d=u.t,g=u.l,p=ln(n,15),y=p.t,m=p.l,P=Ja(d),E=P.c,b=P.n,S=Ja(y),w=S.c,x=S.n,T=new je(19),C=0;C<E.length;++C)++T[E[C]&31];for(var C=0;C<w.length;++C)++T[w[C]&31];for(var L=ln(T,7),G=L.t,U=L.l,R=19;R>4&&!G[tn[R-1]];--R);var z=c+5<<3,B=qr(i,Bt)+qr(n,jr)+o,D=qr(i,d)+qr(n,y)+o+14+3*R+qr(T,G)+2*T[16]+3*T[17]+7*T[18];if(l>=0&&z<=B&&z<=D)return Qa(e,h,s.subarray(l,l+c));var H,I,F,j;if(Mt(e,h,1+(D<B)),h+=2,D<B){H=pt(d,g,0),I=d,F=pt(y,m,0),j=y;var O=pt(G,U,0);Mt(e,h,b-257),Mt(e,h+5,x-1),Mt(e,h+10,R-4),h+=14;for(var C=0;C<R;++C)Mt(e,h+3*C,G[tn[C]]);h+=3*R;for(var $=[E,w],A=0;A<2;++A)for(var M=$[A],C=0;C<M.length;++C){var N=M[C]&31;Mt(e,h,O[N]),h+=G[N],N>15&&(Mt(e,h,M[C]>>5&127),h+=M[C]>>12)}}else H=Cf,I=Bt,F=Sf,j=jr;for(var C=0;C<a;++C){var V=r[C];if(V>255){var N=V>>18&31;Wr(e,h,H[N+257]),h+=I[N+257],N>7&&(Mt(e,h,V>>23&31),h+=Bi[N]);var Y=V&31;Wr(e,h,F[Y]),h+=j[Y],Y>3&&(Wr(e,h,V>>5&8191),h+=Li[Y])}else Wr(e,h,H[V]),h+=I[V]}return Wr(e,h,H[256]),h+I[256]},Of=new en([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),tl=new Te(0),kf=function(s,e,t,r,i,n){var o=n.z||s.length,a=new Te(r+o+5*(1+Math.ceil(o/7e3))+i),l=a.subarray(r,a.length-i),c=n.l,h=(n.r||0)&7;if(e){h&&(l[0]=n.r>>3);for(var u=Of[e-1],d=u>>13,g=u&8191,p=(1<<t)-1,y=n.p||new je(32768),m=n.h||new je(p+1),P=Math.ceil(t/3),E=2*P,b=function(ze){return(s[ze]^s[ze+1]<<P^s[ze+2]<<E)&p},S=new en(25e3),w=new je(288),x=new je(32),T=0,C=0,L=n.i||0,G=0,U=n.w||0,R=0;L+2<o;++L){var z=b(L),B=L&32767,D=m[z];if(y[B]=D,m[z]=B,U<=L){var H=o-L;if((T>7e3||G>24576)&&(H>423||!c)){h=el(s,l,0,S,w,x,C,G,R,L-R,h),G=T=C=0,R=L;for(var I=0;I<286;++I)w[I]=0;for(var I=0;I<30;++I)x[I]=0}var F=2,j=0,O=g,$=B-D&32767;if(H>2&&z==b(L-$))for(var A=Math.min(d,H)-1,M=Math.min(32767,L),N=Math.min(258,H);$<=M&&--O&&B!=D;){if(s[L+F]==s[L+F-$]){for(var V=0;V<N&&s[L+V]==s[L+V-$];++V);if(V>F){if(F=V,j=$,V>A)break;for(var Y=Math.min($,V-2),J=0,I=0;I<Y;++I){var oe=L-$+I&32767,_t=y[oe],Ze=oe-_t&32767;Ze>J&&(J=Ze,D=oe)}}}B=D,D=y[B],$+=B-D&32767}if(j){S[G++]=268435456|rn[F]<<18|Ka[j];var Be=rn[F]&31,$e=Ka[j]&31;C+=Bi[Be]+Li[$e],++w[257+Be],++x[$e],U=L+F,++T}else S[G++]=s[L],++w[s[L]]}}for(L=Math.max(L,U);L<o;++L)S[G++]=s[L],++w[s[L]];h=el(s,l,c,S,w,x,C,G,R,L-R,h),c||(n.r=h&7|l[h/8|0]<<3,h-=7,n.h=m,n.p=y,n.i=L,n.w=U)}else{for(var L=n.w||0;L<o+c;L+=65535){var Pe=L+65535;Pe>=o&&(l[h/8|0]=c,Pe=o),h=Qa(l,h+1,s.subarray(L,Pe))}n.i=o}return Za(a,0,r+an(h)+i)},rl=function(){var s=1,e=0;return{p:function(t){for(var r=s,i=e,n=t.length|0,o=0;o!=n;){for(var a=Math.min(o+2655,n);o<a;++o)i+=r+=t[o];r=(r&65535)+15*(r>>16),i=(i&65535)+15*(i>>16)}s=r,e=i},d:function(){return s%=65521,e%=65521,(s&255)<<24|(s&65280)<<8|(e&255)<<8|e>>8}}},Df=function(s,e,t,r,i){if(!i&&(i={l:1},e.dictionary)){var n=e.dictionary.subarray(-32768),o=new Te(n.length+s.length);o.set(n),o.set(s,n.length),s=o,i.w=n.length}return kf(s,e.level==null?6:e.level,e.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(s.length)))*1.5):20:12+e.mem,t,r,i)},il=function(s,e,t){for(;t;++e)s[e]=t,t>>>=8},If=function(s,e){var t=e.level,r=t==0?0:t<6?1:t==9?3:2;if(s[0]=120,s[1]=r<<6|(e.dictionary&&32),s[1]|=31-(s[0]<<8|s[1])%31,e.dictionary){var i=rl();i.p(e.dictionary),il(s,2,i.d())}},Rf=function(s,e){return((s[0]&15)!=8||s[0]>>4>7||(s[0]<<8|s[1])%31)&&rt(6,"invalid zlib data"),(s[1]>>5&1)==1&&rt(6,"invalid zlib data: "+(s[1]&32?"need":"unexpected")+" dictionary"),(s[1]>>3&4)+2};function Uf(s,e){e||(e={});var t=rl();t.p(s);var r=Df(s,e,e.dictionary?6:2,4);return If(r,e),il(r,r.length-4,t.d()),r}function Bf(s,e){return Af(s.subarray(Rf(s),-4),{i:2},e,e)}var Lf=typeof TextDecoder<"u"&&new TextDecoder,Ff=0;try{Lf.decode(tl,{stream:!0}),Ff=1}catch{}const Nf="modern-font";function Xr(s,e){if(!s)throw new Error(`[${Nf}] ${e}`)}function $f(s){if("buffer"in s){const e=s.buffer;return s.byteOffset>0||s.byteLength<s.buffer.byteLength?e.slice(s.byteOffset,s.byteOffset+s.byteLength):e}else return s}function yr(s){return"buffer"in s?new DataView(s.buffer,s.byteOffset,s.byteLength):new DataView(s)}function zf(s){let e="";for(let t=0,r=s.length,i;t<r;t++)i=s.charCodeAt(t),i!==0&&(e+=String.fromCharCode(i));return e}function Fi(s){s=zf(s);const e=[];for(let t=0,r=s.length,i;t<r;t++)i=s.charCodeAt(t),e.push(i>>8),e.push(i&255);return e}function Vf(s){let e="";for(let t=0,r=s.length;t<r;t++)s[t]<127?e+=String.fromCharCode(s[t]):e+=`%${(256+s[t]).toString(16).slice(1)}`;return unescape(e)}function Gf(s){let e="";for(let t=0,r=s.length;t<r;t+=2)e+=String.fromCharCode((s[t]<<8)+s[t+1]);return e}var jf=Object.defineProperty,Se=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&jf(e,t,i),i};const Hr={int8:1,int16:2,int32:4,uint8:1,uint16:2,uint32:4,float32:4,float64:8,fixed:4,longDateTime:8,char:1};function Ee(){return function(s,e){Object.defineProperty(s.constructor.prototype,e,{get(){if(typeof e=="string"){if(e.startsWith("read"))return(...t)=>this.read(e.substring(4).toLowerCase(),...t);if(e.startsWith("write"))return(...t)=>this.write(e.substring(5).toLowerCase(),...t)}},configurable:!0,enumerable:!0})}}class me extends DataView{constructor(e,t,r,i){super($f(e),t,r),this.littleEndian=i}cursor=0;readColumn(e){if(e.size){const t=Array.from({length:e.size},(r,i)=>this.read(e.type,e.offset+i));switch(e.type){case"char":return t.join("");default:return t}}else return this.read(e.type,e.offset)}writeColumn(e,t){e.size?Array.from({length:e.size},(r,i)=>{this.write(e.type,t[i],e.offset+i)}):this.write(e.type,t,e.offset)}read(e,t=this.cursor,r=this.littleEndian){switch(e){case"char":return this.readChar(t);case"fixed":return this.readFixed(t,r);case"longDateTime":return this.readLongDateTime(t,r)}const i=`get${e.replace(/^\S/,l=>l.toUpperCase())}`,n=this,a=n[i]?.bind(n)?.(t,r);return this.cursor+=Hr[e],a}readUint24(e=this.cursor){const[t,r,i]=this.readBytes(e,3);return(t<<16)+(r<<8)+i}readBytes(e,t){t==null&&(t=e,e=this.cursor);const r=[];for(let i=0;i<t;++i)r.push(this.getUint8(e+i));return this.cursor=e+t,r}readString(e,t){const r=this.readBytes(e,t);let i="";for(let n=0,o=r.length;n<o;n++)i+=String.fromCharCode(r[n]);return i}readFixed(e,t){const r=this.readInt32(e,t)/65536;return Math.ceil(r*1e5)/1e5}readLongDateTime(e=this.cursor,t){const r=this.readUint32(e+4,t),i=new Date;return i.setTime(r*1e3+-20775456e5),i}readChar(e){return this.readString(e,1)}write(e,t,r=this.cursor,i=this.littleEndian){switch(e){case"char":return this.writeChar(t,r);case"fixed":return this.writeFixed(t,r);case"longDateTime":return this.writeLongDateTime(t,r)}const n=`set${e.replace(/^\S/,c=>c.toUpperCase())}`,o=this,l=o[n]?.bind(o)?.(r,t,i);return this.cursor+=Hr[e.toLowerCase()],l}writeString(e="",t=this.cursor){const r=e.replace(/[^\x00-\xFF]/g,"11").length;this.seek(t);for(let i=0,n=e.length,o;i<n;++i)o=e.charCodeAt(i)||0,o>127?this.writeUint16(o):this.writeUint8(o);return this.cursor+=r,this}writeChar(e,t){return this.writeString(e,t)}writeFixed(e,t){return this.writeInt32(Math.round(e*65536),t),this}writeLongDateTime(e,t=this.cursor){typeof e>"u"?e=-20775456e5:typeof e.getTime=="function"?e=e.getTime():/^\d+$/.test(e)?e=+e:e=Date.parse(e);const i=Math.round((e- -20775456e5)/1e3);return this.writeUint32(0,t),this.writeUint32(i,t+4),this}writeBytes(e,t=this.cursor){let r;if(Array.isArray(e)){r=e.length;for(let i=0;i<r;++i)this.setUint8(t+i,e[i])}else{const i=yr(e);r=i.byteLength;for(let n=0;n<r;++n)this.setUint8(t+n,i.getUint8(n))}return this.cursor=t+r,this}seek(e){return this.cursor=e,this}}Se([Ee()],me.prototype,"readInt8"),Se([Ee()],me.prototype,"readInt16"),Se([Ee()],me.prototype,"readInt32"),Se([Ee()],me.prototype,"readUint8"),Se([Ee()],me.prototype,"readUint16"),Se([Ee()],me.prototype,"readUint32"),Se([Ee()],me.prototype,"readFloat32"),Se([Ee()],me.prototype,"readFloat64"),Se([Ee()],me.prototype,"writeInt8"),Se([Ee()],me.prototype,"writeInt16"),Se([Ee()],me.prototype,"writeInt32"),Se([Ee()],me.prototype,"writeUint8"),Se([Ee()],me.prototype,"writeUint16"),Se([Ee()],me.prototype,"writeUint32"),Se([Ee()],me.prototype,"writeFloat32"),Se([Ee()],me.prototype,"writeFloat64");const sl=new WeakMap;function v(s){const e=typeof s=="object"?s:{type:s},{size:t=1,type:r}=e;return(i,n)=>{if(typeof n!="string")return;let o=sl.get(i);o||(o={columns:[],byteLength:0},sl.set(i,o));const a={...e,name:n,byteLength:t*Hr[r],offset:e.offset??o.columns.reduce((l,c)=>l+c.byteLength,0)};o.columns.push(a),o.byteLength=o.columns.reduce((l,c)=>l+Hr[c.type]*(c.size??1),0),Object.defineProperty(i.constructor.prototype,n,{get(){return this.view.readColumn(a)},set(l){this.view.writeColumn(a,l)},configurable:!0,enumerable:!0})}}class We{view;constructor(e,t,r,i){this.view=new me(e,t,r,i)}}class Ni extends We{get buffer(){return this.view.buffer}toBuffer(){return this.view.buffer.slice(this.view.byteOffset,this.view.byteOffset+this.view.byteLength)}toBlob(){return new Blob([new Uint8Array(this.view.buffer,this.view.byteOffset,this.view.byteLength)],{type:this.mimeType})}toFontFace(e){return new FontFace(e,this.view.buffer)}}var Wf=Object.defineProperty,De=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Wf(e,t,i),i};const Ie=class mc extends Ni{format="EmbeddedOpenType";mimeType="application/vnd.ms-fontobject";static from(e){const t=e.sfnt,i=t.name.names,n=Fi(i.fontFamily||""),o=n.length,a=Fi(i.fontStyle||""),l=a.length,c=Fi(i.version||""),h=c.length,u=Fi(i.fullName||""),d=u.length,g=86+o+4+l+4+h+4+d+2+e.view.byteLength,p=new mc(new ArrayBuffer(g),0,g,!0);p.EOTSize=p.view.byteLength,p.FontDataSize=e.view.byteLength,p.Version=131073,p.Flags=0,p.Charset=1,p.MagicNumber=20556,p.Padding1=0,p.CheckSumAdjustment=t.head.checkSumAdjustment;const y=t.os2;return y&&(p.FontPANOSE=y.fontPANOSE,p.Italic=y.fsSelection,p.Weight=y.usWeightClass,p.fsType=y.fsType,p.UnicodeRange=y.ulUnicodeRange,p.CodePageRange=y.ulCodePageRange),p.view.writeUint16(o),p.view.writeBytes(n),p.view.writeUint16(0),p.view.writeUint16(l),p.view.writeBytes(a),p.view.writeUint16(0),p.view.writeUint16(h),p.view.writeBytes(c),p.view.writeUint16(0),p.view.writeUint16(d),p.view.writeBytes(u),p.view.writeUint16(0),p.view.writeUint16(0),p.view.writeBytes(e.view),p}};De([v("uint32")],Ie.prototype,"EOTSize"),De([v("uint32")],Ie.prototype,"FontDataSize"),De([v("uint32")],Ie.prototype,"Version"),De([v("uint32")],Ie.prototype,"Flags"),De([v({type:"uint8",size:10})],Ie.prototype,"FontPANOSE"),De([v("uint8")],Ie.prototype,"Charset"),De([v("uint8")],Ie.prototype,"Italic"),De([v("uint32")],Ie.prototype,"Weight"),De([v("uint16")],Ie.prototype,"fsType"),De([v("uint16")],Ie.prototype,"MagicNumber"),De([v({type:"uint8",size:16})],Ie.prototype,"UnicodeRange"),De([v({type:"uint8",size:8})],Ie.prototype,"CodePageRange"),De([v("uint32")],Ie.prototype,"CheckSumAdjustment"),De([v({type:"uint8",size:16})],Ie.prototype,"Reserved"),De([v("uint16")],Ie.prototype,"Padding1");var qf=Object.defineProperty,$i=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&qf(e,t,i),i};class vr extends We{constructor(e,t){super(e,t,16)}}$i([v({type:"char",size:4})],vr.prototype,"tag"),$i([v("uint32")],vr.prototype,"checkSum"),$i([v("uint32")],vr.prototype,"offset"),$i([v("uint32")],vr.prototype,"length");const hn=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],Xf=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"];class un{index;name;isComposite=!1;components=[];pathCommands=[];constructor(e){const t={...e};if(this.index=t.index??0,t.name===".notdef"?t.unicode=void 0:t.name===".null"&&(t.unicode=0),t.unicode===0&&t.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=t.name??null,t.unicode&&(this.unicode=t.unicode),t.unicodes?this.unicodes=t.unicodes:t.unicode&&(this.unicodes=[t.unicode])}getPathCommands(e=0,t=0,r=72,i={},n){const o=1/(n?.unitsPerEm??1e3)*r,{xScale:a=o,yScale:l=o}=i,c=this.pathCommands,h=[];for(let u=0,d=c.length;u<d;u+=1){const g=c[u];g.type==="M"?h.push({type:"M",x:e+g.x*a,y:t+-g.y*l}):g.type==="L"?h.push({type:"L",x:e+g.x*a,y:t+-g.y*l}):g.type==="Q"?h.push({type:"Q",x1:e+g.x1*a,y1:t+-g.y1*l,x:e+g.x*a,y:t+-g.y*l}):g.type==="C"?h.push({type:"C",x1:e+g.x1*a,y1:t+-g.y1*l,x2:e+g.x2*a,y2:t+-g.y2*l,x:e+g.x*a,y:t+-g.y*l}):g.type==="Z"&&h.push({type:"Z"})}return h}}class Hf extends un{parse(e,t,r){const i=this,{nominalWidthX:n,defaultWidthX:o,gsubrsBias:a,subrsBias:l}=e,c=e.topDict.paintType,h=this.index;let u,d,g,p;const y=[],m=[];let P=0,E=!1,b=!1,S=o,w=0,x=0;function T(B,D){y.push({type:"L",x:B,y:D})}function C(B,D,H,I,F,j){y.push({type:"C",x1:B,y1:D,x2:H,y2:I,x:F,y:j})}function L(B,D){b&&c!==2&&G(),b=!0,y.push({type:"M",x:B,y:D})}function G(){y.push({type:"Z"})}function U(B){y.push(...B)}function R(){m.length%2!==0&&!E&&(S=m.shift()+n),P+=m.length>>1,m.length=0,E=!0}function z(B){let D,H,I,F,j,O,$,A,M,N,V,Y,J=0;for(;J<B.length;){let oe=B[J++];switch(oe){case 1:R();break;case 3:R();break;case 4:m.length>1&&!E&&(S=m.shift()+n,E=!0),x+=m.pop(),L(w,x);break;case 5:for(;m.length>0;)w+=m.shift(),x+=m.shift(),T(w,x);break;case 6:for(;m.length>0&&(w+=m.shift(),T(w,x),m.length!==0);)x+=m.shift(),T(w,x);break;case 7:for(;m.length>0&&(x+=m.shift(),T(w,x),m.length!==0);)w+=m.shift(),T(w,x);break;case 8:for(;m.length>0;)u=w+m.shift(),d=x+m.shift(),g=u+m.shift(),p=d+m.shift(),w=g+m.shift(),x=p+m.shift(),C(u,d,g,p,w,x);break;case 10:j=m.pop()+l,O=e.subrs[j],O&&z(O);break;case 11:return;case 12:switch(oe=B[J],J+=1,oe){case 35:u=w+m.shift(),d=x+m.shift(),g=u+m.shift(),p=d+m.shift(),$=g+m.shift(),A=p+m.shift(),M=$+m.shift(),N=A+m.shift(),V=M+m.shift(),Y=N+m.shift(),w=V+m.shift(),x=Y+m.shift(),m.shift(),C(u,d,g,p,$,A),C(M,N,V,Y,w,x);break;case 34:u=w+m.shift(),d=x,g=u+m.shift(),p=d+m.shift(),$=g+m.shift(),A=p,M=$+m.shift(),N=p,V=M+m.shift(),Y=x,w=V+m.shift(),C(u,d,g,p,$,A),C(M,N,V,Y,w,x);break;case 36:u=w+m.shift(),d=x+m.shift(),g=u+m.shift(),p=d+m.shift(),$=g+m.shift(),A=p,M=$+m.shift(),N=p,V=M+m.shift(),Y=N+m.shift(),w=V+m.shift(),C(u,d,g,p,$,A),C(M,N,V,Y,w,x);break;case 37:u=w+m.shift(),d=x+m.shift(),g=u+m.shift(),p=d+m.shift(),$=g+m.shift(),A=p+m.shift(),M=$+m.shift(),N=A+m.shift(),V=M+m.shift(),Y=N+m.shift(),Math.abs(V-w)>Math.abs(Y-x)?w=V+m.shift():x=Y+m.shift(),C(u,d,g,p,$,A),C(M,N,V,Y,w,x);break;default:console.warn(`Glyph ${h}: unknown operator ${1200+oe}`),m.length=0}break;case 14:if(m.length>=4){const _t=hn[m.pop()],Ze=hn[m.pop()],Be=m.pop(),$e=m.pop();if(_t&&Ze){i.isComposite=!0,i.components=[];const Pe=e.charset.indexOf(_t),ze=e.charset.indexOf(Ze);i.components.push({glyphIndex:ze,dx:0,dy:0}),i.components.push({glyphIndex:Pe,dx:$e,dy:Be}),U(r.get(ze).pathCommands);const ot=JSON.parse(JSON.stringify(r.get(Pe).pathCommands));for(let at=0;at<ot.length;at+=1){const Je=ot[at];Je.type!=="Z"&&(Je.x+=$e,Je.y+=Be),(Je.type==="Q"||Je.type==="C")&&(Je.x1+=$e,Je.y1+=Be),Je.type==="C"&&(Je.x2+=$e,Je.y2+=Be)}U(ot)}}else m.length>0&&!E&&(S=m.shift()+n,E=!0);b&&c!==2&&(G(),b=!1);break;case 18:R();break;case 19:case 20:R(),J+=P+7>>3;break;case 21:m.length>2&&!E&&(S=m.shift()+n,E=!0),x+=m.pop(),w+=m.pop(),L(w,x);break;case 22:m.length>1&&!E&&(S=m.shift()+n,E=!0),w+=m.pop(),L(w,x);break;case 23:R();break;case 24:for(;m.length>2;)u=w+m.shift(),d=x+m.shift(),g=u+m.shift(),p=d+m.shift(),w=g+m.shift(),x=p+m.shift(),C(u,d,g,p,w,x);w+=m.shift(),x+=m.shift(),T(w,x);break;case 25:for(;m.length>6;)w+=m.shift(),x+=m.shift(),T(w,x);u=w+m.shift(),d=x+m.shift(),g=u+m.shift(),p=d+m.shift(),w=g+m.shift(),x=p+m.shift(),C(u,d,g,p,w,x);break;case 26:for(m.length%2&&(w+=m.shift());m.length>0;)u=w,d=x+m.shift(),g=u+m.shift(),p=d+m.shift(),w=g,x=p+m.shift(),C(u,d,g,p,w,x);break;case 27:for(m.length%2&&(x+=m.shift());m.length>0;)u=w+m.shift(),d=x,g=u+m.shift(),p=d+m.shift(),w=g+m.shift(),x=p,C(u,d,g,p,w,x);break;case 28:D=B[J],H=B[J+1],m.push((D<<24|H<<16)>>16),J+=2;break;case 29:j=m.pop()+a,O=e.gsubrs[j],O&&z(O);break;case 30:for(;m.length>0&&(u=w,d=x+m.shift(),g=u+m.shift(),p=d+m.shift(),w=g+m.shift(),x=p+(m.length===1?m.shift():0),C(u,d,g,p,w,x),m.length!==0);)u=w+m.shift(),d=x,g=u+m.shift(),p=d+m.shift(),x=p+m.shift(),w=g+(m.length===1?m.shift():0),C(u,d,g,p,w,x);break;case 31:for(;m.length>0&&(u=w+m.shift(),d=x,g=u+m.shift(),p=d+m.shift(),x=p+m.shift(),w=g+(m.length===1?m.shift():0),C(u,d,g,p,w,x),m.length!==0);)u=w,d=x+m.shift(),g=u+m.shift(),p=d+m.shift(),w=g+m.shift(),x=p+(m.length===1?m.shift():0),C(u,d,g,p,w,x);break;default:oe<32?console.warn(`Glyph ${h}: unknown operator ${oe}`):oe<247?m.push(oe-139):oe<251?(D=B[J],J+=1,m.push((oe-247)*256+D+108)):oe<255?(D=B[J],J+=1,m.push(-(oe-251)*256-D-108)):(D=B[J],H=B[J+1],I=B[J+2],F=B[J+3],J+=4,m.push((D<<24|H<<16|I<<8|F)/65536))}}}z(t),this.pathCommands=y,E&&(this.advanceWidth=S)}}class fn{constructor(e){this._sfnt=e}_items=[];get(e){const t=this._items[e];let r;if(t)r=t;else{r=this._get(e);const i=this._sfnt.hmtx.metrics[e];i&&(r.advanceWidth=r.advanceWidth||i.advanceWidth,r.leftSideBearing=r.leftSideBearing||i.leftSideBearing);const n=this._sfnt.cmap.glyphIndexToUnicodesMap.get(e);n&&(r.unicode??=n[0],r.unicodes??=n),this._items[e]=r}return r}}class Yf extends fn{get length(){return this._sfnt.cff.charStringsIndex.offsets.length-1}_get(e){const t=this._sfnt.cff,r=new Hf({index:e});return r.parse(t,t.charStringsIndex.get(e),this),r.name=t.charset[e],r}}var Kf=Object.defineProperty,nl=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Kf(e,t,i),i};class zi extends We{_offsets;get offsets(){return this._offsets??=this.readOffsets()}_objects;get objects(){return this._objects??=this.readObjects()}constructor(e,t,r,i){super(e,t,r,i),this._init()}_init(){const e=this.view,t=this.count,r=this.offsetSize;this.objectOffset=(t+1)*r+2,this.endOffset=e.byteOffset+this.objectOffset+this.offsets[t]}readOffsets(){const e=this.view,t=this.count,r=this.offsetSize;e.seek(3);const i=[];for(let n=0,o=t+1;n<o;n++){const a=this.view;let l=0;for(let c=0;c<r;c++)l<<=8,l+=a.readUint8();i.push(l)}return i}readObjects(){const e=[];for(let t=0,r=this.count;t<r;t++)e.push(this.get(t));return e}get(e){const t=this.offsets,r=this.objectOffset,i=r+t[e],o=r+t[e+1]-i;return this._isString?this.view.readString(i,o):this.view.readBytes(i,o)}}nl([v("uint16")],zi.prototype,"count"),nl([v("uint8")],zi.prototype,"offsetSize");class Vi extends zi{_isString=!1}class ol extends zi{_isString=!0}const Zf=[".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"],Jf=[".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"],Qf=[".notdef","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"],ed=[".notdef","space","dollaroldstyle","dollarsuperior","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","hyphensuperior","colonmonetary","onefitted","rupiah","centoldstyle","figuredash","hypheninferior","onequarter","onehalf","threequarters","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"];function Gi(s,e){return e<=390?Zf[e]:s[e-391]}function ie(s,e="number",t){return(r,i)=>{if(typeof i!="string")return;const n={type:e,operator:s,default:t??e==="number"?0:void 0};Object.defineProperty(r.constructor.prototype,i,{get(){return this._getProp(n)},set(o){this._setProp(n,o)},configurable:!0,enumerable:!0})}}class al extends We{_dict;get dict(){return this._dict??=this._readDict()}_stringIndex;setStringIndex(e){return this._stringIndex=e,this}_readFloatOperand(){const e=this.view;let t="";const r=15,i=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){const n=e.readUint8(),o=n>>4,a=n&15;if(o===r||(t+=i[o],a===r))break;t+=i[a]}return Number.parseFloat(t)}_readOperand(e){const t=this.view;let r,i,n,o;if(e===28)return r=t.readUint8(),i=t.readUint8(),r<<8|i;if(e===29)return r=t.readUint8(),i=t.readUint8(),n=t.readUint8(),o=t.readUint8(),r<<24|i<<16|n<<8|o;if(e===30)return this._readFloatOperand();if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return r=t.readUint8(),(e-247)*256+r+108;if(e>=251&&e<=254)return r=t.readUint8(),-(e-251)*256-r-108;throw new Error(`invalid b0 ${e}, at: ${t.cursor}`)}_readDict(){const e=this.view;e.seek(0);let t=[];const r=e.cursor+e.byteLength,i={};for(;e.cursor<r;){let n=e.readUint8();n<=21?(n===12&&(n=1200+e.readUint8()),i[n]=t,t=[]):t.push(this._readOperand(n))}return i}_getProp(e){const t=this.dict[e.operator]??e.default;switch(e.type){case"number":return t[0];case"string":return Gi(this._stringIndex?.objects??[],t[0]);case"number[]":return t}return t}_setProp(e,t){}}var td=Object.defineProperty,dn=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&td(e,t,i),i};class ji extends al{}dn([ie(19)],ji.prototype,"subrs"),dn([ie(20)],ji.prototype,"defaultWidthX"),dn([ie(21)],ji.prototype,"nominalWidthX");var rd=Object.defineProperty,ce=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&rd(e,t,i),i};class ne extends al{}ce([ie(0,"string")],ne.prototype,"version"),ce([ie(1,"string")],ne.prototype,"notice"),ce([ie(1200,"string")],ne.prototype,"copyright"),ce([ie(2,"string")],ne.prototype,"fullName"),ce([ie(3,"string")],ne.prototype,"familyName"),ce([ie(4,"string")],ne.prototype,"weight"),ce([ie(1201)],ne.prototype,"isFixedPitch"),ce([ie(1202)],ne.prototype,"italicAngle"),ce([ie(1203,"number",-100)],ne.prototype,"underlinePosition"),ce([ie(1204,"number",50)],ne.prototype,"underlineThickness"),ce([ie(1205)],ne.prototype,"paintType"),ce([ie(1206,"number",2)],ne.prototype,"charstringType"),ce([ie(1207,"number[]",[.001,0,0,.001,0,0])],ne.prototype,"fontMatrix"),ce([ie(13)],ne.prototype,"uniqueId"),ce([ie(5,"number[]",[0,0,0,0])],ne.prototype,"fontBBox"),ce([ie(1208)],ne.prototype,"strokeWidth"),ce([ie(14)],ne.prototype,"xuid"),ce([ie(15)],ne.prototype,"charset"),ce([ie(16)],ne.prototype,"encoding"),ce([ie(17)],ne.prototype,"charStrings"),ce([ie(18,"number[]",[0,0])],ne.prototype,"private");function be(s,e=s){return t=>{gt.tableDefinitions.set(s,{tag:s,prop:e,class:t}),Object.defineProperty(gt.prototype,e,{get(){return this.get(s)},set(r){return this.set(s,r)},configurable:!0,enumerable:!0})}}class gt{static tableDefinitions=new Map;tables=new Map;tableViews=new Map;get hasGlyf(){return this.tableViews.has("glyf")}get names(){return this.name.names}get unitsPerEm(){return this.head.unitsPerEm}get ascender(){return this.hhea.ascent}get descender(){return this.hhea.descent}get createdTimestamp(){return this.head.created}get modifiedTimestamp(){return this.head.modified}get numGlyphs(){return this.maxp.numGlyphs}get unicodes(){return this.cmap.glyphIndexToUnicodesMap}get glyphs(){return this.hasGlyf?this.glyf.glyphs:this.cff.glyphs}charToGlyphIndex(e){let t=this.cmap.unicodeToGlyphIndexMap.get(e.codePointAt(0));if(t===void 0&&!this.hasGlyf){const{encoding:r,charset:i}=this.cff;t=i.indexOf(r[e.codePointAt(0)])}return t??0}charToGlyph(e){return this.glyphs.get(this.charToGlyphIndex(e))}textToGlyphIndexes(e){const t=[];for(const r of e)t.push(this.charToGlyphIndex(r));return t}textToGlyphs(e){const t=this.glyphs,r=this.textToGlyphIndexes(e),i=r.length,n=Array.from({length:i}),o=t.get(0);for(let a=0;a<i;a+=1)n[a]=t.get(r[a])||o;return n}getPathCommands(e,t,r,i,n){const o=[];return this.forEachGlyph(e,t,r,i,n,(a,l,c,h,u)=>{o.push(...a.getPathCommands(l,c,h,u,this))}),o}getAdvanceWidth(e,t,r){return this.forEachGlyph(e,0,0,t,r,()=>{})}forEachGlyph(e,t=0,r=0,i=72,n={},o){const a=1/this.unitsPerEm*i,l=this.textToGlyphs(e);for(let c=0;c<l.length;c+=1){const h=l[c];o.call(this,h,t,r,i,n),h.advanceWidth&&(t+=h.advanceWidth*a),n.letterSpacing?t+=n.letterSpacing*i:n.tracking&&(t+=n.tracking/1e3*i)}return t}constructor(e){(e instanceof Map?e:new Map(Object.entries(e))).forEach((r,i)=>{this.tableViews.set(i,new DataView(r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength)))})}clone(){return new gt(this.tableViews)}delete(e){const t=gt.tableDefinitions.get(e);return t?(this.tableViews.delete(e),this.tables.delete(t.prop),this):this}set(e,t){const r=gt.tableDefinitions.get(e);return r&&this.tables.set(r.prop,t),this.tableViews.set(e,t.view),this}get(e){const t=gt.tableDefinitions.get(e);if(!t)return;let r=this.tables.get(t.prop);if(!r){const i=t.class;if(i){const n=this.tableViews.get(e);if(!n)return;r=new i(n.buffer,n.byteOffset,n.byteLength).setSFNT(this),this.tables.set(t.prop,r)}}return r}}class Me extends We{setSFNT(e){return this._sfnt=e,this}getSFNT(){return this._sfnt}}var id=Object.defineProperty,sd=Object.getOwnPropertyDescriptor,Yr=(s,e,t,r)=>{for(var i=r>1?void 0:r?sd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&id(e,t,i),i};let Yt=class extends Me{_glyphs;get glyphs(){return this._glyphs??=new Yf(this._sfnt)}get gsubrs(){return this.globalSubrIndex.objects}get gsubrsBias(){return this._calcSubroutineBias(this.globalSubrIndex.objects)}privateDict;subrsIndex;get defaultWidthX(){return this.privateDict?.defaultWidthX??0}get nominalWidthX(){return this.privateDict?.nominalWidthX??0}get subrs(){return this.subrsIndex?.objects??[]}get subrsBias(){return this._calcSubroutineBias(this.subrs)}constructor(s,e,t,r){super(s,e,t,r),this._init()}_init(){const s=this.view,{buffer:e,byteOffset:t}=s,r=t+4;this.nameIndex=new ol(e,r),this.topDictIndex=new Vi(e,this.nameIndex.endOffset),this.stringIndex=new ol(e,this.topDictIndex.endOffset),this.globalSubrIndex=new Vi(e,this.stringIndex.endOffset),this.topDict=new ne(new Uint8Array(this.topDictIndex.objects[0]).buffer).setStringIndex(this.stringIndex);const i=this.topDict.private[0],n=this.topDict.private[1];i&&(this.privateDict=new ji(e,t+n,i).setStringIndex(this.stringIndex),this.privateDict.subrs&&(this.subrsIndex=new Vi(e,t+n+this.privateDict.subrs))),this.charStringsIndex=new Vi(e,t+this.topDict.charStrings);const o=this.charStringsIndex.offsets.length-1;this.topDict.charset===0?this.charset=Jf:this.topDict.charset===1?this.charset=Qf:this.topDict.charset===2?this.charset=ed:this.charset=this._readCharset(t+this.topDict.charset,o,this.stringIndex.objects),this.topDict.encoding===0?this.encoding=hn:this.topDict.encoding===1?this.encoding=Xf:this.encoding=this._readEncoding(t+this.topDict.encoding)}_readCharset(s,e,t){const r=this.view;r.seek(s);let i,n,o;e-=1;const a=[".notdef"],l=r.readUint8();if(l===0)for(i=0;i<e;i+=1)n=r.readUint16(),a.push(Gi(t,n));else if(l===1)for(;a.length<=e;)for(n=r.readUint16(),o=r.readUint8(),i=0;i<=o;i+=1)a.push(Gi(t,n)),n+=1;else if(l===2)for(;a.length<=e;)for(n=r.readUint16(),o=r.readUint16(),i=0;i<=o;i+=1)a.push(Gi(t,n)),n+=1;else throw new Error(`Unknown charset format ${l}`);return a}_readEncoding(s){const e=this.view;e.seek(s);let t,r;const i={},n=e.readUint8();if(n===0){const o=e.readUint8();for(t=0;t<o;t+=1)r=e.readUint8(),i[r]=t}else if(n===1){const o=e.readUint8();for(r=1,t=0;t<o;t+=1){const a=e.readUint8(),l=e.readUint8();for(let c=a;c<=a+l;c+=1)i[c]=r,r+=1}}else console.warn(`unknown encoding format:${n}`);return i}_calcSubroutineBias(s){let e;return s.length<1240?e=107:s.length<33900?e=1131:e=32768,e}};Yr([v("uint8")],Yt.prototype,"majorVersion",2),Yr([v("uint8")],Yt.prototype,"minorVersion",2),Yr([v("uint8")],Yt.prototype,"headerSize",2),Yr([v("uint8")],Yt.prototype,"offsetSize",2),Yt=Yr([be("CFF ","cff")],Yt);var nd=Object.defineProperty,Wi=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&nd(e,t,i),i};const Kr=class yc extends We{constructor(e=new ArrayBuffer(262),t){super(e,t,262)}static from(e){const t=new yc;return t.format=0,t.length=t.view.byteLength,t.language=0,e.forEach((r,i)=>{i<256&&r<256&&t.view.writeUint8(r,6+i)}),t}getUnicodeToGlyphIndexMap(){const e=new Map;return this.glyphIndexArray.forEach((t,r)=>{e.set(r,t)}),e}};Wi([v("uint16")],Kr.prototype,"format"),Wi([v("uint16")],Kr.prototype,"length"),Wi([v("uint16")],Kr.prototype,"language"),Wi([v({type:"uint8",size:256})],Kr.prototype,"glyphIndexArray");let pn=Kr;var od=Object.defineProperty,gn=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&od(e,t,i),i};class Zr extends We{get subHeaderKeys(){return this.view.seek(6),Array.from({length:256},()=>this.view.readUint16()/8)}get maxSubHeaderKey(){return this.subHeaderKeys.reduce((e,t)=>Math.max(e,t),0)}get subHeaders(){const e=this.maxSubHeaderKey;return this.view.seek(6+256*2),Array.from({length:e},(t,r)=>({firstCode:this.view.readUint16(),entryCount:this.view.readUint16(),idDelta:this.view.readUint16(),idRangeOffset:(this.view.readUint16()-(e-r)*8-2)/2}))}get glyphIndexArray(){const e=this.maxSubHeaderKey,t=6+256*2+e*8;this.view.seek(t);const r=(this.view.byteLength-t)/2;return Array.from({length:r},()=>this.view.readUint16())}getUnicodeToGlyphIndexMap(e){const t=new Map,r=this.subHeaderKeys,i=this.maxSubHeaderKey,n=this.subHeaders,o=this.glyphIndexArray,a=r.findIndex(c=>c===i);let l=0;for(let c=0;c<256;c++)if(r[c]===0)c>=a||c<n[0].firstCode||c>=n[0].firstCode+n[0].entryCount||n[0].idRangeOffset+(c-n[0].firstCode)>=o.length?l=0:(l=o[n[0].idRangeOffset+(c-n[0].firstCode)],l!==0&&(l=l+n[0].idDelta)),l!==0&&l<e&&t.set(c,l);else{const h=r[c];for(let u=0,d=n[h].entryCount;u<d;u++)if(n[h].idRangeOffset+u>=o.length?l=0:(l=o[n[h].idRangeOffset+u],l!==0&&(l=l+n[h].idDelta)),l!==0&&l<e){const g=(c<<8|u+n[h].firstCode)%65535;t.set(g,l)}}return t}}gn([v("uint16")],Zr.prototype,"format"),gn([v("uint16")],Zr.prototype,"length"),gn([v("uint16")],Zr.prototype,"language");function ll(s){return s>32767?s-65536:s<-32767?s+65536:s}function mn(s,e){let t;const r=[];let i={};return s.forEach((n,o)=>{e&&o>e||((!t||o!==t.unicode+1||n!==t.glyphIndex+1)&&(t?(i.end=t.unicode,r.push(i),i={start:o,startId:n,delta:ll(n-o)}):(i.start=Number(o),i.startId=n,i.delta=ll(n-o))),t={unicode:o,glyphIndex:n})}),t&&(i.end=t.unicode,r.push(i)),r}var ad=Object.defineProperty,Kt=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&ad(e,t,i),i};const Lt=class vc extends We{get endCode(){const e=this.segCountX2;return this.view.seek(14),Array.from({length:e/2},()=>this.view.readUint16())}set endCode(e){this.view.seek(14),e.forEach(t=>this.view.writeUint16(t))}get reservedPad(){return this.view.readUint16(14+this.segCountX2)}set reservedPad(e){this.view.writeUint16(e,14+this.segCountX2)}get startCode(){const e=this.segCountX2;return this.view.seek(14+e+2),Array.from({length:e/2},()=>this.view.readUint16())}set startCode(e){this.view.seek(14+this.segCountX2+2),e.forEach(t=>this.view.writeUint16(t))}get idDelta(){const e=this.segCountX2;return this.view.seek(14+e+2+e),Array.from({length:e/2},()=>this.view.readUint16())}set idDelta(e){const t=this.segCountX2;this.view.seek(14+t+2+t),e.forEach(r=>this.view.writeUint16(r))}get idRangeOffsetCursor(){const e=this.segCountX2;return 14+e+2+e*2}get idRangeOffset(){const e=this.segCountX2;return this.view.seek(this.idRangeOffsetCursor),Array.from({length:e/2},()=>this.view.readUint16())}set idRangeOffset(e){this.view.seek(this.idRangeOffsetCursor),e.forEach(t=>this.view.writeUint16(t))}get glyphIndexArrayCursor(){const e=this.segCountX2;return 14+e+2+e*3}get glyphIndexArray(){const e=this.glyphIndexArrayCursor;this.view.seek(e);const t=(this.view.byteLength-e)/2;return Array.from({length:t},()=>this.view.readUint16())}static from(e){const t=mn(e,65535),r=t.length+1,i=Math.floor(Math.log(r)/Math.LN2),n=2*2**i,o=new vc(new ArrayBuffer(24+t.length*8));return o.format=4,o.length=o.view.byteLength,o.language=0,o.segCountX2=r*2,o.searchRange=n,o.entrySelector=i,o.rangeShift=2*r-n,o.endCode=[...t.map(a=>a.end),65535],o.reservedPad=0,o.startCode=[...t.map(a=>a.start),65535],o.idDelta=[...t.map(a=>a.delta),1],o.idRangeOffset=Array.from({length:r},()=>0),o}getUnicodeToGlyphIndexMap(){const e=new Map,t=this.segCountX2/2,r=(this.glyphIndexArrayCursor-this.idRangeOffsetCursor)/2,i=this.startCode,n=this.endCode,o=this.idRangeOffset,a=this.idDelta,l=this.glyphIndexArray;for(let c=0;c<t;++c)for(let h=i[c],u=n[c];h<=u;++h)if(o[c]===0)e.set(h,(h+a[c])%65536);else{const d=c+o[c]/2+(h-i[c])-r,g=l[d];g!==0?e.set(h,(g+a[c])%65536):e.set(h,0)}return e.delete(65535),e}};Kt([v("uint16")],Lt.prototype,"format"),Kt([v("uint16")],Lt.prototype,"length"),Kt([v("uint16")],Lt.prototype,"language"),Kt([v("uint16")],Lt.prototype,"segCountX2"),Kt([v("uint16")],Lt.prototype,"searchRange"),Kt([v("uint16")],Lt.prototype,"entrySelector"),Kt([v("uint16")],Lt.prototype,"rangeShift");let yn=Lt;var ld=Object.defineProperty,Jr=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&ld(e,t,i),i};class Zt extends We{get glyphIndexArray(){return this.view.seek(12),Array.from({length:this.entryCount},()=>this.view.readUint16())}getUnicodeToGlyphIndexMap(){const e=this.glyphIndexArray,t=new Map;return e.forEach((r,i)=>{t.set(i,r)}),t}}Jr([v("uint16")],Zt.prototype,"format"),Jr([v("uint16")],Zt.prototype,"length"),Jr([v("uint16")],Zt.prototype,"language"),Jr([v("uint16")],Zt.prototype,"firstCode"),Jr([v("uint16")],Zt.prototype,"entryCount");var cd=Object.defineProperty,Qr=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&cd(e,t,i),i};const _r=class _c extends We{get groups(){const e=this.nGroups;return this.view.seek(16),Array.from({length:e},()=>({startCharCode:this.view.readUint32(),endCharCode:this.view.readUint32(),startGlyphCode:this.view.readUint32()}))}static from(e){const t=mn(e),r=new _c(new ArrayBuffer(16+t.length*12));return r.format=12,r.reserved=0,r.length=r.view.byteLength,r.language=0,r.nGroups=t.length,t.forEach(i=>{r.view.writeUint32(i.start),r.view.writeUint32(i.end),r.view.writeUint32(i.startId)}),r}getUnicodeToGlyphIndexMap(){const e=new Map,t=this.groups;for(let r=0,i=t.length;r<i;r++){const n=t[r];let o=n.startGlyphCode,a=n.startCharCode;const l=n.endCharCode;for(;a<=l;)e.set(a++,o++)}return e}};Qr([v("uint16")],_r.prototype,"format"),Qr([v("uint16")],_r.prototype,"reserved"),Qr([v("uint32")],_r.prototype,"length"),Qr([v("uint32")],_r.prototype,"language"),Qr([v("uint32")],_r.prototype,"nGroups");let vn=_r;var hd=Object.defineProperty,_n=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&hd(e,t,i),i};class ei extends We{getVarSelectorRecords(){const e=this.numVarSelectorRecords;return this.view.seek(10),Array.from({length:e},()=>{const t={varSelector:this.view.readUint24(),defaultUVSOffset:this.view.readUint32(),unicodeValueRanges:[],nonDefaultUVSOffset:this.view.readUint32(),uVSMappings:[]};if(t.defaultUVSOffset){this.view.seek(t.defaultUVSOffset);const r=this.view.readUint32();t.unicodeValueRanges=Array.from({length:r},()=>({startUnicodeValue:this.view.readUint24(),additionalCount:this.view.readUint8()}))}if(t.nonDefaultUVSOffset){this.view.seek(t.nonDefaultUVSOffset);const r=this.view.readUint32();t.uVSMappings=Array.from({length:r},()=>({unicodeValue:this.view.readUint24(),glyphID:this.view.readUint16()}))}return t})}getUnicodeToGlyphIndexMap(){const e=new Map,t=this.getVarSelectorRecords();for(let r=0,i=t.length;r<i;r++){const{uVSMappings:n}=t[r];n.forEach(o=>{e.set(o.unicodeValue,o.glyphID)})}return e}}_n([v("uint16")],ei.prototype,"format"),_n([v("uint32")],ei.prototype,"length"),_n([v("uint32")],ei.prototype,"numVarSelectorRecords");var ud=Object.defineProperty,fd=Object.getOwnPropertyDescriptor,bn=(s,e,t,r)=>{for(var i=r>1?void 0:r?fd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&ud(e,t,i),i};let br=class extends Me{static from(s){const e=Array.from(s.keys()).some(h=>h>65535),t=yn.from(s),r=pn.from(s),i=e?vn.from(s):void 0,n=4+(i?32:24),o=n+t.view.byteLength,a=o+r.view.byteLength,l=[{platformID:0,platformSpecificID:3,offset:n},{platformID:1,platformSpecificID:0,offset:o},{platformID:3,platformSpecificID:1,offset:n},i&&{platformID:3,platformSpecificID:10,offset:a}].filter(Boolean),c=new br(new ArrayBuffer(4+8*l.length+t.view.byteLength+r.view.byteLength+(i?.view.byteLength??0)));return c.numberSubtables=l.length,c.view.seek(4),l.forEach(h=>{c.view.writeUint16(h.platformID),c.view.writeUint16(h.platformSpecificID),c.view.writeUint32(h.offset)}),c.view.writeBytes(t.view,n),c.view.writeBytes(r.view,o),i&&c.view.writeBytes(i.view,a),c}_unicodeToGlyphIndexMap;get unicodeToGlyphIndexMap(){return this._unicodeToGlyphIndexMap??=this.readunicodeToGlyphIndexMap()}_glyphIndexToUnicodesMap;get glyphIndexToUnicodesMap(){if(!this._glyphIndexToUnicodesMap){const s=new Map,e=this.unicodeToGlyphIndexMap,t=Array.from(e.keys());for(let r=0,i=t.length;r<i;r++){const n=t[r],o=e.get(n);s.has(o)?s.get(o).push(n):s.set(o,[n])}this._glyphIndexToUnicodesMap=s}return this._glyphIndexToUnicodesMap}readSubtables(){const s=this.numberSubtables;return this.view.seek(4),Array.from({length:s},()=>({platformID:this.view.readUint16(),platformSpecificID:this.view.readUint16(),offset:this.view.readUint32()})).map(e=>{this.view.seek(e.offset);const t=this.view.readUint16();let r;switch(t){case 0:r=new pn(this.view.buffer,e.offset);break;case 2:r=new Zr(this.view.buffer,e.offset,this.view.readUint16());break;case 4:r=new yn(this.view.buffer,e.offset,this.view.readUint16());break;case 6:r=new Zt(this.view.buffer,e.offset,this.view.readUint16());break;case 12:r=new vn(this.view.buffer,e.offset,this.view.readUint32(e.offset+4));break;case 14:default:r=new ei(this.view.buffer,e.offset,this.view.readUint32());break}return{...e,format:t,view:r}})}readunicodeToGlyphIndexMap(){const s=this.readSubtables(),e=s.find(o=>o.format===0)?.view,t=s.find(o=>o.platformID===3&&o.platformSpecificID===3&&o.format===2)?.view,r=s.find(o=>o.platformID===3&&o.platformSpecificID===1&&o.format===4)?.view,i=s.find(o=>o.platformID===3&&o.platformSpecificID===10&&o.format===12)?.view,n=s.find(o=>o.platformID===0&&o.platformSpecificID===5&&o.format===14)?.view;return new Map([...e?.getUnicodeToGlyphIndexMap()??[],...t?.getUnicodeToGlyphIndexMap(this._sfnt.maxp.numGlyphs)??[],...r?.getUnicodeToGlyphIndexMap()??[],...i?.getUnicodeToGlyphIndexMap()??[],...n?.getUnicodeToGlyphIndexMap()??[]])}};bn([v("uint16")],br.prototype,"version",2),bn([v("uint16")],br.prototype,"numberSubtables",2),br=bn([be("cmap")],br);class dd extends un{_parseContours(e){const t=[];let r=[];for(let i=0;i<e.length;i+=1){const n=e[i];r.push(n),n.lastPointOfContour&&(t.push(r),r=[])}return Xr(r.length===0,"There are still points left in the current contour."),t}_transformPoints(e,t){const r=[];for(let i=0;i<e.length;i+=1){const n=e[i],o={x:t.xScale*n.x+t.scale10*n.y+t.dx,y:t.scale01*n.x+t.yScale*n.y+t.dy,onCurve:n.onCurve,lastPointOfContour:n.lastPointOfContour};r.push(o)}return r}_parseGlyphCoordinate(e,t,r,i,n){let o;return(t&i)>0?(o=e.view.readUint8(),(t&n)===0&&(o=-o),o=r+o):(t&n)>0?o=r:o=r+e.view.readInt16(),o}parse(e,t,r){e.view.seek(t);const i=this.numberOfContours=e.view.readInt16();if(this.xMin=e.view.readInt16(),this.yMin=e.view.readInt16(),this.xMax=e.view.readInt16(),this.yMax=e.view.readInt16(),i>0){const a=this.endPointIndices=[];for(let y=0;y<i;y++)a.push(e.view.readUint16());const l=this.instructionLength=e.view.readUint16();Xr(l<5e3,`Bad instructionLength:${l}`);const c=this.instructions=[];for(let y=0;y<l;++y)c.push(e.view.readUint8());const h=e.view.byteOffset,u=a[a.length-1]+1;Xr(u<2e4,`Bad numberOfCoordinates:${h}`);const d=[];let g,p=0;for(;p<u;)if(g=e.view.readUint8(),d.push(g),p++,g&8&&p<u){const y=e.view.readUint8();for(let m=0;m<y;m++)d.push(g),p++}if(Xr(d.length===u,`Bad flags length: ${d.length}, numberOfCoordinates: ${u}`),a.length>0){const y=[];let m;if(u>0){for(let b=0;b<u;b+=1)g=d[b],m={},m.onCurve=!!(g&1),m.lastPointOfContour=a.includes(b),y.push(m);let P=0;for(let b=0;b<u;b+=1)g=d[b],m=y[b],m.x=this._parseGlyphCoordinate(e,g,P,2,16),P=m.x;let E=0;for(let b=0;b<u;b+=1)g=d[b],m=y[b],m.y=this._parseGlyphCoordinate(e,g,E,4,32),E=m.y}this.points=y}else this.points=[]}else if(i===0)this.points=[];else{this.isComposite=!0,this.points=[],this.components=[];let a,l=!0;for(;l;){a=e.view.readUint16();const c={glyphIndex:e.view.readUint16(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(a&1)>0?(a&2)>0?(c.dx=e.view.readInt16(),c.dy=e.view.readInt16()):c.matchedPoints=[e.view.readUint16(),e.view.readUint16()]:(a&2)>0?(c.dx=e.view.readInt8(),c.dy=e.view.readInt8()):c.matchedPoints=[e.view.readUint8(),e.view.readUint8()],(a&8)>0?c.xScale=c.yScale=e.view.readInt16()/16384:(a&64)>0?(c.xScale=e.view.readInt16()/16384,c.yScale=e.view.readInt16()/16384):(a&128)>0&&(c.xScale=e.view.readInt16()/16384,c.scale01=e.view.readInt16()/16384,c.scale10=e.view.readInt16()/16384,c.yScale=e.view.readInt16()/16384),this.components.push(c),l=!!(a&32)}if(a&256){this.instructionLength=e.view.readUint16(),this.instructions=[];for(let c=0;c<this.instructionLength;c+=1)this.instructions.push(e.view.readUint8())}}if(this.isComposite)for(let a=0;a<this.components.length;a+=1){const l=this.components[a],c=r.get(l.glyphIndex);if(c.getPathCommands(),c.points){let h;if(l.matchedPoints===void 0)h=this._transformPoints(c.points,l);else{Xr(l.matchedPoints[0]>this.points.length-1||l.matchedPoints[1]>c.points.length-1,`Matched points out of range in ${this.name}`);const u=this.points[l.matchedPoints[0]];let d=c.points[l.matchedPoints[1]];const g={xScale:l.xScale,scale01:l.scale01,scale10:l.scale10,yScale:l.yScale,dx:0,dy:0};d=this._transformPoints([d],g)[0],g.dx=u.x-d.x,g.dy=u.y-d.y,h=this._transformPoints(c.points,g)}this.points=this.points.concat(h)}}const n=[],o=this._parseContours(this.points);for(let a=0,l=o.length;a<l;++a){const c=o[a];let h=c[c.length-1],u=c[0];h.onCurve?n.push({type:"M",x:h.x,y:h.y}):u.onCurve?n.push({type:"M",x:u.x,y:u.y}):n.push({type:"M",x:(h.x+u.x)*.5,y:(h.y+u.y)*.5});for(let d=0,g=c.length;d<g;++d)if(h=u,u=c[(d+1)%g],h.onCurve)n.push({type:"L",x:h.x,y:h.y});else{let p=u;u.onCurve||(p={x:(h.x+u.x)*.5,y:(h.y+u.y)*.5}),n.push({type:"Q",x1:h.x,y1:h.y,x:p.x,y:p.y})}n.push({type:"Z"})}this.pathCommands=n}}class pd extends fn{get length(){return this._sfnt.loca.locations.length}_get(e){const t=this._sfnt.loca.locations,r=t[e],i=new dd({index:e});return r!==t[e+1]&&i.parse(this._sfnt.glyf,r,this),i}}var gd=Object.getOwnPropertyDescriptor,md=(s,e,t,r)=>{for(var i=r>1?void 0:r?gd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};let qi=class extends Me{static from(s){const e=s.reduce((r,i)=>r+i.byteLength,0),t=new qi(new ArrayBuffer(e));return s.forEach(r=>{t.view.writeBytes(r)}),t}_glyphs;get glyphs(){return this._glyphs??=new pd(this._sfnt)}};qi=md([be("glyf")],qi);var yd=Object.getOwnPropertyDescriptor,vd=(s,e,t,r)=>{for(var i=r>1?void 0:r?yd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};let wn=class extends Me{};wn=vd([be("GPOS","gpos")],wn);var _d=Object.defineProperty,bd=Object.getOwnPropertyDescriptor,Jt=(s,e,t,r)=>{for(var i=r>1?void 0:r?bd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&_d(e,t,i),i};let At=class extends Me{};Jt([v("uint16")],At.prototype,"majorVersion",2),Jt([v("uint16")],At.prototype,"minorVersion",2),Jt([v("uint16")],At.prototype,"scriptListOffset",2),Jt([v("uint16")],At.prototype,"featureListOffset",2),Jt([v("uint16")],At.prototype,"lookupListOffset",2),Jt([v("uint16")],At.prototype,"featureVariationsOffset",2),At=Jt([be("GSUB","gsub")],At);var wd=Object.defineProperty,xd=Object.getOwnPropertyDescriptor,ye=(s,e,t,r)=>{for(var i=r>1?void 0:r?xd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&wd(e,t,i),i};let ue=class extends Me{constructor(s=new ArrayBuffer(54),e){super(s,e,Math.min(54,s.byteLength-(e??0)))}};ye([v("fixed")],ue.prototype,"version",2),ye([v("fixed")],ue.prototype,"fontRevision",2),ye([v("uint32")],ue.prototype,"checkSumAdjustment",2),ye([v("uint32")],ue.prototype,"magickNumber",2),ye([v("uint16")],ue.prototype,"flags",2),ye([v("uint16")],ue.prototype,"unitsPerEm",2),ye([v({type:"longDateTime"})],ue.prototype,"created",2),ye([v({type:"longDateTime"})],ue.prototype,"modified",2),ye([v("int16")],ue.prototype,"xMin",2),ye([v("int16")],ue.prototype,"yMin",2),ye([v("int16")],ue.prototype,"xMax",2),ye([v("int16")],ue.prototype,"yMax",2),ye([v("uint16")],ue.prototype,"macStyle",2),ye([v("uint16")],ue.prototype,"lowestRecPPEM",2),ye([v("int16")],ue.prototype,"fontDirectionHint",2),ye([v("int16")],ue.prototype,"indexToLocFormat",2),ye([v("int16")],ue.prototype,"glyphDataFormat",2),ue=ye([be("head")],ue);var Pd=Object.defineProperty,Cd=Object.getOwnPropertyDescriptor,Re=(s,e,t,r)=>{for(var i=r>1?void 0:r?Cd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Pd(e,t,i),i};let we=class extends Me{constructor(s=new ArrayBuffer(36),e){super(s,e,Math.min(36,s.byteLength-(e??0)))}};Re([v("fixed")],we.prototype,"version",2),Re([v("int16")],we.prototype,"ascent",2),Re([v("int16")],we.prototype,"descent",2),Re([v("int16")],we.prototype,"lineGap",2),Re([v("uint16")],we.prototype,"advanceWidthMax",2),Re([v("int16")],we.prototype,"minLeftSideBearing",2),Re([v("int16")],we.prototype,"minRightSideBearing",2),Re([v("int16")],we.prototype,"xMaxExtent",2),Re([v("int16")],we.prototype,"caretSlopeRise",2),Re([v("int16")],we.prototype,"caretSlopeRun",2),Re([v("int16")],we.prototype,"caretOffset",2),Re([v({type:"int16",size:4})],we.prototype,"reserved",2),Re([v("int16")],we.prototype,"metricDataFormat",2),Re([v("uint16")],we.prototype,"numOfLongHorMetrics",2),we=Re([be("hhea")],we);var Td=Object.getOwnPropertyDescriptor,Sd=(s,e,t,r)=>{for(var i=r>1?void 0:r?Td(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};let Xi=class extends Me{static from(s){const e=s.length*4,t=new Xi(new ArrayBuffer(e));return s.forEach(r=>{t.view.writeUint16(r.advanceWidth),t.view.writeUint16(r.leftSideBearing)}),t}_metrics;get metrics(){return this._metrics??=this.readMetrics()}readMetrics(){const s=this._sfnt.maxp.numGlyphs,e=this._sfnt.hhea.numOfLongHorMetrics;let t=0;const r=this.view;return r.seek(0),Array.from({length:s}).map((i,n)=>(n<e&&(t=r.readUint16()),{advanceWidth:t,leftSideBearing:r.readUint16()}))}};Xi=Sd([be("hmtx")],Xi);var Ed=Object.getOwnPropertyDescriptor,Md=(s,e,t,r)=>{for(var i=r>1?void 0:r?Ed(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};let xn=class extends Me{};xn=Md([be("kern","kern")],xn);var Ad=Object.getOwnPropertyDescriptor,Od=(s,e,t,r)=>{for(var i=r>1?void 0:r?Ad(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};let Hi=class extends Me{static from(s,e=1){const t=s.length*(e?4:2),r=new Hi(new ArrayBuffer(t));return s.forEach(i=>{e?r.view.writeUint32(i):r.view.writeUint16(i/2)}),r}_locations;get locations(){return this._locations??=this.readLocations()}readLocations(){const s=this._sfnt.maxp.numGlyphs,e=this._sfnt.head.indexToLocFormat,t=this.view;return t.seek(0),Array.from({length:s}).map(()=>e?t.readUint32():t.readUint16()*2)}};Hi=Od([be("loca")],Hi);var kd=Object.defineProperty,Dd=Object.getOwnPropertyDescriptor,Ae=(s,e,t,r)=>{for(var i=r>1?void 0:r?Dd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&kd(e,t,i),i};let ve=class extends Me{constructor(s=new ArrayBuffer(32),e){super(s,e,Math.min(32,s.byteLength-(e??0)))}};Ae([v("fixed")],ve.prototype,"version",2),Ae([v("uint16")],ve.prototype,"numGlyphs",2),Ae([v("uint16")],ve.prototype,"maxPoints",2),Ae([v("uint16")],ve.prototype,"maxContours",2),Ae([v("uint16")],ve.prototype,"maxComponentPoints",2),Ae([v("uint16")],ve.prototype,"maxComponentContours",2),Ae([v("uint16")],ve.prototype,"maxZones",2),Ae([v("uint16")],ve.prototype,"maxTwilightPoints",2),Ae([v("uint16")],ve.prototype,"maxStorage",2),Ae([v("uint16")],ve.prototype,"maxFunctionDefs",2),Ae([v("uint16")],ve.prototype,"maxInstructionDefs",2),Ae([v("uint16")],ve.prototype,"maxStackElements",2),Ae([v("uint16")],ve.prototype,"maxSizeOfInstructions",2),Ae([v("uint16")],ve.prototype,"maxComponentElements",2),Ae([v("uint16")],ve.prototype,"maxComponentDepth",2),ve=Ae([be("maxp")],ve);var Id=Object.defineProperty,Rd=Object.getOwnPropertyDescriptor,Yi=(s,e,t,r)=>{for(var i=r>1?void 0:r?Rd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Id(e,t,i),i};const cl={0:"copyright",1:"fontFamily",2:"fontSubFamily",3:"uniqueSubFamily",4:"fullName",5:"version",6:"postScriptName",7:"tradeMark",8:"manufacturer",9:"designer",10:"description",11:"urlOfFontVendor",12:"urlOfFontDesigner",13:"licence",14:"urlOfLicence",16:"preferredFamily",17:"preferredSubFamily",18:"compatibleFull",19:"sampleText"},Pn={Macintosh:1,Microsoft:3},Ud={Default:0},hl={UCS2:1};let wr=class extends Me{_names;get names(){return this._names??=this.readNames()}readNames(){const s=this.count;this.view.seek(6);const e=[];for(let a=0;a<s;++a)e.push({platform:this.view.readUint16(),encoding:this.view.readUint16(),language:this.view.readUint16(),nameId:this.view.readUint16(),length:this.view.readUint16(),offset:this.view.readUint16()});const t=this.stringOffset;for(let a=0;a<s;++a){const l=e[a];l.name=this.view.readBytes(t+l.offset,l.length)}let r=Pn.Macintosh,i=Ud.Default,n=0;e.some(a=>a.platform===Pn.Microsoft&&a.encoding===hl.UCS2&&a.language===1033)&&(r=Pn.Microsoft,i=hl.UCS2,n=1033);const o={};for(let a=0;a<s;++a){const l=e[a];l.platform===r&&l.encoding===i&&l.language===n&&cl[l.nameId]&&(o[cl[l.nameId]]=n===0?Vf(l.name):Gf(l.name))}return o}};Yi([v("uint16")],wr.prototype,"format",2),Yi([v("uint16")],wr.prototype,"count",2),Yi([v("uint16")],wr.prototype,"stringOffset",2),wr=Yi([be("name")],wr);var Bd=Object.defineProperty,Ld=Object.getOwnPropertyDescriptor,q=(s,e,t,r)=>{for(var i=r>1?void 0:r?Ld(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Bd(e,t,i),i};let W=class extends Me{get fontPANOSE(){return[this.bFamilyType,this.bSerifStyle,this.bWeight,this.bProportion,this.bContrast,this.bStrokeVariation,this.bArmStyle,this.bLetterform,this.bMidline,this.bXHeight]}};q([v("uint16")],W.prototype,"version",2),q([v("int16")],W.prototype,"xAvgCharWidth",2),q([v("uint16")],W.prototype,"usWeightClass",2),q([v("uint16")],W.prototype,"usWidthClass",2),q([v("uint16")],W.prototype,"fsType",2),q([v("uint16")],W.prototype,"ySubscriptXSize",2),q([v("uint16")],W.prototype,"ySubscriptYSize",2),q([v("uint16")],W.prototype,"ySubscriptXOffset",2),q([v("uint16")],W.prototype,"ySubscriptYOffset",2),q([v("uint16")],W.prototype,"ySuperscriptXSize",2),q([v("uint16")],W.prototype,"ySuperscriptYSize",2),q([v("uint16")],W.prototype,"ySuperscriptXOffset",2),q([v("uint16")],W.prototype,"ySuperscriptYOffset",2),q([v("uint16")],W.prototype,"yStrikeoutSize",2),q([v("uint16")],W.prototype,"yStrikeoutPosition",2),q([v("uint16")],W.prototype,"sFamilyClass",2),q([v({type:"uint8"})],W.prototype,"bFamilyType",2),q([v({type:"uint8"})],W.prototype,"bSerifStyle",2),q([v({type:"uint8"})],W.prototype,"bWeight",2),q([v({type:"uint8"})],W.prototype,"bProportion",2),q([v({type:"uint8"})],W.prototype,"bContrast",2),q([v({type:"uint8"})],W.prototype,"bStrokeVariation",2),q([v({type:"uint8"})],W.prototype,"bArmStyle",2),q([v({type:"uint8"})],W.prototype,"bLetterform",2),q([v({type:"uint8"})],W.prototype,"bMidline",2),q([v({type:"uint8"})],W.prototype,"bXHeight",2),q([v({type:"uint8",size:16})],W.prototype,"ulUnicodeRange",2),q([v({type:"char",size:4})],W.prototype,"achVendID",2),q([v("uint16")],W.prototype,"fsSelection",2),q([v("uint16")],W.prototype,"usFirstCharIndex",2),q([v("uint16")],W.prototype,"usLastCharIndex",2),q([v("int16")],W.prototype,"sTypoAscender",2),q([v("int16")],W.prototype,"sTypoDescender",2),q([v("int16")],W.prototype,"sTypoLineGap",2),q([v("uint16")],W.prototype,"usWinAscent",2),q([v("uint16")],W.prototype,"usWinDescent",2),q([v({offset:72,type:"uint8",size:8})],W.prototype,"ulCodePageRange",2),q([v({offset:72,type:"int16"})],W.prototype,"sxHeight",2),q([v("int16")],W.prototype,"sCapHeight",2),q([v("uint16")],W.prototype,"usDefaultChar",2),q([v("uint16")],W.prototype,"usBreakChar",2),q([v("uint16")],W.prototype,"usMaxContext",2),W=q([be("OS/2","os2")],W);var Fd=Object.defineProperty,Nd=Object.getOwnPropertyDescriptor,mt=(s,e,t,r)=>{for(var i=r>1?void 0:r?Nd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Fd(e,t,i),i};let Ye=class extends Me{constructor(s=new ArrayBuffer(32),e,t){super(s,e,t)}};mt([v("fixed")],Ye.prototype,"format",2),mt([v("fixed")],Ye.prototype,"italicAngle",2),mt([v("int16")],Ye.prototype,"underlinePosition",2),mt([v("int16")],Ye.prototype,"underlineThickness",2),mt([v("uint32")],Ye.prototype,"isFixedPitch",2),mt([v("uint32")],Ye.prototype,"minMemType42",2),mt([v("uint32")],Ye.prototype,"maxMemType42",2),mt([v("uint32")],Ye.prototype,"minMemType1",2),mt([v("uint32")],Ye.prototype,"maxMemType1",2),Ye=mt([be("post")],Ye);var $d=Object.defineProperty,zd=Object.getOwnPropertyDescriptor,Ue=(s,e,t,r)=>{for(var i=r>1?void 0:r?zd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&$d(e,t,i),i};let xe=class extends Me{constructor(s=new ArrayBuffer(36),e){super(s,e,Math.min(36,s.byteLength-(e??0)))}};Ue([v("fixed")],xe.prototype,"version",2),Ue([v("int16")],xe.prototype,"vertTypoAscender",2),Ue([v("int16")],xe.prototype,"vertTypoDescender",2),Ue([v("int16")],xe.prototype,"vertTypoLineGap",2),Ue([v("int16")],xe.prototype,"advanceHeightMax",2),Ue([v("int16")],xe.prototype,"minTopSideBearing",2),Ue([v("int16")],xe.prototype,"minBottomSideBearing",2),Ue([v("int16")],xe.prototype,"yMaxExtent",2),Ue([v("int16")],xe.prototype,"caretSlopeRise",2),Ue([v("int16")],xe.prototype,"caretSlopeRun",2),Ue([v("int16")],xe.prototype,"caretOffset",2),Ue([v({type:"int16",size:4})],xe.prototype,"reserved",2),Ue([v("int16")],xe.prototype,"metricDataFormat",2),Ue([v("int16")],xe.prototype,"numOfLongVerMetrics",2),xe=Ue([be("vhea")],xe);var Vd=Object.getOwnPropertyDescriptor,Gd=(s,e,t,r)=>{for(var i=r>1?void 0:r?Vd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};let Ki=class extends Me{static from(s){const e=s.length*4,t=new Ki(new ArrayBuffer(e));return s.forEach(r=>{t.view.writeUint16(r.advanceHeight),t.view.writeInt16(r.topSideBearing)}),t}_metrics;get metrics(){return this._metrics??=this.readMetrics()}readMetrics(){const s=this._sfnt.maxp.numGlyphs,e=this._sfnt.vhea?.numOfLongVerMetrics??0,t=this.view;t.seek(0);let r=0;return Array.from({length:s}).map((i,n)=>(n<e&&(r=t.readUint16()),{advanceHeight:r,topSideBearing:t.readUint8()}))}};Ki=Gd([be("vmtx")],Ki);var jd=Object.defineProperty,ti=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&jd(e,t,i),i};class it extends Ni{format="TrueType";mimeType="font/ttf";_sfnt;get sfnt(){return this._sfnt||(this._sfnt=this.createSFNT()),this._sfnt}static signature=new Set([65536,1953658213,1954115633]);static is(e){return typeof e=="number"?this.signature.has(e):this.signature.has(yr(e).getUint32(0))}static checksum(e){const t=yr(e);let r=t.byteLength;for(;r%4;)r++;let i=0;for(let n=0,o=r/4;n<o;n+=4)n*4<r-4&&(i+=t.getUint32(n*4,!1));return i&4294967295}static from(e){const t=u=>u+3&-4,r=e.tableViews.size,i=Array.from(e.tableViews.values()).reduce((u,d)=>u+t(d.byteLength),0),n=new this(new ArrayBuffer(12+r*16+i));n.scalerType=65536,n.numTables=r;const o=Math.log(2);n.searchRange=Math.floor(Math.log(r)/o)*16,n.entrySelector=Math.floor(n.searchRange/o),n.rangeShift=r*16-n.searchRange;let a=12+r*16,l=0;const c=n.getDirectories();e.tableViews.forEach((u,d)=>{const g=c[l++];g.tag=d,g.checkSum=this.checksum(u),g.offset=a,g.length=u.byteLength,n.view.writeBytes(u,a),a+=t(g.length)});const h=n.createSFNT().head;return h.checkSumAdjustment=0,h.checkSumAdjustment=2981146554-this.checksum(n.view),n}getDirectories(){let e=this.view.byteOffset+12;return Array.from({length:this.numTables},()=>{const t=new vr(this.view.buffer,e);return e+=t.view.byteLength,t})}createSFNT(){return new gt(this.getDirectories().reduce((e,t)=>(e[t.tag]=new DataView(this.view.buffer,this.view.byteOffset+t.offset,t.length),e),{}))}}ti([v("uint32")],it.prototype,"scalerType"),ti([v("uint16")],it.prototype,"numTables"),ti([v("uint16")],it.prototype,"searchRange"),ti([v("uint16")],it.prototype,"entrySelector"),ti([v("uint16")],it.prototype,"rangeShift");class Cn extends it{format="OpenType";mimeType="font/otf";static signature=new Set([1330926671]);static from(e){return super.from(e)}}var Wd=Object.defineProperty,ri=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Wd(e,t,i),i};class Qt extends We{constructor(e,t){super(e,t,20)}}ri([v({type:"char",size:4})],Qt.prototype,"tag"),ri([v("uint32")],Qt.prototype,"offset"),ri([v("uint32")],Qt.prototype,"compLength"),ri([v("uint32")],Qt.prototype,"origLength"),ri([v("uint32")],Qt.prototype,"origChecksum");var qd=Object.defineProperty,qe=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&qd(e,t,i),i};const Ne=class Qn extends Ni{format="WOFF";mimeType="font/woff";get subfontFormat(){return it.is(this.flavor)?"TrueType":Cn.is(this.flavor)?"OpenType":"Open"}_sfnt;get sfnt(){return this._sfnt||(this._sfnt=this.createSFNT()),this._sfnt}static signature=new Set([2001684038]);static is(e){return typeof e=="number"?this.signature.has(e):this.signature.has(yr(e).getUint32(0))}static checkSum(e){const t=yr(e),r=t.byteLength,i=Math.floor(r/4);let n=0,o=0;for(;o<i;)n+=t.getUint32(4*o++,!1);let a=r-i*4;if(a){let l=i*4;for(;a>0;)n+=t.getUint8(l)<<a*8,l++,a--}return n%4294967296}static from(e,t=new ArrayBuffer(0)){const r=u=>u+3&-4,i=[];e.tableViews.forEach((u,d)=>{const g=yr(Uf(new Uint8Array(u.buffer,u.byteOffset,u.byteLength)));i.push({tag:d,view:g.byteLength<u.byteLength?g:u,rawView:u})});const n=i.length,o=i.reduce((u,d)=>u+r(d.view.byteLength),0),a=new Qn(new ArrayBuffer(44+20*n+o+t.byteLength));a.signature=2001684038,a.flavor=65536,a.length=a.view.byteLength,a.numTables=n,a.totalSFNTSize=12+16*n+i.reduce((u,d)=>u+r(d.rawView.byteLength),0);let l=44+n*20,c=0;const h=a.getDirectories();return i.forEach(u=>{const d=h[c++];d.tag=u.tag,d.offset=l,d.compLength=u.view.byteLength,d.origChecksum=Qn.checkSum(u.rawView),d.origLength=u.rawView.byteLength,a.view.writeBytes(u.view,l),l+=r(d.compLength)}),a.view.writeBytes(t),a}getDirectories(){let e=44;return Array.from({length:this.numTables},()=>{const t=new Qt(this.view.buffer,e);return e+=t.view.byteLength,t})}createSFNT(){return new gt(this.getDirectories().reduce((e,t)=>{const r=t.tag,i=this.view.byteOffset+t.offset,n=t.compLength,o=t.origLength,a=i+n;return e[r]=n>=o?new DataView(this.view.buffer,i,n):new DataView(Bf(new Uint8Array(this.view.buffer.slice(i,a))).buffer),e},{}))}};qe([v("uint32")],Ne.prototype,"signature"),qe([v("uint32")],Ne.prototype,"flavor"),qe([v("uint32")],Ne.prototype,"length"),qe([v("uint16")],Ne.prototype,"numTables"),qe([v("uint16")],Ne.prototype,"reserved"),qe([v("uint32")],Ne.prototype,"totalSFNTSize"),qe([v("uint16")],Ne.prototype,"majorVersion"),qe([v("uint16")],Ne.prototype,"minorVersion"),qe([v("uint32")],Ne.prototype,"metaOffset"),qe([v("uint32")],Ne.prototype,"metaLength"),qe([v("uint32")],Ne.prototype,"metaOrigLength"),qe([v("uint32")],Ne.prototype,"privOffset"),qe([v("uint32")],Ne.prototype,"privLength");let Zi=Ne;function ul(s,e=!0){if(it.is(s))return new it(s);if(Cn.is(s))return new Cn(s);if(Zi.is(s))return new Zi(s);if(e)throw new Error("Failed to parseFont")}function fl(s,e=!0){const t=ul(s,!1);if(t)return t;if(e)throw new Error("Failed to parseFont")}class Ji{static defaultRequestInit={cache:"force-cache"};fallbackFont;loading=new Map;loaded=new Map;familyToUrl=new Map;setFallbackFont(e){this.fallbackFont=e}async loadFallbackFont(e,t={}){this.fallbackFont=await this.load(e,t)}_createRequest(e,t){const r=new AbortController;return{url:e,when:fetch(e,{...Ji.defaultRequestInit,...t,signal:r.signal}).then(i=>i.arrayBuffer()),cancel:()=>r.abort()}}injectFontFace(e,t){return document.fonts.check(`14px ${e}`)||document.fonts.add(new FontFace(e,t)),this}injectStyleTag(e,t){const r=CSS.escape(e);if(!document.querySelector(`style[data-family="${r}"]`)){const i=document.createElement("style");i.type="text/css",i.dataset.family=e,i.appendChild(document.createTextNode(`@font-face {
|
|
148
|
+
}`,uniforms:{sampler:0,projectionMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),modelViewMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),tint:new Float32Array([1,1,1,1])}})}}class Q extends Ii{static _instance;static get instance(){return this._instance??=new this}static draw(e,t=$r.instance,r){this.instance.draw(e,t,r)}constructor(){super({vertexAttributes:{position:new Ge({buffer:new St({data:new Float32Array([-1,-1,1,-1,1,1,-1,1]),dynamic:!1}),size:2,normalized:!1,type:"float"}),uv:new Ge({buffer:new St({data:new Float32Array([0,0,1,0,1,1,0,1]),dynamic:!1}),size:2,normalized:!1,type:"float"})},indexBuffer:new dr({data:new Uint16Array([0,1,2,0,2,3]),dynamic:!1})})}}class tf extends Ii{positionBuffer;uvBuffer;constructor(){const e=new St({data:new Float32Array,dynamic:!0}),t=new St({data:new Float32Array,dynamic:!0});super({vertexAttributes:{position:new Ge({buffer:e,size:2,normalized:!1,type:"float"}),uv:new Ge({buffer:t,size:2,normalized:!1,type:"float"})},indexBuffer:new dr({data:new Uint16Array,dynamic:!0})}),this.positionBuffer=e,this.uvBuffer=t}}var rf=Object.defineProperty,pr=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&rf(e,t,i),i};class le extends Pt{static get EMPTY(){return new this({width:1,height:1,pixels:null})}static get WHITE(){return new this({width:1,height:1,pixels:new Uint8Array([255,255,255,255])})}static get BLACK(){return new this({width:1,height:1,pixels:new Uint8Array([0,0,0,255])})}static get RED(){return new this({width:1,height:1,pixels:new Uint8Array([255,0,0,255])})}static get GREEN(){return new this({width:1,height:1,pixels:new Uint8Array([0,255,0,255])})}static get BLUE(){return new this({width:1,height:1,pixels:new Uint8Array([0,0,255,255])})}_isPowerOfTwo=!1;_needsUpload=!1;get realWidth(){return Math.round(this.width*this.pixelRatio)}get realHeight(){return Math.round(this.height*this.pixelRatio)}constructor(e){super(),this.source=e,this._updateSize()}isValid(){return!!(this.width&&this.height)}_glTextureOptions(e,t){let r=this.wrapMode;return e.version===1&&!this._isPowerOfTwo&&(r="clamp_to_edge"),{value:this.source,target:"texture_2d",location:0,filterMode:this.filterMode,wrapMode:r,...t}}_glTexture(e,t){return e.getRelated(this,()=>e.texture.create(this._glTextureOptions(e,t)))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"width":case"height":this._updatePOT();break;case"source":this._updateSize();break;case"filterMode":case"wrapMode":case"pixelRatio":this.requestUpload();break}}_updatePOT(){this._isPowerOfTwo=Ts(this.realWidth)&&Ts(this.realHeight),this.requestUpload()}_updateSize(){const e=this.source;"pixels"in e?(this.width=e.width/this.pixelRatio,this.height=e.height/this.pixelRatio):(this.width=Number(e.naturalWidth||e.videoWidth||e.width||0)/this.pixelRatio,this.height=Number(e.naturalHeight||e.videoHeight||e.height||0)/this.pixelRatio),this.requestUpload()}requestUpload(){this._needsUpload=!0}upload(e,t){return this._needsUpload&&this.isValid()?(this._needsUpload=!1,e.texture.update(this._glTexture(e,t),this._glTextureOptions(e,t)),!0):!1}activate(e,t=0){return this.isValid()?(e.texture.bind({target:"texture_2d",value:this._glTexture(e,{location:t}),location:t}),this.upload(e,{location:t}),!0):!1}inactivate(e){e.texture.unbind(this._glTexture(e))}destroy(){Ao&&this.source instanceof ImageBitmap&&this.source.close()}}pr([_({internal:!0})],le.prototype,"source"),pr([_({fallback:0})],le.prototype,"width"),pr([_({fallback:0})],le.prototype,"height"),pr([_({fallback:"linear"})],le.prototype,"filterMode"),pr([_({fallback:"clamp_to_edge"})],le.prototype,"wrapMode"),pr([_({fallback:1})],le.prototype,"pixelRatio");class Ri extends Pt{frames;frameIndex=0;get currentFrame(){return this.frames[this.frameIndex]}constructor(e){super();let t;if(Array.isArray(e))t=e;else if(e instanceof le)t=[{texture:e,duration:0}];else throw new TypeError("Failed new AnimatedTexture");this.frames=t,this.updateDuration()}updateDuration(){return this.duration=this.frames.reduce((e,t)=>t.duration+e,0),this}destroy(){this.frames.forEach(e=>{e.texture.destroy()})}}var sf=Object.defineProperty,nf=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&sf(e,t,i),i};class Ui extends le{constructor(e=document.createElement("canvas")){super(e)}_updateProperty(e,t,r){switch(e){case"width":this.source.width=Math.max(1,Math.ceil(t*this.pixelRatio));break;case"height":this.source.height=Math.max(1,Math.ceil(t*this.pixelRatio));break}super._updateProperty(e,t,r)}}nf([_({fallback:2})],Ui.prototype,"pixelRatio");class of extends le{static _cached=new Map;static get(e){const t=new Qe(e),r=t.toHex();let i=this._cached.get(r);return i||(i=new le({width:1,height:1,pixels:new Uint8Array([t.r8,t.g8,t.b8,t.a8])}),this._cached.set(r,i)),i}constructor(e){const t=new Qe(e);super({width:1,height:1,pixels:new Uint8Array([t.r8,t.g8,t.b8,t.a8])})}}class zr extends le{static test(e){return Ar(e)}static linearGradient(e,t,r){t=t||1,r=r||1;const i=document.createElement("canvas");i.width=t,i.height=r;const n=i.getContext("2d");if(!n)throw new Error("Failed to parse linear gradient, get canvas context is null.");const{angle:o=0,stops:a}=e,l=t,c=r,h=l/2,u=c/2,d=(o+90)*Math.PI/180,g=Math.sin(d),p=-Math.cos(d),y=Math.abs(l*Math.sin(d))+Math.abs(c*Math.cos(d)),m=h-g*(y/2),P=u-p*(y/2),E=h+g*(y/2),b=u+p*(y/2),S=n.createLinearGradient(m,P,E,b);for(const x of a)S.addColorStop(x.offset,x.color);n.fillStyle=S,n.fillRect(0,0,l,c);const w=n.getImageData(0,0,i.width,i.height);return{width:w.width,height:w.height,pixels:new Uint8Array(w.data.buffer)}}constructor(e,t,r){super(zr.linearGradient(e,t,r))}}function af(s){return{autoLoad:!!(s?.autoLoad??!0),useBitmap:!!(s?.useBitmap??!0)&&Es,crossorigin:s?.crossorigin??null}}class lf extends le{bitmap;useBitmap;preserveBitmap=!1;_loadSource;_loadBitmap;constructor(e,t){const r=af(t);super(e);const i=e.src,n=i.includes(".svg")||i.startsWith("data:image/svg+xml");this.useBitmap=r.useBitmap&&!n,r.autoLoad&&this.load()}async load(){return this._loadSource||(this._loadSource=new Promise(e=>{this._loadSource=void 0;const t=this.source,r=()=>{t.onload=null,t.onerror=null},i=()=>{r(),this.requestUpload(),this.useBitmap?this.genBitmap().finally(()=>e(this)):e(this)},n=o=>{r(),console.warn(`Failed to load ImageTexture, src: ${t.src}`,o),this.emit("error",o),e(this)};t.complete&&t.src?i():(t.onload=i,t.onerror=n)})),this._loadSource}genBitmap(){if(this._loadBitmap)return this._loadBitmap;if(this.bitmap||!Es)return Promise.resolve(this);const e=this.source,t=!e.crossOrigin||e.crossOrigin==="anonymous";return this._loadBitmap=fetch(e.src,{mode:t?"cors":"no-cors"}).then(r=>r.blob()).then(r=>createImageBitmap(r,0,0,e.width,e.height,{premultiplyAlpha:"premultiply"})).then(r=>(this.bitmap=r,this.requestUpload(),this._loadBitmap=void 0,this)).catch(r=>(console.warn("Failed to genBitmap",r),this)),this._loadBitmap}_glTextureOptions(e){return{...super._glTextureOptions(e),value:this.bitmap??this.source}}upload(e){if(this.useBitmap){if(!this.bitmap)return this.genBitmap(),!1}else{const r=this.source;if(Dr&&r instanceof HTMLImageElement&&(!r.complete||r.naturalWidth===0))return!1}const t=super.upload(e);return this.preserveBitmap&&this.bitmap&&(this.bitmap.close(),this.bitmap=void 0),t}}class Zs extends le{constructor(e,t=1,r=1){const i={width:t,height:r,pixels:null};e&&(ArrayBuffer.isView(e)?i.pixels=new Uint8Array(e.buffer):i.pixels=new Uint8Array(e)),super(i)}_updateProperty(e,t,r){switch(e){case"width":this.source.width=Math.round(this.width*this.pixelRatio);break;case"height":this.source.height=Math.round(this.height*this.pixelRatio);break;case"pixelRatio":this.source.width=Math.round(this.width*this.pixelRatio),this.source.height=Math.round(this.height*this.pixelRatio);break}super._updateProperty(e,t,r)}}var cf=Object.defineProperty,za=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&cf(e,t,i),i};function hf(s){return{autoLoad:!!(s?.autoLoad??!0),autoPlay:!!(s?.autoPlay??!1),fps:Number(s?.fps??0),crossorigin:s?.crossorigin??null,loop:!!(s?.loop??!1),muted:!!(s?.muted??!1),playsinline:!!(s?.playsinline??!0)}}const Js=class gc extends le{static mimeTypes=new Map(Object.entries({ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"}));get isReady(){return this.source.readyState>2}get isPlaying(){return!this.source.paused&&!this.source.ended&&this.isReady}get duration(){return this.source.duration}get seeking(){return this.source.seeking}get currentTime(){return this.source.currentTime}set currentTime(e){this.source.currentTime=e}_spf=0;_autoPlay=!1;_sourceLoad;_nextTime=0;_connected=!1;_requestId;_resolve;_reject;constructor(e,t){const r=hf(t);if(!Uo(e)){typeof e=="string"&&(e=[e]);const i=e[0].src||e[0],n=document.createElement("video");r.autoLoad&&n.setAttribute("preload","auto"),r.playsinline&&(n.setAttribute("webkit-playsinline",""),n.setAttribute("playsinline","")),r.muted&&(n.setAttribute("muted",""),n.muted=!0),r.loop&&n.setAttribute("loop",""),r.autoPlay&&n.setAttribute("autoplay",""),$o(n,i,r.crossorigin);for(let o=0;o<e.length;++o){let{src:a,mime:l}=e[o];if(a=a||e[o],a.startsWith("data:"))l=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){const h=a.split("?").shift().toLowerCase(),u=h.slice(h.lastIndexOf(".")+1);l=l||gc.mimeTypes.get(u)||`video/${u}`}const c=document.createElement("source");c.src=a,l&&(c.type=l),n.appendChild(c)}e=n}super(e),this.fps=r.fps,this._autoPlay=r.autoPlay,r.autoPlay&&this.load(),this._setupAutoUpdate()}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"fps":this._spf=t?Math.floor(1e3/t):0,this._setupAutoUpdate();break;case"autoUpdate":this._setupAutoUpdate();break}}_onPlayStart=()=>{this.isValid()||this._onCanPlay(),this._setupAutoUpdate()};_onPlayStop=()=>{this._setupAutoUpdate()};_onCanPlay=()=>{const e=this.source;e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay);const t=this.isValid();this._nextTime=0,this._updateSize(),this.requestUpload(),this._nextTime=0,!t&&this._resolve&&(this._resolve(this),this._sourceLoad=void 0,this._resolve=void 0,this._reject=void 0),this.isPlaying?this._onPlayStart():this._autoPlay&&e.play()};_onError=e=>{this.source.removeEventListener("error",this._onError,!0),this.emit("error",e),this._reject&&(this._reject(e),this._reject=void 0,this._resolve=void 0)};_onSeeked=()=>{this.autoUpdate&&!this.isPlaying&&(this._nextTime=0,this.requestUpload(),this._nextTime=0)};_setupAutoUpdate(){this.autoUpdate&&this.isPlaying?!this.fps&&this.source.requestVideoFrameCallback?(this._connected&&(Ce.off(this.requestUpload),this._connected=!1,this._nextTime=0),this._requestId===void 0&&(this._requestId=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected||(Ce.on(this.requestUpload),this._connected=!0,this._nextTime=0)):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected&&(Ce.off(this.requestUpload),this._connected=!1,this._nextTime=0))}_videoFrameRequestCallback=()=>{this.requestUpload(),this._requestId=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)};requestUpload=()=>{const e=Math.floor(Ce.elapsed*this.source.playbackRate);this._nextTime-=e,(!this._spf||this._nextTime<=0)&&(super.requestUpload(),this._nextTime=this._spf||0)};async load(){if(!this._sourceLoad){const e=this.source;(e.readyState===e.HAVE_ENOUGH_DATA||e.readyState===e.HAVE_FUTURE_DATA)&&e.width&&e.height&&(e.complete=!0),e.addEventListener("play",this._onPlayStart),e.addEventListener("pause",this._onPlayStop),e.addEventListener("seeked",this._onSeeked),this.isReady?this._onCanPlay():(e.addEventListener("canplay",this._onCanPlay),e.addEventListener("canplaythrough",this._onCanPlay),e.addEventListener("error",this._onError,!0)),this._sourceLoad=new Promise((t,r)=>{this.isValid()?(this._sourceLoad=void 0,t(this)):(this._resolve=t,this._reject=r,e.load())})}return this._sourceLoad}destroy(){this._setupAutoUpdate();const e=this.source;e&&(e.removeEventListener("play",this._onPlayStart),e.removeEventListener("pause",this._onPlayStop),e.removeEventListener("seeked",this._onSeeked),e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay),e.removeEventListener("error",this._onError,!0),e.pause(),e.src="",e.load())}};za([_({internal:!0,fallback:!0})],Js.prototype,"autoUpdate"),za([_({internal:!0,fallback:0})],Js.prototype,"fps");let Va=Js;class Qs extends Zs{}class Ga extends ge{fillStyle;strokeStyle;strokeAlignment;lineCap;lineJoin;lineWidth;miterLimit;uvTransform;vertTransform;_draws=[];_parseDrawStyle(e){return e?e instanceof le?{texture:e}:{backgroundColor:new Qe(e).toInt8Array()}:{}}stroke(e){if(!this.curves.length)return;let t=this.strokeStyle;if(!t&&this.style.stroke)switch(typeof this.style.stroke){case"string":t=this.style.stroke;break;case"object":xs(this.style.stroke)&&(t=this.style.stroke.color);break}this._draws.push({...e,...this._parseDrawStyle(t),type:"stroke",path:new ge(this),uvTransform:this.uvTransform,vertTransform:this.vertTransform,lineStyle:{alignment:this.strokeAlignment??.5,cap:this.lineCap??"butt",join:this.lineJoin??"miter",width:this.lineWidth??1,miterLimit:this.miterLimit??10}}),this.resetStatus()}fillRect(e,t,r,i){this.rect(e,t,r,i).fill()}strokeRect(e,t,r,i){this.rect(e,t,r,i).stroke()}fill(e){if(!this.curves.length)return;let t=this.fillStyle;if(!t&&this.style.fill)switch(typeof this.style.fill){case"string":t=this.style.fill;break;case"object":xs(this.style.fill)&&(t=this.style.fill.color);break}this._draws.push({...e,...this._parseDrawStyle(t),type:"fill",path:new ge(this),uvTransform:this.uvTransform,vertTransform:this.vertTransform}),this.resetStatus()}copy(e){return super.copy(e),this.strokeStyle=e.strokeStyle,this.fillStyle=e.fillStyle,this.uvTransform=e.uvTransform,this.vertTransform=e.vertTransform,this.strokeAlignment=e.strokeAlignment,this.lineCap=e.lineCap,this.lineJoin=e.lineJoin,this.lineWidth=e.lineWidth,this.miterLimit=e.miterLimit,this._draws=e._draws.slice(),this}resetStatus(){super.reset(),this.strokeStyle=void 0,this.fillStyle=void 0,this.uvTransform=void 0,this.vertTransform=void 0,this.strokeAlignment=void 0,this.lineCap=void 0,this.lineJoin=void 0,this.lineWidth=void 0,this.miterLimit=void 0}reset(){return this.resetStatus(),this._draws.length=0,this}buildUvs(e,t,r,i,n){if(i){const o=i.width,a=i.height;for(let l=t.length,c=e;c<l;c+=2){const h=t[c],u=t[c+1];let d,g;n?[d,g]=n.apply({x:h,y:u}).toArray():[d,g]=[h/o,u/a],r.push(d,g)}}else for(let o=t.length,a=e;a<o;a+=2)r.push(0,0)}toBatchables(){const e=[];for(let t=this._draws.length,r=0;r<t;r++){const i=this._draws[r],n=[],o=[],a=[];i.type==="fill"?i.path.fillTriangulate({vertices:n,indices:o}):i.path.strokeTriangulate({vertices:n,indices:o,lineStyle:i.lineStyle,flipAlignment:!1,closed:!0}),i.texture&&this.buildUvs(0,n,a,i.texture,i.uvTransform);const l=i.path.getBoundingBox();e.push({vertices:new Float32Array(n),indices:new Float32Array(o),uvs:new Float32Array(a),texture:i.texture,backgroundColor:i.backgroundColor,type:i.type,disableWrapMode:i.disableWrapMode,uvTransform:i.uvTransform,vertTransform:i.vertTransform,dimension:new Float32Array([l.width,l.height])})}return e}}class uf{front=[];default=[];back=[];get internal(){return this.getInternal()}constructor(...e){this.set(e)}set(e){return this.front.length=0,this.default.length=0,this.back.length=0,e.forEach(t=>{switch(t.internalMode){case"front":this.front.push(t);break;case"default":this.default.push(t);break;case"back":this.back.push(t);break}}),this}getInternal(e){if(e)switch(e){case"front":return this.front;case"default":return this.default;case"back":return this.back;default:throw new Error(`Unknown internal mode: ${e}`)}else return[...this.front,...this.default,...this.back]}toJSON(){return[...this.default]}}class ja extends xt{constructor(e){return super(),this.parent=e,new Proxy(this,{get:(t,r,i)=>Reflect.has(t,r)||String(r).startsWith("_")?Reflect.get(t,r,i):t.getProperty(String(r)),set:(t,r,i,n)=>Reflect.has(t,r)||String(r).startsWith("_")?Reflect.set(t,r,i,n):(t.setProperty(String(r),i),!0),deleteProperty:(t,r)=>Reflect.has(t,r)||String(r).startsWith("_")?Reflect.deleteProperty(t,r):(t.setProperty(String(r),void 0),!0)})}getPropertyDeclarations(){const e=new Map;return this._properties.forEach((t,r)=>{e.set(r,{internalKey:`____${r}`})}),e}getPropertyDeclaration(e){return{internalKey:`____${e}`}}}var ff=Object.defineProperty,df=Object.getOwnPropertyDescriptor,Et=(s,e,t,r)=>{for(var i=r>1?void 0:r?df(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&ff(e,t,i),i};const Wa={};function pf(s){let e=Wa[s]??0;return e++,Wa[s]=e,e}f.Node=class extends xt{_meta=new ja(this);get meta(){return this._meta}set meta(e){this._meta.resetProperties().setProperties(e)}_readyed=!1;constructor(e,t=[]){super(),this._onTreeEnter=this._onTreeEnter.bind(this),this._onTreeExit=this._onTreeExit.bind(this),this._onParented=this._onParented.bind(this),this._onUnparented=this._onUnparented.bind(this),this._onReady=this._onReady.bind(this),this._onProcess=this._onProcess.bind(this),this.setProperties({name:`${this.is}:${pf(this.is)}`,...e}).append(t),this.on("treeEnter",this._onTreeEnter).on("treeExit",this._onTreeExit).on("parented",this._onParented).on("unparented",this._onUnparented).on("ready",this._onReady).on("process",this._onProcess)}setProperties(e){if(e){const{meta:t,...r}=e;t&&(this.meta=t),super.setProperties(r)}return this}getName(){return this.name}setName(e){return this.name=e,this}_tree;get tree(){return this.getTree()}set tree(e){this.setTree(e)}getTree(){return this._tree}getViewport(){return this.parent?.getViewport()??this.getWindow()}getWindow(){return this._tree?.root}isInsideTree(){return!!this._tree}setTree(e){const t=this._tree;if(!e?.equal(t)){t&&this.emit("treeExit",t),this._tree=e,e&&this.emit("treeEnter",e);const r=this._children.internal;for(let i=r.length,n=0;n<i;n++){const o=r[n];!e&&this.emit("childExitingTree",o),o.setTree(e),e&&this.emit("childEnteredTree",o)}e&&(this.emit("treePostEnter",e),this._readyed||(this._readyed=!0,this.emit("ready")))}return this}_parent;get parent(){return this._parent}set parent(e){this.setParent(e)}hasParent(){return!!this._parent}getParent(){return this._parent}setParent(e){if(!this._parent?.equal(e)){const t=this._parent;t&&this.emit("unparented",t),this._parent=e,e&&this.emit("parented",e),this.setTree(e?._tree)}return this}_children=new uf;get children(){return this._children.default}set children(e){this._children.set(e)}getChildren(e="default"){return this._children.getInternal(e===!0?void 0:e)}getChild(e=0){return this.children[e]}get siblingIndex(){return this.getIndex()}set siblingIndex(e){this._parent?.moveChild(this,e)}get previousSibling(){return this._parent?.children[this.getIndex()-1]}get nextSibling(){return this._parent?.children[this.getIndex()+1]}get firstSibling(){return this._parent?.children[0]}get lastSibling(){const e=this._parent?.children;return e?e[e.length-1]:void 0}canProcess(){if(!this._tree)return!1;switch(this.processMode){case"inherit":return this._parent?.canProcess()??!0;case"pausable":return!this._tree.processPaused;case"when_paused":return this._tree.processPaused;case"always":return!0;case"disabled":default:return!1}}canInput(){if(!this._tree)return!1;switch(this.inputMode){case"inherit":return this._parent?.canInput()??!0;case"always":return!0;case"disabled":default:return!1}}canRender(){if(!this._tree)return!1;switch(this.renderMode){case"inherit":return this._parent?.canRender()??!0;case"always":return!0;case"disabled":default:return!1}}_onTreeEnter(e){this._treeEnter(e),this.emit("treeEntered",e)}_onTreeExit(e){this.emit("treeExiting",e),this._treeExit(e),this.emit("treeExited",e)}_onParented(e){this._parented(e)}_onUnparented(e){this._unparented(e)}_onReady(){this._ready()}_onProcess(e=0){const t=this._tree,r=this.canRender(),i=this.canProcess(),n=[],o=[];this._children.internal.forEach(l=>{switch(l.processSortMode){case"default":o.push(l);break;case"parent_before":n.push(l);break}}),n.forEach(l=>{l.emit("process",e)}),i&&(t?.emit("nodeProcessing",this),this.emit("processing",e),this._process(e));let a;if(r){const l=t.renderStack.push(this);a=t.renderStack.currentCall,t.renderStack.currentCall=l}if(this.mask instanceof f.Node)this.getNode("__$mask")||(this.mask.processMode="disabled",this.appendChild(this.mask,"front"));else{const l=this.getNode("__$mask");l&&this.removeChild(l)}o.forEach(l=>{l.emit("process",e)}),r&&(t.renderStack.currentCall=a),i&&(this.emit("processed",e),t?.emit("nodeProcessed",this))}render(e,t){const r=this.mask;r&&(e.flush(),e.mask.push(this,r)),this._render(e),t?.(),r&&(e.flush(),e.mask.pop(this))}input(e,t){if(e.propagationStopped)return;const r=this._children.internal;for(let i=r.length-1;i>=0;i--)r[i].input(e,t);e.propagationStopped||this.canInput()&&this._input(e,t)}getIndex(){return this._parent?.getChildren(this.internalMode).indexOf(this)??0}getNode(e){return this._children.internal.find(t=>t.name===e)}removeNode(e){this.getNode(e)?.remove()}addSibling(e){return this.equal(e)||!this.hasParent()||e.hasParent()?this:(e.internalMode=this.internalMode,this._parent.moveChild(e,this.getIndex()+1),this)}prepend(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(r=>{this.moveChild(r,0)})}append(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(r=>{this.appendChild(r)})}before(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(r=>{this._parent?.moveChild(r,this.getIndex())})}after(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(r=>{this._parent?.moveChild(r,this.getIndex()+1)})}insertBefore(e,t){return!t.hasParent()||!this.equal(t.parent)||this.moveChild(e,t.getIndex()),e}appendChild(e,t=e.internalMode){if(this.equal(e)||e.hasParent())return e;switch(t){case"front":this._children.front.push(e);break;case"default":this._children.default.push(e);break;case"back":this._children.back.push(e);break}return e.internalMode!==t&&(e.internalMode=t),e.setParent(this),this.emit("appendChild",e),e}moveChild(e,t,r=e.internalMode){if(this.equal(e)||e.hasParent()&&!this.equal(e.parent))return this;const i=this._children.getInternal(e.internalMode),n=i.indexOf(e),o=this._children.getInternal(r);return(e.internalMode!==r||t!==n)&&(n>-1&&i.splice(n,1),e.setParent(this),t>-1&&t<o.length?o.splice(t,0,e):o.push(e),n>-1?this.emit("moveChild",e,t,n):this.emit("appendChild",e)),e.internalMode!==r&&(e.internalMode=r),this}removeChild(e){const t=e.getIndex();return this.equal(e.parent)&&t>-1&&(this.getChildren(e.internalMode).splice(t,1),e.setParent(void 0),this.emit("removeChild",e,t)),e}removeChildren(){this.children.forEach(e=>this.removeChild(e))}remove(){this._parent?.removeChild(this)}findOne(e){for(const t of this._children.default){if(e(t))return t;const r=t.findOne(e);if(r)return r}}findAll(e){const t=[];for(const r of this._children.default)e(r)&&t.push(r),t.push(...r.findAll(e));return t}findAncestor(e){const t=this._parent;if(t){if(e(t))return t;const r=t.findAncestor(e);if(r)return r}}_ready(){}_treeEnter(e){}_treeExit(e){}_parented(e){}_unparented(e){}_process(e){}_input(e,t){}_render(e){}destroy(){super.destroy(),this._children.internal.forEach(e=>this.removeChild(e))}clone(){return new this.constructor(this.toJSON(),this._children.internal)}toJSON(){return Ve({...super.toJSON(),children:this.children.length?[...this.children.map(e=>e.toJSON())]:void 0,meta:{...this.meta.toJSON(),inCanvasIs:this.is}})}static parse(e){if(Array.isArray(e))return e.map(l=>this.parse(l));const{meta:t={},children:r,...i}=e,{inCanvasIs:n="Node"}=t,o=xi.get(n)??f.Node,a=new o({...i,meta:t});return r?.forEach(l=>a.appendChild(this.parse(l))),a}},Et([_({fallback:bo()})],f.Node.prototype,"id",2),Et([_({fallback:bo()})],f.Node.prototype,"name",2),Et([_({internal:!0,fallback:"inherit"})],f.Node.prototype,"processMode",2),Et([_({internal:!0,fallback:"default"})],f.Node.prototype,"processSortMode",2),Et([_({internal:!0,fallback:"inherit"})],f.Node.prototype,"renderMode",2),Et([_({internal:!0,fallback:"inherit"})],f.Node.prototype,"inputMode",2),Et([_({internal:!0,fallback:"default"})],f.Node.prototype,"internalMode",2),Et([_({internal:!0})],f.Node.prototype,"mask",2),f.Node=Et([X("Node")],f.Node);var gf=Object.defineProperty,mf=Object.getOwnPropertyDescriptor,gr=(s,e,t,r)=>{for(var i=r>1?void 0:r?mf(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&gf(e,t,i),i};f.TimelineNode=class extends f.Node{constructor(e,t=[]){super(),this.setProperties(e).append(t)}computedDuration=0;_currentTime=0;_startTime=0;get timeline(){return this._tree?.timeline}get timelineCurrentTime(){return this.timeline?.currentTime??0}get parentStartTime(){return this._parent?.startTime??0}get currentTime(){return ut(this._currentTime,0,this.computedDuration)}get startTime(){return this._startTime}set startTime(e){this.delay=e-this.parentStartTime,this._updateCurrentTime(!0)}get endTime(){return this._startTime+this.computedDuration}get currentTimeProgress(){return this.computedDuration?ut(this._currentTime/this.computedDuration,0,1):0}isInsideTimeRange(){const e=this._currentTime;return this.computedDuration?e>=0&&e<=this.computedDuration:e>=0}_updateCurrentTime(e=!1){if(e||!this.paused){const t=this._parent,r=this.delay+this.parentStartTime,i=t?.computedDuration?Math.min(r+this.duration,t.endTime)-r:this.duration;let n=this.timelineCurrentTime-r;this.loop&&(n=n%i),this._startTime=r,this._currentTime=n,this.computedDuration=i,this.emit("updateCurrentTime",this._currentTime),this.insideTimeRange=this.isInsideTimeRange()}}_process(e){super._process(e),this._updateCurrentTime()}},gr([_({fallback:!1})],f.TimelineNode.prototype,"loop",2),gr([_({fallback:0})],f.TimelineNode.prototype,"delay",2),gr([_({fallback:0})],f.TimelineNode.prototype,"duration",2),gr([_({fallback:!1})],f.TimelineNode.prototype,"paused",2),gr([_({internal:!0,fallback:!1})],f.TimelineNode.prototype,"insideTimeRange",2),f.TimelineNode=gr([X("TimelineNode")],f.TimelineNode);var yf=Object.defineProperty,vf=Object.getOwnPropertyDescriptor,Vr=(s,e,t,r)=>{for(var i=r>1?void 0:r?vf(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&yf(e,t,i),i};f.CanvasItem=class extends f.TimelineNode{_parentGlobalVisible;_globalVisible;get globalVisible(){return this._globalVisible??!0}_parentGlobalOpacity;_globalOpacity;get globalOpacity(){return this._globalOpacity??1}_modulate=new Qe(4294967295);context=new Ga;_resetContext=!0;_redrawing=!0;_relayouting=!1;_repainting=!1;_originalBatchables=[];_layoutedBatchables=[];_batchables=[];constructor(e,t=[]){super(),this.setProperties(e).append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"modulate":this._modulate.value=t,this.requestRepaint();break;case"blendMode":this.requestRepaint();break;case"opacity":this._updateGlobalOpacity();break;case"visible":case"insideTimeRange":this._updateGlobalVisible();break}}show(){this.visible=!0}hide(){this.visible=!1}isVisibleInTree(){return this.globalOpacity>0&&this.globalVisible}canRender(){return super.canRender()&&this.isVisibleInTree()}requestRedraw(){this._redrawing=!0}requestRelayout(){this._relayouting=!0}requestRepaint(){this._repainting=!0}_updateGlobalVisible(){this._parentGlobalVisible=this.getParent()?.globalVisible,this._globalVisible=(this._parentGlobalVisible??!0)&&this.visible&&this.insideTimeRange}_updateGlobalOpacity(){this._parentGlobalOpacity=this.getParent()?.opacity;const e=ut(this.opacity,0,1)*(this._parentGlobalOpacity??1);this._globalOpacity!==e&&(this._globalOpacity=e,this.requestRepaint())}_draw(){this.emit("draw")}_redraw(){return this._tree?.log(this.name,"drawing"),this._draw(),this.context.toBatchables()}_relayout(e){return this._tree?.log(this.name,"layouting"),e}_repaint(e){this._tree?.log(this.name,"painting");const t=this.globalOpacity;return e.map(r=>({...r,modulate:this._modulate.toInt8Array().map(i=>i*t),blendMode:this.blendMode}))}_process(e){super._process(e);const t=this.getParent();this._parentGlobalVisible!==t?.globalVisible&&this._updateGlobalVisible(),this._parentGlobalOpacity!==t?.globalOpacity&&this._updateGlobalOpacity()}_updateBatchables(){const e=this._redrawing;let t=this._relayouting,r=this._repainting,i;e&&(this._originalBatchables=this._redraw(),t=!0),t&&(this._layoutedBatchables=this._relayout(this._originalBatchables),r=!0),r&&(i=this._repaint(this._layoutedBatchables)),e&&this._resetContext&&this.context.reset(),i&&(this._batchables=i,this._redrawing=!1,this._relayouting=!1,this._repainting=!1)}_render(e){this._updateBatchables(),this._batchables.forEach(t=>{t.texture?.upload(e),e.batch2D.render({...t,texture:t.texture?._glTexture(e)})}),super._render(e)}},Vr([_()],f.CanvasItem.prototype,"modulate",2),Vr([_()],f.CanvasItem.prototype,"blendMode",2),Vr([_({internal:!0,fallback:!0})],f.CanvasItem.prototype,"visible",2),Vr([_({internal:!0,fallback:1})],f.CanvasItem.prototype,"opacity",2),f.CanvasItem=Vr([X("CanvasItem")],f.CanvasItem);var _f=Object.defineProperty,bf=Object.getOwnPropertyDescriptor,mr=(s,e,t,r)=>{for(var i=r>1?void 0:r?bf(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&_f(e,t,i),i};f.Viewport=class extends f.Node{constructor(e=!1){super(),this.flipY=e,this.projection.flipY(e)}projection=new Yo;canvasTransform=new ke;_framebufferIndex=0;_framebuffers=[{texture:new Qs,needsUpload:!1},{texture:new Qs,needsUpload:!1}];get valid(){return!!(this.width&&this.height)}get framebuffer(){return this._framebuffers[this._framebufferIndex]}get texture(){return this.framebuffer.texture}getViewport(){return this}_glFramebufferOptions(e){const{width:t,height:r}=this,{pixelRatio:i}=e;return this._framebuffers.forEach(n=>{const o=n.texture;o.width=t,o.height=r,o.pixelRatio=i,o.upload(e)}),{width:t,height:r,msaa:this.msaa,colorTextures:[this.texture._glTexture(e)]}}_glFramebuffer(e){return e.getRelated(this.framebuffer,()=>e.framebuffer.create(this._glFramebufferOptions(e)))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"x":case"y":this.requestUpload(),this.projection.translate(this.x,this.y),this.emit("updateRect");break;case"width":case"height":this.requestUpload(),this.projection.resize(this.width,this.height),this.emit("updateRect");break;case"msaa":this.requestUpload();break}}requestUpload(){this._framebuffers.forEach(e=>e.needsUpload=!0)}resize(e,t){this.width=e,this.height=t}upload(e){const t=this.framebuffer;return t.needsUpload&&this.valid?(t.needsUpload=!1,e.framebuffer.update(this._glFramebuffer(e),this._glFramebufferOptions(e)),!0):!1}activate(e){return this.valid?(e.flush(),this._tree?.setCurrentViewport(this),this.upload(e),e.framebuffer.bind(this._glFramebuffer(e)),!0):!1}redraw(e,t){if(this.valid){e.flush();const r=this.framebuffer.texture;return this._framebufferIndex=(this._framebufferIndex+1)%this._framebuffers.length,this.activate(e),e.clear(),r.activate(e,0),t(),!0}return!1}activateWithCopy(e,t){this.resize(t.width,t.height),this.activate(e)&&(e.clear(),t.texture.activate(e,0),Q.draw(e,$r.instance,{sampler:0}))}render(e,t){const r=this._tree?.getCurrentViewport();e.program.uniforms.projectionMatrix=this.projection.toArray(!0),e.program.uniforms.viewMatrix=this.canvasTransform.toArray(!0),this.activate(e),e.clear(),super.render(e,t),e.flush(),r?r.activate(e):(e.framebuffer.bind(null),this._tree?.setCurrentViewport(void 0))}getRect(){return new It(this.x,this.y,this.width,this.height)}toCanvasGlobal(e,t){return this.canvasTransform.applyAffineInverse(e,t)}toCanvasScreen(e,t){return this.canvasTransform.apply(e,t)}},mr([_({fallback:0})],f.Viewport.prototype,"x",2),mr([_({fallback:0})],f.Viewport.prototype,"y",2),mr([_({fallback:0})],f.Viewport.prototype,"width",2),mr([_({fallback:0})],f.Viewport.prototype,"height",2),mr([_({internal:!0,fallback:!1})],f.Viewport.prototype,"msaa",2),f.Viewport=mr([X("Viewport")],f.Viewport);var wf=Object.defineProperty,xf=Object.getOwnPropertyDescriptor,Gr=(s,e,t,r)=>{for(var i=r>1?void 0:r?xf(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&wf(e,t,i),i};f.Effect=class extends f.TimelineNode{material;get _effectMode(){return this.effectMode??"parent"}viewport1=new f.Viewport;viewport2=new f.Viewport;_renderId=0;_renderViewport;_previousSibling;_nextSibling;constructor(e,t=[]){super(),this._onProcessing=this._onProcessing.bind(this),this._onNodeProcessed=this._onNodeProcessed.bind(this),this.setProperties(e).append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"glsl":{const i=new Nr(t);!this.effectMode&&i.has.transition&&(this.effectMode="transition"),this.material=i;break}case"glslSrc":{t?Ke.text.load(t).then(i=>this.glsl=i):this.glsl="";break}}}_treeEnter(e){e.on("processing",this._onProcessing),e.on("nodeProcessed",this._onNodeProcessed),this.viewport1.setTree(e),this.viewport2.setTree(e)}_treeExit(e){e.off("processing",this._onProcessing),e.off("nodeProcessed",this._onNodeProcessed),this.viewport1.setTree(void 0),this.viewport2.setTree(void 0)}_onProcessing(){if(this.canProcess())switch(this._updateCurrentTime(),this._effectMode){case"transition":this._previousSibling=this.previousSibling,this._nextSibling=this.nextSibling;break;default:this._previousSibling=void 0,this._nextSibling=void 0;break}}_onNodeProcessed(e){if(!this.canProcess()||!this.isInsideTimeRange())return;const t=this._tree?.renderStack;if(t)switch(this._effectMode){case"transition":e.equal(this._previousSibling)?(this._previousSibling=void 0,t.push(this)):e.equal(this._nextSibling)&&(this._nextSibling=void 0,t.push(this));break}}_processParent(){const e=this._tree?.renderStack;if(!e)return;const t=e.currentCall?.parentCall;if(!t)return;const r=t.calls;let i,n;r.forEach((o,a)=>{(o.renderable.equal(this._parent)||o.renderable.parent?.equal(this._parent))&&(i=i??a,n=a)}),!(i===void 0||n===void 0)&&(r.splice(n+1,0,e.createCall(this)),r.splice(i,0,e.createCall(this)))}_processChildren(){this.children.length&&(super.emit("process"),this._tree?.renderStack.push(this))}_onProcess(e=0){if(this.canProcess())switch(this._renderId=0,this._effectMode){case"before":super._onProcess(e);break;case"parent":this._processParent();break;case"children":this._processChildren();break}}_renderBefore(e){const t=this._tree?.getCurrentViewport();t&&this.apply(e,t,{redraw:!0})}_renderTransition(e){if(this._renderId%2===0)this._renderViewport=this._tree?.getCurrentViewport(),this._renderViewport&&(this.viewport1.activateWithCopy(e,this._renderViewport),this.viewport2.resize(this._renderViewport.width,this._renderViewport.height)),this.viewport2.activate(e),e.clear();else{const t=this._renderViewport;this._renderViewport=void 0,t&&(t.activate(e),e.clear(),this.viewport1.texture.activate(e,0),this.viewport2.texture.activate(e,1),this.apply(e,t,{from:this.viewport1,to:this.viewport2}),e.texture.unbind(0),e.texture.unbind(1))}}_renderParentOrChildren(e){if(this._renderId%2===0)this._renderViewport=this._tree?.getCurrentViewport(),this._renderViewport&&this.viewport1.resize(this._renderViewport.width,this._renderViewport.height),this.viewport1.activate(e),e.clear();else{const t=this._renderViewport;this._renderViewport=void 0,t&&(this.viewport1.activate(e),this.apply(e,this.viewport1,{redraw:!0,target:this._effectMode==="parent"?this._parent??void 0:void 0,targetArea:this._parseTargetArea()}),t.activate(e),this.viewport1.texture.activate(e,0),Q.draw(e))}}_parseTargetArea(){if(this._effectMode==="parent"&&this._parent&&"getRect"in this._parent){const e=this._parent.getRect();if(e)return[e.left/this.viewport1.width,e.top/this.viewport1.height,e.width/this.viewport1.width,e.height/this.viewport1.height]}}_render(e){switch(this._effectMode){case"before":this._renderBefore(e);break;case"transition":this._renderTransition(e);break;case"parent":case"children":default:this._renderParentOrChildren(e);break}this._renderId++}apply(e,t,r){this.material&&(r?.redraw?t.redraw(e,()=>{Q.draw(e,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:t.width/t.height})}):Q.draw(e,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:r?.from?r.from.width/r.from.height:0}))}},Gr([_({internal:!0})],f.Effect.prototype,"material",2),Gr([_()],f.Effect.prototype,"effectMode",2),Gr([_()],f.Effect.prototype,"glsl",2),Gr([_()],f.Effect.prototype,"glslSrc",2),f.Effect=Gr([X("Effect")],f.Effect);var Te=Uint8Array,je=Uint16Array,en=Int32Array,Bi=new Te([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Li=new Te([0,0,0,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,0,0]),tn=new Te([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),qa=function(s,e){for(var t=new je(31),r=0;r<31;++r)t[r]=e+=1<<s[r-1];for(var i=new en(t[30]),r=1;r<30;++r)for(var n=t[r];n<t[r+1];++n)i[n]=n-t[r]<<5|r;return{b:t,r:i}},Xa=qa(Bi,2),Ha=Xa.b,rn=Xa.r;Ha[28]=258,rn[258]=28;for(var Ya=qa(Li,0),Pf=Ya.b,Ka=Ya.r,sn=new je(32768),te=0;te<32768;++te){var Ut=(te&43690)>>1|(te&21845)<<1;Ut=(Ut&52428)>>2|(Ut&13107)<<2,Ut=(Ut&61680)>>4|(Ut&3855)<<4,sn[te]=((Ut&65280)>>8|(Ut&255)<<8)>>1}for(var pt=(function(s,e,t){for(var r=s.length,i=0,n=new je(e);i<r;++i)s[i]&&++n[s[i]-1];var o=new je(e);for(i=1;i<e;++i)o[i]=o[i-1]+n[i-1]<<1;var a;if(t){a=new je(1<<e);var l=15-e;for(i=0;i<r;++i)if(s[i])for(var c=i<<4|s[i],h=e-s[i],u=o[s[i]-1]++<<h,d=u|(1<<h)-1;u<=d;++u)a[sn[u]>>l]=c}else for(a=new je(r),i=0;i<r;++i)s[i]&&(a[i]=sn[o[s[i]-1]++]>>15-s[i]);return a}),Bt=new Te(288),te=0;te<144;++te)Bt[te]=8;for(var te=144;te<256;++te)Bt[te]=9;for(var te=256;te<280;++te)Bt[te]=7;for(var te=280;te<288;++te)Bt[te]=8;for(var jr=new Te(32),te=0;te<32;++te)jr[te]=5;var Cf=pt(Bt,9,0),Tf=pt(Bt,9,1),Sf=pt(jr,5,0),Ef=pt(jr,5,1),nn=function(s){for(var e=s[0],t=1;t<s.length;++t)s[t]>e&&(e=s[t]);return e},tt=function(s,e,t){var r=e/8|0;return(s[r]|s[r+1]<<8)>>(e&7)&t},on=function(s,e){var t=e/8|0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>(e&7)},an=function(s){return(s+7)/8|0},Za=function(s,e,t){return(t==null||t>s.length)&&(t=s.length),new Te(s.subarray(e,t))},Mf=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],rt=function(s,e,t){var r=new Error(e||Mf[s]);if(r.code=s,Error.captureStackTrace&&Error.captureStackTrace(r,rt),!t)throw r;return r},Af=function(s,e,t,r){var i=s.length,n=0;if(!i||e.f&&!e.l)return t||new Te(0);var o=!t,a=o||e.i!=2,l=e.i;o&&(t=new Te(i*3));var c=function(Be){var $e=t.length;if(Be>$e){var Pe=new Te(Math.max($e*2,Be));Pe.set(t),t=Pe}},h=e.f||0,u=e.p||0,d=e.b||0,g=e.l,p=e.d,y=e.m,m=e.n,P=i*8;do{if(!g){h=tt(s,u,1);var E=tt(s,u+1,3);if(u+=3,E)if(E==1)g=Tf,p=Ef,y=9,m=5;else if(E==2){var x=tt(s,u,31)+257,T=tt(s,u+10,15)+4,C=x+tt(s,u+5,31)+1;u+=14;for(var L=new Te(C),G=new Te(19),U=0;U<T;++U)G[tn[U]]=tt(s,u+U*3,7);u+=T*3;for(var R=nn(G),z=(1<<R)-1,B=pt(G,R,1),U=0;U<C;){var D=B[tt(s,u,z)];u+=D&15;var b=D>>4;if(b<16)L[U++]=b;else{var H=0,I=0;for(b==16?(I=3+tt(s,u,3),u+=2,H=L[U-1]):b==17?(I=3+tt(s,u,7),u+=3):b==18&&(I=11+tt(s,u,127),u+=7);I--;)L[U++]=H}}var F=L.subarray(0,x),j=L.subarray(x);y=nn(F),m=nn(j),g=pt(F,y,1),p=pt(j,m,1)}else rt(1);else{var b=an(u)+4,S=s[b-4]|s[b-3]<<8,w=b+S;if(w>i){l&&rt(0);break}a&&c(d+S),t.set(s.subarray(b,w),d),e.b=d+=S,e.p=u=w*8,e.f=h;continue}if(u>P){l&&rt(0);break}}a&&c(d+131072);for(var O=(1<<y)-1,$=(1<<m)-1,A=u;;A=u){var H=g[on(s,u)&O],M=H>>4;if(u+=H&15,u>P){l&&rt(0);break}if(H||rt(2),M<256)t[d++]=M;else if(M==256){A=u,g=null;break}else{var N=M-254;if(M>264){var U=M-257,V=Bi[U];N=tt(s,u,(1<<V)-1)+Ha[U],u+=V}var Y=p[on(s,u)&$],J=Y>>4;Y||rt(3),u+=Y&15;var j=Pf[J];if(J>3){var V=Li[J];j+=on(s,u)&(1<<V)-1,u+=V}if(u>P){l&&rt(0);break}a&&c(d+131072);var oe=d+N;if(d<j){var _t=n-j,Ze=Math.min(j,oe);for(_t+d<0&&rt(3);d<Ze;++d)t[d]=r[_t+d]}for(;d<oe;++d)t[d]=t[d-j]}}e.l=g,e.p=A,e.b=d,e.f=h,g&&(h=1,e.m=y,e.d=p,e.n=m)}while(!h);return d!=t.length&&o?Za(t,0,d):t.subarray(0,d)},Mt=function(s,e,t){t<<=e&7;var r=e/8|0;s[r]|=t,s[r+1]|=t>>8},Wr=function(s,e,t){t<<=e&7;var r=e/8|0;s[r]|=t,s[r+1]|=t>>8,s[r+2]|=t>>16},ln=function(s,e){for(var t=[],r=0;r<s.length;++r)s[r]&&t.push({s:r,f:s[r]});var i=t.length,n=t.slice();if(!i)return{t:tl,l:0};if(i==1){var o=new Te(t[0].s+1);return o[t[0].s]=1,{t:o,l:1}}t.sort(function(w,x){return w.f-x.f}),t.push({s:-1,f:25001});var a=t[0],l=t[1],c=0,h=1,u=2;for(t[0]={s:-1,f:a.f+l.f,l:a,r:l};h!=i-1;)a=t[t[c].f<t[u].f?c++:u++],l=t[c!=h&&t[c].f<t[u].f?c++:u++],t[h++]={s:-1,f:a.f+l.f,l:a,r:l};for(var d=n[0].s,r=1;r<i;++r)n[r].s>d&&(d=n[r].s);var g=new je(d+1),p=cn(t[h-1],g,0);if(p>e){var r=0,y=0,m=p-e,P=1<<m;for(n.sort(function(x,T){return g[T.s]-g[x.s]||x.f-T.f});r<i;++r){var E=n[r].s;if(g[E]>e)y+=P-(1<<p-g[E]),g[E]=e;else break}for(y>>=m;y>0;){var b=n[r].s;g[b]<e?y-=1<<e-g[b]++-1:++r}for(;r>=0&&y;--r){var S=n[r].s;g[S]==e&&(--g[S],++y)}p=e}return{t:new Te(g),l:p}},cn=function(s,e,t){return s.s==-1?Math.max(cn(s.l,e,t+1),cn(s.r,e,t+1)):e[s.s]=t},Ja=function(s){for(var e=s.length;e&&!s[--e];);for(var t=new je(++e),r=0,i=s[0],n=1,o=function(l){t[r++]=l},a=1;a<=e;++a)if(s[a]==i&&a!=e)++n;else{if(!i&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(i),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(i);n=1,i=s[a]}return{c:t.subarray(0,r),n:e}},qr=function(s,e){for(var t=0,r=0;r<e.length;++r)t+=s[r]*e[r];return t},Qa=function(s,e,t){var r=t.length,i=an(e+2);s[i]=r&255,s[i+1]=r>>8,s[i+2]=s[i]^255,s[i+3]=s[i+1]^255;for(var n=0;n<r;++n)s[i+n+4]=t[n];return(i+4+r)*8},el=function(s,e,t,r,i,n,o,a,l,c,h){Mt(e,h++,t),++i[256];for(var u=ln(i,15),d=u.t,g=u.l,p=ln(n,15),y=p.t,m=p.l,P=Ja(d),E=P.c,b=P.n,S=Ja(y),w=S.c,x=S.n,T=new je(19),C=0;C<E.length;++C)++T[E[C]&31];for(var C=0;C<w.length;++C)++T[w[C]&31];for(var L=ln(T,7),G=L.t,U=L.l,R=19;R>4&&!G[tn[R-1]];--R);var z=c+5<<3,B=qr(i,Bt)+qr(n,jr)+o,D=qr(i,d)+qr(n,y)+o+14+3*R+qr(T,G)+2*T[16]+3*T[17]+7*T[18];if(l>=0&&z<=B&&z<=D)return Qa(e,h,s.subarray(l,l+c));var H,I,F,j;if(Mt(e,h,1+(D<B)),h+=2,D<B){H=pt(d,g,0),I=d,F=pt(y,m,0),j=y;var O=pt(G,U,0);Mt(e,h,b-257),Mt(e,h+5,x-1),Mt(e,h+10,R-4),h+=14;for(var C=0;C<R;++C)Mt(e,h+3*C,G[tn[C]]);h+=3*R;for(var $=[E,w],A=0;A<2;++A)for(var M=$[A],C=0;C<M.length;++C){var N=M[C]&31;Mt(e,h,O[N]),h+=G[N],N>15&&(Mt(e,h,M[C]>>5&127),h+=M[C]>>12)}}else H=Cf,I=Bt,F=Sf,j=jr;for(var C=0;C<a;++C){var V=r[C];if(V>255){var N=V>>18&31;Wr(e,h,H[N+257]),h+=I[N+257],N>7&&(Mt(e,h,V>>23&31),h+=Bi[N]);var Y=V&31;Wr(e,h,F[Y]),h+=j[Y],Y>3&&(Wr(e,h,V>>5&8191),h+=Li[Y])}else Wr(e,h,H[V]),h+=I[V]}return Wr(e,h,H[256]),h+I[256]},Of=new en([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),tl=new Te(0),kf=function(s,e,t,r,i,n){var o=n.z||s.length,a=new Te(r+o+5*(1+Math.ceil(o/7e3))+i),l=a.subarray(r,a.length-i),c=n.l,h=(n.r||0)&7;if(e){h&&(l[0]=n.r>>3);for(var u=Of[e-1],d=u>>13,g=u&8191,p=(1<<t)-1,y=n.p||new je(32768),m=n.h||new je(p+1),P=Math.ceil(t/3),E=2*P,b=function(ze){return(s[ze]^s[ze+1]<<P^s[ze+2]<<E)&p},S=new en(25e3),w=new je(288),x=new je(32),T=0,C=0,L=n.i||0,G=0,U=n.w||0,R=0;L+2<o;++L){var z=b(L),B=L&32767,D=m[z];if(y[B]=D,m[z]=B,U<=L){var H=o-L;if((T>7e3||G>24576)&&(H>423||!c)){h=el(s,l,0,S,w,x,C,G,R,L-R,h),G=T=C=0,R=L;for(var I=0;I<286;++I)w[I]=0;for(var I=0;I<30;++I)x[I]=0}var F=2,j=0,O=g,$=B-D&32767;if(H>2&&z==b(L-$))for(var A=Math.min(d,H)-1,M=Math.min(32767,L),N=Math.min(258,H);$<=M&&--O&&B!=D;){if(s[L+F]==s[L+F-$]){for(var V=0;V<N&&s[L+V]==s[L+V-$];++V);if(V>F){if(F=V,j=$,V>A)break;for(var Y=Math.min($,V-2),J=0,I=0;I<Y;++I){var oe=L-$+I&32767,_t=y[oe],Ze=oe-_t&32767;Ze>J&&(J=Ze,D=oe)}}}B=D,D=y[B],$+=B-D&32767}if(j){S[G++]=268435456|rn[F]<<18|Ka[j];var Be=rn[F]&31,$e=Ka[j]&31;C+=Bi[Be]+Li[$e],++w[257+Be],++x[$e],U=L+F,++T}else S[G++]=s[L],++w[s[L]]}}for(L=Math.max(L,U);L<o;++L)S[G++]=s[L],++w[s[L]];h=el(s,l,c,S,w,x,C,G,R,L-R,h),c||(n.r=h&7|l[h/8|0]<<3,h-=7,n.h=m,n.p=y,n.i=L,n.w=U)}else{for(var L=n.w||0;L<o+c;L+=65535){var Pe=L+65535;Pe>=o&&(l[h/8|0]=c,Pe=o),h=Qa(l,h+1,s.subarray(L,Pe))}n.i=o}return Za(a,0,r+an(h)+i)},rl=function(){var s=1,e=0;return{p:function(t){for(var r=s,i=e,n=t.length|0,o=0;o!=n;){for(var a=Math.min(o+2655,n);o<a;++o)i+=r+=t[o];r=(r&65535)+15*(r>>16),i=(i&65535)+15*(i>>16)}s=r,e=i},d:function(){return s%=65521,e%=65521,(s&255)<<24|(s&65280)<<8|(e&255)<<8|e>>8}}},Df=function(s,e,t,r,i){if(!i&&(i={l:1},e.dictionary)){var n=e.dictionary.subarray(-32768),o=new Te(n.length+s.length);o.set(n),o.set(s,n.length),s=o,i.w=n.length}return kf(s,e.level==null?6:e.level,e.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(s.length)))*1.5):20:12+e.mem,t,r,i)},il=function(s,e,t){for(;t;++e)s[e]=t,t>>>=8},If=function(s,e){var t=e.level,r=t==0?0:t<6?1:t==9?3:2;if(s[0]=120,s[1]=r<<6|(e.dictionary&&32),s[1]|=31-(s[0]<<8|s[1])%31,e.dictionary){var i=rl();i.p(e.dictionary),il(s,2,i.d())}},Rf=function(s,e){return((s[0]&15)!=8||s[0]>>4>7||(s[0]<<8|s[1])%31)&&rt(6,"invalid zlib data"),(s[1]>>5&1)==1&&rt(6,"invalid zlib data: "+(s[1]&32?"need":"unexpected")+" dictionary"),(s[1]>>3&4)+2};function Uf(s,e){e||(e={});var t=rl();t.p(s);var r=Df(s,e,e.dictionary?6:2,4);return If(r,e),il(r,r.length-4,t.d()),r}function Bf(s,e){return Af(s.subarray(Rf(s),-4),{i:2},e,e)}var Lf=typeof TextDecoder<"u"&&new TextDecoder,Ff=0;try{Lf.decode(tl,{stream:!0}),Ff=1}catch{}const Nf="modern-font";function Xr(s,e){if(!s)throw new Error(`[${Nf}] ${e}`)}function $f(s){if("buffer"in s){const e=s.buffer;return s.byteOffset>0||s.byteLength<s.buffer.byteLength?e.slice(s.byteOffset,s.byteOffset+s.byteLength):e}else return s}function yr(s){return"buffer"in s?new DataView(s.buffer,s.byteOffset,s.byteLength):new DataView(s)}function zf(s){let e="";for(let t=0,r=s.length,i;t<r;t++)i=s.charCodeAt(t),i!==0&&(e+=String.fromCharCode(i));return e}function Fi(s){s=zf(s);const e=[];for(let t=0,r=s.length,i;t<r;t++)i=s.charCodeAt(t),e.push(i>>8),e.push(i&255);return e}function Vf(s){let e="";for(let t=0,r=s.length;t<r;t++)s[t]<127?e+=String.fromCharCode(s[t]):e+=`%${(256+s[t]).toString(16).slice(1)}`;return unescape(e)}function Gf(s){let e="";for(let t=0,r=s.length;t<r;t+=2)e+=String.fromCharCode((s[t]<<8)+s[t+1]);return e}var jf=Object.defineProperty,Se=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&jf(e,t,i),i};const Hr={int8:1,int16:2,int32:4,uint8:1,uint16:2,uint32:4,float32:4,float64:8,fixed:4,longDateTime:8,char:1};function Ee(){return function(s,e){Object.defineProperty(s.constructor.prototype,e,{get(){if(typeof e=="string"){if(e.startsWith("read"))return(...t)=>this.read(e.substring(4).toLowerCase(),...t);if(e.startsWith("write"))return(...t)=>this.write(e.substring(5).toLowerCase(),...t)}},configurable:!0,enumerable:!0})}}class me extends DataView{constructor(e,t,r,i){super($f(e),t,r),this.littleEndian=i}cursor=0;readColumn(e){if(e.size){const t=Array.from({length:e.size},(r,i)=>this.read(e.type,e.offset+i));switch(e.type){case"char":return t.join("");default:return t}}else return this.read(e.type,e.offset)}writeColumn(e,t){e.size?Array.from({length:e.size},(r,i)=>{this.write(e.type,t[i],e.offset+i)}):this.write(e.type,t,e.offset)}read(e,t=this.cursor,r=this.littleEndian){switch(e){case"char":return this.readChar(t);case"fixed":return this.readFixed(t,r);case"longDateTime":return this.readLongDateTime(t,r)}const i=`get${e.replace(/^\S/,l=>l.toUpperCase())}`,n=this,a=n[i]?.bind(n)?.(t,r);return this.cursor+=Hr[e],a}readUint24(e=this.cursor){const[t,r,i]=this.readBytes(e,3);return(t<<16)+(r<<8)+i}readBytes(e,t){t==null&&(t=e,e=this.cursor);const r=[];for(let i=0;i<t;++i)r.push(this.getUint8(e+i));return this.cursor=e+t,r}readString(e,t){const r=this.readBytes(e,t);let i="";for(let n=0,o=r.length;n<o;n++)i+=String.fromCharCode(r[n]);return i}readFixed(e,t){const r=this.readInt32(e,t)/65536;return Math.ceil(r*1e5)/1e5}readLongDateTime(e=this.cursor,t){const r=this.readUint32(e+4,t),i=new Date;return i.setTime(r*1e3+-20775456e5),i}readChar(e){return this.readString(e,1)}write(e,t,r=this.cursor,i=this.littleEndian){switch(e){case"char":return this.writeChar(t,r);case"fixed":return this.writeFixed(t,r);case"longDateTime":return this.writeLongDateTime(t,r)}const n=`set${e.replace(/^\S/,c=>c.toUpperCase())}`,o=this,l=o[n]?.bind(o)?.(r,t,i);return this.cursor+=Hr[e.toLowerCase()],l}writeString(e="",t=this.cursor){const r=e.replace(/[^\x00-\xFF]/g,"11").length;this.seek(t);for(let i=0,n=e.length,o;i<n;++i)o=e.charCodeAt(i)||0,o>127?this.writeUint16(o):this.writeUint8(o);return this.cursor+=r,this}writeChar(e,t){return this.writeString(e,t)}writeFixed(e,t){return this.writeInt32(Math.round(e*65536),t),this}writeLongDateTime(e,t=this.cursor){typeof e>"u"?e=-20775456e5:typeof e.getTime=="function"?e=e.getTime():/^\d+$/.test(e)?e=+e:e=Date.parse(e);const i=Math.round((e- -20775456e5)/1e3);return this.writeUint32(0,t),this.writeUint32(i,t+4),this}writeBytes(e,t=this.cursor){let r;if(Array.isArray(e)){r=e.length;for(let i=0;i<r;++i)this.setUint8(t+i,e[i])}else{const i=yr(e);r=i.byteLength;for(let n=0;n<r;++n)this.setUint8(t+n,i.getUint8(n))}return this.cursor=t+r,this}seek(e){return this.cursor=e,this}}Se([Ee()],me.prototype,"readInt8"),Se([Ee()],me.prototype,"readInt16"),Se([Ee()],me.prototype,"readInt32"),Se([Ee()],me.prototype,"readUint8"),Se([Ee()],me.prototype,"readUint16"),Se([Ee()],me.prototype,"readUint32"),Se([Ee()],me.prototype,"readFloat32"),Se([Ee()],me.prototype,"readFloat64"),Se([Ee()],me.prototype,"writeInt8"),Se([Ee()],me.prototype,"writeInt16"),Se([Ee()],me.prototype,"writeInt32"),Se([Ee()],me.prototype,"writeUint8"),Se([Ee()],me.prototype,"writeUint16"),Se([Ee()],me.prototype,"writeUint32"),Se([Ee()],me.prototype,"writeFloat32"),Se([Ee()],me.prototype,"writeFloat64");const sl=new WeakMap;function v(s){const e=typeof s=="object"?s:{type:s},{size:t=1,type:r}=e;return(i,n)=>{if(typeof n!="string")return;let o=sl.get(i);o||(o={columns:[],byteLength:0},sl.set(i,o));const a={...e,name:n,byteLength:t*Hr[r],offset:e.offset??o.columns.reduce((l,c)=>l+c.byteLength,0)};o.columns.push(a),o.byteLength=o.columns.reduce((l,c)=>l+Hr[c.type]*(c.size??1),0),Object.defineProperty(i.constructor.prototype,n,{get(){return this.view.readColumn(a)},set(l){this.view.writeColumn(a,l)},configurable:!0,enumerable:!0})}}class We{view;constructor(e,t,r,i){this.view=new me(e,t,r,i)}}class Ni extends We{get buffer(){return this.view.buffer}toBuffer(){return this.view.buffer.slice(this.view.byteOffset,this.view.byteOffset+this.view.byteLength)}toBlob(){return new Blob([new Uint8Array(this.view.buffer,this.view.byteOffset,this.view.byteLength)],{type:this.mimeType})}toFontFace(e){return new FontFace(e,this.view.buffer)}}var Wf=Object.defineProperty,De=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Wf(e,t,i),i};const Ie=class mc extends Ni{format="EmbeddedOpenType";mimeType="application/vnd.ms-fontobject";static from(e){const t=e.sfnt,i=t.name.names,n=Fi(i.fontFamily||""),o=n.length,a=Fi(i.fontStyle||""),l=a.length,c=Fi(i.version||""),h=c.length,u=Fi(i.fullName||""),d=u.length,g=86+o+4+l+4+h+4+d+2+e.view.byteLength,p=new mc(new ArrayBuffer(g),0,g,!0);p.EOTSize=p.view.byteLength,p.FontDataSize=e.view.byteLength,p.Version=131073,p.Flags=0,p.Charset=1,p.MagicNumber=20556,p.Padding1=0,p.CheckSumAdjustment=t.head.checkSumAdjustment;const y=t.os2;return y&&(p.FontPANOSE=y.fontPANOSE,p.Italic=y.fsSelection,p.Weight=y.usWeightClass,p.fsType=y.fsType,p.UnicodeRange=y.ulUnicodeRange,p.CodePageRange=y.ulCodePageRange),p.view.writeUint16(o),p.view.writeBytes(n),p.view.writeUint16(0),p.view.writeUint16(l),p.view.writeBytes(a),p.view.writeUint16(0),p.view.writeUint16(h),p.view.writeBytes(c),p.view.writeUint16(0),p.view.writeUint16(d),p.view.writeBytes(u),p.view.writeUint16(0),p.view.writeUint16(0),p.view.writeBytes(e.view),p}};De([v("uint32")],Ie.prototype,"EOTSize"),De([v("uint32")],Ie.prototype,"FontDataSize"),De([v("uint32")],Ie.prototype,"Version"),De([v("uint32")],Ie.prototype,"Flags"),De([v({type:"uint8",size:10})],Ie.prototype,"FontPANOSE"),De([v("uint8")],Ie.prototype,"Charset"),De([v("uint8")],Ie.prototype,"Italic"),De([v("uint32")],Ie.prototype,"Weight"),De([v("uint16")],Ie.prototype,"fsType"),De([v("uint16")],Ie.prototype,"MagicNumber"),De([v({type:"uint8",size:16})],Ie.prototype,"UnicodeRange"),De([v({type:"uint8",size:8})],Ie.prototype,"CodePageRange"),De([v("uint32")],Ie.prototype,"CheckSumAdjustment"),De([v({type:"uint8",size:16})],Ie.prototype,"Reserved"),De([v("uint16")],Ie.prototype,"Padding1");var qf=Object.defineProperty,$i=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&qf(e,t,i),i};class vr extends We{constructor(e,t){super(e,t,16)}}$i([v({type:"char",size:4})],vr.prototype,"tag"),$i([v("uint32")],vr.prototype,"checkSum"),$i([v("uint32")],vr.prototype,"offset"),$i([v("uint32")],vr.prototype,"length");const hn=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],Xf=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"];class un{index;name;isComposite=!1;components=[];pathCommands=[];constructor(e){const t={...e};if(this.index=t.index??0,t.name===".notdef"?t.unicode=void 0:t.name===".null"&&(t.unicode=0),t.unicode===0&&t.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=t.name??null,t.unicode&&(this.unicode=t.unicode),t.unicodes?this.unicodes=t.unicodes:t.unicode&&(this.unicodes=[t.unicode])}getPathCommands(e=0,t=0,r=72,i={},n){const o=1/(n?.unitsPerEm??1e3)*r,{xScale:a=o,yScale:l=o}=i,c=this.pathCommands,h=[];for(let u=0,d=c.length;u<d;u+=1){const g=c[u];g.type==="M"?h.push({type:"M",x:e+g.x*a,y:t+-g.y*l}):g.type==="L"?h.push({type:"L",x:e+g.x*a,y:t+-g.y*l}):g.type==="Q"?h.push({type:"Q",x1:e+g.x1*a,y1:t+-g.y1*l,x:e+g.x*a,y:t+-g.y*l}):g.type==="C"?h.push({type:"C",x1:e+g.x1*a,y1:t+-g.y1*l,x2:e+g.x2*a,y2:t+-g.y2*l,x:e+g.x*a,y:t+-g.y*l}):g.type==="Z"&&h.push({type:"Z"})}return h}}class Hf extends un{parse(e,t,r){const i=this,{nominalWidthX:n,defaultWidthX:o,gsubrsBias:a,subrsBias:l}=e,c=e.topDict.paintType,h=this.index;let u,d,g,p;const y=[],m=[];let P=0,E=!1,b=!1,S=o,w=0,x=0;function T(B,D){y.push({type:"L",x:B,y:D})}function C(B,D,H,I,F,j){y.push({type:"C",x1:B,y1:D,x2:H,y2:I,x:F,y:j})}function L(B,D){b&&c!==2&&G(),b=!0,y.push({type:"M",x:B,y:D})}function G(){y.push({type:"Z"})}function U(B){y.push(...B)}function R(){m.length%2!==0&&!E&&(S=m.shift()+n),P+=m.length>>1,m.length=0,E=!0}function z(B){let D,H,I,F,j,O,$,A,M,N,V,Y,J=0;for(;J<B.length;){let oe=B[J++];switch(oe){case 1:R();break;case 3:R();break;case 4:m.length>1&&!E&&(S=m.shift()+n,E=!0),x+=m.pop(),L(w,x);break;case 5:for(;m.length>0;)w+=m.shift(),x+=m.shift(),T(w,x);break;case 6:for(;m.length>0&&(w+=m.shift(),T(w,x),m.length!==0);)x+=m.shift(),T(w,x);break;case 7:for(;m.length>0&&(x+=m.shift(),T(w,x),m.length!==0);)w+=m.shift(),T(w,x);break;case 8:for(;m.length>0;)u=w+m.shift(),d=x+m.shift(),g=u+m.shift(),p=d+m.shift(),w=g+m.shift(),x=p+m.shift(),C(u,d,g,p,w,x);break;case 10:j=m.pop()+l,O=e.subrs[j],O&&z(O);break;case 11:return;case 12:switch(oe=B[J],J+=1,oe){case 35:u=w+m.shift(),d=x+m.shift(),g=u+m.shift(),p=d+m.shift(),$=g+m.shift(),A=p+m.shift(),M=$+m.shift(),N=A+m.shift(),V=M+m.shift(),Y=N+m.shift(),w=V+m.shift(),x=Y+m.shift(),m.shift(),C(u,d,g,p,$,A),C(M,N,V,Y,w,x);break;case 34:u=w+m.shift(),d=x,g=u+m.shift(),p=d+m.shift(),$=g+m.shift(),A=p,M=$+m.shift(),N=p,V=M+m.shift(),Y=x,w=V+m.shift(),C(u,d,g,p,$,A),C(M,N,V,Y,w,x);break;case 36:u=w+m.shift(),d=x+m.shift(),g=u+m.shift(),p=d+m.shift(),$=g+m.shift(),A=p,M=$+m.shift(),N=p,V=M+m.shift(),Y=N+m.shift(),w=V+m.shift(),C(u,d,g,p,$,A),C(M,N,V,Y,w,x);break;case 37:u=w+m.shift(),d=x+m.shift(),g=u+m.shift(),p=d+m.shift(),$=g+m.shift(),A=p+m.shift(),M=$+m.shift(),N=A+m.shift(),V=M+m.shift(),Y=N+m.shift(),Math.abs(V-w)>Math.abs(Y-x)?w=V+m.shift():x=Y+m.shift(),C(u,d,g,p,$,A),C(M,N,V,Y,w,x);break;default:console.warn(`Glyph ${h}: unknown operator ${1200+oe}`),m.length=0}break;case 14:if(m.length>=4){const _t=hn[m.pop()],Ze=hn[m.pop()],Be=m.pop(),$e=m.pop();if(_t&&Ze){i.isComposite=!0,i.components=[];const Pe=e.charset.indexOf(_t),ze=e.charset.indexOf(Ze);i.components.push({glyphIndex:ze,dx:0,dy:0}),i.components.push({glyphIndex:Pe,dx:$e,dy:Be}),U(r.get(ze).pathCommands);const ot=JSON.parse(JSON.stringify(r.get(Pe).pathCommands));for(let at=0;at<ot.length;at+=1){const Je=ot[at];Je.type!=="Z"&&(Je.x+=$e,Je.y+=Be),(Je.type==="Q"||Je.type==="C")&&(Je.x1+=$e,Je.y1+=Be),Je.type==="C"&&(Je.x2+=$e,Je.y2+=Be)}U(ot)}}else m.length>0&&!E&&(S=m.shift()+n,E=!0);b&&c!==2&&(G(),b=!1);break;case 18:R();break;case 19:case 20:R(),J+=P+7>>3;break;case 21:m.length>2&&!E&&(S=m.shift()+n,E=!0),x+=m.pop(),w+=m.pop(),L(w,x);break;case 22:m.length>1&&!E&&(S=m.shift()+n,E=!0),w+=m.pop(),L(w,x);break;case 23:R();break;case 24:for(;m.length>2;)u=w+m.shift(),d=x+m.shift(),g=u+m.shift(),p=d+m.shift(),w=g+m.shift(),x=p+m.shift(),C(u,d,g,p,w,x);w+=m.shift(),x+=m.shift(),T(w,x);break;case 25:for(;m.length>6;)w+=m.shift(),x+=m.shift(),T(w,x);u=w+m.shift(),d=x+m.shift(),g=u+m.shift(),p=d+m.shift(),w=g+m.shift(),x=p+m.shift(),C(u,d,g,p,w,x);break;case 26:for(m.length%2&&(w+=m.shift());m.length>0;)u=w,d=x+m.shift(),g=u+m.shift(),p=d+m.shift(),w=g,x=p+m.shift(),C(u,d,g,p,w,x);break;case 27:for(m.length%2&&(x+=m.shift());m.length>0;)u=w+m.shift(),d=x,g=u+m.shift(),p=d+m.shift(),w=g+m.shift(),x=p,C(u,d,g,p,w,x);break;case 28:D=B[J],H=B[J+1],m.push((D<<24|H<<16)>>16),J+=2;break;case 29:j=m.pop()+a,O=e.gsubrs[j],O&&z(O);break;case 30:for(;m.length>0&&(u=w,d=x+m.shift(),g=u+m.shift(),p=d+m.shift(),w=g+m.shift(),x=p+(m.length===1?m.shift():0),C(u,d,g,p,w,x),m.length!==0);)u=w+m.shift(),d=x,g=u+m.shift(),p=d+m.shift(),x=p+m.shift(),w=g+(m.length===1?m.shift():0),C(u,d,g,p,w,x);break;case 31:for(;m.length>0&&(u=w+m.shift(),d=x,g=u+m.shift(),p=d+m.shift(),x=p+m.shift(),w=g+(m.length===1?m.shift():0),C(u,d,g,p,w,x),m.length!==0);)u=w,d=x+m.shift(),g=u+m.shift(),p=d+m.shift(),w=g+m.shift(),x=p+(m.length===1?m.shift():0),C(u,d,g,p,w,x);break;default:oe<32?console.warn(`Glyph ${h}: unknown operator ${oe}`):oe<247?m.push(oe-139):oe<251?(D=B[J],J+=1,m.push((oe-247)*256+D+108)):oe<255?(D=B[J],J+=1,m.push(-(oe-251)*256-D-108)):(D=B[J],H=B[J+1],I=B[J+2],F=B[J+3],J+=4,m.push((D<<24|H<<16|I<<8|F)/65536))}}}z(t),this.pathCommands=y,E&&(this.advanceWidth=S)}}class fn{constructor(e){this._sfnt=e}_items=[];get(e){const t=this._items[e];let r;if(t)r=t;else{r=this._get(e);const i=this._sfnt.hmtx.metrics[e];i&&(r.advanceWidth=r.advanceWidth||i.advanceWidth,r.leftSideBearing=r.leftSideBearing||i.leftSideBearing);const n=this._sfnt.cmap.glyphIndexToUnicodesMap.get(e);n&&(r.unicode??=n[0],r.unicodes??=n),this._items[e]=r}return r}}class Yf extends fn{get length(){return this._sfnt.cff.charStringsIndex.offsets.length-1}_get(e){const t=this._sfnt.cff,r=new Hf({index:e});return r.parse(t,t.charStringsIndex.get(e),this),r.name=t.charset[e],r}}var Kf=Object.defineProperty,nl=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Kf(e,t,i),i};class zi extends We{_offsets;get offsets(){return this._offsets??=this.readOffsets()}_objects;get objects(){return this._objects??=this.readObjects()}constructor(e,t,r,i){super(e,t,r,i),this._init()}_init(){const e=this.view,t=this.count,r=this.offsetSize;this.objectOffset=(t+1)*r+2,this.endOffset=e.byteOffset+this.objectOffset+this.offsets[t]}readOffsets(){const e=this.view,t=this.count,r=this.offsetSize;e.seek(3);const i=[];for(let n=0,o=t+1;n<o;n++){const a=this.view;let l=0;for(let c=0;c<r;c++)l<<=8,l+=a.readUint8();i.push(l)}return i}readObjects(){const e=[];for(let t=0,r=this.count;t<r;t++)e.push(this.get(t));return e}get(e){const t=this.offsets,r=this.objectOffset,i=r+t[e],o=r+t[e+1]-i;return this._isString?this.view.readString(i,o):this.view.readBytes(i,o)}}nl([v("uint16")],zi.prototype,"count"),nl([v("uint8")],zi.prototype,"offsetSize");class Vi extends zi{_isString=!1}class ol extends zi{_isString=!0}const Zf=[".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"],Jf=[".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"],Qf=[".notdef","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"],ed=[".notdef","space","dollaroldstyle","dollarsuperior","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","hyphensuperior","colonmonetary","onefitted","rupiah","centoldstyle","figuredash","hypheninferior","onequarter","onehalf","threequarters","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"];function Gi(s,e){return e<=390?Zf[e]:s[e-391]}function ie(s,e="number",t){return(r,i)=>{if(typeof i!="string")return;const n={type:e,operator:s,default:t??e==="number"?0:void 0};Object.defineProperty(r.constructor.prototype,i,{get(){return this._getProp(n)},set(o){this._setProp(n,o)},configurable:!0,enumerable:!0})}}class al extends We{_dict;get dict(){return this._dict??=this._readDict()}_stringIndex;setStringIndex(e){return this._stringIndex=e,this}_readFloatOperand(){const e=this.view;let t="";const r=15,i=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){const n=e.readUint8(),o=n>>4,a=n&15;if(o===r||(t+=i[o],a===r))break;t+=i[a]}return Number.parseFloat(t)}_readOperand(e){const t=this.view;let r,i,n,o;if(e===28)return r=t.readUint8(),i=t.readUint8(),r<<8|i;if(e===29)return r=t.readUint8(),i=t.readUint8(),n=t.readUint8(),o=t.readUint8(),r<<24|i<<16|n<<8|o;if(e===30)return this._readFloatOperand();if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return r=t.readUint8(),(e-247)*256+r+108;if(e>=251&&e<=254)return r=t.readUint8(),-(e-251)*256-r-108;throw new Error(`invalid b0 ${e}, at: ${t.cursor}`)}_readDict(){const e=this.view;e.seek(0);let t=[];const r=e.cursor+e.byteLength,i={};for(;e.cursor<r;){let n=e.readUint8();n<=21?(n===12&&(n=1200+e.readUint8()),i[n]=t,t=[]):t.push(this._readOperand(n))}return i}_getProp(e){const t=this.dict[e.operator]??e.default;switch(e.type){case"number":return t[0];case"string":return Gi(this._stringIndex?.objects??[],t[0]);case"number[]":return t}return t}_setProp(e,t){}}var td=Object.defineProperty,dn=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&td(e,t,i),i};class ji extends al{}dn([ie(19)],ji.prototype,"subrs"),dn([ie(20)],ji.prototype,"defaultWidthX"),dn([ie(21)],ji.prototype,"nominalWidthX");var rd=Object.defineProperty,ce=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&rd(e,t,i),i};class ne extends al{}ce([ie(0,"string")],ne.prototype,"version"),ce([ie(1,"string")],ne.prototype,"notice"),ce([ie(1200,"string")],ne.prototype,"copyright"),ce([ie(2,"string")],ne.prototype,"fullName"),ce([ie(3,"string")],ne.prototype,"familyName"),ce([ie(4,"string")],ne.prototype,"weight"),ce([ie(1201)],ne.prototype,"isFixedPitch"),ce([ie(1202)],ne.prototype,"italicAngle"),ce([ie(1203,"number",-100)],ne.prototype,"underlinePosition"),ce([ie(1204,"number",50)],ne.prototype,"underlineThickness"),ce([ie(1205)],ne.prototype,"paintType"),ce([ie(1206,"number",2)],ne.prototype,"charstringType"),ce([ie(1207,"number[]",[.001,0,0,.001,0,0])],ne.prototype,"fontMatrix"),ce([ie(13)],ne.prototype,"uniqueId"),ce([ie(5,"number[]",[0,0,0,0])],ne.prototype,"fontBBox"),ce([ie(1208)],ne.prototype,"strokeWidth"),ce([ie(14)],ne.prototype,"xuid"),ce([ie(15)],ne.prototype,"charset"),ce([ie(16)],ne.prototype,"encoding"),ce([ie(17)],ne.prototype,"charStrings"),ce([ie(18,"number[]",[0,0])],ne.prototype,"private");function be(s,e=s){return t=>{gt.tableDefinitions.set(s,{tag:s,prop:e,class:t}),Object.defineProperty(gt.prototype,e,{get(){return this.get(s)},set(r){return this.set(s,r)},configurable:!0,enumerable:!0})}}class gt{static tableDefinitions=new Map;tables=new Map;tableViews=new Map;get hasGlyf(){return this.tableViews.has("glyf")}get names(){return this.name.names}get unitsPerEm(){return this.head.unitsPerEm}get ascender(){return this.hhea.ascent}get descender(){return this.hhea.descent}get createdTimestamp(){return this.head.created}get modifiedTimestamp(){return this.head.modified}get numGlyphs(){return this.maxp.numGlyphs}get unicodes(){return this.cmap.glyphIndexToUnicodesMap}get glyphs(){return this.hasGlyf?this.glyf.glyphs:this.cff.glyphs}charToGlyphIndex(e){let t=this.cmap.unicodeToGlyphIndexMap.get(e.codePointAt(0));if(t===void 0&&!this.hasGlyf){const{encoding:r,charset:i}=this.cff;t=i.indexOf(r[e.codePointAt(0)])}return t??0}charToGlyph(e){return this.glyphs.get(this.charToGlyphIndex(e))}textToGlyphIndexes(e){const t=[];for(const r of e)t.push(this.charToGlyphIndex(r));return t}textToGlyphs(e){const t=this.glyphs,r=this.textToGlyphIndexes(e),i=r.length,n=Array.from({length:i}),o=t.get(0);for(let a=0;a<i;a+=1)n[a]=t.get(r[a])||o;return n}getPathCommands(e,t,r,i,n){const o=[];return this.forEachGlyph(e,t,r,i,n,(a,l,c,h,u)=>{o.push(...a.getPathCommands(l,c,h,u,this))}),o}getAdvanceWidth(e,t,r){return this.forEachGlyph(e,0,0,t,r,()=>{})}forEachGlyph(e,t=0,r=0,i=72,n={},o){const a=1/this.unitsPerEm*i,l=this.textToGlyphs(e);for(let c=0;c<l.length;c+=1){const h=l[c];o.call(this,h,t,r,i,n),h.advanceWidth&&(t+=h.advanceWidth*a),n.letterSpacing?t+=n.letterSpacing*i:n.tracking&&(t+=n.tracking/1e3*i)}return t}constructor(e){(e instanceof Map?e:new Map(Object.entries(e))).forEach((r,i)=>{this.tableViews.set(i,new DataView(r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength)))})}clone(){return new gt(this.tableViews)}delete(e){const t=gt.tableDefinitions.get(e);return t?(this.tableViews.delete(e),this.tables.delete(t.prop),this):this}set(e,t){const r=gt.tableDefinitions.get(e);return r&&this.tables.set(r.prop,t),this.tableViews.set(e,t.view),this}get(e){const t=gt.tableDefinitions.get(e);if(!t)return;let r=this.tables.get(t.prop);if(!r){const i=t.class;if(i){const n=this.tableViews.get(e);if(!n)return;r=new i(n.buffer,n.byteOffset,n.byteLength).setSFNT(this),this.tables.set(t.prop,r)}}return r}}class Me extends We{setSFNT(e){return this._sfnt=e,this}getSFNT(){return this._sfnt}}var id=Object.defineProperty,sd=Object.getOwnPropertyDescriptor,Yr=(s,e,t,r)=>{for(var i=r>1?void 0:r?sd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&id(e,t,i),i};let Yt=class extends Me{_glyphs;get glyphs(){return this._glyphs??=new Yf(this._sfnt)}get gsubrs(){return this.globalSubrIndex.objects}get gsubrsBias(){return this._calcSubroutineBias(this.globalSubrIndex.objects)}privateDict;subrsIndex;get defaultWidthX(){return this.privateDict?.defaultWidthX??0}get nominalWidthX(){return this.privateDict?.nominalWidthX??0}get subrs(){return this.subrsIndex?.objects??[]}get subrsBias(){return this._calcSubroutineBias(this.subrs)}constructor(s,e,t,r){super(s,e,t,r),this._init()}_init(){const s=this.view,{buffer:e,byteOffset:t}=s,r=t+4;this.nameIndex=new ol(e,r),this.topDictIndex=new Vi(e,this.nameIndex.endOffset),this.stringIndex=new ol(e,this.topDictIndex.endOffset),this.globalSubrIndex=new Vi(e,this.stringIndex.endOffset),this.topDict=new ne(new Uint8Array(this.topDictIndex.objects[0]).buffer).setStringIndex(this.stringIndex);const i=this.topDict.private[0],n=this.topDict.private[1];i&&(this.privateDict=new ji(e,t+n,i).setStringIndex(this.stringIndex),this.privateDict.subrs&&(this.subrsIndex=new Vi(e,t+n+this.privateDict.subrs))),this.charStringsIndex=new Vi(e,t+this.topDict.charStrings);const o=this.charStringsIndex.offsets.length-1;this.topDict.charset===0?this.charset=Jf:this.topDict.charset===1?this.charset=Qf:this.topDict.charset===2?this.charset=ed:this.charset=this._readCharset(t+this.topDict.charset,o,this.stringIndex.objects),this.topDict.encoding===0?this.encoding=hn:this.topDict.encoding===1?this.encoding=Xf:this.encoding=this._readEncoding(t+this.topDict.encoding)}_readCharset(s,e,t){const r=this.view;r.seek(s);let i,n,o;e-=1;const a=[".notdef"],l=r.readUint8();if(l===0)for(i=0;i<e;i+=1)n=r.readUint16(),a.push(Gi(t,n));else if(l===1)for(;a.length<=e;)for(n=r.readUint16(),o=r.readUint8(),i=0;i<=o;i+=1)a.push(Gi(t,n)),n+=1;else if(l===2)for(;a.length<=e;)for(n=r.readUint16(),o=r.readUint16(),i=0;i<=o;i+=1)a.push(Gi(t,n)),n+=1;else throw new Error(`Unknown charset format ${l}`);return a}_readEncoding(s){const e=this.view;e.seek(s);let t,r;const i={},n=e.readUint8();if(n===0){const o=e.readUint8();for(t=0;t<o;t+=1)r=e.readUint8(),i[r]=t}else if(n===1){const o=e.readUint8();for(r=1,t=0;t<o;t+=1){const a=e.readUint8(),l=e.readUint8();for(let c=a;c<=a+l;c+=1)i[c]=r,r+=1}}else console.warn(`unknown encoding format:${n}`);return i}_calcSubroutineBias(s){let e;return s.length<1240?e=107:s.length<33900?e=1131:e=32768,e}};Yr([v("uint8")],Yt.prototype,"majorVersion",2),Yr([v("uint8")],Yt.prototype,"minorVersion",2),Yr([v("uint8")],Yt.prototype,"headerSize",2),Yr([v("uint8")],Yt.prototype,"offsetSize",2),Yt=Yr([be("CFF ","cff")],Yt);var nd=Object.defineProperty,Wi=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&nd(e,t,i),i};const Kr=class yc extends We{constructor(e=new ArrayBuffer(262),t){super(e,t,262)}static from(e){const t=new yc;return t.format=0,t.length=t.view.byteLength,t.language=0,e.forEach((r,i)=>{i<256&&r<256&&t.view.writeUint8(r,6+i)}),t}getUnicodeToGlyphIndexMap(){const e=new Map;return this.glyphIndexArray.forEach((t,r)=>{e.set(r,t)}),e}};Wi([v("uint16")],Kr.prototype,"format"),Wi([v("uint16")],Kr.prototype,"length"),Wi([v("uint16")],Kr.prototype,"language"),Wi([v({type:"uint8",size:256})],Kr.prototype,"glyphIndexArray");let pn=Kr;var od=Object.defineProperty,gn=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&od(e,t,i),i};class Zr extends We{get subHeaderKeys(){return this.view.seek(6),Array.from({length:256},()=>this.view.readUint16()/8)}get maxSubHeaderKey(){return this.subHeaderKeys.reduce((e,t)=>Math.max(e,t),0)}get subHeaders(){const e=this.maxSubHeaderKey;return this.view.seek(6+256*2),Array.from({length:e},(t,r)=>({firstCode:this.view.readUint16(),entryCount:this.view.readUint16(),idDelta:this.view.readUint16(),idRangeOffset:(this.view.readUint16()-(e-r)*8-2)/2}))}get glyphIndexArray(){const e=this.maxSubHeaderKey,t=6+256*2+e*8;this.view.seek(t);const r=(this.view.byteLength-t)/2;return Array.from({length:r},()=>this.view.readUint16())}getUnicodeToGlyphIndexMap(e){const t=new Map,r=this.subHeaderKeys,i=this.maxSubHeaderKey,n=this.subHeaders,o=this.glyphIndexArray,a=r.findIndex(c=>c===i);let l=0;for(let c=0;c<256;c++)if(r[c]===0)c>=a||c<n[0].firstCode||c>=n[0].firstCode+n[0].entryCount||n[0].idRangeOffset+(c-n[0].firstCode)>=o.length?l=0:(l=o[n[0].idRangeOffset+(c-n[0].firstCode)],l!==0&&(l=l+n[0].idDelta)),l!==0&&l<e&&t.set(c,l);else{const h=r[c];for(let u=0,d=n[h].entryCount;u<d;u++)if(n[h].idRangeOffset+u>=o.length?l=0:(l=o[n[h].idRangeOffset+u],l!==0&&(l=l+n[h].idDelta)),l!==0&&l<e){const g=(c<<8|u+n[h].firstCode)%65535;t.set(g,l)}}return t}}gn([v("uint16")],Zr.prototype,"format"),gn([v("uint16")],Zr.prototype,"length"),gn([v("uint16")],Zr.prototype,"language");function ll(s){return s>32767?s-65536:s<-32767?s+65536:s}function mn(s,e){let t;const r=[];let i={};return s.forEach((n,o)=>{e&&o>e||((!t||o!==t.unicode+1||n!==t.glyphIndex+1)&&(t?(i.end=t.unicode,r.push(i),i={start:o,startId:n,delta:ll(n-o)}):(i.start=Number(o),i.startId=n,i.delta=ll(n-o))),t={unicode:o,glyphIndex:n})}),t&&(i.end=t.unicode,r.push(i)),r}var ad=Object.defineProperty,Kt=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&ad(e,t,i),i};const Lt=class vc extends We{get endCode(){const e=this.segCountX2;return this.view.seek(14),Array.from({length:e/2},()=>this.view.readUint16())}set endCode(e){this.view.seek(14),e.forEach(t=>this.view.writeUint16(t))}get reservedPad(){return this.view.readUint16(14+this.segCountX2)}set reservedPad(e){this.view.writeUint16(e,14+this.segCountX2)}get startCode(){const e=this.segCountX2;return this.view.seek(14+e+2),Array.from({length:e/2},()=>this.view.readUint16())}set startCode(e){this.view.seek(14+this.segCountX2+2),e.forEach(t=>this.view.writeUint16(t))}get idDelta(){const e=this.segCountX2;return this.view.seek(14+e+2+e),Array.from({length:e/2},()=>this.view.readUint16())}set idDelta(e){const t=this.segCountX2;this.view.seek(14+t+2+t),e.forEach(r=>this.view.writeUint16(r))}get idRangeOffsetCursor(){const e=this.segCountX2;return 14+e+2+e*2}get idRangeOffset(){const e=this.segCountX2;return this.view.seek(this.idRangeOffsetCursor),Array.from({length:e/2},()=>this.view.readUint16())}set idRangeOffset(e){this.view.seek(this.idRangeOffsetCursor),e.forEach(t=>this.view.writeUint16(t))}get glyphIndexArrayCursor(){const e=this.segCountX2;return 14+e+2+e*3}get glyphIndexArray(){const e=this.glyphIndexArrayCursor;this.view.seek(e);const t=(this.view.byteLength-e)/2;return Array.from({length:t},()=>this.view.readUint16())}static from(e){const t=mn(e,65535),r=t.length+1,i=Math.floor(Math.log(r)/Math.LN2),n=2*2**i,o=new vc(new ArrayBuffer(24+t.length*8));return o.format=4,o.length=o.view.byteLength,o.language=0,o.segCountX2=r*2,o.searchRange=n,o.entrySelector=i,o.rangeShift=2*r-n,o.endCode=[...t.map(a=>a.end),65535],o.reservedPad=0,o.startCode=[...t.map(a=>a.start),65535],o.idDelta=[...t.map(a=>a.delta),1],o.idRangeOffset=Array.from({length:r},()=>0),o}getUnicodeToGlyphIndexMap(){const e=new Map,t=this.segCountX2/2,r=(this.glyphIndexArrayCursor-this.idRangeOffsetCursor)/2,i=this.startCode,n=this.endCode,o=this.idRangeOffset,a=this.idDelta,l=this.glyphIndexArray;for(let c=0;c<t;++c)for(let h=i[c],u=n[c];h<=u;++h)if(o[c]===0)e.set(h,(h+a[c])%65536);else{const d=c+o[c]/2+(h-i[c])-r,g=l[d];g!==0?e.set(h,(g+a[c])%65536):e.set(h,0)}return e.delete(65535),e}};Kt([v("uint16")],Lt.prototype,"format"),Kt([v("uint16")],Lt.prototype,"length"),Kt([v("uint16")],Lt.prototype,"language"),Kt([v("uint16")],Lt.prototype,"segCountX2"),Kt([v("uint16")],Lt.prototype,"searchRange"),Kt([v("uint16")],Lt.prototype,"entrySelector"),Kt([v("uint16")],Lt.prototype,"rangeShift");let yn=Lt;var ld=Object.defineProperty,Jr=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&ld(e,t,i),i};class Zt extends We{get glyphIndexArray(){return this.view.seek(12),Array.from({length:this.entryCount},()=>this.view.readUint16())}getUnicodeToGlyphIndexMap(){const e=this.glyphIndexArray,t=new Map;return e.forEach((r,i)=>{t.set(i,r)}),t}}Jr([v("uint16")],Zt.prototype,"format"),Jr([v("uint16")],Zt.prototype,"length"),Jr([v("uint16")],Zt.prototype,"language"),Jr([v("uint16")],Zt.prototype,"firstCode"),Jr([v("uint16")],Zt.prototype,"entryCount");var cd=Object.defineProperty,Qr=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&cd(e,t,i),i};const _r=class _c extends We{get groups(){const e=this.nGroups;return this.view.seek(16),Array.from({length:e},()=>({startCharCode:this.view.readUint32(),endCharCode:this.view.readUint32(),startGlyphCode:this.view.readUint32()}))}static from(e){const t=mn(e),r=new _c(new ArrayBuffer(16+t.length*12));return r.format=12,r.reserved=0,r.length=r.view.byteLength,r.language=0,r.nGroups=t.length,t.forEach(i=>{r.view.writeUint32(i.start),r.view.writeUint32(i.end),r.view.writeUint32(i.startId)}),r}getUnicodeToGlyphIndexMap(){const e=new Map,t=this.groups;for(let r=0,i=t.length;r<i;r++){const n=t[r];let o=n.startGlyphCode,a=n.startCharCode;const l=n.endCharCode;for(;a<=l;)e.set(a++,o++)}return e}};Qr([v("uint16")],_r.prototype,"format"),Qr([v("uint16")],_r.prototype,"reserved"),Qr([v("uint32")],_r.prototype,"length"),Qr([v("uint32")],_r.prototype,"language"),Qr([v("uint32")],_r.prototype,"nGroups");let vn=_r;var hd=Object.defineProperty,_n=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&hd(e,t,i),i};class ei extends We{getVarSelectorRecords(){const e=this.numVarSelectorRecords;return this.view.seek(10),Array.from({length:e},()=>{const t={varSelector:this.view.readUint24(),defaultUVSOffset:this.view.readUint32(),unicodeValueRanges:[],nonDefaultUVSOffset:this.view.readUint32(),uVSMappings:[]};if(t.defaultUVSOffset){this.view.seek(t.defaultUVSOffset);const r=this.view.readUint32();t.unicodeValueRanges=Array.from({length:r},()=>({startUnicodeValue:this.view.readUint24(),additionalCount:this.view.readUint8()}))}if(t.nonDefaultUVSOffset){this.view.seek(t.nonDefaultUVSOffset);const r=this.view.readUint32();t.uVSMappings=Array.from({length:r},()=>({unicodeValue:this.view.readUint24(),glyphID:this.view.readUint16()}))}return t})}getUnicodeToGlyphIndexMap(){const e=new Map,t=this.getVarSelectorRecords();for(let r=0,i=t.length;r<i;r++){const{uVSMappings:n}=t[r];n.forEach(o=>{e.set(o.unicodeValue,o.glyphID)})}return e}}_n([v("uint16")],ei.prototype,"format"),_n([v("uint32")],ei.prototype,"length"),_n([v("uint32")],ei.prototype,"numVarSelectorRecords");var ud=Object.defineProperty,fd=Object.getOwnPropertyDescriptor,bn=(s,e,t,r)=>{for(var i=r>1?void 0:r?fd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&ud(e,t,i),i};let br=class extends Me{static from(s){const e=Array.from(s.keys()).some(h=>h>65535),t=yn.from(s),r=pn.from(s),i=e?vn.from(s):void 0,n=4+(i?32:24),o=n+t.view.byteLength,a=o+r.view.byteLength,l=[{platformID:0,platformSpecificID:3,offset:n},{platformID:1,platformSpecificID:0,offset:o},{platformID:3,platformSpecificID:1,offset:n},i&&{platformID:3,platformSpecificID:10,offset:a}].filter(Boolean),c=new br(new ArrayBuffer(4+8*l.length+t.view.byteLength+r.view.byteLength+(i?.view.byteLength??0)));return c.numberSubtables=l.length,c.view.seek(4),l.forEach(h=>{c.view.writeUint16(h.platformID),c.view.writeUint16(h.platformSpecificID),c.view.writeUint32(h.offset)}),c.view.writeBytes(t.view,n),c.view.writeBytes(r.view,o),i&&c.view.writeBytes(i.view,a),c}_unicodeToGlyphIndexMap;get unicodeToGlyphIndexMap(){return this._unicodeToGlyphIndexMap??=this.readunicodeToGlyphIndexMap()}_glyphIndexToUnicodesMap;get glyphIndexToUnicodesMap(){if(!this._glyphIndexToUnicodesMap){const s=new Map,e=this.unicodeToGlyphIndexMap,t=Array.from(e.keys());for(let r=0,i=t.length;r<i;r++){const n=t[r],o=e.get(n);s.has(o)?s.get(o).push(n):s.set(o,[n])}this._glyphIndexToUnicodesMap=s}return this._glyphIndexToUnicodesMap}readSubtables(){const s=this.numberSubtables;return this.view.seek(4),Array.from({length:s},()=>({platformID:this.view.readUint16(),platformSpecificID:this.view.readUint16(),offset:this.view.readUint32()})).map(e=>{this.view.seek(e.offset);const t=this.view.readUint16();let r;switch(t){case 0:r=new pn(this.view.buffer,e.offset);break;case 2:r=new Zr(this.view.buffer,e.offset,this.view.readUint16());break;case 4:r=new yn(this.view.buffer,e.offset,this.view.readUint16());break;case 6:r=new Zt(this.view.buffer,e.offset,this.view.readUint16());break;case 12:r=new vn(this.view.buffer,e.offset,this.view.readUint32(e.offset+4));break;case 14:default:r=new ei(this.view.buffer,e.offset,this.view.readUint32());break}return{...e,format:t,view:r}})}readunicodeToGlyphIndexMap(){const s=this.readSubtables(),e=s.find(o=>o.format===0)?.view,t=s.find(o=>o.platformID===3&&o.platformSpecificID===3&&o.format===2)?.view,r=s.find(o=>o.platformID===3&&o.platformSpecificID===1&&o.format===4)?.view,i=s.find(o=>o.platformID===3&&o.platformSpecificID===10&&o.format===12)?.view,n=s.find(o=>o.platformID===0&&o.platformSpecificID===5&&o.format===14)?.view;return new Map([...e?.getUnicodeToGlyphIndexMap()??[],...t?.getUnicodeToGlyphIndexMap(this._sfnt.maxp.numGlyphs)??[],...r?.getUnicodeToGlyphIndexMap()??[],...i?.getUnicodeToGlyphIndexMap()??[],...n?.getUnicodeToGlyphIndexMap()??[]])}};bn([v("uint16")],br.prototype,"version",2),bn([v("uint16")],br.prototype,"numberSubtables",2),br=bn([be("cmap")],br);class dd extends un{_parseContours(e){const t=[];let r=[];for(let i=0;i<e.length;i+=1){const n=e[i];r.push(n),n.lastPointOfContour&&(t.push(r),r=[])}return Xr(r.length===0,"There are still points left in the current contour."),t}_transformPoints(e,t){const r=[];for(let i=0;i<e.length;i+=1){const n=e[i],o={x:t.xScale*n.x+t.scale10*n.y+t.dx,y:t.scale01*n.x+t.yScale*n.y+t.dy,onCurve:n.onCurve,lastPointOfContour:n.lastPointOfContour};r.push(o)}return r}_parseGlyphCoordinate(e,t,r,i,n){let o;return(t&i)>0?(o=e.view.readUint8(),(t&n)===0&&(o=-o),o=r+o):(t&n)>0?o=r:o=r+e.view.readInt16(),o}parse(e,t,r){e.view.seek(t);const i=this.numberOfContours=e.view.readInt16();if(this.xMin=e.view.readInt16(),this.yMin=e.view.readInt16(),this.xMax=e.view.readInt16(),this.yMax=e.view.readInt16(),i>0){const a=this.endPointIndices=[];for(let y=0;y<i;y++)a.push(e.view.readUint16());const l=this.instructionLength=e.view.readUint16();Xr(l<5e3,`Bad instructionLength:${l}`);const c=this.instructions=[];for(let y=0;y<l;++y)c.push(e.view.readUint8());const h=e.view.byteOffset,u=a[a.length-1]+1;Xr(u<2e4,`Bad numberOfCoordinates:${h}`);const d=[];let g,p=0;for(;p<u;)if(g=e.view.readUint8(),d.push(g),p++,g&8&&p<u){const y=e.view.readUint8();for(let m=0;m<y;m++)d.push(g),p++}if(Xr(d.length===u,`Bad flags length: ${d.length}, numberOfCoordinates: ${u}`),a.length>0){const y=[];let m;if(u>0){for(let b=0;b<u;b+=1)g=d[b],m={},m.onCurve=!!(g&1),m.lastPointOfContour=a.includes(b),y.push(m);let P=0;for(let b=0;b<u;b+=1)g=d[b],m=y[b],m.x=this._parseGlyphCoordinate(e,g,P,2,16),P=m.x;let E=0;for(let b=0;b<u;b+=1)g=d[b],m=y[b],m.y=this._parseGlyphCoordinate(e,g,E,4,32),E=m.y}this.points=y}else this.points=[]}else if(i===0)this.points=[];else{this.isComposite=!0,this.points=[],this.components=[];let a,l=!0;for(;l;){a=e.view.readUint16();const c={glyphIndex:e.view.readUint16(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(a&1)>0?(a&2)>0?(c.dx=e.view.readInt16(),c.dy=e.view.readInt16()):c.matchedPoints=[e.view.readUint16(),e.view.readUint16()]:(a&2)>0?(c.dx=e.view.readInt8(),c.dy=e.view.readInt8()):c.matchedPoints=[e.view.readUint8(),e.view.readUint8()],(a&8)>0?c.xScale=c.yScale=e.view.readInt16()/16384:(a&64)>0?(c.xScale=e.view.readInt16()/16384,c.yScale=e.view.readInt16()/16384):(a&128)>0&&(c.xScale=e.view.readInt16()/16384,c.scale01=e.view.readInt16()/16384,c.scale10=e.view.readInt16()/16384,c.yScale=e.view.readInt16()/16384),this.components.push(c),l=!!(a&32)}if(a&256){this.instructionLength=e.view.readUint16(),this.instructions=[];for(let c=0;c<this.instructionLength;c+=1)this.instructions.push(e.view.readUint8())}}if(this.isComposite)for(let a=0;a<this.components.length;a+=1){const l=this.components[a],c=r.get(l.glyphIndex);if(c.getPathCommands(),c.points){let h;if(l.matchedPoints===void 0)h=this._transformPoints(c.points,l);else{Xr(l.matchedPoints[0]>this.points.length-1||l.matchedPoints[1]>c.points.length-1,`Matched points out of range in ${this.name}`);const u=this.points[l.matchedPoints[0]];let d=c.points[l.matchedPoints[1]];const g={xScale:l.xScale,scale01:l.scale01,scale10:l.scale10,yScale:l.yScale,dx:0,dy:0};d=this._transformPoints([d],g)[0],g.dx=u.x-d.x,g.dy=u.y-d.y,h=this._transformPoints(c.points,g)}this.points=this.points.concat(h)}}const n=[],o=this._parseContours(this.points);for(let a=0,l=o.length;a<l;++a){const c=o[a];let h=c[c.length-1],u=c[0];h.onCurve?n.push({type:"M",x:h.x,y:h.y}):u.onCurve?n.push({type:"M",x:u.x,y:u.y}):n.push({type:"M",x:(h.x+u.x)*.5,y:(h.y+u.y)*.5});for(let d=0,g=c.length;d<g;++d)if(h=u,u=c[(d+1)%g],h.onCurve)n.push({type:"L",x:h.x,y:h.y});else{let p=u;u.onCurve||(p={x:(h.x+u.x)*.5,y:(h.y+u.y)*.5}),n.push({type:"Q",x1:h.x,y1:h.y,x:p.x,y:p.y})}n.push({type:"Z"})}this.pathCommands=n}}class pd extends fn{get length(){return this._sfnt.loca.locations.length}_get(e){const t=this._sfnt.loca.locations,r=t[e],i=new dd({index:e});return r!==t[e+1]&&i.parse(this._sfnt.glyf,r,this),i}}var gd=Object.getOwnPropertyDescriptor,md=(s,e,t,r)=>{for(var i=r>1?void 0:r?gd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};let qi=class extends Me{static from(s){const e=s.reduce((r,i)=>r+i.byteLength,0),t=new qi(new ArrayBuffer(e));return s.forEach(r=>{t.view.writeBytes(r)}),t}_glyphs;get glyphs(){return this._glyphs??=new pd(this._sfnt)}};qi=md([be("glyf")],qi);var yd=Object.getOwnPropertyDescriptor,vd=(s,e,t,r)=>{for(var i=r>1?void 0:r?yd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};let wn=class extends Me{};wn=vd([be("GPOS","gpos")],wn);var _d=Object.defineProperty,bd=Object.getOwnPropertyDescriptor,Jt=(s,e,t,r)=>{for(var i=r>1?void 0:r?bd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&_d(e,t,i),i};let At=class extends Me{};Jt([v("uint16")],At.prototype,"majorVersion",2),Jt([v("uint16")],At.prototype,"minorVersion",2),Jt([v("uint16")],At.prototype,"scriptListOffset",2),Jt([v("uint16")],At.prototype,"featureListOffset",2),Jt([v("uint16")],At.prototype,"lookupListOffset",2),Jt([v("uint16")],At.prototype,"featureVariationsOffset",2),At=Jt([be("GSUB","gsub")],At);var wd=Object.defineProperty,xd=Object.getOwnPropertyDescriptor,ye=(s,e,t,r)=>{for(var i=r>1?void 0:r?xd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&wd(e,t,i),i};let ue=class extends Me{constructor(s=new ArrayBuffer(54),e){super(s,e,Math.min(54,s.byteLength-(e??0)))}};ye([v("fixed")],ue.prototype,"version",2),ye([v("fixed")],ue.prototype,"fontRevision",2),ye([v("uint32")],ue.prototype,"checkSumAdjustment",2),ye([v("uint32")],ue.prototype,"magickNumber",2),ye([v("uint16")],ue.prototype,"flags",2),ye([v("uint16")],ue.prototype,"unitsPerEm",2),ye([v({type:"longDateTime"})],ue.prototype,"created",2),ye([v({type:"longDateTime"})],ue.prototype,"modified",2),ye([v("int16")],ue.prototype,"xMin",2),ye([v("int16")],ue.prototype,"yMin",2),ye([v("int16")],ue.prototype,"xMax",2),ye([v("int16")],ue.prototype,"yMax",2),ye([v("uint16")],ue.prototype,"macStyle",2),ye([v("uint16")],ue.prototype,"lowestRecPPEM",2),ye([v("int16")],ue.prototype,"fontDirectionHint",2),ye([v("int16")],ue.prototype,"indexToLocFormat",2),ye([v("int16")],ue.prototype,"glyphDataFormat",2),ue=ye([be("head")],ue);var Pd=Object.defineProperty,Cd=Object.getOwnPropertyDescriptor,Re=(s,e,t,r)=>{for(var i=r>1?void 0:r?Cd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Pd(e,t,i),i};let we=class extends Me{constructor(s=new ArrayBuffer(36),e){super(s,e,Math.min(36,s.byteLength-(e??0)))}};Re([v("fixed")],we.prototype,"version",2),Re([v("int16")],we.prototype,"ascent",2),Re([v("int16")],we.prototype,"descent",2),Re([v("int16")],we.prototype,"lineGap",2),Re([v("uint16")],we.prototype,"advanceWidthMax",2),Re([v("int16")],we.prototype,"minLeftSideBearing",2),Re([v("int16")],we.prototype,"minRightSideBearing",2),Re([v("int16")],we.prototype,"xMaxExtent",2),Re([v("int16")],we.prototype,"caretSlopeRise",2),Re([v("int16")],we.prototype,"caretSlopeRun",2),Re([v("int16")],we.prototype,"caretOffset",2),Re([v({type:"int16",size:4})],we.prototype,"reserved",2),Re([v("int16")],we.prototype,"metricDataFormat",2),Re([v("uint16")],we.prototype,"numOfLongHorMetrics",2),we=Re([be("hhea")],we);var Td=Object.getOwnPropertyDescriptor,Sd=(s,e,t,r)=>{for(var i=r>1?void 0:r?Td(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};let Xi=class extends Me{static from(s){const e=s.length*4,t=new Xi(new ArrayBuffer(e));return s.forEach(r=>{t.view.writeUint16(r.advanceWidth),t.view.writeUint16(r.leftSideBearing)}),t}_metrics;get metrics(){return this._metrics??=this.readMetrics()}readMetrics(){const s=this._sfnt.maxp.numGlyphs,e=this._sfnt.hhea.numOfLongHorMetrics;let t=0;const r=this.view;return r.seek(0),Array.from({length:s}).map((i,n)=>(n<e&&(t=r.readUint16()),{advanceWidth:t,leftSideBearing:r.readUint16()}))}};Xi=Sd([be("hmtx")],Xi);var Ed=Object.getOwnPropertyDescriptor,Md=(s,e,t,r)=>{for(var i=r>1?void 0:r?Ed(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};let xn=class extends Me{};xn=Md([be("kern","kern")],xn);var Ad=Object.getOwnPropertyDescriptor,Od=(s,e,t,r)=>{for(var i=r>1?void 0:r?Ad(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};let Hi=class extends Me{static from(s,e=1){const t=s.length*(e?4:2),r=new Hi(new ArrayBuffer(t));return s.forEach(i=>{e?r.view.writeUint32(i):r.view.writeUint16(i/2)}),r}_locations;get locations(){return this._locations??=this.readLocations()}readLocations(){const s=this._sfnt.maxp.numGlyphs,e=this._sfnt.head.indexToLocFormat,t=this.view;return t.seek(0),Array.from({length:s}).map(()=>e?t.readUint32():t.readUint16()*2)}};Hi=Od([be("loca")],Hi);var kd=Object.defineProperty,Dd=Object.getOwnPropertyDescriptor,Ae=(s,e,t,r)=>{for(var i=r>1?void 0:r?Dd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&kd(e,t,i),i};let ve=class extends Me{constructor(s=new ArrayBuffer(32),e){super(s,e,Math.min(32,s.byteLength-(e??0)))}};Ae([v("fixed")],ve.prototype,"version",2),Ae([v("uint16")],ve.prototype,"numGlyphs",2),Ae([v("uint16")],ve.prototype,"maxPoints",2),Ae([v("uint16")],ve.prototype,"maxContours",2),Ae([v("uint16")],ve.prototype,"maxComponentPoints",2),Ae([v("uint16")],ve.prototype,"maxComponentContours",2),Ae([v("uint16")],ve.prototype,"maxZones",2),Ae([v("uint16")],ve.prototype,"maxTwilightPoints",2),Ae([v("uint16")],ve.prototype,"maxStorage",2),Ae([v("uint16")],ve.prototype,"maxFunctionDefs",2),Ae([v("uint16")],ve.prototype,"maxInstructionDefs",2),Ae([v("uint16")],ve.prototype,"maxStackElements",2),Ae([v("uint16")],ve.prototype,"maxSizeOfInstructions",2),Ae([v("uint16")],ve.prototype,"maxComponentElements",2),Ae([v("uint16")],ve.prototype,"maxComponentDepth",2),ve=Ae([be("maxp")],ve);var Id=Object.defineProperty,Rd=Object.getOwnPropertyDescriptor,Yi=(s,e,t,r)=>{for(var i=r>1?void 0:r?Rd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Id(e,t,i),i};const cl={0:"copyright",1:"fontFamily",2:"fontSubFamily",3:"uniqueSubFamily",4:"fullName",5:"version",6:"postScriptName",7:"tradeMark",8:"manufacturer",9:"designer",10:"description",11:"urlOfFontVendor",12:"urlOfFontDesigner",13:"licence",14:"urlOfLicence",16:"preferredFamily",17:"preferredSubFamily",18:"compatibleFull",19:"sampleText"},Pn={Macintosh:1,Microsoft:3},Ud={Default:0},hl={UCS2:1};let wr=class extends Me{_names;get names(){return this._names??=this.readNames()}readNames(){const s=this.count;this.view.seek(6);const e=[];for(let a=0;a<s;++a)e.push({platform:this.view.readUint16(),encoding:this.view.readUint16(),language:this.view.readUint16(),nameId:this.view.readUint16(),length:this.view.readUint16(),offset:this.view.readUint16()});const t=this.stringOffset;for(let a=0;a<s;++a){const l=e[a];l.name=this.view.readBytes(t+l.offset,l.length)}let r=Pn.Macintosh,i=Ud.Default,n=0;e.some(a=>a.platform===Pn.Microsoft&&a.encoding===hl.UCS2&&a.language===1033)&&(r=Pn.Microsoft,i=hl.UCS2,n=1033);const o={};for(let a=0;a<s;++a){const l=e[a];l.platform===r&&l.encoding===i&&l.language===n&&cl[l.nameId]&&(o[cl[l.nameId]]=n===0?Vf(l.name):Gf(l.name))}return o}};Yi([v("uint16")],wr.prototype,"format",2),Yi([v("uint16")],wr.prototype,"count",2),Yi([v("uint16")],wr.prototype,"stringOffset",2),wr=Yi([be("name")],wr);var Bd=Object.defineProperty,Ld=Object.getOwnPropertyDescriptor,q=(s,e,t,r)=>{for(var i=r>1?void 0:r?Ld(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Bd(e,t,i),i};let W=class extends Me{get fontPANOSE(){return[this.bFamilyType,this.bSerifStyle,this.bWeight,this.bProportion,this.bContrast,this.bStrokeVariation,this.bArmStyle,this.bLetterform,this.bMidline,this.bXHeight]}};q([v("uint16")],W.prototype,"version",2),q([v("int16")],W.prototype,"xAvgCharWidth",2),q([v("uint16")],W.prototype,"usWeightClass",2),q([v("uint16")],W.prototype,"usWidthClass",2),q([v("uint16")],W.prototype,"fsType",2),q([v("uint16")],W.prototype,"ySubscriptXSize",2),q([v("uint16")],W.prototype,"ySubscriptYSize",2),q([v("uint16")],W.prototype,"ySubscriptXOffset",2),q([v("uint16")],W.prototype,"ySubscriptYOffset",2),q([v("uint16")],W.prototype,"ySuperscriptXSize",2),q([v("uint16")],W.prototype,"ySuperscriptYSize",2),q([v("uint16")],W.prototype,"ySuperscriptXOffset",2),q([v("uint16")],W.prototype,"ySuperscriptYOffset",2),q([v("uint16")],W.prototype,"yStrikeoutSize",2),q([v("uint16")],W.prototype,"yStrikeoutPosition",2),q([v("uint16")],W.prototype,"sFamilyClass",2),q([v({type:"uint8"})],W.prototype,"bFamilyType",2),q([v({type:"uint8"})],W.prototype,"bSerifStyle",2),q([v({type:"uint8"})],W.prototype,"bWeight",2),q([v({type:"uint8"})],W.prototype,"bProportion",2),q([v({type:"uint8"})],W.prototype,"bContrast",2),q([v({type:"uint8"})],W.prototype,"bStrokeVariation",2),q([v({type:"uint8"})],W.prototype,"bArmStyle",2),q([v({type:"uint8"})],W.prototype,"bLetterform",2),q([v({type:"uint8"})],W.prototype,"bMidline",2),q([v({type:"uint8"})],W.prototype,"bXHeight",2),q([v({type:"uint8",size:16})],W.prototype,"ulUnicodeRange",2),q([v({type:"char",size:4})],W.prototype,"achVendID",2),q([v("uint16")],W.prototype,"fsSelection",2),q([v("uint16")],W.prototype,"usFirstCharIndex",2),q([v("uint16")],W.prototype,"usLastCharIndex",2),q([v("int16")],W.prototype,"sTypoAscender",2),q([v("int16")],W.prototype,"sTypoDescender",2),q([v("int16")],W.prototype,"sTypoLineGap",2),q([v("uint16")],W.prototype,"usWinAscent",2),q([v("uint16")],W.prototype,"usWinDescent",2),q([v({offset:72,type:"uint8",size:8})],W.prototype,"ulCodePageRange",2),q([v({offset:72,type:"int16"})],W.prototype,"sxHeight",2),q([v("int16")],W.prototype,"sCapHeight",2),q([v("uint16")],W.prototype,"usDefaultChar",2),q([v("uint16")],W.prototype,"usBreakChar",2),q([v("uint16")],W.prototype,"usMaxContext",2),W=q([be("OS/2","os2")],W);var Fd=Object.defineProperty,Nd=Object.getOwnPropertyDescriptor,mt=(s,e,t,r)=>{for(var i=r>1?void 0:r?Nd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Fd(e,t,i),i};let Ye=class extends Me{constructor(s=new ArrayBuffer(32),e,t){super(s,e,t)}};mt([v("fixed")],Ye.prototype,"format",2),mt([v("fixed")],Ye.prototype,"italicAngle",2),mt([v("int16")],Ye.prototype,"underlinePosition",2),mt([v("int16")],Ye.prototype,"underlineThickness",2),mt([v("uint32")],Ye.prototype,"isFixedPitch",2),mt([v("uint32")],Ye.prototype,"minMemType42",2),mt([v("uint32")],Ye.prototype,"maxMemType42",2),mt([v("uint32")],Ye.prototype,"minMemType1",2),mt([v("uint32")],Ye.prototype,"maxMemType1",2),Ye=mt([be("post")],Ye);var $d=Object.defineProperty,zd=Object.getOwnPropertyDescriptor,Ue=(s,e,t,r)=>{for(var i=r>1?void 0:r?zd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&$d(e,t,i),i};let xe=class extends Me{constructor(s=new ArrayBuffer(36),e){super(s,e,Math.min(36,s.byteLength-(e??0)))}};Ue([v("fixed")],xe.prototype,"version",2),Ue([v("int16")],xe.prototype,"vertTypoAscender",2),Ue([v("int16")],xe.prototype,"vertTypoDescender",2),Ue([v("int16")],xe.prototype,"vertTypoLineGap",2),Ue([v("int16")],xe.prototype,"advanceHeightMax",2),Ue([v("int16")],xe.prototype,"minTopSideBearing",2),Ue([v("int16")],xe.prototype,"minBottomSideBearing",2),Ue([v("int16")],xe.prototype,"yMaxExtent",2),Ue([v("int16")],xe.prototype,"caretSlopeRise",2),Ue([v("int16")],xe.prototype,"caretSlopeRun",2),Ue([v("int16")],xe.prototype,"caretOffset",2),Ue([v({type:"int16",size:4})],xe.prototype,"reserved",2),Ue([v("int16")],xe.prototype,"metricDataFormat",2),Ue([v("int16")],xe.prototype,"numOfLongVerMetrics",2),xe=Ue([be("vhea")],xe);var Vd=Object.getOwnPropertyDescriptor,Gd=(s,e,t,r)=>{for(var i=r>1?void 0:r?Vd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};let Ki=class extends Me{static from(s){const e=s.length*4,t=new Ki(new ArrayBuffer(e));return s.forEach(r=>{t.view.writeUint16(r.advanceHeight),t.view.writeInt16(r.topSideBearing)}),t}_metrics;get metrics(){return this._metrics??=this.readMetrics()}readMetrics(){const s=this._sfnt.maxp.numGlyphs,e=this._sfnt.vhea?.numOfLongVerMetrics??0,t=this.view;t.seek(0);let r=0;return Array.from({length:s}).map((i,n)=>(n<e&&(r=t.readUint16()),{advanceHeight:r,topSideBearing:t.readUint8()}))}};Ki=Gd([be("vmtx")],Ki);var jd=Object.defineProperty,ti=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&jd(e,t,i),i};class it extends Ni{format="TrueType";mimeType="font/ttf";_sfnt;get sfnt(){return this._sfnt||(this._sfnt=this.createSFNT()),this._sfnt}static signature=new Set([65536,1953658213,1954115633]);static is(e){return typeof e=="number"?this.signature.has(e):this.signature.has(yr(e).getUint32(0))}static checksum(e){const t=yr(e);let r=t.byteLength;for(;r%4;)r++;let i=0;for(let n=0,o=r/4;n<o;n+=4)n*4<r-4&&(i+=t.getUint32(n*4,!1));return i&4294967295}static from(e){const t=u=>u+3&-4,r=e.tableViews.size,i=Array.from(e.tableViews.values()).reduce((u,d)=>u+t(d.byteLength),0),n=new this(new ArrayBuffer(12+r*16+i));n.scalerType=65536,n.numTables=r;const o=Math.log(2);n.searchRange=Math.floor(Math.log(r)/o)*16,n.entrySelector=Math.floor(n.searchRange/o),n.rangeShift=r*16-n.searchRange;let a=12+r*16,l=0;const c=n.getDirectories();e.tableViews.forEach((u,d)=>{const g=c[l++];g.tag=d,g.checkSum=this.checksum(u),g.offset=a,g.length=u.byteLength,n.view.writeBytes(u,a),a+=t(g.length)});const h=n.createSFNT().head;return h.checkSumAdjustment=0,h.checkSumAdjustment=2981146554-this.checksum(n.view),n}getDirectories(){let e=this.view.byteOffset+12;return Array.from({length:this.numTables},()=>{const t=new vr(this.view.buffer,e);return e+=t.view.byteLength,t})}createSFNT(){return new gt(this.getDirectories().reduce((e,t)=>(e[t.tag]=new DataView(this.view.buffer,this.view.byteOffset+t.offset,t.length),e),{}))}}ti([v("uint32")],it.prototype,"scalerType"),ti([v("uint16")],it.prototype,"numTables"),ti([v("uint16")],it.prototype,"searchRange"),ti([v("uint16")],it.prototype,"entrySelector"),ti([v("uint16")],it.prototype,"rangeShift");class Cn extends it{format="OpenType";mimeType="font/otf";static signature=new Set([1330926671]);static from(e){return super.from(e)}}var Wd=Object.defineProperty,ri=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Wd(e,t,i),i};class Qt extends We{constructor(e,t){super(e,t,20)}}ri([v({type:"char",size:4})],Qt.prototype,"tag"),ri([v("uint32")],Qt.prototype,"offset"),ri([v("uint32")],Qt.prototype,"compLength"),ri([v("uint32")],Qt.prototype,"origLength"),ri([v("uint32")],Qt.prototype,"origChecksum");var qd=Object.defineProperty,qe=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&qd(e,t,i),i};const Ne=class Qn extends Ni{format="WOFF";mimeType="font/woff";get subfontFormat(){return it.is(this.flavor)?"TrueType":Cn.is(this.flavor)?"OpenType":"Open"}_sfnt;get sfnt(){return this._sfnt||(this._sfnt=this.createSFNT()),this._sfnt}static signature=new Set([2001684038]);static is(e){return typeof e=="number"?this.signature.has(e):this.signature.has(yr(e).getUint32(0))}static checkSum(e){const t=yr(e),r=t.byteLength,i=Math.floor(r/4);let n=0,o=0;for(;o<i;)n+=t.getUint32(4*o++,!1);let a=r-i*4;if(a){let l=i*4;for(;a>0;)n+=t.getUint8(l)<<a*8,l++,a--}return n%4294967296}static from(e,t=new ArrayBuffer(0)){const r=u=>u+3&-4,i=[];e.tableViews.forEach((u,d)=>{const g=yr(Uf(new Uint8Array(u.buffer,u.byteOffset,u.byteLength)));i.push({tag:d,view:g.byteLength<u.byteLength?g:u,rawView:u})});const n=i.length,o=i.reduce((u,d)=>u+r(d.view.byteLength),0),a=new Qn(new ArrayBuffer(44+20*n+o+t.byteLength));a.signature=2001684038,a.flavor=65536,a.length=a.view.byteLength,a.numTables=n,a.totalSFNTSize=12+16*n+i.reduce((u,d)=>u+r(d.rawView.byteLength),0);let l=44+n*20,c=0;const h=a.getDirectories();return i.forEach(u=>{const d=h[c++];d.tag=u.tag,d.offset=l,d.compLength=u.view.byteLength,d.origChecksum=Qn.checkSum(u.rawView),d.origLength=u.rawView.byteLength,a.view.writeBytes(u.view,l),l+=r(d.compLength)}),a.view.writeBytes(t),a}getDirectories(){let e=44;return Array.from({length:this.numTables},()=>{const t=new Qt(this.view.buffer,e);return e+=t.view.byteLength,t})}createSFNT(){return new gt(this.getDirectories().reduce((e,t)=>{const r=t.tag,i=this.view.byteOffset+t.offset,n=t.compLength,o=t.origLength,a=i+n;return e[r]=n>=o?new DataView(this.view.buffer,i,n):new DataView(Bf(new Uint8Array(this.view.buffer.slice(i,a))).buffer),e},{}))}};qe([v("uint32")],Ne.prototype,"signature"),qe([v("uint32")],Ne.prototype,"flavor"),qe([v("uint32")],Ne.prototype,"length"),qe([v("uint16")],Ne.prototype,"numTables"),qe([v("uint16")],Ne.prototype,"reserved"),qe([v("uint32")],Ne.prototype,"totalSFNTSize"),qe([v("uint16")],Ne.prototype,"majorVersion"),qe([v("uint16")],Ne.prototype,"minorVersion"),qe([v("uint32")],Ne.prototype,"metaOffset"),qe([v("uint32")],Ne.prototype,"metaLength"),qe([v("uint32")],Ne.prototype,"metaOrigLength"),qe([v("uint32")],Ne.prototype,"privOffset"),qe([v("uint32")],Ne.prototype,"privLength");let Zi=Ne;function ul(s,e=!0){if(it.is(s))return new it(s);if(Cn.is(s))return new Cn(s);if(Zi.is(s))return new Zi(s);if(e)throw new Error("Failed to parseFont")}function fl(s,e=!0){const t=ul(s,!1);if(t)return t;if(e)throw new Error("Failed to parseFont")}class Ji{static defaultRequestInit={cache:"force-cache"};fallbackFont;loading=new Map;loaded=new Map;familyToUrl=new Map;setFallbackFont(e){this.fallbackFont=e}async loadFallbackFont(e,t={}){this.fallbackFont=await this.load(e,t)}_createRequest(e,t){const r=new AbortController;return{url:e,when:fetch(e,{...Ji.defaultRequestInit,...t,signal:r.signal}).then(i=>i.arrayBuffer()),cancel:()=>r.abort()}}injectFontFace(e,t){return document.fonts.check(`14px ${e}`)||document.fonts.add(new FontFace(e,t)),this}injectStyleTag(e,t){const r=CSS.escape(e);if(!document.querySelector(`style[data-family="${r}"]`)){const i=document.createElement("style");i.type="text/css",i.dataset.family=e,i.appendChild(document.createTextNode(`@font-face {
|
|
149
149
|
font-family: "${e}";
|
|
150
150
|
src: url(${t});
|
|
151
151
|
}`)),document.head.appendChild(i)}return this}_parseUrls(e){const t=Array.from(new Set([...e.split(","),e]));return Array.from(new Set(t.map(r=>this.familyToUrl.get(r.trim())??this.familyToUrl.get(r)??r)))}get(e){let t;return e&&(t=this._parseUrls(e).reduce((i,n)=>i||this.loaded.get(n),void 0)),t??this.fallbackFont}set(e,t){return this.familyToUrl.set(e,t.src),this.loaded.set(t.src,t),this}delete(e){return this._parseUrls(e).forEach(t=>{this.familyToUrl.delete(t),this.loaded.delete(t)}),this}clear(){return this.familyToUrl.clear(),this.loading.clear(),this.loaded.clear(),this}_parseFamilies(e){return e?(Array.isArray(e)?e:[e]).flatMap(t=>t.split(",").map(r=>r.trim())):[]}async load(e,t={}){const{cancelOther:r,injectFontFace:i=!0,injectStyleTag:n=!0,...o}=t;let a,l;typeof e=="string"?a=e:{src:a,family:l}=e;const c=this._parseFamilies(l);if(this.loaded.has(a))return r&&(this.loading.forEach(g=>g.cancel()),this.loading.clear()),u(this.loaded.get(a));let h=this.loading.get(a);return h||(h=this._createRequest(a,o),this.loading.set(a,h)),r&&this.loading.forEach((g,p)=>{g!==h&&(g.cancel(),this.loading.delete(p))}),h.when.then(g=>{let p;return this.loaded.has(a)?p=u(this.loaded.get(a)):(p=d(g),t.noAdd||this.loaded.set(a,p)),Promise.all(Array.from(p.familySet).map(y=>(this.familyToUrl.set(y,a),typeof document<"u"&&(i&&this.injectFontFace(y,g),n&&this.injectStyleTag(y,a),i||n)?document.fonts.load(`14px ${y}`):Promise.resolve()))).then(()=>p)}).catch(g=>{if(g instanceof DOMException&&g.message==="The user aborted a request.")return d();throw g}).finally(()=>{this.loading.delete(a)});function u(g){return c.forEach(p=>{g.familySet.add(p)}),g}function d(g=new ArrayBuffer(0)){let p;function y(){return p||(p=g.byteLength?fl(g,!1):void 0),p}function m(){const P=y();if(P instanceof it||P instanceof Zi)return P.sfnt}return{src:a,family:l,buffer:g,familySet:new Set(c),getFont:y,getSFNT:m}}}async waitUntilLoad(){await Promise.all(Array.from(this.loading.values()).map(e=>e.when))}}const Tn=new Ji,Xd=Object.freeze(Object.defineProperty({__proto__:null,BaseFont:Ni,get Cff(){return Yt},get Cmap(){return br},CmapSubtableFormat0:pn,CmapSubtableFormat12:vn,CmapSubtableFormat14:ei,CmapSubtableFormat2:Zr,CmapSubtableFormat4:yn,CmapSubtableFormat6:Zt,FontDataObject:We,FontDataView:me,Fonts:Ji,get Glyf(){return qi},Glyph:un,GlyphSet:fn,get Gpos(){return wn},get Gsub(){return At},get Head(){return ue},get Hhea(){return we},get Hmtx(){return Xi},get Kern(){return xn},get Loca(){return Hi},get Maxp(){return ve},get Name(){return wr},get Os2(){return W},get Post(){return Ye},SFNT:gt,TTF:it,TableDirectory:vr,get Vhea(){return xe},get Vmtx(){return Ki},WOFF:Zi,WOFFTableDirectoryEntry:Qt,createCmapSegments:mn,dataTypeToByteLength:Hr,defineColumn:v,defineSFNTTable:be,fonts:Tn,parseFont:fl,parseSFNTFont:ul},Symbol.toStringTag,{value:"Module"}));class Hd{currentCall;calls=[];createCall(e){return{renderable:e,parentCall:this.currentCall,fn:e.render.bind(e),calls:[]}}push(e){const t=this.createCall(e);return(this.currentCall?.calls??this.calls).push(t),t}render(e){this.calls.forEach(function t(r){r.fn(e,()=>{r.calls.forEach(t)})}),this.calls=[]}}var Yd=Object.defineProperty,Kd=Object.getOwnPropertyDescriptor,ii=(s,e,t,r)=>{for(var i=r>1?void 0:r?Kd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Yd(e,t,i),i};f.Timeline=class extends f.Node{static from(e,t=!1){const[r,i]=e?Array.isArray(e)?e:[0,e]:[];return new f.Timeline({startTime:r,endTime:i,loop:t})}constructor(e){super(),this.setProperties(e)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"startTime":this.startTime=Math.min(t,this.endTime);break;case"endTime":this.endTime=t||Number.MAX_SAFE_INTEGER;break}}addTime(e){const t=this.startTime,r=this.endTime;let i=this.currentTime;return i=i+e,this.loop&&i>r&&(i=t+i%r),i=ut(i,t,r),this.currentTime=i,this.emit("updateCurrentTime",i,e),this}_process(e){super._process(e),this.addTime(e)}},ii([_({fallback:0})],f.Timeline.prototype,"startTime",2),ii([_({fallback:0})],f.Timeline.prototype,"currentTime",2),ii([_({fallback:Number.MAX_SAFE_INTEGER})],f.Timeline.prototype,"endTime",2),ii([_({fallback:!1})],f.Timeline.prototype,"loop",2),f.Timeline=ii([X("Timeline")],f.Timeline);var Zd=Object.defineProperty,Jd=Object.getOwnPropertyDescriptor,dl=(s,e,t,r)=>{for(var i=r>1?void 0:r?Jd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Zd(e,t,i),i};f.Window=class extends f.Viewport{},dl([_({fallback:!1})],f.Window.prototype,"msaa",2),f.Window=dl([X("Window")],f.Window);var Qd=Object.defineProperty,si=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Qd(e,t,i),i};class er extends Ci{input=new jo;renderStack=new Hd;root=new f.Window(!0).setTree(this);_backgroundColor=new Qe;_currentViewport;getCurrentViewport(){return this._currentViewport}setCurrentViewport(e){this._currentViewport=e}constructor(e){super(),this.setProperties(e)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"backgroundColor":this._backgroundColor.value=t;break;case"timeline":this.timeline.setTree(this);break}}log(...e){this.debug&&console.log(`[modern-canvas][${performance.now().toFixed(4)}ms]`,...e)}_process(e=0){this.timeline.emit("process",e),this.emit("processing"),this.root.emit("process",e),this.emit("processed")}_render(e){this.emit("rendering"),this.renderStack.render(e),this._renderScreen(e),this.emit("rendered")}_renderScreen(e){this.root.msaa&&e.framebuffer.finishRenderPass(this.root._glFramebuffer(e)),e.state.reset(),e.framebuffer.bind(null),e.gl.bindFramebuffer(e.gl.FRAMEBUFFER,null),e.viewport.bind({x:0,y:0,width:this.root.width*e.pixelRatio,height:this.root.height*e.pixelRatio}),this.backgroundColor&&e.gl.clearColor(...this._backgroundColor.toArray()),e.clear(),this.backgroundColor&&e.gl.clearColor(0,0,0,0);const t=this.root.texture;t.activate(e,0),Q.draw(e),e.texture.unbind(t)}destroy(){this.root.destroy(),this.input.destroy(),super.destroy()}}si([_()],er.prototype,"backgroundColor"),si([_({internal:!0,fallback:!1})],er.prototype,"debug"),si([_({internal:!0,fallback:!1})],er.prototype,"processPaused"),si([_({internal:!0,default:()=>Tn})],er.prototype,"fonts"),si([_({internal:!0,default:()=>new f.Timeline})],er.prototype,"timeline");var ep=Object.getOwnPropertyDescriptor,tp=(s,e,t,r)=>{for(var i=r>1?void 0:r?ep(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};f.Transition=class extends f.Effect{constructor(e,t=[]){super(),this.setProperties(e).append(t)}},f.Transition=tp([X("Transition",{effectMode:"transition",processMode:"pausable",duration:2e3})],f.Transition);var rp=Object.defineProperty,ip=Object.getOwnPropertyDescriptor,Sn=(s,e,t,r)=>{for(var i=r>1?void 0:r?ip(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&rp(e,t,i),i};f.Node2D=class extends f.CanvasItem{position=new de().on("update",()=>this.updateGlobalTransform());scale=new de(1,1).on("update",()=>this.updateGlobalTransform());skew=new de().on("update",()=>this.updateGlobalTransform());transform=new ke;globalPosition=new de;globalScale=new de;globalSkew=new de;globalTransform=new ke;_parentTransformDirtyId;constructor(e,t=[]){super(),this.setProperties(e).append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"rotation":this.updateGlobalTransform();break}}getTransformOrigin(){return new de(0,0)}updateTransform(e){const t=this.getTransformOrigin(),r=this.transform.identity().translate(-t.x,-t.y).scale(this.scale.x,this.scale.y).skew(this.skew.x,this.skew.y).rotate(this.rotation);e?.(r),r.translate(this.position.x,this.position.y).translate(t.x,t.y)}updateGlobalTransform(){this.updateTransform();const e=this.getParent();if(e?.globalTransform){const{globalPosition:t,globalScale:r,globalSkew:i,globalTransform:n,globalRotation:o}=e;this._parentTransformDirtyId=n.dirtyId,this.globalPosition.set(t.x+this.position.x,t.y+this.position.y),this.globalScale.set(r.x*this.scale.x,r.y*this.scale.y),this.globalSkew.set(i.x*this.skew.x,i.y*this.skew.y),this.globalRotation=o+this.rotation,e.globalTransform.multiply(this.transform,this.globalTransform)}else this.globalPosition.copy(this.position),this.globalScale.copy(this.scale),this.globalSkew.copy(this.skew),this.globalRotation=this.rotation,this.globalTransform.copy(this.transform);this.requestRelayout()}_transformVertices(e,t){let r,i,n,o,a,l;if(t){const h=this.globalTransform.clone();h.multiply(t),[r,i,n,o,a,l]=h.toArray()}else[r,i,n,o,a,l]=this.globalTransform.toArray();const c=e.slice();for(let h=e.length,u=0;u<h;u+=2){const d=e[u],g=e[u+1];c[u]=r*d+i*g+n,c[u+1]=o*d+a*g+l}return c}_relayout(e){return e=super._relayout(e),this.updateGlobalTransform(),e.map(t=>({...t,vertices:this._transformVertices(t.vertices,t.vertTransform)}))}_process(e){super._process(e);const t=this.getParent();t?.globalTransform&&this._parentTransformDirtyId!==t?.globalTransform?.dirtyId&&this.requestRelayout()}toLocal(e,t){return this.globalTransform.applyAffineInverse(e,t)}toGlobal(e,t){return this.globalTransform.apply(e,t)}},Sn([_({internal:!0,fallback:0})],f.Node2D.prototype,"rotation",2),Sn([_({internal:!0,fallback:0})],f.Node2D.prototype,"globalRotation",2),f.Node2D=Sn([X("Node2D")],f.Node2D);var sp=Object.defineProperty,np=Object.getOwnPropertyDescriptor,Qi=(s,e,t,r)=>{for(var i=r>1?void 0:r?np(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&sp(e,t,i),i};f.Camera2D=class extends f.Node2D{_screenOffset={x:0,y:0};_zoom=new de(1,1).on("update",()=>this.updateCanvasTransform());get zoom(){return this._zoom}set zoom(e){this._zoom.set(e.x,e.y)}_minZoom=new de(.02,.02);get minZoom(){return this._minZoom}set minZoom(e){this._minZoom.set(e.x,e.y)}_maxZoom=new de(256,256);get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom.set(e.x,e.y)}constructor(e,t=[]){super(),this.setProperties(e).append(t)}setProperties(e){if(e){const{zoom:t,minZoom:r,maxZoom:i,...n}=e;t&&(this.zoom=t),r&&(this.minZoom=r),i&&(this.maxZoom=i),super.setProperties(n)}return this}addZoom(e,t=e){return this.setZoom(this._zoom.x+e,this._zoom.y+t)}setZoom(e,t=e){return this._zoom.set(ut(e,this._minZoom.x,this._maxZoom.x),ut(t,this._minZoom.y,this._maxZoom.y)),this}_input(e,t){if(super._input(e,t),t==="keydown"){const r=e;!this.spaceKey&&r.code==="Space"&&(r.cursor="grab",this.spaceKey=!0)}else if(t==="keyup"){const r=e;r.code==="Space"&&(r.cursor="default",this.spaceKey=!1,this.grabbing=!1)}else if(t==="pointerdown"){const r=e;!this.grabbing&&(this.spaceKey||r.button===1)&&(this.grabbing=!0,r.cursor="grabbing",this._screenOffset={x:r.screenX,y:r.screenY})}else if(t==="pointermove"){const r=e;this.grabbing&&(this.position.add(-(this._screenOffset.x-r.screenX),-(this._screenOffset.y-r.screenY)),this._screenOffset={x:r.screenX,y:r.screenY})}else if(t==="pointerup"){const r=e;this.grabbing&&(this.grabbing=!1,this.spaceKey?r.cursor="grab":r.cursor="default")}else t==="wheel"&&this._onWheel(e)}_onWheel(e){if(e.ctrlKey){if(!(e.wheelDeltaY?Math.abs(Math.abs(e.wheelDeltaY)-Math.abs(3*e.deltaY))<3:e.deltaMode===0)){e.preventDefault();const r=this._zoom.x;this.zoomWithWheel(e.deltaY);const i=1-this._zoom.x/r;this.position.add((e.screenX-this.position.x)*i,(e.screenY-this.position.y)*i)}}else e.preventDefault(),this.position.add(-e.deltaX,-e.deltaY)}zoomWithWheel(e){const t=Math.log(this._zoom.x),r=-e*this.wheelSensitivity,i=t+r;this.setZoom(Math.exp(i))}updateTransform(){super.updateTransform(),this.updateCanvasTransform()}updateCanvasTransform(){const e=this.getViewport();e&&(e.canvasTransform.identity().scale(this._zoom.x,this._zoom.y).translate(this.position.x,this.position.y),this.emit("updateCanvasTransform"))}toGlobal(e,t){const r=this.getViewport();if(!r)throw new Error("Failed to toGlobal, viewport is empty");return r.toCanvasGlobal(e,t)}toScreen(e,t){const r=this.getViewport();if(!r)throw new Error("Failed to toScreen, viewport is empty");return r.toCanvasScreen(e,t)}toJSON(){return{zoom:this._zoom.toJSON(),minZoom:this._minZoom.toJSON(),maxZoom:this._maxZoom.toJSON(),...super.toJSON()}}},Qi([_({fallback:.02})],f.Camera2D.prototype,"wheelSensitivity",2),Qi([_({internal:!0,fallback:!1})],f.Camera2D.prototype,"spaceKey",2),Qi([_({internal:!0,fallback:!1})],f.Camera2D.prototype,"grabbing",2),f.Camera2D=Qi([X("Camera2D",{processMode:"disabled",renderMode:"disabled"})],f.Camera2D);const pl={brightness:1,contrast:1,grayscale:0,"hue-rotate":0,invert:0,opacity:1,saturate:1,sepia:0};function op(s){const e=new Us;if(s==="none")return e;const t=kr(s).reduce((r,{name:i,args:n})=>(r[i]=n[0].normalizedIntValue,r),{});Object.keys(pl).forEach(r=>{t[r]=t[r]??pl[r]});for(const r in t){const i=t[r];switch(r){case"hue-rotate":e.hueRotate(i*Fe);break;case"saturate":e.saturate(i);break;case"brightness":e.brightness(i);break;case"contrast":e.contrast(i);break;case"invert":e.invert(i);break;case"sepia":e.sepia(i);break;case"opacity":e.opacity(i);break;case"grayscale":e.grayscale(i);break}}return e}function gl(s,e,t,r=new ke){return s=!s||s==="none"?"":s,kr(s,{width:e,height:t}).reverse().forEach(({name:i,args:n})=>{const o=n.map(a=>a.normalizedIntValue);switch(i){case"translate":r.translate(o[0]*e,(o[1]??o[0])*t);break;case"translateX":r.translateX(o[0]*e);break;case"translateY":r.translateY(o[0]*t);break;case"translateZ":r.translateZ(o[0]);break;case"translate3d":r.translate3d(o[0]*e,(o[1]??o[0])*t,o[2]??o[1]??o[0]);break;case"scale":r.scale(o[0],o[1]??o[0]);break;case"scaleX":r.scaleX(o[0]);break;case"scaleY":r.scaleY(o[0]);break;case"scale3d":r.scale3d(o[0],o[1]??o[0],o[2]??o[1]??o[0]);break;case"rotate":r.rotate(o[0]*Fe);break;case"rotateX":r.rotateX(o[0]*Fe);break;case"rotateY":r.rotateY(o[0]*Fe);break;case"rotateZ":r.rotateZ(o[0]*Fe);break;case"rotate3d":r.rotate3d(o[0]*Fe,(o[1]??o[0])*Fe,(o[2]??o[1]??o[0])*Fe,(o[3]??o[2]??o[1]??o[0])*Fe);break;case"skew":r.skew(o[0],o[0]??o[1]);break;case"skewX":r.skewX(o[0]);break;case"skewY":r.skewY(o[0]);break;case"matrix":r.set(o);break}}),r}function ml(s){const[e,t=e]=s.split(" ");return[e,t].map(r=>{switch(r=r.trim(),r){case"left":case"top":return 0;case"center":return .5;case"right":case"bottom":return 1;default:return Number(r)}})}var yl=Object.defineProperty,ap=Object.getOwnPropertyDescriptor,lp=(s,e,t)=>e in s?yl(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Ot=(s,e,t,r)=>{for(var i=r>1?void 0:r?ap(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&yl(e,t,i),i},cp=(s,e,t)=>lp(s,e+"",t);f.ColorAdjustEffect=class extends f.Effect{constructor(e,t=[]){super(),this.setProperties(e).append(t)}apply(e,t){t.redraw(e,()=>{Q.draw(e,f.ColorAdjustEffect.material,{sampler:0,saturation:this.saturation,contrast:this.contrast,brightness:this.brightness,red:this.red,green:this.green,blue:this.blue,alpha:this.alpha,gamma:Math.max(this.gamma??1,1e-4)})})}},cp(f.ColorAdjustEffect,"material",new re({vert:`precision mediump float;
|
|
@@ -954,7 +954,7 @@ void main() {
|
|
|
954
954
|
gl_FragColor = color;
|
|
955
955
|
}`})),ai([_()],f.ZoomBlurEffect.prototype,"center",2),ai([_({fallback:20})],f.ZoomBlurEffect.prototype,"innerRadius",2),ai([_({fallback:-1})],f.ZoomBlurEffect.prototype,"radius",2),ai([_({fallback:.1})],f.ZoomBlurEffect.prototype,"strength",2),f.ZoomBlurEffect=ai([X("ZoomBlurEffect")],f.ZoomBlurEffect);function rs(s,e){let t=!1;const{left:r=0,top:i=0,width:n,height:o}=e,a=new ke().translate(-r,-i).scale(1/n,1/o);if(s.cropRect){const{left:l=0,top:c=0,right:h=0,bottom:u=0}=s.cropRect;a.scale(Math.abs(1-(l+h)),Math.abs(1-(c+u))).translate(l,c),t=!0}if(s.tile){const{translateX:l=0,translateY:c=0,scaleX:h=1,scaleY:u=1}=s.tile;a.translate(-l/n,-c/o).scale(1/h,1/u),t=!0}else if(s.stretchRect){const{left:l=0,top:c=0,right:h=0,bottom:u=0}=s.stretchRect;a.scale(Math.abs(1-(-l+-h)),Math.abs(1-(-c+-u))).translate(-l,-c),t=!0}return{disableWrapMode:t,uvTransform:a}}var eg=Object.defineProperty,st=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&eg(e,t,i),i};class Oe extends xt{constructor(e){super(),this.parent=e}_texture;_animatedTexture;_setProperties(e){return super.setProperties(e)}setProperties(e){return this._setProperties(K(e)?void 0:ct(e))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"color":case"cropRect":case"stretchRect":case"dpi":case"rotateWithShape":case"tile":case"opacity":case"enabled":this.parent.requestRedraw();break;case"image":case"linearGradient":case"radialGradient":this._updateTexture();break}}async loadTexture(){this.linearGradient||this.radialGradient?this._texture=new zr(this.linearGradient??this.radialGradient,this.parent.size.width,this.parent.size.height):K(this.image)||(this.parent.tree?.log(`load image ${this.image}`),this.image.split("?")[0].endsWith(".gif")?this._animatedTexture=await Ke.gif.load(this.image):this._texture=await Ke.texture.load(this.image))}async _updateTexture(){await this.loadTexture(),this.parent.requestRedraw()}isValid(){return!!(this.enabled&&(this._texture||this._animatedTexture||this.color))}draw(){const e=this.parent.context,{uvTransform:t,disableWrapMode:r}=rs(this,{width:this.parent.size.width,height:this.parent.size.height});e.uvTransform=t,e.fillStyle=this._animatedTexture?.currentFrame.texture??this._texture??this.color,e.fill({disableWrapMode:r})}_getFrameCurrentTime(){const e=this._animatedTexture?.duration??0;if(!e)return 0;const t=this.parent._currentTime;return t<0?0:t%e}updateFrameIndex(){if(!this._animatedTexture)return this;const e=this._getFrameCurrentTime(),t=this._animatedTexture.frames,r=t.length;if(r<=1&&this._animatedTexture.frameIndex===0)return this;let i=r-1;for(let n=0,o=0;o<r;o++)if(n+=t[o].duration??0,n>=e){i=o;break}return this._animatedTexture.frameIndex!==i&&(this._animatedTexture.frameIndex=i,this.parent.requestRedraw()),this}}st([_({fallback:!0})],Oe.prototype,"enabled"),st([_()],Oe.prototype,"color"),st([_()],Oe.prototype,"image"),st([_()],Oe.prototype,"linearGradient"),st([_()],Oe.prototype,"radialGradient"),st([_()],Oe.prototype,"cropRect"),st([_()],Oe.prototype,"stretchRect"),st([_()],Oe.prototype,"dpi"),st([_()],Oe.prototype,"rotateWithShape"),st([_()],Oe.prototype,"tile"),st([_()],Oe.prototype,"opacity");var tg=Object.defineProperty,rg=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&tg(e,t,i),i};class Dn extends Oe{setProperties(e){return super._setProperties(K(e)?void 0:Yc(e))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"fillWithShape":this.parent.requestRedraw();break}}}rg([_()],Dn.prototype,"fillWithShape");var ig=Object.defineProperty,sg=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&ig(e,t,i),i};class In extends Oe{setProperties(e){return super._setProperties(K(e)?void 0:Kc(e))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"fillWithShape":this.parent.requestRedraw();break}}}sg([_()],In.prototype,"fillWithShape");var ng=Object.defineProperty,li=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&ng(e,t,i),i};class tr extends Oe{setProperties(e){return super._setProperties(K(e)?void 0:bi(e))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"width":case"style":case"lineCap":case"lineJoin":case"enabled":this.parent.requestRedraw();break}}isValid(){return!!(this.enabled&&(this.width||this.color||super.isValid()))}draw(){const e=this.parent.context,{uvTransform:t,disableWrapMode:r}=rs(this,{width:this.parent.size.width,height:this.parent.size.height});e.lineWidth=this.width||1,e.uvTransform=t,e.strokeStyle=this._texture??this.color,e.lineCap=this.lineCap,e.lineJoin=this.lineJoin,e.stroke({disableWrapMode:r})}}li([_({fallback:"#00000000"})],tr.prototype,"color"),li([_({fallback:0})],tr.prototype,"width"),li([_({fallback:"solid"})],tr.prototype,"style"),li([_({fallback:"butt"})],tr.prototype,"lineCap"),li([_({fallback:"miter"})],tr.prototype,"lineJoin");var og=Object.defineProperty,ci=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&og(e,t,i),i};class rr extends xt{constructor(e){super(),this.parent=e}setProperties(e){return super.setProperties(K(e)?void 0:Zc(e))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"color":case"blur":case"offsetX":case"offsetY":this.updateEffect();break}}updateEffect(){const e="__$shadow";let t=this.parent.getNode(e);this.blur||this.offsetX||this.offsetY?(t||(t=new f.DropShadowEffect({name:e}),this.parent.appendChild(t,"back")),t.setProperties(this.getProperties())):t&&this.parent.removeChild(t)}}ci([_({fallback:!0})],rr.prototype,"enabled"),ci([_({fallback:"#000000FF"})],rr.prototype,"color"),ci([_({fallback:0})],rr.prototype,"blur"),ci([_({fallback:0})],rr.prototype,"offsetY"),ci([_({fallback:0})],rr.prototype,"offsetX");var ag=Object.defineProperty,hi=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&ag(e,t,i),i};class ir extends xt{constructor(e){super(),this.parent=e,this._updatePath2DSet()}_path2DSet=new Tt;setProperties(e){return super.setProperties(K(e)?void 0:Qc(e))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"svg":case"paths":case"viewBox":case"enabled":this._updatePath2DSet(),this.parent.requestRedraw();break}}_updatePath2DSet(){let e;if(this.svg){const o=Gs(this.svg);this._path2DSet=Ws(o),e=this._path2DSet.viewBox}else this.paths?.forEach((o,a)=>{const{data:l,...c}=o,h=new ge;h.style=c,h.addData(l),this._path2DSet.paths[a]=h});if(!e){const o=this._path2DSet.getBoundingBox();e=o?[o.x,o.y,o.width||1,o.height||1]:[0,0,1,1]}const[t,r,i,n]=e;this._path2DSet.paths.forEach(o=>{o.applyTransform(new _e().translate(-t,-r).scale(1/i,1/n))})}draw(e=!1){if(!e&&this.enabled&&this._path2DSet.paths.length){const t=this.parent.context,{width:r,height:i}=this.parent.size;this._path2DSet.paths.forEach(n=>{t.addPath(n.clone().applyTransform(new _e().scale(r,i)))})}else this._drawRect()}_drawRect(){const e=this.parent.context,{width:t,height:r}=this.parent.size,{borderRadius:i}=this.parent.style;t&&r&&(i?e.roundRect(0,0,t,r,i):e.rect(0,0,t,r))}}hi([_({fallback:!0})],ir.prototype,"enabled"),hi([_()],ir.prototype,"preset"),hi([_()],ir.prototype,"svg"),hi([_()],ir.prototype,"viewBox"),hi([_()],ir.prototype,"paths");class ui extends Pt{constructor(e){super(),this.setProperties(e)}}const $l=Po();for(const s in $l){const e=$l[s];mi(ui,s,{fallback:e})}function Rn(s,e,t){if(typeof e=="string"&&e.startsWith("linear-gradient")){const{x0:r,y0:i,x1:n,y1:o,stops:a}=lg(e,t.left,t.top,t.width,t.height),l=s.createLinearGradient(r,i,n,o);return a.forEach(c=>l.addColorStop(c.offset,c.color)),l}return e}function is(s,e,t){s?.color&&(s.color=Rn(t,s.color,e)),s?.backgroundColor&&(s.backgroundColor=Rn(t,s.backgroundColor,e)),s?.textStrokeColor&&(s.textStrokeColor=Rn(t,s.textStrokeColor,e))}function lg(s,e,t,r,i){const n=s.match(/linear-gradient\((.+)\)$/)?.[1]??"",o=n.split(",")[0],a=o.includes("deg")?o:"0deg",l=n.replace(a,"").matchAll(/(#|rgba|rgb)(.+?) ([\d.]+%)/gi),h=(Number(a.replace("deg",""))||0)*Math.PI/180,u=r*Math.sin(h),d=i*Math.cos(h);return{x0:e+r/2-u,y0:t+i/2+d,x1:e+r/2+u,y1:t+i/2-d,stops:Array.from(l).map(g=>{let p=g[2];return p.startsWith("(")?p=p.split(",").length>3?`rgba${p}`:`rgb${p}`:p=`#${p}`,{offset:Number(g[3].replace("%",""))/100,color:p}})}}function Pr(s){const{ctx:e,path:t,fontSize:r,clipRect:i}=s;e.save(),e.beginPath();const n=t.style,o={...n,fill:s.color??n.fill,stroke:s.textStrokeColor??n.stroke,strokeWidth:s.textStrokeWidth?s.textStrokeWidth*r:n.strokeWidth,strokeLinecap:"round",strokeLinejoin:"round",shadowOffsetX:(s.shadowOffsetX??0)*r,shadowOffsetY:(s.shadowOffsetY??0)*r,shadowBlur:(s.shadowBlur??0)*r,shadowColor:s.shadowColor};i&&(e.rect(i.left,i.top,i.width,i.height),e.clip(),e.beginPath()),t.drawTo(e,o),e.restore()}function cg(s,e,t){const{left:r,top:i,width:n,height:o}=t,a=s.canvas;a.dataset.viewBox=`${r} ${i} ${n} ${o}`,a.dataset.pixelRatio=String(e);const l=n,c=o;a.width=Math.max(1,Math.ceil(l*e)),a.height=Math.max(1,Math.ceil(c*e)),a.style.width=`${l}px`,a.style.height=`${c}px`,s.clearRect(0,0,a.width,a.height),s.scale(e,e),s.translate(-r,-i)}function hg(s,e){const{paragraphs:t,computedStyle:r,glyphBox:i}=e;is(r,i,s),t.forEach(n=>{is(n.computedStyle,n.lineBox,s),n.fragments.forEach(o=>{is(o.computedStyle,o.inlineBox,s)})})}const ug=new Set(["©","®","÷"]),fg=new Set(["—","…","“","”","﹏","﹋","﹌","‘","’","˜"]),dg={1:"italic",32:"bold"},pg={1:"italic",2:"bold"},zl={100:-.2,200:-.1,300:0,400:0,normal:0,500:.1,600:.2,700:.3,bold:.3,800:.4,900:.5};class Vl{constructor(e,t,r){this.content=e,this.index=t,this.parent=r}path=new ge().setMeta(this);lineBox=new Z;inlineBox=new Z;glyphBox;advanceWidth=0;advanceHeight=0;underlinePosition=0;underlineThickness=0;strikeoutPosition=0;strikeoutSize=0;ascender=0;descender=0;typoAscender=0;typoDescender=0;typoLineGap=0;winAscent=0;winDescent=0;xHeight=0;capHeight=0;baseline=0;centerDiviation=0;fontStyle;get compatibleGlyphBox(){const e=this.computedStyle.fontSize*.8;return this.glyphBox??(this.isVertical?new Z(this.lineBox.left+this.lineBox.width/2-e/2,this.lineBox.top,e,this.lineBox.height):new Z(this.lineBox.left,this.lineBox.top+this.lineBox.height/2-e/2,this.lineBox.width,e))}get center(){return this.compatibleGlyphBox.center}get computedFill(){return this.parent.computedFill}get computedOutline(){return this.parent.computedOutline}get computedStyle(){return this.parent.computedStyle}get isVertical(){return this.computedStyle.writingMode.includes("vertical")}get fontSize(){return this.computedStyle.fontSize}get fontHeight(){return this.fontSize*this.computedStyle.lineHeight}_getFontSFNT(e){const t=this.computedStyle.fontFamily,r=e??Tn;let n=(t?r.get(t):r.fallbackFont)?.getSFNT();return n?.textToGlyphIndexes(this.content).includes(0)&&(n=r.fallbackFont?.getSFNT()),n}updateGlyph(e=this._getFontSFNT()){if(!e)return this;const{hhea:t,os2:r,post:i,head:n}=e,o=n.unitsPerEm,a=t.ascent,l=t.descent,{content:c,computedStyle:h,isVertical:u}=this,{fontSize:d}=h,g=o/d,p=e.getAdvanceWidth(c,d),y=(a+Math.abs(l))/g,m=a/g;return this.advanceWidth=p,this.advanceHeight=y,this.inlineBox.width=u?y:p,this.inlineBox.height=u?p:y,this.underlinePosition=(a-i.underlinePosition)/g,this.underlineThickness=i.underlineThickness/g,this.strikeoutPosition=(a-r.yStrikeoutPosition)/g,this.strikeoutSize=r.yStrikeoutSize/g,this.ascender=a/g,this.descender=l/g,this.typoAscender=r.sTypoAscender/g,this.typoDescender=r.sTypoDescender/g,this.typoLineGap=r.sTypoLineGap/g,this.winAscent=r.usWinAscent/g,this.winDescent=r.usWinDescent/g,this.xHeight=r.sxHeight/g,this.capHeight=r.sCapHeight/g,this.baseline=m,this.centerDiviation=y/2-m,this.fontStyle=dg[r.fsSelection]??pg[n.macStyle],this}update(e){const t=this._getFontSFNT(e);if(!t)return this;this.updateGlyph(t);const{isVertical:r,content:i,computedStyle:n,baseline:o,inlineBox:a,ascender:l,descender:c,typoAscender:h,fontStyle:u,advanceWidth:d,advanceHeight:g}=this,{left:p,top:y}=a,m=n.fontStyle==="italic"&&u!=="italic";let P=p,E=y+o,b;const S=new ge().setMeta(this);if(r&&(P+=(g-d)/2,Math.abs(d-g)>.1&&(E-=(l-h)/(l+Math.abs(c))*g),b=void 0),r&&!ug.has(i)&&(i.codePointAt(0)<=256||fg.has(i))){S.addCommands(t.getPathCommands(i,P,y+o-(g-d)/2,n.fontSize));const x={y:y-(g-d)/2+g/2,x:P+d/2};m&&this._italic(S,r?{x:x.x,y:y-(g-d)/2+o}:void 0),S.rotate(90,x)}else b!==void 0?(S.addCommands(t.glyphs.get(b).getPathCommands(P,E,n.fontSize)),m&&this._italic(S,r?{x:P+d/2,y:y+h/(l+Math.abs(c))*g}:void 0)):(S.addCommands(t.getPathCommands(i,P,E,n.fontSize)),m&&this._italic(S,r?{x:P+g/2,y:E}:void 0));const w=n.fontWeight??400;return w in zl&&(w===700||w==="bold")&&u!=="bold"&&S.bold(zl[w]*n.fontSize*.05),S.style={fill:this.computedFill??n.color,fillRule:"nonzero",stroke:this.computedOutline??(n.textStrokeWidth?n.textStrokeColor:"none"),strokeWidth:n.textStrokeWidth?n.textStrokeWidth*n.fontSize*.03:0},this.path=S,this.glyphBox=this.getGlyphBoundingBox(),this}_italic(e,t){e.skew(-.24,0,t||{y:this.inlineBox.top+this.baseline,x:this.inlineBox.left+this.inlineBox.width/2})}getGlyphMinMax(e,t,r){if(this.path.curves[0]?.curves.length)return this.path.getMinMax(e,t,r)}getGlyphBoundingBox(e){const t=this.getGlyphMinMax(void 0,void 0,e);if(!t)return;const{min:r,max:i}=t;return new Z(r.x,r.y,i.x-r.x,i.y-r.y)}drawTo(e,t={}){const r=this.computedStyle,i={ctx:e,path:this.path,fontSize:r.fontSize,color:r.color,...t};if(this.glyphBox)Pr(i);else{e.save(),e.beginPath();const n=this.path.style,o={...n,fill:i.color??n.fill,stroke:i.textStrokeColor??n.stroke,strokeWidth:i.textStrokeWidth?i.textStrokeWidth*i.fontSize:n.strokeWidth,shadowOffsetX:(i.shadowOffsetX??0)*i.fontSize,shadowOffsetY:(i.shadowOffsetY??0)*i.fontSize,shadowBlur:(i.shadowBlur??0)*i.fontSize,shadowColor:i.shadowColor};zs(e,o),e.font=`${i.fontSize}px ${i.fontFamily}`,this.isVertical?(e.textBaseline="middle",e.fillText(this.content,this.inlineBox.left,this.inlineBox.top+this.inlineBox.height/2)):(e.textBaseline="alphabetic",e.fillText(this.content,this.inlineBox.left,this.inlineBox.top+this.baseline)),e.restore()}}}function Gl(){const s=new Map;async function e(r){if(!s.has(r)){s.set(r,r);try{s.set(r,await fetch(r).then(i=>i.text()))}catch(i){console.warn(i),s.delete(r)}}}function t(r){return r.startsWith("http://")||r.startsWith("https://")||r.startsWith("blob://")}return{loaded:s,needsLoad:t,load:e}}function jl(s){const e=new Map;function t(r){let i=e.get(r);if(!i){const n=Gs(s.needsLoad(r)?s.loaded.get(r)??r:r),o=Ws(n);i={dom:n,pathSet:o},e.set(r,i)}return i}return{parsed:e,parse:t}}function Un(s,e){return typeof s=="number"?s:s.endsWith("%")?(s=s.substring(0,s.length-1),Math.ceil(Number(s)/100*e.total)):s.endsWith("rem")?(s=s.substring(0,s.length-3),Number(s)*e.fontSize):s.endsWith("em")?(s=s.substring(0,s.length-2),Number(s)*e.fontSize):Number(s)}function Bn(s){return K(s)?{}:s}function gg(s,e){const t=Object.keys(s),r=Object.keys(e);return Array.from(new Set([...t,...r])).every(n=>Cr(s[n],e[n]))}function Cr(s,e){const t=typeof s;return t===typeof e?t==="object"?gg(s,e):s===e:!1}function Ln(s){if(!s)return s;const e={};for(const t in s)s[t]!==""&&s[t]!==void 0&&(e[t]=s[t]);return e}class mg{constructor(e,t={},r,i){this.content=e,this.style=t,this.index=r,this.parent=i,this.updateComputedStyle().initCharacters()}inlineBox=new Z;fill;outline;get computedFill(){return this.fill??this.parent.computedFill}get computedOutline(){return this.outline??this.parent.computedOutline}get computedContent(){const e=this.computedStyle;return e.textTransform==="uppercase"?this.content.toUpperCase():e.textTransform==="lowercase"?this.content.toLowerCase():this.content}updateComputedStyle(){return this.computedStyle={...this.parent.computedStyle,...Ln(this.style)},this}initCharacters(){const e=[];let t=0;for(const r of this.computedContent)e.push(new Vl(r,t++,this));return this.characters=e,this}}class yg{constructor(e,t,r){this.style=e,this.index=t,this.parent=r,this.updateComputedStyle()}lineBox=new Z;fragments=[];fill;outline;get computedFill(){return this.fill??this.parent.fill}get computedOutline(){return this.outline??this.parent.outline}updateComputedStyle(){return this.computedStyle={...Ln(this.parent.computedStyle),...Ln(this.style)},this}}function km(s){return s}class ss{static notZeroStyles=new Set(["width","height"]);static pxStyles=new Set(["width","height","fontSize","letterSpacing","textStrokeWidth","textIndent","shadowOffsetX","shadowOffsetY","shadowBlur","margin","marginLeft","marginTop","marginRight","marginBottom","padding","paddingLeft","paddingTop","paddingRight","paddingBottom"]);_toDomStyle(e){const t={};for(const r in e){const i=e[r];ss.notZeroStyles.has(r)&&i===0||(typeof i=="number"&&ss.pxStyles.has(r)?t[r]=`${i}px`:t[r]=i)}return t}createDom(e,t){const r=document.createElement("section"),i={...t},n=t.writingMode.includes("horizontal");switch(t.textAlign){case"start":case"left":i.justifyContent="flex-start";break;case"center":i.justifyContent="center";break;case"end":case"right":i.justifyContent="flex-end";break}switch(t.verticalAlign){case"top":i.alignItems="flex-start";break;case"middle":i.alignItems="center";break;case"bottom":i.alignItems="flex-end";break}const o=!!(i.justifyContent||i.alignItems);Object.assign(r.style,{...this._toDomStyle({...i,boxSizing:i.boxSizing??"border-box",display:i.display??(o?"inline-flex":void 0),width:i.width??"max-content",height:i.height??"max-content"}),whiteSpace:"pre-wrap",wordBreak:"break-all"});const a=document.createElement("ul");return Object.assign(a.style,{verticalAlign:"inherit",listStyleType:"inherit",padding:"0",margin:"0",width:o&&n?"100%":void 0,height:o&&!n?"100%":void 0}),e.forEach(l=>{const c=document.createElement("li");Object.assign(c.style,{verticalAlign:"inherit",...this._toDomStyle(l.style)}),l.fragments.forEach(h=>{const u=document.createElement("span");Object.assign(u.style,{verticalAlign:"inherit",...this._toDomStyle(h.style)}),u.appendChild(document.createTextNode(h.content)),c.appendChild(u)}),a.appendChild(c)}),r.appendChild(a),r}measureDomText(e){const t=document.createRange();t.selectNodeContents(e);const r=e.data??"";let i=0;return Array.from(r).map(n=>{const o=i+=r.substring(i).indexOf(n),a=o+n.length;i+=n.length,t.setStart(e,Math.max(o,0)),t.setEnd(e,a);const l=t.getClientRects?.()??[t.getBoundingClientRect()];let c=l[l.length-1];l.length>1&&c.width<2&&(c=l[l.length-2]);const h=t.toString();if(h!==""&&c&&c.width+c.height!==0)return{content:h,top:c.top,left:c.left,height:c.height,width:c.width}}).filter(Boolean)}measureDom(e){const t=[],r=[],i=[];return e.querySelectorAll("li").forEach((n,o)=>{const a=n.getBoundingClientRect();t.push({paragraphIndex:o,left:a.left,top:a.top,width:a.width,height:a.height}),n.querySelectorAll(":scope > *").forEach((l,c)=>{const h=l.getBoundingClientRect();r.push({paragraphIndex:o,fragmentIndex:c,left:h.left,top:h.top,width:h.width,height:h.height});let u=0;!l.children.length&&l.firstChild instanceof window.Text?this.measureDomText(l.firstChild).forEach(d=>{i.push({...d,newParagraphIndex:-1,paragraphIndex:o,fragmentIndex:c,characterIndex:u++,textWidth:-1,textHeight:-1})}):l.querySelectorAll(":scope > *").forEach(d=>{d.firstChild instanceof window.Text&&this.measureDomText(d.firstChild).forEach(g=>{i.push({...g,newParagraphIndex:-1,paragraphIndex:o,fragmentIndex:c,characterIndex:u++,textWidth:-1,textHeight:-1})})})})}),{paragraphs:t,fragments:r,characters:i}}measureParagraphDom(e,t){const r=t.getBoundingClientRect(),i=this.measureDom(t);i.paragraphs.forEach(a=>{const l=e[a.paragraphIndex];l.lineBox.left=a.left-r.left,l.lineBox.top=a.top-r.top,l.lineBox.width=a.width,l.lineBox.height=a.height}),i.fragments.forEach(a=>{const l=e[a.paragraphIndex].fragments[a.fragmentIndex];l.inlineBox.left=a.left-r.left,l.inlineBox.top=a.top-r.top,l.inlineBox.width=a.width,l.inlineBox.height=a.height});const n=[];let o=0;return i.characters.forEach(a=>{const{paragraphIndex:l,fragmentIndex:c,characterIndex:h}=a;n.push({...a,newParagraphIndex:l,left:a.left-r.left,top:a.top-r.top});const u=e[l].fragments[c].characters[h],{fontHeight:d,isVertical:g}=u,p=n[o];u.inlineBox.left=p.left,u.inlineBox.top=p.top,u.inlineBox.width=p.width,u.inlineBox.height=p.height,g?(u.lineBox.left=p.left+(p.width-d)/2,u.lineBox.top=p.top,u.lineBox.width=d,u.lineBox.height=p.height):(u.lineBox.left=p.left,u.lineBox.top=p.top+(p.height-d)/2,u.lineBox.width=p.width,u.lineBox.height=d),o++}),{paragraphs:e,boundingBox:new Z(0,0,r.width,r.height)}}measure(e,t,r){let i;r||(r=this.createDom(e,t),Object.assign(r.style,{position:"fixed",visibility:"hidden"}),document.body.appendChild(r),i=()=>r?.parentNode?.removeChild(r));const n=this.measureParagraphDom(e,r);return i?.(),n}}function vg(){const s=new Tt,e=Gl(),t=jl(e);return{name:"background",pathSet:s,load:async r=>{const{backgroundImage:i}=r.computedStyle;i&&e.needsLoad(i)&&await e.load(i)},update:r=>{s.paths.length=0;const{computedStyle:i,lineBox:n,isVertical:o}=r,{backgroundImage:a,backgroundSize:l,backgroundColormap:c}=i;if(K(a))return;const{pathSet:h}=t.parse(a),u=h.getBoundingBox(!0);let d,g,p,y;o?{x:g,y:d,width:y,height:p}=n:{x:d,y:g,width:p,height:y}=n;const m=Bn(c??"none"),P=h.paths.map(w=>{const x=w.clone();return x.style.fill&&x.style.fill in m&&(x.style.fill=m[x.style.fill]),x.style.stroke&&x.style.stroke in m&&(x.style.stroke=m[x.style.stroke]),x});let E,b;if(l==="rigid"){E=Math.max(r.fontSize*5/u.width),b=E;const w=new k;w.x=u.width-p/E,w.y=u.height-y/b,P.forEach(x=>{x.applyTransform(T=>{const C=T.x>u.left+u.width/2,L=T.y>u.top+u.height/2;C&&(T.x-=w.x),L&&(T.y-=w.y)})})}else E=p/u.width,b=y/u.height;const S=new _e;S.translate(-u.x,-u.y),S.scale(E,b),o&&(S.translate(-p/2,-y/2),S.rotate(-Math.PI/2),S.translate(y/2,p/2)),S.translate(d,g),P.forEach(w=>{w.applyTransform(x=>{x.applyMatrix3(S)})}),s.paths.push(...P)},renderOrder:-2,render:(r,i)=>{const{boundingBox:n,computedStyle:o}=i;K(o.backgroundColor)||(r.fillStyle=o.backgroundColor,r.fillRect(...n.array)),s.paths.forEach(a=>{if(Pr({ctx:r,path:a,fontSize:o.fontSize}),i.debug){const l=new Tt([a]).getBoundingBox();l&&r.strokeRect(l.x,l.y,l.width,l.height)}}),i.paragraphs.forEach(a=>{const{lineBox:l,style:c}=a;K(c.backgroundColor)||(r.fillStyle=c.backgroundColor,r.fillRect(...l.array)),a.fragments.forEach(h=>{const{inlineBox:u,style:d}=h;K(d.backgroundColor)||(r.fillStyle=d.backgroundColor,r.fillRect(...u.array))})})}}}function Fn(s){const{highlight:e,highlightImage:t,highlightReferImage:r,highlightColormap:i,highlightLine:n,highlightSize:o,highlightThickness:a}=s;return{image:e?.image??t??"none",referImage:e?.referImage??r??"none",colormap:e?.colormap??i??"none",line:e?.line??n??"none",size:e?.size??o??"cover",thickness:e?.thickness??a??"100%"}}function _g(){const s=new Tt,e=[],t=Gl(),r=jl(t);return{name:"highlight",pathSet:s,load:async i=>{const n=new Set;i.forEachCharacter(o=>{const{computedStyle:a}=o,{image:l,referImage:c}=Fn(a);l&&t.needsLoad(l)&&n.add(l),c&&t.needsLoad(c)&&n.add(c)}),await Promise.all(Array.from(n).map(o=>t.load(o)))},update:i=>{e.length=0,s.paths.length=0;let n=[],o,a;i.forEachCharacter(l=>{const{computedStyle:c}=l,h=Fn(c),{image:u,colormap:d,line:g,size:p,thickness:y}=h;if(K(u))o?.length&&(o=[],n.push(o));else{const{inlineBox:m,isVertical:P}=l,{fontSize:E}=c;(!a||Cr(a.image,u)&&Cr(a.colormap,d)&&Cr(a.line,g)&&Cr(a.size,p)&&Cr(a.thickness,y))&&o?.length&&(P?o[0].inlineBox.left===m.left:o[0].inlineBox.top===m.top)&&o[0].fontSize===E?o.push(l):(o=[],o.push(l),n.push(o))}a=h}),n=n.filter(l=>l.length);for(let l=0;l<n.length;l++){const c=n[l],h=c[0],u=Z.from(...c.map(O=>O.compatibleGlyphBox));if(!u.height||!u.width)continue;const{computedStyle:d,isVertical:g,inlineBox:p,compatibleGlyphBox:y,strikeoutPosition:m,underlinePosition:P}=h,{fontSize:E}=d,{image:b,referImage:S,colormap:w,line:x,size:T,thickness:C}=Fn(d),L=Un(C,{fontSize:E,total:u.width})/u.width,G=Bn(w),{pathSet:U,dom:R}=r.parse(b),z=U.getBoundingBox(!0),B=E/z.width*2,D=new Z().copy(u);g&&(D.width=u.height,D.height=u.width,D.left=u.left+u.width);const H=Math.floor(D.width);let I=H;T!=="cover"&&(I=Un(T,{fontSize:E,total:u.width})||H,D.width=I);const F=!K(S)&&K(x);if(F)z.copy(r.parse(S).pathSet.getBoundingBox(!0));else{let O;if(K(x))if(z.width/z.height>4){O="underline";const $=R.getAttribute("viewBox");if($){const[A,M,N,V]=$.split(" ").map(J=>Number(J)),Y=M+V/2;z.y<Y&&z.y+z.height>Y?O="line-through":z.y+z.height<Y?O="overline":O="underline"}}else O="outline";else O=x;switch(O){case"outline":{const $=D.width*.2,A=D.height*.2;g?(D.x-=A/2,D.y-=$/2,D.x-=D.height):(D.x-=$/2,D.y-=A/2),D.width+=$,D.height+=A;break}case"overline":D.height=z.height*B,g?D.x=p.left+p.width:D.y=p.top;break;case"line-through":D.height=z.height*B,g?D.x=p.left+p.width-m+D.height/2:D.y=p.top+m-D.height/2;break;case"underline":D.height=z.height*B,g?D.x=y.left+y.width-P:D.y=p.top+P;break}}const j=new _e;if(j.translate(-z.x,-z.y),j.scale(D.width/z.width,D.height/z.height),g){const O=D.width/2,$=D.height/2;F||j.translate(-O,-$),j.rotate(-Math.PI/2),F||j.translate($,O)}j.translate(D.x,D.y);for(let O=0;O<Math.ceil(H/I);O++){const $=j.clone();g?$.translate(0,O*D.width):$.translate(O*D.width,0),U.paths.forEach(A=>{const M=A.clone().applyTransform($);M.style.strokeWidth&&(M.style.strokeWidth*=B*L),M.style.strokeMiterlimit&&(M.style.strokeMiterlimit*=B),M.style.strokeDashoffset&&(M.style.strokeDashoffset*=B),M.style.strokeDasharray&&(M.style.strokeDasharray=M.style.strokeDasharray.map(N=>N*B)),M.style.fill&&M.style.fill in G&&(M.style.fill=G[M.style.fill]),M.style.stroke&&M.style.stroke in G&&(M.style.stroke=G[M.style.stroke]),s.paths.push(M),H!==I&&(g?e[s.paths.length-1]=new Z(u.left-u.width*2,u.top,u.width*4,u.height):e[s.paths.length-1]=new Z(u.left,u.top-u.height*2,u.width,u.height*4))})}}},renderOrder:-1,getBoundingBox:()=>{const i=[];return s.paths.forEach((n,o)=>{const a=e[o];let l=n.getBoundingBox();if(a){const c=Math.max(l.x,a.x),h=Math.max(l.y,a.y),u=Math.min(l.right,a.right),d=Math.min(l.bottom,a.bottom);l=new Z(c,h,u-c,d-h)}i.push(l)}),Z.from(...i)},render:(i,n)=>{s.paths.forEach((o,a)=>{if(Pr({ctx:i,path:o,fontSize:n.computedStyle.fontSize,clipRect:e[a]}),n.debug){const l=new Tt([o]).getBoundingBox();l&&i.strokeRect(l.x,l.y,l.width,l.height)}})}}}function bg(s,e){return`<svg width="${s*2}" height="${s*2}" xmlns="http://www.w3.org/2000/svg">
|
|
956
956
|
<circle cx="${s}" cy="${s}" r="${s}" fill="${e}" />
|
|
957
|
-
</svg>`}function wg(){const s=new Tt;return{name:"listStyle",pathSet:s,update:e=>{s.paths.length=0;const{paragraphs:t,isVertical:r,fontSize:i}=e,n=i*.45;t.forEach(o=>{const{computedStyle:a}=o,{color:l,listStyleImage:c,listStyleColormap:h,listStyleSize:u,listStyleType:d}=a,g=Bn(h);let p=u,y;if(!K(c))y=c;else if(!K(d)){const x=i*.38/2;switch(p=p==="cover"?x*2:p,d){case"disc":y=bg(x,String(l));break}}if(!y)return;const m=Ws(y),P=m.getBoundingBox(),E=o.fragments[0]?.characters[0];if(!E)return;const{inlineBox:b}=E,S=p==="cover"?1:Un(p,{total:i,fontSize:i})/i,w=new _e;if(r){const x=i/P.height*S;w.translate(-P.left,-P.top).rotate(Math.PI/2).scale(x,x).translate(b.left+(b.width-P.height*x)/2,b.top-n)}else{const x=i/P.height*S;w.translate(-P.left,-P.top).scale(x,x).translate(b.left-P.width*x-n,b.top+(b.height-P.height*x)/2)}s.paths.push(...m.paths.map(x=>{const T=x.clone();return T.applyTransform(w),T.style.fill&&T.style.fill in g&&(T.style.fill=g[T.style.fill]),T.style.stroke&&T.style.stroke in g&&(T.style.stroke=g[T.style.stroke]),T}))})}}}function xg(){return{name:"outline"}}const $t=new k,Tr=new _e,zt=new _e;function Pg(){const s=new Tt;return{name:"render",pathSet:s,update:e=>{s.paths.length=0;const{paragraphs:t}=e;t.forEach(r=>{r.fragments.forEach(i=>{i.characters.forEach(n=>{s.paths.push(n.path)})})})},getBoundingBox:e=>{const{characters:t,fontSize:r,effects:i}=e,n=[];return t.forEach(o=>{i?.forEach(a=>{if(!o.glyphBox)return;const l=o.glyphBox.clone(),c=Nn(e,a);$t.set(l.left,l.top),$t.applyMatrix3(c),l.left=$t.x,l.top=$t.y,$t.set(l.right,l.bottom),$t.applyMatrix3(c),l.width=$t.x-l.left,l.height=$t.y-l.top;const h=(a.shadowOffsetX??0)*r,u=(a.shadowOffsetY??0)*r,d=Math.max(.1,a.textStrokeWidth??0)*r;l.left+=h-d,l.top+=u-d,l.width+=d*2,l.height+=d*2,n.push(l)})}),n.length?Z.from(...n):void 0},render:(e,t)=>{const{paragraphs:r,glyphBox:i,effects:n}=t;n?n.forEach(o=>{is(o,i,e),e.save();const[a,l,c,h,u,d]=Nn(t,o).transpose().elements;e.transform(a,h,l,u,c,d),t.forEachCharacter(g=>{g.drawTo(e,o)}),e.restore()}):r.forEach(o=>{o.fragments.forEach(a=>{a.characters.forEach(l=>{l.drawTo(e)})})}),t.debug&&r.forEach(o=>{e.strokeRect(o.lineBox.x,o.lineBox.y,o.lineBox.width,o.lineBox.height)})}}}function Nn(s,e){const{fontSize:t,glyphBox:r}=s,i=(e.translateX??0)*t,n=(e.translateY??0)*t,o=Math.PI*2,a=(e.skewX??0)/360*o,l=(e.skewY??0)/360*o,{left:c,top:h,width:u,height:d}=r,g=c+u/2,p=h+d/2;return Tr.identity(),zt.makeTranslation(i,n),Tr.multiply(zt),zt.makeTranslation(g,p),Tr.multiply(zt),zt.set(1,Math.tan(a),0,Math.tan(l),1,0,0,0,1),Tr.multiply(zt),zt.makeTranslation(-g,-p),Tr.multiply(zt),Tr.clone()}function Cg(){const s=new Tt;return{name:"textDecoration",pathSet:s,update:e=>{s.paths.length=0;const t=[];let r,i;e.forEachCharacter(n=>{const{computedStyle:o,isVertical:a,inlineBox:l,underlinePosition:c,underlineThickness:h,strikeoutPosition:u,strikeoutSize:d}=n,{color:g,textDecoration:p,writingMode:y}=o;if(K(p))i=void 0;else{let m=!1;if(i?.textDecoration===p&&i?.writingMode===y&&i?.color===g&&(a?r[0].inlineBox.left===l.left:r[0].inlineBox.top===l.top))switch(p){case"underline":r[0].underlinePosition===c&&r[0].underlineThickness===h&&(m=!0);break;case"line-through":r[0].strikeoutPosition===u&&r[0].strikeoutSize===d&&(m=!0);break}m?r.push(n):(r=[],r.push(n),t.push(r)),i=o}}),t.forEach(n=>{const{computedStyle:o,isVertical:a,underlinePosition:l,underlineThickness:c,strikeoutPosition:h,strikeoutSize:u}=n[0],{color:d,textDecoration:g}=o,p=Z.from(...n.map(T=>T.inlineBox)),{left:y,top:m,width:P,height:E}=p;let b=a?y+P:m;const S=a?-1:1;let w=0;switch(g){case"overline":w=c*2;break;case"underline":b+=S*l,w=c*2;break;case"line-through":b+=S*h,w=u*2;break}b-=w;let x;a?x=new ge([{type:"M",x:b,y:m},{type:"L",x:b,y:m+E},{type:"L",x:b+w,y:m+E},{type:"L",x:b+w,y:m},{type:"Z"}],{fill:d}):x=new ge([{type:"M",x:y,y:b},{type:"L",x:y+P,y:b},{type:"L",x:y+P,y:b+w},{type:"L",x:y,y:b+w},{type:"Z"}],{fill:d}),s.paths.push(x)})},render:(e,t)=>{const{effects:r,computedStyle:i}=t;r?r.forEach(n=>{e.save();const[o,a,l,c,h,u]=Nn(t,n).transpose().elements;e.transform(o,c,a,h,l,u),s.paths.forEach(d=>{Pr({ctx:e,path:d,fontSize:i.fontSize,...n})}),e.restore()}):s.paths.forEach(n=>{Pr({ctx:e,path:n,fontSize:i.fontSize})})}}}var Tg=Object.defineProperty,Vt=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Tg(e,t,i),i};const Wl=Po();class kt extends bs{needsUpdate=!0;computedStyle={...Wl};paragraphs=[];lineBox=new Z;rawGlyphBox=new Z;glyphBox=new Z;pathBox=new Z;boundingBox=new Z;measurer=new ss;plugins=new Map;pathSets=[];get fontSize(){return this.computedStyle.fontSize}get isVertical(){return this.computedStyle.writingMode.includes("vertical")}get characters(){return this.paragraphs.flatMap(e=>e.fragments.flatMap(t=>t.characters))}constructor(e={}){super(),this.set(e)}set(e={}){const{content:t,effects:r,style:i,measureDom:n,fonts:o,fill:a,outline:l}=To(e);this.debug=e.debug??!1,this.content=t,this.effects=r,this.style=i,this.measureDom=n,this.fonts=o,this.fill=a,this.outline=l,this.use(vg()).use(xg()).use(wg()).use(Cg()).use(_g()).use(Pg()),(e.plugins??[]).forEach(c=>{this.use(c)}),this.updateParagraphs()}use(e){return this.plugins.set(e.name,e),this}forEachCharacter(e){return this.paragraphs.forEach((t,r)=>{t.fragments.forEach((i,n)=>{i.characters.forEach((o,a)=>{e(o,{paragraphIndex:r,fragmentIndex:n,characterIndex:a})})})}),this}async load(){await Promise.all(Array.from(this.plugins.values()).map(e=>e.load?.(this)))}updateParagraphs(){this.computedStyle={...Wl,...this.style};const{content:e}=this,t=[];return e.forEach((r,i)=>{const{fragments:n,fill:o,outline:a,...l}=r,c=new yg(l,i,this);c.fill=o,c.outline=a,n.forEach((h,u)=>{const{content:d,fill:g,outline:p,...y}=h;if(d!==void 0){const m=new mg(d,y,u,c);c.fragments.push(m),m.fill=g,m.outline=p}}),t.push(c)}),this.paragraphs=t,this}createDom(){return this.updateParagraphs(),this.measurer.createDom(this.paragraphs,this.computedStyle)}measure(e=this.measureDom){const t={paragraphs:this.paragraphs,lineBox:this.lineBox,rawGlyphBox:this.rawGlyphBox,glyphBox:this.glyphBox,pathBox:this.pathBox,boundingBox:this.boundingBox};this.updateParagraphs();const r=this.measurer.measure(this.paragraphs,this.computedStyle,e);this.paragraphs=r.paragraphs,this.lineBox=r.boundingBox,this.characters.forEach(i=>{i.update(this.fonts)}),this.rawGlyphBox=this.getGlyphBox(),Array.from(this.plugins.values()).sort((i,n)=>(i.updateOrder??0)-(n.updateOrder??0)).forEach(i=>{i.update?.(this)}),this.pathSets.length=0,Array.from(this.plugins.values()).sort((i,n)=>(i.renderOrder??0)-(n.renderOrder??0)).forEach(i=>{i.pathSet?.paths.length&&this.pathSets.push(i.pathSet)}),this.glyphBox=this.getGlyphBox(),this.updatePathBox().updateBoundingBox();for(const i in t)r[i]=this[i],this[i]=t[i];return this.emit("measure",{text:this,result:r}),r}getGlyphBox(){const e=k.MAX,t=k.MIN;return this.characters.forEach(r=>{if(!r.getGlyphMinMax(e,t)){const{inlineBox:i}=r,{left:n,top:o,width:a,height:l}=i,c=new k(n,o),h=new k(n+a,o+l);e.min(c,h),t.max(c,h)}}),new Z(e.x,e.y,t.x-e.x,t.y-e.y)}updatePathBox(){return this.pathBox=Z.from(this.glyphBox,...Array.from(this.plugins.values()).map(e=>e.getBoundingBox?e.getBoundingBox(this):e.pathSet?.getBoundingBox()).filter(Boolean)),this}updateBoundingBox(){return this.boundingBox=Z.from(this.rawGlyphBox,this.lineBox,this.pathBox),this}requestUpdate(){return this.needsUpdate=!0,this}update(e=this.measureDom){this.needsUpdate=!1;const t=this.measure(e);for(const r in t)this[r]=t[r];return this.emit("update",{text:this}),this}render(e){const{view:t,pixelRatio:r=2}=e,i=t.getContext("2d");i&&(this.needsUpdate&&this.update(),cg(i,r,this.boundingBox),hg(i,this),Array.from(this.plugins.values()).sort((n,o)=>(n.renderOrder??0)-(o.renderOrder??0)).forEach(n=>{if(n.render)n.render?.(i,this);else if(n.pathSet){const o=this.computedStyle;n.pathSet.paths.forEach(a=>{Pr({ctx:i,path:a,fontSize:o.fontSize})})}}),this.emit("render",{text:this,view:t,pixelRatio:r}),e.onContext?.(i))}toString(){return this.content.flatMap(e=>e.fragments.map(t=>t.content)).join("")}}Vt([_({internal:!0})],kt.prototype,"debug"),Vt([_()],kt.prototype,"content"),Vt([_()],kt.prototype,"style"),Vt([_()],kt.prototype,"effects"),Vt([_()],kt.prototype,"fill"),Vt([_()],kt.prototype,"outline"),Vt([_({internal:!0})],kt.prototype,"measureDom"),Vt([_({internal:!0})],kt.prototype,"fonts");var Sg=Object.defineProperty,Gt=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Sg(e,t,i),i};class vt extends xt{constructor(e){super(),this.parent=e,this.base=new kt,this.base.setPropertyAccessor(this),this.update()}base;_texture=new Ui;_textureMap=new Map;setProperties(e){return super.setProperties(K(e)?void 0:To(e))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"enabled":this.parent.requestRedraw();break;case"effects":case"measureDom":case"fonts":this.update(),this.parent.requestRedraw();break;case"fill":case"outline":case"content":this.update(),this._updateTextureMap(),this.parent.requestRedraw();break}}update(){this.base.fonts=this.base.fonts??this.parent.tree?.fonts,this.base.update()}_updateTextureMap(){this._textureMap.clear();const e=[];if(this.base.paragraphs.forEach((t,r)=>{const i=[];if(t.fragments.forEach((n,o)=>{if(n.characters.length){const a=Z.from(...n.characters.map(l=>l.compatibleGlyphBox));this._updateTexture(`${r}.${o}.fill`,n.fill,a),this._updateTexture(`${r}.${o}.outline`,n.outline,a),i.push(a)}}),i.length){const n=Z.from(...i);this._updateTexture(`${r}.fill`,t.fill,n),this._updateTexture(`${r}.outline`,t.outline,n),e.push(n)}}),e.length){const t=Z.from(...e);this._updateTexture("fill",this.fill,t),this._updateTexture("outline",this.outline,t)}}async _updateTexture(e,t,r){t&&Object.keys(t).length>0&&(this._textureMap.set(e,{texture:await this._loadTexture(t,r),box:r}),this.parent.requestRedraw())}async _loadTexture(e,t){return e.linearGradient||e.radialGradient?new zr(e.linearGradient??e.radialGradient,t.width,t.height):K(e.image)?void 0:(this.parent.tree?.log(`load image ${e.image}`),await Ke.texture.load(e.image))}setContent(e){this.content=Ps(e)}measure(){return this.update(),this.base.measure()}isValid(){return!!(this.enabled&&!/^\s*$/.test(this.base.toString()))}_createVertTransform(){const e=this.parent;if(e.scale.x>0&&e.scale.y>0)return;const t=e.scale.x*e.scale.y,r=e.getTransformOrigin();return new ke().translate(-r.x,-r.y).scale(t>0?1:-1,1).translate(r.x,r.y)}useTextureDraw(){return!!this.effects?.length||this.content.some(e=>e.fragments.some(t=>!!t.highlightImage))}_pathDraw(e){this.base.pathSets.forEach(t=>{t.paths.forEach(r=>{const i=r.getMeta();if(i instanceof Vl){const n=i.parent.index,o=i.parent.parent.index;if(r.style.fill&&!K(r.style.fill))if(typeof r.style.fill=="object"){const a=r.style.fill,l=this._textureMap.get(`${o}.${n}.fill`)??this._textureMap.get(`${o}.fill`)??this._textureMap.get("fill");if(a.enabled!==!1&&(l||a.color)){const{uvTransform:c,disableWrapMode:h}=rs(a,l?.box??{width:this.parent.size.width,height:this.parent.size.height});e.addPath(r),e.style={...r.style},e.uvTransform=c,e.fillStyle=l?.texture??a.color,e.vertTransform=this._createVertTransform(),e.fill({disableWrapMode:h})}}else e.addPath(r),e.style={...r.style},e.vertTransform=this._createVertTransform(),e.fill();if(r.style.stroke&&!K(r.style.stroke))if(typeof r.style.stroke=="object"){const a=r.style.stroke,l=this._textureMap.get(`${o}.${n}.outline`)??this._textureMap.get(`${o}.outline`)??this._textureMap.get("outline");if(a.enabled!==!1&&(l||a.color)&&(a.width===void 0||a.width)){const{uvTransform:c,disableWrapMode:h}=rs(a,l?.box??{width:this.parent.size.width,height:this.parent.size.height});e.addPath(r),e.style={...r.style},e.lineWidth=a.width||1,e.uvTransform=c,e.strokeStyle=l?.texture??a.color,e.lineCap=a.lineCap,e.lineJoin=a.lineJoin,e.vertTransform=this._createVertTransform(),e.stroke({disableWrapMode:h})}}else e.addPath(r),e.style={...r.style},e.vertTransform=this._createVertTransform(),e.stroke()}else e.addPath(r),e.style={...r.style},e.vertTransform=this._createVertTransform(),e.fill()})})}_textureDraw(e){this._texture.width=Math.round(this.base.boundingBox.width),this._texture.height=Math.round(this.base.boundingBox.height),this.base.render({view:this._texture.source}),e.fillStyle=this._texture,e.vertTransform=this._createVertTransform(),e.fill()}draw(){const e=this.parent.context;this.useTextureDraw()?this._textureDraw(e):this._pathDraw(e)}}Gt([_({fallback:!0})],vt.prototype,"enabled"),Gt([_({fallback:()=>[]})],vt.prototype,"content"),Gt([_({alias:"parent.style.json"})],vt.prototype,"style"),Gt([_()],vt.prototype,"effects"),Gt([_()],vt.prototype,"fill"),Gt([_()],vt.prototype,"outline"),Gt([_({alias:"base.measureDom"})],vt.prototype,"measureDom"),Gt([_({alias:"base.fonts"})],vt.prototype,"fonts");var Eg=Object.getOwnPropertyDescriptor,Mg=(s,e,t,r)=>{for(var i=r>1?void 0:r?Eg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};const Ag=new Set(Object.keys(wo())),Og=new Set(Object.keys(xo()));f.BaseElement2D=class extends f.Node2D{size=new de().on("update",()=>{this.updateGlobalTransform(),this.requestRedraw()});get style(){return this._style}set style(e){const t=(...r)=>{this.emit("updateStyleProperty",r[0],r[1],r[2]),this._updateStyleProperty(r[0],r[1],r[2])};e.on("updateProperty",t),this._style?.off("updateProperty",t),this._style=e}_background=new Dn(this);get background(){return this._background}set background(e){this._background.resetProperties().setProperties(e)}_shape=new ir(this);get shape(){return this._shape}set shape(e){this._shape.resetProperties().setProperties(e)}_fill=new Oe(this);get fill(){return this._fill}set fill(e){this._fill.resetProperties().setProperties(e)}_outline=new tr(this);get outline(){return this._outline}set outline(e){this._outline.resetProperties().setProperties(e)}_foreground=new In(this);get foreground(){return this._foreground}set foreground(e){this._foreground.resetProperties().setProperties(e)}_text=new vt(this);get text(){return this._text}set text(e){this._text.resetProperties().setProperties(e)}_shadow=new rr(this);get shadow(){return this._shadow}set shadow(e){this._shadow.resetProperties().setProperties(e)}constructor(e,t=[]){super(),this._updateStyleProperty=this._updateStyleProperty.bind(this),this.style=new ui,this.setProperties(e).append(t)}setProperties(e){if(e){const{style:t,text:r,shape:i,background:n,fill:o,outline:a,foreground:l,shadow:c,...h}=e;t&&this.style.setProperties(t),n&&this.background.setProperties(n),i&&this.shape.setProperties(i),o&&this.fill.setProperties(o),a&&this.outline.setProperties(a),r&&this.text.setProperties(r),l&&this.foreground.setProperties(l),c&&this.shadow.setProperties(c),super.setProperties(h)}return this}_updateStyleProperty(e,t,r){switch(e){case"rotate":this.rotation=this.style.rotate*Xo;break;case"scaleX":this.scale.x=this.style.scaleX,this.text.isValid()&&(t^r)<0&&this.requestRedraw();break;case"scaleY":this.scale.y=this.style.scaleY,this.text.isValid()&&(t^r)<0&&this.requestRedraw();break;case"skewX":this.skew.x=this.style.skewX;break;case"skewY":this.skew.y=this.style.skewY;break;case"transform":case"transformOrigin":this.updateGlobalTransform();break;case"opacity":this.opacity=this.style.opacity;break;case"visibility":this.visible=this.style.visibility==="visible";break;case"filter":this.requestRepaint();break;case"maskImage":this._updateMaskImage();break;case"backgroundColor":this.background.color=this.style.backgroundColor;break;case"backgroundImage":this.background.image=this.style.backgroundImage;break;case"borderStyle":case"outlineStyle":this.outline.style=t;break;case"borderWidth":case"outlineWidth":this.outline.width=t;break;case"borderColor":case"outlineColor":this.outline.color=t;break;case"borderRadius":default:this.requestRedraw();break}(Og.has(e)||Ag.has(e))&&this.text.isValid()&&(this.text.update(),this.requestRedraw())}_process(e){this.foreground.updateFrameIndex(),this.fill.updateFrameIndex(),this.outline.updateFrameIndex(),this.background.updateFrameIndex(),super._process(e)}_updateMaskImage(){const e="__$style.maskImage",t=this.style.maskImage;if(t&&t!=="none"){const r=this.getNode(e);r?r.src=t:this.appendChild(new f.MaskEffect({name:e,src:t}),"back")}else{const r=this.getNode(e);r&&this.removeChild(r)}}getTransformOrigin(){const{width:e,height:t}=this.size,[r,i]=ml(this.style.transformOrigin);return new de(r*e,i*t)}updateTransform(e){const{width:t,height:r}=this.size;super.updateTransform(i=>{gl(this.style.transform??"",t,r,i),e?.(i)})}updateGlobalTransform(){super.updateGlobalTransform(),this._updateOverflow()}_relayout(e){return super._relayout(e).map(t=>({...t,dimension:this.size.toFloat32Array()}))}getRect(){return this.getGlobalAabb()}_getPointArray(){const{width:e,height:t}=this.size,r=0,i=0,n=r+e,o=i+t;return[{x:r,y:i},{x:r,y:o},{x:n,y:i},{x:n,y:o}]}getAabb(){return new It(this._getPointArray().map(e=>this.transform.apply(e)))}getGlobalAabb(){return new It(this._getPointArray().map(e=>this.globalTransform.apply(e)))}getObb(){const e=this.getTransformOrigin(),t=this.transform.apply(e).sub(e);return{rect:new It(this._getPointArray().map(r=>(r.x+=t.x,r.y+=t.y,r))),rotation:this.rotation}}getGlobalObb(){const e=this.getTransformOrigin(),t=this.globalTransform.apply(e).sub(e);return{rect:new It(this._getPointArray().map(r=>(r.x+=t.x,r.y+=t.y,r))),rotation:this.globalRotation}}_updateOverflow(){this.style.overflow==="hidden"?this.mask=this.getRect().toJSON():this.mask=void 0}_draw(){super._draw(),this._background.isValid()&&(this._tree?.log(this.name,"background drawing"),this._shape.draw(!this._background.fillWithShape),this._background.draw()),this._fill.isValid()&&(this._tree?.log(this.name,"fill drawing"),this._shape.draw(),this._fill.draw()),this._outline.isValid()&&(this._tree?.log(this.name,"outline drawing"),this._shape.draw(),this._outline.draw()),this._foreground.isValid()&&(this._tree?.log(this.name,"foreground drawing"),this._shape.draw(!this._foreground.fillWithShape),this._foreground.draw()),this._text.isValid()&&(this._tree?.log(this.name,"text drawing"),this._text.useTextureDraw()&&this._shape.draw(!0),this._text.draw()),this._drawContent()}_drawContent(){}_repaint(e){return super._repaint(e).map(t=>({...t}))}canPointerEvents(){return this.style.pointerEvents!=="none"}input(e,t){const r=this.getChildren(!0);for(let i=r.length-1;i>=0;i--)r[i].input(e,t);this.isVisibleInTree()&&this._input(e,t)}_positionInput(e,t){const{width:r,height:i}=this.size;return e.x>=0&&e.x<r&&e.y>=0&&e.y<i}_input(e,t){switch(t){case"pointerdown":case"pointermove":case"pointerup":{if(this.canPointerEvents()){const{screenX:r,screenY:i}=e;if(r&&i){const n=new de(r,i),o=this.getViewport();o&&o.toCanvasGlobal(n,n),this.toLocal(n,n),this._positionInput(n,t)&&(e.target||(e.target=this),this.emit(t,e))}}break}}}toJSON(){const e=t=>Object.keys(t).length>0?t:void 0;return Ve({...super.toJSON(),style:e(this.style.toJSON()),background:e(this.background.toJSON()),shape:e(this.shape.toJSON()),fill:e(this.fill.toJSON()),outline:e(this.outline.toJSON()),text:e(this.text.toJSON()),foreground:e(this.foreground.toJSON()),shadow:e(this.shadow.toJSON())})}},f.BaseElement2D=Mg([X("BaseElement2D")],f.BaseElement2D);class $n extends ui{constructor(e){super(),this.setProperties(e)}}const ql={left:0,top:0,width:0,height:0};for(const s in ql)mi($n,s,{fallback:ql[s]});class Xl extends ui{constructor(e){super(),this.setProperties(e)}}var kg=Object.getOwnPropertyDescriptor,Dg=(s,e,t,r)=>{for(var i=r>1?void 0:r?kg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};f.Element2D=class extends f.BaseElement2D{get style(){return this._style}set style(e){const t=(...r)=>{this.emit("updateStyleProperty",r[0],r[1],r[2]),this._updateStyleProperty(r[0],r[1],r[2])};e.on("updateProperty",t),this._style?.off("updateProperty",t),this._style=e}constructor(e,t=[]){super(),this.style=new $n,this.setProperties(e).append(t)}_updateStyleProperty(e,t,r){switch(super._updateStyleProperty(e,t,r),e){case"left":this.position.x=Number(t);break;case"top":this.position.y=Number(t);break;case"width":this.size.width=Number(t);break;case"height":this.size.height=Number(t);break}switch(e){case"width":case"height":this.mask instanceof f.BaseElement2D&&(this.mask.size.width=this.size.width,this.mask.size.height=this.size.height);break}}},f.Element2D=Dg([X("Element2D")],f.Element2D);const fe={left:0,top:1,right:2,bottom:3,start:4,end:5,horizontal:6,vertical:7,all:8},Hl={column:0,row:1,all:2},sr={auto:0,"flex-start":1,center:2,"flex-end":3,stretch:4,baseline:5,"space-between":6,"space-around":7,"space-evenly":8},zn={flex:0,none:1,contents:2},ns={inherit:0,ltr:1,rtl:2},Vn={column:0,"column-reverse":1,row:2,"row-reverse":3},Gn={"no-wrap":0,wrap:1,"Wrap-reverse":2},jn={"flex-start":0,center:1,"flex-end":2,"space-between":3,"space-around":4,"space-evenly":5},Wn={visible:0,hidden:1,scroll:2},qn={static:0,relative:1,absolute:2},Xn={"border-box":0,"content-box":1};class os{constructor(e){this._element=e}static _yoga;static async load(){const{loadYoga:e}=await import("yoga-layout/load");this._yoga=await e()}_node=os._yoga.Node.create();get _style(){return this._element.style}get offsetLeft(){return this._node.getComputedLeft()}get offsetTop(){return this._node.getComputedTop()}get offsetWidth(){return this._node.getComputedWidth()}get offsetHeight(){return this._node.getComputedHeight()}calculateLayout(e,t,r){return this._node.calculateLayout(e,t,r)}getComputedLayout(){return this._node.getComputedLayout()}updateStyleProperty(e,t,r){switch(e){case"alignContent":this._node.setAlignContent(t?sr[t]:sr["flex-start"]);break;case"alignItems":this._node.setAlignItems(t?sr[t]:sr["flex-start"]);break;case"alignSelf":this._node.setAlignSelf(t?sr[t]:sr["flex-start"]);break;case"aspectRatio":this._node.setAspectRatio(t);break;case"borderTop":this._node.setBorder(fe.top,this._style.borderWidth);break;case"borderBottom":this._node.setBorder(fe.bottom,this._style.borderWidth);break;case"borderLeft":this._node.setBorder(fe.left,this._style.borderWidth);break;case"borderRight":this._node.setBorder(fe.right,this._style.borderWidth);break;case"border":this._node.setBorder(fe.all,this._style.borderWidth);break;case"direction":this._node.setDirection(t?ns[t]:ns.inherit);break;case"display":this._node.setDisplay(t?zn[t]:zn.flex);break;case"flex":this._node.setFlex(this._style.flex);break;case"flexBasis":this._node.setFlexBasis(this._style.flexBasis);break;case"flexDirection":this._node.setFlexDirection(t?Vn[t]:Vn.row);break;case"flexGrow":this._node.setFlexGrow(this._style.flexGrow);break;case"flexShrink":this._node.setFlexShrink(this._style.flexShrink);break;case"flexWrap":this._node.setFlexWrap(t?Gn[t]:Gn.wrap);break;case"height":this._node.setHeight(this._style.height);break;case"justifyContent":this._node.setJustifyContent(t?jn[t]:jn["flex-start"]);break;case"gap":t!==void 0&&this._node.setGap(Hl.all,t);break;case"marginTop":this._node.setMargin(fe.top,t);break;case"marginBottom":this._node.setMargin(fe.bottom,t);break;case"marginLeft":this._node.setMargin(fe.left,t);break;case"marginRight":this._node.setMargin(fe.right,t);break;case"margin":this._node.setMargin(fe.all,t);break;case"maxHeight":this._node.setMaxHeight(t);break;case"maxWidth":this._node.setMaxWidth(t);break;case"minHeight":this._node.setMinHeight(this._style.minHeight);break;case"minWidth":this._node.setMinWidth(this._style.minWidth);break;case"overflow":this._node.setOverflow(t?Wn[t]:Wn.visible);break;case"paddingTop":this._node.setPadding(fe.top,this._style.paddingTop);break;case"paddingBottom":this._node.setPadding(fe.bottom,this._style.paddingBottom);break;case"paddingLeft":this._node.setPadding(fe.left,this._style.paddingLeft);break;case"paddingRight":this._node.setPadding(fe.right,this._style.paddingRight);break;case"padding":this._node.setPadding(fe.all,this._style.padding);break;case"top":this._node.setPosition(fe.top,this._style.top);break;case"bottom":this._node.setPosition(fe.bottom,this._style.bottom);break;case"left":this._node.setPosition(fe.left,this._style.left);break;case"right":this._node.setPosition(fe.right,this._style.right);break;case"position":this._node.setPositionType(t?qn[t]:qn.static);break;case"boxSizing":this._node.setBoxSizing(t?Xn[t]:Xn["content-box"]);break;case"width":this._node.setWidth(this._style.width);break}}}var Ig=Object.getOwnPropertyDescriptor,Rg=(s,e,t,r)=>{for(var i=r>1?void 0:r?Ig(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};f.FlexElement2D=class extends f.BaseElement2D{get style(){return this._style}set style(e){const t=(...r)=>{this.emit("updateStyleProperty",r[0],r[1],r[2]),this._updateStyleProperty(r[0],r[1],r[2])};e.on("updateProperty",t),this._style?.off("updateProperty",t),this._style=e}_layout=new os(this);get offsetLeft(){return this._layout.offsetLeft}get offsetTop(){return this._layout.offsetTop}get offsetWidth(){return this._layout.offsetWidth}get offsetHeight(){return this._layout.offsetHeight}constructor(e,t=[]){super(),this.style=new Xl,this.setProperties(e).append(t)}_parented(e){super._parented(e),e._layout&&this._layout._node&&e._layout._node.insertChild(this._layout._node,e._layout._node.getChildCount())}_unparented(e){super._unparented(e),e._layout?._node&&e._layout._node.removeChild(this._layout._node)}_updateStyleProperty(e,t,r){super._updateStyleProperty(e,t,r),this._layout.updateStyleProperty(e,t,r),this._layout._node.isDirty()&&this.requestRelayout()}updateTransform(){this.calculateLayout(void 0,void 0,ns.ltr);const{left:e,top:t,width:r,height:i}=this._layout.getComputedLayout();this.position.x=e,this.position.y=t,this.size.x=r,this.size.y=i,super.updateTransform()}calculateLayout(e,t,r){const i=this.getParent();i?._layout?.calculateLayout?i?._layout.calculateLayout(e,t,r):this._layout.calculateLayout(e,t,r)}},f.FlexElement2D=Rg([X("FlexElement2D")],f.FlexElement2D);var Ug=Object.defineProperty,Bg=Object.getOwnPropertyDescriptor,fi=(s,e,t,r)=>{for(var i=r>1?void 0:r?Bg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Ug(e,t,i),i};f.Image2D=class extends f.Element2D{get currentFrameTexture(){return this.texture?.frames[this._frameIndex]?.texture}get textureDuration(){return this.texture?.duration??0}get naturalWidth(){return this.currentFrameTexture?.realWidth??0}get naturalHeight(){return this.currentFrameTexture?.realHeight??0}get complete(){return this._complete}_frameIndex=0;_complete=!1;_wait=Promise.resolve();constructor(e,t=[]){super(),this.setProperties(e),this.append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"src":this._wait=this._load(t);break;case"srcRect":this.requestRedraw();break}}decode(){return this._wait}setResource(e){let t;if(e instanceof Ri?t=e:t=new Ri(e),this.texture=t.updateDuration(),this.currentFrameTexture&&(!this.style.width||!this.style.height)){const r=this.currentFrameTexture;this.style.width=r.realWidth,this.style.height=r.realHeight}return this}async _load(e){if(this._complete=!1,e)try{this.setResource(this.gif||e?.includes(".gif")?await Ke.gif.load(e):await Ke.texture.load(e)),this.requestRedraw(),this.emit("load")}catch(t){console.warn(t),this.emit("error",t)}else this.texture=void 0;this._complete=!0}_getFrameCurrentTime(){const e=this.textureDuration;if(!e||!this._tree)return 0;const t=this._currentTime;return t<0?0:t%e}_updateFrameIndex(){if(!this.texture)return this;const e=this._getFrameCurrentTime(),t=this.texture.frames,r=t.length;if(r<=1&&this._frameIndex===0)return this;let i=r-1;for(let n=0,o=0;o<r;o++)if(n+=t[o].duration??0,n>=e){i=o;break}return this._frameIndex!==i&&(this._frameIndex=i,this.requestRedraw()),this}_process(e){this._updateFrameIndex(),super._process(e)}_drawContent(){const e=this.currentFrameTexture;if(e?.isValid()){const{left:t=0,top:r=0,right:i=0,bottom:n=0}=this.srcRect??{},{width:o,height:a}=this.size;this.context.fillStyle=e;const l=Math.abs(1+(t+i))*o,c=Math.abs(1+(r+n))*a,h=1/l,u=1/c,d=t*o*h,g=r*a*u;this.context.uvTransform=new ke().scale(h,u).translate(d,g),this.shape.draw(),this.context.fill()}}_repaint(e){return super._repaint(e).map(t=>({...t,disableWrapMode:!0}))}},fi([_({internal:!0})],f.Image2D.prototype,"texture",2),fi([_({fallback:""})],f.Image2D.prototype,"src",2),fi([_()],f.Image2D.prototype,"srcRect",2),fi([_({fallback:!1})],f.Image2D.prototype,"gif",2),f.Image2D=fi([X("Image2D")],f.Image2D);class Hn extends f.Element2D{texture;constructor(e,t=[]){super(),this.setProperties(e).append(t)}_drawContent(){this.texture?.isValid()&&(this.shape.draw(!0),this.context.fillStyle=this.texture,this.context.fill())}}var Lg=Object.defineProperty,Fg=Object.getOwnPropertyDescriptor,Yl=(s,e,t,r)=>{for(var i=r>1?void 0:r?Fg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Lg(e,t,i),i};f.Lottie2D=class extends Hn{texture=new Ui;animation;constructor(e,t=[]){super(),this.setProperties(e),this.append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"src":this._load();break}}_updateStyleProperty(e,t,r){switch(super._updateStyleProperty(e,t,r),e){case"width":this.texture.width=this.style.width;break;case"height":this.texture.height=this.style.height;break}}async _load(){this.animation=await Ke.lottie.load(this.src,this.texture.source),this.duration=this.animation.getDuration(!1)*1e3,this.texture.requestUpload(),this.requestRedraw()}_process(e){this.animation?.goToAndStop(this.currentTime,!1),this.texture.requestUpload(),this.requestRedraw(),super._process(e)}},Yl([_({fallback:""})],f.Lottie2D.prototype,"src",2),f.Lottie2D=Yl([X("Lottie2D")],f.Lottie2D);var Ng=Object.defineProperty,$g=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Ng(e,t,i),i};class Kl extends f.Element2D{constructor(e,t=[]){super(),this.setProperties(e).append(t)}_updateStyleProperty(e,t,r){switch(super._updateStyleProperty(e,t,r),e){case"width":case"height":this.requestRedraw();break}}_drawCircle(e,t){this.context.arc(e,t,this.handleSize,0,Math.PI*2,!0),this.context.fillStyle=le.WHITE,this.context.fill(),this.context.arc(e,t,this.handleSize,0,Math.PI*2,!0),this.context.strokeStyle="rgba(0, 0, 0, 0.2)",this.context.stroke()}_drawEllipse(e,t){this.context.roundRect(e-this.handleSize,t-this.handleSize*2,this.handleSize*2,this.handleSize*4,this.handleSize),this.context.fillStyle=le.WHITE,this.context.fill(),this.context.roundRect(e-this.handleSize,t-this.handleSize*2,this.handleSize*2,this.handleSize*4,this.handleSize),this.context.strokeStyle="rgba(0, 0, 0, 0.2)",this.context.stroke()}_draw(){const{width:e,height:t}=this.getRect();this.context.rect(0,0,e,t),this.context.strokeStyle="#00FF00",this.context.stroke(),this._drawCircle(0,0),this._drawCircle(e,t),this._drawCircle(0,t),this._drawEllipse(0,t/2),this._drawCircle(e,0),this._drawEllipse(e,t/2)}}$g([_({fallback:6})],Kl.prototype,"handleSize");var zg=Object.defineProperty,Vg=Object.getOwnPropertyDescriptor,Zl=(s,e,t,r)=>{for(var i=r>1?void 0:r?Vg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&zg(e,t,i),i};f.Video2D=class extends Hn{get videoDuration(){return(this.texture?.duration??0)*1e3}_wait=Promise.resolve();constructor(e,t=[]){super(),this.setProperties(e),this.append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"src":this._wait=this._load(t);break}}waitLoad(){return this._wait}async _load(e){this.texture=await Ke.video.load(e),(!this.style.width||!this.style.height)&&(this.style.width=this.texture.width,this.style.height=this.texture.height),this.requestRedraw()}_updateVideoCurrentTime(){let e=this._currentTime;if(e<0)return;const t=this.texture;if(!t)return;const r=t.duration;e=r?e%(r*1e3):0,!t.isPlaying&&!t.seeking&&(e=~~e/1e3,t.currentTime!==e&&(t.currentTime=e))}_process(e){this._updateVideoCurrentTime(),super._process(e)}},Zl([_({fallback:""})],f.Video2D.prototype,"src",2),f.Video2D=Zl([X("Video2D")],f.Video2D);var Gg=Object.defineProperty,jg=Object.getOwnPropertyDescriptor,as=(s,e,t,r)=>{for(var i=r>1?void 0:r?jg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Gg(e,t,i),i};const Jl=s=>s,Ql=Sr(.25,.1,.25,1),ec=Sr(.42,0,1,1),tc=Sr(0,0,.58,1),rc=Sr(.42,0,.58,1);function Sr(s,e,t,r){const n=3*s-3*t+1,o=3*t-6*s,a=3*s,l=3*e-3*r+1,c=3*r-6*e,h=3*e,u=y=>(3*n*y+2*o)*y+a,d=y=>((n*y+o)*y+a)*y,g=y=>((l*y+c)*y+h)*y;function p(y){let m=y,P,E;for(let w=0;w<8;w++){if(E=d(m)-y,Math.abs(E)<1e-6)return m;if(P=u(m),Math.abs(P)<1e-6)break;m-=E/P}let b=1,S=0;for(m=y;b>S;){if(E=d(m)-y,Math.abs(E)<1e-6)return m;E>0?b=m:S=m,m=(b+S)/2}return m}return y=>g(p(y))}const ls={linear:Jl,ease:Ql,easeIn:ec,easeOut:tc,easeInOut:rc};f.Animation=class extends f.TimelineNode{_keyframes=[];_isFirstUpdatePosition=!1;_cachedProps=new ho;_stoped=!1;constructor(e,t=[]){super(),this.setProperties(e).append(t)}_parented(e){super._parented(e),this._updateCachedProps()}_unparented(e){super._unparented(e),this.cancel()}_process(){this.canProcess()&&this.commitStyles()}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"effectMode":case"keyframes":this._updateKeyframes();break}}_getTargets(){let e;switch(this.effectMode){case"sibling":e=this.getParent()?.getChildren(!0).filter(t=>t instanceof f.CanvasItem)??[];break;case"parent":default:e=[this.getParent()].filter(Boolean);break}return e.map(t=>t.style)}_updateKeyframes(){const e=[],t=this.keyframes;for(let n=t.length,o=0;o<n;o++){const{offset:a=o===0?0:o/(n-1),easing:l="linear",...c}=t[o];e.push({offset:a,easing:this._parseEasing(l),props:c})}const r=e[0],i=e[e.length-1];r&&r.offset!==0&&e.unshift({offset:0,easing:this._parseEasing("linear"),props:{}}),i&&i.offset!==1&&e.push({offset:1,easing:this._parseEasing("linear"),props:{}}),this._keyframes=e,this._updateCachedProps()}commitStyles(){if(!this.keyframes.length)return;if(this._updateCurrentTime(),this.isInsideTimeRange())this._isFirstUpdatePosition||(this._isFirstUpdatePosition=!0,this._updateCachedProps());else{if(!this._isFirstUpdatePosition)return;this._isFirstUpdatePosition=!1}const e=this._getTargets(),t=1/e.length,r=this.currentTimeProgress;e.forEach((i,n)=>{const o=t===1?r:ut(Math.max(0,r-t*n)/t,0,1),a=this._cachedProps.get(i);if(!a)return;const l=this._parseKeyframes(o,a);l?.length&&this._commitStyle(o,i,a,l[0],l[1])})}_updateCachedProps(){this.cancel(),this._getTargets().forEach(e=>{const t=new Map,r=this._keyframes;for(let i=r.length,n=0;n<i;n++)Object.keys(r[n].props).forEach(o=>{t.set(o,e[o])});this._cachedProps.set(e,t)})}_parseEasing(e){if(!e)return ls.linear;if(e in ls)return ls[e];const t=e.replace(/cubic-bezier\((.+)\)/,"$1").split(",").map(r=>Number(r));return Sr(t[0],t[1],t[2],t[3])}_parseKeyframes(e,t){let r;const i=this._keyframes;for(let n=i.length,o=0;o<n;o++){const a=i[o],{offset:l,easing:c}=a,h={...a.props};if(r&&e<=l){const{offset:u,easing:d}=r,g={...r.props};return t.forEach((p,y)=>{(!(y in g)||g[y]===null)&&(g[y]=p),(!(y in h)||h[y]===null)&&(h[y]=p)}),[{offset:u,easing:d,props:g},{offset:l,easing:c,props:h}]}r=a}return null}_commitStyle(e,t,r,i,n){const{offset:o,easing:a,props:l}=i,{offset:c,props:h}=n,u=c-o,d=a((e-o)/u),g={width:t.width,height:t.height,fontSize:t.fontSize};r.forEach((p,y)=>{t[y]=this._getDiffValue(y,l[y],h[y],d,g)})}_getDiffValue(e,t,r,i,n){let o,a;if(t==="none"&&(t=void 0),r==="none"&&(r=void 0),t===void 0||r===void 0)if(t!==void 0)o=Or(e,String(t),n),a=Ss(o);else if(r!==void 0)a=Or(e,String(r),n),o=Ss(a);else return;else o=Or(e,String(t),n),a=Or(e,String(r),n);if(Array.isArray(o)&&Array.isArray(a)){const l=new Set,c={},h={};o.forEach(({name:d,args:g})=>{c[d]=g,l.add(d)}),a.forEach(({name:d,args:g})=>{h[d]=g,l.add(d)});let u="";return l.forEach(d=>{const g=Math.max(c[d]?.length??0,h[d]?.length??0),p=c[d],y=h[d];u+=`${d}(${Array.from({length:g},(m,P)=>{const E=p?.[P],b=y?.[P],S=E?.normalizedIntValue??0,w=b?.normalizedIntValue??0;return Number.isNaN(S)||Number.isNaN(w)?b?.value??0:he(S,w,i)}).join(", ")}) `}),u}else if(!Array.isArray(o)&&!Array.isArray(a))return Number.isNaN(o.normalizedIntValue)||Number.isNaN(a.normalizedIntValue)?a.value:he(o.normalizedIntValue,a.normalizedIntValue,i)}isPlaying(){return!this.paused&&this.isInsideTimeRange()}play(){return this._stoped?(this._stoped=!1,this.startTime=this.timelineCurrentTime):this.startTime=this.timelineCurrentTime-this.currentTime,this.paused=!1,!0}pause(){return this.paused=!0,!0}stop(){return this._stoped=!0,this.paused=!0,this._currentTime=0,!0}cancel(){this._getTargets().forEach(e=>{this._cachedProps.get(e)?.forEach((t,r)=>{e[r]=t}),this._cachedProps.delete(e)})}},as([_({fallback:"parent"})],f.Animation.prototype,"effectMode",2),as([_({default:()=>[]})],f.Animation.prototype,"keyframes",2),as([_()],f.Animation.prototype,"easing",2),f.Animation=as([X("Animation",{renderMode:"disabled",processMode:"pausable",processSortMode:"parent_before",duration:2e3})],f.Animation);class cs extends Dt{static _instance;static get instance(){return this._instance||(this._instance=new cs),this._instance}playbackRate=1;muted=!1;volume=1;paused=!1;refresh(){this.emit("refresh")}refreshPaused(){this.emit("refreshPaused")}get processors(){return console.warn("HTML Audio does not support processors"),[]}set processors(e){console.warn("HTML Audio does not support processors")}get audioContext(){return console.warn("HTML Audio does not support audioContext"),null}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this.paused}}class di extends Dt{static PADDING=.1;_source=null;_audio=null;_end=0;_pausedReal=!1;_duration=0;_start=0;_playing=!1;get progress(){return(this._source?.currentTime??0)/this._duration}_paused=!1;get paused(){return this._paused}set paused(e){this._paused!==e&&(this._paused=e,this.refreshPaused())}_playbackRate=1;get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate!==e&&(this._playbackRate=e,this.refresh())}_volume=1;get volume(){return this._volume}set volume(e){this._volume!==e&&(this._volume=e,this.refresh())}_loop=!1;get loop(){return this._loop}set loop(e){this._loop!==e&&(this._loop=e,this.refresh())}_muted=!1;get muted(){return this._muted}set muted(e){this._muted!==e&&(this._muted=e,this.refresh())}set(e,t){if(this[e]===void 0)throw new Error(`Property with name ${e} does not exist.`);switch(e){case"playbackRate":this.playbackRate=t;break;case"volume":this.volume=t;break;case"paused":this.paused=t;break;case"loop":this.loop=t;break;case"muted":this.muted=t;break}return this}_onPlay(){this._playing=!0}_onPause(){this._playing=!1}init(e){this._playing=!1,this._duration=e.source.duration;const t=this._source=e.source.cloneNode(!1);return t.src=e.parent.src,t.onplay=this._onPlay.bind(this),t.onpause=this._onPause.bind(this),e.context.on("refresh",this.refresh),e.context.on("refreshPaused",this.refreshPaused),this._audio=e,this}_stop(){this._source&&this._playing&&(this._source.onended=null,this._source.pause())}stop(){this._stop(),this._source&&this.emit("stop")}get processors(){return console.warn("HTML Audio does not support processors"),[]}set processors(e){console.warn("HTML Audio does not support processors")}refresh(){if(!this._audio||!this._source)return;const e=this._audio.context,t=this._audio.parent;this._source.loop=this._loop||t.loop;const r=e.volume*(e.muted?0:1),i=t.volume*(t.muted?0:1),n=this._volume*(this._muted?0:1);this._source.volume=n*r*i,this._source.playbackRate=this._playbackRate*e.playbackRate*t.playbackRate}refreshPaused(){if(!this._source||!this._audio)return;const e=this._paused||this._audio.parent.paused||this._audio.context.paused;e!==this._pausedReal&&(this._pausedReal=e,e?(this._stop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._source.currentTime,end:this._end,volume:this._volume,playbackRate:this._playbackRate,loop:this._loop})),this.emit("pause",e))}play(e={}){if(!this._source)return;const{start:t=0,end:r=0}=e;r&&console.assert(r>t,"End time is before start time"),e.playbackRate!==void 0&&(this._playbackRate=e.playbackRate),e.volume!==void 0&&(this._volume=e.volume),e.loop!==void 0&&(this._loop=e.loop),e.muted!==void 0&&(this._muted=e.muted),this.refresh(),this.loop&&r!==null&&(console.warn('Looping not support when specifying an "end" time'),this.loop=!1),this._start=t,this._end=r||this._duration,this._start=Math.max(0,this._start-di.PADDING),this._end=Math.min(this._end+di.PADDING,this._duration),this._source.onloadedmetadata=()=>{this._source&&(this._source.currentTime=t,this._source.onloadedmetadata=null,this.emit("progress",t,this._duration),Ce.on(this._onUpdate))},this._source.onended=this._onComplete.bind(this),this._source.play(),this.emit("start")}_onUpdate=()=>{this._source&&(this.emit("progress",this.progress,this._duration),this._source.currentTime>=this._end&&!this._source.loop&&this._onComplete())};_onComplete(){Ce.off(this._onUpdate),this._stop(),this.emit("progress",1,this._duration),this.emit("end",this)}destroy(){Ce.off(this._onUpdate),super.destroy();const e=this._source;e&&(e.onended=null,e.onplay=null,e.onpause=null,this._stop()),this._source=null,this._playbackRate=1,this._volume=1,this._loop=!1,this._end=0,this._start=0,this._duration=0,this._playing=!1,this._pausedReal=!1,this._paused=!1,this._muted=!1,this._audio&&(this._audio.context.off("refresh",this.refresh),this._audio.context.off("refreshPaused",this.refreshPaused),this._audio=null)}}class ic{constructor(e){this.parent=e}source=new globalThis.Audio;_src="";get src(){return this._src}set src(e){this._src!==e&&(this._src=e,this.load())}get duration(){return this.source.duration}get isPlayable(){return!!this.source&&this.source.readyState===4}get context(){return cs.instance}async load(){return new Promise(e=>{this.source.onload=()=>e(this),this.source.src=this._src,this.source.load()})}createSound(){return new di}}class Yn extends Dt{constructor(e,t){super(),this._input=e,this._output=t}_processers=[];get processors(){return this._processers}set processors(e){if(this._processers.forEach(t=>t.disconnect()),this._processers.length=0,this._input.connect(this._output),e.length){this._processers=e.slice(0),this._input.disconnect();let t;e.forEach(r=>{t?t.connect(r.destination):this._input.connect(r.destination),t=r}),t.connect(this._output)}}get destination(){return this._input}}class Wg{constructor(e,t=null){this.destination=e,this.source=t}connect(e){this.source?.connect(e)}disconnect(){this.source?.disconnect()}}function qg(){if(Ms)return new AudioContext;if(As){const s=globalThis.webkitAudioContext;return new s}else throw new Error("Failed to createAudioContext")}function Xg(s,e,t){if(Os)return new OfflineAudioContext(s,e,t);if(Io){const r=globalThis.webkitOfflineAudioContext;return new r(s,e,t)}else throw new Error("Failed to createOfflineAudioContext")}class jt extends Yn{static _instance;static get instance(){return this._instance||(this._instance=new jt),this._instance}static get audioContext(){return this.instance.audioContext}static get offlineContext(){return this.instance.offlineContext}static setParamValue(e,t){this.instance.setParamValue(e,t)}static decode(e){return this.instance.decode(e)}_context;_offlineContext;get audioContext(){return this._context}get offlineContext(){return this._offlineContext}_locked;muted=!1;volume=1;playbackRate=1;autoPause=!0;_paused=!1;_pausedOnBlur=!1;get paused(){return this._paused}set paused(e){e&&this._context.state==="running"?this._context.suspend():!e&&this._context.state==="suspended"&&this._context.resume(),this._paused=e}_compressor;_analyser;constructor(){const e=qg(),t=Xg(1,2,Os?Math.max(8e3,Math.min(96e3,e.sampleRate)):44100),r=e.createDynamicsCompressor(),i=e.createAnalyser();i.connect(r),r.connect(e.destination),super(i,r),this._context=e,this._offlineContext=t,this._compressor=r,this._analyser=i,this._locked=e.state==="suspended"&&(wt||Do),Dr&&(this._locked&&(this._unlock(),document.addEventListener("mousedown",this._unlock,!0),document.addEventListener("touchstart",this._unlock,!0),document.addEventListener("touchend",this._unlock,!0)),globalThis.addEventListener("focus",this._onFocus),globalThis.addEventListener("blur",this._onBlur))}_onFocus(){if(!this.autoPause)return;const e=this._context.state;(e==="suspended"||e==="interrupted"||!this._locked)&&(this.paused=this._pausedOnBlur,this.refreshPaused())}_onBlur(){this.autoPause&&(this._locked||(this._pausedOnBlur=this._paused,this.paused=!0,this.refreshPaused()))}_unlock=()=>{this._locked&&(this.playEmptySound(),this._context.state==="running"&&(document.removeEventListener("mousedown",this._unlock,!0),document.removeEventListener("touchend",this._unlock,!0),document.removeEventListener("touchstart",this._unlock,!0),this._locked=!1))};playEmptySound(){const e=this._context.createBufferSource();e.buffer=this._context.createBuffer(1,1,22050),e.connect(this._context.destination),e.start(0,0,0),e.context.state==="suspended"&&e.context.resume()}refresh(){this.emit("refresh")}refreshPaused(){this.emit("refreshPaused")}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this._paused}decode(e){return new Promise((t,r)=>{const i=o=>{r(new Error(o?.message||"Unable to decode file"))},n=this._offlineContext.decodeAudioData(e,t,i);n&&n.catch(i)})}setParamValue(e,t){e.setValueAtTime?e.setValueAtTime(t,this._context.currentTime):e.value=t}}class sc extends Dt{_audio=null;_sourceNode=null;_gain=null;_progress=0;get progress(){return this._progress}_pausedReal=!1;_paused=!1;get paused(){return this._paused}set paused(e){this._paused!==e&&(this._paused=e,this.refreshPaused())}_volume=1;get volume(){return this._volume}set volume(e){this._volume!==e&&(this._volume=e,this.refresh())}_playbackRate=1;get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate!==e&&(this._playbackRate=e,this.refresh(),this._update(!0))}_loop=!1;get loop(){return this._loop}set loop(e){this._loop!==e&&(this._loop=e,this.refresh())}_muted=!1;get muted(){return this._muted}set muted(e){this._muted!==e&&(this._muted=e,this.refresh())}_duration=0;_end=0;_elapsed=0;_lastUpdate=this._now();_processors=[];init(e){return this._audio=e,e.context.on("refresh",this.refresh),e.context.on("refreshPaused",this.refreshPaused),this}_now(){return this._audio?.context.audioContext.currentTime??0}play(e={}){if(!this._audio)return;const{end:t=0,start:r=0}=e;t&&console.assert(t>r,"End time is before start time"),this._end=t,this._elapsed=r,e.volume!==void 0&&(this._volume=e.volume),e.playbackRate!==void 0&&(this._playbackRate=e.playbackRate),e.muted!==void 0&&(this._muted=e.muted),e.loop!==void 0&&(this._loop=e.loop),e.processors!==void 0&&(this._processors=e.processors),this._paused=!1;const{source:i,gain:n}=this._audio.cloneSource();this._sourceNode=i,this._gain=n,this.refresh(),i.onended=this._onComplete.bind(this),this._duration=i.buffer?.duration??0,this._lastUpdate=this._now(),this._loop?(i.loopStart=r,i.loopEnd=t,i.start(0,r)):t?i.start(0,r,t-r):i.start(0,r),this.emit("start"),this._update(!0),this._enableTicker(!0)}_stop(){if(this._sourceNode){this._enableTicker(!1),this._sourceNode.onended=null,this._sourceNode.stop(0),this._sourceNode.disconnect();try{this._sourceNode.buffer=null}catch(e){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",e)}this._sourceNode=null}}stop(){this._sourceNode&&(this._stop(),this.emit("stop"))}_update(e=!1){if(this._sourceNode){const t=this._now(),r=t-this._lastUpdate;if(r>0||e){this._elapsed+=r*this._sourceNode.playbackRate.value,this._lastUpdate=t;const i=this._duration;let n;if(this._sourceNode.loopStart){const o=this._sourceNode.loopEnd-this._sourceNode.loopStart;n=(this._sourceNode.loopStart+this._elapsed%o)/i}else n=this._elapsed%i/i;this._progress=n,this.emit("progress",n,i)}}}refresh(){if(!this._audio||!this._sourceNode)return;const e=this._audio.context,t=this._audio.parent;this._sourceNode.loop=this._loop||t.loop,e.setParamValue(this._gain.gain,this._volume*(this._muted?0:1)*t.volume*(t.muted?0:1)*e.volume*(e.muted?0:1)),e.setParamValue(this._sourceNode.playbackRate,this._playbackRate*t.playbackRate*e.playbackRate),this.applyProcessors()}applyProcessors(){if(this._sourceNode&&this._processors.length){this._sourceNode.disconnect();let e=this._sourceNode;this._processors.forEach(t=>{e.connect(t.destination),e=t}),e.connect(this._gain)}}refreshPaused(){if(!this._audio)return;const e=this._paused||this._audio.parent.paused||this._audio.context.paused;e!==this._pausedReal&&(this._pausedReal=e,e?(this._stop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._elapsed%this._duration,end:this._end,playbackRate:this._playbackRate,loop:this._loop,volume:this._volume})),this.emit("pause",e))}_onComplete=()=>{if(this._sourceNode){this._enableTicker(!1),this._sourceNode.onended=null,this._sourceNode.disconnect();try{this._sourceNode.buffer=null}catch(e){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",e)}}this._sourceNode=null,this._progress=1,this.emit("progress",1,this._duration),this.emit("end",this)};_updateListener=()=>this._update();_enableTicker(e){Ce.off(this._updateListener),e&&Ce.on(this._updateListener)}destroy(){super.destroy(),this._stop(),this._gain?.disconnect(),this._gain=null,this._audio?.context.off("refresh",this.refresh),this._audio?.context.off("refreshPaused",this.refreshPaused),this._audio=null,this._processors.forEach(e=>e.disconnect()),this._processors.length=0,this._end=0,this._playbackRate=1,this._volume=1,this._loop=!1,this._elapsed=0,this._duration=0,this._paused=!1,this._muted=!1,this._pausedReal=!1}}class nc extends Yn{constructor(e){const t=jt.audioContext,r=t.createBufferSource(),i=t.createGain(),n=t.createAnalyser();r.connect(n),n.connect(i),i.connect(jt.instance.destination),super(n,i),this.parent=e,this._sourceNode=r,this.gain=i,this.analyser=n}_sourceBuffer;_sourceNode;_sourceLoad;gain;analyser;get context(){return jt.instance}get isPlayable(){return!!this._sourceNode.buffer}get duration(){return this._sourceNode.buffer?.duration??0}get buffer(){return this._sourceNode.buffer}set buffer(e){this._sourceNode.buffer=e}async load(){return this._sourceLoad||(this._sourceLoad=new Promise(e=>{this._sourceBuffer?this._decode(this._sourceBuffer).then(()=>e(this)):this.parent.src?this._loadUrl(this.parent.src).then(()=>e(this)):e(this)})),this._sourceLoad}_loadUrl(e){return new Promise(t=>{fetch(e).then(r=>r.arrayBuffer()).then(r=>this._decode(r)).finally(()=>t(this))})}_decode(e){return Promise.resolve(e instanceof AudioBuffer?e:jt.decode(e)).then(t=>(this.parent.isLoaded=!0,this.buffer=t,t))}cloneSource(){const e=this.context,t=this._sourceNode,r=e.audioContext.createBufferSource(),i=e.audioContext.createGain();return r.buffer=t.buffer,r.loop=t.loop,e.setParamValue(r.playbackRate,t.playbackRate.value),r.connect(i),i.connect(this.destination),{source:r,gain:i}}createSound(){return new sc}}var Hg=Object.defineProperty,Yg=Object.getOwnPropertyDescriptor,Kg=(s,e,t)=>e in s?Hg(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Zg=(s,e,t,r)=>{for(var i=r>1?void 0:r?Yg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i},Jg=(s,e,t)=>Kg(s,e+"",t);f.Audio=class extends f.TimelineNode{_sounds=[];_platformAudio=Ro?new nc(this):new ic(this);get platformAudio(){return this._platformAudio}_src;get src(){return this._src}set src(e){this._src!==e&&(this._src=e,this.load())}isLoaded=!1;get isPlayable(){return this.isLoaded&&this._platformAudio.isPlayable}get audioDuration(){return this._platformAudio.duration*1e3}_volume=1;get volume(){return this._volume}set volume(e){this._volume!==e&&(this._volume=e,this.refresh())}_muted=!1;get muted(){return this._muted}set muted(e){this._muted!==e&&(this._muted=e,this.refresh())}_loop=!1;get loop(){return this._loop}set loop(e){this._loop!==e&&(this._loop=e,this.refresh())}_playbackRate=1;get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate!==e&&(this._playbackRate=e,this.refresh())}_isPlaying=!1;get isPlaying(){return this._isPlaying}multiple=!1;start=0;end=0;constructor(e=""){super(),this.src=e}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"paused":this.refreshPaused();break}}async load(){return await this._platformAudio.load(),this}pause(){return this._isPlaying=!1,this.paused=!0,this}resume(){return this._isPlaying=this._sounds.length>0,this.paused=!1,this}stop(){if(!this.isPlayable)return this;this._isPlaying=!1;for(let e=this._sounds.length-1;e>=0;e--)this._sounds[e].stop();return this}play(e={}){if(!this.isLoaded)return;this.multiple||this._removeSounds(),this._isPlaying=!0;const t=this._createSound();this._sounds.push(t),t.once("end",()=>{e.complete?.(),this._onComplete(t)}),t.once("stop",()=>this._onComplete(t));const r=(e?.start??this.start)/1e3,i=(e?.end??this.end)/1e3;return t.play({...e,start:r,end:i}),t}_removeSounds(){for(let e=this._sounds.length-1;e>=0;e--)this._recycleSound(this._sounds[e]);this._sounds.length=0}_createSound(){return f.Audio._soundPool.length>0?f.Audio._soundPool.pop().init(this._platformAudio):this._platformAudio.createSound().init(this._platformAudio)}refresh(){for(let e=this._sounds.length,t=0;t<e;t++)this._sounds[t].refresh()}refreshPaused(){for(let e=this._sounds.length,t=0;t<e;t++)this._sounds[t].refreshPaused()}_onComplete=e=>{if(this._sounds){const t=this._sounds.indexOf(e);t>-1&&this._sounds.splice(t,1),this._isPlaying=this._sounds.length>0}this._recycleSound(e)};_recycleSound(e){e.destroy(),f.Audio._soundPool.includes(e)||f.Audio._soundPool.push(e)}_prevTime=0;_timer=0;_process(e){if(super._process(e),this.canProcess()){const t=this._tree?.timeline.currentTime??0;t-this._prevTime>0&&(this._timer||(this._setTimeStop(),this.play({start:this.start+(t-this.delay)%this.duration})),this._isPlaying&&this._setTimeStop()),this._prevTime=t}}_setTimeStop(){this._timer&&clearTimeout(this._timer),this._timer=setTimeout(()=>{this.stop(),this._timer=0},100)}},Jg(f.Audio,"_soundPool",[]),f.Audio=Zg([X("Audio")],f.Audio);class Qg extends f.Node2D{}var em=Object.defineProperty,tm=Object.getOwnPropertyDescriptor,hs=(s,e,t,r)=>{for(var i=r>1?void 0:r?tm(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&em(e,t,i),i};f.AudioWaveform=class extends f.Element2D{_audioBuffer;_src=Dr?new le(document.createElement("canvas")):void 0;_needsUpdateTexture=!1;constructor(e={}){super(),this.setProperties(e)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"src":this._loadSrc(t);break;case"gap":case"color":case"width":case"height":this._needsUpdateTexture=!0;break}}async _loadSrc(e){await globalThis.fetch(e).then(t=>t.arrayBuffer()).then(t=>jt.decode(t)).then(t=>{this._audioBuffer=t,this.syncTexture(!0)})}syncTexture(e=!1){const t=this._audioBuffer;if(!t||!e&&!this._needsUpdateTexture)return;this._needsUpdateTexture=!1;const r=this._src?.source;if(!r)return;const{width:i=0,height:n=0}=this.style;r.width=i,r.height=n;const o=r.getContext("2d");if(!o){console.warn("Failed to getContext('2d') in syncTexture");return}o.fillStyle=this.color;const a=t.getChannelData(0),l=Math.ceil(a.length/i),c=n/2;for(let h=1,u=-1,d=0;d<i;d++){for(let g=0;g<l;g++){const p=a[d*l+g];p<h&&(h=p),p>u&&(u=p)}if(!this.gap||d%(this.gap*2)===0){const g=d,p=(1+h)*c,y=this.gap||1,m=Math.max(1,(u-h)*c);o.fillRect(g,p,y,m),h=1,u=-1}}this._src?.requestUpload(),this.requestRedraw()}_process(e){this.syncTexture(),super._process(e)}_drawSrc(){const e=this._src;e?.isValid()&&(this.context.fillStyle=e,this.context.uvTransform=new ke().scale(1/this.style.width,1/this.style.height))}},hs([_()],f.AudioWaveform.prototype,"src",2),hs([_({fallback:0})],f.AudioWaveform.prototype,"gap",2),hs([_({fallback:"#000000"})],f.AudioWaveform.prototype,"color",2),f.AudioWaveform=hs([X("AudioWaveform")],f.AudioWaveform);var rm=Object.defineProperty,im=Object.getOwnPropertyDescriptor,sm=(s,e,t)=>e in s?rm(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,nm=(s,e,t,r)=>{for(var i=r>1?void 0:r?im(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i},om=(s,e,t)=>sm(s,e+"",t);f.KawaseTransition=class extends f.Transition{blur=10;quality=10;apply(e,t){const r=this.currentTimeProgress;let i,n;r<.5?(i=0,n=(.5-r)/.5):(i=1,n=(r-.5)/.5);const o=this.blur,a=this.quality,l=t.width,c=t.height,h=[],u=[o];if(o>0){let P=o;const E=o/a;for(let b=1;b<a;b++)P-=E,u.push(P)}const d=1/l,g=1/c,p=[];let y;const m=a-1;for(let P=0;P<m;P++)y=u[P]+.5,p[0]=y*d,p[1]=y*g,h.push({offset:p});y=u[m]+.5,p[0]=y*d,p[1]=y*g,h.push({offset:p}),h.forEach(P=>{Q.draw(e,f.KawaseTransition.material,{sampler:i,progress:n,...P})})}},om(f.KawaseTransition,"material",new re({vert:`attribute vec2 position;
|
|
957
|
+
</svg>`}function wg(){const s=new Tt;return{name:"listStyle",pathSet:s,update:e=>{s.paths.length=0;const{paragraphs:t,isVertical:r,fontSize:i}=e,n=i*.45;t.forEach(o=>{const{computedStyle:a}=o,{color:l,listStyleImage:c,listStyleColormap:h,listStyleSize:u,listStyleType:d}=a,g=Bn(h);let p=u,y;if(!K(c))y=c;else if(!K(d)){const x=i*.38/2;switch(p=p==="cover"?x*2:p,d){case"disc":y=bg(x,String(l));break}}if(!y)return;const m=Ws(y),P=m.getBoundingBox(),E=o.fragments[0]?.characters[0];if(!E)return;const{inlineBox:b}=E,S=p==="cover"?1:Un(p,{total:i,fontSize:i})/i,w=new _e;if(r){const x=i/P.height*S;w.translate(-P.left,-P.top).rotate(Math.PI/2).scale(x,x).translate(b.left+(b.width-P.height*x)/2,b.top-n)}else{const x=i/P.height*S;w.translate(-P.left,-P.top).scale(x,x).translate(b.left-P.width*x-n,b.top+(b.height-P.height*x)/2)}s.paths.push(...m.paths.map(x=>{const T=x.clone();return T.applyTransform(w),T.style.fill&&T.style.fill in g&&(T.style.fill=g[T.style.fill]),T.style.stroke&&T.style.stroke in g&&(T.style.stroke=g[T.style.stroke]),T}))})}}}function xg(){return{name:"outline"}}const $t=new k,Tr=new _e,zt=new _e;function Pg(){const s=new Tt;return{name:"render",pathSet:s,update:e=>{s.paths.length=0;const{paragraphs:t}=e;t.forEach(r=>{r.fragments.forEach(i=>{i.characters.forEach(n=>{s.paths.push(n.path)})})})},getBoundingBox:e=>{const{characters:t,fontSize:r,effects:i}=e,n=[];return t.forEach(o=>{i?.forEach(a=>{if(!o.glyphBox)return;const l=o.glyphBox.clone(),c=Nn(e,a);$t.set(l.left,l.top),$t.applyMatrix3(c),l.left=$t.x,l.top=$t.y,$t.set(l.right,l.bottom),$t.applyMatrix3(c),l.width=$t.x-l.left,l.height=$t.y-l.top;const h=(a.shadowOffsetX??0)*r,u=(a.shadowOffsetY??0)*r,d=Math.max(.1,a.textStrokeWidth??0)*r;l.left+=h-d,l.top+=u-d,l.width+=d*2,l.height+=d*2,n.push(l)})}),n.length?Z.from(...n):void 0},render:(e,t)=>{const{paragraphs:r,glyphBox:i,effects:n}=t;n?n.forEach(o=>{is(o,i,e),e.save();const[a,l,c,h,u,d]=Nn(t,o).transpose().elements;e.transform(a,h,l,u,c,d),t.forEachCharacter(g=>{g.drawTo(e,o)}),e.restore()}):r.forEach(o=>{o.fragments.forEach(a=>{a.characters.forEach(l=>{l.drawTo(e)})})}),t.debug&&r.forEach(o=>{e.strokeRect(o.lineBox.x,o.lineBox.y,o.lineBox.width,o.lineBox.height)})}}}function Nn(s,e){const{fontSize:t,glyphBox:r}=s,i=(e.translateX??0)*t,n=(e.translateY??0)*t,o=Math.PI*2,a=(e.skewX??0)/360*o,l=(e.skewY??0)/360*o,{left:c,top:h,width:u,height:d}=r,g=c+u/2,p=h+d/2;return Tr.identity(),zt.makeTranslation(i,n),Tr.multiply(zt),zt.makeTranslation(g,p),Tr.multiply(zt),zt.set(1,Math.tan(a),0,Math.tan(l),1,0,0,0,1),Tr.multiply(zt),zt.makeTranslation(-g,-p),Tr.multiply(zt),Tr.clone()}function Cg(){const s=new Tt;return{name:"textDecoration",pathSet:s,update:e=>{s.paths.length=0;const t=[];let r,i;e.forEachCharacter(n=>{const{computedStyle:o,isVertical:a,inlineBox:l,underlinePosition:c,underlineThickness:h,strikeoutPosition:u,strikeoutSize:d}=n,{color:g,textDecoration:p,writingMode:y}=o;if(K(p))i=void 0;else{let m=!1;if(i?.textDecoration===p&&i?.writingMode===y&&i?.color===g&&(a?r[0].inlineBox.left===l.left:r[0].inlineBox.top===l.top))switch(p){case"underline":r[0].underlinePosition===c&&r[0].underlineThickness===h&&(m=!0);break;case"line-through":r[0].strikeoutPosition===u&&r[0].strikeoutSize===d&&(m=!0);break}m?r.push(n):(r=[],r.push(n),t.push(r)),i=o}}),t.forEach(n=>{const{computedStyle:o,isVertical:a,underlinePosition:l,underlineThickness:c,strikeoutPosition:h,strikeoutSize:u}=n[0],{color:d,textDecoration:g}=o,p=Z.from(...n.map(T=>T.inlineBox)),{left:y,top:m,width:P,height:E}=p;let b=a?y+P:m;const S=a?-1:1;let w=0;switch(g){case"overline":w=c*2;break;case"underline":b+=S*l,w=c*2;break;case"line-through":b+=S*h,w=u*2;break}b-=w;let x;a?x=new ge([{type:"M",x:b,y:m},{type:"L",x:b,y:m+E},{type:"L",x:b+w,y:m+E},{type:"L",x:b+w,y:m},{type:"Z"}],{fill:d}):x=new ge([{type:"M",x:y,y:b},{type:"L",x:y+P,y:b},{type:"L",x:y+P,y:b+w},{type:"L",x:y,y:b+w},{type:"Z"}],{fill:d}),s.paths.push(x)})},render:(e,t)=>{const{effects:r,computedStyle:i}=t;r?r.forEach(n=>{e.save();const[o,a,l,c,h,u]=Nn(t,n).transpose().elements;e.transform(o,c,a,h,l,u),s.paths.forEach(d=>{Pr({ctx:e,path:d,fontSize:i.fontSize,...n})}),e.restore()}):s.paths.forEach(n=>{Pr({ctx:e,path:n,fontSize:i.fontSize})})}}}var Tg=Object.defineProperty,Vt=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Tg(e,t,i),i};const Wl=Po();class kt extends bs{needsUpdate=!0;computedStyle={...Wl};paragraphs=[];lineBox=new Z;rawGlyphBox=new Z;glyphBox=new Z;pathBox=new Z;boundingBox=new Z;measurer=new ss;plugins=new Map;pathSets=[];get fontSize(){return this.computedStyle.fontSize}get isVertical(){return this.computedStyle.writingMode.includes("vertical")}get characters(){return this.paragraphs.flatMap(e=>e.fragments.flatMap(t=>t.characters))}constructor(e={}){super(),this.set(e)}set(e={}){const{content:t,effects:r,style:i,measureDom:n,fonts:o,fill:a,outline:l}=To(e);this.debug=e.debug??!1,this.content=t,this.effects=r,this.style=i,this.measureDom=n,this.fonts=o,this.fill=a,this.outline=l,this.use(vg()).use(xg()).use(wg()).use(Cg()).use(_g()).use(Pg()),(e.plugins??[]).forEach(c=>{this.use(c)}),this.updateParagraphs()}use(e){return this.plugins.set(e.name,e),this}forEachCharacter(e){return this.paragraphs.forEach((t,r)=>{t.fragments.forEach((i,n)=>{i.characters.forEach((o,a)=>{e(o,{paragraphIndex:r,fragmentIndex:n,characterIndex:a})})})}),this}async load(){await Promise.all(Array.from(this.plugins.values()).map(e=>e.load?.(this)))}updateParagraphs(){this.computedStyle={...Wl,...this.style};const{content:e}=this,t=[];return e.forEach((r,i)=>{const{fragments:n,fill:o,outline:a,...l}=r,c=new yg(l,i,this);c.fill=o,c.outline=a,n.forEach((h,u)=>{const{content:d,fill:g,outline:p,...y}=h;if(d!==void 0){const m=new mg(d,y,u,c);c.fragments.push(m),m.fill=g,m.outline=p}}),t.push(c)}),this.paragraphs=t,this}createDom(){return this.updateParagraphs(),this.measurer.createDom(this.paragraphs,this.computedStyle)}measure(e=this.measureDom){const t={paragraphs:this.paragraphs,lineBox:this.lineBox,rawGlyphBox:this.rawGlyphBox,glyphBox:this.glyphBox,pathBox:this.pathBox,boundingBox:this.boundingBox};this.updateParagraphs();const r=this.measurer.measure(this.paragraphs,this.computedStyle,e);this.paragraphs=r.paragraphs,this.lineBox=r.boundingBox,this.characters.forEach(i=>{i.update(this.fonts)}),this.rawGlyphBox=this.getGlyphBox(),Array.from(this.plugins.values()).sort((i,n)=>(i.updateOrder??0)-(n.updateOrder??0)).forEach(i=>{i.update?.(this)}),this.pathSets.length=0,Array.from(this.plugins.values()).sort((i,n)=>(i.renderOrder??0)-(n.renderOrder??0)).forEach(i=>{i.pathSet?.paths.length&&this.pathSets.push(i.pathSet)}),this.glyphBox=this.getGlyphBox(),this.updatePathBox().updateBoundingBox();for(const i in t)r[i]=this[i],this[i]=t[i];return this.emit("measure",{text:this,result:r}),r}getGlyphBox(){const e=k.MAX,t=k.MIN;return this.characters.forEach(r=>{if(!r.getGlyphMinMax(e,t)){const{inlineBox:i}=r,{left:n,top:o,width:a,height:l}=i,c=new k(n,o),h=new k(n+a,o+l);e.min(c,h),t.max(c,h)}}),new Z(e.x,e.y,t.x-e.x,t.y-e.y)}updatePathBox(){return this.pathBox=Z.from(this.glyphBox,...Array.from(this.plugins.values()).map(e=>e.getBoundingBox?e.getBoundingBox(this):e.pathSet?.getBoundingBox()).filter(Boolean)),this}updateBoundingBox(){return this.boundingBox=Z.from(this.rawGlyphBox,this.lineBox,this.pathBox),this}requestUpdate(){return this.needsUpdate=!0,this}update(e=this.measureDom){this.needsUpdate=!1;const t=this.measure(e);for(const r in t)this[r]=t[r];return this.emit("update",{text:this}),this}render(e){const{view:t,pixelRatio:r=2}=e,i=t.getContext("2d");i&&(this.needsUpdate&&this.update(),cg(i,r,this.boundingBox),hg(i,this),Array.from(this.plugins.values()).sort((n,o)=>(n.renderOrder??0)-(o.renderOrder??0)).forEach(n=>{if(n.render)n.render?.(i,this);else if(n.pathSet){const o=this.computedStyle;n.pathSet.paths.forEach(a=>{Pr({ctx:i,path:a,fontSize:o.fontSize})})}}),this.emit("render",{text:this,view:t,pixelRatio:r}),e.onContext?.(i))}toString(){return this.content.flatMap(e=>e.fragments.map(t=>t.content)).join("")}}Vt([_({internal:!0})],kt.prototype,"debug"),Vt([_()],kt.prototype,"content"),Vt([_()],kt.prototype,"style"),Vt([_()],kt.prototype,"effects"),Vt([_()],kt.prototype,"fill"),Vt([_()],kt.prototype,"outline"),Vt([_({internal:!0})],kt.prototype,"measureDom"),Vt([_({internal:!0})],kt.prototype,"fonts");var Sg=Object.defineProperty,Gt=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Sg(e,t,i),i};class vt extends xt{constructor(e){super(),this.parent=e,this.base=new kt,this.base.setPropertyAccessor(this)}base;_texture=new Ui;_textureMap=new Map;setProperties(e){return super.setProperties(K(e)?void 0:To(e))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"enabled":this.parent.requestRedraw();break;case"effects":case"measureDom":case"fonts":this.update();break;case"fill":case"outline":case"content":this.update(),this._updateTextureMap();break}}update(){this.base.fonts=this.base.fonts??this.parent.tree?.fonts,this.base.update(),this.parent.requestRedraw()}_updateTextureMap(){this._textureMap.clear();const e=[];if(this.base.paragraphs.forEach((t,r)=>{const i=[];if(t.fragments.forEach((n,o)=>{if(n.characters.length){const a=Z.from(...n.characters.map(l=>l.compatibleGlyphBox));this._updateTexture(`${r}.${o}.fill`,n.fill,a),this._updateTexture(`${r}.${o}.outline`,n.outline,a),i.push(a)}}),i.length){const n=Z.from(...i);this._updateTexture(`${r}.fill`,t.fill,n),this._updateTexture(`${r}.outline`,t.outline,n),e.push(n)}}),e.length){const t=Z.from(...e);this._updateTexture("fill",this.fill,t),this._updateTexture("outline",this.outline,t)}}async _updateTexture(e,t,r){t&&Object.keys(t).length>0&&(this._textureMap.set(e,{texture:await this._loadTexture(t,r),box:r}),this.parent.requestRedraw())}async _loadTexture(e,t){return e.linearGradient||e.radialGradient?new zr(e.linearGradient??e.radialGradient,t.width,t.height):K(e.image)?void 0:(this.parent.tree?.log(`load image ${e.image}`),await Ke.texture.load(e.image))}setContent(e){this.content=Ps(e)}measure(){return this.update(),this.base.measure()}isValid(){return!!(this.enabled&&!/^\s*$/.test(this.base.toString()))}_createVertTransform(){const e=this.parent;if(e.scale.x>0&&e.scale.y>0)return;const t=e.scale.x*e.scale.y,r=e.getTransformOrigin();return new ke().translate(-r.x,-r.y).scale(t>0?1:-1,1).translate(r.x,r.y)}useTextureDraw(){return!!this.effects?.length||this.content.some(e=>e.fragments.some(t=>!!t.highlightImage))}_pathDraw(e){this.base.pathSets.forEach(t=>{t.paths.forEach(r=>{const i=r.getMeta();if(i instanceof Vl){const n=i.parent.index,o=i.parent.parent.index;if(r.style.fill&&!K(r.style.fill))if(typeof r.style.fill=="object"){const a=r.style.fill,l=this._textureMap.get(`${o}.${n}.fill`)??this._textureMap.get(`${o}.fill`)??this._textureMap.get("fill");if(a.enabled!==!1&&(l||a.color)){const{uvTransform:c,disableWrapMode:h}=rs(a,l?.box??{width:this.parent.size.width,height:this.parent.size.height});e.addPath(r),e.style={...r.style},e.uvTransform=c,e.fillStyle=l?.texture??a.color,e.vertTransform=this._createVertTransform(),e.fill({disableWrapMode:h})}}else e.addPath(r),e.style={...r.style},e.vertTransform=this._createVertTransform(),e.fill();if(r.style.stroke&&!K(r.style.stroke))if(typeof r.style.stroke=="object"){const a=r.style.stroke,l=this._textureMap.get(`${o}.${n}.outline`)??this._textureMap.get(`${o}.outline`)??this._textureMap.get("outline");if(a.enabled!==!1&&(l||a.color)&&(a.width===void 0||a.width)){const{uvTransform:c,disableWrapMode:h}=rs(a,l?.box??{width:this.parent.size.width,height:this.parent.size.height});e.addPath(r),e.style={...r.style},e.lineWidth=a.width||1,e.uvTransform=c,e.strokeStyle=l?.texture??a.color,e.lineCap=a.lineCap,e.lineJoin=a.lineJoin,e.vertTransform=this._createVertTransform(),e.stroke({disableWrapMode:h})}}else e.addPath(r),e.style={...r.style},e.vertTransform=this._createVertTransform(),e.stroke()}else e.addPath(r),e.style={...r.style},e.vertTransform=this._createVertTransform(),e.fill()})})}_textureDraw(e){this._texture.width=Math.round(this.base.boundingBox.width),this._texture.height=Math.round(this.base.boundingBox.height),this.base.render({view:this._texture.source}),e.fillStyle=this._texture,e.vertTransform=this._createVertTransform(),e.fill()}draw(){const e=this.parent.context;this.useTextureDraw()?this._textureDraw(e):this._pathDraw(e)}}Gt([_({fallback:!0})],vt.prototype,"enabled"),Gt([_({fallback:()=>[]})],vt.prototype,"content"),Gt([_({alias:"parent.style.json"})],vt.prototype,"style"),Gt([_()],vt.prototype,"effects"),Gt([_()],vt.prototype,"fill"),Gt([_()],vt.prototype,"outline"),Gt([_({alias:"base.measureDom"})],vt.prototype,"measureDom"),Gt([_({alias:"base.fonts"})],vt.prototype,"fonts");var Eg=Object.getOwnPropertyDescriptor,Mg=(s,e,t,r)=>{for(var i=r>1?void 0:r?Eg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};const Ag=new Set(Object.keys(wo())),Og=new Set(Object.keys(xo()));f.BaseElement2D=class extends f.Node2D{size=new de().on("update",()=>{this.updateGlobalTransform(),this.requestRedraw()});get style(){return this._style}set style(e){const t=(...r)=>{this.emit("updateStyleProperty",r[0],r[1],r[2]),this._updateStyleProperty(r[0],r[1],r[2])};e.on("updateProperty",t),this._style?.off("updateProperty",t),this._style=e}_background=new Dn(this);get background(){return this._background}set background(e){this._background.resetProperties().setProperties(e)}_shape=new ir(this);get shape(){return this._shape}set shape(e){this._shape.resetProperties().setProperties(e)}_fill=new Oe(this);get fill(){return this._fill}set fill(e){this._fill.resetProperties().setProperties(e)}_outline=new tr(this);get outline(){return this._outline}set outline(e){this._outline.resetProperties().setProperties(e)}_foreground=new In(this);get foreground(){return this._foreground}set foreground(e){this._foreground.resetProperties().setProperties(e)}_text=new vt(this);get text(){return this._text}set text(e){this._text.resetProperties().setProperties(e)}_shadow=new rr(this);get shadow(){return this._shadow}set shadow(e){this._shadow.resetProperties().setProperties(e)}constructor(e,t=[]){super(),this._updateStyleProperty=this._updateStyleProperty.bind(this),this.style=new ui,this.setProperties(e).append(t)}_treeEnter(e){super._treeEnter(e),this._text.isValid()&&this._text.update()}setProperties(e){if(e){const{style:t,text:r,shape:i,background:n,fill:o,outline:a,foreground:l,shadow:c,...h}=e;t&&this.style.setProperties(t),n&&this.background.setProperties(n),i&&this.shape.setProperties(i),o&&this.fill.setProperties(o),a&&this.outline.setProperties(a),r&&this.text.setProperties(r),l&&this.foreground.setProperties(l),c&&this.shadow.setProperties(c),super.setProperties(h)}return this}_updateStyleProperty(e,t,r){switch(e){case"rotate":this.rotation=this.style.rotate*Xo;break;case"scaleX":this.scale.x=this.style.scaleX,this.text.isValid()&&(t^r)<0&&this.requestRedraw();break;case"scaleY":this.scale.y=this.style.scaleY,this.text.isValid()&&(t^r)<0&&this.requestRedraw();break;case"skewX":this.skew.x=this.style.skewX;break;case"skewY":this.skew.y=this.style.skewY;break;case"transform":case"transformOrigin":this.updateGlobalTransform();break;case"opacity":this.opacity=this.style.opacity;break;case"visibility":this.visible=this.style.visibility==="visible";break;case"filter":this.requestRepaint();break;case"maskImage":this._updateMaskImage();break;case"backgroundColor":this.background.color=this.style.backgroundColor;break;case"backgroundImage":this.background.image=this.style.backgroundImage;break;case"borderStyle":case"outlineStyle":this.outline.style=t;break;case"borderWidth":case"outlineWidth":this.outline.width=t;break;case"borderColor":case"outlineColor":this.outline.color=t;break;case"borderRadius":default:this.requestRedraw();break}(Og.has(e)||Ag.has(e))&&this.text.isValid()&&this.text.update()}_process(e){this.foreground.updateFrameIndex(),this.fill.updateFrameIndex(),this.outline.updateFrameIndex(),this.background.updateFrameIndex(),super._process(e)}_updateMaskImage(){const e="__$style.maskImage",t=this.style.maskImage;if(t&&t!=="none"){const r=this.getNode(e);r?r.src=t:this.appendChild(new f.MaskEffect({name:e,src:t}),"back")}else{const r=this.getNode(e);r&&this.removeChild(r)}}getTransformOrigin(){const{width:e,height:t}=this.size,[r,i]=ml(this.style.transformOrigin);return new de(r*e,i*t)}updateTransform(e){const{width:t,height:r}=this.size;super.updateTransform(i=>{gl(this.style.transform??"",t,r,i),e?.(i)})}updateGlobalTransform(){super.updateGlobalTransform(),this._updateOverflow()}_relayout(e){return super._relayout(e).map(t=>({...t,dimension:this.size.toFloat32Array()}))}getRect(){return this.getGlobalAabb()}_getPointArray(){const{width:e,height:t}=this.size,r=0,i=0,n=r+e,o=i+t;return[{x:r,y:i},{x:r,y:o},{x:n,y:i},{x:n,y:o}]}getAabb(){return new It(this._getPointArray().map(e=>this.transform.apply(e)))}getGlobalAabb(){return new It(this._getPointArray().map(e=>this.globalTransform.apply(e)))}getObb(){const e=this.getTransformOrigin(),t=this.transform.apply(e).sub(e);return{rect:new It(this._getPointArray().map(r=>(r.x+=t.x,r.y+=t.y,r))),rotation:this.rotation}}getGlobalObb(){const e=this.getTransformOrigin(),t=this.globalTransform.apply(e).sub(e);return{rect:new It(this._getPointArray().map(r=>(r.x+=t.x,r.y+=t.y,r))),rotation:this.globalRotation}}_updateOverflow(){this.style.overflow==="hidden"?this.mask=this.getRect().toJSON():this.mask=void 0}_draw(){super._draw(),this._background.isValid()&&(this._tree?.log(this.name,"background drawing"),this._shape.draw(!this._background.fillWithShape),this._background.draw()),this._fill.isValid()&&(this._tree?.log(this.name,"fill drawing"),this._shape.draw(),this._fill.draw()),this._outline.isValid()&&(this._tree?.log(this.name,"outline drawing"),this._shape.draw(),this._outline.draw()),this._foreground.isValid()&&(this._tree?.log(this.name,"foreground drawing"),this._shape.draw(!this._foreground.fillWithShape),this._foreground.draw()),this._text.isValid()&&(this._tree?.log(this.name,"text drawing"),this._text.useTextureDraw()&&this._shape.draw(!0),this._text.draw()),this._drawContent()}_drawContent(){}_repaint(e){return super._repaint(e).map(t=>({...t}))}canPointerEvents(){return this.style.pointerEvents!=="none"}input(e,t){const r=this.getChildren(!0);for(let i=r.length-1;i>=0;i--)r[i].input(e,t);this.isVisibleInTree()&&this._input(e,t)}_positionInput(e,t){const{width:r,height:i}=this.size;return e.x>=0&&e.x<r&&e.y>=0&&e.y<i}_input(e,t){switch(t){case"pointerdown":case"pointermove":case"pointerup":{if(this.canPointerEvents()){const{screenX:r,screenY:i}=e;if(r&&i){const n=new de(r,i),o=this.getViewport();o&&o.toCanvasGlobal(n,n),this.toLocal(n,n),this._positionInput(n,t)&&(e.target||(e.target=this),this.emit(t,e))}}break}}}toJSON(){const e=t=>Object.keys(t).length>0?t:void 0;return Ve({...super.toJSON(),style:e(this.style.toJSON()),background:e(this.background.toJSON()),shape:e(this.shape.toJSON()),fill:e(this.fill.toJSON()),outline:e(this.outline.toJSON()),text:e(this.text.toJSON()),foreground:e(this.foreground.toJSON()),shadow:e(this.shadow.toJSON())})}},f.BaseElement2D=Mg([X("BaseElement2D")],f.BaseElement2D);class $n extends ui{constructor(e){super(),this.setProperties(e)}}const ql={left:0,top:0,width:0,height:0};for(const s in ql)mi($n,s,{fallback:ql[s]});class Xl extends ui{constructor(e){super(),this.setProperties(e)}}var kg=Object.getOwnPropertyDescriptor,Dg=(s,e,t,r)=>{for(var i=r>1?void 0:r?kg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};f.Element2D=class extends f.BaseElement2D{get style(){return this._style}set style(e){const t=(...r)=>{this.emit("updateStyleProperty",r[0],r[1],r[2]),this._updateStyleProperty(r[0],r[1],r[2])};e.on("updateProperty",t),this._style?.off("updateProperty",t),this._style=e}constructor(e,t=[]){super(),this.style=new $n,this.setProperties(e).append(t)}_updateStyleProperty(e,t,r){switch(super._updateStyleProperty(e,t,r),e){case"left":this.position.x=Number(t);break;case"top":this.position.y=Number(t);break;case"width":this.size.width=Number(t);break;case"height":this.size.height=Number(t);break}switch(e){case"width":case"height":this.mask instanceof f.BaseElement2D&&(this.mask.size.width=this.size.width,this.mask.size.height=this.size.height);break}}},f.Element2D=Dg([X("Element2D")],f.Element2D);const fe={left:0,top:1,right:2,bottom:3,start:4,end:5,horizontal:6,vertical:7,all:8},Hl={column:0,row:1,all:2},sr={auto:0,"flex-start":1,center:2,"flex-end":3,stretch:4,baseline:5,"space-between":6,"space-around":7,"space-evenly":8},zn={flex:0,none:1,contents:2},ns={inherit:0,ltr:1,rtl:2},Vn={column:0,"column-reverse":1,row:2,"row-reverse":3},Gn={"no-wrap":0,wrap:1,"Wrap-reverse":2},jn={"flex-start":0,center:1,"flex-end":2,"space-between":3,"space-around":4,"space-evenly":5},Wn={visible:0,hidden:1,scroll:2},qn={static:0,relative:1,absolute:2},Xn={"border-box":0,"content-box":1};class os{constructor(e){this._element=e}static _yoga;static async load(){const{loadYoga:e}=await import("yoga-layout/load");this._yoga=await e()}_node=os._yoga.Node.create();get _style(){return this._element.style}get offsetLeft(){return this._node.getComputedLeft()}get offsetTop(){return this._node.getComputedTop()}get offsetWidth(){return this._node.getComputedWidth()}get offsetHeight(){return this._node.getComputedHeight()}calculateLayout(e,t,r){return this._node.calculateLayout(e,t,r)}getComputedLayout(){return this._node.getComputedLayout()}updateStyleProperty(e,t,r){switch(e){case"alignContent":this._node.setAlignContent(t?sr[t]:sr["flex-start"]);break;case"alignItems":this._node.setAlignItems(t?sr[t]:sr["flex-start"]);break;case"alignSelf":this._node.setAlignSelf(t?sr[t]:sr["flex-start"]);break;case"aspectRatio":this._node.setAspectRatio(t);break;case"borderTop":this._node.setBorder(fe.top,this._style.borderWidth);break;case"borderBottom":this._node.setBorder(fe.bottom,this._style.borderWidth);break;case"borderLeft":this._node.setBorder(fe.left,this._style.borderWidth);break;case"borderRight":this._node.setBorder(fe.right,this._style.borderWidth);break;case"border":this._node.setBorder(fe.all,this._style.borderWidth);break;case"direction":this._node.setDirection(t?ns[t]:ns.inherit);break;case"display":this._node.setDisplay(t?zn[t]:zn.flex);break;case"flex":this._node.setFlex(this._style.flex);break;case"flexBasis":this._node.setFlexBasis(this._style.flexBasis);break;case"flexDirection":this._node.setFlexDirection(t?Vn[t]:Vn.row);break;case"flexGrow":this._node.setFlexGrow(this._style.flexGrow);break;case"flexShrink":this._node.setFlexShrink(this._style.flexShrink);break;case"flexWrap":this._node.setFlexWrap(t?Gn[t]:Gn.wrap);break;case"height":this._node.setHeight(this._style.height);break;case"justifyContent":this._node.setJustifyContent(t?jn[t]:jn["flex-start"]);break;case"gap":t!==void 0&&this._node.setGap(Hl.all,t);break;case"marginTop":this._node.setMargin(fe.top,t);break;case"marginBottom":this._node.setMargin(fe.bottom,t);break;case"marginLeft":this._node.setMargin(fe.left,t);break;case"marginRight":this._node.setMargin(fe.right,t);break;case"margin":this._node.setMargin(fe.all,t);break;case"maxHeight":this._node.setMaxHeight(t);break;case"maxWidth":this._node.setMaxWidth(t);break;case"minHeight":this._node.setMinHeight(this._style.minHeight);break;case"minWidth":this._node.setMinWidth(this._style.minWidth);break;case"overflow":this._node.setOverflow(t?Wn[t]:Wn.visible);break;case"paddingTop":this._node.setPadding(fe.top,this._style.paddingTop);break;case"paddingBottom":this._node.setPadding(fe.bottom,this._style.paddingBottom);break;case"paddingLeft":this._node.setPadding(fe.left,this._style.paddingLeft);break;case"paddingRight":this._node.setPadding(fe.right,this._style.paddingRight);break;case"padding":this._node.setPadding(fe.all,this._style.padding);break;case"top":this._node.setPosition(fe.top,this._style.top);break;case"bottom":this._node.setPosition(fe.bottom,this._style.bottom);break;case"left":this._node.setPosition(fe.left,this._style.left);break;case"right":this._node.setPosition(fe.right,this._style.right);break;case"position":this._node.setPositionType(t?qn[t]:qn.static);break;case"boxSizing":this._node.setBoxSizing(t?Xn[t]:Xn["content-box"]);break;case"width":this._node.setWidth(this._style.width);break}}}var Ig=Object.getOwnPropertyDescriptor,Rg=(s,e,t,r)=>{for(var i=r>1?void 0:r?Ig(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};f.FlexElement2D=class extends f.BaseElement2D{get style(){return this._style}set style(e){const t=(...r)=>{this.emit("updateStyleProperty",r[0],r[1],r[2]),this._updateStyleProperty(r[0],r[1],r[2])};e.on("updateProperty",t),this._style?.off("updateProperty",t),this._style=e}_layout=new os(this);get offsetLeft(){return this._layout.offsetLeft}get offsetTop(){return this._layout.offsetTop}get offsetWidth(){return this._layout.offsetWidth}get offsetHeight(){return this._layout.offsetHeight}constructor(e,t=[]){super(),this.style=new Xl,this.setProperties(e).append(t)}_parented(e){super._parented(e),e._layout&&this._layout._node&&e._layout._node.insertChild(this._layout._node,e._layout._node.getChildCount())}_unparented(e){super._unparented(e),e._layout?._node&&e._layout._node.removeChild(this._layout._node)}_updateStyleProperty(e,t,r){super._updateStyleProperty(e,t,r),this._layout.updateStyleProperty(e,t,r),this._layout._node.isDirty()&&this.requestRelayout()}updateTransform(){this.calculateLayout(void 0,void 0,ns.ltr);const{left:e,top:t,width:r,height:i}=this._layout.getComputedLayout();this.position.x=e,this.position.y=t,this.size.x=r,this.size.y=i,super.updateTransform()}calculateLayout(e,t,r){const i=this.getParent();i?._layout?.calculateLayout?i?._layout.calculateLayout(e,t,r):this._layout.calculateLayout(e,t,r)}},f.FlexElement2D=Rg([X("FlexElement2D")],f.FlexElement2D);var Ug=Object.defineProperty,Bg=Object.getOwnPropertyDescriptor,fi=(s,e,t,r)=>{for(var i=r>1?void 0:r?Bg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Ug(e,t,i),i};f.Image2D=class extends f.Element2D{get currentFrameTexture(){return this.texture?.frames[this._frameIndex]?.texture}get textureDuration(){return this.texture?.duration??0}get naturalWidth(){return this.currentFrameTexture?.realWidth??0}get naturalHeight(){return this.currentFrameTexture?.realHeight??0}get complete(){return this._complete}_frameIndex=0;_complete=!1;_wait=Promise.resolve();constructor(e,t=[]){super(),this.setProperties(e),this.append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"src":this._wait=this._load(t);break;case"srcRect":this.requestRedraw();break}}decode(){return this._wait}setResource(e){let t;if(e instanceof Ri?t=e:t=new Ri(e),this.texture=t.updateDuration(),this.currentFrameTexture&&(!this.style.width||!this.style.height)){const r=this.currentFrameTexture;this.style.width=r.realWidth,this.style.height=r.realHeight}return this}async _load(e){if(this._complete=!1,e)try{this.setResource(this.gif||e?.includes(".gif")?await Ke.gif.load(e):await Ke.texture.load(e)),this.requestRedraw(),this.emit("load")}catch(t){console.warn(t),this.emit("error",t)}else this.texture=void 0;this._complete=!0}_getFrameCurrentTime(){const e=this.textureDuration;if(!e||!this._tree)return 0;const t=this._currentTime;return t<0?0:t%e}_updateFrameIndex(){if(!this.texture)return this;const e=this._getFrameCurrentTime(),t=this.texture.frames,r=t.length;if(r<=1&&this._frameIndex===0)return this;let i=r-1;for(let n=0,o=0;o<r;o++)if(n+=t[o].duration??0,n>=e){i=o;break}return this._frameIndex!==i&&(this._frameIndex=i,this.requestRedraw()),this}_process(e){this._updateFrameIndex(),super._process(e)}_drawContent(){const e=this.currentFrameTexture;if(e?.isValid()){const{left:t=0,top:r=0,right:i=0,bottom:n=0}=this.srcRect??{},{width:o,height:a}=this.size;this.context.fillStyle=e;const l=Math.abs(1+(t+i))*o,c=Math.abs(1+(r+n))*a,h=1/l,u=1/c,d=t*o*h,g=r*a*u;this.context.uvTransform=new ke().scale(h,u).translate(d,g),this.shape.draw(),this.context.fill()}}_repaint(e){return super._repaint(e).map(t=>({...t,disableWrapMode:!0}))}},fi([_({internal:!0})],f.Image2D.prototype,"texture",2),fi([_({fallback:""})],f.Image2D.prototype,"src",2),fi([_()],f.Image2D.prototype,"srcRect",2),fi([_({fallback:!1})],f.Image2D.prototype,"gif",2),f.Image2D=fi([X("Image2D")],f.Image2D);class Hn extends f.Element2D{texture;constructor(e,t=[]){super(),this.setProperties(e).append(t)}_drawContent(){this.texture?.isValid()&&(this.shape.draw(!0),this.context.fillStyle=this.texture,this.context.fill())}}var Lg=Object.defineProperty,Fg=Object.getOwnPropertyDescriptor,Yl=(s,e,t,r)=>{for(var i=r>1?void 0:r?Fg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Lg(e,t,i),i};f.Lottie2D=class extends Hn{texture=new Ui;animation;constructor(e,t=[]){super(),this.setProperties(e),this.append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"src":this._load();break}}_updateStyleProperty(e,t,r){switch(super._updateStyleProperty(e,t,r),e){case"width":this.texture.width=this.style.width;break;case"height":this.texture.height=this.style.height;break}}async _load(){this.animation=await Ke.lottie.load(this.src,this.texture.source),this.duration=this.animation.getDuration(!1)*1e3,this.texture.requestUpload(),this.requestRedraw()}_process(e){this.animation?.goToAndStop(this.currentTime,!1),this.texture.requestUpload(),this.requestRedraw(),super._process(e)}},Yl([_({fallback:""})],f.Lottie2D.prototype,"src",2),f.Lottie2D=Yl([X("Lottie2D")],f.Lottie2D);var Ng=Object.defineProperty,$g=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Ng(e,t,i),i};class Kl extends f.Element2D{constructor(e,t=[]){super(),this.setProperties(e).append(t)}_updateStyleProperty(e,t,r){switch(super._updateStyleProperty(e,t,r),e){case"width":case"height":this.requestRedraw();break}}_drawCircle(e,t){this.context.arc(e,t,this.handleSize,0,Math.PI*2,!0),this.context.fillStyle=le.WHITE,this.context.fill(),this.context.arc(e,t,this.handleSize,0,Math.PI*2,!0),this.context.strokeStyle="rgba(0, 0, 0, 0.2)",this.context.stroke()}_drawEllipse(e,t){this.context.roundRect(e-this.handleSize,t-this.handleSize*2,this.handleSize*2,this.handleSize*4,this.handleSize),this.context.fillStyle=le.WHITE,this.context.fill(),this.context.roundRect(e-this.handleSize,t-this.handleSize*2,this.handleSize*2,this.handleSize*4,this.handleSize),this.context.strokeStyle="rgba(0, 0, 0, 0.2)",this.context.stroke()}_draw(){const{width:e,height:t}=this.getRect();this.context.rect(0,0,e,t),this.context.strokeStyle="#00FF00",this.context.stroke(),this._drawCircle(0,0),this._drawCircle(e,t),this._drawCircle(0,t),this._drawEllipse(0,t/2),this._drawCircle(e,0),this._drawEllipse(e,t/2)}}$g([_({fallback:6})],Kl.prototype,"handleSize");var zg=Object.defineProperty,Vg=Object.getOwnPropertyDescriptor,Zl=(s,e,t,r)=>{for(var i=r>1?void 0:r?Vg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&zg(e,t,i),i};f.Video2D=class extends Hn{get videoDuration(){return(this.texture?.duration??0)*1e3}_wait=Promise.resolve();constructor(e,t=[]){super(),this.setProperties(e),this.append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"src":this._wait=this._load(t);break}}waitLoad(){return this._wait}async _load(e){this.texture=await Ke.video.load(e),(!this.style.width||!this.style.height)&&(this.style.width=this.texture.width,this.style.height=this.texture.height),this.requestRedraw()}_updateVideoCurrentTime(){let e=this._currentTime;if(e<0)return;const t=this.texture;if(!t)return;const r=t.duration;e=r?e%(r*1e3):0,!t.isPlaying&&!t.seeking&&(e=~~e/1e3,t.currentTime!==e&&(t.currentTime=e))}_process(e){this._updateVideoCurrentTime(),super._process(e)}},Zl([_({fallback:""})],f.Video2D.prototype,"src",2),f.Video2D=Zl([X("Video2D")],f.Video2D);var Gg=Object.defineProperty,jg=Object.getOwnPropertyDescriptor,as=(s,e,t,r)=>{for(var i=r>1?void 0:r?jg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Gg(e,t,i),i};const Jl=s=>s,Ql=Sr(.25,.1,.25,1),ec=Sr(.42,0,1,1),tc=Sr(0,0,.58,1),rc=Sr(.42,0,.58,1);function Sr(s,e,t,r){const n=3*s-3*t+1,o=3*t-6*s,a=3*s,l=3*e-3*r+1,c=3*r-6*e,h=3*e,u=y=>(3*n*y+2*o)*y+a,d=y=>((n*y+o)*y+a)*y,g=y=>((l*y+c)*y+h)*y;function p(y){let m=y,P,E;for(let w=0;w<8;w++){if(E=d(m)-y,Math.abs(E)<1e-6)return m;if(P=u(m),Math.abs(P)<1e-6)break;m-=E/P}let b=1,S=0;for(m=y;b>S;){if(E=d(m)-y,Math.abs(E)<1e-6)return m;E>0?b=m:S=m,m=(b+S)/2}return m}return y=>g(p(y))}const ls={linear:Jl,ease:Ql,easeIn:ec,easeOut:tc,easeInOut:rc};f.Animation=class extends f.TimelineNode{_keyframes=[];_isFirstUpdatePosition=!1;_cachedProps=new ho;_stoped=!1;constructor(e,t=[]){super(),this.setProperties(e).append(t)}_parented(e){super._parented(e),this._updateCachedProps()}_unparented(e){super._unparented(e),this.cancel()}_process(){this.canProcess()&&this.commitStyles()}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"effectMode":case"keyframes":this._updateKeyframes();break}}_getTargets(){let e;switch(this.effectMode){case"sibling":e=this.getParent()?.getChildren(!0).filter(t=>t instanceof f.CanvasItem)??[];break;case"parent":default:e=[this.getParent()].filter(Boolean);break}return e.map(t=>t.style)}_updateKeyframes(){const e=[],t=this.keyframes;for(let n=t.length,o=0;o<n;o++){const{offset:a=o===0?0:o/(n-1),easing:l="linear",...c}=t[o];e.push({offset:a,easing:this._parseEasing(l),props:c})}const r=e[0],i=e[e.length-1];r&&r.offset!==0&&e.unshift({offset:0,easing:this._parseEasing("linear"),props:{}}),i&&i.offset!==1&&e.push({offset:1,easing:this._parseEasing("linear"),props:{}}),this._keyframes=e,this._updateCachedProps()}commitStyles(){if(!this.keyframes.length)return;if(this._updateCurrentTime(),this.isInsideTimeRange())this._isFirstUpdatePosition||(this._isFirstUpdatePosition=!0,this._updateCachedProps());else{if(!this._isFirstUpdatePosition)return;this._isFirstUpdatePosition=!1}const e=this._getTargets(),t=1/e.length,r=this.currentTimeProgress;e.forEach((i,n)=>{const o=t===1?r:ut(Math.max(0,r-t*n)/t,0,1),a=this._cachedProps.get(i);if(!a)return;const l=this._parseKeyframes(o,a);l?.length&&this._commitStyle(o,i,a,l[0],l[1])})}_updateCachedProps(){this.cancel(),this._getTargets().forEach(e=>{const t=new Map,r=this._keyframes;for(let i=r.length,n=0;n<i;n++)Object.keys(r[n].props).forEach(o=>{t.set(o,e[o])});this._cachedProps.set(e,t)})}_parseEasing(e){if(!e)return ls.linear;if(e in ls)return ls[e];const t=e.replace(/cubic-bezier\((.+)\)/,"$1").split(",").map(r=>Number(r));return Sr(t[0],t[1],t[2],t[3])}_parseKeyframes(e,t){let r;const i=this._keyframes;for(let n=i.length,o=0;o<n;o++){const a=i[o],{offset:l,easing:c}=a,h={...a.props};if(r&&e<=l){const{offset:u,easing:d}=r,g={...r.props};return t.forEach((p,y)=>{(!(y in g)||g[y]===null)&&(g[y]=p),(!(y in h)||h[y]===null)&&(h[y]=p)}),[{offset:u,easing:d,props:g},{offset:l,easing:c,props:h}]}r=a}return null}_commitStyle(e,t,r,i,n){const{offset:o,easing:a,props:l}=i,{offset:c,props:h}=n,u=c-o,d=a((e-o)/u),g={width:t.width,height:t.height,fontSize:t.fontSize};r.forEach((p,y)=>{t[y]=this._getDiffValue(y,l[y],h[y],d,g)})}_getDiffValue(e,t,r,i,n){let o,a;if(t==="none"&&(t=void 0),r==="none"&&(r=void 0),t===void 0||r===void 0)if(t!==void 0)o=Or(e,String(t),n),a=Ss(o);else if(r!==void 0)a=Or(e,String(r),n),o=Ss(a);else return;else o=Or(e,String(t),n),a=Or(e,String(r),n);if(Array.isArray(o)&&Array.isArray(a)){const l=new Set,c={},h={};o.forEach(({name:d,args:g})=>{c[d]=g,l.add(d)}),a.forEach(({name:d,args:g})=>{h[d]=g,l.add(d)});let u="";return l.forEach(d=>{const g=Math.max(c[d]?.length??0,h[d]?.length??0),p=c[d],y=h[d];u+=`${d}(${Array.from({length:g},(m,P)=>{const E=p?.[P],b=y?.[P],S=E?.normalizedIntValue??0,w=b?.normalizedIntValue??0;return Number.isNaN(S)||Number.isNaN(w)?b?.value??0:he(S,w,i)}).join(", ")}) `}),u}else if(!Array.isArray(o)&&!Array.isArray(a))return Number.isNaN(o.normalizedIntValue)||Number.isNaN(a.normalizedIntValue)?a.value:he(o.normalizedIntValue,a.normalizedIntValue,i)}isPlaying(){return!this.paused&&this.isInsideTimeRange()}play(){return this._stoped?(this._stoped=!1,this.startTime=this.timelineCurrentTime):this.startTime=this.timelineCurrentTime-this.currentTime,this.paused=!1,!0}pause(){return this.paused=!0,!0}stop(){return this._stoped=!0,this.paused=!0,this._currentTime=0,!0}cancel(){this._getTargets().forEach(e=>{this._cachedProps.get(e)?.forEach((t,r)=>{e[r]=t}),this._cachedProps.delete(e)})}},as([_({fallback:"parent"})],f.Animation.prototype,"effectMode",2),as([_({default:()=>[]})],f.Animation.prototype,"keyframes",2),as([_()],f.Animation.prototype,"easing",2),f.Animation=as([X("Animation",{renderMode:"disabled",processMode:"pausable",processSortMode:"parent_before",duration:2e3})],f.Animation);class cs extends Dt{static _instance;static get instance(){return this._instance||(this._instance=new cs),this._instance}playbackRate=1;muted=!1;volume=1;paused=!1;refresh(){this.emit("refresh")}refreshPaused(){this.emit("refreshPaused")}get processors(){return console.warn("HTML Audio does not support processors"),[]}set processors(e){console.warn("HTML Audio does not support processors")}get audioContext(){return console.warn("HTML Audio does not support audioContext"),null}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this.paused}}class di extends Dt{static PADDING=.1;_source=null;_audio=null;_end=0;_pausedReal=!1;_duration=0;_start=0;_playing=!1;get progress(){return(this._source?.currentTime??0)/this._duration}_paused=!1;get paused(){return this._paused}set paused(e){this._paused!==e&&(this._paused=e,this.refreshPaused())}_playbackRate=1;get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate!==e&&(this._playbackRate=e,this.refresh())}_volume=1;get volume(){return this._volume}set volume(e){this._volume!==e&&(this._volume=e,this.refresh())}_loop=!1;get loop(){return this._loop}set loop(e){this._loop!==e&&(this._loop=e,this.refresh())}_muted=!1;get muted(){return this._muted}set muted(e){this._muted!==e&&(this._muted=e,this.refresh())}set(e,t){if(this[e]===void 0)throw new Error(`Property with name ${e} does not exist.`);switch(e){case"playbackRate":this.playbackRate=t;break;case"volume":this.volume=t;break;case"paused":this.paused=t;break;case"loop":this.loop=t;break;case"muted":this.muted=t;break}return this}_onPlay(){this._playing=!0}_onPause(){this._playing=!1}init(e){this._playing=!1,this._duration=e.source.duration;const t=this._source=e.source.cloneNode(!1);return t.src=e.parent.src,t.onplay=this._onPlay.bind(this),t.onpause=this._onPause.bind(this),e.context.on("refresh",this.refresh),e.context.on("refreshPaused",this.refreshPaused),this._audio=e,this}_stop(){this._source&&this._playing&&(this._source.onended=null,this._source.pause())}stop(){this._stop(),this._source&&this.emit("stop")}get processors(){return console.warn("HTML Audio does not support processors"),[]}set processors(e){console.warn("HTML Audio does not support processors")}refresh(){if(!this._audio||!this._source)return;const e=this._audio.context,t=this._audio.parent;this._source.loop=this._loop||t.loop;const r=e.volume*(e.muted?0:1),i=t.volume*(t.muted?0:1),n=this._volume*(this._muted?0:1);this._source.volume=n*r*i,this._source.playbackRate=this._playbackRate*e.playbackRate*t.playbackRate}refreshPaused(){if(!this._source||!this._audio)return;const e=this._paused||this._audio.parent.paused||this._audio.context.paused;e!==this._pausedReal&&(this._pausedReal=e,e?(this._stop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._source.currentTime,end:this._end,volume:this._volume,playbackRate:this._playbackRate,loop:this._loop})),this.emit("pause",e))}play(e={}){if(!this._source)return;const{start:t=0,end:r=0}=e;r&&console.assert(r>t,"End time is before start time"),e.playbackRate!==void 0&&(this._playbackRate=e.playbackRate),e.volume!==void 0&&(this._volume=e.volume),e.loop!==void 0&&(this._loop=e.loop),e.muted!==void 0&&(this._muted=e.muted),this.refresh(),this.loop&&r!==null&&(console.warn('Looping not support when specifying an "end" time'),this.loop=!1),this._start=t,this._end=r||this._duration,this._start=Math.max(0,this._start-di.PADDING),this._end=Math.min(this._end+di.PADDING,this._duration),this._source.onloadedmetadata=()=>{this._source&&(this._source.currentTime=t,this._source.onloadedmetadata=null,this.emit("progress",t,this._duration),Ce.on(this._onUpdate))},this._source.onended=this._onComplete.bind(this),this._source.play(),this.emit("start")}_onUpdate=()=>{this._source&&(this.emit("progress",this.progress,this._duration),this._source.currentTime>=this._end&&!this._source.loop&&this._onComplete())};_onComplete(){Ce.off(this._onUpdate),this._stop(),this.emit("progress",1,this._duration),this.emit("end",this)}destroy(){Ce.off(this._onUpdate),super.destroy();const e=this._source;e&&(e.onended=null,e.onplay=null,e.onpause=null,this._stop()),this._source=null,this._playbackRate=1,this._volume=1,this._loop=!1,this._end=0,this._start=0,this._duration=0,this._playing=!1,this._pausedReal=!1,this._paused=!1,this._muted=!1,this._audio&&(this._audio.context.off("refresh",this.refresh),this._audio.context.off("refreshPaused",this.refreshPaused),this._audio=null)}}class ic{constructor(e){this.parent=e}source=new globalThis.Audio;_src="";get src(){return this._src}set src(e){this._src!==e&&(this._src=e,this.load())}get duration(){return this.source.duration}get isPlayable(){return!!this.source&&this.source.readyState===4}get context(){return cs.instance}async load(){return new Promise(e=>{this.source.onload=()=>e(this),this.source.src=this._src,this.source.load()})}createSound(){return new di}}class Yn extends Dt{constructor(e,t){super(),this._input=e,this._output=t}_processers=[];get processors(){return this._processers}set processors(e){if(this._processers.forEach(t=>t.disconnect()),this._processers.length=0,this._input.connect(this._output),e.length){this._processers=e.slice(0),this._input.disconnect();let t;e.forEach(r=>{t?t.connect(r.destination):this._input.connect(r.destination),t=r}),t.connect(this._output)}}get destination(){return this._input}}class Wg{constructor(e,t=null){this.destination=e,this.source=t}connect(e){this.source?.connect(e)}disconnect(){this.source?.disconnect()}}function qg(){if(Ms)return new AudioContext;if(As){const s=globalThis.webkitAudioContext;return new s}else throw new Error("Failed to createAudioContext")}function Xg(s,e,t){if(Os)return new OfflineAudioContext(s,e,t);if(Io){const r=globalThis.webkitOfflineAudioContext;return new r(s,e,t)}else throw new Error("Failed to createOfflineAudioContext")}class jt extends Yn{static _instance;static get instance(){return this._instance||(this._instance=new jt),this._instance}static get audioContext(){return this.instance.audioContext}static get offlineContext(){return this.instance.offlineContext}static setParamValue(e,t){this.instance.setParamValue(e,t)}static decode(e){return this.instance.decode(e)}_context;_offlineContext;get audioContext(){return this._context}get offlineContext(){return this._offlineContext}_locked;muted=!1;volume=1;playbackRate=1;autoPause=!0;_paused=!1;_pausedOnBlur=!1;get paused(){return this._paused}set paused(e){e&&this._context.state==="running"?this._context.suspend():!e&&this._context.state==="suspended"&&this._context.resume(),this._paused=e}_compressor;_analyser;constructor(){const e=qg(),t=Xg(1,2,Os?Math.max(8e3,Math.min(96e3,e.sampleRate)):44100),r=e.createDynamicsCompressor(),i=e.createAnalyser();i.connect(r),r.connect(e.destination),super(i,r),this._context=e,this._offlineContext=t,this._compressor=r,this._analyser=i,this._locked=e.state==="suspended"&&(wt||Do),Dr&&(this._locked&&(this._unlock(),document.addEventListener("mousedown",this._unlock,!0),document.addEventListener("touchstart",this._unlock,!0),document.addEventListener("touchend",this._unlock,!0)),globalThis.addEventListener("focus",this._onFocus),globalThis.addEventListener("blur",this._onBlur))}_onFocus(){if(!this.autoPause)return;const e=this._context.state;(e==="suspended"||e==="interrupted"||!this._locked)&&(this.paused=this._pausedOnBlur,this.refreshPaused())}_onBlur(){this.autoPause&&(this._locked||(this._pausedOnBlur=this._paused,this.paused=!0,this.refreshPaused()))}_unlock=()=>{this._locked&&(this.playEmptySound(),this._context.state==="running"&&(document.removeEventListener("mousedown",this._unlock,!0),document.removeEventListener("touchend",this._unlock,!0),document.removeEventListener("touchstart",this._unlock,!0),this._locked=!1))};playEmptySound(){const e=this._context.createBufferSource();e.buffer=this._context.createBuffer(1,1,22050),e.connect(this._context.destination),e.start(0,0,0),e.context.state==="suspended"&&e.context.resume()}refresh(){this.emit("refresh")}refreshPaused(){this.emit("refreshPaused")}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this._paused}decode(e){return new Promise((t,r)=>{const i=o=>{r(new Error(o?.message||"Unable to decode file"))},n=this._offlineContext.decodeAudioData(e,t,i);n&&n.catch(i)})}setParamValue(e,t){e.setValueAtTime?e.setValueAtTime(t,this._context.currentTime):e.value=t}}class sc extends Dt{_audio=null;_sourceNode=null;_gain=null;_progress=0;get progress(){return this._progress}_pausedReal=!1;_paused=!1;get paused(){return this._paused}set paused(e){this._paused!==e&&(this._paused=e,this.refreshPaused())}_volume=1;get volume(){return this._volume}set volume(e){this._volume!==e&&(this._volume=e,this.refresh())}_playbackRate=1;get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate!==e&&(this._playbackRate=e,this.refresh(),this._update(!0))}_loop=!1;get loop(){return this._loop}set loop(e){this._loop!==e&&(this._loop=e,this.refresh())}_muted=!1;get muted(){return this._muted}set muted(e){this._muted!==e&&(this._muted=e,this.refresh())}_duration=0;_end=0;_elapsed=0;_lastUpdate=this._now();_processors=[];init(e){return this._audio=e,e.context.on("refresh",this.refresh),e.context.on("refreshPaused",this.refreshPaused),this}_now(){return this._audio?.context.audioContext.currentTime??0}play(e={}){if(!this._audio)return;const{end:t=0,start:r=0}=e;t&&console.assert(t>r,"End time is before start time"),this._end=t,this._elapsed=r,e.volume!==void 0&&(this._volume=e.volume),e.playbackRate!==void 0&&(this._playbackRate=e.playbackRate),e.muted!==void 0&&(this._muted=e.muted),e.loop!==void 0&&(this._loop=e.loop),e.processors!==void 0&&(this._processors=e.processors),this._paused=!1;const{source:i,gain:n}=this._audio.cloneSource();this._sourceNode=i,this._gain=n,this.refresh(),i.onended=this._onComplete.bind(this),this._duration=i.buffer?.duration??0,this._lastUpdate=this._now(),this._loop?(i.loopStart=r,i.loopEnd=t,i.start(0,r)):t?i.start(0,r,t-r):i.start(0,r),this.emit("start"),this._update(!0),this._enableTicker(!0)}_stop(){if(this._sourceNode){this._enableTicker(!1),this._sourceNode.onended=null,this._sourceNode.stop(0),this._sourceNode.disconnect();try{this._sourceNode.buffer=null}catch(e){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",e)}this._sourceNode=null}}stop(){this._sourceNode&&(this._stop(),this.emit("stop"))}_update(e=!1){if(this._sourceNode){const t=this._now(),r=t-this._lastUpdate;if(r>0||e){this._elapsed+=r*this._sourceNode.playbackRate.value,this._lastUpdate=t;const i=this._duration;let n;if(this._sourceNode.loopStart){const o=this._sourceNode.loopEnd-this._sourceNode.loopStart;n=(this._sourceNode.loopStart+this._elapsed%o)/i}else n=this._elapsed%i/i;this._progress=n,this.emit("progress",n,i)}}}refresh(){if(!this._audio||!this._sourceNode)return;const e=this._audio.context,t=this._audio.parent;this._sourceNode.loop=this._loop||t.loop,e.setParamValue(this._gain.gain,this._volume*(this._muted?0:1)*t.volume*(t.muted?0:1)*e.volume*(e.muted?0:1)),e.setParamValue(this._sourceNode.playbackRate,this._playbackRate*t.playbackRate*e.playbackRate),this.applyProcessors()}applyProcessors(){if(this._sourceNode&&this._processors.length){this._sourceNode.disconnect();let e=this._sourceNode;this._processors.forEach(t=>{e.connect(t.destination),e=t}),e.connect(this._gain)}}refreshPaused(){if(!this._audio)return;const e=this._paused||this._audio.parent.paused||this._audio.context.paused;e!==this._pausedReal&&(this._pausedReal=e,e?(this._stop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._elapsed%this._duration,end:this._end,playbackRate:this._playbackRate,loop:this._loop,volume:this._volume})),this.emit("pause",e))}_onComplete=()=>{if(this._sourceNode){this._enableTicker(!1),this._sourceNode.onended=null,this._sourceNode.disconnect();try{this._sourceNode.buffer=null}catch(e){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",e)}}this._sourceNode=null,this._progress=1,this.emit("progress",1,this._duration),this.emit("end",this)};_updateListener=()=>this._update();_enableTicker(e){Ce.off(this._updateListener),e&&Ce.on(this._updateListener)}destroy(){super.destroy(),this._stop(),this._gain?.disconnect(),this._gain=null,this._audio?.context.off("refresh",this.refresh),this._audio?.context.off("refreshPaused",this.refreshPaused),this._audio=null,this._processors.forEach(e=>e.disconnect()),this._processors.length=0,this._end=0,this._playbackRate=1,this._volume=1,this._loop=!1,this._elapsed=0,this._duration=0,this._paused=!1,this._muted=!1,this._pausedReal=!1}}class nc extends Yn{constructor(e){const t=jt.audioContext,r=t.createBufferSource(),i=t.createGain(),n=t.createAnalyser();r.connect(n),n.connect(i),i.connect(jt.instance.destination),super(n,i),this.parent=e,this._sourceNode=r,this.gain=i,this.analyser=n}_sourceBuffer;_sourceNode;_sourceLoad;gain;analyser;get context(){return jt.instance}get isPlayable(){return!!this._sourceNode.buffer}get duration(){return this._sourceNode.buffer?.duration??0}get buffer(){return this._sourceNode.buffer}set buffer(e){this._sourceNode.buffer=e}async load(){return this._sourceLoad||(this._sourceLoad=new Promise(e=>{this._sourceBuffer?this._decode(this._sourceBuffer).then(()=>e(this)):this.parent.src?this._loadUrl(this.parent.src).then(()=>e(this)):e(this)})),this._sourceLoad}_loadUrl(e){return new Promise(t=>{fetch(e).then(r=>r.arrayBuffer()).then(r=>this._decode(r)).finally(()=>t(this))})}_decode(e){return Promise.resolve(e instanceof AudioBuffer?e:jt.decode(e)).then(t=>(this.parent.isLoaded=!0,this.buffer=t,t))}cloneSource(){const e=this.context,t=this._sourceNode,r=e.audioContext.createBufferSource(),i=e.audioContext.createGain();return r.buffer=t.buffer,r.loop=t.loop,e.setParamValue(r.playbackRate,t.playbackRate.value),r.connect(i),i.connect(this.destination),{source:r,gain:i}}createSound(){return new sc}}var Hg=Object.defineProperty,Yg=Object.getOwnPropertyDescriptor,Kg=(s,e,t)=>e in s?Hg(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Zg=(s,e,t,r)=>{for(var i=r>1?void 0:r?Yg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i},Jg=(s,e,t)=>Kg(s,e+"",t);f.Audio=class extends f.TimelineNode{_sounds=[];_platformAudio=Ro?new nc(this):new ic(this);get platformAudio(){return this._platformAudio}_src;get src(){return this._src}set src(e){this._src!==e&&(this._src=e,this.load())}isLoaded=!1;get isPlayable(){return this.isLoaded&&this._platformAudio.isPlayable}get audioDuration(){return this._platformAudio.duration*1e3}_volume=1;get volume(){return this._volume}set volume(e){this._volume!==e&&(this._volume=e,this.refresh())}_muted=!1;get muted(){return this._muted}set muted(e){this._muted!==e&&(this._muted=e,this.refresh())}_loop=!1;get loop(){return this._loop}set loop(e){this._loop!==e&&(this._loop=e,this.refresh())}_playbackRate=1;get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate!==e&&(this._playbackRate=e,this.refresh())}_isPlaying=!1;get isPlaying(){return this._isPlaying}multiple=!1;start=0;end=0;constructor(e=""){super(),this.src=e}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"paused":this.refreshPaused();break}}async load(){return await this._platformAudio.load(),this}pause(){return this._isPlaying=!1,this.paused=!0,this}resume(){return this._isPlaying=this._sounds.length>0,this.paused=!1,this}stop(){if(!this.isPlayable)return this;this._isPlaying=!1;for(let e=this._sounds.length-1;e>=0;e--)this._sounds[e].stop();return this}play(e={}){if(!this.isLoaded)return;this.multiple||this._removeSounds(),this._isPlaying=!0;const t=this._createSound();this._sounds.push(t),t.once("end",()=>{e.complete?.(),this._onComplete(t)}),t.once("stop",()=>this._onComplete(t));const r=(e?.start??this.start)/1e3,i=(e?.end??this.end)/1e3;return t.play({...e,start:r,end:i}),t}_removeSounds(){for(let e=this._sounds.length-1;e>=0;e--)this._recycleSound(this._sounds[e]);this._sounds.length=0}_createSound(){return f.Audio._soundPool.length>0?f.Audio._soundPool.pop().init(this._platformAudio):this._platformAudio.createSound().init(this._platformAudio)}refresh(){for(let e=this._sounds.length,t=0;t<e;t++)this._sounds[t].refresh()}refreshPaused(){for(let e=this._sounds.length,t=0;t<e;t++)this._sounds[t].refreshPaused()}_onComplete=e=>{if(this._sounds){const t=this._sounds.indexOf(e);t>-1&&this._sounds.splice(t,1),this._isPlaying=this._sounds.length>0}this._recycleSound(e)};_recycleSound(e){e.destroy(),f.Audio._soundPool.includes(e)||f.Audio._soundPool.push(e)}_prevTime=0;_timer=0;_process(e){if(super._process(e),this.canProcess()){const t=this._tree?.timeline.currentTime??0;t-this._prevTime>0&&(this._timer||(this._setTimeStop(),this.play({start:this.start+(t-this.delay)%this.duration})),this._isPlaying&&this._setTimeStop()),this._prevTime=t}}_setTimeStop(){this._timer&&clearTimeout(this._timer),this._timer=setTimeout(()=>{this.stop(),this._timer=0},100)}},Jg(f.Audio,"_soundPool",[]),f.Audio=Zg([X("Audio")],f.Audio);class Qg extends f.Node2D{}var em=Object.defineProperty,tm=Object.getOwnPropertyDescriptor,hs=(s,e,t,r)=>{for(var i=r>1?void 0:r?tm(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&em(e,t,i),i};f.AudioWaveform=class extends f.Element2D{_audioBuffer;_src=Dr?new le(document.createElement("canvas")):void 0;_needsUpdateTexture=!1;constructor(e={}){super(),this.setProperties(e)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"src":this._loadSrc(t);break;case"gap":case"color":case"width":case"height":this._needsUpdateTexture=!0;break}}async _loadSrc(e){await globalThis.fetch(e).then(t=>t.arrayBuffer()).then(t=>jt.decode(t)).then(t=>{this._audioBuffer=t,this.syncTexture(!0)})}syncTexture(e=!1){const t=this._audioBuffer;if(!t||!e&&!this._needsUpdateTexture)return;this._needsUpdateTexture=!1;const r=this._src?.source;if(!r)return;const{width:i=0,height:n=0}=this.style;r.width=i,r.height=n;const o=r.getContext("2d");if(!o){console.warn("Failed to getContext('2d') in syncTexture");return}o.fillStyle=this.color;const a=t.getChannelData(0),l=Math.ceil(a.length/i),c=n/2;for(let h=1,u=-1,d=0;d<i;d++){for(let g=0;g<l;g++){const p=a[d*l+g];p<h&&(h=p),p>u&&(u=p)}if(!this.gap||d%(this.gap*2)===0){const g=d,p=(1+h)*c,y=this.gap||1,m=Math.max(1,(u-h)*c);o.fillRect(g,p,y,m),h=1,u=-1}}this._src?.requestUpload(),this.requestRedraw()}_process(e){this.syncTexture(),super._process(e)}_drawSrc(){const e=this._src;e?.isValid()&&(this.context.fillStyle=e,this.context.uvTransform=new ke().scale(1/this.style.width,1/this.style.height))}},hs([_()],f.AudioWaveform.prototype,"src",2),hs([_({fallback:0})],f.AudioWaveform.prototype,"gap",2),hs([_({fallback:"#000000"})],f.AudioWaveform.prototype,"color",2),f.AudioWaveform=hs([X("AudioWaveform")],f.AudioWaveform);var rm=Object.defineProperty,im=Object.getOwnPropertyDescriptor,sm=(s,e,t)=>e in s?rm(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,nm=(s,e,t,r)=>{for(var i=r>1?void 0:r?im(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i},om=(s,e,t)=>sm(s,e+"",t);f.KawaseTransition=class extends f.Transition{blur=10;quality=10;apply(e,t){const r=this.currentTimeProgress;let i,n;r<.5?(i=0,n=(.5-r)/.5):(i=1,n=(r-.5)/.5);const o=this.blur,a=this.quality,l=t.width,c=t.height,h=[],u=[o];if(o>0){let P=o;const E=o/a;for(let b=1;b<a;b++)P-=E,u.push(P)}const d=1/l,g=1/c,p=[];let y;const m=a-1;for(let P=0;P<m;P++)y=u[P]+.5,p[0]=y*d,p[1]=y*g,h.push({offset:p});y=u[m]+.5,p[0]=y*d,p[1]=y*g,h.push({offset:p}),h.forEach(P=>{Q.draw(e,f.KawaseTransition.material,{sampler:i,progress:n,...P})})}},om(f.KawaseTransition,"material",new re({vert:`attribute vec2 position;
|
|
958
958
|
attribute vec2 uv;
|
|
959
959
|
varying vec2 vUv;
|
|
960
960
|
void main() {
|