@seatlayer/core 0.110.0 → 0.110.1
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/ar-C5PA2DVE.js +1 -0
- package/dist/be-TMKSMYPN.js +1 -0
- package/dist/bg-V6HTEDUB.js +1 -0
- package/dist/ca-CTZMHWW4.js +1 -0
- package/dist/{categoryInventory-BfvwE3nC.d.cts → categoryInventory-BE1AThTx.d.cts} +1 -1
- package/dist/{categoryInventory-ClZ-68jI.d.ts → categoryInventory-DxciZQK_.d.ts} +1 -1
- package/dist/{chunk-6VOUTNRV.js → chunk-2VYFNNYC.js} +1 -1
- package/dist/{chunk-YE4NP3XB.js → chunk-3V32MDJI.js} +1 -1
- package/dist/chunk-4AGC7B64.js +1 -0
- package/dist/{chunk-ZYQXT5JP.js → chunk-5IADCFUU.js} +1 -1
- package/dist/{chunk-2JFCDE27.js → chunk-6CBJBESS.js} +1 -1
- package/dist/{chunk-WUNZCUE6.js → chunk-DLHW3UDD.js} +1 -1
- package/dist/{chunk-UUIZHJYL.js → chunk-GVVZR3YS.js} +1 -1
- package/dist/{chunk-MRLWH6RC.js → chunk-GWGWNBGU.js} +1 -1
- package/dist/chunk-JQBJZMLG.js +1 -0
- package/dist/{chunk-OJSGMXJS.js → chunk-NVAF2E7Q.js} +1 -1
- package/dist/{chunk-FBXZWNND.js → chunk-YRDOE3N7.js} +1 -1
- package/dist/{chunk-BNLANXXZ.js → chunk-ZY6WTPTI.js} +1 -1
- package/dist/core/chart-ops/index.cjs +1 -1
- package/dist/core/chart-ops/index.d.cts +6 -4
- package/dist/core/chart-ops/index.d.ts +6 -4
- package/dist/core/chart-ops/index.js +1 -1
- package/dist/core/inventory/index.d.cts +4 -4
- package/dist/core/inventory/index.d.ts +4 -4
- package/dist/core/inventory/index.js +1 -1
- package/dist/core/layout/index.d.cts +5 -5
- package/dist/core/layout/index.d.ts +5 -5
- package/dist/core/layout/index.js +1 -1
- package/dist/core/quality/index.cjs +1 -1
- package/dist/core/quality/index.d.cts +3 -3
- package/dist/core/quality/index.d.ts +3 -3
- package/dist/core/render-assets/index.cjs +1 -1
- package/dist/core/render-assets/index.d.cts +2 -2
- package/dist/core/render-assets/index.d.ts +2 -2
- package/dist/core/render-assets/index.js +1 -1
- package/dist/core/seatConfidence.d.cts +1 -1
- package/dist/core/seatConfidence.d.ts +1 -1
- package/dist/core/sections/index.d.cts +5 -5
- package/dist/core/sections/index.d.ts +5 -5
- package/dist/core/sections/index.js +1 -1
- package/dist/cs-FUDGOUFL.js +1 -0
- package/dist/cy-5RRARIAP.js +1 -0
- package/dist/da-PONPPWKY.js +1 -0
- package/dist/de-PKG7AAB5.js +1 -0
- package/dist/el-H7OFU4QQ.js +1 -0
- package/dist/es-QSW5IZ6U.js +1 -0
- package/dist/et-GTMPSS72.js +1 -0
- package/dist/{eventConfigurations-DsW5Mj2e.d.ts → eventConfigurations-Cdt-e0uD.d.ts} +1 -1
- package/dist/{eventConfigurations-dmn9FClw.d.cts → eventConfigurations-D0us5j0K.d.cts} +1 -1
- package/dist/fa-SGLTFGJF.js +1 -0
- package/dist/fi-7YTEAVDM.js +1 -0
- package/dist/fr-ECCQ24MZ.js +1 -0
- package/dist/he-YHMMDOX7.js +1 -0
- package/dist/hi-GRAQX2E6.js +1 -0
- package/dist/hr-MN33LRIJ.js +1 -0
- package/dist/hu-NW3SMQVM.js +1 -0
- package/dist/id-3OPRAUF7.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.js +1 -1
- package/dist/it-RYM74YWO.js +1 -0
- package/dist/ja-4NI6DG5D.js +1 -0
- package/dist/{ko-6YCWWHFQ.js → ko-C4F6UEMK.js} +1 -1
- package/dist/ku-DMSBMWTC.js +1 -0
- package/dist/{labeling-Bn41ByDd.d.ts → labeling-DXgkxMoi.d.ts} +1 -1
- package/dist/{labeling-BmEjVxFt.d.cts → labeling-eYKVPLMb.d.cts} +1 -1
- package/dist/localeLoaders-G3GCGLPW.js +1 -0
- package/dist/lt-3EXKKZFG.js +1 -0
- package/dist/lv-4EWNRDCG.js +1 -0
- package/dist/ms-7LJBSAEJ.js +1 -0
- package/dist/nl-GWTIWXRW.js +1 -0
- package/dist/no-T3FW2WLX.js +1 -0
- package/dist/pl-OG5OBRHR.js +1 -0
- package/dist/pt-YQ6VES5R.js +1 -0
- package/dist/{renderedQuality-MDkNe8GA.d.ts → renderedQuality-Dzo2_8f4.d.ts} +1 -1
- package/dist/{renderedQuality-Bt2d0uq1.d.cts → renderedQuality-Frgw6jdx.d.cts} +1 -1
- package/dist/{renderer-DH0yI32q.d.cts → renderer-DM2sv1un.d.cts} +1 -1
- package/dist/{renderer-BJrpMV6U.d.ts → renderer-DuieD7jP.d.ts} +1 -1
- package/dist/ro-VK5MASYF.js +1 -0
- package/dist/ru-YU5CYR6T.js +1 -0
- package/dist/{seatTypeIcons-CG_Uzpaw.d.ts → seatTypeIcons-Bz0OJtEi.d.ts} +1 -1
- package/dist/{seatTypeIcons-Ck7oEFei.d.cts → seatTypeIcons-Cm8tjLYl.d.cts} +1 -1
- package/dist/{sections-C-UAqr1x.d.ts → sections-Bf_DV0oG.d.ts} +1 -1
- package/dist/{sections-C8HApYxd.d.cts → sections-PbQiqN0i.d.cts} +1 -1
- package/dist/{segmentedRowModel-DR1w9M13.d.ts → segmentedRowModel-CO7DD803.d.ts} +1 -1
- package/dist/{segmentedRowModel-CeoMsBnt.d.cts → segmentedRowModel-Co9LqS4i.d.cts} +1 -1
- package/dist/sk-CE7PXAYL.js +1 -0
- package/dist/sl-EYUPV4BG.js +1 -0
- package/dist/sr-PPXCN4IK.js +1 -0
- package/dist/sv-WR2BJBCJ.js +1 -0
- package/dist/{tableSizing-RRmpxOXl.d.ts → tableSizing-BDePQyPD.d.ts} +3 -3
- package/dist/{tableSizing-Bz-hxLza.d.cts → tableSizing-C6EjKNnk.d.cts} +3 -3
- package/dist/th-JUB2DODR.js +1 -0
- package/dist/{ticketRestrictions-lq4dH4k6.d.cts → ticketRestrictions-CgYwHQOf.d.cts} +2 -2
- package/dist/{ticketRestrictions-C7KUrulv.d.ts → ticketRestrictions-D5wgOq4P.d.ts} +2 -2
- package/dist/tr-GFHA7FT6.js +1 -0
- package/dist/{types-DM-OneoD.d.ts → types-CGOr0BpE.d.cts} +40 -16
- package/dist/{types-DM-OneoD.d.cts → types-CGOr0BpE.d.ts} +40 -16
- package/dist/uk-3FTS2SRK.js +1 -0
- package/dist/vi-7OTXPOQV.js +1 -0
- package/dist/view3d/crossfade/panorama.d.cts +1 -1
- package/dist/view3d/crossfade/panorama.d.ts +1 -1
- package/dist/view3d/index.cjs +410 -169
- package/dist/view3d/index.d.cts +100 -4
- package/dist/view3d/index.d.ts +100 -4
- package/dist/view3d/index.js +408 -167
- package/dist/view3d/scene/scene.worker.cjs +1 -1
- package/dist/view3d/scene/scene.worker.js +1 -1
- package/dist/zh-Hans-FD4XNYUA.js +1 -0
- package/dist/zh-Hant-7TXVJKJQ.js +1 -0
- package/package.json +1 -1
- package/dist/ar-O3RHQRH3.js +0 -1
- package/dist/be-SXFCG3F5.js +0 -1
- package/dist/bg-W7YBNYB2.js +0 -1
- package/dist/ca-FA7WHACR.js +0 -1
- package/dist/chunk-4N5CHKHD.js +0 -1
- package/dist/chunk-4QQG5EEP.js +0 -1
- package/dist/cs-RR3VIKRC.js +0 -1
- package/dist/cy-U4JJ5C47.js +0 -1
- package/dist/da-ATULGB2M.js +0 -1
- package/dist/de-VB543CPC.js +0 -1
- package/dist/el-7Y2KXU6N.js +0 -1
- package/dist/es-GUV5XIYC.js +0 -1
- package/dist/et-SZ6I4Z44.js +0 -1
- package/dist/fa-FM6ELEN7.js +0 -1
- package/dist/fi-6QQ2M5JI.js +0 -1
- package/dist/fr-2SEQSVLR.js +0 -1
- package/dist/he-V3EVB7IW.js +0 -1
- package/dist/hi-I4QIBK5Q.js +0 -1
- package/dist/hr-I5DNEVUU.js +0 -1
- package/dist/hu-KTFWBQMF.js +0 -1
- package/dist/id-RZWUH426.js +0 -1
- package/dist/it-CNQP36V4.js +0 -1
- package/dist/ja-JQZOYIHI.js +0 -1
- package/dist/ku-33PM4OWG.js +0 -1
- package/dist/localeLoaders-VFQOZMUH.js +0 -1
- package/dist/lt-24JO2B7V.js +0 -1
- package/dist/lv-HTSDEEAB.js +0 -1
- package/dist/ms-PUEZJJ3R.js +0 -1
- package/dist/nl-NQPDRSCW.js +0 -1
- package/dist/no-3N3MUMSA.js +0 -1
- package/dist/pl-YHBEO6ZF.js +0 -1
- package/dist/pt-5RPESNZB.js +0 -1
- package/dist/ro-XDFXIMHX.js +0 -1
- package/dist/ru-BIIALOM5.js +0 -1
- package/dist/sk-LHSFRUFT.js +0 -1
- package/dist/sl-MPE5TPI3.js +0 -1
- package/dist/sr-T3N67KTP.js +0 -1
- package/dist/sv-LJWWYUIY.js +0 -1
- package/dist/th-E5POGG37.js +0 -1
- package/dist/tr-2DCWQ2CY.js +0 -1
- package/dist/uk-C3VJP6EA.js +0 -1
- package/dist/vi-XVMTKCOL.js +0 -1
- package/dist/zh-Hans-RG4CQGBY.js +0 -1
- package/dist/zh-Hant-YHNTYPFS.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as Qo,c as tr,d as nr}from"./chunk-6CBJBESS.js";import{b as Xo,c as zo,d as $o,e as qo,h as Jo}from"./chunk-PBXGWYB4.js";import{a as pn,w as er}from"./chunk-2VYFNNYC.js";import{a as Yo,c as dn,d as Ot,f as Mt,i as Zo}from"./chunk-YRDOE3N7.js";import{e as Vo,l as Ko}from"./chunk-JQBJZMLG.js";import{n as Le}from"./chunk-GUNNA5LB.js";import{h as $n}from"./chunk-URW7MSCJ.js";import{Aa as Ut,Ba as en,C as Go,Ca as Ho,D as hn,Da as Uo,Ha as ke,Ja as Ce,Ya as Lt,ca as No,da as Do,fb as Qn,j as Fo,ka as nt,la as Ct,ua as qn,va as yn,wa as Jn,ya as vo}from"./chunk-3V32MDJI.js";import{A as Xt,D as Wo,b as jo,d as lt,y as ct}from"./chunk-JBOTRSMY.js";var Fe=t=>t<=.04045?t/12.92:((t+.055)/1.055)**2.4,Ge=t=>t<=.0031308?12.92*t:1.055*Math.max(0,t)**.4166666666666667-.055,Ne=t=>Math.min(1,Math.max(0,t));function ne(t){let n=Fe(t[0]),e=Fe(t[1]),o=Fe(t[2]),r=Math.cbrt(.4122214708*n+.5363325363*e+.0514459929*o),a=Math.cbrt(.2119034982*n+.6806995451*e+.1073969566*o),i=Math.cbrt(.0883024619*n+.2817188376*e+.6299787005*o);return[.2104542553*r+.793617785*a-.0040720468*i,1.9779984951*r-2.428592205*a+.4505937099*i,.0259040371*r+.7827717662*a-.808675766*i]}function te([t,n,e]){let o=(t+.3963377774*n+.2158037573*e)**3,r=(t-.1055613458*n-.0638541728*e)**3,a=(t-.0894841775*n-1.291485548*e)**3;return[Ne(Ge(4.0767416621*o-3.3077115913*r+.2309699292*a)),Ne(Ge(-1.2684380046*o+2.6097574011*r-.3413193965*a)),Ne(Ge(-.0041960863*o-.7034186147*r+1.707614701*a))]}var ee=t=>ne(t)[0];function An(t){let[,n,e]=ne(t);return Math.hypot(n,e)}function on(t,n,e){let[,o,r]=ne(t);if(e===void 0)return te([n,o,r]);let a=Math.hypot(o,r),i=a===0?0:e/a;return te([n,o*i,r*i])}function or(t,n,e){let[o,r,a]=ne(t);return o>=n&&o<=e?t:te([Math.min(e,Math.max(n,o)),r,a])}function oe(t){return te([t,-.004,-.008])}var En=["available","held","sold","selected","dimmed"];function De(t){let n=En.indexOf(t);return n<0?0:n}var ir={available:[.24,.82,.52],held:[.34,.39,.45],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};function Ns(t){let n=.2126*t[0]+.7152*t[1]+.0722*t[2],e=.78,o=.86;return[(n+(t[0]-n)*e)*o,(n+(t[1]-n)*e)*o,(n+(t[2]-n)*e)*o]}var rr={day:{ground:.9,deck:.84,fascia:.77,shell:.79,seatMin:.45,seatMax:.58,unavailable:.58,dimmed:.62,sectionDeck:.66,sectionDeckChromaShare:.8,sectionDeckChromaCap:.11,stageTop:.52,stageWall:.42},night:{ground:.26,deck:.34,fascia:.28,shell:.32,seatMin:.64,seatMax:.8,unavailable:.42,dimmed:.39,sectionDeck:.34,sectionDeckChromaShare:.45,sectionDeckChromaCap:.05,stageTop:0,stageWall:0}},re=.012;function rn(t){return ee(t.tierTop)>.6}function sn(t){return t?rr.day:rr.night}function um(t,n){let e=sn(n);return or(Ns(t),e.seatMin,e.seatMax)}var ve={ground:[.07,.085,.11],tierTop:[.24,.28,.34],tierWall:[.17,.2,.25],stageTop:[.94,.7,.38],stageWall:[.48,.33,.18],decorTop:[.22,.25,.29],decorWall:[.15,.17,.2],gaTop:[.24,.28,.33],gaWall:[.16,.19,.23],boothTop:[.3,.33,.38],boothWall:[.2,.23,.27],tableTop:[.38,.34,.29],tableWall:[.24,.21,.18]},He={top:[.05,.06,.08],bottom:[.1,.12,.15]};function z(t,n){return[Math.min(1,t[0]*n),Math.min(1,t[1]*n),Math.min(1,t[2]*n)]}import Ds from"earcut";import ar from"polygon-clipping";var I=nt,vs=.002;function Hs(t,n,e){let o=Math.hypot(n[0]-t[0],n[1]-t[1],n[2]-t[2]),r=Math.hypot(e[0]-n[0],e[1]-n[1],e[2]-n[2]),a=Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2]),i=Math.max(o,r,a);if(i<1e-9)return!0;let s=(o+r+a)/2;return 2*Math.sqrt(Math.max(0,s*(s-o)*(s-r)*(s-a)))/i<vs}var an=class{constructor(n=16384){this.len=0;this.buf=new Float32Array(n)}push3(n,e,o){this.len+3>this.buf.length&&this.grow(this.len+3),this.buf[this.len++]=n,this.buf[this.len++]=e,this.buf[this.len++]=o}push1(n){this.len+1>this.buf.length&&this.grow(this.len+1),this.buf[this.len++]=n}grow(n){let e=this.buf.length*2;for(;e<n;)e*=2;let o=new Float32Array(e);o.set(this.buf.subarray(0,this.len)),this.buf=o}get length(){return this.len}toArray(){return this.buf.slice(0,this.len)}},ae=class{constructor(){this.pos=new an;this.nor=new an;this.col=new an;this.flr=new an;this.mat=new an;this.currentFloor=0;this.currentMaterial=0}setFloor(n){this.currentFloor=n}setMaterial(n){this.currentMaterial=n}tri(n,e,o,r,a,i=a,s=a,c){if(Hs(n,e,o))return;this.pos.push3(n[0],n[1],n[2]),this.pos.push3(e[0],e[1],e[2]),this.pos.push3(o[0],o[1],o[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(r[0],r[1],r[2]),this.col.push3(a[0],a[1],a[2]),this.col.push3(i[0],i[1],i[2]),this.col.push3(s[0],s[1],s[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor);let l=this.currentMaterial;this.mat.push1(c?.[0]??l),this.mat.push1(c?.[1]??l),this.mat.push1(c?.[2]??l)}triN(n,e,o,r,a,i,s,c=s,l=s){[...n,...e,...o].every(Number.isFinite)&&(this.pos.push3(n[0],n[1],n[2]),this.pos.push3(e[0],e[1],e[2]),this.pos.push3(o[0],o[1],o[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(a[0],a[1],a[2]),this.nor.push3(i[0],i[1],i[2]),this.col.push3(s[0],s[1],s[2]),this.col.push3(c[0],c[1],c[2]),this.col.push3(l[0],l[1],l[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}get vertexCount(){return this.pos.length/3}build(){return{position:this.pos.toArray(),normal:this.nor.toArray(),color:this.col.toArray(),floor:this.flr.toArray(),material:this.mat.toArray(),count:this.pos.length/3}}};function Us(t,n,e){let o=n[0]-t[0],r=n[1]-t[1],a=n[2]-t[2],i=e[0]-t[0],s=e[1]-t[1],c=e[2]-t[2],l=r*c-a*s,u=a*i-o*c,f=o*s-r*i,m=Math.hypot(l,u,f)||1;return l/=m,u/=m,f/=m,[l,u,f]}function Xs(t,n){let e=[...t],o=[];for(let i of t)o.push(i.x,i.y);let r=[];if(n){for(let i of n)if(!(i.length<3)){r.push(e.length);for(let s of i)e.push(s),o.push(s.x,s.y)}}let a=Ds(o,r.length?r:void 0,2);return{pts:e,tris:a}}function jt(t){return Ot(t)<0?[...t].reverse():t}var js=3;function Ws(t,n,e,o){let r=o(t),a=o(n),i=o(e),s=(h,d,y,x)=>Math.abs(o({x:(h.x+d.x)/2,y:(h.y+d.y)/2})-(y+x)/2),c=(t.x+n.x+e.x)/3,l=(t.y+n.y+e.y)/3,u=(r+a+i)/3,f=Math.max(s(t,n,r,a),s(n,e,a,i),s(e,t,i,r),Math.abs(o({x:c,y:l})-u)),m=(h,d,y)=>{let x=Math.abs(o({x:(h+c)/2,y:(d+l)/2})-(y+u)/2);x>f&&(f=x)};return m((t.x+n.x)/2,(t.y+n.y)/2,(r+a)/2),m((n.x+e.x)/2,(n.y+e.y)/2,(a+i)/2),m((e.x+t.x)/2,(e.y+t.y)/2,(i+r)/2),f}function wn(t,n,e,o,r){if(r<=0)return Ws(t,n,e,o);let a={x:(t.x+n.x)/2,y:(t.y+n.y)/2},i={x:(n.x+e.x)/2,y:(n.y+e.y)/2},s={x:(e.x+t.x)/2,y:(e.y+t.y)/2};return Math.max(wn(t,a,s,o,r-1),wn(a,n,i,o,r-1),wn(s,i,e,o,r-1),wn(a,i,s,o,r-1))}function Bn(t,n,e,o,r,a,i,s){if(i>0){let m={x:(n.x+e.x)/2,y:(n.y+e.y)/2},h={x:(e.x+o.x)/2,y:(e.y+o.y)/2},d={x:(o.x+n.x)/2,y:(o.y+n.y)/2};Bn(t,n,m,d,r,a,i-1,s),Bn(t,m,e,h,r,a,i-1,s),Bn(t,d,h,o,r,a,i-1,s),Bn(t,m,h,d,r,a,i-1,s);return}let c=[n.x*I,r(n),n.y*I],l=[e.x*I,r(e),e.y*I],u=[o.x*I,r(o),o.y*I];if(s){t.triN(c,l,u,s(n),s(e),s(o),a);return}let f=Us(c,l,u);f[1]<0&&(f=[-f[0],-f[1],-f[2]]),t.tri(c,l,u,f,a)}var Vs=8;function sr(t,n,e){if(!Number.isFinite(e))return t;let o=[],r=(a,i,s,c,l)=>{if(l>0){let u={x:(a.x+i.x)/2,y:(a.y+i.y)/2},f=n(u);if(Math.abs(f-(s+c)/2)>e){r(a,u,s,f,l-1),r(u,i,f,c,l-1);return}}o.push(a)};for(let a=0;a<t.length;a++){let i=t[a],s=t[(a+1)%t.length];r(i,s,n(i),n(s),Vs)}return o}function ie(t,n){if(t.length<3)return t;let e=[];for(let r of t){let a=e[e.length-1];a&&Math.hypot(r.x-a.x,r.y-a.y)<n||e.push(r)}for(;e.length>2&&Math.hypot(e[0].x-e[e.length-1].x,e[0].y-e[e.length-1].y)<n;)e.pop();if(e.length<3)return t;let o=[];for(let r=0;r<e.length;r++){let a=o.length?o[o.length-1]:e[(r-1+e.length)%e.length],i=e[r],s=e[(r+1)%e.length],c=s.x-a.x,l=s.y-a.y,u=Math.hypot(c,l);u>n&&Math.abs((i.x-a.x)*l-(i.y-a.y)*c)/u<n||o.push(i)}return o.length>=3?o:e}var se=.001*Ct*.1;function Z(t,n,e,o,r,a,i,s,c=1/0,l){if(!n||n.length<3||(c===void 0&&(c=1/0),Math.abs(Ot(n))<1e-4))return;let u=ie(sr(ie(jt(n),se),o,c),se),f=e?.map(b=>ie(sr(ie(jt(b),se),o,c),se)).filter(b=>b.length>=3&&Math.abs(Ot(b))>=1e-4),{pts:m,tris:h}=Xs(u,f),d=[a[0]*s.top,a[1]*s.top,a[2]*s.top],y=[a[0]*s.bottomCap,a[1]*s.bottomCap,a[2]*s.bottomCap],x=[i[0]*s.top,i[1]*s.top,i[2]*s.top],M=[i[0]*s.wallBottom,i[1]*s.wallBottom,i[2]*s.wallBottom],p=0;if(Number.isFinite(c))for(;p<js;p++){let b=0;for(let _=0;_<h.length;_+=3){let S=wn(m[h[_]],m[h[_+1]],m[h[_+2]],o,p);S>b&&(b=S)}if(b<=c)break}for(let b=0;b<h.length;b+=3){let _=m[h[b]],S=m[h[b+1]],R=m[h[b+2]];Bn(t,_,S,R,o,d,p,l);let B=[_.x*I,r,_.y*I],C=[S.x*I,r,S.y*I],O=[R.x*I,r,R.y*I];t.tri(B,O,C,[0,-1,0],y)}let g=b=>{if(p<=0)return b;let _=1<<p,S=[];for(let R=0;R<b.length;R++){let B=b[R],C=b[(R+1)%b.length];for(let O=0;O<_;O++){let k=O/_;S.push({x:B.x+(C.x-B.x)*k,y:B.y+(C.y-B.y)*k})}}return S},A=Go(u),P=[{ring:g(u),flip:!1}];if(f)for(let b of f)b.length>=3&&P.push({ring:g(b),flip:!0});for(let{ring:b,flip:_}of P)for(let S=0;S<b.length;S++){let R=b[S],B=b[(S+1)%b.length],C=(B.x-R.x)*I,k=(B.y-R.y)*I,E=-C,w=Math.hypot(k,E)||1;k/=w,E/=w;let L=(R.x+B.x)/2-A.x,D=(R.y+B.y)/2-A.y,T=k*L+E*D;_&&(T=-T),T<0&&(k=-k,E=-E);let N=[k,0,E],U=[R.x*I,o(R),R.y*I],j=[B.x*I,o(B),B.y*I],G=[R.x*I,r,R.y*I],v=[B.x*I,r,B.y*I];t.tri(U,j,v,N,x,x,M),t.tri(U,v,G,N,x,M,M)}}function cr(t){let n=0;for(let c of t)n+=c.count;let e=new Float32Array(n*3),o=new Float32Array(n*3),r=new Float32Array(n*3),a=new Float32Array(n),i=new Float32Array(n),s=0;for(let c of t)e.set(c.position,s*3),o.set(c.normal,s*3),r.set(c.color,s*3),a.set(c.floor,s),i.set(c.material,s),s+=c.count;return{position:e,normal:o,color:r,floor:a,material:i,count:n}}function Wt(t,n,e=2.5){if(n<=0||t.length<3)return t;let o=jt(t),r=o.length,a=[];for(let s=0;s<r;s++){let c=o[s],l=o[(s+1)%r],u=l.x-c.x,f=l.y-c.y,m=Math.hypot(u,f)||1;a.push({x:f/m,y:-u/m})}let i=[];for(let s=0;s<r;s++){let c=o[s],l=a[(s-1+r)%r],u=a[s],f=l.x+u.x,m=l.y+u.y,h=Math.hypot(f,m),d=()=>{i.push([c.x+l.x*n,c.y+l.y*n]),i.push([c.x+u.x*n,c.y+u.y*n])};if(h<1e-9){d();continue}f/=h,m/=h;let y=f*l.x+m*l.y,x=1/Math.max(y,1e-6);if(!Number.isFinite(x)||x>e){d();continue}i.push([c.x+f*n*x,c.y+m*n*x])}if(i.length<3)return t;try{let s=ar.union([[...i,i[0]]]),c=null,l=-1/0;for(let f of s){let m=Math.abs(Ot(f[0].map(([h,d])=>({x:h,y:d}))));m>l&&(l=m,c=f[0])}if(!c)return t;let u=c.map(([f,m])=>({x:f,y:m}));if(u.length>1){let f=u[0],m=u[u.length-1];Math.abs(f.x-m.x)<1e-9&&Math.abs(f.y-m.y)<1e-9&&u.pop()}return u.length>=3?u:t}catch{return t}}function Ft(t,n,e=2.5){if(t.length<3)return[];if(n<=0)return t;let o=jt(t),r=o.length,a=[];for(let c=0;c<r;c++){let l=o[c],u=o[(c+1)%r],f=Math.hypot(u.x-l.x,u.y-l.y)||1;a.push({x:-(u.y-l.y)/f,y:(u.x-l.x)/f})}let i=[],s=[];for(let c=0;c<r;c++){let l=o[c],u=a[(c-1+r)%r],f=a[c],m=u.x+f.x,h=u.y+f.y,d=Math.hypot(m,h),y=d<1e-9?1/0:1/Math.max(m/d*u.x+h/d*u.y,1e-6);if(!Number.isFinite(y)||y>e){i.push({x:l.x+u.x*n,y:l.y+u.y*n},{x:l.x+f.x*n,y:l.y+f.y*n}),s.push(c,c);continue}m/=d,h/=d,i.push({x:l.x+m*n*y,y:l.y+h*n*y}),s.push(c)}for(let c=0;c<i.length;c++){let l=(c+1)%i.length,u=s[c],f=s[l];if(f!==(u+1)%r)continue;let m=o[u],h=o[f];if((i[l].x-i[c].x)*(h.x-m.x)+(i[l].y-i[c].y)*(h.y-m.y)<=0)return[]}try{let c=ar.intersection([[...i.map(d=>[d.x,d.y]),[i[0].x,i[0].y]]],[[...o.map(d=>[d.x,d.y]),[o[0].x,o[0].y]]]),l=null,u=0;for(let d of c){let y=Math.abs(Ot(d[0].map(([x,M])=>({x,y:M}))));y>u&&(u=y,l=d[0])}if(!l)return[];let f=l.map(([d,y])=>({x:d,y})),m=f[0],h=f[f.length-1];return f.length>1&&Math.abs(m.x-h.x)<1e-9&&Math.abs(m.y-h.y)<1e-9&&f.pop(),f.length>=3?jt(f):[]}catch{return[]}}function ce(t,n,e,o,r=28){let a=[];for(let i=0;i<r;i++){let s=i/r*Math.PI*2;a.push({x:t+e*Math.cos(s),y:n+o*Math.sin(s)})}return a}function On(t,n,e,o){return[{x:t,y:n},{x:t+e,y:n},{x:t+e,y:n+o},{x:t,y:n+o}]}var _t={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,spine:6,armrest:7},Ks=.44,zs=.15,Ys=.3,Zs=.24;function ur(t){return t===void 0||!Number.isFinite(t)||t<=0?Zs:Math.min(Ys,Math.max(zs,t*Ks))}var bm=.21,$s=.05,fr=.45,qs=fr+$s,Js=.92,Qs=.66,gm=1.205;var Mm=.6,Rm=.56,_m=.5,Im=-.9,Sm=.76,Pm=.66;var Am=.38,Em=-.84,wm=.06,Bm=78;var ta=.28,lr=.15,na=[{part:_t.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:_t.pad,min:[-1,.36,-.95],max:[1,fr,1]},{part:_t.back,min:[-1,qs,-1],max:[1,Js,-.72]},{part:_t.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:_t.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:_t.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:_t.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:_t.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:_t.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:_t.leg,min:[.62,0,.48],max:[.82,.37,.7]},{part:_t.spine,min:[-.8,.3,-1],max:[.8,.6,-.9]},...[1,-1].flatMap(t=>{let n=i=>{let s=t*(lr-i),c=t*(lr+i);return[Math.min(s,c),Math.max(s,c)]},[e,o]=n(.09),[r,a]=n(ta/2);return[{part:_t.armrest,min:[e,0,-.5],max:[o,.6,.05],skip:[2,3]},{part:_t.armrest,min:[r,.6,-.74],max:[a,.655,.58],skip:[3]}]})],ea=[{n:[1,0,0],c:[[1,0,0],[1,1,0],[1,1,1],[1,0,1]]},{n:[-1,0,0],c:[[0,0,1],[0,1,1],[0,1,0],[0,0,0]]},{n:[0,1,0],c:[[0,1,0],[0,1,1],[1,1,1],[1,1,0]]},{n:[0,-1,0],c:[[0,0,1],[0,0,0],[1,0,0],[1,0,1]]},{n:[0,0,1],c:[[0,0,1],[1,0,1],[1,1,1],[0,1,1]]},{n:[0,0,-1],c:[[1,0,0],[0,0,0],[0,1,0],[1,1,0]]}];function Om(){let t=[],n=[],e=[],o=[],r=(h,d,y)=>{let x=e.length,[M,p,g]=h,A=[p[0]-M[0],p[1]-M[1],p[2]-M[2]],P=[g[0]-M[0],g[1]-M[1],g[2]-M[2]],b=A[1]*P[2]-A[2]*P[1],_=A[2]*P[0]-A[0]*P[2],S=A[0]*P[1]-A[1]*P[0],R=Math.hypot(b,_,S);R>1e-9?(b/=R,_/=R,S/=R):[b,_,S]=d,b*d[0]+_*d[1]+S*d[2]<0&&(b=-b,_=-_,S=-S);for(let B of h)t.push(...B),n.push(b,_,S),e.push(y);o.push(x,x+1,x+2,x,x+2,x+3)},a=h=>{for(let[d,y]of ea.entries()){if(h.skip?.includes(d))continue;let x=y.c.map(M=>M.map((p,g)=>p?h.max[g]:h.min[g]));r(x,y.n,h.part)}},i=h=>{let{part:d,vertical:y,across:x,along:M,alongCoord:p,halfWidth:g,swell:A,base:P}=h,b=(G,v,X)=>y?[G*g(v),p(v),X]:[G*g(v),X,p(v)],_=(G,v)=>b(G,v,A(G,v)),S=y?2:1,R=(G,v)=>{let V=Math.max(-1,G-.001),Q=Math.min(1,G+.001),et=Math.max(0,v-.001),tt=Math.min(1,v+.001),J=_(V,v),ft=_(Q,v),mt=_(G,et),ht=_(G,tt),rt=[ft[0]-J[0],ft[1]-J[1],ft[2]-J[2]],yt=[ht[0]-mt[0],ht[1]-mt[1],ht[2]-mt[2]],dt=[rt[1]*yt[2]-rt[2]*yt[1],rt[2]*yt[0]-rt[0]*yt[2],rt[0]*yt[1]-rt[1]*yt[0]];dt[S]<0&&(dt=[-dt[0],-dt[1],-dt[2]]);let bt=Math.hypot(...dt)||1;return[dt[0]/bt,dt[1]/bt,dt[2]/bt]},B=(G,v)=>(t.push(...G),n.push(...v),e.push(d),e.length-1),C=M.map(G=>x.map(v=>B(_(v,G),R(v,G))));for(let G=0;G<M.length-1;G++)for(let v=0;v<x.length-1;v++)o.push(C[G][v],C[G][v+1],C[G+1][v+1],C[G][v],C[G+1][v+1],C[G+1][v]);let O=[];for(let G=0;G<x.length-1;G++)O.push([x[G],M[0]]);for(let G=0;G<M.length-1;G++)O.push([x[x.length-1],M[G]]);for(let G=x.length-1;G>0;G--)O.push([x[G],M[M.length-1]]);for(let G=M.length-1;G>0;G--)O.push([x[0],M[G]]);let k=O.map(([G,v])=>b(G,v,P)),E=G=>y?[G[0],G[1]]:[G[0],G[2]],w=G=>{let[v,X]=E(k[G]),[V,Q]=E(k[(G+1)%k.length]),et=Math.hypot(V-v,Q-X)||1;return[(Q-X)/et,-(V-v)/et]},L=k.reduce((G,v)=>{let[X,V]=E(v);return[G[0]+X/k.length,G[1]+V/k.length]},[0,0]),D=G=>{let v=w((G+k.length-1)%k.length),X=w(G),V=v[0]+X[0],Q=v[1]+X[1],[et,tt]=E(k[G]);V*(et-L[0])+Q*(tt-L[1])<0&&(V=-V,Q=-Q);let J=Math.hypot(V,Q)||1;return y?[V/J,Q/J,0]:[V/J,0,Q/J]},T=O.map(([G,v],X)=>B(_(G,v),D(X))),N=k.map((G,v)=>B(G,D(v)));for(let G=0;G<O.length;G++){let v=(G+1)%O.length;o.push(T[G],T[v],N[v],T[G],N[v],N[G])}let U=y?[0,0,-1]:[0,-1,0],j=k.map(G=>B(G,U));for(let G=1;G<j.length-1;G++)o.push(j[0],j[G],j[G+1])},s=h=>1-h*h*h*h,c=h=>d=>{for(let y=1;y<h.length;y++)if(d<=h[y][0]){let[x,M]=h[y-1],[p,g]=h[y];return M+(g-M)*(d-x)/(p-x)}return h[h.length-1][1]};for(let h of na)if(h.part===_t.back){let d=[[0,.8],[.04,.9],[.1,.97],[.25,1],[.77,.94],[.88,.88],[.95,.79],[1,Qs]],y=h.min[1],x=h.max[1];i({part:h.part,vertical:!0,across:[-1,-.6,0,.6,1],along:d.map(([M])=>M),alongCoord:M=>y+(x-y)*M,halfWidth:c(d),swell:(M,p)=>h.max[2]-.12+.12*s(M)*s(2*p-1),base:h.min[2]})}else if(h.part===_t.pad){let d=[[0,.84],[.1,.92],[.78,.92],[.9,.89],[.97,.82],[1,.72]],y=h.min[2],x=h.max[2],M=h.min[1],p=h.max[1];i({part:h.part,vertical:!1,across:[-1,-.6,0,.6,1],along:d.map(([g])=>g),alongCoord:g=>y+(x-y)*g,halfWidth:c(d),swell:(g,A)=>M+(p-M)*(.45+.55*s(g)*s(2*A-1)),base:M})}else a(h);let l=new Float32Array(t),u=new Float32Array(n),f=new Float32Array(e),m=new Uint16Array(o);return{position:l,normal:u,part:f,index:m,vertexCount:e.length,indexCount:o.length}}var Ue=20*Math.PI/180;function mr(t,n,e,o,r){let a=new Float32Array(n),i=f=>t[f*3],s=f=>t[f*3+2],c=Math.cos(Ue),l=0,u=(f,m)=>{let h=m-f,d=r?.(f),y=d!==void 0;for(let g=f+1;!y&&g<m-1;g++){let A=i(g)-i(g-1),P=s(g)-s(g-1),b=i(g+1)-i(g),_=s(g+1)-s(g),S=Math.hypot(A,P)*Math.hypot(b,_);S>1e-9&&(A*b+P*_)/S<c&&(y=!0)}let x=0,M=0,p=!1;if(y){if(d)[x,M]=d;else{for(let A=f;A<m;A++)x+=i(A),M+=s(A);x/=h,M/=h}let g=0;for(let A=f+1;A<m;A++)g=Math.max(g,Math.hypot(i(A)-i(A-1),s(A)-s(A-1)));p=h>=3&&Math.hypot(i(m-1)-i(f),s(m-1)-s(f))<=g*1.6}for(let g=f;g<m;g++){let[A,P]=y?[x,M]:o(g),b=A-i(g),_=P-s(g);if(h>=2&&!(d&&h<3)){let S=p?f+(g-1-f+h)%h:Math.max(f,g-1),R=p?f+(g+1-f)%h:Math.min(m-1,g+1),B=i(R)-i(S),C=s(R)-s(S),O=Math.hypot(B,C);if(O>1e-6){let k=-C/O,E=B/O;k*b+E*_<0&&(k=-k,E=-E),b=k,_=E}}a[g]=b===0&&_===0?0:Math.atan2(b,_)}};for(let f=1;f<=n;f++)(f===n||e(f)!==e(l))&&(u(l,f),l=f);return a}var le=.22;function vm(t){let n=En[t];return n==="sold"||n==="held"?1:0}var oa=.42,hr=1.6;function ra(t,n){let e=new Float32Array(t.length*4),o=Math.cos(Ue),r=0;for(let a=1;a<=t.length;a++){if(a<t.length&&t[a].rowId===t[r].rowId)continue;let i=a-r>=2&&!n?.has(t[r].rowId);for(let l=r;i&&l<a;l++)t[l].kind==="booth"&&(i=!1);for(let l=r+1;i&&l<a-1;l++){let u=t[l].x-t[l-1].x,f=t[l].y-t[l-1].y,m=t[l+1].x-t[l].x,h=t[l+1].y-t[l].y,d=Math.hypot(u,f)*Math.hypot(m,h);d>1e-9&&(u*m+f*h)/d<o&&(i=!1)}let s=[];for(let l=r+1;i&&l<a;l++){let u=Math.hypot(t[l].x-t[l-1].x,t[l].y-t[l-1].y);u>1e-6&&s.push(u)}s.sort((l,u)=>l-u);let c=s.length?s[Math.floor(s.length/2)]:0;for(let l=r;c>0&&l<a;l++){let u=x=>{let M=l+x;if(M<r||M>=a)return null;let p=t[M].x-t[l].x,g=t[M].y-t[l].y,A=Math.hypot(p,g);return A>1e-6?{x:p/A,y:g/A,gap:A}:null},f=u(1),m=u(-1),h=c/2,d=f??(m?{x:-m.x,y:-m.y,gap:1/0}:null);if(!d)continue;let y=f&&f.gap<c*hr?f.gap/2:h;if(e[l*4]=d.x*y*I,e[l*4+1]=d.y*y*I,!m||m.gap>=c*hr){let x=m??{x:-d.x,y:-d.y};e[l*4+2]=x.x*h*I,e[l*4+3]=x.y*h*I}}r=a}return e}function ia(t){let n=t.length,e=new Float64Array(n);if(n<2)return e.fill(1/0),e;let o=1/0,r=1/0,a=-1/0,i=-1/0;for(let d of t)d.x<o&&(o=d.x),d.y<r&&(r=d.y),d.x>a&&(a=d.x),d.y>i&&(i=d.y);let s=Math.max(a-o,1e-6),c=Math.max(i-r,1e-6),l=Math.max(Math.sqrt(s*c/n),1e-6),u=Math.max(1,Math.ceil(s/l)+1),f=Math.max(1,Math.ceil(c/l)+1),m=new Map,h=(d,y)=>{let x=Math.min(u-1,Math.max(0,Math.floor((d-o)/l)));return Math.min(f-1,Math.max(0,Math.floor((y-r)/l)))*u+x};for(let d=0;d<n;d++){let y=h(t[d].x,t[d].y),x=m.get(y);x?x.push(d):m.set(y,[d])}for(let d=0;d<n;d++){let y=t[d],x=Math.min(u-1,Math.max(0,Math.floor((y.x-o)/l))),M=Math.min(f-1,Math.max(0,Math.floor((y.y-r)/l))),p=1/0;for(let g=1;g<=4;g++){for(let A=M-g;A<=M+g;A++)if(!(A<0||A>=f))for(let P=x-g;P<=x+g;P++){if(P<0||P>=u||g>1&&Math.abs(A-M)<g&&Math.abs(P-x)<g)continue;let b=m.get(A*u+P);if(b)for(let _ of b){if(_===d)continue;let S=Math.hypot(t[_].x-y.x,t[_].y-y.y);S<p&&(p=S)}}if(Number.isFinite(p)&&p<=g*l)break}e[d]=p}return e}function sa(t){let n=t.eyeHeightM;return Number.isFinite(n)?Math.max(0,n-qn):0}function yr(t,n,e,o,r,a,i){let s=t.length,c=new Float32Array(s*3),l=new Float32Array(s),u=new Float32Array(s*3),f=new Float32Array(s),m=new Float32Array(s),h=new Float32Array(s),d=new Float32Array(s),y=new Float32Array(s*3),x=new Map,M=ia(t);for(let p=0;p<s;p++){let g=t[p],P=(e?.seatPitchU(p)??M[p])*I;f[p]=Number.isFinite(P)?Math.max(.06,Math.min(le,P*oa)):le,m[p]=ur(Number.isFinite(P)?P:void 0);let b=Ko(g.glyph,{seatGlyph:a?.get(g.categoryKey)}),_=g.glyph!==void 0||a?.has(g.categoryKey);h[p]=Vo.indexOf(!_&&i?.has(g.rowId)?"dining":b),d[p]=g.wheelchairSpaceType==="no-seat"?0:1,c[p*3]=g.x*I,c[p*3+1]=e?e.seatDeckY(p):sa(g),c[p*3+2]=g.y*I,l[p]=De(n?n(g):"available");let S=lt(r?.get(g.categoryKey)??"#6e7bff")??[.43,.48,1];if(u[p*3]=S[0],u[p*3+1]=S[1],u[p*3+2]=S[2],g.accessibility?.length){let R=lt($n(g.accessibility));R&&(y[p*3]=R[0],y[p*3+1]=R[1],y[p*3+2]=R[2])}x.set(g.id,p)}return{count:s,iPosition:c,iState:l,iCategory:u,iMaxRadius:f,iRing:y,idToIndex:x,iChairWidth:m,iGlyph:h,iPhysicalSeat:d,iArmrests:ra(t,i),iFloor:o??new Float32Array(s),iSection:new Float32Array(s).fill(-1),iYaw:new Float32Array(s)}}var aa=64;function Hm(t,n){let e=[];for(let i of n){let s=t.idToIndex.get(i.seatId);if(s===void 0)continue;let c=De(i.state);t.iState[s]!==c&&(t.iState[s]=c,e.push(s))}if(!e.length)return[];e.sort((i,s)=>i-s);let o=[],r=e[0],a=e[0];for(let i=1;i<e.length;i++){let s=e[i];if(s!==a){if(s<=a+aa){a=s;continue}o.push({start:r,length:a-r+1}),r=s,a=s}}return o.push({start:r,length:a-r+1}),o}import Ma from"polygon-clipping";var K={top:1,wallBottom:.58,bottomCap:.4};function cn(t,n){if(!t)return n;let e=z(Xt(t,.4),.62);return ct(n,e,.22)}function dr(t,n){return t?ct(n,z(Xt(t,.25),.74),.62):n}function pr(t,n){let e=sn(rn({tierTop:n}));return t?on(t,e.sectionDeck,Math.min(e.sectionDeckChromaShare*An(t),e.sectionDeckChromaCap)):on(n,e.deck,Math.min(An(n),re))}function xr(t,n){let e=new Map;for(let a of t.categories??[])e.set(a.key,a.color);let o=new Map;for(let a of n){if(!a.sectionId)continue;let i=o.get(a.sectionId);i||(i=new Map,o.set(a.sectionId,i)),i.set(a.categoryKey,(i.get(a.categoryKey)??0)+1)}let r=new Map;for(let[a,i]of o){let s=0,c=0,l=0,u=0;for(let[f,m]of i){let h=lt(e.get(f));h&&(s+=h[0]*m,c+=h[1]*m,l+=h[2]*m,u+=m)}u>0&&r.set(a,[s/u,c/u,l/u])}return r}function br(t,n){return lt(t.color)??n.get(t.logicalSectionId??t.id)??null}import Tr from"polygon-clipping";import _r from"polygon-clipping";import ca from"earcut";var la=.58,gr=.01,Gt=le*1.5*Ct,ua=.5,fa=.6;function ma(t,n){let e=t.length,o=[];for(let i=0;i<e;i++){let s=t[Math.max(0,i-1)],c=t[Math.min(e-1,i+1)],l=c.x-s.x,u=c.y-s.y,f=Math.hypot(l,u);if(f<1e-9){o.push([0,0]);continue}l/=f,u/=f,o.push([-u,l])}let r=0;for(let i=0;i<e;i++)r+=(t[i].x-n.x)*o[i][0]+(t[i].y-n.y)*o[i][1];return r<0?o.map(([i,s])=>[-i,-s]):o}function ha(t,n){if(t.length<2||n<=0)return[...t];let e=[...t],o=(i,s)=>{let c=s.x-i.x,l=s.y-i.y,u=Math.hypot(c,l)||1;return{x:c/u,y:l/u}},r=o(e[1],e[0]),a=o(e[e.length-2],e[e.length-1]);return e.unshift({x:e[0].x+r.x*n,y:e[0].y+r.y*n}),e.push({x:e[e.length-1].x+a.x*n,y:e[e.length-1].y+a.y*n}),e}var Mr=Math.PI/12;function ya(t){if(t.length<3)return[...t];let n=pn(t);return n.length>=3?n:[...t]}function Ir(t,n){if(!t.length||!(n>0))return[];let e=ya(t),o=(s,c,l,u)=>{let f=l-c;for(;f<0;)f+=Math.PI*2;for(;f>Math.PI*2;)f-=Math.PI*2;let m=Math.max(1,Math.ceil(f/Mr)),h=n/Math.cos(f/m/2);for(let d=0;d<=m;d++){let y=c+f*d/m;u.push({x:s.x+Math.cos(y)*h,y:s.y+Math.sin(y)*h})}};if(e.length<3){let s=0,c=0;for(let h of e)s+=h.x,c+=h.y;s/=e.length||1,c/=e.length||1;let l=0;for(let h of e)l=Math.max(l,Math.hypot(h.x-s,h.y-c));let u=[],f=Math.max(3,Math.ceil(Math.PI*2/Mr)),m=(l+n)/Math.cos(Math.PI/f);for(let h=0;h<f;h++){let d=h/f*Math.PI*2;u.push({x:s+Math.cos(d)*m,y:c+Math.sin(d)*m})}return u}let r=e.length,a=[];for(let s=0;s<r;s++){let c=e[s],l=e[(s+1)%r];a.push(Math.atan2(-(l.x-c.x),l.y-c.y))}let i=[];for(let s=0;s<r;s++)o(e[s],a[(s+r-1)%r],a[s],i);return wr(i)}function da(t,n,e){if(t.length===1)return Math.hypot(n-t[0].x,e-t[0].y);let o=1/0;for(let r=0;r+1<t.length;r++){let a=t[r],i=t[r+1],s=i.x-a.x,c=i.y-a.y,l=s*s+c*c,u=l>1e-12?((n-a.x)*s+(e-a.y)*c)/l:0;u<0?u=0:u>1&&(u=1);let f=Math.hypot(n-(a.x+u*s),e-(a.y+u*c));f<o&&(o=f)}return o}function ue(t){let n=t.map(r=>{let a=0,i=0;for(let l of r.pts)a+=l.x,i+=l.y;let s=r.pts.length||1;a/=s,i/=s;let c=0;for(let l of r.pts){let u=Math.hypot(l.x-a,l.y-i);u>c&&(c=u)}return{cx:a,cy:i,rad:c}}),e=r=>{let a=r.length;return a<=2?[...r]:[r[Math.floor(a*.25)],r[Math.floor(a*.5)],r[Math.floor(a*.75)]]},o=[];for(let r=0;r<t.length;r++){let a=e(t[r].pts),i=[],s=1/0,c=null;for(let u of a){let f=1/0;for(let m=0;m<t.length;m++){if(m===r||Math.abs(t[m].y-t[r].y)<.001)continue;let h=n[m],d=Math.hypot(u.x-h.cx,u.y-h.cy)-h.rad;if(d>=f&&d>=s)continue;let y=da(t[m].pts,u.x,u.y);y<f&&(f=y),t[m].depth<t[r].depth&&y<s&&(s=y,c=t[m].y)}Number.isFinite(f)&&f>0&&i.push(f)}i.sort((u,f)=>u-f);let l=i.length?i[Math.floor(i.length/2)]:1;o.push({pitch:l,belowY:c})}return o}function Sr(t,n,e,o){let r=t[n],a=r.pts.length>=2?[...r.pts]:r.pts.length===1?(()=>{let u=r.pts[0],f=u.x-o.x,m=u.y-o.y,h=Math.hypot(f,m)||1;f/=h,m/=h;let d=Math.max(e[n].pitch,.001)*.5;return[{x:u.x+m*d,y:u.y-f*d},{x:u.x-m*d,y:u.y+f*d}]})():[];if(a.length<2)return null;let i=0,s=0;for(let u=1;u<a.length;u++){let f=Math.hypot(a[u].x-a[u-1].x,a[u].y-a[u-1].y);f>1e-6&&(i+=f,s++)}let c=s>0?i/s:0,l=ha(a,Math.max(c*fa,Gt));return{pts:l,nrm:ma(l,o),front:Math.max(e[n].pitch*la,Gt),back:Math.max(e[n].pitch*ua,Gt)}}var xn=1.5,Pr=.3;function Xe(t,n){if(t.length<3)return t;let e=t[0],o=t[t.length-1],r=o.x-e.x,a=o.y-e.y,i=Math.hypot(r,a),s=-1,c=-1;for(let f=1;f<t.length-1;f++){let m=t[f],h=i>1e-12?Math.abs((m.x-e.x)*a-(m.y-e.y)*r)/i:Math.hypot(m.x-e.x,m.y-e.y);h>s&&(s=h,c=f)}if(s<=n||c<0)return[e,o];let l=Xe(t.slice(0,c+1),n),u=Xe(t.slice(c),n);return[...l.slice(0,-1),...u]}function Ar(t,n){if(t.length<4)return t;let e=Xe([...t,t[0]],n);return e.pop(),e.length>=3?e:t}function pa(t){let n=t.map((o,r)=>{let a=t[(r+1)%t.length];return{a:o,b:a,i:r,minX:Math.min(o.x,a.x),maxX:Math.max(o.x,a.x),minY:Math.min(o.y,a.y),maxY:Math.max(o.y,a.y)}}).sort((o,r)=>o.minX-r.minX),e=(o,r,a)=>(r.x-o.x)*(a.y-o.y)-(r.y-o.y)*(a.x-o.x);for(let o=0;o<n.length;o++){let r=n[o];for(let a=o+1;a<n.length&&n[a].minX<=r.maxX;a++){let i=n[a];if(!(Math.abs(r.i-i.i)===1||Math.abs(r.i-i.i)===t.length-1||r.maxY<i.minY||i.maxY<r.minY)&&e(r.a,r.b,i.a)*e(r.a,r.b,i.b)<=0&&e(i.a,i.b,r.a)*e(i.a,i.b,r.b)<=0)return!0}}return!1}function Er(t,n,e){if(t.length<2)return[];let o=e??ue(t),r=new Map;for(let i=0;i<t.length;i++){let s=r.get(t[i].blockId);s?s.push(i):r.set(t[i].blockId,[i])}let a=[];for(let[,i]of r){let s=[];for(let p of i){let g=t[p].patch;g&&g.length>=3?a.push({outline:[...g],holes:[],topY:t[p].y}):s.push(p)}if(!s.length)continue;s.sort((p,g)=>t[p].depth-t[g].depth);let l=s.map(p=>Sr(t,p,o,n)).filter(p=>p!==null);if(!l.length)continue;let u=(p,g)=>({x:p.pts[g].x-p.nrm[g][0]*(p.front+xn),y:p.pts[g].y-p.nrm[g][1]*(p.front+xn)}),f=(p,g)=>({x:p.pts[g].x+p.nrm[g][0]*(p.back+xn),y:p.pts[g].y+p.nrm[g][1]*(p.back+xn)}),m=l[0],h=l[l.length-1],d=[];for(let p=0;p<m.pts.length;p++)d.push(u(m,p));for(let p of l)d.push(f(p,p.pts.length-1));for(let p=h.pts.length-1;p>=0;p--)d.push(f(h,p));for(let p=l.length-1;p>=0;p--)d.push(u(l[p],0));let y=wr(d),x=1/0;for(let p of s)t[p].y<x&&(x=t[p].y);if(!Number.isFinite(x))continue;if(y.length>=3&&Math.abs(Ot(y))>1e-6&&l.every(p=>{let g=p.pts[Math.floor(p.pts.length/2)];return Mt(y,g.x,g.y)})&&!pa(y)){a.push({outline:Ar(y,Pr),holes:[],topY:x});continue}for(let p of xa(l))a.push({outline:p,holes:[],topY:x})}return a}function xa(t){let n=[];for(let e of t){let o=[],r=[],a=e.front+xn,i=e.back+xn;for(let c=0;c<e.pts.length;c++){let l=e.pts[c],u=e.nrm[c];o.push([l.x-u[0]*a,l.y-u[1]*a]),r.push([l.x+u[0]*i,l.y+u[1]*i])}let s=[...o,...r.reverse()];s.length<3||(s.push(s[0]),n.push([s]))}if(!n.length)return[];try{let e=_r.union(n[0],...n.slice(1)),o=[];for(let r of e){if(!r.length||r[0].length<4)continue;let a=r[0].map(([c,l])=>({x:c,y:l})),i=a[0],s=a[a.length-1];a.length>1&&Math.abs(i.x-s.x)<1e-9&&Math.abs(i.y-s.y)<1e-9&&a.pop(),a.length>=3&&o.push(Ar(a,Pr))}return o}catch{return[]}}function wr(t){let n=[];for(let e of t){let o=n[n.length-1];o&&Math.hypot(e.x-o.x,e.y-o.y)<1e-9||n.push(e)}for(;n.length>2&&Math.hypot(n[0].x-n[n.length-1].x,n[0].y-n[n.length-1].y)<1e-9;)n.pop();return n}var je=class{constructor(n){this.minX=1/0;this.minY=1/0;this.maxX=-1/0;this.maxY=-1/0;this.rings=n;for(let e of n)for(let o of e)o.x<this.minX&&(this.minX=o.x),o.y<this.minY&&(this.minY=o.y),o.x>this.maxX&&(this.maxX=o.x),o.y>this.maxY&&(this.maxY=o.y)}containsAll(n){for(let e of n)if(e.x<this.minX||e.x>this.maxX||e.y<this.minY||e.y>this.maxY)return!1;for(let e of this.rings){let o=!0;for(let r of n)if(!Mt(e,r.x,r.y)){o=!1;break}if(o)return!0}return!1}};function Rr(t,n,e,o,r,a){if(o.length<3)return;if(e.containsAll(o)){let l=[0,1,0],u=o[0];for(let f=1;f+1<o.length;f++){let m=o[f],h=o[f+1];t.tri([u.x*I,r,u.y*I],[m.x*I,r,m.y*I],[h.x*I,r,h.y*I],l,a)}return}let i=o.map(l=>[l.x,l.y]);i.push(i[0]);let s;try{s=_r.intersection([i],n)}catch{return}let c=[0,1,0];for(let l of s){if(!l.length||l[0].length<4)continue;let u=l[0],f=[],m=[];for(let d=0;d<u.length-1;d++)f.push(u[d][0],u[d][1]),m.push([u[d][0],u[d][1]]);if(m.length<3)continue;let h=ca(f,void 0,2);for(let d=0;d<h.length;d+=3){let y=m[h[d]],x=m[h[d+1]],M=m[h[d+2]];t.tri([y[0]*I,r,y[1]*I],[x[0]*I,r,x[1]*I],[M[0]*I,r,M[1]*I],c,a)}}}function Br(t,n,e,o,r,a,i){if(n.length<2)return;let s=i??ue(n),c=[0,1,0],l=a&&a.length>=3?[[...a.map(h=>[h.x,h.y]),[a[0].x,a[0].y]]]:null,u=a&&a.length>=3?new je([[...a]]):null,f=h=>{t.setMaterial(2),h(),t.setMaterial(0)},m=h=>{t.setMaterial(3),h(),t.setMaterial(0)};for(let h=0;h<n.length;h++){let d=n[h];if(d.patch&&d.patch.length>=3){let P=[...d.patch],b=s[h].belowY??o;if(m(()=>{if(l&&u)Rr(t,l,u,P,d.y,r.tread);else{let _=P[0];for(let S=1;S+1<P.length;S++){let R=P[S],B=P[S+1];t.tri([_.x*I,d.y,_.y*I],[R.x*I,d.y,R.y*I],[B.x*I,d.y,B.y*I],c,r.tread)}}}),d.y>b+gr){let _=0,S=0;for(let R of P)_+=R.x,S+=R.y;_/=P.length,S/=P.length,f(()=>{for(let R=0;R<P.length;R++){let B=P[R],C=P[(R+1)%P.length],O=C.x-B.x,k=C.y-B.y,E=Math.hypot(O,k);if(E<1e-6)continue;let w=k/E,L=-O/E;(B.x-_)*w+(B.y-S)*L<0&&(w=-w,L=-L);let D=[w,0,L],T=[B.x*I,d.y,B.y*I],N=[C.x*I,d.y,C.y*I],U=[B.x*I,b,B.y*I],j=[C.x*I,b,C.y*I];t.tri(T,N,j,D,r.riser),t.tri(T,j,U,D,r.riser)}})}continue}let y=Sr(n,h,s,e);if(!y)continue;let{pts:x,nrm:M,front:p,back:g}=y,A=s[h].belowY??o;for(let P=0;P+1<x.length;P++){let b=x[P],_=x[P+1],S=M[P],R=M[P+1];if(Math.hypot(_.x-b.x,_.y-b.y)<1e-6||S[0]===0&&S[1]===0||R[0]===0&&R[1]===0)continue;let B=[(b.x-S[0]*p)*I,d.y,(b.y-S[1]*p)*I],C=[(_.x-R[0]*p)*I,d.y,(_.y-R[1]*p)*I],O=[(b.x+S[0]*g)*I,d.y,(b.y+S[1]*g)*I],k=[(_.x+R[0]*g)*I,d.y,(_.y+R[1]*g)*I];if(m(()=>{l&&u?Rr(t,l,u,[{x:b.x-S[0]*p,y:b.y-S[1]*p},{x:_.x-R[0]*p,y:_.y-R[1]*p},{x:_.x+R[0]*g,y:_.y+R[1]*g},{x:b.x+S[0]*g,y:b.y+S[1]*g}],d.y,r.tread):(t.tri(B,C,k,c,r.tread),t.tri(B,k,O,c,r.tread))}),d.y>A+gr){let E=[B[0],A,B[2]],w=[C[0],A,C[2]],L=[-S[0],0,-S[1]];f(()=>{t.tri(B,C,w,L,r.riser),t.tri(B,w,E,L,r.riser)})}}}}function ba(t,n){let e=t.eventConfigurationIds;return!e?.length||!!n&&e.includes(n)}function Or(t,n){return t.filter(e=>e.type!=="shape"||ba(e,n))}function kr(t,n){let e=t.focalPoint??{x:0,y:0};return t.floors?.length?t.floors.map((o,r)=>({objects:Or(o.objects,n),focal:{x:(o.focalPoint??e).x,y:(o.focalPoint??e).y},baseHeightM:o.baseHeightM??0,index:r})):[{objects:Or(t.objects,n),focal:e,baseHeightM:0,index:0}]}var ga={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function zt(t){return Yo(t)??ga}function Cr(t,n){let e=Wt(t.outline,Gt),o=zt(e),r=n.filter(i=>i!==t&&i.outline&&i.outline.length>=3&&dn(o,zt(i.outline)));if(!r.length)return[e];let a=i=>{let s=i.map(c=>[c.x,c.y]);return s.push(s[0]),s};try{let i=Tr.difference([a(e)],...r.map(c=>[a(c.outline)])),s=[];for(let c of i){if(!c.length)continue;let l=c[0].map(([u,f])=>({x:u,y:f}));if(l.length>1){let u=l[0],f=l[l.length-1];Math.abs(u.x-f.x)<1e-9&&Math.abs(u.y-f.y)<1e-9&&l.pop()}l.length>=3&&s.push(l)}return s.length?s:[e]}catch{return[e]}}function Lr(t,n){if(!n.length)return t;let e=a=>{let i=a.map(s=>[s.x,s.y]);return i.push(i[0]),i},o=n.map(a=>[e(a)]),r=[];for(let a of t){let i;try{i=Tr.intersection([e(a.outline)],o.flat())}catch{r.push(a);continue}for(let s of i){if(!s.length)continue;let c=s[0].map(([l,u])=>({x:l,y:u}));if(c.length>1){let l=c[0],u=c[c.length-1];Math.abs(l.x-u.x)<1e-9&&Math.abs(l.y-u.y)<1e-9&&c.pop()}c.length>=3&&r.push({outline:c,holes:[],topY:a.topY})}}return r.length?r:t}function Ra(t,n){return t===void 0||n===void 0?!0:Math.abs(t-n)<.001}var fe=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(n,e){let o=n.map(c=>[c.x,c.y]);if(o.length<3)return[];o.push(o[0]);let r=zt(n),a=this.rings.filter((c,l)=>dn(r,this.boxes[l])&&Ra(e,this.levels[l])),i=[[o]];if(a.length)try{i=Ma.difference([o],...a).map(l=>l.map(u=>u.map(([f,m])=>[f,m])))}catch{i=[[o]]}this.rings.push([o]),this.boxes.push(r),this.levels.push(e);let s=[];for(let c of i){if(!c.length)continue;let l=c[0].map(([u,f])=>({x:u,y:f}));if(l.length>1){let u=l[0],f=l[l.length-1];Math.abs(u.x-f.x)<1e-9&&Math.abs(u.y-f.y)<1e-9&&l.pop()}l.length>=3&&s.push(l)}return s}};function bn(t,n,e=t){if(!n)return t;let o=1/0,r=-1/0,a=1/0,i=-1/0;for(let m of e)o=Math.min(o,m.x),r=Math.max(r,m.x),a=Math.min(a,m.y),i=Math.max(i,m.y);let s=(o+r)/2,c=(a+i)/2,l=n*Math.PI/180,u=Math.cos(l),f=Math.sin(l);return t.map(m=>{let h=m.x-s,d=m.y-c;return{x:s+h*u-d*f,y:c+h*f+d*u}})}function Fr(t){let n=Do(t);return!n.length||!t.points?.length?[]:n.map(e=>bn(e,t.rotation,t.points))}function st(t){let n=null;if(t.kind==="polygon"&&t.points&&t.points.length>=3)return bn(No(t,4),t.rotation,t.points);if(t.kind==="rect"&&t.width&&t.height&&(n=On(t.x??0,t.y??0,t.width,t.height)),t.kind==="ellipse"&&t.width&&t.height){let e=(t.x??0)+t.width/2,o=(t.y??0)+t.height/2;n=ce(e,o,t.width/2,t.height/2)}return n?bn(n,t.rotation):null}function Dt(t){let n=t.role??"",o=n==="stage"?{kind:"stage",heightM:Uo(t.stageKind)}:{stage:{kind:"stage",heightM:1},entrance:{kind:"portal",heightM:2.7},exit:{kind:"portal",heightM:2.7},screen:{kind:"solid",heightM:6},wall:{kind:"solid",heightM:2.8},rail:{kind:"solid",heightM:1.1},suite:{kind:"suite",heightM:3},obstruction:{kind:"solid",heightM:4.5},sound:{kind:"solid",heightM:1.45},restroom:{kind:"solid",heightM:2.4},bar:{kind:"solid",heightM:1.1},concession:{kind:"solid",heightM:1.1},coat:{kind:"solid",heightM:1.1},goal:{kind:"portal",heightM:1.8}}[n]??{kind:"plate",heightM:.25};return{...o,heightM:t.heightM??o.heightM}}var _a=.08,Ia=30,Sa=.015;function Pa(t,n){let e=!1;for(let o=0,r=n.length-1;o<n.length;r=o++){let a=n[o],i=n[r];a.y>t.y!=i.y>t.y&&t.x<(i.x-a.x)*(t.y-a.y)/(i.y-a.y)+a.x&&(e=!e)}return e}function Gr(t,n){let e=st(t)??(t.points?.length?bn(t.points,t.rotation):null),o=Dt(t),a=!t.role&&o.kind==="plate"&&t.heightM===void 0&&!!e&&Math.abs(Ot(e))*nt**2>=Ia?Sa:o.heightM;if(!e)return{topOffsetM:a,supportOffsetM:0};if(o.kind!=="plate"&&o.kind!=="stage")return{topOffsetM:a,supportOffsetM:0};let i=1/0,s=1/0,c=-1/0,l=-1/0;for(let h of e)i=Math.min(i,h.x),s=Math.min(s,h.y),c=Math.max(c,h.x),l=Math.max(l,h.y);let u=a,f=0,m=1e-6*Math.max(1,c-i,l-s);for(let h of n)c>h.minX&&i<h.maxX&&l>h.minY&&s<h.maxY&&u<=h.topOffsetM+1e-6&&(u=h.topOffsetM+_a),i>=h.minX-m&&c<=h.maxX+m&&s>=h.minY-m&&l<=h.maxY+m&&(!h.poly||e.every(x=>Pa(x,h.poly)||Aa(x,h.poly,m)))&&(f=Math.max(f,h.topOffsetM));return t.fill&&t.fill!=="none"&&t.fill!=="transparent"&&n.push({minX:i,minY:s,maxX:c,maxY:l,topOffsetM:u,poly:e}),{topOffsetM:u,supportOffsetM:Math.min(f,u)}}function Aa(t,n,e){for(let o=0,r=n.length-1;o<n.length;r=o++){let a=n[r],i=n[o],s=i.x-a.x,c=i.y-a.y,l=s*s+c*c,u=l?Math.max(0,Math.min(1,((t.x-a.x)*s+(t.y-a.y)*c)/l)):0;if(Math.hypot(t.x-(a.x+u*s),t.y-(a.y+u*c))<=e)return!0}return!1}function $t(t,n,e){return{x:t.x+(n.x-t.x)*e,y:t.y+(n.y-t.y)*e}}function Tt(t){if(t.length!==4)return t;let n=Math.hypot(t[1].x-t[0].x,t[1].y-t[0].y),e=Math.hypot(t[2].x-t[1].x,t[2].y-t[1].y);return n>=e?t:[t[1],t[2],t[3],t[0]]}function Pt(t,n,e){return[$t(t[0],t[1],n),$t(t[0],t[1],e),$t(t[3],t[2],e),$t(t[3],t[2],n)]}function Tn(t,n,e){return[$t(t[0],t[3],n),$t(t[1],t[2],n),$t(t[1],t[2],e),$t(t[0],t[3],e)]}function ut(t,n,e,o,r,a,i){Z(t,n,i?.length?i:void 0,()=>e,o,r,a,K)}function kn(t){if(t.length<3)return t.map(e=>({...e}));let n=pn(t);return n.length>=3?n:[...t].sort((e,o)=>e.x-o.x||e.y-o.y).map(e=>({...e}))}var Ea=.8,wa=.6,Ba=2;function qt(t,n){if(!n.length)return null;let e=[],o=0;for(let i of t.objects){if(i.type!=="shape"||i.role!=="wall")continue;let s=st(i)??[],c=Nr(s)/2;!(c>0)||ka(s)/c*I>Ba||(e.push(...s),o+=c)}if(e.length<3)return null;let r=kn(e);if(r.length<3||o<Nr(r)*wa)return null;let a=0;for(let i of n)Ca(i,r)&&(a+=1);return a>=n.length*Ea?r:null}var me=6,Oa=5,Ta=8;function Dr(t){return Math.max(Ta,(Number.isFinite(t)?t:0)+Oa)}function gn(t){let n=0,e=0,o=0;for(let r=0;r<t.length;r++){let a=t[r],i=t[(r+1)%t.length],s=a.x*i.y-i.x*a.y;n+=s,e+=(a.x+i.x)*s,o+=(a.y+i.y)*s}if(Math.abs(n)<1e-9){let r=0,a=0;for(let i of t)r+=i.x,a+=i.y;return{x:r/Math.max(1,t.length),y:a/Math.max(1,t.length)}}return{x:e/(3*n),y:o/(3*n)}}function ka(t){let n=0;for(let e=0;e<t.length;e++){let o=t[e],r=t[(e+1)%t.length];n+=o.x*r.y-r.x*o.y}return Math.abs(n)/2}function Nr(t){let n=0;for(let e=0;e<t.length;e++){let o=t[e],r=t[(e+1)%t.length];n+=Math.hypot(r.x-o.x,r.y-o.y)}return n}function Ca(t,n){let e=!1;for(let o=0,r=n.length-1;o<n.length;r=o++){let a=n[o],i=n[r];a.y>t.y!=i.y>t.y&&t.x<(i.x-a.x)*(t.y-a.y)/(i.y-a.y)+a.x&&(e=!e)}return e}var La=[[/\b(wc|toilets?|restrooms?|washrooms?|lavatory|loo)\b/i,"restroom"],[/\b(bar|drinks|pub|cocktails?)\b/i,"bar"],[/\b(food|concessions?|snacks?|kiosk|caf[eé]|kitchen|catering)\b/i,"concession"],[/\b(coat ?check|cloak ?room|cloakroom|coats)\b/i,"coat"],[/\b(screen|led wall|projection|video wall)\b/i,"screen"],[/\b(sound|foh|mixing desk|control booth)\b/i,"sound"],[/\b(entrance|entry|way in|gate)\b/i,"entrance"],[/\b(exit|way out)\b/i,"exit"],[/\b(pillar|column|obstruction)\b/i,"obstruction"],[/\b(walls?|outline|boundary|perimeter)\b/i,"wall"]],Fa=1.2,Ga=12;function vr(t){if(t.heightM!==void 0)return!1;let n=st(t);if(!n||n.length<3)return!1;let e=0;for(let r=0;r<n.length;r++){let a=n[r],i=n[(r+1)%n.length];e+=Math.hypot(i.x-a.x,i.y-a.y)}return e*nt<Ga*2?!1:2*Cn(n)/e*nt<=Fa}function We(t){if(!t)return null;for(let[n,e]of La)if(n.test(t))return e;return null}var Ur="auto-rows-";function Xr(t){return t.id.startsWith(Ur)&&!t.label}var Na=1.15,Da=.09,jr=6,va=34,Ha=.35,Ua=6,Xa=.35,ja=.75,Wa=12,Va=2.5,Ka=40,za=[18,24],Ya=[12,16],Hr=14,Za=.8,$a=.6,qa=5,Ja=.3,Wr=.4,Vr=2,Qa=400,tc=2.6,nc=.8,ec=4,oc=26,rc=.7,ic=.5,sc=.985,ac=1.5,cc=2.2,lc=3,uc=25,fc=.985,mc=2,hc=6,yc=3,dc=.1,pc=1.5,xc=1.6,bc=6e3,gc=.6,Mc="#c3c7cd",Ve=300,Rc=240;function _c(t,n,e,o){if(!t.fill||!/^#[0-9a-f]{6}$/i.test(t.fill))return null;let r=ze([...n]),a=new Set;for(let u of o)a.add(Math.floor(Math.atan2(u.y-r.y,u.x-r.x)*180/Math.PI/10));if(a.size*10<Rc)return null;let{h:i,s,l:c}=Wo(jo(t.fill));return i<70/360||i>170/360||s<.2||c<.08||c>.75||e.some(u=>u!==t&&u.type==="shape"&&st(u)?.some(f=>$e(f,n)))?null:t.kind==="ellipse"?"oval-cricket":t.kind==="rect"?"pitch-football":null}var Ic="Estimated from the drawing; confirm with the venue.",Ye=t=>{if(!t.length)return null;let n=[...t].sort((o,r)=>o-r),e=Math.floor(n.length/2);return n.length%2?n[e]:(n[e-1]+n[e])/2},ze=t=>({x:t.reduce((n,e)=>n+e.x,0)/t.length,y:t.reduce((n,e)=>n+e.y,0)/t.length}),Cn=t=>{let n=0;for(let e=0;e<t.length;e++){let o=t[e],r=t[(e+1)%t.length];n+=o.x*r.y-r.x*o.y}return Math.abs(n)/2};function Sc(t){return t.height!==void 0||t.rake!==void 0||t.elevation!==void 0||t.surfaceKind!==void 0}function Ze(t){let n=new Map;for(let e of t){let o=n.get(e.rowId);o?o.push(e):n.set(e.rowId,[e])}return n}function $e(t,n){let e=!1;for(let o=0,r=n.length-1;o<n.length;r=o++){let a=n[o],i=n[r];a.y>t.y!=i.y>t.y&&t.x<(i.x-a.x)*(t.y-a.y)/(i.y-a.y)+a.x&&(e=!e)}return e}function qe(t,n){let e=n[0],o=1/0;for(let r=0;r<n.length;r++){let a=n[r],i=n[(r+1)%n.length],s=i.x-a.x,c=i.y-a.y,l=s*s+c*c,u=l>0?Math.max(0,Math.min(1,((t.x-a.x)*s+(t.y-a.y)*c)/l)):0,f={x:a.x+s*u,y:a.y+c*u},m=Math.hypot(t.x-f.x,t.y-f.y);m<o&&(o=m,e=f)}return e}function Kr(t,n){let e=0,o=0;for(let r of t.values()){if(r.length<3)continue;let a=r[0],i=r[r.length-1],s=i.x-a.x,c=i.y-a.y,l=Math.hypot(s,c);if(l<1e-6)continue;let u={x:(a.x+i.x)/2,y:(a.y+i.y)/2},f=qe(u,n),m=f.x-u.x,h=f.y-u.y,d=Math.hypot(m,h);d<1e-6||(o+=Math.abs((-c*m+s*h)/(l*d))*r.length,e+=r.length)}return e?o/e:0}function Pc(t,n,e){let o=t.filter(y=>y.type==="shape"),r=o.find(y=>y.role==="stage");if(r){let y=st(r);return y?{shape:r,centre:ze(y),outline:y,inferred:!1}:null}if(!e.length)return null;let a=1/0,i=-1/0,s=1/0,c=-1/0;for(let y of e)a=Math.min(a,y.x),i=Math.max(i,y.x),s=Math.min(s,y.y),c=Math.max(c,y.y);let l=(i-a)*(c-s),u=[];for(let y of o){if(y.role)continue;let x=st(y);if(!x)continue;let M=Cn(x);if(M*nt*nt<6||M>l)continue;let p=Math.min(...x.map(R=>R.x)),g=Math.max(...x.map(R=>R.x)),A=Math.min(...x.map(R=>R.y)),P=Math.max(...x.map(R=>R.y)),b=0;for(let R of e)R.x>p&&R.x<g&&R.y>A&&R.y<P&&$e(R,x)&&b++;if(b>e.length*.05)continue;let _=ze(x),S=Kr(n,x);S>=Za&&u.push({shape:y,centre:_,outline:x,score:S,area:M,box:[p,A,g,P]})}let f=(y,x)=>x!==y&&x.area>y.area&&y.box[0]>=x.box[0]-1e-6&&y.box[1]>=x.box[1]-1e-6&&y.box[2]<=x.box[2]+1e-6&&y.box[3]<=x.box[3]+1e-6,m=u.filter(y=>!u.some(x=>f(y,x))),h=Math.max(0,...m.map(y=>y.score)),d=m.filter(y=>y.score>=h-.03).sort((y,x)=>x.area-y.area)[0]??null;return d?{shape:d.shape,centre:d.centre,outline:d.outline,inferred:!0}:null}function Ac(t,n,e){if(!e||e.length<3)return Math.hypot(t.x-n.x,t.y-n.y);let o=qe(t,e);return Math.hypot(t.x-o.x,t.y-o.y)}function zr(t){return t.length<3?[...t].sort((n,e)=>n.x-e.x||n.y-e.y):pn(t)}function Ec(t){if(!t.length||t.length>bc)return[];let n=[...Ze(t).values()],e=n.map((s,c)=>c),o=s=>e[s]===s?s:e[s]=o(e[s]),r=xc/nt,a=n.map(s=>({minX:Math.min(...s.map(c=>c.x))-r,maxX:Math.max(...s.map(c=>c.x))+r,minY:Math.min(...s.map(c=>c.y))-r,maxY:Math.max(...s.map(c=>c.y))+r}));for(let s=0;s<n.length;s++)for(let c=s+1;c<n.length;c++){let l=a[s],u=a[c];if(l.maxX<u.minX||u.maxX<l.minX||l.maxY<u.minY||u.maxY<l.minY)continue;n[s].some(m=>n[c].some(h=>Math.hypot(m.x-h.x,m.y-h.y)<=r))&&(e[o(s)]=o(c))}let i=new Map;return n.forEach((s,c)=>{let l=o(c),u=i.get(l);u?u.push(...s):i.set(l,[...s])}),[...i.values()].filter(s=>new Set(s.map(c=>c.rowId)).size>=2)}function wc(t,n,e){if(!n.length)return null;let o=n.filter(S=>e.tableIds.has(S.rowId)||S.kind==="booth").length>n.length/2,r=Ze(n),a=!e.outline||Kr(r,e.outline)>=$a,i=0,s=0;for(let S of r.values()){if(S.length<2)continue;let R=S[0],B=S[S.length-1],C=B.x-R.x,O=B.y-R.y,k=Math.hypot(C,O);if(k<1e-6)continue;let E={x:(R.x+B.x)/2,y:(R.y+B.y)/2},w=a?e.outline?qe(E,e.outline):e.focal:e.middle,L=-O/k,D=C/k;L*(w.x-E.x)+D*(w.y-E.y)<0&&(L=-L,D=-D),i+=L*S.length,s+=D*S.length}let c={x:n.reduce((S,R)=>S+R.x,0)/n.length,y:n.reduce((S,R)=>S+R.y,0)/n.length};if(Math.hypot(i,s)<1e-9){let S=a?e.focal:e.middle;i=S.x-c.x,s=S.y-c.y}let l=Math.hypot(i,s)||1,u={x:i/l,y:s/l},f=S=>-(S.x*u.x+S.y*u.y),m=S=>-S.x*u.y+S.y*u.x,h=1/0,d=-1/0,y=1/0,x=-1/0,M=1/0,p=new Map;for(let S of n){let R=f(S),B=m(S);h=Math.min(h,R),d=Math.max(d,R),y=Math.min(y,B),x=Math.max(x,B),a&&(M=Math.min(M,Ac(S,e.focal,e.outline)));let C=S.logicalRowId??S.rowId,O=p.get(C);O?O.push(R):p.set(C,[R])}a||(M=Math.max(0,h-f(e.middle)));let g=[...p.values()].map(S=>Ye(S)).sort((S,R)=>S-R),A=[];if(!o)for(let S of g)A.length&&S-A[A.length-1]<Xa/nt||A.push(S);let P=Sc(t),b=yn(t,{floorBaseHeightM:e.baseHeightM}),_={id:t.id,section:t,authored:P,plane:e,facing:u,facesAction:a,hull:zr(n),sample:n.filter((S,R)=>R%Math.ceil(n.length/Qa)===0),frontD:h,backD:d,latMin:y,latMax:x,frontDistance:M,rowDepths:A,rowCount:A.length,level:0,height:b.height,rake:P?b.rake:0,backHeight:0};return _.backHeight=_.height+(d-h)*nt*Math.tan(_.rake*Math.PI/180),_}function Bc(t,n,e,o){if(t.length<2)return 0;let r=Math.max(1,n*nt),a=e+Na-o,i=0,s=0;for(let l=1;l<t.length;l++){let u=Math.max(ja,(t[l]-t[l-1])*nt),f=(a+Da)*(r+u)/r;i+=f-a,s+=u,a=f,r+=u}let c=Math.atan(i/s)*180/Math.PI;return Math.round(Math.max(jr,Math.min(va,c))*10)/10}function Oc(t,n,e=!1){if(!e&&t.facing.x*n.facing.x+t.facing.y*n.facing.y<Ja)return null;let o=-1/0,r=1/0,a=-1/0;for(let m of n.hull){o=Math.max(o,-(m.x*t.facing.x+m.y*t.facing.y));let h=-m.x*t.facing.y+m.y*t.facing.x;r=Math.min(r,h),a=Math.max(a,h)}if(Math.min(t.latMax,a)-Math.max(t.latMin,r)<(e?1e-6:Wr*(t.latMax-t.latMin)))return null;let s=Vr/nt,c=new Map,l=new Map;for(let m of t.sample){let h=Math.floor((-m.x*t.facing.y+m.y*t.facing.x)/s),d=-(m.x*t.facing.x+m.y*t.facing.y);c.set(h,Math.min(c.get(h)??1/0,d))}for(let m of n.sample){let h=Math.floor((-m.x*t.facing.y+m.y*t.facing.x)/s),d=-(m.x*t.facing.x+m.y*t.facing.y);l.set(h,Math.max(l.get(h)??-1/0,d))}let u=[];for(let[m,h]of c){let d=l.get(m);d!==void 0&&u.push(h-d)}let f=u.length?Ye(u):t.frontD-o;return f<-1/nt?null:f}function Tc(t,n){if(n.plane.floorIndex>=t.plane.floorIndex)return!1;let e=-1/0,o=1/0,r=1/0,a=-1/0;for(let c of n.hull){let l=-(c.x*t.facing.x+c.y*t.facing.y);e=Math.max(e,l),o=Math.min(o,l);let u=-c.x*t.facing.y+c.y*t.facing.x;r=Math.min(r,u),a=Math.max(a,u)}let i=Math.min(t.latMax,a)-Math.max(t.latMin,r),s=Math.min(t.backD,e)-Math.max(t.frontD,o);return i>Wr*(t.latMax-t.latMin)&&s>1/nt}function kc(t,n){let e=new Set;for(let o of t){let r=(Math.atan2(o.y-n.y,o.x-n.x)*180/Math.PI+360)%360;e.add(Math.floor(r/10))}return e.size/36}function Cc(t,n){let e=1/0,o=-1/0;for(let a of n.hull){let i=-(a.x*t.facing.x+a.y*t.facing.y);e=Math.min(e,i),o=Math.max(o,i)}let r=Math.max(0,Math.min(o-e,t.frontD-e));return n.height+r*nt*Math.tan(n.rake*Math.PI/180)}function Lc(t,n){if(!t.facesAction)return!1;let e={x:-t.facing.y,y:t.facing.x},o=Vr/nt,r=Math.max(1,Math.ceil((t.backD-t.frontD)/o)),a={left:new Map,right:new Map};for(let s of n)if(!(s===t||s.plane.floorIndex!==t.plane.floorIndex)&&!(s.facing.x*t.facing.x+s.facing.y*t.facing.y>=sc))for(let c of s.sample){let l=-(c.x*t.facing.x+c.y*t.facing.y);if(l<t.frontD||l>t.backD)continue;let u=-c.x*t.facing.y+c.y*t.facing.x,f=u<t.latMin?"left":u>t.latMax?"right":null;if(!f)return!1;let m=Math.min(r-1,Math.floor((l-t.frontD)/o)),h=f==="left"?t.latMin-u:u-t.latMax;h<(a[f].get(m)?.gap??1/0)&&a[f].set(m,{gap:h,other:s})}let i=s=>{let c=s==="left"?t.latMin:t.latMax,l=0;for(let[u,{other:f}]of a[s]){if((f.facing.x*e.x+f.facing.y*e.y)*(s==="left"?1:-1)<rc)continue;let h=t.frontD+(u+.5)*o,d={x:-h*t.facing.x+c*e.x,y:-h*t.facing.y+c*e.y},y=-(d.x*f.facing.x+d.y*f.facing.y),x=-d.x*f.facing.y+d.y*f.facing.x;y<f.frontD&&x>=f.latMin&&x<=f.latMax&&l++}return l/r>=ic};return i("left")&&i("right")}function Fc(t,n){if(n.plane.floorIndex!==t.plane.floorIndex||n.facing.x*t.facing.x+n.facing.y*t.facing.y<fc)return!1;let e=1/0,o=-1/0,r=1/0;for(let s of n.hull){let c=-s.x*t.facing.y+s.y*t.facing.x;e=Math.min(e,c),o=Math.max(o,c),r=Math.min(r,-(s.x*t.facing.x+s.y*t.facing.y))}let a=(t.frontD-r)*nt;if(a<-mc||a>hc)return!1;let i=Math.max(e-t.latMax,t.latMin-o);return i*nt<=yc&&i*nt>=-dc}function Gc(t,n=!1,e=!1,o){let r=n?Ya:za,a=new Set(e?[]:t.filter(y=>!y.authored&&Lc(y,t))),i=[...t].sort((y,x)=>y.plane.floorIndex-x.plane.floorIndex||Number(a.has(x))-Number(a.has(y))||y.frontDistance-x.frontDistance);for(let y of a)o?.add(y.id);let s=(y,x,M)=>{let p=new Map,g=[],A=new Map,P=b=>{if(b.plane.floorIndex===0||b.plane.baseHeightM>0)return b.plane.baseHeightM;let _=A.get(b.plane.floorIndex-1);return _===void 0?b.plane.baseHeightM:_+er};for(let b of i){if(a.has(b))b.height=P(b),b.level=0,b.rake=0,b.backHeight=b.height,p.set(b.id,void 0);else if(!b.authored){let S=P(b),R;for(let E of g){if(E.plane.floorIndex>b.plane.floorIndex)continue;if(Tc(b,E)){let T=Cc(b,E)+tc;T>S&&(S=T,R=E);continue}let w=Oc(b,E,a.has(E));if(w==null)continue;let L=e&&!!b.plane.stageDeck&&E.level===0&&E.plane.floorIndex===b.plane.floorIndex&&Math.max(0,w)*nt<=ec,D=a.has(E)?E.height+ac:L?E.backHeight:E.backHeight+Ha+Math.min(Ua,Math.max(0,w)*nt)*Math.tan(E.rake*Math.PI/180);D>S&&(S=D,R=E)}let B=y.get(b);B&&B.height>S+.01?(S=B.height,R=void 0):B=void 0,b.height=Math.round(Math.min(S,b.plane.baseHeightM+Ka)*100)/100;let C=!R&&!B&&b.height>b.plane.baseHeightM;if(b.level=R?R.level+1:B?B.level:C?1:0,b.rake=Bc(b.rowDepths,b.frontDistance,b.height,b.plane.focalHeightM),!b.facesAction&&b.rowCount<qa)b.rake=0;else if(b.level===0){let E=Math.max(1e-6,(b.backD-b.frontD)*nt);b.rake=Math.min(b.rake,Wa,Math.round(Math.atan(Va/E)*1800/Math.PI)/10)}else b.rowCount>=2&&(b.rake=Math.max(b.rake,r[Math.min(b.level,r.length)-1]));let O=(b.backD-b.frontD)*nt,k=R&&a.has(R)||B&&M?.has(B.id);if(x!==void 0&&k&&b.rowCount>=2&&(b.rake=x),n&&O>0&&b.height+O*Math.tan(b.rake*Math.PI/180)>b.plane.baseHeightM+Hr){let E=Math.max(0,b.plane.baseHeightM+Hr-b.height);b.rake=Math.max(jr,Math.round(Math.atan(E/O)*1800/Math.PI)/10)}e&&b.plane.stageDeck&&b.level>0&&(b.rake=Math.min(b.rake,oc)),b.backHeight=b.height+O*Math.tan(b.rake*Math.PI/180),p.set(b.id,R?.id??(B?p.get(B.id):void 0))}let _=b.plane.floorIndex;A.set(_,Math.min(A.get(_)??1/0,b.height)),g.push(b)}return p},c=s(new Map),l=new Map,u=y=>l.get(y)?.height??y.height;for(let y=!0,x=0;y&&x<t.length;x++){y=!1;for(let M of t)if(!(M.authored||a.has(M)))for(let p of t){let g=l.get(p)??p;p===M||g.height-g.plane.baseHeightM<pc||g.height<=u(M)+.01||Fc(M,p)&&(l.set(M,g),y=!0)}}let f=new Map(t.map(y=>[y.id,y])),m=t.filter(y=>!y.authored&&y.rowCount>=2&&a.has(f.get(c.get(y.id)??""))),h=m.length?Ye(m.map(y=>y.rake)):void 0;if(!l.size&&h===void 0)return c;let d=new Map([...new Set(l.values())].map(y=>[y,{...y}]));return s(new Map([...l].map(([y,x])=>[y,d.get(x)])),h,new Set(m.map(y=>y.id)))}var Ke=(t,n)=>!!t&&t.x===n.x&&t.y===n.y;function Yr(t,n={x:0,y:-40}){let e=Qn(t),o=new Map;for(let M of e){if(!M.sectionId)continue;let p=o.get(M.sectionId);p?p.push(M):o.set(M.sectionId,[M])}let r={focalInferred:!1,confident:!1,sections:[]},a=t.floors?.length?t.floors.map((M,p)=>({objects:M.objects,floorIndex:p,floorId:M.id,baseHeightM:M.baseHeightM??0,focal:M.focalPoint??t.focalPoint})):[{objects:t.objects,floorIndex:0,floorId:void 0,baseHeightM:0,focal:t.focalPoint}],i=new Set(a.flatMap(M=>M.objects.filter(p=>p.type==="table").map(p=>p.id))),s=[],c,l=new Set,u=a.map(M=>{let p=k=>!t.floors?.length||k.floorId===M.floorId,g=Ec(e.filter(k=>!k.sectionId&&k.kind!=="booth"&&!i.has(k.rowId)&&p(k))),A=[];for(let k of g){let E=Wt(jt(zr(k)),gc/nt);if(e.some(L=>!p(L)&&$e(L,E)))continue;let w=`${Ur}${M.floorIndex}-${A.length}`;l.add(w),o.set(w,k),A.push({type:"section",id:w,label:"",color:Mc,outline:E})}let P=A.length?{...M,objects:[...M.objects,...A]}:M,b=new Set(P.objects.filter(k=>k.type==="section").map(k=>k.logicalSectionId??k.id)),_=[...o.entries()].filter(([k])=>b.has(k)).flatMap(([,k])=>k),S=Pc(P.objects,Ze(_),_),R=P.focal;(S||P.focal&&!Ke(P.focal,n))&&(r.confident=!0),S&&(r.stage??={id:S.shape.id,inferred:S.inferred,...P.floorId?{floorId:P.floorId}:{}},(S.inferred||Ke(P.focal,n))&&(R=S.centre,r.focalInferred=!0));let B=S&&(!S.inferred||Cn(S.outline)*nt*nt<=Ve),C=S?void 0:c,O={tableIds:i,floorIndex:P.floorIndex,floorId:P.floorId,baseHeightM:P.baseHeightM,focal:C?.focal??R,outline:S?.outline??C?.outline,focalHeightM:C?.focalHeightM??P.baseHeightM+(S&&B?Dt({...S.shape,role:"stage"}).heightM:0),stageDeck:C?.stageDeck??!!(S&&B&&Cn(S.outline)*nt*nt<=Ve),middle:_.length?{x:_.reduce((k,E)=>k+E.x,0)/_.length,y:_.reduce((k,E)=>k+E.y,0)/_.length}:R};for(let k of P.objects){if(k.type!=="section")continue;let E=wc(k,o.get(k.logicalSectionId??k.id)??[],O);E&&s.push(E)}return O.outline&&(c=O),Ke(P.focal,O.focal)||(r.focal??=[]).push({...P.floorId?{floorId:P.floorId}:{},point:{...O.focal}}),{unit:P,plane:O,stage:S,planeSeats:_}}),f=a.flatMap(M=>M.objects).map(M=>M.type==="shape"&&!M.role&&(We(M.label)==="wall"||!We(M.label)&&vr(M))?{...M,role:"wall"}:M),m=qt({objects:f},e)!==null;m&&(r.indoor=!0);let h=new Set,d=Gc(s,m,kc(e,u[0]?.plane.focal??n)<nc,h),y=new Map(s.filter(M=>!M.authored).map(M=>[M.id,M])),x=u.map(({unit:M,plane:p,stage:g,planeSeats:A})=>M.objects.map(P=>{let b=P.type==="shape"&&!P.role&&P.id!==g?.shape.id?We(P.label):null;if(P.type==="shape"&&!P.role&&P.id!==g?.shape.id&&(b==="wall"||!b&&vr(P))&&P.type==="shape"){(r.roles??=[]).push({id:P.id,...p.floorId?{floorId:p.floorId}:{},role:"wall"});let{fill:E,...w}=P;return{...w,role:"wall"}}if(b&&P.type==="shape")return(r.roles??=[]).push({id:P.id,...p.floorId?{floorId:p.floorId}:{},role:b}),{...P,role:b};let S=g?.inferred&&P.id===g.shape.id&&P.type==="shape"?_c(P,g.outline,M.objects,A):null;if(S&&P.type==="shape")return r.stage?.id===P.id&&(r.stage.field=S),{...P,role:"stage",stageKind:S};let R=P.type==="shape"&&P.id===g?.shape.id&&P.heightM===void 0&&!P.stageKind&&s.some(E=>E.plane===p&&(h.has(E.id)||E.level===0&&E.facesAction&&E.rake<=lc&&(E.frontDistance+E.backD-E.frontD)*nt>=uc)),B=R?{heightM:cc}:{};if(g?.inferred&&P.id===g.shape.id&&P.type==="shape"&&Cn(g.outline)*nt*nt<=Ve)return r.stage?.id===P.id&&(r.stage.deck=!0),{...P,role:"stage",...B};if(R&&P.type==="shape"&&P.role==="stage")return{...P,...B};let C=P.type==="section"?y.get(P.id):void 0;if(!C||P.type!=="section")return P;let O=C.rowCount>=2&&C.rake>0;l.has(C.id)?r.looseRowBlocks=(r.looseRowBlocks??0)+1:r.sections.push({id:C.id,floorId:p.floorId,surfaceKind:O?"rakedRows":"flat",height:C.height,rake:C.rake,stackedOn:d.get(C.id)});let k={status:"inferred",source:"public-2d-topology",note:Ic};return{...P,height:C.height,rake:C.rake,surfaceKind:O?"rakedRows":"flat",physical3dProvenance:{height:k,rake:k,surfaceKind:k}}}));if(t.floors?.length){let M=t.floors.map((p,g)=>({...p,objects:x[g],focalPoint:u[g].plane.focal}));return{doc:{...t,floors:M,objects:M[0].objects,focalPoint:M[0].focalPoint},report:r}}return{doc:{...t,objects:x[0],focalPoint:u[0].plane.focal},report:r}}function Th(t,n,e){return e<0?n>1?t.filter(o=>o.kind==="floor"):[...t]:t.filter(o=>o.floorIndex===void 0||o.floorIndex===e)}function kh(t,n){let e=[...t].sort((r,a)=>r.screen.y-a.screen.y),o=[];for(let r of e){let a=o.find(i=>i.some(s=>Math.abs(s.screen.x-r.screen.x)<104&&Math.abs(s.screen.y-r.screen.y)<34));a?a.push(r):o.push([r])}return o.flatMap(r=>r.length<2?r:r.map((a,i)=>({...a,screen:{...a.screen,x:Math.max(54,Math.min(n-54,a.screen.x+(i-(r.length-1)/2)*104))}})))}var Nc=1.15,Dc=2.75,vc=4.5,Hc=.85,Uc=.5,Xc=.26;function Ch(t,n,e){let o=Math.max(1e-6,n),r=t/o,a=e?.hasZoneLabels??!0,i=new Set(["stage","gate"]);return r>=.75&&i.add("floor"),r>=Nc&&i.add("zone"),r<=(a?Dc:vc)&&(i.add("section"),i.add("ga")),r<=Hc&&(i.add("annotation"),i.add("booth")),r<=Uc&&i.add("row"),r<=Xc&&i.add("seat"),i}function Lh(t,n,e,o,r,a=6){let i=a+n,s=o-a-n,c=a+e,l=r-a-e;return{...t,x:i>s?o/2:Math.max(i,Math.min(s,t.x)),y:c>l?r/2:Math.max(c,Math.min(l,t.y))}}function Fh(t,n,e,o){let r=t,a=n[0],i=n[1],s=n[2],c=r[0]*a+r[4]*i+r[8]*s+r[12],l=r[1]*a+r[5]*i+r[9]*s+r[13],u=r[2]*a+r[6]*i+r[10]*s+r[14],f=r[3]*a+r[7]*i+r[11]*s+r[15];if(!(f>1e-6))return{x:0,y:0,depth:1/0,visible:!1};let m=c/f,h=l/f,d=u/f,y=m>=-1.05&&m<=1.05&&h>=-1.05&&h<=1.05&&d<=1;return{x:(m*.5+.5)*e,y:(1-(h*.5+.5))*o,depth:d,visible:y}}function Gh(t,n,e=n,o=()=>0){let r=[],a=[...t].sort((i,s)=>o(s)-o(i)||i.screen.depth-s.screen.depth);for(let i of a){let s=!1;for(let c of r)if(Je(i,c,n,e)){s=!0;break}s||r.push(i)}return r}var jc=6;function Je(t,n,e,o){let r=Math.abs(t.screen.x-n.screen.x),a=Math.abs(t.screen.y-n.screen.y),i=t.halfWidth!=null&&n.halfWidth!=null?Math.max(e,t.halfWidth+n.halfWidth+jc):e;return r<i&&a<o}function Nh(t,n,e){return t.length*n*.58+(e?14:0)}var Wc={row:8,seat:14};function Dh(t){return t<480?{row:5,seat:8}:t<768?{row:6,seat:10}:Wc}function vh(t,n,e,o){let r=Math.max(1,Math.min(e,o)*.5),a=Math.min(2,Math.hypot(t.x-e/2,t.y-o/2)/r);return n*(1+1.5*a)}function Hh(t,n,e,o,r=[]){let a=[...t].sort((s,c)=>(c.priority??0)-(s.priority??0)||s.focus-c.focus),i=[];for(let s of a){if(i.length>=o)break;let c=!1;for(let l of r)if(Je(s,l,n,e)){c=!0;break}if(!c){for(let l of i)if(Je(s,l,n,e)){c=!0;break}}c||i.push(s)}return i}function Uh(t,n,e,o){let r=t[3]*n[0]+t[7]*n[1]+t[11]*n[2]+t[15];return r<=0||!(e>0)?0:e*Math.hypot(t[0],t[4],t[8])*o/(2*r)}function Mn(t,n,e){if(t.length!==4||e<=n)return null;let o=Tt(t),r=Math.hypot(o[1].x-o[0].x,o[1].y-o[0].y)*I,a=Math.hypot(o[3].x-o[0].x,o[3].y-o[0].y)*I;if(r<1e-6||a<1e-6)return null;let i=Math.min(.22/r,.16),s=Math.min(.28,(e-n)*.13),c=Math.min(.065/a,.2);return{quad:o,side:i,face:c,opening:Pt(o,i,1-i),openingTop:e-s}}function Qe(t,n,e){if(t.length!==4||e-n<=.2)return null;let o=Tt(t),r=Math.hypot(o[1].x-o[0].x,o[1].y-o[0].y)*I;if(r<=1e-6)return null;let a=Math.min(.14,(e-n)*.08,r*.08),i=a/r,s=Pt(o,i,1-i);return{quad:o,side:i,trim:a,inner:s,panel:Tn(s,.15,.85),bottom:n+a,top:e-a}}function Zr(t,n,e,o){let r=Qe(t,n,e);if(!r)return;let{panel:a}=r,i=(p,g)=>({x:(p.x+g.x)/2,y:(p.y+g.y)/2}),s=i(a[0],a[1]),c=i(a[3],a[2]),l=Math.hypot(s.x-o.x,s.y-o.y)<=Math.hypot(c.x-o.x,c.y-o.y),[u,f]=l?[a[0],a[1]]:[a[3],a[2]],m=l?{x:s.x-c.x,y:s.y-c.y}:{x:c.x-s.x,y:c.y-s.y},h=Math.hypot(m.x,m.y);if(h<1e-6)return;-(f.y-u.y)*m.x+(f.x-u.x)*m.y<0&&([u,f]=[f,u]);let d=Math.min(.006,h*I*.05),y=m.x/h*d,x=m.y/h*d,M=(p,g)=>[p.x*I+y,g,p.y*I+x];return[M(u,r.bottom),M(f,r.bottom),M(u,r.top),M(f,r.top)]}import Kc from"polygon-clipping";import Vc from"polygon-clipping";function Yt(t,n,e,o,r,a,i,s={}){let c=zt(n),l=s.ao??K,u=r.flatMap(y=>{if(y.role!=="entrance"&&y.role!=="exit")return[];let x=st(y);if(!x||x.length!==4||!dn(c,zt(x)))return[];let M=s.portalBase??e,p=Mn(x,M,M+Dt(y).heightM);if(!p)return[];let g=Math.min(o,p.openingTop);return g<=e?[]:[{poly:p.opening,height:g}]});if(!u.length)return!1;let f=y=>y.map(x=>[x.x,x.y]),m=[f(n),...(s.holes??[]).map(f)],h=[e,...new Set(u.map(y=>y.height)),o].sort((y,x)=>y-x),d=[];try{for(let y=1;y<h.length;y++){let x=h[y-1],M=h[y];if(M-x<1e-6)continue;let p=u.filter(A=>A.height>x+1e-6).map(A=>[f(A.poly)]),g=p.length?Vc.difference(m,...p):[m];d.push({low:x,high:M,polys:g})}}catch{return!1}for(let y of d)for(let x of y.polys){let[M,...p]=x.map(A=>A.map(([P,b])=>({x:P,y:b}))),g=A=>l.wallBottom+(l.top-l.wallBottom)*(A-e)/(o-e);Z(t,M,p,()=>y.high,y.low,a,i,{...l,top:g(y.high),wallBottom:g(y.low)})}return!0}var to={depthM:1.6,thicknessM:.35,minWallM:6};function he(t,n,e,o,r,a,i,s,c){let l=o-e;if(l<=0)return;let u=s&&(c??l)>=to.minWallM?zc(n,s):null,f=u?o-to.thicknessM:o,m=f-e,h=m<1.5?[[e,f,1]]:u?[[e,e+Math.min(.9,m*.18),.82],[e+Math.min(.9,m*.18),f,1]]:[[e,e+Math.min(.9,m*.18),.82],[e+Math.min(.9,m*.18),f-.1,1],[f-.1,f,1.1]],d=y=>K.wallBottom+(K.top-K.wallBottom)*(y-e)/l;for(let[y,x,M]of h){let p={...K,top:d(x),wallBottom:d(y)},g=z(a,M),A=z(i,M);Yt(t,n,y,x,r,g,A,{portalBase:e,ao:p})||Z(t,n,void 0,()=>x,y,g,A,p)}for(let[y,...x]of u??[])Z(t,y,x.length?x:void 0,()=>o,f,z(a,1.12),z(i,.78),K)}function zc(t,n){let e=to.depthM/I,o=t.map(i=>{let s=n.x-i.x,c=n.y-i.y,l=Math.hypot(s,c)||1;return{x:i.x+s/l*e,y:i.y+c/l*e}}),r=i=>{let s=i.map(c=>[c.x,c.y]);return s.push(s[0]),s},a=[[r(t)],[r(o)]];for(let i=0;i<t.length;i++){let s=(i+1)%t.length;a.push([r([t[i],t[s],o[s],o[i]])])}try{let[i,...s]=a,c=Kc.union(i,...s);return c.length?c.map(l=>l.map(u=>u.slice(0,-1).map(([f,m])=>({x:f,y:m})))):null}catch{return null}}function Ln(t,n,e){let o=lt(n.stroke?.color),r=n.stroke?.width??0;if(!o||!Number.isFinite(r)||r<=0)return;let a=n.kind==="line"||n.kind==="polyline",i=a?bn(n.points??[],n.rotation):st(n);if(!i||i.length<2)return;let s=r*.5,c=$o(n)?Jo(i,...qo(r)):Array.from({length:a?i.length-1:i.length},(l,u)=>[i[u],i[(u+1)%i.length]]);for(let[l,u]of c){let f=Math.hypot(u.x-l.x,u.y-l.y);if(f<1e-6)continue;let m=-(u.y-l.y)/f*s,h=(u.x-l.x)/f*s,d=[(l.x+m)*I,e,(l.y+h)*I],y=[(u.x+m)*I,e,(u.y+h)*I],x=[(u.x-m)*I,e,(u.y-h)*I],M=[(l.x-m)*I,e,(l.y-h)*I];t.tri(d,y,x,[0,1,0],o),t.tri(d,x,M,[0,1,0],o)}}function $r(t){return t==="bar"||t==="concession"||t==="coat"||t==="restroom"}var Rn=(t,n,e)=>({x:t.x+(n.x-t.x)*e,y:t.y+(n.y-t.y)*e});function ye(t,n,e,o){let[r,a,i,s]=n?t:[t[3],t[2],t[1],t[0]];return[Rn(r,s,e),Rn(a,i,e),Rn(a,i,o),Rn(r,s,o)]}function qr(t,n,e,o,r,a,i,s,c=!1){if(e.length!==4||r-o<.4)return!1;let l=S=>c?Math.min(S,r):S,u=Tt(e),f=Math.hypot(u[3].x-u[0].x,u[3].y-u[0].y)*I;if(f<.4)return!1;let m=Rn(u[0],u[1],.5),h=Rn(u[3],u[2],.5),d=Math.hypot(m.x-s.x,m.y-s.y)<=Math.hypot(h.x-s.x,h.y-s.y),y=ct(i,[.92,.9,.86],.35),x=z(a,.72),M=r-o;if(n==="restroom"){let S=Math.min(.18,M*.08);return ut(t,u,r-S,o,i,a),ut(t,u,r,r-S,y,y),!0}let p=o+Math.min(1.1,M),g=n==="coat"?1:Math.min(.5,.75/f),A=ye(u,d,0,g);if(ut(t,A,p-.05,o,x,a),ut(t,A,p,p-.05,y,y),n==="coat"||f<1.2)return!0;if(n==="bar"){let S=ye(u,d,Math.max(g+.2,1-.45/f),1),R=l(o+Math.max(Math.min(2.2,M*2),p-o+.6));return ut(t,S,R,o,i,x),!0}let P=ye(u,d,Math.max(g+.25,.55),1),b=l(o+Math.max(2.6,p-o+1.4));if(b-.14<=p)return!0;ut(t,P,b-.14,o,i,a),ut(t,u,b,b-.14,y,x);let _=Math.min(.08,.1/Math.max(.1,Math.hypot(u[1].x-u[0].x,u[1].y-u[0].y)*I));for(let[S,R]of[[0,_],[1-_,1]])ut(t,ye(Pt(u,S,R),d,0,Math.min(.08,.1/f)),b-.14,p,x,x);return!0}var Jt=.06,Yc=.05,Qr=.05,Jr=.15,no=25;function ti(t,n,e){let o=new Map,r=new Array(n.length).fill(null),a=new Float64Array(n.length),i=new Array(n.length).fill(void 0),s=new Array(n.length).fill(void 0),c=new Map,l=[],u=new Set;for(let m=0;m<t.length;m+=1){let h=t[m];for(let d of h.objects){if(d.type==="table"&&u.add(d.id),d.type!=="section"||!d.outline||d.outline.length<3)continue;let y=Wt(d.outline,Gt);c.set(d.id,{section:d,unit:h,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),l.push({id:d.id,floorIndex:m,box:zt(y),section:d,unit:h,outline:y})}}let f=new Map;for(let m of l){let h=f.get(m.floorIndex);h?h.push(m):f.set(m.floorIndex,[m])}for(let m=0;m<n.length;m++){let h=n[m],d=e?f.get(e[m])??[]:l,y=h.sectionId?d.find(M=>M.id===h.sectionId)??d.find(M=>M.section.logicalSectionId===h.sectionId&&Lt({x:h.x,y:h.y},M.outline,M.section.holes)):void 0,x=y?[y]:d;for(let M of x){if(e&&M.floorIndex!==e[m]||!y&&(h.x<M.box.minX||h.x>M.box.maxX||h.y<M.box.minY||h.y>M.box.maxY||!Lt({x:h.x,y:h.y},M.outline,M.section.holes)))continue;r[m]=M.id;let p=c.get(M.id);p.hasSeats=!0;let g=h.focalPoint??M.unit.focal,A=Math.hypot(h.x-g.x,h.y-g.y);A<p.frontU&&(p.frontU=A),p.seatIndices.push(m);let P=h.rowId||`__seat-${m}`,b=p.rows.get(P);b?b.push({x:h.x,y:h.y}):p.rows.set(P,[{x:h.x,y:h.y}]);break}}for(let[m,h]of c){let d=yn(h.section,{floorBaseHeightM:h.unit.baseHeightM}),y=h.unit.baseHeightM,x=d.rake>0?Math.tan(d.rake*Math.PI/180):0,M=d.rake<=.01&&d.height<=y+.001,p=h.section.surfaceKind,g=p==="flat"?!0:p==="rakedRows"&&d.rake>.01?!1:M,A=h.hasSeats?vo(m,n,h.seatIndices,h.unit.focal):{sectionId:m,rows:[],blockCount:0},b=A.rows.length<2?Qo([...h.rows.values()].map(T=>({points:T})),h.unit.focal):null,_=1/0;if(b){if(h.hasSeats)for(let T of h.rows.values())for(let N of T){let U=b.depthAt(N.x,N.y);U<_&&(_=U)}if(!h.hasSeats||!Number.isFinite(_)){_=1/0;for(let T of h.section.outline){let N=b.depthAt(T.x,T.y);N<_&&(_=N)}}}let S=y+Yc,R=Math.max(S,d.height),B=T=>{let N=Math.max(0,T-_)*nt,U=Math.min(N*x,no);return Math.max(S,d.height+U)},C=T=>{let N=Math.max(0,T)*nt,U=Math.min(N*x,no);return Math.max(S,d.height+U)},O=g?[]:A.rows.map(T=>({pts:T.pts,y:C(T.blockDepth),depth:T.blockDepth,blockId:T.blockId,...u.has(T.id)?{patch:Ir(T.pts,Gt)}:{}})),k=O.length?O[0].y:R,E=O.map(T=>{let N=T.patch&&T.patch.length>=3?T.patch:T.pts,U=0,j=0;for(let X of N)U+=X.x,j+=X.y;let G=N.length||1;U/=G,j/=G;let v=0;for(let X of N){let V=Math.hypot(X.x-U,X.y-j);V>v&&(v=V)}return{cx:U,cy:j,rad:v}}),w=g?()=>R:O.length>=2?(T,N)=>{let U=1/0,j=k;for(let G=0;G<O.length;G++){let v=E[G];if(Math.hypot(T-v.cx,N-v.cy)-v.rad>=U)continue;let X=O[G].patch,V=X&&X.length>=3?Mt(X,T,N)?0:Jn(X,T,N):Jn(O[G].pts,T,N);V<U&&(U=V,j=O[G].y)}return j}:(T,N)=>b?B(b.depthAt(T,N)):R,L=[0,1,0],D=O.length>=2||g?()=>L:(T,N)=>{if(!b)return L;let U=b.depthAt(T,N);if(U<=_)return L;let j=(U-_)*nt;if(j*x>=no||d.height+j*x<=S)return L;let[G,v]=b.gradientAt(T,N);if(G===0&&v===0)return L;let X=1/Math.hypot(x,1);return[-G*x*X,X,-v*x*X]};if(!g)for(let T of A.rows){let N=C(T.blockDepth);for(let U of T.seatIndices)i[U]=N}for(let T of A.rows){let N=[];for(let X=1;X<T.pts.length;X++){let V=Math.hypot(T.pts[X].x-T.pts[X-1].x,T.pts[X].y-T.pts[X-1].y);V>1e-6&&N.push(V)}N.sort((X,V)=>X-V);let U=N.length?N[Math.floor(N.length/2)]:1/0,j=1/0,G=T.pts[Math.floor(T.pts.length/2)];if(G)for(let X of A.rows){if(X===T||X.blockId!==T.blockId)continue;let V=Jn(X.pts,G.x,G.y);V>1e-6&&V<j&&(j=V)}let v=Math.min(U,Math.max(j,U*.5));if(Number.isFinite(v)&&v>0)for(let X of T.seatIndices)s[X]=v}o.set(m,{sectionId:m,deckAt:w,normalAt:D,flat:g,bottomY:y,rowLevels:O,landingY:k})}for(let m=0;m<n.length;m++){let h=r[m],d=n[m];if(h){let M=i[m];a[m]=(M??o.get(h).deckAt(d.x,d.y))+Jr;continue}let y=d.eyeHeightM,x=Number.isFinite(y)?Math.max(0,y-qn):0;a[m]=d.kind==="booth"?x+Jt+Jr:x}return{bySection:o,seatOwner:r,seatDeckY:m=>a[m],seatPitchU:m=>s[m]}}var ii=10,ln=11,_n=[.93,.94,.95],Zc=[.93,.8,.22],$c=[.82,.14,.16],qc=[.78,.1,.12],eo=[.74,.77,.8],oo={width:7.32,height:2.44,depth:2},de={width:1.83,height:1.22,depth:1,fromEndBoards:3.35},Jc=1.5,Qc=1.8,ro=2.4,At=(t,n)=>[t[0]-n[0],t[1]-n[1],t[2]-n[2]],Gn=(t,n)=>[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]],Zt=t=>{let n=Math.hypot(t[0],t[1],t[2])||1;return[t[0]/n,t[1]/n,t[2]/n]};function Nt(t,n,e,o,r){let a=Zt(At(e,n)),i=Zt(Gn(a,Math.abs(a[1])<.9?[0,1,0]:[1,0,0])),s=Gn(i,a),c=(l,u)=>{let f=u===0||u===3?-o:o,m=u<2?-o:o;return[l[0]+i[0]*f+s[0]*m,l[1]+i[1]*f+s[1]*m,l[2]+i[2]*f+s[2]*m]};for(let l=0;l<4;l++){let u=(l+1)%4,f=c(n,l),m=c(n,u),h=c(e,l),d=c(e,u),y=Zt(Gn(At(m,f),At(h,f))),x=At([(f[0]+m[0])/2,(f[1]+m[1])/2,(f[2]+m[2])/2],n);y[0]*x[0]+y[1]*x[1]+y[2]*x[2]<0&&(y=[-y[0],-y[1],-y[2]]);let M=z(r,.86+.14*Math.max(0,y[1]));t.tri(f,m,d,y,M),t.tri(f,d,h,y,M)}}function Fn(t,n,e,o,r){let a=Math.hypot(...At(e,n)),i=Math.hypot(...At(r,n)),s=Zt(Gn(At(e,n),At(r,n)));t.tri(n,e,o,s,[0,0,0],[a,0,0],[a,i,0]),t.tri(n,o,r,s,[0,0,0],[a,i,0],[0,i,0])}function so(t,n,e,o,r,a,i,s,c){let l=(p,g)=>[p[0],p[1]+g,p[2]],u=p=>[p[0]+o[0]*a,p[1],p[2]+o[2]*a],f=l(n,r),m=l(e,r),h=u(n),d=u(e),y=u(f),x=u(m);t.setMaterial(c),Nt(t,n,f,i,s),Nt(t,e,m,i,s),Nt(t,f,m,i,s),t.setMaterial(ln);let M=Math.min(i,.03);for(let[p,g]of[[h,y],[d,x],[f,y],[m,x],[y,x],[n,h],[e,d],[h,d]])Nt(t,p,g,M,z(s,.92));t.setMaterial(ii),Fn(t,h,d,x,y),Fn(t,f,m,x,y),Fn(t,n,h,y,f),Fn(t,e,d,x,m),t.setMaterial(0)}var io={height:.711,width:.2286,pitchLength:20.12},tl=[.88,.8,.6];function si(t,n,e){if(n.length!==4)return;let o=i=>Math.hypot(n[(i+1)%4].x-n[i].x,n[(i+1)%4].y-n[i].y),r=o(0)<=o(1)?0:1,a=Math.max(o(0),o(1))*I/io.pitchLength;if(a>.2){t.setMaterial(ln);for(let i of[r,r+2]){let s=n[i%4],c=n[(i+1)%4],l=o(i%4)||1,u={x:(s.x+c.x)/2,y:(s.y+c.y)/2},f=(c.x-s.x)/l,m=(c.y-s.y)/l;for(let h of[-1,0,1]){let d=h*io.width*a/2/I,y=pt({x:u.x+f*d,y:u.y+m*d},e);Nt(t,y,[y[0],y[1]+io.height*a,y[2]],.019*a,tl)}}t.setMaterial(0)}}var pt=(t,n)=>[t.x*I,n,t.y*I];function ai(t){if(t.length<3)return null;let n=0,e=0;for(let M of t)n+=M.x,e+=M.y;n/=t.length,e/=t.length;let o=0,r=0,a=0;for(let M of t){let p=M.x-n,g=M.y-e;o+=p*p,r+=g*g,a+=p*g}let i=.5*Math.atan2(2*a,o-r),s=Math.cos(i),c=Math.sin(i),l=1/0,u=-1/0,f=1/0,m=-1/0;for(let M of t){let p=(M.x-n)*s+(M.y-e)*c,g=-(M.x-n)*c+(M.y-e)*s;l=Math.min(l,p),u=Math.max(u,p),f=Math.min(f,g),m=Math.max(m,g)}let h=(u-l)*I,d=(m-f)*I;if(!(h>4)||!(d>2))return null;let y={a:(l+u)/2,b:(f+m)/2};return{at:(M,p)=>{let g=y.a+M/I,A=y.b+p/I;return{x:n+s*g-c*A,y:e+c*g+s*A}},lengthM:h,widthM:d}}function ci(t,n,e,o,r,a){let i=n.map(c=>pt(c,e)),s=n.map(c=>pt(c,e+o));t.setMaterial(0);for(let c=0;c<n.length;c++)Nt(t,i[c],s[c],r,a);t.setMaterial(ln);for(let c=0;c+1<n.length;c++)Nt(t,s[c],s[c+1],.025,a);t.setMaterial(ii);for(let c=0;c+1<n.length;c++)Fn(t,i[c],i[c+1],s[c+1],s[c]);t.setMaterial(0)}var ni=[.66,.29,.22],nl=[.87,.79,.58],ei=[.17,.36,.63],li=[.56,.59,.63],el=[.7,.7,.68],ol={length:176.9,trackWidth:9.76,longJump:{runway:40,runwayWidth:1.22,pit:9,pitWidth:2.75,fromKerb:3,start:-25},highJump:{matLength:3,matWidth:5,matHeight:.7,apron:15,intoBend:3.5,bar:2},cage:{radius:3.5,height:7,intoBend:10,pad:1.07,sectorDeg:34.92,sector:60,openDeg:120}};function ui(t,n,e){let o=ai(n);if(!o)return;let{at:r,lengthM:a,widthM:i}=o,s=ol,c=Math.min(1.2,Math.max(.5,a/s.length)),l=i/2,u=a/2-l,f=l-s.trackWidth;if(!(u>30*c)||!(f>22*c))return;let m=e+.03,h=(O,k,E=0)=>{Z(t,O,void 0,()=>m+E,m+E-.004,k,k,K)},d=(O,k,E,w)=>[r(O,E),r(k,E),r(k,w),r(O,w)];t.setMaterial(0),h(d(u-.08,u+.08,-l+.2,-f-.2),_n);let y=s.longJump,x=f-y.fromKerb*c,M=(y.start+y.runway)*c;h(d(y.start*c,M,x-y.runwayWidth*c/2,x+y.runwayWidth*c/2),ni),h(d(M,M+y.pit*c,x-y.pitWidth*c/2,x+y.pitWidth*c/2),nl);let p=s.highJump,g=-(u+p.intoBend*c),A=[];for(let O=0;O<=16;O++){let k=-Math.PI/2+Math.PI*O/16;A.push(r(g-.3*c+Math.cos(k)*p.apron*c,Math.sin(k)*p.apron*c))}h(A,ni),Z(t,d(g-p.matLength*c,g,-(p.matWidth*c)/2,p.matWidth*c/2),void 0,()=>e+p.matHeight*c,e,ei,z(ei,.82),K),t.setMaterial(ln);let P=[-1,1].map(O=>r(g+.25*c,O*(p.bar+.1)*c));for(let O of P)Nt(t,pt(O,e),pt(O,e+(p.bar+.3)*c),.02,_n);Nt(t,pt(P[0],e+p.bar*c),pt(P[1],e+p.bar*c),.015,_n),t.setMaterial(0);let b=s.cage,_=u+b.intoBend*c;h(((O,k)=>Array.from({length:k},(E,w)=>{let L=2*Math.PI*w/k;return r(_+Math.cos(L)*O,Math.sin(L)*O)}))(b.pad*c,16),el);let R=b.sectorDeg/2*Math.PI/180;for(let O of[-1,1]){let k=b.sector*c,E=-Math.cos(R),w=O*Math.sin(R);h([r(_+w*.15,-E*.15),r(_+E*k+w*.15,w*k-E*.15),r(_+E*k-w*.15,w*k+E*.15),r(_-w*.15,E*.15)],_n,.006)}let B=b.openDeg/2*Math.PI/180,C=[];for(let O=0;O<=6;O++){let k=B+(2*Math.PI-2*B)*O/6;C.push(r(_-Math.cos(k)*b.radius*c,Math.sin(k)*b.radius*c))}ci(t,C,e,b.height*c,.05,li)}var rl=[.95,.8,.16],oi=[.13,.17,.2],ri=[.78,.8,.83],il={backY:70,backHalf:25,pole:{x:70,y:-18},net:{height:9,inset:.5,wing:15},poleHeight:12,dugout:{length:18,depth:2.4,height:1,along:.32,inset:1.9}};function fi(t,n,e,o,r,a){let i=il,s={x:i.pole.x-i.backHalf,y:i.pole.y-i.backY},c=Math.hypot(s.x,s.y),l=s.x/c,u=s.y/c,f=(g,A,P)=>n(g*(i.backHalf+l*A+u*P),i.backY+u*A-l*P),m=i.net,h=i.backY-m.inset,d=i.backHalf-m.inset,y=[f(-1,m.wing,m.inset)];for(let g of[-d,-d/2,d/2,d])y.push(n(g,h));y.push(f(1,m.wing,m.inset)),ci(t,y,e,m.height*o,.05,li),t.setMaterial(0);for(let g of[-1,1]){let A=pt(n(g*(i.pole.x-.4),i.pole.y+.4),e);Nt(t,A,[A[0],A[1]+i.poleHeight*o,A[2]],.09,rl)}if(!a)return;let x=i.dugout,M=x.along*c-x.length/2,p=M+x.length;for(let g of[-1,1]){let A=[f(g,M,x.inset-x.depth/2),f(g,p,x.inset-x.depth/2)],P=[f(g,M,x.inset+x.depth/2),f(g,p,x.inset+x.depth/2)],b=Math.ceil(x.length),_=!0;for(let C=0;_&&C<=b;C++){let O=C/b;_=r({x:A[0].x+(A[1].x-A[0].x)*O,y:A[0].y+(A[1].y-A[0].y)*O})}if(!_)continue;let S=[A[0],A[1],P[1],P[0]];Z(t,S,void 0,()=>e+(x.height-.1)*o,e,oi,z(oi,.85),K);let R=(C,O)=>({x:C.x+(C.x-O.x)*.04,y:C.y+(C.y-O.y)*.04}),B=[R(A[0],P[1]),R(A[1],P[0]),R(P[1],A[0]),R(P[0],A[1])];Z(t,B,void 0,()=>e+x.height*o,e+(x.height-.14)*o,ri,z(ri,.9),K)}}function mi(t,n,e,o,r,a){let i=n.lengthM/2,s=n.widthM/2;if(a){let c=oo.width/2*o,l=oo.depth*o;for(let u of[-1,1]){let f=n.at(u*(i+l),-c),m=n.at(u*(i+l),c);if(!r(f)||!r(m))continue;let h=pt(n.at(u*i,-c),e),d=pt(n.at(u*i,c),e),y=pt(n.at(u*(i+1),0),e),x=pt(n.at(u*i,0),e);so(t,h,d,Zt(At(y,x)),oo.height*o,l,.06,_n,0)}}t.setMaterial(ln);for(let c of[-1,1])for(let l of[-1,1]){if(!r(n.at(c*i,l*s)))continue;let u=pt(n.at(c*i,l*s),e),f=[u[0],u[1]+Jc*o,u[2]];Nt(t,u,f,.02,Zc);let m=Zt(At(pt(n.at(c*(i+1),l*(s+1)),e),u)),h=[f[0]+m[0]*.4*o,f[1]-.14*o,f[2]+m[2]*.4*o],d=[f[0],f[1]-.28*o,f[2]];t.tri(f,h,d,Zt(Gn(At(h,f),At(d,f))),$c)}t.setMaterial(0)}function hi(t,n,e,o,r){let a=ai(n);if(!a)return;let{at:i,lengthM:s}=a,c=Math.min(1.2,Math.max(.5,s/60)),l=s/2-de.fromEndBoards*c,u=de.width/2*c;for(let x of[-1,1]){let M=pt(i(x*l,-u),e),p=pt(i(x*l,u),e),g=pt(i(x*(l+1),0),e),A=pt(i(x*l,0),e);so(t,M,p,Zt(At(g,A)),de.height*c,de.depth*c,.03,qc,ln)}let f=Ft(n,r/2/I);if(f.length<3)return;let m=o+Qc;t.setMaterial(ln);let h=ro;for(let x=0;x<f.length;x++){let M=f[x],p=f[(x+1)%f.length],g=Math.hypot(p.x-M.x,p.y-M.y)*I,A=0;for(;h+(g-A)>=ro;){A+=ro-h,h=0;let P=g>0?A/g:0,b={x:M.x+(p.x-M.x)*P,y:M.y+(p.y-M.y)*P};Nt(t,pt(b,o),pt(b,m),.025,eo)}h+=g-A}let d=Ft(n,(r/2-.03)/I),y=Ft(n,(r/2+.03)/I);d.length>=3&&y.length>=3&&Z(t,d,[y.slice().reverse()],()=>m,m-.05,eo,z(eo,.9),K),t.setMaterial(0)}function yi(t,n,e,o,r){if(n.length!==4||!(r-o>.2))return;let a=(d,y)=>({x:(d.x+y.x)/2,y:(d.y+y.y)/2}),i=d=>Math.hypot(d.x-e.x,d.y-e.y),s=i(a(n[0],n[1]))<=i(a(n[3],n[2])),[c,l,u]=s?[n[0],n[1],n[3]]:[n[3],n[2],n[0]],f=Math.hypot(u.x-c.x,u.y-c.y)*I;if(!(f>.05))return;let m=pt(c,o),h=pt(l,o);so(t,m,h,Zt(At(pt(u,o),m)),r-o,f,.06,_n,0)}var sl=[.12,.38,.16],al=[.72,.62,.45],cl=[.88,.93,.96],di=[.95,.95,.94],ll=[.66,.29,.22],ao={length:20.12,width:3.05},ul=.14,fl=9.76,vt=[.93,.94,.95],pe=[.1,.11,.13],ml=[.45,.85,1.25],hl=1.45,pi=.012,xi=.004,bi=1.07,xe=.15,gi=[.93,.76,.18],co={height:.2,proud:.02,buried:.03};function un(t,n,e,o,r,a){t.setMaterial(a),Z(t,n,e?[e.slice().reverse()]:void 0,()=>o,o-.004,r,r,K)}var In=(t,n)=>Ft(t,n/I);function Ri(t,n,e){let o=n.x-t.x,r=n.y-t.y,a=Math.hypot(o,r);if(a<1e-9)return null;let i=-r/a*e,s=o/a*e;return[{x:t.x+i,y:t.y+s},{x:n.x+i,y:n.y+s},{x:n.x-i,y:n.y-s},{x:t.x-i,y:t.y-s}]}function yl(t,n,e,o){let r=n.map(a=>[a.x*I,e,a.y*I]);t.tri(r[0],r[1],r[2],[0,1,0],o),t.tri(r[0],r[2],r[3],[0,1,0],o)}function Sn(t,n,e,o,r,a){let i=e/I,s=[{x:n.x-i,y:n.y-i},{x:n.x+i,y:n.y-i},{x:n.x+i,y:n.y+i},{x:n.x-i,y:n.y+i}];Z(t,s,void 0,()=>r,o,a,z(a,.85),K)}function Et(t,n,e,o,r,a,i){let s=Ri(n,e,o/I);s&&Z(t,s,void 0,()=>a,r,i,z(i,.85),K)}function Hn(t){let n=Tt(t),e={x:(n[0].x+n[2].x)/2,y:(n[0].y+n[2].y)/2},o=Math.hypot(n[1].x-n[0].x,n[1].y-n[0].y)||1,r=Math.hypot(n[3].x-n[0].x,n[3].y-n[0].y)||1,a={x:(n[1].x-n[0].x)/o,y:(n[1].y-n[0].y)/o},i={x:(n[3].x-n[0].x)/r,y:(n[3].y-n[0].y)/r};return{at:(c,l)=>({x:e.x+(a.x*c+i.x*l)/I,y:e.y+(a.y*c+i.y*l)/I}),lengthM:o*I,widthM:r*I}}function lo(t){let n=1/0,e=-1/0,o=1/0,r=-1/0;for(let m of t.points??[])n=Math.min(n,m.x),e=Math.max(e,m.x),o=Math.min(o,m.y),r=Math.max(r,m.y);let a=(t.rotation??0)*Math.PI/180,i=Math.cos(a),s=Math.sin(a),c=(n+e)/2,l=(o+r)/2,u=m=>a?{x:c+(m.x-c)*i-(m.y-l)*s,y:l+(m.x-c)*s+(m.y-l)*i}:m,f=(m,h,d,y)=>u({x:c+m/d*(e-n),y:l+h/y*(r-o)});return{turn:u,shortSideM:Math.min(e-n,r-o)*I,local:f,widthU:e-n}}function dl(t){let n=Ce(t).find(e=>e.closed&&!e.fill&&e.points.length===4);return n?n.points.map(lo(t).turn):null}function _i(t,n,e){let o=Ce(n);if(!o.length)return;let{turn:r,shortSideM:a}=lo(n),i=Math.max(.04,Math.min(.3,a*.004))/I,s=0;t.setMaterial(0);for(let u of o){if(!u.fill)continue;let f=u.points.map(r);un(t,f,null,e+pi+s*xi,lt(u.fill)??vt,0),s++}let c=o.filter(u=>!(u.fill&&u.ink===u.fill)),l=[...new Set(c.map(u=>u.ink??ke))];for(let u of l){let f=e+pi+s++*xi,m=lt(u)??vt;for(let h of c){if((h.ink??ke)!==u)continue;let d=h.points.map(r),y=h.closed?d.length:d.length-1;for(let x=0;x<y;x++){let M=Ri(d[x],d[(x+1)%d.length],i);M&&yl(t,M,f,m)}}}}function Ii(t,n,e,o,r,a){if(n.length<3)return!1;let i=o+.006,s=r??sl;if(e==="oval-cricket"){let c=n.reduce((b,_)=>b+_.x,0)/n.length,l=n.reduce((b,_)=>b+_.y,0)/n.length,u=b=>n.map(_=>({x:c+(_.x-c)*b,y:l+(_.y-l)*b})),f=8;for(let b=0;b<f;b++){let _=u(1-b/f),S=b===f-1?null:u(1-(b+1)/f);un(t,_,S,i,z(s,b%2?1.04:.96),4)}let m=n[0];for(let b of n)Math.hypot(b.x-c,b.y-l)>Math.hypot(m.x-c,m.y-l)&&(m=b);let h=Math.hypot(m.x-c,m.y-l)||1,d=(m.x-c)/h,y=(m.y-l)/h,x=-y,M=d,p=Math.min(1,2*h*I*ul/ao.length),g=ao.length*p/2/I,A=ao.width*p/2/I,P=(a&&dl(a))??[[-g,-A],[g,-A],[g,A],[-g,A]].map(([b,_])=>({x:c+d*b+x*_,y:l+y*b+M*_}));return un(t,P,null,i+.004,al,0),si(t,P,i+.004),t.setMaterial(0),!0}if(e==="rink-hockey"){let c=In(n,xe);un(t,c,null,i,cl,0),t.setMaterial(0),Z(t,n,[c.slice().reverse()],()=>o+bi,o,di,z(di,.9),K);let l=In(n,xe-co.buried),u=In(n,xe+co.proud);return l.length>=3&&u.length>=3&&Z(t,l,[u.slice().reverse()],()=>o+co.height,o,gi,z(gi,.92),K),hi(t,n,i,o+bi,xe),!0}if(e==="ring-boxing"&&n.length===4){let{at:c}=Hn(n),l=[c(-3.05,-3.05),c(3.05,-3.05),c(3.05,3.05),c(-3.05,3.05)],u=[[.77,.19,.19],vt,[.17,.42,.69],vt];t.setMaterial(0),l.forEach((f,m)=>Sn(t,f,.07,o,o+hl,u[m]));for(let f of ml)for(let m=0;m<4;m++)Et(t,l[m],l[(m+1)%4],.025,o+f-.025,o+f+.025,vt);return!0}if(e==="court-tennis"&&n.length===4){let{at:c}=Hn(n);t.setMaterial(0),Et(t,c(0,-6.4),c(0,6.4),.015,o,o+.95,pe),Et(t,c(0,-6.4),c(0,6.4),.03,o+.95,o+1,vt);for(let l of[-1,1])Sn(t,c(0,l*6.4),.05,o,o+1.07,pe);return!0}if(e==="court-basketball"&&n.length===4){let{at:c,lengthM:l}=Hn(n),u=Math.min(14,l/2-.5);t.setMaterial(0);for(let f of[-1,1]){let m=c(f*(u+1.2),0),h=c(f*(u-1.2),0);Sn(t,m,.12,o,o+3.4,pe),Et(t,m,h,.06,o+3.25,o+3.4,pe),Et(t,c(f*(u-1.2),-.9),c(f*(u-1.2),.9),.03,o+2.9,o+3.95,vt)}return!0}if(e==="pitch-rugby"&&n.length===4){let{at:c,lengthM:l}=Hn(n),u=l*(50/120);t.setMaterial(0);for(let f of[-1,1]){for(let m of[-2.8,2.8])Sn(t,c(f*u,m),.07,o,o+12,vt);Et(t,c(f*u,-2.8),c(f*u,2.8),.06,o+2.94,o+3.06,vt)}return!0}if(e==="track-athletics"){let c=In(n,fl);return c.length<3?!1:(un(t,n,c,i,ll,0),un(t,c,null,i,s,4),t.setMaterial(0),ui(t,n,o),!0)}return!1}var Nn=140,Mi=1.6,Dn=[.9,.91,.93],be=[.15,.19,.3],vn=[.14,.15,.18],pl=[.1,.24,.18],ge=.9,xl=6,bl={"pitch-football":105,"pitch-rugby":120,"court-tennis":23.77,"court-basketball":32},gl={sidelineShare:15/19,fromSideline:1.35,tableHalfLength:4.5,tableHalfDepth:.38,tableHeight:.76,benchFrom:6,benchTo:12.5,benchHalfDepth:.25,benchHeight:.45,benchBackHeight:.85},Ml=[.13,.15,.2],Rl=[.82,.84,.87];function Si(t,n,e,o,r,a=!1,i=!1){let s=n.stageKind;if(!s||e.length<3)return;if(t.setMaterial(0),s==="diamond-baseball"){let{local:R,widthU:B}=lo(n);if(!(B>0))return;let C=R(0,0,Nn,Nn),O=r.filter(E=>Math.hypot(E.x-C.x,E.y-C.y)<=B),k=Math.min(1.2,Math.max(.5,B*I/Nn));fi(t,(E,w)=>R(E,w,Nn,Nn),o,k,E=>O.every(w=>Math.hypot(w.x-E.x,w.y-E.y)*I>=Mi),!i),t.setMaterial(0);return}if(s==="oval-cricket"){let R=In(e,2.85),B=In(e,3.1);R.length>=3&&B.length>=3&&un(t,R,B,o+.03,vt,0),t.setMaterial(0);return}let c=bl[s];if(!c||e.length!==4)return;let{at:l,lengthM:u,widthM:f}=Hn(e),m=Math.min(1.2,Math.max(.5,u/c)),h=u/2,d=f/2,y=Math.max(h,d)+14,x=l(0,0),M=r.filter(R=>Math.hypot(R.x-x.x,R.y-x.y)*I<y),p=R=>M.every(B=>Math.hypot(B.x-R.x,B.y-R.y)*I>=Mi),g=(R,B)=>{let C=Math.max(1,Math.ceil(Math.hypot(B.x-R.x,B.y-R.y)*I));for(let O=0;O<=C;O++)if(!p({x:R.x+(B.x-R.x)*(O/C),y:R.y+(B.y-R.y)*(O/C)}))return!1;return!0},A=(R,B,C,O,k)=>{let E=Math.hypot(B[0]-R[0],B[1]-R[1]),w=Math.max(1,Math.round(E/xl));for(let L=0;L<w;L++){let D=L/w+.012,T=(L+1)/w-.012,N=l(R[0]+(B[0]-R[0])*D,R[1]+(B[1]-R[1])*D),U=l(R[0]+(B[0]-R[0])*T,R[1]+(B[1]-R[1])*T);g(N,U)&&Et(t,N,U,.06,o,o+k,O&&L%2?O:C)}};if(s==="court-basketball"){let R=gl;for(let B of[-1,1]){let C=B*(d*R.sidelineShare+R.fromSideline*m),O=C+B*R.tableHalfDepth*m,k=(D,T)=>g(l(D,C),l(T,C))&&g(l(D,O),l(T,O)),E=R.tableHalfLength*m;if(!k(-E,E))continue;let w=l(-E,C),L=l(E,C);Et(t,w,L,R.tableHalfDepth*m,o,o+R.tableHeight-.04,Ml),Et(t,w,L,R.tableHalfDepth*m+.04,o+R.tableHeight-.06,o+R.tableHeight,Rl);for(let D of[-1,1]){let T=D*R.benchFrom*m,N=D*R.benchTo*m;if(!k(T,N))continue;Et(t,l(T,C),l(N,C),R.benchHalfDepth,o,o+R.benchHeight,vn);let U=C+B*(R.benchHalfDepth+.04);Et(t,l(T,U),l(N,U),.03,o,o+R.benchBackHeight,vn)}break}return}if(s==="court-tennis"){let R=h+6.4*m,B=d+3.66*m;for(let O of[-1,1])A([O*R,-B],[O*R,B],pl,null,1);let C=l(0,d+1.2*m);p(C)&&(Sn(t,C,.3,o,o+1.5,vn),Sn(t,C,.36,o+1.5,o+1.62,vt));return}mi(t,{at:l,lengthM:u,widthM:f},o,m,p,s==="pitch-football"&&!a);let P=d+3.2*m,b=h+4*m,_=3*m,S=15*m;A([-h+_,P],[h-_,P],Dn,be,ge),A([-h+_,-P],[-S,-P],Dn,be,ge),A([S,-P],[h-_,-P],Dn,be,ge);for(let R of[-1,1])A([R*b,-d+_],[R*b,d-_],Dn,be,ge);for(let R of i?[]:[-1,1]){let B=R*2.5*m,C=R*10.5*m,O=-(d+4.4*m),k=l(B,O),E=l(C,O);!g(k,E)||!g(l(B,O-.75*m),l(C,O-.75*m))||(Et(t,k,E,.35,o,o+.45,vn),Et(t,l(B,O-.75*m),l(C,O-.75*m),.05,o,o+1.9,vn),Et(t,l(B,O-.2*m),l(C,O-.2*m),.62,o+1.9,o+1.98,Dn))}}var _e=[.19,.4,.15],_l=.012,Se=2.4,Il=1,Sl=.75,Pl=.15;function Ht(t){if(t.points&&t.points.length>=3)return t.points;let{center:n,width:e,height:o,rotation:r}=t;if(!e||!o)return null;let a=(r??0)*Math.PI/180,i=Math.cos(a),s=Math.sin(a),c=e/2,l=o/2;return[[-c,-l],[c,-l],[c,l],[-c,l]].map(([u,f])=>({x:n.x+u*i-f*s,y:n.y+u*s+f*i}))}function Oi(t,n,e,o,r,a,i=!1){let s=Ht(n);if(s){if(i){let c=cn(o,r.boothTop),l=jt([...s]);Z(t,Wt(l,Al/I),[l.slice().reverse()],()=>e+.03,e,c,z(c,.8),K);return}if(!(!n.points&&a&&wl(t,s,e,o,a))){if(!n.points&&a&&s.length===4){El(t,s,e,o,a);return}Z(t,s,void 0,()=>e+Se,e,cn(o,r.boothTop),r.boothWall,K)}}}var uo=1.1,Pi=[.9,.9,.88],Al=.1,Me=[.87,.87,.85],Ai=.08;function Ti(t,n){let e=c=>({x:(t[c].x+t[(c+1)%4].x)/2,y:(t[c].y+t[(c+1)%4].y)/2}),o=0,r=1/0;for(let c=0;c<4;c++){let l=e(c),u=Math.hypot(l.x-n.x,l.y-n.y);u<r&&(r=u,o=c)}let a=[0,1,2,3].map(c=>t[(o+c)%4]),i=(c,l,u)=>({x:c.x+(l.x-c.x)*u,y:c.y+(l.y-c.y)*u});return{q:a,part:(c,l,u,f)=>{let m=i(a[0],a[1],c),h=i(a[0],a[1],l),d=i(a[3],a[2],c),y=i(a[3],a[2],l);return[i(m,d,u),i(h,y,u),i(h,y,f),i(m,d,f)]},depthM:Math.hypot(a[3].x-a[0].x,a[3].y-a[0].y)*I,widthM:Math.hypot(a[1].x-a[0].x,a[1].y-a[0].y)*I}}function El(t,n,e,o,r){let{q:a,part:i}=Ti(n,r),s=o??[.35,.42,.55],c=ct(s,[.78,.78,.77],.62),l=ct(s,[.95,.95,.94],.45);ut(t,a,e+Jt,e,c,z(c,.8)),ut(t,i(.05,.95,.72,.98),e+uo-.05,e+Jt,l,z(l,.8)),ut(t,i(.03,.97,.7,1),e+uo,e+uo-.05,Pi,z(Pi,.9))}function wl(t,n,e,o,r){if(n.length!==4)return!1;let{q:a,part:i,depthM:s,widthM:c}=Ti(n,r);if(s<1||c<1)return!1;let l=o??[.35,.42,.55],u=ct(l,[.78,.78,.77],.62),f=e+Se,m=Ai/c,h=Ai/s;ut(t,a,e+Jt,e,u,z(u,.8)),ut(t,i(0,1,1-h,1),f,e+Jt,Me,z(Me,.9));for(let[x,M]of[[0,m],[1-m,1]])ut(t,i(x,M,0,1-h),f,e+Jt,Me,z(Me,.9));ut(t,i(m,1-m,0,Math.min(.5,.06/s)),f,f-.3,l,z(l,.85));let d=Math.min(.4,.6/c),y=Math.min(.12,.3/s);return ut(t,i(.5-d,.5+d,.72-y,.72+y),e+Il,e+Jt,ct(l,[.95,.95,.94],.7),z(l,.75)),!0}function Pe(t){if(t.shape==="round"){let u=t.radius;return u?ce(t.center.x,t.center.y,u,u,24):null}let{width:n,height:e,rotation:o,center:r}=t;if(!n||!e)return null;let a=(o??0)*Math.PI/180,i=Math.cos(a),s=Math.sin(a),c=n/2,l=e/2;return[[-c,-l],[c,-l],[c,l],[-c,l]].map(([u,f])=>({x:r.x+u*i-f*s,y:r.y+u*s+f*i}))}function ki(t,n,e,o,r,a=!0){let i=Pe(n);if(!i)return;let s=i.reduce((d,y)=>d+y.x,0)/i.length,c=i.reduce((d,y)=>d+y.y,0)/i.length,l=d=>i.map(y=>({x:s+(y.x-s)*d,y:c+(y.y-c)*d})),u=rn(r)?1:Tl,f=a&&o?cn(o,r.tableTop):z(Bl,u),m=z(Ol,u),h=e+Sl;Z(t,i,void 0,()=>h,e+kl,f,z(f,.86),K),Z(t,l(.12),void 0,()=>h+.12,h,m,z(m,.8),K)}var Bl=[.93,.92,.89],Ol=[.78,.66,.42],Tl=.62,kl=.25,Un={armM:1.1,widthM:.28,insideM:1.4,low:.043,high:.048};function Cl(t,n,e){let o=t.reduce((M,p)=>M+p.x,0)/4,r=t.reduce((M,p)=>M+p.y,0)/4,a=t[3].x-t[0].x,i=t[3].y-t[0].y,s=Math.hypot(a,i)||1;a/=s,i/=s,a*(n.x-o)+i*(n.y-r)<0&&(a=-a,i=-i);let c=-i,l=a,u=Un.armM/I,f=Un.widthM/I,m=s/2+Un.insideM/I,h=e?-1:1,d=o+a*(m+(e?0:u)),y=r+i*(m+(e?0:u)),x=(M,p)=>({x:d+a*M*h+c*p,y:y+i*M*h+l*p});return[x(0,0),x(-u,u),x(-u-f,u),x(-f,0),x(-u-f,-u),x(-u,-u)]}function Ll(t,n,e,o,r){let a=[.94,.95,.96];Z(t,Cl(n,o,r),void 0,()=>e+Un.high,e+Un.low,a,a,K)}function Ie(t,n){let e=lt(t);return e?{top:z(Xt(e,.12),.95),wall:z(Xt(e,.12),.85)}:{top:n.tierTop,wall:n.tierWall}}function Ci(t,n,e,o,r,a,i,s,c=[]){let l=st(n),u=Fr(n);if(!n.role&&(!n.fill||n.fill==="none"||n.fill==="transparent")||!l){Ln(t,n,e+o+_l);return}let m=s?s.kind==="stage":n.role==="stage",h=s?s.kind==="screen":n.role==="screen",d=s?{kind:m?"stage":"solid",heightM:s.topY-s.baseY}:Dt(n),y=s?.baseY??e,x=s?.topY??e+o,M=null;if(m&&i){let k=1/0,E=-1/0,w=1/0,L=-1/0;for(let D of l)D.x<k&&(k=D.x),D.x>E&&(E=D.x),D.y<w&&(w=D.y),D.y>L&&(L=D.y);M={cx:(k+E)/2*I,cz:(w+L)/2*I,y:x,halfX:Math.max((E-k)/2*I,.5),halfZ:Math.max((L-w)/2*I,.5)},i.push(M)}let p=lt(n.fill),g=n.role==="wall"||n.role==="entrance"||n.role==="exit",A=g?Ie(n.fill,r).top:m&&p?ct(r.stageTop,z(Xt(p,.18),.9),.9):!n.role&&p?p:cn(p,m?r.stageTop:r.decorTop),P=h?p:null,b=g?Ie(n.fill,r).wall:m?p?ct(r.stageWall,z(p,.58),.82):r.stageWall:h?P?ct(z(P,1.42),[.24,.46,.82],.08):[.24,.46,.82]:cn(lt(n.fill),r.decorWall),_=m&&rn(r)?sn(!0):null,S=_?Bi(A,_.stageTop):A,R=_?Bi(b,_.stageWall):b;if(M&&(M.top=S),n.role==="wall"&&!s){he(t,l,y,x,c,S,R,a),Ln(t,n,x+.012);return}if(h&&l.length===4&&x-y>.2){let k=Qe(l,y,x);if(!k)return;let{quad:E,side:w,trim:L,inner:D,panel:T}=k,N=[.12,.15,.18];for(let[U,j]of[[0,w],[1-w,1]])ut(t,Pt(E,U,j),x,y,N,N);ut(t,D,y+L,y,N,N),ut(t,D,x,x-L,N,N),ut(t,T,x-L,y+L,R,R),Ln(t,n,x+.012);return}let B=p?z(Xt(p,.15),.82):R,C=p?z(Xt(p,.1),1.02):S;if($r(n.role)&&!s&&qr(t,n.role,l,y,x,B,C,a,n.heightM!==void 0))return;if((n.role==="sound"||s?.kind==="sound_desk")&&l.length===4&&x-y>.3){let k=Tt(l),E=Math.hypot(k[1].x-k[0].x,k[1].y-k[0].y)*I,w=Math.min(.12,.09/Math.max(E,.001)),L=[.18,.21,.24],D=x-Math.min(.12,(x-y)*.15);for(let[T,N]of[[0,w],[1-w,1]])ut(t,Pt(k,T,N),D,y,L,L);ut(t,k,x,D,S,L);return}if(n.role==="rail"&&l.length===4&&x>y){let k=Tt(l),E=Math.hypot(k[1].x-k[0].x,k[1].y-k[0].y)*I,w=Math.max(1,Math.min(128,Math.ceil(E/1.4))),L=Math.min(.08,.055/Math.max(.055,E)),D=[.58,.64,.66];for(let T=0;T<=w;T++){let N=T/w,U=Math.min(1-L,Math.max(0,N-L/2));ut(t,Pt(k,U,U+L),x,y,D,z(D,.8))}for(let T of[.52,1]){let N=y+(x-y)*T;ut(t,k,N,Math.max(y,N-.055),D,z(D,.8))}return}if(n.role==="goal"&&l.length===4){yi(t,Tt(l),a,y,x),t.setMaterial(0);return}if(d.kind==="portal"&&l.length===4){let k=Mn(l,y,x);if(!k)return;let{quad:E,side:w,face:L,openingTop:D}=k;for(let[T,N,U]of[[0,L,1],[L,1-L,.67],[1-L,1,1]]){let j=Tn(E,T,N),G=z(S,U),v=z(R,U);for(let[X,V]of[[0,w],[1-w,1]])ut(t,Pt(j,X,V),D,y,G,v);ut(t,j,x,D,G,v)}(n.role==="entrance"||n.role==="exit")&&Ll(t,E,y,a,n.role==="exit");return}if(d.kind==="suite"&&l.length===4){let k=l.map((L,D)=>{let T=l[(D+1)%4],N=(L.x+T.x)/2,U=(L.y+T.y)/2;return Math.hypot(N-a.x,U-a.y)}),E=k.indexOf(Math.min(...k)),w=[0,1,2,3].map(L=>l[(E+L)%4]);ut(t,Pt(w,0,.08),x,y,S,R),ut(t,Pt(w,.92,1),x,y,S,R),ut(t,Tn(w,.88,1),x,y,S,R),ut(t,w,x,Math.max(y,x-.18),S,R);return}if(m&&!n.stageKind?.startsWith("pitch-")&&x-y>.12){let k=x-Math.min(.06,(x-y)*.15);ut(t,l,k,y,S,R,u),ut(t,l,x,k,S,ct(S,R,.2),u)}else ut(t,l,x,y,S,R,u);if((n.stageKind==="pitch-football"||n.stageKind==="pitch-rugby")&&l.length===4){t.setMaterial(4);let k=Tt(l),E=ct(p??_e,_e,p?.45:0);for(let w=0;w<12;w++){let L=Pt(k,w/12,(w+1)/12),D=z(E,w%2?1.09:.91),T=L.map(N=>[N.x*I,x+.006,N.y*I]);t.tri(T[0],T[1],T[2],[0,1,0],D),t.tri(T[0],T[2],T[3],[0,1,0],D)}}n.stageKind&&n.stageKind!=="pitch-football"&&Ii(t,l,n.stageKind,x,p,n),m&&Ut(n.stageKind)&&_i(t,n,x),t.setMaterial(h?1:0),Ln(t,n,x+.012)}function Ae(t){let{x:n,y:e,width:o,height:r}=t;if(!o||!r)return null;let a=n+o/2,i=e+r/2,s=(t.rotation??0)*Math.PI/180,c=Math.cos(s),l=Math.sin(s),u=o/2,f=r/2;return[[-u,-f],[u,-f],[u,f],[-u,f]].map(([m,h])=>({x:a+m*c-h*l,y:i+m*l+h*c}))}function Fl(t){if(!t||!t.startsWith("data:image/svg+xml"))return null;let n=t.slice(t.indexOf(",")+1);if(/;base64/i.test(t.slice(0,t.indexOf(","))))try{n=atob(n)}catch{return null}else try{n=decodeURIComponent(n)}catch{}let e=n.match(/<(?:rect|path)\b[^>]*\bfill="([^"]+)"/i);if(!e)return null;let o=e[1].trim();if(o==="none"||o==="transparent")return null;let r=o.match(/^url\(#([^)]+)\)$/);if(!r)return lt(o);let a=n.match(new RegExp(`<(?:linear|radial)Gradient\\b[^>]*\\bid="${r[1]}"[^>]*>([\\s\\S]*?)</(?:linear|radial)Gradient>`,"i"));if(!a)return null;let i=[];for(let s of a[1].matchAll(/stop-color="([^"]+)"/gi)){let c=lt(s[1].trim());c&&i.push(c)}return i.length?i.reduce((s,c,l)=>ct(s,c,1/(l+1)),i[0]):null}function Li(t,n,e,o){if(n.layer==="foreground")return;let r=Ae(n);if(!r)return;let a=e+Pl,i=cn(Fl(n.href),o.decorTop),s=Math.max(0,Math.min(1,n.opacity??1));s<1&&(i=ct(o.ground,i,s)),Z(t,r,void 0,()=>a,e,i,ct(i,o.decorWall,.5),K)}function Fi(t,n,e,o,r){if(!n.points||n.points.length<3)return;let a=dr(o,r.gaTop);Z(t,n.points,n.holes,()=>e+Ei,e,a,r.gaWall,K),Dl(t,n.points,e+Ei)}var Ei=.15,Re=[.72,.74,.76],fo=1.1,wi=.12,mo=.05,Gl=.06,Nl=2.4;function Dl(t,n,e){let o=jt([...n]),r=Ft(o,wi/I),a=Ft(o,(wi+mo)/I);if(r.length<3||a.length<3)return;for(let s of[e+fo,e+fo*.5])Z(t,r,[a.slice().reverse()],()=>s,s-mo,Re,z(Re,.85),K);let i=Gl/2/I;for(let s=0;s<r.length;s++){let c=r[s],l=r[(s+1)%r.length],u=Math.hypot(l.x-c.x,l.y-c.y)*I,f=Math.max(1,Math.round(u/Nl));for(let m=0;m<f;m++){let h=m/f,d=c.x+(l.x-c.x)*h,y=c.y+(l.y-c.y)*h,x=[{x:d-i,y:y-i},{x:d+i,y:y-i},{x:d+i,y:y+i},{x:d-i,y:y+i}];Z(t,x,void 0,()=>e+fo-mo,e,Re,z(Re,.8),K)}}}function Bi(t,n){return ee(t)<n?on(t,n):t}function Gi(t){let n=1/0,e=1/0,o=-1/0,r=-1/0;for(let a of t)n=Math.min(n,a.x),o=Math.max(o,a.x),e=Math.min(e,a.y),r=Math.max(r,a.y);return{x:(n+o)/2,y:(e+r)/2}}function vl(t,n){let e=Gi(t),o=Gi(n);return Mt(n,e.x,e.y)||Mt(t,o.x,o.y)}function Ee(t){let n=new Set;if(t.length<2)return n;let e=[...t].sort((r,a)=>r.baseHeightM-a.baseHeightM||r.index-a.index),o=[];for(let r of e){let a=[];for(let i of r.objects){if(i.type!=="shape"||i.role!=="stage")continue;let s=st(i);!s||s.length<3||(o.some(c=>vl(s,c))?n.add(i):a.push(s))}o.push(...a)}return n}var Hl=1.5,Ul=30,Xl=4,jl=3.6,Wl=6,ho=15,Vl=3,Kl=1;function zl(t){return Math.max(jl,Math.min(Wl,2.4+.15*t))}var Xn=Math.PI*2;function Yl(t,n){let e=0,o=0;for(let f of t)e+=f.x,o+=f.y;let r=Math.atan2(o/t.length-n.y,e/t.length-n.x),a=t.map(f=>{let m=Math.atan2(f.y-n.y,f.x-n.x)-r;for(;m>Math.PI;)m-=Xn;for(;m<-Math.PI;)m+=Xn;return m+r}),i=a.map((f,m)=>m).sort((f,m)=>a[f]-a[m]),s=a[i[0]],c=a[i[i.length-1]];if(c-s>Math.PI)return null;let l=f=>Math.hypot(f.x-n.x,f.y-n.y),u=f=>{let m=t[f],h=(f+t.length-1)%t.length,d=(f+1)%t.length,y=Math.abs(a[h]-a[f])<=Math.abs(a[d]-a[f])?h:d,x=t[y];return l(m)<=l(x)?[m,x]:[x,m]};return{start:s,end:c,startEdge:u(i[0]),endEdge:u(i[i.length-1])}}function Ni(t){return t.type==="shape"&&t.role==="wall"&&t.heightM===void 0}function yo(t,n,e=()=>!0){let o=[];for(let c of t){if(!Ni(c)||!e(c))continue;let l=st(c);if(!l||l.length<3)continue;let u=Yl(l,n);if(!u)return[];o.push(u)}if(o.length<2)return[];let r=t.flatMap(c=>{if(c.type!=="shape"||c.role!=="entrance"&&c.role!=="exit")return[];let l=st(c);if(!l?.length)return[];let u=0,f=0;for(let m of l)u+=m.x,f+=m.y;return[{x:u/l.length,y:f/l.length}]}),a=c=>(c%Xn+Xn)%Xn;o.sort((c,l)=>a(c.start)-a(l.start));let i=c=>Math.hypot(c.x-n.x,c.y-n.y),s=[];for(let c=0;c<o.length;c++){let l=o[c],u=o[(c+1)%o.length],f=a(u.start-l.end);if(f<=0||f>=Math.PI/2)continue;let m=b=>a(b-l.end)<f;if(o.some(b=>b!==l&&b!==u&&(m(b.start)||m(b.end)||a(l.end-b.start)<b.end-b.start)))continue;let[d,y]=l.endEdge,[x,M]=u.startEdge,p={x:(d.x+y.x)/2,y:(d.y+y.y)/2},g={x:(x.x+M.x)/2,y:(x.y+M.y)/2},A=Math.hypot(g.x-p.x,g.y-p.y)*I;if(A<Hl||A>Ul||Math.abs(i(p)-i(g))*I>Xl+.2*A)continue;let P={x:(p.x+g.x)/2,y:(p.y+g.y)/2};r.some(b=>m(Math.atan2(b.y-n.y,b.x-n.x))&&Math.abs(i(b)-i(P))*I<=Vl)||s.push({quad:[d,y,M,x],mid:P,widthM:A,openingM:zl(A)})}return s}function Di(t,n){let e=[];for(let a of n)if(a.text?.trim())for(let i of t){let s=Math.hypot(a.position.x-i.mid.x,a.position.y-i.mid.y)*I;s<=ho&&e.push({text:a,gate:i,d:s})}e.sort((a,i)=>a.d-i.d);let o=new Map,r=new Set;for(let{text:a,gate:i}of e)o.has(a.id)||r.has(i)||(o.set(a.id,i),r.add(i));return o}function vi(t,n,e,o,r,a,i,s=()=>!0){let c=yo(n,gn(e),s);if(!c.length)return;let l=n.find(f=>Ni(f)&&s(f)),u=Ie(l?.fill,i);t.setMaterial(me);for(let f of c)r-f.openingM<Kl||he(t,f.quad,o+f.openingM,o+r,[],u.top,u.wall,a,r);t.setMaterial(0)}var Zl=6,$l=2.2,we=.1,ql=/^(gate|entrance|entry|exit|way in|way out|door)s?$/i,Jl=new Set(["stage","entrance","exit","screen","suite","obstruction","sound","bar","concession","restroom","coat"]),Ql=.3,tu=1.8,nu=.9,eu=.55,ou=1,Hi=4e3,ru=6,Ui="#d8a425",iu="#e8c15a",po="#1c1608";function Xi(t){let n=su(t);if(!n)return null;let e=Xo(t).find(o=>o.icon===n.icon);return{...n,name:e?.titleFallback??n.icon}}function su(t){let n=t.accessibility;if(n?.length)return{icon:n.includes("wheelchair")?"wheelchair":n[0],color:$n(n)};let e=t.commercial;return e?.obstructedView?{icon:"obstructedView",color:Ui,ink:po}:e?.restrictedView?{icon:"restrictedView",color:Ui,ink:po}:e?.premium?{icon:"premium",color:iu,ink:po}:null}function au(t,n){if(!t)return;let e,o=0;for(let[a,i]of t)i>o&&(o=i,e=a);let r=n.categories?.find(a=>a.key===e)?.color;return r&&/^#[0-9a-f]{6}$/i.test(r)?r:void 0}var cu=6e3,lu=.25,ji=[-90,90,-135,135,-45,45];function uu(t,n,e,o){let r=t.flatMap(({id:i,a:s,members:c})=>{let l=(s.minX+s.maxX)/2,u=(s.minY+s.maxY)/2,f=.5*Math.hypot(s.maxX-s.minX,s.maxY-s.minY),m=1/0;for(let h of c)m=Math.min(m,Math.hypot(n[h].x-l,n[h].y-u));return c.length&&m>=f*lu?[{id:i,cx:l,cy:u,half:f,members:c}]:[]}).sort((i,s)=>i.half-s.half),a=new Map;return r.forEach(({id:i,cx:s,cy:c,members:l},u)=>{let f=o.x-s,m=o.y-c,y=(Math.hypot(f,m)>1e-6?Math.atan2(m,f):0)+ji[u%ji.length]*Math.PI/180,x=Math.cos(y),M=Math.sin(y),p=-1,g=-1/0;for(let A of l){let P=(n[A].x-s)*x+(n[A].y-c)*M;P>g&&(g=P,p=A)}a.set(i,[n[p].x*I,e.seatDeckY(p),n[p].y*I])}),a}function Vi(t){let{doc:n,units:e,seats:o,surfaces:r,focal:a}=t,i=n.zones??[],s=[];if(i.length){let c=new Map;for(let m of e)for(let h of m.objects)h.type==="section"&&h.zone&&c.set(h.id,h.zone);let l=new Map,u=new Map;for(let m=0;m<o.length;m++){let h=o[m],d=r.seatOwner[m],y=h.zoneId??(d?c.get(d):void 0);if(!y)continue;let x=l.get(y);x||(x={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},l.set(y,x));let M=u.get(y);M||u.set(y,M=[]),M.push(m),x.n++,h.x<x.minX&&(x.minX=h.x),h.y<x.minY&&(x.minY=h.y),h.x>x.maxX&&(x.maxX=h.x),h.y>x.maxY&&(x.maxY=h.y),x.sumY+=r.seatDeckY(m)}let f=uu(i.flatMap(m=>{let h=l.get(m.id);return h?[{id:m.id,a:h,members:u.get(m.id)??[]}]:[]}),o,r,a);for(let m of i){let h=l.get(m.id),d=[];for(let[y,x]of c)x===m.id&&d.push(y);if(!h||h.n===0){s.push({id:m.id,label:m.label,color:lt(m.color),sectionIds:d,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(m.focalPoint??a).x*I,1.5,(m.focalPoint??a).y*I]});continue}s.push({id:m.id,label:m.label,color:lt(m.color),sectionIds:d,seatCount:h.n,...f.has(m.id)?{labelAt:f.get(m.id)}:{},center:[(h.minX+h.maxX)/2*I,h.sumY/h.n,(h.minY+h.maxY)/2*I],radius:.5*Math.hypot((h.maxX-h.minX)*I,(h.maxY-h.minY)*I)||1,focalWorld:[(m.focalPoint??a).x*I,1.5,(m.focalPoint??a).y*I]})}}return s}function Ki(t){let{doc:n,units:e,seats:o,surfaces:r,seatData:a,hintedSeatFloor:i,zones:s,focal:c}=t,l=[],u=[],f=[],m=new Map;for(let d of e)for(let y of d.objects){if(y.type!=="section"||!y.zone)continue;let x=(y.displayLabel||y.label||"").trim().toLocaleLowerCase();if(!x)continue;let M=n.floors?.[d.index]?.name?.trim().toLocaleLowerCase();if(e.length>1&&M===x)continue;let p=m.get(y.zone);p||m.set(y.zone,p=new Set),p.add(x)}for(let d of s)d.seatCount!==0&&(m.get(d.id)?.has(d.label.trim().toLocaleLowerCase())||l.push({id:`zone:${d.id}`,kind:"zone",text:d.label,anchor:[(d.labelAt??d.center)[0],(d.labelAt??d.center)[1]+Zl,(d.labelAt??d.center)[2]],color:n.zones?.find(y=>y.id===d.id)?.color}));{let d=new Map,y=new Map,x=new Map,M=new Map;for(let p=0;p<o.length;p++){let g=r.seatOwner[p];if(!g)continue;let A=d.get(g);A||(A={n:0,x:0,y:0,deck:0},d.set(g,A)),A.n++,A.x+=o[p].x,A.y+=o[p].y,A.deck+=r.seatDeckY(p);let P=o[p].categoryKey;if(P){let _=y.get(g);_||(_=new Map,y.set(g,_)),_.set(P,(_.get(P)??0)+1)}if(o[p].accessibility?.includes("wheelchair")){let _=x.get(g);_?_.push(p):x.set(g,[p])}let b=M.get(g);b||(b={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0,minDeck:1/0,maxDeck:-1/0},M.set(g,b)),b.minDeck=Math.min(b.minDeck,r.seatDeckY(p)),b.maxDeck=Math.max(b.maxDeck,r.seatDeckY(p)),o[p].x<b.minX&&(b.minX=o[p].x),o[p].x>b.maxX&&(b.maxX=o[p].x),o[p].y<b.minY&&(b.minY=o[p].y),o[p].y>b.maxY&&(b.maxY=o[p].y)}for(let p of e)for(let g of p.objects){if(g.type!=="section"||Xr(g))continue;let A=d.get(g.id);if(!A||A.n===0)continue;let P=M.get(g.id),b=[A.x/A.n*I,A.deck/A.n,A.y/A.n*I],_=g.displayLabel||g.label||g.id;u.push({id:g.id,floorIndex:p.index,label:_,seatCount:A.n,center:b,radius:Math.max(1,Math.hypot(P.maxX-P.minX,P.maxY-P.minY)*.5*I),box:{min:[P.minX*I-.4,P.minDeck,P.minY*I-.4],max:[P.maxX*I+.4,P.maxDeck+1,P.maxY*I+.4]},focalWorld:[p.focal.x*I,p.baseHeightM+1.5,p.focal.y*I]});let S=n.floors?.[p.index]?.name?.trim().toLocaleLowerCase();if(!(e.length>1&&S===_.trim().toLocaleLowerCase())){let R=au(y.get(g.id),n),B=x.get(g.id);l.push({id:`section:${g.id}`,kind:"section",text:_,anchor:[b[0],b[1]+$l,b[2]],floorIndex:p.index,...R?{tint:R}:{},...B?{wheelchairSeats:B}:{}})}}}{for(let b of e)for(let _ of b.objects){if(_.type!=="gaArea")continue;let S=hn(_.points);if(!S)continue;let R=_.labelPresentation?.visible===!1?"":_.displayLabel||_.label||_.id,B=_.capacity>0?[R,_.capacity.toLocaleString()].filter(Boolean).join(" \xB7 "):R;B&&l.push({id:`ga:${_.id}`,kind:"ga",text:B,anchor:[S.x*I,b.baseHeightM+tu,S.y*I],floorIndex:b.index})}let d=new Map,y=new Map;for(let b of e)for(let _ of b.objects)if(_.type==="section"&&d.set(_.id,_.displayLabel||_.label||_.id),_.type==="row"){let S=_.displayLabel?.trim()||_.segmentedRow?.displayLabel?.trim();S&&y.set(_.id,S)}let x=new Map;for(let b=0;b<o.length;b++){let _=o[b],S=Math.hypot(_.x-c.x,_.y-c.y),R=x.get(_.rowId);(!R||S>R.far)&&x.set(_.rowId,{seat:_,index:b,far:S})}for(let[b,_]of x){let S=r.seatOwner[_.index]??_.seat.sectionId,R=Wi(_.seat.label,b,d.get(S??""),y.get(b));R&&l.push({id:`row:${b}`,kind:"row",text:R,anchor:[_.seat.x*I,r.seatDeckY(_.index)+nu,_.seat.y*I],floorIndex:i[_.index]})}let M=new Map;for(let b=0;b<o.length;b++){let _=o[b],S=M.get(_.rowId);S||(S={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:Wi(_.label,_.rowId,d.get(r.seatOwner[b]??_.sectionId??""),y.get(_.rowId)),sectionId:r.seatOwner[b]??_.sectionId},M.set(_.rowId,S));let R=b*3,B=a.iPosition[R],C=a.iPosition[R+1],O=a.iPosition[R+2];S.n++,S.x+=B,S.y+=C,S.z+=O,S.minX=Math.min(S.minX,B),S.maxX=Math.max(S.maxX,B),S.minZ=Math.min(S.minZ,O),S.maxZ=Math.max(S.maxZ,O)}for(let[b,_]of M)f.push({id:b,label:_.label,sectionId:_.sectionId,seatCount:_.n,center:[_.x/_.n,_.y/_.n,_.z/_.n],radius:Math.max(.8,Math.hypot(_.maxX-_.minX,_.maxZ-_.minZ)*.5)});let p=0,g=(b,_)=>{p++,l.push({id:`access:${o[b].id}`,kind:"access",text:_.name,icon:_.icon,color:_.color,..._.ink?{ink:_.ink}:{},seatWidthM:a.iChairWidth[b]*2,anchor:[o[b].x*I,r.seatDeckY(b)+ou,o[b].y*I],floorIndex:i[b],rowId:o[b].rowId})},A=null,P=()=>{if(A){let b=Xi(o[A.seats[0]]),_=A.seats.length,S=Math.max(1,Math.round(_/ru));for(let R=0;R<S&&p<Hi;R++)g(A.seats[Math.min(_-1,Math.floor((R+.5)*_/S))],b)}A=null};for(let b=0;b<o.length&&p<Hi;b++){let _=Xi(o[b]);if(_&&o[b].accessibility?.length){P(),g(b,_);continue}if(!_){P();continue}A&&A.rowId===o[b].rowId&&A.icon===_.icon?A.seats.push(b):(P(),A={rowId:o[b].rowId,icon:_.icon,seats:[b]})}if(P(),o.length<=cu)for(let b=0;b<o.length;b++){let _=o[b],S=fu(_.displayLabel||_.label);S&&l.push({id:`seat:${_.id}`,kind:"seat",seatWidthM:a.iChairWidth[b]*2,text:S,anchor:[_.x*I,r.seatDeckY(b)+eu,_.y*I],floorIndex:i[b],rowId:_.rowId})}}let h=Ee(e);for(let d of e){let y=qt(d,e.length===1?o:o.filter((p,g)=>i[g]===d.index)),x=y?Di(yo(d.objects,gn(y)),d.objects.filter(p=>p.type==="text")):new Map,M=[...x.values()];for(let p of d.objects){let g=p.type==="text"?x.get(p.id):void 0;if(p.type==="shape"&&(p.role==="entrance"||p.role==="exit")&&ql.test(p.label?.trim()??"")){let A=st(p),P=A?hn(A):null;if(P&&M.some(b=>Math.hypot(P.x-b.mid.x,P.y-b.mid.y)*I<=ho+b.widthM))continue}if(g&&p.type==="text")l.push({id:`text:${p.id}`,kind:"gate",text:p.text,icon:"entrance",anchor:[g.mid.x*I,d.baseHeightM+g.openingM+we,g.mid.y*I],color:p.color,floorIndex:d.index});else if(p.type==="shape"&&p.role&&Jl.has(p.role)){if(h.has(p))continue;let A=st(p),P=A?hn(A):null;if(!P||!p.label||p.gate?.hideFromBuyers)continue;l.push({id:`architecture:${p.id}`,kind:p.role==="stage"?"stage":p.role==="entrance"||p.role==="exit"?"gate":"annotation",text:p.label,...p.role==="entrance"||p.role==="exit"?{icon:p.role}:{},...p.gate?.stepFree?{stepFree:!0}:{},anchor:[P.x*I,d.baseHeightM+Dt(p).heightM+we,P.y*I],color:p.fill,floorIndex:d.index})}else if(p.type==="text"){let A=p.semanticKind==="icon"?Le(p.iconKey)?.key:void 0,P=p.text||(A?Le(A).label:"");if(!P)continue;l.push({id:`text:${p.id}`,kind:"annotation",text:P,...A?{venueIcon:A}:{},anchor:A?[(p.position.x+p.fontSize/2)*I,d.baseHeightM+we,(p.position.y+p.fontSize/2)*I]:[p.position.x*I,d.baseHeightM+we,p.position.y*I],color:p.color,rotation:p.rotation,floorIndex:d.index})}else if(p.type==="booth"){if(p.labelPresentation?.visible===!1)continue;let A=Ht(p);if(!A)continue;let P=hn(A);if(!P)continue;l.push({id:`booth:${p.id}`,kind:"booth",text:p.displayLabel||p.label||p.id,anchor:[P.x*I,d.baseHeightM+Se+Ql,P.y*I],floorIndex:d.index})}}}return{labels:l,sections:u,rows:f}}function zi(t,n){if(n.length>1)for(let e of n)t.push({id:`floor:${e.id}`,kind:"floor",text:e.label,anchor:[e.center[0],e.box.max[1]+1.2,e.center[2]],floorIndex:e.index})}function fu(t){let n=t.lastIndexOf("-");return n>=0&&n<t.length-1?t.slice(n+1):t}function Wi(t,n,e,o){if(o?.trim())return o.trim();let r=t?t.lastIndexOf("-"):-1,a=r>0?t.slice(0,r):n;return a&&zo(a,e)}var jn=3,fn=.38,Wn=.24;function mu(t){if(t.length<3)return null;let n=t[0],e=t[Math.floor(t.length/2)],o=t[t.length-1],r=(e.x-n.x)*I,a=(e.y-n.y)*I,i=(o.x-n.x)*I,s=(o.y-n.y)*I,c=2*(r*s-a*i);if(Math.abs(c)<1e-7)return null;let l=r*r+a*a,u=i*i+s*s,f=(l*s-u*a)/c+n.x*I,m=(r*u-i*l)/c+n.y*I,h=Math.hypot(n.x*I-f,n.y*I-m);return h<1||h>200||!Number.isFinite(h)||t.some(d=>Math.abs(Math.hypot(d.x*I-f,d.y*I-m)-h)>.03)?null:{x:f,z:m,radius:h}}function Yi(t){let n=[],e=new Map,o=(c,l)=>`${Math.floor(c/jn)},${Math.floor(l/jn)}`;for(let c of t)for(let l of c.rows){for(let f of l.pts){let m=f.x*I,h=f.y*I,d=o(m,h),y=e.get(d)??[];y.push({x:m,z:h,y:l.y,floor:c.floorIndex}),e.set(d,y)}if(l.patch||l.pts.length<2)continue;let u=mu(l.pts);for(let f of[0,l.pts.length-1]){let m=l.pts[f],h=l.pts[f===0?1:f-1],d=m.x-h.x,y=m.y-h.y,x=Math.hypot(d,y);x<1e-6||n.push({sectionId:c.sectionId,floorIndex:c.floorIndex,curve:u,row:l,point:m,x:m.x*I,z:m.y*I,dx:d/x,dz:y/x})}}let r=new Map;n.forEach((c,l)=>{let u=o(c.x,c.z),f=r.get(u)??[];f.push(l),r.set(u,f)});let a=(c,l)=>{let u=Math.floor(c/jn),f=Math.floor(l/jn);return[-1,0,1].flatMap(m=>[-1,0,1].map(h=>`${u+m},${f+h}`))},i=new Map;n.forEach((c,l)=>{let u=-1,f=1/0,m=!1;for(let h of a(c.x,c.z))for(let d of r.get(h)??[]){let y=n[d];if(c.sectionId===y.sectionId&&c.row.blockId===y.row.blockId||c.floorIndex!==y.floorIndex||Math.abs(c.row.y-y.row.y)>.05)continue;let x=y.x-c.x,M=y.z-c.z,p=Math.hypot(x,M);if(p<fn*2+.45||p>jn)continue;let g=c.curve&&y.curve&&Math.hypot(c.curve.x-y.curve.x,c.curve.z-y.curve.z)<=.05&&Math.abs(c.curve.radius-y.curve.radius)<=.05,A=Math.min((x*c.dx+M*c.dz)/p,(-x*y.dx-M*y.dz)/p);(g?A<.8:A<.98)||!g&&(Math.abs(x*c.dz-M*c.dx)>.15||Math.abs(x*y.dz-M*y.dx)>.15)||(p<f-.02?(u=d,f=p,m=!1):Math.abs(p-f)<=.02&&(m=!0))}u>=0&&!m&&i.set(l,u)});let s=[];for(let[c,l]of i){if(c>=l||i.get(l)!==c)continue;let u=n[c],f=n[l],m=Math.hypot(f.x-u.x,f.z-u.z),h=(f.x-u.x)/m,d=(f.z-u.z)/m,y=!1;for(let M of a((u.x+f.x)/2,(u.z+f.z)/2))for(let p of e.get(M)??[]){if(p.floor!==u.floorIndex||Math.abs(p.y-u.row.y)>.75)continue;let g=(p.x-u.x)*h+(p.z-u.z)*d,A=Math.abs((p.x-u.x)*d-(p.z-u.z)*h);g>.01&&g<m-.01&&A<Wn+fn&&(y=!0)}if(y)continue;let x=(M,p)=>({x:(u.x+h*M-d*p)/I,y:(u.z+d*M+h*p)/I});s.push({sections:[u.sectionId,f.sectionId],blocks:[u.row.blockId,f.row.blockId],floorIndex:u.floorIndex,ends:[u.point,f.point],clearWidthM:m-2*fn,heightM:(u.row.y+f.row.y)/2,outline:[x(fn,-Wn),x(m-fn,-Wn),x(m-fn,Wn),x(fn,Wn)]})}return s}var xo={key:[1,1,1],ambient:[1,1,1]},Ey=.5,hu=[{id:"daylight",label:"Daylight",description:"Open air by day: pale concrete under a warm sun and a blue sky.",background:"#dce3e8",materials:{deck:"#c9ccc8",fascia:"#b4bab8",shell:"#c3c9c8",roughness:.87},light:{key:[1.05,1,.93],ambient:[.95,.99,1.06]},indoor:!1},{id:"floodlit",label:"Floodlit night",description:"A night match: dark sky, hard cool-white floodlights.",background:"#0c1420",materials:{deck:"#66727c",fascia:"#3a4a58",shell:"#4c6072",roughness:.84},light:{key:[1.08,1.08,1.12],ambient:[.8,.88,1.1]},indoor:!1},{id:"evening",label:"Evening",description:"A quiet dark hall: slate structure in a cool, even light.",background:"#17232e",materials:{deck:"#69747b",fascia:"#3e4d58",shell:"#526572",roughness:.87},light:{key:[1,.99,.96],ambient:[.94,.98,1.06]},indoor:!1},{id:"arena-show",label:"Arena show",description:"House lights down for a show: deep blue room, warm light on the floor.",background:"#10121c",materials:{deck:"#626a7a",fascia:"#383f52",shell:"#484f66",roughness:.82},light:{key:[1.08,.98,.88],ambient:[.8,.84,1.16]},indoor:!0},{id:"theatre",label:"Theatre house lights",description:"A warm auditorium before curtain-up: amber light, dark warm room.",background:"#1c1512",materials:{deck:"#74685c",fascia:"#4c4038",shell:"#5c4e44",roughness:.9},light:{key:[1.14,.98,.78],ambient:[1.04,.94,.84]},indoor:!0},{id:"concert-hall",label:"Concert hall",description:"A bright hall in pale wood and cream, softly warm.",background:"#e9e2d6",materials:{deck:"#d2c8b8",fascia:"#bcb0a0",shell:"#c8beae",roughness:.8},light:{key:[1.06,1,.9],ambient:[1.02,1,.95]},indoor:!0}],yu=new Map(hu.map(t=>[t.id,t])),Zi="plain",$i=3e3;function qi(t,n){return t.openField?n?"daylight":"floodlit":t.court||t.inTheRound||t.stage&&t.seatCount>$i?n?"daylight":"arena-show":t.stage?n?"concert-hall":"theatre":n?"daylight":"evening"}function Ji(t){return t.openField?!1:t.indoorCourt?!0:t.stage&&!t.inTheRound&&!t.court&&t.standing<t.seatCount&&t.seatCount<=$i}function bo(t){return t&&yu.get(t)||null}var du=.15,pu=.9,xu=1.76;function bu(t,n,e){let o=t??gu,r=(a,i,s)=>[Math.min(1,a[0]*i*s[0]),Math.min(1,a[1]*i*s[1]),Math.min(1,a[2]*i*s[2])];return Vn(t)?{indoor:e,ceiling:r(o,1.02,n.light.ambient),wall:r(o,.9,n.light.ambient),lamp:r([.1,.1,.1],1,n.light.key)}:{indoor:e,ceiling:r(o,.7,n.light.ambient),wall:r(o,1.55,n.light.ambient),lamp:r([.92,.86,.74],1,n.light.key)}}var gu=[.075,.09,.115];function Qi(t){return Vn(t)?{zenith:[.36,.58,.84],horizon:[.82,.88,.94]}:{zenith:[.05,.08,.15],horizon:[.3,.38,.5]}}function Vn(t){return!!t&&t[0]*.2126+t[1]*.7152+t[2]*.0722>.55}function Mu(){return{background:{top:[...He.top],bottom:[...He.bottom]},sky:Qi(null),structure:ve,seatStates:{...ir},seatScale:1,materials:{seat:null,shell:null,roughness:.78},light:{key:[...xo.key],ambient:[...xo.ambient]},house:null}}function Ru(t){return Vn(t)?{deck:"#c9ccc8",fascia:"#b4bab8",shell:"#c3c9c8",roughness:.87}:{deck:"#69747b",fascia:"#3e4d58",shell:"#526572",roughness:.87}}function ts(t,n){let e=t?.venue3d?.look;if(e===Zi)return{look:null,chosen:!0};let o=bo(e);return o?{look:o,chosen:!0}:n?{look:bo(qi(n,Vn(lt(t?.background)))),chosen:!1}:{look:null,chosen:!1}}function _u(t,n){let{look:e,chosen:o}=ts(t,n);return lt(t?.background)??(o?lt(e?.background):null)}function ns(t,n){let e=Mu();t??={};let{look:o,chosen:r}=ts(t,n);o&&(e.light={key:[...o.light.key],ambient:[...o.light.ambient]});let a=_u(t,n);if(o&&(e.house=bu(a,o,r?o.indoor:!!n&&Ji(n))),a){e.background={top:z(a,pu),bottom:z(a,xu)},e.sky=Qi(a);let u={};for(let[m,h]of Object.entries(ve))u[m]=ct(h,a,du);a[0]*.2126+a[1]*.7152+a[2]*.0722>.55&&(u.ground=z(a,.86)),e.structure=u}let i=lt(t.selectionColor)??lt(t.accent);i&&(e.seatStates={...e.seatStates,selected:i});let s=t.seatScale;typeof s=="number"&&Number.isFinite(s)&&(e.seatScale=Zo(s));let c=Object.fromEntries(Object.entries(t.venue3d??{}).filter(([u,f])=>f!=null&&u!=="look")),l={...Ru(a),...o?.materials,...c};if(l){let u=lt(l.deck),f=lt(l.fascia);u&&(e.structure={...e.structure,tierTop:u,gaTop:u}),f&&(e.structure={...e.structure,tierWall:f,gaWall:f}),e.materials.seat=lt(l.seat),e.materials.shell=lt(l.shell),typeof l.roughness=="number"&&Number.isFinite(l.roughness)&&(e.materials.roughness=Math.min(1,Math.max(0,l.roughness)))}return Iu(e,Vn(a)),e}function Iu(t,n){let e=sn(n);t.seatStates={...t.seatStates,held:oe(e.unavailable),sold:oe(e.unavailable),dimmed:oe(e.dimmed)};let o=(a,i)=>on(a,i,Math.min(An(a),re)),r=t.structure;t.structure={...r,ground:o(r.ground,e.ground),tierTop:o(r.tierTop,e.deck),tierWall:o(r.tierWall,e.fascia)},t.materials.shell&&(t.materials.shell=o(t.materials.shell,e.shell))}function es(t,n){let e=[];for(let o of n)e.push(...t.seatStates[o]);return e}var os=[.13,.14,.17],Pn=[.4,.43,.47],Su=.18,Pu=.02,Au=2.4,Eu=1500,wu=240,Bu=.25,Ou=12,Tu=[.055,.06,.075],ku=[.46,.33,.22],Cu=[1,.96,.84],Lu=[.98,.66,.28],Fu=[.5,.31,.15],Gu=[1,.87,.64],gt={lampEvery:1.8,lampsMin:3,lampsMax:14,lampDrop:.45,lampRadius:[.11,.2],poolShare:.44,poolEdge:.9,poolStrength:.5,washByDay:.35,drapeClear:.12,glowClear:.06,coreClear:.12,poolLift:.02};function Nu(t,n,e,o){let r=1/0,a=0;for(let i=0;i<t.length;i++){let s=t[i],c=t[(i+1)%t.length],l=c.x-s.x,u=c.y-s.y,f=e*u-o*l;if(Math.abs(f)<1e-12)continue;let m=((s.x-n.x)*u-(s.y-n.y)*l)/f,h=((s.x-n.x)*o-(s.y-n.y)*e)/f;m>0&&h>=0&&h<1&&(a+=1,r=Math.min(r,m))}return a%2===1?r:0}function go(t,n){if(!n.length)return!1;let e=0,o=0,r=0,a=new Set;for(let s of n)e+=s.x,o+=s.y,r+=Math.hypot(s.x-t.x,s.y-t.y),a.add(Math.floor(Math.atan2(s.y-t.y,s.x-t.x)*180/Math.PI/10));let i=Math.hypot(t.x-e/n.length,t.y-o/n.length);return a.size*10>wu&&i<Bu*(r/n.length)}function rs(t,n,e,o,r={}){let a=n.stageKind??"";if(Ut(a)||a==="round"||!o.length)return;let i=st(n);if(!i||i.length<3)return;let s={x:i.reduce((F,W)=>F+W.x,0)/i.length,y:i.reduce((F,W)=>F+W.y,0)/i.length},c=0,l=0;for(let F of o)c+=F.x,l+=F.y;let u=s.x-c/o.length,f=s.y-l/o.length,m=Math.hypot(u,f);if(m<1e-6||go(s,o))return;let h=u/m,d=f/m,y=-d,x=h,M=-1/0,p=1/0,g=1/0,A=-1/0;for(let F of i){let W=(F.x-s.x)*h+(F.y-s.y)*d,Y=(F.x-s.x)*y+(F.y-s.y)*x;M=Math.max(M,W),p=Math.min(p,W),g=Math.min(g,Y),A=Math.max(A,Y)}let P=(A-g)*I,b=(M-p)*I;if(P<3||b<1.5||P*b>Eu)return;let _=Su/I,S=(F,W)=>({x:s.x+h*F+y*W,y:s.y+d*F+x*W}),R=(F,W,Y,q)=>[S(F,Y),S(F,q),S(W,q),S(W,Y)],B=e+Math.max(3.5,Math.min(8,P*.35)),C=e+Math.min(Au,B-e-1),O=.2/I,k=p+Math.min(b*.25,1.5)/I,E=Pu/I;Z(t,R(M-2*_+E,M-_-E,g+_+O,A-_-O),void 0,()=>C,e,os,os,K);for(let[F,W]of[[g+_,g+_+O],[A-_-O,A-_]])Z(t,R(M-2*_,M-_,F,W),void 0,()=>B+.3,e,Pn,Pn,K),Z(t,R(k+O,M-2*_,F,W),void 0,()=>B+.3,B,Pn,Pn,K);Z(t,R(k,k+O,g+_,A-_),void 0,()=>B+.3,B,Pn,Pn,K);let w=(F,W)=>[F.x*I,W,F.y*I],L=[-h,0,-d],D=g+_+O,T=A-_-O,N=M-2*_-gt.drapeClear/I,U=B-e,j=r.night===!1?gt.washByDay:1,G=(F,W)=>ct(Tu,ku,j*(1-F*F)*Math.pow(1-W,1.6)),v=(F,W,Y=0)=>w(S(N-Y/I,(D+T)/2+F*(T-D)/2),e+U*W);t.setMaterial(Ou);let X=8,V=5;for(let F=0;F<X;F++)for(let W=0;W<V;W++){let Y=F/X*2-1,q=(F+1)/X*2-1,ot=W/V,at=(W+1)/V;t.tri(v(Y,ot),v(q,ot),v(q,at),L,G(Y,ot),G(q,ot),G(q,at)),t.tri(v(Y,ot),v(q,at),v(Y,at),L,G(Y,ot),G(q,at),G(Y,at))}let Q=Math.max(gt.lampsMin,Math.min(gt.lampsMax,Math.round(P/gt.lampEvery))),et=Math.max(gt.lampRadius[0],Math.min(gt.lampRadius[1],P*.012)),tt=(T-D)*I,J=1-gt.lampDrop/U,ft=(F,W,Y,q,ot)=>{let it=W/tt*2,St=W/U;for(let $=0;$<10;$++){let xt=2*Math.PI*$/10,Kt=2*Math.PI*($+1)/10,tn=[Math.cos(xt)*it,Math.sin(xt)*St],kt=[Math.cos(Kt)*it,Math.sin(Kt)*St];t.tri(v(F,J,Y),v(F+tn[0],J+tn[1],Y),v(F+kt[0],J+kt[1],Y),L,q,ot(tn[0],tn[1]),ot(kt[0],kt[1]))}};for(let F=0;F<Q;F++){let W=(F+.5)/Q*2-1;ft(W,et*3,gt.glowClear,ct(G(W,J),Fu,.85),(Y,q)=>G(W+Y,J+q)),ft(W,et,gt.coreClear,Cu,()=>Lu)}if(t.setMaterial(0),!r.night||!r.deck)return;let mt=r.deck,ht=S((p+M-2*_)/2,(g+A)/2),rt=e+gt.poolLift,yt=[0,1,0],dt=[{r:.4,k:.72},{r:.72,k:.28},{r:1,k:0}],bt=28,Bt=[];for(let F=0;F<bt;F++){let W=2*Math.PI*F/bt,Y=Math.cos(W)*(M-2*_-p)*gt.poolShare,q=Math.sin(W)*(A-g)*gt.poolShare,ot=Math.hypot(Y,q),at=(h*Y+y*q)/ot,it=(d*Y+x*q)/ot;Bt.push(Math.min(ot,Nu(i,ht,at,it)*gt.poolEdge))}if(Bt.some(F=>!(F>0)))return;let Rt=(F,W)=>{let Y=2*Math.PI*(F%bt)/bt,q=Math.cos(Y)*(M-2*_-p)*gt.poolShare,ot=Math.sin(Y)*(A-g)*gt.poolShare,at=Math.hypot(q,ot),it=Bt[F%bt]*W/at;return w({x:ht.x+(h*q+y*ot)*it,y:ht.y+(d*q+x*ot)*it},rt)},H=F=>ct(mt,Gu,gt.poolStrength*F);for(let F=0;F<bt;F++){t.tri(w(ht,rt),Rt(F,dt[0].r),Rt(F+1,dt[0].r),yt,H(1),H(dt[0].k),H(dt[0].k));for(let W=0;W+1<dt.length;W++){let Y=dt[W],q=dt[W+1];t.tri(Rt(F,Y.r),Rt(F,q.r),Rt(F+1,q.r),yt,H(Y.k),H(q.k),H(q.k)),t.tri(Rt(F,Y.r),Rt(F+1,q.r),Rt(F+1,Y.r),yt,H(Y.k),H(q.k),H(Y.k))}}}function is(t,n){let e={openField:!1,court:!1,indoorCourt:!1,inTheRound:!1,stage:!1,standing:0,seatCount:n.length};for(let o of t)for(let r of o.objects){if(r.type==="gaArea"&&(e.standing+=r.capacity),r.type!=="shape")continue;let a=r.stageKind;if(en(a)){e.openField=!0;continue}if(Ut(a)){e.court=!0,Ho(a)&&(e.indoorCourt=!0);continue}if(r.role!=="stage")continue;if(e.stage=!0,a==="round"){e.inTheRound=!0;continue}let i=st(r);if(!i||i.length<3)continue;let s={x:i.reduce((c,l)=>c+l.x,0)/i.length,y:i.reduce((c,l)=>c+l.y,0)/i.length};go(s,n)&&(e.inTheRound=!0)}return e}var Qt=72,Du=1.2,vu=5,Hu=30,Uu=4;function Xu(t,n,e,o){let r=0;for(let a=0;a<t.length;a++){let i=t[a],s=t[(a+1)%t.length],c=s.x-i.x,l=s.y-i.y,u=e*l-o*c;if(Math.abs(u)<1e-12)continue;let f=((i.x-n.x)*l-(i.y-n.y)*c)/u,m=((i.x-n.x)*o-(i.y-n.y)*e)/u;f>r&&m>=-1e-9&&m<=1+1e-9&&(r=f)}return r}function ju(t,n){if(t.length<3)return null;let e={x:t.reduce((s,c)=>s+c.x,0)/t.length,y:t.reduce((s,c)=>s+c.y,0)/t.length},o=2*Math.PI/Qt,r=new Float64Array(Qt);for(let s=0;s<Qt;s++)if(r[s]=Xu(t,e,Math.cos(s*o),Math.sin(s*o)),!(r[s]>0))return null;let a=new Float64Array(Qt).fill(1/0);for(let s of n){let c=s.x-e.x,l=s.y-e.y,u=Math.hypot(c,l),f=(Math.round(Math.atan2(l,c)/o)%Qt+Qt)%Qt;u>r[f]&&u<a[f]&&(a[f]=u)}let i=[];for(let s=0;s<Qt;s++){let l=Number.isFinite(a[s])&&a[s]-r[s]<=Hu/I?a[s]+Du/I:r[s]+vu/I;i.push({x:e.x+Math.cos(s*o)*l,y:e.y+Math.sin(s*o)*l})}return i}function Wu(t){return ct(z(t,.84),[.33,.36,.31],.22)}function ss(t,n,e,o,r){let a=ju(n,o);if(!a)return;let i=e-.015;t.setMaterial(Uu);let s=Wu(r);Z(t,a,void 0,()=>i,i-.004,s,s,K),t.setMaterial(0)}function as(t,n,e,o=[],r){if(n<1)return null;let a=1/0,i=-1/0,s=1/0,c=-1/0,l=-1/0,u=(g,A)=>{g<a&&(a=g),g>i&&(i=g),A<s&&(s=A),A>c&&(c=A)};for(let g=0;g<n;g++)u(t[g*3],t[g*3+2]),t[g*3+1]>l&&(l=t[g*3+1]);for(let[g,A]of o)u(g,A);if(!Number.isFinite(a)||!Number.isFinite(l))return null;let f=(a+i)/2,m=(s+c)/2,h=Math.max(4,(i-a)/2),d=Math.max(4,(c-s)/2),y=1,x=(g,A)=>{let P=Math.hypot((g-f)/h,(A-m)/d);P>y&&(y=P)};for(let g=0;g<n;g++)x(t[g*3],t[g*3+2]);for(let[g,A]of o)x(g,A);let M=Math.min(9,Math.max(5,2*Math.max(h,d)*.1)),p=Math.max(e+8,l+M);return{centre:[f,m],radii:[h*y+6,d*y+6],floorY:e,ceilingY:r===void 0?p:Math.max(r,l+5)}}var Mo=.6,cs=3,Vu=.25;function Ku(t,n){if(Mt(n,t.x,t.y))return 0;let e=1/0;for(let o=0,r=n.length-1;o<n.length;r=o++){let a=n[r],i=n[o],s=i.x-a.x,c=i.y-a.y,l=s*s+c*c||1,u=Math.max(0,Math.min(1,((t.x-a.x)*s+(t.y-a.y)*c)/l));e=Math.min(e,Math.hypot(t.x-(a.x+u*s),t.y-(a.y+u*c)))}return e}function ls(t,n){let e=t.map(i=>({booth:i,ring:Ht(i)})).filter(i=>!!i.ring&&i.ring.length===4&&!i.booth.points),o=e.map(({ring:i})=>({minX:Math.min(...i.map(s=>s.x)),maxX:Math.max(...i.map(s=>s.x)),minY:Math.min(...i.map(s=>s.y)),maxY:Math.max(...i.map(s=>s.y))})),r=(cs+Mo)/I,a=new Map;return e.forEach(({booth:i,ring:s},c)=>{let l={x:s.reduce((h,d)=>h+d.x,0)/4,y:s.reduce((h,d)=>h+d.y,0)/4},u=[0,1,2,3].map(h=>{let d=s[h],y=s[(h+1)%4],x={x:(d.x+y.x)/2,y:(d.y+y.y)/2},M=x.x-l.x,p=x.y-l.y,g=Math.hypot(M,p)||1,A={x:x.x+M/g*Mo/I,y:x.y+p/g*Mo/I},P=cs/I;return o.forEach((b,_)=>{_===c||A.x<b.minX-r||A.x>b.maxX+r||A.y<b.minY-r||A.y>b.maxY+r||(P=Math.min(P,Ku(A,e[_].ring)))}),{open:P*I,toward:{x:x.x+M/g*10/I,y:x.y+p/g*10/I},focal:Math.hypot(x.x-n.x,x.y-n.y)}}),f=Math.max(...u.map(h=>h.open)),m=u.filter(h=>h.open>=f-Vu).sort((h,d)=>h.focal-d.focal)[0];a.set(i.id,m.toward)}),a}import zu from"polygon-clipping";var Yu=.45,Zu=1500,$u=200;function us(t,n){if(t.role!=="stage"||Ut(t.stageKind))return t;let e=st(t);if(!e||e.length<3||Math.abs(Ot(e))*I*I>Zu)return t;let o=n.filter(i=>Mt(e,i.x,i.y));if(!o.length||o.length>$u)return t;let r=Yu/I,a=o.map(i=>[[[i.x-r,i.y-r],[i.x+r,i.y-r],[i.x+r,i.y+r],[i.x-r,i.y+r],[i.x-r,i.y-r]]]);try{let i=zu.difference([[...e.map(l=>[l.x,l.y]),[e[0].x,e[0].y]]],...a),s=null,c=0;for(let l of i){let u=l[0].slice(0,-1).map(([m,h])=>({x:m,y:h})),f=Math.abs(Ot(u));f>c&&(c=f,s=u)}return!s||s.length<3?t:{...t,kind:"polygon",points:s,rotation:0}}catch{return t}}function Ro(t,n,e,o,r,a,i,s,c,l=[],u=r){if(n.length!==e.length||n.length<2||a-r<1.5)return;let f=(y,x,M)=>{Yt(t,y,x,M,l,i,s,{portalBase:u,ao:c})||Z(t,y,void 0,()=>M,x,i,s,c)},m=(y,x,M)=>({x:y.x+(x.x-y.x)*M,y:y.y+(x.y-y.y)*M}),h=o?n.length:n.length-1,d=0;for(let y=0;y<h;y++){let x=(y+1)%n.length,M=Math.hypot(e[x].x-e[y].x,e[x].y-e[y].y)*nt;if(M<1e-5)continue;let p=(b,_)=>[m(n[y],n[x],b),m(n[y],n[x],_),m(e[y],e[x],_),m(e[y],e[x],b)];f(p(0,1),r,r+.95),f(p(0,1),a-.22,a);let g=Math.ceil((d-.32)/6)*6,A=!1,P=!1;for(let b=g;b<d+M;b+=6){let _=Math.max(0,(b-d)/M),S=Math.min(1,(b+.32-d)/M);S<=_||(f(p(_,S),r+.95,a-.22),A||=_<1e-6,P||=S>1-1e-6)}if(!o&&(y===0&&!A||y===h-1&&!P)){let b=Math.min(1,.32/M);f(p(y===0?0:1-b,y===0?b:1),r+.95,a-.22)}d+=M}}import mn from"polygon-clipping";var zn=.65;function _o(t,n){let e=1/0;for(let o of n)for(let r=0;r<o.length;r++){let a=o[r],i=o[(r+1)%o.length],s=i.x-a.x,c=i.y-a.y,l=Math.max(0,Math.min(1,((t.x-a.x)*s+(t.y-a.y)*c)/(s*s+c*c||1)));e=Math.min(e,Math.hypot(t.x-a.x-l*s,t.y-a.y-l*c))}return e}var Io=.01;function fs(t,n,e,o,r,a,i,s=[],c=!0,l={bays:[],walls:[]}){if(o-r<=1e-5)return;let u=o-r>=3,f=u?o-zn:r;t.setMaterial(5);let m=u?[]:s.filter(b=>{if(b.role!=="entrance"&&b.role!=="exit")return!1;let _=st(b);if(!_)return!1;let S=Mn(_,r,r+Dt(b).heightM);return S!==null&&S.openingTop<=o-.12});if((!m.length||!Yt(t,n,f,o,m,a,i,{holes:e,portalBase:r}))&&Z(t,n,e,()=>o,f,a,i,K,void 0,()=>[0,1,0]),!u){t.setMaterial(0);return}let h=c&&l.bays.length?qu(n,e,Ft(n,Kn/I),l):null,d=6/I,y=.22/I,x=s.flatMap(b=>{if(b.role!=="entrance"&&b.role!=="exit")return[];let _=st(b);return _?.length?[{minX:Math.min(..._.map(S=>S.x)),maxX:Math.max(..._.map(S=>S.x)),minY:Math.min(..._.map(S=>S.y)),maxY:Math.max(..._.map(S=>S.y))}]:[]}),M=Math.min(...n.map(b=>b.x)),p=Math.max(...n.map(b=>b.x)),g=Math.min(...n.map(b=>b.y)),A=Math.max(...n.map(b=>b.y));for(let b=M+d/2;b<p;b+=d)for(let _=g+d/2;_<A;_+=d){if(x.some(R=>b+y>=R.minX&&b-y<=R.maxX&&_+y>=R.minY&&_-y<=R.maxY))continue;let S=[{x:b-y,y:_-y},{x:b+y,y:_-y},{x:b+y,y:_+y},{x:b-y,y:_+y}];!Lt({x:b,y:_},n,e)||_o({x:b,y:_},[n,...e??[]])<y*Math.SQRT2+(c?Kn/I:0)||h&&_o({x:b,y:_},h.flat())<y*Math.SQRT2+Kn/I||Z(t,S,void 0,()=>f,r,a,i,K)}if(h){for(let[b,..._]of h)Z(t,b,_,()=>f,r-Io,a,i,K);t.setMaterial(0);return}let P=Ft(n,Kn/I);if(c&&P.length>=3){let b=s.filter(R=>{if(R.role!=="entrance"&&R.role!=="exit")return!1;let B=st(R);return!!B&&B.some(C=>!Lt(C,n,void 0)||_o(C,[n])<=Kn/I)}),_=[P.slice().reverse()],S=r-Io;(!b.length||!Yt(t,n,S,f,b,a,i,{holes:_,portalBase:r+Io}))&&Z(t,n,_,()=>f,S,a,i,K)}t.setMaterial(0)}var So=.25,Kn=So;function qu(t,n,e,o){if(e.length<3)return null;let r=i=>{let s=i.map(c=>[c.x,c.y]);return s.push(s[0]),s},a=i=>{let[s,...c]=i.map(l=>[r(l)]);return mn.union(s,...c)};try{let i=[r(t),...(n??[]).map(r)],s=mn.difference(i,[r(e)]),c=mn.intersection(i,a(o.bays));if(!c.length)return null;let l=mn.difference(mn.intersection(i,a(o.walls)),c);return mn.union(mn.difference(s,c),l).map(f=>f.map(m=>m.slice(0,-1).map(([h,d])=>({x:h,y:d}))))}catch{return null}}var Ju=.02,Qu=.25,tf=1.2,nf=.6,ef=.45,of=2.3,rf=Math.PI/180,ms=.005;function Vt(t,n,e){let o=e*rf;return{x:t.x+n*Math.sin(o),y:t.y+n*Math.cos(o)}}function sf(t,n){let e=n.rings[n.rings.length-1];if(!e)return!1;let o=e.outerRMedian*.85;for(let r of t){if(r.role!=="wall")continue;let a=r.points&&r.points.length>=2?r.points:r.x!==void 0&&r.y!==void 0&&r.width!==void 0&&r.height!==void 0?[{x:r.x,y:r.y},{x:r.x+r.width,y:r.y},{x:r.x+r.width,y:r.y+r.height},{x:r.x,y:r.y+r.height}]:[];if(a.length<2)continue;let i=0;for(let s of a)Math.hypot(s.x-n.centre.x,s.y-n.centre.y)>=o&&i++;if(i>=a.length/2)return!0}return!1}var af=24,cf=.01;function lf(t,n,e,o,r,a,i,s,c){let l=e.binCount,u=af,f=nt,m=a+.02,h=a-cf,d=[];for(let E=0;E<l;E++){let w=(e.startBin+E+.5)*n.binStepDeg,L=new Float64Array(u+1);for(let D=0;D<=u;D++){let T=o[E]+(r[E]-o[E])*D/u;L[D]=Math.max(m,nr(n,e,w,T)-Qu)}d.push(L)}if(c){let E=0;for(let w=0;w+1<l;w++)for(let L=0;L<u;L++){let D=Vt(n.centre,o[w]+(r[w]-o[w])*L/u,(e.startBin+w+.5)*n.binStepDeg),T=Vt(n.centre,o[w+1]+(r[w+1]-o[w+1])*(L+1)/u,(e.startBin+w+1.5)*n.binStepDeg);E=Math.max(E,Math.hypot(T.x-D.x,T.y-D.y))}for(let w=0;w<l;w++){let L=(e.startBin+w+.5)*n.binStepDeg;for(let D=0;D<=u;D++){let T=Vt(n.centre,o[w]+(r[w]-o[w])*D/u,L),N=c(T.x,T.y,E*1.01);N!==null&&(d[w][D]=Math.min(d[w][D],Math.max(h+ms,N-ms)))}}}let y=[i.bandTop[0]*s.top,i.bandTop[1]*s.top,i.bandTop[2]*s.top],x=[i.bandTop[0]*s.bottomCap,i.bandTop[1]*s.bottomCap,i.bandTop[2]*s.bottomCap],M=[i.bandWall[0]*s.top,i.bandWall[1]*s.top,i.bandWall[2]*s.top],p=[i.bandWall[0]*s.wallBottom,i.bandWall[1]*s.wallBottom,i.bandWall[2]*s.wallBottom],g=(E,w)=>{let L=(e.startBin+E+.5)*n.binStepDeg,D=o[E]+(r[E]-o[E])*w/u,T=Vt(n.centre,D,L);return[T.x*f,d[E][w],T.y*f]};{let E=Math.tan(12*Math.PI/180);for(let w=0;w<6;w++){let L=!1;for(let T=0;T<l;T++)for(let N=u-1;N>=0;N--)d[T][N]>d[T][N+1]&&(d[T][N]=d[T][N+1],L=!0);let D=e.closed?l:l-1;for(let T=0;T<D;T++){let N=(T+1)%l;for(let U=0;U<=u;U++){let j=d[N][U]-d[T][U];if(Math.abs(j)>1)continue;let G=o[T]+(r[T]-o[T])*U/u,v=o[N]+(r[N]-o[N])*U/u,X=Vt(n.centre,G,(e.startBin+T+.5)*n.binStepDeg),V=Vt(n.centre,v,(e.startBin+N+.5)*n.binStepDeg),Q=E*Math.hypot(V.x-X.x,V.y-X.y)*f;j>Q?(d[N][U]=d[T][U]+Q,L=!0):-j>Q&&(d[T][U]=d[N][U]+Q,L=!0)}}if(!L)break}}let A=1,P=(E,w)=>{for(let L=0;L<=u;L+=4)if(Math.abs(d[E][L]-d[w][L])>A)return!0;return Math.abs(d[E][u]-d[w][u])>A},b=Math.tan(38*Math.PI/180),_=E=>(r[E]-o[E])/u*f,S=(E,w)=>d[E][w+1]-d[E][w]>b*Math.max(1e-6,_(E)),R=(E,w)=>{let L=e.closed?(E-1+l)%l:Math.max(0,E-1),D=e.closed?(E+1)%l:Math.min(l-1,E+1);Math.abs(d[L][w]-d[E][w])>A&&(L=E),Math.abs(d[D][w]-d[E][w])>A&&(D=E);let T=Math.max(0,w-1),N=Math.min(u,w+1);T<w&&S(E,T)&&(T=w),N>w&&S(E,w)&&(N=w);let U=g(L,w),j=g(D,w),G=g(E,T),v=g(E,N),X=j[0]-U[0],V=j[1]-U[1],Q=j[2]-U[2],et=v[0]-G[0],tt=v[1]-G[1],J=v[2]-G[2],ft=V*J-Q*tt,mt=Q*et-X*J,ht=X*tt-V*et,rt=Math.hypot(ft,mt,ht);return rt>1e-12?(ft/=rt,mt/=rt,ht/=rt,mt<0&&(ft=-ft,mt=-mt,ht=-ht),[ft,mt,ht]):[0,1,0]},B=(E,w,L=!1)=>{let D=L&&Math.min(E[1],w[1])-a>=3,T=[E[0],D?E[1]-zn:h,E[2]],N=[w[0],D?w[1]-zn:h,w[2]],U=w[0]-E[0],j=w[2]-E[2],G=Math.hypot(U,j);if(!(G>1e-12))return;let v=[j/G,0,-U/G];t.tri(E,w,N,v,M,M,p),t.tri(E,N,T,v,M,p,p)},C=.05*Ct,O=E=>r[E]-o[E]<C,k=e.closed?l:l-1;for(let E=0;E<k;E++){let w=(E+1)%l;if(O(E)||O(w))continue;if(P(E,w)){let j=(e.startBin+E+1)*n.binStepDeg,G=(tt,J)=>{let ft=(o[E]+o[w])/2,mt=(r[E]+r[w])/2,ht=ft+(mt-ft)*J/u,rt=Vt(n.centre,ht,j);return[rt.x*f,d[tt][J],rt.y*f]};for(let tt=0;tt<u;tt++){let J=g(E,tt),ft=g(E,tt+1),mt=G(E,tt),ht=G(E,tt+1),rt=R(E,tt),yt=R(E,tt+1);t.triN(J,mt,ht,rt,rt,yt,y),t.triN(J,ht,ft,rt,yt,yt,y);let dt=g(w,tt),bt=g(w,tt+1),Bt=G(w,tt),Rt=G(w,tt+1),H=R(w,tt),F=R(w,tt+1);t.triN(Bt,dt,bt,H,H,F,y),t.triN(Bt,bt,Rt,H,F,F,y);let W=G(E,tt),Y=G(E,tt+1),q=G(w,tt+1),ot=G(w,tt),at=Y[0]-W[0],it=Y[2]-W[2],St=Math.hypot(at,it);if(St>1e-12){let $=[it/St,0,-at/St];t.tri(W,Y,q,$,M),t.tri(W,q,ot,$,M)}}let v=g(E,0),X=g(w,0),V=g(w,u),Q=g(E,u),et=tt=>[tt[0],h,tt[2]];Math.min(v[1],X[1])-a<3&&(t.tri(et(v),et(V),et(X),[0,-1,0],x),t.tri(et(v),et(Q),et(V),[0,-1,0],x)),B(v,X,!0),B(Q,V,!0);continue}for(let j=0;j<u;j++){let G=R(E,j),v=R(w,j),X=R(w,j+1),V=R(E,j+1);if(S(E,j)||S(w,j)){let ft=(Y,q)=>{let ot=(e.startBin+Y+.5)*n.binStepDeg,at=o[Y]+(r[Y]-o[Y])*(j+.5)/u,it=Vt(n.centre,at,ot);return[it.x*f,q,it.y*f]},mt=g(E,j),ht=g(w,j),rt=ft(E,d[E][j]),yt=ft(w,d[w][j]);t.triN(mt,ht,yt,G,v,v,y),t.triN(mt,yt,rt,G,v,G,y);let dt=g(w,j+1),bt=g(E,j+1),Bt=ft(E,d[E][j+1]),Rt=ft(w,d[w][j+1]);t.triN(Bt,Rt,dt,V,X,X,y),t.triN(Bt,dt,bt,V,X,V,y);let H=yt[0]-rt[0],F=yt[2]-rt[2],W=Math.hypot(H,F);if(W>1e-12){let Y=[-F/W,0,H/W];t.tri(rt,yt,Rt,Y,M),t.tri(rt,Rt,Bt,Y,M)}continue}let Q=g(E,j),et=g(w,j),tt=g(w,j+1),J=g(E,j+1);t.triN(Q,et,tt,G,v,X,y),t.triN(Q,tt,J,G,X,V,y)}let L=g(E,0),D=g(w,0),T=g(w,u),N=g(E,u),U=j=>[j[0],h,j[2]];Math.min(L[1],D[1])-a<3&&(t.tri(U(L),U(T),U(D),[0,-1,0],x),t.tri(U(L),U(N),U(T),[0,-1,0],x)),B(L,D,!0),B(N,T,!0)}if(!e.closed)for(let E of[0,l-1])for(let w=0;w<u;w++)B(g(E,w),g(E,w+1))}function hs(t,n,e){let{bottomY:o,colors:r,ao:a}=e,i=new Float64Array(n.binCount).fill(-1/0);for(let u of n.rings)for(let f of u.arcs){let m=new Float64Array(f.binCount),h=new Float64Array(f.binCount);for(let y=0;y<f.binCount;y++){let x=(f.startBin+y)%n.binCount,M=Math.max(0,f.innerR[y]-Gt);m[y]=Math.max(M,i[x]+.001),h[y]=Math.max(m[y]+.001,f.outerR[y]+Gt)}let d=0;for(let y=0;y<f.binCount;y++){let x=f.topLevelM[y]-o;x>d&&(d=x)}d>=tf&&lf(t,n,f,m,h,o,r,a,e.standTopNear);for(let y=0;y<f.binCount;y++){let x=(f.startBin+y)%n.binCount;h[y]>i[x]&&(i[x]=h[y])}}if(e.deriveShell===!1||sf(e.shapes,n))return;let s=n.rings[n.rings.length-1],c=nf*Ct,l=ef*Ct;for(let u of s.arcs){let f=[],m=[];for(let R=0;R<u.binCount;R++){let B=(u.startBin+R+.5)*n.binStepDeg,C=u.outerR[R]+Gt+c;f.push(Vt(n.centre,C,B)),m.push(Vt(n.centre,C+l,B))}let h=-1/0;for(let R=0;R<u.binCount;R++)u.topLevelM[R]>h&&(h=u.topLevelM[R]);let d=h+of,y=u.closed?m:[...m,...f.slice().reverse()],x=u.closed?[f.slice().reverse()]:void 0,M=ct(r.shellWall,[.66,.71,.72],.62),p=(R,B,C,O,k)=>{let E=Math.abs(O-h)<1e-6?O-Ju:O;Yt(t,R,C,E,e.shapes,r.shellTop,k,{holes:B,portalBase:o,ao:a})||Z(t,R,B,()=>E,C,r.shellTop,k,a)},g=Math.max(1,Math.ceil((h-o)/4.5)),A=(h-o)/g,P=new Set,b=e.tierFrontLevels??n.rings.map(R=>{let B=R.arcs.flatMap(C=>Array.from(C.frontLevelM)).filter(Number.isFinite).sort((C,O)=>C-O);return B[Math.floor(B.length/2)]});for(let R of b)Number.isFinite(R)&&R-o>=3&&R<h&&P.add(Math.max(0,Math.min(g-1,Math.floor((R-o)/A))));let _=Math.min(...b.filter(R=>Number.isFinite(R)&&R-o>=3&&R<h));for(let R=0;R<g;R++)o+(R+1)*A<=_-zn&&Number.isFinite(_)&&P.add(R);for(let R=0;R<g;R++){let B=o+(h-o)*R/g,C=o+(h-o)*(R+1)/g;P.has(R)&&C-B>=3.2?(p(y,x,B,B+.45,M),Ro(t,f,m,u.closed,B+.45,C-.16,r.shellTop,M,a,e.shapes,o)):p(y,x,B,C-.16,M),p(y,x,C-.16,C,z(M,.62))}Ro(t,f,m,u.closed,h,d,r.shellTop,M,a,e.shapes,o);let S=8;for(let R=1;R<m.length;R++){if(S+=Math.hypot(m[R].x-m[R-1].x,m[R].y-m[R-1].y)*nt,S<8)continue;S=0;let B=m[R],C=m[R-1],O=B.x-C.x,k=B.y-C.y,E=Math.max(1,Math.hypot(O,k)),w=O/E*.16*Ct,L=k/E*.16*Ct,D=Math.max(1,Math.hypot(B.x-n.centre.x,B.y-n.centre.y)),T=(B.x-n.centre.x)/D*.24*Ct,N=(B.y-n.centre.y)/D*.24*Ct,U=[{x:B.x-w,y:B.y-L},{x:B.x+w,y:B.y+L},{x:B.x+w+T,y:B.y+L+N},{x:B.x-w+T,y:B.y-L+N}];p(U,void 0,o,h,z(M,1.12))}}}var uf=2.5,ys=.65,ff=2,mf=.03;function hf(t,n){let e=()=>{let o=n;for(;t.length>2;){let r=t[0],a=t[1],i=Math.hypot(a.x-r.x,a.y-r.y);if(i>o){t[0]={x:r.x+(a.x-r.x)/i*o,y:r.y+(a.y-r.y)/i*o};return}o-=i,t.shift()}};e(),t.reverse(),e(),t.reverse()}function Eo(t,n,e){let o=new Map;for(let a of t){let i=o.get(a.blockId);(!i||a.depth<i.depth)&&o.set(a.blockId,a)}let r=[];for(let[a,i]of o){if(i.y-e<uf||i.pts.length<2)continue;let s=i.pts.map(u=>{let f=u.x-n.x,m=u.y-n.y,h=Math.max(1,Math.hypot(f,m));return{x:u.x-f/h*ys/I,y:u.y-m/h*ys/I}}),c=[],l=[s[0]];for(let u=1;u<s.length;u++){let f=s[u-1],m=s[u];Math.hypot(m.x-f.x,m.y-f.y)*I>ff?(l.length>=2&&c.push(l),l=[m]):l.push(m)}l.length>=2&&c.push(l);for(let u of c)hf(u,mf/I);c.length&&r.push({blockId:a,y:i.y,runs:c})}return r}var ds=.1,yf=1.1,df=.22,Po=.95,Ao=.05,ps=1.8;function xs(t,n,e,o){let r=[.72,.72,.69],a=[.48,.55,.57];for(let i of Eo(n,e,o)){let s=i.y;for(let c of i.runs){let l=ps;for(let u=1;u<c.length;u++){let f=c[u-1],m=c[u],h=m.x-f.x,d=m.y-f.y,y=Math.hypot(h,d);if(y<1e-5)continue;let x=M=>{let p=-d/y*M/I/2,g=h/y*M/I/2;return[{x:f.x+p,y:f.y+g},{x:m.x+p,y:m.y+g},{x:m.x-p,y:m.y-g},{x:f.x-p,y:f.y-g}]};if(Z(t,x(df),void 0,()=>s+ds,s-yf,r,r,K),Z(t,x(Ao),void 0,()=>s+Po,s+Po-Ao,a,a,K),l+=y*I,l>=ps||u===c.length-1){l=0;let M=.028/I,p=[{x:f.x-M,y:f.y-M},{x:f.x+M,y:f.y-M},{x:f.x+M,y:f.y+M},{x:f.x-M,y:f.y+M}];Z(t,p,void 0,()=>s+Po-Ao,s+ds,a,a,K)}}}}}var pf=.9,xf=1.5,bf=.3;function bs(t,n,e){let o=[],r=[],a=pf/I,i=xf/I,s=bf/I;for(let c of t)for(let l of c.runs){if(l.length<2)continue;let u=l.slice(),f=(x,M)=>{let p=u[x],g=u[M],A=Math.hypot(p.x-g.x,p.y-g.y)||1;u[x]={x:p.x+(p.x-g.x)/A*s,y:p.y+(p.y-g.y)/A*s}};f(0,1),f(u.length-1,u.length-2);let m=u.map((x,M)=>{let p=u[Math.max(0,M-1)],g=u[Math.min(u.length-1,M+1)],A=g.x-p.x,P=g.y-p.y,b=Math.hypot(A,P)||1,_=-P/b,S=A/b;return _*(x.x-n.x)+S*(x.y-n.y)<0&&(_=-_,S=-S),{nx:_,ny:S}}),h=u.map((x,M)=>({x:x.x-m[M].nx*i,y:x.y-m[M].ny*i})),d=u.map((x,M)=>({x:x.x+m[M].nx*a,y:x.y+m[M].ny*a})),y=u.map((x,M)=>({x:x.x+m[M].nx*(a+e/I),y:x.y+m[M].ny*(a+e/I)}));o.push([...h,...d.slice().reverse()]),r.push([...d,...y.reverse()])}return{bays:o,walls:r}}var wo=.88,Be=.27,gf=1.2,Mf=.01,Rf=7,_f=.05,If=.25;function gs(t,n,e,o,r){let a=[.67,.71,.68],i=[a[0]*wo,a[1]*wo,a[2]*wo],s=c=>!!r&&r.some((l,u)=>u!==c&&l?.belowY!=null&&Math.abs(l.belowY-n[c].y)<1e-6&&n[u].blockId===n[c].blockId);for(let c=0;c<n.length;c++){let l=n[c];if(!(l.pts.length<2))for(let u of[0,l.pts.length-1]){let f=l.pts[u],m=l.pts[u===0?1:u-1],h=f.x-m.x,d=f.y-m.y,y=Math.hypot(h,d);if(y<1e-5)continue;h/=y,d/=y;let x=1/0;for(let w=0;w<e.length;w++){let L=e[w],D=e[(w+1)%e.length],T=D.x-L.x,N=D.y-L.y,U=h*N-d*T;if(Math.abs(U)<1e-8)continue;let j=L.x-f.x,G=L.y-f.y,v=(j*N-G*T)/U,X=(j*d-G*h)/U;v>0&&X>=0&&X<=1&&(x=Math.min(x,v))}let M=.3/I,p=x-.04/I;if(!Number.isFinite(x)||x*I>2||p-M<.12/I)continue;let g=!!o&&s(c),A=r?.[c]?.pitch,P=g&&A&&Number.isFinite(A)?Math.min(gf/I,Math.max(Be/I,A-Be/I-Mf/I)):Be/I,b=-d,_=h;o&&b*(o.x-f.x)+_*(o.y-f.y)<0&&(b=-b,_=-_);let S=Be/I,R=[{x:f.x+h*M+b*S,y:f.y+d*M+_*S},{x:f.x+h*p+b*S,y:f.y+d*p+_*S},{x:f.x+h*p-b*P,y:f.y+d*p-_*P},{x:f.x+h*M-b*P,y:f.y+d*M-_*P}];if(!R.every(w=>Mt(e,w.x,w.y)))continue;let B=r?.[c]?.belowY,C=B==null?0:l.y-B,O=!!o&&C>.03&&C<=.65;if(O&&o){let w=(L,D)=>Math.hypot((L.x+D.x)/2-o.x,(L.y+D.y)/2-o.y);w(R[0],R[1])>w(R[3],R[2])&&(R=[R[3],R[2],R[1],R[0]])}let k=O?Math.ceil((C-1e-8)/.2):1,E=(w,L,D)=>({x:w.x+(L.x-w.x)*D,y:w.y+(L.y-w.y)*D});for(let w=0;w<k;w++){let L=w/k,D=(w+1)/k,T=[E(R[0],R[3],L),E(R[1],R[2],L),E(R[1],R[2],D),E(R[0],R[3],D)],N=l.y+.008-(O?C*(1-D):0);if(Z(t,T,void 0,()=>N,N-(O?C/k+.1:.16),a,i,K),!O)continue;let U=Math.hypot(T[3].x-T[0].x,T[3].y-T[0].y)*I;if(U<1e-4)continue;let j=Math.min(_f/U,If),G=E(T[0],T[3],j),v=E(T[1],T[2],j),X=Q=>[Q.x*I,N+.004,Q.y*I],V=[.8,.67,.3];t.setMaterial(Rf),t.tri(X(T[0]),X(T[1]),X(v),[0,1,0],V),t.tri(X(T[0]),X(v),X(G),[0,1,0],V),t.setMaterial(0)}}}}var Sf=.02,Pf=.012,Af=.01,Ef=.3,wf=.5;function Bf(t,n,e){if(t.length===1)return Math.hypot(n-t[0].x,e-t[0].y);let o=1/0;for(let r=0;r+1<t.length;r++){let a=t[r],i=t[r+1],s=i.x-a.x,c=i.y-a.y,l=s*s+c*c,u=l>1e-12?((n-a.x)*s+(e-a.y)*c)/l:0;u=Math.max(0,Math.min(1,u)),o=Math.min(o,Math.hypot(n-(a.x+u*s),e-(a.y+u*c)))}return o}function Of(t,n,e,o){let r=1/0,a=Number.NaN;for(let i=0;i<t.length;i++){let s=n[i];if(Math.hypot(e-s.cx,o-s.cy)-s.rad>=r)continue;let c=Bf(t[i].pts,e,o);c<r&&(r=c,a=t[i].y)}return a}function Ms(t,n,e,o,r,a,i){let s=o.filter(m=>m.pts.length>0);if(s.length<2||n.length<3)return;let c=s.map(m=>{let h=0,d=0;for(let x of m.pts)h+=x.x,d+=x.y;h/=m.pts.length,d/=m.pts.length;let y=0;for(let x of m.pts)y=Math.max(y,Math.hypot(x.x-h,x.y-d));return{cx:h,cy:d,rad:y}}),l=[...n],u=e.map(m=>[...m]),f=Sf/I;for(let m of[l,...u])for(let h=0;h<m.length;h++){let d=m[h],y=m[(h+1)%m.length],x=y.x-d.x,M=y.y-d.y,p=Math.hypot(x,M);if(p*I<.05)continue;let g=(d.x+y.x)/2,A=(d.y+y.y)/2,P=M/p,b=-x/p;Lt({x:g+P*f,y:A+b*f},l,u)&&(P=-P,b=-b);let _=r.x-g,S=r.y-A,R=Math.hypot(_,S)||1;if((P*_+b*S)/R>wf)continue;let B=1/0;for(let T of[.2,.5,.8]){let N=Of(s,c,d.x+x*T-P*f*2,d.y+M*T-b*f*2);Number.isFinite(N)&&(B=Math.min(B,N))}if(!Number.isFinite(B)||B-a<Ef)continue;let C=a-Af,O=B-Pf,k={x:(d.x-P*f)*I,z:(d.y-b*f)*I},E={x:(y.x-P*f)*I,z:(y.y-b*f)*I},w=[P,0,b],L=z(i,K.wallBottom),D=z(i,K.top);t.tri([k.x,O,k.z],[E.x,O,E.z],[E.x,C,E.z],w,D,D,L),t.tri([k.x,O,k.z],[E.x,C,E.z],[k.x,C,k.z],w,D,L,L)}}function Rs(t,n,e,o,r,a,i,s,c=!1){if(!n.outline||n.outline.length<3)return;let l=e.baseHeightM,u=e.objects.filter(p=>p.type==="shape"&&(p.role==="entrance"||p.role==="exit")),f=pr(o,s.tierTop);if(!r)return;let m=p=>r.deckAt(p.x,p.y),h=Cr(n,i),d=h[0]??n.outline;if(r.rowLevels.length>=2){let p=ue(r.rowLevels),g=Lr(Er(r.rowLevels,e.focal,p),h),A=bs(Eo(r.rowLevels,e.focal,l),e.focal,So);for(let b of g){let _=Math.max(l,b.topY-_s);for(let S of a.subtract(b.outline,_))fs(t,S,b.holes,_,l,s.tierTop,s.tierWall,u,!c,A);t.setMaterial(5),Ms(t,b.outline,b.holes,r.rowLevels,e.focal,_,s.tierWall),t.setMaterial(0)}g.length||Z(t,d,n.holes,()=>r.landingY,l,f,s.tierWall,K);let P={tread:[f[0]*K.top,f[1]*K.top,f[2]*K.top],riser:[f[0]*.72,f[1]*.72,f[2]*.72]};for(let b of h.length?h:[d])Br(t,r.rowLevels,e.focal,r.landingY,P,b,p);xs(t,r.rowLevels,e.focal,l),gs(t,r.rowLevels,n.outline,e.focal,p);return}let y=r.flat?1/0:Qr,x=p=>r.normalAt(p.x,p.y),M=r.flat?r.landingY:void 0;for(let p of a.subtract(d,M))Z(t,p,n.holes,m,l,f,s.tierWall,K,y,x)}function Tf(t,n,e){let o=new Set;for(let i of t.objects)i.type==="section"&&o.add(i.id);let r=new Map;for(let i=0;i<n.length;i++){let s=e.seatOwner[i];if(!s||!o.has(s))continue;let c=e.bySection.get(s);if(c&&c.rowLevels.length>=2)continue;let l=n[i];if(l.kind==="booth")continue;let u=r.get(s);u||(u=new Map,r.set(s,u));let f=l.rowId||`__seat-${i}`,m=u.get(f);m||(m={pts:[],levelM:0,n:0},u.set(f,m)),m.pts.push({x:l.x,y:l.y}),m.levelM+=e.seatDeckY(i),m.n++}let a=[];for(let i of t.objects){if(i.type!=="section")continue;let s=e.bySection.get(i.id);if(s&&s.rowLevels.length>=2){let l=s.rowLevels.filter(u=>!u.patch).map(u=>({pts:u.pts,levelM:u.y}));l.length>=2&&a.push({sectionId:i.id,rows:l});continue}let c=r.get(i.id);c&&a.push({sectionId:i.id,rows:[...c.values()].map(l=>({pts:l.pts,levelM:l.levelM/l.n}))})}return a}function kf(t,n){let e=1/0;for(let o=0;o<n.length;o++){let r=n[o],a=n[(o+1)%n.length],i=a.x-r.x,s=a.y-r.y,c=Math.max(0,Math.min(1,((t.x-r.x)*i+(t.y-r.y)*s)/(i*i+s*s||1)));e=Math.min(e,Math.hypot(t.x-r.x-c*i,t.y-r.y-c*s))}return e}var _s=.02;function Cf(t,n){let e=t.objects.filter(o=>o.type==="section"&&!!o.outline&&o.outline.length>=3).flatMap(o=>{let r=n.bySection.get(o.id);if(!r)return[];let a=1/0,i=-1/0,s=1/0,c=-1/0;for(let u of o.outline)u.x<a&&(a=u.x),u.x>i&&(i=u.x),u.y<s&&(s=u.y),u.y>c&&(c=u.y);let l=r.landingY;for(let u of r.rowLevels)l=Math.min(l,u.y-_s);return[{outline:o.outline,holes:o.holes,surface:r,floorTop:l,minX:a,maxX:i,minY:s,maxY:c}]});return(o,r,a)=>{let i=null;for(let s of e){if(o<s.minX-a||o>s.maxX+a||r<s.minY-a||r>s.maxY+a)continue;let c={x:o,y:r};if(!Lt(c,s.outline,s.holes)&&kf(c,s.outline)>a)continue;let l=Math.min(s.surface.deckAt(o,r),s.floorTop);(i===null||l<i)&&(i=l)}return i}}var Lf=3,Ff=.4;function Is(t,n,e,o,r,a,i=!0){let s=Tf(n,e,o);if(s.length<Lf)return;let c=tr(s,n.focal);if(!c)return;let l=Math.max(0,...c.rings.map(u=>u.arcs.reduce((f,m)=>f+m.binCount,0)))/c.binCount;t.setMaterial(5),hs(t,c,{bottomY:n.baseHeightM,tierFrontLevels:s.map(u=>Math.min(...u.rows.map(f=>f.levelM))),colors:{bandTop:z(r.tierTop,.8),bandWall:r.tierWall,shellTop:a??z(r.tierWall,1.15),shellWall:a??r.tierWall},ao:K,shapes:n.objects.filter(u=>u.type==="shape"),deriveShell:i&&l>=Ff,standTopNear:Cf(n,o)}),t.setMaterial(0)}function Ss(t){let{doc:n,units:e,seats:o,surfaces:r,solids:a,hintedSeatFloor:i,seatFloor:s}=t,c=[];{let l=e.map(()=>({minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}));for(let m=0;m<a.floor.length;m+=1){let h=Math.max(0,Math.min(e.length-1,Math.round(a.floor[m]))),d=m*3,y=l[h];y.minX=Math.min(y.minX,a.position[d]),y.minY=Math.min(y.minY,a.position[d+1]),y.minZ=Math.min(y.minZ,a.position[d+2]),y.maxX=Math.max(y.maxX,a.position[d]),y.maxY=Math.max(y.maxY,a.position[d+1]),y.maxZ=Math.max(y.maxZ,a.position[d+2])}let u=new Map;for(let m=0;m<e.length;m++)for(let h of e[m].objects)h.type==="section"&&u.set(h.id,m);let f=e.map(()=>({n:0,minX:1/0,minY:1/0,minDeck:1/0,maxX:-1/0,maxY:-1/0,maxDeck:-1/0,sumX:0,sumDeck:0,sumZ:0}));for(let m=0;m<o.length;m++){let h=r.seatOwner[m],d=(h!==null?u.get(h):void 0)??i[m];if(d===void 0)continue;let y=f[d],x=o[m];y.n++,x.x<y.minX&&(y.minX=x.x),x.y<y.minY&&(y.minY=x.y),x.x>y.maxX&&(y.maxX=x.x),x.y>y.maxY&&(y.maxY=x.y);let M=r.seatDeckY(m);y.sumX+=x.x*I,y.sumDeck+=M,y.sumZ+=x.y*I,y.minDeck=Math.min(y.minDeck,M),y.maxDeck=Math.max(y.maxDeck,M+1.6),s[m]=d}for(let m=0;m<e.length;m++){let h=f[m],d=n.floors?.[m],y=l[m],x=Math.min(h.n?h.minX*I:e[m].focal.x*I-1,Number.isFinite(y.minX)?y.minX:1/0),M=Math.max(h.n?h.maxX*I:e[m].focal.x*I+1,Number.isFinite(y.maxX)?y.maxX:-1/0),p=Math.min(h.n?h.minY*I:e[m].focal.y*I-1,Number.isFinite(y.minZ)?y.minZ:1/0),g=Math.max(h.n?h.maxY*I:e[m].focal.y*I+1,Number.isFinite(y.maxZ)?y.maxZ:-1/0),A=Math.min(h.n?Math.min(e[m].baseHeightM,h.minDeck):e[m].baseHeightM,Number.isFinite(y.minY)?y.minY:1/0),P=Math.max(h.n?Math.max(h.maxDeck,A+.5):A+.5,Number.isFinite(y.maxY)?y.maxY:-1/0),b=[h.n?h.sumX/h.n:(x+M)/2,h.n?h.sumDeck/h.n:(A+P)/2,h.n?h.sumZ/h.n:(p+g)/2],_=Math.max(1,.5*Math.hypot(M-x,P-A,g-p));c.push({index:m,id:d?.id??`floor-${m}`,label:d?.name??(e.length>1?`Floor ${m+1}`:"Venue"),seatCount:h.n,center:b,radius:_,box:{min:[x,A,p],max:[M,P,g]},focalWorld:[e[m].focal.x*I,e[m].baseHeightM+1.5,e[m].focal.y*I]})}}return c}function ko(t,n){let e=1/0,o=1/0,r=-1/0,a=-1/0,i=(s,c)=>{s<e&&(e=s),c<o&&(o=c),s>r&&(r=s),c>a&&(a=c)};for(let s of n)i(s.x,s.y);for(let s of t)for(let c of s.objects)if(c.type==="section")for(let l of c.outline)i(l.x,l.y);else if(c.type==="shape"&&c.points)for(let l of c.points)i(l.x,l.y);else if(c.type==="gaArea")for(let l of c.points)i(l.x,l.y);else if(c.type==="booth"){let l=Ht(c);if(l)for(let u of l)i(u.x,u.y)}else if(c.type==="table"){let l=Pe(c);if(l)for(let u of l)i(u.x,u.y)}else if(c.type==="decorImage"){let l=Ae(c);if(l)for(let u of l)i(u.x,u.y)}return Number.isFinite(e)||(e=-100,o=-100,r=100,a=100),{minX:e,minY:o,maxX:r,maxY:a}}function Ts(t,n,e,o,r,a){if(n.length===1){let i=e.map(f=>({x:f.x,y:f.y}));for(let f of n[0].objects)f.type==="section"?i.push(...f.outline):f.type==="shape"?i.push(...st(f)??f.points??[]):f.type==="gaArea"?i.push(...f.points):f.type==="booth"?i.push(...Ht(f)??[]):f.type==="table"?i.push(...Pe(f)??[]):f.type==="decorImage"&&i.push(...Ae(f)??[]);if(ws(t,n[0],e,a)||Os(t,n[0],e,i,a))return!1;if(Es(t,n[0].baseHeightM,i,a))return!0;let s=kn(i),c=(r.minX+r.maxX)/2,l=(r.minY+r.maxY)/2,u=s.length>=3?s.map(f=>{let m=f.x-c,h=f.y-l,d=Math.max(1,Math.hypot(m,h));return{x:f.x+m/d*80,y:f.y+h/d*80}}):On(r.minX-28,r.minY-28,r.maxX-r.minX+56,r.maxY-r.minY+56);return Z(t,u,void 0,()=>-.04,-.22,a.ground,a.ground,K),!1}else{let i=n.reduce((y,x)=>x.baseHeightM<y.baseHeightM?x:y);t.setFloor(i.index);let s={...i,objects:n.flatMap(y=>y.objects)},c=e.map(y=>({x:y.x,y:y.y}));for(let y of s.objects)y.type==="section"&&c.push(...y.outline);if(ws(t,s,e,a)||Os(t,s,e,c,a))return!1;if(Es(t,i.baseHeightM,c,a))return!0;let l=e.filter((y,x)=>o[x]===i.index),u=ko([i],l),f=Math.hypot(u.maxX-u.minX,u.maxY-u.minY),m=Math.max(28,Math.min(80,f*.04)),h=On(u.minX-m,u.minY-m,u.maxX-u.minX+m*2,u.maxY-u.minY+m*2),d=i.baseHeightM-.03;return Z(t,h,void 0,()=>d,d-.22,a.ground,a.ground,K),!1}}function Co(t,n,e,o){let{cx:r,cz:a,radius:i}=e,s=1/0,c=1/0,l=1/0,u=-1/0,f=-1/0,m=-1/0,h=(x,M,p)=>{s=Math.min(s,x),u=Math.max(u,x),c=Math.min(c,M),f=Math.max(f,M),l=Math.min(l,p),m=Math.max(m,p)};for(let x=0;x<t.position.length;x+=3){let M=x/3;o&&M>=o[0]&&M<o[1]||h(t.position[x],t.position[x+1],t.position[x+2])}for(let x=0;x<n.count;x++){let M=x*3,p=n.iPosition[M],g=n.iPosition[M+1],A=n.iPosition[M+2],P=Math.max(.35,n.iMaxRadius[x]??.35);h(p-P,g,A-P),h(p+P,g+1.6,A+P)}Number.isFinite(s)||(s=r-i,u=r+i,c=0,f=i*.16,l=a-i,m=a+i);let d=[(s+u)/2,(c+f)/2,(l+m)/2],y=Math.max(1,.5*Math.hypot(u-s,f-c,m-l));return{center:d,radius:y,minY:c,maxY:f}}var Gf=4096;function ks(t,n,e=[]){let o=Math.max(1,Math.ceil(t.count/Gf)),r=Math.ceil(t.count/o),a=new Float32Array((r*2+n.length*4+e.length)*3),i=0;for(let s=0;s<t.count;s+=o){let c=t.iPosition[s*3],l=t.iPosition[s*3+1],u=t.iPosition[s*3+2];a[i++]=c,a[i++]=l,a[i++]=u,a[i++]=c,a[i++]=0,a[i++]=u}for(let[s,c,l]of e)a[i++]=s,a[i++]=c,a[i++]=l;for(let s of n)for(let[c,l]of[[-1,-1],[1,-1],[1,1],[-1,1]])a[i++]=s.cx+c*s.halfX,a[i++]=s.y,a[i++]=s.cz+l*s.halfZ;return a.subarray(0,i)}function Cs(t,n,e,o,r,a,i=[]){let s=1/0,c=1/0,l=-1/0,u=-1/0;for(let P=0;P<t.count;P++){let b=P*3,_=t.iPosition[b],S=t.iPosition[b+2];_<s&&(s=_),_>l&&(l=_),S<c&&(c=S),S>u&&(u=S)}for(let[P,,b]of i)P<s&&(s=P),P>l&&(l=P),b<c&&(c=b),b>u&&(u=b);for(let P of n)s=Math.min(s,P.cx-P.halfX),l=Math.max(l,P.cx+P.halfX),c=Math.min(c,P.cz-P.halfZ),u=Math.max(u,P.cz+P.halfZ);let f=e.minX*I,m=e.maxX*I,h=e.minY*I,d=e.maxY*I,y=f,x=m,M=h,p=d;if(Number.isFinite(s)){let P=Math.max(2,.06*Math.hypot(l-s,u-c));y=Math.max(f,s-P),x=Math.min(m,l+P),M=Math.max(h,c-P),p=Math.min(d,u+P)}let g=Math.min(0,o),A=Math.max(r,a*.05);return{min:[y,g,M],max:[x,A,p]}}var Bo=12,Nf=.5,Df=6,Oo=.8,Ps=5,vf=.6,Hf=40,To=0,As=8;function Es(t,n,e,o){let r=kn([...e]);if(r.length<3)return!1;let a=1/0,i=1/0,s=-1/0,c=-1/0;for(let P of r)a=Math.min(a,P.x),s=Math.max(s,P.x),i=Math.min(i,P.y),c=Math.max(c,P.y);let l=Math.hypot(s-a,c-i)*I,u=Math.max(Hf,l*vf),f=P=>Wt(r,P/I,1.2),m=f(Nf),h=[m,f(Df),f(Bo),f(Bo+Ps),f(Bo+Ps+u)];if(h.some(P=>P.length!==m.length))return!1;let d=ct(o.ground,[.78,.76,.72],.35),y=ct(o.ground,[.56,.62,.52],.3),x=[d[0]*Oo,d[1]*Oo,d[2]*Oo],M=n-.04;t.setMaterial(To),Z(t,m,void 0,()=>M,n-.22,x,x,K);let p=[0,1,0],g=(P,b,_,S,R)=>{let B=P.map(E=>[E.x*I,M,E.y*I]),C=b.map(E=>[E.x*I,M,E.y*I]),[O,k]=R;for(let E=0;E<B.length;E++){let w=(E+1)%B.length;t.tri(B[E],C[w],C[E],p,_,S,S,[O,k,k]),t.tri(B[E],B[w],C[w],p,_,_,S,[O,O,k])}},A=[To,To];return g(h[0],h[1],x,d,A),g(h[1],h[2],d,d,A),g(h[2],h[3],d,y,A),g(h[3],h[4],y,y,[As,As+1]),t.setMaterial(0),!0}function ws(t,n,e,o){let r=qt(n,e);if(!r)return!1;let a=n.baseHeightM,i=ct(o.ground,[.62,.55,.47],.4);return Z(t,r,void 0,()=>a-.04,a-.22,i,i,K),!0}var Uf=3e3,Xf=20,Bs=1.5,jf=1.2,Wf=.25;function Os(t,n,e,o,r){if(!e.length||e.length>Uf||o.length<3)return!1;for(let R of n.objects){if(R.type==="shape"&&en(R.stageKind))return!1;if(R.type==="section"){let{height:B}=yn(R,{floorBaseHeightM:n.baseHeightM});if(B-n.baseHeightM>Xf)return!1}}let a=0,i=0;for(let R of o)a+=R.x,i+=R.y;a/=o.length,i/=o.length;let s=0,c=0,l=0;for(let R of o){let B=R.x-a,C=R.y-i;s+=B*B,c+=C*C,l+=B*C}let u=.5*Math.atan2(2*l,s-c),f=Math.cos(u),m=Math.sin(u),h=-m,d=f,y=1/0,x=-1/0,M=1/0,p=-1/0;for(let R of o){let B=(R.x-a)*f+(R.y-i)*m,C=(R.x-a)*h+(R.y-i)*d;y=Math.min(y,B),x=Math.max(x,B),M=Math.min(M,C),p=Math.max(p,C)}let g=R=>[[y-R,M-R],[x+R,M-R],[x+R,p+R],[y-R,p+R]].map(([B,C])=>({x:a+f*B+h*C,y:i+m*B+d*C})),A=g(Bs/I),P=g((Bs+Wf)/I),b=n.baseHeightM,_=ct(r.ground,[.62,.55,.47],.4),S=ct(r.ground,[.86,.86,.84],.55);return Z(t,P,void 0,()=>b-.04,b-.22,_,_,K),Z(t,P,[A.slice().reverse()],()=>b+jf,b-.04,ct(S,[1,1,1],.2),S,K),!0}function Ls(t,n,e){let o=()=>({byObjectId:new Map,elements:[]});if(!n||!t)return o();let r=Fo(n);if(!r.ok||r.value.id!==t)return o();let a=new Map;for(let f of e)for(let m of f.objects)m.type==="shape"&&a.set(m.id,{shape:m,unit:f});let i=new Set,s=new Set,c=new Map((n.overlay.productionElements??[]).map(f=>{let m=f.runtimeContentImageUrl;return[f.id,typeof m=="string"&&/^(?:blob:|data:image\/|https:\/\/)/.test(m)?m:void 0]})),l=[];for(let f of r.value.overlay.productionElements??[]){let m=a.get(f.objectId),h=m?st(m.shape):null,d=f.baseElevationM??0;if(!m||!h||h.length<3||!f.id||i.has(f.id)||s.has(f.objectId)||!Number.isFinite(f.heightM)||f.heightM<.05||f.heightM>50||!Number.isFinite(d)||d<-10||d>100)return o();i.add(f.id),s.add(f.objectId);let y=h.map(S=>S.x*I),x=h.map(S=>S.y*I),M=m.unit.baseHeightM+d,p=Math.min(...y),g=Math.max(...y),A=Math.min(...x),P=Math.max(...x),b,_=c.get(f.id)??f.contentImageUrl;if(f.kind==="screen"&&_&&(b=Zr(h,M,M+f.heightM,m.unit.focal),!b))if(g-p>=P-A){let S=Math.abs(A-m.unit.focal.y*I)<=Math.abs(P-m.unit.focal.y*I)?A-.006:P+.006;b=[[p,M,S],[g,M,S],[p,M+f.heightM,S],[g,M+f.heightM,S]]}else{let S=Math.abs(p-m.unit.focal.x*I)<=Math.abs(g-m.unit.focal.x*I)?p-.006:g+.006;b=[[S,M,A],[S,M,P],[S,M+f.heightM,A],[S,M+f.heightM,P]]}l.push({id:f.id,objectId:f.objectId,kind:f.kind,floorIndex:m.unit.index,baseY:M,topY:M+f.heightM,bounds:{min:[p,M,A],max:[g,M+f.heightM,P]},occlusion:f.occlusion,..._?{contentImageUrl:_}:{},...b?{contentPlane:b}:{}})}let u=l.sort((f,m)=>f.id.localeCompare(m.id));return{byObjectId:new Map(u.map(f=>[f.objectId,f])),elements:u}}function Vf(t){let n=Math.min(1,Math.max(0,t));return n<=.0031308?n*12.92:1.055*Math.pow(n,1/2.4)-.055}function It(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function wt(t){return Array.isArray(t)?t:[]}function Kf(t){let n=[t];for(;n.length;){let e=n.pop();if(Array.isArray(e)){n.push(...e);continue}if(!It(e))continue;let o=It(e.extensions)?e.extensions:null;if(o&&Object.prototype.hasOwnProperty.call(o,"KHR_draco_mesh_compression"))return!0;n.push(...Object.values(e))}return!1}function Yn(t,n){return!Array.isArray(t)||t.length!==n||!t.every(e=>typeof e=="number"&&Number.isFinite(e))?null:t}function zf(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Yf(t,n){let e=new Array(16).fill(0);for(let o=0;o<4;o++)for(let r=0;r<4;r++)for(let a=0;a<4;a++)e[o*4+r]+=t[a*4+r]*n[o*4+a];return e}function Zf(t){let n=Yn(t.matrix,16);if(n)return n;if(t.matrix!==void 0)return null;let e=t.translation===void 0?[0,0,0]:Yn(t.translation,3),o=t.rotation===void 0?[0,0,0,1]:Yn(t.rotation,4),r=t.scale===void 0?[1,1,1]:Yn(t.scale,3);if(!e||!o||!r)return null;let[a,i,s,c]=o,l=Math.hypot(a,i,s,c);if(!(l>1e-8))return null;let u=a/l,f=i/l,m=s/l,h=c/l,d=u+u,y=f+f,x=m+m,M=u*d,p=u*y,g=u*x,A=f*y,P=f*x,b=m*x,_=h*d,S=h*y,R=h*x;return[(1-(A+b))*r[0],(p+R)*r[0],(g-S)*r[0],0,(p-R)*r[1],(1-(M+b))*r[1],(P+_)*r[1],0,(g+S)*r[2],(P-_)*r[2],(1-(M+A))*r[2],0,e[0],e[1],e[2],1]}function $f(t,n,e,o){return[t[0]*n+t[4]*e+t[8]*o+t[12],t[1]*n+t[5]*e+t[9]*o+t[13],t[2]*n+t[6]*e+t[10]*o+t[14]]}function qf(t){let n=t[0],e=t[4],o=t[8],r=t[1],a=t[5],i=t[9],s=t[2],c=t[6],l=t[10],u=a*l-i*c,f=i*s-r*l,m=r*c-a*s,h=n*u+e*f+o*m;if(Math.abs(h)<1e-12)return null;let d=1/h;return[u*d,f*d,m*d,(o*c-e*l)*d,(n*l-o*s)*d,(e*s-n*c)*d,(e*i-o*a)*d,(o*r-n*i)*d,(n*a-e*r)*d]}function Fs(t,n,e,o){let r=t[0]*n+t[1]*e+t[2]*o,a=t[3]*n+t[4]*e+t[5]*o,i=t[6]*n+t[7]*e+t[8]*o,s=Math.hypot(r,a,i)||1;return r/=s,a/=s,i/=s,[r,a,i]}function Jf(t){if(t.byteLength<20||t.byteLength>8388608)return null;let n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0,!0)!==1179937895||n.getUint32(4,!0)!==2||n.getUint32(8,!0)!==t.byteLength)return null;let e=12,o=null,r=null;for(;e+8<=t.byteLength;){let a=n.getUint32(e,!0),i=n.getUint32(e+4,!0);if(e+=8,a%4!==0||e+a>t.byteLength)return null;let s=t.subarray(e,e+a);if(i===1313821514&&!o)try{let c=JSON.parse(new TextDecoder().decode(s).replace(/[\u0000 ]+$/g,""));if(!It(c))return null;o=c}catch{return null}else if(i===5130562&&!r)r=s;else return null;e+=a}return e===t.byteLength&&o&&r?{json:o,bin:r}:null}function Qf(t){return t===5120||t===5121?1:t===5122||t===5123?2:t===5125||t===5126?4:0}function tm(t){return t==="SCALAR"?1:t==="VEC2"?2:t==="VEC3"?3:t==="VEC4"?4:0}function nm(t,n,e){return e===5120?t.getInt8(n):e===5121?t.getUint8(n):e===5122?t.getInt16(n,!0):e===5123?t.getUint16(n,!0):e===5125?t.getUint32(n,!0):t.getFloat32(n,!0)}function em(t){let n=t instanceof Uint8Array?t:new Uint8Array(t),e=Jf(n);if(!e)return{ok:!1,issue:"invalid_glb"};let{json:o,bin:r}=e;if(!It(o.asset)||o.asset.version!=="2.0")return{ok:!1,issue:"unsupported_glb"};let a=wt(o.extensionsUsed).filter(S=>typeof S=="string");if(a.includes("KHR_draco_mesh_compression")||Kf(o))return{ok:!1,issue:"draco_not_allowed"};if(a.length||wt(o.extensionsRequired).length)return{ok:!1,issue:"unsupported_glb"};if(wt(o.images).length||wt(o.textures).length)return{ok:!1,issue:"external_resource"};let i=wt(o.buffers);if(i.length!==1||!It(i[0])||i[0].uri!==void 0||typeof i[0].byteLength!="number"||!Number.isInteger(i[0].byteLength)||i[0].byteLength<0||i[0].byteLength>r.byteLength)return{ok:!1,issue:"external_resource"};let s=wt(o.accessors),c=wt(o.bufferViews),l=wt(o.meshes),u=wt(o.nodes),f=wt(o.scenes),m=typeof o.scene=="number"?o.scene:0;if(!It(f[m]))return{ok:!1,issue:"unsupported_glb"};let h=new DataView(r.buffer,r.byteOffset,r.byteLength),d=(S,R,B,C=!1)=>{if(typeof S!="number"||!Number.isInteger(S)||!It(s[S]))return null;let O=s[S],k=typeof R=="string"?O.type===R:R.includes(O.type),E=O.componentType!==5126,w=C&&E?O.normalized===!0:O.normalized!==!0;if(!k||O.sparse!==void 0||!w||typeof O.count!="number"||!Number.isInteger(O.count)||O.count<1||typeof O.componentType!="number"||!B.includes(O.componentType)||typeof O.bufferView!="number")return null;let L=c[O.bufferView];if(!It(L)||L.buffer!==0||typeof L.byteLength!="number"||!Number.isInteger(L.byteLength)||L.byteLength<0)return null;let D=tm(O.type),T=Qf(O.componentType),N=typeof L.byteStride=="number"?L.byteStride:D*T,U=typeof L.byteOffset=="number"?L.byteOffset:0,j=typeof O.byteOffset=="number"?O.byteOffset:0,G=U+j,v=j+(O.count-1)*N+D*T;if(!Number.isInteger(N)||!Number.isInteger(U)||!Number.isInteger(j)||N<D*T||U<0||j<0||U+L.byteLength>r.byteLength||v>L.byteLength)return null;let X=[];for(let V=0;V<O.count;V++){let Q=[];for(let et=0;et<D;et++){let tt=nm(h,G+V*N+et*T,O.componentType);if(!Number.isFinite(tt))return null;Q.push(tt)}X.push(Q)}return X},y=[],x=[],M=[],p=!1,g=wt(o.materials),A=S=>{if(S===void 0)return null;if(typeof S!="number"||!Number.isInteger(S)||!It(g[S]))return!1;let R=g[S].pbrMetallicRoughness;if(R===void 0)return null;if(!It(R))return!1;if(R.baseColorFactor===void 0)return null;let B=Yn(R.baseColorFactor,4);return!B||B.some(C=>C<0||C>1)?!1:[B[0],B[1],B[2]]},P=0,b=new Set,_=(S,R)=>{if(typeof S!="number"||!Number.isInteger(S)||!It(u[S])||b.has(S))return!1;b.add(S);let B=u[S],C=Zf(B);if(!C)return!1;let O=Yf(R,C),k=qf(O);if(!k)return!1;if(B.mesh!==void 0){if(typeof B.mesh!="number")return!1;let E=l[B.mesh];if(!It(E))return!1;for(let w of wt(E.primitives)){if(!It(w)||w.mode!==void 0&&w.mode!==4||!It(w.attributes))return!1;let L=d(w.attributes.POSITION,"VEC3",[5126]),D=w.attributes.NORMAL===void 0?null:d(w.attributes.NORMAL,"VEC3",[5126]);if(!L||w.attributes.NORMAL!==void 0&&!D)return!1;let T=A(w.material);if(T===!1)return!1;let N=w.attributes.COLOR_0===void 0?null:d(w.attributes.COLOR_0,["VEC3","VEC4"],[5126,5121,5123],!0);if(w.attributes.COLOR_0!==void 0&&(!N||N.length!==L.length))return!1;let U=N?s[w.attributes.COLOR_0]:null,j=!U||U.componentType===5126?1:U.componentType===5121?1/255:1/65535,G=T!==null||N!==null;G&&(p=!0);let v=L.length;if(w.indices!==void 0){let V=typeof w.indices=="number"?s[w.indices]:null;v=It(V)?V.count:void 0}if(typeof v!="number"||!Number.isInteger(v)||v%3!==0||(P+=v/3,P>1e5))return!1;let X=w.indices===void 0?L.map((V,Q)=>[Q]):d(w.indices,"SCALAR",[5121,5123,5125]);if(!X||X.length%3!==0||X.length!==v)return!1;for(let V=0;V<X.length;V+=3){let Q=[X[V][0],X[V+1][0],X[V+2][0]];if(Q.some(J=>!Number.isInteger(J)||J<0||J>=L.length))return!1;let et=Q.map(J=>$f(O,...L[J])),tt=null;if(!D){let J=et[1][0]-et[0][0],ft=et[1][1]-et[0][1],mt=et[1][2]-et[0][2],ht=et[2][0]-et[0][0],rt=et[2][1]-et[0][1],yt=et[2][2]-et[0][2];tt=Fs([1,0,0,0,1,0,0,0,1],ft*yt-mt*rt,mt*ht-J*yt,J*rt-ft*ht)}for(let J=0;J<3;J++){if(y.push(...et[J]),x.push(...D?Fs(k,...D[Q[J]]):tt),!G){M.push(-1,-1,-1);continue}let ft=N?N[Q[J]]:null;for(let mt=0;mt<3;mt++)M.push(Vf((T?T[mt]:1)*(ft?ft[mt]*j:1)))}}}}for(let E of wt(B.children))if(!_(E,O))return!1;return b.delete(S),!0};for(let S of wt(f[m].nodes))if(!_(S,zf()))return{ok:!1,issue:P>1e5?"triangle_limit":"unsupported_glb"};return!P||y.length!==P*9||x.length!==y.length?{ok:!1,issue:"unsupported_glb"}:{ok:!0,triangleCount:P,position:new Float32Array(y),normal:new Float32Array(x),color:p?new Float32Array(M):null}}function Gs(t){try{return em(t)}catch{return{ok:!1,issue:"invalid_glb"}}}function qp(t){let{doc:n}=t,e=kr(n,t.eventConfigurationId??n.eventConfigurationId),o=ns(n.theme,is(e,t.seats)),r=o.structure,a=Ls(t.eventConfigurationId,t.eventConfiguration,e),i=t.seats,s=new ae,c=null;if(t.registeredShellGlb){let H=Gs(t.registeredShellGlb);if(H.ok){let F=H.position.length/3,W=new Float32Array(H.position.length),Y=o.materials.shell??r.tierWall,q=H.color;for(let ot=0;ot<F;ot++){let at=H.normal[ot*3+1],it=at<-.25?.4:.62+.38*Math.max(0,at),St=!!q&&q[ot*3]!==-1;W[ot*3]=(St?q[ot*3]:Y[0])*it,W[ot*3+1]=(St?q[ot*3+1]:Y[1])*it,W[ot*3+2]=(St?q[ot*3+2]:Y[2])*it}c={position:H.position,normal:H.normal,color:W,floor:new Float32Array(F).fill(-2),material:new Float32Array(F),count:F}}}let l=new Map;for(let H of e)for(let F of H.objects)l.set(F.id,H.index),F.type==="section"&&l.set(F.logicalSectionId??F.id,H.index);let u=i.map(H=>l.get(H.sectionId??"")??l.get(H.rowId??"")??0),f=ko(e,i),m=s.vertexCount,d=Ts(s,e,i,u,f,r)?s.vertexCount:m,y=xr(n,i),x=new Map,M=new Map;for(let H of n.categories??[])x.set(H.key,H.color),H.seatGlyph&&M.set(H.key,H.seatGlyph);let p=[],g=ti(e,i,u),A=new Map;i.forEach((H,F)=>{let W=g.seatDeckY(F);Number.isFinite(W)&&A.set(H.rowId,Math.min(A.get(H.rowId)??1/0,W))});let P=new Float32Array(i.length),b=[],_=new Map((n.floors??[]).map((H,F)=>[H.id,F])),S=e.map(()=>[]);for(let H of i){let F=H.floorId?_.get(H.floorId)??0:0;S[Math.min(F,S.length-1)]?.push(H)}let R=(H,F)=>{if(!F||F.length<3)return!1;let W=Math.min(...F.map(at=>at.x)),Y=Math.max(...F.map(at=>at.x)),q=Math.min(...F.map(at=>at.y)),ot=Math.max(...F.map(at=>at.y));for(let at=0;at<H;at++)for(let it of S[at])if(!(it.x<W||it.x>Y||it.y<q||it.y>ot)&&Lt(it,F,void 0))return!0;return!1},B=Ee(e),C=null,O=H=>e.length===1?i:i.filter((F,W)=>u[W]===H),k=(H,F)=>{let W=Ht(H);if(!W)return!1;let Y=1/0,q=1/0,ot=-1/0,at=-1/0;for(let it of W)Y=Math.min(Y,it.x),ot=Math.max(ot,it.x),q=Math.min(q,it.y),at=Math.max(at,it.y);return i.some((it,St)=>it.kind!=="booth"&&(e.length===1||u[St]===F)&&it.x>Y&&it.x<ot&&it.y>q&&it.y<at&&Mt(W,it.x,it.y))},E,w=[],L;for(let H=0;H<e.length;H++){let F=e[H];s.setFloor(H);let W=qt(F,O(H)),Y=0;if(W){let $=0;for(let xt of F.objects)if(xt.type==="section")for(let Kt of g.bySection.get(xt.id)?.rowLevels??[])$=Math.max($,Kt.y-F.baseHeightM);Y=Dr($);for(let xt of W)w.push([xt.x*I,xt.y*I]);if(L=Math.max(L??-1/0,F.baseHeightM+Y),!E){let xt=gn(W);E={centre:[xt.x*I,xt.y*I]}}}let q=new fe,ot=[],at=F.objects.filter($=>$.type==="shape"&&($.role==="entrance"||$.role==="exit")),it=F.objects.filter($=>$.type==="section"&&!!$.outline&&$.outline.length>=3),St=ls(F.objects.filter($=>$.type==="booth"),F.focal);for(let $ of F.objects)if($.type==="section"){let xt=s.vertexCount;Rs(s,$,F,br($,y),g.bySection.get($.id),q,it,r,H>0&&R(H,$.outline));let Kt=s.vertexCount-xt;Kt>0&&b.push({sectionId:$.id,start:xt,count:Kt})}else if($.type==="shape"){let xt=a.byObjectId.get($.id);if(B.has($)&&!xt)continue;let Kt=p.length,tn=W!==null&&$.role==="wall"&&!xt;s.setMaterial(tn?me:(xt?.kind??$.role)==="screen"?1:0);let kt=$.role==="stage"&&!xt?us($,O(H)):tn&&$.heightM===void 0?{...$,heightM:Y}:$,Oe=Gr(kt,ot);if(Ci(s,kt,F.baseHeightM+Oe.supportOffsetM,Oe.topOffsetM-Oe.supportOffsetM,r,F.focal,p,xt,at),s.setMaterial(0),$.role==="stage"&&!xt&&p.length>Kt&&(C??H)===H){C=H;let Lo=n.floors?.[H]?.id,Te=e.length>1&&Lo?i.filter(nn=>nn.floorId===Lo):i;rs(s,kt,p[p.length-1].y,Te,{deck:p[p.length-1].top,night:!rn(r)});let Zn=Ut(kt.stageKind)?st(kt):null;Zn&&Si(s,kt,Zn,p[p.length-1].y,Te,F.objects.some(nn=>nn.type==="shape"&&nn.role==="goal"),F.objects.some(nn=>nn.type==="shape"&&nn.role==="dugout")),Zn&&en(kt.stageKind)&&ss(s,Zn,p[p.length-1].y,Te,_e),s.setMaterial(0)}}else $.type==="gaArea"?Fi(s,$,F.baseHeightM,lt(x.get($.categoryKey)),r):$.type==="booth"?Oi(s,$,F.baseHeightM,lt(x.get($.categoryKey)),r,St.get($.id)??F.focal,k($,H)):$.type==="table"?ki(s,$,Math.max(F.baseHeightM,A.get($.id)??F.baseHeightM),lt($.fill??n.theme?.decorFill??"#232c40"),r,!!($.fill??n.theme?.decorFill)):$.type==="decorImage"&&Li(s,$,F.baseHeightM,r);W&&vi(s,F.objects,W,F.baseHeightM,Y,F.focal,r,$=>!a.byObjectId.has($.id)),Is(s,F,i,g,r,o.materials.shell,!c)}let D=e.length>1?{x:e.reduce((H,F)=>H+F.focal.x,0)/e.length,y:e.reduce((H,F)=>H+F.focal.y,0)/e.length}:n.focalPoint??{x:(f.minX+f.maxX)/2,y:(f.minY+f.maxY)/2},T=cr(c?[s.build(),c]:[s.build()]),N=new Map;for(let H of e)for(let F of H.objects)F.type==="table"&&N.set(F.id,F.center);let U=yr(i,t.initialState,g,P,x,M,new Set(N.keys())),j=Vi({doc:n,units:e,seats:i,surfaces:g,focal:D}),{labels:G,sections:v,rows:X}=Ki({doc:n,units:e,seats:i,surfaces:g,seatData:U,hintedSeatFloor:u,zones:j,focal:D}),V=new Map(v.map((H,F)=>[H.id,F]));g.seatOwner.forEach((H,F)=>{U.iSection[F]=H?V.get(H)??-1:-1});let Q=Ss({doc:n,units:e,seats:i,surfaces:g,solids:T,hintedSeatFloor:u,seatFloor:P});zi(G,Q),U.iYaw=mr(U.iPosition,i.length,H=>i[H].rowId,H=>{let F=e[P[H]]?.focal??D;return[F.x*I,F.y*I]},H=>{let F=N.get(i[H].rowId);return F?[F.x*I,F.y*I]:void 0});let et=(f.minX+f.maxX)/2*I,tt=(f.minY+f.maxY)/2*I,J=.5*Math.hypot((f.maxX-f.minX)*I,(f.maxY-f.minY)*I)||10,ft=Co(T,U,{cx:et,cz:tt,radius:J},[m,d]),mt=Co(T,U,{cx:et,cz:tt,radius:J}),ht=rm(e),rt=Cs(U,p,f,ft.minY,ft.maxY,J,ht),yt=!E&&e.some(H=>H.objects.some(F=>F.type==="shape"&&en(F.stageKind))),dt=!!o.house&&!yt&&!c&&(!!E||o.house.indoor),bt=p.flatMap(H=>[[H.cx-H.halfX,H.cz-H.halfZ],[H.cx+H.halfX,H.cz-H.halfZ],[H.cx+H.halfX,H.cz+H.halfZ],[H.cx-H.halfX,H.cz+H.halfZ]]),Bt=dt?as(U.iPosition,i.length,e[0]?.baseHeightM??0,[...bt,...w],L):null;return{sharedAisles:Yi(e.flatMap(H=>H.objects.flatMap(F=>{if(F.type!=="section")return[];let W=g.bySection.get(F.id);return W?[{sectionId:F.id,floorIndex:H.index,rows:W.rowLevels}]:[]}))),solids:T,sectionSolidRanges:b,seats:U,seatSectionIds:g.seatOwner,bounds:{center:[(rt.min[0]+rt.max[0])/2,(rt.min[1]+rt.max[1])/2,(rt.min[2]+rt.max[2])/2],radius:J,groundY:0,box:rt,fitPoints:ks(U,p,ht)},...E?{room:E}:{},...yt?{outdoor:!0}:{},...Bt?{house:Bt}:{},renderBounds:{center:ft.center,radius:ft.radius},clipBounds:{center:mt.center,radius:mt.radius},stateColorLUT:es(o,En),theme:o,seatCount:i.length,focalWorld:[D.x*I,1.5,D.y*I],zones:j,stages:p,productionElements:a.elements,sections:v,rows:X,labels:G,floors:Q}}function rm(t){let n=[];for(let e of t)for(let o of e.objects){let r=o.type==="gaArea"?o.points:o.type==="booth"?Ht(o):null;for(let a of r??[])n.push([a.x*I,e.baseHeightM,a.y*I])}return n}function im(t,n){let{doc:e,report:o}=Yr(t),r=o.confident&&(o.sections.length>0||!!o.looseRowBlocks);if(!r&&!o.roles?.length)return null;if(!r){let c=new Map(o.roles.map(h=>[h.id,h.role])),l=h=>h.map(d=>d.type==="shape"&&c.has(d.id)?{...d,role:c.get(d.id)}:d),u=t.floors?.map(h=>({...h,objects:l(h.objects)})),f=new Float64Array(n.length).fill(Number.NaN),m=new Float64Array(n.length*2).fill(Number.NaN);return n.forEach((h,d)=>{h.eyeHeightM!==void 0&&(f[d]=h.eyeHeightM),h.focalPoint&&(m[d*2]=h.focalPoint.x,m[d*2+1]=h.focalPoint.y)}),{doc:{...t,objects:u?.[0]?.objects??l(t.objects),...u?{floors:u}:{}},report:o,eyeHeightM:f,focal:m}}let a=new Map(Qn(e).map(c=>[c.id,c])),i=new Float64Array(n.length).fill(Number.NaN),s=new Float64Array(n.length*2).fill(Number.NaN);return n.forEach((c,l)=>{let u=a.get(c.id)??c;u.eyeHeightM!==void 0&&(i[l]=u.eyeHeightM),u.focalPoint&&(s[l*2]=u.focalPoint.x,s[l*2+1]=u.focalPoint.y)}),{doc:e,report:o,eyeHeightM:i,focal:s}}function sm(t,n){return t.map((e,o)=>{let r=n.eyeHeightM[o],a=n.focal[o*2],i=n.focal[o*2+1],s={...e};return Number.isNaN(r)?delete s.eyeHeightM:s.eyeHeightM=r,Number.isNaN(a)?delete s.focalPoint:s.focalPoint={x:a,y:i},s})}function nx(t){let n=t.estimate===!1?null:im(t.doc,t.seats);return n?{input:{...t,doc:n.doc,seats:sm(t.seats,n)},estimate:n}:{input:t}}export{bm as a,qs as b,Js as c,Qs as d,gm as e,Mm as f,Rm as g,_m as h,Im as i,Sm as j,Pm as k,Am as l,Em as m,wm as n,Bm as o,lr as p,Om as q,En as r,De as s,rn as t,um as u,He as v,I as w,le as x,vm as y,Hm as z,Ey as A,Yr as B,Th as C,kh as D,Ch as E,Lh as F,Fh as G,Gh as H,Je as I,Nh as J,Dh as K,vh as L,Hh as M,Uh as N,fu as O,qp as P,im as Q,sm as R,nx as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Ta as re,cb as le,fb as se}from"./chunk-3V32MDJI.js";function P(e){let i=Number(e.slice(e.lastIndexOf(":")+1));return Number.isFinite(i)?i:-1}function ve(e,i,n){let t=new Map;for(let a of e){if(a.kind==="booth")continue;let o=t.get(a.rowId);o?o.push(a):t.set(a.rowId,[a])}let c=a=>n.has(a.id)||i(a.id)!=="free",r=[];for(let a of t.values())if(!(a.length<3)){a.sort((o,s)=>P(o.id)-P(s.id));for(let o=1;o<a.length-1;o++){let s=a[o];if(c(s))continue;let p=a[o-1],f=a[o+1];P(s.id)-P(p.id)!==1||P(f.id)-P(s.id)!==1||!c(p)||!c(f)||!n.has(p.id)&&!n.has(f.id)||r.push(s)}}return r}function ye(e){return Array.isArray(e.objects)}function de(e,i){if(i.seatsByLabel)return i.seatsByLabel;if(!ye(e))throw new Error("ticketRestrictions: a categories-only chart document requires options.seatsByLabel");return new Map(se(e,{resolveEyeHeights:!1}).map(n=>[n.label,n]))}function he(e){return{code:"ticket_option_not_applicable",labels:e,message:"That ticket choice is not available for the selected seat."}}function U(e,i){let n=e.applicability;return n?!(n.seatLabels?.length&&!n.seatLabels.includes(i.label)||n.accessibility?.length&&!n.accessibility.some(t=>i.accessibility?.includes(t))):!0}function De(e,i){return(e.categories.find(n=>n.key===i.categoryKey)?.tiers??[]).filter(n=>U(n,i))}function ue(e,i,n){let t=e.categories.find(r=>r.key===i.categoryKey)?.tiers;if(!t?.length)return{kind:"none"};let c=n==null?t.find(r=>U(r,i)):t.find(r=>r.id===n&&U(r,i));return c?{kind:"resolved",tier:c}:{kind:"invalid"}}function me(e,i){return(e.logicalRowId??e.rowId)===(i.logicalRowId??i.rowId)}function ce(e){if(Number.isInteger(e.logicalSeatIndex))return e.logicalSeatIndex;let i=e.id.slice(e.id.lastIndexOf(":")+1),n=Number(i);return Number.isInteger(n)?n:void 0}function xe(e,i){if(!me(e,i))return!1;let n=ce(e),t=ce(i);return n!=null&&t!=null&&Math.abs(n-t)===1}function Se(e,i,n={}){if(!i.length)return null;let t=de(e,n),c=i.flatMap(o=>{let s=t.get(o.label);return s?[{selection:o,seat:s}]:[]}),r=c.map(({seat:o})=>o).filter(o=>o.accessibility?.includes("wheelchair")),a=[];for(let{selection:o,seat:s}of c){let p=ue(e,s,o.tierId),f=p.kind==="resolved"?p.tier:void 0;(s.accessibility?.includes("companion")||f?.restriction==="companion")&&!r.some(b=>b.id!==s.id&&xe(s,b))&&a.push(s.label)}return a.length?{code:"companion_pair_required",labels:a,message:"Select the adjacent wheelchair place with each companion ticket."}:null}function Me(e,i,n={}){if(!i.length)return null;let t=de(e,n),c=new Set(e.categories.filter(o=>o.notForSale).map(o=>o.key)),r=[],a=[];for(let o of i){let s=t.get(o.label);if(!s)continue;if(c.has(s.categoryKey)){r.push(s.label);continue}ue(e,s,o.tierId).kind==="invalid"&&a.push(s.label)}return r.length?{code:"not_for_sale",labels:r,message:"These seats are not for sale."}:a.length?he(a):Se(e,i,{seatsByLabel:t})}function pe(e){return e.sectionId?`s:${e.sectionId}`:`r:${e.logicalRowId??e.rowId}`}function Ie(e,i){let n=new Set,t=new Map;for(let c of e){let r=c.focalPoint??i,a=`${r.x},${r.y}`,o=t.get(a);o||(o={focal:r,seats:[]},t.set(a,o)),o.seats.push(c)}for(let{focal:c,seats:r}of t.values()){let a=Y(r),o=a.x-c.x,s=a.y-c.y,p=Math.hypot(o,s),f=0;for(let g of r)f=Math.max(f,Math.abs(g.x-c.x),Math.abs(g.y-c.y));let u=Math.max(f,1)*1e-6;if(!(p>u))continue;let b=0,w=new Set;for(let g of r)((g.x-c.x)*o+(g.y-c.y)*s)/p<-u&&(b+=1,w.add(pe(g)));if(!w.size||b*10>r.length)continue;let k=r.filter(g=>w.has(pe(g)));if(!(k.length*4>r.length))for(let g of k)n.add(g.label)}return n}function W(e,i){if(Number.isInteger(e.logicalSeatIndex))return e.logicalSeatIndex;let n=e.id.lastIndexOf(":");if(n<0)return i;let t=Number(e.id.slice(n+1));return Number.isFinite(t)?t:i}function A(e,i){let n=e.x-i.x,t=e.y-i.y;return n*n+t*t}function Y(e){let i=0,n=0;for(let t of e)i+=t.x,n+=t.y;return{x:i/e.length,y:n/e.length}}function we(e,i){return e.find(n=>n.focalPoint)?.focalPoint??i}function V(e){return e.commercial?.premium===!0}var be=new WeakMap;function ke(e){let i=be.get(e);if(i&&i.length===e.length&&i.first===e[0]&&i.last===e[e.length-1])return i;let n=new Map;e.forEach((a,o)=>{let s=a.logicalRowId??a.rowId,p=n.get(s);p||(p=[],n.set(s,p)),p.push({seat:a,index:W(a,o),order:o})});let t=new Map([...n].map(([a,o])=>[a,Y(o.map(s=>s.seat))])),c=[...n].map(([a,o])=>({rowId:a,slots:[...o].sort((s,p)=>s.index-p.index)})),r={length:e.length,first:e[0],last:e[e.length-1],rows:c,rowCentres:t,behind:new Map};return be.set(e,r),r}function Te(e,i,n){let t=`${n.x},${n.y}`,c=e.behind.get(t);return c||(c=Ie(i,n),e.behind.set(t,c)),c}function Ce(e,i,n){let t=Math.floor(n.qty);if(!Number.isFinite(t)||t<=0)return{labels:[],reason:"sold_out"};let{categoryKey:c,zoneId:r,focal:a,preferPremium:o,preferNearest:s,preferredRowIds:p,accessibility:f,requireContiguous:u}=n,b=n.preferAisle&&n.aisleLabels?.size?n.aisleLabels:null,w=ke(e),k=new Uint8Array(e.length),g=0;for(let l=0;l<e.length;l++){let d=e[l];i.has(d.label)&&(!c||d.categoryKey===c)&&(!r||d.zoneId===r)&&(!f||f.some(x=>d.accessibility?.includes(x)))&&(k[l]=1,g+=1)}if(g===0)return{labels:[],reason:"sold_out"};let R=!c&&!r&&!s?Te(w,e,a):new Set,{rowCentres:H}=w,X=(p??[]).map(l=>H.get(l)).filter(l=>!!l),J=l=>{let d=H.get(l);return!d||!X.length?0:Math.min(...X.map(x=>A(d,x)))},L=!1,Q=[],N=0,Z="",ee=0,B=0,F=0,K=0,j=0,q=0,v=0;for(let{rowId:l,slots:d}of w.rows){let x=J(l),y=0;for(;y<d.length;){if(!k[d[y].order]){y++;continue}let h=y;for(;h<d.length&&k[d[h].order]&&(h===y||d[h].index===d[h-1].index+1);)h++;let I=h-y;for(let m=0;m+t<=I;m++){let fe=m,ge=I-(m+t),z=fe===1||ge===1?1:0,M=y+m,O=0,_=0,ne=!1,ie=0,oe=0,$;for(let C=M;C<M+t;C++){let T=d[C].seat;o&&!V(T)&&(O+=1),R.size&&R.has(T.label)&&(_+=1),b&&b.has(T.label)&&(ne=!0),ie+=T.x,oe+=T.y,!$&&T.focalPoint&&($=T.focalPoint)}let G=b&&!ne?1:0,E=A({x:ie/t,y:oe/t},s?a:$??a),ae=d[M].index,S;if(!L)S=!0;else if(o&&O!==F)S=O<F;else if(s&&x!==q)S=x<q;else if(s&&E!==v)S=E<v;else if(_!==K)S=_<K;else if(G!==j)S=G<j;else if(z!==B)S=z<B;else if(E!==v)S=E<v;else{let C=l.localeCompare(Z);S=C!==0?C<0:ae<ee}S&&(L=!0,Q=d,N=M,Z=l,ee=ae,B=z,F=O,K=_,j=G,q=x,v=E)}y=h}}if(L)return{labels:Q.slice(N,N+t).map(l=>l.seat.label)};if(u)return{labels:[],reason:"not_enough_together"};if(g<t)return{labels:[],reason:"not_enough_together"};let te=[];for(let l=0;l<e.length;l++)k[l]&&te.push(e[l]);return{labels:te.map((l,d)=>({seat:l,i:d,rowD2:J(l.logicalRowId??l.rowId),d2:A(l,s?a:l.focalPoint??a)})).sort((l,d)=>{if(o){let I=V(l.seat)?0:1,m=V(d.seat)?0:1;if(I!==m)return I-m}if(s&&l.rowD2!==d.rowD2)return l.rowD2-d.rowD2;let x=R.has(l.seat.label)?1:0,y=R.has(d.seat.label)?1:0;if(x!==y)return x-y;if(b){let I=b.has(l.seat.label)?0:1,m=b.has(d.seat.label)?0:1;if(I!==m)return I-m}if(l.d2!==d.d2)return l.d2-d.d2;let h=(l.seat.logicalRowId??l.seat.rowId).localeCompare(d.seat.logicalRowId??d.seat.rowId);return h!==0?h:W(l.seat,l.i)-W(d.seat,d.i)}).slice(0,t).map(l=>l.seat.label)}}function _e(e,i,n,t){let c=Math.floor(t.qty),r=Ce(e,n,t),o=i.filter(u=>u.bookingMode==="whole"&&u.capacity===c&&n.has(u.label)&&(!t.categoryKey||u.categoryKey===t.categoryKey)&&(!t.zoneId||u.zoneId===t.zoneId)&&!t.accessibility).map(u=>({table:u,d2:A(u.center,t.preferNearest?t.focal:u.focalPoint??t.focal)})).sort((u,b)=>u.d2-b.d2||u.table.label.localeCompare(b.table.label))[0];if(!o)return r;if(!r.labels.length)return{labels:[o.table.label]};if(t.preferAisle&&t.aisleLabels&&r.labels.some(u=>t.aisleLabels.has(u)))return r;let s=new Map(e.map(u=>[u.label,u])),p=r.labels.map(u=>s.get(u)).filter(u=>!!u),f=p.length?A(Y(p),we(p,t.focal)):Number.POSITIVE_INFINITY;return o.d2<f?{labels:[o.table.label]}:r}var D=class extends Error{constructor(n,t){super(t);this.objectId=n;this.name="GroupedTableProjectionError"}};function Pe(e){let i=e.minOccupancy,n=e.maxOccupancy;if(!Number.isInteger(i)||!Number.isInteger(n)||i<1||n<i||n>e.seatCount)throw new D(e.id,`Table "${e.label}" has invalid variable-occupancy bounds`);return{min:i,max:n}}function Be(e,i){if(i!==2)return[];let n=[];for(let t of le(e)){if(t.type!=="table"||!t.bookAsWhole&&!t.variableOccupancy)continue;if(t.bookAsWhole&&t.variableOccupancy)throw new D(t.id,`Table "${t.label}" cannot be whole-table and variable-occupancy inventory`);if(!Number.isInteger(t.seatCount)||t.seatCount<1||!t.label.trim())throw new D(t.id,"Grouped tables require a label and at least one chair");let c=t.variableOccupancy?"variable":"whole",r=c==="variable"?Pe(t):{min:t.seatCount,max:t.seatCount};n.push({objectId:t.id,label:t.label,...t.displayLabel?{displayLabel:t.displayLabel}:{},...t.displayType?{displayType:t.displayType}:{},categoryKey:t.categoryKey,mode:c,capacity:t.seatCount,minOccupancy:r.min,maxOccupancy:r.max,chairs:re(t)})}return n}export{ve as a,ye as b,he as c,U as d,De as e,ue as f,Se as g,Me as h,Ie as i,Ce as j,_e as k,D as l,Be as m};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{xa as Y}from"./chunk-
|
|
1
|
+
import{xa as Y}from"./chunk-3V32MDJI.js";function nn(c){return{kind:"radial",rowCount:0,rows:[],nearestRow:()=>-1,depthAt:(l,a)=>Math.hypot(l-c.x,a-c.y),gradientAt:(l,a)=>{let e=l-c.x,f=a-c.y,i=Math.hypot(e,f);return i<1e-9?[0,0]:[e/i,f/i]}}}function tn(c,l){if(!c.length)return null;let a=0,e=0,f=0;for(let n of c)a+=n.x,e+=n.y,f+=Math.hypot(n.x-l.x,n.y-l.y);let i=c.length;a/=i,e/=i,f/=i;let u=c[0],R=-1;for(let n of c){let o=Math.hypot(n.x-a,n.y-e);o>R&&(R=o,u=n)}let b=u.x-a,m=u.y-e,d=Math.hypot(b,m);d>1e-9?(b/=d,m/=d):(b=1,m=0);let y=[...c].sort((n,o)=>(n.x-a)*b+(n.y-e)*m-((o.x-a)*b+(o.y-e)*m)),t=0;for(let n of y){let o=Math.hypot(n.x-a,n.y-e);o>t&&(t=o)}return{pts:y,cx:a,cy:e,radius:t,depth:f}}function Z(c,l,a){let e=c.pts;if(e.length===1)return Math.hypot(l-e[0].x,a-e[0].y);let f=1/0;for(let i=0;i+1<e.length;i++){let u=e[i],R=e[i+1],b=R.x-u.x,m=R.y-u.y,d=b*b+m*m,y=d>1e-12?((l-u.x)*b+(a-u.y)*m)/d:0;y<0?y=0:y>1&&(y=1);let t=Math.hypot(l-(u.x+y*b),a-(u.y+y*m));t<f&&(f=t)}return f}var U=8;function en(c,l,a){let e=new Array(U).fill(1/0),f=new Array(U).fill(-1);for(let d=0;d<c.length;d++){let y=c[d],t=Math.hypot(l-y.cx,a-y.cy)-y.radius;for(let n=0;n<U;n++)if(t<e[n]){for(let o=U-1;o>n;o--)e[o]=e[o-1],f[o]=f[o-1];e[n]=t,f[n]=d;break}}let i=new Array(3).fill(1/0),u=new Array(3).fill(-1);for(let d of f){if(d<0)continue;let y=Z(c[d],l,a);for(let t=0;t<3;t++)if(y<i[t]){for(let n=2;n>t;n--)i[n]=i[n-1],u[n]=u[n-1];i[t]=y,u[t]=d;break}}if(u[0]<0)return 0;if(i[0]<1e-6)return c[u[0]].depth;let R=i[0]*2.2,b=0,m=0;for(let d=0;d<3;d++){let y=u[d];if(y<0||i[d]>R)continue;let t=1/(i[d]*i[d]);b+=t*c[y].depth,m+=t}return m>0?b/m:c[u[0]].depth}function on(c){let l=(e,f)=>en(c,e,f),a=(e,f)=>{let i=1/0,u=-1;for(let R=0;R<c.length;R++){let b=c[R];if(Math.hypot(e-b.cx,f-b.cy)-b.radius>=i)continue;let m=Z(b,e,f);m<i&&(i=m,u=R)}return u};return{kind:"rows",rowCount:c.length,rows:c,nearestRow:a,depthAt:l,gradientAt:(e,f)=>{let i=(l(e+.5,f)-l(e-.5,f))/1,u=(l(e,f+.5)-l(e,f-.5))/(2*.5),R=Math.hypot(i,u);return R<1e-9?[0,0]:[i/R,u/R]}}}function bn(c,l){let a=[];for(let e of c){let f=tn(e.points,l);f&&a.push(f)}return a.length<2?nn(l):(a.sort((e,f)=>e.depth-f.depth),on(a))}var rn=Math.PI/180,h=96,sn=6,ln=60,cn=150,$=.2,an=.35;function fn(c,l){let a=Math.atan2(l.x-c.x,l.y-c.y)/rn;return a<0?a+360:a}function z(c){if(!c.length)return NaN;let l=[...c].sort((a,e)=>a-e);return l[Math.floor(l.length/2)]}function J(c,l,a=2){let e=c.length,f=new Float64Array(e);for(let i=0;i<e;i++){let u=0,R=0;for(let b=-a;b<=a;b++){let m=i+b;if(l)m=(m%e+e)%e;else if(m<0||m>=e)continue;u+=c[m],R++}f[i]=u/R}return f}function hn(c,l){let a=c.filter(t=>t.rows.length>=1);if(a.length<1)return null;let e=[],f=0,i=0,u=0;for(let t of a)for(let n of t.rows){for(let o of n.pts)f+=o.x,i+=o.y,u++;if(n.pts.length>=4){let o=Y(n.pts);o&&Number.isFinite(o.cx)&&Number.isFinite(o.cy)&&e.push({x:o.cx,y:o.cy})}}if(!u)return null;let R={x:f/u,y:i/u},b=R;if(e.length>=8){let t=z(e.map(D=>D.x)),n=z(e.map(D=>D.y)),o=0;for(let D of a)for(let j of D.rows)for(let F of j.pts){let W=Math.hypot(F.x-R.x,F.y-R.y);W>o&&(o=W)}let B=0,S=o*.2;for(let D of a)for(let j of D.rows)for(let F of j.pts)Math.hypot(F.x-t,F.y-n)<S&&B++;Math.hypot(t-R.x,n-R.y)<=o&&B/u<.01&&(b={x:t,y:n})}let m=[];for(let t of a){let n={sectionId:t.sectionId,rMin:1/0,rMax:-1/0,samples:[]};for(let o of t.rows)for(let B of o.pts){let S=Math.hypot(B.x-b.x,B.y-b.y),D=Math.min(h-1,Math.floor(fn(b,B)/(360/h)));n.samples.push({r:S,bin:D,levelM:o.levelM}),S<n.rMin&&(n.rMin=S),S>n.rMax&&(n.rMax=S)}n.samples.length&&m.push(n)}if(!m.length)return null;m.sort((t,n)=>t.rMin+t.rMax-(n.rMin+n.rMax));let d=[];for(let t of m){let n=!1;for(let o of d){let B=Math.min(t.rMax,o.rMax)-Math.max(t.rMin,o.rMin),S=Math.min(t.rMax-t.rMin,o.rMax-o.rMin);if(S>1e-9&&B>=an*S){o.members.push(t),o.rMin=Math.min(o.rMin,t.rMin),o.rMax=Math.max(o.rMax,t.rMax),n=!0;break}}n||d.push({members:[t],rMin:t.rMin,rMax:t.rMax})}let y=[];for(let t of d){let n=new Array(h).fill(null);for(let r of t.members)for(let p of r.samples){let x=n[p.bin];x||(x={samples:[]},n[p.bin]=x),x.samples.push({r:p.r,levelM:p.levelM})}let o=n.map(r=>!!r);if(!o.filter(Boolean).length)continue;let S=[],D=[];for(let r of n){if(!r)continue;let p=1/0,x=-1/0;for(let A of r.samples)A.r<p&&(p=A.r),A.r>x&&(x=A.r);S.push(p),D.push(x)}let j=z(S),F=z(D);if(!(j>=$*F)||!(F>0))continue;let W=[...S].sort((r,p)=>r-p);if(!(W[Math.floor(W.length*.1)]>=$*F))continue;let V=n.map(r=>{if(!r)return null;let p=[...r.samples].sort((w,k)=>w.r-k.r),x=p[0].r,A=p[p.length-1].r,P=p[0].levelM,N=-1/0;for(let w of p)w.levelM>N&&(N=w.levelM);let M=[];for(let w of p){let k={r:w.r,l:w.levelM};for(;M.length&&Math.abs(M[M.length-1].r-k.r)<1e-9;){if(M[M.length-1].l<=k.l){k.skip=!0;break}M.pop()}if(!k.skip){for(;M.length>=2;){let L=M[M.length-2],v=M[M.length-1];if((v.r-L.r)*(k.l-L.l)-(v.l-L.l)*(k.r-L.r)<=0)M.pop();else break}M.push(k)}}let C=M.map(w=>w.r),_=M.map(w=>w.l);return{inner:x,outer:A,front:P,top:N,profile:{rs:C,ls:_}}}),O=o.slice();for(let r=0;r<h;r++){if(O[r])continue;let p=-1,x=-1,A=0;for(let s=1;s<=h;s++){let g=(r-s+h*2)%h;if(O[g]){p=g;break}}for(let s=1;s<=h;s++){let g=(r+s)%h;if(O[g]){x=g,A=s;break}}if(p<0||x<0)continue;let P=0;for(let s=1;s<=h;s++){let g=(r-s+h*2)%h;if(o[g]){P=s;break}}if(P-1+A>sn)continue;let M=V[p],C=V[x],_=P/(P+A),w=M.inner+(C.inner-M.inner)*_,k=M.outer+(C.outer-M.outer)*_,L=M.front+(C.front-M.front)*_,v=M.top+(C.top-M.top)*_;V[r]={inner:w,outer:k,front:L,top:v,profile:{rs:[w,k],ls:[L,v]}}}for(let r=0;r<h;r++)V[r]&&(O[r]=!0);let X=360/h,K=[],q=O.filter(Boolean).length,Q=[];if(q===h)Q.push({start:0,len:h});else{let r=0;for(;O[r];)r=(r+1)%h;let p=-1;for(let x=0;x<=h;x++){let A=(r+x)%h,P=x<h&&O[A];if(P&&p<0)p=A;else if(!P&&p>=0){let N=(A-p+h)%h||h;Q.push({start:p,len:N}),p=-1}}}for(let r of Q){if(r.len*X<ln&&r.len<h)continue;let p=r.len===h,x=new Float64Array(r.len),A=new Float64Array(r.len),P=new Float64Array(r.len),N=new Float64Array(r.len),M=[];for(let s=0;s<r.len;s++){let g=V[(r.start+s)%h];x[s]=g.inner,A[s]=g.outer,P[s]=g.front,N[s]=g.top,M.push(g.profile??{rs:[g.inner,g.outer],ls:[g.front,g.top]})}let C=J(x,p),_=J(A,p),w=J(P,p),k=J(N,p);for(let s=0;s<r.len;s++)C[s]>x[s]&&(C[s]=x[s]),_[s]<A[s]&&(_[s]=A[s]),C[s]>_[s]-1e-6&&(C[s]=Math.max(0,_[s]-1e-6)),k[s]<w[s]&&(k[s]=w[s]);let L={startBin:r.start,binCount:r.len,closed:p,innerR:C,outerR:_,frontLevelM:w,topLevelM:k,profiles:M},v=(s,g,I)=>{let H=M[s],T=H.rs,E=H.ls;if(g<=T[0]){E[0]>I&&(E[0]=I);return}if(g>=T[T.length-1]){E[E.length-1]>I&&(E[E.length-1]=I);return}for(let G=0;G+1<T.length;G++)if(g<=T[G+1]){E[G]>I&&(E[G]=I),E[G+1]>I&&(E[G+1]=I);return}};for(let s=0;s<r.len;s++){let g=n[(r.start+s)%h];if(g)for(let I of g.samples){v(s,I.r,I.levelM);let H=p?(s-1+r.len)%r.len:s-1,T=p?(s+1)%r.len:s+1;H>=0&&v(H,I.r,I.levelM),T<r.len&&v(T,I.r,I.levelM)}}K.push(L)}K.reduce((r,p)=>r+p.binCount*X,0)<cn||y.push({arcs:K,sectionIds:t.members.map(r=>r.sectionId),innerRMedian:j,outerRMedian:F})}if(!y.length)return null;if(y.sort((t,n)=>t.innerRMedian-n.innerRMedian),l){let t=y[y.length-1].outerRMedian;if(Math.hypot(l.x-b.x,l.y-b.y)>.9*t)return null}return{centre:b,binCount:h,binStepDeg:360/h,rings:y}}function dn(c,l,a,e){let f=c.binStepDeg,i=a/f-.5-l.startBin;i=(i%c.binCount+c.binCount)%c.binCount,i>l.binCount-1&&(l.closed?i=i-l.binCount<l.binCount-i?0:l.binCount-1:i=i-(l.binCount-1)<c.binCount-i?l.binCount-1:0);let u=Math.floor(i),R=l.closed?(u+1)%l.binCount:Math.min(l.binCount-1,u+1),b=i-u,m=d=>{let y=l.profiles[d],t=y.rs,n=y.ls;if(e<=t[0])return n[0];if(e>=t[t.length-1])return n[n.length-1];for(let o=0;o+1<t.length;o++)if(e<=t[o+1]){let B=t[o+1]-t[o],S=B>1e-9?(e-t[o])/B:0;return n[o]+(n[o+1]-n[o])*S}return n[n.length-1]};return m(u)*(1-b)+m(R)*b}export{bn as a,fn as b,hn as c,dn as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as D}from"./chunk-
|
|
1
|
+
import{f as D}from"./chunk-NVAF2E7Q.js";import{g as A,i as P}from"./chunk-GVVZR3YS.js";import{C as M,N as v,Na as w,Pa as C,Qa as S,Sa as O,Ta as j}from"./chunk-3V32MDJI.js";function x(r){return r.floors?.length?r.floors.flatMap(o=>o.objects):r.objects}function B(r){return x(r).reduce((o,n)=>n.type==="row"?o+w(n):n.type==="table"?o+O(n):n.type==="gaArea"?o+Math.max(0,Math.floor(n.capacity)):n.type==="booth"?o+1:o,0)}function G(r){let o={};for(let a of r.categories??[])o[a.key]=0;let n=(a,s)=>{s>0&&(o[a]=(o[a]??0)+s)};for(let a of x(r))if(a.type==="row")for(let s of C(a))n(s.categoryKey,1);else if(a.type==="table")if(a.bookAsWhole||a.variableOccupancy)n(a.categoryKey,Math.max(0,Math.round(a.seatCount)));else for(let s of j(a))n(s.categoryKey,1);else a.type==="gaArea"?n(a.categoryKey,Math.max(0,Math.floor(a.capacity))):a.type==="booth"&&n(a.categoryKey,1);return o}function _(r){if(!r.template)return null;let o=x(r),n=o.filter(c=>c.type==="row"||c.type==="table"||c.type==="gaArea");if(!n.length)return null;let s=o.filter(c=>c.type==="booth").length+n.reduce((c,l)=>c+(l.type==="table"?2:1),0),y=B(r),h=Math.max(s+1,Math.min(5e4,y*4)),d=[.5,1,1.5,2].map(c=>v(Math.round(y*c),s,h));return{family:r.template.family,display:r.template.family.replace(/-/g," ").replace(/\b\w/g,c=>c.toUpperCase()),min:s,max:h,presets:["S","M","L","XL"].map((c,l)=>({size:c,seats:d[l]}))}}function R(r){let o=C(r);return o.length?M(o):{...r.origin}}function N(r,o){let n=_(r);if(!n)return structuredClone(r);let a=structuredClone(r),s=x(a),y=s.filter(t=>t.type==="row"||t.type==="table"||t.type==="gaArea"),h=s.filter(t=>t.type==="booth").length,d=Math.max(n.min,Math.min(n.max,Math.round(o))),c=d-h,l=y.map((t,e)=>{let u=t.type==="gaArea"?Math.max(0,Math.floor(t.capacity)):t.seatCount,p=t.type==="table"?2:1;return{object:t,index:e,current:u,minimum:p,value:p,fraction:0}}),K=l.reduce((t,e)=>t+e.minimum,0),g=Math.max(0,c-K),T=l.reduce((t,e)=>t+Math.max(1,e.current-e.minimum),0);for(let t of l){let e=g*Math.max(1,t.current-t.minimum)/T,u=Math.floor(e);t.value+=u,t.fraction=e-u}g=c-l.reduce((t,e)=>t+e.value,0),l.sort((t,e)=>e.fraction-t.fraction||t.index-e.index);for(let t=0;t<g;t++)l[t%l.length].value++;l.sort((t,e)=>t.index-e.index);for(let t of l)if(t.object.type==="row"){let e=R(t.object);t.object.seatCount=t.value;let u=R(t.object);t.object.origin.x+=e.x-u.x,t.object.origin.y+=e.y-u.y}else if(t.object.type==="table"){let e=t.object;if(e.seatCountsBySide){let u=["top","bottom","left","right"],p=S(e),z=u.reduce((i,f)=>i+p[f],0)||1,m=u.map((i,f)=>{let b=t.value*p[i]/z;return{side:i,index:f,value:Math.floor(b),fraction:b-Math.floor(b)}}),L=t.value-m.reduce((i,f)=>i+f.value,0);m.sort((i,f)=>f.fraction-i.fraction||i.index-f.index);for(let i=0;i<L;i++)m[i%m.length].value+=1;m.sort((i,f)=>i.index-f.index),e.seatCountsBySide={top:m[0].value,bottom:m[1].value,left:m[2].value,right:m[3].value},e.sides=u.filter(i=>e.seatCountsBySide[i]>0)}e.seatCount=t.value,e.overrides&&(e.overrides=e.overrides.filter(u=>u.index<t.value),e.overrides.length||delete e.overrides)}else{let e=t.object;e.capacity=P(e)?Math.min(t.value,A):t.value,e.variableOccupancy&&(e.maxOccupancy=Math.min(e.maxOccupancy??e.capacity,e.capacity),e.minOccupancy=Math.min(e.minOccupancy??1,e.maxOccupancy)),e.wheelchairPlaces&&(e.wheelchairPlaces=Math.min(e.wheelchairPlaces,e.capacity))}return a.floors?.length&&(a.objects=a.floors[0].objects),a.template={family:a.template.family,targetSeats:d},a=D(a).doc,a.template={family:r.template.family,targetSeats:B(a)},a}export{B as a,G as b,_ as c,N as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$a as
|
|
1
|
+
import{$a as d,Pa as I,Ta as A,Ua as y,ab as S,cb as f}from"./chunk-3V32MDJI.js";var p="__sl_ga__";function w(t){return t.startsWith(p)}var E=p,g=1e5;function L(t,e){return`${E}${encodeURIComponent(t)}__${e+1}`}function C(t){let e=t.inventorySegments;if(e===void 0)return!0;if(!Array.isArray(e)||e.length<1||e.length>256)return!1;let n=0,r=new Map;for(let o of e){if(!o||typeof o.sourceAreaId!="string"||!o.sourceAreaId.trim()||o.sourceAreaId.length>160||!Number.isInteger(o.startIndex)||o.startIndex<0||!Number.isInteger(o.count)||o.count<1||o.startIndex+o.count>g||(n+=o.count,n>g))return!1;let c=r.get(o.sourceAreaId)??[],s=o.startIndex+o.count;if(c.some(i=>o.startIndex<i.end&&s>i.start))return!1;c.push({start:o.startIndex,end:s}),r.set(o.sourceAreaId,c)}return n===t.capacity}function x(t){let e=Math.min(g,Math.max(0,Math.floor(t.capacity)));return t.inventorySegments===void 0?e?[{sourceAreaId:t.id,startIndex:0,count:e}]:[]:C(t)?t.inventorySegments.map(n=>({...n})):[]}var v=100,k=`An area sold to one party holds at most ${v} guests.`;function h(t){return t.variableOccupancy?"variable":t.bookAsWhole?"whole":null}function $(t){return h(t)==="variable"?{min:t.minOccupancy??1,max:t.maxOccupancy??t.capacity}:{min:t.capacity,max:t.capacity}}function j(t){return O(t,2)}function O(t,e){return e===2&&h(t)&&t.inventorySegments===void 0?t.label.trim()?[t.label]:[]:x(t).flatMap(n=>Array.from({length:n.count},(r,o)=>L(n.sourceAreaId,n.startIndex+o)))}function N(t){let e=t.wheelchairPlaces;return!Number.isInteger(e)||e<=0?0:Math.min(e,Math.max(0,Math.floor(t.capacity)))}function J(t,e=2){let n=N(t);if(!n)return new Set;let r=O(t,e);return r.length===1&&h(t)&&e===2?new Set(r):new Set(r.slice(Math.max(0,r.length-n)))}function q(t,e){if(t.inventorySegments===void 0||e===t.capacity)return t.inventorySegments;if(e<t.capacity)return;let n=x(t);if(!n.length)return;let r=e-t.capacity;if(!r)return n;let c=n.filter(i=>i.sourceAreaId===t.id).reduce((i,a)=>Math.max(i,a.startIndex+a.count),0),s=n[n.length-1];if(s?.sourceAreaId===t.id&&s.startIndex+s.count===c)s.count+=r;else{if(n.length>=256)return;n.push({sourceAreaId:t.id,startIndex:c,count:r})}return n}function K(t){return f(t).filter(e=>e.type==="gaArea")}var m="__ungrouped__";function R(t){return t.type==="row"?I(t).map(e=>e.label):t.type==="table"?A(t).map(e=>e.label):t.type==="booth"?y(t).map(e=>e.label):t.type==="gaArea"?j(t):[]}function M(t){return t.type==="row"||t.type==="table"||t.type==="booth"||t.type==="gaArea"}function T(t){return t.displayLabel||t.label||"Section"}function _(t){let e=new Map;for(let n of f(t)){if(n.type!=="section")continue;let r=n.logicalSectionId??n.id;e.has(r)||e.set(r,{id:r,label:T(n),zone:n.zone})}return e}function rt(t){let e=new Map;for(let n of f(t)){if(n.type!=="section")continue;let r=n.logicalSectionId??n.id,o=n.entrance?.trim();o&&!e.has(r)&&e.set(r,o)}return e}function it(t){let e=new Map;for(let[n,r]of _(t))e.set(n,r.label);return e}function D(t){let e=new Map;for(let n of S(t)){let r=n.objects.filter(o=>o.type==="section");if(r.length)for(let o of n.objects){if(!M(o))continue;let c=d(n.objects,o,r);c&&e.set(o.id,c.logicalSectionId??c.id)}}return e}function G(t,e){let n=f(t),r=n.filter(i=>i.type==="section"),o=new Map;for(let[i,a]of _(t))o.set(i,{id:i,label:a.label,zone:a.zone,seatCount:0,objectIds:[],seatLabels:[]});let c={id:m,label:"Other seats",seatCount:0,objectIds:[],seatLabels:[]},s=new Map;for(let i of n){if(!M(i))continue;let a=R(i);if(a.length===0)continue;let u;if(e)u=e.get(i.id);else{let b=d(n,i,r);u=b?b.logicalSectionId??b.id:void 0}let l=u?o.get(u):c;l.seatCount+=a.length,l.objectIds.push(i.id),l.seatLabels.push(...a),s.set(i.id,l.id)}return{sections:[...o.values()],ungrouped:c.objectIds.length?c:null,objectToSection:s}}function st(t){return G(t,null)}function U(t){return G(t,D(t))}function z(t,e){return e.has(t.id)||!!t.logicalSectionId&&e.has(t.logicalSectionId)||!!t.zone&&e.has(t.zone)}function B(t,e){let n=new Set;if(!e.size)return n;let{sections:r,ungrouped:o,objectToSection:c}=U(t),s=new Set,i=new Map(r.map(u=>[u.id,u.zone]));for(let u of r){let l=i.get(u.id);(e.has(u.id)||l&&e.has(l))&&s.add(u.id)}let a=!!o&&e.has(m);for(let[u,l]of c)(s.has(l)||a&&l===m)&&n.add(u);return n}function ct(t,e){if(!e.size)return t;let n=B(t,e),r=e instanceof Set?e:new Set(e),o=s=>!(n.has(s.id)||s.type==="section"&&z(s,r));if(t.floors&&t.floors.length){let s=!1,i=t.floors.map(a=>{let u=a.objects.filter(o);return u.length!==a.objects.length&&(s=!0),u.length===a.objects.length?a:{...a,objects:u}});return s?{...t,floors:i,objects:i[0].objects}:t}let c=t.objects.filter(o);return c.length===t.objects.length?t:{...t,objects:c}}export{p as a,w as b,g as c,L as d,C as e,x as f,v as g,k as h,h as i,$ as j,j as k,O as l,N as m,J as n,q as o,K as p,m as q,_ as r,rt as s,it as t,D as u,st as v,U as w,z as x,B as y,ct as z};
|