three-text 0.3.4 → 0.4.0

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