three-text 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +74 -21
- package/dist/index.d.ts +1 -0
- package/dist/index.js +74 -21
- package/dist/index.min.cjs +268 -257
- package/dist/index.min.js +194 -183
- package/dist/index.umd.js +74 -21
- package/dist/index.umd.min.js +67 -56
- package/dist/three/react.d.ts +1 -0
- package/dist/types/core/Text.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.min.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* three-text v0.3.
|
|
2
|
+
* three-text v0.3.3
|
|
3
3
|
* Copyright (C) 2025 Countertype LLC
|
|
4
4
|
*
|
|
5
5
|
* This program is free software: you can redistribute it and/or modify
|
|
@@ -57,16 +57,16 @@ try{return e()}finally{this.end(t)}}async T(t,e,i){if(!a)return e()
|
|
|
57
57
|
this.start(t,i)
|
|
58
58
|
try{return await e()}finally{this.end(t)}}}
|
|
59
59
|
const c=800,l=100,u=0,f=1/3
|
|
60
|
-
var d,
|
|
61
|
-
class
|
|
60
|
+
var d,y;(t=>{t[t.BOX=0]="BOX",t[t.GLUE=1]="GLUE",t[t.PENALTY=2]="PENALTY",t[t.DISCRETIONARY=3]="DISCRETIONARY"})(d||(d={})),(t=>{t[t.TIGHT=0]="TIGHT",t[t.NORMAL=1]="NORMAL",t[t.LOOSE=2]="LOOSE",t[t.VERY_LOOSE=3]="VERY_LOOSE"})(y||(y={}))
|
|
61
|
+
class p{constructor(){this.L=new Map,this.M=[],this.I=new Set}getKey(t,e){return t<<2|e}F(t){const e=this.getKey(t.position,t.G),i=this.L.get(e)
|
|
62
62
|
i&&i.O>t.O?(i.O=t.O,i.k=t.k,i.D=t.D):i||(this.L.set(e,t),this.I.add(t),t.U=this.M.length,this.M.push(t))}$(t,e){return this.L.get(this.getKey(t,e))}N(){return this.M}P(t){if(t.active&&void 0!==t.U){t.active=!1
|
|
63
63
|
const e=t.U,i=this.M.length-1
|
|
64
64
|
if(e!==i){const t=this.M[i]
|
|
65
|
-
this.M[e]=t,t.U=e}this.M.pop(),t.U=void 0}}size(){return this.I.size}}const w=50,g=50,m=1e4,v=10,x=1e4,
|
|
65
|
+
this.M[e]=t,t.U=e}this.M.pop(),t.U=void 0}}size(){return this.I.size}}const w=50,g=50,m=1e4,v=10,x=1e4,b=-1/0,S=2,_=4,E=1e4,T=.7
|
|
66
66
|
class A{static R(t,e){if(0===t)return 0
|
|
67
67
|
if(0>=e)return E
|
|
68
68
|
let i
|
|
69
|
-
return i=t>7230584?1663497>e?t:Math.floor(t/Math.floor(e/297)):Math.floor(297*t/e),i>1290?E:Math.floor((i*i*i+131072)/262144)}static W(t,e="en-us",i,n=
|
|
69
|
+
return i=t>7230584?1663497>e?t:Math.floor(t/Math.floor(e/297)):Math.floor(297*t/e),i>1290?E:Math.floor((i*i*i+131072)/262144)}static W(t,e="en-us",i,n=S,s=_){let r
|
|
70
70
|
if(!i||!i[e])return[]
|
|
71
71
|
if(r=i[e],!r)return[]
|
|
72
72
|
const o=`.${t.toLowerCase()}.`,a=Array(o.length).fill(0)
|
|
@@ -76,33 +76,33 @@ if(!e.children||!e.children[n])break
|
|
|
76
76
|
if(e=e.children[n],e.j)for(let i=0;e.j.length>i;i++){const n=t+i
|
|
77
77
|
a.length>n&&(a[n]=Math.max(a[n],e.j[i]))}}}const h=[]
|
|
78
78
|
for(let t=2;o.length-2>t;t++)a[t]%2==1&&h.push(t-1)
|
|
79
|
-
return h.filter(e=>e>=n&&t.length-e>=s)}static H(t,e,i,n=!1,s="en-us",r,o=
|
|
79
|
+
return h.filter(e=>e>=n&&t.length-e>=s)}static H(t,e,i,n=!1,s="en-us",r,o=S,a=_,h){const c=[]
|
|
80
80
|
return c.push(...this.V(t,e,i,n,s,r,o,a,h)),c.push({type:d.GLUE,width:0,stretch:1/0,q:0,text:"",Y:t.length}),c.push({type:d.PENALTY,width:0,J:-1/0,text:"",Y:t.length}),c}static K(t){const e=t.codePointAt(0)
|
|
81
81
|
return void 0!==e&&(e>=19968&&40959>=e||e>=13312&&19903>=e||e>=131072&&173791>=e||e>=173824&&177983>=e||e>=177984&&178207>=e||e>=178208&&183983>=e||e>=63744&&64255>=e||e>=12352&&12447>=e||e>=12448&&12543>=e||e>=44032&&55215>=e||e>=4352&&4607>=e||e>=12592&&12687>=e||e>=43360&&43391>=e||e>=55216&&55295>=e||e>=65440&&65500>=e)}static X(t){const e=t.charCodeAt(0)
|
|
82
82
|
return 12289===e||12290===e||65292===e||65294===e||65306===e||65307===e||65281===e||65311===e||65289===e||12305===e||65373===e||12301===e||12303===e||12297===e||12299===e||12309===e||12311===e||12313===e||12315===e||12540===e||8212===e||8230===e||8229===e}static Z(t){const e=t.charCodeAt(0)
|
|
83
83
|
return 65288===e||12304===e||65371===e||12300===e||12302===e||12296===e||12298===e||12308===e||12310===e||12312===e||12314===e}static tt(t){return this.X(t)||this.Z(t)}static et(t,e,i,n,s=0,r){const o=[],a=Array.from(t),h=i?i(t):null
|
|
84
|
-
let c,l,u,
|
|
84
|
+
let c,l,u,y=s
|
|
85
85
|
if(r)c=r.width,l=r.stretch,u=r.q
|
|
86
86
|
else{const t=e("字")
|
|
87
87
|
c=0,l=.04*t,u=.04*t}for(let t=0;a.length>t;t++){const i=a[t],n=a.length-1>t?a[t+1]:null
|
|
88
88
|
if(/\s/.test(i)){const n=h?h[t]??e(i):e(i)
|
|
89
|
-
o.push({type:d.GLUE,width:n,stretch:.5*n,q:n*f,text:i,Y:
|
|
90
|
-
continue}if(o.push({type:d.BOX,width:h?h[t]??e(i):e(i),text:i,Y:
|
|
89
|
+
o.push({type:d.GLUE,width:n,stretch:.5*n,q:n*f,text:i,Y:y}),y+=i.length
|
|
90
|
+
continue}if(o.push({type:d.BOX,width:h?h[t]??e(i):e(i),text:i,Y:y}),y+=i.length,n&&!/\s/.test(n)){let t=!0
|
|
91
91
|
this.X(n)&&(t=!1),this.Z(i)&&(t=!1)
|
|
92
92
|
const e=this.tt(i)&&this.tt(n)
|
|
93
|
-
t&&!e&&o.push({type:d.GLUE,width:c,stretch:l,q:u,text:"",Y:
|
|
94
|
-
let u,f="",d=0,
|
|
95
|
-
const w=()=>{if(0!==f.length){if("cjk"===
|
|
93
|
+
t&&!e&&o.push({type:d.GLUE,width:c,stretch:l,q:u,text:"",Y:y})}}return o}static V(t,e,i,n,s,r,o,a,h){const c=[],l=Array.from(t)
|
|
94
|
+
let u,f="",d=0,y=null,p=0
|
|
95
|
+
const w=()=>{if(0!==f.length){if("cjk"===y){const t=this.et(f,e,i,h,d,(()=>{if(!u){const t=e("字")
|
|
96
96
|
u={width:0,stretch:.04*t,q:.04*t}}return u})())
|
|
97
97
|
c.push(...t)}else{const t=this.it(f,d,e,n,s,r,o,a,h)
|
|
98
|
-
c.push(...t)}f="",
|
|
98
|
+
c.push(...t)}f="",y=null}}
|
|
99
99
|
for(let t=0;l.length>t;t++){const e=l[t],i=this.K(e)?"cjk":"word"
|
|
100
|
-
null!==
|
|
100
|
+
null!==y&&y!==i&&(w(),d=p),null===y&&(y=i,d=p),f+=e,p+=e.length}return w(),c}static it(t,e,i,n,s,r,o,a,h){const c=[],l=t.match(/\S+|\s+/g)||[]
|
|
101
101
|
let u=0
|
|
102
|
-
for(let t=0;l.length>t;t++){const
|
|
103
|
-
if(/\s+/.test(
|
|
104
|
-
c.push({type:d.GLUE,width:t,stretch:.5*t,q:t*f,text:
|
|
105
|
-
let e=
|
|
102
|
+
for(let t=0;l.length>t;t++){const y=l[t],p=e+u
|
|
103
|
+
if(/\s+/.test(y)){const t=i(y)
|
|
104
|
+
c.push({type:d.GLUE,width:t,stretch:.5*t,q:t*f,text:y,Y:p}),u+=y.length}else{const t=y.split(/(-)/)
|
|
105
|
+
let e=p
|
|
106
106
|
for(let l=0;t.length>l;l++){const u=t[l]
|
|
107
107
|
if(u)if("-"===u)c.push({type:d.DISCRETIONARY,width:i("-"),nt:"-",st:"",rt:"-",ot:i("-"),J:h?.ht??g,ct:!0,text:"-",Y:e}),e+=1
|
|
108
108
|
else{if(u.includes("")){const t=u.split("")
|
|
@@ -113,33 +113,33 @@ if(t.length>0){let n=0
|
|
|
113
113
|
for(const s of t){const t=u.substring(n,s)
|
|
114
114
|
c.push({type:d.BOX,width:i(t),text:t,Y:e+n}),c.push({type:d.DISCRETIONARY,width:0,nt:"-",st:"",rt:"",ot:i("-"),J:h?.lt??w,ct:!0,text:"",Y:e+s}),n=s}const s=u.substring(n)
|
|
115
115
|
c.push({type:d.BOX,width:i(s),text:s,Y:e+n})}else c.push({type:d.BOX,width:i(u),text:u,Y:e})}else c.push({type:d.BOX,width:i(u),text:u,Y:e})
|
|
116
|
-
e+=u.length}}u+=
|
|
116
|
+
e+=u.length}}u+=y.length}}return c}static ut(t,e,i,n){let s=0
|
|
117
117
|
for(let r=0;e.length-1>r;r++){const o=e[r]
|
|
118
118
|
let a=0
|
|
119
119
|
for(let e=s;o>e;e++)t[e].type!==d.PENALTY&&(a+=t[e].width)
|
|
120
120
|
if(a>0&&n>a/i)return!0
|
|
121
|
-
s=o+1}return!1}static ft(t){const{text:e,width:i,align:n="left",direction:s="ltr",dt:r=!1,language:o="en-us",yt:a=!0,measureText:f,wt:d,gt:
|
|
121
|
+
s=o+1}return!1}static ft(t){const{text:e,width:i,align:n="left",direction:s="ltr",dt:r=!1,language:o="en-us",yt:a=!0,measureText:f,wt:d,gt:y,vt:p,letterSpacing:b=0,xt:L=c,bt:M=l,St:I=u,_t:F,Et:G=S,Tt:O=_,At:k=v,Lt:C=x,Mt:D=w,It:B=g,Ft:U=m,Gt:$=0,Ot:N=!1,kt:P=T}=t
|
|
122
122
|
if(a&&e.includes("\n")){const i=e.split("\n"),n=[]
|
|
123
123
|
let s=0
|
|
124
|
-
for(const e of i){if(0===e.length)n.push({text:"",Ct:s,Dt:s,
|
|
124
|
+
for(const e of i){if(0===e.length)n.push({text:"",Ct:s,Dt:s,Bt:0,Ut:!0,naturalWidth:0,$t:!1})
|
|
125
125
|
else{const i=A.ft({...t,text:e,yt:!1})
|
|
126
126
|
i.forEach(t=>{t.Ct+=s,t.Dt+=s}),n.push(...i)}s+=e.length+1}return n}let R=r
|
|
127
|
-
!R||
|
|
127
|
+
!R||y&&y[o]||(h.warn(`Hyphenation patterns for ${o} not available`),R=!1)
|
|
128
128
|
let W=I
|
|
129
129
|
void 0!==F&&i?W=i*F:!R&&I===u&&i&&(W=.1*i)
|
|
130
|
-
const j={Nt:k,Pt:C,Rt:
|
|
130
|
+
const j={Nt:k,Pt:C,Rt:U,lt:D,ht:B,Wt:n,vt:p,jt:p?b*p:0}
|
|
131
131
|
if(!i||i===1/0){const t=f(e)
|
|
132
|
-
return[{text:e,Ct:0,Dt:e.length-1,
|
|
132
|
+
return[{text:e,Ct:0,Dt:e.length-1,Bt:0,Ut:!0,naturalWidth:t,$t:!1}]}const z=A.H(e,f,d,!1,o,y,G,O,j)
|
|
133
133
|
if(0===z.length)return[]
|
|
134
134
|
let H=0,V=W,q=null
|
|
135
135
|
const Y=!N
|
|
136
136
|
for(;5>H;){let t=z,r=A.zt(t,i,M,$,!1,0,j)
|
|
137
|
-
if(0===r.length&&R&&(t=A.H(e,f,d,!0,o,
|
|
137
|
+
if(0===r.length&&R&&(t=A.H(e,f,d,!0,o,y,G,O,j),r=A.zt(t,i,L,$,!1,0,j)),0===r.length&&(V=W+H*i*.1,r=A.zt(t,i,L,$,!0,V,j)),0===r.length&&(r=A.zt(t,i,E,$,!0,V,j)),r.length>0){const o=A.Ht(t)
|
|
138
138
|
if(q=A.Vt(e,t,r,i,n,s,o,j),Y&&r.length>1&&A.ut(t,r,i,P)){H++
|
|
139
139
|
continue}break}break}if(q&&q.length>0)return q
|
|
140
140
|
const J=f(e)
|
|
141
|
-
return[{text:e,Ct:0,Dt:e.length-1,
|
|
142
|
-
h.F({position:0,line:0,G:
|
|
141
|
+
return[{text:e,Ct:0,Dt:e.length-1,Bt:0,qt:0,Ut:!0,naturalWidth:J,$t:!1}]}static zt(t,e,i=1/0,n=0,s=!1,r=0,o){const a=A.Ht(t),h=new p,c={value:1/0}
|
|
142
|
+
h.F({position:0,line:0,G:y.NORMAL,O:0,D:0,k:null,active:!0})
|
|
143
143
|
for(let n=0;t.length>n;n++){const l=t[n]
|
|
144
144
|
l.type===d.PENALTY&&1/0>l.J&&A.Yt(t,h,n,e,i,r,a,o,s,c),l.type===d.DISCRETIONARY&&1/0>l.J&&A.Yt(t,h,n,e,i,r,a,o,s,c),l.type===d.GLUE&&n>0&&t[n-1].type===d.BOX&&A.Yt(t,h,n,e,i,r,a,o,s,c),A.Jt(h,n,e,a.Kt)}const l=[]
|
|
145
145
|
let u=null
|
|
@@ -154,58 +154,58 @@ const t=i.line-e
|
|
|
154
154
|
r>t&&t>=n||t>r&&n>=t?(u=i,r=t,o=i.O):t===r&&o>i.O&&(u=i,o=i.O)}if(!s&&r!==n&&u)return[]}if(!u)return[]
|
|
155
155
|
for(;u&&u.position>0;)l.unshift(u.position),u=u.k
|
|
156
156
|
return l}static Yt(t,e,i,n,s=1/0,r=0,o,a,h=!1,c={value:1/0}){const l=-1/0>=(t[i].type===d.PENALTY?t[i].J:0),u=e.N()
|
|
157
|
-
for(let f=0;u.length>f;f++){const
|
|
158
|
-
if(!
|
|
159
|
-
const
|
|
160
|
-
let
|
|
157
|
+
for(let f=0;u.length>f;f++){const y=u[f]
|
|
158
|
+
if(!y.active)continue
|
|
159
|
+
const p=A.Xt(t,y.position,i,y.line,n,o,a),{ratio:w,Qt:g,stretch:m,q:v,D:x}=p
|
|
160
|
+
let S
|
|
161
161
|
if(g>0){const t=m+r
|
|
162
|
-
|
|
163
|
-
const _=h&&l&&c.value===1/0&&1===u.length&&
|
|
162
|
+
S=t>0?A.R(g,t):10001}else S=0>g?v>0?-g>v?10001:A.R(-g,v):10001:0
|
|
163
|
+
const _=h&&l&&c.value===1/0&&1===u.length&&y.active
|
|
164
164
|
if(!l&&!_&&-1>w)continue
|
|
165
|
-
const E=A.Zt(
|
|
166
|
-
if(!l&&!_&&
|
|
167
|
-
let T=0,L=0,M=(a?.Nt??0)+
|
|
165
|
+
const E=A.Zt(S,g>0)
|
|
166
|
+
if(!l&&!_&&S>s)continue
|
|
167
|
+
let T=0,L=0,M=(a?.Nt??0)+S,I=1e4>Math.abs(M)?M*M:1e8
|
|
168
168
|
const F=_,G=t[i].type===d.PENALTY||t[i].type===d.DISCRETIONARY?t[i].J:0
|
|
169
|
-
0!==G&&(G>0?I+=G*G:G>
|
|
170
|
-
const O=
|
|
169
|
+
0!==G&&(G>0?I+=G*G:G>b&&(I-=G*G)),(t[i].type===d.PENALTY&&t[i].ct||t[i].type===d.DISCRETIONARY&&t[i].ct)&&y.position>0&&(t[y.position].type===d.PENALTY&&t[y.position].ct||t[y.position].type===d.DISCRETIONARY&&t[y.position].ct)&&(T=a?.Rt??0,I+=T),Math.abs(E-y.G)>1&&(L=a?.Pt??0,I+=L),(l||F)&&(I=0)
|
|
170
|
+
const O=y.O+I
|
|
171
171
|
c.value>O&&(c.value=O)
|
|
172
172
|
let k=e.$(i,E)
|
|
173
|
-
k?k.O>O&&(k.O=O,k.k=
|
|
173
|
+
k?k.O>O&&(k.O=O,k.k=y,k.D=x):e.F({position:i,line:y.line+1,G:E,O,D:x,k:y,active:!0})}}static Xt(t,e,i,n,s,r,o){let a=0,h=0,c=0
|
|
174
174
|
if(r){a=r.te[i]-r.te[e],h=r.ee[i]-r.ee[e],c=r.ie[i]-r.ie[e]
|
|
175
175
|
for(let n=e;i>n;n++){const e=t[n]
|
|
176
176
|
e.type===d.PENALTY&&(a-=e.width)}}else for(let n=e;i>n;n++){const e=t[n]
|
|
177
177
|
e.type!==d.PENALTY&&(a+=e.width,e.type===d.GLUE&&(h+=e.stretch,c+=e.q))}i>=t.length||t[i].type!==d.PENALTY&&t[i].type!==d.DISCRETIONARY||(a+=t[i].type===d.PENALTY?t[i].width:t[i].ot),o?.jt&&0!==a&&(a-=o.jt)
|
|
178
178
|
const l=s-a
|
|
179
179
|
let u
|
|
180
|
-
return u=l>0&&h>0?l/h:0>l&&c>0?l/c:0===l?0:l>0?3:-1,{ratio:u,Qt:l,stretch:h,q:c,D:a}}static Zt(t,e){return e?t>12?t>99?
|
|
180
|
+
return u=l>0&&h>0?l/h:0>l&&c>0?l/c:0===l?0:l>0?3:-1,{ratio:u,Qt:l,stretch:h,q:c,D:a}}static Zt(t,e){return e?t>12?t>99?y.VERY_LOOSE:y.LOOSE:y.NORMAL:t>12?y.TIGHT:y.NORMAL}static Ht(t){const e=t.length+1,i=Array(e),n=Array(e),s=Array(e),r=Array(e)
|
|
181
181
|
i[0]=0,n[0]=0,s[0]=0,r[0]=0
|
|
182
182
|
for(let e=0;t.length>e;e++){const o=t[e]
|
|
183
183
|
if(i[e+1]=i[e]+o.width,o.type===d.PENALTY)n[e+1]=n[e],s[e+1]=s[e],r[e+1]=r[e]
|
|
184
184
|
else if(o.type===d.GLUE){const t=o
|
|
185
185
|
n[e+1]=n[e]+t.stretch,s[e+1]=s[e]+t.q,r[e+1]=r[e]+Math.max(0,t.width-t.q)}else n[e+1]=n[e],s[e+1]=s[e],r[e+1]=r[e]+o.width}return{te:i,ee:n,ie:s,Kt:r}}static Jt(t,e,i,n){const s=t.N()
|
|
186
186
|
for(let r=s.length-1;r>=0;r--){const o=s[r]
|
|
187
|
-
o.active&&n[e]-n[o.position]>i&&t.P(o)}}static Vt(t,e,i,n,s,r,o,a){if(0===i.length)return[{text:t,Ct:0,Dt:t.length-1,
|
|
187
|
+
o.active&&n[e]-n[o.position]>i&&t.P(o)}}static Vt(t,e,i,n,s,r,o,a){if(0===i.length)return[{text:t,Ct:0,Dt:t.length-1,Bt:0}]
|
|
188
188
|
const h=[]
|
|
189
189
|
let c=0
|
|
190
190
|
for(let t=0;i.length>t;t++){const l=i[t],u=!(e.length-1>i[i.length-1]+1)&&t===i.length-1,f=[]
|
|
191
|
-
let
|
|
191
|
+
let y=-1,p=-1,w=0
|
|
192
192
|
for(let t=c;l>t;t++){const i=e[t]
|
|
193
|
-
if((i.type!==d.PENALTY||i.text)&&(i.type!==d.DISCRETIONARY||i.rt)){if(void 0!==i.Y){(-1===
|
|
193
|
+
if((i.type!==d.PENALTY||i.text)&&(i.type!==d.DISCRETIONARY||i.rt)){if(void 0!==i.Y){(-1===y||y>i.Y)&&(y=i.Y)
|
|
194
194
|
const t=i.Y+(i.text?i.text.length:0)-1
|
|
195
|
-
t>
|
|
195
|
+
t>p&&(p=t)}i.text?f.push(i.text):i.type===d.DISCRETIONARY&&i.rt&&f.push(i.rt),w+=i.width}}const g=e[l]
|
|
196
196
|
let m=!1
|
|
197
|
-
if(e.length>l)if(g.type===d.PENALTY&&g.ct)f.push("-"),w+=g.width,m=!0,void 0!==g.Y&&(
|
|
197
|
+
if(e.length>l)if(g.type===d.PENALTY&&g.ct)f.push("-"),w+=g.width,m=!0,void 0!==g.Y&&(p=g.Y-1)
|
|
198
198
|
else if(g.type===d.DISCRETIONARY){const t=g
|
|
199
|
-
t.nt&&(f.push(t.nt),w+=t.ot,m=t.ct||!1,void 0!==g.Y&&(
|
|
199
|
+
t.nt&&(f.push(t.nt),w+=t.ot,m=t.ct||!1,void 0!==g.Y&&(p=g.Y-1))}const v=f.join("")
|
|
200
200
|
a?.jt&&0!==w&&(w-=a.jt)
|
|
201
|
-
let x=0,
|
|
202
|
-
"justify"===s&&u&&(
|
|
201
|
+
let x=0,b=0,S=s
|
|
202
|
+
"justify"===s&&u&&(S="rtl"===r?"right":"left"),"center"===S?x=(n-w)/2:"right"===S?x=n-w:"justify"!==S||u||(b=A.Xt(e,c,l,t,n,o,a).ratio),h.push({text:v,Ct:y,Dt:p,Bt:x,qt:b,Ut:!1,naturalWidth:w,$t:m}),c=l+1}if(e.length-1>c){const t=[]
|
|
203
203
|
let i=-1,o=-1,l=0
|
|
204
204
|
for(let n=c;e.length-1>n;n++){const s=e[n]
|
|
205
205
|
s.type!==d.PENALTY&&(void 0!==s.Y&&((-1===i||i>s.Y)&&(i=s.Y),s.Y>o&&(o=s.Y)),s.text&&t.push(s.text),l+=s.width)}const u=t.join("")
|
|
206
206
|
a?.jt&&0!==l&&(l-=a.jt)
|
|
207
|
-
let f=0,
|
|
208
|
-
"justify"===s&&(
|
|
207
|
+
let f=0,y=s
|
|
208
|
+
"justify"===s&&(y="rtl"===r?"right":"left"),"center"===y?f=(n-l)/2:"right"===y&&(f=n-l),h.push({text:u,Ct:i,Dt:o,Bt:f,qt:0,Ut:!0,naturalWidth:l,$t:!1}),h.length>1&&(h[h.length-2].Ut=!1),h[h.length-1].Ut=!0}else h.length>0&&(h[h.length-1].Ut=!0)
|
|
209
209
|
return h}}const L=new WeakMap
|
|
210
210
|
class M{static wt(e,i,n=0){const s=Array.from(i)
|
|
211
211
|
if(0===s.length)return[]
|
|
@@ -227,28 +227,28 @@ const r=t(e.re)
|
|
|
227
227
|
e.hb.shape(e.font,s,r)
|
|
228
228
|
const o=s.json(e.font),a=n*e.upem
|
|
229
229
|
let h=0
|
|
230
|
-
return o.forEach(t=>{h+=t.ax,0!==a&&(h+=a)}),s.destroy(),h}}class I{constructor(t){this.ae=t}he(t){const{text:e,width:i,align:n,direction:s,dt:r,language:o,yt:a,xt:h,
|
|
230
|
+
return o.forEach(t=>{h+=t.ax,0!==a&&(h+=a)}),s.destroy(),h}}class I{constructor(t){this.ae=t}he(t){const{text:e,width:i,align:n,direction:s,dt:r,language:o,yt:a,xt:h,bt:c,St:l,_t:u,gt:f,Et:d,Tt:y,At:p,Lt:w,Mt:g,It:m,Ft:v,Gt:x,Ot:b,kt:S,letterSpacing:_}=t
|
|
231
231
|
let E
|
|
232
|
-
if(i)E=A.ft({text:e,width:i,align:n,direction:s,dt:r,language:o,yt:a,xt:h,
|
|
232
|
+
if(i)E=A.ft({text:e,width:i,align:n,direction:s,dt:r,language:o,yt:a,xt:h,bt:c,St:l,_t:u,gt:f,Et:d,Tt:y,At:p,Lt:w,Mt:g,It:m,Ft:v,Gt:x,Ot:b,kt:S,vt:this.ae.upem,letterSpacing:_,measureText:t=>M.measureTextWidth(this.ae,t,_),wt:t=>M.wt(this.ae,t,_)})
|
|
233
233
|
else{const t=e.split("\n")
|
|
234
234
|
E=[]
|
|
235
235
|
let i=0
|
|
236
|
-
for(const e of t)E.push({text:e,Ct:i,Dt:0===e.length?i:i+e.length-1,
|
|
236
|
+
for(const e of t)E.push({text:e,Ct:i,Dt:0===e.length?i:i+e.length-1,Bt:0}),i+=e.length+1}return{lines:E}}ce(t,e){const{offset:i,le:n}=this.ue(e)
|
|
237
237
|
if(0!==i)for(let e=0;t.length>e;e+=3)t[e]+=i
|
|
238
238
|
return{offset:i,le:n}}ue(t){const{width:e,align:i,planeBounds:n}=t
|
|
239
239
|
let s=0
|
|
240
240
|
const r={min:{...n.min},max:{...n.max}}
|
|
241
|
-
return!e||"center"!==i&&"right"!==i||(s="center"===i?(e-(n.max.x-n.min.x))/2-n.min.x:e-n.max.x),0!==s&&(r.min.x+=s,r.max.x+=s),{offset:s,le:r}}}const F=65536,G=1330926671,O=2001684038,k=1751474532,C=1751672161,D=1330851634,
|
|
241
|
+
return!e||"center"!==i&&"right"!==i||(s="center"===i?(e-(n.max.x-n.min.x))/2-n.min.x:e-n.max.x),0!==s&&(r.min.x+=s,r.max.x+=s),{offset:s,le:r}}}const F=65536,G=1330926671,O=2001684038,k=1751474532,C=1751672161,D=1330851634,B=1719034226,U=1398030676,$=1851878757,N=1128678944,P=1128678962,R=1196643650,W=1196445523,j=new TextDecoder("utf-16be")
|
|
242
242
|
class z{static fe(t){if(!t||12>t.byteLength)throw Error("Invalid font buffer: too small to be a valid font file")
|
|
243
243
|
const i=new DataView(t),n=i.getUint32(0)
|
|
244
244
|
if(![F,G].includes(n))throw Error("Invalid font format. Expected TTF/OTF (or WOFF), got signature: 0x"+n.toString(16))
|
|
245
|
-
const s=e(i),r=s.has(N)||s.has(P),o=s.get(k)?.offset??0,a=s.get(C)?.offset??0,h=s.get(D)?.offset??0,c=s.get(
|
|
245
|
+
const s=e(i),r=s.has(N)||s.has(P),o=s.get(k)?.offset??0,a=s.get(C)?.offset??0,h=s.get(D)?.offset??0,c=s.get(B)?.offset??0,l=s.get(U)?.offset??0,u=s.get($)?.offset??0,f=o?i.getUint16(o+18):1e3
|
|
246
246
|
let d=null
|
|
247
|
-
a&&(d={de:i.getInt16(a+4),
|
|
248
|
-
let p=null
|
|
249
|
-
h&&(p={we:i.getInt16(h+68),ge:i.getInt16(h+70),me:i.getInt16(h+72),ve:i.getUint16(h+74),xe:i.getUint16(h+76)})
|
|
247
|
+
a&&(d={de:i.getInt16(a+4),ye:i.getInt16(a+6),pe:i.getInt16(a+8)})
|
|
250
248
|
let y=null
|
|
251
|
-
|
|
249
|
+
h&&(y={we:i.getInt16(h+68),ge:i.getInt16(h+70),me:i.getInt16(h+72),ve:i.getUint16(h+74),xe:i.getUint16(h+76)})
|
|
250
|
+
let p=null
|
|
251
|
+
return c&&l&&u&&(p=this.be(i,l,u)),{Se:r,vt:f,_e:d?.de||null,Ee:d?.ye||null,Te:d?.pe||null,we:y?.we||null,ge:y?.ge||null,me:y?.me||null,ve:y?.ve||null,xe:y?.xe||null,Ae:p}}static Le(t){const i=new DataView(t),n=e(i),s=n.get(R)?.offset??0,r=n.get(W)?.offset??0,o=n.get($)?.offset??0,a=new Set,h={}
|
|
252
252
|
try{if(s){const t=this.Me(i,s,o)
|
|
253
253
|
t.features.forEach(t=>a.add(t)),Object.assign(h,t.names)}if(r){const t=this.Me(i,r,o)
|
|
254
254
|
t.features.forEach(t=>a.add(t)),Object.assign(h,t.names)}}catch(t){return}const c=Array.from(a).sort()
|
|
@@ -257,7 +257,7 @@ for(let e=0;s>e;e++){const s=n+2+6*e,a=String.fromCharCode(t.getUint8(s),t.getUi
|
|
|
257
257
|
if(r.push(a),/^(ss\d{2}|cv\d{2})$/.test(a)&&i){const e=n+t.getUint16(s+4),r=t.getUint16(e)
|
|
258
258
|
if(0!==r){const n=e+r
|
|
259
259
|
if(0===t.getUint16(n)){const e=t.getUint16(n+2),s=this.Ie(t,i,e)
|
|
260
|
-
s&&(o[a]=s)}}}}return{features:r,names:o}}static
|
|
260
|
+
s&&(o[a]=s)}}}}return{features:r,names:o}}static be(t,e,i){try{if(1>t.getUint16(e))return null
|
|
261
261
|
const n=t.getUint16(e+4),s=t.getUint16(e+6),r=t.getUint32(e+8),o={}
|
|
262
262
|
for(let a=0;s>a;a++){const s=e+r+a*n,h=String.fromCharCode(t.getUint8(s),t.getUint8(s+1),t.getUint8(s+2),t.getUint8(s+3)),c=t.getUint16(s+4),l=this.Ie(t,i,c)
|
|
263
263
|
l&&(o[h]=l)}return Object.keys(o).length>0?o:null}catch(t){return null}}static Ie(t,e,i){try{const n=t.getUint16(e+2),s=t.getUint16(e+4)
|
|
@@ -272,19 +272,19 @@ const i=new DataView(t),n=i.getUint32(0)
|
|
|
272
272
|
if(![F,G].includes(n))throw Error("Invalid font format. Expected TTF/OTF (or WOFF), got signature: 0x"+n.toString(16))
|
|
273
273
|
const s=e(i),r=s.get($)?.offset??0,o=r?this.Ge(i,r):null
|
|
274
274
|
return{h:this.Oe(i,s,o),features:this.ke(i,s,o)}}static Ge(t,e){const i=new Map,n=t.getUint16(e+2),s=t.getUint16(e+4)
|
|
275
|
-
for(let r=0;n>r;r++){const n=e+6+12*r,o=t.getUint16(n),a=t.getUint16(n+2),h=t.getUint16(n+4),c=t.getUint16(n+6),l=t.getUint16(n+8),u=t.getUint16(n+10);(0===o||3===o&&1033===h)&&(i.has(c)||i.set(c,{offset:e+s+u,length:l,Ce:o,De:a}))}return i}static
|
|
275
|
+
for(let r=0;n>r;r++){const n=e+6+12*r,o=t.getUint16(n),a=t.getUint16(n+2),h=t.getUint16(n+4),c=t.getUint16(n+6),l=t.getUint16(n+8),u=t.getUint16(n+10);(0===o||3===o&&1033===h)&&(i.has(c)||i.set(c,{offset:e+s+u,length:l,Ce:o,De:a}))}return i}static Be(t,e,i){if(!e)return null
|
|
276
276
|
const n=e.get(i)
|
|
277
277
|
if(!n)return null
|
|
278
278
|
try{const e=new Uint8Array(t.buffer,n.offset,n.length)
|
|
279
|
-
return 0===n.Ce||3===n.Ce&&1===n.De?j.decode(e):new TextDecoder("ascii").decode(e)}catch{return null}}static Oe(t,e,i){const n=e.has(N)||e.has(P),s=e.get(k)?.offset??0,r=e.get(C)?.offset??0,o=e.get(D)?.offset??0,a=e.get(
|
|
279
|
+
return 0===n.Ce||3===n.Ce&&1===n.De?j.decode(e):new TextDecoder("ascii").decode(e)}catch{return null}}static Oe(t,e,i){const n=e.has(N)||e.has(P),s=e.get(k)?.offset??0,r=e.get(C)?.offset??0,o=e.get(D)?.offset??0,a=e.get(B)?.offset??0,h=e.get(U)?.offset??0,c=s?t.getUint16(s+18):1e3
|
|
280
280
|
let l=null
|
|
281
|
-
r&&(l={de:t.getInt16(r+4),
|
|
281
|
+
r&&(l={de:t.getInt16(r+4),ye:t.getInt16(r+6),pe:t.getInt16(r+8)})
|
|
282
282
|
let u=null
|
|
283
283
|
o&&(u={we:t.getInt16(o+68),ge:t.getInt16(o+70),me:t.getInt16(o+72),ve:t.getUint16(o+74),xe:t.getUint16(o+76)})
|
|
284
284
|
let f=null
|
|
285
|
-
return a&&h&&i&&(f=this.
|
|
285
|
+
return a&&h&&i&&(f=this.Ue(t,h,i)),{Se:n,vt:c,_e:l?.de||null,Ee:l?.ye||null,Te:l?.pe||null,we:u?.we||null,ge:u?.ge||null,me:u?.me||null,ve:u?.ve||null,xe:u?.xe||null,Ae:f}}static Ue(t,e,i){try{if(1>t.getUint16(e))return null
|
|
286
286
|
const n=t.getUint16(e+4),s=t.getUint16(e+6),r=t.getUint32(e+8),o={}
|
|
287
|
-
for(let a=0;s>a;a++){const s=e+r+a*n,h=String.fromCharCode(t.getUint8(s),t.getUint8(s+1),t.getUint8(s+2),t.getUint8(s+3)),c=t.getUint16(s+4),l=this.
|
|
287
|
+
for(let a=0;s>a;a++){const s=e+r+a*n,h=String.fromCharCode(t.getUint8(s),t.getUint8(s+1),t.getUint8(s+2),t.getUint8(s+3)),c=t.getUint16(s+4),l=this.Be(t,i,c)
|
|
288
288
|
l&&(o[h]=l)}return Object.keys(o).length>0?o:null}catch{return null}}static ke(t,e,i){const n=e.get(R)?.offset??0,s=e.get(W)?.offset??0,r=new Set,o={}
|
|
289
289
|
try{n&&this.$e(t,n,i,r,o),s&&this.$e(t,s,i,r,o)}catch{return}if(0!==r.size)return{tags:Array.from(r).sort((t,e)=>t-e).map(this.Ne),names:Object.keys(o).length>0?o:{}}}static $e(t,e,i,n,s){const r=e+t.getUint16(e+6),o=t.getUint16(r)
|
|
290
290
|
for(let e=0;o>e;e++){const o=r+2+6*e,a=t.getUint32(o)
|
|
@@ -298,9 +298,9 @@ const u=r+t.getUint16(o+4),f=t.getUint16(u)
|
|
|
298
298
|
if(0===f)continue
|
|
299
299
|
const d=u+f
|
|
300
300
|
if(0!==t.getUint16(d))continue
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
return{de:e.de,
|
|
301
|
+
const y=t.getUint16(d+2),p=this.Be(t,i,y)
|
|
302
|
+
p&&(s[String.fromCharCode(a>>24&255,a>>16&255,a>>8&255,255&a)]=p)}}static Ne(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,255&t)}static Pe(t){return null!==t.we&&null!==t.ge?{de:t.we,ye:t.ge,pe:0}:null!==t._e&&null!==t.Ee?{de:t._e,ye:t.Ee,pe:0}:null!==t.ve&&null!==t.xe?{de:t.ve,ye:-t.xe,pe:0}:{de:Math.round(.8*t.vt),ye:-Math.round(.2*t.vt),pe:0}}static Re(t){const e=z.Pe(t)
|
|
303
|
+
return{de:e.de,ye:e.ye,pe:e.pe,vt:t.vt,We:e.de-e.ye}}}class H{static je(t){if(4>t.byteLength)return"ttf/otf"
|
|
304
304
|
const e=new DataView(t).getUint32(0)
|
|
305
305
|
return e===O?"woff":2001684018===e?"woff2":"ttf/otf"}static async ze(t){const e=new DataView(t),i=new Uint8Array(t)
|
|
306
306
|
if(e.getUint32(0)!==O)throw Error("Not a valid WOFF font")
|
|
@@ -348,25 +348,25 @@ return n+s>0?(e.a-i.a)*n+(e.a-t.a)*s:0}function r(t,e){return e.a>t.a||t.a===e.a
|
|
|
348
348
|
return n+s>0?s>n?e.b-t.b+n/(n+s)*(t.b-i.b):e.b-i.b+s/(n+s)*(i.b-t.b):0}function a(t,e,i){var n=e.a-t.a,s=i.a-e.a
|
|
349
349
|
return n+s>0?(e.b-i.b)*n+(e.b-t.b)*s:0}function h(t){return i(t.b.a,t.a)}function c(t){return i(t.a,t.b.a)}function l(t,e,i,n){return(t=0>t?0:t)>(i=0>i?0:i)?n+i/(t+i)*(e-n):0===i?(e+n)/2:e+t/(t+i)*(n-e)}function u(t){var e=w(t.b)
|
|
350
350
|
return m(e,t.c),m(e.b,t.c),v(e,t.a),e}function f(t,e){var i=!1,n=!1
|
|
351
|
-
t!==e&&(e.a!==t.a&&(n=!0,
|
|
352
|
-
t.d!==t.b.d&&(i=!0,
|
|
353
|
-
return g(e,t.e),e.a=t.b.a,m(i,e.a),e.d=i.d=t.d,e=e.b,g(t.b,K(t.b)),g(t.b,e),t.b.a=e.a,e.b.a.c=e.b,e.b.d=t.b.d,e.f=t.f,e.b.f=t.b.f,e}function
|
|
354
|
-
return e.d!==t.d&&(i=!0,
|
|
355
|
-
return i.
|
|
351
|
+
t!==e&&(e.a!==t.a&&(n=!0,b(e.a,t.a)),e.d!==t.d&&(i=!0,S(e.d,t.d)),g(e,t),n||(m(e,t.a),t.a.c=t),i||(v(e,t.d),t.d.a=t))}function d(t){var e=t.b,i=!1
|
|
352
|
+
t.d!==t.b.d&&(i=!0,S(t.d,t.b.d)),t.c===t?b(t.a,null):(t.b.d.a=K(t),t.a.c=t.c,g(t,K(t)),i||v(t,t.d)),e.c===e?(b(e.a,null),S(e.d,null)):(t.d.a=K(e),e.a.c=e.c,g(e,K(e))),x(t)}function y(t){var e=w(t),i=e.b
|
|
353
|
+
return g(e,t.e),e.a=t.b.a,m(i,e.a),e.d=i.d=t.d,e=e.b,g(t.b,K(t.b)),g(t.b,e),t.b.a=e.a,e.b.a.c=e.b,e.b.d=t.b.d,e.f=t.f,e.b.f=t.b.f,e}function p(t,e){var i=!1,n=w(t),s=n.b
|
|
354
|
+
return e.d!==t.d&&(i=!0,S(e.d,t.d)),g(n,t.e),g(s,e),n.a=t.b.a,s.a=e.a,n.d=s.d=t.d,t.d.a=s,i||v(n,t.d),n}function w(t){var e=new J,i=new J,n=t.b.yi
|
|
355
|
+
return i.yi=n,n.b.yi=e,e.yi=t,t.b.yi=i,e.b=i,e.c=e,e.e=i,i.b=e,i.c=i,i.e=e}function g(t,e){var i=t.c,n=e.c
|
|
356
356
|
i.b.e=e,n.b.e=t,t.c=n,e.c=i}function m(t,e){var i=e.f,n=new Q(e,i)
|
|
357
357
|
i.e=n,e.f=n,i=n.c=t
|
|
358
358
|
do{i.a=n,i=i.c}while(i!==t)}function v(t,e){var i=e.d,n=new Y(e,i)
|
|
359
359
|
i.b=n,e.d=n,n.a=t,n.c=e.c,i=t
|
|
360
|
-
do{i.d=n,i=i.e}while(i!==t)}function x(t){var e=t.
|
|
361
|
-
e.b.
|
|
362
|
-
do{n.a=e,n=n.c}while(n!==i);(n=t.e).f=i=t.f,i.e=n}function
|
|
360
|
+
do{i.d=n,i=i.e}while(i!==t)}function x(t){var e=t.yi
|
|
361
|
+
e.b.yi=t=t.b.yi,t.b.yi=e}function b(t,e){var i=t.c,n=i
|
|
362
|
+
do{n.a=e,n=n.c}while(n!==i);(n=t.e).f=i=t.f,i.e=n}function S(t,e){var i=t.a,n=i
|
|
363
363
|
do{n.d=e,n=n.e}while(n!==i);(n=t.b).d=i=t.d,i.b=n}function _(t){var e=0
|
|
364
|
-
return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e}function E(t,e){t.f+=e.f,t.b.f+=e.b.f}function T(t,e,r){return r=r.a,(e=e.a).b.a===(t=t.a)?r.b.a===t?i(e.a,r.a)?0>=s(r.b.a,e.a,r.a):s(e.b.a,r.a,e.a)>=0:0>=s(r.b.a,t,r.a):r.b.a===t?s(e.b.a,t,e.a)>=0:(e=n(e.b.a,t,e.a))>=(t=n(r.b.a,t,r.a))}function A(t){t.a.
|
|
364
|
+
return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e}function E(t,e){t.f+=e.f,t.b.f+=e.b.f}function T(t,e,r){return r=r.a,(e=e.a).b.a===(t=t.a)?r.b.a===t?i(e.a,r.a)?0>=s(r.b.a,e.a,r.a):s(e.b.a,r.a,e.a)>=0:0>=s(r.b.a,t,r.a):r.b.a===t?s(e.b.a,t,e.a)>=0:(e=n(e.b.a,t,e.a))>=(t=n(r.b.a,t,r.a))}function A(t){t.a.pi=null
|
|
365
365
|
var e=t.e
|
|
366
|
-
e.a.c=e.c,e.c.a=e.a,t.e=null}function L(t,e){d(t.a),t.c=!1,t.a=e,e.
|
|
366
|
+
e.a.c=e.c,e.c.a=e.a,t.e=null}function L(t,e){d(t.a),t.c=!1,t.a=e,e.pi=t}function M(t){var e=t.a.a
|
|
367
367
|
do{t=ut(t)}while(t.a.a===e)
|
|
368
|
-
return t.c&&(L(t,e=
|
|
369
|
-
return n.a=i,n.e=j(t.f,e.e,n),i.
|
|
368
|
+
return t.c&&(L(t,e=p(lt(t).a.b,t.a.e)),t=ut(t)),t}function I(t,e,i){var n=new ct
|
|
369
|
+
return n.a=i,n.e=j(t.f,e.e,n),i.pi=n}function F(t,e){switch(t.s){case 100130:return!!(1&e)
|
|
370
370
|
case 100131:return 0!==e
|
|
371
371
|
case 100132:return e>0
|
|
372
372
|
case 100133:return 0>e
|
|
@@ -374,55 +374,55 @@ case 100134:return e>=2||-2>=e}return!1}function G(t){var e=t.a,i=e.d
|
|
|
374
374
|
i.c=t.d,i.a=e,A(t)}function O(t,e,i){for(t=e,e=e.a;t!==i;){t.c=!1
|
|
375
375
|
var n=lt(t),s=n.a
|
|
376
376
|
if(s.a!==e.a){if(!n.c){G(t)
|
|
377
|
-
break}L(n,s=
|
|
377
|
+
break}L(n,s=p(e.c.b,s.b))}e.c!==s&&(f(K(s),s),f(e,s)),G(t),e=n.a,t=n}return e}function k(t,e,i,n,s,r){var o=!0
|
|
378
378
|
do{I(t,e,i.b),i=i.c}while(i!==n)
|
|
379
|
-
for(null===s&&(s=lt(e).a.b.c);(i=(n=lt(e)).a.b).a===s.a;)i.c!==s&&(f(K(i),i),f(K(s),i)),n.f=e.f-i.f,n.d=F(t,n.f),e.b=!0,!o&&
|
|
379
|
+
for(null===s&&(s=lt(e).a.b.c);(i=(n=lt(e)).a.b).a===s.a;)i.c!==s&&(f(K(i),i),f(K(s),i)),n.f=e.f-i.f,n.d=F(t,n.f),e.b=!0,!o&&U(t,e)&&(E(i,s),A(e),d(s)),o=!1,e=n,s=i
|
|
380
380
|
e.b=!0,r&&N(t,e)}function C(t,e,i,n,s){var r=[e.g[0],e.g[1],e.g[2]]
|
|
381
381
|
e.d=null,e.d=t.wi&&t.wi(r,i,n,t.c)||null,null===e.d&&(s?t.n||(q(t,100156),t.n=!0):e.d=i[0])}function D(t,e,i){var n=[null,null,null,null]
|
|
382
|
-
n[0]=e.a.d,n[1]=i.a.d,C(t,e.a,n,[.5,.5,0,0],!1),f(e,i)}function
|
|
383
|
-
n[s]=.5*o/(r+o),n[a]=.5*r/(r+o),t.g[0]+=n[s]*e.g[0]+n[a]*i.g[0],t.g[1]+=n[s]*e.g[1]+n[a]*i.g[1],t.g[2]+=n[s]*e.g[2]+n[a]*i.g[2]}function
|
|
382
|
+
n[0]=e.a.d,n[1]=i.a.d,C(t,e.a,n,[.5,.5,0,0],!1),f(e,i)}function B(t,e,i,n,s){var r=Math.abs(e.b-t.b)+Math.abs(e.a-t.a),o=Math.abs(i.b-t.b)+Math.abs(i.a-t.a),a=s+1
|
|
383
|
+
n[s]=.5*o/(r+o),n[a]=.5*r/(r+o),t.g[0]+=n[s]*e.g[0]+n[a]*i.g[0],t.g[1]+=n[s]*e.g[1]+n[a]*i.g[1],t.g[2]+=n[s]*e.g[2]+n[a]*i.g[2]}function U(t,n){var r=lt(n),o=n.a,a=r.a
|
|
384
384
|
if(i(o.a,a.a)){if(s(a.b.a,o.a,a.a)>0)return!1
|
|
385
385
|
if(e(o.a,a.a)){if(o.a!==a.a){r=t.e
|
|
386
|
-
var h=o.a.
|
|
386
|
+
var h=o.a.yi
|
|
387
387
|
if(0>h)for(r.c[-(h+1)]=null;r.a>0&&null===r.c[r.d[r.a-1]];)--r.a
|
|
388
388
|
else{var c=(r=r.b).d,l=r.e,u=r.c,d=u[h]
|
|
389
|
-
c[d]=c[r.a],u[c[d]]=d,d<=--r.a&&(d>1?i(l[c[d>>1]],l[c[d]])?at(r,d):ht(r,d):at(r,d)),l[h]=null,u[h]=r.b,r.b=h}D(t,K(a),o)}}else
|
|
390
|
-
ut(n).b=n.b=!0,
|
|
391
|
-
if(s(g,t.a,
|
|
392
|
-
if(i(
|
|
393
|
-
var x,S
|
|
394
|
-
if(i(
|
|
395
|
-
if(!e(g,t.a)&&s(g,t.a,v)>=0||!e(m,t.a)&&0>=s(m,t.a,v)){if(m===t.a)return
|
|
396
|
-
if(g===t.a){
|
|
397
|
-
do{
|
|
398
|
-
return
|
|
389
|
+
c[d]=c[r.a],u[c[d]]=d,d<=--r.a&&(d>1?i(l[c[d>>1]],l[c[d]])?at(r,d):ht(r,d):at(r,d)),l[h]=null,u[h]=r.b,r.b=h}D(t,K(a),o)}}else y(a.b),f(o,K(a)),n.b=r.b=!0}else{if(0>s(o.b.a,a.a,o.a))return!1
|
|
390
|
+
ut(n).b=n.b=!0,y(o.b),f(K(a),o)}return!0}function $(t,h){var c=lt(h),u=h.a,d=c.a,p=u.a,w=d.a,g=u.b.a,m=d.b.a,v=new Q
|
|
391
|
+
if(s(g,t.a,p),s(m,t.a,w),p===w||Math.min(p.a,g.a)>Math.max(w.a,m.a))return!1
|
|
392
|
+
if(i(p,w)){if(s(m,p,w)>0)return!1}else if(0>s(g,w,p))return!1
|
|
393
|
+
var x,b,S=g,_=p,E=m,T=w
|
|
394
|
+
if(i(S,_)||(x=S,S=_,_=x),i(E,T)||(x=E,E=T,T=x),i(S,E)||(x=S,S=E,E=x,x=_,_=T,T=x),i(E,_)?i(_,T)?(0>(x=n(S,E,_))+(b=n(E,_,T))&&(x=-x,b=-b),v.b=l(x,E.b,b,_.b)):(0>(x=s(S,E,_))+(b=-s(S,T,_))&&(x=-x,b=-b),v.b=l(x,E.b,b,T.b)):v.b=(E.b+_.b)/2,r(S,_)||(x=S,S=_,_=x),r(E,T)||(x=E,E=T,T=x),r(S,E)||(x=S,S=E,E=x,x=_,_=T,T=x),r(E,_)?r(_,T)?(0>(x=o(S,E,_))+(b=o(E,_,T))&&(x=-x,b=-b),v.a=l(x,E.a,b,_.a)):(0>(x=a(S,E,_))+(b=-a(S,T,_))&&(x=-x,b=-b),v.a=l(x,E.a,b,T.a)):v.a=(E.a+_.a)/2,i(v,t.a)&&(v.b=t.a.b,v.a=t.a.a),S=i(p,w)?p:w,i(S,v)&&(v.b=S.b,v.a=S.a),e(v,p)||e(v,w))return U(t,h),!1
|
|
395
|
+
if(!e(g,t.a)&&s(g,t.a,v)>=0||!e(m,t.a)&&0>=s(m,t.a,v)){if(m===t.a)return y(u.b),f(d.b,u),u=lt(h=M(h)).a,O(t,lt(h),c),k(t,h,K(u),u,u,!0),!0
|
|
396
|
+
if(g===t.a){y(d.b),f(u.e,K(d)),w=(p=c=h).a.b.a
|
|
397
|
+
do{p=ut(p)}while(p.a.b.a===w)
|
|
398
|
+
return p=lt(h=p).a.b.c,c.a=K(d),k(t,h,(d=O(t,c,null)).c,u.b.c,p,!0),!0}return s(g,t.a,v)>=0&&(ut(h).b=h.b=!0,y(u.b),u.a.b=t.a.b,u.a.a=t.a.a),0>=s(m,t.a,v)&&(h.b=c.b=!0,y(d.b),d.a.b=t.a.b,d.a.a=t.a.a),!1}return y(u.b),y(d.b),f(K(d),u),u.a.b=v.b,u.a.a=v.a,u.a.yi=tt(t.e,u.a),d=[0,0,0,0],v=[p.d,g.d,w.d,m.d],(u=u.a).g[0]=u.g[1]=u.g[2]=0,B(u,p,g,d,0),B(u,w,m,d,2),C(t,u,v,d,!0),ut(h).b=h.b=c.b=!0,!1}function N(t,e){for(var n=lt(e);;){for(;n.b;)e=n,n=lt(n)
|
|
399
399
|
if(!e.b&&(n=e,null===(e=ut(e))||!e.b))break
|
|
400
400
|
e.b=!1
|
|
401
401
|
var r,o=e.a,a=n.a
|
|
402
402
|
if(r=o.b.a!==a.b.a)t:{var h=lt(r=e),c=r.a,l=h.a,u=void 0
|
|
403
403
|
if(i(c.b.a,l.b.a)){if(0>s(c.b.a,l.b.a,c.a)){r=!1
|
|
404
|
-
break t}ut(r).b=r.b=!0,u=
|
|
405
|
-
break t}r.b=h.b=!0,u=
|
|
404
|
+
break t}ut(r).b=r.b=!0,u=y(c),f(l.b,u),u.d.c=r.d}else{if(s(l.b.a,c.b.a,l.a)>0){r=!1
|
|
405
|
+
break t}r.b=h.b=!0,u=y(l),f(c.e,l.b),u.b.d.c=r.d}r=!0}if(r&&(n.c?(A(n),d(a),a=(n=lt(e)).a):e.c&&(A(e),d(o),o=(e=ut(n)).a)),o.a!==a.a)if(o.b.a===a.b.a||e.c||n.c||o.b.a!==t.a&&a.b.a!==t.a)U(t,e)
|
|
406
406
|
else if($(t,e))break
|
|
407
407
|
o.a===a.a&&o.b.a===a.b.a&&(E(a,o),A(e),d(o),e=ut(n))}}function P(t,n){t.a=n
|
|
408
|
-
for(var r=n.c;null===r.
|
|
408
|
+
for(var r=n.c;null===r.pi;)if((r=r.c)===n.c){r=t
|
|
409
409
|
var o=n;(u=new ct).a=o.c.b
|
|
410
410
|
var a=(l=r.f).a
|
|
411
411
|
do{a=a.a}while(null!==a.b&&!l.c(l.b,u,a.b))
|
|
412
|
-
if(a=(c=lt(l=a.b)).a,0===s((u=l.a).b.a,o,u.a))e((u=l.a).a,o)||e(u.b.a,o)||(
|
|
412
|
+
if(a=(c=lt(l=a.b)).a,0===s((u=l.a).b.a,o,u.a))e((u=l.a).a,o)||e(u.b.a,o)||(y(u.b),l.c&&(d(u.c),l.c=!1),f(o.c,u),P(r,o))
|
|
413
413
|
else{var h=i(a.b.a,u.b.a)?l:c,c=void 0
|
|
414
|
-
l.d||h.c?(c=h===l?
|
|
415
|
-
n.a.b=dt,n.a.a=e,n.b.a.b=-dt,n.b.a.a=e,t.a=n.b.a,i.a=n,i.f=0,i.d=!1,i.c=!1,i.
|
|
416
|
-
return t=new z(i,e.a,e),e.a.c=t,e.a=t}function z(t,e,i){this.b=t||null,this.a=e||this,this.c=i||this}function H(){this.d=
|
|
414
|
+
l.d||h.c?(c=h===l?p(o.c.b,u.e):p(a.b.c.b,o.c).b,h.c?L(h,c):(u=r,(l=I(r,l,c)).f=ut(l).f+l.a.f,l.d=F(u,l.f)),P(r,o)):k(r,l,o.c,o.c,null,!0)}return}if(l=(u=lt(r=M(r.pi))).a,(u=O(t,u,null)).c===l){var l,u=(l=u).c,w=(a=lt(r),!1);(c=r.a).b.a!==(h=a.a).b.a&&$(t,r),e(c.a,t.a)&&(f(K(u),c),u=lt(r=M(r)).a,O(t,lt(r),a),w=!0),e(h.a,t.a)&&(f(l,K(h)),l=O(t,a,null),w=!0),w?k(t,r,l.c,u,u,!0):(o=i(h.a,c.a)?K(h):c,k(t,r,o=p(l.c.b,o),o.c,o.c,!1),o.b.pi.c=!0,N(t,r))}else k(t,r,u.c,l,l,!0)}function R(t,e){var i=new ct,n=u(t.b)
|
|
415
|
+
n.a.b=dt,n.a.a=e,n.b.a.b=-dt,n.b.a.a=e,t.a=n.b.a,i.a=n,i.f=0,i.d=!1,i.c=!1,i.yi=!0,i.b=!1,n=j(n=t.f,n.a,i),i.e=n}function W(t){this.a=new z,this.b=t,this.c=T}function j(t,e,i){do{e=e.c}while(null!==e.b&&!t.c(t.b,e.b,i))
|
|
416
|
+
return t=new z(i,e.a,e),e.a.c=t,e.a=t}function z(t,e,i){this.b=t||null,this.a=e||this,this.c=i||this}function H(){this.d=yt,this.gi=this.b=this.mi=null,this.xi=[0,0,0],this.s=100130,this.n=!1,this.wi=this.a=this.e=this.f=null,this.bi=!1,this.c=this.r=this.pi=this.Si=this._i=this.yi=null}function V(t,e){if(t.d!==e)for(;t.d!==e;)if(e>t.d)switch(t.d){case yt:q(t,100151),t.Ei(null)
|
|
417
417
|
break
|
|
418
418
|
case 1:q(t,100152),t.Ti()}else switch(t.d){case 2:q(t,100154),t.Ai()
|
|
419
419
|
break
|
|
420
|
-
case 1:q(t,100153),t.w()}}function q(t,e){t.gi&&t.gi(e,t.c)}function Y(t,e){this.b=t||this,this.d=e||this,this.a=null,this.c=!1}function J(){this.
|
|
421
|
-
return 2*s>n.f&&(n.f*=2,n.c=st(n.c,n.f+1)),0===n.b?i=s:(i=n.b,n.b=n.c[n.b]),n.e[i]=e,n.c[i]=s,n.d[s]=i,n.
|
|
420
|
+
case 1:q(t,100153),t.w()}}function q(t,e){t.gi&&t.gi(e,t.c)}function Y(t,e){this.b=t||this,this.d=e||this,this.a=null,this.c=!1}function J(){this.yi=this,this.pi=this.d=this.a=this.e=this.c=this.b=null,this.f=0}function K(t){return t.b.e}function X(){this.c=new Q,this.a=new Y,this.b=new J,this.d=new J,this.b.b=this.d,this.d.b=this.b}function Q(t,e){this.e=t||this,this.f=e||this,this.d=this.c=null,this.g=[0,0,0],this.yi=this.a=this.b=0}function Z(){this.c=[],this.d=null,this.a=0,this.e=!1,this.b=new nt}function tt(t,e){if(t.e){var i,n=t.b,s=++n.a
|
|
421
|
+
return 2*s>n.f&&(n.f*=2,n.c=st(n.c,n.f+1)),0===n.b?i=s:(i=n.b,n.b=n.c[n.b]),n.e[i]=e,n.c[i]=s,n.d[s]=i,n.yi&&ht(n,s),i}return n=t.a++,t.c[n]=e,-(n+1)}function et(t){if(0===t.a)return ot(t.b)
|
|
422
422
|
var e=t.c[t.d[t.a-1]]
|
|
423
423
|
if(0!==t.b.a&&i(rt(t.b),e))return ot(t.b)
|
|
424
424
|
do{--t.a}while(t.a>0&&null===t.c[t.d[t.a-1]])
|
|
425
|
-
return e}function nt(){this.d=st([0],33),this.e=[null,null],this.c=[0,0],this.a=0,this.f=32,this.b=0,this.
|
|
425
|
+
return e}function nt(){this.d=st([0],33),this.e=[null,null],this.c=[0,0],this.a=0,this.f=32,this.b=0,this.yi=!1,this.d[1]=1}function st(t,e){for(var i=Array(e),n=0;t.length>n;n++)i[n]=t[n]
|
|
426
426
|
for(;e>n;n++)i[n]=0
|
|
427
427
|
return i}function rt(t){return t.e[t.d[1]]}function ot(t){var e=t.d,i=t.e,n=t.c,s=e[1],r=i[s]
|
|
428
428
|
return t.a>0&&(e[1]=e[t.a],n[e[1]]=1,i[s]=null,n[s]=t.b,t.b=s,--t.a>0&&at(t,1)),r}function at(t,e){for(var n=t.d,s=t.e,r=t.c,o=e,a=n[o];;){var h=o<<1
|
|
@@ -431,20 +431,20 @@ var c=n[h]
|
|
|
431
431
|
if(h>t.a||i(s[a],s[c])){n[o]=a,r[a]=o
|
|
432
432
|
break}n[o]=c,r[c]=o,o=h}}function ht(t,e){for(var n=t.d,s=t.e,r=t.c,o=e,a=n[o];;){var h=o>>1,c=n[h]
|
|
433
433
|
if(0===h||i(s[c],s[a])){n[o]=a,r[a]=o
|
|
434
|
-
break}n[o]=c,r[c]=o,o=h}}function ct(){this.e=this.a=null,this.f=0,this.c=this.b=this.
|
|
434
|
+
break}n[o]=c,r[c]=o,o=h}}function ct(){this.e=this.a=null,this.f=0,this.c=this.b=this.yi=this.d=!1}function lt(t){return t.e.c.b}function ut(t){return t.e.a.b}var ft,dt=4e150,yt=0;(ft=H.prototype).x=function(){V(this,yt)},ft.B=function(t,e){switch(t){case 100142:return
|
|
435
435
|
case 100140:switch(e){case 100130:case 100131:case 100132:case 100133:case 100134:return void(this.s=e)}break
|
|
436
|
-
case 100141:return void(this.
|
|
436
|
+
case 100141:return void(this.bi=!!e)
|
|
437
437
|
default:return void q(this,100900)}q(this,100901)},ft.y=function(t){switch(t){case 100142:return 0
|
|
438
438
|
case 100140:return this.s
|
|
439
|
-
case 100141:return this.
|
|
439
|
+
case 100141:return this.bi
|
|
440
440
|
default:q(this,100900)}return!1},ft.A=function(t,e,i){this.xi[0]=t,this.xi[1]=e,this.xi[2]=i},ft.z=function(t,e){var i=e||null
|
|
441
|
-
switch(t){case 100100:case 100106:this.
|
|
441
|
+
switch(t){case 100100:case 100106:this.yi=i
|
|
442
442
|
break
|
|
443
443
|
case 100104:case 100110:this._i=i
|
|
444
444
|
break
|
|
445
|
-
case 100101:case 100107:this.
|
|
445
|
+
case 100101:case 100107:this.Si=i
|
|
446
446
|
break
|
|
447
|
-
case 100102:case 100108:this.
|
|
447
|
+
case 100102:case 100108:this.pi=i
|
|
448
448
|
break
|
|
449
449
|
case 100103:case 100109:this.gi=i
|
|
450
450
|
break
|
|
@@ -454,32 +454,32 @@ case 100112:this.r=i
|
|
|
454
454
|
break
|
|
455
455
|
default:q(this,100900)}},ft.C=function(t,e){var i=!1,n=[0,0,0]
|
|
456
456
|
V(this,2)
|
|
457
|
-
for(var s=0;3>s;++s){var r=t[s];-1e150>r&&(r=-1e150,i=!0),r>1e150&&(r=1e150,i=!0),n[s]=r}i&&q(this,100155),null===(i=this.mi)?f(i=u(this.b),i.b):(
|
|
457
|
+
for(var s=0;3>s;++s){var r=t[s];-1e150>r&&(r=-1e150,i=!0),r>1e150&&(r=1e150,i=!0),n[s]=r}i&&q(this,100155),null===(i=this.mi)?f(i=u(this.b),i.b):(y(i),i=i.e),i.a.d=e,i.a.g[0]=n[0],i.a.g[1]=n[1],i.a.g[2]=n[2],i.f=1,i.b.f=-1,this.mi=i},ft.Ei=function(t){V(this,yt),this.d=1,this.b=new X,this.c=t},ft.Ti=function(){V(this,1),this.d=2,this.mi=null},ft.Ai=function(){V(this,2),this.d=1},ft.w=function(){V(this,1),this.d=yt
|
|
458
458
|
var t=!1,n=[u=this.xi[0],r=this.xi[1],a=this.xi[2]]
|
|
459
|
-
if(0===u&&0===r&&0===a){for(var r=[-2e150,-2e150,-2e150],o=[2e150,2e150,2e150],a=[],l=[],u=(t=this.b.c).e;u!==t;u=u.e)for(var f=0;3>f;++f){var
|
|
460
|
-
o[f]>
|
|
459
|
+
if(0===u&&0===r&&0===a){for(var r=[-2e150,-2e150,-2e150],o=[2e150,2e150,2e150],a=[],l=[],u=(t=this.b.c).e;u!==t;u=u.e)for(var f=0;3>f;++f){var y=u.g[f]
|
|
460
|
+
o[f]>y&&(o[f]=y,l[f]=u),y>r[f]&&(r[f]=y,a[f]=u)}if(u=0,r[1]-o[1]>r[0]-o[0]&&(u=1),r[2]-o[2]>r[u]-o[u]&&(u=2),r[u]>o[u]){for(r=0,o=l[u],l=[0,0,0],o=[o.g[0]-(a=a[u]).g[0],o.g[1]-a.g[1],o.g[2]-a.g[2]],f=[0,0,0],u=t.e;u!==t;u=u.e)f[0]=u.g[0]-a.g[0],f[1]=u.g[1]-a.g[1],f[2]=u.g[2]-a.g[2],l[0]=o[1]*f[2]-o[2]*f[1],l[1]=o[2]*f[0]-o[0]*f[2],l[2]=o[0]*f[1]-o[1]*f[0],(y=l[0]*l[0]+l[1]*l[1]+l[2]*l[2])>r&&(r=y,n[0]=l[0],n[1]=l[1],n[2]=l[2])
|
|
461
461
|
0>=r&&(n[0]=n[1]=n[2]=0,n[_(o)]=1)}else n[0]=0,n[1]=0,n[2]=1
|
|
462
462
|
t=!0}for(r=((l=_(n))+1)%3,a=(l+2)%3,l=n[l]>0?1:-1,n=(u=this.b.c).e;n!==u;n=n.e)n.b=n.g[r],n.a=l*n.g[a]
|
|
463
463
|
if(t){for(n=0,u=(t=this.b.a).b;u!==t;u=u.b)if((r=u.a).f>0)do{n+=(r.a.b-r.b.a.b)*(r.a.a+r.b.a.a),r=r.e}while(r!==u.a)
|
|
464
|
-
if(0>n)for(t=(n=this.b.c).e;t!==n;t=t.e)t.a=-t.a}for(this.n=!1,u=(n=this.b.b).
|
|
465
|
-
for(this.e=n=new Z,u=(t=this.b.c).e;u!==t;u=u.e)u.
|
|
464
|
+
if(0>n)for(t=(n=this.b.c).e;t!==n;t=t.e)t.a=-t.a}for(this.n=!1,u=(n=this.b.b).yi;u!==n;u=t)t=u.yi,r=u.e,e(u.a,u.b.a)&&u.e.e!==u&&(D(this,r,u),d(u),r=(u=r).e),r.e===u&&(r!==u&&(r!==t&&r!==t.b||(t=t.yi),d(r)),u!==t&&u!==t.b||(t=t.yi),d(u))
|
|
465
|
+
for(this.e=n=new Z,u=(t=this.b.c).e;u!==t;u=u.e)u.yi=tt(n,u)
|
|
466
466
|
for((t=>{t.d=[]
|
|
467
467
|
for(var e=0;t.a>e;e++)t.d[e]=e
|
|
468
468
|
t.d.sort((t=>(e,n)=>i(t[e],t[n])?1:-1)(t.c)),t.e=!0,(t=>{for(var e=t.a;e>=1;--e)at(t,e)
|
|
469
|
-
t.
|
|
469
|
+
t.yi=!0})(t.b)})(n),this.f=new W(this),R(this,-dt),R(this,dt);null!==(n=et(this.e));){for(;;){t:if(u=this.e,0===u.a)t=rt(u.b)
|
|
470
470
|
else if(t=u.c[u.d[u.a-1]],0!==u.b.a&&(u=rt(u.b),i(u,t))){t=u
|
|
471
471
|
break t}if(null===t||!e(t,n))break
|
|
472
|
-
t=et(this.e),D(this,n.c,t.c)}P(this,n)}for(this.a=this.f.a.a.b.a.a,n=0;null!==(t=this.f.a.a.b);)t.
|
|
472
|
+
t=et(this.e),D(this,n.c,t.c)}P(this,n)}for(this.a=this.f.a.a.b.a.a,n=0;null!==(t=this.f.a.a.b);)t.yi||++n,A(t)
|
|
473
473
|
for(this.f=null,(n=this.e).b=null,n.d=null,this.e=n.c=null,u=(n=this.b).a.b;u!==n.a;u=t)t=u.b,(u=u.a).e.e===u&&(E(u.c,u),d(u))
|
|
474
|
-
if(!this.n){if(n=this.b,this.
|
|
475
|
-
else for(u=n.a.b;u!==n.a;u=t)if(t=u.b,u.c){for(u=u.a;i(u.b.a,u.a);u=u.c.b);for(;i(u.a,u.b.a);u=u.e);for(r=u.c.b,a=void 0;u.e!==r;)if(i(u.b.a,r.a)){for(;r.e!==u&&(h(r.e)||0>=s(r.a,r.b.a,r.e.b.a));)r=(a=
|
|
476
|
-
r=r.c.b}else{for(;r.e!==u&&(c(u.c.b)||s(u.b.a,u.a,u.c.b.a)>=0);)u=(a=
|
|
477
|
-
u=u.e}for(;r.e.e!==u;)r=(a=
|
|
478
|
-
do{this.
|
|
479
|
-
this.
|
|
480
|
-
do{t&&r!==(o=l.b.d.c?0:1)&&(r=o,this._i&&this._i(!!r,this.c)),this.
|
|
481
|
-
do{a=(l=a).e,l.d=null,null===l.b.d&&(l.c===l?
|
|
482
|
-
r=u.d,(u=u.b).d=r,r.b=u}return this.r(this.b),void(this.c=this.b=null)}}this.b=this.c=null},it.Li={GluTesselator:H,Mi:{GLU_TESS_WINDING_ODD:100130,GLU_TESS_WINDING_NONZERO:100131,GLU_TESS_WINDING_POSITIVE:100132,GLU_TESS_WINDING_NEGATIVE:100133,GLU_TESS_WINDING_ABS_GEQ_TWO:100134},primitiveType:{GL_LINE_LOOP:2,GL_TRIANGLES:4,GL_TRIANGLE_STRIP:5,GL_TRIANGLE_FAN:6},Ii:{GLU_TESS_MISSING_BEGIN_POLYGON:100151,GLU_TESS_MISSING_END_POLYGON:100153,GLU_TESS_MISSING_BEGIN_CONTOUR:100152,GLU_TESS_MISSING_END_CONTOUR:100154,GLU_TESS_COORD_TOO_LARGE:100155,GLU_TESS_NEED_COMBINE_CALLBACK:100156},Fi:{GLU_TESS_MESH:100112,GLU_TESS_TOLERANCE:100142,GLU_TESS_WINDING_RULE:100140,GLU_TESS_BOUNDARY_ONLY:100141,GLU_INVALID_ENUM:100900,GLU_INVALID_VALUE:100901,GLU_TESS_BEGIN:100100,GLU_TESS_VERTEX:100101,GLU_TESS_END:100102,GLU_TESS_ERROR:100103,GLU_TESS_EDGE_FLAG:100104,GLU_TESS_COMBINE:100105,GLU_TESS_BEGIN_DATA:100106,GLU_TESS_VERTEX_DATA:100107,GLU_TESS_END_DATA:100108,GLU_TESS_ERROR_DATA:100109,GLU_TESS_EDGE_FLAG_DATA:100110,GLU_TESS_COMBINE_DATA:100111}},H.prototype.Gi=H.prototype.x,H.prototype.Oi=H.prototype.B,H.prototype.ki=H.prototype.y,H.prototype.Ci=H.prototype.A,H.prototype.Di=H.prototype.z,H.prototype.
|
|
474
|
+
if(!this.n){if(n=this.b,this.bi)for(u=n.b.yi;u!==n.b;u=t)t=u.yi,u.b.d.c!==u.d.c?u.f=u.d.c?1:-1:d(u)
|
|
475
|
+
else for(u=n.a.b;u!==n.a;u=t)if(t=u.b,u.c){for(u=u.a;i(u.b.a,u.a);u=u.c.b);for(;i(u.a,u.b.a);u=u.e);for(r=u.c.b,a=void 0;u.e!==r;)if(i(u.b.a,r.a)){for(;r.e!==u&&(h(r.e)||0>=s(r.a,r.b.a,r.e.b.a));)r=(a=p(r.e,r)).b
|
|
476
|
+
r=r.c.b}else{for(;r.e!==u&&(c(u.c.b)||s(u.b.a,u.a,u.c.b.a)>=0);)u=(a=p(u,u.c.b)).b
|
|
477
|
+
u=u.e}for(;r.e.e!==u;)r=(a=p(r.e,r)).b}if(this.yi||this.pi||this.Si||this._i)if(this.bi){for(t=(n=this.b).a.b;t!==n.a;t=t.b)if(t.c){this.yi&&this.yi(2,this.c),u=t.a
|
|
478
|
+
do{this.Si&&this.Si(u.a.d,this.c),u=u.e}while(u!==t.a)
|
|
479
|
+
this.pi&&this.pi(this.c)}}else{for(t=!!this._i,u=!1,r=-1,a=(n=this.b).a.d;a!==n.a;a=a.d)if(a.c){u||(this.yi&&this.yi(4,this.c),u=!0),l=a.a
|
|
480
|
+
do{t&&r!==(o=l.b.d.c?0:1)&&(r=o,this._i&&this._i(!!r,this.c)),this.Si&&this.Si(l.a.d,this.c),l=l.e}while(l!==a.a)}u&&this.pi&&this.pi(this.c)}if(this.r){for(u=(n=this.b).a.b;u!==n.a;u=t)if(t=u.b,!u.c){a=(r=u.a).e,l=void 0
|
|
481
|
+
do{a=(l=a).e,l.d=null,null===l.b.d&&(l.c===l?b(l.a,null):(l.a.c=l.c,g(l,K(l))),(o=l.b).c===o?b(o.a,null):(o.a.c=o.c,g(o,K(o))),x(l))}while(l!==r)
|
|
482
|
+
r=u.d,(u=u.b).d=r,r.b=u}return this.r(this.b),void(this.c=this.b=null)}}this.b=this.c=null},it.Li={GluTesselator:H,Mi:{GLU_TESS_WINDING_ODD:100130,GLU_TESS_WINDING_NONZERO:100131,GLU_TESS_WINDING_POSITIVE:100132,GLU_TESS_WINDING_NEGATIVE:100133,GLU_TESS_WINDING_ABS_GEQ_TWO:100134},primitiveType:{GL_LINE_LOOP:2,GL_TRIANGLES:4,GL_TRIANGLE_STRIP:5,GL_TRIANGLE_FAN:6},Ii:{GLU_TESS_MISSING_BEGIN_POLYGON:100151,GLU_TESS_MISSING_END_POLYGON:100153,GLU_TESS_MISSING_BEGIN_CONTOUR:100152,GLU_TESS_MISSING_END_CONTOUR:100154,GLU_TESS_COORD_TOO_LARGE:100155,GLU_TESS_NEED_COMBINE_CALLBACK:100156},Fi:{GLU_TESS_MESH:100112,GLU_TESS_TOLERANCE:100142,GLU_TESS_WINDING_RULE:100140,GLU_TESS_BOUNDARY_ONLY:100141,GLU_INVALID_ENUM:100900,GLU_INVALID_VALUE:100901,GLU_TESS_BEGIN:100100,GLU_TESS_VERTEX:100101,GLU_TESS_END:100102,GLU_TESS_ERROR:100103,GLU_TESS_EDGE_FLAG:100104,GLU_TESS_COMBINE:100105,GLU_TESS_BEGIN_DATA:100106,GLU_TESS_VERTEX_DATA:100107,GLU_TESS_END_DATA:100108,GLU_TESS_ERROR_DATA:100109,GLU_TESS_EDGE_FLAG_DATA:100110,GLU_TESS_COMBINE_DATA:100111}},H.prototype.Gi=H.prototype.x,H.prototype.Oi=H.prototype.B,H.prototype.ki=H.prototype.y,H.prototype.Ci=H.prototype.A,H.prototype.Di=H.prototype.z,H.prototype.Bi=H.prototype.C,H.prototype.Ui=H.prototype.Ei,H.prototype.$i=H.prototype.Ti,H.prototype.Ni=H.prototype.Ai,H.prototype.Pi=H.prototype.w,t.exports=it.Li})(nt)
|
|
483
483
|
var st=nt.exports
|
|
484
484
|
class rt{process(t,e=!0,i=!1,n=!0){if(0===t.length)return{Ri:{vertices:[],indices:[]},Wi:[]}
|
|
485
485
|
const s=t.filter(t=>t.points.length>=3)
|
|
@@ -500,10 +500,10 @@ i.Oi(st.Fi.GLU_TESS_WINDING_RULE,st.Mi.GLU_TESS_WINDING_NONZERO)
|
|
|
500
500
|
const n=[],s=[],r=[]
|
|
501
501
|
let o=[]
|
|
502
502
|
"boundary"===e&&i.Oi(st.Fi.GLU_TESS_BOUNDARY_ONLY,!0),"triangles"===e?i.Di(st.Fi.GLU_TESS_VERTEX_DATA,t=>{s.push(t)}):(i.Di(st.Fi.GLU_TESS_BEGIN,()=>{o=[]}),i.Di(st.Fi.GLU_TESS_VERTEX_DATA,t=>{o.push(t)}),i.Di(st.Fi.GLU_TESS_END,()=>{o.length>0&&r.push(o)})),i.Di(st.Fi.GLU_TESS_COMBINE,t=>{const e=n.length/2
|
|
503
|
-
return n.push(t[0],t[1]),e}),i.Di(st.Fi.GLU_TESS_ERROR,t=>{h.warn("libtess error: "+t)}),i.Ci(0,0,1),i.
|
|
503
|
+
return n.push(t[0],t[1]),e}),i.Di(st.Fi.GLU_TESS_ERROR,t=>{h.warn("libtess error: "+t)}),i.Ci(0,0,1),i.Ui(null)
|
|
504
504
|
for(const e of t){i.$i()
|
|
505
505
|
for(let t=0;e.length>t;t+=2){const s=n.length/2
|
|
506
|
-
n.push(e[t],e[t+1]),i.
|
|
506
|
+
n.push(e[t],e[t+1]),i.Bi([e[t],e[t+1],0],s)}i.Ni()}return i.Pi(),0===n.length?null:"triangles"===e?{vertices:n,indices:s}:{vertices:n,qi:r}}Vi(t){if(!t.qi)return[]
|
|
507
507
|
const e=[]
|
|
508
508
|
for(const i of t.qi){const n=[]
|
|
509
509
|
for(const e of i){const i=2*e
|
|
@@ -531,18 +531,18 @@ return u.set(s),{vertices:c,normals:l,indices:u}}const f=25e-6*i,d=e>f?e:f
|
|
|
531
531
|
for(let t=0,e=0;n.length>t;t+=2,e++){const i=n[t],s=n[t+1],o=3*e
|
|
532
532
|
c[o]=i,c[o+1]=s,c[o+2]=0,l[o]=0,l[o+1]=0,l[o+2]=-1
|
|
533
533
|
const a=3*(r+e)
|
|
534
|
-
c[a]=i,c[a+1]=s,c[a+2]=d,l[a]=0,l[a+1]=0,l[a+2]=1}const
|
|
535
|
-
for(let t=0;
|
|
536
|
-
for(let t=0;
|
|
537
|
-
let
|
|
534
|
+
c[a]=i,c[a+1]=s,c[a+2]=d,l[a]=0,l[a+1]=0,l[a+2]=1}const y=s.length
|
|
535
|
+
for(let t=0;y>t;t++)u[t]=s[y-1-t]
|
|
536
|
+
for(let t=0;y>t;t++)u[y+t]=s[t]+r
|
|
537
|
+
let p=2*r,w=2*y
|
|
538
538
|
const g=o.length
|
|
539
|
-
for(let t=0;g>t;t++){const e=o[t],i=e[0]<<1,s=e[1]<<1,r=n[i],a=n[i+1],h=n[s],f=n[s+1],
|
|
539
|
+
for(let t=0;g>t;t++){const e=o[t],i=e[0]<<1,s=e[1]<<1,r=n[i],a=n[i+1],h=n[s],f=n[s+1],y=h-r,g=f-a,m=y*y+g*g
|
|
540
540
|
let v=0,x=0
|
|
541
541
|
if(m>1e-10){const t=1/Math.sqrt(m)
|
|
542
|
-
v=g*t,x=-
|
|
543
|
-
c[
|
|
544
|
-
const
|
|
545
|
-
u[w]=
|
|
542
|
+
v=g*t,x=-y*t}const b=3*p
|
|
543
|
+
c[b]=r,c[b+1]=a,c[b+2]=0,c[b+3]=h,c[b+4]=f,c[b+5]=0,c[b+6]=r,c[b+7]=a,c[b+8]=d,c[b+9]=h,c[b+10]=f,c[b+11]=d,l[b]=v,l[b+1]=x,l[b+2]=0,l[b+3]=v,l[b+4]=x,l[b+5]=0,l[b+6]=v,l[b+7]=x,l[b+8]=0,l[b+9]=v,l[b+10]=x,l[b+11]=0
|
|
544
|
+
const S=p
|
|
545
|
+
u[w]=S,u[w+1]=S+1,u[w+2]=S+2,u[w+3]=S+1,u[w+4]=S+3,u[w+5]=S+2,w+=6,p+=4}return{vertices:c,normals:l,indices:u}}}class at{constructor(){}Xi(t,e){const i=t.length
|
|
546
546
|
return 0===i?[]:1===i?[[0]]:this.Qi(t,e)}Qi(t,e){function i(t){return h[t]===t?t:h[t]=i(h[t])}function n(t,e){const n=i(t),s=i(e)
|
|
547
547
|
n!==s&&(c[s]>c[n]?h[n]=s:c[n]>c[s]?h[s]=n:(h[s]=n,c[n]++))}const s=t.length,r=Array(s),o=Array(2*s)
|
|
548
548
|
let a=0
|
|
@@ -573,13 +573,13 @@ let r=t,o=e
|
|
|
573
573
|
const a=this.rn[n]
|
|
574
574
|
if(0>this.compare(a,o)&&(r=n,o=a),i>s){const t=this.rn[s]
|
|
575
575
|
0>this.compare(t,o)&&(r=s,o=t)}if(r===t)break
|
|
576
|
-
this.rn[t]=o,this.an.set(o,t),t=r}this.rn[t]=e,this.an.set(e,t)}}const ct={enabled:!0,dn:1,
|
|
576
|
+
this.rn[t]=o,this.an.set(o,t),t=r}this.rn[t]=e,this.an.set(e,t)}}const ct={enabled:!0,dn:1,yn:.0087,pn:10}
|
|
577
577
|
class lt{constructor(t){this.stats={wn:0,gn:0,mn:0},this.config=t}vn(t){this.config=t}xn(t){if(!this.config.enabled||2>=t.points.length)return t
|
|
578
578
|
this.stats.mn+=t.points.length
|
|
579
579
|
const e=t.points
|
|
580
580
|
if(5>e.length)return t
|
|
581
|
-
let i=this.
|
|
582
|
-
return 3>i.length?t:(i=this.
|
|
581
|
+
let i=this.bn(e,this.config.dn)
|
|
582
|
+
return 3>i.length?t:(i=this.Sn(i,this.config.yn),3>i.length?t:{...t,points:i})}bn(t,e){if(3>=t.length)return t
|
|
583
583
|
const i=t.length,n=t.map((t,e)=>({index:e,_n:1/0,En:null,next:null}))
|
|
584
584
|
for(let t=0;n.length>t;t++)n[t].En=n[t-1]||null,n[t].next=n[t+1]||null
|
|
585
585
|
const s=new ht((t,e)=>t._n-e._n)
|
|
@@ -587,44 +587,44 @@ for(let e=1;n.length-1>e;e++){const i=n[e]
|
|
|
587
587
|
i._n=this.Tn(t[i.En.index],t[i.index],t[i.next.index]),s.F(i)}let r=i
|
|
588
588
|
for(;!s.un()&&r>3;){const i=s.ln()
|
|
589
589
|
if(!i||i._n>e)break
|
|
590
|
-
if(this.config.
|
|
591
|
-
if(this.config.
|
|
590
|
+
if(this.config.pn>0&&i.En&&i.next){const e=t[i.index],n=t[i.next.index],s=t[i.En.index].ui(e),r=e.ui(n)
|
|
591
|
+
if(this.config.pn>s||this.config.pn>r)continue}i.En&&(i.En.next=i.next),i.next&&(i.next.En=i.En),r--,i.En&&i.En.En&&(i.En._n=this.Tn(t[i.En.En.index],t[i.En.index],t[i.next.index]),s.update(i.En)),i.next&&i.next.next&&(i.next._n=this.Tn(t[i.En.index],t[i.next.index],t[i.next.next.index]),s.update(i.next))}const o=[]
|
|
592
592
|
let a=n[0]
|
|
593
593
|
for(;a;)o.push(t[a.index]),a=a.next
|
|
594
|
-
return this.stats.wn+=i-o.length,o}
|
|
594
|
+
return this.stats.wn+=i-o.length,o}Sn(t,e){if(2>=t.length)return t
|
|
595
595
|
const i=[t[0]]
|
|
596
|
-
for(let n=1;t.length-1>n;n++){const s=t[n-1],r=t[n],o=t[n+1],a=r.x-s.x,h=r.y-s.y,c=o.x-r.x,l=o.y-r.y,u=this.config.
|
|
596
|
+
for(let n=1;t.length-1>n;n++){const s=t[n-1],r=t[n],o=t[n+1],a=r.x-s.x,h=r.y-s.y,c=o.x-r.x,l=o.y-r.y,u=this.config.pn*this.config.pn
|
|
597
597
|
Math.abs(Math.atan2(a*l-h*c,a*c+h*l))>e||u>a*a+h*h||u>c*c+l*l?i.push(r):this.stats.gn++}return i.push(t[t.length-1]),i}Tn(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}}An(){this.stats={wn:0,gn:0,mn:0}}}const ut={Ln:.5,Mn:.2},ft=1e-6
|
|
598
598
|
class dt{constructor(t){this.In={...ut,...t}}Fn(t){this.In={...ut,...t}}Gn(t,e,i){const n=[]
|
|
599
599
|
return this.On(t.x,t.y,e.x,e.y,i.x,i.y,n),this.kn(i.x,i.y,n),n}Cn(t,e,i,n){const s=[]
|
|
600
600
|
return this.Dn(t.x,t.y,e.x,e.y,i.x,i.y,n.x,n.y,s),this.kn(n.x,n.y,s),s}On(t,e,i,n,s,r,o,a=0){if(a>16)return
|
|
601
|
-
const h=(t+i)/2,c=(e+n)/2,l=(i+s)/2,u=(n+r)/2,f=(h+l)/2,d=(c+u)/2,
|
|
602
|
-
if(w>ft){if(m*(p*p
|
|
601
|
+
const h=(t+i)/2,c=(e+n)/2,l=(i+s)/2,u=(n+r)/2,f=(h+l)/2,d=(c+u)/2,y=s-t,p=r-e,w=Math.abs((i-s)*p-(n-r)*y),g=this.In.Ln??ut.Ln,m=g*g
|
|
602
|
+
if(w>ft){if(m*(y*y+p*p)>=w*w){const a=this.In.Mn??ut.Mn
|
|
603
603
|
if(0>=a)return void this.kn(i,n,o)
|
|
604
604
|
{const h=i-t,c=n-e,l=s-i,u=r-n
|
|
605
|
-
if(a>Math.abs(Math.atan2(h*u-c*l,h*l+c*u)))return void this.kn(i,n,o)}}}else{const s=p*p
|
|
606
|
-
if(0===s){if(m>=(i-t)*(i-t)+(n-e)*(n-e))return void this.kn(i,n,o)}else{const r=((i-t)*
|
|
605
|
+
if(a>Math.abs(Math.atan2(h*u-c*l,h*l+c*u)))return void this.kn(i,n,o)}}}else{const s=y*y+p*p
|
|
606
|
+
if(0===s){if(m>=(i-t)*(i-t)+(n-e)*(n-e))return void this.kn(i,n,o)}else{const r=((i-t)*y+(n-e)*p)/s
|
|
607
607
|
if(r>0&&1>r&&m*s>=w*w)return void this.kn(i,n,o)}}this.On(t,e,h,c,f,d,o,a+1),this.On(f,d,l,u,s,r,o,a+1)}Dn(t,e,i,n,s,r,o,a,h,c=0){if(c>16)return
|
|
608
|
-
const l=(t+i)/2,u=(e+n)/2,f=(i+s)/2,d=(n+r)/2,
|
|
608
|
+
const l=(t+i)/2,u=(e+n)/2,f=(i+s)/2,d=(n+r)/2,y=(s+o)/2,p=(r+a)/2,w=(l+f)/2,g=(u+d)/2,m=(f+y)/2,v=(d+p)/2,x=(w+m)/2,b=(g+v)/2,S=o-t,_=a-e,E=Math.abs((i-o)*_-(n-a)*S),T=Math.abs((s-o)*_-(r-a)*S),A=this.In.Ln??ut.Ln,L=A*A
|
|
609
609
|
let M=0
|
|
610
|
-
switch(E>ft&&(M|=1),T>ft&&(M|=2),M){case 0:const c=
|
|
611
|
-
if(0===c){if(L>=(i-t)*(i-t)+(n-e)*(n-e)&&L>=(s-t)*(s-t)+(r-e)*(r-e))return this.kn(i,n,h),void this.kn(s,r,h)}else{const o=((i-t)*
|
|
610
|
+
switch(E>ft&&(M|=1),T>ft&&(M|=2),M){case 0:const c=S*S+_*_
|
|
611
|
+
if(0===c){if(L>=(i-t)*(i-t)+(n-e)*(n-e)&&L>=(s-t)*(s-t)+(r-e)*(r-e))return this.kn(i,n,h),void this.kn(s,r,h)}else{const o=((i-t)*S+(n-e)*_)/c,a=((s-t)*S+(r-e)*_)/c
|
|
612
612
|
if(o>0&&1>o&&a>0&&1>a&&L*c>=(E+T)*(E+T))return this.kn(i,n,h),void this.kn(s,r,h)}break
|
|
613
|
-
case 1:if(L*(
|
|
613
|
+
case 1:if(L*(S*S+_*_)>=T*T){const t=this.In.Mn??ut.Mn
|
|
614
614
|
if(0>=t)return this.kn(i,n,h),void this.kn(s,r,h)
|
|
615
615
|
{const e=s-i,c=r-n,l=o-s,u=a-r
|
|
616
616
|
if(t>Math.abs(Math.atan2(e*u-c*l,e*l+c*u)))return this.kn(i,n,h),void this.kn(s,r,h)}}break
|
|
617
|
-
case 2:if(L*(
|
|
617
|
+
case 2:if(L*(S*S+_*_)>=E*E){const o=this.In.Mn??ut.Mn
|
|
618
618
|
if(0>=o)return this.kn(i,n,h),void this.kn(s,r,h)
|
|
619
619
|
{const a=i-t,c=n-e,l=s-i,u=r-n
|
|
620
620
|
if(o>Math.abs(Math.atan2(a*u-c*l,a*l+c*u)))return this.kn(i,n,h),void this.kn(s,r,h)}}break
|
|
621
|
-
case 3:if(L*(
|
|
621
|
+
case 3:if(L*(S*S+_*_)>=(E+T)*(E+T)){const c=this.In.Mn??ut.Mn
|
|
622
622
|
if(0>=c)return this.kn(i,n,h),void this.kn(s,r,h)
|
|
623
|
-
{const l=i-t,u=n-e,f=s-i,d=r-n,
|
|
624
|
-
if(c>Math.abs(Math.atan2(l*d-u*f,l*f+u*d))+Math.abs(Math.atan2(f*
|
|
623
|
+
{const l=i-t,u=n-e,f=s-i,d=r-n,y=o-s,p=a-r
|
|
624
|
+
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.kn(i,n,h),void this.kn(s,r,h)}}}this.Dn(t,e,l,u,w,g,x,b,h,c+1),this.Dn(x,b,m,v,y,p,o,a,h,c+1)}kn(t,e,i){const n=new J(t,e)
|
|
625
625
|
if(0===i.length)return void i.push(n)
|
|
626
626
|
const s=i[i.length-1],r=n.x-s.x,o=n.y-s.y
|
|
627
|
-
r*r+o*o>1e-12&&i.push(n)}}class
|
|
627
|
+
r*r+o*o>1e-12&&i.push(n)}}class yt{constructor(t,e){this.Bn=0,this.Un=0,this.$n=[],this.Nn=null,this.Pn=null,this.Rn={min:new J(1/0,1/0),max:new J(-1/0,-1/0)},this.Wn=[],this.jn=[],this.zn=[],this.Hn=new J(0,0),this.Vn=new dt(t),this.qn=new lt({...ct,...e})}setPosition(t,e){this.Hn.set(t,e)}Yn(t,e){this.Hn.x+=t,this.Hn.y+=e}Jn(t,e){this.$n.length>0&&this.Kn(),this.Bn=t,this.Un=e,this.$n=[],this.Rn.min.set(1/0,1/0),this.Rn.max.set(-1/0,-1/0),this.jn.push(this.Hn.clone())}Kn(){this.Nn&&this.Xn(),this.$n.length>0&&(this.Wn.push({Qn:this.Bn,Zn:this.$n,bounds:{min:{x:this.Rn.min.x,y:this.Rn.min.y},max:{x:this.Rn.max.x,y:this.Rn.max.y}}}),this.zn.push(this.Un)),this.$n=[]}ts(t,e){this.Nn&&this.Xn(),this.Pn=new J(t,e),this.es(this.Pn),this.Nn={points:[this.Pn],glyphIndex:this.Bn}}ns(t,e){if(!this.Nn||!this.Pn)return
|
|
628
628
|
const i=new J(t,e)
|
|
629
629
|
this.es(i),this.Nn.points.push(i),this.Pn=i}ss(t,e,i,n){if(!this.Nn||!this.Pn)return
|
|
630
630
|
const s=this.Pn,r=new J(t,e),o=new J(i,n)
|
|
@@ -639,22 +639,22 @@ for(let t=0;f.length>t;t++){const e=f[t]
|
|
|
639
639
|
this.es(e),this.Nn.points.push(e)}this.Pn=c}hs(){if(!this.Nn||!this.Pn)return
|
|
640
640
|
const t=this.Nn.points[0]
|
|
641
641
|
this.Pn.equals(t)||this.Nn.points.push(t),this.Xn()}Xn(){if(this.Nn){const t=this.qn.xn(this.Nn)
|
|
642
|
-
this.$n.push(t),this.Nn=null,this.Pn=null}}es(t){this.Rn.min.x=Math.min(this.Rn.min.x,t.x),this.Rn.min.y=Math.min(this.Rn.min.y,t.y),this.Rn.max.x=Math.max(this.Rn.max.x,t.x),this.Rn.max.y=Math.max(this.Rn.max.y,t.y)}cs(){return this.$n.length>0&&this.Kn(),this.Wn}ls(){return this.jn}us(){return this.zn}reset(){this.Wn=[],this.jn=[],this.zn=[],this.$n=[],this.Nn=null,this.Pn=null,this.
|
|
643
|
-
if(this.
|
|
642
|
+
this.$n.push(t),this.Nn=null,this.Pn=null}}es(t){this.Rn.min.x=Math.min(this.Rn.min.x,t.x),this.Rn.min.y=Math.min(this.Rn.min.y,t.y),this.Rn.max.x=Math.max(this.Rn.max.x,t.x),this.Rn.max.y=Math.max(this.Rn.max.y,t.y)}cs(){return this.$n.length>0&&this.Kn(),this.Wn}ls(){return this.jn}us(){return this.zn}reset(){this.Wn=[],this.jn=[],this.zn=[],this.$n=[],this.Nn=null,this.Pn=null,this.Bn=0,this.Un=0,this.Hn.set(0,0),this.Rn={min:new J(1/0,1/0),max:new J(-1/0,-1/0)}}Fn(t){this.Vn.Fn(t)}fs(t){this.qn.vn({...ct,...t})}ds(){return this.qn.getStats()}}class pt{constructor(){this.ys=null,this.ps=null,this.ws=null,this.gs=null,this.vs=null,this.xs=0,this.position={x:0,y:0}}setPosition(t,e){this.position.x=t,this.position.y=e,this.bs&&this.bs.setPosition(t,e)}Yn(t,e){this.position.x+=t,this.position.y+=e,this.bs&&this.bs.Yn(t,e)}Ss(t){this.bs=t}_s(t,e){if(!t||!t.module||!t.hb)throw Error("Invalid font object")
|
|
643
|
+
if(this.bs=e,this.xs)return
|
|
644
644
|
const i=t.module
|
|
645
|
-
this.
|
|
645
|
+
this.ys=i.Es((t,e,i,n,s)=>{this.bs?.ts(n,s)},"viiiffi"),this.ps=i.Es((t,e,i,n,s)=>{this.bs?.ns(n,s)},"viiiffi"),this.ws=i.Es((t,e,i,n,s,r,o)=>{this.bs?.ss(n,s,r,o)},"viiiffffi"),this.gs=i.Es((t,e,i,n,s,r,o,a,h)=>{this.bs?.rs(n,s,r,o,a,h)},"viiiffffffi"),this.vs=i.Es(()=>{this.bs?.hs()},"viiii"),this.xs=i.exports.Ts(),i.exports.As(this.xs,this.ys,0,0),i.exports.Ls(this.xs,this.ps,0,0),i.exports.Ms(this.xs,this.ws,0,0),i.exports.Is(this.xs,this.gs,0,0),i.exports.Fs(this.xs,this.vs,0,0)}Gs(){if(!this.xs)throw Error("Draw functions not initialized")
|
|
646
646
|
return this.xs}destroy(t){if(!t||!t.module||!t.hb)return
|
|
647
647
|
const e=t.module
|
|
648
|
-
try{this.xs&&(e.exports.Os(this.xs),this.xs=0),null!==this.
|
|
649
|
-
class gt{constructor(t,e){this.Cs="default",this.Ds="default",this.
|
|
648
|
+
try{this.xs&&(e.exports.Os(this.xs),this.xs=0),null!==this.ys&&(e.ks(this.ys),this.ys=null),null!==this.ps&&(e.ks(this.ps),this.ps=null),null!==this.ws&&(e.ks(this.ws),this.ws=null),null!==this.gs&&(e.ks(this.gs),this.gs=null),null!==this.vs&&(e.ks(this.vs),this.vs=null)}catch(t){h.warn("Error destroying draw callbacks:",t)}this.bs=void 0}}const wt=new WeakMap
|
|
649
|
+
class gt{constructor(t,e){this.Cs="default",this.Ds="default",this.Bs=new Set,this.cache=t,this.ae=e,this.tessellator=new rt,this.Us=new ot,this.$s=new at,this.bs=new yt,this.Ns=(()=>{const t=this.ae.module,e=wt.get(t)
|
|
650
650
|
if(e)return e
|
|
651
|
-
const i=new
|
|
652
|
-
return wt.set(t,i),i})(),this.Ns._s(this.ae,this.
|
|
651
|
+
const i=new pt
|
|
652
|
+
return wt.set(t,i),i})(),this.Ns._s(this.ae,this.bs),this.Ps=Z,this.Rs=tt,this.Ws=et}ds(){return this.bs.ds()}Fn(t){this.In=t,this.bs.Fn(t),this.js()}fs(t){this.zs=t,this.bs.fs(t),this.js()}Hs(t){this.Cs=t,this.js()}js(){this.Ds=`${this.Cs}__${this.Vs()}`}Vs(){const t=this.In?.Ln??ut.Ln,e=this.In?.Mn??ut.Mn,i=this.zs?.enabled??!0,n=this.zs?.dn??1,s=this.zs?.yn??.0087,r=this.zs?.pn??10
|
|
653
653
|
return[`cf:${t.toFixed(4)},${e.toFixed(4)}`,`opt:${i?1:0},${n.toFixed(4)},${s.toFixed(6)},${r.toFixed(4)}`].join("|")}qs(t,e,i,s,r,o=!1,h){if(a){let e=0
|
|
654
654
|
for(let i=0;t.length>i;i++)e+=t[i].length}const c=[]
|
|
655
655
|
let l=0,u=0,f=0,d=0
|
|
656
|
-
const
|
|
657
|
-
return c.push({data:t,px:e,Ys:i,Js:n,Ks:s}),l+=t.vertices.length,u+=t.normals.length,f+=t.indices.length,d+=t.vertices.length/3,s},
|
|
656
|
+
const y=(t,e,i,n)=>{const s=d
|
|
657
|
+
return c.push({data:t,px:e,Ys:i,Js:n,Ks:s}),l+=t.vertices.length,u+=t.normals.length,f+=t.indices.length,d+=t.vertices.length/3,s},p=[],w={min:{x:1/0,y:1/0,z:0},max:{x:-1/0,y:-1/0,z:e}}
|
|
658
658
|
for(let r=0;t.length>r;r++){const a=t[r]
|
|
659
659
|
for(const t of a){const r=t.position.x,a=t.position.y,c=t.position.z,l=[]
|
|
660
660
|
for(const e of t.glyphs)l.push(this.Xs(e.g))
|
|
@@ -671,77 +671,77 @@ for(const o of u)if(o.length>1&&!d){const n=o.map(e=>t.glyphs[e]),h=this.tr(n,e,
|
|
|
671
671
|
let u=this.Rs.get(h)
|
|
672
672
|
if(!u){const i=[],r=n[0].x??0,a=n[0].y??0
|
|
673
673
|
for(let e=0;o.length>e;e++){const n=o[e],s=l[n],h=t.glyphs[n],c=(h.x??0)-r,u=(h.y??0)-a
|
|
674
|
-
for(const t of s.Zn)i.push({...t,points:t.points.map(t=>new J(t.x+c,t.y+u))})}u=this.er(i,e,s),this.Rs.set(h,u)}const f=n[0],d=
|
|
674
|
+
for(const t of s.Zn)i.push({...t,points:t.points.map(t=>new J(t.x+c,t.y+u))})}u=this.er(i,e,s),this.Rs.set(h,u)}const f=n[0],d=y(u,r+(f.x??0),a+(f.y??0),c),g=u.vertices.length/3
|
|
675
675
|
for(let i=0;o.length>i;i++){const n=o[i],s=t.glyphs[n],h=this.ir(s,d,g,r+(s.x??0),a+(s.y??0),c,l[n],e)
|
|
676
|
-
|
|
676
|
+
p.push(h),this.nr(h.bounds,w)}}else for(const h of o){const o=t.glyphs[h],u=l[h],f=r+(o.x??0),d=a+(o.y??0),g=c
|
|
677
677
|
if(0===u.Zn.length){const t=this.ir(o,0,0,f,d,g,u,e)
|
|
678
|
-
|
|
678
|
+
p.push(t)
|
|
679
679
|
continue}const m=n(this.Ds,o.g,e,i)
|
|
680
680
|
let v=this.cache.get(m)
|
|
681
681
|
v?v.sr++:(v=this.rr(u,e,i,s),this.cache.set(m,v))
|
|
682
|
-
const x=
|
|
683
|
-
|
|
684
|
-
let x=0,
|
|
682
|
+
const x=y(v,f,d,g),b=this.ir(o,x,v.vertices.length/3,f,d,g,u,e)
|
|
683
|
+
p.push(b),this.nr(b.bounds,w)}}}const g=new Float32Array(l),m=new Float32Array(u),v=new Uint32Array(f)
|
|
684
|
+
let x=0,b=0,S=0
|
|
685
685
|
for(let t=0;c.length>t;t++){const e=c[t],i=e.data.vertices,n=e.data.normals,s=e.data.indices,o=e.px,a=e.Ys,h=e.Js
|
|
686
686
|
for(let t=0;i.length>t;t+=3)g[x++]=(i[t]+o)*r,g[x++]=(i[t+1]+a)*r,g[x++]=(i[t+2]+h)*r
|
|
687
|
-
m.set(n,
|
|
687
|
+
m.set(n,b),b+=n.length
|
|
688
688
|
const l=e.Ks
|
|
689
|
-
for(let t=0;s.length>t;t++)v[
|
|
690
|
-
for(let t=0;
|
|
691
|
-
return{vertices:g,normals:m,indices:v,ar:
|
|
689
|
+
for(let t=0;s.length>t;t++)v[S++]=s[t]+l}w.min.x*=r,w.min.y*=r,w.min.z*=r,w.max.x*=r,w.max.y*=r,w.max.z*=r
|
|
690
|
+
for(let t=0;p.length>t;t++)p[t].bounds.min.x*=r,p[t].bounds.min.y*=r,p[t].bounds.min.z*=r,p[t].bounds.max.x*=r,p[t].bounds.max.y*=r,p[t].bounds.max.z*=r
|
|
691
|
+
return{vertices:g,normals:m,indices:v,ar:p,planeBounds:w}}tr(t,e,i){if(0===t.length)return""
|
|
692
692
|
const n=t[0].x??0,s=t[0].y??0,r=t.map(t=>`${t.g}:${(t.x??0)-n},${(t.y??0)-s}`).join("|")
|
|
693
|
-
return`${this.Ds}_${r}_${Math.round(1e3*e)/1e3}_${i}`}ir(t,e,i,n,s,r,o,a){return{hr:t.Zs,cr:t.cr,Ks:e,lr:i,bounds:{min:{x:o.bounds.min.x+n,y:o.bounds.min.y+s,z:r},max:{x:o.bounds.max.x+n,y:o.bounds.max.y+s,z:r+a}}}}Xs(t){if(this.
|
|
693
|
+
return`${this.Ds}_${r}_${Math.round(1e3*e)/1e3}_${i}`}ir(t,e,i,n,s,r,o,a){return{hr:t.Zs,cr:t.cr,Ks:e,lr:i,bounds:{min:{x:o.bounds.min.x+n,y:o.bounds.min.y+s,z:r},max:{x:o.bounds.max.x+n,y:o.bounds.max.y+s,z:r+a}}}}Xs(t){if(this.Bs.has(t))return{Qn:t,Zn:[],bounds:{min:{x:0,y:0},max:{x:0,y:0}}}
|
|
694
694
|
const e=`${this.Ds}_${t}`,i=this.Ps.get(e)
|
|
695
695
|
if(i)return i
|
|
696
|
-
this.Ns.
|
|
697
|
-
const n=this.
|
|
698
|
-
return 0===n.Zn.length&&this.
|
|
699
|
-
return this.
|
|
696
|
+
this.Ns.Ss(this.bs),this.bs.reset(),this.bs.Jn(t,0),this.ae.module.exports.ur(this.ae.font.dr,t,this.Ns.Gs(),0),this.bs.Kn()
|
|
697
|
+
const n=this.bs.cs()[0]||{Qn:t,Zn:[],bounds:{min:{x:0,y:0},max:{x:0,y:0}}}
|
|
698
|
+
return 0===n.Zn.length&&this.Bs.add(t),this.Ps.set(e,n),n}er(t,e,i){const n=this.tessellator.process(t,!0,i,0!==e)
|
|
699
|
+
return this.yr(n,e)}yr(t,e){const i=this.Us.Ki(t,e,this.ae.upem),n=i.vertices
|
|
700
700
|
let s=1/0,r=1/0,o=1/0,a=-1/0,h=-1/0,c=-1/0
|
|
701
701
|
for(let t=0;n.length>t;t+=3){const e=n[t],i=n[t+1],l=n[t+2]
|
|
702
702
|
s>e&&(s=e),e>a&&(a=e),r>i&&(r=i),i>h&&(h=i),o>l&&(o=l),l>c&&(c=l)}const l=new K(s,r,o),u=new K(a,h,c)
|
|
703
703
|
return{geometry:t,vertices:i.vertices,normals:i.normals,indices:i.indices,bounds:{min:l,max:u},sr:1}}rr(t,e,i,n){const s=this.tessellator.process(t.Zn,i,n,0!==e)
|
|
704
|
-
return this.
|
|
705
|
-
i.x>s.x&&(i.x=s.x),i.y>s.y&&(i.y=s.y),i.z>s.z&&(i.z=s.z),r.x>n.x&&(n.x=r.x),r.y>n.y&&(n.y=r.y),r.z>n.z&&(n.z=r.z)}
|
|
704
|
+
return this.yr(s,e)}nr(t,e){const i=e.min,n=e.max,s=t.min,r=t.max
|
|
705
|
+
i.x>s.x&&(i.x=s.x),i.y>s.y&&(i.y=s.y),i.z>s.z&&(i.z=s.z),r.x>n.x&&(n.x=r.x),r.y>n.y&&(n.y=r.y),r.z>n.z&&(n.z=r.z)}pr(){return this.cache.getStats()}clearCache(){this.cache.clear(),this.Rs.clear(),this.Ws.clear(),this.Ps.clear()}}class mt{constructor(t,e){this.wr=new Map,this.ae=t,this.gr=e}mr(t,e,i,n,s,r,o){try{const r=[]
|
|
706
706
|
return t.forEach((t,o)=>{const a=this.vr(t,o,e,i,n,s)
|
|
707
707
|
r.push(a)}),r}finally{}}vr(e,i,n,s,r,o){const a=this.ae.hb.createBuffer()
|
|
708
|
-
"rtl"===o&&a.
|
|
708
|
+
"rtl"===o&&a.br("rtl"),a.ne(e.text),a.se()
|
|
709
709
|
const h=t(this.ae.re)
|
|
710
710
|
this.ae.hb.shape(this.ae.font,a,h)
|
|
711
711
|
const c=a.json(this.ae.font)
|
|
712
712
|
a.destroy()
|
|
713
713
|
const l=[]
|
|
714
|
-
let u=[],f=[],d=0,
|
|
715
|
-
const g=s*this.ae.upem,m=this.
|
|
714
|
+
let u=[],f=[],d=0,y=0,p=e.Bt,w=-i*n
|
|
715
|
+
const g=s*this.ae.upem,m=this.Sr(e,r,s),v=this._r(e,r),x=e.text,b=x.length,S=c.length
|
|
716
716
|
let _
|
|
717
|
-
for(let t=0;
|
|
718
|
-
n.Zs=e.$t&&s===
|
|
719
|
-
const h=
|
|
720
|
-
if(a||(0===u.length&&(d=h,
|
|
717
|
+
for(let t=0;S>t;t++){const n=c[t],s=n.oe,r=x[s],o=r.charCodeAt(0),a=32===o||9===o||10===o||13===o
|
|
718
|
+
n.Zs=e.$t&&s===b-1&&"-"===r?e.Dt:e.Ct+s,n.cr=i,a&&u.length>0&&(l.push({text:f.join(""),glyphs:u,position:new K(d,y,0)}),u=[],f=[])
|
|
719
|
+
const h=p+n.dx,E=w+n.dy
|
|
720
|
+
if(a||(0===u.length&&(d=h,y=E),n.x=h-d,n.y=E-y,u.push(n),f.push(r)),p+=n.ax,w+=n.ay,0!==g&&S-1>t&&(p+=g),a&&(p+=m),0!==v&&S-1>t&&!a){const e=x[c[t+1].oe],i=void 0!==_?_:A.K(r)
|
|
721
721
|
if(_=!!e&&A.K(e),i&&_){let t=!0
|
|
722
|
-
A.X(e)&&(t=!1),A.Z(r)&&(t=!1),A.tt(r)&&A.tt(e)&&(t=!1),t&&(
|
|
723
|
-
if(void 0!==t.qt&&"justify"===e&&!t.
|
|
724
|
-
void 0===e&&(e=M.measureTextWidth(this.ae," ",i),this.wr.set(i,e)),t.qt>0?n=t.qt*e*.5:0>t.qt&&(n=t.qt*e*f)}return n}_r(t,e){if(void 0===t.qt||"justify"!==e||t.
|
|
725
|
-
return t.qt>0||0>t.qt?.04*t.qt*this.ae.upem:0}clearCache(){this.gr.clearCache()}
|
|
722
|
+
A.X(e)&&(t=!1),A.Z(r)&&(t=!1),A.tt(r)&&A.tt(e)&&(t=!1),t&&(p+=v)}}else _=void 0}return u.length>0&&l.push({text:f.join(""),glyphs:u,position:new K(d,y,0)}),l}Sr(t,e,i){let n=0
|
|
723
|
+
if(void 0!==t.qt&&"justify"===e&&!t.Ut){let e=this.wr.get(i)
|
|
724
|
+
void 0===e&&(e=M.measureTextWidth(this.ae," ",i),this.wr.set(i,e)),t.qt>0?n=t.qt*e*.5:0>t.qt&&(n=t.qt*e*f)}return n}_r(t,e){if(void 0===t.qt||"justify"!==e||t.Ut)return 0
|
|
725
|
+
return t.qt>0||0>t.qt?.04*t.qt*this.ae.upem:0}clearCache(){this.gr.clearCache()}pr(){return this.gr.pr()}}var vt={exports:{}},xt=r(Object.freeze({__proto__:null,default:{},Er(){throw Error("fs not available in browser")}}))
|
|
726
726
|
!(function(t){var e,i=(e="undefined"!=typeof document?document.currentScript?.src:void 0,async function(t={}){function i(){var t=g.buffer
|
|
727
|
-
s.HEAP8=new Int8Array(t),s.HEAPU8=m=new Uint8Array(t),s.HEAP32=new Int32Array(t),s.HEAPU32=new Uint32Array(t),s.HEAPF32=new Float32Array(t),new BigInt64Array(t),new BigUint64Array(t)}function n(t){s.Tr?.(t),x(t="Aborted("+t+")"),
|
|
727
|
+
s.HEAP8=new Int8Array(t),s.HEAPU8=m=new Uint8Array(t),s.HEAP32=new Int32Array(t),s.HEAPU32=new Uint32Array(t),s.HEAPF32=new Float32Array(t),new BigInt64Array(t),new BigUint64Array(t)}function n(t){s.Tr?.(t),x(t="Aborted("+t+")"),b=!0,t+=". Build with -sASSERTIONS for more info."
|
|
728
728
|
var e=new WebAssembly.RuntimeError(t)
|
|
729
729
|
throw w?.(e),e}var s=t,r="object"==typeof window,o="undefined"!=typeof WorkerGlobalScope,a="object"==typeof process&&process.versions?.node&&"renderer"!=process.type,h=(t,e)=>{throw e}
|
|
730
730
|
"undefined"!=typeof __filename?e=__filename:o&&(e=self.location.href)
|
|
731
731
|
var c,l,u=""
|
|
732
732
|
if(a){var f=xt
|
|
733
|
-
u=__dirname+"/",l=t=>(t=
|
|
734
|
-
return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),c=async t=>{if(
|
|
733
|
+
u=__dirname+"/",l=t=>(t=S(t)?new URL(t):t,f.Er(t)),c=async(t,e=!0)=>(t=S(t)?new URL(t):t,f.Er(t,e?void 0:"utf8")),process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),h=(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
|
|
734
|
+
return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),c=async t=>{if(S(t))return new Promise((e,i)=>{var n=new XMLHttpRequest
|
|
735
735
|
n.open("GET",t,!0),n.responseType="arraybuffer",n.onload=()=>{200==n.status||0==n.status&&n.response?e(n.response):i(n.status)},n.onerror=i,n.send(null)})
|
|
736
736
|
var e=await fetch(t,{credentials:"same-origin"})
|
|
737
737
|
if(e.ok)return e.arrayBuffer()
|
|
738
738
|
throw Error(e.status+" : "+e.url)}}console.log.bind(console)
|
|
739
|
-
var d,p,
|
|
739
|
+
var d,y,p,w,g,m,v,x=console.error.bind(console),b=!1,S=t=>t.startsWith("file://"),_=!1,E=0,T=null
|
|
740
740
|
class A{name="ExitStatus"
|
|
741
|
-
constructor(t){this.message=`Program terminated with exit(${t})`,this.status=t}}var L,M,I,F=t=>{for(;t.length>0;)t.shift()(s)},G=[],O=t=>G.push(t),k=[],C=t=>k.push(t),D=!0,
|
|
742
|
-
h(1,t)},N=()=>D||
|
|
741
|
+
constructor(t){this.message=`Program terminated with exit(${t})`,this.status=t}}var L,M,I,F=t=>{for(;t.length>0;)t.shift()(s)},G=[],O=t=>G.push(t),k=[],C=t=>k.push(t),D=!0,B=0,U={},$=t=>{if(t instanceof A||"unwind"==t)return y
|
|
742
|
+
h(1,t)},N=()=>D||B>0,P=t=>{y=t,N()||(s.Ar?.(t),b=!0),h(t,new A(t))},R=(t,e)=>Math.ceil(t/e)*e,W=t=>{var e=(t-g.buffer.byteLength+65535)/65536|0
|
|
743
743
|
try{return g.grow(e),i(),1}catch(t){}},j=t=>{const e=t.length
|
|
744
|
-
return[e%128|128,e>>7,...t]},z={
|
|
744
|
+
return[e%128|128,e>>7,...t]},z={pi:127,gi:127,xi:126,f:125,d:124,e:111},H=t=>j(Array.from(t,t=>z[t])),V=t=>L.get(t),q=[],Y=(t,e)=>L.set(t,e)
|
|
745
745
|
s.Lr&&(D=s.Lr),s.Mr&&(x=s.Mr),s.Ir&&(d=s.Ir),s.Fr=g,s.Gr=K,s.Es=(t,e)=>{var i=(t=>(M||(M=new WeakMap,((t,e)=>{if(M)for(var i=0;0+e>i;i++){var n=V(i)
|
|
746
746
|
n&&M.set(n,i)}})(0,L.length)),M.get(t)||0))(t)
|
|
747
747
|
if(i)return i
|
|
@@ -750,26 +750,26 @@ try{Y(n,t)}catch(i){if(!(i instanceof TypeError))throw i
|
|
|
750
750
|
var s=((t,e)=>{var i=Uint8Array.of(0,97,115,109,1,0,0,0,1,...j([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),n=new WebAssembly.Module(i)
|
|
751
751
|
return new WebAssembly.Instance(n,{e:{f:t}}).exports.f})(t,e)
|
|
752
752
|
Y(n,s)}return M.set(t,n),n},s.ks=t=>{M.delete(V(t)),Y(t,null),q.push(t)}
|
|
753
|
-
var J={Or:()=>n(""),kr(){D=!1,
|
|
754
|
-
var i=setTimeout(()=>{delete
|
|
755
|
-
return
|
|
753
|
+
var J={Or:()=>n(""),kr(){D=!1,B=0},Cr(t,e){if(U[t]&&(clearTimeout(U[t].id),delete U[t]),!e)return 0
|
|
754
|
+
var i=setTimeout(()=>{delete U[t],(t=>{if(!b)try{t(),(()=>{if(!N())try{y=t=y,P(t)}catch(t){$(t)}var t})()}catch(t){$(t)}})(()=>I(t,performance.now()))},e)
|
|
755
|
+
return U[t]={id:i,Dr:e},0},Br(t){var e=m.length,i=2147483648
|
|
756
756
|
if((t>>>=0)>i)return!1
|
|
757
757
|
for(var n=1;4>=n;n*=2){var s=e*(1+.2/n),r=Math.min(i,R(Math.max(t,s=Math.min(s,t+100663296)),65536))
|
|
758
|
-
if(W(r))return!0}return!1},
|
|
758
|
+
if(W(r))return!0}return!1},Ur:P},K=await(async()=>{function t(t){return s.Gr=K=t.exports,s.Fr=g=K.memory,i(),L=K.$r,(t=>{s.Nr=t.Pr,s.Rr=t.Wr,s.jr=t.zr,s.Hr=t.Vr,s.qr=t.Yr,s.Jr=t.Kr,s.Xr=t.Qr,s.Zr=t.eo,s.io=t.no,s.so=t.ro,s.oo=t.ao,s.ho=t.co,s.lo=t.uo,s.fo=t.do,s.yo=t.po,s.wo=t.mo,s.vo=t.xo,s.bo=t.So,s._o=t.Eo,s.To=t.Ao,s.Lo=t.Mo,s.Io=t.Fo,s.Go=t.Oo,s.ko=t.Co,s.Do=t.Bo,s.Uo=t.$o,s.No=t.Po,s.Ro=t.Wo,s.jo=t.As,s.zo=t.Ls,s.Ho=t.Ms,s.Vo=t.Is,s.qo=t.Fs,s.Yo=t.Ts,s.Jo=t.Os,s.Ko=t.Xo,s.Qo=t.Zo,s.ta=t.ea,s.ia=t.na,s.sa=t.ra,s.oa=t.ur,s.aa=t.ha,s.ca=t.la,s.ua=t.fa,s.da=t.ya,s.pa=t.wa,s.ga=t.ma,s.va=t.xa,s.ba=t.Sa,s._a=t.Ea,s.Ta=t.Aa,s.La=t.Ma,I=t.Ia})(K),(()=>{if(E--,s.Fa?.(E),0==E&&T){var t=T
|
|
759
759
|
T=null,t()}})(),K}E++,s.Fa?.(E)
|
|
760
760
|
var e,r={o:J,Ga:J}
|
|
761
|
-
return s.Oa?new Promise(e=>{s.Oa(r,i=>{e(t(i))})}):(v??=(e="hb.wasm",s.ka?s.ka(e,u):u+e),t((await(async function(t,e,i){if(!t&&!
|
|
761
|
+
return s.Oa?new Promise(e=>{s.Oa(r,i=>{e(t(i))})}):(v??=(e="hb.wasm",s.ka?s.ka(e,u):u+e),t((await(async function(t,e,i){if(!t&&!S(e)&&!a)try{var s=fetch(e,{credentials:"same-origin"})
|
|
762
762
|
return await WebAssembly.instantiateStreaming(s,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)
|
|
763
763
|
return new Uint8Array(e)}catch{}return(t=>{if(t==v&&d)return new Uint8Array(d)
|
|
764
764
|
if(l)return l(t)
|
|
765
765
|
throw"both async and sync fetching of the wasm failed"})(t)})(t)
|
|
766
766
|
return await WebAssembly.instantiate(i,e)}catch(t){x("failed to asynchronously prepare wasm: "+t),n(t)}})(e,i)})(d,v,r)).Ca))})()
|
|
767
|
-
return(()=>{if(s.Da)for("function"==typeof s.Da&&(s.Da=[s.Da]);s.Da.length>0;)s.Da.shift()()})(),(function t(){function e(){s.
|
|
767
|
+
return(()=>{if(s.Da)for("function"==typeof s.Da&&(s.Da=[s.Da]);s.Da.length>0;)s.Da.shift()()})(),(function t(){function e(){s.Ba=!0,b||(_=!0,K.Ua(),p?.(s),s.$a?.(),(()=>{if(s.Na)for("function"==typeof s.Na&&(s.Na=[s.Na]);s.Na.length;)O(s.Na.shift())
|
|
768
768
|
F(G)})())}E>0?T=t:((()=>{if(s.Pa)for("function"==typeof s.Pa&&(s.Pa=[s.Pa]);s.Pa.length;)C(s.Pa.shift())
|
|
769
|
-
F(k)})(),E>0?T=t:s.setStatus?(s.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>s.setStatus(""),1),e()},1)):e())})(),_?s:new Promise((t,e)=>{
|
|
769
|
+
F(k)})(),E>0?T=t:s.setStatus?(s.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>s.setStatus(""),1),e()},1)):e())})(),_?s:new Promise((t,e)=>{p=t,w=e})})
|
|
770
770
|
t.exports=i,t.exports.default=i})(vt)
|
|
771
|
-
var
|
|
772
|
-
try{
|
|
771
|
+
var bt=s(vt.exports),St={exports:{}}
|
|
772
|
+
try{St.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=s.Po(e.length+1)
|
|
773
773
|
for(let n=0;e.length>n;++n){const s=e.charCodeAt(n)
|
|
774
774
|
if(s>127)throw Error("Expected ASCII text")
|
|
775
775
|
t.HEAPU8[i+n]=s}return t.HEAPU8[i+e.length]=0,{dr:i,length:e.length,Wo(){s.Wo(i)}}}function n(t,e,n){var r=0,o=0
|
|
@@ -785,44 +785,44 @@ const o=s.na(r)
|
|
|
785
785
|
return{dr:r,upem:o,Ra(i){var n=s.ea(r,e(i)),o=s.zr(n)
|
|
786
786
|
if(o){var a=s.Vr(n,null)
|
|
787
787
|
return t.HEAPU8.subarray(a,a+o)}},Ze(){var e=s.Po(2048),i=s.Po(4)
|
|
788
|
-
t.HEAPU32[i/4]=64,s.
|
|
788
|
+
t.HEAPU32[i/4]=64,s.Sa(r,0,i,e)
|
|
789
789
|
var n={}
|
|
790
790
|
return Array.from({length:t.HEAPU32[i/4]}).forEach((i,s)=>{var r
|
|
791
791
|
n[(r=t.HEAPU32[e/4+8*s+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*s+4],default:t.HEAPF32[e/4+8*s+5],max:t.HEAPF32[e/4+8*s+6]}}),s.Wo(i),s.Wo(e),n},Wa(){var e=s.ma()
|
|
792
792
|
s.ra(r,e)
|
|
793
793
|
var i=(e=>{const i=s.Ea(e),n=s.Po(i<<2),r=n>>2,o=t.HEAPU32.subarray(r,r+i)
|
|
794
794
|
return t.HEAPU32.set(o,r),s.Aa(e,-1,n,i),o})(e)
|
|
795
|
-
return s.xa(e),i},destroy(){s.Zo(r)}}},Xe(i){function n(t){return c||(f=o((t,e,i,n,s)=>{l+=`M${n},${s}`},"viiiffi"),d=o((t,e,i,n,s)=>{l+=`L${n},${s}`},"viiiffi"),
|
|
795
|
+
return s.xa(e),i},destroy(){s.Zo(r)}}},Xe(i){function n(t){return c||(f=o((t,e,i,n,s)=>{l+=`M${n},${s}`},"viiiffi"),d=o((t,e,i,n,s)=>{l+=`L${n},${s}`},"viiiffi"),y=o((t,e,i,n,s,r,o,a,h)=>{l+=`C${n},${s} ${r},${o} ${a},${h}`},"viiiffffffi"),p=o((t,e,i,n,s,r,o)=>{l+=`Q${n},${s} ${r},${o}`},"viiiffffi"),w=o(()=>{l+="Z"},"viiii"),c=s.Ts(),s.As(c,f,0,0),s.Ls(c,d,0,0),s.Is(c,y,0,0),s.Ms(c,p,0,0),s.Fs(c,w,0,0)),l="",s.ur(h,t,c,0),l}var h=s.la(i.dr),c=null,f=null,d=null,y=null,p=null,w=null
|
|
796
796
|
return{dr:h,ja(e){s.ha(h,e,u,256)
|
|
797
797
|
var i=t.HEAPU8.subarray(u,u+256)
|
|
798
798
|
return r.decode(i.slice(0,i.indexOf(0)))},za:n,Ha:t=>n(t).replace(/([MLQCZ])/g,"|$1 ").split("|").filter(t=>t.length).map(t=>{var e=t.split(/[ ,]/g)
|
|
799
799
|
return{type:e[0],values:e.slice(1).filter(t=>t.length).map(t=>+t)}}),setScale(t,e){s.wa(h,t,e)},Qe(i){var n=Object.entries(i),r=s.Po(8*n.length)
|
|
800
|
-
n.forEach((i,n)=>{t.HEAPU32[r/4+2*n+0]=e(i[0]),t.HEAPF32[r/4+2*n+1]=i[1]}),s.fa(h,r,n.length),s.Wo(r)},destroy(){s.
|
|
800
|
+
n.forEach((i,n)=>{t.HEAPU32[r/4+2*n+0]=e(i[0]),t.HEAPF32[r/4+2*n+1]=i[1]}),s.fa(h,r,n.length),s.Wo(r)},destroy(){s.ya(h),c&&(s.Os(c),c=null,a(f),a(d),a(y),a(p),a(w))}}},createBuffer(){var e=s.Kr()
|
|
801
801
|
return{dr:e,ne(i){const n=(e=>{const i=s.Po(2*e.length),n=new Uint16Array(t.Fr.buffer,i,e.length)
|
|
802
802
|
for(let t=0;n.length>t;++t)n[t]=e.charCodeAt(t)
|
|
803
803
|
return{dr:i,length:n.length,Wo(){s.Wo(i)}}})(i)
|
|
804
|
-
s.Ao(e,n.dr,n.length,0,n.length),n.Wo()},se:()=>s.
|
|
804
|
+
s.Ao(e,n.dr,n.length,0,n.length),n.Wo()},se:()=>s.So(e),br(t){s.no(e,{Va:4,qa:5,Ya:6,Ja:7}[t]||0)},Ka(t){var i=0
|
|
805
805
|
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)}),s.co(e,i)},Xa(t){var n=i(t)
|
|
806
806
|
s.ao(e,s.Fo(n.dr,-1)),n.Wo()},Qa(t){var n=i(t)
|
|
807
|
-
s.ro(e,s.Oo(n.dr,-1)),n.Wo()},Za(t){s.uo(e,t)},json(){for(var i=s.do(e),n=[],r=s.
|
|
808
|
-
return n},destroy(){s.Qr(e)}}},shape:n,th(e,i,h,l,u){var f=[],d=0,
|
|
809
|
-
return o.startsWith("start table GSUB")?d=1:o.startsWith("start table GPOS")&&(d=2),d!=u&&(
|
|
807
|
+
s.ro(e,s.Oo(n.dr,-1)),n.Wo()},Za(t){s.uo(e,t)},json(){for(var i=s.do(e),n=[],r=s.po(e,0),o=r/4,a=s.mo(e,0)/4,h=t.HEAPU32.subarray(o,o+5*i),c=t.HEAP32.subarray(a,a+5*i),l=0;i>l;++l)n.push({g:h[5*l+0],oe:h[5*l+2],ax:c[5*l+0],ay:c[5*l+1],dx:c[5*l+2],dy:c[5*l+3],flags:s.xo(r+20*l)})
|
|
808
|
+
return n},destroy(){s.Qr(e)}}},shape:n,th(e,i,h,l,u){var f=[],d=0,y=!1,p=1048576,w=s.Po(p),g=o((e,i,n)=>{var o=r.decode(t.HEAPU8.subarray(n,t.HEAPU8.indexOf(0,n)))
|
|
809
|
+
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:(s.Yr(e,0,s.do(e),w,p,0,i,c,4),f.push({bi:o,Ti:JSON.parse(r.decode(t.HEAPU8.subarray(w,t.HEAPU8.indexOf(0,w)))),glyphs:2==s.eo(e)}),1)},"iiiii")
|
|
810
810
|
return s.Mo(i.dr,g,0,0),n(e,i,h),s.Wo(w),a(g),f},version(){var e=s.Po(12)
|
|
811
811
|
s.Co(e,e+4,e+8)
|
|
812
812
|
var i={eh:t.HEAPU32[e/4],ih:t.HEAPU32[(e+4)/4],nh:t.HEAPU32[(e+8)/4]}
|
|
813
|
-
return s.Wo(e),i},sh(){var e=s.
|
|
814
|
-
return r.decode(t.HEAPU8.subarray(e,t.HEAPU8.indexOf(0,e)))}}}}catch(t){}var _t=s(
|
|
813
|
+
return s.Wo(e),i},sh(){var e=s.Bo()
|
|
814
|
+
return r.decode(t.HEAPU8.subarray(e,t.HEAPU8.indexOf(0,e)))}}}}catch(t){}var _t=s(St.exports)
|
|
815
815
|
let Et=null,Tt=null,At=null
|
|
816
816
|
const Lt={rh(t){Tt=t,At=null,Et=null},oh(t){At=t,Tt=null,Et=null},ah:async()=>Et||(Et=new Promise(async(t,e)=>{try{const e={}
|
|
817
817
|
if(At)e.Ir=At
|
|
818
818
|
else{if(!Tt)throw Error("HarfBuzz WASM path or buffer must be set before initialization.")
|
|
819
|
-
e.ka=(t,e)=>t.endsWith(".wasm")?Tt:e+t}const i=await
|
|
819
|
+
e.ka=(t,e)=>t.endsWith(".wasm")?Tt:e+t}const i=await bt(e)
|
|
820
820
|
t({hb:_t(i),module:{Es:i.Es,exports:i.Gr,ks:i.ks}})}catch(t){e(Error("Failed to initialize HarfBuzz: "+t))}}),Et)}
|
|
821
821
|
class Mt{constructor(t,e){this.text=t,this.hh=new Map,e.forEach(t=>{const e=this.hh.get(t.hr)||[]
|
|
822
822
|
e.push(t),this.hh.set(t.hr,e)})}uh(t){const e=[]
|
|
823
|
-
return t.fh&&e.push(...this.dh(t.fh)),t.
|
|
823
|
+
return t.fh&&e.push(...this.dh(t.fh)),t.yh&&e.push(...this.ph(t.yh)),e}dh(t){const e=[]
|
|
824
824
|
for(const i of t){let t=0
|
|
825
|
-
for(;-1!==(t=this.text.indexOf(i,t));)e.push(this.createTextRange(t,t+i.length,i)),t+=i.length}return e}
|
|
825
|
+
for(;-1!==(t=this.text.indexOf(i,t));)e.push(this.createTextRange(t,t+i.length,i)),t+=i.length}return e}ph(t){return t.map(t=>{const e=this.text.slice(t.start,t.end)
|
|
826
826
|
return this.createTextRange(t.start,t.end,e)})}createTextRange(t,e,i){const n=[],s=new Map
|
|
827
827
|
for(let i=t;e>i;i++){const t=this.hh.get(i)
|
|
828
828
|
if(t)for(const e of t){n.push(e)
|
|
@@ -831,11 +831,11 @@ t.push(e),s.set(e.cr,t)}}return{start:t,end:e,wh:i,bounds:Array.from(s.values())
|
|
|
831
831
|
let e=1/0,i=1/0,n=1/0,s=-1/0,r=-1/0,o=-1/0
|
|
832
832
|
for(const a of t)e>a.bounds.min.x&&(e=a.bounds.min.x),i>a.bounds.min.y&&(i=a.bounds.min.y),n>a.bounds.min.z&&(n=a.bounds.min.z),a.bounds.max.x>s&&(s=a.bounds.max.x),a.bounds.max.y>r&&(r=a.bounds.max.y),a.bounds.max.z>o&&(o=a.bounds.max.z)
|
|
833
833
|
return{min:{x:e,y:i,z:n},max:{x:s,y:r,z:o}}}}const It=72
|
|
834
|
-
class Ft{static{this.xh=new Map}static{this.
|
|
834
|
+
class Ft{static{this.xh=new Map}static{this.bh=null}static{this.Sh=new Map}static{this._h=0}static{this.Eh=1/0}static{this.Th=0}static Ah(t){const e=Object.keys(t).sort()
|
|
835
835
|
let i=""
|
|
836
836
|
for(let n=0;e.length>n;n++)n>0&&(i+=","),i+=e[n]+":"+t[e[n]]
|
|
837
|
-
return i}constructor(){this.Lh="",Ft.
|
|
838
|
-
Ft.
|
|
837
|
+
return i}constructor(){this.Lh="",Ft.bh||(Ft.bh=Lt.ah()),this.Mh=new V(()=>Ft.bh)}static Ih(t){Lt.rh(t),Ft.bh=null}static Fh(t){Lt.oh(t),Ft.bh=null}static init(){return Ft.bh||(Ft.bh=Lt.ah()),Ft.bh}static async create(t){if(!t.font)throw Error("Font is required. Specify options.font as a URL string or ArrayBuffer.")
|
|
838
|
+
Ft.bh||(Ft.bh=Lt.ah())
|
|
839
839
|
const e=await Ft.Gh(t),i=new Ft
|
|
840
840
|
i.Oh(e)
|
|
841
841
|
const n=await i.kh(t),s=async e=>{const n={...t}
|
|
@@ -844,20 +844,20 @@ void 0!==i&&(n[t]=i)}if(void 0!==e.font||void 0!==e.ti||void 0!==e.re){const t=a
|
|
|
844
844
|
i.Oh(t),i.Ch()}return t=n,{...await i.kh(t),getLoadedFont(){return i.getLoadedFont()},getCacheSize(){return i.getCacheSize()},clearCache(){return i.clearCache()},measureTextWidth(t,e){return i.measureTextWidth(t,e)},update:s}}
|
|
845
845
|
return{...n,getLoadedFont(){return i.getLoadedFont()},getCacheSize(){return i.getCacheSize()},clearCache(){return i.clearCache()},measureTextWidth(t,e){return i.measureTextWidth(t,e)},update:s}}static async Gh(t){let e="string"==typeof t.font?t.font:"buffer-"+Ft.Dh(t.font)
|
|
846
846
|
t.ti&&(e+="_var_"+Ft.Ah(t.ti)),t.re&&(e+="_feat_"+Ft.Ah(t.re))
|
|
847
|
-
let i=Ft.
|
|
848
|
-
return i||(i=await Ft.
|
|
847
|
+
let i=Ft.Sh.get(e)
|
|
848
|
+
return i||(i=await Ft.Bh(e,t.font,t.ti,t.re)),i}static async Bh(t,e,i,n){const s=new Ft
|
|
849
849
|
await s.Ye(e,i,n)
|
|
850
850
|
const r=s.getLoadedFont()
|
|
851
|
-
return Ft.
|
|
852
|
-
e&&(Ft._h-=e.ri?.byteLength??0,0>Ft._h&&(Ft._h=0))}static $h(){if(Ft.Eh!==1/0)for(;Ft._h>Ft.Eh&&Ft.
|
|
851
|
+
return Ft.Sh.set(t,r),Ft.Uh(r),Ft.$h(),r}static Uh(t){Ft._h+=t.ri?.byteLength??0}static Nh(t){const e=Ft.Sh.get(t)
|
|
852
|
+
e&&(Ft._h-=e.ri?.byteLength??0,0>Ft._h&&(Ft._h=0))}static $h(){if(Ft.Eh!==1/0)for(;Ft._h>Ft.Eh&&Ft.Sh.size>0;){const t=Ft.Sh.keys().next().value
|
|
853
853
|
if(void 0===t)break
|
|
854
|
-
Ft.Nh(t),Ft.
|
|
854
|
+
Ft.Nh(t),Ft.Sh.delete(t)}}static Dh(t){if(t){const e=new Uint8Array(t)
|
|
855
855
|
let i=2166136261
|
|
856
856
|
const n=Math.min(32,e.length),s=Math.floor(e.length/n)
|
|
857
857
|
for(let t=0;n>t;t++)i^=e[t*s],i=Math.imul(i,16777619)
|
|
858
858
|
return i^=e.length,i=Math.imul(i,16777619),(i>>>0).toString(36)}return"c"+ ++Ft.Th}Oh(t){this.ae=t
|
|
859
859
|
const e=Ft.Dh(t.ri)
|
|
860
|
-
this.Lh="font_"+e,t.ti&&(this.Lh+="_var_"+Ft.Ah(t.ti)),t.re&&(this.Lh+="_feat_"+Ft.Ah(t.re))}async Ye(t,e,i){Ft.
|
|
860
|
+
this.Lh="font_"+e,t.ti&&(this.Lh+="_var_"+Ft.Ah(t.ti)),t.re&&(this.Lh+="_feat_"+Ft.Ah(t.re))}async Ye(t,e,i){Ft.bh||(Ft.bh=Lt.ah()),await Ft.bh
|
|
861
861
|
const n="string"==typeof t?await fetch(t).then(e=>{if(!e.ok)throw Error(`Failed to load font from ${t}: HTTP ${e.status} ${e.statusText}`)
|
|
862
862
|
return e.arrayBuffer()}):t
|
|
863
863
|
try{this.ae&&this.destroy(),this.ae=await this.Mh.Ye(n,e),i&&(this.ae.re=i)
|
|
@@ -867,56 +867,67 @@ const e=await this.Ph(t)
|
|
|
867
867
|
this.Rh(e),this.Wh(t=e),this.gr||(this.gr=new gt(Q,this.ae),this.gr.Hs(this.Lh)),this.gr.Fn(t.jh),this.gr.fs(t.zh),this.ae.font.setScale(this.ae.upem,this.ae.upem),this.Hh||(this.Hh=new mt(this.ae,this.gr))
|
|
868
868
|
const i=this.Vh(t),n=t.qh??this.ae.ei??!1,s=this.Hh.mr(i.lines,i.Yh,i.letterSpacing,i.align,i.direction,t.color,t.text)
|
|
869
869
|
let r,o
|
|
870
|
-
if(t.color&&"object"==typeof t.color&&!Array.isArray(t.color)&&(t.color.fh||t.color.
|
|
870
|
+
if(t.color&&"object"==typeof t.color&&!Array.isArray(t.color)&&(t.color.fh||t.color.yh)){if(r=new Set,t.color.fh){o=[]
|
|
871
871
|
for(const e of Object.keys(t.color.fh)){let i=0
|
|
872
872
|
for(;-1!==(i=t.text.indexOf(e,i));){o.push({pattern:e,start:i,end:i+e.length})
|
|
873
873
|
for(let t=i;i+e.length>t;t++)r.add(t)
|
|
874
|
-
i+=e.length}}}if(t.color.
|
|
874
|
+
i+=e.length}}}if(t.color.yh)for(const e of t.color.yh)for(let t=e.start;e.end>t;t++)r.add(t)}const a=this.gr.qs(s,i.depth,n,this.ae.h.Se,i.Jh,t.perGlyphAttributes??!1,r),h=this.Kh(a.vertices,a.normals,a.indices,a.ar,a.planeBounds,t,t.text,o)
|
|
875
875
|
if(t.perGlyphAttributes){const t=this.Xh(h.vertices.length/3,h.glyphs)
|
|
876
876
|
h.glyphAttributes=t}return h}finally{}}async Ph(t){if(!1!==t.layout?.dt&&t.layout?.width){const e=t.layout?.language||"en-us"
|
|
877
877
|
if(!t.layout?.gt?.[e])try{if(!Ft.xh.has(e)){const n=await i(e,t.layout?.Qh)
|
|
878
878
|
Ft.xh.set(e,n)}return{...t,layout:{...t.layout,gt:{...t.layout?.gt,[e]:Ft.xh.get(e)}}}}catch(i){return h.warn(`Failed to load patterns for ${e}: ${i}`),{...t,layout:{...t.layout,dt:!1}}}}return t}Rh(t){if(!t.text)throw Error("Text content is required")
|
|
879
879
|
const e=t.Zh??1e5
|
|
880
880
|
if(t.text.length>e)throw Error(`Text exceeds ${e} character limit`)}Wh(t){t.ti&&this.ae&&Ft.Ah(t.ti)!==Ft.Ah(this.ae.ti||{})&&(this.ae.font.Qe(t.ti),this.ae.ti=t.ti)}Vh(t){if(!this.ae)throw Error("Font not loaded. Use Text.create() with a font option")
|
|
881
|
-
const{text:e,size:i=It,depth:n=0,lineHeight:s=1,letterSpacing:r=0,layout:o={}}=t,{width:a,direction:h="ltr",align:f=("rtl"===h?"right":"left"),yt:d=!0,dt:
|
|
881
|
+
const{text:e,size:i=It,depth:n=0,lineHeight:s=1,letterSpacing:r=0,layout:o={}}=t,{width:a,direction:h="ltr",align:f=("rtl"===h?"right":"left"),yt:d=!0,dt:y=!0,language:p="en-us",xt:w=c,bt:g=l,St:m=u,_t:v,gt:x,Et:b,Tt:S,At:_,Lt:E,Mt:T,It:A,Ft:L,Gt:M,Ot:F,kt:G}=o,O=this.ae.upem/i
|
|
882
882
|
let k
|
|
883
883
|
void 0!==a&&(k=a*O)
|
|
884
884
|
const C=n*O,D=C>0?Math.max(C,25e-6*this.ae.upem):0
|
|
885
885
|
this.tc||(this.tc=new I(this.ae))
|
|
886
|
-
const
|
|
887
|
-
return{lines:
|
|
886
|
+
const B=this.tc.he({text:e,width:k,align:f,direction:h,dt:y,language:p,yt:d,xt:w,bt:g,St:m,_t:v,gt:x,Et:b,Tt:S,At:_,Lt:E,Mt:T,It:A,Ft:L,Gt:M,Ot:F,kt:G,letterSpacing:r}),U=z.Pe(this.ae.h)
|
|
887
|
+
return{lines:B.lines,Yh:(U.de-U.ye)*s,letterSpacing:r,align:f,direction:h,depth:D,size:i,Jh:1/O}}ec(t,e,i,n,s){const r=t.length/3,o=new Float32Array(3*r),a=[]
|
|
888
888
|
if(Array.isArray(i)){for(let t=0;r>t;t++){const e=3*t
|
|
889
889
|
o[e]=i[0],o[e+1]=i[1],o[e+2]=i[2]}a.push({start:0,end:n.length,wh:n,color:i,bounds:[],glyphs:e,mh:[...new Set(e.map(t=>t.cr))]})}else{const t=i.default||[1,1,1]
|
|
890
890
|
for(let e=0;o.length>e;e+=3)o[e]=t[0],o[e+1]=t[1],o[e+2]=t[2]
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
if(
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
891
|
+
let r
|
|
892
|
+
if(i.fh&&s||i.yh){r=new Map
|
|
893
|
+
for(const t of e){const e=r.get(t.hr)
|
|
894
|
+
e?e.push(t):r.set(t.hr,[t])}}if(i.fh&&s&&r)for(const t of s){const e=i.fh[t.pattern]
|
|
895
|
+
if(!e)continue
|
|
896
|
+
const n=[],s=new Map
|
|
897
|
+
for(let i=t.start;t.end>i;i++){const t=r.get(i)
|
|
898
|
+
if(t)for(const i of t){n.push(i)
|
|
899
|
+
const t=s.get(i.cr)
|
|
900
|
+
t?t.push(i):s.set(i.cr,[i])
|
|
901
|
+
for(let t=0;i.lr>t;t++){const n=3*(i.Ks+t)
|
|
902
|
+
n>=0&&o.length>n&&(o[n]=e[0],o[n+1]=e[1],o[n+2]=e[2])}}}const h=Array.from(s.values()).map(t=>this.nc(t))
|
|
903
|
+
a.push({start:t.start,end:t.end,wh:t.pattern,color:e,bounds:h,glyphs:n,mh:Array.from(s.keys()).sort((t,e)=>t-e)})}if(i.yh&&r)for(const t of i.yh){const e=[],i=new Map
|
|
904
|
+
for(let n=t.start;t.end>n;n++){const s=r.get(n)
|
|
905
|
+
if(s)for(const n of s){e.push(n)
|
|
906
|
+
const s=i.get(n.cr)
|
|
907
|
+
s?s.push(n):i.set(n.cr,[n])
|
|
901
908
|
for(let e=0;n.lr>e;e++){const i=3*(n.Ks+e)
|
|
902
|
-
i>=0&&o.length>i&&(o[i]=t.color[0],o[i+1]=t.color[1],o[i+2]=t.color[2])}}
|
|
909
|
+
i>=0&&o.length>i&&(o[i]=t.color[0],o[i+1]=t.color[1],o[i+2]=t.color[2])}}}const s=Array.from(i.values()).map(t=>this.nc(t))
|
|
910
|
+
a.push({start:t.start,end:t.end,wh:n.slice(t.start,t.end),color:t.color,bounds:s,glyphs:e,mh:Array.from(i.keys()).sort((t,e)=>t-e)})}}return{colors:o,sc:a}}nc(t){if(0===t.length)return{min:{x:0,y:0,z:0},max:{x:0,y:0,z:0}}
|
|
911
|
+
let e=1/0,i=1/0,n=1/0,s=-1/0,r=-1/0,o=-1/0
|
|
912
|
+
for(const a of t)e>a.bounds.min.x&&(e=a.bounds.min.x),i>a.bounds.min.y&&(i=a.bounds.min.y),n>a.bounds.min.z&&(n=a.bounds.min.z),a.bounds.max.x>s&&(s=a.bounds.max.x),a.bounds.max.y>r&&(r=a.bounds.max.y),a.bounds.max.z>o&&(o=a.bounds.max.z)
|
|
913
|
+
return{min:{x:e,y:i,z:n},max:{x:s,y:r,z:o}}}Kh(t,e,i,n,s,r,o,a){const{layout:h={}}=r,{width:c,align:l=("rtl"===h.direction?"right":"left")}=h
|
|
903
914
|
this.tc||(this.tc=new I(this.ae))
|
|
904
915
|
const u=this.tc.ue({width:c,align:l,planeBounds:s}),f=u.offset
|
|
905
916
|
if(s.min.x=u.le.min.x,s.max.x=u.le.max.x,0!==f){for(let e=0;t.length>e;e+=3)t[e]+=f
|
|
906
|
-
for(let t=0;n.length>t;t++)n[t].bounds.min.x+=f,n[t].bounds.max.x+=f}let d,
|
|
917
|
+
for(let t=0;n.length>t;t++)n[t].bounds.min.x+=f,n[t].bounds.max.x+=f}let d,y
|
|
907
918
|
if(r.color){const e=this.ec(t,n,r.color,r.text,a)
|
|
908
|
-
d=e.colors,
|
|
909
|
-
return{vertices:t,normals:e,indices:i,colors:d,glyphs:n,planeBounds:s,stats:{
|
|
919
|
+
d=e.colors,y=e.sc}const p=this.gr.ds()
|
|
920
|
+
return{vertices:t,normals:e,indices:i,colors:d,glyphs:n,planeBounds:s,stats:{rc:i.length/3,oc:t.length/3,wn:p.wn,gn:p.gn,mn:p.mn},query:(()=>{let t=null
|
|
910
921
|
return e=>{if(!o)throw Error("Original text not available for querying")
|
|
911
|
-
return t||(t=new Mt(o,n)),t.uh(e)}})(),
|
|
912
|
-
return z.Re(this.ae.h)}static async
|
|
913
|
-
Ft.xh.set(t,n)}catch(e){h.warn(`Failed to pre-load patterns for ${t}: ${e}`)}}))}static
|
|
914
|
-
return M.measureTextWidth(this.ae,t,e)}getCacheSize(){return this.gr?this.gr.
|
|
922
|
+
return t||(t=new Mt(o,n)),t.uh(e)}})(),sc:y,glyphAttributes:void 0}}Re(){if(!this.ae)throw Error("Font not loaded. Call loadFont() first")
|
|
923
|
+
return z.Re(this.ae.h)}static async ac(t,e){await Promise.all(t.map(async t=>{if(!Ft.xh.has(t))try{const n=await i(t,e)
|
|
924
|
+
Ft.xh.set(t,n)}catch(e){h.warn(`Failed to pre-load patterns for ${t}: ${e}`)}}))}static hc(t,e){Ft.xh.set(t,e)}static cc(t){Ft.Eh=t===1/0?1/0:1048576*Math.max(1,Math.floor(t)),Ft.$h()}getLoadedFont(){return this.ae}measureTextWidth(t,e=0){if(!this.ae)throw Error("Font not loaded. Call loadFont() first")
|
|
925
|
+
return M.measureTextWidth(this.ae,t,e)}getCacheSize(){return this.gr?this.gr.pr().size:0}clearCache(){this.gr&&this.gr.clearCache()}Xh(t,e){const i=new Float32Array(3*t),n=new Float32Array(t),s=new Float32Array(t),r=new Float32Array(t),o=new Float32Array(t)
|
|
915
926
|
let a=1/0,h=-1/0
|
|
916
927
|
for(let t=0;e.length>t;t++){const i=(e[t].bounds.min.x+e[t].bounds.max.x)/2
|
|
917
928
|
a>i&&(a=i),i>h&&(h=i)}const c=h-a
|
|
918
|
-
for(let h=0;e.length>h;h++){const l=e[h],u=(l.bounds.min.x+l.bounds.max.x)/2,f=(l.bounds.min.y+l.bounds.max.y)/2,d=(l.bounds.min.z+l.bounds.max.z)/2,
|
|
919
|
-
if(g>w){n.fill(h,w,g),s.fill(l.cr,w,g),r.fill(
|
|
929
|
+
for(let h=0;e.length>h;h++){const l=e[h],u=(l.bounds.min.x+l.bounds.max.x)/2,f=(l.bounds.min.y+l.bounds.max.y)/2,d=(l.bounds.min.z+l.bounds.max.z)/2,y=l.bounds.min.y,p=c>0?(u-a)/c:0,w=l.Ks,g=Math.min(w+l.lr,t)
|
|
930
|
+
if(g>w){n.fill(h,w,g),s.fill(l.cr,w,g),r.fill(p,w,g),o.fill(y,w,g)
|
|
920
931
|
for(let t=3*w;3*g>t;t+=3)i[t]=u,i[t+1]=f,i[t+2]=d}}return{glyphCenter:i,glyphIndex:n,glyphLineIndex:s,glyphProgress:r,glyphBaselineY:o}}Ch(){this.gr=void 0,this.Hh=void 0,this.tc=void 0}destroy(){if(!this.ae)return
|
|
921
932
|
const t=this.ae
|
|
922
933
|
try{V.oi(t)}catch(t){h.warn("Error destroying HarfBuzz objects:",t)}finally{this.ae=void 0,this.tc=void 0,this.Hh=void 0}}}exports.DEFAULT_CURVE_FIDELITY=ut,exports.FontMetadataExtractor=z,exports.Text=Ft,exports.createGlyphCache=()=>new X,exports.globalGlyphCache=Q
|