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