three-text 0.2.17 → 0.2.19
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/README.md +8 -8
- package/dist/index.cjs +133 -105
- package/dist/index.d.ts +48 -43
- package/dist/index.js +133 -105
- package/dist/index.min.cjs +259 -251
- package/dist/index.min.js +319 -311
- package/dist/index.umd.js +133 -105
- package/dist/index.umd.min.js +295 -287
- package/dist/three/index.cjs +1 -0
- package/dist/three/index.d.ts +13 -1
- package/dist/three/index.js +1 -0
- package/dist/three/react.cjs +2 -1
- package/dist/three/react.d.ts +18 -12
- package/dist/three/react.js +2 -1
- package/dist/types/core/Text.d.ts +0 -1
- package/dist/types/core/geometry/Extruder.d.ts +1 -0
- package/dist/types/core/types.d.ts +10 -3
- package/dist/types/three/index.d.ts +6 -1
- package/dist/types/three/react.d.ts +1 -0
- package/package.json +14 -3
package/dist/index.min.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* three-text v0.2.
|
|
2
|
+
* three-text v0.2.19
|
|
3
3
|
* Copyright (C) 2025 Countertype LLC
|
|
4
4
|
*
|
|
5
5
|
* This program is free software: you can redistribute it and/or modify
|
|
@@ -469,14 +469,14 @@ r=u.d,(u=u.b).d=r,r.b=u}return this.r(this.b),void(this.c=this.b=null)}}this.b=t
|
|
|
469
469
|
var Y=J.exports
|
|
470
470
|
class K{process(t,e=!0,i=!1,s=!0){if(0===t.length)return{Yi:{vertices:[],indices:[]},Ki:[]}
|
|
471
471
|
const n=t.filter(t=>t.points.length>=3)
|
|
472
|
-
return 0===n.length?{Yi:{vertices:[],indices:[]},Ki:[]}:this.Xi(n,e,i,s)}Xi(t,e,i,s){
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
472
|
+
return 0===n.length?{Yi:{vertices:[],indices:[]},Ki:[]}:this.Xi(n,e,i,s)}Xi(t,e,i,s){const n=!i&&!e
|
|
473
|
+
let r,o
|
|
474
|
+
n?(o=this.Qi(t,!0),(e||s)&&(r=this.Qi(t))):(r=this.Qi(t),o=r)
|
|
475
|
+
let h=s?n?o:r??this.Qi(t):[]
|
|
476
|
+
if(e){const t=this.Zi(r,"boundary")
|
|
476
477
|
if(!t)return l.warn("libtess returned empty result from boundary pass"),{Yi:{vertices:[],indices:[]},Ki:[]}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
return h?{Yi:{vertices:h.vertices,indices:h.indices||[]},Ki:o}:(l.warn(e?"libtess returned empty result from triangulation pass":"libtess returned empty result from single-pass triangulation"),{Yi:{vertices:[],indices:[]},Ki:o})}Qi(t,e=!1){const i=Array(t.length)
|
|
478
|
+
o=this.ts(t),s&&(h=o)}const a=this.Zi(o,"triangles")
|
|
479
|
+
return a?{Yi:{vertices:a.vertices,indices:a.indices||[]},Ki:h}:(l.warn(e?"libtess returned empty result from triangulation pass":"libtess returned empty result from single-pass triangulation"),{Yi:{vertices:[],indices:[]},Ki:h})}Qi(t,e=!1){const i=Array(t.length)
|
|
480
480
|
for(let s=0;t.length>s;s++){const n=t[s].points,r=n.length,o=r>1&&n[0].x===n[r-1].x&&n[0].y===n[r-1].y?r-1:r,h=Array(2*(o+1))
|
|
481
481
|
let a=0
|
|
482
482
|
if(e)for(let t=o-1;t>=0;t--){const e=n[t]
|
|
@@ -489,11 +489,11 @@ let o=[]
|
|
|
489
489
|
return s.push(t[0],t[1]),e}),i.zi(Y.Ni.GLU_TESS_ERROR,t=>{l.warn("libtess error: "+t)}),i.ji(0,0,1),i.Hi(null)
|
|
490
490
|
for(const e of t){i.Vi()
|
|
491
491
|
for(let t=0;e.length>t;t+=2){const n=s.length/2
|
|
492
|
-
s.push(e[t],e[t+1]),i.Wi([e[t],e[t+1],0],n)}i.qi()}return i.Ji(),0===s.length?null:"triangles"===e?{vertices:s,indices:n}:{vertices:s,
|
|
492
|
+
s.push(e[t],e[t+1]),i.Wi([e[t],e[t+1],0],n)}i.qi()}return i.Ji(),0===s.length?null:"triangles"===e?{vertices:s,indices:n}:{vertices:s,es:r}}ts(t){if(!t.es)return[]
|
|
493
493
|
const e=[]
|
|
494
|
-
for(const i of t.
|
|
494
|
+
for(const i of t.es){const s=[]
|
|
495
495
|
for(const e of i){const i=2*e
|
|
496
|
-
s.push(t.vertices[i],t.vertices[i+1])}s.length>2&&(s[0]===s[s.length-2]&&s[1]===s[s.length-1]||s.push(s[0],s[1])),e.push(s)}return e}
|
|
496
|
+
s.push(t.vertices[i],t.vertices[i+1])}s.length>2&&(s[0]===s[s.length-2]&&s[1]===s[s.length-1]||s.push(s[0],s[1])),e.push(s)}return e}ss(t){if(0===t.length)return!1
|
|
497
497
|
if(1===t.length)return!1
|
|
498
498
|
let e=null
|
|
499
499
|
for(const i of t){const t=0>this.ns(i)?-1:1
|
|
@@ -502,210 +502,218 @@ else if(t!==e)return!0}return!1}ns(t){let e=0
|
|
|
502
502
|
const i=t.length
|
|
503
503
|
if(6>i)return 0
|
|
504
504
|
for(let s=0;i>s;s+=2)e+=t[s]*t[(s+3)%i]-t[(s+2)%i]*t[s+1]
|
|
505
|
-
return e/2}}class X{constructor(){}rs(t,e=0,i){const s=t.Yi.vertices,n=t.Yi.indices,r=s.length/2
|
|
506
|
-
let o=
|
|
507
|
-
if(0!==e)
|
|
508
|
-
|
|
505
|
+
return e/2}}class X{constructor(){}rs(t,e){return 4294967296*(e>t?t:e)+(e>t?e:t)}hs(t,e=0,i){const s=t.Yi.vertices,n=t.Yi.indices,r=s.length/2
|
|
506
|
+
let o=[]
|
|
507
|
+
if(0!==e){const t=new Map,e=new Map
|
|
508
|
+
for(let i=0;n.length>i;i+=3){const s=n[i],r=n[i+1],o=n[i+2],h=this.rs(s,r),a=(t.get(h)??0)+1
|
|
509
|
+
t.set(h,a),1===a&&e.set(h,[s,r])
|
|
510
|
+
const c=this.rs(r,o),l=(t.get(c)??0)+1
|
|
511
|
+
t.set(c,l),1===l&&e.set(c,[r,o])
|
|
512
|
+
const u=this.rs(o,s),f=(t.get(u)??0)+1
|
|
513
|
+
t.set(u,f),1===f&&e.set(u,[o,s])}o=[]
|
|
514
|
+
for(const[i,s]of t){if(1!==s)continue
|
|
515
|
+
const t=e.get(i)
|
|
516
|
+
t&&o.push(t)}}const h=0===e?0:o.length,a=(0===e?r:2*r)+(0===e?0:4*h),c=new Float32Array(3*a),l=new Float32Array(3*a),u=new Uint32Array(0===e?n.length:2*n.length+6*h)
|
|
509
517
|
if(0===e){let t=0
|
|
510
|
-
for(let e=0;s.length>e;e+=2)
|
|
511
|
-
for(let t=0;n.length>t;t++)
|
|
512
|
-
return{vertices:
|
|
518
|
+
for(let e=0;s.length>e;e+=2)c[t]=s[e],c[t+1]=s[e+1],c[t+2]=0,l[t]=0,l[t+1]=0,l[t+2]=1,t+=3
|
|
519
|
+
for(let t=0;n.length>t;t++)u[t]=n[t]
|
|
520
|
+
return{vertices:c,normals:l,indices:u}}const f=25e-6*i,d=e>f?e:f
|
|
513
521
|
for(let t=0,e=0;s.length>t;t+=2,e++){const i=s[t],n=s[t+1],o=3*e
|
|
514
|
-
|
|
522
|
+
c[o]=i,c[o+1]=n,c[o+2]=0,l[o]=0,l[o+1]=0,l[o+2]=-1
|
|
515
523
|
const h=3*(r+e)
|
|
516
|
-
|
|
517
|
-
for(let t=0;n.length>t;t++)
|
|
518
|
-
let
|
|
519
|
-
for(
|
|
520
|
-
let
|
|
521
|
-
if(
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
return 0===i?[]:1===i?[[0]]:this.
|
|
524
|
+
c[h]=i,c[h+1]=n,c[h+2]=d,l[h]=0,l[h+1]=0,l[h+2]=1}for(let t=0;n.length>t;t++)u[t]=n[n.length-1-t]
|
|
525
|
+
for(let t=0;n.length>t;t++)u[n.length+t]=n[t]+r
|
|
526
|
+
let y=2*r,p=2*n.length
|
|
527
|
+
for(let t=0;o.length>t;t++){const[e,i]=o[t],n=2*e,r=2*i,h=s[n],a=s[n+1],f=s[r],w=s[r+1],m=f-h,v=w-a,g=m*m+v*v
|
|
528
|
+
let x=0,S=0
|
|
529
|
+
if(g>0){const t=1/Math.sqrt(g)
|
|
530
|
+
x=v*t,S=-m*t}const b=y,_=3*b
|
|
531
|
+
c[_]=h,c[_+1]=a,c[_+2]=0,c[_+3]=f,c[_+4]=w,c[_+5]=0,c[_+6]=h,c[_+7]=a,c[_+8]=d,c[_+9]=f,c[_+10]=w,c[_+11]=d,l[_]=x,l[_+1]=S,l[_+2]=0,l[_+3]=x,l[_+4]=S,l[_+5]=0,l[_+6]=x,l[_+7]=S,l[_+8]=0,l[_+9]=x,l[_+10]=S,l[_+11]=0,u[p++]=b,u[p++]=b+1,u[p++]=b+2,u[p++]=b+1,u[p++]=b+3,u[p++]=b+2,y+=4}return{vertices:c,normals:l,indices:u}}}class Q{constructor(){}cs(t,e){const i=t.length
|
|
532
|
+
return 0===i?[]:1===i?[[0]]:this.ls(t,e)}ls(t,e){function i(t){return a[t]===t?t:a[t]=i(a[t])}function s(t,e){const s=i(t),n=i(e)
|
|
525
533
|
s!==n&&(c[n]>c[s]?a[s]=n:c[s]>c[n]?a[n]=s:(a[n]=s,c[s]++))}const n=t.length,r=Array(n),o=Array(2*n)
|
|
526
534
|
let h=0
|
|
527
|
-
for(let i=0;n>i;i++)r[i]=this.
|
|
535
|
+
for(let i=0;n>i;i++)r[i]=this.us(t[i],e[i]),o[h++]=[r[i].fs,0,i],o[h++]=[r[i].ds,1,i]
|
|
528
536
|
o.sort((t,e)=>t[0]-e[0]||t[1]-e[1])
|
|
529
537
|
const a=Array.from({length:n},(t,e)=>e),c=Array(n).fill(0),l=new Set
|
|
530
538
|
for(const[,t,e]of o)if(0===t){const t=r[e]
|
|
531
539
|
for(const i of l){const n=r[i]
|
|
532
|
-
n.
|
|
540
|
+
n.ys+.001>t.ps&&t.ys>n.ps-.001&&s(e,i)}l.add(e)}else l.delete(e)
|
|
533
541
|
const u=new Map
|
|
534
542
|
for(let t=0;n>t;t++){const e=i(t)
|
|
535
543
|
let s=u.get(e)
|
|
536
|
-
s||(s=[],u.set(e,s)),s.push(t)}return Array.from(u.values())}
|
|
537
|
-
if(void 0!==e)return this.
|
|
538
|
-
const i=this.
|
|
539
|
-
this.
|
|
544
|
+
s||(s=[],u.set(e,s)),s.push(t)}return Array.from(u.values())}us(t,e){return{fs:t.bounds.min.x+e.x,ps:t.bounds.min.y+e.y,ds:t.bounds.max.x+e.x,ys:t.bounds.max.y+e.y}}}class Z{constructor(t){this.ws=[],this.vs=new Map,this.compare=t}k(t){const e=this.vs.get(t)
|
|
545
|
+
if(void 0!==e)return this.gs(e),void this.xs(e)
|
|
546
|
+
const i=this.ws.length
|
|
547
|
+
this.ws.push(t),this.vs.set(t,i),this.gs(i)}Ss(){const t=this.ws.length
|
|
540
548
|
if(!t)return
|
|
541
|
-
if(1===t){const t=this.
|
|
542
|
-
return this.
|
|
543
|
-
return this.
|
|
544
|
-
void 0!==e?(this.
|
|
545
|
-
this.
|
|
546
|
-
for(;t>0;){const i=t-1>>1,s=this.
|
|
549
|
+
if(1===t){const t=this.ws.pop()
|
|
550
|
+
return this.vs.clear(),t}const e=this.ws[0],i=this.ws.pop()
|
|
551
|
+
return this.ws[0]=i,this.vs.delete(e),this.vs.set(i,0),this.xs(0),e}update(t){const e=this.vs.get(t)
|
|
552
|
+
void 0!==e?(this.gs(e),this.xs(e)):this.k(t)}bs(){return!this.ws.length}_s(t,e){const i=this.ws[t],s=this.ws[e]
|
|
553
|
+
this.ws[t]=s,this.ws[e]=i,this.vs.set(i,e),this.vs.set(s,t)}gs(t){const e=this.ws[t]
|
|
554
|
+
for(;t>0;){const i=t-1>>1,s=this.ws[i]
|
|
547
555
|
if(this.compare(e,s)>=0)break
|
|
548
|
-
this.
|
|
556
|
+
this.ws[t]=s,this.vs.set(s,t),t=i}this.ws[t]=e,this.vs.set(e,t)}xs(t){const e=this.ws[t],i=this.ws.length,s=i>>1
|
|
549
557
|
for(;s>t;){const s=1+(t<<1),n=s+1
|
|
550
558
|
let r=t,o=e
|
|
551
|
-
const h=this.
|
|
552
|
-
if(0>this.compare(h,o)&&(r=s,o=h),i>n){const t=this.
|
|
559
|
+
const h=this.ws[s]
|
|
560
|
+
if(0>this.compare(h,o)&&(r=s,o=h),i>n){const t=this.ws[n]
|
|
553
561
|
0>this.compare(t,o)&&(r=n,o=t)}if(r===t)break
|
|
554
|
-
this.
|
|
555
|
-
class et{constructor(t){this.stats={
|
|
556
|
-
this.stats.
|
|
562
|
+
this.ws[t]=o,this.vs.set(o,t),t=r}this.ws[t]=e,this.vs.set(e,t)}}const tt={enabled:!0,Es:1,Ts:.0087,As:10}
|
|
563
|
+
class et{constructor(t){this.stats={Ls:0,Ms:0,Is:0},this.config=t}Gs(t){this.config=t}Os(t){if(!this.config.enabled||2>=t.points.length)return t
|
|
564
|
+
this.stats.Is+=t.points.length
|
|
557
565
|
const e=t.points
|
|
558
566
|
if(5>e.length)return t
|
|
559
|
-
let i=this.
|
|
560
|
-
return 3>i.length?t:(i=this.
|
|
561
|
-
const i=t.length,s=t.map((t,e)=>({index:e,
|
|
567
|
+
let i=this.Fs(e,this.config.Es)
|
|
568
|
+
return 3>i.length?t:(i=this.ks(i,this.config.Ts),3>i.length?t:{...t,points:i})}Fs(t,e){if(3>=t.length)return t
|
|
569
|
+
const i=t.length,s=t.map((t,e)=>({index:e,Cs:1/0,pi:null,next:null}))
|
|
562
570
|
for(let t=0;s.length>t;t++)s[t].pi=s[t-1]||null,s[t].next=s[t+1]||null
|
|
563
|
-
const n=new Z((t,e)=>t.
|
|
571
|
+
const n=new Z((t,e)=>t.Cs-e.Cs)
|
|
564
572
|
for(let e=1;s.length-1>e;e++){const i=s[e]
|
|
565
|
-
i.
|
|
566
|
-
for(;!n.
|
|
567
|
-
if(!i||i.
|
|
568
|
-
if(this.config.
|
|
569
|
-
if(this.config.
|
|
573
|
+
i.Cs=this.Bs(t[i.pi.index],t[i.index],t[i.next.index]),n.k(i)}let r=i
|
|
574
|
+
for(;!n.bs()&&r>3;){const i=n.Ss()
|
|
575
|
+
if(!i||i.Cs>e)break
|
|
576
|
+
if(this.config.As>0&&i.pi&&i.next){const e=t[i.index],s=t[i.next.index],n=t[i.pi.index].ni(e),r=e.ni(s)
|
|
577
|
+
if(this.config.As>n||this.config.As>r)continue}i.pi&&(i.pi.next=i.next),i.next&&(i.next.pi=i.pi),r--,i.pi&&i.pi.pi&&(i.pi.Cs=this.Bs(t[i.pi.pi.index],t[i.pi.index],t[i.next.index]),n.update(i.pi)),i.next&&i.next.next&&(i.next.Cs=this.Bs(t[i.pi.index],t[i.next.index],t[i.next.next.index]),n.update(i.next))}const o=[]
|
|
570
578
|
let h=s[0]
|
|
571
579
|
for(;h;)o.push(t[h.index]),h=h.next
|
|
572
|
-
return this.stats.
|
|
580
|
+
return this.stats.Ls+=i-o.length,o}ks(t,e){if(2>=t.length)return t
|
|
573
581
|
const i=[t[0]]
|
|
574
|
-
for(let s=1;t.length-1>s;s++){const n=t[s-1],r=t[s],o=t[s+1],h=r.x-n.x,a=r.y-n.y,c=o.x-r.x,l=o.y-r.y,u=this.config.
|
|
575
|
-
Math.abs(Math.atan2(h*l-a*c,h*c+a*l))>e||u>h*h+a*a||u>c*c+l*l?i.push(r):this.stats.
|
|
576
|
-
class nt{constructor(t){this.
|
|
577
|
-
return this.
|
|
578
|
-
return this.
|
|
579
|
-
const a=(t+i)/2,c=(e+s)/2,l=(i+n)/2,u=(s+r)/2,f=(a+l)/2,d=(c+u)/2,y=n-t,p=r-e,w=Math.abs((i-n)*p-(s-r)*y),m=this.
|
|
580
|
-
if(w>st){if(v*(y*y+p*p)>=w*w){const h=this.Ns
|
|
581
|
-
if(0>=h)return void this.
|
|
582
|
+
for(let s=1;t.length-1>s;s++){const n=t[s-1],r=t[s],o=t[s+1],h=r.x-n.x,a=r.y-n.y,c=o.x-r.x,l=o.y-r.y,u=this.config.As*this.config.As
|
|
583
|
+
Math.abs(Math.atan2(h*l-a*c,h*c+a*l))>e||u>h*h+a*a||u>c*c+l*l?i.push(r):this.stats.Ms++}return i.push(t[t.length-1]),i}Bs(t,e,i){return Math.abs((t.x*(e.y-i.y)+e.x*(i.y-t.y)+i.x*(t.y-e.y))/2)}getStats(){return{...this.stats}}Us(){this.stats={Ls:0,Ms:0,Is:0}}}const it={$s:.5,Ns:.2},st=1e-6
|
|
584
|
+
class nt{constructor(t){this.Ds={...it,...t}}Ps(t){this.Ds={...it,...t}}Rs(t,e,i){const s=[]
|
|
585
|
+
return this.js(t.x,t.y,e.x,e.y,i.x,i.y,s),this.zs(i.x,i.y,s),s}Ws(t,e,i,s){const n=[]
|
|
586
|
+
return this.Hs(t.x,t.y,e.x,e.y,i.x,i.y,s.x,s.y,n),this.zs(s.x,s.y,n),n}js(t,e,i,s,n,r,o,h=0){if(h>16)return
|
|
587
|
+
const a=(t+i)/2,c=(e+s)/2,l=(i+n)/2,u=(s+r)/2,f=(a+l)/2,d=(c+u)/2,y=n-t,p=r-e,w=Math.abs((i-n)*p-(s-r)*y),m=this.Ds.$s??it.$s,v=m*m
|
|
588
|
+
if(w>st){if(v*(y*y+p*p)>=w*w){const h=this.Ds.Ns??it.Ns
|
|
589
|
+
if(0>=h)return void this.zs(i,s,o)
|
|
582
590
|
{const a=i-t,c=s-e,l=n-i,u=r-s
|
|
583
|
-
if(h>Math.abs(Math.atan2(a*u-c*l,a*l+c*u)))return void this.
|
|
584
|
-
if(0===n){if(v>=(i-t)*(i-t)+(s-e)*(s-e))return void this.
|
|
585
|
-
if(r>0&&1>r&&v*n>=w*w)return void this.
|
|
586
|
-
const l=(t+i)/2,u=(e+s)/2,f=(i+n)/2,d=(s+r)/2,y=(n+o)/2,p=(r+h)/2,w=(l+f)/2,m=(u+d)/2,v=(f+y)/2,g=(d+p)/2,x=(w+v)/2,S=(m+g)/2,b=o-t,_=h-e,E=Math.abs((i-o)*_-(s-h)*b),T=Math.abs((n-o)*_-(r-h)*b),A=this.
|
|
591
|
+
if(h>Math.abs(Math.atan2(a*u-c*l,a*l+c*u)))return void this.zs(i,s,o)}}}else{const n=y*y+p*p
|
|
592
|
+
if(0===n){if(v>=(i-t)*(i-t)+(s-e)*(s-e))return void this.zs(i,s,o)}else{const r=((i-t)*y+(s-e)*p)/n
|
|
593
|
+
if(r>0&&1>r&&v*n>=w*w)return void this.zs(i,s,o)}}this.js(t,e,a,c,f,d,o,h+1),this.js(f,d,l,u,n,r,o,h+1)}Hs(t,e,i,s,n,r,o,h,a,c=0){if(c>16)return
|
|
594
|
+
const l=(t+i)/2,u=(e+s)/2,f=(i+n)/2,d=(s+r)/2,y=(n+o)/2,p=(r+h)/2,w=(l+f)/2,m=(u+d)/2,v=(f+y)/2,g=(d+p)/2,x=(w+v)/2,S=(m+g)/2,b=o-t,_=h-e,E=Math.abs((i-o)*_-(s-h)*b),T=Math.abs((n-o)*_-(r-h)*b),A=this.Ds.$s??it.$s,L=A*A
|
|
587
595
|
let M=0
|
|
588
596
|
switch(E>st&&(M|=1),T>st&&(M|=2),M){case 0:const c=b*b+_*_
|
|
589
|
-
if(0===c){if(L>=(i-t)*(i-t)+(s-e)*(s-e)&&L>=(n-t)*(n-t)+(r-e)*(r-e))return this.
|
|
590
|
-
if(o>0&&1>o&&h>0&&1>h&&L*c>=(E+T)*(E+T))return this.
|
|
591
|
-
case 1:if(L*(b*b+_*_)>=T*T){const t=this.Ns
|
|
592
|
-
if(0>=t)return this.
|
|
597
|
+
if(0===c){if(L>=(i-t)*(i-t)+(s-e)*(s-e)&&L>=(n-t)*(n-t)+(r-e)*(r-e))return this.zs(i,s,a),void this.zs(n,r,a)}else{const o=((i-t)*b+(s-e)*_)/c,h=((n-t)*b+(r-e)*_)/c
|
|
598
|
+
if(o>0&&1>o&&h>0&&1>h&&L*c>=(E+T)*(E+T))return this.zs(i,s,a),void this.zs(n,r,a)}break
|
|
599
|
+
case 1:if(L*(b*b+_*_)>=T*T){const t=this.Ds.Ns??it.Ns
|
|
600
|
+
if(0>=t)return this.zs(i,s,a),void this.zs(n,r,a)
|
|
593
601
|
{const e=n-i,c=r-s,l=o-n,u=h-r
|
|
594
|
-
if(t>Math.abs(Math.atan2(e*u-c*l,e*l+c*u)))return this.
|
|
595
|
-
case 2:if(L*(b*b+_*_)>=E*E){const o=this.Ns
|
|
596
|
-
if(0>=o)return this.
|
|
602
|
+
if(t>Math.abs(Math.atan2(e*u-c*l,e*l+c*u)))return this.zs(i,s,a),void this.zs(n,r,a)}}break
|
|
603
|
+
case 2:if(L*(b*b+_*_)>=E*E){const o=this.Ds.Ns??it.Ns
|
|
604
|
+
if(0>=o)return this.zs(i,s,a),void this.zs(n,r,a)
|
|
597
605
|
{const h=i-t,c=s-e,l=n-i,u=r-s
|
|
598
|
-
if(o>Math.abs(Math.atan2(h*u-c*l,h*l+c*u)))return this.
|
|
599
|
-
case 3:if(L*(b*b+_*_)>=(E+T)*(E+T)){const c=this.Ns
|
|
600
|
-
if(0>=c)return this.
|
|
606
|
+
if(o>Math.abs(Math.atan2(h*u-c*l,h*l+c*u)))return this.zs(i,s,a),void this.zs(n,r,a)}}break
|
|
607
|
+
case 3:if(L*(b*b+_*_)>=(E+T)*(E+T)){const c=this.Ds.Ns??it.Ns
|
|
608
|
+
if(0>=c)return this.zs(i,s,a),void this.zs(n,r,a)
|
|
601
609
|
{const l=i-t,u=s-e,f=n-i,d=r-s,y=o-n,p=h-r
|
|
602
|
-
if(c>Math.abs(Math.atan2(l*d-u*f,l*f+u*d))+Math.abs(Math.atan2(f*p-d*y,f*y+d*p)))return this.
|
|
610
|
+
if(c>Math.abs(Math.atan2(l*d-u*f,l*f+u*d))+Math.abs(Math.atan2(f*p-d*y,f*y+d*p)))return this.zs(i,s,a),void this.zs(n,r,a)}}}this.Hs(t,e,l,u,w,m,x,S,a,c+1),this.Hs(x,S,v,g,y,p,o,h,a,c+1)}zs(t,e,i){const s=new P(t,e)
|
|
603
611
|
if(0===i.length)return void i.push(s)
|
|
604
612
|
const n=i[i.length-1],r=s.x-n.x,o=s.y-n.y
|
|
605
|
-
r*r+o*o>1e-12&&i.push(s)}}class rt{constructor(t,e){this.
|
|
613
|
+
r*r+o*o>1e-12&&i.push(s)}}class rt{constructor(t,e){this.Vs=0,this.qs=0,this.Js=[],this.Ys=null,this.Ks=null,this.Xs={min:new P(1/0,1/0),max:new P(-1/0,-1/0)},this.Qs=[],this.Zs=[],this.tn=[],this.en=new P(0,0),this.sn=new nt(t),this.nn=new et({...tt,...e})}setPosition(t,e){this.en.set(t,e)}rn(t,e){this.en.x+=t,this.en.y+=e}hn(t,e){this.Js.length>0&&this.an(),this.Vs=t,this.qs=e,this.Js=[],this.Xs.min.set(1/0,1/0),this.Xs.max.set(-1/0,-1/0),this.Zs.push(this.en.clone())}an(){this.Ys&&this.cn(),this.Js.length>0&&(this.Qs.push({ln:this.Vs,bi:this.Js,bounds:{min:{x:this.Xs.min.x,y:this.Xs.min.y},max:{x:this.Xs.max.x,y:this.Xs.max.y}}}),this.tn.push(this.qs)),this.Js=[]}un(t,e){this.Ys&&this.cn(),this.Ks=new P(t,e),this.fn(this.Ks),this.Ys={points:[this.Ks],dn:this.Vs}}yn(t,e){if(!this.Ys||!this.Ks)return
|
|
606
614
|
const i=new P(t,e)
|
|
607
|
-
this.
|
|
608
|
-
const n=this.
|
|
609
|
-
if(st>Math.abs((r.x-o.x)*(o.y-n.y)-(r.y-o.y)*(o.x-n.x)))return void this.
|
|
610
|
-
const h=this.
|
|
615
|
+
this.fn(i),this.Ys.points.push(i),this.Ks=i}pn(t,e,i,s){if(!this.Ys||!this.Ks)return
|
|
616
|
+
const n=this.Ks,r=new P(t,e),o=new P(i,s)
|
|
617
|
+
if(st>Math.abs((r.x-o.x)*(o.y-n.y)-(r.y-o.y)*(o.x-n.x)))return void this.yn(i,s)
|
|
618
|
+
const h=this.sn.Rs(n,r,o)
|
|
611
619
|
for(let t=0;h.length>t;t++){const e=h[t]
|
|
612
|
-
this.
|
|
613
|
-
const o=this.
|
|
614
|
-
if(st>Math.abs((h.x-c.x)*u-(h.y-c.y)*l)&&st>Math.abs((a.x-c.x)*u-(a.y-c.y)*l))return void this.
|
|
615
|
-
const f=this.
|
|
620
|
+
this.fn(e),this.Ys.points.push(e)}this.Ks=o}wn(t,e,i,s,n,r){if(!this.Ys||!this.Ks)return
|
|
621
|
+
const o=this.Ks,h=new P(t,e),a=new P(i,s),c=new P(n,r),l=c.x-o.x,u=c.y-o.y
|
|
622
|
+
if(st>Math.abs((h.x-c.x)*u-(h.y-c.y)*l)&&st>Math.abs((a.x-c.x)*u-(a.y-c.y)*l))return void this.yn(n,r)
|
|
623
|
+
const f=this.sn.Ws(o,h,a,c)
|
|
616
624
|
for(let t=0;f.length>t;t++){const e=f[t]
|
|
617
|
-
this.
|
|
618
|
-
const t=this.
|
|
619
|
-
this.
|
|
620
|
-
this.
|
|
621
|
-
if(this.
|
|
625
|
+
this.fn(e),this.Ys.points.push(e)}this.Ks=c}mn(){if(!this.Ys||!this.Ks)return
|
|
626
|
+
const t=this.Ys.points[0]
|
|
627
|
+
this.Ks.equals(t)||this.Ys.points.push(t),this.cn()}cn(){if(this.Ys){const t=this.nn.Os(this.Ys)
|
|
628
|
+
this.Js.push(t),this.Ys=null,this.Ks=null}}fn(t){this.Xs.min.x=Math.min(this.Xs.min.x,t.x),this.Xs.min.y=Math.min(this.Xs.min.y,t.y),this.Xs.max.x=Math.max(this.Xs.max.x,t.x),this.Xs.max.y=Math.max(this.Xs.max.y,t.y)}vn(){return this.Js.length>0&&this.an(),this.Qs}gn(){return this.Zs}xn(){return this.tn}reset(){this.Qs=[],this.Zs=[],this.tn=[],this.Js=[],this.Ys=null,this.Ks=null,this.Vs=0,this.qs=0,this.en.set(0,0),this.Xs={min:new P(1/0,1/0),max:new P(-1/0,-1/0)}}Ps(t){this.sn.Ps(t)}Sn(t){this.nn.Gs({...tt,...t})}bn(){return this.nn.getStats()}}class ot{constructor(){this._n=null,this.En=null,this.Tn=null,this.An=null,this.Ln=null,this.Mn=0,this.position={x:0,y:0}}setPosition(t,e){this.position.x=t,this.position.y=e,this.In&&this.In.setPosition(t,e)}rn(t,e){this.position.x+=t,this.position.y+=e,this.In&&this.In.rn(t,e)}Gn(t){this.In=t}On(t,e){if(!t||!t.module||!t.hb)throw Error("Invalid font object")
|
|
629
|
+
if(this.In=e,this.Mn)return
|
|
622
630
|
const i=t.module
|
|
623
|
-
this.
|
|
624
|
-
return this.
|
|
631
|
+
this._n=i.Fn((t,e,i,s,n)=>{this.In?.un(s,n)},"viiiffi"),this.En=i.Fn((t,e,i,s,n)=>{this.In?.yn(s,n)},"viiiffi"),this.Tn=i.Fn((t,e,i,s,n,r,o)=>{this.In?.pn(s,n,r,o)},"viiiffffi"),this.An=i.Fn((t,e,i,s,n,r,o,h,a)=>{this.In?.wn(s,n,r,o,h,a)},"viiiffffffi"),this.Ln=i.Fn(()=>{this.In?.mn()},"viiii"),this.Mn=i.exports.kn(),i.exports.Cn(this.Mn,this._n,0,0),i.exports.Bn(this.Mn,this.En,0,0),i.exports.Un(this.Mn,this.Tn,0,0),i.exports.$n(this.Mn,this.An,0,0),i.exports.Nn(this.Mn,this.Ln,0,0)}Dn(){if(!this.Mn)throw Error("Draw functions not initialized")
|
|
632
|
+
return this.Mn}destroy(t){if(!t||!t.module||!t.hb)return
|
|
625
633
|
const e=t.module
|
|
626
|
-
try{this.
|
|
627
|
-
class at{constructor(t,e){this.
|
|
634
|
+
try{this.Mn&&(e.exports.Pn(this.Mn),this.Mn=0),null!==this._n&&(e.Rn(this._n),this._n=null),null!==this.En&&(e.Rn(this.En),this.En=null),null!==this.Tn&&(e.Rn(this.Tn),this.Tn=null),null!==this.An&&(e.Rn(this.An),this.An=null),null!==this.Ln&&(e.Rn(this.Ln),this.Ln=null)}catch(t){l.warn("Error destroying draw callbacks:",t)}this.In=void 0}}const ht=new WeakMap
|
|
635
|
+
class at{constructor(t,e){this.jn="default",this.zn="default",this.Wn=new Set,this.cache=t,this.le=e,this.tessellator=new K,this.Hn=new X,this.Vn=new Q,this.In=new rt,this.qn=(()=>{const t=this.le.module,e=ht.get(t)
|
|
628
636
|
if(e)return e
|
|
629
637
|
const i=new ot
|
|
630
|
-
return ht.set(t,i),i})(),this.
|
|
631
|
-
return[`cf:${t.toFixed(4)},${e.toFixed(4)}`,`opt:${i?1:0},${s.toFixed(4)},${n.toFixed(6)},${r.toFixed(4)}`].join("|")}
|
|
638
|
+
return ht.set(t,i),i})(),this.qn.On(this.le,this.In),this.Jn=W,this.Yn=H,this.Kn=V}bn(){return this.In.bn()}Ps(t){this.Ds=t,this.In.Ps(t),this.Xn()}Sn(t){this.Qn=t,this.In.Sn(t),this.Xn()}Zn(t){this.jn=t,this.Xn()}Xn(){this.zn=`${this.jn}__${this.tr()}`}tr(){const t=this.Ds?.$s??it.$s,e=this.Ds?.Ns??it.Ns,i=this.Qn?.enabled??!0,s=this.Qn?.Es??1,n=this.Qn?.Ts??.0087,r=this.Qn?.As??10
|
|
639
|
+
return[`cf:${t.toFixed(4)},${e.toFixed(4)}`,`opt:${i?1:0},${s.toFixed(4)},${n.toFixed(6)},${r.toFixed(4)}`].join("|")}er(t,e,i,n,r=!1,o){if(c){let e=0
|
|
632
640
|
for(let i=0;t.length>i;i++)e+=t[i].length}const h=[]
|
|
633
641
|
let a=0,l=0,u=0,f=0
|
|
634
642
|
const d=(t,e,i,s)=>{const n=f
|
|
635
|
-
return h.push({data:t,px:e,
|
|
643
|
+
return h.push({data:t,px:e,ir:i,sr:s,nr:n}),a+=t.vertices.length,l+=t.normals.length,u+=t.indices.length,f+=t.vertices.length/3,n},y=[],p={min:{x:1/0,y:1/0,z:0},max:{x:-1/0,y:-1/0,z:e}}
|
|
636
644
|
for(let h=0;t.length>h;h++){const a=t[h]
|
|
637
645
|
for(const t of a){const h=t.position.x,a=t.position.y,c=t.position.z,l=[]
|
|
638
|
-
for(const e of t.glyphs)l.push(this.
|
|
646
|
+
for(const e of t.glyphs)l.push(this.rr(e.g))
|
|
639
647
|
let u
|
|
640
|
-
if(t.glyphs.length>1){const e=`${this.
|
|
648
|
+
if(t.glyphs.length>1){const e=`${this.zn}_${t.text}`,i=this.Kn.get(e)
|
|
641
649
|
let s=!1
|
|
642
|
-
if(i&&i.
|
|
643
|
-
for(let e=0;t.glyphs.length>e;e++)if(i.
|
|
650
|
+
if(i&&i.hr.length===t.glyphs.length){s=!0
|
|
651
|
+
for(let e=0;t.glyphs.length>e;e++)if(i.hr[e]!==t.glyphs[e].g){s=!1
|
|
644
652
|
break}}if(s&&i)u=i.groups
|
|
645
653
|
else{const i=t.glyphs.map(t=>new R(t.x??0,t.y??0,0))
|
|
646
|
-
u=this.
|
|
647
|
-
const f=o&&t.glyphs.some(t=>o.has(t.
|
|
648
|
-
for(const r of u)if(r.length>1&&!w){const s=r.map(e=>t.glyphs[e]),o=this.
|
|
649
|
-
let u=this.
|
|
654
|
+
u=this.Vn.cs(l,i),this.Kn.set(e,{hr:t.glyphs.map(t=>t.g),groups:u})}}else u=[[0]]
|
|
655
|
+
const f=o&&t.glyphs.some(t=>o.has(t.ar)),w=r||f
|
|
656
|
+
for(const r of u)if(r.length>1&&!w){const s=r.map(e=>t.glyphs[e]),o=this.cr(s,e,i)
|
|
657
|
+
let u=this.Yn.get(o)
|
|
650
658
|
if(!u){const i=[],h=s[0].x??0,a=s[0].y??0
|
|
651
659
|
for(let e=0;r.length>e;e++){const s=r[e],n=l[s],o=t.glyphs[s],c=(o.x??0)-h,u=(o.y??0)-a
|
|
652
|
-
for(const t of n.bi)i.push({...t,points:t.points.map(t=>new P(t.x+c,t.y+u))})}u=this.
|
|
653
|
-
for(let i=0;r.length>i;i++){const s=r[i],n=t.glyphs[s],o=this.
|
|
654
|
-
y.push(o),this.
|
|
655
|
-
if(0===u.bi.length){const t=this.
|
|
660
|
+
for(const t of n.bi)i.push({...t,points:t.points.map(t=>new P(t.x+c,t.y+u))})}u=this.lr(i,e,n),this.Yn.set(o,u)}const f=s[0],w=d(u,h+(f.x??0),a+(f.y??0),c),m=u.vertices.length/3
|
|
661
|
+
for(let i=0;r.length>i;i++){const s=r[i],n=t.glyphs[s],o=this.ur(n,w,m,h+(n.x??0),a+(n.y??0),c,l[s],e)
|
|
662
|
+
y.push(o),this.dr(o.bounds,p)}}else for(const o of r){const r=t.glyphs[o],u=l[o],f=h+(r.x??0),w=a+(r.y??0),m=c
|
|
663
|
+
if(0===u.bi.length){const t=this.ur(r,0,0,f,w,m,u,e)
|
|
656
664
|
y.push(t)
|
|
657
|
-
continue}const v=s(this.
|
|
665
|
+
continue}const v=s(this.zn,r.g,e,i)
|
|
658
666
|
let g=this.cache.get(v)
|
|
659
|
-
g?g.
|
|
660
|
-
const x=d(g,f,w,m),S=this.
|
|
661
|
-
y.push(S),this.
|
|
667
|
+
g?g.yr++:(g=this.pr(u,e,i,n),this.cache.set(v,g))
|
|
668
|
+
const x=d(g,f,w,m),S=this.ur(r,x,g.vertices.length/3,f,w,m,u,e)
|
|
669
|
+
y.push(S),this.dr(S.bounds,p)}}}const w=new Float32Array(a),m=new Float32Array(l),v=new Uint32Array(u)
|
|
662
670
|
let g=0,x=0,S=0
|
|
663
|
-
for(let t=0;h.length>t;t++){const e=h[t],i=e.data.vertices,s=e.data.normals,n=e.data.indices,r=e.px,o=e.
|
|
671
|
+
for(let t=0;h.length>t;t++){const e=h[t],i=e.data.vertices,s=e.data.normals,n=e.data.indices,r=e.px,o=e.ir,a=e.sr
|
|
664
672
|
for(let t=0;i.length>t;t+=3)w[g++]=i[t]+r,w[g++]=i[t+1]+o,w[g++]=i[t+2]+a
|
|
665
673
|
m.set(s,x),x+=s.length
|
|
666
|
-
const c=e.
|
|
667
|
-
for(let t=0;n.length>t;t++)v[S++]=n[t]+c}return{vertices:w,normals:m,indices:v,
|
|
674
|
+
const c=e.nr
|
|
675
|
+
for(let t=0;n.length>t;t++)v[S++]=n[t]+c}return{vertices:w,normals:m,indices:v,wr:y,planeBounds:p}}cr(t,e,i){if(0===t.length)return""
|
|
668
676
|
const s=t[0].x??0,n=t[0].y??0,r=t.map(t=>`${t.g}:${(t.x??0)-s},${(t.y??0)-n}`).join("|")
|
|
669
|
-
return`${this.
|
|
670
|
-
const e=`${this.
|
|
677
|
+
return`${this.zn}_${r}_${Math.round(1e3*e)/1e3}_${i}`}ur(t,e,i,s,n,r,o,h){return{mr:t.ar,vr:t.vr,nr:e,gr:i,bounds:{min:{x:o.bounds.min.x+s,y:o.bounds.min.y+n,z:r},max:{x:o.bounds.max.x+s,y:o.bounds.max.y+n,z:r+h}}}}rr(t){if(this.Wn.has(t))return{ln:t,bi:[],bounds:{min:{x:0,y:0},max:{x:0,y:0}}}
|
|
678
|
+
const e=`${this.zn}_${t}`,i=this.Jn.get(e)
|
|
671
679
|
if(i)return i
|
|
672
|
-
this.
|
|
673
|
-
const s=this.
|
|
674
|
-
return 0===s.bi.length&&this.
|
|
675
|
-
return this.
|
|
680
|
+
this.qn.Gn(this.In),this.In.reset(),this.In.hn(t,0),this.le.module.exports.Sr(this.le.font.br,t,this.qn.Dn(),0),this.In.an()
|
|
681
|
+
const s=this.In.vn()[0]||{ln:t,bi:[],bounds:{min:{x:0,y:0},max:{x:0,y:0}}}
|
|
682
|
+
return 0===s.bi.length&&this.Wn.add(t),this.Jn.set(e,s),s}lr(t,e,i){const s=this.tessellator.process(t,!0,i,0!==e)
|
|
683
|
+
return this._r(s,e)}_r(t,e){const i=this.Hn.hs(t,e,this.le.upem),s=i.vertices
|
|
676
684
|
let n=1/0,r=1/0,o=1/0,h=-1/0,a=-1/0,c=-1/0
|
|
677
685
|
for(let t=0;s.length>t;t+=3){const e=s[t],i=s[t+1],l=s[t+2]
|
|
678
686
|
n>e&&(n=e),e>h&&(h=e),r>i&&(r=i),i>a&&(a=i),o>l&&(o=l),l>c&&(c=l)}const l=new R(n,r,o),u=new R(h,a,c)
|
|
679
|
-
return{geometry:t,vertices:i.vertices,normals:i.normals,indices:i.indices,bounds:{min:l,max:u},
|
|
680
|
-
return this.
|
|
681
|
-
i.x>n.x&&(i.x=n.x),i.y>n.y&&(i.y=n.y),i.z>n.z&&(i.z=n.z),r.x>s.x&&(s.x=r.x),r.y>s.y&&(s.y=r.y),r.z>s.z&&(s.z=r.z)}
|
|
682
|
-
return t.forEach((t,o)=>{const h=this.
|
|
683
|
-
r.push(h)}),r}finally{}}
|
|
684
|
-
"rtl"===o&&h.
|
|
687
|
+
return{geometry:t,vertices:i.vertices,normals:i.normals,indices:i.indices,bounds:{min:l,max:u},yr:1}}pr(t,e,i,s){const n=this.tessellator.process(t.bi,i,s,0!==e)
|
|
688
|
+
return this._r(n,e)}dr(t,e){const i=e.min,s=e.max,n=t.min,r=t.max
|
|
689
|
+
i.x>n.x&&(i.x=n.x),i.y>n.y&&(i.y=n.y),i.z>n.z&&(i.z=n.z),r.x>s.x&&(s.x=r.x),r.y>s.y&&(s.y=r.y),r.z>s.z&&(s.z=r.z)}Er(){return this.cache.getStats()}clearCache(){this.cache.clear(),this.Yn.clear(),this.Kn.clear(),this.Jn.clear()}}class ct{constructor(t,e){this.Tr=new Map,this.le=t,this.Ar=e}Lr(t,e,i,s,n,r,o){try{const r=[]
|
|
690
|
+
return t.forEach((t,o)=>{const h=this.Mr(t,o,e,i,s,n)
|
|
691
|
+
r.push(h)}),r}finally{}}Mr(e,i,s,n,r,o){const h=this.le.hb.createBuffer()
|
|
692
|
+
"rtl"===o&&h.Ir("rtl"),h.oe(e.text),h.he()
|
|
685
693
|
const a=t(this.le.ae)
|
|
686
694
|
this.le.hb.shape(this.le.font,h,a)
|
|
687
695
|
const c=h.json(this.le.font)
|
|
688
696
|
h.destroy()
|
|
689
697
|
const l=[]
|
|
690
698
|
let u=[],f="",d=0,y=0,p=e.Dt,w=-i*s
|
|
691
|
-
const m=n*this.le.upem,v=this.
|
|
699
|
+
const m=n*this.le.upem,v=this.Gr(e,r,n),g=this.Or(e,r)
|
|
692
700
|
for(let t=0;c.length>t;t++){const s=c[t],n=/\s/.test(e.text[s.ce])
|
|
693
|
-
s.
|
|
701
|
+
s.ar=e.Rt&&s.ce===e.text.length-1&&"-"===e.text[s.ce]?e.Nt:e.$t+s.ce,s.vr=i,n&&u.length>0&&(l.push({text:f,glyphs:u,position:new R(d,y,0)}),u=[],f="")
|
|
694
702
|
const r=p+s.dx,o=w+s.dy
|
|
695
703
|
if(n||(0===u.length&&(d=r,y=o),s.x=r-d,s.y=o-y,u.push(s),f+=e.text[s.ce]),p+=s.ax,w+=s.ay,0!==m&&c.length-1>t&&(p+=m),n&&(p+=v),0!==g&&c.length-1>t&&!n){const i=e.text[s.ce],n=e.text[c[t+1].ce],r=M.tt(i),o=n&&M.tt(n)
|
|
696
704
|
if(r&&o){let t=!0
|
|
697
|
-
M.et(n)&&(t=!1),M.it(i)&&(t=!1),M.st(i)&&M.st(n)&&(t=!1),t&&(p+=g)}}}return u.length>0&&l.push({text:f,glyphs:u,position:new R(d,y,0)}),l}
|
|
698
|
-
if(void 0!==t.Kt&&"justify"===e&&!t.Pt){let e=this.
|
|
699
|
-
void 0===e&&(e=G.measureTextWidth(this.le," ",i),this.
|
|
700
|
-
return t.Kt>0||0>t.Kt?.04*t.Kt*this.le.upem:0}clearCache(){this.
|
|
705
|
+
M.et(n)&&(t=!1),M.it(i)&&(t=!1),M.st(i)&&M.st(n)&&(t=!1),t&&(p+=g)}}}return u.length>0&&l.push({text:f,glyphs:u,position:new R(d,y,0)}),l}Gr(t,e,i){let s=0
|
|
706
|
+
if(void 0!==t.Kt&&"justify"===e&&!t.Pt){let e=this.Tr.get(i)
|
|
707
|
+
void 0===e&&(e=G.measureTextWidth(this.le," ",i),this.Tr.set(i,e)),t.Kt>0?s=t.Kt*e*.5:0>t.Kt&&(s=t.Kt*e*y)}return s}Or(t,e){if(void 0===t.Kt||"justify"!==e||t.Pt)return 0
|
|
708
|
+
return t.Kt>0||0>t.Kt?.04*t.Kt*this.le.upem:0}clearCache(){this.Ar.clearCache()}Er(){return this.Ar.Er()}}var lt={exports:{}},ut=h(Object.freeze({__proto__:null,default:{},Fr(){throw Error("fs not available in browser")}}))
|
|
701
709
|
!(function(t){var e,i=(e="undefined"!=typeof document?document.currentScript?.src:void 0,async function(t={}){function i(){var t=m.buffer
|
|
702
|
-
n.HEAP8=new Int8Array(t),n.HEAPU8=v=new Uint8Array(t),n.HEAP32=new Int32Array(t),n.HEAPU32=new Uint32Array(t),n.HEAPF32=new Float32Array(t),new BigInt64Array(t),new BigUint64Array(t)}function s(t){n.
|
|
710
|
+
n.HEAP8=new Int8Array(t),n.HEAPU8=v=new Uint8Array(t),n.HEAP32=new Int32Array(t),n.HEAPU32=new Uint32Array(t),n.HEAPF32=new Float32Array(t),new BigInt64Array(t),new BigUint64Array(t)}function s(t){n.kr?.(t),x(t="Aborted("+t+")"),S=!0,t+=". Build with -sASSERTIONS for more info."
|
|
703
711
|
var e=new WebAssembly.RuntimeError(t)
|
|
704
712
|
throw w?.(e),e}var n=t,r="object"==typeof window,o="undefined"!=typeof WorkerGlobalScope,h="object"==typeof process&&process.versions?.node&&"renderer"!=process.type,a=(t,e)=>{throw e}
|
|
705
713
|
"undefined"!=typeof __filename?e=__filename:o&&(e=self.location.href)
|
|
706
714
|
var c,l,u=""
|
|
707
715
|
if(h){var f=ut
|
|
708
|
-
u=__dirname+"/",l=t=>(t=b(t)?new URL(t):t,f.
|
|
716
|
+
u=__dirname+"/",l=t=>(t=b(t)?new URL(t):t,f.Fr(t)),c=async(t,e=!0)=>(t=b(t)?new URL(t):t,f.Fr(t,e?void 0:"utf8")),process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),a=(t,e)=>{throw process.exitCode=t,e}}else if(r||o){try{u=new URL(".",e).href}catch{}o&&(l=t=>{var e=new XMLHttpRequest
|
|
709
717
|
return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),c=async t=>{if(b(t))return new Promise((e,i)=>{var s=new XMLHttpRequest
|
|
710
718
|
s.open("GET",t,!0),s.responseType="arraybuffer",s.onload=()=>{200==s.status||0==s.status&&s.response?e(s.response):i(s.status)},s.onerror=i,s.send(null)})
|
|
711
719
|
var e=await fetch(t,{credentials:"same-origin"})
|
|
@@ -714,158 +722,158 @@ throw Error(e.status+" : "+e.url)}}console.log.bind(console)
|
|
|
714
722
|
var d,y,p,w,m,v,g,x=console.error.bind(console),S=!1,b=t=>t.startsWith("file://"),_=!1,E=0,T=null
|
|
715
723
|
class A{name="ExitStatus"
|
|
716
724
|
constructor(t){this.message=`Program terminated with exit(${t})`,this.status=t}}var L,M,I,G=t=>{for(;t.length>0;)t.shift()(n)},O=[],F=t=>O.push(t),k=[],C=t=>k.push(t),B=!0,U=0,$={},N=t=>{if(t instanceof A||"unwind"==t)return y
|
|
717
|
-
a(1,t)},D=()=>B||U>0,P=t=>{y=t,D()||(n.
|
|
725
|
+
a(1,t)},D=()=>B||U>0,P=t=>{y=t,D()||(n.Cr?.(t),S=!0),a(t,new A(t))},R=(t,e)=>Math.ceil(t/e)*e,j=t=>{var e=(t-m.buffer.byteLength+65535)/65536|0
|
|
718
726
|
try{return m.grow(e),i(),1}catch(t){}},z=t=>{const e=t.length
|
|
719
727
|
return[e%128|128,e>>7,...t]},W={Ei:127,Ai:127,Mi:126,f:125,d:124,e:111},H=t=>z(Array.from(t,t=>W[t])),V=t=>L.get(t),q=[],J=(t,e)=>L.set(t,e)
|
|
720
|
-
n.
|
|
728
|
+
n.Br&&(B=n.Br),n.Ur&&(x=n.Ur),n.$r&&(d=n.$r),n.Nr=m,n.Dr=K,n.Fn=(t,e)=>{var i=(t=>(M||(M=new WeakMap,((t,e)=>{if(M)for(var i=0;0+e>i;i++){var s=V(i)
|
|
721
729
|
s&&M.set(s,i)}})(0,L.length)),M.get(t)||0))(t)
|
|
722
730
|
if(i)return i
|
|
723
731
|
var s=q.length?q.pop():L.grow(1)
|
|
724
732
|
try{J(s,t)}catch(i){if(!(i instanceof TypeError))throw i
|
|
725
733
|
var n=((t,e)=>{var i=Uint8Array.of(0,97,115,109,1,0,0,0,1,...z([1,96,...H(e.slice(1)),...H("v"===e[0]?"":e[0])]),2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0),s=new WebAssembly.Module(i)
|
|
726
734
|
return new WebAssembly.Instance(s,{e:{f:t}}).exports.f})(t,e)
|
|
727
|
-
J(s,n)}return M.set(t,s),s},n.
|
|
728
|
-
var Y={
|
|
735
|
+
J(s,n)}return M.set(t,s),s},n.Rn=t=>{M.delete(V(t)),J(t,null),q.push(t)}
|
|
736
|
+
var Y={Pr:()=>s(""),Rr(){B=!1,U=0},jr(t,e){if($[t]&&(clearTimeout($[t].id),delete $[t]),!e)return 0
|
|
729
737
|
var i=setTimeout(()=>{delete $[t],(t=>{if(!S)try{t(),(()=>{if(!D())try{y=t=y,P(t)}catch(t){N(t)}var t})()}catch(t){N(t)}})(()=>I(t,performance.now()))},e)
|
|
730
|
-
return $[t]={id:i,
|
|
738
|
+
return $[t]={id:i,zr:e},0},Wr(t){var e=v.length,i=2147483648
|
|
731
739
|
if((t>>>=0)>i)return!1
|
|
732
740
|
for(var s=1;4>=s;s*=2){var n=e*(1+.2/s),r=Math.min(i,R(Math.max(t,n=Math.min(n,t+100663296)),65536))
|
|
733
|
-
if(j(r))return!0}return!1},
|
|
734
|
-
T=null,t()}})(),K}E++,n.
|
|
735
|
-
var e,r={u:Y,
|
|
736
|
-
return n.
|
|
741
|
+
if(j(r))return!0}return!1},Hr:P},K=await(async()=>{function t(t){return n.Dr=K=t.exports,n.Nr=m=K.memory,i(),L=K.Vr,(t=>{n.qr=t.Jr,n.Yr=t.Kr,n.Xr=t.Qr,n.Zr=t.eo,n.io=t.so,n.no=t.ro,n.oo=t.ho,n.ao=t.co,n.lo=t.uo,n.fo=t.do,n.yo=t.po,n.wo=t.mo,n.vo=t.xo,n.So=t.bo,n._o=t.Eo,n.To=t.Ao,n.Lo=t.Mo,n.Io=t.Go,n.Oo=t.Fo,n.ko=t.Co,n.Bo=t.Uo,n.$o=t.No,n.Do=t.Po,n.Ro=t.jo,n.zo=t.Wo,n.Ho=t.Vo,n.qo=t.Jo,n.Yo=t.Ko,n.Xo=t.Cn,n.Qo=t.Bn,n.Zo=t.Un,n.th=t.$n,n.eh=t.Nn,n.ih=t.kn,n.sh=t.Pn,n.nh=t.rh,n.oh=t.hh,n.ah=t.uh,n.fh=t.dh,n.yh=t.ph,n.wh=t.Sr,n.mh=t.gh,n.xh=t.Sh,n.bh=t._h,n.Eh=t.Th,n.Ah=t.Lh,n.Mh=t.Ih,n.Gh=t.Oh,n.Fh=t.kh,n.Ch=t.Bh,n.Uh=t.$h,n.Nh=t.Dh,I=t.Ph})(K),(()=>{if(E--,n.Rh?.(E),0==E&&T){var t=T
|
|
742
|
+
T=null,t()}})(),K}E++,n.Rh?.(E)
|
|
743
|
+
var e,r={u:Y,jh:Y}
|
|
744
|
+
return n.zh?new Promise(e=>{n.zh(r,i=>{e(t(i))})}):(g??=(e="hb.wasm",n.Wh?n.Wh(e,u):u+e),t((await(async function(t,e,i){if(!t&&!b(e)&&!h)try{var n=fetch(e,{credentials:"same-origin"})
|
|
737
745
|
return await WebAssembly.instantiateStreaming(n,i)}catch(t){x("wasm streaming compile failed: "+t),x("falling back to ArrayBuffer instantiation")}return(async(t,e)=>{try{var i=await(async t=>{if(!d)try{var e=await c(t)
|
|
738
746
|
return new Uint8Array(e)}catch{}return(t=>{if(t==g&&d)return new Uint8Array(d)
|
|
739
747
|
if(l)return l(t)
|
|
740
748
|
throw"both async and sync fetching of the wasm failed"})(t)})(t)
|
|
741
|
-
return await WebAssembly.instantiate(i,e)}catch(t){x("failed to asynchronously prepare wasm: "+t),s(t)}})(e,i)})(d,g,r)).
|
|
742
|
-
return(()=>{if(n.
|
|
743
|
-
G(O)})())}E>0?T=t:((()=>{if(n.
|
|
749
|
+
return await WebAssembly.instantiate(i,e)}catch(t){x("failed to asynchronously prepare wasm: "+t),s(t)}})(e,i)})(d,g,r)).Hh))})()
|
|
750
|
+
return(()=>{if(n.Vh)for("function"==typeof n.Vh&&(n.Vh=[n.Vh]);n.Vh.length>0;)n.Vh.shift()()})(),(function t(){function e(){n.qh=!0,S||(_=!0,K.Jh(),p?.(n),n.Yh?.(),(()=>{if(n.Kh)for("function"==typeof n.Kh&&(n.Kh=[n.Kh]);n.Kh.length;)F(n.Kh.shift())
|
|
751
|
+
G(O)})())}E>0?T=t:((()=>{if(n.Xh)for("function"==typeof n.Xh&&(n.Xh=[n.Xh]);n.Xh.length;)C(n.Xh.shift())
|
|
744
752
|
G(k)})(),E>0?T=t:n.setStatus?(n.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>n.setStatus(""),1),e()},1)):e())})(),_?n:new Promise((t,e)=>{p=t,w=e})})
|
|
745
753
|
t.exports=i,t.exports.default=i})(lt)
|
|
746
754
|
var ft=o(lt.exports),dt={exports:{}}
|
|
747
|
-
try{dt.exports=t=>{function e(t){return(255&t.charCodeAt(0))<<24|(255&t.charCodeAt(1))<<16|(255&t.charCodeAt(2))<<8|255&t.charCodeAt(3)}function i(e){var i=n.
|
|
755
|
+
try{dt.exports=t=>{function e(t){return(255&t.charCodeAt(0))<<24|(255&t.charCodeAt(1))<<16|(255&t.charCodeAt(2))<<8|255&t.charCodeAt(3)}function i(e){var i=n.Jo(e.length+1)
|
|
748
756
|
for(let s=0;e.length>s;++s){const n=e.charCodeAt(s)
|
|
749
757
|
if(n>127)throw Error("Expected ASCII text")
|
|
750
|
-
t.HEAPU8[i+s]=n}return t.HEAPU8[i+e.length]=0,{
|
|
751
|
-
s&&(s=s.split(","),r=n.
|
|
752
|
-
n.
|
|
753
|
-
let o=t.
|
|
754
|
-
var a=o(t=>{n.
|
|
755
|
-
return{je(e){var i=n.
|
|
758
|
+
t.HEAPU8[i+s]=n}return t.HEAPU8[i+e.length]=0,{br:i,length:e.length,Ko(){n.Ko(i)}}}function s(t,e,s){var r=0,o=0
|
|
759
|
+
s&&(s=s.split(","),r=n.Jo(16*s.length),s.forEach(t=>{var e=i(t)
|
|
760
|
+
n.Vo(e.br,-1,r+16*o)&&o++,e.Ko()})),n.Dh(t.br,e.br,r,o),r&&n.Ko(r)}var n=t.Dr,r=new TextDecoder("utf8")
|
|
761
|
+
let o=t.Fn,h=t.Rn
|
|
762
|
+
var a=o(t=>{n.Ko(t)},"vi"),c=e("JSON"),l="",u=n.Jo(256)
|
|
763
|
+
return{je(e){var i=n.Jo(e.byteLength)
|
|
756
764
|
t.HEAPU8.set(new Uint8Array(e),i)
|
|
757
|
-
var s=n.
|
|
758
|
-
return{
|
|
759
|
-
const o=n.
|
|
760
|
-
return{
|
|
761
|
-
if(o){var h=n.
|
|
762
|
-
return t.HEAPU8.subarray(h,h+o)}},Ve(){var e=n.
|
|
763
|
-
t.HEAPU32[i/4]=64,n.
|
|
765
|
+
var s=n.Jr(i,e.byteLength,2,i,a)
|
|
766
|
+
return{br:s,destroy(){n.Kr(s)}}},ze(i,s){var r=n.rh(i.br,s)
|
|
767
|
+
const o=n.dh(r)
|
|
768
|
+
return{br:r,upem:o,Qh(i){var s=n.uh(r,e(i)),o=n.Qr(s)
|
|
769
|
+
if(o){var h=n.eo(s,null)
|
|
770
|
+
return t.HEAPU8.subarray(h,h+o)}},Ve(){var e=n.Jo(2048),i=n.Jo(4)
|
|
771
|
+
t.HEAPU32[i/4]=64,n.kh(r,0,i,e)
|
|
764
772
|
var s={}
|
|
765
773
|
return Array.from({length:t.HEAPU32[i/4]}).forEach((i,n)=>{var r
|
|
766
|
-
s[(r=t.HEAPU32[e/4+8*n+1],""+String.fromCharCode(r>>24&255)+String.fromCharCode(r>>16&255)+String.fromCharCode(r>>8&255)+String.fromCharCode(255&r))]={min:t.HEAPF32[e/4+8*n+4],default:t.HEAPF32[e/4+8*n+5],max:t.HEAPF32[e/4+8*n+6]}}),n.
|
|
767
|
-
n.
|
|
768
|
-
var i=(e=>{const i=n.
|
|
769
|
-
return t.HEAPU32.set(o,r),n
|
|
770
|
-
return n.
|
|
771
|
-
return{
|
|
774
|
+
s[(r=t.HEAPU32[e/4+8*n+1],""+String.fromCharCode(r>>24&255)+String.fromCharCode(r>>16&255)+String.fromCharCode(r>>8&255)+String.fromCharCode(255&r))]={min:t.HEAPF32[e/4+8*n+4],default:t.HEAPF32[e/4+8*n+5],max:t.HEAPF32[e/4+8*n+6]}}),n.Ko(i),n.Ko(e),s},Zh(){var e=n.Ih()
|
|
775
|
+
n.ph(r,e)
|
|
776
|
+
var i=(e=>{const i=n.Bh(e),s=n.Jo(i<<2),r=s>>2,o=t.HEAPU32.subarray(r,r+i)
|
|
777
|
+
return t.HEAPU32.set(o,r),n.$h(e,-1,s,i),o})(e)
|
|
778
|
+
return n.Oh(e),i},destroy(){n.hh(r)}}},We(i){function s(t){return c||(f=o((t,e,i,s,n)=>{l+=`M${s},${n}`},"viiiffi"),d=o((t,e,i,s,n)=>{l+=`L${s},${n}`},"viiiffi"),y=o((t,e,i,s,n,r,o,h,a)=>{l+=`C${s},${n} ${r},${o} ${h},${a}`},"viiiffffffi"),p=o((t,e,i,s,n,r,o)=>{l+=`Q${s},${n} ${r},${o}`},"viiiffffi"),w=o(()=>{l+="Z"},"viiii"),c=n.kn(),n.Cn(c,f,0,0),n.Bn(c,d,0,0),n.$n(c,y,0,0),n.Un(c,p,0,0),n.Nn(c,w,0,0)),l="",n.Sr(a,t,c,0),l}var a=n.Sh(i.br),c=null,f=null,d=null,y=null,p=null,w=null
|
|
779
|
+
return{br:a,ta(e){n.gh(a,e,u,256)
|
|
772
780
|
var i=t.HEAPU8.subarray(u,u+256)
|
|
773
|
-
return r.decode(i.slice(0,i.indexOf(0)))},
|
|
774
|
-
return{type:e[0],values:e.slice(1).filter(t=>t.length).map(t=>+t)}}),setScale(t,e){n.
|
|
775
|
-
s.forEach((i,s)=>{t.HEAPU32[r/4+2*s+0]=e(i[0]),t.HEAPF32[r/4+2*s+1]=i[1]}),n.
|
|
776
|
-
return{
|
|
781
|
+
return r.decode(i.slice(0,i.indexOf(0)))},ea:s,ia:t=>s(t).replace(/([MLQCZ])/g,"|$1 ").split("|").filter(t=>t.length).map(t=>{var e=t.split(/[ ,]/g)
|
|
782
|
+
return{type:e[0],values:e.slice(1).filter(t=>t.length).map(t=>+t)}}),setScale(t,e){n.Lh(a,t,e)},He(i){var s=Object.entries(i),r=n.Jo(8*s.length)
|
|
783
|
+
s.forEach((i,s)=>{t.HEAPU32[r/4+2*s+0]=e(i[0]),t.HEAPF32[r/4+2*s+1]=i[1]}),n._h(a,r,s.length),n.Ko(r)},destroy(){n.Th(a),c&&(n.Pn(c),c=null,h(f),h(d),h(y),h(p),h(w))}}},createBuffer(){var e=n.ro()
|
|
784
|
+
return{br:e,oe(i){const s=(e=>{const i=n.Jo(2*e.length),s=new Uint16Array(t.Nr.buffer,i,e.length)
|
|
777
785
|
for(let t=0;s.length>t;++t)s[t]=e.charCodeAt(t)
|
|
778
|
-
return{
|
|
779
|
-
n.
|
|
780
|
-
t.forEach(t=>{i|=(t=>"BOT"==t?1:"EOT"==t?2:"PRESERVE_DEFAULT_IGNORABLES"==t?4:"REMOVE_DEFAULT_IGNORABLES"==t?8:"DO_NOT_INSERT_DOTTED_CIRCLE"==t?16:"PRODUCE_UNSAFE_TO_CONCAT"==t?64:0)(t)}),n.
|
|
781
|
-
n.
|
|
782
|
-
n.
|
|
783
|
-
return s},destroy(){n.
|
|
784
|
-
return o.startsWith("start table GSUB")?d=1:o.startsWith("start table GPOS")&&(d=2),d!=u&&(y=!1),0!=u&&d==u&&o.startsWith("end lookup "+l)&&(y=!0),y?0:(n.
|
|
785
|
-
return n.
|
|
786
|
-
n.
|
|
787
|
-
var i={
|
|
788
|
-
return n.
|
|
786
|
+
return{br:i,length:s.length,Ko(){n.Ko(i)}}})(i)
|
|
787
|
+
n.Co(e,s.br,s.length,0,s.length),s.Ko()},he:()=>n.Go(e),Ir(t){n.uo(e,{sa:4,na:5,ra:6,oa:7}[t]||0)},ha(t){var i=0
|
|
788
|
+
t.forEach(t=>{i|=(t=>"BOT"==t?1:"EOT"==t?2:"PRESERVE_DEFAULT_IGNORABLES"==t?4:"REMOVE_DEFAULT_IGNORABLES"==t?8:"DO_NOT_INSERT_DOTTED_CIRCLE"==t?16:"PRODUCE_UNSAFE_TO_CONCAT"==t?64:0)(t)}),n.mo(e,i)},aa(t){var s=i(t)
|
|
789
|
+
n.po(e,n.No(s.br,-1)),s.Ko()},ca(t){var s=i(t)
|
|
790
|
+
n.do(e,n.Po(s.br,-1)),s.Ko()},la(t){n.xo(e,t)},json(){for(var i=n.bo(e),s=[],r=n.Eo(e,0),o=r/4,h=n.Ao(e,0)/4,a=t.HEAPU32.subarray(o,o+5*i),c=t.HEAP32.subarray(h,h+5*i),l=0;i>l;++l)s.push({g:a[5*l+0],ce:a[5*l+2],ax:c[5*l+0],ay:c[5*l+1],dx:c[5*l+2],dy:c[5*l+3],flags:n.Mo(r+20*l)})
|
|
791
|
+
return s},destroy(){n.ho(e)}}},shape:s,ua(e,i,a,l,u){var f=[],d=0,y=!1,p=1048576,w=n.Jo(p),m=o((e,i,s)=>{var o=r.decode(t.HEAPU8.subarray(s,t.HEAPU8.indexOf(0,s)))
|
|
792
|
+
return o.startsWith("start table GSUB")?d=1:o.startsWith("start table GPOS")&&(d=2),d!=u&&(y=!1),0!=u&&d==u&&o.startsWith("end lookup "+l)&&(y=!0),y?0:(n.so(e,0,n.bo(e),w,p,0,i,c,4),f.push({Ii:o,ki:JSON.parse(r.decode(t.HEAPU8.subarray(w,t.HEAPU8.indexOf(0,w)))),glyphs:2==n.co(e)}),1)},"iiiii")
|
|
793
|
+
return n.Uo(i.br,m,0,0),s(e,i,a),n.Ko(w),h(m),f},version(){var e=n.Jo(12)
|
|
794
|
+
n.jo(e,e+4,e+8)
|
|
795
|
+
var i={fa:t.HEAPU32[e/4],da:t.HEAPU32[(e+4)/4],ya:t.HEAPU32[(e+8)/4]}
|
|
796
|
+
return n.Ko(e),i},pa(){var e=n.Wo()
|
|
789
797
|
return r.decode(t.HEAPU8.subarray(e,t.HEAPU8.indexOf(0,e)))}}}}catch(t){}var yt=o(dt.exports)
|
|
790
798
|
let pt=null,wt=null,mt=null
|
|
791
|
-
const vt={
|
|
792
|
-
if(mt)e
|
|
799
|
+
const vt={wa(t){wt=t,mt=null,pt=null},ma(t){mt=t,wt=null,pt=null},va:async()=>pt||(pt=new Promise(async(t,e)=>{try{const e={}
|
|
800
|
+
if(mt)e.$r=mt
|
|
793
801
|
else{if(!wt)throw Error("HarfBuzz WASM path or buffer must be set before initialization.")
|
|
794
|
-
e.
|
|
795
|
-
t({hb:yt(i),module:{
|
|
796
|
-
class gt{constructor(t,e){this.text=t,this.
|
|
797
|
-
e.push(t),this.
|
|
798
|
-
return t.
|
|
802
|
+
e.Wh=(t,e)=>t.endsWith(".wasm")?wt:e+t}const i=await ft(e)
|
|
803
|
+
t({hb:yt(i),module:{Fn:i.Fn,exports:i.Dr,Rn:i.Rn}})}catch(t){e(Error("Failed to initialize HarfBuzz: "+t))}}),pt)}
|
|
804
|
+
class gt{constructor(t,e){this.text=t,this.ga=new Map,e.forEach(t=>{const e=this.ga.get(t.mr)||[]
|
|
805
|
+
e.push(t),this.ga.set(t.mr,e)})}xa(t){const e=[]
|
|
806
|
+
return t.Sa&&e.push(...this.ba(t.Sa)),t._a&&e.push(...this.Ea(t._a)),e}ba(t){const e=[]
|
|
799
807
|
for(const i of t){let t=0
|
|
800
|
-
for(;-1!==(t=this.text.indexOf(i,t));)e.push(this.createTextRange(t,t+i.length,i)),t+=i.length}return e}
|
|
808
|
+
for(;-1!==(t=this.text.indexOf(i,t));)e.push(this.createTextRange(t,t+i.length,i)),t+=i.length}return e}Ea(t){return t.map(t=>{const e=this.text.slice(t.start,t.end)
|
|
801
809
|
return this.createTextRange(t.start,t.end,e)})}createTextRange(t,e,i){const s=[],n=new Map
|
|
802
|
-
for(let i=t;e>i;i++){const t=this.
|
|
810
|
+
for(let i=t;e>i;i++){const t=this.ga.get(i)
|
|
803
811
|
if(t)for(const e of t){s.push(e)
|
|
804
|
-
const t=n.get(e.
|
|
805
|
-
t.push(e),n.set(e.
|
|
812
|
+
const t=n.get(e.vr)||[]
|
|
813
|
+
t.push(e),n.set(e.vr,t)}}return{start:t,end:e,Ta:i,bounds:Array.from(n.values()).map(t=>this.Aa(t)),glyphs:s,La:Array.from(n.keys()).sort((t,e)=>t-e)}}Aa(t){if(0===t.length)return{min:{x:0,y:0,z:0},max:{x:0,y:0,z:0}}
|
|
806
814
|
let e=1/0,i=1/0,s=1/0,n=-1/0,r=-1/0,o=-1/0
|
|
807
815
|
for(const h of t)e>h.bounds.min.x&&(e=h.bounds.min.x),i>h.bounds.min.y&&(i=h.bounds.min.y),s>h.bounds.min.z&&(s=h.bounds.min.z),h.bounds.max.x>n&&(n=h.bounds.max.x),h.bounds.max.y>r&&(r=h.bounds.max.y),h.bounds.max.z>o&&(o=h.bounds.max.z)
|
|
808
|
-
return{min:{x:e,y:i,z:s},max:{x:n,y:r,z:o}}}}class xt{static{this.
|
|
809
|
-
xt.
|
|
810
|
-
const e=await xt.
|
|
811
|
-
i.
|
|
812
|
-
const s=await i.
|
|
816
|
+
return{min:{x:e,y:i,z:s},max:{x:n,y:r,z:o}}}}class xt{static{this.Ma=new Map}static{this.Ia=null}static{this.Ga=new Map}static{this.Oa=0}static{this.Fa=1/0}static{this.ka=0}static Ca(t){return Object.keys(t).sort().map(e=>`${e}:${t[e]}`).join(",")}constructor(){this.Ba="",xt.Ia||(xt.Ia=vt.va()),this.Ua=new $(()=>xt.Ia)}static $a(t){vt.wa(t),xt.Ia=null}static Na(t){vt.ma(t),xt.Ia=null}static init(){return xt.Ia||(xt.Ia=vt.va()),xt.Ia}static async create(t){if(!t.font)throw Error("Font is required. Specify options.font as a URL string or ArrayBuffer.")
|
|
817
|
+
xt.Ia||(xt.Ia=vt.va())
|
|
818
|
+
const e=await xt.Da(t),i=new xt
|
|
819
|
+
i.Pa(e)
|
|
820
|
+
const s=await i.Ra(t),n=async e=>{const s={...t}
|
|
813
821
|
for(const t in e){const i=e[t]
|
|
814
|
-
void 0!==i&&(s[t]=i)}if(void 0!==e.font||void 0!==e.qe||void 0!==e.ae){const t=await xt.
|
|
815
|
-
i.
|
|
816
|
-
return{...s,getLoadedFont(){return i.getLoadedFont()},getCacheStatistics(){return i.getCacheStatistics()},clearCache(){return i.clearCache()},measureTextWidth(t,e){return i.measureTextWidth(t,e)},update:n}}static async
|
|
817
|
-
t.qe&&(e+="_var_"+xt.
|
|
818
|
-
let i=xt.
|
|
819
|
-
return i||(i=await xt.
|
|
822
|
+
void 0!==i&&(s[t]=i)}if(void 0!==e.font||void 0!==e.qe||void 0!==e.ae){const t=await xt.Da(s)
|
|
823
|
+
i.Pa(t),i.ja()}return t=s,{...await i.Ra(t),getLoadedFont(){return i.getLoadedFont()},getCacheStatistics(){return i.getCacheStatistics()},clearCache(){return i.clearCache()},measureTextWidth(t,e){return i.measureTextWidth(t,e)},update:n}}
|
|
824
|
+
return{...s,getLoadedFont(){return i.getLoadedFont()},getCacheStatistics(){return i.getCacheStatistics()},clearCache(){return i.clearCache()},measureTextWidth(t,e){return i.measureTextWidth(t,e)},update:n}}static async Da(t){let e="string"==typeof t.font?t.font:"buffer-"+xt.za(t.font)
|
|
825
|
+
t.qe&&(e+="_var_"+xt.Ca(t.qe)),t.ae&&(e+="_feat_"+xt.Ca(t.ae))
|
|
826
|
+
let i=xt.Ga.get(e)
|
|
827
|
+
return i||(i=await xt.Wa(e,t.font,t.qe,t.ae)),i}static async Wa(t,e,i,s){const n=new xt
|
|
820
828
|
await n.Re(e,i,s)
|
|
821
829
|
const r=n.getLoadedFont()
|
|
822
|
-
return xt.
|
|
823
|
-
e&&(xt.
|
|
830
|
+
return xt.Ga.set(t,r),xt.Ha(r),xt.Va(),r}static Ha(t){xt.Oa+=t.Qe?.byteLength??0}static qa(t){const e=xt.Ga.get(t)
|
|
831
|
+
e&&(xt.Oa-=e.Qe?.byteLength??0,0>xt.Oa&&(xt.Oa=0))}static Va(){if(xt.Fa!==1/0)for(;xt.Oa>xt.Fa&&xt.Ga.size>0;){const t=xt.Ga.keys().next().value
|
|
824
832
|
if(void 0===t)break
|
|
825
|
-
xt.
|
|
833
|
+
xt.qa(t),xt.Ga.delete(t)}}static za(t){if(t){const e=new Uint8Array(t)
|
|
826
834
|
let i=2166136261
|
|
827
835
|
const s=Math.min(32,e.length),n=Math.floor(e.length/s)
|
|
828
836
|
for(let t=0;s>t;t++)i^=e[t*n],i=Math.imul(i,16777619)
|
|
829
|
-
return i^=e.length,i=Math.imul(i,16777619),(i>>>0).toString(36)}return"c"+ ++xt.
|
|
830
|
-
const e=xt.
|
|
831
|
-
this.
|
|
837
|
+
return i^=e.length,i=Math.imul(i,16777619),(i>>>0).toString(36)}return"c"+ ++xt.ka}Pa(t){this.le=t
|
|
838
|
+
const e=xt.za(t.Qe)
|
|
839
|
+
this.Ba="font_"+e,t.qe&&(this.Ba+="_var_"+xt.Ca(t.qe)),t.ae&&(this.Ba+="_feat_"+xt.Ca(t.ae))}async Re(t,e,i){xt.Ia||(xt.Ia=vt.va()),await xt.Ia
|
|
832
840
|
const s="string"==typeof t?await fetch(t).then(e=>{if(!e.ok)throw Error(`Failed to load font from ${t}: HTTP ${e.status} ${e.statusText}`)
|
|
833
841
|
return e.arrayBuffer()}):t
|
|
834
|
-
try{this.le&&this.destroy(),this.le=await this.
|
|
835
|
-
const t=xt.
|
|
836
|
-
this.
|
|
837
|
-
const e=await this.
|
|
838
|
-
if(this.
|
|
839
|
-
this.
|
|
840
|
-
const i=this.
|
|
842
|
+
try{this.le&&this.destroy(),this.le=await this.Ua.Re(s,e),i&&(this.le.ae=i)
|
|
843
|
+
const t=xt.za(s)
|
|
844
|
+
this.Ba="font_"+t,e&&(this.Ba+="_var_"+xt.Ca(e)),i&&(this.Ba+="_feat_"+xt.Ca(i))}catch(t){throw l.error("Failed to load font:",t),t}}async Ra(t){try{if(!this.le)throw Error("Font not loaded. Use Text.create() with a font option.")
|
|
845
|
+
const e=await this.Ja(t)
|
|
846
|
+
if(this.Ya(e),this.Ka(t=e),!this.Ar){const e=t.Xa?r(t.Xa):z
|
|
847
|
+
this.Ar=new at(e,this.le),this.Ar.Zn(this.Ba)}this.Ar.Ps(t.Qa),this.Ar.Sn(t.Za),this.le.font.setScale(this.le.upem,this.le.upem),this.tc||(this.tc=new ct(this.le,this.Ar))
|
|
848
|
+
const i=this.ec(t),s=t.sc??this.le.Je??!1,n=this.tc.Lr(i.lines,i.nc,i.letterSpacing,i.align,i.direction,t.color,t.text)
|
|
841
849
|
let o
|
|
842
|
-
if(t.color&&"object"==typeof t.color&&!Array.isArray(t.color)&&(t.color.
|
|
850
|
+
if(t.color&&"object"==typeof t.color&&!Array.isArray(t.color)&&(t.color.Sa||t.color._a)){if(o=new Set,t.color.Sa)for(const e of Object.keys(t.color.Sa)){let i=0
|
|
843
851
|
for(;-1!==(i=t.text.indexOf(e,i));){for(let t=i;i+e.length>t;t++)o.add(t)
|
|
844
|
-
i+=e.length}}if(t.color.
|
|
845
|
-
if(t.
|
|
846
|
-
c.glyphAttributes=t}return c}finally{}}async
|
|
847
|
-
if(!t.layout?.St?.[e])try{if(!xt.
|
|
848
|
-
xt.
|
|
849
|
-
const e=t.
|
|
850
|
-
if(t.text.length>e)throw Error(`Text exceeds ${e} character limit`)}
|
|
852
|
+
i+=e.length}}if(t.color._a)for(const e of t.color._a)for(let t=e.start;e.end>t;t++)o.add(t)}const h=this.Ar.er(n,i.depth,s,this.le.p.Te,t.rc||!1,o),a=this.Ar.Er(),c=this.oc(h.vertices,h.normals,h.indices,h.wr,h.planeBounds,t,a,t.text)
|
|
853
|
+
if(t.rc){const t=this.hc(c.vertices.length/3,c.glyphs)
|
|
854
|
+
c.glyphAttributes=t}return c}finally{}}async Ja(t){if(!1!==t.layout?.vt&&t.layout?.width){const e=t.layout?.language||"en-us"
|
|
855
|
+
if(!t.layout?.St?.[e])try{if(!xt.Ma.has(e)){const s=await i(e,t.layout?.ac)
|
|
856
|
+
xt.Ma.set(e,s)}return{...t,layout:{...t.layout,St:{...t.layout?.St,[e]:xt.Ma.get(e)}}}}catch(i){return l.warn(`Failed to load patterns for ${e}: ${i}`),{...t,layout:{...t.layout,vt:!1}}}}return t}Ya(t){if(!t.text)throw Error("Text content is required")
|
|
857
|
+
const e=t.cc??1e5
|
|
858
|
+
if(t.text.length>e)throw Error(`Text exceeds ${e} character limit`)}Ka(t){t.qe&&this.le&&xt.Ca(t.qe)!==xt.Ca(this.le.qe||{})&&(this.le.font.He(t.qe),this.le.qe=t.qe)}ec(t){if(!this.le)throw Error("Font not loaded. Use Text.create() with a font option")
|
|
851
859
|
const{text:e,size:i=72,depth:s=0,lineHeight:n=1,letterSpacing:r=0,layout:o={}}=t,{width:h,direction:a="ltr",align:c=("rtl"===a?"right":"left"),gt:l=!0,vt:y=!0,language:p="en-us",_t:w=u,Et:m=f,Tt:v=d,At:g,St:x,Lt:S,Mt:b,It:_,Gt:E,Ot:T,Ft:A,kt:L,Ct:M,Bt:I,Ut:G}=o
|
|
852
860
|
let F
|
|
853
861
|
void 0!==h&&(F=h*(this.le.upem/i))
|
|
854
862
|
const k=s*(this.le.upem/i),C=k>0?Math.max(k,25e-6*this.le.upem):0
|
|
855
|
-
this.
|
|
856
|
-
const U=this.
|
|
857
|
-
return{lines:U.lines,
|
|
863
|
+
this.lc||(this.lc=new O(this.le))
|
|
864
|
+
const U=this.lc.ue({text:e,width:F,align:c,direction:a,vt:y,language:p,gt:l,_t:w,Et:m,Tt:v,At:g,St:x,Lt:S,Mt:b,It:_,Gt:E,Ot:T,Ft:A,kt:L,Ct:M,Bt:I,Ut:G,letterSpacing:r}),$=B.ke(this.le.p)
|
|
865
|
+
return{lines:U.lines,nc:($.we-$.me)*n,letterSpacing:r,align:c,direction:a,depth:C,size:i}}uc(t,e,i,s){const n=t.length/3,r=new Float32Array(3*n),o=[]
|
|
858
866
|
if(Array.isArray(i)){for(let t=0;n>t;t++){const e=3*t
|
|
859
|
-
r[e]=i[0],r[e+1]=i[1],r[e+2]=i[2]}o.push({start:0,end:s.length,
|
|
867
|
+
r[e]=i[0],r[e+1]=i[1],r[e+2]=i[2]}o.push({start:0,end:s.length,Ta:s,color:i,bounds:[],glyphs:e,La:[...new Set(e.map(t=>t.vr))]})}else{const t=i.default||[1,1,1]
|
|
860
868
|
for(let e=0;r.length>e;e+=3)r[e]=t[0],r[e+1]=t[1],r[e+2]=t[2]
|
|
861
|
-
i.
|
|
862
|
-
e&&(t.glyphs.forEach(t=>{for(let i=0;t.
|
|
863
|
-
s>=0&&r.length>s&&(r[s]=e[0],r[s+1]=e[1],r[s+2]=e[2])}}),o.push({start:t.start,end:t.end,
|
|
864
|
-
for(const s of e)if(s.
|
|
865
|
-
for(let e=0;s.
|
|
866
|
-
i>=0&&r.length>i&&(r[i]=t.color[0],r[i+1]=t.color[1],r[i+2]=t.color[2])}}o.push({start:t.start,end:t.end,
|
|
867
|
-
this.
|
|
868
|
-
const f=this.
|
|
869
|
+
i.Sa&&new gt(s,e).xa({Sa:Object.keys(i.Sa)}).forEach(t=>{const e=i.Sa[t.Ta]
|
|
870
|
+
e&&(t.glyphs.forEach(t=>{for(let i=0;t.gr>i;i++){const s=3*(t.nr+i)
|
|
871
|
+
s>=0&&r.length>s&&(r[s]=e[0],r[s+1]=e[1],r[s+2]=e[2])}}),o.push({start:t.start,end:t.end,Ta:t.Ta,color:e,bounds:t.bounds,glyphs:t.glyphs,La:t.La}))}),i._a&&i._a.forEach(t=>{const i=[]
|
|
872
|
+
for(const s of e)if(s.mr>=t.start&&t.end>s.mr){i.push(s)
|
|
873
|
+
for(let e=0;s.gr>e;e++){const i=3*(s.nr+e)
|
|
874
|
+
i>=0&&r.length>i&&(r[i]=t.color[0],r[i+1]=t.color[1],r[i+2]=t.color[2])}}o.push({start:t.start,end:t.end,Ta:s.slice(t.start,t.end),color:t.color,bounds:[],glyphs:i,La:[...new Set(i.map(t=>t.vr))]})})}return{colors:r,fc:o}}oc(t,e,i,s,n,r,o,h){const{layout:a={},size:c=72}=r,{width:l,align:u=("rtl"===a.direction?"right":"left")}=a
|
|
875
|
+
this.lc||(this.lc=new O(this.le))
|
|
876
|
+
const f=this.lc.ye({width:l,align:u,planeBounds:n}),d=f.offset
|
|
869
877
|
n.min.x=f.de.min.x,n.max.x=f.de.max.x
|
|
870
878
|
const y=c/this.le.upem,p=d*y
|
|
871
879
|
if(0===p)for(let e=0;t.length>e;e++)t[e]*=y
|
|
@@ -873,15 +881,15 @@ else for(let e=0;t.length>e;e+=3)t[e]=t[e]*y+p,t[e+1]*=y,t[e+2]*=y
|
|
|
873
881
|
n.min.x*=y,n.min.y*=y,n.min.z*=y,n.max.x*=y,n.max.y*=y,n.max.z*=y
|
|
874
882
|
for(let t=0;s.length>t;t++){const e=s[t]
|
|
875
883
|
e.bounds.min.x=e.bounds.min.x*y+p,e.bounds.min.y*=y,e.bounds.min.z*=y,e.bounds.max.x=e.bounds.max.x*y+p,e.bounds.max.y*=y,e.bounds.max.z*=y}let w,m
|
|
876
|
-
if(r.color){const e=this.
|
|
877
|
-
w=e.colors,m=e.
|
|
878
|
-
return{vertices:t,normals:e,indices:i,colors:w,glyphs:s,planeBounds:n,stats:{
|
|
879
|
-
return new gt(h,s).
|
|
880
|
-
return B.Ce(this.le.p)}static async
|
|
881
|
-
xt.
|
|
882
|
-
return G.measureTextWidth(this.le,t,e)}getCacheStatistics(){return this.
|
|
884
|
+
if(r.color){const e=this.uc(t,s,r.color,r.text)
|
|
885
|
+
w=e.colors,m=e.fc}const v=this.Ar.bn()
|
|
886
|
+
return{vertices:t,normals:e,indices:i,colors:w,glyphs:s,planeBounds:n,stats:{dc:i.length/3,yc:t.length/3,Ls:v.Ls,Ms:v.Ms,Is:v.Is,...o||{}},query(t){if(!h)throw Error("Original text not available for querying")
|
|
887
|
+
return new gt(h,s).xa(t)},fc:m,glyphAttributes:void 0}}Ce(){if(!this.le)throw Error("Font not loaded. Call loadFont() first")
|
|
888
|
+
return B.Ce(this.le.p)}static async wc(t,e){await Promise.all(t.map(async t=>{if(!xt.Ma.has(t))try{const s=await i(t,e)
|
|
889
|
+
xt.Ma.set(t,s)}catch(e){l.warn(`Failed to pre-load patterns for ${t}: ${e}`)}}))}static mc(t,e){xt.Ma.set(t,e)}static vc(t){xt.Fa=t===1/0?1/0:1048576*Math.max(1,Math.floor(t)),xt.Va()}getLoadedFont(){return this.le}measureTextWidth(t,e=0){if(!this.le)throw Error("Font not loaded. Call loadFont() first")
|
|
890
|
+
return G.measureTextWidth(this.le,t,e)}getCacheStatistics(){return this.Ar?this.Ar.Er():null}clearCache(){this.Ar&&this.Ar.clearCache()}hc(t,e){const i=new Float32Array(3*t),s=new Float32Array(t),n=new Float32Array(t)
|
|
883
891
|
return e.forEach((e,r)=>{const o=(e.bounds.min.x+e.bounds.max.x)/2,h=(e.bounds.min.y+e.bounds.max.y)/2,a=(e.bounds.min.z+e.bounds.max.z)/2
|
|
884
|
-
for(let c=0;e.
|
|
885
|
-
t>l&&(i[3*l]=o,i[3*l+1]=h,i[3*l+2]=a,s[l]=r,n[l]=e.
|
|
892
|
+
for(let c=0;e.gr>c;c++){const l=e.nr+c
|
|
893
|
+
t>l&&(i[3*l]=o,i[3*l+1]=h,i[3*l+2]=a,s[l]=r,n[l]=e.vr)}}),{gc:i,dn:s,xc:n}}ja(){this.Ar=void 0,this.tc=void 0,this.lc=void 0}destroy(){if(!this.le)return
|
|
886
894
|
const t=this.le
|
|
887
|
-
try{$.Ze(t)}catch(t){l.warn("Error destroying HarfBuzz objects:",t)}finally{this.le=void 0,this.
|
|
895
|
+
try{$.Ze(t)}catch(t){l.warn("Error destroying HarfBuzz objects:",t)}finally{this.le=void 0,this.lc=void 0,this.tc=void 0}}}exports.DEFAULT_CURVE_FIDELITY=it,exports.FontMetadataExtractor=B,exports.Text=xt,exports.createGlyphCache=r,exports.globalGlyphCache=z
|