three-text 0.4.5 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * three-text v0.4.5
2
+ * three-text v0.4.6
3
3
  * Copyright (C) 2025 Countertype LLC
4
4
  *
5
5
  * This program is free software: you can redistribute it and/or modify
@@ -21,8 +21,8 @@ return M.set(t,n??null),n}function i(t){const e=t.getUint16(4),i=new Map
21
21
  for(let n=0;e>n;n++){const e=12+16*n
22
22
  if(e+16>t.byteLength)break
23
23
  const s=t.getUint32(e),r=t.getUint32(e+4),o=t.getUint32(e+8),h=t.getUint32(e+12)
24
- i.set(s,{tag:s,t:r,offset:o,length:h})}return i}async function n(t,e){if(!q.test(t))throw Error(`Invalid hyphenation language code "${t}". Expected e.g. "en-us".`)
25
- if(!e&&!Y.has(t))throw Error(`Unsupported hyphenation language "${t}". Use a built-in language (e.g. "en-us") or register patterns via Text.registerPattern("${t}", pattern).`)
24
+ i.set(s,{tag:s,t:r,offset:o,length:h})}return i}async function n(t,e){if(!J.test(t))throw Error(`Invalid hyphenation language code "${t}". Expected e.g. "en-us".`)
25
+ if(!e&&!K.has(t))throw Error(`Unsupported hyphenation language "${t}". Use a built-in language (e.g. "en-us") or register patterns via Text.registerPattern("${t}", pattern).`)
26
26
  {const i="ThreeTextPatterns_"+t.replace(/-/g,"_")
27
27
  if(window[i])return window[i]
28
28
  const n=e||"/patterns/"
@@ -68,7 +68,7 @@ try{return await e()}finally{this.end(t)}}}
68
68
  const l=800,u=100,f=0,d=1/3
69
69
  var y,p;(t=>{t[t.BOX=0]="BOX",t[t.GLUE=1]="GLUE",t[t.PENALTY=2]="PENALTY",t[t.DISCRETIONARY=3]="DISCRETIONARY"})(y||(y={})),(t=>{t[t.VERY_LOOSE=0]="VERY_LOOSE",t[t.LOOSE=1]="LOOSE",t[t.DECENT=2]="DECENT",t[t.TIGHT=3]="TIGHT"})(p||(p={}))
70
70
  class w{constructor(){this.F=new Map,this.L=[]}getKey(t,e){return t<<2|e}G(t){const e=this.getKey(t.position,t.O),i=this.F.get(e)
71
- return i?i.k>t.k&&(i.k=t.k,i.D=t.D,i.N=t.N,i.line=t.line,i.U=t.U,i.P=t.P,i.$=t.$,!0):(t.active=!0,t.W=this.L.length,this.L.push(t),this.F.set(e,t),!0)}R(t){if(!t.active)return
71
+ return i?i.k>t.k&&(i.k=t.k,i.D=t.D,i.N=t.N,i.line=t.line,i.U=t.U,i.$=t.$,i.P=t.P,!0):(t.active=!0,t.W=this.L.length,this.L.push(t),this.F.set(e,t),!0)}R(t){if(!t.active)return
72
72
  t.active=!1
73
73
  const e=t.W,i=this.L.length-1
74
74
  if(e!==i){const t=this.L[i]
@@ -126,7 +126,7 @@ if(c&&e>c){const e=Array.from(t)
126
126
  for(let t=0;e.length>t;t++)l.push({type:y.BOX,width:i(e[t]),text:e[t],Z:d+t}),e.length-1>t&&l.push({type:y.PENALTY,width:0,tt:5e3,Z:d+t+1})}else l.push({type:y.BOX,width:e,text:t,Z:d})}}else{const e=i(t)
127
127
  if(c&&e>c){const e=Array.from(t)
128
128
  for(let t=0;e.length>t;t++)l.push({type:y.BOX,width:i(e[t]),text:e[t],Z:d+t}),e.length-1>t&&l.push({type:y.PENALTY,width:0,tt:5e3,Z:d+t+1})}else l.push({type:y.BOX,width:e,text:t,Z:d})}d+=t.length}f+=t.length}}return l}static lineBreak(t,e,i,n,s){const r=new w
129
- r.G({position:0,line:0,O:p.DECENT,k:0,D:null,N:!1,active:!0,W:0,U:0,P:0,$:0})
129
+ r.G({position:0,line:0,O:p.DECENT,k:0,D:null,N:!1,active:!0,W:0,U:0,$:0,P:0})
130
130
  let o=0,h=0,a=0
131
131
  for(let c=0;t.length>c;c++){const l=t[c]
132
132
  if(!(l.type===y.PENALTY&&1e4>l.tt||l.type===y.DISCRETIONARY||l.type===y.GLUE&&c>0&&t[c-1].type===y.BOX)){l.type===y.BOX?o+=l.width:l.type===y.GLUE?(o+=l.width,h+=l.stretch,a+=l.X):l.type===y.DISCRETIONARY&&(o+=l.width)
@@ -134,7 +134,7 @@ continue}let u=0,f=!1;(l.type===y.PENALTY||l.type===y.DISCRETIONARY)&&(u=l.tt,f=
134
134
  let d=0
135
135
  l.type===y.DISCRETIONARY&&(d=l.ut)
136
136
  const p=[null,null,null,null],w=[1/0,1/0,1/0,1/0],g=[],v=r.j()
137
- for(let t=0;v.length>t;t++){const r=v[t],l=h-r.P,y=a-r.$,m=e-(o-r.U+d)
137
+ for(let t=0;v.length>t;t++){const r=v[t],l=h-r.$,y=a-r.P,m=e-(o-r.U+d)
138
138
  let x
139
139
  if(m>0){const t=l+n
140
140
  x=t>0?m/t:1/0}else x=0>m?y>0?m/y:-1/0:0
@@ -146,7 +146,7 @@ let S=s.wt+b
146
146
  const _=this.V(x)
147
147
  Math.abs(_-r.O)>1&&(S+=s.vt)
148
148
  const E=r.k+S
149
- w[_]>E&&(w[_]=E,p[_]={position:c,line:r.line+1,O:_,k:E,D:r,N:f,active:!0,W:-1,U:o,P:h,$:a})}for(const t of g)r.R(t)
149
+ w[_]>E&&(w[_]=E,p[_]={position:c,line:r.line+1,O:_,k:E,D:r,N:f,active:!0,W:-1,U:o,$:h,P:a})}for(const t of g)r.R(t)
150
150
  for(let t=0;4>t;t++)p[t]&&r.G(p[t])
151
151
  if(0===r.size()&&u!==T)return null
152
152
  l.type===y.BOX?o+=l.width:l.type===y.GLUE?(o+=l.width,h+=l.stretch,a+=l.X):l.type===y.DISCRETIONARY&&(o+=l.width)}let c=null,l=1/0
@@ -155,21 +155,21 @@ return c}static xt(t){if(!t.text||0===t.text.length)return[]
155
155
  const{text:e,width:i,align:n="left",direction:s="ltr",bt:r=!1,language:o="en-us",St:h=!0,measureText:a,_t:d,Et:y,Tt:p,letterSpacing:w=0,At:T=l,Mt:A=u,It:M=f,Ft:I,Lt:F=_,Gt:L=E,Ot:G=b,Ct:O=S,kt:C=g,Dt:k=v,Bt:D=m,Nt:B=x}=t
156
156
  if(h&&e.includes("\n")){const i=e.split("\n"),n=[]
157
157
  let s=0
158
- for(const e of i){if(0===e.length)n.push({text:"",Ut:s,Pt:s,$t:0,zt:!0,naturalWidth:0,Wt:!1})
158
+ for(const e of i){if(0===e.length)n.push({text:"",Ut:s,$t:s,Pt:0,Wt:!0,naturalWidth:0,zt:!1})
159
159
  else{const i=this.xt({...t,text:e,St:!1})
160
- i.forEach(t=>{t.Ut+=s,t.Pt+=s}),n.push(...i)}s+=e.length+1}return n}let N=r
160
+ i.forEach(t=>{t.Ut+=s,t.$t+=s}),n.push(...i)}s+=e.length+1}return n}let N=r
161
161
  !N||y&&y[o]||(c.warn(`Hyphenation patterns for ${o} not available`),N=!1)
162
162
  let U=M
163
163
  void 0!==I&&i&&(U=i*I)
164
- const P={wt:G,vt:O,gt:D,Rt:B,yt:C,ft:k,jt:n,Tt:p,Ht:p?w*p:0}
164
+ const $={wt:G,vt:O,gt:D,Rt:B,yt:C,ft:k,jt:n,Tt:p,Ht:p?w*p:0}
165
165
  if(!i||i===1/0){const t=a(e)
166
- return[{text:e,Ut:0,Pt:e.length-1,$t:0,zt:!0,naturalWidth:t,Wt:!1}]}let $=this.J(e,a,d,!1,o,y,F,L,P,i),z=this.lineBreak($,i,A,0,P)
167
- if(!z&&N&&($=this.J(e,a,d,!0,o,y,F,L,P,i),z=this.lineBreak($,i,T,0,P)),!z){const t=5
168
- for(let e=0;t>e&&!z;e++){const t=U+e*i*.1
169
- z=this.lineBreak($,i,T,t,P),z||(z=this.lineBreak($,i,1e4,t,P))}}if(z){const t=[]
170
- let r=z
166
+ return[{text:e,Ut:0,$t:e.length-1,Pt:0,Wt:!0,naturalWidth:t,zt:!1}]}let P=this.J(e,a,d,!1,o,y,F,L,$,i),W=this.lineBreak(P,i,A,0,$)
167
+ if(!W&&N&&(P=this.J(e,a,d,!0,o,y,F,L,$,i),W=this.lineBreak(P,i,T,0,$)),!W){const t=5
168
+ for(let e=0;t>e&&!W;e++){const t=U+e*i*.1
169
+ W=this.lineBreak(P,i,T,t,$),W||(W=this.lineBreak(P,i,1e4,t,$))}}if(W){const t=[]
170
+ let r=W
171
171
  for(;r&&r.position>0;)t.unshift(r.position),r=r.D
172
- return this.Vt(e,$,t,i,n,s,P)}return[{text:e,Ut:0,Pt:e.length-1,$t:0,qt:0,zt:!0,naturalWidth:a(e),Wt:!1}]}static Vt(t,e,i,n,s,r,o){if(0===i.length)return[{text:t,Ut:0,Pt:t.length-1,$t:0}]
172
+ return this.Vt(e,P,t,i,n,s,$)}return[{text:e,Ut:0,$t:e.length-1,Pt:0,qt:0,Wt:!0,naturalWidth:a(e),zt:!1}]}static Vt(t,e,i,n,s,r,o){if(0===i.length)return[{text:t,Ut:0,$t:t.length-1,Pt:0}]
173
173
  const h=[]
174
174
  let a=0
175
175
  for(let t=0;i.length>t;t++){const c=i[t],l=!(e.length-1>i[i.length-1]+1)&&t===i.length-1,u=[]
@@ -187,12 +187,12 @@ let b=0,S=0,_=s
187
187
  if("justify"===s&&l&&(_="rtl"===r?"right":"left"),"center"===_)b=(n-p)/2
188
188
  else if("right"===_)b=n-p
189
189
  else if("justify"===_&&!l){const t=n-p
190
- t>0&&w>0?S=t/w:0>t&&g>0&&(S=t/g)}h.push({text:x,Ut:f,Pt:d,$t:b,qt:S,zt:!1,naturalWidth:p,Wt:m}),a=c+1}if(e.length-1>a){const t=[]
190
+ t>0&&w>0?S=t/w:0>t&&g>0&&(S=t/g)}h.push({text:x,Ut:f,$t:d,Pt:b,qt:S,Wt:!1,naturalWidth:p,zt:m}),a=c+1}if(e.length-1>a){const t=[]
191
191
  let i=-1,c=-1,l=0
192
192
  for(let n=a;e.length-1>n;n++){const s=e[n]
193
193
  s.type!==y.PENALTY&&(void 0!==s.Z&&((-1===i||i>s.Z)&&(i=s.Z),s.Z>c&&(c=s.Z)),s.text&&t.push(s.text),l+=s.width)}o?.Ht&&0!==l&&(l-=o.Ht)
194
194
  let u=0,f=s
195
- "justify"===s&&(f="rtl"===r?"right":"left"),"center"===f?u=(n-l)/2:"right"===f&&(u=n-l),h.push({text:t.join(""),Ut:i,Pt:c,$t:u,qt:0,zt:!0,naturalWidth:l,Wt:!1}),h.length>1&&(h[h.length-2].zt=!1),h[h.length-1].zt=!0}else h.length>0&&(h[h.length-1].zt=!0)
195
+ "justify"===s&&(f="rtl"===r?"right":"left"),"center"===f?u=(n-l)/2:"right"===f&&(u=n-l),h.push({text:t.join(""),Ut:i,$t:c,Pt:u,qt:0,Wt:!0,naturalWidth:l,zt:!1}),h.length>1&&(h[h.length-2].Wt=!1),h[h.length-1].Wt=!0}else h.length>0&&(h[h.length-1].Wt=!0)
196
196
  return h}}const M=new WeakMap
197
197
  class I{static _t(t,i,n=0){const s=Array.from(i)
198
198
  if(0===s.length)return[]
@@ -220,22 +220,22 @@ if(i)b=A.xt({text:e,width:i,align:n,direction:s,bt:r,language:o,St:h,At:a,Mt:c,I
220
220
  else{const t=e.split("\n")
221
221
  b=[]
222
222
  let i=0
223
- for(const e of t)b.push({text:e,Ut:i,Pt:0===e.length?i:i+e.length-1,$t:0}),i+=e.length+1}return{lines:b}}te(t,e){const{offset:i,ee:n}=this.ie(e)
223
+ for(const e of t)b.push({text:e,Ut:i,$t:0===e.length?i:i+e.length-1,Pt:0}),i+=e.length+1}return{lines:b}}te(t,e){const{offset:i,ee:n}=this.ie(e)
224
224
  if(0!==i)for(let e=0;t.length>e;e+=3)t[e]+=i
225
225
  return{offset:i,ee:n}}ie(t){const{width:e,align:i,planeBounds:n}=t
226
226
  let s=0
227
227
  const r={min:{...n.min},max:{...n.max}}
228
- 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,ee:r}}}const L=65536,G=1330926671,O=2001684038,C=1751474532,k=1751672161,D=1330851634,B=1719034226,N=1398030676,U=1851878757,P=1128678944,$=1128678962,z=1196643650,W=1196445523,R=new TextDecoder("utf-16be")
229
- class j{static ne(t){if(!t||12>t.byteLength)throw Error("Invalid font buffer: too small to be a valid font file")
228
+ 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,ee:r}}}const L=65536,G=1330926671,O=2001684038,C=2001684018,k=1751474532,D=1751672161,B=1330851634,N=1719034226,U=1398030676,$=1851878757,P=1128678944,W=1128678962,z=1196643650,R=1196445523,j=new TextDecoder("utf-16be")
229
+ class H{static ne(t){if(!t||12>t.byteLength)throw Error("Invalid font buffer: too small to be a valid font file")
230
230
  const e=new DataView(t),n=e.getUint32(0)
231
- if(![L,G].includes(n))throw Error("Invalid font format. Expected TTF/OTF (or WOFF), got signature: 0x"+n.toString(16))
232
- const s=i(e),r=s.has(P)||s.has($),o=s.get(C)?.offset??0,h=s.get(k)?.offset??0,a=s.get(D)?.offset??0,c=s.get(B)?.offset??0,l=s.get(N)?.offset??0,u=s.get(U)?.offset??0,f=o?e.getUint16(o+18):1e3
231
+ if(![L,G].includes(n))throw Error("Invalid font format. Expected TTF/OTF/WOFF/WOFF2, got signature: 0x"+n.toString(16))
232
+ const s=i(e),r=s.has(P)||s.has(W),o=s.get(k)?.offset??0,h=s.get(D)?.offset??0,a=s.get(B)?.offset??0,c=s.get(N)?.offset??0,l=s.get(U)?.offset??0,u=s.get($)?.offset??0,f=o?e.getUint16(o+18):1e3
233
233
  let d=null
234
234
  h&&(d={se:e.getInt16(h+4),re:e.getInt16(h+6),oe:e.getInt16(h+8)})
235
235
  let y=null
236
236
  a&&(y={he:e.getInt16(a+68),ae:e.getInt16(a+70),ce:e.getInt16(a+72),le:e.getUint16(a+74),ue:e.getUint16(a+76)})
237
237
  let p=null
238
- return c&&l&&u&&(p=this.fe(e,l,u)),{de:r,Tt:f,ye:d?.se||null,pe:d?.re||null,we:d?.oe||null,he:y?.he||null,ae:y?.ae||null,ce:y?.ce||null,le:y?.le||null,ue:y?.ue||null,ge:p}}static ve(t){const e=new DataView(t),n=i(e),s=n.get(z)?.offset??0,r=n.get(W)?.offset??0,o=n.get(U)?.offset??0,h=new Set,a={}
238
+ return c&&l&&u&&(p=this.fe(e,l,u)),{de:r,Tt:f,ye:d?.se||null,pe:d?.re||null,we:d?.oe||null,he:y?.he||null,ae:y?.ae||null,ce:y?.ce||null,le:y?.le||null,ue:y?.ue||null,ge:p}}static ve(t){const e=new DataView(t),n=i(e),s=n.get(z)?.offset??0,r=n.get(R)?.offset??0,o=n.get($)?.offset??0,h=new Set,a={}
239
239
  try{if(s){const t=this.me(e,s,o)
240
240
  t.features.forEach(t=>h.add(t)),Object.assign(a,t.names)}if(r){const t=this.me(e,r,o)
241
241
  t.features.forEach(t=>h.add(t)),Object.assign(a,t.names)}}catch(t){return}const c=Array.from(h).sort()
@@ -256,14 +256,14 @@ if(0===o||3===o&&1===h){let t=""
256
256
  for(let e=0;f.length>e;e+=2)t+=String.fromCharCode(f[e]<<8|f[e+1])
257
257
  return t}return new TextDecoder("ascii").decode(f)}return null}catch(t){return null}}static be(t){if(!t||12>t.byteLength)throw Error("Invalid font buffer: too small to be a valid font file")
258
258
  const e=new DataView(t),n=e.getUint32(0)
259
- if(![L,G].includes(n))throw Error("Invalid font format. Expected TTF/OTF (or WOFF), got signature: 0x"+n.toString(16))
260
- const s=i(e),r=s.get(U)?.offset??0,o=r?this.Se(e,r):null
259
+ if(![L,G].includes(n))throw Error("Invalid font format. Expected TTF/OTF/WOFF/WOFF2, got signature: 0x"+n.toString(16))
260
+ const s=i(e),r=s.get($)?.offset??0,o=r?this.Se(e,r):null
261
261
  return{u:this._e(e,s,o),features:this.Ee(e,s,o)}}static Se(t,e){const i=new Map,n=t.getUint16(e+2),s=t.getUint16(e+4)
262
262
  for(let r=0;n>r;r++){const n=e+6+12*r,o=t.getUint16(n),h=t.getUint16(n+2),a=t.getUint16(n+4),c=t.getUint16(n+6),l=t.getUint16(n+8),u=t.getUint16(n+10);(0===o||3===o&&1033===a)&&(i.has(c)||i.set(c,{offset:e+s+u,length:l,Te:o,Ae:h}))}return i}static Me(t,e,i){if(!e)return null
263
263
  const n=e.get(i)
264
264
  if(!n)return null
265
265
  try{const e=new Uint8Array(t.buffer,n.offset,n.length)
266
- return 0===n.Te||3===n.Te&&1===n.Ae?R.decode(e):new TextDecoder("ascii").decode(e)}catch{return null}}static _e(t,e,i){const n=e.has(P)||e.has($),s=e.get(C)?.offset??0,r=e.get(k)?.offset??0,o=e.get(D)?.offset??0,h=e.get(B)?.offset??0,a=e.get(N)?.offset??0,c=s?t.getUint16(s+18):1e3
266
+ return 0===n.Te||3===n.Te&&1===n.Ae?j.decode(e):new TextDecoder("ascii").decode(e)}catch{return null}}static _e(t,e,i){const n=e.has(P)||e.has(W),s=e.get(k)?.offset??0,r=e.get(D)?.offset??0,o=e.get(B)?.offset??0,h=e.get(N)?.offset??0,a=e.get(U)?.offset??0,c=s?t.getUint16(s+18):1e3
267
267
  let l=null
268
268
  r&&(l={se:t.getInt16(r+4),re:t.getInt16(r+6),oe:t.getInt16(r+8)})
269
269
  let u=null
@@ -272,7 +272,7 @@ let f=null
272
272
  return h&&a&&i&&(f=this.Ie(t,a,i)),{de:n,Tt:c,ye:l?.se||null,pe:l?.re||null,we:l?.oe||null,he:u?.he||null,ae:u?.ae||null,ce:u?.ce||null,le:u?.le||null,ue:u?.ue||null,ge:f}}static Ie(t,e,i){try{if(1>t.getUint16(e))return null
273
273
  const n=t.getUint16(e+4),s=t.getUint16(e+6),r=t.getUint32(e+8),o={}
274
274
  for(let h=0;s>h;h++){const s=e+r+h*n,a=String.fromCharCode(t.getUint8(s),t.getUint8(s+1),t.getUint8(s+2),t.getUint8(s+3)),c=t.getUint16(s+4),l=this.Me(t,i,c)
275
- l&&(o[a]=l)}return Object.keys(o).length>0?o:null}catch{return null}}static Ee(t,e,i){const n=e.get(z)?.offset??0,s=e.get(W)?.offset??0,r=new Set,o={}
275
+ l&&(o[a]=l)}return Object.keys(o).length>0?o:null}catch{return null}}static Ee(t,e,i){const n=e.get(z)?.offset??0,s=e.get(R)?.offset??0,r=new Set,o={}
276
276
  try{n&&this.Fe(t,n,i,r,o),s&&this.Fe(t,s,i,r,o)}catch{return}if(0!==r.size)return{tags:Array.from(r).sort((t,e)=>t-e).map(this.Le),names:Object.keys(o).length>0?o:{}}}static Fe(t,e,i,n,s){const r=e+t.getUint16(e+6),o=t.getUint16(r)
277
277
  for(let e=0;o>e;e++){const o=r+2+6*e,h=t.getUint32(o)
278
278
  n.add(h)
@@ -286,10 +286,11 @@ if(0===f)continue
286
286
  const d=u+f
287
287
  if(0!==t.getUint16(d))continue
288
288
  const y=t.getUint16(d+2),p=this.Me(t,i,y)
289
- p&&(s[String.fromCharCode(h>>24&255,h>>16&255,h>>8&255,255&h)]=p)}}static Le(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,255&t)}static Ge(t){return null!==t.he&&null!==t.ae?{se:t.he,re:t.ae,oe:0}:null!==t.ye&&null!==t.pe?{se:t.ye,re:t.pe,oe:0}:null!==t.le&&null!==t.ue?{se:t.le,re:-t.ue,oe:0}:{se:Math.round(.8*t.Tt),re:-Math.round(.2*t.Tt),oe:0}}static Oe(t){const e=j.Ge(t)
290
- return{se:e.se,re:e.re,oe:e.oe,Tt:t.Tt,Ce:e.se-e.re}}}class H{static ke(t){if(4>t.byteLength)return"ttf/otf"
289
+ p&&(s[String.fromCharCode(h>>24&255,h>>16&255,h>>8&255,255&h)]=p)}}static Le(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,255&t)}static Ge(t){return null!==t.he&&null!==t.ae?{se:t.he,re:t.ae,oe:0}:null!==t.ye&&null!==t.pe?{se:t.ye,re:t.pe,oe:0}:null!==t.le&&null!==t.ue?{se:t.le,re:-t.ue,oe:0}:{se:Math.round(.8*t.Tt),re:-Math.round(.2*t.Tt),oe:0}}static Oe(t){const e=H.Ge(t)
290
+ return{se:e.se,re:e.re,oe:e.oe,Tt:t.Tt,Ce:e.se-e.re}}}let V=null
291
+ class q{static ke(t){if(4>t.byteLength)return"ttf/otf"
291
292
  const e=new DataView(t).getUint32(0)
292
- return e===O?"woff":2001684018===e?"woff2":"ttf/otf"}static async De(t){const e=new DataView(t),i=new Uint8Array(t)
293
+ return e===O?"woff":e===C?"woff2":"ttf/otf"}static async De(t){const e=new DataView(t),i=new Uint8Array(t)
293
294
  if(e.getUint32(0)!==O)throw Error("Not a valid WOFF font")
294
295
  const n=e.getUint32(4),s=e.getUint16(12),r=e.getUint32(16)
295
296
  if("undefined"==typeof DecompressionStream)throw Error("WOFF fonts require DecompressionStream API (Chrome 80+, Firefox 113+, Safari 16.4+). Please use TTF/OTF fonts or upgrade your browser.")
@@ -302,33 +303,34 @@ const l=[]
302
303
  for(let t=0;s>t;t++){const i=44+20*t
303
304
  l.push({tag:e.getUint32(i),offset:e.getUint32(i+4),length:e.getUint32(i+8),Be:e.getUint32(i+12),t:e.getUint32(i+16)})}l.sort((t,e)=>t.tag-e.tag)
304
305
  const u=await Promise.all(l.map(async t=>{if(t.length===t.Be)return i.subarray(t.offset,t.offset+t.length)
305
- const e=i.subarray(t.offset,t.offset+t.length),n=await H.Ne(e)
306
+ const e=i.subarray(t.offset,t.offset+t.length),n=await q.Ne(e)
306
307
  if(n.byteLength!==t.Be)throw Error(`Decompression failed: expected ${t.Be} bytes, got ${n.byteLength}`)
307
308
  return new Uint8Array(n)}))
308
309
  for(let t=0;s>t;t++){const e=l[t],i=12+16*t
309
- h.setUint32(i,e.tag),h.setUint32(i+4,e.t),h.setUint32(i+8,c),h.setUint32(i+12,e.Be),o.set(u[t],c),c+=e.Be,c+=(4-e.Be%4)%4}return o.buffer.slice(0,c)}static async Ne(t){const e=new ReadableStream({start(e){e.enqueue(t),e.close()}}).pipeThrough(new DecompressionStream("deflate"))
310
- return new Response(e).arrayBuffer()}}class V{constructor(t){this.Ue=t}async Pe(t,e){if(!t||12>t.byteLength)throw Error("Invalid font buffer: too small to be a valid font file")
311
- const i=H.ke(t)
312
- if("woff"===i)t=await H.De(t)
313
- else if("woff2"===i)throw Error("WOFF2 fonts are not yet supported. Please use WOFF or TTF/OTF format.")
310
+ h.setUint32(i,e.tag),h.setUint32(i+4,e.t),h.setUint32(i+8,c),h.setUint32(i+12,e.Be),o.set(u[t],c),c+=e.Be,c+=(4-e.Be%4)%4}return o.buffer.slice(0,c)}static Ue(t){if(new DataView(t).getUint32(0)!==C)throw Error("Not a valid WOFF2 font")
311
+ if(!V)throw Error("WOFF2 fonts require enabling the decoder. Add to your code:\n import { decode } from 'woff2-decode';\n Text.enableWoff2(decode);")
312
+ return V(t).buffer}static async Ne(t){const e=new ReadableStream({start(e){e.enqueue(t),e.close()}}).pipeThrough(new DecompressionStream("deflate"))
313
+ return new Response(e).arrayBuffer()}}class Y{constructor(t){this.$e=t}async Pe(t,e){if(!t||12>t.byteLength)throw Error("Invalid font buffer: too small to be a valid font file")
314
+ const i=q.ke(t)
315
+ "woff"===i?t=await q.De(t):"woff2"===i&&(t=q.Ue(t))
314
316
  const n=new DataView(t).getUint32(0)
315
- if(![L,G].includes(n))throw Error("Invalid font format. Expected TTF/OTF (or WOFF), got signature: 0x"+n.toString(16))
316
- const{hb:s,module:r}=await this.Ue()
317
- try{const i=s.$e(new Uint8Array(t)),n=s.ze(i,0),o=s.We(n)
318
- e&&o.Re(e)
319
- const h=n.je(),a=Object.keys(h).length>0,{u:c,features:l}=j.be(t)
317
+ if(![L,G].includes(n))throw Error("Invalid font format. Expected TTF/OTF/WOFF/WOFF2, got signature: 0x"+n.toString(16))
318
+ const{hb:s,module:r}=await this.$e()
319
+ try{const i=s.We(new Uint8Array(t)),n=s.ze(i,0),o=s.Re(n)
320
+ e&&o.je(e)
321
+ const h=n.He(),a=Object.keys(h).length>0,{u:c,features:l}=H.be(t)
320
322
  let u
321
323
  if(a&&h){u={}
322
- for(const[t,e]of Object.entries(h))u[t]={...e,name:c.ge?.[t]||null}}return{hb:s,fontBlob:i,face:n,font:o,module:r,upem:c.Tt,u:c,He:e,Ve:a,qe:u,Ye:l?.tags,Je:l?.names,Ke:t}}catch(t){throw c.error("Failed to load font:",t),t}}static Qe(t){try{t.font&&"function"==typeof t.font.destroy&&t.font.destroy(),t.face&&"function"==typeof t.face.destroy&&t.face.destroy(),t.fontBlob&&"function"==typeof t.fontBlob.destroy&&t.fontBlob.destroy()}catch(t){c.error("Error destroying font resources:",t)}}}const q=/^[a-z]{2,3}(?:-[a-z0-9]{2,16})*$/i,Y=new Set(["af","as","be","bg","bn","ca","cs","cy","da","de-1996","el-monoton","el-polyton","en-gb","en-us","eo","es","et","eu","fi","fr","fur","ga","gl","gu","hi","hr","hsb","hu","hy","ia","id","is","it","ka","kmr","kn","la","lt","lv","mk","ml","mn-cyrl","mr","mul-ethi","nb","nl","nn","oc","or","pa","pl","pms","pt","rm","ro","ru","sa","sh-cyrl","sh-latn","sk","sl","sq","sr-cyrl","sv","ta","te","th","tk","tr","uk","zh-latn-pinyin"])
323
- class J{constructor(t=0,e=0){this.x=t,this.y=e}set(t,e){return this.x=t,this.y=e,this}clone(){return new J(this.x,this.y)}Xe(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}sub(t){return this.x-=t.x,this.y-=t.y,this}multiply(t){return this.x*=t,this.y*=t,this}Ze(t){return this.x/=t,this.y/=t,this}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}ti(){return this.x*this.x+this.y*this.y}normalize(){const t=this.length()
324
- return t>0&&this.Ze(t),this}ei(t){return this.x*t.x+this.y*t.y}ii(t){const e=this.x-t.x,i=this.y-t.y
325
- return Math.sqrt(e*e+i*i)}ni(t){const e=this.x-t.x,i=this.y-t.y
326
- return e*e+i*i}equals(t){return this.x===t.x&&this.y===t.y}angle(){return Math.atan2(this.y,this.x)}}class K{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.z=i}set(t,e,i){return this.x=t,this.y=e,this.z=i,this}clone(){return new K(this.x,this.y,this.z)}Xe(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}multiply(t){return this.x*=t,this.y*=t,this.z*=t,this}Ze(t){return this.x/=t,this.y/=t,this.z/=t,this}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}ti(){return this.x*this.x+this.y*this.y+this.z*this.z}normalize(){const t=this.length()
327
- return t>0&&this.Ze(t),this}ei(t){return this.x*t.x+this.y*t.y+this.z*t.z}si(t){const e=this.z*t.x-this.x*t.z,i=this.x*t.y-this.y*t.x
328
- return this.x=this.y*t.z-this.z*t.y,this.y=e,this.z=i,this}ii(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z
329
- return Math.sqrt(e*e+i*i+n*n)}ni(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z
330
- return e*e+i*i+n*n}equals(t){return this.x===t.x&&this.y===t.y&&this.z===t.z}}class Q{constructor(){this.cache=new Map}get(t){return this.cache.get(t)}has(t){return this.cache.has(t)}set(t,e){this.cache.set(t,e)}delete(t){return this.cache.delete(t)}clear(){this.cache.clear()}get size(){return this.cache.size}keys(){return Array.from(this.cache.keys())}getStats(){return{size:this.cache.size}}}const X=new Q,Z=new Q,tt=new Q,et=new Q
331
- var it="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},nt={exports:{}}
324
+ for(const[t,e]of Object.entries(h))u[t]={...e,name:c.ge?.[t]||null}}return{hb:s,fontBlob:i,face:n,font:o,module:r,upem:c.Tt,u:c,Ve:e,qe:a,Ye:u,Je:l?.tags,Ke:l?.names,Qe:t}}catch(t){throw c.error("Failed to load font:",t),t}}static Xe(t){try{t.font&&"function"==typeof t.font.destroy&&t.font.destroy(),t.face&&"function"==typeof t.face.destroy&&t.face.destroy(),t.fontBlob&&"function"==typeof t.fontBlob.destroy&&t.fontBlob.destroy()}catch(t){c.error("Error destroying font resources:",t)}}}const J=/^[a-z]{2,3}(?:-[a-z0-9]{2,16})*$/i,K=new Set(["af","as","be","bg","bn","ca","cs","cy","da","de-1996","el-monoton","el-polyton","en-gb","en-us","eo","es","et","eu","fi","fr","fur","ga","gl","gu","hi","hr","hsb","hu","hy","ia","id","is","it","ka","kmr","kn","la","lt","lv","mk","ml","mn-cyrl","mr","mul-ethi","nb","nl","nn","oc","or","pa","pl","pms","pt","rm","ro","ru","sa","sh-cyrl","sh-latn","sk","sl","sq","sr-cyrl","sv","ta","te","th","tk","tr","uk","zh-latn-pinyin"])
325
+ class Q{constructor(t=0,e=0){this.x=t,this.y=e}set(t,e){return this.x=t,this.y=e,this}clone(){return new Q(this.x,this.y)}Ze(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}sub(t){return this.x-=t.x,this.y-=t.y,this}multiply(t){return this.x*=t,this.y*=t,this}ti(t){return this.x/=t,this.y/=t,this}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}ei(){return this.x*this.x+this.y*this.y}normalize(){const t=this.length()
326
+ return t>0&&this.ti(t),this}ii(t){return this.x*t.x+this.y*t.y}ni(t){const e=this.x-t.x,i=this.y-t.y
327
+ return Math.sqrt(e*e+i*i)}si(t){const e=this.x-t.x,i=this.y-t.y
328
+ return e*e+i*i}equals(t){return this.x===t.x&&this.y===t.y}angle(){return Math.atan2(this.y,this.x)}}class X{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.z=i}set(t,e,i){return this.x=t,this.y=e,this.z=i,this}clone(){return new X(this.x,this.y,this.z)}Ze(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}multiply(t){return this.x*=t,this.y*=t,this.z*=t,this}ti(t){return this.x/=t,this.y/=t,this.z/=t,this}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}ei(){return this.x*this.x+this.y*this.y+this.z*this.z}normalize(){const t=this.length()
329
+ return t>0&&this.ti(t),this}ii(t){return this.x*t.x+this.y*t.y+this.z*t.z}ri(t){const e=this.z*t.x-this.x*t.z,i=this.x*t.y-this.y*t.x
330
+ return this.x=this.y*t.z-this.z*t.y,this.y=e,this.z=i,this}ni(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z
331
+ return Math.sqrt(e*e+i*i+n*n)}si(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z
332
+ return e*e+i*i+n*n}equals(t){return this.x===t.x&&this.y===t.y&&this.z===t.z}}class Z{constructor(){this.cache=new Map}get(t){return this.cache.get(t)}has(t){return this.cache.has(t)}set(t,e){this.cache.set(t,e)}delete(t){return this.cache.delete(t)}clear(){this.cache.clear()}get size(){return this.cache.size}keys(){return Array.from(this.cache.keys())}getStats(){return{size:this.cache.size}}}const tt=new Z,et=new Z,it=new Z,nt=new Z
333
+ var st="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},rt={exports:{}}
332
334
  !(function(t){function e(t,e){return t.b===e.b&&t.a===e.a}function i(t,e){return e.b>t.b||t.b===e.b&&e.a>=t.a}function n(t,e,i){var n=e.b-t.b,s=i.b-e.b
333
335
  return n+s>0?s>n?e.a-t.a+n/(n+s)*(t.a-i.a):e.a-i.a+s/(n+s)*(i.a-t.a):0}function s(t,e,i){var n=e.b-t.b,s=i.b-e.b
334
336
  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&&e.b>=t.b}function o(t,e,i){var n=e.a-t.a,s=i.a-e.a
@@ -338,22 +340,22 @@ return v(e,t.c),v(e.b,t.c),m(e,t.a),e}function f(t,e){var i=!1,n=!1
338
340
  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||(v(e,t.a),t.a.c=t),i||(m(e,t.d),t.d.a=t))}function d(t){var e=t.b,i=!1
339
341
  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||m(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
340
342
  return g(e,t.e),e.a=t.b.a,v(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
341
- 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||m(n,t.d),n}function w(t){var e=new J,i=new J,n=t.b.ri
342
- return i.ri=n,n.b.ri=e,e.ri=t,t.b.ri=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
343
+ 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||m(n,t.d),n}function w(t){var e=new J,i=new J,n=t.b.oi
344
+ return i.oi=n,n.b.oi=e,e.oi=t,t.b.oi=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
343
345
  i.b.e=e,n.b.e=t,t.c=n,e.c=i}function v(t,e){var i=e.f,n=new X(e,i)
344
346
  i.e=n,e.f=n,i=n.c=t
345
347
  do{i.a=n,i=i.c}while(i!==t)}function m(t,e){var i=e.d,n=new Y(e,i)
346
348
  i.b=n,e.d=n,n.a=t,n.c=e.c,i=t
347
- do{i.d=n,i=i.e}while(i!==t)}function x(t){var e=t.ri
348
- e.b.ri=t=t.b.ri,t.b.ri=e}function b(t,e){var i=t.c,n=i
349
+ do{i.d=n,i=i.e}while(i!==t)}function x(t){var e=t.oi
350
+ e.b.oi=t=t.b.oi,t.b.oi=e}function b(t,e){var i=t.c,n=i
349
351
  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
350
352
  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
351
- 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.oi=null
353
+ 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.hi=null
352
354
  var e=t.e
353
- e.a.c=e.c,e.c.a=e.a,t.e=null}function M(t,e){d(t.a),t.c=!1,t.a=e,e.oi=t}function I(t){var e=t.a.a
355
+ e.a.c=e.c,e.c.a=e.a,t.e=null}function M(t,e){d(t.a),t.c=!1,t.a=e,e.hi=t}function I(t){var e=t.a.a
354
356
  do{t=ut(t)}while(t.a.a===e)
355
357
  return t.c&&(M(t,e=p(lt(t).a.b,t.a.e)),t=ut(t)),t}function F(t,e,i){var n=new ct
356
- return n.a=i,n.e=R(t.f,e.e,n),i.oi=n}function L(t,e){switch(t.s){case 100130:return!!(1&e)
358
+ return n.a=i,n.e=R(t.f,e.e,n),i.hi=n}function L(t,e){switch(t.s){case 100130:return!!(1&e)
357
359
  case 100131:return 0!==e
358
360
  case 100132:return e>0
359
361
  case 100133:return 0>e
@@ -364,13 +366,13 @@ if(s.a!==e.a){if(!n.c){G(t)
364
366
  break}M(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 C(t,e,i,n,s,r){var o=!0
365
367
  do{F(t,e,i.b),i=i.c}while(i!==n)
366
368
  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=L(t,n.f),e.b=!0,!o&&N(t,e)&&(E(i,s),A(e),d(s)),o=!1,e=n,s=i
367
- e.b=!0,r&&P(t,e)}function k(t,e,i,n,s){var r=[e.g[0],e.g[1],e.g[2]]
368
- e.d=null,e.d=t.hi&&t.hi(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]
369
+ e.b=!0,r&&$(t,e)}function k(t,e,i,n,s){var r=[e.g[0],e.g[1],e.g[2]]
370
+ e.d=null,e.d=t.ai&&t.ai(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]
369
371
  n[0]=e.a.d,n[1]=i.a.d,k(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),h=s+1
370
372
  n[s]=.5*o/(r+o),n[h]=.5*r/(r+o),t.g[0]+=n[s]*e.g[0]+n[h]*i.g[0],t.g[1]+=n[s]*e.g[1]+n[h]*i.g[1],t.g[2]+=n[s]*e.g[2]+n[h]*i.g[2]}function N(t,n){var r=lt(n),o=n.a,h=r.a
371
373
  if(i(o.a,h.a)){if(s(h.b.a,o.a,h.a)>0)return!1
372
374
  if(e(o.a,h.a)){if(o.a!==h.a){r=t.e
373
- var a=o.a.ri
375
+ var a=o.a.oi
374
376
  if(0>a)for(r.c[-(a+1)]=null;r.a>0&&null===r.c[r.d[r.a-1]];)--r.a
375
377
  else{var c=(r=r.b).d,l=r.e,u=r.c,d=u[a]
376
378
  c[d]=c[r.a],u[c[d]]=d,d<=--r.a&&(d>1?i(l[c[d>>1]],l[c[d]])?ht(r,d):at(r,d):ht(r,d)),l[a]=null,u[a]=r.b,r.b=a}D(t,K(h),o)}}else y(h.b),f(o,K(h)),n.b=r.b=!0}else{if(0>s(o.b.a,h.a,o.a))return!1
@@ -382,7 +384,7 @@ 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)
382
384
  if(!e(g,t.a)&&s(g,t.a,m)>=0||!e(v,t.a)&&0>=s(v,t.a,m)){if(v===t.a)return y(u.b),f(d.b,u),u=lt(a=I(a)).a,O(t,lt(a),c),C(t,a,K(u),u,u,!0),!0
383
385
  if(g===t.a){y(d.b),f(u.e,K(d)),w=(p=c=a).a.b.a
384
386
  do{p=ut(p)}while(p.a.b.a===w)
385
- return p=lt(a=p).a.b.c,c.a=K(d),C(t,a,(d=O(t,c,null)).c,u.b.c,p,!0),!0}return s(g,t.a,m)>=0&&(ut(a).b=a.b=!0,y(u.b),u.a.b=t.a.b,u.a.a=t.a.a),0>=s(v,t.a,m)&&(a.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=m.b,u.a.a=m.a,u.a.ri=tt(t.e,u.a),d=[0,0,0,0],m=[p.d,g.d,w.d,v.d],(u=u.a).g[0]=u.g[1]=u.g[2]=0,B(u,p,g,d,0),B(u,w,v,d,2),k(t,u,m,d,!0),ut(a).b=a.b=c.b=!0,!1}function P(t,e){for(var n=lt(e);;){for(;n.b;)e=n,n=lt(n)
387
+ return p=lt(a=p).a.b.c,c.a=K(d),C(t,a,(d=O(t,c,null)).c,u.b.c,p,!0),!0}return s(g,t.a,m)>=0&&(ut(a).b=a.b=!0,y(u.b),u.a.b=t.a.b,u.a.a=t.a.a),0>=s(v,t.a,m)&&(a.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=m.b,u.a.a=m.a,u.a.oi=tt(t.e,u.a),d=[0,0,0,0],m=[p.d,g.d,w.d,v.d],(u=u.a).g[0]=u.g[1]=u.g[2]=0,B(u,p,g,d,0),B(u,w,v,d,2),k(t,u,m,d,!0),ut(a).b=a.b=c.b=!0,!1}function $(t,e){for(var n=lt(e);;){for(;n.b;)e=n,n=lt(n)
386
388
  if(!e.b&&(n=e,null===(e=ut(e))||!e.b))break
387
389
  e.b=!1
388
390
  var r,o=e.a,h=n.a
@@ -391,25 +393,25 @@ if(i(c.b.a,l.b.a)){if(0>s(c.b.a,l.b.a,c.a)){r=!1
391
393
  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
392
394
  break t}r.b=a.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(h),h=(n=lt(e)).a):e.c&&(A(e),d(o),o=(e=ut(n)).a)),o.a!==h.a)if(o.b.a===h.b.a||e.c||n.c||o.b.a!==t.a&&h.b.a!==t.a)N(t,e)
393
395
  else if(U(t,e))break
394
- o.a===h.a&&o.b.a===h.b.a&&(E(h,o),A(e),d(o),e=ut(n))}}function $(t,n){t.a=n
395
- for(var r=n.c;null===r.oi;)if((r=r.c)===n.c){r=t
396
+ o.a===h.a&&o.b.a===h.b.a&&(E(h,o),A(e),d(o),e=ut(n))}}function P(t,n){t.a=n
397
+ for(var r=n.c;null===r.hi;)if((r=r.c)===n.c){r=t
396
398
  var o=n;(u=new ct).a=o.c.b
397
399
  var h=(l=r.f).a
398
400
  do{h=h.a}while(null!==h.b&&!l.c(l.b,u,h.b))
399
- if(h=(c=lt(l=h.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),$(r,o))
401
+ if(h=(c=lt(l=h.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))
400
402
  else{var a=i(h.b.a,u.b.a)?l:c,c=void 0
401
- l.d||a.c?(c=a===l?p(o.c.b,u.e):p(h.b.c.b,o.c).b,a.c?M(a,c):(u=r,(l=F(r,l,c)).f=ut(l).f+l.a.f,l.d=L(u,l.f)),$(r,o)):C(r,l,o.c,o.c,null,!0)}return}if(l=(u=lt(r=I(r.oi))).a,(u=O(t,u,null)).c===l){var l,u=(l=u).c,w=(h=lt(r),!1);(c=r.a).b.a!==(a=h.a).b.a&&U(t,r),e(c.a,t.a)&&(f(K(u),c),u=lt(r=I(r)).a,O(t,lt(r),h),w=!0),e(a.a,t.a)&&(f(l,K(a)),l=O(t,h,null),w=!0),w?C(t,r,l.c,u,u,!0):(o=i(a.a,c.a)?K(a):c,C(t,r,o=p(l.c.b,o),o.c,o.c,!1),o.b.oi.c=!0,P(t,r))}else C(t,r,u.c,l,l,!0)}function z(t,e){var i=new ct,n=u(t.b)
402
- 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.ri=!0,i.b=!1,n=R(n=t.f,n.a,i),i.e=n}function W(t){this.a=new j,this.b=t,this.c=T}function R(t,e,i){do{e=e.c}while(null!==e.b&&!t.c(t.b,e.b,i))
403
- return t=new j(i,e.a,e),e.a.c=t,e.a=t}function j(t,e,i){this.b=t||null,this.a=e||this,this.c=i||this}function H(){this.d=yt,this.ai=this.b=this.ci=null,this.li=[0,0,0],this.s=100130,this.n=!1,this.hi=this.a=this.e=this.f=null,this.ui=!1,this.c=this.r=this.oi=this.fi=this.di=this.ri=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.yi(null)
403
+ l.d||a.c?(c=a===l?p(o.c.b,u.e):p(h.b.c.b,o.c).b,a.c?M(a,c):(u=r,(l=F(r,l,c)).f=ut(l).f+l.a.f,l.d=L(u,l.f)),P(r,o)):C(r,l,o.c,o.c,null,!0)}return}if(l=(u=lt(r=I(r.hi))).a,(u=O(t,u,null)).c===l){var l,u=(l=u).c,w=(h=lt(r),!1);(c=r.a).b.a!==(a=h.a).b.a&&U(t,r),e(c.a,t.a)&&(f(K(u),c),u=lt(r=I(r)).a,O(t,lt(r),h),w=!0),e(a.a,t.a)&&(f(l,K(a)),l=O(t,h,null),w=!0),w?C(t,r,l.c,u,u,!0):(o=i(a.a,c.a)?K(a):c,C(t,r,o=p(l.c.b,o),o.c,o.c,!1),o.b.hi.c=!0,$(t,r))}else C(t,r,u.c,l,l,!0)}function W(t,e){var i=new ct,n=u(t.b)
404
+ 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.oi=!0,i.b=!1,n=R(n=t.f,n.a,i),i.e=n}function z(t){this.a=new j,this.b=t,this.c=T}function R(t,e,i){do{e=e.c}while(null!==e.b&&!t.c(t.b,e.b,i))
405
+ return t=new j(i,e.a,e),e.a.c=t,e.a=t}function j(t,e,i){this.b=t||null,this.a=e||this,this.c=i||this}function H(){this.d=yt,this.ci=this.b=this.li=null,this.ui=[0,0,0],this.s=100130,this.n=!1,this.ai=this.a=this.e=this.f=null,this.fi=!1,this.c=this.r=this.hi=this.di=this.yi=this.oi=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.pi(null)
404
406
  break
405
- case 1:q(t,100152),t.pi()}else switch(t.d){case 2:q(t,100154),t.wi()
407
+ case 1:q(t,100152),t.wi()}else switch(t.d){case 2:q(t,100154),t.gi()
406
408
  break
407
- case 1:q(t,100153),t.w()}}function q(t,e){t.ai&&t.ai(e,t.c)}function Y(t,e){this.b=t||this,this.d=e||this,this.a=null,this.c=!1}function J(){this.ri=this,this.oi=this.d=this.a=this.e=this.c=this.b=null,this.f=0}function K(t){return t.b.e}function Q(){this.c=new X,this.a=new Y,this.b=new J,this.d=new J,this.b.b=this.d,this.d.b=this.b}function X(t,e){this.e=t||this,this.f=e||this,this.d=this.c=null,this.g=[0,0,0],this.ri=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
408
- 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.ri&&at(n,s),i}return n=t.a++,t.c[n]=e,-(n+1)}function et(t){if(0===t.a)return ot(t.b)
409
+ case 1:q(t,100153),t.w()}}function q(t,e){t.ci&&t.ci(e,t.c)}function Y(t,e){this.b=t||this,this.d=e||this,this.a=null,this.c=!1}function J(){this.oi=this,this.hi=this.d=this.a=this.e=this.c=this.b=null,this.f=0}function K(t){return t.b.e}function Q(){this.c=new X,this.a=new Y,this.b=new J,this.d=new J,this.b.b=this.d,this.d.b=this.b}function X(t,e){this.e=t||this,this.f=e||this,this.d=this.c=null,this.g=[0,0,0],this.oi=this.a=this.b=0}function Z(){this.c=[],this.d=null,this.a=0,this.e=!1,this.b=new it}function tt(t,e){if(t.e){var i,n=t.b,s=++n.a
410
+ return 2*s>n.f&&(n.f*=2,n.c=nt(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.oi&&at(n,s),i}return n=t.a++,t.c[n]=e,-(n+1)}function et(t){if(0===t.a)return ot(t.b)
409
411
  var e=t.c[t.d[t.a-1]]
410
412
  if(0!==t.b.a&&i(rt(t.b),e))return ot(t.b)
411
413
  do{--t.a}while(t.a>0&&null===t.c[t.d[t.a-1]])
412
- 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.ri=!1,this.d[1]=1}function st(t,e){for(var i=Array(e),n=0;t.length>n;n++)i[n]=t[n]
414
+ return e}function it(){this.d=nt([0],33),this.e=[null,null],this.c=[0,0],this.a=0,this.f=32,this.b=0,this.oi=!1,this.d[1]=1}function nt(t,e){for(var i=Array(e),n=0;t.length>n;n++)i[n]=t[n]
413
415
  for(;e>n;n++)i[n]=0
414
416
  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]
415
417
  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&&ht(t,1)),r}function ht(t,e){for(var n=t.d,s=t.e,r=t.c,o=e,h=n[o];;){var a=o<<1
@@ -418,110 +420,110 @@ var c=n[a]
418
420
  if(a>t.a||i(s[h],s[c])){n[o]=h,r[h]=o
419
421
  break}n[o]=c,r[c]=o,o=a}}function at(t,e){for(var n=t.d,s=t.e,r=t.c,o=e,h=n[o];;){var a=o>>1,c=n[a]
420
422
  if(0===a||i(s[c],s[h])){n[o]=h,r[h]=o
421
- break}n[o]=c,r[c]=o,o=a}}function ct(){this.e=this.a=null,this.f=0,this.c=this.b=this.ri=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
423
+ break}n[o]=c,r[c]=o,o=a}}function ct(){this.e=this.a=null,this.f=0,this.c=this.b=this.oi=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
422
424
  case 100140:switch(e){case 100130:case 100131:case 100132:case 100133:case 100134:return void(this.s=e)}break
423
- case 100141:return void(this.ui=!!e)
425
+ case 100141:return void(this.fi=!!e)
424
426
  default:return void q(this,100900)}q(this,100901)},ft.y=function(t){switch(t){case 100142:return 0
425
427
  case 100140:return this.s
426
- case 100141:return this.ui
427
- default:q(this,100900)}return!1},ft.A=function(t,e,i){this.li[0]=t,this.li[1]=e,this.li[2]=i},ft.z=function(t,e){var i=e||null
428
- switch(t){case 100100:case 100106:this.ri=i
428
+ case 100141:return this.fi
429
+ default:q(this,100900)}return!1},ft.A=function(t,e,i){this.ui[0]=t,this.ui[1]=e,this.ui[2]=i},ft.z=function(t,e){var i=e||null
430
+ switch(t){case 100100:case 100106:this.oi=i
429
431
  break
430
- case 100104:case 100110:this.di=i
432
+ case 100104:case 100110:this.yi=i
431
433
  break
432
- case 100101:case 100107:this.fi=i
434
+ case 100101:case 100107:this.di=i
433
435
  break
434
- case 100102:case 100108:this.oi=i
436
+ case 100102:case 100108:this.hi=i
435
437
  break
436
- case 100103:case 100109:this.ai=i
438
+ case 100103:case 100109:this.ci=i
437
439
  break
438
- case 100105:case 100111:this.hi=i
440
+ case 100105:case 100111:this.ai=i
439
441
  break
440
442
  case 100112:this.r=i
441
443
  break
442
444
  default:q(this,100900)}},ft.C=function(t,e){var i=!1,n=[0,0,0]
443
445
  V(this,2)
444
- 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.ci)?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.ci=i},ft.yi=function(t){V(this,yt),this.d=1,this.b=new Q,this.c=t},ft.pi=function(){V(this,1),this.d=2,this.ci=null},ft.wi=function(){V(this,2),this.d=1},ft.w=function(){V(this,1),this.d=yt
445
- var t=!1,n=[u=this.li[0],r=this.li[1],h=this.li[2]]
446
+ 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.li)?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.li=i},ft.pi=function(t){V(this,yt),this.d=1,this.b=new Q,this.c=t},ft.wi=function(){V(this,1),this.d=2,this.li=null},ft.gi=function(){V(this,2),this.d=1},ft.w=function(){V(this,1),this.d=yt
447
+ var t=!1,n=[u=this.ui[0],r=this.ui[1],h=this.ui[2]]
446
448
  if(0===u&&0===r&&0===h){for(var r=[-2e150,-2e150,-2e150],o=[2e150,2e150,2e150],h=[],l=[],u=(t=this.b.c).e;u!==t;u=u.e)for(var f=0;3>f;++f){var y=u.g[f]
447
449
  o[f]>y&&(o[f]=y,l[f]=u),y>r[f]&&(r[f]=y,h[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]-(h=h[u]).g[0],o.g[1]-h.g[1],o.g[2]-h.g[2]],f=[0,0,0],u=t.e;u!==t;u=u.e)f[0]=u.g[0]-h.g[0],f[1]=u.g[1]-h.g[1],f[2]=u.g[2]-h.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])
448
450
  0>=r&&(n[0]=n[1]=n[2]=0,n[_(o)]=1)}else n[0]=0,n[1]=0,n[2]=1
449
451
  t=!0}for(r=((l=_(n))+1)%3,h=(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[h]
450
452
  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)
451
- 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).ri;u!==n;u=t)t=u.ri,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.ri),d(r)),u!==t&&u!==t.b||(t=t.ri),d(u))
452
- for(this.e=n=new Z,u=(t=this.b.c).e;u!==t;u=u.e)u.ri=tt(n,u)
453
+ 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).oi;u!==n;u=t)t=u.oi,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.oi),d(r)),u!==t&&u!==t.b||(t=t.oi),d(u))
454
+ for(this.e=n=new Z,u=(t=this.b.c).e;u!==t;u=u.e)u.oi=tt(n,u)
453
455
  for((t=>{t.d=[]
454
456
  for(var e=0;t.a>e;e++)t.d[e]=e
455
457
  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)ht(t,e)
456
- t.ri=!0})(t.b)})(n),this.f=new W(this),z(this,-dt),z(this,dt);null!==(n=et(this.e));){for(;;){t:if(u=this.e,0===u.a)t=rt(u.b)
458
+ t.oi=!0})(t.b)})(n),this.f=new z(this),W(this,-dt),W(this,dt);null!==(n=et(this.e));){for(;;){t:if(u=this.e,0===u.a)t=rt(u.b)
457
459
  else if(t=u.c[u.d[u.a-1]],0!==u.b.a&&(u=rt(u.b),i(u,t))){t=u
458
460
  break t}if(null===t||!e(t,n))break
459
- t=et(this.e),D(this,n.c,t.c)}$(this,n)}for(this.a=this.f.a.a.b.a.a,n=0;null!==(t=this.f.a.a.b);)t.ri||++n,A(t)
461
+ 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.oi||++n,A(t)
460
462
  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))
461
- if(!this.n){if(n=this.b,this.ui)for(u=n.b.ri;u!==n.b;u=t)t=u.ri,u.b.d.c!==u.d.c?u.f=u.d.c?1:-1:d(u)
463
+ if(!this.n){if(n=this.b,this.fi)for(u=n.b.oi;u!==n.b;u=t)t=u.oi,u.b.d.c!==u.d.c?u.f=u.d.c?1:-1:d(u)
462
464
  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,h=void 0;u.e!==r;)if(i(u.b.a,r.a)){for(;r.e!==u&&(a(r.e)||0>=s(r.a,r.b.a,r.e.b.a));)r=(h=p(r.e,r)).b
463
465
  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=(h=p(u,u.c.b)).b
464
- u=u.e}for(;r.e.e!==u;)r=(h=p(r.e,r)).b}if(this.ri||this.oi||this.fi||this.di)if(this.ui){for(t=(n=this.b).a.b;t!==n.a;t=t.b)if(t.c){this.ri&&this.ri(2,this.c),u=t.a
465
- do{this.fi&&this.fi(u.a.d,this.c),u=u.e}while(u!==t.a)
466
- this.oi&&this.oi(this.c)}}else{for(t=!!this.di,u=!1,r=-1,h=(n=this.b).a.d;h!==n.a;h=h.d)if(h.c){u||(this.ri&&this.ri(4,this.c),u=!0),l=h.a
467
- do{t&&r!==(o=l.b.d.c?0:1)&&(r=o,this.di&&this.di(!!r,this.c)),this.fi&&this.fi(l.a.d,this.c),l=l.e}while(l!==h.a)}u&&this.oi&&this.oi(this.c)}if(this.r){for(u=(n=this.b).a.b;u!==n.a;u=t)if(t=u.b,!u.c){h=(r=u.a).e,l=void 0
466
+ u=u.e}for(;r.e.e!==u;)r=(h=p(r.e,r)).b}if(this.oi||this.hi||this.di||this.yi)if(this.fi){for(t=(n=this.b).a.b;t!==n.a;t=t.b)if(t.c){this.oi&&this.oi(2,this.c),u=t.a
467
+ do{this.di&&this.di(u.a.d,this.c),u=u.e}while(u!==t.a)
468
+ this.hi&&this.hi(this.c)}}else{for(t=!!this.yi,u=!1,r=-1,h=(n=this.b).a.d;h!==n.a;h=h.d)if(h.c){u||(this.oi&&this.oi(4,this.c),u=!0),l=h.a
469
+ do{t&&r!==(o=l.b.d.c?0:1)&&(r=o,this.yi&&this.yi(!!r,this.c)),this.di&&this.di(l.a.d,this.c),l=l.e}while(l!==h.a)}u&&this.hi&&this.hi(this.c)}if(this.r){for(u=(n=this.b).a.b;u!==n.a;u=t)if(t=u.b,!u.c){h=(r=u.a).e,l=void 0
468
470
  do{h=(l=h).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)
469
- 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.gi={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},xi:{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},bi:{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.Si=H.prototype.x,H.prototype._i=H.prototype.B,H.prototype.Ei=H.prototype.y,H.prototype.Ti=H.prototype.A,H.prototype.Ai=H.prototype.z,H.prototype.Mi=H.prototype.C,H.prototype.Ii=H.prototype.yi,H.prototype.Fi=H.prototype.pi,H.prototype.Li=H.prototype.wi,H.prototype.Gi=H.prototype.w,t.exports=it.gi})(nt)
470
- var st=nt.exports
471
- class rt{process(t,e=!0,i=!1,n=!0){if(0===t.length)return{Oi:{vertices:[],indices:[]},Ci:[]}
471
+ 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},st.mi={GluTesselator:H,xi:{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},bi:{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},Si:{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._i=H.prototype.x,H.prototype.Ei=H.prototype.B,H.prototype.Ti=H.prototype.y,H.prototype.Ai=H.prototype.A,H.prototype.Mi=H.prototype.z,H.prototype.Ii=H.prototype.C,H.prototype.Fi=H.prototype.pi,H.prototype.Li=H.prototype.wi,H.prototype.Gi=H.prototype.gi,H.prototype.Oi=H.prototype.w,t.exports=st.mi})(rt)
472
+ var ot=rt.exports
473
+ class ht{process(t,e=!0,i=!1,n=!0){if(0===t.length)return{Ci:{vertices:[],indices:[]},ki:[]}
472
474
  const s=t.filter(t=>t.points.length>=3)
473
- return 0===s.length?{Oi:{vertices:[],indices:[]},Ci:[]}:this.ki(s,e,i,n)}Di(t,e=!0,i=!1,n=!0){return 0===t.length?{Oi:{vertices:[],indices:[]},Ci:[]}:this.Bi(t,e,i,n)}ki(t,e,i,n){const s=!i&&!e
475
+ return 0===s.length?{Ci:{vertices:[],indices:[]},ki:[]}:this.Di(s,e,i,n)}Bi(t,e=!0,i=!1,n=!0){return 0===t.length?{Ci:{vertices:[],indices:[]},ki:[]}:this.Ni(t,e,i,n)}Di(t,e,i,n){const s=!i&&!e
474
476
  let r,o
475
- s?(o=this.Ni(t,!0),(e||n)&&(r=this.Ni(t))):(r=this.Ni(t),o=r)
476
- let h=n?s?o:r??this.Ni(t):[]
477
- if(e){const t=this.Ui(r,"boundary")
478
- if(!t)return c.warn("libtess returned empty result from boundary pass"),{Oi:{vertices:[],indices:[]},Ci:[]}
479
- o=this.Pi(t),n&&(h=o)}const a=this.Ui(o,"triangles")
480
- return a?{Oi:{vertices:a.vertices,indices:a.indices||[]},Ci:h,$i:e}:(c.warn(e?"libtess returned empty result from triangulation pass":"libtess returned empty result from single-pass triangulation"),{Oi:{vertices:[],indices:[]},Ci:h})}Bi(t,e,i,n){const s=!i&&!e
477
+ s?(o=this.Ui(t,!0),(e||n)&&(r=this.Ui(t))):(r=this.Ui(t),o=r)
478
+ let h=n?s?o:r??this.Ui(t):[]
479
+ if(e){const t=this.$i(r,"boundary")
480
+ if(!t)return c.warn("libtess returned empty result from boundary pass"),{Ci:{vertices:[],indices:[]},ki:[]}
481
+ o=this.Pi(t),n&&(h=o)}const a=this.$i(o,"triangles")
482
+ return a?{Ci:{vertices:a.vertices,indices:a.indices||[]},ki:h,Wi:e}:(c.warn(e?"libtess returned empty result from triangulation pass":"libtess returned empty result from single-pass triangulation"),{Ci:{vertices:[],indices:[]},ki:h})}Ni(t,e,i,n){const s=!i&&!e
481
483
  let r,o
482
484
  s?(o=this.zi(t),(e||n)&&(r=t)):(r=t,o=t)
483
485
  let h=n?s?o:r??t:[]
484
- if(e){const t=this.Ui(r,"boundary")
485
- if(!t)return c.warn("libtess returned empty result from boundary pass"),{Oi:{vertices:[],indices:[]},Ci:[]}
486
- o=this.Pi(t),n&&(h=o)}const a=this.Ui(o,"triangles")
487
- return a?{Oi:{vertices:a.vertices,indices:a.indices||[]},Ci:h,$i:e}:(c.warn(e?"libtess returned empty result from triangulation pass":"libtess returned empty result from single-pass triangulation"),{Oi:{vertices:[],indices:[]},Ci:h})}Ni(t,e=!1){const i=Array(t.length)
486
+ if(e){const t=this.$i(r,"boundary")
487
+ if(!t)return c.warn("libtess returned empty result from boundary pass"),{Ci:{vertices:[],indices:[]},ki:[]}
488
+ o=this.Pi(t),n&&(h=o)}const a=this.$i(o,"triangles")
489
+ return a?{Ci:{vertices:a.vertices,indices:a.indices||[]},ki:h,Wi:e}:(c.warn(e?"libtess returned empty result from triangulation pass":"libtess returned empty result from single-pass triangulation"),{Ci:{vertices:[],indices:[]},ki:h})}Ui(t,e=!1){const i=Array(t.length)
488
490
  for(let n=0;t.length>n;n++){const s=t[n].points,r=s.length,o=r>1&&s[0].x===s[r-1].x&&s[0].y===s[r-1].y?r-1:r,h=Array(2*(o+1))
489
491
  let a=0
490
492
  if(e)for(let t=o-1;t>=0;t--){const e=s[t]
491
493
  h[a++]=e.x,h[a++]=e.y}else for(let t=0;o>t;t++){const e=s[t]
492
494
  h[a++]=e.x,h[a++]=e.y}2>a||(h[a++]=h[0],h[a++]=h[1]),i[n]=h}return i}zi(t){const e=Array(t.length)
493
- for(let i=0;t.length>i;i++)e[i]=this.Wi(t[i])
494
- return e}Wi(t){const e=t.length
495
+ for(let i=0;t.length>i;i++)e[i]=this.Ri(t[i])
496
+ return e}Ri(t){const e=t.length
495
497
  if(0===e)return[]
496
498
  const i=4>e||t[0]!==t[e-2]||t[1]!==t[e-1]?e:e-2
497
499
  if(0===i)return[]
498
500
  const n=Array(i+2)
499
501
  let s=0
500
502
  for(let e=i-2;e>=0;e-=2)n[s++]=t[e],n[s++]=t[e+1]
501
- return 2>s||(n[s++]=n[0],n[s++]=n[1]),n}Ui(t,e){const i=new st.GluTesselator
502
- i._i(st.bi.GLU_TESS_WINDING_RULE,st.mi.GLU_TESS_WINDING_NONZERO)
503
+ return 2>s||(n[s++]=n[0],n[s++]=n[1]),n}$i(t,e){const i=new ot.GluTesselator
504
+ i.Ei(ot.Si.GLU_TESS_WINDING_RULE,ot.xi.GLU_TESS_WINDING_NONZERO)
503
505
  const n=[],s=[],r=[]
504
506
  let o=[]
505
- "boundary"===e&&i._i(st.bi.GLU_TESS_BOUNDARY_ONLY,!0),"triangles"===e?i.Ai(st.bi.GLU_TESS_VERTEX_DATA,t=>{s.push(t)}):(i.Ai(st.bi.GLU_TESS_BEGIN,()=>{o=[]}),i.Ai(st.bi.GLU_TESS_VERTEX_DATA,t=>{o.push(t)}),i.Ai(st.bi.GLU_TESS_END,()=>{o.length>0&&r.push(o)})),i.Ai(st.bi.GLU_TESS_COMBINE,t=>{const e=n.length/2
506
- return n.push(t[0],t[1]),e}),i.Ai(st.bi.GLU_TESS_ERROR,t=>{c.warn("libtess error: "+t)}),i.Ti(0,0,1),i.Ii(null)
507
- for(const e of t){i.Fi()
507
+ "boundary"===e&&i.Ei(ot.Si.GLU_TESS_BOUNDARY_ONLY,!0),"triangles"===e?i.Mi(ot.Si.GLU_TESS_VERTEX_DATA,t=>{s.push(t)}):(i.Mi(ot.Si.GLU_TESS_BEGIN,()=>{o=[]}),i.Mi(ot.Si.GLU_TESS_VERTEX_DATA,t=>{o.push(t)}),i.Mi(ot.Si.GLU_TESS_END,()=>{o.length>0&&r.push(o)})),i.Mi(ot.Si.GLU_TESS_COMBINE,t=>{const e=n.length/2
508
+ return n.push(t[0],t[1]),e}),i.Mi(ot.Si.GLU_TESS_ERROR,t=>{c.warn("libtess error: "+t)}),i.Ai(0,0,1),i.Fi(null)
509
+ for(const e of t){i.Li()
508
510
  for(let t=0;e.length>t;t+=2){const s=n.length/2
509
- n.push(e[t],e[t+1]),i.Mi([e[t],e[t+1],0],s)}i.Li()}return i.Gi(),0===n.length?null:"triangles"===e?{vertices:n,indices:s}:{vertices:n,Ri:r}}Pi(t){if(!t.Ri)return[]
511
+ n.push(e[t],e[t+1]),i.Ii([e[t],e[t+1],0],s)}i.Gi()}return i.Oi(),0===n.length?null:"triangles"===e?{vertices:n,indices:s}:{vertices:n,ji:r}}Pi(t){if(!t.ji)return[]
510
512
  const e=[]
511
- for(const i of t.Ri){const n=[]
513
+ for(const i of t.ji){const n=[]
512
514
  for(const e of i){const i=2*e
513
- n.push(t.vertices[i],t.vertices[i+1])}n.length>2&&(n[0]===n[n.length-2]&&n[1]===n[n.length-1]||n.push(n[0],n[1])),e.push(n)}return e}ji(t){if(0===t.length)return!1
515
+ n.push(t.vertices[i],t.vertices[i+1])}n.length>2&&(n[0]===n[n.length-2]&&n[1]===n[n.length-1]||n.push(n[0],n[1])),e.push(n)}return e}Hi(t){if(0===t.length)return!1
514
516
  if(1===t.length)return!1
515
517
  let e=null
516
- for(const i of t){const t=0>this.Hi(i)?-1:1
518
+ for(const i of t){const t=0>this.Vi(i)?-1:1
517
519
  if(null===e)e=t
518
- else if(t!==e)return!0}return!1}Hi(t){let e=0
520
+ else if(t!==e)return!0}return!1}Vi(t){let e=0
519
521
  const i=t.length
520
522
  if(6>i)return 0
521
523
  for(let n=0;i>n;n+=2)e+=t[n]*t[(n+3)%i]-t[(n+2)%i]*t[n+1]
522
- return e/2}}class ot{constructor(){}Vi(t,e=0,i){const n=t.Oi.vertices,s=t.Oi.indices,r=t.Ci,o=n.length,h=o/2
524
+ return e/2}}class at{constructor(){}qi(t,e=0,i){const n=t.Ci.vertices,s=t.Ci.indices,r=t.ki,o=n.length,h=o/2
523
525
  let a=[],c=0,l=!1
524
- if(0!==e)if(!0===t.$i&&r.length>0){l=!0
526
+ if(0!==e)if(!0===t.Wi&&r.length>0){l=!0
525
527
  for(const t of r){const e=t.length>>1
526
528
  2>e||(c+=e-1)}}else{const t=new Map,e=s.length
527
529
  for(let i=0;e>i;i+=3){const e=s[i],n=s[i+1],r=s[i+2]
@@ -553,229 +555,229 @@ if(p>1e-10){const t=1/Math.sqrt(p)
553
555
  g=u*t,v=-l*t}const b=3*m
554
556
  f[b]=r,f[b+1]=o,f[b+2]=0,f[b+3]=h,f[b+4]=c,f[b+5]=0,f[b+6]=r,f[b+7]=o,f[b+8]=w,f[b+9]=h,f[b+10]=c,f[b+11]=w,d[b]=g,d[b+1]=v,d[b+2]=0,d[b+3]=g,d[b+4]=v,d[b+5]=0,d[b+6]=g,d[b+7]=v,d[b+8]=0,d[b+9]=g,d[b+10]=v,d[b+11]=0
555
557
  const S=m
556
- y[x]=S,y[x+1]=S+1,y[x+2]=S+2,y[x+3]=S+1,y[x+4]=S+3,y[x+5]=S+2,x+=6,m+=4}return{vertices:f,normals:d,indices:y}}}class ht{constructor(){}qi(t,e){const i=t.length
557
- return 0===i?[]:1===i?[[0]]:this.Yi(t,e)}Yi(t,e){function i(t){return a[t]===t?t:a[t]=i(a[t])}function n(t,e){const n=i(t),s=i(e)
558
+ y[x]=S,y[x+1]=S+1,y[x+2]=S+2,y[x+3]=S+1,y[x+4]=S+3,y[x+5]=S+2,x+=6,m+=4}return{vertices:f,normals:d,indices:y}}}class ct{constructor(){}Yi(t,e){const i=t.length
559
+ return 0===i?[]:1===i?[[0]]:this.Ji(t,e)}Ji(t,e){function i(t){return a[t]===t?t:a[t]=i(a[t])}function n(t,e){const n=i(t),s=i(e)
558
560
  n!==s&&(c[s]>c[n]?a[n]=s:c[n]>c[s]?a[s]=n:(a[s]=n,c[n]++))}const s=t.length,r=Array(s),o=Array(2*s)
559
561
  let h=0
560
- for(let i=0;s>i;i++)r[i]=this.Ji(t[i],e[i]),o[h++]=[r[i].Ki,0,i],o[h++]=[r[i].Qi,1,i]
562
+ for(let i=0;s>i;i++)r[i]=this.Ki(t[i],e[i]),o[h++]=[r[i].Qi,0,i],o[h++]=[r[i].Xi,1,i]
561
563
  o.sort((t,e)=>t[0]-e[0]||t[1]-e[1])
562
564
  const a=Array.from({length:s},(t,e)=>e),c=Array(s).fill(0),l=new Set
563
565
  for(const[,t,e]of o)if(0===t){const t=r[e]
564
566
  for(const i of l){const s=r[i]
565
- s.Xi+.001>t.Zi&&t.Xi>s.Zi-.001&&n(e,i)}l.add(e)}else l.delete(e)
567
+ s.Zi+.001>t.tn&&t.Zi>s.tn-.001&&n(e,i)}l.add(e)}else l.delete(e)
566
568
  const u=new Map
567
569
  for(let t=0;s>t;t++){const e=i(t)
568
570
  let n=u.get(e)
569
- n||(n=[],u.set(e,n)),n.push(t)}return Array.from(u.values())}Ji(t,e){return{Ki:t.bounds.min.x+e.x,Zi:t.bounds.min.y+e.y,Qi:t.bounds.max.x+e.x,Xi:t.bounds.max.y+e.y}}}class at{constructor(t){this.tn=[],this.en=new Map,this.compare=t}G(t){const e=this.en.get(t)
570
- if(void 0!==e)return this.nn(e),void this.sn(e)
571
- const i=this.tn.length
572
- this.tn.push(t),this.en.set(t,i),this.nn(i)}rn(){const t=this.tn.length
571
+ n||(n=[],u.set(e,n)),n.push(t)}return Array.from(u.values())}Ki(t,e){return{Qi:t.bounds.min.x+e.x,tn:t.bounds.min.y+e.y,Xi:t.bounds.max.x+e.x,Zi:t.bounds.max.y+e.y}}}class lt{constructor(t){this.en=[],this.nn=new Map,this.compare=t}G(t){const e=this.nn.get(t)
572
+ if(void 0!==e)return this.sn(e),void this.rn(e)
573
+ const i=this.en.length
574
+ this.en.push(t),this.nn.set(t,i),this.sn(i)}hn(){const t=this.en.length
573
575
  if(!t)return
574
- if(1===t){const t=this.tn.pop()
575
- return this.en.clear(),t}const e=this.tn[0],i=this.tn.pop()
576
- return this.tn[0]=i,this.en.delete(e),this.en.set(i,0),this.sn(0),e}update(t){const e=this.en.get(t)
577
- void 0!==e?(this.nn(e),this.sn(e)):this.G(t)}hn(){return!this.tn.length}an(t,e){const i=this.tn[t],n=this.tn[e]
578
- this.tn[t]=n,this.tn[e]=i,this.en.set(i,e),this.en.set(n,t)}nn(t){const e=this.tn[t]
579
- for(;t>0;){const i=t-1>>1,n=this.tn[i]
576
+ if(1===t){const t=this.en.pop()
577
+ return this.nn.clear(),t}const e=this.en[0],i=this.en.pop()
578
+ return this.en[0]=i,this.nn.delete(e),this.nn.set(i,0),this.rn(0),e}update(t){const e=this.nn.get(t)
579
+ void 0!==e?(this.sn(e),this.rn(e)):this.G(t)}an(){return!this.en.length}cn(t,e){const i=this.en[t],n=this.en[e]
580
+ this.en[t]=n,this.en[e]=i,this.nn.set(i,e),this.nn.set(n,t)}sn(t){const e=this.en[t]
581
+ for(;t>0;){const i=t-1>>1,n=this.en[i]
580
582
  if(this.compare(e,n)>=0)break
581
- this.tn[t]=n,this.en.set(n,t),t=i}this.tn[t]=e,this.en.set(e,t)}sn(t){const e=this.tn[t],i=this.tn.length,n=i>>1
583
+ this.en[t]=n,this.nn.set(n,t),t=i}this.en[t]=e,this.nn.set(e,t)}rn(t){const e=this.en[t],i=this.en.length,n=i>>1
582
584
  for(;n>t;){const n=1+(t<<1),s=n+1
583
585
  let r=t,o=e
584
- const h=this.tn[n]
585
- if(0>this.compare(h,o)&&(r=n,o=h),i>s){const t=this.tn[s]
586
+ const h=this.en[n]
587
+ if(0>this.compare(h,o)&&(r=n,o=h),i>s){const t=this.en[s]
586
588
  0>this.compare(t,o)&&(r=s,o=t)}if(r===t)break
587
- this.tn[t]=o,this.en.set(o,t),t=r}this.tn[t]=e,this.en.set(e,t)}}const ct={enabled:!0,areaThreshold:1}
588
- class lt{constructor(t){this.stats={pointsRemovedByVisvalingam:0,originalPointCount:0},this.config=t}cn(t){this.config=t}ln(t){if(2>=t.points.length)return t
589
+ this.en[t]=o,this.nn.set(o,t),t=r}this.en[t]=e,this.nn.set(e,t)}}const ut={enabled:!0,areaThreshold:1}
590
+ class ft{constructor(t){this.stats={pointsRemovedByVisvalingam:0,originalPointCount:0},this.config=t}ln(t){this.config=t}un(t){if(2>=t.points.length)return t
589
591
  if(!this.config.enabled)return t
590
592
  this.stats.originalPointCount+=t.points.length
591
593
  const e=t.points
592
594
  if(5>e.length)return t
593
595
  let i=e
594
- return i=this.un(i,this.config.areaThreshold),3>i.length?t:{...t,points:i}}un(t,e){if(3>=t.length)return t
595
- const i=t.length,n=t.map((t,e)=>({index:e,fn:1/0,dn:null,next:null}))
596
- for(let t=0;n.length>t;t++)n[t].dn=n[t-1]||null,n[t].next=n[t+1]||null
597
- const s=new at((t,e)=>t.fn-e.fn)
596
+ return i=this.fn(i,this.config.areaThreshold),3>i.length?t:{...t,points:i}}fn(t,e){if(3>=t.length)return t
597
+ const i=t.length,n=t.map((t,e)=>({index:e,dn:1/0,yn:null,next:null}))
598
+ for(let t=0;n.length>t;t++)n[t].yn=n[t-1]||null,n[t].next=n[t+1]||null
599
+ const s=new lt((t,e)=>t.dn-e.dn)
598
600
  for(let e=1;n.length-1>e;e++){const i=n[e]
599
- i.fn=this.yn(t[i.dn.index],t[i.index],t[i.next.index]),s.G(i)}let r=i
600
- for(;!s.hn()&&r>3;){const i=s.rn()
601
- if(!i||i.fn>e)break
602
- i.dn&&(i.dn.next=i.next),i.next&&(i.next.dn=i.dn),r--,i.dn&&i.dn.dn&&(i.dn.fn=this.yn(t[i.dn.dn.index],t[i.dn.index],t[i.next.index]),s.update(i.dn)),i.next&&i.next.next&&(i.next.fn=this.yn(t[i.dn.index],t[i.next.index],t[i.next.next.index]),s.update(i.next))}const o=[]
601
+ i.dn=this.pn(t[i.yn.index],t[i.index],t[i.next.index]),s.G(i)}let r=i
602
+ for(;!s.an()&&r>3;){const i=s.hn()
603
+ if(!i||i.dn>e)break
604
+ i.yn&&(i.yn.next=i.next),i.next&&(i.next.yn=i.yn),r--,i.yn&&i.yn.yn&&(i.yn.dn=this.pn(t[i.yn.yn.index],t[i.yn.index],t[i.next.index]),s.update(i.yn)),i.next&&i.next.next&&(i.next.dn=this.pn(t[i.yn.index],t[i.next.index],t[i.next.next.index]),s.update(i.next))}const o=[]
603
605
  let h=n[0]
604
606
  for(;h;)o.push(t[h.index]),h=h.next
605
- return this.stats.pointsRemovedByVisvalingam+=i-o.length,o}yn(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}}pn(){this.stats={pointsRemovedByVisvalingam:0,originalPointCount:0}}}const ut={distanceTolerance:.5,angleTolerance:.2},ft=1e-6
606
- class dt{constructor(t){this.curveSteps=null,this.wn={...ut,...t}}gn(t){this.wn={...ut,...t}}vn(t){if(null==t)return void(this.curveSteps=null)
607
+ return this.stats.pointsRemovedByVisvalingam+=i-o.length,o}pn(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}}wn(){this.stats={pointsRemovedByVisvalingam:0,originalPointCount:0}}}const dt={distanceTolerance:.5,angleTolerance:.2},yt=1e-6
608
+ class pt{constructor(t){this.curveSteps=null,this.gn={...dt,...t}}vn(t){this.gn={...dt,...t}}mn(t){if(null==t)return void(this.curveSteps=null)
607
609
  if(!Number.isFinite(t))return void(this.curveSteps=null)
608
610
  const e=Math.round(t)
609
- this.curveSteps=1>e?null:e}mn(t,e,i){if(null!==this.curveSteps)return this.xn(t,e,i,this.curveSteps)
611
+ this.curveSteps=1>e?null:e}xn(t,e,i){if(null!==this.curveSteps)return this.bn(t,e,i,this.curveSteps)
610
612
  const n=[]
611
- return this.bn(t.x,t.y,e.x,e.y,i.x,i.y,n),this.Sn(i.x,i.y,n),n}_n(t,e,i,n){if(null!==this.curveSteps)return this.En(t,e,i,n,this.curveSteps)
613
+ return this.Sn(t.x,t.y,e.x,e.y,i.x,i.y,n),this._n(i.x,i.y,n),n}En(t,e,i,n){if(null!==this.curveSteps)return this.Tn(t,e,i,n,this.curveSteps)
612
614
  const s=[]
613
- return this.Tn(t.x,t.y,e.x,e.y,i.x,i.y,n.x,n.y,s),this.Sn(n.x,n.y,s),s}An(t,e,i){return t+(e-t)*i}xn(t,e,i,n){const s=[]
614
- for(let r=1;n>=r;r++){const o=r/n,h=this.An(t.x,e.x,o),a=this.An(t.y,e.y,o),c=this.An(e.x,i.x,o),l=this.An(e.y,i.y,o),u=this.An(h,c,o),f=this.An(a,l,o)
615
- this.Sn(u,f,s)}return s}En(t,e,i,n,s){const r=[]
616
- for(let o=1;s>=o;o++){const h=o/s,a=this.An(t.x,e.x,h),c=this.An(t.y,e.y,h),l=this.An(e.x,i.x,h),u=this.An(e.y,i.y,h),f=this.An(i.x,n.x,h),d=this.An(i.y,n.y,h),y=this.An(a,l,h),p=this.An(c,u,h),w=this.An(l,f,h),g=this.An(u,d,h),v=this.An(y,w,h),m=this.An(p,g,h)
617
- this.Sn(v,m,r)}return r}bn(t,e,i,n,s,r,o,h=0){if(h>16)return
618
- const a=(t+i)/2,c=(e+n)/2,l=(i+s)/2,u=(n+r)/2,f=(a+l)/2,d=(c+u)/2,y=s-t,p=r-e,w=Math.abs((i-s)*p-(n-r)*y),g=this.wn.distanceTolerance??ut.distanceTolerance,v=g*g
619
- if(w>ft){if(v*(y*y+p*p)>=w*w){const h=this.wn.angleTolerance??ut.angleTolerance
620
- if(0>=h)return void this.Sn(i,n,o)
615
+ return this.An(t.x,t.y,e.x,e.y,i.x,i.y,n.x,n.y,s),this._n(n.x,n.y,s),s}Mn(t,e,i){return t+(e-t)*i}bn(t,e,i,n){const s=[]
616
+ for(let r=1;n>=r;r++){const o=r/n,h=this.Mn(t.x,e.x,o),a=this.Mn(t.y,e.y,o),c=this.Mn(e.x,i.x,o),l=this.Mn(e.y,i.y,o),u=this.Mn(h,c,o),f=this.Mn(a,l,o)
617
+ this._n(u,f,s)}return s}Tn(t,e,i,n,s){const r=[]
618
+ for(let o=1;s>=o;o++){const h=o/s,a=this.Mn(t.x,e.x,h),c=this.Mn(t.y,e.y,h),l=this.Mn(e.x,i.x,h),u=this.Mn(e.y,i.y,h),f=this.Mn(i.x,n.x,h),d=this.Mn(i.y,n.y,h),y=this.Mn(a,l,h),p=this.Mn(c,u,h),w=this.Mn(l,f,h),g=this.Mn(u,d,h),v=this.Mn(y,w,h),m=this.Mn(p,g,h)
619
+ this._n(v,m,r)}return r}Sn(t,e,i,n,s,r,o,h=0){if(h>16)return
620
+ const a=(t+i)/2,c=(e+n)/2,l=(i+s)/2,u=(n+r)/2,f=(a+l)/2,d=(c+u)/2,y=s-t,p=r-e,w=Math.abs((i-s)*p-(n-r)*y),g=this.gn.distanceTolerance??dt.distanceTolerance,v=g*g
621
+ if(w>yt){if(v*(y*y+p*p)>=w*w){const h=this.gn.angleTolerance??dt.angleTolerance
622
+ if(0>=h)return void this._n(i,n,o)
621
623
  {const a=i-t,c=n-e,l=s-i,u=r-n
622
- if(h>Math.abs(Math.atan2(a*u-c*l,a*l+c*u)))return void this.Sn(i,n,o)}}}else{const s=y*y+p*p
623
- if(0===s){if(v>=(i-t)*(i-t)+(n-e)*(n-e))return void this.Sn(i,n,o)}else{const r=((i-t)*y+(n-e)*p)/s
624
- if(r>0&&1>r&&v*s>=w*w)return void this.Sn(i,n,o)}}this.bn(t,e,a,c,f,d,o,h+1),this.bn(f,d,l,u,s,r,o,h+1)}Tn(t,e,i,n,s,r,o,h,a,c=0){if(c>16)return
625
- const l=(t+i)/2,u=(e+n)/2,f=(i+s)/2,d=(n+r)/2,y=(s+o)/2,p=(r+h)/2,w=(l+f)/2,g=(u+d)/2,v=(f+y)/2,m=(d+p)/2,x=(w+v)/2,b=(g+m)/2,S=o-t,_=h-e,E=Math.abs((i-o)*_-(n-h)*S),T=Math.abs((s-o)*_-(r-h)*S),A=this.wn.distanceTolerance??ut.distanceTolerance,M=A*A
624
+ if(h>Math.abs(Math.atan2(a*u-c*l,a*l+c*u)))return void this._n(i,n,o)}}}else{const s=y*y+p*p
625
+ if(0===s){if(v>=(i-t)*(i-t)+(n-e)*(n-e))return void this._n(i,n,o)}else{const r=((i-t)*y+(n-e)*p)/s
626
+ if(r>0&&1>r&&v*s>=w*w)return void this._n(i,n,o)}}this.Sn(t,e,a,c,f,d,o,h+1),this.Sn(f,d,l,u,s,r,o,h+1)}An(t,e,i,n,s,r,o,h,a,c=0){if(c>16)return
627
+ const l=(t+i)/2,u=(e+n)/2,f=(i+s)/2,d=(n+r)/2,y=(s+o)/2,p=(r+h)/2,w=(l+f)/2,g=(u+d)/2,v=(f+y)/2,m=(d+p)/2,x=(w+v)/2,b=(g+m)/2,S=o-t,_=h-e,E=Math.abs((i-o)*_-(n-h)*S),T=Math.abs((s-o)*_-(r-h)*S),A=this.gn.distanceTolerance??dt.distanceTolerance,M=A*A
626
628
  let I=0
627
- switch(E>ft&&(I|=1),T>ft&&(I|=2),I){case 0:const c=S*S+_*_
628
- if(0===c){if(M>=(i-t)*(i-t)+(n-e)*(n-e)&&M>=(s-t)*(s-t)+(r-e)*(r-e))return this.Sn(i,n,a),void this.Sn(s,r,a)}else{const o=((i-t)*S+(n-e)*_)/c,h=((s-t)*S+(r-e)*_)/c
629
- if(o>0&&1>o&&h>0&&1>h&&M*c>=(E+T)*(E+T))return this.Sn(i,n,a),void this.Sn(s,r,a)}break
630
- case 1:if(M*(S*S+_*_)>=T*T){const t=this.wn.angleTolerance??ut.angleTolerance
631
- if(0>=t)return this.Sn(i,n,a),void this.Sn(s,r,a)
629
+ switch(E>yt&&(I|=1),T>yt&&(I|=2),I){case 0:const c=S*S+_*_
630
+ if(0===c){if(M>=(i-t)*(i-t)+(n-e)*(n-e)&&M>=(s-t)*(s-t)+(r-e)*(r-e))return this._n(i,n,a),void this._n(s,r,a)}else{const o=((i-t)*S+(n-e)*_)/c,h=((s-t)*S+(r-e)*_)/c
631
+ if(o>0&&1>o&&h>0&&1>h&&M*c>=(E+T)*(E+T))return this._n(i,n,a),void this._n(s,r,a)}break
632
+ case 1:if(M*(S*S+_*_)>=T*T){const t=this.gn.angleTolerance??dt.angleTolerance
633
+ if(0>=t)return this._n(i,n,a),void this._n(s,r,a)
632
634
  {const e=s-i,c=r-n,l=o-s,u=h-r
633
- if(t>Math.abs(Math.atan2(e*u-c*l,e*l+c*u)))return this.Sn(i,n,a),void this.Sn(s,r,a)}}break
634
- case 2:if(M*(S*S+_*_)>=E*E){const o=this.wn.angleTolerance??ut.angleTolerance
635
- if(0>=o)return this.Sn(i,n,a),void this.Sn(s,r,a)
635
+ if(t>Math.abs(Math.atan2(e*u-c*l,e*l+c*u)))return this._n(i,n,a),void this._n(s,r,a)}}break
636
+ case 2:if(M*(S*S+_*_)>=E*E){const o=this.gn.angleTolerance??dt.angleTolerance
637
+ if(0>=o)return this._n(i,n,a),void this._n(s,r,a)
636
638
  {const h=i-t,c=n-e,l=s-i,u=r-n
637
- if(o>Math.abs(Math.atan2(h*u-c*l,h*l+c*u)))return this.Sn(i,n,a),void this.Sn(s,r,a)}}break
638
- case 3:if(M*(S*S+_*_)>=(E+T)*(E+T)){const c=this.wn.angleTolerance??ut.angleTolerance
639
- if(0>=c)return this.Sn(i,n,a),void this.Sn(s,r,a)
639
+ if(o>Math.abs(Math.atan2(h*u-c*l,h*l+c*u)))return this._n(i,n,a),void this._n(s,r,a)}}break
640
+ case 3:if(M*(S*S+_*_)>=(E+T)*(E+T)){const c=this.gn.angleTolerance??dt.angleTolerance
641
+ if(0>=c)return this._n(i,n,a),void this._n(s,r,a)
640
642
  {const l=i-t,u=n-e,f=s-i,d=r-n,y=o-s,p=h-r
641
- 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.Sn(i,n,a),void this.Sn(s,r,a)}}}this.Tn(t,e,l,u,w,g,x,b,a,c+1),this.Tn(x,b,v,m,y,p,o,h,a,c+1)}Sn(t,e,i){const n=new J(t,e)
643
+ 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._n(i,n,a),void this._n(s,r,a)}}}this.An(t,e,l,u,w,g,x,b,a,c+1),this.An(x,b,v,m,y,p,o,h,a,c+1)}_n(t,e,i){const n=new Q(t,e)
642
644
  if(0===i.length)return void i.push(n)
643
645
  const s=i[i.length-1],r=n.x-s.x,o=n.y-s.y
644
- r*r+o*o>1e-12&&i.push(n)}}class yt{constructor(t,e){this.Mn=0,this.In=0,this.Fn=[],this.Ln=null,this.Gn=null,this.On={min:new J(1/0,1/0),max:new J(-1/0,-1/0)},this.Cn=[],this.kn=[],this.Dn=[],this.Bn=new J(0,0),this.Nn=new dt(t),this.Un=new lt({...ct,...e})}setPosition(t,e){this.Bn.set(t,e)}Pn(t,e){this.Bn.x+=t,this.Bn.y+=e}$n(t,e){this.Fn.length>0&&this.zn(),this.Mn=t,this.In=e,this.Fn=[],this.On.min.set(1/0,1/0),this.On.max.set(-1/0,-1/0),this.kn.push(this.Bn.clone())}zn(){this.Ln&&this.Wn(),this.Fn.length>0&&(this.Cn.push({Rn:this.Mn,jn:this.Fn,bounds:{min:{x:this.On.min.x,y:this.On.min.y},max:{x:this.On.max.x,y:this.On.max.y}}}),this.Dn.push(this.In)),this.Fn=[]}Hn(t,e){this.Ln&&this.Wn(),this.Gn=new J(t,e),this.Vn(this.Gn),this.Ln={points:[this.Gn],glyphIndex:this.Mn}}qn(t,e){if(!this.Ln||!this.Gn)return
645
- const i=new J(t,e)
646
- this.Vn(i),this.Ln.points.push(i),this.Gn=i}Yn(t,e,i,n){if(!this.Ln||!this.Gn)return
647
- const s=this.Gn,r=new J(t,e),o=new J(i,n)
648
- if(ft>Math.abs((r.x-o.x)*(o.y-s.y)-(r.y-o.y)*(o.x-s.x)))return void this.qn(i,n)
649
- const h=this.Nn.mn(s,r,o)
646
+ r*r+o*o>1e-12&&i.push(n)}}class wt{constructor(t,e){this.In=0,this.Fn=0,this.Ln=[],this.Gn=null,this.On=null,this.Cn={min:new Q(1/0,1/0),max:new Q(-1/0,-1/0)},this.kn=[],this.Dn=[],this.Bn=[],this.Nn=new Q(0,0),this.Un=new pt(t),this.$n=new ft({...ut,...e})}setPosition(t,e){this.Nn.set(t,e)}Pn(t,e){this.Nn.x+=t,this.Nn.y+=e}Wn(t,e){this.Ln.length>0&&this.zn(),this.In=t,this.Fn=e,this.Ln=[],this.Cn.min.set(1/0,1/0),this.Cn.max.set(-1/0,-1/0),this.Dn.push(this.Nn.clone())}zn(){this.Gn&&this.Rn(),this.Ln.length>0&&(this.kn.push({jn:this.In,Hn:this.Ln,bounds:{min:{x:this.Cn.min.x,y:this.Cn.min.y},max:{x:this.Cn.max.x,y:this.Cn.max.y}}}),this.Bn.push(this.Fn)),this.Ln=[]}Vn(t,e){this.Gn&&this.Rn(),this.On=new Q(t,e),this.qn(this.On),this.Gn={points:[this.On],glyphIndex:this.In}}Yn(t,e){if(!this.Gn||!this.On)return
647
+ const i=new Q(t,e)
648
+ this.qn(i),this.Gn.points.push(i),this.On=i}Jn(t,e,i,n){if(!this.Gn||!this.On)return
649
+ const s=this.On,r=new Q(t,e),o=new Q(i,n)
650
+ if(yt>Math.abs((r.x-o.x)*(o.y-s.y)-(r.y-o.y)*(o.x-s.x)))return void this.Yn(i,n)
651
+ const h=this.Un.xn(s,r,o)
650
652
  for(let t=0;h.length>t;t++){const e=h[t]
651
- this.Vn(e),this.Ln.points.push(e)}this.Gn=o}Jn(t,e,i,n,s,r){if(!this.Ln||!this.Gn)return
652
- const o=this.Gn,h=new J(t,e),a=new J(i,n),c=new J(s,r),l=c.x-o.x,u=c.y-o.y
653
- if(ft>Math.abs((h.x-c.x)*u-(h.y-c.y)*l)&&ft>Math.abs((a.x-c.x)*u-(a.y-c.y)*l))return void this.qn(s,r)
654
- const f=this.Nn._n(o,h,a,c)
653
+ this.qn(e),this.Gn.points.push(e)}this.On=o}Kn(t,e,i,n,s,r){if(!this.Gn||!this.On)return
654
+ const o=this.On,h=new Q(t,e),a=new Q(i,n),c=new Q(s,r),l=c.x-o.x,u=c.y-o.y
655
+ if(yt>Math.abs((h.x-c.x)*u-(h.y-c.y)*l)&&yt>Math.abs((a.x-c.x)*u-(a.y-c.y)*l))return void this.Yn(s,r)
656
+ const f=this.Un.En(o,h,a,c)
655
657
  for(let t=0;f.length>t;t++){const e=f[t]
656
- this.Vn(e),this.Ln.points.push(e)}this.Gn=c}Kn(){if(!this.Ln||!this.Gn)return
657
- const t=this.Ln.points[0]
658
- this.Gn.equals(t)||this.Ln.points.push(t),this.Wn()}Wn(){if(this.Ln){const t=this.Un.ln(this.Ln)
659
- this.Fn.push(t),this.Ln=null,this.Gn=null}}Vn(t){this.On.min.x=Math.min(this.On.min.x,t.x),this.On.min.y=Math.min(this.On.min.y,t.y),this.On.max.x=Math.max(this.On.max.x,t.x),this.On.max.y=Math.max(this.On.max.y,t.y)}Qn(){return this.Fn.length>0&&this.zn(),this.Cn}Xn(){return this.kn}Zn(){return this.Dn}reset(){this.Cn=[],this.kn=[],this.Dn=[],this.Fn=[],this.Ln=null,this.Gn=null,this.Mn=0,this.In=0,this.Bn.set(0,0),this.On={min:new J(1/0,1/0),max:new J(-1/0,-1/0)}}gn(t){this.Nn.gn(t)}vn(t){this.Nn.vn(t)}ts(t){this.Un.cn({...ct,...t})}es(){return this.Un.getStats()}}class pt{constructor(){this.ns=null,this.ss=null,this.rs=null,this.hs=null,this.cs=null,this.ls=0,this.position={x:0,y:0}}setPosition(t,e){this.position.x=t,this.position.y=e,this.us&&this.us.setPosition(t,e)}Pn(t,e){this.position.x+=t,this.position.y+=e,this.us&&this.us.Pn(t,e)}fs(t){this.us=t}ds(t,e){if(!t||!t.module||!t.hb)throw Error("Invalid font object")
660
- if(this.us=e,this.ls)return
658
+ this.qn(e),this.Gn.points.push(e)}this.On=c}Qn(){if(!this.Gn||!this.On)return
659
+ const t=this.Gn.points[0]
660
+ this.On.equals(t)||this.Gn.points.push(t),this.Rn()}Rn(){if(this.Gn){const t=this.$n.un(this.Gn)
661
+ this.Ln.push(t),this.Gn=null,this.On=null}}qn(t){this.Cn.min.x=Math.min(this.Cn.min.x,t.x),this.Cn.min.y=Math.min(this.Cn.min.y,t.y),this.Cn.max.x=Math.max(this.Cn.max.x,t.x),this.Cn.max.y=Math.max(this.Cn.max.y,t.y)}Xn(){return this.Ln.length>0&&this.zn(),this.kn}Zn(){return this.Dn}ts(){return this.Bn}reset(){this.kn=[],this.Dn=[],this.Bn=[],this.Ln=[],this.Gn=null,this.On=null,this.In=0,this.Fn=0,this.Nn.set(0,0),this.Cn={min:new Q(1/0,1/0),max:new Q(-1/0,-1/0)}}vn(t){this.Un.vn(t)}mn(t){this.Un.mn(t)}es(t){this.$n.ln({...ut,...t})}ns(){return this.$n.getStats()}}class gt{constructor(){this.ss=null,this.rs=null,this.hs=null,this.cs=null,this.ls=null,this.us=0,this.position={x:0,y:0}}setPosition(t,e){this.position.x=t,this.position.y=e,this.fs&&this.fs.setPosition(t,e)}Pn(t,e){this.position.x+=t,this.position.y+=e,this.fs&&this.fs.Pn(t,e)}ds(t){this.fs=t}ys(t,e){if(!t||!t.module||!t.hb)throw Error("Invalid font object")
662
+ if(this.fs=e,this.us)return
661
663
  const i=t.module
662
- this.ns=i.ys((t,e,i,n,s)=>{this.us?.Hn(n,s)},"viiiffi"),this.ss=i.ys((t,e,i,n,s)=>{this.us?.qn(n,s)},"viiiffi"),this.rs=i.ys((t,e,i,n,s,r,o)=>{this.us?.Yn(n,s,r,o)},"viiiffffi"),this.hs=i.ys((t,e,i,n,s,r,o,h,a)=>{this.us?.Jn(n,s,r,o,h,a)},"viiiffffffi"),this.cs=i.ys(()=>{this.us?.Kn()},"viiii"),this.ls=i.exports.ps(),i.exports.ws(this.ls,this.ns,0,0),i.exports.gs(this.ls,this.ss,0,0),i.exports.vs(this.ls,this.rs,0,0),i.exports.xs(this.ls,this.hs,0,0),i.exports.bs(this.ls,this.cs,0,0)}Ss(){if(!this.ls)throw Error("Draw functions not initialized")
663
- return this.ls}destroy(t){if(!t||!t.module||!t.hb)return
664
+ this.ss=i.ps((t,e,i,n,s)=>{this.fs?.Vn(n,s)},"viiiffi"),this.rs=i.ps((t,e,i,n,s)=>{this.fs?.Yn(n,s)},"viiiffi"),this.hs=i.ps((t,e,i,n,s,r,o)=>{this.fs?.Jn(n,s,r,o)},"viiiffffi"),this.cs=i.ps((t,e,i,n,s,r,o,h,a)=>{this.fs?.Kn(n,s,r,o,h,a)},"viiiffffffi"),this.ls=i.ps(()=>{this.fs?.Qn()},"viiii"),this.us=i.exports.ws(),i.exports.gs(this.us,this.ss,0,0),i.exports.vs(this.us,this.rs,0,0),i.exports.xs(this.us,this.hs,0,0),i.exports.bs(this.us,this.cs,0,0),i.exports.Ss(this.us,this.ls,0,0)}_s(){if(!this.us)throw Error("Draw functions not initialized")
665
+ return this.us}destroy(t){if(!t||!t.module||!t.hb)return
664
666
  const e=t.module
665
- try{this.ls&&(e.exports._s(this.ls),this.ls=0),null!==this.ns&&(e.Es(this.ns),this.ns=null),null!==this.ss&&(e.Es(this.ss),this.ss=null),null!==this.rs&&(e.Es(this.rs),this.rs=null),null!==this.hs&&(e.Es(this.hs),this.hs=null),null!==this.cs&&(e.Es(this.cs),this.cs=null)}catch(t){c.warn("Error destroying draw callbacks:",t)}this.us=void 0}}const wt=new WeakMap
666
- class gt{constructor(t,e){this.Ts="default",this.As="default",this.Ms=new Set,this.Is=[],this.Fs=[],this.Ls=[],this.cache=t,this.Xt=e,this.tessellator=new rt,this.Gs=new ot,this.Os=new ht,this.us=new yt,this.Cs=(()=>{const t=this.Xt.module,e=wt.get(t)
667
+ try{this.us&&(e.exports.Es(this.us),this.us=0),null!==this.ss&&(e.Ts(this.ss),this.ss=null),null!==this.rs&&(e.Ts(this.rs),this.rs=null),null!==this.hs&&(e.Ts(this.hs),this.hs=null),null!==this.cs&&(e.Ts(this.cs),this.cs=null),null!==this.ls&&(e.Ts(this.ls),this.ls=null)}catch(t){c.warn("Error destroying draw callbacks:",t)}this.fs=void 0}}const vt=new WeakMap
668
+ class mt{constructor(t,e){this.As="default",this.Ms="default",this.Is=new Set,this.Fs=[],this.Ls=[],this.Gs=[],this.cache=t,this.Xt=e,this.tessellator=new ht,this.Os=new at,this.Cs=new ct,this.fs=new wt,this.ks=(()=>{const t=this.Xt.module,e=vt.get(t)
667
669
  if(e)return e
668
- const i=new pt
669
- return wt.set(t,i),i})(),this.Cs.ds(this.Xt,this.us),this.ks=Z,this.Ds=tt,this.Bs=et}es(){return this.us.es()}gn(t){this.wn=t,this.us.gn(t),this.Ns()}vn(t){if(null==t)this.curveSteps=void 0
670
+ const i=new gt
671
+ return vt.set(t,i),i})(),this.ks.ys(this.Xt,this.fs),this.Ds=et,this.Bs=it,this.Ns=nt}ns(){return this.fs.ns()}vn(t){this.gn=t,this.fs.vn(t),this.Us()}mn(t){if(null==t)this.curveSteps=void 0
670
672
  else if(Number.isFinite(t)){const e=Math.round(t)
671
673
  this.curveSteps=1>e?void 0:e}else this.curveSteps=void 0
672
- this.us.vn(this.curveSteps),this.Ns()}ts(t){this.Us=t,this.us.ts(t),this.Ns()}Ps(t){this.Ts=t,this.Ns()}Ns(){this.As=`${this.Ts}__${this.$s()}`}$s(){return[(()=>{if(void 0!==this.curveSteps)return"cf:steps:"+this.curveSteps
673
- const t=this.wn?.distanceTolerance??ut.distanceTolerance,e=this.wn?.angleTolerance??ut.angleTolerance
674
- return`cf:${t.toFixed(4)},${e.toFixed(4)}`})(),`opt:${this.Us?.enabled??1?1:0},${(this.Us?.areaThreshold??1).toFixed(4)}`].join("|")}zs(t,e,i,n,r,o=!1,h){if(a){let e=0
675
- for(let i=0;t.length>i;i++)e+=t[i].length}const c=this.Ls
674
+ this.fs.mn(this.curveSteps),this.Us()}es(t){this.$s=t,this.fs.es(t),this.Us()}Ps(t){this.As=t,this.Us()}Us(){this.Ms=`${this.As}__${this.Ws()}`}Ws(){return[(()=>{if(void 0!==this.curveSteps)return"cf:steps:"+this.curveSteps
675
+ const t=this.gn?.distanceTolerance??dt.distanceTolerance,e=this.gn?.angleTolerance??dt.angleTolerance
676
+ return`cf:${t.toFixed(4)},${e.toFixed(4)}`})(),`opt:${this.$s?.enabled??1?1:0},${(this.$s?.areaThreshold??1).toFixed(4)}`].join("|")}zs(t,e,i,n,r,o=!1,h){if(a){let e=0
677
+ for(let i=0;t.length>i;i++)e+=t[i].length}const c=this.Gs
676
678
  c.length=0
677
679
  let l=0,u=0,f=0,d=0,y=0
678
680
  const p=(t,e,i,n)=>{const s=y
679
681
  let r=c[l]
680
- return r?(r.data=t,r.px=e,r.Ws=i,r.Rs=n,r.js=s):(r={data:t,px:e,Ws:i,Rs:n,js:s},c[l]=r),l++,u+=t.vertices.length,f+=t.normals.length,d+=t.indices.length,y+=t.vertices.length/3,s},w=[],g={min:{x:1/0,y:1/0,z:0},max:{x:-1/0,y:-1/0,z:e}}
682
+ return r?(r.data=t,r.px=e,r.Rs=i,r.js=n,r.Hs=s):(r={data:t,px:e,Rs:i,js:n,Hs:s},c[l]=r),l++,u+=t.vertices.length,f+=t.normals.length,d+=t.indices.length,y+=t.vertices.length/3,s},w=[],g={min:{x:1/0,y:1/0,z:0},max:{x:-1/0,y:-1/0,z:e}}
681
683
  for(let r=0;t.length>r;r++){const a=t[r]
682
684
  for(const t of a){const r=t.position.x,a=t.position.y,c=t.position.z,l=[]
683
- for(const e of t.glyphs)l.push(this.Hs(e.g))
685
+ for(const e of t.glyphs)l.push(this.Vs(e.g))
684
686
  let u
685
- if(t.glyphs.length>1){const e=`${this.As}_${t.text}`,i=this.Bs.get(e)
687
+ if(t.glyphs.length>1){const e=`${this.Ms}_${t.text}`,i=this.Ns.get(e)
686
688
  let n=!1
687
- if(i&&i.Vs.length===t.glyphs.length){n=!0
688
- for(let e=0;t.glyphs.length>e;e++){const s=t.glyphs[e],r=i.qs[e]
689
- if(i.Vs[e]!==s.g||r.x!==(s.x??0)||r.y!==(s.y??0)){n=!1
689
+ if(i&&i.qs.length===t.glyphs.length){n=!0
690
+ for(let e=0;t.glyphs.length>e;e++){const s=t.glyphs[e],r=i.Ys[e]
691
+ if(i.qs[e]!==s.g||r.x!==(s.x??0)||r.y!==(s.y??0)){n=!1
690
692
  break}}}if(n&&i)u=i.groups
691
693
  else{const i=t.glyphs.length
692
- if(i>this.Is.length)for(let t=this.Is.length;i>t;t++)this.Is.push(new K(0,0,0))
693
- this.Is.length=i
694
- for(let e=0;i>e;e++){const i=t.glyphs[e],n=this.Is[e]
695
- n.x=i.x??0,n.y=i.y??0,n.z=0}u=this.Os.qi(l,this.Is),this.Bs.set(e,{Vs:t.glyphs.map(t=>t.g),qs:t.glyphs.map(t=>({x:t.x??0,y:t.y??0})),groups:u})}}else u=[[0]]
694
+ if(i>this.Fs.length)for(let t=this.Fs.length;i>t;t++)this.Fs.push(new X(0,0,0))
695
+ this.Fs.length=i
696
+ for(let e=0;i>e;e++){const i=t.glyphs[e],n=this.Fs[e]
697
+ n.x=i.x??0,n.y=i.y??0,n.z=0}u=this.Cs.Yi(l,this.Fs),this.Ns.set(e,{qs:t.glyphs.map(t=>t.g),Ys:t.glyphs.map(t=>({x:t.x??0,y:t.y??0})),groups:u})}}else u=[[0]]
696
698
  const f=o
697
699
  let d=u
698
700
  if(h&&h.size>0){d=[]
699
701
  for(const e of u)if(e.length>1){const i=[],n=[]
700
- for(const s of e)h.has(t.glyphs[s].Ys)?i.push(s):n.push(s)
701
- i.length>0&&d.push(i),n.length>0&&d.push(n)}else d.push(e)}for(const o of d)if(o.length>1&&!f){const s=o.map(e=>t.glyphs[e]),h=this.Js(s,e,i)
702
- let u=this.Ds.get(h)
703
- if(!u){const i=this.Fs
702
+ for(const s of e)h.has(t.glyphs[s].Js)?i.push(s):n.push(s)
703
+ i.length>0&&d.push(i),n.length>0&&d.push(n)}else d.push(e)}for(const o of d)if(o.length>1&&!f){const s=o.map(e=>t.glyphs[e]),h=this.Ks(s,e,i)
704
+ let u=this.Bs.get(h)
705
+ if(!u){const i=this.Ls
704
706
  let r=0
705
707
  const a=s[0].x??0,c=s[0].y??0
706
708
  for(let e=0;o.length>e;e++){const n=o[e],s=l[n],h=t.glyphs[n],u=(h.x??0)-a,f=(h.y??0)-c
707
- for(const t of s.jn){const e=t.points,n=e.length
709
+ for(const t of s.Hn){const e=t.points,n=e.length
708
710
  if(3>n)continue
709
711
  const s=n>1&&e[0].x===e[n-1].x&&e[0].y===e[n-1].y?n-1:n,o=2*(s+1)
710
712
  let h=i[r]
711
713
  !h||o>h.length?(h=Array(o),i[r]=h):h.length=o
712
714
  let a=0
713
715
  for(let t=0;s>t;t++){const i=e[t]
714
- h[a++]=i.x+u,h[a++]=i.y+f}2>a||(h[a++]=h[0],h[a++]=h[1]),r++}}i.length=r,u=this.Ks(i,e,n),this.Ds.set(h,u)}const f=s[0],d=p(u,r+(f.x??0),a+(f.y??0),c),y=u.vertices.length/3
715
- for(let i=0;o.length>i;i++){const n=o[i],s=t.glyphs[n],h=this.Qs(s,d,y,r+(s.x??0),a+(s.y??0),c,l[n],e)
716
- w.push(h),this.Xs(h.bounds,g)}}else for(const h of o){const o=t.glyphs[h],u=l[h],f=r+(o.x??0),d=a+(o.y??0),y=c
717
- if(0===u.jn.length){const t=this.Qs(o,0,0,f,d,y,u,e)
716
+ h[a++]=i.x+u,h[a++]=i.y+f}2>a||(h[a++]=h[0],h[a++]=h[1]),r++}}i.length=r,u=this.Qs(i,e,n),this.Bs.set(h,u)}const f=s[0],d=p(u,r+(f.x??0),a+(f.y??0),c),y=u.vertices.length/3
717
+ for(let i=0;o.length>i;i++){const n=o[i],s=t.glyphs[n],h=this.Xs(s,d,y,r+(s.x??0),a+(s.y??0),c,l[n],e)
718
+ w.push(h),this.Zs(h.bounds,g)}}else for(const h of o){const o=t.glyphs[h],u=l[h],f=r+(o.x??0),d=a+(o.y??0),y=c
719
+ if(0===u.Hn.length){const t=this.Xs(o,0,0,f,d,y,u,e)
718
720
  w.push(t)
719
- continue}const v=s(this.As,o.g,e,i)
721
+ continue}const v=s(this.Ms,o.g,e,i)
720
722
  let m=this.cache.get(v)
721
- m?m.Zs++:(m=this.tr(u,e,i,n),this.cache.set(v,m))
722
- const x=p(m,f,d,y),b=this.Qs(o,x,m.vertices.length/3,f,d,y,u,e)
723
- w.push(b),this.Xs(b.bounds,g)}}}c.length=l
723
+ m?m.tr++:(m=this.er(u,e,i,n),this.cache.set(v,m))
724
+ const x=p(m,f,d,y),b=this.Xs(o,x,m.vertices.length/3,f,d,y,u,e)
725
+ w.push(b),this.Zs(b.bounds,g)}}}c.length=l
724
726
  const v=new Float32Array(u),m=new Float32Array(f),x=new Uint32Array(d)
725
727
  let b=0,S=0,_=0
726
- 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*r,h=e.Ws*r,a=e.Rs*r,l=i.length
728
+ 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*r,h=e.Rs*r,a=e.js*r,l=i.length
727
729
  let u=b
728
730
  for(let t=0;l>t;t+=3)v[u]=i[t]*r+o,v[u+1]=i[t+1]*r+h,v[u+2]=i[t+2]*r+a,u+=3
729
731
  b=u,m.set(n,S),S+=n.length
730
- const f=e.js,d=s.length
732
+ const f=e.Hs,d=s.length
731
733
  let y=_
732
734
  for(let t=0;d>t;t++)x[y++]=s[t]+f
733
735
  _=y}g.min.x*=r,g.min.y*=r,g.min.z*=r,g.max.x*=r,g.max.y*=r,g.max.z*=r
734
736
  for(let t=0;w.length>t;t++)w[t].bounds.min.x*=r,w[t].bounds.min.y*=r,w[t].bounds.min.z*=r,w[t].bounds.max.x*=r,w[t].bounds.max.y*=r,w[t].bounds.max.z*=r
735
- return{vertices:v,normals:m,indices:x,er:w,planeBounds:g}}Js(t,e,i){if(0===t.length)return""
737
+ return{vertices:v,normals:m,indices:x,ir:w,planeBounds:g}}Ks(t,e,i){if(0===t.length)return""
736
738
  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("|")
737
- return`${this.As}_${r}_${Math.round(1e3*e)/1e3}_${i}`}Qs(t,e,i,n,s,r,o,h){return{ir:t.Ys,nr:t.nr,js:e,sr: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+h}}}}Hs(t){if(this.Ms.has(t))return{Rn:t,jn:[],bounds:{min:{x:0,y:0},max:{x:0,y:0}}}
738
- const e=`${this.As}_${t}`,i=this.ks.get(e)
739
+ return`${this.Ms}_${r}_${Math.round(1e3*e)/1e3}_${i}`}Xs(t,e,i,n,s,r,o,h){return{nr:t.Js,sr:t.sr,Hs:e,rr: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+h}}}}Vs(t){if(this.Is.has(t))return{jn:t,Hn:[],bounds:{min:{x:0,y:0},max:{x:0,y:0}}}
740
+ const e=`${this.Ms}_${t}`,i=this.Ds.get(e)
739
741
  if(i)return i
740
- this.Cs.fs(this.us),this.us.reset(),this.us.$n(t,0),this.Xt.module.exports.rr(this.Xt.font.hr,t,this.Cs.Ss(),0),this.us.zn()
741
- const n=this.us.Qn()[0]||{Rn:t,jn:[],bounds:{min:{x:0,y:0},max:{x:0,y:0}}}
742
- return 0===n.jn.length&&this.Ms.add(t),this.ks.set(e,n),n}Ks(t,e,i){const n=this.tessellator.Di(t,!0,i,0!==e)
743
- return this.ar(n,e)}ar(t,e){const i=this.Gs.Vi(t,e,this.Xt.upem),n=i.vertices
742
+ this.ks.ds(this.fs),this.fs.reset(),this.fs.Wn(t,0),this.Xt.module.exports.hr(this.Xt.font.ar,t,this.ks._s(),0),this.fs.zn()
743
+ const n=this.fs.Xn()[0]||{jn:t,Hn:[],bounds:{min:{x:0,y:0},max:{x:0,y:0}}}
744
+ return 0===n.Hn.length&&this.Is.add(t),this.Ds.set(e,n),n}Qs(t,e,i){const n=this.tessellator.Bi(t,!0,i,0!==e)
745
+ return this.cr(n,e)}cr(t,e){const i=this.Os.qi(t,e,this.Xt.upem),n=i.vertices
744
746
  let s=1/0,r=1/0,o=1/0,h=-1/0,a=-1/0,c=-1/0
745
747
  for(let t=0;n.length>t;t+=3){const e=n[t],i=n[t+1],l=n[t+2]
746
- s>e&&(s=e),e>h&&(h=e),r>i&&(r=i),i>a&&(a=i),o>l&&(o=l),l>c&&(c=l)}const l=new K(s,r,o),u=new K(h,a,c)
747
- return{geometry:t,vertices:i.vertices,normals:i.normals,indices:i.indices,bounds:{min:l,max:u},Zs:1}}tr(t,e,i,n){const s=this.tessellator.process(t.jn,i,n,0!==e)
748
- return this.ar(s,e)}Xs(t,e){const i=e.min,n=e.max,s=t.min,r=t.max
749
- 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)}cr(){return this.cache.getStats()}clearCache(){this.cache.clear(),this.Ds.clear(),this.Bs.clear(),this.ks.clear()}}class vt{constructor(t,e){this.lr=new Map,this.Xt=t,this.ur=e}dr(t,e,i,n,s,r,o){try{const r=[]
750
- return t.forEach((t,o)=>{const h=this.yr(t,o,e,i,n,s)
751
- r.push(h)}),r}finally{}}yr(t,i,n,s,r,o){const h=this.Xt.hb.createBuffer()
752
- "rtl"===o&&h.pr("rtl"),h.Yt(t.text),h.Jt()
748
+ s>e&&(s=e),e>h&&(h=e),r>i&&(r=i),i>a&&(a=i),o>l&&(o=l),l>c&&(c=l)}const l=new X(s,r,o),u=new X(h,a,c)
749
+ return{geometry:t,vertices:i.vertices,normals:i.normals,indices:i.indices,bounds:{min:l,max:u},tr:1}}er(t,e,i,n){const s=this.tessellator.process(t.Hn,i,n,0!==e)
750
+ return this.cr(s,e)}Zs(t,e){const i=e.min,n=e.max,s=t.min,r=t.max
751
+ 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)}lr(){return this.cache.getStats()}clearCache(){this.cache.clear(),this.Bs.clear(),this.Ns.clear(),this.Ds.clear()}}class xt{constructor(t,e){this.ur=new Map,this.Xt=t,this.dr=e}yr(t,e,i,n,s,r,o){try{const r=[]
752
+ return t.forEach((t,o)=>{const h=this.pr(t,o,e,i,n,s)
753
+ r.push(h)}),r}finally{}}pr(t,i,n,s,r,o){const h=this.Xt.hb.createBuffer()
754
+ "rtl"===o&&h.wr("rtl"),h.Yt(t.text),h.Jt()
753
755
  const a=e(this.Xt.Kt)
754
756
  this.Xt.hb.shape(this.Xt.font,h,a)
755
757
  const c=h.json(this.Xt.font)
756
758
  h.destroy()
757
759
  const l=[]
758
- let u=[],f=[],d=0,y=0,p=t.$t,w=-i*n
759
- const g=s*this.Xt.upem,v=this.wr(t,r,s),m=this.gr(t,r),x=t.text,b=x.length,S=c.length
760
+ let u=[],f=[],d=0,y=0,p=t.Pt,w=-i*n
761
+ const g=s*this.Xt.upem,v=this.gr(t,r,s),m=this.vr(t,r),x=t.text,b=x.length,S=c.length
760
762
  let _
761
763
  for(let e=0;S>e;e++){const n=c[e],s=n.Qt,r=x[s],o=r.charCodeAt(0),h=32===o||9===o||10===o||13===o
762
- n.Ys=t.Wt&&s===b-1&&"-"===r?t.Pt:t.Ut+s,n.nr=i,h&&u.length>0&&(l.push({text:f.join(""),glyphs:u,position:new K(d,y,0)}),u=[],f=[])
764
+ n.Js=t.zt&&s===b-1&&"-"===r?t.$t:t.Ut+s,n.sr=i,h&&u.length>0&&(l.push({text:f.join(""),glyphs:u,position:new X(d,y,0)}),u=[],f=[])
763
765
  const a=p+n.dx,E=w+n.dy
764
766
  if(h||(0===u.length&&(d=a,y=E),n.x=a-d,n.y=E-y,u.push(n),f.push(r)),p+=n.ax,w+=n.ay,0!==g&&S-1>e&&(p+=g),h&&(p+=v),0!==m&&S-1>e&&!h){const t=x[c[e+1].Qt],i=void 0!==_?_:A.et(r)
765
767
  if(_=!!t&&A.et(t),i&&_){let e=!0
766
- A.it(t)&&(e=!1),A.nt(r)&&(e=!1),A.st(r)&&A.st(t)&&(e=!1),e&&(p+=m)}}else _=void 0}return u.length>0&&l.push({text:f.join(""),glyphs:u,position:new K(d,y,0)}),l}wr(t,e,i){let n=0
767
- if(void 0!==t.qt&&"justify"===e&&!t.zt){let e=this.lr.get(i)
768
- void 0===e&&(e=I.measureTextWidth(this.Xt," ",i),this.lr.set(i,e)),t.qt>0?n=t.qt*e*.5:0>t.qt&&(n=t.qt*e*d)}return n}gr(t,e){if(void 0===t.qt||"justify"!==e||t.zt)return 0
769
- return t.qt>0||0>t.qt?.04*t.qt*this.Xt.upem:0}clearCache(){this.ur.clearCache()}cr(){return this.ur.cr()}}var mt={exports:{}},xt=o({__proto__:null,default:{},h(...t){const e="undefined"!=typeof globalThis?globalThis.require:void 0
768
+ A.it(t)&&(e=!1),A.nt(r)&&(e=!1),A.st(r)&&A.st(t)&&(e=!1),e&&(p+=m)}}else _=void 0}return u.length>0&&l.push({text:f.join(""),glyphs:u,position:new X(d,y,0)}),l}gr(t,e,i){let n=0
769
+ if(void 0!==t.qt&&"justify"===e&&!t.Wt){let e=this.ur.get(i)
770
+ void 0===e&&(e=I.measureTextWidth(this.Xt," ",i),this.ur.set(i,e)),t.qt>0?n=t.qt*e*.5:0>t.qt&&(n=t.qt*e*d)}return n}vr(t,e){if(void 0===t.qt||"justify"!==e||t.Wt)return 0
771
+ return t.qt>0||0>t.qt?.04*t.qt*this.Xt.upem:0}clearCache(){this.dr.clearCache()}lr(){return this.dr.lr()}}var bt={exports:{}},St=o({__proto__:null,default:{},h(...t){const e="undefined"!=typeof globalThis?globalThis.require:void 0
770
772
  if("function"==typeof e)return e("fs").h(...t)
771
773
  throw Error("fs not available in this environment")}})
772
774
  !(function(t){var e,i=(e="undefined"!=typeof document?document.currentScript?.src:void 0,async function(t={}){function i(){var t=g.buffer
773
- s.HEAP8=new Int8Array(t),s.HEAPU8=v=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.vr?.(t),x(t="Aborted("+t+")"),b=!0,t+=". Build with -sASSERTIONS for more info."
775
+ s.HEAP8=new Int8Array(t),s.HEAPU8=v=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.mr?.(t),x(t="Aborted("+t+")"),b=!0,t+=". Build with -sASSERTIONS for more info."
774
776
  var e=new WebAssembly.RuntimeError(t)
775
777
  throw w?.(e),e}var s=t,r="object"==typeof window,o="undefined"!=typeof WorkerGlobalScope,h="object"==typeof process&&process.versions?.node&&"renderer"!=process.type,a=(t,e)=>{throw e}
776
778
  "undefined"!=typeof __filename?e=__filename:o&&(e=self.location.href)
777
779
  var c,l,u=""
778
- if(h){var f=xt
780
+ if(h){var f=St
779
781
  u="undefined"!=typeof __dirname?__dirname+"/":"",l=t=>(t=S(t)?new URL(t):t,f.h(t)),c=async(t,e=!0)=>(t=S(t)?new URL(t):t,f.h(t,e?void 0:"utf8")),process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),a=(t,e)=>{throw process.exitCode=t,e}}else if(r||o){try{u=new URL(".",e).href}catch{}o&&(l=t=>{var e=new XMLHttpRequest
780
782
  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
781
783
  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)})
@@ -785,196 +787,196 @@ throw Error(e.status+" : "+e.url)}}console.log.bind(console)
785
787
  var d,y,p,w,g,v,m,x=console.error.bind(console),b=!1,S=t=>t.startsWith("file://"),_=!1,E=0,T=null
786
788
  class A{name="ExitStatus"
787
789
  constructor(t){this.message=`Program terminated with exit(${t})`,this.status=t}}var M,I,F,L=t=>{for(;t.length>0;)t.shift()(s)},G=[],O=t=>G.push(t),C=[],k=t=>C.push(t),D=!0,B=0,N={},U=t=>{if(t instanceof A||"unwind"==t)return y
788
- a(1,t)},P=()=>D||B>0,$=t=>{y=t,P()||(s.mr?.(t),b=!0),a(t,new A(t))},z=(t,e)=>Math.ceil(t/e)*e,W=t=>{var e=(t-g.buffer.byteLength+65535)/65536|0
790
+ a(1,t)},$=()=>D||B>0,P=t=>{y=t,$()||(s.br?.(t),b=!0),a(t,new A(t))},W=(t,e)=>Math.ceil(t/e)*e,z=t=>{var e=(t-g.buffer.byteLength+65535)/65536|0
789
791
  try{return g.grow(e),i(),1}catch(t){}},R=t=>{const e=t.length
790
- return[e%128|128,e>>7,...t]},j={oi:127,ai:127,li:126,f:125,d:124,e:111},H=t=>R(Array.from(t,t=>j[t])),V=t=>M.get(t),q=[],Y=(t,e)=>M.set(t,e)
791
- s.br&&(D=s.br),s.Sr&&(x=s.Sr),s._r&&(d=s._r),s.Er=g,s.Tr=K,s.ys=(t,e)=>{var i=(t=>(I||(I=new WeakMap,((t,e)=>{if(I)for(var i=0;0+e>i;i++){var n=V(i)
792
+ return[e%128|128,e>>7,...t]},j={hi:127,ci:127,ui:126,f:125,d:124,e:111},H=t=>R(Array.from(t,t=>j[t])),V=t=>M.get(t),q=[],Y=(t,e)=>M.set(t,e)
793
+ s.Sr&&(D=s.Sr),s._r&&(x=s._r),s.Er&&(d=s.Er),s.Tr=g,s.Ar=K,s.ps=(t,e)=>{var i=(t=>(I||(I=new WeakMap,((t,e)=>{if(I)for(var i=0;0+e>i;i++){var n=V(i)
792
794
  n&&I.set(n,i)}})(0,M.length)),I.get(t)||0))(t)
793
795
  if(i)return i
794
796
  var n=q.length?q.pop():M.grow(1)
795
797
  try{Y(n,t)}catch(i){if(!(i instanceof TypeError))throw i
796
798
  var s=((t,e)=>{var i=Uint8Array.of(0,97,115,109,1,0,0,0,1,...R([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)
797
799
  return new WebAssembly.Instance(n,{e:{f:t}}).exports.f})(t,e)
798
- Y(n,s)}return I.set(t,n),n},s.Es=t=>{I.delete(V(t)),Y(t,null),q.push(t)}
799
- var J={Ar:()=>n(""),Mr(){D=!1,B=0},Ir(t,e){if(N[t]&&(clearTimeout(N[t].id),delete N[t]),!e)return 0
800
- var i=setTimeout(()=>{delete N[t],(t=>{if(!b)try{t(),(()=>{if(!P())try{y=t=y,$(t)}catch(t){U(t)}var t})()}catch(t){U(t)}})(()=>F(t,performance.now()))},e)
801
- return N[t]={id:i,Fr:e},0},Lr(t){var e=v.length,i=2147483648
800
+ Y(n,s)}return I.set(t,n),n},s.Ts=t=>{I.delete(V(t)),Y(t,null),q.push(t)}
801
+ var J={Mr:()=>n(""),Ir(){D=!1,B=0},Fr(t,e){if(N[t]&&(clearTimeout(N[t].id),delete N[t]),!e)return 0
802
+ var i=setTimeout(()=>{delete N[t],(t=>{if(!b)try{t(),(()=>{if(!$())try{y=t=y,P(t)}catch(t){U(t)}var t})()}catch(t){U(t)}})(()=>F(t,performance.now()))},e)
803
+ return N[t]={id:i,Lr:e},0},Gr(t){var e=v.length,i=2147483648
802
804
  if((t>>>=0)>i)return!1
803
- for(var n=1;4>=n;n*=2){var s=e*(1+.2/n),r=Math.min(i,z(Math.max(t,s=Math.min(s,t+100663296)),65536))
804
- if(W(r))return!0}return!1},Gr:$},K=await(async()=>{function t(t){return s.Tr=K=t.exports,s.Er=g=K.memory,i(),M=K.Or,(t=>{s.Cr=t.kr,s.Dr=t.Br,s.Nr=t.Ur,s.Pr=t.$r,s.zr=t.Wr,s.Rr=t.jr,s.Hr=t.Vr,s.qr=t.Yr,s.Jr=t.Kr,s.Qr=t.Xr,s.Zr=t.eo,s.io=t.no,s.so=t.ro,s.oo=t.ho,s.ao=t.co,s.lo=t.uo,s.fo=t.do,s.yo=t.po,s.wo=t.vo,s.mo=t.xo,s.bo=t.So,s._o=t.Eo,s.To=t.Ao,s.Mo=t.Io,s.Fo=t.Lo,s.Go=t.Oo,s.Co=t.ko,s.Do=t.Bo,s.No=t.ws,s.Uo=t.gs,s.Po=t.vs,s.$o=t.xs,s.zo=t.bs,s.Wo=t.ps,s.Ro=t._s,s.jo=t.Ho,s.Vo=t.qo,s.Yo=t.Jo,s.Ko=t.Qo,s.Xo=t.Zo,s.th=t.rr,s.eh=t.ih,s.nh=t.sh,s.rh=t.oh,s.hh=t.ah,s.uh=t.fh,s.dh=t.yh,s.ph=t.wh,s.gh=t.mh,s.xh=t.bh,s.Sh=t._h,s.Eh=t.Th,F=t.Ah})(K),(()=>{if(E--,s.Mh?.(E),0==E&&T){var t=T
805
- T=null,t()}})(),K}E++,s.Mh?.(E)
806
- var e,r={l:J,Ih:J}
807
- return s.Fh?new Promise(e=>{s.Fh(r,i=>{e(t(i))})}):(m??=(e="hb.wasm",s.Lh?s.Lh(e,u):u+e),t((await(async function(t,e,i){if(!t&&!S(e)&&!h)try{var s=fetch(e,{credentials:"same-origin"})
805
+ for(var n=1;4>=n;n*=2){var s=e*(1+.2/n),r=Math.min(i,W(Math.max(t,s=Math.min(s,t+100663296)),65536))
806
+ if(z(r))return!0}return!1},Or:P},K=await(async()=>{function t(t){return s.Ar=K=t.exports,s.Tr=g=K.memory,i(),M=K.Cr,(t=>{s.kr=t.Dr,s.Br=t.Nr,s.Ur=t.$r,s.Pr=t.Wr,s.zr=t.Rr,s.jr=t.Hr,s.Vr=t.qr,s.Yr=t.Jr,s.Kr=t.Qr,s.Xr=t.Zr,s.eo=t.io,s.no=t.so,s.ro=t.oo,s.ho=t.ao,s.co=t.lo,s.uo=t.fo,s.do=t.yo,s.po=t.wo,s.vo=t.mo,s.xo=t.bo,s.So=t._o,s.Eo=t.To,s.Ao=t.Mo,s.Io=t.Fo,s.Lo=t.Go,s.Oo=t.Co,s.ko=t.Do,s.Bo=t.No,s.Uo=t.gs,s.$o=t.vs,s.Po=t.xs,s.Wo=t.bs,s.zo=t.Ss,s.Ro=t.ws,s.jo=t.Es,s.Ho=t.Vo,s.qo=t.Yo,s.Jo=t.Ko,s.Qo=t.Xo,s.Zo=t.th,s.eh=t.hr,s.ih=t.nh,s.sh=t.rh,s.oh=t.hh,s.ah=t.uh,s.fh=t.dh,s.yh=t.ph,s.wh=t.gh,s.mh=t.xh,s.bh=t.Sh,s._h=t.Eh,s.Th=t.Ah,F=t.Mh})(K),(()=>{if(E--,s.Ih?.(E),0==E&&T){var t=T
807
+ T=null,t()}})(),K}E++,s.Ih?.(E)
808
+ var e,r={l:J,Fh:J}
809
+ return s.Lh?new Promise(e=>{s.Lh(r,i=>{e(t(i))})}):(m??=(e="hb.wasm",s.Gh?s.Gh(e,u):u+e),t((await(async function(t,e,i){if(!t&&!S(e)&&!h)try{var s=fetch(e,{credentials:"same-origin"})
808
810
  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)
809
811
  return new Uint8Array(e)}catch{}return(t=>{if(t==m&&d)return new Uint8Array(d)
810
812
  if(l)return l(t)
811
813
  throw"both async and sync fetching of the wasm failed"})(t)})(t)
812
- return await WebAssembly.instantiate(i,e)}catch(t){x("failed to asynchronously prepare wasm: "+t),n(t)}})(e,i)})(d,m,r)).Gh))})()
813
- return(()=>{if(s.Oh)for("function"==typeof s.Oh&&(s.Oh=[s.Oh]);s.Oh.length>0;)s.Oh.shift()()})(),(function t(){function e(){s.Ch=!0,b||(_=!0,K.kh(),p?.(s),s.Dh?.(),(()=>{if(s.Bh)for("function"==typeof s.Bh&&(s.Bh=[s.Bh]);s.Bh.length;)O(s.Bh.shift())
814
- L(G)})())}E>0?T=t:((()=>{if(s.Nh)for("function"==typeof s.Nh&&(s.Nh=[s.Nh]);s.Nh.length;)k(s.Nh.shift())
814
+ return await WebAssembly.instantiate(i,e)}catch(t){x("failed to asynchronously prepare wasm: "+t),n(t)}})(e,i)})(d,m,r)).Oh))})()
815
+ return(()=>{if(s.Ch)for("function"==typeof s.Ch&&(s.Ch=[s.Ch]);s.Ch.length>0;)s.Ch.shift()()})(),(function t(){function e(){s.kh=!0,b||(_=!0,K.Dh(),p?.(s),s.Bh?.(),(()=>{if(s.Nh)for("function"==typeof s.Nh&&(s.Nh=[s.Nh]);s.Nh.length;)O(s.Nh.shift())
816
+ L(G)})())}E>0?T=t:((()=>{if(s.Uh)for("function"==typeof s.Uh&&(s.Uh=[s.Uh]);s.Uh.length;)k(s.Uh.shift())
815
817
  L(C)})(),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})})
816
- t.exports=i,t.exports.default=i})(mt)
817
- var bt=r(mt.exports),St={exports:{}}
818
- 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.ko(e.length+1)
818
+ t.exports=i,t.exports.default=i})(bt)
819
+ var _t=r(bt.exports),Et={exports:{}}
820
+ try{Et.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.Do(e.length+1)
819
821
  for(let n=0;e.length>n;++n){const s=e.charCodeAt(n)
820
822
  if(s>127)throw Error("Expected ASCII text")
821
- t.HEAPU8[i+n]=s}return t.HEAPU8[i+e.length]=0,{hr:i,length:e.length,Bo(){s.Bo(i)}}}function n(t,e,n){var r=0,o=0
822
- n&&(n=n.split(","),r=s.ko(16*n.length),n.forEach(t=>{var e=i(t)
823
- s.Oo(e.hr,-1,r+16*o)&&o++,e.Bo()})),s.Th(t.hr,e.hr,r,o),r&&s.Bo(r)}var s=t.Tr,r=new TextDecoder("utf8")
824
- let o=t.ys,h=t.Es
825
- var a=o(t=>{s.Bo(t)},"vi"),c=e("JSON"),l="",u=s.ko(256)
826
- return{$e(e){var i=s.ko(e.byteLength)
823
+ t.HEAPU8[i+n]=s}return t.HEAPU8[i+e.length]=0,{ar:i,length:e.length,No(){s.No(i)}}}function n(t,e,n){var r=0,o=0
824
+ n&&(n=n.split(","),r=s.Do(16*n.length),n.forEach(t=>{var e=i(t)
825
+ s.Co(e.ar,-1,r+16*o)&&o++,e.No()})),s.Ah(t.ar,e.ar,r,o),r&&s.No(r)}var s=t.Ar,r=new TextDecoder("utf8")
826
+ let o=t.ps,h=t.Ts
827
+ var a=o(t=>{s.No(t)},"vi"),c=e("JSON"),l="",u=s.Do(256)
828
+ return{We(e){var i=s.Do(e.byteLength)
827
829
  t.HEAPU8.set(new Uint8Array(e),i)
828
- var n=s.kr(i,e.byteLength,2,i,a)
829
- return{hr:n,destroy(){s.Br(n)}}},ze(i,n){var r=s.Ho(i.hr,n)
830
- const o=s.Qo(r)
831
- return{hr:r,upem:o,Uh(i){var n=s.Jo(r,e(i)),o=s.Ur(n)
832
- if(o){var h=s.$r(n,null)
833
- return t.HEAPU8.subarray(h,h+o)}},je(){var e=s.ko(2048),i=s.ko(4)
834
- t.HEAPU32[i/4]=64,s.mh(r,0,i,e)
830
+ var n=s.Dr(i,e.byteLength,2,i,a)
831
+ return{ar:n,destroy(){s.Nr(n)}}},ze(i,n){var r=s.Vo(i.ar,n)
832
+ const o=s.Xo(r)
833
+ return{ar:r,upem:o,$h(i){var n=s.Ko(r,e(i)),o=s.$r(n)
834
+ if(o){var h=s.Wr(n,null)
835
+ return t.HEAPU8.subarray(h,h+o)}},He(){var e=s.Do(2048),i=s.Do(4)
836
+ t.HEAPU32[i/4]=64,s.xh(r,0,i,e)
835
837
  var n={}
836
838
  return Array.from({length:t.HEAPU32[i/4]}).forEach((i,s)=>{var r
837
- 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.Bo(i),s.Bo(e),n},Ph(){var e=s.yh()
838
- s.Zo(r,e)
839
- var i=(e=>{const i=s.bh(e),n=s.ko(i<<2),r=n>>2,o=t.HEAPU32.subarray(r,r+i)
840
- return t.HEAPU32.set(o,r),s._h(e,-1,n,i),o})(e)
841
- return s.wh(e),i},destroy(){s.qo(r)}}},We(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,h,a)=>{l+=`C${n},${s} ${r},${o} ${h},${a}`},"viiiffffffi"),p=o((t,e,i,n,s,r,o)=>{l+=`Q${n},${s} ${r},${o}`},"viiiffffi"),w=o(()=>{l+="Z"},"viiii"),c=s.ps(),s.ws(c,f,0,0),s.gs(c,d,0,0),s.xs(c,y,0,0),s.vs(c,p,0,0),s.bs(c,w,0,0)),l="",s.rr(a,t,c,0),l}var a=s.sh(i.hr),c=null,f=null,d=null,y=null,p=null,w=null
842
- return{hr:a,$h(e){s.ih(a,e,u,256)
839
+ 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.No(i),s.No(e),n},Ph(){var e=s.ph()
840
+ s.th(r,e)
841
+ var i=(e=>{const i=s.Sh(e),n=s.Do(i<<2),r=n>>2,o=t.HEAPU32.subarray(r,r+i)
842
+ return t.HEAPU32.set(o,r),s.Eh(e,-1,n,i),o})(e)
843
+ return s.gh(e),i},destroy(){s.Yo(r)}}},Re(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,h,a)=>{l+=`C${n},${s} ${r},${o} ${h},${a}`},"viiiffffffi"),p=o((t,e,i,n,s,r,o)=>{l+=`Q${n},${s} ${r},${o}`},"viiiffffi"),w=o(()=>{l+="Z"},"viiii"),c=s.ws(),s.gs(c,f,0,0),s.vs(c,d,0,0),s.bs(c,y,0,0),s.xs(c,p,0,0),s.Ss(c,w,0,0)),l="",s.hr(a,t,c,0),l}var a=s.rh(i.ar),c=null,f=null,d=null,y=null,p=null,w=null
844
+ return{ar:a,Wh(e){s.nh(a,e,u,256)
843
845
  var i=t.HEAPU8.subarray(u,u+256)
844
- return r.decode(i.slice(0,i.indexOf(0)))},zh:n,Wh:t=>n(t).replace(/([MLQCZ])/g,"|$1 ").split("|").filter(t=>t.length).map(t=>{var e=t.split(/[ ,]/g)
845
- return{type:e[0],values:e.slice(1).filter(t=>t.length).map(t=>+t)}}),setScale(t,e){s.fh(a,t,e)},Re(i){var n=Object.entries(i),r=s.ko(8*n.length)
846
- n.forEach((i,n)=>{t.HEAPU32[r/4+2*n+0]=e(i[0]),t.HEAPF32[r/4+2*n+1]=i[1]}),s.oh(a,r,n.length),s.Bo(r)},destroy(){s.ah(a),c&&(s._s(c),c=null,h(f),h(d),h(y),h(p),h(w))}}},createBuffer(){var e=s.jr()
847
- return{hr:e,Yt(i){const n=(e=>{const i=s.ko(2*e.length),n=new Uint16Array(t.Er.buffer,i,e.length)
846
+ return r.decode(i.slice(0,i.indexOf(0)))},zh:n,Rh:t=>n(t).replace(/([MLQCZ])/g,"|$1 ").split("|").filter(t=>t.length).map(t=>{var e=t.split(/[ ,]/g)
847
+ return{type:e[0],values:e.slice(1).filter(t=>t.length).map(t=>+t)}}),setScale(t,e){s.dh(a,t,e)},je(i){var n=Object.entries(i),r=s.Do(8*n.length)
848
+ n.forEach((i,n)=>{t.HEAPU32[r/4+2*n+0]=e(i[0]),t.HEAPF32[r/4+2*n+1]=i[1]}),s.hh(a,r,n.length),s.No(r)},destroy(){s.uh(a),c&&(s.Es(c),c=null,h(f),h(d),h(y),h(p),h(w))}}},createBuffer(){var e=s.Hr()
849
+ return{ar:e,Yt(i){const n=(e=>{const i=s.Do(2*e.length),n=new Uint16Array(t.Tr.buffer,i,e.length)
848
850
  for(let t=0;n.length>t;++t)n[t]=e.charCodeAt(t)
849
- return{hr:i,length:n.length,Bo(){s.Bo(i)}}})(i)
850
- s.xo(e,n.hr,n.length,0,n.length),n.Bo()},Jt:()=>s.po(e),pr(t){s.Kr(e,{Rh:4,jh:5,Hh:6,Vh:7}[t]||0)},qh(t){var i=0
851
- 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.no(e,i)},Yh(t){var n=i(t)
852
- s.eo(e,s.Eo(n.hr,-1)),n.Bo()},Jh(t){var n=i(t)
853
- s.Xr(e,s.Ao(n.hr,-1)),n.Bo()},Kh(t){s.ro(e,t)},json(){for(var i=s.ho(e),n=[],r=s.co(e,0),o=r/4,h=s.uo(e,0)/4,a=t.HEAPU32.subarray(o,o+5*i),c=t.HEAP32.subarray(h,h+5*i),l=0;i>l;++l)n.push({g:a[5*l+0],Qt:a[5*l+2],ax:c[5*l+0],ay:c[5*l+1],dx:c[5*l+2],dy:c[5*l+3],flags:s.do(r+20*l)})
854
- return n},destroy(){s.Vr(e)}}},shape:n,Qh(e,i,a,l,u){var f=[],d=0,y=!1,p=1048576,w=s.ko(p),g=o((e,i,n)=>{var o=r.decode(t.HEAPU8.subarray(n,t.HEAPU8.indexOf(0,n)))
855
- 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.Wr(e,0,s.ho(e),w,p,0,i,c,4),f.push({ui:o,pi:JSON.parse(r.decode(t.HEAPU8.subarray(w,t.HEAPU8.indexOf(0,w)))),glyphs:2==s.Yr(e)}),1)},"iiiii")
856
- return s.So(i.hr,g,0,0),n(e,i,a),s.Bo(w),h(g),f},version(){var e=s.ko(12)
857
- s.Io(e,e+4,e+8)
858
- var i={Xh:t.HEAPU32[e/4],Zh:t.HEAPU32[(e+4)/4],ta:t.HEAPU32[(e+8)/4]}
859
- return s.Bo(e),i},ea(){var e=s.Lo()
860
- return r.decode(t.HEAPU8.subarray(e,t.HEAPU8.indexOf(0,e)))}}}}catch(t){}var _t=r(St.exports)
861
- let Et=null,Tt=null,At=null
862
- const Mt={ia(t){Tt=t,At=null,Et=null},na(t){At=t,Tt=null,Et=null},sa:async()=>Et||(Et=new Promise(async(t,e)=>{try{const e={}
863
- if(At)e._r=At
864
- else{if(!Tt)throw Error("HarfBuzz WASM path or buffer must be set before initialization.")
865
- e._r=await h(Tt)}const i=await bt(e)
866
- t({hb:_t(i),module:{ys:i.ys,exports:i.Tr,Es:i.Es}})}catch(t){e(Error("Failed to initialize HarfBuzz: "+t))}}),Et)}
867
- class It{constructor(t,e){this.text=t,this.ra=new Map,e.forEach(t=>{const e=this.ra.get(t.ir)||[]
868
- e.push(t),this.ra.set(t.ir,e)})}oa(t){const e=[]
869
- return t.ha&&e.push(...this.aa(t.ha)),t.ca&&e.push(...this.la(t.ca)),e}aa(t){const e=[]
851
+ return{ar:i,length:n.length,No(){s.No(i)}}})(i)
852
+ s.bo(e,n.ar,n.length,0,n.length),n.No()},Jt:()=>s.wo(e),wr(t){s.Qr(e,{jh:4,Hh:5,Vh:6,qh:7}[t]||0)},Yh(t){var i=0
853
+ 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.so(e,i)},Jh(t){var n=i(t)
854
+ s.io(e,s.To(n.ar,-1)),n.No()},Kh(t){var n=i(t)
855
+ s.Zr(e,s.Mo(n.ar,-1)),n.No()},Qh(t){s.oo(e,t)},json(){for(var i=s.ao(e),n=[],r=s.lo(e,0),o=r/4,h=s.fo(e,0)/4,a=t.HEAPU32.subarray(o,o+5*i),c=t.HEAP32.subarray(h,h+5*i),l=0;i>l;++l)n.push({g:a[5*l+0],Qt:a[5*l+2],ax:c[5*l+0],ay:c[5*l+1],dx:c[5*l+2],dy:c[5*l+3],flags:s.yo(r+20*l)})
856
+ return n},destroy(){s.qr(e)}}},shape:n,Xh(e,i,a,l,u){var f=[],d=0,y=!1,p=1048576,w=s.Do(p),g=o((e,i,n)=>{var o=r.decode(t.HEAPU8.subarray(n,t.HEAPU8.indexOf(0,n)))
857
+ 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.Rr(e,0,s.ao(e),w,p,0,i,c,4),f.push({fi:o,wi:JSON.parse(r.decode(t.HEAPU8.subarray(w,t.HEAPU8.indexOf(0,w)))),glyphs:2==s.Jr(e)}),1)},"iiiii")
858
+ return s._o(i.ar,g,0,0),n(e,i,a),s.No(w),h(g),f},version(){var e=s.Do(12)
859
+ s.Fo(e,e+4,e+8)
860
+ var i={Zh:t.HEAPU32[e/4],ta:t.HEAPU32[(e+4)/4],ea:t.HEAPU32[(e+8)/4]}
861
+ return s.No(e),i},ia(){var e=s.Go()
862
+ return r.decode(t.HEAPU8.subarray(e,t.HEAPU8.indexOf(0,e)))}}}}catch(t){}var Tt=r(Et.exports)
863
+ let At=null,Mt=null,It=null
864
+ const Ft={na(t){Mt=t,It=null,At=null},sa(t){It=t,Mt=null,At=null},ra:async()=>At||(At=new Promise(async(t,e)=>{try{const e={}
865
+ if(It)e.Er=It
866
+ else{if(!Mt)throw Error("HarfBuzz WASM path or buffer must be set before initialization.")
867
+ e.Er=await h(Mt)}const i=await _t(e)
868
+ t({hb:Tt(i),module:{ps:i.ps,exports:i.Ar,Ts:i.Ts}})}catch(t){e(Error("Failed to initialize HarfBuzz: "+t))}}),At)}
869
+ class Lt{constructor(t,e){this.text=t,this.oa=new Map,e.forEach(t=>{const e=this.oa.get(t.nr)||[]
870
+ e.push(t),this.oa.set(t.nr,e)})}ha(t){const e=[]
871
+ return t.aa&&e.push(...this.ca(t.aa)),t.la&&e.push(...this.ua(t.la)),e}ca(t){const e=[]
870
872
  for(const i of t){let t=0
871
- for(;-1!==(t=this.text.indexOf(i,t));)e.push(this.createTextRange(t,t+i.length,i)),t+=i.length}return e}la(t){return t.map(t=>{const e=this.text.slice(t.start,t.end)
873
+ for(;-1!==(t=this.text.indexOf(i,t));)e.push(this.createTextRange(t,t+i.length,i)),t+=i.length}return e}ua(t){return t.map(t=>{const e=this.text.slice(t.start,t.end)
872
874
  return this.createTextRange(t.start,t.end,e)})}createTextRange(t,e,i){const n=[],s=new Map
873
- for(let i=t;e>i;i++){const t=this.ra.get(i)
875
+ for(let i=t;e>i;i++){const t=this.oa.get(i)
874
876
  if(t)for(const e of t){n.push(e)
875
- const t=s.get(e.nr)||[]
876
- t.push(e),s.set(e.nr,t)}}return{start:t,end:e,ua:i,bounds:Array.from(s.values()).map(t=>this.fa(t)),glyphs:n,da:Array.from(s.keys()).sort((t,e)=>t-e)}}fa(t){if(0===t.length)return{min:{x:0,y:0,z:0},max:{x:0,y:0,z:0}}
877
+ const t=s.get(e.sr)||[]
878
+ t.push(e),s.set(e.sr,t)}}return{start:t,end:e,fa:i,bounds:Array.from(s.values()).map(t=>this.da(t)),glyphs:n,ya:Array.from(s.keys()).sort((t,e)=>t-e)}}da(t){if(0===t.length)return{min:{x:0,y:0,z:0},max:{x:0,y:0,z:0}}
877
879
  let e=1/0,i=1/0,n=1/0,s=-1/0,r=-1/0,o=-1/0
878
880
  for(const h of t)e>h.bounds.min.x&&(e=h.bounds.min.x),i>h.bounds.min.y&&(i=h.bounds.min.y),n>h.bounds.min.z&&(n=h.bounds.min.z),h.bounds.max.x>s&&(s=h.bounds.max.x),h.bounds.max.y>r&&(r=h.bounds.max.y),h.bounds.max.z>o&&(o=h.bounds.max.z)
879
- return{min:{x:e,y:i,z:n},max:{x:s,y:r,z:o}}}}const Ft=72
880
- class Lt{static{this.ya=new Map}static{this.pa=null}static{this.wa=new Map}static{this.ga=0}static{this.va=1/0}static{this.ma=0}static xa(t){const e=Object.keys(t).sort()
881
+ return{min:{x:e,y:i,z:n},max:{x:s,y:r,z:o}}}}const Gt=72
882
+ class Ot{static{this.pa=new Map}static{this.wa=null}static{this.ga=new Map}static{this.va=0}static{this.ma=1/0}static{this.xa=0}static ba(t){(t=>{V=t})(t)}static Sa(t){const e=Object.keys(t).sort()
881
883
  let i=""
882
884
  for(let n=0;e.length>n;n++)n>0&&(i+=","),i+=e[n]+":"+t[e[n]]
883
- return i}constructor(){this.ba="",Lt.pa||(Lt.pa=Mt.sa()),this.Sa=new V(()=>Lt.pa)}static _a(t){Mt.ia(t),Lt.pa=null}static Ea(t){Mt.na(t),Lt.pa=null}static init(){return Lt.pa||(Lt.pa=Mt.sa()),Lt.pa}static async create(t){if(!t.font)throw Error("Font is required. Specify options.font as a URL string or ArrayBuffer.")
884
- Lt.pa||(Lt.pa=Mt.sa())
885
- const e=await Lt.Ta(t),i=new Lt
886
- i.Aa(e)
887
- const n=await i.Ma(t),s=async e=>{const n={...t}
885
+ return i}constructor(){this._a="",Ot.wa||(Ot.wa=Ft.ra()),this.Ea=new Y(()=>Ot.wa)}static Ta(t){Ft.na(t),Ot.wa=null}static Aa(t){Ft.sa(t),Ot.wa=null}static init(){return Ot.wa||(Ot.wa=Ft.ra()),Ot.wa}static async create(t){if(!t.font)throw Error("Font is required. Specify options.font as a URL string or ArrayBuffer.")
886
+ Ot.wa||(Ot.wa=Ft.ra())
887
+ const e=await Ot.Ma(t),i=new Ot
888
+ i.Ia(e)
889
+ const n=await i.Fa(t),s=async e=>{const n={...t}
888
890
  for(const t in e){const i=e[t]
889
- void 0!==i&&(n[t]=i)}if(void 0!==e.font||void 0!==e.He||void 0!==e.Kt){const t=await Lt.Ta(n)
890
- i.Aa(t),i.Ia()}return t=n,{...await i.Ma(t),getLoadedFont(){return i.getLoadedFont()},getCacheSize(){return i.getCacheSize()},clearCache(){return i.clearCache()},measureTextWidth(t,e){return i.measureTextWidth(t,e)},update:s}}
891
- 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 Ta(t){let e="string"==typeof t.font?t.font:"buffer-"+Lt.Fa(t.font)
892
- t.He&&(e+="_var_"+Lt.xa(t.He)),t.Kt&&(e+="_feat_"+Lt.xa(t.Kt))
893
- let i=Lt.wa.get(e)
894
- return i||(i=await Lt.La(e,t.font,t.He,t.Kt)),i}static async La(t,e,i,n){const s=new Lt
891
+ void 0!==i&&(n[t]=i)}if(void 0!==e.font||void 0!==e.Ve||void 0!==e.Kt){const t=await Ot.Ma(n)
892
+ i.Ia(t),i.La()}return t=n,{...await i.Fa(t),getLoadedFont(){return i.getLoadedFont()},getCacheSize(){return i.getCacheSize()},clearCache(){return i.clearCache()},measureTextWidth(t,e){return i.measureTextWidth(t,e)},update:s}}
893
+ 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 Ma(t){let e="string"==typeof t.font?t.font:"buffer-"+Ot.Ga(t.font)
894
+ t.Ve&&(e+="_var_"+Ot.Sa(t.Ve)),t.Kt&&(e+="_feat_"+Ot.Sa(t.Kt))
895
+ let i=Ot.ga.get(e)
896
+ return i||(i=await Ot.Oa(e,t.font,t.Ve,t.Kt)),i}static async Oa(t,e,i,n){const s=new Ot
895
897
  await s.Pe(e,i,n)
896
898
  const r=s.getLoadedFont()
897
- return Lt.wa.set(t,r),Lt.Ga(r),Lt.Oa(),r}static Ga(t){Lt.ga+=t.Ke?.byteLength??0}static Ca(t){const e=Lt.wa.get(t)
898
- e&&(Lt.ga-=e.Ke?.byteLength??0,0>Lt.ga&&(Lt.ga=0))}static Oa(){if(Lt.va!==1/0)for(;Lt.ga>Lt.va&&Lt.wa.size>0;){const t=Lt.wa.keys().next().value
899
+ return Ot.ga.set(t,r),Ot.Ca(r),Ot.ka(),r}static Ca(t){Ot.va+=t.Qe?.byteLength??0}static Da(t){const e=Ot.ga.get(t)
900
+ e&&(Ot.va-=e.Qe?.byteLength??0,0>Ot.va&&(Ot.va=0))}static ka(){if(Ot.ma!==1/0)for(;Ot.va>Ot.ma&&Ot.ga.size>0;){const t=Ot.ga.keys().next().value
899
901
  if(void 0===t)break
900
- Lt.Ca(t),Lt.wa.delete(t)}}static Fa(t){if(t){const e=new Uint8Array(t)
902
+ Ot.Da(t),Ot.ga.delete(t)}}static Ga(t){if(t){const e=new Uint8Array(t)
901
903
  let i=2166136261
902
904
  const n=Math.min(32,e.length),s=Math.floor(e.length/n)
903
905
  for(let t=0;n>t;t++)i^=e[t*s],i=Math.imul(i,16777619)
904
- return i^=e.length,i=Math.imul(i,16777619),(i>>>0).toString(36)}return"c"+ ++Lt.ma}Aa(t){this.Xt=t
905
- const e=Lt.Fa(t.Ke)
906
- this.ba="font_"+e,t.He&&(this.ba+="_var_"+Lt.xa(t.He)),t.Kt&&(this.ba+="_feat_"+Lt.xa(t.Kt))}async Pe(t,e,i){Lt.pa||(Lt.pa=Mt.sa()),await Lt.pa
906
+ return i^=e.length,i=Math.imul(i,16777619),(i>>>0).toString(36)}return"c"+ ++Ot.xa}Ia(t){this.Xt=t
907
+ const e=Ot.Ga(t.Qe)
908
+ this._a="font_"+e,t.Ve&&(this._a+="_var_"+Ot.Sa(t.Ve)),t.Kt&&(this._a+="_feat_"+Ot.Sa(t.Kt))}async Pe(t,e,i){Ot.wa||(Ot.wa=Ft.ra()),await Ot.wa
907
909
  const n="string"==typeof t?await h(t):t
908
- try{this.Xt&&this.destroy(),this.Xt=await this.Sa.Pe(n,e),i&&(this.Xt.Kt=i)
909
- const t=Lt.Fa(n)
910
- this.ba="font_"+t,e&&(this.ba+="_var_"+Lt.xa(e)),i&&(this.ba+="_feat_"+Lt.xa(i))}catch(t){throw c.error("Failed to load font:",t),t}}async Ma(t){try{if(!this.Xt)throw Error("Font not loaded. Use Text.create() with a font option.")
911
- const e=await this.ka(t)
912
- this.Da(e),this.Ba(t=e),this.ur||(this.ur=new gt(X,this.Xt),this.ur.Ps(this.ba))
910
+ try{this.Xt&&this.destroy(),this.Xt=await this.Ea.Pe(n,e),i&&(this.Xt.Kt=i)
911
+ const t=Ot.Ga(n)
912
+ this._a="font_"+t,e&&(this._a+="_var_"+Ot.Sa(e)),i&&(this._a+="_feat_"+Ot.Sa(i))}catch(t){throw c.error("Failed to load font:",t),t}}async Fa(t){try{if(!this.Xt)throw Error("Font not loaded. Use Text.create() with a font option.")
913
+ const e=await this.Ba(t)
914
+ this.Na(e),this.Ua(t=e),this.dr||(this.dr=new mt(tt,this.Xt),this.dr.Ps(this._a))
913
915
  const i=null!=t.curveSteps&&t.curveSteps>0
914
- this.ur.vn(t.curveSteps),this.ur.gn(i?void 0:t.curveFidelity),this.ur.ts(t.geometryOptimization),this.Xt.font.setScale(this.Xt.upem,this.Xt.upem),this.Na||(this.Na=new vt(this.Xt,this.ur))
915
- const n=this.Ua(t),s=t.Pa??this.Xt.Ve??!1,r=this.Na.dr(n.lines,n.$a,n.letterSpacing,n.align,n.direction,t.color,t.text)
916
+ this.dr.mn(t.curveSteps),this.dr.vn(i?void 0:t.curveFidelity),this.dr.es(t.geometryOptimization),this.Xt.font.setScale(this.Xt.upem,this.Xt.upem),this.$a||(this.$a=new xt(this.Xt,this.dr))
917
+ const n=this.Pa(t),s=t.Wa??this.Xt.qe??!1,r=this.$a.yr(n.lines,n.za,n.letterSpacing,n.align,n.direction,t.color,t.text)
916
918
  let o,h
917
- if(t.color&&"object"==typeof t.color&&!Array.isArray(t.color)&&(t.color.ha||t.color.ca)){if(o=new Set,t.color.ha){h=[]
918
- for(const e of Object.keys(t.color.ha)){let i=0
919
+ if(t.color&&"object"==typeof t.color&&!Array.isArray(t.color)&&(t.color.aa||t.color.la)){if(o=new Set,t.color.aa){h=[]
920
+ for(const e of Object.keys(t.color.aa)){let i=0
919
921
  for(;-1!==(i=t.text.indexOf(e,i));){h.push({pattern:e,start:i,end:i+e.length})
920
922
  for(let t=i;i+e.length>t;t++)o.add(t)
921
- i+=e.length}}}if(t.color.ca)for(const e of t.color.ca)for(let t=e.start;e.end>t;t++)o.add(t)}const a=this.ur.zs(r,n.depth,s,this.Xt.u.de,n.za,t.perGlyphAttributes??!1,o),c=this.Wa(a.vertices,a.normals,a.indices,a.er,a.planeBounds,t,t.text,h)
922
- if(t.perGlyphAttributes){const t=this.Ra(c.vertices.length/3,c.glyphs)
923
- c.glyphAttributes=t}return c}finally{}}async ka(t){if(!1!==t.layout?.bt&&t.layout?.width){const e=t.layout?.language||"en-us"
924
- if(!t.layout?.Et?.[e])try{if(!Lt.ya.has(e)){const i=await n(e,t.layout?.ja)
925
- Lt.ya.set(e,i)}return{...t,layout:{...t.layout,Et:{...t.layout?.Et,[e]:Lt.ya.get(e)}}}}catch(i){return c.warn(`Failed to load patterns for ${e}: ${i}`),{...t,layout:{...t.layout,bt:!1}}}}return t}Da(t){if(!t.text)throw Error("Text content is required")
926
- const e=t.Ha??1e5
927
- if(t.text.length>e)throw Error(`Text exceeds ${e} character limit`)}Ba(t){t.He&&this.Xt&&Lt.xa(t.He)!==Lt.xa(this.Xt.He||{})&&(this.Xt.font.Re(t.He),this.Xt.He=t.He)}Ua(t){if(!this.Xt)throw Error("Font not loaded. Use Text.create() with a font option")
928
- const{text:e,size:i=Ft,depth:n=0,lineHeight:s=1,letterSpacing:r=0,layout:o={}}=t,{width:h,direction:a="ltr",align:c=("rtl"===a?"right":"left"),St:d=!0,bt:y=!0,language:p="en-us",At:w=l,Mt:g=u,It:v=f,Ft:m,Et:x,Lt:b,Gt:S,Ot:_,Ct:E,kt:T,Dt:A,Bt:M}=o,I=this.Xt.upem/i
923
+ i+=e.length}}}if(t.color.la)for(const e of t.color.la)for(let t=e.start;e.end>t;t++)o.add(t)}const a=this.dr.zs(r,n.depth,s,this.Xt.u.de,n.Ra,t.perGlyphAttributes??!1,o),c=this.ja(a.vertices,a.normals,a.indices,a.ir,a.planeBounds,t,t.text,h)
924
+ if(t.perGlyphAttributes){const t=this.Ha(c.vertices.length/3,c.glyphs)
925
+ c.glyphAttributes=t}return c}finally{}}async Ba(t){if(!1!==t.layout?.bt&&t.layout?.width){const e=t.layout?.language||"en-us"
926
+ if(!t.layout?.Et?.[e])try{if(!Ot.pa.has(e)){const i=await n(e,t.layout?.Va)
927
+ Ot.pa.set(e,i)}return{...t,layout:{...t.layout,Et:{...t.layout?.Et,[e]:Ot.pa.get(e)}}}}catch(i){return c.warn(`Failed to load patterns for ${e}: ${i}`),{...t,layout:{...t.layout,bt:!1}}}}return t}Na(t){if(!t.text)throw Error("Text content is required")
928
+ const e=t.qa??1e5
929
+ if(t.text.length>e)throw Error(`Text exceeds ${e} character limit`)}Ua(t){t.Ve&&this.Xt&&Ot.Sa(t.Ve)!==Ot.Sa(this.Xt.Ve||{})&&(this.Xt.font.je(t.Ve),this.Xt.Ve=t.Ve)}Pa(t){if(!this.Xt)throw Error("Font not loaded. Use Text.create() with a font option")
930
+ const{text:e,size:i=Gt,depth:n=0,lineHeight:s=1,letterSpacing:r=0,layout:o={}}=t,{width:h,direction:a="ltr",align:c=("rtl"===a?"right":"left"),St:d=!0,bt:y=!0,language:p="en-us",At:w=l,Mt:g=u,It:v=f,Ft:m,Et:x,Lt:b,Gt:S,Ot:_,Ct:E,kt:T,Dt:A,Bt:M}=o,I=this.Xt.upem/i
929
931
  let L
930
932
  void 0!==h&&(L=h*I)
931
933
  const G=n*I,O=G>0?Math.max(G,25e-6*this.Xt.upem):0
932
- this.Va||(this.Va=new F(this.Xt))
933
- const C=this.Va.Zt({text:e,width:L,align:c,direction:a,bt:y,language:p,St:d,At:w,Mt:g,It:v,Ft:m,Et:x,Lt:b,Gt:S,Ot:_,Ct:E,kt:T,Dt:A,Bt:M,letterSpacing:r}),k=j.Ge(this.Xt.u)
934
- return{lines:C.lines,$a:(k.se-k.re)*s,letterSpacing:r,align:c,direction:a,depth:O,size:i,za:1/I}}qa(t,e,i,n,s){const r=t.length/3,o=new Float32Array(3*r),h=[]
934
+ this.Ya||(this.Ya=new F(this.Xt))
935
+ const C=this.Ya.Zt({text:e,width:L,align:c,direction:a,bt:y,language:p,St:d,At:w,Mt:g,It:v,Ft:m,Et:x,Lt:b,Gt:S,Ot:_,Ct:E,kt:T,Dt:A,Bt:M,letterSpacing:r}),k=H.Ge(this.Xt.u)
936
+ return{lines:C.lines,za:(k.se-k.re)*s,letterSpacing:r,align:c,direction:a,depth:O,size:i,Ra:1/I}}Ja(t,e,i,n,s){const r=t.length/3,o=new Float32Array(3*r),h=[]
935
937
  if(Array.isArray(i)){for(let t=0;r>t;t++){const e=3*t
936
- o[e]=i[0],o[e+1]=i[1],o[e+2]=i[2]}h.push({start:0,end:n.length,ua:n,color:i,bounds:[],glyphs:e,da:[...new Set(e.map(t=>t.nr))]})}else{const t=i.default||[1,1,1]
938
+ o[e]=i[0],o[e+1]=i[1],o[e+2]=i[2]}h.push({start:0,end:n.length,fa:n,color:i,bounds:[],glyphs:e,ya:[...new Set(e.map(t=>t.sr))]})}else{const t=i.default||[1,1,1]
937
939
  for(let e=0;o.length>e;e+=3)o[e]=t[0],o[e+1]=t[1],o[e+2]=t[2]
938
940
  let r
939
- if(i.ha&&s||i.ca){r=new Map
940
- for(const t of e){const e=r.get(t.ir)
941
- e?e.push(t):r.set(t.ir,[t])}}if(i.ha&&s&&r)for(const t of s){const e=i.ha[t.pattern]
941
+ if(i.aa&&s||i.la){r=new Map
942
+ for(const t of e){const e=r.get(t.nr)
943
+ e?e.push(t):r.set(t.nr,[t])}}if(i.aa&&s&&r)for(const t of s){const e=i.aa[t.pattern]
942
944
  if(!e)continue
943
945
  const n=[],s=new Map
944
946
  for(let i=t.start;t.end>i;i++){const t=r.get(i)
945
947
  if(t)for(const i of t){n.push(i)
946
- const t=s.get(i.nr)
947
- t?t.push(i):s.set(i.nr,[i])
948
- for(let t=0;i.sr>t;t++){const n=3*(i.js+t)
949
- n>=0&&o.length>n&&(o[n]=e[0],o[n+1]=e[1],o[n+2]=e[2])}}}const a=Array.from(s.values()).map(t=>this.Ya(t))
950
- h.push({start:t.start,end:t.end,ua:t.pattern,color:e,bounds:a,glyphs:n,da:Array.from(s.keys()).sort((t,e)=>t-e)})}if(i.ca&&r)for(const t of i.ca){const e=[],i=new Map
948
+ const t=s.get(i.sr)
949
+ t?t.push(i):s.set(i.sr,[i])
950
+ for(let t=0;i.rr>t;t++){const n=3*(i.Hs+t)
951
+ n>=0&&o.length>n&&(o[n]=e[0],o[n+1]=e[1],o[n+2]=e[2])}}}const a=Array.from(s.values()).map(t=>this.Ka(t))
952
+ h.push({start:t.start,end:t.end,fa:t.pattern,color:e,bounds:a,glyphs:n,ya:Array.from(s.keys()).sort((t,e)=>t-e)})}if(i.la&&r)for(const t of i.la){const e=[],i=new Map
951
953
  for(let n=t.start;t.end>n;n++){const s=r.get(n)
952
954
  if(s)for(const n of s){e.push(n)
953
- const s=i.get(n.nr)
954
- s?s.push(n):i.set(n.nr,[n])
955
- for(let e=0;n.sr>e;e++){const i=3*(n.js+e)
956
- 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.Ya(t))
957
- h.push({start:t.start,end:t.end,ua:n.slice(t.start,t.end),color:t.color,bounds:s,glyphs:e,da:Array.from(i.keys()).sort((t,e)=>t-e)})}}return{colors:o,Ja:h}}Ya(t){if(0===t.length)return{min:{x:0,y:0,z:0},max:{x:0,y:0,z:0}}
955
+ const s=i.get(n.sr)
956
+ s?s.push(n):i.set(n.sr,[n])
957
+ for(let e=0;n.rr>e;e++){const i=3*(n.Hs+e)
958
+ 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.Ka(t))
959
+ h.push({start:t.start,end:t.end,fa:n.slice(t.start,t.end),color:t.color,bounds:s,glyphs:e,ya:Array.from(i.keys()).sort((t,e)=>t-e)})}}return{colors:o,Qa:h}}Ka(t){if(0===t.length)return{min:{x:0,y:0,z:0},max:{x:0,y:0,z:0}}
958
960
  let e=1/0,i=1/0,n=1/0,s=-1/0,r=-1/0,o=-1/0
959
961
  for(const h of t)e>h.bounds.min.x&&(e=h.bounds.min.x),i>h.bounds.min.y&&(i=h.bounds.min.y),n>h.bounds.min.z&&(n=h.bounds.min.z),h.bounds.max.x>s&&(s=h.bounds.max.x),h.bounds.max.y>r&&(r=h.bounds.max.y),h.bounds.max.z>o&&(o=h.bounds.max.z)
960
- return{min:{x:e,y:i,z:n},max:{x:s,y:r,z:o}}}Wa(t,e,i,n,s,r,o,h){const{layout:a={}}=r,{width:c,align:l=("rtl"===a.direction?"right":"left")}=a
961
- this.Va||(this.Va=new F(this.Xt))
962
- const u=this.Va.ie({width:c,align:l,planeBounds:s}),f=u.offset
962
+ return{min:{x:e,y:i,z:n},max:{x:s,y:r,z:o}}}ja(t,e,i,n,s,r,o,h){const{layout:a={}}=r,{width:c,align:l=("rtl"===a.direction?"right":"left")}=a
963
+ this.Ya||(this.Ya=new F(this.Xt))
964
+ const u=this.Ya.ie({width:c,align:l,planeBounds:s}),f=u.offset
963
965
  if(s.min.x=u.ee.min.x,s.max.x=u.ee.max.x,0!==f){for(let e=0;t.length>e;e+=3)t[e]+=f
964
966
  for(let t=0;n.length>t;t++)n[t].bounds.min.x+=f,n[t].bounds.max.x+=f}let d,y
965
- if(r.color){const e=this.qa(t,n,r.color,r.text,h)
966
- d=e.colors,y=e.Ja}const p=this.ur.es()
967
+ if(r.color){const e=this.Ja(t,n,r.color,r.text,h)
968
+ d=e.colors,y=e.Qa}const p=this.dr.ns()
967
969
  return{vertices:t,normals:e,indices:i,colors:d,glyphs:n,planeBounds:s,stats:{trianglesGenerated:i.length/3,verticesGenerated:t.length/3,pointsRemovedByVisvalingam:p.pointsRemovedByVisvalingam,originalPointCount:p.originalPointCount},query:(()=>{let t=null
968
970
  return e=>{if(!o)throw Error("Original text not available for querying")
969
- return t||(t=new It(o,n)),t.oa(e)}})(),Ja:y,glyphAttributes:void 0}}Oe(){if(!this.Xt)throw Error("Font not loaded. Call loadFont() first")
970
- return j.Oe(this.Xt.u)}static async Ka(t,e){await Promise.all(t.map(async t=>{if(!Lt.ya.has(t))try{const i=await n(t,e)
971
- Lt.ya.set(t,i)}catch(e){c.warn(`Failed to pre-load patterns for ${t}: ${e}`)}}))}static Qa(t,e){Lt.ya.set(t,e)}static Xa(t){Lt.va=t===1/0?1/0:1048576*Math.max(1,Math.floor(t)),Lt.Oa()}getLoadedFont(){return this.Xt}measureTextWidth(t,e=0){if(!this.Xt)throw Error("Font not loaded. Call loadFont() first")
972
- return I.measureTextWidth(this.Xt,t,e)}getCacheSize(){return this.ur?this.ur.cr().size:0}clearCache(){this.ur&&this.ur.clearCache()}Ra(t,e){const i=new Float32Array(3*t),n=new Float32Array(t),s=new Float32Array(t),r=new Float32Array(t),o=new Float32Array(t)
971
+ return t||(t=new Lt(o,n)),t.ha(e)}})(),Qa:y,glyphAttributes:void 0}}Oe(){if(!this.Xt)throw Error("Font not loaded. Call loadFont() first")
972
+ return H.Oe(this.Xt.u)}static async Xa(t,e){await Promise.all(t.map(async t=>{if(!Ot.pa.has(t))try{const i=await n(t,e)
973
+ Ot.pa.set(t,i)}catch(e){c.warn(`Failed to pre-load patterns for ${t}: ${e}`)}}))}static Za(t,e){Ot.pa.set(t,e)}static tc(t){Ot.ma=t===1/0?1/0:1048576*Math.max(1,Math.floor(t)),Ot.ka()}getLoadedFont(){return this.Xt}measureTextWidth(t,e=0){if(!this.Xt)throw Error("Font not loaded. Call loadFont() first")
974
+ return I.measureTextWidth(this.Xt,t,e)}getCacheSize(){return this.dr?this.dr.lr().size:0}clearCache(){this.dr&&this.dr.clearCache()}Ha(t,e){const i=new Float32Array(3*t),n=new Float32Array(t),s=new Float32Array(t),r=new Float32Array(t),o=new Float32Array(t)
973
975
  let h=1/0,a=-1/0
974
976
  for(let t=0;e.length>t;t++){const i=(e[t].bounds.min.x+e[t].bounds.max.x)/2
975
977
  h>i&&(h=i),i>a&&(a=i)}const c=a-h
976
- for(let a=0;e.length>a;a++){const l=e[a],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-h)/c:0,w=l.js,g=Math.min(w+l.sr,t)
977
- if(g>w){n.fill(a,w,g),s.fill(l.nr,w,g),r.fill(p,w,g),o.fill(y,w,g)
978
- 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}}Ia(){this.ur=void 0,this.Na=void 0,this.Va=void 0}destroy(){if(!this.Xt)return
978
+ for(let a=0;e.length>a;a++){const l=e[a],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-h)/c:0,w=l.Hs,g=Math.min(w+l.rr,t)
979
+ if(g>w){n.fill(a,w,g),s.fill(l.sr,w,g),r.fill(p,w,g),o.fill(y,w,g)
980
+ 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}}La(){this.dr=void 0,this.$a=void 0,this.Ya=void 0}destroy(){if(!this.Xt)return
979
981
  const t=this.Xt
980
- try{V.Qe(t)}catch(t){c.warn("Error destroying HarfBuzz objects:",t)}finally{this.Xt=void 0,this.Va=void 0,this.Na=void 0}}}t.DEFAULT_CURVE_FIDELITY=ut,t.FontMetadataExtractor=j,t.Text=Lt,t.Za=()=>new Q,t.tc=X})
982
+ try{Y.Xe(t)}catch(t){c.warn("Error destroying HarfBuzz objects:",t)}finally{this.Xt=void 0,this.Ya=void 0,this.$a=void 0}}}t.DEFAULT_CURVE_FIDELITY=dt,t.FontMetadataExtractor=H,t.Text=Ot,t.ec=()=>new Z,t.nc=tt})