mirror of
https://github.com/SoPat712/dotfiles.git
synced 2025-08-21 18:38:46 -04:00
162 lines
76 KiB
JavaScript
162 lines
76 KiB
JavaScript
import{E as S,U as yt,T as pe,O as Q,M as I,N as Re,c as Ae,w as K,j as W,P as wt,t as We,K as M,L as A,b as Z,B as D,D as L,a as Ue,Q as ge,V as me,W as ze,I as H,X as Tt,R as X,Y as vt,Z as R,q as B,_ as Ct,$ as Bt,a0 as J,a1 as Ft,m as Pt,a2 as kt,a3 as se,n as xe,e as F,a4 as Mt,__tla as __tla_0}from"./TorrentDetail-BZZ-B8cw.js";import{U as V,T as z,R as ae,S as Ie,i as oe,b as He,c as Ge,j as Le,e as Rt,r as Oe,o as At,n as De,a as Wt,g as Ut,k as zt,m as It,B as Ee,__tla as __tla_1}from"./colorToUniform-pFJ8sYB5.js";import{C as O,__tla as __tla_2}from"./CanvasPool-DIOMPpzz.js";import{g as Ht,__tla as __tla_3}from"./getBatchSamplersUniformGroup-PJByx64R.js";import{__tla as __tla_4}from"./MoveTorrentDialog.vue_vue_type_script_setup_true_lang-G1lEzMcG.js";import{__tla as __tla_5}from"./index-DF2-l4SD.js";import"./vue-BQgCUbk_.js";import"./vuetify-DWkLi8Ew.js";import{__tla as __tla_6}from"./MixedButton.vue_vue_type_script_setup_true_lang-QFpliKgB.js";import"./FileIcon-DH65fwz5.js";import{__tla as __tla_7}from"./MoveTorrentFileDialog.vue_vue_type_script_setup_true_lang-DEnRCAW6.js";let __tla=Promise.all([(()=>{try{return __tla_0}catch{}})(),(()=>{try{return __tla_1}catch{}})(),(()=>{try{return __tla_2}catch{}})(),(()=>{try{return __tla_3}catch{}})(),(()=>{try{return __tla_4}catch{}})(),(()=>{try{return __tla_5}catch{}})(),(()=>{try{return __tla_6}catch{}})(),(()=>{try{return __tla_7}catch{}})()]).then(async()=>{class $e{static init(e){Object.defineProperty(this,"resizeTo",{set(t){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=t,t&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let t,r;if(this._resizeTo===globalThis.window)t=globalThis.innerWidth,r=globalThis.innerHeight;else{const{clientWidth:i,clientHeight:n}=this._resizeTo;t=i,r=n}this.renderer.resize(t,r),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=e.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}$e.extension=S.Application;class Ke{static init(e){e=Object.assign({autoStart:!0,sharedTicker:!1},e),Object.defineProperty(this,"ticker",{set(t){this._ticker&&this._ticker.remove(this.render,this),this._ticker=t,t&&t.add(this.render,this,yt.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=e.sharedTicker?pe.shared:new pe,e.autoStart&&this.start()}static destroy(){if(this._ticker){const e=this._ticker;this.ticker=null,e.destroy()}}}Ke.extension=S.Application;class Ve{constructor(e){this._renderer=e}push(e,t,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:t,filterEffect:e})}pop(e,t,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(e){e.action==="pushFilter"?this._renderer.filter.push(e):e.action==="popFilter"&&this._renderer.filter.pop()}destroy(){this._renderer=null}}Ve.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"filter"};const Gt=new I;function Lt(s,e){return e.clear(),Ye(s,e),e.isValid||e.set(0,0,0,0),s.renderGroup?e.applyMatrix(s.renderGroup.localTransform):e.applyMatrix(s.parentRenderGroup.worldTransform),e}function Ye(s,e){if(s.localDisplayStatus!==7||!s.measurable)return;const t=!!s.effects.length;let r=e;if((s.renderGroup||t)&&(r=Q.get().clear()),s.boundsArea)e.addRect(s.boundsArea,s.worldTransform);else{if(s.renderPipeId){const n=s.bounds;r.addFrame(n.minX,n.minY,n.maxX,n.maxY,s.groupTransform)}const i=s.children;for(let n=0;n<i.length;n++)Ye(i[n],r)}if(t){let i=!1;for(let n=0;n<s.effects.length;n++)s.effects[n].addBounds&&(i||(i=!0,r.applyMatrix(s.parentRenderGroup.worldTransform)),s.effects[n].addBounds(r,!0));i&&(r.applyMatrix(s.parentRenderGroup.worldTransform.copyTo(Gt).invert()),e.addBounds(r,s.relativeGroupTransform)),e.addBounds(r),Q.return(r)}else s.renderGroup&&(e.addBounds(r,s.relativeGroupTransform),Q.return(r))}function Ot(s,e){e.clear();const t=e.matrix;for(let r=0;r<s.length;r++){const i=s[r];i.globalDisplayStatus<7||(e.matrix=i.worldTransform,i.addBounds(e))}return e.matrix=t,e}const Dt=new Re({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),location:0,format:"float32x2",stride:2*4,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])});class je{constructor(e){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new V({uInputSize:{value:new Float32Array(4),type:"vec4<f32>"},uInputPixel:{value:new Float32Array(4),type:"vec4<f32>"},uInputClamp:{value:new Float32Array(4),type:"vec4<f32>"},uOutputFrame:{value:new Float32Array(4),type:"vec4<f32>"},uGlobalFrame:{value:new Float32Array(4),type:"vec4<f32>"},uOutputTexture:{value:new Float32Array(4),type:"vec4<f32>"}}),this._globalFilterBindGroup=new Ae({}),this.renderer=e}get activeBackTexture(){return this._activeFilterData?.backTexture}push(e){const t=this.renderer,r=e.filterEffect.filters;this._filterStack[this._filterStackIndex]||(this._filterStack[this._filterStackIndex]=this._getFilterData());const i=this._filterStack[this._filterStackIndex];if(this._filterStackIndex++,r.length===0){i.skip=!0;return}const n=i.bounds;e.renderables?Ot(e.renderables,n):e.filterEffect.filterArea?(n.clear(),n.addRect(e.filterEffect.filterArea),n.applyMatrix(e.container.worldTransform)):Lt(e.container,n);const a=t.renderTarget.rootRenderTarget.colorTexture.source;let o=a._resolution,c=0,h=a.antialias,l=!1,d=!1;for(let u=0;u<r.length;u++){const p=r[u];if(o=Math.min(o,p.resolution),c+=p.padding,p.antialias!=="inherit"&&(p.antialias==="on"?h=!0:h=!1),!!!(p.compatibleRenderers&t.type)){d=!1;break}if(p.blendRequired&&!(t.backBuffer?.useBackBuffer??!0)){K("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),d=!1;break}d=p.enabled||d,l=l||p.blendRequired}if(!d){i.skip=!0;return}const f=t.renderTarget.rootViewPort;if(n.scale(o).fitBounds(0,f.width,0,f.height).scale(1/o).pad(c).ceil(),!n.isPositive){i.skip=!0;return}i.skip=!1,i.bounds=n,i.blendRequired=l,i.container=e.container,i.filterEffect=e.filterEffect,i.previousRenderSurface=t.renderTarget.renderSurface,i.inputTexture=z.getOptimalTexture(n.width,n.height,o,h),t.renderTarget.bind(i.inputTexture,!0),t.globalUniforms.push({offset:n})}pop(){const e=this.renderer;this._filterStackIndex--;const t=this._filterStack[this._filterStackIndex];if(t.skip)return;this._activeFilterData=t;const r=t.inputTexture,i=t.bounds;let n=W.EMPTY;if(e.renderTarget.finishRenderPass(),t.blendRequired){const o=this._filterStackIndex>0?this._filterStack[this._filterStackIndex-1].bounds:null,c=e.renderTarget.getRenderTarget(t.previousRenderSurface);n=this.getBackTexture(c,i,o)}t.backTexture=n;const a=t.filterEffect.filters;if(this._globalFilterBindGroup.setResource(r.source.style,2),this._globalFilterBindGroup.setResource(n.source,3),e.globalUniforms.pop(),a.length===1)a[0].apply(this,r,t.previousRenderSurface,!1),z.returnTexture(r);else{let o=t.inputTexture,c=z.getOptimalTexture(i.width,i.height,o.source._resolution,!1),h=0;for(h=0;h<a.length-1;++h){a[h].apply(this,o,c,!0);const d=o;o=c,c=d}a[h].apply(this,o,t.previousRenderSurface,!1),z.returnTexture(o),z.returnTexture(c)}t.blendRequired&&z.returnTexture(n)}getBackTexture(e,t,r){const i=e.colorTexture.source._resolution,n=z.getOptimalTexture(t.width,t.height,i,!1);let a=t.minX,o=t.minY;r&&(a-=r.minX,o-=r.minY),a=Math.floor(a*i),o=Math.floor(o*i);const c=Math.ceil(t.width*i),h=Math.ceil(t.height*i);return this.renderer.renderTarget.copyToTexture(e,n,{x:a,y:o},{width:c,height:h},{x:0,y:0}),n}applyFilter(e,t,r,i){const n=this.renderer,a=this._filterStack[this._filterStackIndex],o=a.bounds,c=wt.shared,l=a.previousRenderSurface===r;let d=this.renderer.renderTarget.rootRenderTarget.colorTexture.source._resolution,f=this._filterStackIndex-1;for(;f>0&&this._filterStack[f].skip;)--f;f>0&&(d=this._filterStack[f].inputTexture.source._resolution);const u=this._filterGlobalUniforms,p=u.uniforms,x=p.uOutputFrame,m=p.uInputSize,_=p.uInputPixel,w=p.uInputClamp,b=p.uGlobalFrame,y=p.uOutputTexture;if(l){let v=this._filterStackIndex;for(;v>0;){v--;const k=this._filterStack[this._filterStackIndex-1];if(!k.skip){c.x=k.bounds.minX,c.y=k.bounds.minY;break}}x[0]=o.minX-c.x,x[1]=o.minY-c.y}else x[0]=0,x[1]=0;x[2]=t.frame.width,x[3]=t.frame.height,m[0]=t.source.width,m[1]=t.source.height,m[2]=1/m[0],m[3]=1/m[1],_[0]=t.source.pixelWidth,_[1]=t.source.pixelHeight,_[2]=1/_[0],_[3]=1/_[1],w[0]=.5*_[2],w[1]=.5*_[3],w[2]=t.frame.width*m[2]-.5*_[2],w[3]=t.frame.height*m[3]-.5*_[3];const T=this.renderer.renderTarget.rootRenderTarget.colorTexture;b[0]=c.x*d,b[1]=c.y*d,b[2]=T.source.width*d,b[3]=T.source.height*d;const P=this.renderer.renderTarget.getRenderTarget(r);if(n.renderTarget.bind(r,!!i),r instanceof W?(y[0]=r.frame.width,y[1]=r.frame.height):(y[0]=P.width,y[1]=P.height),y[2]=P.isRoot?-1:1,u.update(),n.renderPipes.uniformBatch){const v=n.renderPipes.uniformBatch.getUboResource(u);this._globalFilterBindGroup.setResource(v,0)}else this._globalFilterBindGroup.setResource(u,0);this._globalFilterBindGroup.setResource(t.source,1),this._globalFilterBindGroup.setResource(t.source.style,2),e.groups[0]=this._globalFilterBindGroup,n.encoder.draw({geometry:Dt,shader:e,state:e._state,topology:"triangle-list"}),n.type===ae.WEBGL&&n.renderTarget.finishRenderPass()}_getFilterData(){return{skip:!1,inputTexture:null,bounds:new We,container:null,filterEffect:null,blendRequired:!1,previousRenderSurface:null}}calculateSpriteMatrix(e,t){const r=this._activeFilterData,i=e.set(r.inputTexture._source.width,0,0,r.inputTexture._source.height,r.bounds.minX,r.bounds.minY),n=t.worldTransform.copyTo(I.shared);return n.invert(),i.prepend(n),i.scale(1/t.texture.frame.width,1/t.texture.frame.height),i.translate(t.anchor.x,t.anchor.y),i}}je.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"filter"};const Xe=class Ne extends Re{constructor(...e){let t=e[0]??{};t instanceof Float32Array&&(M(A,"use new MeshGeometry({ positions, uvs, indices }) instead"),t={positions:t,uvs:e[1],indices:e[2]}),t={...Ne.defaultOptions,...t};const r=t.positions||new Float32Array([0,0,1,0,1,1,0,1]),i=t.uvs||new Float32Array([0,0,1,0,1,1,0,1]),n=t.indices||new Uint32Array([0,1,2,0,2,3]),a=t.shrinkBuffersToFit,o=new Z({data:r,label:"attribute-mesh-positions",shrinkToFit:a,usage:D.VERTEX|D.COPY_DST}),c=new Z({data:i,label:"attribute-mesh-uvs",shrinkToFit:a,usage:D.VERTEX|D.COPY_DST}),h=new Z({data:n,label:"index-mesh-buffer",shrinkToFit:a,usage:D.INDEX|D.COPY_DST});super({attributes:{aPosition:{buffer:o,format:"float32x2",stride:2*4,offset:0},aUV:{buffer:c,format:"float32x2",stride:2*4,offset:0}},indexBuffer:h,topology:t.topology}),this.batchMode="auto"}get positions(){return this.attributes.aPosition.buffer.data}set positions(e){this.attributes.aPosition.buffer.data=e}get uvs(){return this.attributes.aUV.buffer.data}set uvs(e){this.attributes.aUV.buffer.data=e}get indices(){return this.indexBuffer.data}set indices(e){this.indexBuffer.data=e}};Xe.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let ce=Xe;const Et=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function N(s){const e=typeof s.fontSize=="number"?`${s.fontSize}px`:s.fontSize;let t=s.fontFamily;Array.isArray(s.fontFamily)||(t=s.fontFamily.split(","));for(let r=t.length-1;r>=0;r--){let i=t[r].trim();!/([\"\'])[^\'\"]+\1/.test(i)&&!Et.includes(i)&&(i=`"${i}"`),t[r]=i}return`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${e} ${t.join(",")}`}const ee={willReadFrequently:!0},U=class g{static get experimentalLetterSpacingSupported(){let e=g._experimentalLetterSpacingSupported;if(e!==void 0){const t=L.get().getCanvasRenderingContext2D().prototype;e=g._experimentalLetterSpacingSupported="letterSpacing"in t||"textLetterSpacing"in t}return e}constructor(e,t,r,i,n,a,o,c,h){this.text=e,this.style=t,this.width=r,this.height=i,this.lines=n,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=c,this.fontProperties=h}static measureText(e=" ",t,r=g._canvas,i=t.wordWrap){const n=`${e}:${t.styleKey}`;if(g._measurementCache[n])return g._measurementCache[n];const a=N(t),o=g.measureFont(a);o.fontSize===0&&(o.fontSize=t.fontSize,o.ascent=t.fontSize);const c=g.__context;c.font=a;const l=(i?g._wordWrap(e,t,r):e).split(/(?:\r\n|\r|\n)/),d=new Array(l.length);let f=0;for(let w=0;w<l.length;w++){const b=g._measureText(l[w],t.letterSpacing,c);d[w]=b,f=Math.max(f,b)}const u=t._stroke?.width||0;let p=f+u;t.dropShadow&&(p+=t.dropShadow.distance);const x=t.lineHeight||o.fontSize+u;let m=Math.max(x,o.fontSize+u*2)+(l.length-1)*(x+t.leading);return t.dropShadow&&(m+=t.dropShadow.distance),new g(e,t,p,m,l,d,x+t.leading,f,o)}static _measureText(e,t,r){let i=!1;g.experimentalLetterSpacingSupported&&(g.experimentalLetterSpacing?(r.letterSpacing=`${t}px`,r.textLetterSpacing=`${t}px`,i=!0):(r.letterSpacing="0px",r.textLetterSpacing="0px"));let n=r.measureText(e).width;return n>0&&(i?n-=t:n+=(g.graphemeSegmenter(e).length-1)*t),n}static _wordWrap(e,t,r=g._canvas){const i=r.getContext("2d",ee);let n=0,a="",o="";const c=Object.create(null),{letterSpacing:h,whiteSpace:l}=t,d=g._collapseSpaces(l),f=g._collapseNewlines(l);let u=!d;const p=t.wordWrapWidth+h,x=g._tokenize(e);for(let m=0;m<x.length;m++){let _=x[m];if(g._isNewline(_)){if(!f){o+=g._addLine(a),u=!d,a="",n=0;continue}_=" "}if(d){const b=g.isBreakingSpace(_),y=g.isBreakingSpace(a[a.length-1]);if(b&&y)continue}const w=g._getFromCache(_,h,c,i);if(w>p)if(a!==""&&(o+=g._addLine(a),a="",n=0),g.canBreakWords(_,t.breakWords)){const b=g.wordWrapSplit(_);for(let y=0;y<b.length;y++){let T=b[y],P=T,v=1;for(;b[y+v];){const C=b[y+v];if(!g.canBreakChars(P,C,_,y,t.breakWords))T+=C;else break;P=C,v++}y+=v-1;const k=g._getFromCache(T,h,c,i);k+n>p&&(o+=g._addLine(a),u=!1,a="",n=0),a+=T,n+=k}}else{a.length>0&&(o+=g._addLine(a),a="",n=0);const b=m===x.length-1;o+=g._addLine(_,!b),u=!1,a="",n=0}else w+n>p&&(u=!1,o+=g._addLine(a),a="",n=0),(a.length>0||!g.isBreakingSpace(_)||u)&&(a+=_,n+=w)}return o+=g._addLine(a,!1),o}static _addLine(e,t=!0){return e=g._trimRight(e),e=t?`${e}
|
|
`:e,e}static _getFromCache(e,t,r,i){let n=r[e];return typeof n!="number"&&(n=g._measureText(e,t,i)+t,r[e]=n),n}static _collapseSpaces(e){return e==="normal"||e==="pre-line"}static _collapseNewlines(e){return e==="normal"}static _trimRight(e){if(typeof e!="string")return"";for(let t=e.length-1;t>=0;t--){const r=e[t];if(!g.isBreakingSpace(r))break;e=e.slice(0,-1)}return e}static _isNewline(e){return typeof e!="string"?!1:g._newlines.includes(e.charCodeAt(0))}static isBreakingSpace(e,t){return typeof e!="string"?!1:g._breakingSpaces.includes(e.charCodeAt(0))}static _tokenize(e){const t=[];let r="";if(typeof e!="string")return t;for(let i=0;i<e.length;i++){const n=e[i],a=e[i+1];if(g.isBreakingSpace(n,a)||g._isNewline(n)){r!==""&&(t.push(r),r=""),t.push(n);continue}r+=n}return r!==""&&t.push(r),t}static canBreakWords(e,t){return t}static canBreakChars(e,t,r,i,n){return!0}static wordWrapSplit(e){return g.graphemeSegmenter(e)}static measureFont(e){if(g._fonts[e])return g._fonts[e];const t=g._context;t.font=e;const r=t.measureText(g.METRICS_STRING+g.BASELINE_SYMBOL),i={ascent:r.actualBoundingBoxAscent,descent:r.actualBoundingBoxDescent,fontSize:r.actualBoundingBoxAscent+r.actualBoundingBoxDescent};return g._fonts[e]=i,i}static clearMetrics(e=""){e?delete g._fonts[e]:g._fonts={}}static get _canvas(){if(!g.__canvas){let e;try{const t=new OffscreenCanvas(0,0);if(t.getContext("2d",ee)?.measureText)return g.__canvas=t,t;e=L.get().createCanvas()}catch{e=L.get().createCanvas()}e.width=e.height=10,g.__canvas=e}return g.__canvas}static get _context(){return g.__context||(g.__context=g._canvas.getContext("2d",ee)),g.__context}};U.METRICS_STRING="|\xc9q\xc5";U.BASELINE_SYMBOL="M";U.BASELINE_MULTIPLIER=1.4;U.HEIGHT_MULTIPLIER=2;U.graphemeSegmenter=(()=>{if(typeof Intl?.Segmenter=="function"){const s=new Intl.Segmenter;return e=>[...s.segment(e)].map(t=>t.segment)}return s=>[...s]})();U.experimentalLetterSpacing=!1;U._fonts={};U._newlines=[10,13];U._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];U._measurementCache={};let G=U;const _e=["_fontFamily","_fontStyle","_fontSize","_fontVariant","_fontWeight","_breakWords","_align","_leading","_letterSpacing","_lineHeight","_textBaseline","_whiteSpace","_wordWrap","_wordWrapWidth","_padding","_cssOverrides","_trim"];function qe(s){const e=[];let t=0;for(let r=0;r<_e.length;r++){const i=_e[r];e[t++]=s[i]}return t=Qe(s._fill,e,t),t=$t(s._stroke,e,t),e.join("-")}function Qe(s,e,t){return s&&(e[t++]=s.color,e[t++]=s.alpha,e[t++]=s.fill?.uid),t}function $t(s,e,t){return s&&(t=Qe(s,e,t),e[t++]=s.width,e[t++]=s.alignment,e[t++]=s.cap,e[t++]=s.join,e[t++]=s.miterLimit),t}const le=class E extends Ue{constructor(e={}){super(),Kt(e);const t={...E.defaultTextStyle,...e};for(const r in t){const i=r;this[i]=t[r]}this.update()}get align(){return this._align}set align(e){this._align=e,this.update()}get breakWords(){return this._breakWords}set breakWords(e){this._breakWords=e,this.update()}get dropShadow(){return this._dropShadow}set dropShadow(e){e!==null&&typeof e=="object"?this._dropShadow={...E.defaultDropShadow,...e}:this._dropShadow=e?{...E.defaultDropShadow}:null,this.update()}get fontFamily(){return this._fontFamily}set fontFamily(e){this._fontFamily=e,this.update()}get fontSize(){return this._fontSize}set fontSize(e){typeof e=="string"?this._fontSize=parseInt(e,10):this._fontSize=e,this.update()}get fontStyle(){return this._fontStyle}set fontStyle(e){this._fontStyle=e,this.update()}get fontVariant(){return this._fontVariant}set fontVariant(e){this._fontVariant=e,this.update()}get fontWeight(){return this._fontWeight}set fontWeight(e){this._fontWeight=e,this.update()}get leading(){return this._leading}set leading(e){this._leading=e,this.update()}get letterSpacing(){return this._letterSpacing}set letterSpacing(e){this._letterSpacing=e,this.update()}get lineHeight(){return this._lineHeight}set lineHeight(e){this._lineHeight=e,this.update()}get padding(){return this._padding}set padding(e){this._padding=e,this.update()}get trim(){return this._trim}set trim(e){this._trim=e,this.update()}get textBaseline(){return this._textBaseline}set textBaseline(e){this._textBaseline=e,this.update()}get whiteSpace(){return this._whiteSpace}set whiteSpace(e){this._whiteSpace=e,this.update()}get wordWrap(){return this._wordWrap}set wordWrap(e){this._wordWrap=e,this.update()}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(e){this._wordWrapWidth=e,this.update()}get fill(){return this._originalFill}set fill(e){e!==this._originalFill&&(this._originalFill=e,this._fill=ge(e===0?"black":e,me.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(e){e!==this._originalStroke&&(this._originalStroke=e,this._stroke=ge(e,me.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=qe(this),this._styleKey}update(){this._styleKey=null,this.emit("update",this)}reset(){const e=E.defaultTextStyle;for(const t in e)this[t]=e[t]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new E({align:this.align,breakWords:this.breakWords,dropShadow:this.dropShadow,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,textBaseline:this.textBaseline,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth})}destroy(e=!1){if(this.removeAllListeners(),typeof e=="boolean"?e:e?.texture){const r=typeof e=="boolean"?e:e?.textureSource;this._fill?.texture&&this._fill.texture.destroy(r),this._originalFill?.texture&&this._originalFill.texture.destroy(r),this._stroke?.texture&&this._stroke.texture.destroy(r),this._originalStroke?.texture&&this._originalStroke.texture.destroy(r)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}};le.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};le.defaultTextStyle={align:"left",breakWords:!1,dropShadow:null,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,padding:0,stroke:null,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let $=le;function Kt(s){const e=s;if(typeof e.dropShadow=="boolean"&&e.dropShadow){const t=$.defaultDropShadow;s.dropShadow={alpha:e.dropShadowAlpha??t.alpha,angle:e.dropShadowAngle??t.angle,blur:e.dropShadowBlur??t.blur,color:e.dropShadowColor??t.color,distance:e.dropShadowDistance??t.distance}}if(e.strokeThickness!==void 0){M(A,"strokeThickness is now a part of stroke");const t=e.stroke;s.stroke={color:t,width:e.strokeThickness}}if(Array.isArray(e.fill)){M(A,"gradient fill is now a fill pattern: `new FillGradient(...)`");const t=new ze(0,0,0,s.fontSize*1.7),r=e.fill.map(i=>H.shared.setValue(i).toNumber());r.forEach((i,n)=>{const a=e.fillGradientStops[n]??n/r.length;t.addColorStop(a,i)}),s.fill={fill:t}}}function q(s,e){if(s.texture===W.WHITE&&!s.fill)return H.shared.setValue(s.color).toHex();if(s.fill){if(s.fill instanceof Tt){const t=s.fill,r=e.createPattern(t.texture.source.resource,"repeat"),i=t.transform.copyTo(I.shared);return i.scale(t.texture.frame.width,t.texture.frame.height),r.setTransform(i),r}else if(s.fill instanceof ze){const t=s.fill;if(t.type==="linear"){const r=e.createLinearGradient(t.x0,t.y0,t.x1,t.y1);return t.gradientStops.forEach(i=>{r.addColorStop(i.offset,H.shared.setValue(i.color).toHex())}),r}}}else{const t=e.createPattern(s.texture.source.resource,"repeat"),r=s.matrix.copyTo(I.shared);return r.scale(s.texture.frame.width,s.texture.frame.height),t.setTransform(r),t}return K("FillStyle not recognised",s),"red"}class Ze extends Ue{constructor(){super(...arguments),this.chars=Object.create(null),this.lineHeight=0,this.fontFamily="",this.fontMetrics={fontSize:0,ascent:0,descent:0},this.baseLineOffset=0,this.distanceField={type:"none",range:0},this.pages=[],this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}get font(){return M(A,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return M(A,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return M(A,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return M(A,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return M(A,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(e=!1){this.emit("destroy",this),this.removeAllListeners();for(const t in this.chars)this.chars[t].texture.destroy();this.chars=null,e&&(this.pages.forEach(t=>t.texture.destroy(!0)),this.pages=null)}}function Je(s){if(s==="")return[];typeof s=="string"&&(s=[s]);const e=[];for(let t=0,r=s.length;t<r;t++){const i=s[t];if(Array.isArray(i)){if(i.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${i.length}.`);if(i[0].length===0||i[1].length===0)throw new Error("[BitmapFont]: Invalid character delimiter.");const n=i[0].charCodeAt(0),a=i[1].charCodeAt(0);if(a<n)throw new Error("[BitmapFont]: Invalid character range.");for(let o=n,c=a;o<=c;o++)e.push(String.fromCharCode(o))}else e.push(...Array.from(i))}if(e.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return e}class be extends Ze{constructor(e){super(),this.resolution=1,this.pages=[],this._padding=4,this._measureCache=Object.create(null),this._currentChars=[],this._currentX=0,this._currentY=0,this._currentPageIndex=-1,this._skipKerning=!1;const t=e,r=t.style.clone();t.overrideFill&&(r._fill.color=16777215,r._fill.alpha=1,r._fill.texture=W.WHITE,r._fill.fill=null);const i=r.fontSize;r.fontSize=this.baseMeasurementFontSize;const n=N(r);t.overrideSize?r._stroke&&(r._stroke.width*=this.baseRenderedFontSize/i):r.fontSize=this.baseRenderedFontSize=i,this._style=r,this._skipKerning=t.skipKerning??!1,this.resolution=t.resolution??1,this._padding=t.padding??4,this.fontMetrics=G.measureFont(n),this.lineHeight=r.lineHeight||this.fontMetrics.fontSize||r.fontSize}ensureCharacters(e){const t=Je(e).filter(x=>!this._currentChars.includes(x)).filter((x,m,_)=>_.indexOf(x)===m);if(!t.length)return;this._currentChars=[...this._currentChars,...t];let r;this._currentPageIndex===-1?r=this._nextPage():r=this.pages[this._currentPageIndex];let{canvas:i,context:n}=r.canvasAndContext,a=r.texture.source;const o=this._style;let c=this._currentX,h=this._currentY;const l=this.baseRenderedFontSize/this.baseMeasurementFontSize,d=this._padding*l,f=o.fontStyle==="italic"?2:1;let u=0,p=!1;for(let x=0;x<t.length;x++){const m=t[x],_=G.measureText(m,o,i,!1);_.lineHeight=_.height;const w=f*_.width*l,b=_.height*l,y=w+d*2,T=b+d*2;if(p=!1,m!==`
|
|
`&&m!=="\r"&&m!==" "&&m!==" "&&(p=!0,u=Math.ceil(Math.max(T,u))),c+y>512&&(h+=u,u=T,c=0,h+u>512)){a.update();const v=this._nextPage();i=v.canvasAndContext.canvas,n=v.canvasAndContext.context,a=v.texture.source,h=0}const P=w/l-(o.dropShadow?.distance??0)-(o._stroke?.width??0);if(this.chars[m]={id:m.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:P,kerning:{}},p){this._drawGlyph(n,_,c+d,h+d,l,o);const v=a.width*l,k=a.height*l,C=new X(c/v*a.width,h/k*a.height,y/v*a.width,T/k*a.height);this.chars[m].texture=new W({source:a,frame:C}),c+=Math.ceil(y)}}a.update(),this._currentX=c,this._currentY=h,this._skipKerning&&this._applyKerning(t,n)}get pageTextures(){return M(A,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(e,t){const r=this._measureCache;for(let i=0;i<e.length;i++){const n=e[i];for(let a=0;a<this._currentChars.length;a++){const o=this._currentChars[a];let c=r[n];c||(c=r[n]=t.measureText(n).width);let h=r[o];h||(h=r[o]=t.measureText(o).width);let l=t.measureText(n+o).width,d=l-(c+h);d&&(this.chars[n].kerning[o]=d),l=t.measureText(n+o).width,d=l-(c+h),d&&(this.chars[o].kerning[n]=d)}}}_nextPage(){this._currentPageIndex++;const e=this.resolution,t=O.getOptimalCanvasAndContext(512,512,e);this._setupContext(t.context,this._style,e);const r=e*(this.baseRenderedFontSize/this.baseMeasurementFontSize),i=new W({source:new vt({resource:t.canvas,resolution:r,alphaMode:"premultiply-alpha-on-upload"})}),n={canvasAndContext:t,texture:i};return this.pages[this._currentPageIndex]=n,n}_setupContext(e,t,r){t.fontSize=this.baseRenderedFontSize,e.scale(r,r),e.font=N(t),t.fontSize=this.baseMeasurementFontSize,e.textBaseline=t.textBaseline;const i=t._stroke,n=i?.width??0;if(i&&(e.lineWidth=n,e.lineJoin=i.join,e.miterLimit=i.miterLimit,e.strokeStyle=q(i,e)),t._fill&&(e.fillStyle=q(t._fill,e)),t.dropShadow){const a=t.dropShadow,o=H.shared.setValue(a.color).toArray(),c=a.blur*r,h=a.distance*r;e.shadowColor=`rgba(${o[0]*255},${o[1]*255},${o[2]*255},${a.alpha})`,e.shadowBlur=c,e.shadowOffsetX=Math.cos(a.angle)*h,e.shadowOffsetY=Math.sin(a.angle)*h}else e.shadowColor="black",e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0}_drawGlyph(e,t,r,i,n,a){const o=t.text,c=t.fontProperties,l=(a._stroke?.width??0)*n,d=r+l/2,f=i-l/2,u=c.descent*n,p=t.lineHeight*n;a.stroke&&l&&e.strokeText(o,d,f+p-u),a._fill&&e.fillText(o,d,f+p-u)}destroy(){super.destroy();for(let e=0;e<this.pages.length;e++){const{canvasAndContext:t,texture:r}=this.pages[e];O.returnCanvasAndContext(t),r.destroy(!0)}this.pages=null}}function et(s,e,t){const r={width:0,height:0,offsetY:0,scale:e.fontSize/t.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};r.offsetY=t.baseLineOffset;let i=r.lines[0],n=null,a=!0;const o={spaceWord:!1,width:0,start:0,index:0,positions:[],chars:[]},c=u=>{const p=i.width;for(let x=0;x<o.index;x++){const m=u.positions[x];i.chars.push(u.chars[x]),i.charPositions.push(m+p)}i.width+=u.width,a=!1,o.width=0,o.index=0,o.chars.length=0},h=()=>{let u=i.chars.length-1,p=i.chars[u];for(;p===" ";)i.width-=t.chars[p].xAdvance,p=i.chars[--u];r.width=Math.max(r.width,i.width),i={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},a=!0,r.lines.push(i),r.height+=t.lineHeight},l=t.baseMeasurementFontSize/e.fontSize,d=e.letterSpacing*l,f=e.wordWrapWidth*l;for(let u=0;u<s.length+1;u++){let p;const x=u===s.length;x||(p=s[u]);const m=t.chars[p]||t.chars[" "];if(/(?:\s)/.test(p)||p==="\r"||p===`
|
|
`||x){if(!a&&e.wordWrap&&i.width+o.width-d>f?(h(),c(o),x||i.charPositions.push(0)):(o.start=i.width,c(o),x||i.charPositions.push(0)),p==="\r"||p===`
|
|
`)i.width!==0&&h();else if(!x){const y=m.xAdvance+(m.kerning[n]||0)+d;i.width+=y,i.spaceWidth=y,i.spacesIndex.push(i.charPositions.length),i.chars.push(p)}}else{const b=m.kerning[n]||0,y=m.xAdvance+b+d;o.positions[o.index++]=o.width+b,o.chars.push(p),o.width+=y}n=p}return h(),e.align==="center"?Vt(r):e.align==="right"?Yt(r):e.align==="justify"&&jt(r),r}function Vt(s){for(let e=0;e<s.lines.length;e++){const t=s.lines[e],r=s.width/2-t.width/2;for(let i=0;i<t.charPositions.length;i++)t.charPositions[i]+=r}}function Yt(s){for(let e=0;e<s.lines.length;e++){const t=s.lines[e],r=s.width-t.width;for(let i=0;i<t.charPositions.length;i++)t.charPositions[i]+=r}}function jt(s){const e=s.width;for(let t=0;t<s.lines.length;t++){const r=s.lines[t];let i=0,n=r.spacesIndex[i++],a=0;const o=r.spacesIndex.length,h=(e-r.width)/o;for(let l=0;l<r.charPositions.length;l++)l===n&&(n=r.spacesIndex[i++],a+=h),r.charPositions[l]+=a}}class Xt{constructor(){this.ALPHA=[["a","z"],["A","Z"]," "],this.NUMERIC=[["0","9"]],this.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],this.ASCII=[[" ","~"]],this.defaultOptions={chars:this.ALPHANUMERIC,resolution:1,padding:4,skipKerning:!1}}getFont(e,t){let r=`${t.fontFamily}-bitmap`,i=!0;if(t._fill.fill&&(r+=t._fill.fill.uid,i=!1),!R.has(r)){const a=new be({style:t,overrideFill:i,overrideSize:!0,...this.defaultOptions});a.once("destroy",()=>R.remove(r)),R.set(r,a)}const n=R.get(r);return n.ensureCharacters?.(e),n}getLayout(e,t){const r=this.getFont(e,t);return et([...e],t,r)}measureText(e,t){return this.getLayout(e,t)}install(...e){let t=e[0];typeof t=="string"&&(t={name:t,style:e[1],chars:e[2]?.chars,resolution:e[2]?.resolution,padding:e[2]?.padding,skipKerning:e[2]?.skipKerning},M(A,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const r=t?.name;if(!r)throw new Error("[BitmapFontManager] Property `name` is required.");t={...this.defaultOptions,...t};const i=t.style,n=i instanceof $?i:new $(i),a=n._fill.fill!==null&&n._fill.fill!==void 0,o=new be({style:n,overrideFill:a,skipKerning:t.skipKerning,padding:t.padding,resolution:t.resolution,overrideSize:!1}),c=Je(t.chars);return o.ensureCharacters(c.join("")),R.set(`${r}-bitmap`,o),o.once("destroy",()=>R.remove(`${r}-bitmap`)),o}uninstall(e){const t=`${e}-bitmap`,r=R.get(t);r&&(R.remove(t),r.destroy())}}const ne=new Xt;function Nt(s){const e=s._stroke,t=s._fill,i=[`div { ${[`color: ${H.shared.setValue(t.color).toHex()}`,`font-size: ${s.fontSize}px`,`font-family: ${s.fontFamily}`,`font-weight: ${s.fontWeight}`,`font-style: ${s.fontStyle}`,`font-variant: ${s.fontVariant}`,`letter-spacing: ${s.letterSpacing}px`,`text-align: ${s.align}`,`padding: ${s.padding}px`,`white-space: ${s.whiteSpace==="pre"&&s.wordWrap?"pre-wrap":s.whiteSpace}`,...s.lineHeight?[`line-height: ${s.lineHeight}px`]:[],...s.wordWrap?[`word-wrap: ${s.breakWords?"break-all":"break-word"}`,`max-width: ${s.wordWrapWidth}px`]:[],...e?[rt(e)]:[],...s.dropShadow?[tt(s.dropShadow)]:[],...s.cssOverrides].join(";")} }`];return qt(s.tagStyles,i),i.join(" ")}function tt(s){const e=H.shared.setValue(s.color).setAlpha(s.alpha).toHexa(),t=Math.round(Math.cos(s.angle)*s.distance),r=Math.round(Math.sin(s.angle)*s.distance),i=`${t}px ${r}px`;return s.blur>0?`text-shadow: ${i} ${s.blur}px ${e}`:`text-shadow: ${i} ${e}`}function rt(s){return[`-webkit-text-stroke-width: ${s.width}px`,`-webkit-text-stroke-color: ${H.shared.setValue(s.color).toHex()}`,`text-stroke-width: ${s.width}px`,`text-stroke-color: ${H.shared.setValue(s.color).toHex()}`,"paint-order: stroke"].join(";")}const Se={fontSize:"font-size: {{VALUE}}px",fontFamily:"font-family: {{VALUE}}",fontWeight:"font-weight: {{VALUE}}",fontStyle:"font-style: {{VALUE}}",fontVariant:"font-variant: {{VALUE}}",letterSpacing:"letter-spacing: {{VALUE}}px",align:"text-align: {{VALUE}}",padding:"padding: {{VALUE}}px",whiteSpace:"white-space: {{VALUE}}",lineHeight:"line-height: {{VALUE}}px",wordWrapWidth:"max-width: {{VALUE}}px"},ye={fill:s=>`color: ${H.shared.setValue(s).toHex()}`,breakWords:s=>`word-wrap: ${s?"break-all":"break-word"}`,stroke:rt,dropShadow:tt};function qt(s,e){for(const t in s){const r=s[t],i=[];for(const n in r)ye[n]?i.push(ye[n](r[n])):Se[n]&&i.push(Se[n].replace("{{VALUE}}",r[n]));e.push(`${t} { ${i.join(";")} }`)}}class he extends ${constructor(e={}){super(e),this._cssOverrides=[],this.cssOverrides??(this.cssOverrides=e.cssOverrides),this.tagStyles=e.tagStyles??{}}set cssOverrides(e){this._cssOverrides=e instanceof Array?e:[e],this.update()}get cssOverrides(){return this._cssOverrides}_generateKey(){return this._styleKey=qe(this)+this._cssOverrides.join("-"),this._styleKey}update(){this._cssStyle=null,super.update()}clone(){return new he({align:this.align,breakWords:this.breakWords,dropShadow:this.dropShadow,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,cssOverrides:this.cssOverrides})}get cssStyle(){return this._cssStyle||(this._cssStyle=Nt(this)),this._cssStyle}addOverride(...e){const t=e.filter(r=>!this.cssOverrides.includes(r));t.length>0&&(this.cssOverrides.push(...t),this.update())}removeOverride(...e){const t=e.filter(r=>this.cssOverrides.includes(r));t.length>0&&(this.cssOverrides=this.cssOverrides.filter(r=>!t.includes(r)),this.update())}set fill(e){typeof e!="string"&&typeof e!="number"&&K("[HTMLTextStyle] only color fill is not supported by HTMLText"),super.fill=e}set stroke(e){e&&typeof e!="string"&&typeof e!="number"&&K("[HTMLTextStyle] only color stroke is not supported by HTMLText"),super.stroke=e}}const we="http://www.w3.org/2000/svg",Te="http://www.w3.org/1999/xhtml";class it{constructor(){this.svgRoot=document.createElementNS(we,"svg"),this.foreignObject=document.createElementNS(we,"foreignObject"),this.domElement=document.createElementNS(Te,"div"),this.styleElement=document.createElementNS(Te,"style"),this.image=new Image;const{foreignObject:e,svgRoot:t,styleElement:r,domElement:i}=this;e.setAttribute("width","10000"),e.setAttribute("height","10000"),e.style.overflow="hidden",t.appendChild(e),e.appendChild(r),e.appendChild(i)}}let ve;function Qt(s,e,t,r){r=r||ve||(ve=new it);const{domElement:i,styleElement:n,svgRoot:a}=r;i.innerHTML=`<style>${e.cssStyle}</style><div>${s}</div>`,i.setAttribute("style","transform-origin: top left; display: inline-block"),t&&(n.textContent=t),document.body.appendChild(a);const o=i.getBoundingClientRect();a.remove();const c=G.measureFont(e.fontStyle).descent;return{width:o.width,height:o.height+c}}class st{constructor(e,t){this.state=Ie.for2d(),this._graphicsBatchesHash=Object.create(null),this.renderer=e,this._adaptor=t,this._adaptor.init()}validateRenderable(e){const t=e.context,r=!!this._graphicsBatchesHash[e.uid],i=this.renderer.graphicsContext.updateGpuContext(t);return!!(i.isBatchable||r!==i.isBatchable)}addRenderable(e,t){const r=this.renderer.graphicsContext.updateGpuContext(e.context);e._didGraphicsUpdate&&(e._didGraphicsUpdate=!1,this._rebuild(e)),r.isBatchable?this._addToBatcher(e,t):(this.renderer.renderPipes.batch.break(t),t.add(e))}updateRenderable(e){const t=this._graphicsBatchesHash[e.uid];if(t)for(let r=0;r<t.length;r++){const i=t[r];i.batcher.updateElement(i)}}destroyRenderable(e){this._graphicsBatchesHash[e.uid]&&this._removeBatchForRenderable(e.uid)}execute(e){if(!e.isRenderable)return;const t=this.renderer,r=e.context;if(!t.graphicsContext.getGpuContext(r).batches.length)return;const n=r.customShader||this._adaptor.shader;this.state.blendMode=e.groupBlendMode;const a=n.resources.localUniforms.uniforms;a.uTransformMatrix=e.groupTransform,a.uRound=t._roundPixels|e._roundPixels,oe(e.groupColorAlpha,a.uColor,0),this._adaptor.execute(this,e)}_rebuild(e){const t=!!this._graphicsBatchesHash[e.uid],r=this.renderer.graphicsContext.updateGpuContext(e.context);t&&this._removeBatchForRenderable(e.uid),r.isBatchable&&this._initBatchesForRenderable(e),e.batched=r.isBatchable}_addToBatcher(e,t){const r=this.renderer.renderPipes.batch,i=this._getBatchesForRenderable(e);for(let n=0;n<i.length;n++){const a=i[n];r.addToBatch(a,t)}}_getBatchesForRenderable(e){return this._graphicsBatchesHash[e.uid]||this._initBatchesForRenderable(e)}_initBatchesForRenderable(e){const t=e.context,r=this.renderer.graphicsContext.getGpuContext(t),i=this.renderer._roundPixels|e._roundPixels,n=r.batches.map(a=>{const o=B.get(Ct);return a.copyTo(o),o.renderable=e,o.roundPixels=i,o});return this._graphicsBatchesHash[e.uid]===void 0&&e.on("destroyed",()=>{this.destroyRenderable(e)}),this._graphicsBatchesHash[e.uid]=n,n}_removeBatchForRenderable(e){this._graphicsBatchesHash[e].forEach(t=>{B.return(t)}),this._graphicsBatchesHash[e]=null}destroy(){this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null;for(const e in this._graphicsBatchesHash)this._removeBatchForRenderable(e);this._graphicsBatchesHash=null}}st.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"graphics"};const nt=class at extends ce{constructor(...e){super({});let t=e[0]??{};typeof t=="number"&&(M(A,"PlaneGeometry constructor changed please use { width, height, verticesX, verticesY } instead"),t={width:t,height:e[1],verticesX:e[2],verticesY:e[3]}),this.build(t)}build(e){e={...at.defaultOptions,...e},this.verticesX=this.verticesX??e.verticesX,this.verticesY=this.verticesY??e.verticesY,this.width=this.width??e.width,this.height=this.height??e.height;const t=this.verticesX*this.verticesY,r=[],i=[],n=[],a=this.verticesX-1,o=this.verticesY-1,c=this.width/a,h=this.height/o;for(let d=0;d<t;d++){const f=d%this.verticesX,u=d/this.verticesX|0;r.push(f*c,u*h),i.push(f/a,u/o)}const l=a*o;for(let d=0;d<l;d++){const f=d%a,u=d/a|0,p=u*this.verticesX+f,x=u*this.verticesX+f+1,m=(u+1)*this.verticesX+f,_=(u+1)*this.verticesX+f+1;n.push(p,x,m,x,_,m)}this.buffers[0].data=new Float32Array(r),this.buffers[1].data=new Float32Array(i),this.indexBuffer.data=new Uint32Array(n),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}};nt.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};let Zt=nt;class de{constructor(){this.batcher=null,this.batch=null,this.roundPixels=0,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}get blendMode(){return this.mesh.groupBlendMode}reset(){this.mesh=null,this.texture=null,this.batcher=null,this.batch=null}packIndex(e,t,r){const i=this.geometry.indices;for(let n=0;n<i.length;n++)e[t++]=i[n]+r}packAttributes(e,t,r,i){const n=this.mesh,a=this.geometry,o=n.groupTransform,c=i<<16|this.roundPixels&65535,h=o.a,l=o.b,d=o.c,f=o.d,u=o.tx,p=o.ty,x=a.positions,m=a.getBuffer("aUV"),_=m.data;let w=_;const b=this.texture.textureMatrix;b.isSimple||(w=this._transformedUvs,(this._textureMatrixUpdateId!==b._updateID||this._uvUpdateId!==m._updateID)&&((!w||w.length<_.length)&&(w=this._transformedUvs=new Float32Array(_.length)),this._textureMatrixUpdateId=b._updateID,this._uvUpdateId=m._updateID,b.multiplyUvs(_,w)));const y=n.groupColorAlpha;for(let T=0;T<x.length;T+=2){const P=x[T],v=x[T+1];e[r]=h*P+d*v+u,e[r+1]=l*P+f*v+p,e[r+2]=w[T],e[r+3]=w[T+1],t[r+4]=y,t[r+5]=c,r+=6}}get vertexSize(){return this.geometry.positions.length/2}get indexSize(){return this.geometry.indices.length}}class ot{constructor(e,t){this.localUniforms=new V({uTransformMatrix:{value:new I,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new Ae({0:this.localUniforms}),this._meshDataHash=Object.create(null),this._gpuBatchableMeshHash=Object.create(null),this.renderer=e,this._adaptor=t,this._adaptor.init()}validateRenderable(e){const t=this._getMeshData(e),r=t.batched,i=e.batched;if(t.batched=i,r!==i)return!0;if(i){const n=e._geometry;if(n.indices.length!==t.indexSize||n.positions.length!==t.vertexSize)return t.indexSize=n.indices.length,t.vertexSize=n.positions.length,!0;const a=this._getBatchableMesh(e),o=e.texture;if(a.texture._source!==o._source&&a.texture._source!==o._source)return!a.batcher.checkAndUpdateTexture(a,o)}return!1}addRenderable(e,t){const r=this.renderer.renderPipes.batch,{batched:i}=this._getMeshData(e);if(i){const n=this._getBatchableMesh(e);n.texture=e._texture,n.geometry=e._geometry,r.addToBatch(n)}else r.break(t),t.add({renderPipeId:"mesh",mesh:e})}updateRenderable(e){if(e.batched){const t=this._gpuBatchableMeshHash[e.uid];t.texture=e._texture,t.geometry=e._geometry,t.batcher.updateElement(t)}}destroyRenderable(e){this._meshDataHash[e.uid]=null;const t=this._gpuBatchableMeshHash[e.uid];t&&(B.return(t),this._gpuBatchableMeshHash[e.uid]=null)}execute({mesh:e}){if(!e.isRenderable)return;e.state.blendMode=e.groupBlendMode;const t=this.localUniforms;t.uniforms.uTransformMatrix=e.groupTransform,t.uniforms.uRound=this.renderer._roundPixels|e._roundPixels,t.update(),oe(e.groupColorAlpha,t.uniforms.uColor,0),this._adaptor.execute(this,e)}_getMeshData(e){return this._meshDataHash[e.uid]||this._initMeshData(e)}_initMeshData(e){return this._meshDataHash[e.uid]={batched:e.batched,indexSize:e._geometry.indices?.length,vertexSize:e._geometry.positions?.length},e.on("destroyed",()=>{this.destroyRenderable(e)}),this._meshDataHash[e.uid]}_getBatchableMesh(e){return this._gpuBatchableMeshHash[e.uid]||this._initBatchableMesh(e)}_initBatchableMesh(e){const t=B.get(de);return t.mesh=e,t.texture=e._texture,t.roundPixels=this.renderer._roundPixels|e._roundPixels,this._gpuBatchableMeshHash[e.uid]=t,t.mesh=e,t}destroy(){for(const e in this._gpuBatchableMeshHash)this._gpuBatchableMeshHash[e]&&B.return(this._gpuBatchableMeshHash[e]);this._gpuBatchableMeshHash=null,this._meshDataHash=null,this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}}ot.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"mesh"};const ct=class lt extends Zt{constructor(e={}){e={...lt.defaultOptions,...e},super({width:e.width,height:e.height,verticesX:4,verticesY:4}),this.update(e)}update(e){this.width=e.width??this.width,this.height=e.height??this.height,this._originalWidth=e.originalWidth??this._originalWidth,this._originalHeight=e.originalHeight??this._originalHeight,this._leftWidth=e.leftWidth??this._leftWidth,this._rightWidth=e.rightWidth??this._rightWidth,this._topHeight=e.topHeight??this._topHeight,this._bottomHeight=e.bottomHeight??this._bottomHeight,this.updateUvs(),this.updatePositions()}updatePositions(){const e=this.positions,t=this._leftWidth+this._rightWidth,r=this.width>t?1:this.width/t,i=this._topHeight+this._bottomHeight,n=this.height>i?1:this.height/i,a=Math.min(r,n);e[9]=e[11]=e[13]=e[15]=this._topHeight*a,e[17]=e[19]=e[21]=e[23]=this.height-this._bottomHeight*a,e[25]=e[27]=e[29]=e[31]=this.height,e[2]=e[10]=e[18]=e[26]=this._leftWidth*a,e[4]=e[12]=e[20]=e[28]=this.width-this._rightWidth*a,e[6]=e[14]=e[22]=e[30]=this.width,this.getBuffer("aPosition").update()}updateUvs(){const e=this.uvs;e[0]=e[8]=e[16]=e[24]=0,e[1]=e[3]=e[5]=e[7]=0,e[6]=e[14]=e[22]=e[30]=1,e[25]=e[27]=e[29]=e[31]=1;const t=1/this._originalWidth,r=1/this._originalHeight;e[2]=e[10]=e[18]=e[26]=t*this._leftWidth,e[9]=e[11]=e[13]=e[15]=r*this._topHeight,e[4]=e[12]=e[20]=e[28]=1-t*this._rightWidth,e[17]=e[19]=e[21]=e[23]=1-r*this._bottomHeight,this.getBuffer("aUV").update()}};ct.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let Jt=ct;class ht{constructor(e){this._gpuSpriteHash=Object.create(null),this._renderer=e}addRenderable(e,t){const r=this._getGpuSprite(e);e._didSpriteUpdate&&this._updateBatchableSprite(e,r),this._renderer.renderPipes.batch.addToBatch(r)}updateRenderable(e){const t=this._gpuSpriteHash[e.uid];e._didSpriteUpdate&&this._updateBatchableSprite(e,t),t.batcher.updateElement(t)}validateRenderable(e){const t=e._texture,r=this._getGpuSprite(e);return r.texture._source!==t._source?!r.batcher.checkAndUpdateTexture(r,t):!1}destroyRenderable(e){const t=this._gpuSpriteHash[e.uid];B.return(t),this._gpuSpriteHash[e.uid]=null}_updateBatchableSprite(e,t){e._didSpriteUpdate=!1,t.geometry.update(e),t.texture=e._texture}_getGpuSprite(e){return this._gpuSpriteHash[e.uid]||this._initGPUSprite(e)}_initGPUSprite(e){const t=new de;return t.geometry=new Jt,t.mesh=e,t.texture=e._texture,t.roundPixels=this._renderer._roundPixels|e._roundPixels,this._gpuSpriteHash[e.uid]=t,e.on("destroyed",()=>{this.destroyRenderable(e)}),t}destroy(){for(const e in this._gpuSpriteHash)this._gpuSpriteHash[e].geometry.destroy();this._gpuSpriteHash=null,this._renderer=null}}ht.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"nineSliceSprite"};const er={name:"tiling-bit",vertex:{header:`
|
|
struct TilingUniforms {
|
|
uMapCoord:mat3x3<f32>,
|
|
uClampFrame:vec4<f32>,
|
|
uClampOffset:vec2<f32>,
|
|
uTextureTransform:mat3x3<f32>,
|
|
uSizeAnchor:vec4<f32>
|
|
};
|
|
|
|
@group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
|
|
@group(2) @binding(1) var uTexture: texture_2d<f32>;
|
|
@group(2) @binding(2) var uSampler: sampler;
|
|
`,main:`
|
|
uv = (tilingUniforms.uTextureTransform * vec3(uv, 1.0)).xy;
|
|
|
|
position = (position - tilingUniforms.uSizeAnchor.zw) * tilingUniforms.uSizeAnchor.xy;
|
|
`},fragment:{header:`
|
|
struct TilingUniforms {
|
|
uMapCoord:mat3x3<f32>,
|
|
uClampFrame:vec4<f32>,
|
|
uClampOffset:vec2<f32>,
|
|
uTextureTransform:mat3x3<f32>,
|
|
uSizeAnchor:vec4<f32>
|
|
};
|
|
|
|
@group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
|
|
@group(2) @binding(1) var uTexture: texture_2d<f32>;
|
|
@group(2) @binding(2) var uSampler: sampler;
|
|
`,main:`
|
|
|
|
var coord = vUV + ceil(tilingUniforms.uClampOffset - vUV);
|
|
coord = (tilingUniforms.uMapCoord * vec3(coord, 1.0)).xy;
|
|
var unclamped = coord;
|
|
coord = clamp(coord, tilingUniforms.uClampFrame.xy, tilingUniforms.uClampFrame.zw);
|
|
|
|
var bias = 0.;
|
|
|
|
if(unclamped.x == coord.x && unclamped.y == coord.y)
|
|
{
|
|
bias = -32.;
|
|
}
|
|
|
|
outColor = textureSampleBias(uTexture, uSampler, coord, bias);
|
|
`}},tr={name:"tiling-bit",vertex:{header:`
|
|
uniform mat3 uTextureTransform;
|
|
uniform vec4 uSizeAnchor;
|
|
|
|
`,main:`
|
|
uv = (uTextureTransform * vec3(aUV, 1.0)).xy;
|
|
|
|
position = (position - uSizeAnchor.zw) * uSizeAnchor.xy;
|
|
`},fragment:{header:`
|
|
uniform sampler2D uTexture;
|
|
uniform mat3 uMapCoord;
|
|
uniform vec4 uClampFrame;
|
|
uniform vec2 uClampOffset;
|
|
`,main:`
|
|
|
|
vec2 coord = vUV + ceil(uClampOffset - vUV);
|
|
coord = (uMapCoord * vec3(coord, 1.0)).xy;
|
|
vec2 unclamped = coord;
|
|
coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
|
|
|
|
outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0
|
|
|
|
`}};let te,re;class rr extends He{constructor(){te??(te=Ge({name:"tiling-sprite-shader",bits:[Rt,er,Oe]})),re??(re=Le({name:"tiling-sprite-shader",bits:[At,tr,De]}));const e=new V({uMapCoord:{value:new I,type:"mat3x3<f32>"},uClampFrame:{value:new Float32Array([0,0,1,1]),type:"vec4<f32>"},uClampOffset:{value:new Float32Array([0,0]),type:"vec2<f32>"},uTextureTransform:{value:new I,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:re,gpuProgram:te,resources:{localUniforms:new V({uTransformMatrix:{value:new I,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),tilingUniforms:e,uTexture:W.EMPTY.source,uSampler:W.EMPTY.source.style}})}updateUniforms(e,t,r,i,n,a){const o=this.resources.tilingUniforms,c=a.width,h=a.height,l=a.textureMatrix,d=o.uniforms.uTextureTransform;d.set(r.a*c/e,r.b*c/t,r.c*h/e,r.d*h/t,r.tx/e,r.ty/t),d.invert(),o.uniforms.uMapCoord=l.mapCoord,o.uniforms.uClampFrame=l.uClampFrame,o.uniforms.uClampOffset=l.uClampOffset,o.uniforms.uTextureTransform=d,o.uniforms.uSizeAnchor[0]=e,o.uniforms.uSizeAnchor[1]=t,o.uniforms.uSizeAnchor[2]=i,o.uniforms.uSizeAnchor[3]=n,a&&(this.resources.uTexture=a.source,this.resources.uSampler=a.source.style)}}class ir extends ce{constructor(){super({positions:new Float32Array([0,0,1,0,1,1,0,1]),uvs:new Float32Array([0,0,1,0,1,1,0,1]),indices:new Uint32Array([0,1,2,0,2,3])})}}function sr(s,e){const t=s.anchor.x,r=s.anchor.y;e[0]=-t*s.width,e[1]=-r*s.height,e[2]=(1-t)*s.width,e[3]=-r*s.height,e[4]=(1-t)*s.width,e[5]=(1-r)*s.height,e[6]=-t*s.width,e[7]=(1-r)*s.height}function nr(s,e,t,r){let i=0;const n=s.length/e,a=r.a,o=r.b,c=r.c,h=r.d,l=r.tx,d=r.ty;for(t*=e;i<n;){const f=s[t],u=s[t+1];s[t]=a*f+c*u+l,s[t+1]=o*f+h*u+d,t+=e,i++}}function ar(s,e){const t=s.texture,r=t.frame.width,i=t.frame.height;let n=0,a=0;s._applyAnchorToTexture&&(n=s.anchor.x,a=s.anchor.y),e[0]=e[6]=-n,e[2]=e[4]=1-n,e[1]=e[3]=-a,e[5]=e[7]=1-a;const o=I.shared;o.copyFrom(s._tileTransform.matrix),o.tx/=s.width,o.ty/=s.height,o.invert(),o.scale(s.width/r,s.height/i),nr(e,2,0,o)}const Y=new ir;class dt{constructor(e){this._tilingSpriteDataHash=Object.create(null),this._renderer=e}validateRenderable(e){const t=this._getTilingSpriteData(e),r=t.canBatch;this._updateCanBatch(e);const i=t.canBatch;if(i&&i===r){const{batchableMesh:n}=t;if(n.texture._source!==e.texture._source)return!n.batcher.checkAndUpdateTexture(n,e.texture)}return r!==i}addRenderable(e,t){const r=this._renderer.renderPipes.batch;this._updateCanBatch(e);const i=this._getTilingSpriteData(e),{geometry:n,canBatch:a}=i;if(a){i.batchableMesh||(i.batchableMesh=new de);const o=i.batchableMesh;e._didTilingSpriteUpdate&&(e._didTilingSpriteUpdate=!1,this._updateBatchableMesh(e),o.geometry=n,o.mesh=e,o.texture=e._texture),o.roundPixels=this._renderer._roundPixels|e._roundPixels,r.addToBatch(o)}else r.break(t),i.shader||(i.shader=new rr),this.updateRenderable(e),t.add(e)}execute(e){const{shader:t}=this._tilingSpriteDataHash[e.uid];t.groups[0]=this._renderer.globalUniforms.bindGroup;const r=t.resources.localUniforms.uniforms;r.uTransformMatrix=e.groupTransform,r.uRound=this._renderer._roundPixels|e._roundPixels,oe(e.groupColorAlpha,r.uColor,0),this._renderer.encoder.draw({geometry:Y,shader:t,state:Ie.default2d})}updateRenderable(e){const t=this._getTilingSpriteData(e),{canBatch:r}=t;if(r){const{batchableMesh:i}=t;e._didTilingSpriteUpdate&&this._updateBatchableMesh(e),i.batcher.updateElement(i)}else if(e._didTilingSpriteUpdate){const{shader:i}=t;i.updateUniforms(e.width,e.height,e._tileTransform.matrix,e.anchor.x,e.anchor.y,e.texture)}e._didTilingSpriteUpdate=!1}destroyRenderable(e){const t=this._getTilingSpriteData(e);t.batchableMesh=null,t.shader?.destroy(),this._tilingSpriteDataHash[e.uid]=null}_getTilingSpriteData(e){return this._tilingSpriteDataHash[e.uid]||this._initTilingSpriteData(e)}_initTilingSpriteData(e){const t=new ce({indices:Y.indices,positions:Y.positions.slice(),uvs:Y.uvs.slice()});return this._tilingSpriteDataHash[e.uid]={canBatch:!0,renderable:e,geometry:t},e.on("destroyed",()=>{this.destroyRenderable(e)}),this._tilingSpriteDataHash[e.uid]}_updateBatchableMesh(e){const t=this._getTilingSpriteData(e),{geometry:r}=t,i=e.texture.source.style;i.addressMode!=="repeat"&&(i.addressMode="repeat",i.update()),ar(e,r.uvs),sr(e,r.positions)}destroy(){for(const e in this._tilingSpriteDataHash)this.destroyRenderable(this._tilingSpriteDataHash[e].renderable);this._tilingSpriteDataHash=null,this._renderer=null}_updateCanBatch(e){const t=this._getTilingSpriteData(e),r=e.texture;let i=!0;return this._renderer.type===ae.WEBGL&&(i=this._renderer.context.supports.nonPowOf2wrapping),t.canBatch=r.textureMatrix.isSimple&&(i||r.source.isPowerOfTwo),t.canBatch}}dt.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"tilingSprite"};const ie={test(s){return typeof s=="string"&&s.startsWith("info face=")},parse(s){const e=s.match(/^[a-z]+\s+.+$/gm),t={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const d in e){const f=e[d].match(/^[a-z]+/gm)[0],u=e[d].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),p={};for(const x in u){const m=u[x].split("="),_=m[0],w=m[1].replace(/"/gm,""),b=parseFloat(w),y=isNaN(b)?w:b;p[_]=y}t[f].push(p)}const r={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[i]=t.info,[n]=t.common,[a]=t.distanceField??[];a&&(r.distanceField={range:parseInt(a.distanceRange,10),type:a.fieldType}),r.fontSize=parseInt(i.size,10),r.fontFamily=i.face,r.lineHeight=parseInt(n.lineHeight,10);const o=t.page;for(let d=0;d<o.length;d++)r.pages.push({id:parseInt(o[d].id,10)||0,file:o[d].file});const c={};r.baseLineOffset=r.lineHeight-parseInt(n.base,10);const h=t.char;for(let d=0;d<h.length;d++){const f=h[d],u=parseInt(f.id,10);let p=f.letter??f.char??String.fromCharCode(u);p==="space"&&(p=" "),c[u]=p,r.chars[p]={id:u,page:parseInt(f.page,10)||0,x:parseInt(f.x,10),y:parseInt(f.y,10),width:parseInt(f.width,10),height:parseInt(f.height,10),xOffset:parseInt(f.xoffset,10),yOffset:parseInt(f.yoffset,10),xAdvance:parseInt(f.xadvance,10),kerning:{}}}const l=t.kerning||[];for(let d=0;d<l.length;d++){const f=parseInt(l[d].first,10),u=parseInt(l[d].second,10),p=parseInt(l[d].amount,10);r.chars[c[u]].kerning[c[f]]=p}return r}},Ce={test(s){const e=s;return typeof e!="string"&&"getElementsByTagName"in e&&e.getElementsByTagName("page").length&&e.getElementsByTagName("info")[0].getAttribute("face")!==null},parse(s){const e={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},t=s.getElementsByTagName("info")[0],r=s.getElementsByTagName("common")[0],i=s.getElementsByTagName("distanceField")[0];i&&(e.distanceField={type:i.getAttribute("fieldType"),range:parseInt(i.getAttribute("distanceRange"),10)});const n=s.getElementsByTagName("page"),a=s.getElementsByTagName("char"),o=s.getElementsByTagName("kerning");e.fontSize=parseInt(t.getAttribute("size"),10),e.fontFamily=t.getAttribute("face"),e.lineHeight=parseInt(r.getAttribute("lineHeight"),10);for(let h=0;h<n.length;h++)e.pages.push({id:parseInt(n[h].getAttribute("id"),10)||0,file:n[h].getAttribute("file")});const c={};e.baseLineOffset=e.lineHeight-parseInt(r.getAttribute("base"),10);for(let h=0;h<a.length;h++){const l=a[h],d=parseInt(l.getAttribute("id"),10);let f=l.getAttribute("letter")??l.getAttribute("char")??String.fromCharCode(d);f==="space"&&(f=" "),c[d]=f,e.chars[f]={id:d,page:parseInt(l.getAttribute("page"),10)||0,x:parseInt(l.getAttribute("x"),10),y:parseInt(l.getAttribute("y"),10),width:parseInt(l.getAttribute("width"),10),height:parseInt(l.getAttribute("height"),10),xOffset:parseInt(l.getAttribute("xoffset"),10),yOffset:parseInt(l.getAttribute("yoffset"),10),xAdvance:parseInt(l.getAttribute("xadvance"),10),kerning:{}}}for(let h=0;h<o.length;h++){const l=parseInt(o[h].getAttribute("first"),10),d=parseInt(o[h].getAttribute("second"),10),f=parseInt(o[h].getAttribute("amount"),10);e.chars[c[d]].kerning[c[l]]=f}return e}},Be={test(s){return typeof s=="string"&&s.includes("<font>")?Ce.test(L.get().parseXML(s)):!1},parse(s){return Ce.parse(L.get().parseXML(s))}};class ut extends Ze{constructor(e,t){super();const{textures:r,data:i}=e;Object.keys(i.pages).forEach(n=>{const a=i.pages[parseInt(n,10)],o=r[a.id];this.pages.push({texture:o})}),Object.keys(i.chars).forEach(n=>{const a=i.chars[n],{frame:o,source:c}=r[a.page],h=new X(a.x+o.x,a.y+o.y,a.width,a.height),l=new W({source:c,frame:h});this.chars[n]={id:n.codePointAt(0),xOffset:a.xOffset,yOffset:a.yOffset,xAdvance:a.xAdvance,kerning:a.kerning??{},texture:l}}),this.baseRenderedFontSize=i.fontSize,this.baseMeasurementFontSize=i.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:i.fontSize},this.baseLineOffset=i.baseLineOffset,this.lineHeight=i.lineHeight,this.fontFamily=i.fontFamily,this.distanceField=i.distanceField??{type:"none",range:0},this.url=t}destroy(){super.destroy();for(let e=0;e<this.pages.length;e++){const{texture:t}=this.pages[e];t.destroy(!0)}this.pages=null}static install(e){ne.install(e)}static uninstall(e){ne.uninstall(e)}}const or=[".xml",".fnt"],cr={extension:S.CacheParser,test:s=>s instanceof ut,getCacheableAssets(s,e){const t={};return s.forEach(r=>{t[r]=e}),t[`${e.fontFamily}-bitmap`]=e,t}},lr={extension:{type:S.LoadParser,priority:Bt.Normal},test(s){return or.includes(J.extname(s).toLowerCase())},async testParse(s){return ie.test(s)||Be.test(s)},async parse(s,e,t){const r=ie.test(s)?ie.parse(s):Be.parse(s),{src:i}=e,{pages:n}=r,a=[];for(let l=0;l<n.length;++l){const d=n[l].file;let f=J.join(J.dirname(i),d);f=Ft(f,i),a.push(f)}const o=await t.load(a),c=a.map(l=>o[l]);return new ut({data:r,textures:c},i)},async load(s,e){return await (await L.get().fetch(s)).text()},async unload(s,e,t){await Promise.all(s.pages.map(r=>t.unload(r.texture.source._sourceOrigin))),s.destroy()}},hr={name:"local-uniform-msdf-bit",vertex:{header:`
|
|
struct LocalUniforms {
|
|
uColor:vec4<f32>,
|
|
uTransformMatrix:mat3x3<f32>,
|
|
uDistance: f32,
|
|
uRound:f32,
|
|
}
|
|
|
|
@group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;
|
|
`,main:`
|
|
vColor *= localUniforms.uColor;
|
|
modelMatrix *= localUniforms.uTransformMatrix;
|
|
`,end:`
|
|
if(localUniforms.uRound == 1)
|
|
{
|
|
vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
|
|
}
|
|
`},fragment:{header:`
|
|
struct LocalUniforms {
|
|
uColor:vec4<f32>,
|
|
uTransformMatrix:mat3x3<f32>,
|
|
uDistance: f32
|
|
}
|
|
|
|
@group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;
|
|
`,main:`
|
|
outColor = vColor * calculateMSDFAlpha(outColor, localUniforms.uDistance);
|
|
`}},dr={name:"local-uniform-msdf-bit",vertex:{header:`
|
|
uniform mat3 uTransformMatrix;
|
|
uniform vec4 uColor;
|
|
uniform float uRound;
|
|
`,main:`
|
|
vColor *= uColor;
|
|
modelMatrix *= uTransformMatrix;
|
|
`,end:`
|
|
if(uRound == 1.)
|
|
{
|
|
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
|
|
}
|
|
`},fragment:{header:`
|
|
uniform float uDistance;
|
|
`,main:`
|
|
outColor = vColor * calculateMSDFAlpha(outColor, uDistance);
|
|
`}},ur={name:"msdf-bit",fragment:{header:`
|
|
fn calculateMSDFAlpha(msdfColor:vec4<f32>, distance:f32) -> f32 {
|
|
|
|
// MSDF
|
|
var median = msdfColor.r + msdfColor.g + msdfColor.b -
|
|
min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
|
|
max(msdfColor.r, max(msdfColor.g, msdfColor.b));
|
|
|
|
// SDF
|
|
median = min(median, msdfColor.a);
|
|
|
|
var screenPxDistance = distance * (median - 0.5);
|
|
var alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
|
|
if (median < 0.01) {
|
|
alpha = 0.0;
|
|
} else if (median > 0.99) {
|
|
alpha = 1.0;
|
|
}
|
|
|
|
return alpha;
|
|
}
|
|
`}},fr={name:"msdf-bit",fragment:{header:`
|
|
float calculateMSDFAlpha(vec4 msdfColor, float distance) {
|
|
|
|
// MSDF
|
|
float median = msdfColor.r + msdfColor.g + msdfColor.b -
|
|
min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
|
|
max(msdfColor.r, max(msdfColor.g, msdfColor.b));
|
|
|
|
// SDF
|
|
median = min(median, msdfColor.a);
|
|
|
|
float screenPxDistance = distance * (median - 0.5);
|
|
float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
|
|
|
|
if (median < 0.01) {
|
|
alpha = 0.0;
|
|
} else if (median > 0.99) {
|
|
alpha = 1.0;
|
|
}
|
|
|
|
return alpha;
|
|
}
|
|
`}};class pr extends He{constructor(){const e=new V({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new I,type:"mat3x3<f32>"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}}),t=Pt(),r=Ge({name:"sdf-shader",bits:[Wt,Ut(t),hr,ur,Oe]}),i=Le({name:"sdf-shader",bits:[zt,It(t),dr,fr,De]});super({glProgram:i,gpuProgram:r,resources:{localUniforms:e,batchSamplers:Ht(t)}})}}class ft{constructor(e){this._gpuBitmapText={},this._renderer=e}validateRenderable(e){const t=this._getGpuBitmapText(e);return e._didTextUpdate&&(e._didTextUpdate=!1,this._updateContext(e,t)),this._renderer.renderPipes.graphics.validateRenderable(t)}addRenderable(e,t){const r=this._getGpuBitmapText(e);Fe(e,r),e._didTextUpdate&&(e._didTextUpdate=!1,this._updateContext(e,r)),this._renderer.renderPipes.graphics.addRenderable(r,t),r.context.customShader&&this._updateDistanceField(e)}destroyRenderable(e){this._destroyRenderableByUid(e.uid)}_destroyRenderableByUid(e){B.return(this._gpuBitmapText[e]),this._gpuBitmapText[e]=null}updateRenderable(e){const t=this._getGpuBitmapText(e);Fe(e,t),this._renderer.renderPipes.graphics.updateRenderable(t),t.context.customShader&&this._updateDistanceField(e)}_updateContext(e,t){const{context:r}=t,i=ne.getFont(e.text,e._style);r.clear(),i.distanceField.type!=="none"&&(r.customShader||(this._sdfShader||(this._sdfShader=new pr),r.customShader=this._sdfShader));const n=Array.from(e.text),a=e._style;let o=(a._stroke?.width||0)/2;o+=i.baseLineOffset;const c=et(n,a,i);let h=0;const l=a.padding,d=c.scale;r.translate(-e._anchor._x*c.width-l,-e._anchor._y*(c.height+c.offsetY)-l).scale(d,d);const f=a._fill.color;for(let u=0;u<c.lines.length;u++){const p=c.lines[u];for(let x=0;x<p.charPositions.length;x++){const m=n[h++],_=i.chars[m];_?.texture&&r.texture(_.texture,f||"black",Math.round(p.charPositions[x]+_.xOffset),Math.round(o+_.yOffset))}o+=i.lineHeight}}_getGpuBitmapText(e){return this._gpuBitmapText[e.uid]||this.initGpuText(e)}initGpuText(e){const t=B.get(kt);return this._gpuBitmapText[e.uid]=t,this._updateContext(e,t),e.on("destroyed",()=>{this.destroyRenderable(e)}),this._gpuBitmapText[e.uid]}_updateDistanceField(e){const t=this._getGpuBitmapText(e).context,r=e._style.fontFamily,i=R.get(`${r}-bitmap`),{a:n,b:a,c:o,d:c}=e.groupTransform,h=Math.sqrt(n*n+a*a),l=Math.sqrt(o*o+c*c),d=(Math.abs(h)+Math.abs(l))/2,f=i.baseRenderedFontSize/e._style.fontSize,u=e.resolution??this._renderer.resolution,p=d*i.distanceField.range*(1/f)*u;t.customShader.resources.localUniforms.uniforms.uDistance=p}destroy(){for(const e in this._gpuBitmapText)this._destroyRenderableByUid(e);this._gpuBitmapText=null,this._sdfShader?.destroy(!0),this._sdfShader=null,this._renderer=null}}ft.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"bitmapText"};function Fe(s,e){e.groupTransform=s.groupTransform,e.groupColorAlpha=s.groupColorAlpha,e.groupColor=s.groupColor,e.groupBlendMode=s.groupBlendMode,e.globalDisplayStatus=s.globalDisplayStatus,e.groupTransform=s.groupTransform,e.localDisplayStatus=s.localDisplayStatus,e.groupAlpha=s.groupAlpha,e._roundPixels=s._roundPixels}class pt{constructor(e){this._gpuText=Object.create(null),this._renderer=e}validateRenderable(e){const t=this._getGpuText(e),r=e._getKey();return t.textureNeedsUploading?(t.textureNeedsUploading=!1,!0):t.currentKey!==r}addRenderable(e){const r=this._getGpuText(e).batchableSprite;e._didTextUpdate&&this._updateText(e),this._renderer.renderPipes.batch.addToBatch(r)}updateRenderable(e){const r=this._getGpuText(e).batchableSprite;e._didTextUpdate&&this._updateText(e),r.batcher.updateElement(r)}destroyRenderable(e){this._destroyRenderableById(e.uid)}_destroyRenderableById(e){const t=this._gpuText[e];this._renderer.htmlText.decreaseReferenceCount(t.currentKey),B.return(t.batchableSprite),this._gpuText[e]=null}_updateText(e){const t=e._getKey(),r=this._getGpuText(e),i=r.batchableSprite;r.currentKey!==t&&this._updateGpuText(e).catch(a=>{console.error(a)}),e._didTextUpdate=!1;const n=e._style.padding;se(i.bounds,e._anchor,i.texture,n)}async _updateGpuText(e){e._didTextUpdate=!1;const t=this._getGpuText(e);if(t.generatingTexture)return;const r=e._getKey();this._renderer.htmlText.decreaseReferenceCount(t.currentKey),t.generatingTexture=!0,t.currentKey=r;const i=e.resolution??this._renderer.resolution,n=await this._renderer.htmlText.getManagedTexture(e.text,i,e._style,e._getKey()),a=t.batchableSprite;a.texture=t.texture=n,t.generatingTexture=!1,t.textureNeedsUploading=!0,e.onViewUpdate();const o=e._style.padding;se(a.bounds,e._anchor,a.texture,o)}_getGpuText(e){return this._gpuText[e.uid]||this.initGpuText(e)}initGpuText(e){const t={texture:W.EMPTY,currentKey:"--",batchableSprite:B.get(Ee),textureNeedsUploading:!1,generatingTexture:!1},r=t.batchableSprite;return r.renderable=e,r.texture=W.EMPTY,r.bounds={minX:0,maxX:1,minY:0,maxY:0},r.roundPixels=this._renderer._roundPixels|e._roundPixels,this._gpuText[e.uid]=t,e.on("destroyed",()=>{this.destroyRenderable(e)}),t}destroy(){for(const e in this._gpuText)this._destroyRenderableById(e);this._gpuText=null,this._renderer=null}}pt.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"htmlText"};function gr(){const{userAgent:s}=L.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(s)}const mr=new We;function gt(s,e,t,r){const i=mr;i.minX=0,i.minY=0,i.maxX=s.width/r|0,i.maxY=s.height/r|0;const n=z.getOptimalTexture(i.width,i.height,r,!1);return n.source.uploadMethodId="image",n.source.resource=s,n.source.alphaMode="premultiply-alpha-on-upload",n.frame.width=e/r,n.frame.height=t/r,n.source.emit("update",n.source),n.updateUvs(),n}function xr(s,e){const t=e.fontFamily,r=[],i={},n=/font-family:([^;"\s]+)/g,a=s.match(n);function o(c){i[c]||(r.push(c),i[c]=!0)}if(Array.isArray(t))for(let c=0;c<t.length;c++)o(t[c]);else o(t);a&&a.forEach(c=>{const h=c.split(":")[1].trim();o(h)});for(const c in e.tagStyles){const h=e.tagStyles[c].fontFamily;o(h)}return r}async function _r(s){const t=await (await L.get().fetch(s)).blob(),r=new FileReader;return await new Promise((n,a)=>{r.onloadend=()=>n(r.result),r.onerror=a,r.readAsDataURL(t)})}async function Pe(s,e){const t=await _r(e);return`@font-face {
|
|
font-family: "${s.fontFamily}";
|
|
src: url('${t}');
|
|
font-weight: ${s.fontWeight};
|
|
font-style: ${s.fontStyle};
|
|
}`}const j=new Map;async function br(s,e,t){const r=s.filter(i=>R.has(`${i}-and-url`)).map((i,n)=>{if(!j.has(i)){const{url:a}=R.get(`${i}-and-url`);n===0?j.set(i,Pe(e,a)):j.set(i,Pe({fontWeight:t.fontWeight,fontStyle:t.fontStyle,fontFamily:i},a))}return j.get(i)});return(await Promise.all(r)).join(`
|
|
`)}function Sr(s,e,t,r,i){const{domElement:n,styleElement:a,svgRoot:o}=i;n.innerHTML=`<style>${e.cssStyle}</style><div>${s}</div>`,n.setAttribute("style",`transform: scale(${t});transform-origin: top left; display: inline-block`),a.textContent=r;const{width:c,height:h}=i.image;return o.setAttribute("width",c.toString()),o.setAttribute("height",h.toString()),new XMLSerializer().serializeToString(o)}function yr(s,e){const t=O.getOptimalCanvasAndContext(s.width,s.height,e),{context:r}=t;return r.clearRect(0,0,s.width,s.height),r.drawImage(s,0,0),O.returnCanvasAndContext(t),t.canvas}function wr(s,e,t){return new Promise(async r=>{t&&await new Promise(i=>setTimeout(i,100)),s.onload=()=>{r()},s.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(e)}`,s.crossOrigin="anonymous"})}class ue{constructor(e){this._activeTextures={},this._renderer=e,this._createCanvas=e.type===ae.WEBGPU}getTexture(e){return this._buildTexturePromise(e.text,e.resolution,e.style)}getManagedTexture(e,t,r,i){if(this._activeTextures[i])return this._increaseReferenceCount(i),this._activeTextures[i].promise;const n=this._buildTexturePromise(e,t,r).then(a=>(this._activeTextures[i].texture=a,a));return this._activeTextures[i]={texture:null,promise:n,usageCount:1},n}async _buildTexturePromise(e,t,r){const i=B.get(it),n=xr(e,r),a=await br(n,r,he.defaultTextStyle),o=Qt(e,r,a,i),c=Math.ceil(Math.ceil(Math.max(1,o.width)+r.padding*2)*t),h=Math.ceil(Math.ceil(Math.max(1,o.height)+r.padding*2)*t),l=i.image;l.width=c|0,l.height=h|0;const d=Sr(e,r,t,a,i);await wr(l,d,gr()&&n.length>0);let f=l;this._createCanvas&&(f=yr(l,t));const u=gt(f,l.width,l.height,t);return this._createCanvas&&this._renderer.texture.initSource(u.source),B.return(i),u}_increaseReferenceCount(e){this._activeTextures[e].usageCount++}decreaseReferenceCount(e){const t=this._activeTextures[e];t&&(t.usageCount--,t.usageCount===0&&(t.texture?this._cleanUp(t):t.promise.then(r=>{t.texture=r,this._cleanUp(t)}).catch(()=>{K("HTMLTextSystem: Failed to clean texture")}),this._activeTextures[e]=null))}_cleanUp(e){z.returnTexture(e.texture),e.texture.source.resource=null,e.texture.source.uploadMethodId="unknown"}getReferenceCount(e){return this._activeTextures[e].usageCount}destroy(){this._activeTextures=null}}ue.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"htmlText"};ue.defaultFontOptions={fontFamily:"Arial",fontStyle:"normal",fontWeight:"normal"};class mt{constructor(e){this._gpuText=Object.create(null),this._renderer=e}validateRenderable(e){const t=this._getGpuText(e),r=e._getKey();if(t.currentKey!==r){const i=e.resolution??this._renderer.resolution,{width:n,height:a}=this._renderer.canvasText.getTextureSize(e.text,i,e._style);return!(this._renderer.canvasText.getReferenceCount(t.currentKey)===1&&n===t.texture._source.width&&a===t.texture._source.height)}return!1}addRenderable(e,t){const i=this._getGpuText(e).batchableSprite;e._didTextUpdate&&this._updateText(e),this._renderer.renderPipes.batch.addToBatch(i)}updateRenderable(e){const r=this._getGpuText(e).batchableSprite;e._didTextUpdate&&this._updateText(e),r.batcher.updateElement(r)}destroyRenderable(e){this._destroyRenderableById(e.uid)}_destroyRenderableById(e){const t=this._gpuText[e];this._renderer.canvasText.decreaseReferenceCount(t.currentKey),B.return(t.batchableSprite),this._gpuText[e]=null}_updateText(e){const t=e._getKey(),r=this._getGpuText(e),i=r.batchableSprite;r.currentKey!==t&&this._updateGpuText(e),e._didTextUpdate=!1;const n=e._style.padding;se(i.bounds,e._anchor,i.texture,n)}_updateGpuText(e){const t=this._getGpuText(e),r=t.batchableSprite;t.texture&&this._renderer.canvasText.decreaseReferenceCount(t.currentKey),t.texture=r.texture=this._renderer.canvasText.getManagedTexture(e),t.currentKey=e._getKey(),r.texture=t.texture}_getGpuText(e){return this._gpuText[e.uid]||this.initGpuText(e)}initGpuText(e){const t={texture:null,currentKey:"--",batchableSprite:B.get(Ee)};return t.batchableSprite.renderable=e,t.batchableSprite.bounds={minX:0,maxX:1,minY:0,maxY:0},t.batchableSprite.roundPixels=this._renderer._roundPixels|e._roundPixels,this._gpuText[e.uid]=t,this._updateText(e),e.on("destroyed",()=>{this.destroyRenderable(e)}),t}destroy(){for(const e in this._gpuText)this._destroyRenderableById(e);this._gpuText=null,this._renderer=null}}mt.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"text"};function ke(s,e,t){for(let r=0,i=4*t*e;r<e;++r,i+=4)if(s[i+3]!==0)return!1;return!0}function Me(s,e,t,r,i){const n=4*e;for(let a=r,o=r*n+4*t;a<=i;++a,o+=n)if(s[o+3]!==0)return!1;return!0}function Tr(s,e=1){const{width:t,height:r}=s,i=s.getContext("2d",{willReadFrequently:!0});if(i===null)throw new TypeError("Failed to get canvas 2D context");const a=i.getImageData(0,0,t,r).data;let o=0,c=0,h=t-1,l=r-1;for(;c<r&&ke(a,t,c);)++c;if(c===r)return X.EMPTY;for(;ke(a,t,l);)--l;for(;Me(a,t,o,c,l);)++o;for(;Me(a,t,h,c,l);)--h;return++h,++l,new X(o/e,c/e,(h-o)/e,(l-c)/e)}class xt{constructor(e){this._activeTextures={},this._renderer=e}getTextureSize(e,t,r){const i=G.measureText(e||" ",r);let n=Math.ceil(Math.ceil(Math.max(1,i.width)+r.padding*2)*t),a=Math.ceil(Math.ceil(Math.max(1,i.height)+r.padding*2)*t);return n=Math.ceil(n-1e-6),a=Math.ceil(a-1e-6),n=xe(n),a=xe(a),{width:n,height:a}}getTexture(e,t,r,i){typeof e=="string"&&(M("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),e={text:e,style:r,resolution:t}),e.style instanceof $||(e.style=new $(e.style));const{texture:n,canvasAndContext:a}=this.createTextureAndCanvas(e);return this._renderer.texture.initSource(n._source),O.returnCanvasAndContext(a),n}createTextureAndCanvas(e){const{text:t,style:r}=e,i=e.resolution??this._renderer.resolution,n=G.measureText(t||" ",r),a=Math.ceil(Math.ceil(Math.max(1,n.width)+r.padding*2)*i),o=Math.ceil(Math.ceil(Math.max(1,n.height)+r.padding*2)*i),c=O.getOptimalCanvasAndContext(a,o),{canvas:h}=c;this.renderTextToCanvas(t,r,i,c);const l=gt(h,a,o,i);if(r.trim){const d=Tr(h,i);l.frame.copyFrom(d),l.updateUvs()}return{texture:l,canvasAndContext:c}}getManagedTexture(e){const t=e._getKey();if(this._activeTextures[t])return this._increaseReferenceCount(t),this._activeTextures[t].texture;const{texture:r,canvasAndContext:i}=this.createTextureAndCanvas(e);return this._activeTextures[t]={canvasAndContext:i,texture:r,usageCount:1},r}_increaseReferenceCount(e){this._activeTextures[e].usageCount++}decreaseReferenceCount(e){const t=this._activeTextures[e];if(t.usageCount--,t.usageCount===0){O.returnCanvasAndContext(t.canvasAndContext),z.returnTexture(t.texture);const r=t.texture.source;r.resource=null,r.uploadMethodId="unknown",r.alphaMode="no-premultiply-alpha",this._activeTextures[e]=null}}getReferenceCount(e){return this._activeTextures[e].usageCount}renderTextToCanvas(e,t,r,i){const{canvas:n,context:a}=i,o=N(t),c=G.measureText(e||" ",t),h=c.lines,l=c.lineHeight,d=c.lineWidths,f=c.maxLineWidth,u=c.fontProperties,p=n.height;a.resetTransform(),a.scale(r,r);const x=t.padding*2;if(a.clearRect(0,0,c.width+4+x,c.height+4+x),t._stroke?.width){const b=t._stroke;a.lineWidth=b.width,a.miterLimit=b.miterLimit,a.lineJoin=b.join,a.lineCap=b.cap}a.font=o;let m,_;const w=t.dropShadow?2:1;for(let b=0;b<w;++b){const y=t.dropShadow&&b===0,T=y?Math.ceil(Math.max(1,p)+t.padding*2):0,P=T*r;if(y){a.fillStyle="black",a.strokeStyle="black";const C=t.dropShadow,_t=C.color,bt=C.alpha;a.shadowColor=H.shared.setValue(_t).setAlpha(bt).toRgbaString();const St=C.blur*r,fe=C.distance*r;a.shadowBlur=St,a.shadowOffsetX=Math.cos(C.angle)*fe,a.shadowOffsetY=Math.sin(C.angle)*fe+P}else a.globalAlpha=t._fill?.alpha??1,a.fillStyle=t._fill?q(t._fill,a):null,t._stroke?.width&&(a.strokeStyle=q(t._stroke,a)),a.shadowColor="black";let v=(l-u.fontSize)/2;l-u.fontSize<0&&(v=0);const k=t._stroke?.width??0;for(let C=0;C<h.length;C++)m=k/2,_=k/2+C*l+u.ascent+v,t.align==="right"?m+=f-d[C]:t.align==="center"&&(m+=(f-d[C])/2),t._stroke?.width&&this._drawLetterSpacing(h[C],t,i,m+t.padding,_+t.padding-T,!0),t._fill!==void 0&&this._drawLetterSpacing(h[C],t,i,m+t.padding,_+t.padding-T)}}_drawLetterSpacing(e,t,r,i,n,a=!1){const{context:o}=r,c=t.letterSpacing;let h=!1;if(G.experimentalLetterSpacingSupported&&(G.experimentalLetterSpacing?(o.letterSpacing=`${c}px`,o.textLetterSpacing=`${c}px`,h=!0):(o.letterSpacing="0px",o.textLetterSpacing="0px")),c===0||h){a?o.strokeText(e,i,n):o.fillText(e,i,n);return}let l=i;const d=G.graphemeSegmenter(e);let f=o.measureText(e).width,u=0;for(let p=0;p<d.length;++p){const x=d[p];a?o.strokeText(x,l,n):o.fillText(x,l,n);let m="";for(let _=p+1;_<d.length;++_)m+=d[_];u=o.measureText(m).width,l+=f-u+c,f=u}}destroy(){this._activeTextures=null}}xt.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"canvasText"};F.add($e);F.add(Ke);F.add(st);F.add(Mt);F.add(ot);F.add(xt);F.add(mt);F.add(ft,lr,cr);F.add(ue);F.add(pt);F.add(dt);F.add(ht);F.add(je);F.add(Ve)});export{__tla}; |