three-text 0.3.1 → 0.3.2

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