@seatlayer/core 0.99.0 → 0.101.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{categoryInventory-DdJdJ4Og.d.ts → categoryInventory-DZ5IcDOy.d.ts} +1 -1
- package/dist/{categoryInventory-DuOez0-4.d.cts → categoryInventory-H77A_8pF.d.cts} +1 -1
- package/dist/{chunk-KFVUBZMK.js → chunk-2RNZOV5I.js} +1 -1
- package/dist/{chunk-HYEZPOZU.js → chunk-52XO3LA7.js} +1 -1
- package/dist/{chunk-VWT44HBR.js → chunk-5HXTEMRE.js} +1 -1
- package/dist/{chunk-UIMDB6GZ.js → chunk-5PFYIYM5.js} +1 -1
- package/dist/chunk-FLZKBXHA.js +1 -0
- package/dist/{chunk-23OTKCJU.js → chunk-JK3DUFRX.js} +1 -1
- package/dist/chunk-NO6OLVTT.js +1 -0
- package/dist/core/chart-ops/index.cjs +1 -1
- package/dist/core/chart-ops/index.d.cts +4 -4
- package/dist/core/chart-ops/index.d.ts +4 -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/quality/index.d.cts +3 -3
- package/dist/core/quality/index.d.ts +3 -3
- package/dist/core/quality/index.js +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/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/{eventConfigurations-BISNREZL.d.ts → eventConfigurations-B6aS6c-_.d.ts} +1 -1
- package/dist/{eventConfigurations-DYn5XP3J.d.cts → eventConfigurations-ClFqXQi9.d.cts} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +18 -13
- package/dist/index.d.ts +18 -13
- package/dist/index.js +1 -1
- package/dist/{labeling-owTTG6e0.d.cts → labeling-ByEZkLee.d.cts} +1 -1
- package/dist/{labeling-CzuSxAkr.d.ts → labeling-CP3GhUrf.d.ts} +1 -1
- package/dist/{renderedQuality-Bl1Kq_XO.d.cts → renderedQuality--H0toc-2.d.cts} +1 -1
- package/dist/{renderedQuality-BMSbVkwu.d.ts → renderedQuality-Bo4k99GE.d.ts} +1 -1
- package/dist/{renderer-njHDbIqI.d.ts → renderer-BPhSZUGh.d.cts} +12 -1
- package/dist/{renderer-Ccv8ZDZS.d.cts → renderer-CWbam_zr.d.ts} +12 -1
- package/dist/{seatTypeIcons-QwEebl3k.d.cts → seatTypeIcons-B2tvcQ0H.d.cts} +1 -1
- package/dist/{seatTypeIcons-dy3XQVWN.d.ts → seatTypeIcons-CSt1isBY.d.ts} +1 -1
- package/dist/{sections-DSIfnBJY.d.cts → sections-C_AKwOIh.d.cts} +1 -1
- package/dist/{sections-C8VTe6BN.d.ts → sections-JHox6Lsw.d.ts} +1 -1
- package/dist/{segmentedRowModel-CDvvJJ4-.d.cts → segmentedRowModel-CZ0Ciea-.d.cts} +1 -1
- package/dist/{segmentedRowModel-I8eYUQft.d.ts → segmentedRowModel-DQO0vHR1.d.ts} +1 -1
- package/dist/{tableSizing-BLtQ-KV0.d.ts → tableSizing-ClgbhNks.d.ts} +3 -3
- package/dist/{tableSizing-CB8g2Fs0.d.cts → tableSizing-Cp5T_6Lw.d.cts} +3 -3
- package/dist/{ticketRestrictions-BvlWLw10.d.cts → ticketRestrictions-BHNbxzFT.d.cts} +2 -2
- package/dist/{ticketRestrictions-DUjN2bZn.d.ts → ticketRestrictions-DUdzkp4F.d.ts} +2 -2
- package/dist/{types-DWx32xXH.d.cts → types-5AlKCD4j.d.cts} +17 -0
- package/dist/{types-DWx32xXH.d.ts → types-5AlKCD4j.d.ts} +17 -0
- package/dist/view3d/crossfade/panorama.d.cts +1 -1
- package/dist/view3d/crossfade/panorama.d.ts +1 -1
- package/dist/view3d/index.cjs +127 -53
- package/dist/view3d/index.d.cts +34 -5
- package/dist/view3d/index.d.ts +34 -5
- package/dist/view3d/index.js +125 -51
- package/dist/view3d/scene/scene.worker.cjs +1 -1
- package/dist/view3d/scene/scene.worker.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-K22SISYC.js +0 -1
- package/dist/chunk-QJXSZT3H.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as f,F as d}from"../../chunk-
|
|
1
|
+
import{C as f,F as d}from"../../chunk-NO6OLVTT.js";import"../../chunk-5PFYIYM5.js";import"../../chunk-L34T3APU.js";import"../../chunk-FLZKBXHA.js";import"../../chunk-5HXTEMRE.js";import"../../chunk-JK3DUFRX.js";import"../../chunk-D723OZEY.js";import"../../chunk-52XO3LA7.js";import"../../chunk-N4J4CT6P.js";import"../../chunk-4N5CHKHD.js";import"../../chunk-TQN2VWQO.js";import"../../chunk-5BMXWOE7.js";import"../../chunk-HO4MFTVX.js";import{Va as i}from"../../chunk-UISTXRO5.js";import"../../chunk-5ITK5236.js";import"../../chunk-JBOTRSMY.js";import"../../chunk-CRCGO52K.js";function p(e){return[e.solids.position,e.solids.normal,e.solids.color,e.solids.floor,e.solids.material,e.seats.iPosition,e.seats.iState,e.seats.iCategory,e.seats.iMaxRadius,e.seats.iRing,e.seats.iFloor,e.seats.iYaw,e.seats.iChairWidth,e.seats.iGlyph,e.seats.iPhysicalSeat].map(t=>t.buffer)}var c=self;c.onmessage=e=>{let s=performance.now(),t=!e.data.seats,r=e.data.seats??i(e.data.doc),{input:u,estimate:a}=d({doc:e.data.doc,seats:r,eventConfigurationId:e.data.eventConfigurationId,eventConfiguration:e.data.eventConfiguration,registeredShellGlb:e.data.registeredShellGlb,estimate:e.data.estimate}),o=f(u),n=p(o);a&&n.push(a.eyeHeightM.buffer,a.focal.buffer),c.postMessage({model:o,buildMs:performance.now()-s,...t?{seats:r}:{},...a?{estimate:a}:{}},n)};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seatlayer/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.101.0",
|
|
4
4
|
"description": "SeatLayer's seat map rendering engine — the seating chart runtime behind @seatlayer/js and the React, Vue, and Angular SDKs.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": {
|
package/dist/chunk-K22SISYC.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as Be,c as Te,d as Oe}from"./chunk-L34T3APU.js";import{a as _e}from"./chunk-QJXSZT3H.js";import{v as Ce}from"./chunk-VWT44HBR.js";import{a as we,c as zt,d as pt,f as dt,i as Ee}from"./chunk-D723OZEY.js";import{h as pe}from"./chunk-HYEZPOZU.js";import{e as Ie,l as Ae}from"./chunk-4N5CHKHD.js";import{B as xe,C as nn,Ma as wt,Va as gn,ba as $,ca as Mt,j as de,la as dn,na as Wt,oa as xn,qa as be,sa as Yt,ta as bn,ua as ge,wa as Nn,xa as Me,ya as Pe}from"./chunk-UISTXRO5.js";import{A as St,D as Re,b as Se,d as ot,y as et}from"./chunk-JBOTRSMY.js";import kr from"earcut";import Fe from"polygon-clipping";var P=$,Fr=.002;function Lr(t,n,e){let r=Math.hypot(n[0]-t[0],n[1]-t[1],n[2]-t[2]),o=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(r,o,a);if(i<1e-9)return!0;let s=(r+o+a)/2;return 2*Math.sqrt(Math.max(0,s*(s-r)*(s-o)*(s-a)))/i<Fr}var Ht=class{constructor(n=16384){this.len=0;this.buf=new Float32Array(n)}push3(n,e,r){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++]=r}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 r=new Float32Array(e);r.set(this.buf.subarray(0,this.len)),this.buf=r}get length(){return this.len}toArray(){return this.buf.slice(0,this.len)}},Sn=class{constructor(){this.pos=new Ht;this.nor=new Ht;this.col=new Ht;this.flr=new Ht;this.mat=new Ht;this.currentFloor=0;this.currentMaterial=0}setFloor(n){this.currentFloor=n}setMaterial(n){this.currentMaterial=n}tri(n,e,r,o,a,i=a,s=a){Lr(n,e,r)||(this.pos.push3(n[0],n[1],n[2]),this.pos.push3(e[0],e[1],e[2]),this.pos.push3(r[0],r[1],r[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[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),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}triN(n,e,r,o,a,i,s,u=s,c=s){[...n,...e,...r].every(Number.isFinite)&&(this.pos.push3(n[0],n[1],n[2]),this.pos.push3(e[0],e[1],e[2]),this.pos.push3(r[0],r[1],r[2]),this.nor.push3(o[0],o[1],o[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(u[0],u[1],u[2]),this.col.push3(c[0],c[1],c[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 vr(t,n,e){let r=n[0]-t[0],o=n[1]-t[1],a=n[2]-t[2],i=e[0]-t[0],s=e[1]-t[1],u=e[2]-t[2],c=o*u-a*s,l=a*i-r*u,f=r*s-o*i,m=Math.hypot(c,l,f)||1;return c/=m,l/=m,f/=m,[c,l,f]}function Dr(t,n){let e=[...t],r=[];for(let i of t)r.push(i.x,i.y);let o=[];if(n){for(let i of n)if(!(i.length<3)){o.push(e.length);for(let s of i)e.push(s),r.push(s.x,s.y)}}let a=kr(r,o.length?o:void 0,2);return{pts:e,tris:a}}function Et(t){return pt(t)<0?[...t].reverse():t}var Nr=3;function Gr(t,n,e,r){let o=r(t),a=r(n),i=r(e),s=(p,h,y,x)=>Math.abs(r({x:(p.x+h.x)/2,y:(p.y+h.y)/2})-(y+x)/2),u=(t.x+n.x+e.x)/3,c=(t.y+n.y+e.y)/3,l=(o+a+i)/3,f=Math.max(s(t,n,o,a),s(n,e,a,i),s(e,t,i,o),Math.abs(r({x:u,y:c})-l)),m=(p,h,y)=>{let x=Math.abs(r({x:(p+u)/2,y:(h+c)/2})-(y+l)/2);x>f&&(f=x)};return m((t.x+n.x)/2,(t.y+n.y)/2,(o+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+o)/2),f}function en(t,n,e,r,o){if(o<=0)return Gr(t,n,e,r);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(en(t,a,s,r,o-1),en(a,n,i,r,o-1),en(s,i,e,r,o-1),en(a,i,s,r,o-1))}function on(t,n,e,r,o,a,i,s){if(i>0){let m={x:(n.x+e.x)/2,y:(n.y+e.y)/2},p={x:(e.x+r.x)/2,y:(e.y+r.y)/2},h={x:(r.x+n.x)/2,y:(r.y+n.y)/2};on(t,n,m,h,o,a,i-1,s),on(t,m,e,p,o,a,i-1,s),on(t,h,p,r,o,a,i-1,s),on(t,m,p,h,o,a,i-1,s);return}let u=[n.x*P,o(n),n.y*P],c=[e.x*P,o(e),e.y*P],l=[r.x*P,o(r),r.y*P];if(s){t.triN(u,c,l,s(n),s(e),s(r),a);return}let f=vr(u,c,l);f[1]<0&&(f=[-f[0],-f[1],-f[2]]),t.tri(u,c,l,f,a)}var Hr=8;function ke(t,n,e){if(!Number.isFinite(e))return t;let r=[],o=(a,i,s,u,c)=>{if(c>0){let l={x:(a.x+i.x)/2,y:(a.y+i.y)/2},f=n(l);if(Math.abs(f-(s+u)/2)>e){o(a,l,s,f,c-1),o(l,i,f,u,c-1);return}}r.push(a)};for(let a=0;a<t.length;a++){let i=t[a],s=t[(a+1)%t.length];o(i,s,n(i),n(s),Hr)}return r}function Mn(t,n){if(t.length<3)return t;let e=[];for(let o of t){let a=e[e.length-1];a&&Math.hypot(o.x-a.x,o.y-a.y)<n||e.push(o)}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 r=[];for(let o=0;o<e.length;o++){let a=r.length?r[r.length-1]:e[(o-1+e.length)%e.length],i=e[o],s=e[(o+1)%e.length],u=s.x-a.x,c=s.y-a.y,l=Math.hypot(u,c);l>n&&Math.abs((i.x-a.x)*c-(i.y-a.y)*u)/l<n||r.push(i)}return r.length>=3?r:e}var Pn=.001*Mt*.1;function K(t,n,e,r,o,a,i,s,u=1/0,c){if(!n||n.length<3||(u===void 0&&(u=1/0),Math.abs(pt(n))<1e-4))return;let l=Mn(ke(Mn(Et(n),Pn),r,u),Pn),f=e?.map(I=>Mn(ke(Mn(Et(I),Pn),r,u),Pn)).filter(I=>I.length>=3&&Math.abs(pt(I))>=1e-4),{pts:m,tris:p}=Dr(l,f),h=[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],b=[i[0]*s.wallBottom,i[1]*s.wallBottom,i[2]*s.wallBottom],d=0;if(Number.isFinite(u))for(;d<Nr;d++){let I=0;for(let A=0;A<p.length;A+=3){let M=en(m[p[A]],m[p[A+1]],m[p[A+2]],r,d);M>I&&(I=M)}if(I<=u)break}for(let I=0;I<p.length;I+=3){let A=m[p[I]],M=m[p[I+1]],R=m[p[I+2]];on(t,A,M,R,r,h,d,c);let w=[A.x*P,o,A.y*P],T=[M.x*P,o,M.y*P],k=[R.x*P,o,R.y*P];t.tri(w,k,T,[0,-1,0],y)}let g=I=>{if(d<=0)return I;let A=1<<d,M=[];for(let R=0;R<I.length;R++){let w=I[R],T=I[(R+1)%I.length];for(let k=0;k<A;k++){let D=k/A;M.push({x:w.x+(T.x-w.x)*D,y:w.y+(T.y-w.y)*D})}}return M},S=xe(l),_=[{ring:g(l),flip:!1}];if(f)for(let I of f)I.length>=3&&_.push({ring:g(I),flip:!0});for(let{ring:I,flip:A}of _)for(let M=0;M<I.length;M++){let R=I[M],w=I[(M+1)%I.length],T=(w.x-R.x)*P,D=(w.y-R.y)*P,B=-T,E=Math.hypot(D,B)||1;D/=E,B/=E;let C=(R.x+w.x)/2-S.x,v=(R.y+w.y)/2-S.y,O=D*C+B*v;A&&(O=-O),O<0&&(D=-D,B=-B);let F=[D,0,B],L=[R.x*P,r(R),R.y*P],H=[w.x*P,r(w),w.y*P],j=[R.x*P,o,R.y*P],U=[w.x*P,o,w.y*P];t.tri(L,H,U,F,x,x,b),t.tri(L,U,j,F,x,b,b)}}function Le(t){let n=0;for(let u of t)n+=u.count;let e=new Float32Array(n*3),r=new Float32Array(n*3),o=new Float32Array(n*3),a=new Float32Array(n),i=new Float32Array(n),s=0;for(let u of t)e.set(u.position,s*3),r.set(u.normal,s*3),o.set(u.color,s*3),a.set(u.floor,s),i.set(u.material,s),s+=u.count;return{position:e,normal:r,color:o,floor:a,material:i,count:n}}function Rt(t,n,e=2.5){if(n<=0||t.length<3)return t;let r=Et(t),o=r.length,a=[];for(let s=0;s<o;s++){let u=r[s],c=r[(s+1)%o],l=c.x-u.x,f=c.y-u.y,m=Math.hypot(l,f)||1;a.push({x:f/m,y:-l/m})}let i=[];for(let s=0;s<o;s++){let u=r[s],c=a[(s-1+o)%o],l=a[s],f=c.x+l.x,m=c.y+l.y,p=Math.hypot(f,m),h=()=>{i.push([u.x+c.x*n,u.y+c.y*n]),i.push([u.x+l.x*n,u.y+l.y*n])};if(p<1e-9){h();continue}f/=p,m/=p;let y=f*c.x+m*c.y,x=1/Math.max(y,1e-6);if(!Number.isFinite(x)||x>e){h();continue}i.push([u.x+f*n*x,u.y+m*n*x])}if(i.length<3)return t;try{let s=Fe.union([[...i,i[0]]]),u=null,c=-1/0;for(let f of s){let m=Math.abs(pt(f[0].map(([p,h])=>({x:p,y:h}))));m>c&&(c=m,u=f[0])}if(!u)return t;let l=u.map(([f,m])=>({x:f,y:m}));if(l.length>1){let f=l[0],m=l[l.length-1];Math.abs(f.x-m.x)<1e-9&&Math.abs(f.y-m.y)<1e-9&&l.pop()}return l.length>=3?l:t}catch{return t}}function Lt(t,n,e=2.5){if(t.length<3)return[];if(n<=0)return t;let r=Et(t),o=r.length,a=[];for(let u=0;u<o;u++){let c=r[u],l=r[(u+1)%o],f=Math.hypot(l.x-c.x,l.y-c.y)||1;a.push({x:-(l.y-c.y)/f,y:(l.x-c.x)/f})}let i=[],s=[];for(let u=0;u<o;u++){let c=r[u],l=a[(u-1+o)%o],f=a[u],m=l.x+f.x,p=l.y+f.y,h=Math.hypot(m,p),y=h<1e-9?1/0:1/Math.max(m/h*l.x+p/h*l.y,1e-6);if(!Number.isFinite(y)||y>e){i.push({x:c.x+l.x*n,y:c.y+l.y*n},{x:c.x+f.x*n,y:c.y+f.y*n}),s.push(u,u);continue}m/=h,p/=h,i.push({x:c.x+m*n*y,y:c.y+p*n*y}),s.push(u)}for(let u=0;u<i.length;u++){let c=(u+1)%i.length,l=s[u],f=s[c];if(f!==(l+1)%o)continue;let m=r[l],p=r[f];if((i[c].x-i[u].x)*(p.x-m.x)+(i[c].y-i[u].y)*(p.y-m.y)<=0)return[]}try{let u=Fe.intersection([[...i.map(h=>[h.x,h.y]),[i[0].x,i[0].y]]],[[...r.map(h=>[h.x,h.y]),[r[0].x,r[0].y]]]),c=null,l=0;for(let h of u){let y=Math.abs(pt(h[0].map(([x,b])=>({x,y:b}))));y>l&&(l=y,c=h[0])}if(!c)return[];let f=c.map(([h,y])=>({x:h,y})),m=f[0],p=f[f.length-1];return f.length>1&&Math.abs(m.x-p.x)<1e-9&&Math.abs(m.y-p.y)<1e-9&&f.pop(),f.length>=3?Et(f):[]}catch{return[]}}function Rn(t,n,e,r,o=28){let a=[];for(let i=0;i<o;i++){let s=i/o*Math.PI*2;a.push({x:t+e*Math.cos(s),y:n+r*Math.sin(s)})}return a}function rn(t,n,e,r){return[{x:t,y:n},{x:t+e,y:n},{x:t+e,y:n+r},{x:t,y:n+r}]}var sn=["available","held","sold","selected","dimmed"];function Gn(t){let n=sn.indexOf(t);return n<0?0:n}var ve={available:[.24,.82,.52],held:[.34,.39,.45],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};function Ac(t){let n=.2126*t[0]+.7152*t[1]+.0722*t[2],e=.78,r=.86;return[(n+(t[0]-n)*e)*r,(n+(t[1]-n)*e)*r,(n+(t[2]-n)*e)*r]}var Hn={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]},Xn={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)]}var lt={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,body:10,head:11},Xr=.44,jr=.15,Ur=.3,Wr=.24;function Ne(t){return t===void 0||!Number.isFinite(t)||t<=0?Wr:Math.min(Ur,Math.max(jr,t*Xr))}var wc=.21,Yr=.05,jn=.45,zr=jn+Yr,Vr=.92,De=.66,Kr=1.205,Zr=-.23,qr=.38,$r=[{part:lt.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:lt.pad,min:[-1,.36,-.95],max:[1,jn,1]},{part:lt.back,min:[-1,zr,-1],max:[1,Vr,-.72]},{part:lt.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:lt.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:lt.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:lt.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:lt.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:lt.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:lt.leg,min:[.62,0,.48],max:[.82,.37,.7]}],Qr=[{part:lt.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:lt.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:lt.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:lt.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:lt.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}],Jr=[{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 Ec(){let t=[],n=[],e=[],r=[],o=(C,v,O)=>{let F=e.length,[L,H,j]=C,U=[H[0]-L[0],H[1]-L[1],H[2]-L[2]],X=[j[0]-L[0],j[1]-L[1],j[2]-L[2]],W=U[1]*X[2]-U[2]*X[1],Q=U[2]*X[0]-U[0]*X[2],tt=U[0]*X[1]-U[1]*X[0],q=Math.hypot(W,Q,tt);q>1e-9?(W/=q,Q/=q,tt/=q):[W,Q,tt]=v,W*v[0]+Q*v[1]+tt*v[2]<0&&(W=-W,Q=-Q,tt=-tt);for(let st of C)t.push(...st),n.push(W,Q,tt),e.push(O);r.push(F,F+1,F+2,F,F+2,F+3)},a=C=>{for(let v of Jr){let O=v.c.map(F=>F.map((L,H)=>L?C.max[H]:C.min[H]));o(O,v.n,C.part)}},i=(C,v)=>{let[O,F,L]=v?[0,1,2]:[0,2,1],H=C.min[O],j=C.max[O],U=C.min[F],X=C.max[F],W=(j-H)*.1,Q=(X-U)*.1,tt=v?[[H+W,U],[j-W,U],[j,U+Q],[j*.94,X-(X-U)*.23],[j*De,X],[H*De,X],[H*.94,X-(X-U)*.23],[H,U+Q]]:[[H+W,U],[j-W,U],[j,U+Q],[j,X-Q],[j-W,X],[H+W,X],[H,X-Q],[H,U+Q]],q=(nt,N,G)=>{let V=[0,0,0];return V[O]=nt,V[F]=N,V[L]=G,V},st=[C.min[L],C.max[L]].map(nt=>tt.map(([N,G])=>q(N,G,nt)));for(let nt=0;nt<tt.length;nt++){let N=(nt+1)%tt.length,G=[0,0,0];G[O]=(tt[nt][0]+tt[N][0])/2-(H+j)/2,G[F]=(tt[nt][1]+tt[N][1])/2-(U+X)/2,o([st[0][nt],st[0][N],st[1][N],st[1][nt]],G,C.part)}for(let nt=0;nt<2;nt++){let N=[0,0,0];N[L]=nt?1:-1;let G=st[nt];for(let V=1;V<G.length-1;V++){let at=e.length;for(let ft of[G[0],G[V],G[V+1]])t.push(...ft),n.push(...N),e.push(C.part);r.push(at,at+1,at+2)}}};for(let C of $r)C.part===lt.pad||C.part===lt.back?i(C,C.part===lt.back):a(C);for(let C of Qr)a(C);let s=jn,u=1.08,c=.47,l=.69,f=-.55,m=.08,p=-.48,h=.01,y=[-c,s,f],x=[c,s,f],b=[-c,s,m],d=[c,s,m],g=[-l,u,p],S=[l,u,p],_=[-l,u,h],I=[l,u,h];o([x,S,I,d],[1,0,0],lt.body),o([b,_,g,y],[-1,0,0],lt.body),o([_,I,S,g],[0,1,0],lt.body),o([y,x,d,b],[0,-1,0],lt.body),o([d,I,_,b],[0,0,1],lt.body),o([y,g,S,x],[0,0,-1],lt.body);let A=10,M=8,R=[0,Kr,Zr],w=[.42,.115,qr],T=e.length;for(let C=0;C<=M;C++){let v=Math.PI*C/M,O=Math.cos(v),F=Math.sin(v);for(let L=0;L<=A;L++){let H=Math.PI*2*L/A,j=F*Math.cos(H),U=F*Math.sin(H);t.push(R[0]+w[0]*j,R[1]+w[1]*O,R[2]+w[2]*U);let X=j/w[0],W=O/w[1],Q=U/w[2],tt=Math.hypot(X,W,Q)||1;X/=tt,W/=tt,Q/=tt,n.push(X,W,Q),e.push(lt.head)}}for(let C=0;C<M;C++)for(let v=0;v<A;v++){let O=T+C*(A+1)+v,F=O+A+1;r.push(O,F,O+1,O+1,F,F+1)}let k=new Float32Array(t),D=new Float32Array(n),B=new Float32Array(e),E=new Uint16Array(r);return{position:k,normal:D,part:B,index:E,vertexCount:e.length,indexCount:r.length}}function Ge(t,n,e,r){let o=new Float32Array(n),a=c=>t[c*3],i=c=>t[c*3+2],s=0,u=(c,l)=>{let f=l-c;for(let m=c;m<l;m++){let[p,h]=r(m),y=p-a(m),x=h-i(m);if(f>=2){let b=Math.max(c,m-1),d=Math.min(l-1,m+1),g=a(d)-a(b),S=i(d)-i(b),_=Math.hypot(g,S);if(_>1e-6){let I=-S/_,A=g/_;I*y+A*x<0&&(I=-I,A=-A),y=I,x=A}}o[m]=y===0&&x===0?0:Math.atan2(y,x)}};for(let c=1;c<=n;c++)(c===n||e(c)!==e(s))&&(u(s,c),s=c);return o}var In=.22;function Dc(t,n){let e=sn[t];if(e!=="sold"&&e!=="held")return-1;let r=(n+1)*2654435761;return r^=r>>>15,r=Math.imul(r,2246822519),r^=r>>>13,(r>>>0)%1e5/1e5}var ti=.42;function ni(t){let n=t.length,e=new Float64Array(n);if(n<2)return e.fill(1/0),e;let r=1/0,o=1/0,a=-1/0,i=-1/0;for(let h of t)h.x<r&&(r=h.x),h.y<o&&(o=h.y),h.x>a&&(a=h.x),h.y>i&&(i=h.y);let s=Math.max(a-r,1e-6),u=Math.max(i-o,1e-6),c=Math.max(Math.sqrt(s*u/n),1e-6),l=Math.max(1,Math.ceil(s/c)+1),f=Math.max(1,Math.ceil(u/c)+1),m=new Map,p=(h,y)=>{let x=Math.min(l-1,Math.max(0,Math.floor((h-r)/c)));return Math.min(f-1,Math.max(0,Math.floor((y-o)/c)))*l+x};for(let h=0;h<n;h++){let y=p(t[h].x,t[h].y),x=m.get(y);x?x.push(h):m.set(y,[h])}for(let h=0;h<n;h++){let y=t[h],x=Math.min(l-1,Math.max(0,Math.floor((y.x-r)/c))),b=Math.min(f-1,Math.max(0,Math.floor((y.y-o)/c))),d=1/0;for(let g=1;g<=4;g++){for(let S=b-g;S<=b+g;S++)if(!(S<0||S>=f))for(let _=x-g;_<=x+g;_++){if(_<0||_>=l||g>1&&Math.abs(S-b)<g&&Math.abs(_-x)<g)continue;let I=m.get(S*l+_);if(I)for(let A of I){if(A===h)continue;let M=Math.hypot(t[A].x-y.x,t[A].y-y.y);M<d&&(d=M)}}if(Number.isFinite(d)&&d<=g*c)break}e[h]=d}return e}function ei(t){let n=t.eyeHeightM;return Number.isFinite(n)?Math.max(0,n-dn):0}function He(t,n,e,r,o,a){let i=t.length,s=new Float32Array(i*3),u=new Float32Array(i),c=new Float32Array(i*3),l=new Float32Array(i),f=new Float32Array(i),m=new Float32Array(i),p=new Float32Array(i),h=new Float32Array(i*3),y=new Map,x=ni(t);for(let b=0;b<i;b++){let d=t[b],S=(e?.seatPitchU(b)??x[b])*P;l[b]=Number.isFinite(S)?Math.max(.06,Math.min(In,S*ti)):In,f[b]=Ne(Number.isFinite(S)?S:void 0);let _=Ae(d.glyph,{seatGlyph:a?.get(d.categoryKey)});m[b]=Ie.indexOf(_),p[b]=d.wheelchairSpaceType==="no-seat"?0:1,s[b*3]=d.x*P,s[b*3+1]=e?e.seatDeckY(b):ei(d),s[b*3+2]=d.y*P,u[b]=Gn(n?n(d):"available");let I=ot(o?.get(d.categoryKey)??"#6e7bff")??[.43,.48,1];if(c[b*3]=I[0],c[b*3+1]=I[1],c[b*3+2]=I[2],d.accessibility?.length){let A=ot(pe(d.accessibility));A&&(h[b*3]=A[0],h[b*3+1]=A[1],h[b*3+2]=A[2])}y.set(d.id,b)}return{count:i,iPosition:s,iState:u,iCategory:c,iMaxRadius:l,iRing:h,idToIndex:y,iChairWidth:f,iGlyph:m,iPhysicalSeat:p,iFloor:r??new Float32Array(i),iSection:new Float32Array(i).fill(-1),iYaw:new Float32Array(i)}}var oi=64;function Nc(t,n){let e=[];for(let i of n){let s=t.idToIndex.get(i.seatId);if(s===void 0)continue;let u=Gn(i.state);t.iState[s]!==u&&(t.iState[s]=u,e.push(s))}if(!e.length)return[];e.sort((i,s)=>i-s);let r=[],o=e[0],a=e[0];for(let i=1;i<e.length;i++){let s=e[i];if(s!==a){if(s<=a+oi){a=s;continue}r.push({start:o,length:a-o+1}),o=s,a=s}}return r.push({start:o,length:a-o+1}),r}import di from"polygon-clipping";var Y={top:1,wallBottom:.58,bottomCap:.4};function Xt(t,n){if(!t)return n;let e=Z(St(t,.4),.62);return et(n,e,.22)}function Xe(t,n){return t?et(n,Z(St(t,.25),.74),.62):n}function je(t,n){return t?et(n,Z(St(t,.08),.9),.82):n}function Ue(t,n){let e=new Map;for(let a of t.categories??[])e.set(a.key,a.color);let r=new Map;for(let a of n){if(!a.sectionId)continue;let i=r.get(a.sectionId);i||(i=new Map,r.set(a.sectionId,i)),i.set(a.categoryKey,(i.get(a.categoryKey)??0)+1)}let o=new Map;for(let[a,i]of r){let s=0,u=0,c=0,l=0;for(let[f,m]of i){let p=ot(e.get(f));p&&(s+=p[0]*m,u+=p[1]*m,c+=p[2]*m,l+=m)}l>0&&o.set(a,[s/l,u/l,c/l])}return o}function We(t,n){return ot(t.color)??n.get(t.logicalSectionId??t.id)??null}import oo from"polygon-clipping";import Ke from"polygon-clipping";import ri from"earcut";var ii=.58,Ye=.01,Pt=In*1.5*Mt,si=.5,ai=.6;function ci(t,n){let e=t.length,r=[];for(let i=0;i<e;i++){let s=t[Math.max(0,i-1)],u=t[Math.min(e-1,i+1)],c=u.x-s.x,l=u.y-s.y,f=Math.hypot(c,l);if(f<1e-9){r.push([0,0]);continue}c/=f,l/=f,r.push([-l,c])}let o=0;for(let i=0;i<e;i++)o+=(t[i].x-n.x)*r[i][0]+(t[i].y-n.y)*r[i][1];return o<0?r.map(([i,s])=>[-i,-s]):r}function li(t,n){if(t.length<2||n<=0)return[...t];let e=[...t],r=(i,s)=>{let u=s.x-i.x,c=s.y-i.y,l=Math.hypot(u,c)||1;return{x:u/l,y:c/l}},o=r(e[1],e[0]),a=r(e[e.length-2],e[e.length-1]);return e.unshift({x:e[0].x+o.x*n,y:e[0].y+o.y*n}),e.push({x:e[e.length-1].x+a.x*n,y:e[e.length-1].y+a.y*n}),e}var ze=Math.PI/12;function ui(t){if(t.length<3)return[...t];let n=[...t].sort((a,i)=>a.x-i.x||a.y-i.y),e=(a,i,s)=>(i.x-a.x)*(s.y-a.y)-(i.y-a.y)*(s.x-a.x),r=a=>{let i=[];for(let s of a){for(;i.length>=2&&e(i[i.length-2],i[i.length-1],s)<=0;)i.pop();i.push(s)}return i.pop(),i},o=[...r(n),...r([...n].reverse())];return o.length>=3?o:[...t]}function Ze(t,n){if(!t.length||!(n>0))return[];let e=ui(t),r=(s,u,c,l)=>{let f=c-u;for(;f<0;)f+=Math.PI*2;for(;f>Math.PI*2;)f-=Math.PI*2;let m=Math.max(1,Math.ceil(f/ze)),p=n/Math.cos(f/m/2);for(let h=0;h<=m;h++){let y=u+f*h/m;l.push({x:s.x+Math.cos(y)*p,y:s.y+Math.sin(y)*p})}};if(e.length<3){let s=0,u=0;for(let p of e)s+=p.x,u+=p.y;s/=e.length||1,u/=e.length||1;let c=0;for(let p of e)c=Math.max(c,Math.hypot(p.x-s,p.y-u));let l=[],f=Math.max(3,Math.ceil(Math.PI*2/ze)),m=(c+n)/Math.cos(Math.PI/f);for(let p=0;p<f;p++){let h=p/f*Math.PI*2;l.push({x:s+Math.cos(h)*m,y:u+Math.sin(h)*m})}return l}let o=e.length,a=[];for(let s=0;s<o;s++){let u=e[s],c=e[(s+1)%o];a.push(Math.atan2(-(c.x-u.x),c.y-u.y))}let i=[];for(let s=0;s<o;s++)r(e[s],a[(s+o-1)%o],a[s],i);return to(i)}function fi(t,n,e){if(t.length===1)return Math.hypot(n-t[0].x,e-t[0].y);let r=1/0;for(let o=0;o+1<t.length;o++){let a=t[o],i=t[o+1],s=i.x-a.x,u=i.y-a.y,c=s*s+u*u,l=c>1e-12?((n-a.x)*s+(e-a.y)*u)/c:0;l<0?l=0:l>1&&(l=1);let f=Math.hypot(n-(a.x+l*s),e-(a.y+l*u));f<r&&(r=f)}return r}function An(t){let n=t.map(o=>{let a=0,i=0;for(let c of o.pts)a+=c.x,i+=c.y;let s=o.pts.length||1;a/=s,i/=s;let u=0;for(let c of o.pts){let l=Math.hypot(c.x-a,c.y-i);l>u&&(u=l)}return{cx:a,cy:i,rad:u}}),e=o=>{let a=o.length;return a<=2?[...o]:[o[Math.floor(a*.25)],o[Math.floor(a*.5)],o[Math.floor(a*.75)]]},r=[];for(let o=0;o<t.length;o++){let a=e(t[o].pts),i=[],s=1/0,u=null;for(let l of a){let f=1/0;for(let m=0;m<t.length;m++){if(m===o||Math.abs(t[m].y-t[o].y)<.001)continue;let p=n[m],h=Math.hypot(l.x-p.cx,l.y-p.cy)-p.rad;if(h>=f&&h>=s)continue;let y=fi(t[m].pts,l.x,l.y);y<f&&(f=y),t[m].depth<t[o].depth&&y<s&&(s=y,u=t[m].y)}Number.isFinite(f)&&f>0&&i.push(f)}i.sort((l,f)=>l-f);let c=i.length?i[Math.floor(i.length/2)]:1;r.push({pitch:c,belowY:u})}return r}function qe(t,n,e,r){let o=t[n],a=o.pts.length>=2?[...o.pts]:o.pts.length===1?(()=>{let l=o.pts[0],f=l.x-r.x,m=l.y-r.y,p=Math.hypot(f,m)||1;f/=p,m/=p;let h=Math.max(e[n].pitch,.001)*.5;return[{x:l.x+m*h,y:l.y-f*h},{x:l.x-m*h,y:l.y+f*h}]})():[];if(a.length<2)return null;let i=0,s=0;for(let l=1;l<a.length;l++){let f=Math.hypot(a[l].x-a[l-1].x,a[l].y-a[l-1].y);f>1e-6&&(i+=f,s++)}let u=s>0?i/s:0,c=li(a,Math.max(u*ai,Pt));return{pts:c,nrm:ci(c,r),front:Math.max(e[n].pitch*ii,Pt),back:Math.max(e[n].pitch*si,Pt)}}var Vt=1.5,$e=.3;function Un(t,n){if(t.length<3)return t;let e=t[0],r=t[t.length-1],o=r.x-e.x,a=r.y-e.y,i=Math.hypot(o,a),s=-1,u=-1;for(let f=1;f<t.length-1;f++){let m=t[f],p=i>1e-12?Math.abs((m.x-e.x)*a-(m.y-e.y)*o)/i:Math.hypot(m.x-e.x,m.y-e.y);p>s&&(s=p,u=f)}if(s<=n||u<0)return[e,r];let c=Un(t.slice(0,u+1),n),l=Un(t.slice(u),n);return[...c.slice(0,-1),...l]}function Qe(t,n){if(t.length<4)return t;let e=Un([...t,t[0]],n);return e.pop(),e.length>=3?e:t}function mi(t){let n=t.map((r,o)=>{let a=t[(o+1)%t.length];return{a:r,b:a,i:o,minX:Math.min(r.x,a.x),maxX:Math.max(r.x,a.x),minY:Math.min(r.y,a.y),maxY:Math.max(r.y,a.y)}}).sort((r,o)=>r.minX-o.minX),e=(r,o,a)=>(o.x-r.x)*(a.y-r.y)-(o.y-r.y)*(a.x-r.x);for(let r=0;r<n.length;r++){let o=n[r];for(let a=r+1;a<n.length&&n[a].minX<=o.maxX;a++){let i=n[a];if(!(Math.abs(o.i-i.i)===1||Math.abs(o.i-i.i)===t.length-1||o.maxY<i.minY||i.maxY<o.minY)&&e(o.a,o.b,i.a)*e(o.a,o.b,i.b)<=0&&e(i.a,i.b,o.a)*e(i.a,i.b,o.b)<=0)return!0}}return!1}function Je(t,n,e){if(t.length<2)return[];let r=e??An(t),o=new Map;for(let i=0;i<t.length;i++){let s=o.get(t[i].blockId);s?s.push(i):o.set(t[i].blockId,[i])}let a=[];for(let[,i]of o){let s=[];for(let d of i){let g=t[d].patch;g&&g.length>=3?a.push({outline:[...g],holes:[],topY:t[d].y}):s.push(d)}if(!s.length)continue;s.sort((d,g)=>t[d].depth-t[g].depth);let c=s.map(d=>qe(t,d,r,n)).filter(d=>d!==null);if(!c.length)continue;let l=(d,g)=>({x:d.pts[g].x-d.nrm[g][0]*(d.front+Vt),y:d.pts[g].y-d.nrm[g][1]*(d.front+Vt)}),f=(d,g)=>({x:d.pts[g].x+d.nrm[g][0]*(d.back+Vt),y:d.pts[g].y+d.nrm[g][1]*(d.back+Vt)}),m=c[0],p=c[c.length-1],h=[];for(let d=0;d<m.pts.length;d++)h.push(l(m,d));for(let d of c)h.push(f(d,d.pts.length-1));for(let d=p.pts.length-1;d>=0;d--)h.push(f(p,d));for(let d=c.length-1;d>=0;d--)h.push(l(c[d],0));let y=to(h),x=1/0;for(let d of s)t[d].y<x&&(x=t[d].y);if(!Number.isFinite(x))continue;if(y.length>=3&&Math.abs(pt(y))>1e-6&&c.every(d=>{let g=d.pts[Math.floor(d.pts.length/2)];return dt(y,g.x,g.y)})&&!mi(y)){a.push({outline:Qe(y,$e),holes:[],topY:x});continue}for(let d of hi(c))a.push({outline:d,holes:[],topY:x})}return a}function hi(t){let n=[];for(let e of t){let r=[],o=[],a=e.front+Vt,i=e.back+Vt;for(let u=0;u<e.pts.length;u++){let c=e.pts[u],l=e.nrm[u];r.push([c.x-l[0]*a,c.y-l[1]*a]),o.push([c.x+l[0]*i,c.y+l[1]*i])}let s=[...r,...o.reverse()];s.length<3||(s.push(s[0]),n.push([s]))}if(!n.length)return[];try{let e=Ke.union(n[0],...n.slice(1)),r=[];for(let o of e){if(!o.length||o[0].length<4)continue;let a=o[0].map(([u,c])=>({x:u,y:c})),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&&r.push(Qe(a,$e))}return r}catch{return[]}}function to(t){let n=[];for(let e of t){let r=n[n.length-1];r&&Math.hypot(e.x-r.x,e.y-r.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 Wn=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 r of e)r.x<this.minX&&(this.minX=r.x),r.y<this.minY&&(this.minY=r.y),r.x>this.maxX&&(this.maxX=r.x),r.y>this.maxY&&(this.maxY=r.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 r=!0;for(let o of n)if(!dt(e,o.x,o.y)){r=!1;break}if(r)return!0}return!1}};function Ve(t,n,e,r,o,a){if(r.length<3)return;if(e.containsAll(r)){let c=[0,1,0],l=r[0];for(let f=1;f+1<r.length;f++){let m=r[f],p=r[f+1];t.tri([l.x*P,o,l.y*P],[m.x*P,o,m.y*P],[p.x*P,o,p.y*P],c,a)}return}let i=r.map(c=>[c.x,c.y]);i.push(i[0]);let s;try{s=Ke.intersection([i],n)}catch{return}let u=[0,1,0];for(let c of s){if(!c.length||c[0].length<4)continue;let l=c[0],f=[],m=[];for(let h=0;h<l.length-1;h++)f.push(l[h][0],l[h][1]),m.push([l[h][0],l[h][1]]);if(m.length<3)continue;let p=ri(f,void 0,2);for(let h=0;h<p.length;h+=3){let y=m[p[h]],x=m[p[h+1]],b=m[p[h+2]];t.tri([y[0]*P,o,y[1]*P],[x[0]*P,o,x[1]*P],[b[0]*P,o,b[1]*P],u,a)}}}function no(t,n,e,r,o,a,i){if(n.length<2)return;let s=i??An(n),u=[0,1,0],c=a&&a.length>=3?[[...a.map(p=>[p.x,p.y]),[a[0].x,a[0].y]]]:null,l=a&&a.length>=3?new Wn([[...a]]):null,f=p=>{t.setMaterial(2),p(),t.setMaterial(0)},m=p=>{t.setMaterial(3),p(),t.setMaterial(0)};for(let p=0;p<n.length;p++){let h=n[p];if(h.patch&&h.patch.length>=3){let _=[...h.patch],I=s[p].belowY??r;if(m(()=>{if(c&&l)Ve(t,c,l,_,h.y,o.tread);else{let A=_[0];for(let M=1;M+1<_.length;M++){let R=_[M],w=_[M+1];t.tri([A.x*P,h.y,A.y*P],[R.x*P,h.y,R.y*P],[w.x*P,h.y,w.y*P],u,o.tread)}}}),h.y>I+Ye){let A=0,M=0;for(let R of _)A+=R.x,M+=R.y;A/=_.length,M/=_.length,f(()=>{for(let R=0;R<_.length;R++){let w=_[R],T=_[(R+1)%_.length],k=T.x-w.x,D=T.y-w.y,B=Math.hypot(k,D);if(B<1e-6)continue;let E=D/B,C=-k/B;(w.x-A)*E+(w.y-M)*C<0&&(E=-E,C=-C);let v=[E,0,C],O=[w.x*P,h.y,w.y*P],F=[T.x*P,h.y,T.y*P],L=[w.x*P,I,w.y*P],H=[T.x*P,I,T.y*P];t.tri(O,F,H,v,o.riser),t.tri(O,H,L,v,o.riser)}})}continue}let y=qe(n,p,s,e);if(!y)continue;let{pts:x,nrm:b,front:d,back:g}=y,S=s[p].belowY??r;for(let _=0;_+1<x.length;_++){let I=x[_],A=x[_+1],M=b[_],R=b[_+1];if(Math.hypot(A.x-I.x,A.y-I.y)<1e-6||M[0]===0&&M[1]===0||R[0]===0&&R[1]===0)continue;let w=[(I.x-M[0]*d)*P,h.y,(I.y-M[1]*d)*P],T=[(A.x-R[0]*d)*P,h.y,(A.y-R[1]*d)*P],k=[(I.x+M[0]*g)*P,h.y,(I.y+M[1]*g)*P],D=[(A.x+R[0]*g)*P,h.y,(A.y+R[1]*g)*P];if(m(()=>{c&&l?Ve(t,c,l,[{x:I.x-M[0]*d,y:I.y-M[1]*d},{x:A.x-R[0]*d,y:A.y-R[1]*d},{x:A.x+R[0]*g,y:A.y+R[1]*g},{x:I.x+M[0]*g,y:I.y+M[1]*g}],h.y,o.tread):(t.tri(w,T,D,u,o.tread),t.tri(w,D,k,u,o.tread))}),h.y>S+Ye){let B=[w[0],S,w[2]],E=[T[0],S,T[2]],C=[-M[0],0,-M[1]];f(()=>{t.tri(w,T,E,C,o.riser),t.tri(w,E,B,C,o.riser)})}}}}function yi(t,n){let e=t.eventConfigurationIds;return!e?.length||!!n&&e.includes(n)}function eo(t,n){return t.filter(e=>e.type!=="shape"||yi(e,n))}function ro(t,n){let e=t.focalPoint??{x:0,y:0};return t.floors?.length?t.floors.map((r,o)=>({objects:eo(r.objects,n),focal:{x:(r.focalPoint??e).x,y:(r.focalPoint??e).y},baseHeightM:r.baseHeightM??0,index:o})):[{objects:eo(t.objects,n),focal:e,baseHeightM:0,index:0}]}var pi={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Tt(t){return we(t)??pi}function io(t,n){let e=Rt(t.outline,Pt),r=Tt(e),o=n.filter(i=>i!==t&&i.outline&&i.outline.length>=3&&zt(r,Tt(i.outline)));if(!o.length)return[e];let a=i=>{let s=i.map(u=>[u.x,u.y]);return s.push(s[0]),s};try{let i=oo.difference([a(e)],...o.map(u=>[a(u.outline)])),s=[];for(let u of i){if(!u.length)continue;let c=u[0].map(([l,f])=>({x:l,y:f}));if(c.length>1){let l=c[0],f=c[c.length-1];Math.abs(l.x-f.x)<1e-9&&Math.abs(l.y-f.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s.length?s:[e]}catch{return[e]}}function so(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},r=n.map(a=>[e(a)]),o=[];for(let a of t){let i;try{i=oo.intersection([e(a.outline)],r.flat())}catch{o.push(a);continue}for(let s of i){if(!s.length)continue;let u=s[0].map(([c,l])=>({x:c,y:l}));if(u.length>1){let c=u[0],l=u[u.length-1];Math.abs(c.x-l.x)<1e-9&&Math.abs(c.y-l.y)<1e-9&&u.pop()}u.length>=3&&o.push({outline:u,holes:[],topY:a.topY})}}return o.length?o:t}function xi(t,n){return t===void 0||n===void 0?!0:Math.abs(t-n)<.001}var _n=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(n,e){let r=n.map(u=>[u.x,u.y]);if(r.length<3)return[];r.push(r[0]);let o=Tt(n),a=this.rings.filter((u,c)=>zt(o,this.boxes[c])&&xi(e,this.levels[c])),i=[[r]];if(a.length)try{i=di.difference([r],...a).map(c=>c.map(l=>l.map(([f,m])=>[f,m])))}catch{i=[[r]]}this.rings.push([r]),this.boxes.push(o),this.levels.push(e);let s=[];for(let u of i){if(!u.length)continue;let c=u[0].map(([l,f])=>({x:l,y:f}));if(c.length>1){let l=c[0],f=c[c.length-1];Math.abs(l.x-f.x)<1e-9&&Math.abs(l.y-f.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s}};function wn(t,n){if(!n)return t;let e=1/0,r=-1/0,o=1/0,a=-1/0;for(let f of t)e=Math.min(e,f.x),r=Math.max(r,f.x),o=Math.min(o,f.y),a=Math.max(a,f.y);let i=(e+r)/2,s=(o+a)/2,u=n*Math.PI/180,c=Math.cos(u),l=Math.sin(u);return t.map(f=>{let m=f.x-i,p=f.y-s;return{x:i+m*c-p*l,y:s+m*l+p*c}})}function it(t){let n=null;if(t.kind==="polygon"&&t.points&&t.points.length>=3&&(n=t.points),t.kind==="rect"&&t.width&&t.height&&(n=rn(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,r=(t.y??0)+t.height/2;n=Rn(e,r,t.width/2,t.height/2)}return n?wn(n,t.rotation):null}function It(t){let n=t.role??"",e={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}},r=n==="stage"&&Me(t.stageKind)?{kind:"stage",heightM:t.stageKind==="ring-boxing"?ge:.06}:e[n]??{kind:"plate",heightM:.25};return{...r,heightM:t.heightM??r.heightM}}var bi=.08,gi=30,Mi=.015;function Pi(t,n){let e=!1;for(let r=0,o=n.length-1;r<n.length;o=r++){let a=n[r],i=n[o];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 ao(t,n){let e=it(t)??(t.points?.length?wn(t.points,t.rotation):null),r=It(t),a=!t.role&&r.kind==="plate"&&t.heightM===void 0&&!!e&&Math.abs(pt(e))*$**2>=gi?Mi:r.heightM;if(!e)return{topOffsetM:a,supportOffsetM:0};if(r.kind!=="plate"&&r.kind!=="stage")return{topOffsetM:a,supportOffsetM:0};let i=1/0,s=1/0,u=-1/0,c=-1/0;for(let p of e)i=Math.min(i,p.x),s=Math.min(s,p.y),u=Math.max(u,p.x),c=Math.max(c,p.y);let l=a,f=0,m=1e-6*Math.max(1,u-i,c-s);for(let p of n)u>p.minX&&i<p.maxX&&c>p.minY&&s<p.maxY&&l<=p.topOffsetM+1e-6&&(l=p.topOffsetM+bi),i>=p.minX-m&&u<=p.maxX+m&&s>=p.minY-m&&c<=p.maxY+m&&(!p.poly||e.every(x=>Pi(x,p.poly)||Si(x,p.poly,m)))&&(f=Math.max(f,p.topOffsetM));return t.fill&&t.fill!=="none"&&t.fill!=="transparent"&&n.push({minX:i,minY:s,maxX:u,maxY:c,topOffsetM:l,poly:e}),{topOffsetM:l,supportOffsetM:Math.min(f,l)}}function Si(t,n,e){for(let r=0,o=n.length-1;r<n.length;o=r++){let a=n[o],i=n[r],s=i.x-a.x,u=i.y-a.y,c=s*s+u*u,l=c?Math.max(0,Math.min(1,((t.x-a.x)*s+(t.y-a.y)*u)/c)):0;if(Math.hypot(t.x-(a.x+l*s),t.y-(a.y+l*u))<=e)return!0}return!1}function vt(t,n,e){return{x:t.x+(n.x-t.x)*e,y:t.y+(n.y-t.y)*e}}function xt(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 yt(t,n,e){return[vt(t[0],t[1],n),vt(t[0],t[1],e),vt(t[3],t[2],e),vt(t[3],t[2],n)]}function an(t,n,e){return[vt(t[0],t[3],n),vt(t[1],t[2],n),vt(t[1],t[2],e),vt(t[0],t[3],e)]}function J(t,n,e,r,o,a){K(t,n,void 0,()=>e,r,o,a,Y)}function cn(t){if(t.length<3)return t.map(a=>({...a}));let n=[...t].sort((a,i)=>a.x-i.x||a.y-i.y),e=(a,i,s)=>(i.x-a.x)*(s.y-a.y)-(i.y-a.y)*(s.x-a.x),r=a=>{let i=[];for(let s of a){for(;i.length>=2&&e(i[i.length-2],i[i.length-1],s)<=0;)i.pop();i.push(s)}return i.pop(),i},o=[...r(n),...r([...n].reverse())];return o.length>=3?o.map(a=>({...a})):n.map(a=>({...a}))}var Ri=.8,Ii=.6,Ai=2;function Kt(t,n){if(!n.length)return null;let e=[],r=0;for(let i of t.objects){if(i.type!=="shape"||i.role!=="wall")continue;let s=it(i)??[],u=co(s)/2;!(u>0)||Ei(s)/u*P>Ai||(e.push(...s),r+=u)}if(e.length<3)return null;let o=cn(e);if(o.length<3||r<co(o)*Ii)return null;let a=0;for(let i of n)Bi(i,o)&&(a+=1);return a>=n.length*Ri?o:null}var lo=6,_i=5,wi=8;function uo(t){return Math.max(wi,(Number.isFinite(t)?t:0)+_i)}function fo(t){let n=0,e=0,r=0;for(let o=0;o<t.length;o++){let a=t[o],i=t[(o+1)%t.length],s=a.x*i.y-i.x*a.y;n+=s,e+=(a.x+i.x)*s,r+=(a.y+i.y)*s}if(Math.abs(n)<1e-9){let o=0,a=0;for(let i of t)o+=i.x,a+=i.y;return{x:o/Math.max(1,t.length),y:a/Math.max(1,t.length)}}return{x:e/(3*n),y:r/(3*n)}}function Ei(t){let n=0;for(let e=0;e<t.length;e++){let r=t[e],o=t[(e+1)%t.length];n+=r.x*o.y-o.x*r.y}return Math.abs(n)/2}function co(t){let n=0;for(let e=0;e<t.length;e++){let r=t[e],o=t[(e+1)%t.length];n+=Math.hypot(o.x-r.x,o.y-r.y)}return n}function Bi(t,n){let e=!1;for(let r=0,o=n.length-1;r<n.length;o=r++){let a=n[r],i=n[o];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 Ti=[[/\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"]],Oi=1.2,Ci=12;function mo(t){if(t.heightM!==void 0)return!1;let n=it(t);if(!n||n.length<3)return!1;let e=0;for(let o=0;o<n.length;o++){let a=n[o],i=n[(o+1)%n.length];e+=Math.hypot(i.x-a.x,i.y-a.y)}return e*$<Ci*2?!1:2*ln(n)/e*$<=Oi}function Yn(t){if(!t)return null;for(let[n,e]of Ti)if(n.test(t))return e;return null}var yo="auto-rows-";function po(t){return t.id.startsWith(yo)&&!t.label}var ki=1.15,Fi=.09,xo=6,Li=34,vi=.35,Di=6,Ni=.35,Gi=.75,Hi=12,Xi=2.5,ji=40,Ui=[18,24],Wi=[12,16],ho=14,Yi=.8,zi=.6,Vi=5,Ki=.3,bo=.4,Zi=2,qi=400,$i=2.6,Qi=.8,Ji=4,ts=26,ns=1.6,es=6e3,os=.6,rs="#c3c7cd",zn=300,is=240;function ss(t,n,e,r){if(!t.fill||!/^#[0-9a-f]{6}$/i.test(t.fill))return null;let o=Kn([...n]),a=new Set;for(let l of r)a.add(Math.floor(Math.atan2(l.y-o.y,l.x-o.x)*180/Math.PI/10));if(a.size*10<is)return null;let{h:i,s,l:u}=Re(Se(t.fill));return i<70/360||i>170/360||s<.2||u<.08||u>.75||e.some(l=>l!==t&&l.type==="shape"&&it(l)?.some(f=>qn(f,n)))?null:t.kind==="ellipse"?"oval-cricket":t.kind==="rect"?"pitch-football":null}var as="Estimated from the drawing; confirm with the venue.",go=t=>{if(!t.length)return null;let n=[...t].sort((r,o)=>r-o),e=Math.floor(n.length/2);return n.length%2?n[e]:(n[e-1]+n[e])/2},Kn=t=>({x:t.reduce((n,e)=>n+e.x,0)/t.length,y:t.reduce((n,e)=>n+e.y,0)/t.length}),ln=t=>{let n=0;for(let e=0;e<t.length;e++){let r=t[e],o=t[(e+1)%t.length];n+=r.x*o.y-o.x*r.y}return Math.abs(n)/2};function cs(t){return t.height!==void 0||t.rake!==void 0||t.elevation!==void 0||t.surfaceKind!==void 0}function Zn(t){let n=new Map;for(let e of t){let r=n.get(e.rowId);r?r.push(e):n.set(e.rowId,[e])}return n}function qn(t,n){let e=!1;for(let r=0,o=n.length-1;r<n.length;o=r++){let a=n[r],i=n[o];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 $n(t,n){let e=n[0],r=1/0;for(let o=0;o<n.length;o++){let a=n[o],i=n[(o+1)%n.length],s=i.x-a.x,u=i.y-a.y,c=s*s+u*u,l=c>0?Math.max(0,Math.min(1,((t.x-a.x)*s+(t.y-a.y)*u)/c)):0,f={x:a.x+s*l,y:a.y+u*l},m=Math.hypot(t.x-f.x,t.y-f.y);m<r&&(r=m,e=f)}return e}function Mo(t,n){let e=0,r=0;for(let o of t.values()){if(o.length<3)continue;let a=o[0],i=o[o.length-1],s=i.x-a.x,u=i.y-a.y,c=Math.hypot(s,u);if(c<1e-6)continue;let l={x:(a.x+i.x)/2,y:(a.y+i.y)/2},f=$n(l,n),m=f.x-l.x,p=f.y-l.y,h=Math.hypot(m,p);h<1e-6||(r+=Math.abs((-u*m+s*p)/(c*h))*o.length,e+=o.length)}return e?r/e:0}function ls(t,n,e){let r=t.filter(y=>y.type==="shape"),o=r.find(y=>y.role==="stage");if(o){let y=it(o);return y?{shape:o,centre:Kn(y),outline:y,inferred:!1}:null}if(!e.length)return null;let a=1/0,i=-1/0,s=1/0,u=-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),u=Math.max(u,y.y);let c=(i-a)*(u-s),l=[];for(let y of r){if(y.role)continue;let x=it(y);if(!x)continue;let b=ln(x);if(b*$*$<6||b>c)continue;let d=Math.min(...x.map(R=>R.x)),g=Math.max(...x.map(R=>R.x)),S=Math.min(...x.map(R=>R.y)),_=Math.max(...x.map(R=>R.y)),I=0;for(let R of e)R.x>d&&R.x<g&&R.y>S&&R.y<_&&qn(R,x)&&I++;if(I>e.length*.05)continue;let A=Kn(x),M=Mo(n,x);M>=Yi&&l.push({shape:y,centre:A,outline:x,score:M,area:b,box:[d,S,g,_]})}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=l.filter(y=>!l.some(x=>f(y,x))),p=Math.max(0,...m.map(y=>y.score)),h=m.filter(y=>y.score>=p-.03).sort((y,x)=>x.area-y.area)[0]??null;return h?{shape:h.shape,centre:h.centre,outline:h.outline,inferred:!0}:null}function us(t,n,e){if(!e||e.length<3)return Math.hypot(t.x-n.x,t.y-n.y);let r=$n(t,e);return Math.hypot(t.x-r.x,t.y-r.y)}function Po(t){let n=[...t].sort((a,i)=>a.x-i.x||a.y-i.y);if(n.length<3)return n;let e=(a,i,s)=>(i.x-a.x)*(s.y-a.y)-(i.y-a.y)*(s.x-a.x),r=[];for(let a of n){for(;r.length>=2&&e(r[r.length-2],r[r.length-1],a)<=0;)r.pop();r.push(a)}let o=[];for(let a=n.length-1;a>=0;a--){let i=n[a];for(;o.length>=2&&e(o[o.length-2],o[o.length-1],i)<=0;)o.pop();o.push(i)}return[...r.slice(0,-1),...o.slice(0,-1)]}function fs(t){if(!t.length||t.length>es)return[];let n=[...Zn(t).values()],e=n.map((s,u)=>u),r=s=>e[s]===s?s:e[s]=r(e[s]),o=ns/$,a=n.map(s=>({minX:Math.min(...s.map(u=>u.x))-o,maxX:Math.max(...s.map(u=>u.x))+o,minY:Math.min(...s.map(u=>u.y))-o,maxY:Math.max(...s.map(u=>u.y))+o}));for(let s=0;s<n.length;s++)for(let u=s+1;u<n.length;u++){let c=a[s],l=a[u];if(c.maxX<l.minX||l.maxX<c.minX||c.maxY<l.minY||l.maxY<c.minY)continue;n[s].some(m=>n[u].some(p=>Math.hypot(m.x-p.x,m.y-p.y)<=o))&&(e[r(s)]=r(u))}let i=new Map;return n.forEach((s,u)=>{let c=r(u),l=i.get(c);l?l.push(...s):i.set(c,[...s])}),[...i.values()].filter(s=>new Set(s.map(u=>u.rowId)).size>=2)}function ms(t,n,e){if(!n.length)return null;let r=n.filter(M=>e.tableIds.has(M.rowId)||M.kind==="booth").length>n.length/2,o=Zn(n),a=!e.outline||Mo(o,e.outline)>=zi,i=0,s=0;for(let M of o.values()){if(M.length<2)continue;let R=M[0],w=M[M.length-1],T=w.x-R.x,k=w.y-R.y,D=Math.hypot(T,k);if(D<1e-6)continue;let B={x:(R.x+w.x)/2,y:(R.y+w.y)/2},E=a?e.outline?$n(B,e.outline):e.focal:e.middle,C=-k/D,v=T/D;C*(E.x-B.x)+v*(E.y-B.y)<0&&(C=-C,v=-v),i+=C*M.length,s+=v*M.length}let u={x:n.reduce((M,R)=>M+R.x,0)/n.length,y:n.reduce((M,R)=>M+R.y,0)/n.length};if(Math.hypot(i,s)<1e-9){let M=a?e.focal:e.middle;i=M.x-u.x,s=M.y-u.y}let c=Math.hypot(i,s)||1,l={x:i/c,y:s/c},f=M=>-(M.x*l.x+M.y*l.y),m=M=>-M.x*l.y+M.y*l.x,p=1/0,h=-1/0,y=1/0,x=-1/0,b=1/0,d=new Map;for(let M of n){let R=f(M),w=m(M);p=Math.min(p,R),h=Math.max(h,R),y=Math.min(y,w),x=Math.max(x,w),a&&(b=Math.min(b,us(M,e.focal,e.outline)));let T=M.logicalRowId??M.rowId,k=d.get(T);k?k.push(R):d.set(T,[R])}a||(b=Math.max(0,p-f(e.middle)));let g=[...d.values()].map(M=>go(M)).sort((M,R)=>M-R),S=[];if(!r)for(let M of g)S.length&&M-S[S.length-1]<Ni/$||S.push(M);let _=cs(t),I=Wt(t,{floorBaseHeightM:e.baseHeightM}),A={id:t.id,section:t,authored:_,plane:e,facing:l,facesAction:a,hull:Po(n),sample:n.filter((M,R)=>R%Math.ceil(n.length/qi)===0),frontD:p,backD:h,latMin:y,latMax:x,frontDistance:b,rowDepths:S,rowCount:S.length,level:0,height:I.height,rake:_?I.rake:0,backHeight:0};return A.backHeight=A.height+(h-p)*$*Math.tan(A.rake*Math.PI/180),A}function hs(t,n,e,r){if(t.length<2)return 0;let o=Math.max(1,n*$),a=e+ki-r,i=0,s=0;for(let c=1;c<t.length;c++){let l=Math.max(Gi,(t[c]-t[c-1])*$),f=(a+Fi)*(o+l)/o;i+=f-a,s+=l,a=f,o+=l}let u=Math.atan(i/s)*180/Math.PI;return Math.round(Math.max(xo,Math.min(Li,u))*10)/10}function ys(t,n){if(t.facing.x*n.facing.x+t.facing.y*n.facing.y<Ki)return null;let e=-1/0,r=1/0,o=-1/0;for(let f of n.hull){e=Math.max(e,-(f.x*t.facing.x+f.y*t.facing.y));let m=-f.x*t.facing.y+f.y*t.facing.x;r=Math.min(r,m),o=Math.max(o,m)}if(Math.min(t.latMax,o)-Math.max(t.latMin,r)<bo*(t.latMax-t.latMin))return null;let i=Zi/$,s=new Map,u=new Map;for(let f of t.sample){let m=Math.floor((-f.x*t.facing.y+f.y*t.facing.x)/i),p=-(f.x*t.facing.x+f.y*t.facing.y);s.set(m,Math.min(s.get(m)??1/0,p))}for(let f of n.sample){let m=Math.floor((-f.x*t.facing.y+f.y*t.facing.x)/i),p=-(f.x*t.facing.x+f.y*t.facing.y);u.set(m,Math.max(u.get(m)??-1/0,p))}let c=[];for(let[f,m]of s){let p=u.get(f);p!==void 0&&c.push(m-p)}let l=c.length?go(c):t.frontD-e;return l<-1/$?null:l}function ps(t,n){if(n.plane.floorIndex>=t.plane.floorIndex)return!1;let e=-1/0,r=1/0,o=1/0,a=-1/0;for(let u of n.hull){let c=-(u.x*t.facing.x+u.y*t.facing.y);e=Math.max(e,c),r=Math.min(r,c);let l=-u.x*t.facing.y+u.y*t.facing.x;o=Math.min(o,l),a=Math.max(a,l)}let i=Math.min(t.latMax,a)-Math.max(t.latMin,o),s=Math.min(t.backD,e)-Math.max(t.frontD,r);return i>bo*(t.latMax-t.latMin)&&s>1/$}function ds(t,n){let e=new Set;for(let r of t){let o=(Math.atan2(r.y-n.y,r.x-n.x)*180/Math.PI+360)%360;e.add(Math.floor(o/10))}return e.size/36}function xs(t,n){let e=1/0,r=-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),r=Math.max(r,i)}let o=Math.max(0,Math.min(r-e,t.frontD-e));return n.height+o*$*Math.tan(n.rake*Math.PI/180)}function bs(t,n=!1,e=!1){let r=n?Wi:Ui,o=new Map,a=[...t].sort((c,l)=>c.plane.floorIndex-l.plane.floorIndex||c.frontDistance-l.frontDistance),i=[],s=new Map,u=c=>{if(c.plane.floorIndex===0||c.plane.baseHeightM>0)return c.plane.baseHeightM;let l=s.get(c.plane.floorIndex-1);return l===void 0?c.plane.baseHeightM:l+Ce};for(let c of a){if(!c.authored){let f=u(c),m;for(let y of i){if(y.plane.floorIndex>c.plane.floorIndex)continue;if(ps(c,y)){let g=xs(c,y)+$i;g>f&&(f=g,m=y);continue}let x=ys(c,y);if(x==null)continue;let d=e&&!!c.plane.stageDeck&&y.level===0&&y.plane.floorIndex===c.plane.floorIndex&&Math.max(0,x)*$<=Ji?y.backHeight:y.backHeight+vi+Math.min(Di,Math.max(0,x)*$)*Math.tan(y.rake*Math.PI/180);d>f&&(f=d,m=y)}c.height=Math.round(Math.min(f,c.plane.baseHeightM+ji)*100)/100;let p=!m&&c.height>c.plane.baseHeightM;if(c.level=m?m.level+1:p?1:0,c.rake=hs(c.rowDepths,c.frontDistance,c.height,c.plane.focalHeightM),!c.facesAction&&c.rowCount<Vi)c.rake=0;else if(!m&&!p){let y=Math.max(1e-6,(c.backD-c.frontD)*$);c.rake=Math.min(c.rake,Hi,Math.round(Math.atan(Xi/y)*1800/Math.PI)/10)}else c.rowCount>=2&&(c.rake=Math.max(c.rake,r[Math.min(c.level,r.length)-1]));let h=(c.backD-c.frontD)*$;if(n&&h>0&&c.height+h*Math.tan(c.rake*Math.PI/180)>c.plane.baseHeightM+ho){let y=Math.max(0,c.plane.baseHeightM+ho-c.height);c.rake=Math.max(xo,Math.round(Math.atan(y/h)*1800/Math.PI)/10)}e&&c.plane.stageDeck&&c.level>0&&(c.rake=Math.min(c.rake,ts)),c.backHeight=c.height+h*Math.tan(c.rake*Math.PI/180),o.set(c.id,m?.id)}let l=c.plane.floorIndex;s.set(l,Math.min(s.get(l)??1/0,c.height)),i.push(c)}return o}var Vn=(t,n)=>!!t&&t.x===n.x&&t.y===n.y;function So(t,n={x:0,y:-40}){let e=gn(t),r=new Map;for(let x of e){if(!x.sectionId)continue;let b=r.get(x.sectionId);b?b.push(x):r.set(x.sectionId,[x])}let o={focalInferred:!1,confident:!1,sections:[]},a=t.floors?.length?t.floors.map((x,b)=>({objects:x.objects,floorIndex:b,floorId:x.id,baseHeightM:x.baseHeightM??0,focal:x.focalPoint??t.focalPoint})):[{objects:t.objects,floorIndex:0,floorId:void 0,baseHeightM:0,focal:t.focalPoint}],i=new Set(a.flatMap(x=>x.objects.filter(b=>b.type==="table").map(b=>b.id))),s=[],u,c=new Set,l=a.map(x=>{let b=k=>!t.floors?.length||k.floorId===x.floorId,d=fs(e.filter(k=>!k.sectionId&&k.kind!=="booth"&&!i.has(k.rowId)&&b(k))),g=[];for(let k of d){let D=Rt(Et(Po(k)),os/$);if(e.some(E=>!b(E)&&qn(E,D)))continue;let B=`${yo}${x.floorIndex}-${g.length}`;c.add(B),r.set(B,k),g.push({type:"section",id:B,label:"",color:rs,outline:D})}let S=g.length?{...x,objects:[...x.objects,...g]}:x,_=new Set(S.objects.filter(k=>k.type==="section").map(k=>k.logicalSectionId??k.id)),I=[...r.entries()].filter(([k])=>_.has(k)).flatMap(([,k])=>k),A=ls(S.objects,Zn(I),I),M=S.focal;(A||S.focal&&!Vn(S.focal,n))&&(o.confident=!0),A&&(o.stage??={id:A.shape.id,inferred:A.inferred,...S.floorId?{floorId:S.floorId}:{}},(A.inferred||Vn(S.focal,n))&&(M=A.centre,o.focalInferred=!0));let R=A&&(!A.inferred||ln(A.outline)*$*$<=zn),w=A?void 0:u,T={tableIds:i,floorIndex:S.floorIndex,floorId:S.floorId,baseHeightM:S.baseHeightM,focal:w?.focal??M,outline:A?.outline??w?.outline,focalHeightM:w?.focalHeightM??S.baseHeightM+(A&&R?It({...A.shape,role:"stage"}).heightM:0),stageDeck:w?.stageDeck??!!(A&&R&&ln(A.outline)*$*$<=zn),middle:I.length?{x:I.reduce((k,D)=>k+D.x,0)/I.length,y:I.reduce((k,D)=>k+D.y,0)/I.length}:M};for(let k of S.objects){if(k.type!=="section")continue;let D=ms(k,r.get(k.logicalSectionId??k.id)??[],T);D&&s.push(D)}return T.outline&&(u=T),Vn(S.focal,T.focal)||(o.focal??=[]).push({...S.floorId?{floorId:S.floorId}:{},point:{...T.focal}}),{unit:S,plane:T,stage:A,planeSeats:I}}),f=a.flatMap(x=>x.objects).map(x=>x.type==="shape"&&!x.role&&(Yn(x.label)==="wall"||!Yn(x.label)&&mo(x))?{...x,role:"wall"}:x),m=Kt({objects:f},e)!==null;m&&(o.indoor=!0);let p=bs(s,m,ds(e,l[0]?.plane.focal??n)<Qi),h=new Map(s.filter(x=>!x.authored).map(x=>[x.id,x])),y=l.map(({unit:x,plane:b,stage:d,planeSeats:g})=>x.objects.map(S=>{let _=S.type==="shape"&&!S.role&&S.id!==d?.shape.id?Yn(S.label):null;if(S.type==="shape"&&!S.role&&S.id!==d?.shape.id&&(_==="wall"||!_&&mo(S))&&S.type==="shape"){(o.roles??=[]).push({id:S.id,...b.floorId?{floorId:b.floorId}:{},role:"wall"});let{fill:T,...k}=S;return{...k,role:"wall"}}if(_&&S.type==="shape")return(o.roles??=[]).push({id:S.id,...b.floorId?{floorId:b.floorId}:{},role:_}),{...S,role:_};let A=d?.inferred&&S.id===d.shape.id&&S.type==="shape"?ss(S,d.outline,x.objects,g):null;if(A&&S.type==="shape")return o.stage?.id===S.id&&(o.stage.field=A),{...S,role:"stage",stageKind:A};if(d?.inferred&&S.id===d.shape.id&&S.type==="shape"&&ln(d.outline)*$*$<=zn)return o.stage?.id===S.id&&(o.stage.deck=!0),{...S,role:"stage"};let M=S.type==="section"?h.get(S.id):void 0;if(!M||S.type!=="section")return S;let R=M.rowCount>=2&&M.rake>0;c.has(M.id)?o.looseRowBlocks=(o.looseRowBlocks??0)+1:o.sections.push({id:M.id,floorId:b.floorId,surfaceKind:R?"rakedRows":"flat",height:M.height,rake:M.rake,stackedOn:p.get(M.id)});let w={status:"inferred",source:"public-2d-topology",note:as};return{...S,height:M.height,rake:M.rake,surfaceKind:R?"rakedRows":"flat",physical3dProvenance:{height:w,rake:w,surfaceKind:w}}}));if(t.floors?.length){let x=t.floors.map((b,d)=>({...b,objects:y[d],focalPoint:l[d].plane.focal}));return{doc:{...t,floors:x,objects:x[0].objects,focalPoint:x[0].focalPoint},report:o}}return{doc:{...t,objects:y[0],focalPoint:l[0].plane.focal},report:o}}function Il(t,n,e){return e<0?n>1?t.filter(r=>r.kind==="floor"):[...t]:t.filter(r=>r.floorIndex===void 0||r.floorIndex===e)}function Al(t,n){let e=[...t].sort((o,a)=>o.screen.y-a.screen.y),r=[];for(let o of e){let a=r.find(i=>i.some(s=>Math.abs(s.screen.x-o.screen.x)<104&&Math.abs(s.screen.y-o.screen.y)<34));a?a.push(o):r.push([o])}return r.flatMap(o=>o.length<2?o:o.map((a,i)=>({...a,screen:{...a.screen,x:Math.max(54,Math.min(n-54,a.screen.x+(i-(o.length-1)/2)*104))}})))}var gs=1.15,Ms=2.75,Ps=4.5,Ss=.85,Rs=.5,Is=.26;function _l(t,n,e){let r=Math.max(1e-6,n),o=t/r,a=e?.hasZoneLabels??!0,i=new Set(["stage"]);return o>=.75&&i.add("floor"),o>=gs&&i.add("zone"),o<=(a?Ms:Ps)&&(i.add("section"),i.add("ga")),o<=Ss&&(i.add("annotation"),i.add("booth")),o<=Rs&&i.add("row"),o<=Is&&i.add("seat"),i}function wl(t,n,e,r,o,a=6){let i=a+n,s=r-a-n,u=a+e,c=o-a-e;return{...t,x:i>s?r/2:Math.max(i,Math.min(s,t.x)),y:u>c?o/2:Math.max(u,Math.min(c,t.y))}}function El(t,n,e,r){let o=t,a=n[0],i=n[1],s=n[2],u=o[0]*a+o[4]*i+o[8]*s+o[12],c=o[1]*a+o[5]*i+o[9]*s+o[13],l=o[2]*a+o[6]*i+o[10]*s+o[14],f=o[3]*a+o[7]*i+o[11]*s+o[15];if(!(f>1e-6))return{x:0,y:0,depth:1/0,visible:!1};let m=u/f,p=c/f,h=l/f,y=m>=-1.05&&m<=1.05&&p>=-1.05&&p<=1.05&&h<=1;return{x:(m*.5+.5)*e,y:(1-(p*.5+.5))*r,depth:h,visible:y}}function Bl(t,n,e=n){let r=[],o=[...t].sort((a,i)=>a.screen.depth-i.screen.depth);for(let a of o){let i=!1;for(let s of r)if(Qn(a,s,n,e)){i=!0;break}i||r.push(a)}return r}var As=6;function Qn(t,n,e,r){let o=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+As):e;return o<i&&a<r}function Tl(t,n,e){return t.length*n*.58+(e?14:0)}var _s={row:8,seat:14};function Ol(t){return t<480?{row:5,seat:8}:t<768?{row:6,seat:10}:_s}function Cl(t,n,e,r){let o=Math.max(1,Math.min(e,r)*.5),a=Math.min(2,Math.hypot(t.x-e/2,t.y-r/2)/o);return n*(1+1.5*a)}function kl(t,n,e,r,o=[]){let a=[...t].sort((s,u)=>(u.priority??0)-(s.priority??0)||s.focus-u.focus),i=[];for(let s of a){if(i.length>=r)break;let u=!1;for(let c of o)if(Qn(s,c,n,e)){u=!0;break}if(!u){for(let c of i)if(Qn(s,c,n,e)){u=!0;break}}u||i.push(s)}return i}function Fl(t,n,e,r){let o=t[3]*n[0]+t[7]*n[1]+t[11]*n[2]+t[15];return o<=0||!(e>0)?0:e*Math.hypot(t[0],t[4],t[8])*r/(2*o)}function Zt(t,n,e){if(t.length!==4||e<=n)return null;let r=xt(t),o=Math.hypot(r[1].x-r[0].x,r[1].y-r[0].y)*P,a=Math.hypot(r[3].x-r[0].x,r[3].y-r[0].y)*P;if(o<1e-6||a<1e-6)return null;let i=Math.min(.22/o,.16),s=Math.min(.28,(e-n)*.13),u=Math.min(.065/a,.2);return{quad:r,side:i,face:u,opening:yt(r,i,1-i),openingTop:e-s}}function Jn(t,n,e){if(t.length!==4||e-n<=.2)return null;let r=xt(t),o=Math.hypot(r[1].x-r[0].x,r[1].y-r[0].y)*P;if(o<=1e-6)return null;let a=Math.min(.14,(e-n)*.08,o*.08),i=a/o,s=yt(r,i,1-i);return{quad:r,side:i,trim:a,inner:s,panel:an(s,.15,.85),bottom:n+a,top:e-a}}function Ro(t,n,e,r){let o=Jn(t,n,e);if(!o)return;let{panel:a}=o,i=(d,g)=>({x:(d.x+g.x)/2,y:(d.y+g.y)/2}),s=i(a[0],a[1]),u=i(a[3],a[2]),c=Math.hypot(s.x-r.x,s.y-r.y)<=Math.hypot(u.x-r.x,u.y-r.y),[l,f]=c?[a[0],a[1]]:[a[3],a[2]],m=c?{x:s.x-u.x,y:s.y-u.y}:{x:u.x-s.x,y:u.y-s.y},p=Math.hypot(m.x,m.y);if(p<1e-6)return;-(f.y-l.y)*m.x+(f.x-l.x)*m.y<0&&([l,f]=[f,l]);let h=Math.min(.006,p*P*.05),y=m.x/p*h,x=m.y/p*h,b=(d,g)=>[d.x*P+y,g,d.y*P+x];return[b(l,o.bottom),b(f,o.bottom),b(l,o.top),b(f,o.top)]}import ws from"polygon-clipping";function Ot(t,n,e,r,o,a,i,s={}){let u=Tt(n),c=s.ao??Y,l=o.flatMap(y=>{if(y.role!=="entrance"&&y.role!=="exit")return[];let x=it(y);if(!x||x.length!==4||!zt(u,Tt(x)))return[];let b=s.portalBase??e,d=Zt(x,b,b+It(y).heightM);if(!d)return[];let g=Math.min(r,d.openingTop);return g<=e?[]:[{poly:d.opening,height:g}]});if(!l.length)return!1;let f=y=>y.map(x=>[x.x,x.y]),m=[f(n),...(s.holes??[]).map(f)],p=[e,...new Set(l.map(y=>y.height)),r].sort((y,x)=>y-x),h=[];try{for(let y=1;y<p.length;y++){let x=p[y-1],b=p[y];if(b-x<1e-6)continue;let d=l.filter(S=>S.height>x+1e-6).map(S=>[f(S.poly)]),g=d.length?ws.difference(m,...d):[m];h.push({low:x,high:b,polys:g})}}catch{return!1}for(let y of h)for(let x of y.polys){let[b,...d]=x.map(S=>S.map(([_,I])=>({x:_,y:I}))),g=S=>c.wallBottom+(c.top-c.wallBottom)*(S-e)/(r-e);K(t,b,d,()=>y.high,y.low,a,i,{...c,top:g(y.high),wallBottom:g(y.low)})}return!0}function Io(t,n,e,r,o,a,i){let s=r-e;if(s<=0)return;let u=s<1.5?[[e,r,1]]:[[e,e+Math.min(.9,s*.18),.82],[e+Math.min(.9,s*.18),r-.1,1],[r-.1,r,1.1]],c=l=>Y.wallBottom+(Y.top-Y.wallBottom)*(l-e)/s;for(let[l,f,m]of u){let p={...Y,top:c(f),wallBottom:c(l)},h=Z(a,m),y=Z(i,m);Ot(t,n,l,f,o,h,y,{portalBase:e,ao:p})||K(t,n,void 0,()=>f,l,h,y,p)}}function un(t,n,e){let r=ot(n.stroke?.color),o=n.stroke?.width??0;if(!r||!Number.isFinite(o)||o<=0)return;let a=n.kind==="line"||n.kind==="polyline",i=a?wn(n.points??[],n.rotation):it(n);if(!i||i.length<2)return;let s=a?i.length-1:i.length,u=o*.5;for(let c=0;c<s;c++){let l=i[c],f=i[(c+1)%i.length],m=Math.hypot(f.x-l.x,f.y-l.y);if(m<1e-6)continue;let p=-(f.y-l.y)/m*u,h=(f.x-l.x)/m*u,y=[(l.x+p)*P,e,(l.y+h)*P],x=[(f.x+p)*P,e,(f.y+h)*P],b=[(f.x-p)*P,e,(f.y-h)*P],d=[(l.x-p)*P,e,(l.y-h)*P];t.tri(y,x,b,[0,1,0],r),t.tri(y,b,d,[0,1,0],r)}}function Ao(t){return t==="bar"||t==="concession"||t==="coat"||t==="restroom"}var qt=(t,n,e)=>({x:t.x+(n.x-t.x)*e,y:t.y+(n.y-t.y)*e});function En(t,n,e,r){let[o,a,i,s]=n?t:[t[3],t[2],t[1],t[0]];return[qt(o,s,e),qt(a,i,e),qt(a,i,r),qt(o,s,r)]}function _o(t,n,e,r,o,a,i,s,u=!1){if(e.length!==4||o-r<.4)return!1;let c=M=>u?Math.min(M,o):M,l=xt(e),f=Math.hypot(l[3].x-l[0].x,l[3].y-l[0].y)*P;if(f<.4)return!1;let m=qt(l[0],l[1],.5),p=qt(l[3],l[2],.5),h=Math.hypot(m.x-s.x,m.y-s.y)<=Math.hypot(p.x-s.x,p.y-s.y),y=et(i,[.92,.9,.86],.35),x=Z(a,.72),b=o-r;if(n==="restroom"){let M=Math.min(.18,b*.08);return J(t,l,o-M,r,i,a),J(t,l,o,o-M,y,y),!0}let d=r+Math.min(1.1,b),g=n==="coat"?1:Math.min(.5,.75/f),S=En(l,h,0,g);if(J(t,S,d-.05,r,x,a),J(t,S,d,d-.05,y,y),n==="coat"||f<1.2)return!0;if(n==="bar"){let M=En(l,h,Math.max(g+.2,1-.45/f),1),R=c(r+Math.max(Math.min(2.2,b*2),d-r+.6));return J(t,M,R,r,i,x),!0}let _=En(l,h,Math.max(g+.25,.55),1),I=c(r+Math.max(2.6,d-r+1.4));if(I-.14<=d)return!0;J(t,_,I-.14,r,i,a),J(t,l,I,I-.14,y,x);let A=Math.min(.08,.1/Math.max(.1,Math.hypot(l[1].x-l[0].x,l[1].y-l[0].y)*P));for(let[M,R]of[[0,A],[1-A,1]])J(t,En(yt(l,M,R),h,0,Math.min(.08,.1/f)),I-.14,d,x,x);return!0}var Dt=.06,Es=.05,Eo=.05,wo=.15,te=25;function Bo(t,n,e){let r=new Map,o=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),u=new Map,c=[],l=new Set;for(let m=0;m<t.length;m+=1){let p=t[m];for(let h of p.objects){if(h.type==="table"&&l.add(h.id),h.type!=="section"||!h.outline||h.outline.length<3)continue;let y=Rt(h.outline,Pt);u.set(h.id,{section:h,unit:p,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),c.push({id:h.id,floorIndex:m,box:Tt(y),section:h,unit:p,outline:y})}}let f=new Map;for(let m of c){let p=f.get(m.floorIndex);p?p.push(m):f.set(m.floorIndex,[m])}for(let m=0;m<n.length;m++){let p=n[m],h=e?f.get(e[m])??[]:c,y=p.sectionId?h.find(b=>b.id===p.sectionId)??h.find(b=>b.section.logicalSectionId===p.sectionId&&wt({x:p.x,y:p.y},b.outline,b.section.holes)):void 0,x=y?[y]:h;for(let b of x){if(e&&b.floorIndex!==e[m]||!y&&(p.x<b.box.minX||p.x>b.box.maxX||p.y<b.box.minY||p.y>b.box.maxY||!wt({x:p.x,y:p.y},b.outline,b.section.holes)))continue;o[m]=b.id;let d=u.get(b.id);d.hasSeats=!0;let g=p.focalPoint??b.unit.focal,S=Math.hypot(p.x-g.x,p.y-g.y);S<d.frontU&&(d.frontU=S),d.seatIndices.push(m);let _=p.rowId||`__seat-${m}`,I=d.rows.get(_);I?I.push({x:p.x,y:p.y}):d.rows.set(_,[{x:p.x,y:p.y}]);break}}for(let[m,p]of u){let h=Wt(p.section,{floorBaseHeightM:p.unit.baseHeightM}),y=p.unit.baseHeightM,x=h.rake>0?Math.tan(h.rake*Math.PI/180):0,b=h.rake<=.01&&h.height<=y+.001,d=p.section.surfaceKind,g=d==="flat"?!0:d==="rakedRows"&&h.rake>.01?!1:b,S=p.hasSeats?be(m,n,p.seatIndices,p.unit.focal):{sectionId:m,rows:[],blockCount:0},I=S.rows.length<2?Be([...p.rows.values()].map(O=>({points:O})),p.unit.focal):null,A=1/0;if(I){if(p.hasSeats)for(let O of p.rows.values())for(let F of O){let L=I.depthAt(F.x,F.y);L<A&&(A=L)}if(!p.hasSeats||!Number.isFinite(A)){A=1/0;for(let O of p.section.outline){let F=I.depthAt(O.x,O.y);F<A&&(A=F)}}}let M=y+Es,R=Math.max(M,h.height),w=O=>{let F=Math.max(0,O-A)*$,L=Math.min(F*x,te);return Math.max(M,h.height+L)},T=O=>{let F=Math.max(0,O)*$,L=Math.min(F*x,te);return Math.max(M,h.height+L)},k=g?[]:S.rows.map(O=>({pts:O.pts,y:T(O.blockDepth),depth:O.blockDepth,blockId:O.blockId,...l.has(O.id)?{patch:Ze(O.pts,Pt)}:{}})),D=k.length?k[0].y:R,B=k.map(O=>{let F=O.patch&&O.patch.length>=3?O.patch:O.pts,L=0,H=0;for(let X of F)L+=X.x,H+=X.y;let j=F.length||1;L/=j,H/=j;let U=0;for(let X of F){let W=Math.hypot(X.x-L,X.y-H);W>U&&(U=W)}return{cx:L,cy:H,rad:U}}),E=g?()=>R:k.length>=2?(O,F)=>{let L=1/0,H=D;for(let j=0;j<k.length;j++){let U=B[j];if(Math.hypot(O-U.cx,F-U.cy)-U.rad>=L)continue;let X=k[j].patch,W=X&&X.length>=3?dt(X,O,F)?0:xn(X,O,F):xn(k[j].pts,O,F);W<L&&(L=W,H=k[j].y)}return H}:(O,F)=>I?w(I.depthAt(O,F)):R,C=[0,1,0],v=k.length>=2||g?()=>C:(O,F)=>{if(!I)return C;let L=I.depthAt(O,F);if(L<=A)return C;let H=(L-A)*$;if(H*x>=te||h.height+H*x<=M)return C;let[j,U]=I.gradientAt(O,F);if(j===0&&U===0)return C;let X=1/Math.hypot(x,1);return[-j*x*X,X,-U*x*X]};if(!g)for(let O of S.rows){let F=T(O.blockDepth);for(let L of O.seatIndices)i[L]=F}for(let O of S.rows){let F=[];for(let X=1;X<O.pts.length;X++){let W=Math.hypot(O.pts[X].x-O.pts[X-1].x,O.pts[X].y-O.pts[X-1].y);W>1e-6&&F.push(W)}F.sort((X,W)=>X-W);let L=F.length?F[Math.floor(F.length/2)]:1/0,H=1/0,j=O.pts[Math.floor(O.pts.length/2)];if(j)for(let X of S.rows){if(X===O||X.blockId!==O.blockId)continue;let W=xn(X.pts,j.x,j.y);W>1e-6&&W<H&&(H=W)}let U=Math.min(L,Math.max(H,L*.5));if(Number.isFinite(U)&&U>0)for(let X of O.seatIndices)s[X]=U}r.set(m,{sectionId:m,deckAt:E,normalAt:v,flat:g,bottomY:y,rowLevels:k,landingY:D})}for(let m=0;m<n.length;m++){let p=o[m],h=n[m];if(p){let b=i[m];a[m]=(b??r.get(p).deckAt(h.x,h.y))+wo;continue}let y=h.eyeHeightM,x=Number.isFinite(y)?Math.max(0,y-dn):0;a[m]=h.kind==="booth"?x+Dt+wo:x}return{bySection:r,seatOwner:o,seatDeckY:m=>a[m],seatPitchU:m=>s[m]}}var Bs=[.12,.38,.16],Ts=[.72,.62,.45],Os=[.88,.93,.96],To=[.95,.95,.94],Cs=[.66,.29,.22],ne={length:20.12,width:3.05},ks=.14,Fs=9.76,Ct=[.93,.94,.95],Bn=[.1,.11,.13],Ls=[.45,.85,1.25],vs=1.45,Oo=.012,Co=.004,Ds=1.07,Ns=.15;function Qt(t,n,e,r,o,a){t.setMaterial(a),K(t,n,e?[e.slice().reverse()]:void 0,()=>r,r-.004,o,o,Y)}var ko=(t,n)=>Lt(t,n/P);function Fo(t,n,e){let r=n.x-t.x,o=n.y-t.y,a=Math.hypot(r,o);if(a<1e-9)return null;let i=-o/a*e,s=r/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 Gs(t,n,e,r){let o=n.map(a=>[a.x*P,e,a.y*P]);t.tri(o[0],o[1],o[2],[0,1,0],r),t.tri(o[0],o[2],o[3],[0,1,0],r)}function Tn(t,n,e,r,o,a){let i=e/P,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}];K(t,s,void 0,()=>o,r,a,Z(a,.85),Y)}function $t(t,n,e,r,o,a,i){let s=Fo(n,e,r/P);s&&K(t,s,void 0,()=>a,o,i,Z(i,.85),Y)}function On(t){let n=xt(t),e={x:(n[0].x+n[2].x)/2,y:(n[0].y+n[2].y)/2},r=Math.hypot(n[1].x-n[0].x,n[1].y-n[0].y)||1,o=Math.hypot(n[3].x-n[0].x,n[3].y-n[0].y)||1,a={x:(n[1].x-n[0].x)/r,y:(n[1].y-n[0].y)/r},i={x:(n[3].x-n[0].x)/o,y:(n[3].y-n[0].y)/o};return{at:(u,c)=>({x:e.x+(a.x*u+i.x*c)/P,y:e.y+(a.y*u+i.y*c)/P}),lengthM:r*P,widthM:o*P}}function Lo(t,n,e){let r=Pe(n);if(!r.length)return;let o=1/0,a=-1/0,i=1/0,s=-1/0;for(let g of n.points??[])o=Math.min(o,g.x),a=Math.max(a,g.x),i=Math.min(i,g.y),s=Math.max(s,g.y);let u=(n.rotation??0)*Math.PI/180,c=Math.cos(u),l=Math.sin(u),f=(o+a)/2,m=(i+s)/2,p=g=>u?{x:f+(g.x-f)*c-(g.y-m)*l,y:m+(g.x-f)*l+(g.y-m)*c}:g,h=Math.min(a-o,s-i)*P,y=Math.max(.04,Math.min(.3,h*.004))/P,x=0;t.setMaterial(0);for(let g of r){if(!g.fill)continue;let S=g.points.map(p);Qt(t,S,null,e+Oo+x*Co,ot(g.fill)??Ct,0),x++}let b=r.filter(g=>!(g.fill&&g.ink===g.fill)),d=[...new Set(b.map(g=>g.ink??Nn))];for(let g of d){let S=e+Oo+x++*Co,_=ot(g)??Ct;for(let I of b){if((I.ink??Nn)!==g)continue;let A=I.points.map(p),M=I.closed?A.length:A.length-1;for(let R=0;R<M;R++){let w=Fo(A[R],A[(R+1)%A.length],y);w&&Gs(t,w,S,_)}}}}function vo(t,n,e,r,o){if(n.length<3)return!1;let a=r+.006,i=o??Bs;if(e==="oval-cricket"){let s=n.reduce((_,I)=>_+I.x,0)/n.length,u=n.reduce((_,I)=>_+I.y,0)/n.length,c=_=>n.map(I=>({x:s+(I.x-s)*_,y:u+(I.y-u)*_})),l=8;for(let _=0;_<l;_++){let I=c(1-_/l),A=_===l-1?null:c(1-(_+1)/l);Qt(t,I,A,a,Z(i,_%2?1.04:.96),4)}let f=n[0];for(let _ of n)Math.hypot(_.x-s,_.y-u)>Math.hypot(f.x-s,f.y-u)&&(f=_);let m=Math.hypot(f.x-s,f.y-u)||1,p=(f.x-s)/m,h=(f.y-u)/m,y=-h,x=p,b=Math.min(1,2*m*P*ks/ne.length),d=ne.length*b/2/P,g=ne.width*b/2/P,S=[[-d,-g],[d,-g],[d,g],[-d,g]].map(([_,I])=>({x:s+p*_+y*I,y:u+h*_+x*I}));return Qt(t,S,null,a+.004,Ts,0),t.setMaterial(0),!0}if(e==="rink-hockey"){let s=ko(n,Ns);return Qt(t,s,null,a,Os,0),t.setMaterial(0),K(t,n,[s.slice().reverse()],()=>r+Ds,r,To,Z(To,.9),Y),!0}if(e==="ring-boxing"&&n.length===4){let{at:s}=On(n),u=[s(-3.05,-3.05),s(3.05,-3.05),s(3.05,3.05),s(-3.05,3.05)],c=[[.77,.19,.19],Ct,[.17,.42,.69],Ct];t.setMaterial(0),u.forEach((l,f)=>Tn(t,l,.07,r,r+vs,c[f]));for(let l of Ls)for(let f=0;f<4;f++)$t(t,u[f],u[(f+1)%4],.025,r+l-.025,r+l+.025,Ct);return!0}if(e==="court-tennis"&&n.length===4){let{at:s}=On(n);t.setMaterial(0),$t(t,s(0,-6.4),s(0,6.4),.015,r,r+.95,Bn),$t(t,s(0,-6.4),s(0,6.4),.03,r+.95,r+1,Ct);for(let u of[-1,1])Tn(t,s(0,u*6.4),.05,r,r+1.07,Bn);return!0}if(e==="court-basketball"&&n.length===4){let{at:s,lengthM:u}=On(n),c=Math.min(14,u/2-.5);t.setMaterial(0);for(let l of[-1,1]){let f=s(l*(c+1.2),0),m=s(l*(c-1.2),0);Tn(t,f,.12,r,r+3.4,Bn),$t(t,f,m,.06,r+3.25,r+3.4,Bn),$t(t,s(l*(c-1.2),-.9),s(l*(c-1.2),.9),.03,r+2.9,r+3.95,Ct)}return!0}if(e==="pitch-rugby"&&n.length===4){let{at:s,lengthM:u}=On(n),c=u*(50/120);t.setMaterial(0);for(let l of[-1,1]){for(let f of[-2.8,2.8])Tn(t,s(l*c,f),.07,r,r+12,Ct);$t(t,s(l*c,-2.8),s(l*c,2.8),.06,r+2.94,r+3.06,Ct)}return!0}if(e==="track-athletics"){let s=ko(n,Fs);return s.length<3?!1:(Qt(t,n,s,a,Cs,0),Qt(t,s,null,a,i,4),t.setMaterial(0),!0)}return!1}var Do=[.19,.4,.15],Hs=.012,Fn=2.4,Xs=1,js=.75,Us=.15;function At(t){if(t.points&&t.points.length>=3)return t.points;let{center:n,width:e,height:r,rotation:o}=t;if(!e||!r)return null;let a=(o??0)*Math.PI/180,i=Math.cos(a),s=Math.sin(a),u=e/2,c=r/2;return[[-u,-c],[u,-c],[u,c],[-u,c]].map(([l,f])=>({x:n.x+l*i-f*s,y:n.y+l*s+f*i}))}function Uo(t,n,e,r,o,a,i=!1){let s=At(n);if(s){if(i){let u=Xt(r,o.boothTop),c=Et([...s]);K(t,Rt(c,Ws/P),[c.slice().reverse()],()=>e+.03,e,u,Z(u,.8),Y);return}if(!(!n.points&&a&&zs(t,s,e,r,a))){if(!n.points&&a&&s.length===4){Ys(t,s,e,r,a);return}K(t,s,void 0,()=>e+Fn,e,Xt(r,o.boothTop),o.boothWall,Y)}}}var ee=1.1,No=[.9,.9,.88],Ws=.1,Cn=[.87,.87,.85],Go=.08;function Wo(t,n){let e=u=>({x:(t[u].x+t[(u+1)%4].x)/2,y:(t[u].y+t[(u+1)%4].y)/2}),r=0,o=1/0;for(let u=0;u<4;u++){let c=e(u),l=Math.hypot(c.x-n.x,c.y-n.y);l<o&&(o=l,r=u)}let a=[0,1,2,3].map(u=>t[(r+u)%4]),i=(u,c,l)=>({x:u.x+(c.x-u.x)*l,y:u.y+(c.y-u.y)*l});return{q:a,part:(u,c,l,f)=>{let m=i(a[0],a[1],u),p=i(a[0],a[1],c),h=i(a[3],a[2],u),y=i(a[3],a[2],c);return[i(m,h,l),i(p,y,l),i(p,y,f),i(m,h,f)]},depthM:Math.hypot(a[3].x-a[0].x,a[3].y-a[0].y)*P,widthM:Math.hypot(a[1].x-a[0].x,a[1].y-a[0].y)*P}}function Ys(t,n,e,r,o){let{q:a,part:i}=Wo(n,o),s=r??[.35,.42,.55],u=et(s,[.78,.78,.77],.62),c=et(s,[.95,.95,.94],.45);J(t,a,e+Dt,e,u,Z(u,.8)),J(t,i(.05,.95,.72,.98),e+ee-.05,e+Dt,c,Z(c,.8)),J(t,i(.03,.97,.7,1),e+ee,e+ee-.05,No,Z(No,.9))}function zs(t,n,e,r,o){if(n.length!==4)return!1;let{q:a,part:i,depthM:s,widthM:u}=Wo(n,o);if(s<1||u<1)return!1;let c=r??[.35,.42,.55],l=et(c,[.78,.78,.77],.62),f=e+Fn,m=Go/u,p=Go/s;J(t,a,e+Dt,e,l,Z(l,.8)),J(t,i(0,1,1-p,1),f,e+Dt,Cn,Z(Cn,.9));for(let[x,b]of[[0,m],[1-m,1]])J(t,i(x,b,0,1-p),f,e+Dt,Cn,Z(Cn,.9));J(t,i(m,1-m,0,Math.min(.5,.06/s)),f,f-.3,c,Z(c,.85));let h=Math.min(.4,.6/u),y=Math.min(.12,.3/s);return J(t,i(.5-h,.5+h,.72-y,.72+y),e+Xs,e+Dt,et(c,[.95,.95,.94],.7),Z(c,.75)),!0}function Ln(t){if(t.shape==="round"){let l=t.radius;return l?Rn(t.center.x,t.center.y,l,l,24):null}let{width:n,height:e,rotation:r,center:o}=t;if(!n||!e)return null;let a=(r??0)*Math.PI/180,i=Math.cos(a),s=Math.sin(a),u=n/2,c=e/2;return[[-u,-c],[u,-c],[u,c],[-u,c]].map(([l,f])=>({x:o.x+l*i-f*s,y:o.y+l*s+f*i}))}function Yo(t,n,e,r,o,a=!0){let i=Ln(n);if(!i)return;let s=i.reduce((m,p)=>m+p.x,0)/i.length,u=i.reduce((m,p)=>m+p.y,0)/i.length,c=m=>i.map(p=>({x:s+(p.x-s)*m,y:u+(p.y-u)*m})),l=a&&r?Xt(r,o.tableTop):Vs,f=e+js;K(t,i,void 0,()=>f,e+Ks,l,Z(l,.86),Y),K(t,c(.12),void 0,()=>f+.12,f,Ho,Z(Ho,.8),Y)}var Vs=[.93,.92,.89],Ho=[.78,.66,.42],Ks=.25;function zo(t,n,e,r,o,a,i,s,u=[]){let c=it(n);if(!n.role&&(!n.fill||n.fill==="none"||n.fill==="transparent")||!c){un(t,n,e+r+Hs);return}let f=s?s.kind==="stage":n.role==="stage",m=s?s.kind==="screen":n.role==="screen",p=s?{kind:f?"stage":"solid",heightM:s.topY-s.baseY}:It(n),h=s?.baseY??e,y=s?.topY??e+r;if(f&&i){let M=1/0,R=-1/0,w=1/0,T=-1/0;for(let k of c)k.x<M&&(M=k.x),k.x>R&&(R=k.x),k.y<w&&(w=k.y),k.y>T&&(T=k.y);i.push({cx:(M+R)/2*P,cz:(w+T)/2*P,y,halfX:Math.max((R-M)/2*P,.5),halfZ:Math.max((T-w)/2*P,.5)})}let x=ot(n.fill),b=n.role==="wall"||n.role==="entrance"||n.role==="exit",d=b?x?Z(St(x,.12),.95):o.tierTop:f&&x?et(o.stageTop,Z(St(x,.18),.9),.9):!n.role&&x?x:Xt(x,f?o.stageTop:o.decorTop),g=m?x:null,S=b?x?Z(St(x,.12),.85):o.tierWall:f?x?et(o.stageWall,Z(x,.58),.82):o.stageWall:m?g?et(Z(g,1.42),[.24,.46,.82],.08):[.24,.46,.82]:Xt(ot(n.fill),o.decorWall);if(n.role==="wall"&&!s){Io(t,c,h,y,u,d,S),un(t,n,y+.012);return}if(m&&c.length===4&&y-h>.2){let M=Jn(c,h,y);if(!M)return;let{quad:R,side:w,trim:T,inner:k,panel:D}=M,B=[.12,.15,.18];for(let[E,C]of[[0,w],[1-w,1]])J(t,yt(R,E,C),y,h,B,B);J(t,k,h+T,h,B,B),J(t,k,y,y-T,B,B),J(t,D,y-T,h+T,S,S),un(t,n,y+.012);return}let _=x?Z(St(x,.15),.82):S,I=x?Z(St(x,.1),1.02):d;if(Ao(n.role)&&!s&&_o(t,n.role,c,h,y,_,I,a,n.heightM!==void 0))return;if((n.role==="sound"||s?.kind==="sound_desk")&&c.length===4&&y-h>.3){let M=xt(c),R=Math.hypot(M[1].x-M[0].x,M[1].y-M[0].y)*P,w=Math.min(.12,.09/Math.max(R,.001)),T=[.18,.21,.24],k=y-Math.min(.12,(y-h)*.15);for(let[D,B]of[[0,w],[1-w,1]])J(t,yt(M,D,B),k,h,T,T);J(t,M,y,k,d,T);return}if(n.role==="rail"&&c.length===4&&y>h){let M=xt(c),R=Math.hypot(M[1].x-M[0].x,M[1].y-M[0].y)*P,w=Math.max(1,Math.min(128,Math.ceil(R/1.4))),T=Math.min(.08,.055/Math.max(.055,R)),k=[.58,.64,.66];for(let D=0;D<=w;D++){let B=D/w,E=Math.min(1-T,Math.max(0,B-T/2));J(t,yt(M,E,E+T),y,h,k,Z(k,.8))}for(let D of[.52,1]){let B=h+(y-h)*D;J(t,M,B,Math.max(h,B-.055),k,Z(k,.8))}return}if(n.role==="goal"&&c.length===4){let M=xt(c),R=Math.hypot(M[1].x-M[0].x,M[1].y-M[0].y)*P,w=Math.min(.12,.1/Math.max(.1,R)),T=[.9,.94,.94];for(let[k,D]of[[0,w],[1-w,1]])J(t,yt(M,k,D),Math.max(h,y-.1),h,T,T);J(t,M,y,Math.max(h,y-.1),T,T);return}if(p.kind==="portal"&&c.length===4){let M=Zt(c,h,y);if(!M)return;let{quad:R,side:w,face:T,openingTop:k}=M;for(let[D,B,E]of[[0,T,1],[T,1-T,.67],[1-T,1,1]]){let C=an(R,D,B),v=Z(d,E),O=Z(S,E);for(let[F,L]of[[0,w],[1-w,1]])J(t,yt(C,F,L),k,h,v,O);J(t,C,y,k,v,O)}return}if(p.kind==="suite"&&c.length===4){let M=c.map((T,k)=>{let D=c[(k+1)%4],B=(T.x+D.x)/2,E=(T.y+D.y)/2;return Math.hypot(B-a.x,E-a.y)}),R=M.indexOf(Math.min(...M)),w=[0,1,2,3].map(T=>c[(R+T)%4]);J(t,yt(w,0,.08),y,h,d,S),J(t,yt(w,.92,1),y,h,d,S),J(t,an(w,.88,1),y,h,d,S),J(t,w,y,Math.max(h,y-.18),d,S);return}if(f&&!n.stageKind?.startsWith("pitch-")&&y-h>.12){let M=y-Math.min(.06,(y-h)*.15);J(t,c,M,h,d,S),J(t,c,y,M,d,et(d,S,.2))}else J(t,c,y,h,d,S);if((n.stageKind==="pitch-football"||n.stageKind==="pitch-rugby")&&c.length===4){t.setMaterial(4);let M=xt(c),R=et(x??Do,Do,x?.45:0);for(let w=0;w<12;w++){let T=yt(M,w/12,(w+1)/12),k=Z(R,w%2?1.09:.91),D=T.map(B=>[B.x*P,y+.006,B.y*P]);t.tri(D[0],D[1],D[2],[0,1,0],k),t.tri(D[0],D[2],D[3],[0,1,0],k)}}n.stageKind&&n.stageKind!=="pitch-football"&&vo(t,c,n.stageKind,y,x),f&&Yt(n.stageKind)&&Lo(t,n,y),t.setMaterial(m?1:0),un(t,n,y+.012)}function vn(t){let{x:n,y:e,width:r,height:o}=t;if(!r||!o)return null;let a=n+r/2,i=e+o/2,s=(t.rotation??0)*Math.PI/180,u=Math.cos(s),c=Math.sin(s),l=r/2,f=o/2;return[[-l,-f],[l,-f],[l,f],[-l,f]].map(([m,p])=>({x:a+m*u-p*c,y:i+m*c+p*u}))}function Zs(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 r=e[1].trim();if(r==="none"||r==="transparent")return null;let o=r.match(/^url\(#([^)]+)\)$/);if(!o)return ot(r);let a=n.match(new RegExp(`<(?:linear|radial)Gradient\\b[^>]*\\bid="${o[1]}"[^>]*>([\\s\\S]*?)</(?:linear|radial)Gradient>`,"i"));if(!a)return null;let i=[];for(let s of a[1].matchAll(/stop-color="([^"]+)"/gi)){let u=ot(s[1].trim());u&&i.push(u)}return i.length?i.reduce((s,u,c)=>et(s,u,1/(c+1)),i[0]):null}function Vo(t,n,e,r){if(n.layer==="foreground")return;let o=vn(n);if(!o)return;let a=e+Us,i=Xt(Zs(n.href),r.decorTop),s=Math.max(0,Math.min(1,n.opacity??1));s<1&&(i=et(r.ground,i,s)),K(t,o,void 0,()=>a,e,i,et(i,r.decorWall,.5),Y)}function Ko(t,n,e,r,o){if(!n.points||n.points.length<3)return;let a=Xe(r,o.gaTop);K(t,n.points,n.holes,()=>e+Xo,e,a,o.gaWall,Y),Qs(t,n.points,e+Xo)}var Xo=.15,kn=[.72,.74,.76],oe=1.1,jo=.12,re=.05,qs=.06,$s=2.4;function Qs(t,n,e){let r=Et([...n]),o=Lt(r,jo/P),a=Lt(r,(jo+re)/P);if(o.length<3||a.length<3)return;for(let s of[e+oe,e+oe*.5])K(t,o,[a.slice().reverse()],()=>s,s-re,kn,Z(kn,.85),Y);let i=qs/2/P;for(let s=0;s<o.length;s++){let u=o[s],c=o[(s+1)%o.length],l=Math.hypot(c.x-u.x,c.y-u.y)*P,f=Math.max(1,Math.round(l/$s));for(let m=0;m<f;m++){let p=m/f,h=u.x+(c.x-u.x)*p,y=u.y+(c.y-u.y)*p,x=[{x:h-i,y:y-i},{x:h+i,y:y-i},{x:h+i,y:y+i},{x:h-i,y:y+i}];K(t,x,void 0,()=>e+oe-re,e,kn,Z(kn,.8),Y)}}}var Js=6,ta=2.2,Zo=.1,na=new Set(["stage","entrance","exit","screen","suite","obstruction","sound","bar","concession","restroom","coat"]),ea=.3,oa=1.8,ra=.9,ia=.55,sa=6e3;function $o(t){let{doc:n,units:e,seats:r,surfaces:o,focal:a}=t,i=n.zones??[],s=[];if(i.length){let u=new Map;for(let l of e)for(let f of l.objects)f.type==="section"&&f.zone&&u.set(f.id,f.zone);let c=new Map;for(let l=0;l<r.length;l++){let f=r[l],m=o.seatOwner[l],p=f.zoneId??(m?u.get(m):void 0);if(!p)continue;let h=c.get(p);h||(h={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},c.set(p,h)),h.n++,f.x<h.minX&&(h.minX=f.x),f.y<h.minY&&(h.minY=f.y),f.x>h.maxX&&(h.maxX=f.x),f.y>h.maxY&&(h.maxY=f.y),h.sumY+=o.seatDeckY(l)}for(let l of i){let f=c.get(l.id),m=[];for(let[p,h]of u)h===l.id&&m.push(p);if(!f||f.n===0){s.push({id:l.id,label:l.label,color:ot(l.color),sectionIds:m,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(l.focalPoint??a).x*P,1.5,(l.focalPoint??a).y*P]});continue}s.push({id:l.id,label:l.label,color:ot(l.color),sectionIds:m,seatCount:f.n,center:[(f.minX+f.maxX)/2*P,f.sumY/f.n,(f.minY+f.maxY)/2*P],radius:.5*Math.hypot((f.maxX-f.minX)*P,(f.maxY-f.minY)*P)||1,focalWorld:[(l.focalPoint??a).x*P,1.5,(l.focalPoint??a).y*P]})}}return s}function Qo(t){let{doc:n,units:e,seats:r,surfaces:o,seatData:a,hintedSeatFloor:i,zones:s,focal:u}=t,c=[],l=[],f=[],m=new Map;for(let p of e)for(let h of p.objects){if(h.type!=="section"||!h.zone)continue;let y=(h.displayLabel||h.label||"").trim().toLocaleLowerCase();if(!y)continue;let x=n.floors?.[p.index]?.name?.trim().toLocaleLowerCase();if(e.length>1&&x===y)continue;let b=m.get(h.zone);b||m.set(h.zone,b=new Set),b.add(y)}for(let p of s)p.seatCount!==0&&(m.get(p.id)?.has(p.label.trim().toLocaleLowerCase())||c.push({id:`zone:${p.id}`,kind:"zone",text:p.label,anchor:[p.center[0],p.center[1]+Js,p.center[2]],color:n.zones?.find(h=>h.id===p.id)?.color}));{let p=new Map,h=new Map;for(let y=0;y<r.length;y++){let x=o.seatOwner[y];if(!x)continue;let b=p.get(x);b||(b={n:0,x:0,y:0,deck:0},p.set(x,b)),b.n++,b.x+=r[y].x,b.y+=r[y].y,b.deck+=o.seatDeckY(y);let d=h.get(x);d||(d={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0,minDeck:1/0,maxDeck:-1/0},h.set(x,d)),d.minDeck=Math.min(d.minDeck,o.seatDeckY(y)),d.maxDeck=Math.max(d.maxDeck,o.seatDeckY(y)),r[y].x<d.minX&&(d.minX=r[y].x),r[y].x>d.maxX&&(d.maxX=r[y].x),r[y].y<d.minY&&(d.minY=r[y].y),r[y].y>d.maxY&&(d.maxY=r[y].y)}for(let y of e)for(let x of y.objects){if(x.type!=="section"||po(x))continue;let b=p.get(x.id);if(!b||b.n===0)continue;let d=h.get(x.id),g=[b.x/b.n*P,b.deck/b.n,b.y/b.n*P],S=x.displayLabel||x.label||x.id;l.push({id:x.id,floorIndex:y.index,label:S,seatCount:b.n,center:g,radius:Math.max(1,Math.hypot(d.maxX-d.minX,d.maxY-d.minY)*.5*P),box:{min:[d.minX*P-.4,d.minDeck,d.minY*P-.4],max:[d.maxX*P+.4,d.maxDeck+1,d.maxY*P+.4]},focalWorld:[y.focal.x*P,y.baseHeightM+1.5,y.focal.y*P]});let _=n.floors?.[y.index]?.name?.trim().toLocaleLowerCase();e.length>1&&_===S.trim().toLocaleLowerCase()||c.push({id:`section:${x.id}`,kind:"section",text:S,anchor:[g[0],g[1]+ta,g[2]],floorIndex:y.index})}}{for(let b of e)for(let d of b.objects){if(d.type!=="gaArea")continue;let g=nn(d.points);if(!g)continue;let S=d.displayLabel||d.label||d.id;c.push({id:`ga:${d.id}`,kind:"ga",text:d.capacity>0?`${S} \xB7 ${d.capacity.toLocaleString()}`:S,anchor:[g.x*P,b.baseHeightM+oa,g.y*P],floorIndex:b.index})}let p=new Map,h=new Map;for(let b of e)for(let d of b.objects)if(d.type==="section"&&p.set(d.id,d.displayLabel||d.label||d.id),d.type==="row"){let g=d.displayLabel?.trim()||d.segmentedRow?.displayLabel?.trim();g&&h.set(d.id,g)}let y=new Map;for(let b=0;b<r.length;b++){let d=r[b],g=Math.hypot(d.x-u.x,d.y-u.y),S=y.get(d.rowId);(!S||g>S.far)&&y.set(d.rowId,{seat:d,index:b,far:g})}for(let[b,d]of y){let g=o.seatOwner[d.index]??d.seat.sectionId,S=qo(d.seat.label,b,p.get(g??""),h.get(b));S&&c.push({id:`row:${b}`,kind:"row",text:S,anchor:[d.seat.x*P,o.seatDeckY(d.index)+ra,d.seat.y*P],floorIndex:i[d.index]})}let x=new Map;for(let b=0;b<r.length;b++){let d=r[b],g=x.get(d.rowId);g||(g={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:qo(d.label,d.rowId,p.get(o.seatOwner[b]??d.sectionId??""),h.get(d.rowId)),sectionId:o.seatOwner[b]??d.sectionId},x.set(d.rowId,g));let S=b*3,_=a.iPosition[S],I=a.iPosition[S+1],A=a.iPosition[S+2];g.n++,g.x+=_,g.y+=I,g.z+=A,g.minX=Math.min(g.minX,_),g.maxX=Math.max(g.maxX,_),g.minZ=Math.min(g.minZ,A),g.maxZ=Math.max(g.maxZ,A)}for(let[b,d]of x)f.push({id:b,label:d.label,sectionId:d.sectionId,seatCount:d.n,center:[d.x/d.n,d.y/d.n,d.z/d.n],radius:Math.max(.8,Math.hypot(d.maxX-d.minX,d.maxZ-d.minZ)*.5)});if(r.length<=sa)for(let b=0;b<r.length;b++){let d=r[b],g=aa(d.displayLabel||d.label);g&&c.push({id:`seat:${d.id}`,kind:"seat",seatWidthM:a.iChairWidth[b]*2,text:g,anchor:[d.x*P,o.seatDeckY(b)+ia,d.y*P],floorIndex:i[b],rowId:d.rowId})}}for(let p of e)for(let h of p.objects)if(h.type==="shape"&&h.role&&na.has(h.role)){let y=it(h),x=y?nn(y):null;if(!x||!h.label)continue;c.push({id:`architecture:${h.id}`,kind:h.role==="stage"?"stage":"annotation",text:h.label,anchor:[x.x*P,p.baseHeightM+It(h).heightM+Zo,x.y*P],color:h.fill,floorIndex:p.index})}else if(h.type==="text"){if(!h.text)continue;c.push({id:`text:${h.id}`,kind:"annotation",text:h.text,anchor:[h.position.x*P,p.baseHeightM+Zo,h.position.y*P],color:h.color,rotation:h.rotation,floorIndex:p.index})}else if(h.type==="booth"){let y=At(h);if(!y)continue;let x=nn(y);if(!x)continue;c.push({id:`booth:${h.id}`,kind:"booth",text:h.displayLabel||h.label||h.id,anchor:[x.x*P,p.baseHeightM+Fn+ea,x.y*P],floorIndex:p.index})}return{labels:c,sections:l,rows:f}}function Jo(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 aa(t){let n=t.lastIndexOf("-");return n>=0&&n<t.length-1?t.slice(n+1):t}function qo(t,n,e,r){if(r?.trim())return r.trim();let o=t?t.lastIndexOf("-"):-1,a=o>0?t.slice(0,o):n;return a&&_e(a,e)}var fn=3,jt=.38,mn=.24;function ca(t){if(t.length<3)return null;let n=t[0],e=t[Math.floor(t.length/2)],r=t[t.length-1],o=(e.x-n.x)*P,a=(e.y-n.y)*P,i=(r.x-n.x)*P,s=(r.y-n.y)*P,u=2*(o*s-a*i);if(Math.abs(u)<1e-7)return null;let c=o*o+a*a,l=i*i+s*s,f=(c*s-l*a)/u+n.x*P,m=(o*l-i*c)/u+n.y*P,p=Math.hypot(n.x*P-f,n.y*P-m);return p<1||p>200||!Number.isFinite(p)||t.some(h=>Math.abs(Math.hypot(h.x*P-f,h.y*P-m)-p)>.03)?null:{x:f,z:m,radius:p}}function tr(t){let n=[],e=new Map,r=(u,c)=>`${Math.floor(u/fn)},${Math.floor(c/fn)}`;for(let u of t)for(let c of u.rows){for(let f of c.pts){let m=f.x*P,p=f.y*P,h=r(m,p),y=e.get(h)??[];y.push({x:m,z:p,y:c.y,floor:u.floorIndex}),e.set(h,y)}if(c.patch||c.pts.length<2)continue;let l=ca(c.pts);for(let f of[0,c.pts.length-1]){let m=c.pts[f],p=c.pts[f===0?1:f-1],h=m.x-p.x,y=m.y-p.y,x=Math.hypot(h,y);x<1e-6||n.push({sectionId:u.sectionId,floorIndex:u.floorIndex,curve:l,row:c,point:m,x:m.x*P,z:m.y*P,dx:h/x,dz:y/x})}}let o=new Map;n.forEach((u,c)=>{let l=r(u.x,u.z),f=o.get(l)??[];f.push(c),o.set(l,f)});let a=(u,c)=>{let l=Math.floor(u/fn),f=Math.floor(c/fn);return[-1,0,1].flatMap(m=>[-1,0,1].map(p=>`${l+m},${f+p}`))},i=new Map;n.forEach((u,c)=>{let l=-1,f=1/0,m=!1;for(let p of a(u.x,u.z))for(let h of o.get(p)??[]){let y=n[h];if(u.sectionId===y.sectionId&&u.row.blockId===y.row.blockId||u.floorIndex!==y.floorIndex||Math.abs(u.row.y-y.row.y)>.05)continue;let x=y.x-u.x,b=y.z-u.z,d=Math.hypot(x,b);if(d<jt*2+.45||d>fn)continue;let g=u.curve&&y.curve&&Math.hypot(u.curve.x-y.curve.x,u.curve.z-y.curve.z)<=.05&&Math.abs(u.curve.radius-y.curve.radius)<=.05,S=Math.min((x*u.dx+b*u.dz)/d,(-x*y.dx-b*y.dz)/d);(g?S<.8:S<.98)||!g&&(Math.abs(x*u.dz-b*u.dx)>.15||Math.abs(x*y.dz-b*y.dx)>.15)||(d<f-.02?(l=h,f=d,m=!1):Math.abs(d-f)<=.02&&(m=!0))}l>=0&&!m&&i.set(c,l)});let s=[];for(let[u,c]of i){if(u>=c||i.get(c)!==u)continue;let l=n[u],f=n[c],m=Math.hypot(f.x-l.x,f.z-l.z),p=(f.x-l.x)/m,h=(f.z-l.z)/m,y=!1;for(let b of a((l.x+f.x)/2,(l.z+f.z)/2))for(let d of e.get(b)??[]){if(d.floor!==l.floorIndex||Math.abs(d.y-l.row.y)>.75)continue;let g=(d.x-l.x)*p+(d.z-l.z)*h,S=Math.abs((d.x-l.x)*h-(d.z-l.z)*p);g>.01&&g<m-.01&&S<mn+jt&&(y=!0)}if(y)continue;let x=(b,d)=>({x:(l.x+p*b-h*d)/P,y:(l.z+h*b+p*d)/P});s.push({sections:[l.sectionId,f.sectionId],blocks:[l.row.blockId,f.row.blockId],floorIndex:l.floorIndex,ends:[l.point,f.point],clearWidthM:m-2*jt,heightM:(l.row.y+f.row.y)/2,outline:[x(jt,-mn),x(m-jt,-mn),x(m-jt,mn),x(jt,mn)]})}return s}var la=.15,ua=.9,fa=1.76;function nr(t){return!!t&&t[0]*.2126+t[1]*.7152+t[2]*.0722>.55?{zenith:[.36,.58,.84],horizon:[.82,.88,.94]}:{zenith:[.05,.08,.15],horizon:[.3,.38,.5]}}function ma(){return{background:{top:[...Xn.top],bottom:[...Xn.bottom]},sky:nr(null),structure:Hn,seatStates:{...ve},seatScale:1,materials:{seat:null,shell:null,roughness:.78}}}function ha(t){return!!t&&t[0]*.2126+t[1]*.7152+t[2]*.0722>.55?{deck:"#a8ada9",fascia:"#69777c",shell:"#8d9ca0",roughness:.87}:{deck:"#69747b",fascia:"#3e4d58",shell:"#526572",roughness:.87}}function er(t){let n=ma();t??={};let e=ot(t.background);if(e){n.background={top:Z(e,ua),bottom:Z(e,fa)},n.sky=nr(e);let s={};for(let[c,l]of Object.entries(Hn))s[c]=et(l,e,la);e[0]*.2126+e[1]*.7152+e[2]*.0722>.55&&(s.ground=Z(e,.86)),n.structure=s}let r=ot(t.selectionColor)??ot(t.accent);r&&(n.seatStates={...n.seatStates,selected:r});let o=t.seatScale;typeof o=="number"&&Number.isFinite(o)&&(n.seatScale=Ee(o));let a=Object.fromEntries(Object.entries(t.venue3d??{}).filter(([,s])=>s!=null)),i={...ha(e),...a};if(i){let s=ot(i.deck),u=ot(i.fascia);s&&(n.structure={...n.structure,tierTop:s,gaTop:s}),u&&(n.structure={...n.structure,tierWall:u,gaWall:u}),n.materials.seat=ot(i.seat),n.materials.shell=ot(i.shell),typeof i.roughness=="number"&&Number.isFinite(i.roughness)&&(n.materials.roughness=Math.min(1,Math.max(0,i.roughness)))}return n}function or(t,n){let e=[];for(let r of n)e.push(...t.seatStates[r]);return e}var ie=.6,rr=3,ya=.25;function pa(t,n){if(dt(n,t.x,t.y))return 0;let e=1/0;for(let r=0,o=n.length-1;r<n.length;o=r++){let a=n[o],i=n[r],s=i.x-a.x,u=i.y-a.y,c=s*s+u*u||1,l=Math.max(0,Math.min(1,((t.x-a.x)*s+(t.y-a.y)*u)/c));e=Math.min(e,Math.hypot(t.x-(a.x+l*s),t.y-(a.y+l*u)))}return e}function ir(t,n){let e=t.map(i=>({booth:i,ring:At(i)})).filter(i=>!!i.ring&&i.ring.length===4&&!i.booth.points),r=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))})),o=(rr+ie)/P,a=new Map;return e.forEach(({booth:i,ring:s},u)=>{let c={x:s.reduce((p,h)=>p+h.x,0)/4,y:s.reduce((p,h)=>p+h.y,0)/4},l=[0,1,2,3].map(p=>{let h=s[p],y=s[(p+1)%4],x={x:(h.x+y.x)/2,y:(h.y+y.y)/2},b=x.x-c.x,d=x.y-c.y,g=Math.hypot(b,d)||1,S={x:x.x+b/g*ie/P,y:x.y+d/g*ie/P},_=rr/P;return r.forEach((I,A)=>{A===u||S.x<I.minX-o||S.x>I.maxX+o||S.y<I.minY-o||S.y>I.maxY+o||(_=Math.min(_,pa(S,e[A].ring)))}),{open:_*P,toward:{x:x.x+b/g*10/P,y:x.y+d/g*10/P},focal:Math.hypot(x.x-n.x,x.y-n.y)}}),f=Math.max(...l.map(p=>p.open)),m=l.filter(p=>p.open>=f-ya).sort((p,h)=>p.focal-h.focal)[0];a.set(i.id,m.toward)}),a}import da from"polygon-clipping";var xa=.45,ba=1500,ga=200;function sr(t,n){if(t.role!=="stage"||Yt(t.stageKind))return t;let e=it(t);if(!e||e.length<3||Math.abs(pt(e))*P*P>ba)return t;let r=n.filter(i=>dt(e,i.x,i.y));if(!r.length||r.length>ga)return t;let o=xa/P,a=r.map(i=>[[[i.x-o,i.y-o],[i.x+o,i.y-o],[i.x+o,i.y+o],[i.x-o,i.y+o],[i.x-o,i.y-o]]]);try{let i=da.difference([[...e.map(c=>[c.x,c.y]),[e[0].x,e[0].y]]],...a),s=null,u=0;for(let c of i){let l=c[0].slice(0,-1).map(([m,p])=>({x:m,y:p})),f=Math.abs(pt(l));f>u&&(u=f,s=l)}return!s||s.length<3?t:{...t,kind:"polygon",points:s,rotation:0}}catch{return t}}function se(t,n,e,r,o,a,i,s,u,c=[],l=o){if(n.length!==e.length||n.length<2||a-o<1.5)return;let f=(y,x,b)=>{Ot(t,y,x,b,c,i,s,{portalBase:l,ao:u})||K(t,y,void 0,()=>b,x,i,s,u)},m=(y,x,b)=>({x:y.x+(x.x-y.x)*b,y:y.y+(x.y-y.y)*b}),p=r?n.length:n.length-1,h=0;for(let y=0;y<p;y++){let x=(y+1)%n.length,b=Math.hypot(e[x].x-e[y].x,e[x].y-e[y].y)*$;if(b<1e-5)continue;let d=(I,A)=>[m(n[y],n[x],I),m(n[y],n[x],A),m(e[y],e[x],A),m(e[y],e[x],I)];f(d(0,1),o,o+.95),f(d(0,1),a-.22,a);let g=Math.ceil((h-.32)/6)*6,S=!1,_=!1;for(let I=g;I<h+b;I+=6){let A=Math.max(0,(I-h)/b),M=Math.min(1,(I+.32-h)/b);M<=A||(f(d(A,M),o+.95,a-.22),S||=A<1e-6,_||=M>1-1e-6)}if(!r&&(y===0&&!S||y===p-1&&!_)){let I=Math.min(1,.32/b);f(d(y===0?0:1-I,y===0?I:1),o+.95,a-.22)}h+=b}}import Ut from"polygon-clipping";var yn=.65;function ae(t,n){let e=1/0;for(let r of n)for(let o=0;o<r.length;o++){let a=r[o],i=r[(o+1)%r.length],s=i.x-a.x,u=i.y-a.y,c=Math.max(0,Math.min(1,((t.x-a.x)*s+(t.y-a.y)*u)/(s*s+u*u||1)));e=Math.min(e,Math.hypot(t.x-a.x-c*s,t.y-a.y-c*u))}return e}var ce=.01;function ar(t,n,e,r,o,a,i,s=[],u=!0,c={bays:[],walls:[]}){if(r-o<=1e-5)return;let l=r-o>=3,f=l?r-yn:o;t.setMaterial(5);let m=l?[]:s.filter(I=>{if(I.role!=="entrance"&&I.role!=="exit")return!1;let A=it(I);if(!A)return!1;let M=Zt(A,o,o+It(I).heightM);return M!==null&&M.openingTop<=r-.12});if((!m.length||!Ot(t,n,f,r,m,a,i,{holes:e,portalBase:o}))&&K(t,n,e,()=>r,f,a,i,Y,void 0,()=>[0,1,0]),!l){t.setMaterial(0);return}let p=u&&c.bays.length?Ma(n,e,Lt(n,hn/P),c):null,h=6/P,y=.22/P,x=s.flatMap(I=>{if(I.role!=="entrance"&&I.role!=="exit")return[];let A=it(I);return A?.length?[{minX:Math.min(...A.map(M=>M.x)),maxX:Math.max(...A.map(M=>M.x)),minY:Math.min(...A.map(M=>M.y)),maxY:Math.max(...A.map(M=>M.y))}]:[]}),b=Math.min(...n.map(I=>I.x)),d=Math.max(...n.map(I=>I.x)),g=Math.min(...n.map(I=>I.y)),S=Math.max(...n.map(I=>I.y));for(let I=b+h/2;I<d;I+=h)for(let A=g+h/2;A<S;A+=h){if(x.some(R=>I+y>=R.minX&&I-y<=R.maxX&&A+y>=R.minY&&A-y<=R.maxY))continue;let M=[{x:I-y,y:A-y},{x:I+y,y:A-y},{x:I+y,y:A+y},{x:I-y,y:A+y}];!wt({x:I,y:A},n,e)||ae({x:I,y:A},[n,...e??[]])<y*Math.SQRT2+(u?hn/P:0)||p&&ae({x:I,y:A},p.flat())<y*Math.SQRT2+hn/P||K(t,M,void 0,()=>f,o,a,i,Y)}if(p){for(let[I,...A]of p)K(t,I,A,()=>f,o-ce,a,i,Y);t.setMaterial(0);return}let _=Lt(n,hn/P);if(u&&_.length>=3){let I=s.filter(R=>{if(R.role!=="entrance"&&R.role!=="exit")return!1;let w=it(R);return!!w&&w.some(T=>!wt(T,n,void 0)||ae(T,[n])<=hn/P)}),A=[_.slice().reverse()],M=o-ce;(!I.length||!Ot(t,n,M,f,I,a,i,{holes:A,portalBase:o+ce}))&&K(t,n,A,()=>f,M,a,i,Y)}t.setMaterial(0)}var le=.25,hn=le;function Ma(t,n,e,r){if(e.length<3)return null;let o=i=>{let s=i.map(u=>[u.x,u.y]);return s.push(s[0]),s},a=i=>{let[s,...u]=i.map(c=>[o(c)]);return Ut.union(s,...u)};try{let i=[o(t),...(n??[]).map(o)],s=Ut.difference(i,[o(e)]),u=Ut.intersection(i,a(r.bays));if(!u.length)return null;let c=Ut.difference(Ut.intersection(i,a(r.walls)),u);return Ut.union(Ut.difference(s,u),c).map(f=>f.map(m=>m.slice(0,-1).map(([p,h])=>({x:p,y:h}))))}catch{return null}}var Pa=.02,Sa=.25,Ra=1.2,Ia=.6,Aa=.45,_a=2.3,wa=Math.PI/180,cr=.005;function Bt(t,n,e){let r=e*wa;return{x:t.x+n*Math.sin(r),y:t.y+n*Math.cos(r)}}function Ea(t,n){let e=n.rings[n.rings.length-1];if(!e)return!1;let r=e.outerRMedian*.85;for(let o of t){if(o.role!=="wall")continue;let a=o.points&&o.points.length>=2?o.points:o.x!==void 0&&o.y!==void 0&&o.width!==void 0&&o.height!==void 0?[{x:o.x,y:o.y},{x:o.x+o.width,y:o.y},{x:o.x+o.width,y:o.y+o.height},{x:o.x,y:o.y+o.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)>=r&&i++;if(i>=a.length/2)return!0}return!1}var Ba=24,Ta=.01;function Oa(t,n,e,r,o,a,i,s,u){let c=e.binCount,l=Ba,f=$,m=a+.02,p=a-Ta,h=[];for(let B=0;B<c;B++){let E=(e.startBin+B+.5)*n.binStepDeg,C=new Float64Array(l+1);for(let v=0;v<=l;v++){let O=r[B]+(o[B]-r[B])*v/l;C[v]=Math.max(m,Oe(n,e,E,O)-Sa)}h.push(C)}if(u){let B=0;for(let E=0;E+1<c;E++)for(let C=0;C<l;C++){let v=Bt(n.centre,r[E]+(o[E]-r[E])*C/l,(e.startBin+E+.5)*n.binStepDeg),O=Bt(n.centre,r[E+1]+(o[E+1]-r[E+1])*(C+1)/l,(e.startBin+E+1.5)*n.binStepDeg);B=Math.max(B,Math.hypot(O.x-v.x,O.y-v.y))}for(let E=0;E<c;E++){let C=(e.startBin+E+.5)*n.binStepDeg;for(let v=0;v<=l;v++){let O=Bt(n.centre,r[E]+(o[E]-r[E])*v/l,C),F=u(O.x,O.y,B*1.01);F!==null&&(h[E][v]=Math.min(h[E][v],Math.max(p+cr,F-cr)))}}}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],b=[i.bandWall[0]*s.top,i.bandWall[1]*s.top,i.bandWall[2]*s.top],d=[i.bandWall[0]*s.wallBottom,i.bandWall[1]*s.wallBottom,i.bandWall[2]*s.wallBottom],g=(B,E)=>{let C=(e.startBin+B+.5)*n.binStepDeg,v=r[B]+(o[B]-r[B])*E/l,O=Bt(n.centre,v,C);return[O.x*f,h[B][E],O.y*f]};{let B=Math.tan(12*Math.PI/180);for(let E=0;E<6;E++){let C=!1;for(let O=0;O<c;O++)for(let F=l-1;F>=0;F--)h[O][F]>h[O][F+1]&&(h[O][F]=h[O][F+1],C=!0);let v=e.closed?c:c-1;for(let O=0;O<v;O++){let F=(O+1)%c;for(let L=0;L<=l;L++){let H=h[F][L]-h[O][L];if(Math.abs(H)>1)continue;let j=r[O]+(o[O]-r[O])*L/l,U=r[F]+(o[F]-r[F])*L/l,X=Bt(n.centre,j,(e.startBin+O+.5)*n.binStepDeg),W=Bt(n.centre,U,(e.startBin+F+.5)*n.binStepDeg),Q=B*Math.hypot(W.x-X.x,W.y-X.y)*f;H>Q?(h[F][L]=h[O][L]+Q,C=!0):-H>Q&&(h[O][L]=h[F][L]+Q,C=!0)}}if(!C)break}}let S=1,_=(B,E)=>{for(let C=0;C<=l;C+=4)if(Math.abs(h[B][C]-h[E][C])>S)return!0;return Math.abs(h[B][l]-h[E][l])>S},I=Math.tan(38*Math.PI/180),A=B=>(o[B]-r[B])/l*f,M=(B,E)=>h[B][E+1]-h[B][E]>I*Math.max(1e-6,A(B)),R=(B,E)=>{let C=e.closed?(B-1+c)%c:Math.max(0,B-1),v=e.closed?(B+1)%c:Math.min(c-1,B+1);Math.abs(h[C][E]-h[B][E])>S&&(C=B),Math.abs(h[v][E]-h[B][E])>S&&(v=B);let O=Math.max(0,E-1),F=Math.min(l,E+1);O<E&&M(B,O)&&(O=E),F>E&&M(B,E)&&(F=E);let L=g(C,E),H=g(v,E),j=g(B,O),U=g(B,F),X=H[0]-L[0],W=H[1]-L[1],Q=H[2]-L[2],tt=U[0]-j[0],q=U[1]-j[1],st=U[2]-j[2],nt=W*st-Q*q,N=Q*tt-X*st,G=X*q-W*tt,V=Math.hypot(nt,N,G);return V>1e-12?(nt/=V,N/=V,G/=V,N<0&&(nt=-nt,N=-N,G=-G),[nt,N,G]):[0,1,0]},w=(B,E,C=!1)=>{let v=C&&Math.min(B[1],E[1])-a>=3,O=[B[0],v?B[1]-yn:p,B[2]],F=[E[0],v?E[1]-yn:p,E[2]],L=E[0]-B[0],H=E[2]-B[2],j=Math.hypot(L,H);if(!(j>1e-12))return;let U=[H/j,0,-L/j];t.tri(B,E,F,U,b,b,d),t.tri(B,F,O,U,b,d,d)},T=.05*Mt,k=B=>o[B]-r[B]<T,D=e.closed?c:c-1;for(let B=0;B<D;B++){let E=(B+1)%c;if(k(B)||k(E))continue;if(_(B,E)){let H=(e.startBin+B+1)*n.binStepDeg,j=(q,st)=>{let nt=(r[B]+r[E])/2,N=(o[B]+o[E])/2,G=nt+(N-nt)*st/l,V=Bt(n.centre,G,H);return[V.x*f,h[q][st],V.y*f]};for(let q=0;q<l;q++){let st=g(B,q),nt=g(B,q+1),N=j(B,q),G=j(B,q+1),V=R(B,q),at=R(B,q+1);t.triN(st,N,G,V,V,at,y),t.triN(st,G,nt,V,at,at,y);let ft=g(E,q),ht=g(E,q+1),rt=j(E,q),ct=j(E,q+1),_t=R(E,q),z=R(E,q+1);t.triN(rt,ft,ht,_t,_t,z,y),t.triN(rt,ht,ct,_t,z,z,y);let ut=j(B,q),mt=j(B,q+1),Nt=j(E,q+1),Gt=j(E,q),kt=mt[0]-ut[0],Ft=mt[2]-ut[2],tn=Math.hypot(kt,Ft);if(tn>1e-12){let pn=[Ft/tn,0,-kt/tn];t.tri(ut,mt,Nt,pn,b),t.tri(ut,Nt,Gt,pn,b)}}let U=g(B,0),X=g(E,0),W=g(E,l),Q=g(B,l),tt=q=>[q[0],p,q[2]];Math.min(U[1],X[1])-a<3&&(t.tri(tt(U),tt(W),tt(X),[0,-1,0],x),t.tri(tt(U),tt(Q),tt(W),[0,-1,0],x)),w(U,X,!0),w(Q,W,!0);continue}for(let H=0;H<l;H++){let j=R(B,H),U=R(E,H),X=R(E,H+1),W=R(B,H+1);if(M(B,H)||M(E,H)){let nt=(mt,Nt)=>{let Gt=(e.startBin+mt+.5)*n.binStepDeg,kt=r[mt]+(o[mt]-r[mt])*(H+.5)/l,Ft=Bt(n.centre,kt,Gt);return[Ft.x*f,Nt,Ft.y*f]},N=g(B,H),G=g(E,H),V=nt(B,h[B][H]),at=nt(E,h[E][H]);t.triN(N,G,at,j,U,U,y),t.triN(N,at,V,j,U,j,y);let ft=g(E,H+1),ht=g(B,H+1),rt=nt(B,h[B][H+1]),ct=nt(E,h[E][H+1]);t.triN(rt,ct,ft,W,X,X,y),t.triN(rt,ft,ht,W,X,W,y);let _t=at[0]-V[0],z=at[2]-V[2],ut=Math.hypot(_t,z);if(ut>1e-12){let mt=[-z/ut,0,_t/ut];t.tri(V,at,ct,mt,b),t.tri(V,ct,rt,mt,b)}continue}let Q=g(B,H),tt=g(E,H),q=g(E,H+1),st=g(B,H+1);t.triN(Q,tt,q,j,U,X,y),t.triN(Q,q,st,j,X,W,y)}let C=g(B,0),v=g(E,0),O=g(E,l),F=g(B,l),L=H=>[H[0],p,H[2]];Math.min(C[1],v[1])-a<3&&(t.tri(L(C),L(O),L(v),[0,-1,0],x),t.tri(L(C),L(F),L(O),[0,-1,0],x)),w(C,v,!0),w(F,O,!0)}if(!e.closed)for(let B of[0,c-1])for(let E=0;E<l;E++)w(g(B,E),g(B,E+1))}function lr(t,n,e){let{bottomY:r,colors:o,ao:a}=e,i=new Float64Array(n.binCount).fill(-1/0);for(let l of n.rings)for(let f of l.arcs){let m=new Float64Array(f.binCount),p=new Float64Array(f.binCount);for(let y=0;y<f.binCount;y++){let x=(f.startBin+y)%n.binCount,b=Math.max(0,f.innerR[y]-Pt);m[y]=Math.max(b,i[x]+.001),p[y]=Math.max(m[y]+.001,f.outerR[y]+Pt)}let h=0;for(let y=0;y<f.binCount;y++){let x=f.topLevelM[y]-r;x>h&&(h=x)}h>=Ra&&Oa(t,n,f,m,p,r,o,a,e.standTopNear);for(let y=0;y<f.binCount;y++){let x=(f.startBin+y)%n.binCount;p[y]>i[x]&&(i[x]=p[y])}}if(e.deriveShell===!1||Ea(e.shapes,n))return;let s=n.rings[n.rings.length-1],u=Ia*Mt,c=Aa*Mt;for(let l of s.arcs){let f=[],m=[];for(let R=0;R<l.binCount;R++){let w=(l.startBin+R+.5)*n.binStepDeg,T=l.outerR[R]+Pt+u;f.push(Bt(n.centre,T,w)),m.push(Bt(n.centre,T+c,w))}let p=-1/0;for(let R=0;R<l.binCount;R++)l.topLevelM[R]>p&&(p=l.topLevelM[R]);let h=p+_a,y=l.closed?m:[...m,...f.slice().reverse()],x=l.closed?[f.slice().reverse()]:void 0,b=et(o.shellWall,[.66,.71,.72],.62),d=(R,w,T,k,D)=>{let B=Math.abs(k-p)<1e-6?k-Pa:k;Ot(t,R,T,B,e.shapes,o.shellTop,D,{holes:w,portalBase:r,ao:a})||K(t,R,w,()=>B,T,o.shellTop,D,a)},g=Math.max(1,Math.ceil((p-r)/4.5)),S=(p-r)/g,_=new Set,I=e.tierFrontLevels??n.rings.map(R=>{let w=R.arcs.flatMap(T=>Array.from(T.frontLevelM)).filter(Number.isFinite).sort((T,k)=>T-k);return w[Math.floor(w.length/2)]});for(let R of I)Number.isFinite(R)&&R-r>=3&&R<p&&_.add(Math.max(0,Math.min(g-1,Math.floor((R-r)/S))));let A=Math.min(...I.filter(R=>Number.isFinite(R)&&R-r>=3&&R<p));for(let R=0;R<g;R++)r+(R+1)*S<=A-yn&&Number.isFinite(A)&&_.add(R);for(let R=0;R<g;R++){let w=r+(p-r)*R/g,T=r+(p-r)*(R+1)/g;_.has(R)&&T-w>=3.2?(d(y,x,w,w+.45,b),se(t,f,m,l.closed,w+.45,T-.16,o.shellTop,b,a,e.shapes,r)):d(y,x,w,T-.16,b),d(y,x,T-.16,T,Z(b,.62))}se(t,f,m,l.closed,p,h,o.shellTop,b,a,e.shapes,r);let M=8;for(let R=1;R<m.length;R++){if(M+=Math.hypot(m[R].x-m[R-1].x,m[R].y-m[R-1].y)*$,M<8)continue;M=0;let w=m[R],T=m[R-1],k=w.x-T.x,D=w.y-T.y,B=Math.max(1,Math.hypot(k,D)),E=k/B*.16*Mt,C=D/B*.16*Mt,v=Math.max(1,Math.hypot(w.x-n.centre.x,w.y-n.centre.y)),O=(w.x-n.centre.x)/v*.24*Mt,F=(w.y-n.centre.y)/v*.24*Mt,L=[{x:w.x-E,y:w.y-C},{x:w.x+E,y:w.y+C},{x:w.x+E+O,y:w.y+C+F},{x:w.x-E+O,y:w.y-C+F}];d(L,void 0,r,p,Z(b,1.12))}}}var Ca=2.5,ur=.65,ka=2,Fa=.03;function La(t,n){let e=()=>{let r=n;for(;t.length>2;){let o=t[0],a=t[1],i=Math.hypot(a.x-o.x,a.y-o.y);if(i>r){t[0]={x:o.x+(a.x-o.x)/i*r,y:o.y+(a.y-o.y)/i*r};return}r-=i,t.shift()}};e(),t.reverse(),e(),t.reverse()}function me(t,n,e){let r=new Map;for(let a of t){let i=r.get(a.blockId);(!i||a.depth<i.depth)&&r.set(a.blockId,a)}let o=[];for(let[a,i]of r){if(i.y-e<Ca||i.pts.length<2)continue;let s=i.pts.map(l=>{let f=l.x-n.x,m=l.y-n.y,p=Math.max(1,Math.hypot(f,m));return{x:l.x-f/p*ur/P,y:l.y-m/p*ur/P}}),u=[],c=[s[0]];for(let l=1;l<s.length;l++){let f=s[l-1],m=s[l];Math.hypot(m.x-f.x,m.y-f.y)*P>ka?(c.length>=2&&u.push(c),c=[m]):c.push(m)}c.length>=2&&u.push(c);for(let l of u)La(l,Fa/P);u.length&&o.push({blockId:a,y:i.y,runs:u})}return o}var fr=.1,va=1.1,Da=.22,ue=.95,fe=.05,mr=1.8;function hr(t,n,e,r){let o=[.72,.72,.69],a=[.48,.55,.57];for(let i of me(n,e,r)){let s=i.y;for(let u of i.runs){let c=mr;for(let l=1;l<u.length;l++){let f=u[l-1],m=u[l],p=m.x-f.x,h=m.y-f.y,y=Math.hypot(p,h);if(y<1e-5)continue;let x=b=>{let d=-h/y*b/P/2,g=p/y*b/P/2;return[{x:f.x+d,y:f.y+g},{x:m.x+d,y:m.y+g},{x:m.x-d,y:m.y-g},{x:f.x-d,y:f.y-g}]};if(K(t,x(Da),void 0,()=>s+fr,s-va,o,o,Y),K(t,x(fe),void 0,()=>s+ue,s+ue-fe,a,a,Y),c+=y*P,c>=mr||l===u.length-1){c=0;let b=.028/P,d=[{x:f.x-b,y:f.y-b},{x:f.x+b,y:f.y-b},{x:f.x+b,y:f.y+b},{x:f.x-b,y:f.y+b}];K(t,d,void 0,()=>s+ue-fe,s+fr,a,a,Y)}}}}}var Na=.9,Ga=1.5,Ha=.3;function yr(t,n,e){let r=[],o=[],a=Na/P,i=Ga/P,s=Ha/P;for(let u of t)for(let c of u.runs){if(c.length<2)continue;let l=c.slice(),f=(x,b)=>{let d=l[x],g=l[b],S=Math.hypot(d.x-g.x,d.y-g.y)||1;l[x]={x:d.x+(d.x-g.x)/S*s,y:d.y+(d.y-g.y)/S*s}};f(0,1),f(l.length-1,l.length-2);let m=l.map((x,b)=>{let d=l[Math.max(0,b-1)],g=l[Math.min(l.length-1,b+1)],S=g.x-d.x,_=g.y-d.y,I=Math.hypot(S,_)||1,A=-_/I,M=S/I;return A*(x.x-n.x)+M*(x.y-n.y)<0&&(A=-A,M=-M),{nx:A,ny:M}}),p=l.map((x,b)=>({x:x.x-m[b].nx*i,y:x.y-m[b].ny*i})),h=l.map((x,b)=>({x:x.x+m[b].nx*a,y:x.y+m[b].ny*a})),y=l.map((x,b)=>({x:x.x+m[b].nx*(a+e/P),y:x.y+m[b].ny*(a+e/P)}));r.push([...p,...h.slice().reverse()]),o.push([...h,...y.reverse()])}return{bays:r,walls:o}}function pr(t,n,e,r,o){let a=[.67,.71,.68];for(let i=0;i<n.length;i++){let s=n[i];if(!(s.pts.length<2))for(let u of[0,s.pts.length-1]){let c=s.pts[u],l=s.pts[u===0?1:u-1],f=c.x-l.x,m=c.y-l.y,p=Math.hypot(f,m);if(p<1e-5)continue;f/=p,m/=p;let h=1/0;for(let M=0;M<e.length;M++){let R=e[M],w=e[(M+1)%e.length],T=w.x-R.x,k=w.y-R.y,D=f*k-m*T;if(Math.abs(D)<1e-8)continue;let B=R.x-c.x,E=R.y-c.y,C=(B*k-E*T)/D,v=(B*m-E*f)/D;C>0&&v>=0&&v<=1&&(h=Math.min(h,C))}let y=.3/P,x=h-.04/P;if(!Number.isFinite(h)||h*P>2||x-y<.12/P)continue;let b=.27/P,d=[{x:c.x+f*y-m*b,y:c.y+m*y+f*b},{x:c.x+f*x-m*b,y:c.y+m*x+f*b},{x:c.x+f*x+m*b,y:c.y+m*x-f*b},{x:c.x+f*y+m*b,y:c.y+m*y-f*b}];if(!d.every(M=>dt(e,M.x,M.y)))continue;let g=o?.[i]?.belowY,S=g==null?0:s.y-g,_=!!r&&S>.03&&S<=.65;if(_&&r){let M=(R,w)=>Math.hypot((R.x+w.x)/2-r.x,(R.y+w.y)/2-r.y);M(d[0],d[1])>M(d[3],d[2])&&(d=[d[3],d[2],d[1],d[0]])}let I=_?Math.ceil((S-1e-8)/.2):1,A=(M,R,w)=>({x:M.x+(R.x-M.x)*w,y:M.y+(R.y-M.y)*w});for(let M=0;M<I;M++){let R=M/I,w=(M+1)/I,T=[A(d[0],d[3],R),A(d[1],d[2],R),A(d[1],d[2],w),A(d[0],d[3],w)],k=s.y+.008-(_?S*(1-w):0);if(K(t,T,void 0,()=>k,k-(_?S/I+.1:.16),a,[.43,.47,.46],Y),!_)continue;let D=Math.hypot(T[3].x-T[0].x,T[3].y-T[0].y)*P,B=Math.min(.04/D,.25),E=A(T[0],T[3],B),C=A(T[1],T[2],B),v=F=>[F.x*P,k+.004,F.y*P],O=[.66,.59,.39];t.tri(v(T[0]),v(T[1]),v(C),[0,1,0],O),t.tri(v(T[0]),v(C),v(E),[0,1,0],O)}}}}function dr(t,n,e,r,o,a,i,s,u=!1){if(!n.outline||n.outline.length<3)return;let c=e.baseHeightM,l=e.objects.filter(d=>d.type==="shape"&&(d.role==="entrance"||d.role==="exit")),f=je(r,s.tierTop);if(!o)return;let m=d=>o.deckAt(d.x,d.y),p=io(n,i),h=p[0]??n.outline;if(o.rowLevels.length>=2){let d=An(o.rowLevels),g=so(Je(o.rowLevels,e.focal,d),p),S=yr(me(o.rowLevels,e.focal,c),e.focal,le);for(let I of g){let A=Math.max(c,I.topY-xr);for(let M of a.subtract(I.outline,A))ar(t,M,I.holes,A,c,s.tierTop,s.tierWall,l,!u,S)}g.length||K(t,h,n.holes,()=>o.landingY,c,f,s.tierWall,Y);let _={tread:[f[0]*Y.top,f[1]*Y.top,f[2]*Y.top],riser:[f[0]*.72,f[1]*.72,f[2]*.72]};for(let I of p.length?p:[h])no(t,o.rowLevels,e.focal,o.landingY,_,I,d);hr(t,o.rowLevels,e.focal,c),pr(t,o.rowLevels,n.outline,e.focal,d);return}let y=o.flat?1/0:Eo,x=d=>o.normalAt(d.x,d.y),b=o.flat?o.landingY:void 0;for(let d of a.subtract(h,b))K(t,d,n.holes,m,c,f,s.tierWall,Y,y,x)}function Xa(t,n,e){let r=new Set;for(let i of t.objects)i.type==="section"&&r.add(i.id);let o=new Map;for(let i=0;i<n.length;i++){let s=e.seatOwner[i];if(!s||!r.has(s))continue;let u=e.bySection.get(s);if(u&&u.rowLevels.length>=2)continue;let c=n[i];if(c.kind==="booth")continue;let l=o.get(s);l||(l=new Map,o.set(s,l));let f=c.rowId||`__seat-${i}`,m=l.get(f);m||(m={pts:[],levelM:0,n:0},l.set(f,m)),m.pts.push({x:c.x,y:c.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 c=s.rowLevels.filter(l=>!l.patch).map(l=>({pts:l.pts,levelM:l.y}));c.length>=2&&a.push({sectionId:i.id,rows:c});continue}let u=o.get(i.id);u&&a.push({sectionId:i.id,rows:[...u.values()].map(c=>({pts:c.pts,levelM:c.levelM/c.n}))})}return a}function ja(t,n){let e=1/0;for(let r=0;r<n.length;r++){let o=n[r],a=n[(r+1)%n.length],i=a.x-o.x,s=a.y-o.y,u=Math.max(0,Math.min(1,((t.x-o.x)*i+(t.y-o.y)*s)/(i*i+s*s||1)));e=Math.min(e,Math.hypot(t.x-o.x-u*i,t.y-o.y-u*s))}return e}var xr=.02;function Ua(t,n){let e=t.objects.filter(r=>r.type==="section"&&!!r.outline&&r.outline.length>=3).flatMap(r=>{let o=n.bySection.get(r.id);if(!o)return[];let a=1/0,i=-1/0,s=1/0,u=-1/0;for(let l of r.outline)l.x<a&&(a=l.x),l.x>i&&(i=l.x),l.y<s&&(s=l.y),l.y>u&&(u=l.y);let c=o.landingY;for(let l of o.rowLevels)c=Math.min(c,l.y-xr);return[{outline:r.outline,holes:r.holes,surface:o,floorTop:c,minX:a,maxX:i,minY:s,maxY:u}]});return(r,o,a)=>{let i=null;for(let s of e){if(r<s.minX-a||r>s.maxX+a||o<s.minY-a||o>s.maxY+a)continue;let u={x:r,y:o};if(!wt(u,s.outline,s.holes)&&ja(u,s.outline)>a)continue;let c=Math.min(s.surface.deckAt(r,o),s.floorTop);(i===null||c<i)&&(i=c)}return i}}var Wa=3,Ya=.4;function br(t,n,e,r,o,a,i=!0){let s=Xa(n,e,r);if(s.length<Wa)return;let u=Te(s,n.focal);if(!u)return;let c=Math.max(0,...u.rings.map(l=>l.arcs.reduce((f,m)=>f+m.binCount,0)))/u.binCount;t.setMaterial(5),lr(t,u,{bottomY:n.baseHeightM,tierFrontLevels:s.map(l=>Math.min(...l.rows.map(f=>f.levelM))),colors:{bandTop:Z(o.tierTop,.8),bandWall:o.tierWall,shellTop:a??Z(o.tierWall,1.15),shellWall:a??o.tierWall},ao:Y,shapes:n.objects.filter(l=>l.type==="shape"),deriveShell:i&&c>=Ya,standTopNear:Ua(n,r)}),t.setMaterial(0)}function gr(t){let{doc:n,units:e,seats:r,surfaces:o,solids:a,hintedSeatFloor:i,seatFloor:s}=t,u=[];{let c=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 p=Math.max(0,Math.min(e.length-1,Math.round(a.floor[m]))),h=m*3,y=c[p];y.minX=Math.min(y.minX,a.position[h]),y.minY=Math.min(y.minY,a.position[h+1]),y.minZ=Math.min(y.minZ,a.position[h+2]),y.maxX=Math.max(y.maxX,a.position[h]),y.maxY=Math.max(y.maxY,a.position[h+1]),y.maxZ=Math.max(y.maxZ,a.position[h+2])}let l=new Map;for(let m=0;m<e.length;m++)for(let p of e[m].objects)p.type==="section"&&l.set(p.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<r.length;m++){let p=o.seatOwner[m],h=(p!==null?l.get(p):void 0)??i[m];if(h===void 0)continue;let y=f[h],x=r[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 b=o.seatDeckY(m);y.sumX+=x.x*P,y.sumDeck+=b,y.sumZ+=x.y*P,y.minDeck=Math.min(y.minDeck,b),y.maxDeck=Math.max(y.maxDeck,b+1.6),s[m]=h}for(let m=0;m<e.length;m++){let p=f[m],h=n.floors?.[m],y=c[m],x=Math.min(p.n?p.minX*P:e[m].focal.x*P-1,Number.isFinite(y.minX)?y.minX:1/0),b=Math.max(p.n?p.maxX*P:e[m].focal.x*P+1,Number.isFinite(y.maxX)?y.maxX:-1/0),d=Math.min(p.n?p.minY*P:e[m].focal.y*P-1,Number.isFinite(y.minZ)?y.minZ:1/0),g=Math.max(p.n?p.maxY*P:e[m].focal.y*P+1,Number.isFinite(y.maxZ)?y.maxZ:-1/0),S=Math.min(p.n?Math.min(e[m].baseHeightM,p.minDeck):e[m].baseHeightM,Number.isFinite(y.minY)?y.minY:1/0),_=Math.max(p.n?Math.max(p.maxDeck,S+.5):S+.5,Number.isFinite(y.maxY)?y.maxY:-1/0),I=[p.n?p.sumX/p.n:(x+b)/2,p.n?p.sumDeck/p.n:(S+_)/2,p.n?p.sumZ/p.n:(d+g)/2],A=Math.max(1,.5*Math.hypot(b-x,_-S,g-d));u.push({index:m,id:h?.id??`floor-${m}`,label:h?.name??(e.length>1?`Floor ${m+1}`:"Venue"),seatCount:p.n,center:I,radius:A,box:{min:[x,S,d],max:[b,_,g]},focalWorld:[e[m].focal.x*P,e[m].baseHeightM+1.5,e[m].focal.y*P]})}}return u}function he(t,n){let e=1/0,r=1/0,o=-1/0,a=-1/0,i=(s,u)=>{s<e&&(e=s),u<r&&(r=u),s>o&&(o=s),u>a&&(a=u)};for(let s of n)i(s.x,s.y);for(let s of t)for(let u of s.objects)if(u.type==="section")for(let c of u.outline)i(c.x,c.y);else if(u.type==="shape"&&u.points)for(let c of u.points)i(c.x,c.y);else if(u.type==="gaArea")for(let c of u.points)i(c.x,c.y);else if(u.type==="booth"){let c=At(u);if(c)for(let l of c)i(l.x,l.y)}else if(u.type==="table"){let c=Ln(u);if(c)for(let l of c)i(l.x,l.y)}else if(u.type==="decorImage"){let c=vn(u);if(c)for(let l of c)i(l.x,l.y)}return Number.isFinite(e)||(e=-100,r=-100,o=100,a=100),{minX:e,minY:r,maxX:o,maxY:a}}function Ar(t,n,e,r,o,a,i){if(n.length===1){let s=e.map(m=>({x:m.x,y:m.y}));for(let m of n[0].objects)m.type==="section"?s.push(...m.outline):m.type==="shape"?s.push(...it(m)??m.points??[]):m.type==="gaArea"?s.push(...m.points):m.type==="booth"?s.push(...At(m)??[]):m.type==="table"?s.push(...Ln(m)??[]):m.type==="decorImage"&&s.push(...vn(m)??[]);if(Sr(t,n[0],e,a)||Ir(t,n[0],e,s,a))return!1;if(i&&Pr(t,n[0].baseHeightM,s,a,i))return!0;let u=cn(s),c=(o.minX+o.maxX)/2,l=(o.minY+o.maxY)/2,f=u.length>=3?u.map(m=>{let p=m.x-c,h=m.y-l,y=Math.max(1,Math.hypot(p,h));return{x:m.x+p/y*80,y:m.y+h/y*80}}):rn(o.minX-28,o.minY-28,o.maxX-o.minX+56,o.maxY-o.minY+56);return K(t,f,void 0,()=>-.04,-.22,a.ground,a.ground,Y),!1}else{let s=n.reduce((x,b)=>b.baseHeightM<x.baseHeightM?b:x);t.setFloor(s.index);let u={...s,objects:n.flatMap(x=>x.objects)},c=e.map(x=>({x:x.x,y:x.y}));for(let x of u.objects)x.type==="section"&&c.push(...x.outline);if(Sr(t,u,e,a)||Ir(t,u,e,c,a))return!1;if(i&&Pr(t,s.baseHeightM,c,a,i))return!0;let l=e.filter((x,b)=>r[b]===s.index),f=he([s],l),m=Math.hypot(f.maxX-f.minX,f.maxY-f.minY),p=Math.max(28,Math.min(80,m*.04)),h=rn(f.minX-p,f.minY-p,f.maxX-f.minX+p*2,f.maxY-f.minY+p*2),y=s.baseHeightM-.03;return K(t,h,void 0,()=>y,y-.22,a.ground,a.ground,Y),!1}}function ye(t,n,e,r){let{cx:o,cz:a,radius:i}=e,s=1/0,u=1/0,c=1/0,l=-1/0,f=-1/0,m=-1/0,p=(x,b,d)=>{s=Math.min(s,x),l=Math.max(l,x),u=Math.min(u,b),f=Math.max(f,b),c=Math.min(c,d),m=Math.max(m,d)};for(let x=0;x<t.position.length;x+=3){let b=x/3;r&&b>=r[0]&&b<r[1]||p(t.position[x],t.position[x+1],t.position[x+2])}for(let x=0;x<n.count;x++){let b=x*3,d=n.iPosition[b],g=n.iPosition[b+1],S=n.iPosition[b+2],_=Math.max(.35,n.iMaxRadius[x]??.35);p(d-_,g,S-_),p(d+_,g+1.6,S+_)}Number.isFinite(s)||(s=o-i,l=o+i,u=0,f=i*.16,c=a-i,m=a+i);let h=[(s+l)/2,(u+f)/2,(c+m)/2],y=Math.max(1,.5*Math.hypot(l-s,f-u,m-c));return{center:h,radius:y,minY:u,maxY:f}}var za=4096;function _r(t,n,e=[]){let r=Math.max(1,Math.ceil(t.count/za)),o=Math.ceil(t.count/r),a=new Float32Array((o*2+n.length*4+e.length)*3),i=0;for(let s=0;s<t.count;s+=r){let u=t.iPosition[s*3],c=t.iPosition[s*3+1],l=t.iPosition[s*3+2];a[i++]=u,a[i++]=c,a[i++]=l,a[i++]=u,a[i++]=0,a[i++]=l}for(let[s,u,c]of e)a[i++]=s,a[i++]=u,a[i++]=c;for(let s of n)for(let[u,c]of[[-1,-1],[1,-1],[1,1],[-1,1]])a[i++]=s.cx+u*s.halfX,a[i++]=s.y,a[i++]=s.cz+c*s.halfZ;return a.subarray(0,i)}function wr(t,n,e,r,o,a,i=[]){let s=1/0,u=1/0,c=-1/0,l=-1/0;for(let _=0;_<t.count;_++){let I=_*3,A=t.iPosition[I],M=t.iPosition[I+2];A<s&&(s=A),A>c&&(c=A),M<u&&(u=M),M>l&&(l=M)}for(let[_,,I]of i)_<s&&(s=_),_>c&&(c=_),I<u&&(u=I),I>l&&(l=I);for(let _ of n)s=Math.min(s,_.cx-_.halfX),c=Math.max(c,_.cx+_.halfX),u=Math.min(u,_.cz-_.halfZ),l=Math.max(l,_.cz+_.halfZ);let f=e.minX*P,m=e.maxX*P,p=e.minY*P,h=e.maxY*P,y=f,x=m,b=p,d=h;if(Number.isFinite(s)){let _=Math.max(2,.06*Math.hypot(c-s,l-u));y=Math.max(f,s-_),x=Math.min(m,c+_),b=Math.max(p,u-_),d=Math.min(h,l+_)}let g=Math.min(0,r),S=Math.max(o,a*.05);return{min:[y,g,b],max:[x,S,d]}}var Mr=12,Va=.6,Ka=40;function Pr(t,n,e,r,o){let a=cn([...e]);if(a.length<3)return!1;let i=1/0,s=1/0,u=-1/0,c=-1/0;for(let S of a)i=Math.min(i,S.x),u=Math.max(u,S.x),s=Math.min(s,S.y),c=Math.max(c,S.y);let l=Math.hypot(u-i,c-s)*P,f=Rt(a,Mr/P,1.2),m=Math.max(Ka,l*Va),p=Rt(a,(Mr+m)/P,1.2);if(f.length!==p.length)return!1;let h=et(r.ground,[.78,.76,.72],.35),y=et(r.ground,[.56,.62,.52],.3);K(t,f,void 0,()=>n-.04,n-.22,h,h,Y);let x=n-.05,b=f.map(S=>[S.x*P,x,S.y*P]),d=p.map(S=>[S.x*P,x,S.y*P]),g=[0,1,0];for(let S=0;S<b.length;S++){let _=(S+1)%b.length;t.tri(b[S],d[_],d[S],g,y,o,o),t.tri(b[S],b[_],d[_],g,y,y,o)}return!0}function Sr(t,n,e,r){let o=Kt(n,e);if(!o)return!1;let a=n.baseHeightM,i=et(r.ground,[.62,.55,.47],.4);return K(t,o,void 0,()=>a-.04,a-.22,i,i,Y),!0}var Za=3e3,qa=20,Rr=1.5,$a=1.2,Qa=.25;function Ir(t,n,e,r,o){if(!e.length||e.length>Za||r.length<3)return!1;for(let R of n.objects){if(R.type==="shape"&&bn(R.stageKind))return!1;if(R.type==="section"){let{height:w}=Wt(R,{floorBaseHeightM:n.baseHeightM});if(w-n.baseHeightM>qa)return!1}}let a=0,i=0;for(let R of r)a+=R.x,i+=R.y;a/=r.length,i/=r.length;let s=0,u=0,c=0;for(let R of r){let w=R.x-a,T=R.y-i;s+=w*w,u+=T*T,c+=w*T}let l=.5*Math.atan2(2*c,s-u),f=Math.cos(l),m=Math.sin(l),p=-m,h=f,y=1/0,x=-1/0,b=1/0,d=-1/0;for(let R of r){let w=(R.x-a)*f+(R.y-i)*m,T=(R.x-a)*p+(R.y-i)*h;y=Math.min(y,w),x=Math.max(x,w),b=Math.min(b,T),d=Math.max(d,T)}let g=R=>[[y-R,b-R],[x+R,b-R],[x+R,d+R],[y-R,d+R]].map(([w,T])=>({x:a+f*w+p*T,y:i+m*w+h*T})),S=g(Rr/P),_=g((Rr+Qa)/P),I=n.baseHeightM,A=et(o.ground,[.62,.55,.47],.4),M=et(o.ground,[.86,.86,.84],.55);return K(t,_,void 0,()=>I-.04,I-.22,A,A,Y),K(t,_,[S.slice().reverse()],()=>I+$a,I-.04,et(M,[1,1,1],.2),M,Y),!0}function Er(t,n,e){let r=()=>({byObjectId:new Map,elements:[]});if(!n||!t)return r();let o=de(n);if(!o.ok||o.value.id!==t)return r();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,u=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]})),c=[];for(let f of o.value.overlay.productionElements??[]){let m=a.get(f.objectId),p=m?it(m.shape):null,h=f.baseElevationM??0;if(!m||!p||p.length<3||!f.id||i.has(f.id)||s.has(f.objectId)||!Number.isFinite(f.heightM)||f.heightM<.05||f.heightM>50||!Number.isFinite(h)||h<-10||h>100)return r();i.add(f.id),s.add(f.objectId);let y=p.map(M=>M.x*P),x=p.map(M=>M.y*P),b=m.unit.baseHeightM+h,d=Math.min(...y),g=Math.max(...y),S=Math.min(...x),_=Math.max(...x),I,A=u.get(f.id)??f.contentImageUrl;if(f.kind==="screen"&&A&&(I=Ro(p,b,b+f.heightM,m.unit.focal),!I))if(g-d>=_-S){let M=Math.abs(S-m.unit.focal.y*P)<=Math.abs(_-m.unit.focal.y*P)?S-.006:_+.006;I=[[d,b,M],[g,b,M],[d,b+f.heightM,M],[g,b+f.heightM,M]]}else{let M=Math.abs(d-m.unit.focal.x*P)<=Math.abs(g-m.unit.focal.x*P)?d-.006:g+.006;I=[[M,b,S],[M,b,_],[M,b+f.heightM,S],[M,b+f.heightM,_]]}c.push({id:f.id,objectId:f.objectId,kind:f.kind,floorIndex:m.unit.index,baseY:b,topY:b+f.heightM,bounds:{min:[d,b,S],max:[g,b+f.heightM,_]},occlusion:f.occlusion,...A?{contentImageUrl:A}:{},...I?{contentPlane:I}:{}})}let l=c.sort((f,m)=>f.id.localeCompare(m.id));return{byObjectId:new Map(l.map(f=>[f.objectId,f])),elements:l}}var Br=[.13,.14,.17],Jt=[.4,.43,.47],Ja=.18,tc=.02,nc=2.4,ec=1500,oc=240;function Tr(t,n,e,r){let o=n.stageKind??"";if(Yt(o)||o==="round"||!r.length)return;let a=it(n);if(!a||a.length<3)return;let i={x:a.reduce((E,C)=>E+C.x,0)/a.length,y:a.reduce((E,C)=>E+C.y,0)/a.length},s=0,u=0,c=new Set;for(let E of r)s+=E.x,u+=E.y,c.add(Math.floor(Math.atan2(E.y-i.y,E.x-i.x)*180/Math.PI/10));if(c.size*10>oc)return;let l=i.x-s/r.length,f=i.y-u/r.length,m=Math.hypot(l,f);if(m<1e-6)return;let p=l/m,h=f/m,y=-h,x=p,b=-1/0,d=1/0,g=1/0,S=-1/0;for(let E of a){let C=(E.x-i.x)*p+(E.y-i.y)*h,v=(E.x-i.x)*y+(E.y-i.y)*x;b=Math.max(b,C),d=Math.min(d,C),g=Math.min(g,v),S=Math.max(S,v)}let _=(S-g)*P,I=(b-d)*P;if(_<3||I<1.5||_*I>ec)return;let A=Ja/P,M=(E,C)=>({x:i.x+p*E+y*C,y:i.y+h*E+x*C}),R=(E,C,v,O)=>[M(E,v),M(E,O),M(C,O),M(C,v)],w=e+Math.max(3.5,Math.min(8,_*.35)),T=e+Math.min(nc,w-e-1),k=.2/P,D=d+Math.min(I*.25,1.5)/P,B=tc/P;K(t,R(b-2*A+B,b-A-B,g+A+k,S-A-k),void 0,()=>T,e,Br,Br,Y);for(let[E,C]of[[g+A,g+A+k],[S-A-k,S-A]])K(t,R(b-2*A,b-A,E,C),void 0,()=>w+.3,e,Jt,Jt,Y),K(t,R(D+k,b-2*A,E,C),void 0,()=>w+.3,w,Jt,Jt,Y);K(t,R(D,D+k,g+A,S-A),void 0,()=>w+.3,w,Jt,Jt,Y)}function gt(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function bt(t){return Array.isArray(t)?t:[]}function rc(t){let n=[t];for(;n.length;){let e=n.pop();if(Array.isArray(e)){n.push(...e);continue}if(!gt(e))continue;let r=gt(e.extensions)?e.extensions:null;if(r&&Object.prototype.hasOwnProperty.call(r,"KHR_draco_mesh_compression"))return!0;n.push(...Object.values(e))}return!1}function Dn(t,n){return!Array.isArray(t)||t.length!==n||!t.every(e=>typeof e=="number"&&Number.isFinite(e))?null:t}function ic(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function sc(t,n){let e=new Array(16).fill(0);for(let r=0;r<4;r++)for(let o=0;o<4;o++)for(let a=0;a<4;a++)e[r*4+o]+=t[a*4+o]*n[r*4+a];return e}function ac(t){let n=Dn(t.matrix,16);if(n)return n;if(t.matrix!==void 0)return null;let e=t.translation===void 0?[0,0,0]:Dn(t.translation,3),r=t.rotation===void 0?[0,0,0,1]:Dn(t.rotation,4),o=t.scale===void 0?[1,1,1]:Dn(t.scale,3);if(!e||!r||!o)return null;let[a,i,s,u]=r,c=Math.hypot(a,i,s,u);if(!(c>1e-8))return null;let l=a/c,f=i/c,m=s/c,p=u/c,h=l+l,y=f+f,x=m+m,b=l*h,d=l*y,g=l*x,S=f*y,_=f*x,I=m*x,A=p*h,M=p*y,R=p*x;return[(1-(S+I))*o[0],(d+R)*o[0],(g-M)*o[0],0,(d-R)*o[1],(1-(b+I))*o[1],(_+A)*o[1],0,(g+M)*o[2],(_-A)*o[2],(1-(b+S))*o[2],0,e[0],e[1],e[2],1]}function cc(t,n,e,r){return[t[0]*n+t[4]*e+t[8]*r+t[12],t[1]*n+t[5]*e+t[9]*r+t[13],t[2]*n+t[6]*e+t[10]*r+t[14]]}function lc(t){let n=t[0],e=t[4],r=t[8],o=t[1],a=t[5],i=t[9],s=t[2],u=t[6],c=t[10],l=a*c-i*u,f=i*s-o*c,m=o*u-a*s,p=n*l+e*f+r*m;if(Math.abs(p)<1e-12)return null;let h=1/p;return[l*h,f*h,m*h,(r*u-e*c)*h,(n*c-r*s)*h,(e*s-n*u)*h,(e*i-r*a)*h,(r*o-n*i)*h,(n*a-e*o)*h]}function Or(t,n,e,r){let o=t[0]*n+t[1]*e+t[2]*r,a=t[3]*n+t[4]*e+t[5]*r,i=t[6]*n+t[7]*e+t[8]*r,s=Math.hypot(o,a,i)||1;return o/=s,a/=s,i/=s,[o,a,i]}function uc(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,r=null,o=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&&!r)try{let u=JSON.parse(new TextDecoder().decode(s).replace(/[\u0000 ]+$/g,""));if(!gt(u))return null;r=u}catch{return null}else if(i===5130562&&!o)o=s;else return null;e+=a}return e===t.byteLength&&r&&o?{json:r,bin:o}:null}function fc(t){return t===5120||t===5121?1:t===5122||t===5123?2:t===5125||t===5126?4:0}function mc(t){return t==="SCALAR"?1:t==="VEC2"?2:t==="VEC3"?3:t==="VEC4"?4:0}function hc(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 yc(t){let n=t instanceof Uint8Array?t:new Uint8Array(t),e=uc(n);if(!e)return{ok:!1,issue:"invalid_glb"};let{json:r,bin:o}=e;if(!gt(r.asset)||r.asset.version!=="2.0")return{ok:!1,issue:"unsupported_glb"};let a=bt(r.extensionsUsed).filter(S=>typeof S=="string");if(a.includes("KHR_draco_mesh_compression")||rc(r))return{ok:!1,issue:"draco_not_allowed"};if(a.length||bt(r.extensionsRequired).length)return{ok:!1,issue:"unsupported_glb"};if(bt(r.images).length||bt(r.textures).length)return{ok:!1,issue:"external_resource"};let i=bt(r.buffers);if(i.length!==1||!gt(i[0])||i[0].uri!==void 0||typeof i[0].byteLength!="number"||!Number.isInteger(i[0].byteLength)||i[0].byteLength<0||i[0].byteLength>o.byteLength)return{ok:!1,issue:"external_resource"};let s=bt(r.accessors),u=bt(r.bufferViews),c=bt(r.meshes),l=bt(r.nodes),f=bt(r.scenes),m=typeof r.scene=="number"?r.scene:0;if(!gt(f[m]))return{ok:!1,issue:"unsupported_glb"};let p=new DataView(o.buffer,o.byteOffset,o.byteLength),h=(S,_,I)=>{if(typeof S!="number"||!Number.isInteger(S)||!gt(s[S]))return null;let A=s[S];if(A.type!==_||A.sparse!==void 0||A.normalized===!0||typeof A.count!="number"||!Number.isInteger(A.count)||A.count<1||typeof A.componentType!="number"||!I.includes(A.componentType)||typeof A.bufferView!="number")return null;let M=u[A.bufferView];if(!gt(M)||M.buffer!==0||typeof M.byteLength!="number"||!Number.isInteger(M.byteLength)||M.byteLength<0)return null;let R=mc(A.type),w=fc(A.componentType),T=typeof M.byteStride=="number"?M.byteStride:R*w,k=typeof M.byteOffset=="number"?M.byteOffset:0,D=typeof A.byteOffset=="number"?A.byteOffset:0,B=k+D,E=D+(A.count-1)*T+R*w;if(!Number.isInteger(T)||!Number.isInteger(k)||!Number.isInteger(D)||T<R*w||k<0||D<0||k+M.byteLength>o.byteLength||E>M.byteLength)return null;let C=[];for(let v=0;v<A.count;v++){let O=[];for(let F=0;F<R;F++){let L=hc(p,B+v*T+F*w,A.componentType);if(!Number.isFinite(L))return null;O.push(L)}C.push(O)}return C},y=[],x=[],b=0,d=new Set,g=(S,_)=>{if(typeof S!="number"||!Number.isInteger(S)||!gt(l[S])||d.has(S))return!1;d.add(S);let I=l[S],A=ac(I);if(!A)return!1;let M=sc(_,A),R=lc(M);if(!R)return!1;if(I.mesh!==void 0){if(typeof I.mesh!="number")return!1;let w=c[I.mesh];if(!gt(w))return!1;for(let T of bt(w.primitives)){if(!gt(T)||T.mode!==void 0&&T.mode!==4||!gt(T.attributes))return!1;let k=h(T.attributes.POSITION,"VEC3",[5126]),D=T.attributes.NORMAL===void 0?null:h(T.attributes.NORMAL,"VEC3",[5126]);if(!k||T.attributes.NORMAL!==void 0&&!D)return!1;let B=k.length;if(T.indices!==void 0){let C=typeof T.indices=="number"?s[T.indices]:null;B=gt(C)?C.count:void 0}if(typeof B!="number"||!Number.isInteger(B)||B%3!==0||(b+=B/3,b>1e5))return!1;let E=T.indices===void 0?k.map((C,v)=>[v]):h(T.indices,"SCALAR",[5121,5123,5125]);if(!E||E.length%3!==0||E.length!==B)return!1;for(let C=0;C<E.length;C+=3){let v=[E[C][0],E[C+1][0],E[C+2][0]];if(v.some(L=>!Number.isInteger(L)||L<0||L>=k.length))return!1;let O=v.map(L=>cc(M,...k[L])),F=null;if(!D){let L=O[1][0]-O[0][0],H=O[1][1]-O[0][1],j=O[1][2]-O[0][2],U=O[2][0]-O[0][0],X=O[2][1]-O[0][1],W=O[2][2]-O[0][2];F=Or([1,0,0,0,1,0,0,0,1],H*W-j*X,j*U-L*W,L*X-H*U)}for(let L=0;L<3;L++)y.push(...O[L]),x.push(...D?Or(R,...D[v[L]]):F)}}}for(let w of bt(I.children))if(!g(w,M))return!1;return d.delete(S),!0};for(let S of bt(f[m].nodes))if(!g(S,ic()))return{ok:!1,issue:b>1e5?"triangle_limit":"unsupported_glb"};return!b||y.length!==b*9||x.length!==y.length?{ok:!1,issue:"unsupported_glb"}:{ok:!0,triangleCount:b,position:new Float32Array(y),normal:new Float32Array(x)}}function Cr(t){try{return yc(t)}catch{return{ok:!1,issue:"invalid_glb"}}}function Km(t){let{doc:n}=t,e=er(n.theme),r=e.structure,o=ro(n,t.eventConfigurationId??n.eventConfigurationId),a=Er(t.eventConfigurationId,t.eventConfiguration,o),i=t.seats,s=new Sn,u=null;if(t.registeredShellGlb){let N=Cr(t.registeredShellGlb);if(N.ok){let G=N.position.length/3,V=new Float32Array(N.position.length),at=e.materials.shell??r.tierWall;for(let ft=0;ft<G;ft++){let ht=N.normal[ft*3+1],rt=ht<-.25?.4:.62+.38*Math.max(0,ht);V[ft*3]=at[0]*rt,V[ft*3+1]=at[1]*rt,V[ft*3+2]=at[2]*rt}u={position:N.position,normal:N.normal,color:V,floor:new Float32Array(G).fill(-2),material:new Float32Array(G),count:G}}}let c=new Map;for(let N of o)for(let G of N.objects)c.set(G.id,N.index),G.type==="section"&&c.set(G.logicalSectionId??G.id,N.index);let l=i.map(N=>c.get(N.sectionId??"")??c.get(N.rowId??"")??0),f=he(o,i),m=s.vertexCount,h=Ar(s,o,i,l,f,r,et(e.background.top,e.background.bottom,.5))?s.vertexCount:m,y=Ue(n,i),x=new Map,b=new Map;for(let N of n.categories??[])x.set(N.key,N.color),N.seatGlyph&&b.set(N.key,N.seatGlyph);let d=[],g=Bo(o,i,l),S=new Map;i.forEach((N,G)=>{let V=g.seatDeckY(G);Number.isFinite(V)&&S.set(N.rowId,Math.min(S.get(N.rowId)??1/0,V))});let _=new Float32Array(i.length),I=[],A=new Map((n.floors??[]).map((N,G)=>[N.id,G])),M=o.map(()=>[]);for(let N of i){let G=N.floorId?A.get(N.floorId)??0:0;M[Math.min(G,M.length-1)]?.push(N)}let R=(N,G)=>{if(!G||G.length<3)return!1;let V=Math.min(...G.map(rt=>rt.x)),at=Math.max(...G.map(rt=>rt.x)),ft=Math.min(...G.map(rt=>rt.y)),ht=Math.max(...G.map(rt=>rt.y));for(let rt=0;rt<N;rt++)for(let ct of M[rt])if(!(ct.x<V||ct.x>at||ct.y<ft||ct.y>ht)&&wt(ct,G,void 0))return!0;return!1},w=null,T=N=>o.length===1?i:i.filter((G,V)=>l[V]===N),k=(N,G)=>{let V=At(N);if(!V)return!1;let at=1/0,ft=1/0,ht=-1/0,rt=-1/0;for(let ct of V)at=Math.min(at,ct.x),ht=Math.max(ht,ct.x),ft=Math.min(ft,ct.y),rt=Math.max(rt,ct.y);return i.some((ct,_t)=>ct.kind!=="booth"&&(o.length===1||l[_t]===G)&&ct.x>at&&ct.x<ht&&ct.y>ft&&ct.y<rt&&dt(V,ct.x,ct.y))},D;for(let N=0;N<o.length;N++){let G=o[N];s.setFloor(N);let V=Kt(G,T(N)),at=0;if(V){let z=0;for(let ut of G.objects)if(ut.type==="section")for(let mt of g.bySection.get(ut.id)?.rowLevels??[])z=Math.max(z,mt.y-G.baseHeightM);if(at=uo(z),!D){let ut=fo(V);D={centre:[ut.x*P,ut.y*P]}}}let ft=new _n,ht=[],rt=G.objects.filter(z=>z.type==="shape"&&(z.role==="entrance"||z.role==="exit")),ct=G.objects.filter(z=>z.type==="section"&&!!z.outline&&z.outline.length>=3),_t=ir(G.objects.filter(z=>z.type==="booth"),G.focal);for(let z of G.objects)if(z.type==="section"){let ut=s.vertexCount;dr(s,z,G,We(z,y),g.bySection.get(z.id),ft,ct,r,N>0&&R(N,z.outline));let mt=s.vertexCount-ut;mt>0&&I.push({sectionId:z.id,start:ut,count:mt})}else if(z.type==="shape"){let ut=a.byObjectId.get(z.id),mt=d.length,Nt=V!==null&&z.role==="wall"&&!ut;s.setMaterial(Nt?lo:(ut?.kind??z.role)==="screen"?1:0);let Gt=z.role==="stage"&&!ut?sr(z,T(N)):Nt&&z.heightM===void 0?{...z,heightM:at}:z,kt=ao(Gt,ht);if(zo(s,Gt,G.baseHeightM+kt.supportOffsetM,kt.topOffsetM-kt.supportOffsetM,r,G.focal,d,ut,rt),s.setMaterial(0),z.role==="stage"&&!ut&&d.length>mt&&(w??N)===N){w=N;let Ft=n.floors?.[N]?.id,tn=o.length>1&&Ft?i.filter(pn=>pn.floorId===Ft):i;Tr(s,Gt,d[d.length-1].y,tn)}}else z.type==="gaArea"?Ko(s,z,G.baseHeightM,ot(x.get(z.categoryKey)),r):z.type==="booth"?Uo(s,z,G.baseHeightM,ot(x.get(z.categoryKey)),r,_t.get(z.id)??G.focal,k(z,N)):z.type==="table"?Yo(s,z,Math.max(G.baseHeightM,S.get(z.id)??G.baseHeightM),ot(z.fill??n.theme?.decorFill??"#232c40"),r,!!(z.fill??n.theme?.decorFill)):z.type==="decorImage"&&Vo(s,z,G.baseHeightM,r);br(s,G,i,g,r,e.materials.shell,!u)}let B=o.length>1?{x:o.reduce((N,G)=>N+G.focal.x,0)/o.length,y:o.reduce((N,G)=>N+G.focal.y,0)/o.length}:n.focalPoint??{x:(f.minX+f.maxX)/2,y:(f.minY+f.maxY)/2},E=Le(u?[s.build(),u]:[s.build()]),C=He(i,t.initialState,g,_,x,b),v=$o({doc:n,units:o,seats:i,surfaces:g,focal:B}),{labels:O,sections:F,rows:L}=Qo({doc:n,units:o,seats:i,surfaces:g,seatData:C,hintedSeatFloor:l,zones:v,focal:B}),H=new Map(F.map((N,G)=>[N.id,G]));g.seatOwner.forEach((N,G)=>{C.iSection[G]=N?H.get(N)??-1:-1});let j=gr({doc:n,units:o,seats:i,surfaces:g,solids:E,hintedSeatFloor:l,seatFloor:_});Jo(O,j),C.iYaw=Ge(C.iPosition,i.length,N=>i[N].rowId,N=>{let G=o[_[N]]?.focal??B;return[G.x*P,G.y*P]});let U=(f.minX+f.maxX)/2*P,X=(f.minY+f.maxY)/2*P,W=.5*Math.hypot((f.maxX-f.minX)*P,(f.maxY-f.minY)*P)||10,Q=ye(E,C,{cx:U,cz:X,radius:W},[m,h]),tt=ye(E,C,{cx:U,cz:X,radius:W}),q=pc(o),st=wr(C,d,f,Q.minY,Q.maxY,W,q);return{sharedAisles:tr(o.flatMap(N=>N.objects.flatMap(G=>{if(G.type!=="section")return[];let V=g.bySection.get(G.id);return V?[{sectionId:G.id,floorIndex:N.index,rows:V.rowLevels}]:[]}))),solids:E,sectionSolidRanges:I,seats:C,seatSectionIds:g.seatOwner,bounds:{center:[(st.min[0]+st.max[0])/2,(st.min[1]+st.max[1])/2,(st.min[2]+st.max[2])/2],radius:W,groundY:0,box:st,fitPoints:_r(C,d,q)},...D?{room:D}:{},...!D&&o.some(N=>N.objects.some(G=>G.type==="shape"&&bn(G.stageKind)))?{outdoor:!0}:{},renderBounds:{center:Q.center,radius:Q.radius},clipBounds:{center:tt.center,radius:tt.radius},stateColorLUT:or(e,sn),theme:e,seatCount:i.length,focalWorld:[B.x*P,1.5,B.y*P],zones:v,stages:d,productionElements:a.elements,sections:F,rows:L,labels:O,floors:j}}function pc(t){let n=[];for(let e of t)for(let r of e.objects){let o=r.type==="gaArea"?r.points:r.type==="booth"?At(r):null;for(let a of o??[])n.push([a.x*P,e.baseHeightM,a.y*P])}return n}function dc(t,n){let{doc:e,report:r}=So(t),o=r.confident&&(r.sections.length>0||!!r.looseRowBlocks);if(!o&&!r.roles?.length)return null;if(!o){let u=new Map(r.roles.map(p=>[p.id,p.role])),c=p=>p.map(h=>h.type==="shape"&&u.has(h.id)?{...h,role:u.get(h.id)}:h),l=t.floors?.map(p=>({...p,objects:c(p.objects)})),f=new Float64Array(n.length).fill(Number.NaN),m=new Float64Array(n.length*2).fill(Number.NaN);return n.forEach((p,h)=>{p.eyeHeightM!==void 0&&(f[h]=p.eyeHeightM),p.focalPoint&&(m[h*2]=p.focalPoint.x,m[h*2+1]=p.focalPoint.y)}),{doc:{...t,objects:l?.[0]?.objects??c(t.objects),...l?{floors:l}:{}},report:r,eyeHeightM:f,focal:m}}let a=new Map(gn(e).map(u=>[u.id,u])),i=new Float64Array(n.length).fill(Number.NaN),s=new Float64Array(n.length*2).fill(Number.NaN);return n.forEach((u,c)=>{let l=a.get(u.id)??u;l.eyeHeightM!==void 0&&(i[c]=l.eyeHeightM),l.focalPoint&&(s[c*2]=l.focalPoint.x,s[c*2+1]=l.focalPoint.y)}),{doc:e,report:r,eyeHeightM:i,focal:s}}function xc(t,n){return t.map((e,r)=>{let o=n.eyeHeightM[r],a=n.focal[r*2],i=n.focal[r*2+1],s={...e};return Number.isNaN(o)?delete s.eyeHeightM:s.eyeHeightM=o,Number.isNaN(a)?delete s.focalPoint:s.focalPoint={x:a,y:i},s})}function Qm(t){let n=t.estimate===!1?null:dc(t.doc,t.seats);return n?{input:{...t,doc:n.doc,seats:xc(t.seats,n)},estimate:n}:{input:t}}export{wc as a,zr as b,Vr as c,De as d,Kr as e,Ec as f,sn as g,Gn as h,Ac as i,Xn as j,P as k,In as l,Dc as m,Nc as n,So as o,Il as p,Al as q,_l as r,wl as s,El as t,Bl as u,Qn as v,Tl as w,Ol as x,Cl as y,kl as z,Fl as A,aa as B,Km as C,dc as D,xc as E,Qm as F};
|
package/dist/chunk-QJXSZT3H.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var c=/^[\p{L}\p{N}]{1,4}$/u,a=/^([\p{L}\p{N}]{2,})[\s\-\u2013\u2014\u00b7_./]+(.+)$/u;function p(t,i){let o=i?.trim();if(!o)return t;let u=t.toLocaleLowerCase("en-US"),s=o.toLocaleLowerCase("en-US");if(u.startsWith(`${s} `)){let e=t.slice(o.length).trim();if(c.test(e))return e}let n=a.exec(t);if(n){let e=n[1].toLocaleLowerCase("en-US"),r=n[2].trim();if((s.startsWith(e)||e.startsWith(s))&&c.test(r))return r}return t}export{p as a};
|