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