@seatlayer/core 0.106.1 → 0.106.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-C5GKFG36.js → chunk-45W3GKPP.js} +1 -1
- package/dist/{chunk-UGMXII72.js → chunk-6DZ2EVH2.js} +1 -1
- package/dist/{chunk-TAKLS47V.js → chunk-IFQFHR6Q.js} +1 -1
- package/dist/chunk-J33DNOMI.js +1 -0
- package/dist/{chunk-MLPJTJFE.js → chunk-N562FZPD.js} +1 -1
- package/dist/{chunk-3YNO3XCY.js → chunk-NXZ2GLII.js} +1 -1
- package/dist/{chunk-M4J7U2E2.js → chunk-QXJEN5LV.js} +1 -1
- package/dist/{chunk-V65VJE6F.js → chunk-RI4LNRP4.js} +1 -1
- package/dist/{chunk-FQTSVDD4.js → chunk-T7DQX3MB.js} +1 -1
- package/dist/chunk-WGRLTDLW.js +1 -0
- package/dist/{chunk-INCPWAWP.js → chunk-YGRBCSUI.js} +1 -1
- package/dist/core/chart-ops/index.js +1 -1
- package/dist/core/inventory/index.cjs +1 -1
- package/dist/core/inventory/index.js +1 -1
- package/dist/core/layout/index.cjs +1 -1
- package/dist/core/layout/index.js +1 -1
- package/dist/core/sections/index.cjs +1 -1
- package/dist/core/sections/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +1 -1
- package/dist/view3d/index.cjs +44 -44
- package/dist/view3d/index.js +1 -1
- 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-3DHQYZ47.js +0 -1
- package/dist/chunk-5R6I2XL7.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as Ze,c as qe,d as $e}from"./chunk-45W3GKPP.js";import{b as De,c as Ue,d as ze,e as Ke,h as Ve}from"./chunk-LWBTU56C.js";import{v as Qe}from"./chunk-QXJEN5LV.js";import{a as We,c as Vt,d as pt,f as xt,i as Ye}from"./chunk-T7DQX3MB.js";import{e as Xe,l as je}from"./chunk-4N5CHKHD.js";import{n as Vn}from"./chunk-JXIX3PNI.js";import{h as Mn}from"./chunk-R6BN4HDQ.js";import{Aa as Kt,Ba as Sn,C as Ce,Ca as ve,D as Yt,Ga as Kn,Ia as Ne,Xa as Rt,ca as ke,da as Fe,eb as In,j as Oe,ka as $,la as Pt,ua as Pn,va as zt,wa as Rn,ya as Le}from"./chunk-J33DNOMI.js";import{A as It,D as He,b as Ge,d as it,y as st}from"./chunk-JBOTRSMY.js";var rn=["available","held","sold","selected","dimmed"];function Zn(t){let n=rn.indexOf(t);return n<0?0:n}var Je={available:[.24,.82,.52],held:[.34,.39,.45],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};function to(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 qn={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]},$n={top:[.05,.06,.08],bottom:[.1,.12,.15]};function V(t,n){return[Math.min(1,t[0]*n),Math.min(1,t[1]*n),Math.min(1,t[2]*n)]}import si from"earcut";import eo from"polygon-clipping";var R=$,ai=.002;function ci(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<ai}var Xt=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)}},wn=class{constructor(){this.pos=new Xt;this.nor=new Xt;this.col=new Xt;this.flr=new Xt;this.mat=new Xt;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){ci(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,c=s,l=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(c[0],c[1],c[2]),this.col.push3(l[0],l[1],l[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}get vertexCount(){return this.pos.length/3}build(){return{position:this.pos.toArray(),normal:this.nor.toArray(),color:this.col.toArray(),floor:this.flr.toArray(),material:this.mat.toArray(),count:this.pos.length/3}}};function li(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],c=e[2]-t[2],l=o*c-a*s,u=a*i-r*c,f=r*s-o*i,m=Math.hypot(l,u,f)||1;return l/=m,u/=m,f/=m,[l,u,f]}function ui(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=si(r,o.length?o:void 0,2);return{pts:e,tris:a}}function Et(t){return pt(t)<0?[...t].reverse():t}var fi=3;function mi(t,n,e,r){let o=r(t),a=r(n),i=r(e),s=(h,d,y,b)=>Math.abs(r({x:(h.x+d.x)/2,y:(h.y+d.y)/2})-(y+b)/2),c=(t.x+n.x+e.x)/3,l=(t.y+n.y+e.y)/3,u=(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:c,y:l})-u)),m=(h,d,y)=>{let b=Math.abs(r({x:(h+c)/2,y:(d+l)/2})-(y+u)/2);b>f&&(f=b)};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 sn(t,n,e,r,o){if(o<=0)return mi(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(sn(t,a,s,r,o-1),sn(a,n,i,r,o-1),sn(s,i,e,r,o-1),sn(a,i,s,r,o-1))}function an(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},h={x:(e.x+r.x)/2,y:(e.y+r.y)/2},d={x:(r.x+n.x)/2,y:(r.y+n.y)/2};an(t,n,m,d,o,a,i-1,s),an(t,m,e,h,o,a,i-1,s),an(t,d,h,r,o,a,i-1,s),an(t,m,h,d,o,a,i-1,s);return}let c=[n.x*R,o(n),n.y*R],l=[e.x*R,o(e),e.y*R],u=[r.x*R,o(r),r.y*R];if(s){t.triN(c,l,u,s(n),s(e),s(r),a);return}let f=li(c,l,u);f[1]<0&&(f=[-f[0],-f[1],-f[2]]),t.tri(c,l,u,f,a)}var hi=8;function no(t,n,e){if(!Number.isFinite(e))return t;let r=[],o=(a,i,s,c,l)=>{if(l>0){let u={x:(a.x+i.x)/2,y:(a.y+i.y)/2},f=n(u);if(Math.abs(f-(s+c)/2)>e){o(a,u,s,f,l-1),o(u,i,f,c,l-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),hi)}return r}function _n(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],c=s.x-a.x,l=s.y-a.y,u=Math.hypot(c,l);u>n&&Math.abs((i.x-a.x)*l-(i.y-a.y)*c)/u<n||r.push(i)}return r.length>=3?r:e}var An=.001*Pt*.1;function Z(t,n,e,r,o,a,i,s,c=1/0,l){if(!n||n.length<3||(c===void 0&&(c=1/0),Math.abs(pt(n))<1e-4))return;let u=_n(no(_n(Et(n),An),r,c),An),f=e?.map(x=>_n(no(_n(Et(x),An),r,c),An)).filter(x=>x.length>=3&&Math.abs(pt(x))>=1e-4),{pts:m,tris:h}=ui(u,f),d=[a[0]*s.top,a[1]*s.top,a[2]*s.top],y=[a[0]*s.bottomCap,a[1]*s.bottomCap,a[2]*s.bottomCap],b=[i[0]*s.top,i[1]*s.top,i[2]*s.top],p=[i[0]*s.wallBottom,i[1]*s.wallBottom,i[2]*s.wallBottom],g=0;if(Number.isFinite(c))for(;g<fi;g++){let x=0;for(let _=0;_<h.length;_+=3){let I=sn(m[h[_]],m[h[_+1]],m[h[_+2]],r,g);I>x&&(x=I)}if(x<=c)break}for(let x=0;x<h.length;x+=3){let _=m[h[x]],I=m[h[x+1]],S=m[h[x+2]];an(t,_,I,S,r,d,g,l);let B=[_.x*R,o,_.y*R],T=[I.x*R,o,I.y*R],F=[S.x*R,o,S.y*R];t.tri(B,F,T,[0,-1,0],y)}let P=x=>{if(g<=0)return x;let _=1<<g,I=[];for(let S=0;S<x.length;S++){let B=x[S],T=x[(S+1)%x.length];for(let F=0;F<_;F++){let k=F/_;I.push({x:B.x+(T.x-B.x)*k,y:B.y+(T.y-B.y)*k})}}return I},A=Ce(u),M=[{ring:P(u),flip:!1}];if(f)for(let x of f)x.length>=3&&M.push({ring:P(x),flip:!0});for(let{ring:x,flip:_}of M)for(let I=0;I<x.length;I++){let S=x[I],B=x[(I+1)%x.length],T=(B.x-S.x)*R,k=(B.y-S.y)*R,w=-T,E=Math.hypot(k,w)||1;k/=E,w/=E;let C=(S.x+B.x)/2-A.x,L=(S.y+B.y)/2-A.y,O=k*C+w*L;_&&(O=-O),O<0&&(k=-k,w=-w);let D=[k,0,w],H=[S.x*R,r(S),S.y*R],j=[B.x*R,r(B),B.y*R],G=[S.x*R,o,S.y*R],U=[B.x*R,o,B.y*R];t.tri(H,j,U,D,b,b,p),t.tri(H,U,G,D,b,p,p)}}function oo(t){let n=0;for(let c of t)n+=c.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 c of t)e.set(c.position,s*3),r.set(c.normal,s*3),o.set(c.color,s*3),a.set(c.floor,s),i.set(c.material,s),s+=c.count;return{position:e,normal:r,color:o,floor:a,material:i,count:n}}function _t(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 c=r[s],l=r[(s+1)%o],u=l.x-c.x,f=l.y-c.y,m=Math.hypot(u,f)||1;a.push({x:f/m,y:-u/m})}let i=[];for(let s=0;s<o;s++){let c=r[s],l=a[(s-1+o)%o],u=a[s],f=l.x+u.x,m=l.y+u.y,h=Math.hypot(f,m),d=()=>{i.push([c.x+l.x*n,c.y+l.y*n]),i.push([c.x+u.x*n,c.y+u.y*n])};if(h<1e-9){d();continue}f/=h,m/=h;let y=f*l.x+m*l.y,b=1/Math.max(y,1e-6);if(!Number.isFinite(b)||b>e){d();continue}i.push([c.x+f*n*b,c.y+m*n*b])}if(i.length<3)return t;try{let s=eo.union([[...i,i[0]]]),c=null,l=-1/0;for(let f of s){let m=Math.abs(pt(f[0].map(([h,d])=>({x:h,y:d}))));m>l&&(l=m,c=f[0])}if(!c)return t;let u=c.map(([f,m])=>({x:f,y:m}));if(u.length>1){let f=u[0],m=u[u.length-1];Math.abs(f.x-m.x)<1e-9&&Math.abs(f.y-m.y)<1e-9&&u.pop()}return u.length>=3?u:t}catch{return t}}function 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 c=0;c<o;c++){let l=r[c],u=r[(c+1)%o],f=Math.hypot(u.x-l.x,u.y-l.y)||1;a.push({x:-(u.y-l.y)/f,y:(u.x-l.x)/f})}let i=[],s=[];for(let c=0;c<o;c++){let l=r[c],u=a[(c-1+o)%o],f=a[c],m=u.x+f.x,h=u.y+f.y,d=Math.hypot(m,h),y=d<1e-9?1/0:1/Math.max(m/d*u.x+h/d*u.y,1e-6);if(!Number.isFinite(y)||y>e){i.push({x:l.x+u.x*n,y:l.y+u.y*n},{x:l.x+f.x*n,y:l.y+f.y*n}),s.push(c,c);continue}m/=d,h/=d,i.push({x:l.x+m*n*y,y:l.y+h*n*y}),s.push(c)}for(let c=0;c<i.length;c++){let l=(c+1)%i.length,u=s[c],f=s[l];if(f!==(u+1)%o)continue;let m=r[u],h=r[f];if((i[l].x-i[c].x)*(h.x-m.x)+(i[l].y-i[c].y)*(h.y-m.y)<=0)return[]}try{let c=eo.intersection([[...i.map(d=>[d.x,d.y]),[i[0].x,i[0].y]]],[[...r.map(d=>[d.x,d.y]),[r[0].x,r[0].y]]]),l=null,u=0;for(let d of c){let y=Math.abs(pt(d[0].map(([b,p])=>({x:b,y:p}))));y>u&&(u=y,l=d[0])}if(!l)return[];let f=l.map(([d,y])=>({x:d,y})),m=f[0],h=f[f.length-1];return f.length>1&&Math.abs(m.x-h.x)<1e-9&&Math.abs(m.y-h.y)<1e-9&&f.pop(),f.length>=3?Et(f):[]}catch{return[]}}function En(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 cn(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 ut={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,body:10,head:11},yi=.44,di=.15,pi=.3,xi=.24;function io(t){return t===void 0||!Number.isFinite(t)||t<=0?xi:Math.min(pi,Math.max(di,t*yi))}var Yl=.21,bi=.05,Qn=.45,gi=Qn+bi,Mi=.92,ro=.66,Pi=1.205,Ri=-.23,Si=.38,Ii=[{part:ut.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:ut.pad,min:[-1,.36,-.95],max:[1,Qn,1]},{part:ut.back,min:[-1,gi,-1],max:[1,Mi,-.72]},{part:ut.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:ut.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:ut.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:ut.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:ut.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:ut.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:ut.leg,min:[.62,0,.48],max:[.82,.37,.7]}],_i=[{part:ut.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:ut.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:ut.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:ut.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:ut.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}],Ai=[{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 zl(){let t=[],n=[],e=[],r=[],o=(G,U,X)=>{let Y=e.length,[nt,rt,q]=G,Q=[rt[0]-nt[0],rt[1]-nt[1],rt[2]-nt[2]],J=[q[0]-nt[0],q[1]-nt[1],q[2]-nt[2]],v=Q[1]*J[2]-Q[2]*J[1],N=Q[2]*J[0]-Q[0]*J[2],W=Q[0]*J[1]-Q[1]*J[0],lt=Math.hypot(v,N,W);lt>1e-9?(v/=lt,N/=lt,W/=lt):[v,N,W]=U,v*U[0]+N*U[1]+W*U[2]<0&&(v=-v,N=-N,W=-W);for(let ft of G)t.push(...ft),n.push(v,N,W),e.push(X);r.push(Y,Y+1,Y+2,Y,Y+2,Y+3)},a=G=>{for(let U of Ai){let X=U.c.map(Y=>Y.map((nt,rt)=>nt?G.max[rt]:G.min[rt]));o(X,U.n,G.part)}},i=(G,U)=>{let[X,Y,nt]=U?[0,1,2]:[0,2,1],rt=G.min[X],q=G.max[X],Q=G.min[Y],J=G.max[Y],v=(q-rt)*.1,N=(J-Q)*.1,W=U?[[rt+v,Q],[q-v,Q],[q,Q+N],[q*.94,J-(J-Q)*.23],[q*ro,J],[rt*ro,J],[rt*.94,J-(J-Q)*.23],[rt,Q+N]]:[[rt+v,Q],[q-v,Q],[q,Q+N],[q,J-N],[q-v,J],[rt+v,J],[rt,J-N],[rt,Q+N]],lt=(at,tt,et)=>{let ht=[0,0,0];return ht[X]=at,ht[Y]=tt,ht[nt]=et,ht},ft=[G.min[nt],G.max[nt]].map(at=>W.map(([tt,et])=>lt(tt,et,at)));for(let at=0;at<W.length;at++){let tt=(at+1)%W.length,et=[0,0,0];et[X]=(W[at][0]+W[tt][0])/2-(rt+q)/2,et[Y]=(W[at][1]+W[tt][1])/2-(Q+J)/2,o([ft[0][at],ft[0][tt],ft[1][tt],ft[1][at]],et,G.part)}for(let at=0;at<2;at++){let tt=[0,0,0];tt[nt]=at?1:-1;let et=ft[at];for(let ht=1;ht<et.length-1;ht++){let z=e.length;for(let mt of[et[0],et[ht],et[ht+1]])t.push(...mt),n.push(...tt),e.push(G.part);r.push(z,z+1,z+2)}}};for(let G of Ii)G.part===ut.pad||G.part===ut.back?i(G,G.part===ut.back):a(G);for(let G of _i)a(G);let s=Qn,c=1.08,l=.47,u=.69,f=-.55,m=.08,h=-.48,d=.01,y=[-l,s,f],b=[l,s,f],p=[-l,s,m],g=[l,s,m],P=[-u,c,h],A=[u,c,h],M=[-u,c,d],x=[u,c,d];o([b,A,x,g],[1,0,0],ut.body),o([p,M,P,y],[-1,0,0],ut.body),o([y,b,g,p],[0,-1,0],ut.body);let _=c+.07,I=.24,S=[-I,_,h],B=[I,_,h],T=[-I,_,d],F=[I,_,d];o([M,T,S,P],[-.5,1,0],ut.body),o([T,F,B,S],[0,1,0],ut.body),o([F,x,A,B],[.5,1,0],ut.body),o([g,x,M,p],[0,0,1],ut.body),o([x,F,T,M],[0,0,1],ut.body),o([y,P,A,b],[0,0,-1],ut.body),o([P,S,B,A],[0,0,-1],ut.body);let k=10,w=8,E=[0,Pi,Ri],C=[.32,.115,Si],L=e.length;for(let G=0;G<=w;G++){let U=Math.PI*G/w,X=Math.cos(U),Y=Math.sin(U);for(let nt=0;nt<=k;nt++){let rt=Math.PI*2*nt/k,q=Y*Math.cos(rt),Q=Y*Math.sin(rt);t.push(E[0]+C[0]*q,E[1]+C[1]*X,E[2]+C[2]*Q);let J=q/C[0],v=X/C[1],N=Q/C[2],W=Math.hypot(J,v,N)||1;J/=W,v/=W,N/=W,n.push(J,v,N),e.push(ut.head)}}for(let G=0;G<w;G++)for(let U=0;U<k;U++){let X=L+G*(k+1)+U,Y=X+k+1;r.push(X,Y,X+1,X+1,Y,Y+1)}let O=new Float32Array(t),D=new Float32Array(n),H=new Float32Array(e),j=new Uint16Array(r);return{position:O,normal:D,part:H,index:j,vertexCount:e.length,indexCount:r.length}}function so(t,n,e,r){let o=new Float32Array(n),a=l=>t[l*3],i=l=>t[l*3+2],s=0,c=(l,u)=>{let f=u-l;for(let m=l;m<u;m++){let[h,d]=r(m),y=h-a(m),b=d-i(m);if(f>=2){let p=Math.max(l,m-1),g=Math.min(u-1,m+1),P=a(g)-a(p),A=i(g)-i(p),M=Math.hypot(P,A);if(M>1e-6){let x=-A/M,_=P/M;x*y+_*b<0&&(x=-x,_=-_),y=x,b=_}}o[m]=y===0&&b===0?0:Math.atan2(y,b)}};for(let l=1;l<=n;l++)(l===n||e(l)!==e(s))&&(c(s,l),s=l);return o}var Bn=.22;function nu(t,n){let e=rn[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 wi=.42;function Ei(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 d of t)d.x<r&&(r=d.x),d.y<o&&(o=d.y),d.x>a&&(a=d.x),d.y>i&&(i=d.y);let s=Math.max(a-r,1e-6),c=Math.max(i-o,1e-6),l=Math.max(Math.sqrt(s*c/n),1e-6),u=Math.max(1,Math.ceil(s/l)+1),f=Math.max(1,Math.ceil(c/l)+1),m=new Map,h=(d,y)=>{let b=Math.min(u-1,Math.max(0,Math.floor((d-r)/l)));return Math.min(f-1,Math.max(0,Math.floor((y-o)/l)))*u+b};for(let d=0;d<n;d++){let y=h(t[d].x,t[d].y),b=m.get(y);b?b.push(d):m.set(y,[d])}for(let d=0;d<n;d++){let y=t[d],b=Math.min(u-1,Math.max(0,Math.floor((y.x-r)/l))),p=Math.min(f-1,Math.max(0,Math.floor((y.y-o)/l))),g=1/0;for(let P=1;P<=4;P++){for(let A=p-P;A<=p+P;A++)if(!(A<0||A>=f))for(let M=b-P;M<=b+P;M++){if(M<0||M>=u||P>1&&Math.abs(A-p)<P&&Math.abs(M-b)<P)continue;let x=m.get(A*u+M);if(x)for(let _ of x){if(_===d)continue;let I=Math.hypot(t[_].x-y.x,t[_].y-y.y);I<g&&(g=I)}}if(Number.isFinite(g)&&g<=P*l)break}e[d]=g}return e}function Bi(t){let n=t.eyeHeightM;return Number.isFinite(n)?Math.max(0,n-Pn):0}function ao(t,n,e,r,o,a){let i=t.length,s=new Float32Array(i*3),c=new Float32Array(i),l=new Float32Array(i*3),u=new Float32Array(i),f=new Float32Array(i),m=new Float32Array(i),h=new Float32Array(i),d=new Float32Array(i*3),y=new Map,b=Ei(t);for(let p=0;p<i;p++){let g=t[p],A=(e?.seatPitchU(p)??b[p])*R;u[p]=Number.isFinite(A)?Math.max(.06,Math.min(Bn,A*wi)):Bn,f[p]=io(Number.isFinite(A)?A:void 0);let M=je(g.glyph,{seatGlyph:a?.get(g.categoryKey)});m[p]=Xe.indexOf(M),h[p]=g.wheelchairSpaceType==="no-seat"?0:1,s[p*3]=g.x*R,s[p*3+1]=e?e.seatDeckY(p):Bi(g),s[p*3+2]=g.y*R,c[p]=Zn(n?n(g):"available");let x=it(o?.get(g.categoryKey)??"#6e7bff")??[.43,.48,1];if(l[p*3]=x[0],l[p*3+1]=x[1],l[p*3+2]=x[2],g.accessibility?.length){let _=it(Mn(g.accessibility));_&&(d[p*3]=_[0],d[p*3+1]=_[1],d[p*3+2]=_[2])}y.set(g.id,p)}return{count:i,iPosition:s,iState:c,iCategory:l,iMaxRadius:u,iRing:d,idToIndex:y,iChairWidth:f,iGlyph:m,iPhysicalSeat:h,iFloor:r??new Float32Array(i),iSection:new Float32Array(i).fill(-1),iYaw:new Float32Array(i)}}var Ti=64;function eu(t,n){let e=[];for(let i of n){let s=t.idToIndex.get(i.seatId);if(s===void 0)continue;let c=Zn(i.state);t.iState[s]!==c&&(t.iState[s]=c,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+Ti){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 Wi from"polygon-clipping";var K={top:1,wallBottom:.58,bottomCap:.4};function jt(t,n){if(!t)return n;let e=V(It(t,.4),.62);return st(n,e,.22)}function lo(t,n){return t?st(n,V(It(t,.25),.74),.62):n}var Oi=.5,co=t=>.2126*t[0]+.7152*t[1]+.0722*t[2];function uo(t,n){if(!t)return n;let e=st(n,V(It(t,.08),.9),.82),r=co(to(t))*Oi,o=co(e);return o>r&&o>0?V(e,r/o):e}function fo(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,c=0,l=0,u=0;for(let[f,m]of i){let h=it(e.get(f));h&&(s+=h[0]*m,c+=h[1]*m,l+=h[2]*m,u+=m)}u>0&&o.set(a,[s/u,c/u,l/u])}return o}function mo(t,n){return it(t.color)??n.get(t.logicalSectionId??t.id)??null}import Ao from"polygon-clipping";import xo from"polygon-clipping";import Ci from"earcut";var ki=.58,ho=.01,St=Bn*1.5*Pt,Fi=.5,Li=.6;function vi(t,n){let e=t.length,r=[];for(let i=0;i<e;i++){let s=t[Math.max(0,i-1)],c=t[Math.min(e-1,i+1)],l=c.x-s.x,u=c.y-s.y,f=Math.hypot(l,u);if(f<1e-9){r.push([0,0]);continue}l/=f,u/=f,r.push([-u,l])}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 Ni(t,n){if(t.length<2||n<=0)return[...t];let e=[...t],r=(i,s)=>{let c=s.x-i.x,l=s.y-i.y,u=Math.hypot(c,l)||1;return{x:c/u,y:l/u}},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 yo=Math.PI/12;function Di(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 bo(t,n){if(!t.length||!(n>0))return[];let e=Di(t),r=(s,c,l,u)=>{let f=l-c;for(;f<0;)f+=Math.PI*2;for(;f>Math.PI*2;)f-=Math.PI*2;let m=Math.max(1,Math.ceil(f/yo)),h=n/Math.cos(f/m/2);for(let d=0;d<=m;d++){let y=c+f*d/m;u.push({x:s.x+Math.cos(y)*h,y:s.y+Math.sin(y)*h})}};if(e.length<3){let s=0,c=0;for(let h of e)s+=h.x,c+=h.y;s/=e.length||1,c/=e.length||1;let l=0;for(let h of e)l=Math.max(l,Math.hypot(h.x-s,h.y-c));let u=[],f=Math.max(3,Math.ceil(Math.PI*2/yo)),m=(l+n)/Math.cos(Math.PI/f);for(let h=0;h<f;h++){let d=h/f*Math.PI*2;u.push({x:s+Math.cos(d)*m,y:c+Math.sin(d)*m})}return u}let o=e.length,a=[];for(let s=0;s<o;s++){let c=e[s],l=e[(s+1)%o];a.push(Math.atan2(-(l.x-c.x),l.y-c.y))}let i=[];for(let s=0;s<o;s++)r(e[s],a[(s+o-1)%o],a[s],i);return So(i)}function Gi(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,c=i.y-a.y,l=s*s+c*c,u=l>1e-12?((n-a.x)*s+(e-a.y)*c)/l:0;u<0?u=0:u>1&&(u=1);let f=Math.hypot(n-(a.x+u*s),e-(a.y+u*c));f<r&&(r=f)}return r}function Tn(t){let n=t.map(o=>{let a=0,i=0;for(let l of o.pts)a+=l.x,i+=l.y;let s=o.pts.length||1;a/=s,i/=s;let c=0;for(let l of o.pts){let u=Math.hypot(l.x-a,l.y-i);u>c&&(c=u)}return{cx:a,cy:i,rad:c}}),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,c=null;for(let u 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 h=n[m],d=Math.hypot(u.x-h.cx,u.y-h.cy)-h.rad;if(d>=f&&d>=s)continue;let y=Gi(t[m].pts,u.x,u.y);y<f&&(f=y),t[m].depth<t[o].depth&&y<s&&(s=y,c=t[m].y)}Number.isFinite(f)&&f>0&&i.push(f)}i.sort((u,f)=>u-f);let l=i.length?i[Math.floor(i.length/2)]:1;r.push({pitch:l,belowY:c})}return r}function go(t,n,e,r){let o=t[n],a=o.pts.length>=2?[...o.pts]:o.pts.length===1?(()=>{let u=o.pts[0],f=u.x-r.x,m=u.y-r.y,h=Math.hypot(f,m)||1;f/=h,m/=h;let d=Math.max(e[n].pitch,.001)*.5;return[{x:u.x+m*d,y:u.y-f*d},{x:u.x-m*d,y:u.y+f*d}]})():[];if(a.length<2)return null;let i=0,s=0;for(let u=1;u<a.length;u++){let f=Math.hypot(a[u].x-a[u-1].x,a[u].y-a[u-1].y);f>1e-6&&(i+=f,s++)}let c=s>0?i/s:0,l=Ni(a,Math.max(c*Li,St));return{pts:l,nrm:vi(l,r),front:Math.max(e[n].pitch*ki,St),back:Math.max(e[n].pitch*Fi,St)}}var Zt=1.5,Mo=.3;function Jn(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,c=-1;for(let f=1;f<t.length-1;f++){let m=t[f],h=i>1e-12?Math.abs((m.x-e.x)*a-(m.y-e.y)*o)/i:Math.hypot(m.x-e.x,m.y-e.y);h>s&&(s=h,c=f)}if(s<=n||c<0)return[e,r];let l=Jn(t.slice(0,c+1),n),u=Jn(t.slice(c),n);return[...l.slice(0,-1),...u]}function Po(t,n){if(t.length<4)return t;let e=Jn([...t,t[0]],n);return e.pop(),e.length>=3?e:t}function Hi(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 Ro(t,n,e){if(t.length<2)return[];let r=e??Tn(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 g of i){let P=t[g].patch;P&&P.length>=3?a.push({outline:[...P],holes:[],topY:t[g].y}):s.push(g)}if(!s.length)continue;s.sort((g,P)=>t[g].depth-t[P].depth);let l=s.map(g=>go(t,g,r,n)).filter(g=>g!==null);if(!l.length)continue;let u=(g,P)=>({x:g.pts[P].x-g.nrm[P][0]*(g.front+Zt),y:g.pts[P].y-g.nrm[P][1]*(g.front+Zt)}),f=(g,P)=>({x:g.pts[P].x+g.nrm[P][0]*(g.back+Zt),y:g.pts[P].y+g.nrm[P][1]*(g.back+Zt)}),m=l[0],h=l[l.length-1],d=[];for(let g=0;g<m.pts.length;g++)d.push(u(m,g));for(let g of l)d.push(f(g,g.pts.length-1));for(let g=h.pts.length-1;g>=0;g--)d.push(f(h,g));for(let g=l.length-1;g>=0;g--)d.push(u(l[g],0));let y=So(d),b=1/0;for(let g of s)t[g].y<b&&(b=t[g].y);if(!Number.isFinite(b))continue;if(y.length>=3&&Math.abs(pt(y))>1e-6&&l.every(g=>{let P=g.pts[Math.floor(g.pts.length/2)];return xt(y,P.x,P.y)})&&!Hi(y)){a.push({outline:Po(y,Mo),holes:[],topY:b});continue}for(let g of Xi(l))a.push({outline:g,holes:[],topY:b})}return a}function Xi(t){let n=[];for(let e of t){let r=[],o=[],a=e.front+Zt,i=e.back+Zt;for(let c=0;c<e.pts.length;c++){let l=e.pts[c],u=e.nrm[c];r.push([l.x-u[0]*a,l.y-u[1]*a]),o.push([l.x+u[0]*i,l.y+u[1]*i])}let s=[...r,...o.reverse()];s.length<3||(s.push(s[0]),n.push([s]))}if(!n.length)return[];try{let e=xo.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(([c,l])=>({x:c,y:l})),i=a[0],s=a[a.length-1];a.length>1&&Math.abs(i.x-s.x)<1e-9&&Math.abs(i.y-s.y)<1e-9&&a.pop(),a.length>=3&&r.push(Po(a,Mo))}return r}catch{return[]}}function So(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 te=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(!xt(e,o.x,o.y)){r=!1;break}if(r)return!0}return!1}};function po(t,n,e,r,o,a){if(r.length<3)return;if(e.containsAll(r)){let l=[0,1,0],u=r[0];for(let f=1;f+1<r.length;f++){let m=r[f],h=r[f+1];t.tri([u.x*R,o,u.y*R],[m.x*R,o,m.y*R],[h.x*R,o,h.y*R],l,a)}return}let i=r.map(l=>[l.x,l.y]);i.push(i[0]);let s;try{s=xo.intersection([i],n)}catch{return}let c=[0,1,0];for(let l of s){if(!l.length||l[0].length<4)continue;let u=l[0],f=[],m=[];for(let d=0;d<u.length-1;d++)f.push(u[d][0],u[d][1]),m.push([u[d][0],u[d][1]]);if(m.length<3)continue;let h=Ci(f,void 0,2);for(let d=0;d<h.length;d+=3){let y=m[h[d]],b=m[h[d+1]],p=m[h[d+2]];t.tri([y[0]*R,o,y[1]*R],[b[0]*R,o,b[1]*R],[p[0]*R,o,p[1]*R],c,a)}}}function Io(t,n,e,r,o,a,i){if(n.length<2)return;let s=i??Tn(n),c=[0,1,0],l=a&&a.length>=3?[[...a.map(h=>[h.x,h.y]),[a[0].x,a[0].y]]]:null,u=a&&a.length>=3?new te([[...a]]):null,f=h=>{t.setMaterial(2),h(),t.setMaterial(0)},m=h=>{t.setMaterial(3),h(),t.setMaterial(0)};for(let h=0;h<n.length;h++){let d=n[h];if(d.patch&&d.patch.length>=3){let M=[...d.patch],x=s[h].belowY??r;if(m(()=>{if(l&&u)po(t,l,u,M,d.y,o.tread);else{let _=M[0];for(let I=1;I+1<M.length;I++){let S=M[I],B=M[I+1];t.tri([_.x*R,d.y,_.y*R],[S.x*R,d.y,S.y*R],[B.x*R,d.y,B.y*R],c,o.tread)}}}),d.y>x+ho){let _=0,I=0;for(let S of M)_+=S.x,I+=S.y;_/=M.length,I/=M.length,f(()=>{for(let S=0;S<M.length;S++){let B=M[S],T=M[(S+1)%M.length],F=T.x-B.x,k=T.y-B.y,w=Math.hypot(F,k);if(w<1e-6)continue;let E=k/w,C=-F/w;(B.x-_)*E+(B.y-I)*C<0&&(E=-E,C=-C);let L=[E,0,C],O=[B.x*R,d.y,B.y*R],D=[T.x*R,d.y,T.y*R],H=[B.x*R,x,B.y*R],j=[T.x*R,x,T.y*R];t.tri(O,D,j,L,o.riser),t.tri(O,j,H,L,o.riser)}})}continue}let y=go(n,h,s,e);if(!y)continue;let{pts:b,nrm:p,front:g,back:P}=y,A=s[h].belowY??r;for(let M=0;M+1<b.length;M++){let x=b[M],_=b[M+1],I=p[M],S=p[M+1];if(Math.hypot(_.x-x.x,_.y-x.y)<1e-6||I[0]===0&&I[1]===0||S[0]===0&&S[1]===0)continue;let B=[(x.x-I[0]*g)*R,d.y,(x.y-I[1]*g)*R],T=[(_.x-S[0]*g)*R,d.y,(_.y-S[1]*g)*R],F=[(x.x+I[0]*P)*R,d.y,(x.y+I[1]*P)*R],k=[(_.x+S[0]*P)*R,d.y,(_.y+S[1]*P)*R];if(m(()=>{l&&u?po(t,l,u,[{x:x.x-I[0]*g,y:x.y-I[1]*g},{x:_.x-S[0]*g,y:_.y-S[1]*g},{x:_.x+S[0]*P,y:_.y+S[1]*P},{x:x.x+I[0]*P,y:x.y+I[1]*P}],d.y,o.tread):(t.tri(B,T,k,c,o.tread),t.tri(B,k,F,c,o.tread))}),d.y>A+ho){let w=[B[0],A,B[2]],E=[T[0],A,T[2]],C=[-I[0],0,-I[1]];f(()=>{t.tri(B,T,E,C,o.riser),t.tri(B,E,w,C,o.riser)})}}}}function ji(t,n){let e=t.eventConfigurationIds;return!e?.length||!!n&&e.includes(n)}function _o(t,n){return t.filter(e=>e.type!=="shape"||ji(e,n))}function wo(t,n){let e=t.focalPoint??{x:0,y:0};return t.floors?.length?t.floors.map((r,o)=>({objects:_o(r.objects,n),focal:{x:(r.focalPoint??e).x,y:(r.focalPoint??e).y},baseHeightM:r.baseHeightM??0,index:o})):[{objects:_o(t.objects,n),focal:e,baseHeightM:0,index:0}]}var Ui={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Tt(t){return We(t)??Ui}function Eo(t,n){let e=_t(t.outline,St),r=Tt(e),o=n.filter(i=>i!==t&&i.outline&&i.outline.length>=3&&Vt(r,Tt(i.outline)));if(!o.length)return[e];let a=i=>{let s=i.map(c=>[c.x,c.y]);return s.push(s[0]),s};try{let i=Ao.difference([a(e)],...o.map(c=>[a(c.outline)])),s=[];for(let c of i){if(!c.length)continue;let l=c[0].map(([u,f])=>({x:u,y:f}));if(l.length>1){let u=l[0],f=l[l.length-1];Math.abs(u.x-f.x)<1e-9&&Math.abs(u.y-f.y)<1e-9&&l.pop()}l.length>=3&&s.push(l)}return s.length?s:[e]}catch{return[e]}}function Bo(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=Ao.intersection([e(a.outline)],r.flat())}catch{o.push(a);continue}for(let s of i){if(!s.length)continue;let c=s[0].map(([l,u])=>({x:l,y:u}));if(c.length>1){let l=c[0],u=c[c.length-1];Math.abs(l.x-u.x)<1e-9&&Math.abs(l.y-u.y)<1e-9&&c.pop()}c.length>=3&&o.push({outline:c,holes:[],topY:a.topY})}}return o.length?o:t}function Yi(t,n){return t===void 0||n===void 0?!0:Math.abs(t-n)<.001}var On=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(n,e){let r=n.map(c=>[c.x,c.y]);if(r.length<3)return[];r.push(r[0]);let o=Tt(n),a=this.rings.filter((c,l)=>Vt(o,this.boxes[l])&&Yi(e,this.levels[l])),i=[[r]];if(a.length)try{i=Wi.difference([r],...a).map(l=>l.map(u=>u.map(([f,m])=>[f,m])))}catch{i=[[r]]}this.rings.push([r]),this.boxes.push(o),this.levels.push(e);let s=[];for(let c of i){if(!c.length)continue;let l=c[0].map(([u,f])=>({x:u,y:f}));if(l.length>1){let u=l[0],f=l[l.length-1];Math.abs(u.x-f.x)<1e-9&&Math.abs(u.y-f.y)<1e-9&&l.pop()}l.length>=3&&s.push(l)}return s}};function qt(t,n,e=t){if(!n)return t;let r=1/0,o=-1/0,a=1/0,i=-1/0;for(let m of e)r=Math.min(r,m.x),o=Math.max(o,m.x),a=Math.min(a,m.y),i=Math.max(i,m.y);let s=(r+o)/2,c=(a+i)/2,l=n*Math.PI/180,u=Math.cos(l),f=Math.sin(l);return t.map(m=>{let h=m.x-s,d=m.y-c;return{x:s+h*u-d*f,y:c+h*f+d*u}})}function To(t){let n=Fe(t);return!n.length||!t.points?.length?[]:n.map(e=>qt(e,t.rotation,t.points))}function ct(t){let n=null;if(t.kind==="polygon"&&t.points&&t.points.length>=3)return qt(ke(t,4),t.rotation,t.points);if(t.kind==="rect"&&t.width&&t.height&&(n=cn(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=En(e,r,t.width/2,t.height/2)}return n?qt(n,t.rotation):null}function At(t){let n=t.role??"",r=n==="stage"?{kind:"stage",heightM:ve(t.stageKind)}:{stage:{kind:"stage",heightM:1},entrance:{kind:"portal",heightM:2.7},exit:{kind:"portal",heightM:2.7},screen:{kind:"solid",heightM:6},wall:{kind:"solid",heightM:2.8},rail:{kind:"solid",heightM:1.1},suite:{kind:"suite",heightM:3},obstruction:{kind:"solid",heightM:4.5},sound:{kind:"solid",heightM:1.45},restroom:{kind:"solid",heightM:2.4},bar:{kind:"solid",heightM:1.1},concession:{kind:"solid",heightM:1.1},coat:{kind:"solid",heightM:1.1},goal:{kind:"portal",heightM:1.8}}[n]??{kind:"plate",heightM:.25};return{...r,heightM:t.heightM??r.heightM}}var zi=.08,Ki=30,Vi=.015;function Zi(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 Oo(t,n){let e=ct(t)??(t.points?.length?qt(t.points,t.rotation):null),r=At(t),a=!t.role&&r.kind==="plate"&&t.heightM===void 0&&!!e&&Math.abs(pt(e))*$**2>=Ki?Vi: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,c=-1/0,l=-1/0;for(let h of e)i=Math.min(i,h.x),s=Math.min(s,h.y),c=Math.max(c,h.x),l=Math.max(l,h.y);let u=a,f=0,m=1e-6*Math.max(1,c-i,l-s);for(let h of n)c>h.minX&&i<h.maxX&&l>h.minY&&s<h.maxY&&u<=h.topOffsetM+1e-6&&(u=h.topOffsetM+zi),i>=h.minX-m&&c<=h.maxX+m&&s>=h.minY-m&&l<=h.maxY+m&&(!h.poly||e.every(b=>Zi(b,h.poly)||qi(b,h.poly,m)))&&(f=Math.max(f,h.topOffsetM));return t.fill&&t.fill!=="none"&&t.fill!=="transparent"&&n.push({minX:i,minY:s,maxX:c,maxY:l,topOffsetM:u,poly:e}),{topOffsetM:u,supportOffsetM:Math.min(f,u)}}function qi(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,c=i.y-a.y,l=s*s+c*c,u=l?Math.max(0,Math.min(1,((t.x-a.x)*s+(t.y-a.y)*c)/l)):0;if(Math.hypot(t.x-(a.x+u*s),t.y-(a.y+u*c))<=e)return!0}return!1}function vt(t,n,e){return{x:t.x+(n.x-t.x)*e,y:t.y+(n.y-t.y)*e}}function bt(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 dt(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 ln(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 ot(t,n,e,r,o,a,i){Z(t,n,i?.length?i:void 0,()=>e,r,o,a,K)}function un(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 $i=.8,Qi=.6,Ji=2;function Nt(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=ct(i)??[],c=Co(s)/2;!(c>0)||es(s)/c*R>Ji||(e.push(...s),r+=c)}if(e.length<3)return null;let o=un(e);if(o.length<3||r<Co(o)*Qi)return null;let a=0;for(let i of n)os(i,o)&&(a+=1);return a>=n.length*$i?o:null}var Cn=6,ts=5,ns=8;function ko(t){return Math.max(ns,(Number.isFinite(t)?t:0)+ts)}function $t(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 es(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 os(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 rs=[[/\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"]],is=1.2,ss=12;function Fo(t){if(t.heightM!==void 0)return!1;let n=ct(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*$<ss*2?!1:2*fn(n)/e*$<=is}function ne(t){if(!t)return null;for(let[n,e]of rs)if(n.test(t))return e;return null}var vo="auto-rows-";function No(t){return t.id.startsWith(vo)&&!t.label}var as=1.15,cs=.09,Do=6,ls=34,us=.35,fs=6,ms=.35,hs=.75,ys=12,ds=2.5,ps=40,xs=[18,24],bs=[12,16],Lo=14,gs=.8,Ms=.6,Ps=5,Rs=.3,Go=.4,Ho=2,Ss=400,Is=2.6,_s=.8,As=4,ws=26,Es=.7,Bs=.5,Ts=.985,Os=1.5,Cs=2.2,ks=3,Fs=25,Ls=.985,vs=2,Ns=6,Ds=3,Gs=.1,Hs=1.5,Xs=1.6,js=6e3,Us=.6,Ws="#c3c7cd",ee=300,Ys=240;function zs(t,n,e,r){if(!t.fill||!/^#[0-9a-f]{6}$/i.test(t.fill))return null;let o=re([...n]),a=new Set;for(let u of r)a.add(Math.floor(Math.atan2(u.y-o.y,u.x-o.x)*180/Math.PI/10));if(a.size*10<Ys)return null;let{h:i,s,l:c}=He(Ge(t.fill));return i<70/360||i>170/360||s<.2||c<.08||c>.75||e.some(u=>u!==t&&u.type==="shape"&&ct(u)?.some(f=>ae(f,n)))?null:t.kind==="ellipse"?"oval-cricket":t.kind==="rect"?"pitch-football":null}var Ks="Estimated from the drawing; confirm with the venue.",ie=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},re=t=>({x:t.reduce((n,e)=>n+e.x,0)/t.length,y:t.reduce((n,e)=>n+e.y,0)/t.length}),fn=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 Vs(t){return t.height!==void 0||t.rake!==void 0||t.elevation!==void 0||t.surfaceKind!==void 0}function se(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 ae(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 ce(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,c=i.y-a.y,l=s*s+c*c,u=l>0?Math.max(0,Math.min(1,((t.x-a.x)*s+(t.y-a.y)*c)/l)):0,f={x:a.x+s*u,y:a.y+c*u},m=Math.hypot(t.x-f.x,t.y-f.y);m<r&&(r=m,e=f)}return e}function Xo(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,c=i.y-a.y,l=Math.hypot(s,c);if(l<1e-6)continue;let u={x:(a.x+i.x)/2,y:(a.y+i.y)/2},f=ce(u,n),m=f.x-u.x,h=f.y-u.y,d=Math.hypot(m,h);d<1e-6||(r+=Math.abs((-c*m+s*h)/(l*d))*o.length,e+=o.length)}return e?r/e:0}function Zs(t,n,e){let r=t.filter(y=>y.type==="shape"),o=r.find(y=>y.role==="stage");if(o){let y=ct(o);return y?{shape:o,centre:re(y),outline:y,inferred:!1}:null}if(!e.length)return null;let a=1/0,i=-1/0,s=1/0,c=-1/0;for(let y of e)a=Math.min(a,y.x),i=Math.max(i,y.x),s=Math.min(s,y.y),c=Math.max(c,y.y);let l=(i-a)*(c-s),u=[];for(let y of r){if(y.role)continue;let b=ct(y);if(!b)continue;let p=fn(b);if(p*$*$<6||p>l)continue;let g=Math.min(...b.map(S=>S.x)),P=Math.max(...b.map(S=>S.x)),A=Math.min(...b.map(S=>S.y)),M=Math.max(...b.map(S=>S.y)),x=0;for(let S of e)S.x>g&&S.x<P&&S.y>A&&S.y<M&&ae(S,b)&&x++;if(x>e.length*.05)continue;let _=re(b),I=Xo(n,b);I>=gs&&u.push({shape:y,centre:_,outline:b,score:I,area:p,box:[g,A,P,M]})}let f=(y,b)=>b!==y&&b.area>y.area&&y.box[0]>=b.box[0]-1e-6&&y.box[1]>=b.box[1]-1e-6&&y.box[2]<=b.box[2]+1e-6&&y.box[3]<=b.box[3]+1e-6,m=u.filter(y=>!u.some(b=>f(y,b))),h=Math.max(0,...m.map(y=>y.score)),d=m.filter(y=>y.score>=h-.03).sort((y,b)=>b.area-y.area)[0]??null;return d?{shape:d.shape,centre:d.centre,outline:d.outline,inferred:!0}:null}function qs(t,n,e){if(!e||e.length<3)return Math.hypot(t.x-n.x,t.y-n.y);let r=ce(t,e);return Math.hypot(t.x-r.x,t.y-r.y)}function jo(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 $s(t){if(!t.length||t.length>js)return[];let n=[...se(t).values()],e=n.map((s,c)=>c),r=s=>e[s]===s?s:e[s]=r(e[s]),o=Xs/$,a=n.map(s=>({minX:Math.min(...s.map(c=>c.x))-o,maxX:Math.max(...s.map(c=>c.x))+o,minY:Math.min(...s.map(c=>c.y))-o,maxY:Math.max(...s.map(c=>c.y))+o}));for(let s=0;s<n.length;s++)for(let c=s+1;c<n.length;c++){let l=a[s],u=a[c];if(l.maxX<u.minX||u.maxX<l.minX||l.maxY<u.minY||u.maxY<l.minY)continue;n[s].some(m=>n[c].some(h=>Math.hypot(m.x-h.x,m.y-h.y)<=o))&&(e[r(s)]=r(c))}let i=new Map;return n.forEach((s,c)=>{let l=r(c),u=i.get(l);u?u.push(...s):i.set(l,[...s])}),[...i.values()].filter(s=>new Set(s.map(c=>c.rowId)).size>=2)}function Qs(t,n,e){if(!n.length)return null;let r=n.filter(I=>e.tableIds.has(I.rowId)||I.kind==="booth").length>n.length/2,o=se(n),a=!e.outline||Xo(o,e.outline)>=Ms,i=0,s=0;for(let I of o.values()){if(I.length<2)continue;let S=I[0],B=I[I.length-1],T=B.x-S.x,F=B.y-S.y,k=Math.hypot(T,F);if(k<1e-6)continue;let w={x:(S.x+B.x)/2,y:(S.y+B.y)/2},E=a?e.outline?ce(w,e.outline):e.focal:e.middle,C=-F/k,L=T/k;C*(E.x-w.x)+L*(E.y-w.y)<0&&(C=-C,L=-L),i+=C*I.length,s+=L*I.length}let c={x:n.reduce((I,S)=>I+S.x,0)/n.length,y:n.reduce((I,S)=>I+S.y,0)/n.length};if(Math.hypot(i,s)<1e-9){let I=a?e.focal:e.middle;i=I.x-c.x,s=I.y-c.y}let l=Math.hypot(i,s)||1,u={x:i/l,y:s/l},f=I=>-(I.x*u.x+I.y*u.y),m=I=>-I.x*u.y+I.y*u.x,h=1/0,d=-1/0,y=1/0,b=-1/0,p=1/0,g=new Map;for(let I of n){let S=f(I),B=m(I);h=Math.min(h,S),d=Math.max(d,S),y=Math.min(y,B),b=Math.max(b,B),a&&(p=Math.min(p,qs(I,e.focal,e.outline)));let T=I.logicalRowId??I.rowId,F=g.get(T);F?F.push(S):g.set(T,[S])}a||(p=Math.max(0,h-f(e.middle)));let P=[...g.values()].map(I=>ie(I)).sort((I,S)=>I-S),A=[];if(!r)for(let I of P)A.length&&I-A[A.length-1]<ms/$||A.push(I);let M=Vs(t),x=zt(t,{floorBaseHeightM:e.baseHeightM}),_={id:t.id,section:t,authored:M,plane:e,facing:u,facesAction:a,hull:jo(n),sample:n.filter((I,S)=>S%Math.ceil(n.length/Ss)===0),frontD:h,backD:d,latMin:y,latMax:b,frontDistance:p,rowDepths:A,rowCount:A.length,level:0,height:x.height,rake:M?x.rake:0,backHeight:0};return _.backHeight=_.height+(d-h)*$*Math.tan(_.rake*Math.PI/180),_}function Js(t,n,e,r){if(t.length<2)return 0;let o=Math.max(1,n*$),a=e+as-r,i=0,s=0;for(let l=1;l<t.length;l++){let u=Math.max(hs,(t[l]-t[l-1])*$),f=(a+cs)*(o+u)/o;i+=f-a,s+=u,a=f,o+=u}let c=Math.atan(i/s)*180/Math.PI;return Math.round(Math.max(Do,Math.min(ls,c))*10)/10}function ta(t,n,e=!1){if(!e&&t.facing.x*n.facing.x+t.facing.y*n.facing.y<Rs)return null;let r=-1/0,o=1/0,a=-1/0;for(let m of n.hull){r=Math.max(r,-(m.x*t.facing.x+m.y*t.facing.y));let h=-m.x*t.facing.y+m.y*t.facing.x;o=Math.min(o,h),a=Math.max(a,h)}if(Math.min(t.latMax,a)-Math.max(t.latMin,o)<(e?1e-6:Go*(t.latMax-t.latMin)))return null;let s=Ho/$,c=new Map,l=new Map;for(let m of t.sample){let h=Math.floor((-m.x*t.facing.y+m.y*t.facing.x)/s),d=-(m.x*t.facing.x+m.y*t.facing.y);c.set(h,Math.min(c.get(h)??1/0,d))}for(let m of n.sample){let h=Math.floor((-m.x*t.facing.y+m.y*t.facing.x)/s),d=-(m.x*t.facing.x+m.y*t.facing.y);l.set(h,Math.max(l.get(h)??-1/0,d))}let u=[];for(let[m,h]of c){let d=l.get(m);d!==void 0&&u.push(h-d)}let f=u.length?ie(u):t.frontD-r;return f<-1/$?null:f}function na(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 c of n.hull){let l=-(c.x*t.facing.x+c.y*t.facing.y);e=Math.max(e,l),r=Math.min(r,l);let u=-c.x*t.facing.y+c.y*t.facing.x;o=Math.min(o,u),a=Math.max(a,u)}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>Go*(t.latMax-t.latMin)&&s>1/$}function ea(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 oa(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 ra(t,n){if(!t.facesAction)return!1;let e={x:-t.facing.y,y:t.facing.x},r=Ho/$,o=Math.max(1,Math.ceil((t.backD-t.frontD)/r)),a={left:new Map,right:new Map};for(let s of n)if(!(s===t||s.plane.floorIndex!==t.plane.floorIndex)&&!(s.facing.x*t.facing.x+s.facing.y*t.facing.y>=Ts))for(let c of s.sample){let l=-(c.x*t.facing.x+c.y*t.facing.y);if(l<t.frontD||l>t.backD)continue;let u=-c.x*t.facing.y+c.y*t.facing.x,f=u<t.latMin?"left":u>t.latMax?"right":null;if(!f)return!1;let m=Math.min(o-1,Math.floor((l-t.frontD)/r)),h=f==="left"?t.latMin-u:u-t.latMax;h<(a[f].get(m)?.gap??1/0)&&a[f].set(m,{gap:h,other:s})}let i=s=>{let c=s==="left"?t.latMin:t.latMax,l=0;for(let[u,{other:f}]of a[s]){if((f.facing.x*e.x+f.facing.y*e.y)*(s==="left"?1:-1)<Es)continue;let h=t.frontD+(u+.5)*r,d={x:-h*t.facing.x+c*e.x,y:-h*t.facing.y+c*e.y},y=-(d.x*f.facing.x+d.y*f.facing.y),b=-d.x*f.facing.y+d.y*f.facing.x;y<f.frontD&&b>=f.latMin&&b<=f.latMax&&l++}return l/o>=Bs};return i("left")&&i("right")}function ia(t,n){if(n.plane.floorIndex!==t.plane.floorIndex||n.facing.x*t.facing.x+n.facing.y*t.facing.y<Ls)return!1;let e=1/0,r=-1/0,o=1/0;for(let s of n.hull){let c=-s.x*t.facing.y+s.y*t.facing.x;e=Math.min(e,c),r=Math.max(r,c),o=Math.min(o,-(s.x*t.facing.x+s.y*t.facing.y))}let a=(t.frontD-o)*$;if(a<-vs||a>Ns)return!1;let i=Math.max(e-t.latMax,t.latMin-r);return i*$<=Ds&&i*$>=-Gs}function sa(t,n=!1,e=!1,r){let o=n?bs:xs,a=new Set(e?[]:t.filter(y=>!y.authored&&ra(y,t))),i=[...t].sort((y,b)=>y.plane.floorIndex-b.plane.floorIndex||Number(a.has(b))-Number(a.has(y))||y.frontDistance-b.frontDistance);for(let y of a)r?.add(y.id);let s=(y,b,p)=>{let g=new Map,P=[],A=new Map,M=x=>{if(x.plane.floorIndex===0||x.plane.baseHeightM>0)return x.plane.baseHeightM;let _=A.get(x.plane.floorIndex-1);return _===void 0?x.plane.baseHeightM:_+Qe};for(let x of i){if(a.has(x))x.height=M(x),x.level=0,x.rake=0,x.backHeight=x.height,g.set(x.id,void 0);else if(!x.authored){let I=M(x),S;for(let w of P){if(w.plane.floorIndex>x.plane.floorIndex)continue;if(na(x,w)){let O=oa(x,w)+Is;O>I&&(I=O,S=w);continue}let E=ta(x,w,a.has(w));if(E==null)continue;let C=e&&!!x.plane.stageDeck&&w.level===0&&w.plane.floorIndex===x.plane.floorIndex&&Math.max(0,E)*$<=As,L=a.has(w)?w.height+Os:C?w.backHeight:w.backHeight+us+Math.min(fs,Math.max(0,E)*$)*Math.tan(w.rake*Math.PI/180);L>I&&(I=L,S=w)}let B=y.get(x);B&&B.height>I+.01?(I=B.height,S=void 0):B=void 0,x.height=Math.round(Math.min(I,x.plane.baseHeightM+ps)*100)/100;let T=!S&&!B&&x.height>x.plane.baseHeightM;if(x.level=S?S.level+1:B?B.level:T?1:0,x.rake=Js(x.rowDepths,x.frontDistance,x.height,x.plane.focalHeightM),!x.facesAction&&x.rowCount<Ps)x.rake=0;else if(x.level===0){let w=Math.max(1e-6,(x.backD-x.frontD)*$);x.rake=Math.min(x.rake,ys,Math.round(Math.atan(ds/w)*1800/Math.PI)/10)}else x.rowCount>=2&&(x.rake=Math.max(x.rake,o[Math.min(x.level,o.length)-1]));let F=(x.backD-x.frontD)*$,k=S&&a.has(S)||B&&p?.has(B.id);if(b!==void 0&&k&&x.rowCount>=2&&(x.rake=b),n&&F>0&&x.height+F*Math.tan(x.rake*Math.PI/180)>x.plane.baseHeightM+Lo){let w=Math.max(0,x.plane.baseHeightM+Lo-x.height);x.rake=Math.max(Do,Math.round(Math.atan(w/F)*1800/Math.PI)/10)}e&&x.plane.stageDeck&&x.level>0&&(x.rake=Math.min(x.rake,ws)),x.backHeight=x.height+F*Math.tan(x.rake*Math.PI/180),g.set(x.id,S?.id??(B?g.get(B.id):void 0))}let _=x.plane.floorIndex;A.set(_,Math.min(A.get(_)??1/0,x.height)),P.push(x)}return g},c=s(new Map),l=new Map,u=y=>l.get(y)?.height??y.height;for(let y=!0,b=0;y&&b<t.length;b++){y=!1;for(let p of t)if(!(p.authored||a.has(p)))for(let g of t){let P=l.get(g)??g;g===p||P.height-P.plane.baseHeightM<Hs||P.height<=u(p)+.01||ia(p,g)&&(l.set(p,P),y=!0)}}let f=new Map(t.map(y=>[y.id,y])),m=t.filter(y=>!y.authored&&y.rowCount>=2&&a.has(f.get(c.get(y.id)??""))),h=m.length?ie(m.map(y=>y.rake)):void 0;if(!l.size&&h===void 0)return c;let d=new Map([...new Set(l.values())].map(y=>[y,{...y}]));return s(new Map([...l].map(([y,b])=>[y,d.get(b)])),h,new Set(m.map(y=>y.id)))}var oe=(t,n)=>!!t&&t.x===n.x&&t.y===n.y;function Uo(t,n={x:0,y:-40}){let e=In(t),r=new Map;for(let p of e){if(!p.sectionId)continue;let g=r.get(p.sectionId);g?g.push(p):r.set(p.sectionId,[p])}let o={focalInferred:!1,confident:!1,sections:[]},a=t.floors?.length?t.floors.map((p,g)=>({objects:p.objects,floorIndex:g,floorId:p.id,baseHeightM:p.baseHeightM??0,focal:p.focalPoint??t.focalPoint})):[{objects:t.objects,floorIndex:0,floorId:void 0,baseHeightM:0,focal:t.focalPoint}],i=new Set(a.flatMap(p=>p.objects.filter(g=>g.type==="table").map(g=>g.id))),s=[],c,l=new Set,u=a.map(p=>{let g=k=>!t.floors?.length||k.floorId===p.floorId,P=$s(e.filter(k=>!k.sectionId&&k.kind!=="booth"&&!i.has(k.rowId)&&g(k))),A=[];for(let k of P){let w=_t(Et(jo(k)),Us/$);if(e.some(C=>!g(C)&&ae(C,w)))continue;let E=`${vo}${p.floorIndex}-${A.length}`;l.add(E),r.set(E,k),A.push({type:"section",id:E,label:"",color:Ws,outline:w})}let M=A.length?{...p,objects:[...p.objects,...A]}:p,x=new Set(M.objects.filter(k=>k.type==="section").map(k=>k.logicalSectionId??k.id)),_=[...r.entries()].filter(([k])=>x.has(k)).flatMap(([,k])=>k),I=Zs(M.objects,se(_),_),S=M.focal;(I||M.focal&&!oe(M.focal,n))&&(o.confident=!0),I&&(o.stage??={id:I.shape.id,inferred:I.inferred,...M.floorId?{floorId:M.floorId}:{}},(I.inferred||oe(M.focal,n))&&(S=I.centre,o.focalInferred=!0));let B=I&&(!I.inferred||fn(I.outline)*$*$<=ee),T=I?void 0:c,F={tableIds:i,floorIndex:M.floorIndex,floorId:M.floorId,baseHeightM:M.baseHeightM,focal:T?.focal??S,outline:I?.outline??T?.outline,focalHeightM:T?.focalHeightM??M.baseHeightM+(I&&B?At({...I.shape,role:"stage"}).heightM:0),stageDeck:T?.stageDeck??!!(I&&B&&fn(I.outline)*$*$<=ee),middle:_.length?{x:_.reduce((k,w)=>k+w.x,0)/_.length,y:_.reduce((k,w)=>k+w.y,0)/_.length}:S};for(let k of M.objects){if(k.type!=="section")continue;let w=Qs(k,r.get(k.logicalSectionId??k.id)??[],F);w&&s.push(w)}return F.outline&&(c=F),oe(M.focal,F.focal)||(o.focal??=[]).push({...M.floorId?{floorId:M.floorId}:{},point:{...F.focal}}),{unit:M,plane:F,stage:I,planeSeats:_}}),f=a.flatMap(p=>p.objects).map(p=>p.type==="shape"&&!p.role&&(ne(p.label)==="wall"||!ne(p.label)&&Fo(p))?{...p,role:"wall"}:p),m=Nt({objects:f},e)!==null;m&&(o.indoor=!0);let h=new Set,d=sa(s,m,ea(e,u[0]?.plane.focal??n)<_s,h),y=new Map(s.filter(p=>!p.authored).map(p=>[p.id,p])),b=u.map(({unit:p,plane:g,stage:P,planeSeats:A})=>p.objects.map(M=>{let x=M.type==="shape"&&!M.role&&M.id!==P?.shape.id?ne(M.label):null;if(M.type==="shape"&&!M.role&&M.id!==P?.shape.id&&(x==="wall"||!x&&Fo(M))&&M.type==="shape"){(o.roles??=[]).push({id:M.id,...g.floorId?{floorId:g.floorId}:{},role:"wall"});let{fill:w,...E}=M;return{...E,role:"wall"}}if(x&&M.type==="shape")return(o.roles??=[]).push({id:M.id,...g.floorId?{floorId:g.floorId}:{},role:x}),{...M,role:x};let I=P?.inferred&&M.id===P.shape.id&&M.type==="shape"?zs(M,P.outline,p.objects,A):null;if(I&&M.type==="shape")return o.stage?.id===M.id&&(o.stage.field=I),{...M,role:"stage",stageKind:I};let S=M.type==="shape"&&M.id===P?.shape.id&&M.heightM===void 0&&!M.stageKind&&s.some(w=>w.plane===g&&(h.has(w.id)||w.level===0&&w.facesAction&&w.rake<=ks&&(w.frontDistance+w.backD-w.frontD)*$>=Fs)),B=S?{heightM:Cs}:{};if(P?.inferred&&M.id===P.shape.id&&M.type==="shape"&&fn(P.outline)*$*$<=ee)return o.stage?.id===M.id&&(o.stage.deck=!0),{...M,role:"stage",...B};if(S&&M.type==="shape"&&M.role==="stage")return{...M,...B};let T=M.type==="section"?y.get(M.id):void 0;if(!T||M.type!=="section")return M;let F=T.rowCount>=2&&T.rake>0;l.has(T.id)?o.looseRowBlocks=(o.looseRowBlocks??0)+1:o.sections.push({id:T.id,floorId:g.floorId,surfaceKind:F?"rakedRows":"flat",height:T.height,rake:T.rake,stackedOn:d.get(T.id)});let k={status:"inferred",source:"public-2d-topology",note:Ks};return{...M,height:T.height,rake:T.rake,surfaceKind:F?"rakedRows":"flat",physical3dProvenance:{height:k,rake:k,surfaceKind:k}}}));if(t.floors?.length){let p=t.floors.map((g,P)=>({...g,objects:b[P],focalPoint:u[P].plane.focal}));return{doc:{...t,floors:p,objects:p[0].objects,focalPoint:p[0].focalPoint},report:o}}return{doc:{...t,objects:b[0],focalPoint:u[0].plane.focal},report:o}}function Uu(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 Wu(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 aa=1.15,ca=2.75,la=4.5,ua=.85,fa=.5,ma=.26;function Yu(t,n,e){let r=Math.max(1e-6,n),o=t/r,a=e?.hasZoneLabels??!0,i=new Set(["stage","gate"]);return o>=.75&&i.add("floor"),o>=aa&&i.add("zone"),o<=(a?ca:la)&&(i.add("section"),i.add("ga")),o<=ua&&(i.add("annotation"),i.add("booth")),o<=fa&&i.add("row"),o<=ma&&i.add("seat"),i}function zu(t,n,e,r,o,a=6){let i=a+n,s=r-a-n,c=a+e,l=o-a-e;return{...t,x:i>s?r/2:Math.max(i,Math.min(s,t.x)),y:c>l?o/2:Math.max(c,Math.min(l,t.y))}}function Ku(t,n,e,r){let o=t,a=n[0],i=n[1],s=n[2],c=o[0]*a+o[4]*i+o[8]*s+o[12],l=o[1]*a+o[5]*i+o[9]*s+o[13],u=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=c/f,h=l/f,d=u/f,y=m>=-1.05&&m<=1.05&&h>=-1.05&&h<=1.05&&d<=1;return{x:(m*.5+.5)*e,y:(1-(h*.5+.5))*r,depth:d,visible:y}}function Vu(t,n,e=n,r=()=>0){let o=[],a=[...t].sort((i,s)=>r(s)-r(i)||i.screen.depth-s.screen.depth);for(let i of a){let s=!1;for(let c of o)if(le(i,c,n,e)){s=!0;break}s||o.push(i)}return o}var ha=6;function le(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+ha):e;return o<i&&a<r}function Zu(t,n,e){return t.length*n*.58+(e?14:0)}var ya={row:8,seat:14};function qu(t){return t<480?{row:5,seat:8}:t<768?{row:6,seat:10}:ya}function $u(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 Qu(t,n,e,r,o=[]){let a=[...t].sort((s,c)=>(c.priority??0)-(s.priority??0)||s.focus-c.focus),i=[];for(let s of a){if(i.length>=r)break;let c=!1;for(let l of o)if(le(s,l,n,e)){c=!0;break}if(!c){for(let l of i)if(le(s,l,n,e)){c=!0;break}}c||i.push(s)}return i}function Ju(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 Qt(t,n,e){if(t.length!==4||e<=n)return null;let r=bt(t),o=Math.hypot(r[1].x-r[0].x,r[1].y-r[0].y)*R,a=Math.hypot(r[3].x-r[0].x,r[3].y-r[0].y)*R;if(o<1e-6||a<1e-6)return null;let i=Math.min(.22/o,.16),s=Math.min(.28,(e-n)*.13),c=Math.min(.065/a,.2);return{quad:r,side:i,face:c,opening:dt(r,i,1-i),openingTop:e-s}}function ue(t,n,e){if(t.length!==4||e-n<=.2)return null;let r=bt(t),o=Math.hypot(r[1].x-r[0].x,r[1].y-r[0].y)*R;if(o<=1e-6)return null;let a=Math.min(.14,(e-n)*.08,o*.08),i=a/o,s=dt(r,i,1-i);return{quad:r,side:i,trim:a,inner:s,panel:ln(s,.15,.85),bottom:n+a,top:e-a}}function Wo(t,n,e,r){let o=ue(t,n,e);if(!o)return;let{panel:a}=o,i=(g,P)=>({x:(g.x+P.x)/2,y:(g.y+P.y)/2}),s=i(a[0],a[1]),c=i(a[3],a[2]),l=Math.hypot(s.x-r.x,s.y-r.y)<=Math.hypot(c.x-r.x,c.y-r.y),[u,f]=l?[a[0],a[1]]:[a[3],a[2]],m=l?{x:s.x-c.x,y:s.y-c.y}:{x:c.x-s.x,y:c.y-s.y},h=Math.hypot(m.x,m.y);if(h<1e-6)return;-(f.y-u.y)*m.x+(f.x-u.x)*m.y<0&&([u,f]=[f,u]);let d=Math.min(.006,h*R*.05),y=m.x/h*d,b=m.y/h*d,p=(g,P)=>[g.x*R+y,P,g.y*R+b];return[p(u,o.bottom),p(f,o.bottom),p(u,o.top),p(f,o.top)]}import pa from"polygon-clipping";import da from"polygon-clipping";function Ot(t,n,e,r,o,a,i,s={}){let c=Tt(n),l=s.ao??K,u=o.flatMap(y=>{if(y.role!=="entrance"&&y.role!=="exit")return[];let b=ct(y);if(!b||b.length!==4||!Vt(c,Tt(b)))return[];let p=s.portalBase??e,g=Qt(b,p,p+At(y).heightM);if(!g)return[];let P=Math.min(r,g.openingTop);return P<=e?[]:[{poly:g.opening,height:P}]});if(!u.length)return!1;let f=y=>y.map(b=>[b.x,b.y]),m=[f(n),...(s.holes??[]).map(f)],h=[e,...new Set(u.map(y=>y.height)),r].sort((y,b)=>y-b),d=[];try{for(let y=1;y<h.length;y++){let b=h[y-1],p=h[y];if(p-b<1e-6)continue;let g=u.filter(A=>A.height>b+1e-6).map(A=>[f(A.poly)]),P=g.length?da.difference(m,...g):[m];d.push({low:b,high:p,polys:P})}}catch{return!1}for(let y of d)for(let b of y.polys){let[p,...g]=b.map(A=>A.map(([M,x])=>({x:M,y:x}))),P=A=>l.wallBottom+(l.top-l.wallBottom)*(A-e)/(r-e);Z(t,p,g,()=>y.high,y.low,a,i,{...l,top:P(y.high),wallBottom:P(y.low)})}return!0}var fe={depthM:1.6,thicknessM:.35,minWallM:6};function kn(t,n,e,r,o,a,i,s,c){let l=r-e;if(l<=0)return;let u=s&&(c??l)>=fe.minWallM?xa(n,s):null,f=u?r-fe.thicknessM:r,m=f-e,h=m<1.5?[[e,f,1]]:u?[[e,e+Math.min(.9,m*.18),.82],[e+Math.min(.9,m*.18),f,1]]:[[e,e+Math.min(.9,m*.18),.82],[e+Math.min(.9,m*.18),f-.1,1],[f-.1,f,1.1]],d=y=>K.wallBottom+(K.top-K.wallBottom)*(y-e)/l;for(let[y,b,p]of h){let g={...K,top:d(b),wallBottom:d(y)},P=V(a,p),A=V(i,p);Ot(t,n,y,b,o,P,A,{portalBase:e,ao:g})||Z(t,n,void 0,()=>b,y,P,A,g)}for(let[y,...b]of u??[])Z(t,y,b.length?b:void 0,()=>r,f,V(a,1.12),V(i,.78),K)}function xa(t,n){let e=fe.depthM/R,r=t.map(i=>{let s=n.x-i.x,c=n.y-i.y,l=Math.hypot(s,c)||1;return{x:i.x+s/l*e,y:i.y+c/l*e}}),o=i=>{let s=i.map(c=>[c.x,c.y]);return s.push(s[0]),s},a=[[o(t)],[o(r)]];for(let i=0;i<t.length;i++){let s=(i+1)%t.length;a.push([o([t[i],t[s],r[s],r[i]])])}try{let[i,...s]=a,c=pa.union(i,...s);return c.length?c.map(l=>l.map(u=>u.slice(0,-1).map(([f,m])=>({x:f,y:m})))):null}catch{return null}}function mn(t,n,e){let r=it(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?qt(n.points??[],n.rotation):ct(n);if(!i||i.length<2)return;let s=o*.5,c=ze(n)?Ve(i,...Ke(o)):Array.from({length:a?i.length-1:i.length},(l,u)=>[i[u],i[(u+1)%i.length]]);for(let[l,u]of c){let f=Math.hypot(u.x-l.x,u.y-l.y);if(f<1e-6)continue;let m=-(u.y-l.y)/f*s,h=(u.x-l.x)/f*s,d=[(l.x+m)*R,e,(l.y+h)*R],y=[(u.x+m)*R,e,(u.y+h)*R],b=[(u.x-m)*R,e,(u.y-h)*R],p=[(l.x-m)*R,e,(l.y-h)*R];t.tri(d,y,b,[0,1,0],r),t.tri(d,b,p,[0,1,0],r)}}function Yo(t){return t==="bar"||t==="concession"||t==="coat"||t==="restroom"}var Jt=(t,n,e)=>({x:t.x+(n.x-t.x)*e,y:t.y+(n.y-t.y)*e});function Fn(t,n,e,r){let[o,a,i,s]=n?t:[t[3],t[2],t[1],t[0]];return[Jt(o,s,e),Jt(a,i,e),Jt(a,i,r),Jt(o,s,r)]}function zo(t,n,e,r,o,a,i,s,c=!1){if(e.length!==4||o-r<.4)return!1;let l=I=>c?Math.min(I,o):I,u=bt(e),f=Math.hypot(u[3].x-u[0].x,u[3].y-u[0].y)*R;if(f<.4)return!1;let m=Jt(u[0],u[1],.5),h=Jt(u[3],u[2],.5),d=Math.hypot(m.x-s.x,m.y-s.y)<=Math.hypot(h.x-s.x,h.y-s.y),y=st(i,[.92,.9,.86],.35),b=V(a,.72),p=o-r;if(n==="restroom"){let I=Math.min(.18,p*.08);return ot(t,u,o-I,r,i,a),ot(t,u,o,o-I,y,y),!0}let g=r+Math.min(1.1,p),P=n==="coat"?1:Math.min(.5,.75/f),A=Fn(u,d,0,P);if(ot(t,A,g-.05,r,b,a),ot(t,A,g,g-.05,y,y),n==="coat"||f<1.2)return!0;if(n==="bar"){let I=Fn(u,d,Math.max(P+.2,1-.45/f),1),S=l(r+Math.max(Math.min(2.2,p*2),g-r+.6));return ot(t,I,S,r,i,b),!0}let M=Fn(u,d,Math.max(P+.25,.55),1),x=l(r+Math.max(2.6,g-r+1.4));if(x-.14<=g)return!0;ot(t,M,x-.14,r,i,a),ot(t,u,x,x-.14,y,b);let _=Math.min(.08,.1/Math.max(.1,Math.hypot(u[1].x-u[0].x,u[1].y-u[0].y)*R));for(let[I,S]of[[0,_],[1-_,1]])ot(t,Fn(dt(u,I,S),d,0,Math.min(.08,.1/f)),x-.14,g,b,b);return!0}var Dt=.06,ba=.05,Vo=.05,Ko=.15,me=25;function Zo(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),c=new Map,l=[],u=new Set;for(let m=0;m<t.length;m+=1){let h=t[m];for(let d of h.objects){if(d.type==="table"&&u.add(d.id),d.type!=="section"||!d.outline||d.outline.length<3)continue;let y=_t(d.outline,St);c.set(d.id,{section:d,unit:h,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),l.push({id:d.id,floorIndex:m,box:Tt(y),section:d,unit:h,outline:y})}}let f=new Map;for(let m of l){let h=f.get(m.floorIndex);h?h.push(m):f.set(m.floorIndex,[m])}for(let m=0;m<n.length;m++){let h=n[m],d=e?f.get(e[m])??[]:l,y=h.sectionId?d.find(p=>p.id===h.sectionId)??d.find(p=>p.section.logicalSectionId===h.sectionId&&Rt({x:h.x,y:h.y},p.outline,p.section.holes)):void 0,b=y?[y]:d;for(let p of b){if(e&&p.floorIndex!==e[m]||!y&&(h.x<p.box.minX||h.x>p.box.maxX||h.y<p.box.minY||h.y>p.box.maxY||!Rt({x:h.x,y:h.y},p.outline,p.section.holes)))continue;o[m]=p.id;let g=c.get(p.id);g.hasSeats=!0;let P=h.focalPoint??p.unit.focal,A=Math.hypot(h.x-P.x,h.y-P.y);A<g.frontU&&(g.frontU=A),g.seatIndices.push(m);let M=h.rowId||`__seat-${m}`,x=g.rows.get(M);x?x.push({x:h.x,y:h.y}):g.rows.set(M,[{x:h.x,y:h.y}]);break}}for(let[m,h]of c){let d=zt(h.section,{floorBaseHeightM:h.unit.baseHeightM}),y=h.unit.baseHeightM,b=d.rake>0?Math.tan(d.rake*Math.PI/180):0,p=d.rake<=.01&&d.height<=y+.001,g=h.section.surfaceKind,P=g==="flat"?!0:g==="rakedRows"&&d.rake>.01?!1:p,A=h.hasSeats?Le(m,n,h.seatIndices,h.unit.focal):{sectionId:m,rows:[],blockCount:0},x=A.rows.length<2?Ze([...h.rows.values()].map(O=>({points:O})),h.unit.focal):null,_=1/0;if(x){if(h.hasSeats)for(let O of h.rows.values())for(let D of O){let H=x.depthAt(D.x,D.y);H<_&&(_=H)}if(!h.hasSeats||!Number.isFinite(_)){_=1/0;for(let O of h.section.outline){let D=x.depthAt(O.x,O.y);D<_&&(_=D)}}}let I=y+ba,S=Math.max(I,d.height),B=O=>{let D=Math.max(0,O-_)*$,H=Math.min(D*b,me);return Math.max(I,d.height+H)},T=O=>{let D=Math.max(0,O)*$,H=Math.min(D*b,me);return Math.max(I,d.height+H)},F=P?[]:A.rows.map(O=>({pts:O.pts,y:T(O.blockDepth),depth:O.blockDepth,blockId:O.blockId,...u.has(O.id)?{patch:bo(O.pts,St)}:{}})),k=F.length?F[0].y:S,w=F.map(O=>{let D=O.patch&&O.patch.length>=3?O.patch:O.pts,H=0,j=0;for(let X of D)H+=X.x,j+=X.y;let G=D.length||1;H/=G,j/=G;let U=0;for(let X of D){let Y=Math.hypot(X.x-H,X.y-j);Y>U&&(U=Y)}return{cx:H,cy:j,rad:U}}),E=P?()=>S:F.length>=2?(O,D)=>{let H=1/0,j=k;for(let G=0;G<F.length;G++){let U=w[G];if(Math.hypot(O-U.cx,D-U.cy)-U.rad>=H)continue;let X=F[G].patch,Y=X&&X.length>=3?xt(X,O,D)?0:Rn(X,O,D):Rn(F[G].pts,O,D);Y<H&&(H=Y,j=F[G].y)}return j}:(O,D)=>x?B(x.depthAt(O,D)):S,C=[0,1,0],L=F.length>=2||P?()=>C:(O,D)=>{if(!x)return C;let H=x.depthAt(O,D);if(H<=_)return C;let j=(H-_)*$;if(j*b>=me||d.height+j*b<=I)return C;let[G,U]=x.gradientAt(O,D);if(G===0&&U===0)return C;let X=1/Math.hypot(b,1);return[-G*b*X,X,-U*b*X]};if(!P)for(let O of A.rows){let D=T(O.blockDepth);for(let H of O.seatIndices)i[H]=D}for(let O of A.rows){let D=[];for(let X=1;X<O.pts.length;X++){let Y=Math.hypot(O.pts[X].x-O.pts[X-1].x,O.pts[X].y-O.pts[X-1].y);Y>1e-6&&D.push(Y)}D.sort((X,Y)=>X-Y);let H=D.length?D[Math.floor(D.length/2)]:1/0,j=1/0,G=O.pts[Math.floor(O.pts.length/2)];if(G)for(let X of A.rows){if(X===O||X.blockId!==O.blockId)continue;let Y=Rn(X.pts,G.x,G.y);Y>1e-6&&Y<j&&(j=Y)}let U=Math.min(H,Math.max(j,H*.5));if(Number.isFinite(U)&&U>0)for(let X of O.seatIndices)s[X]=U}r.set(m,{sectionId:m,deckAt:E,normalAt:L,flat:P,bottomY:y,rowLevels:F,landingY:k})}for(let m=0;m<n.length;m++){let h=o[m],d=n[m];if(h){let p=i[m];a[m]=(p??r.get(h).deckAt(d.x,d.y))+Ko;continue}let y=d.eyeHeightM,b=Number.isFinite(y)?Math.max(0,y-Pn):0;a[m]=d.kind==="booth"?b+Dt+Ko:b}return{bySection:r,seatOwner:o,seatDeckY:m=>a[m],seatPitchU:m=>s[m]}}var ga=[.12,.38,.16],Ma=[.72,.62,.45],Pa=[.88,.93,.96],qo=[.95,.95,.94],Ra=[.66,.29,.22],he={length:20.12,width:3.05},Sa=.14,Ia=9.76,Ct=[.93,.94,.95],Ln=[.1,.11,.13],_a=[.45,.85,1.25],Aa=1.45,$o=.012,Qo=.004,wa=1.07,Ea=.15;function nn(t,n,e,r,o,a){t.setMaterial(a),Z(t,n,e?[e.slice().reverse()]:void 0,()=>r,r-.004,o,o,K)}var Jo=(t,n)=>Lt(t,n/R);function tr(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 Ba(t,n,e,r){let o=n.map(a=>[a.x*R,e,a.y*R]);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 vn(t,n,e,r,o,a){let i=e/R,s=[{x:n.x-i,y:n.y-i},{x:n.x+i,y:n.y-i},{x:n.x+i,y:n.y+i},{x:n.x-i,y:n.y+i}];Z(t,s,void 0,()=>o,r,a,V(a,.85),K)}function tn(t,n,e,r,o,a,i){let s=tr(n,e,r/R);s&&Z(t,s,void 0,()=>a,o,i,V(i,.85),K)}function Nn(t){let n=bt(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:(c,l)=>({x:e.x+(a.x*c+i.x*l)/R,y:e.y+(a.y*c+i.y*l)/R}),lengthM:r*R,widthM:o*R}}function nr(t,n,e){let r=Ne(n);if(!r.length)return;let o=1/0,a=-1/0,i=1/0,s=-1/0;for(let P of n.points??[])o=Math.min(o,P.x),a=Math.max(a,P.x),i=Math.min(i,P.y),s=Math.max(s,P.y);let c=(n.rotation??0)*Math.PI/180,l=Math.cos(c),u=Math.sin(c),f=(o+a)/2,m=(i+s)/2,h=P=>c?{x:f+(P.x-f)*l-(P.y-m)*u,y:m+(P.x-f)*u+(P.y-m)*l}:P,d=Math.min(a-o,s-i)*R,y=Math.max(.04,Math.min(.3,d*.004))/R,b=0;t.setMaterial(0);for(let P of r){if(!P.fill)continue;let A=P.points.map(h);nn(t,A,null,e+$o+b*Qo,it(P.fill)??Ct,0),b++}let p=r.filter(P=>!(P.fill&&P.ink===P.fill)),g=[...new Set(p.map(P=>P.ink??Kn))];for(let P of g){let A=e+$o+b++*Qo,M=it(P)??Ct;for(let x of p){if((x.ink??Kn)!==P)continue;let _=x.points.map(h),I=x.closed?_.length:_.length-1;for(let S=0;S<I;S++){let B=tr(_[S],_[(S+1)%_.length],y);B&&Ba(t,B,A,M)}}}}function er(t,n,e,r,o){if(n.length<3)return!1;let a=r+.006,i=o??ga;if(e==="oval-cricket"){let s=n.reduce((M,x)=>M+x.x,0)/n.length,c=n.reduce((M,x)=>M+x.y,0)/n.length,l=M=>n.map(x=>({x:s+(x.x-s)*M,y:c+(x.y-c)*M})),u=8;for(let M=0;M<u;M++){let x=l(1-M/u),_=M===u-1?null:l(1-(M+1)/u);nn(t,x,_,a,V(i,M%2?1.04:.96),4)}let f=n[0];for(let M of n)Math.hypot(M.x-s,M.y-c)>Math.hypot(f.x-s,f.y-c)&&(f=M);let m=Math.hypot(f.x-s,f.y-c)||1,h=(f.x-s)/m,d=(f.y-c)/m,y=-d,b=h,p=Math.min(1,2*m*R*Sa/he.length),g=he.length*p/2/R,P=he.width*p/2/R,A=[[-g,-P],[g,-P],[g,P],[-g,P]].map(([M,x])=>({x:s+h*M+y*x,y:c+d*M+b*x}));return nn(t,A,null,a+.004,Ma,0),t.setMaterial(0),!0}if(e==="rink-hockey"){let s=Jo(n,Ea);return nn(t,s,null,a,Pa,0),t.setMaterial(0),Z(t,n,[s.slice().reverse()],()=>r+wa,r,qo,V(qo,.9),K),!0}if(e==="ring-boxing"&&n.length===4){let{at:s}=Nn(n),c=[s(-3.05,-3.05),s(3.05,-3.05),s(3.05,3.05),s(-3.05,3.05)],l=[[.77,.19,.19],Ct,[.17,.42,.69],Ct];t.setMaterial(0),c.forEach((u,f)=>vn(t,u,.07,r,r+Aa,l[f]));for(let u of _a)for(let f=0;f<4;f++)tn(t,c[f],c[(f+1)%4],.025,r+u-.025,r+u+.025,Ct);return!0}if(e==="court-tennis"&&n.length===4){let{at:s}=Nn(n);t.setMaterial(0),tn(t,s(0,-6.4),s(0,6.4),.015,r,r+.95,Ln),tn(t,s(0,-6.4),s(0,6.4),.03,r+.95,r+1,Ct);for(let c of[-1,1])vn(t,s(0,c*6.4),.05,r,r+1.07,Ln);return!0}if(e==="court-basketball"&&n.length===4){let{at:s,lengthM:c}=Nn(n),l=Math.min(14,c/2-.5);t.setMaterial(0);for(let u of[-1,1]){let f=s(u*(l+1.2),0),m=s(u*(l-1.2),0);vn(t,f,.12,r,r+3.4,Ln),tn(t,f,m,.06,r+3.25,r+3.4,Ln),tn(t,s(u*(l-1.2),-.9),s(u*(l-1.2),.9),.03,r+2.9,r+3.95,Ct)}return!0}if(e==="pitch-rugby"&&n.length===4){let{at:s,lengthM:c}=Nn(n),l=c*(50/120);t.setMaterial(0);for(let u of[-1,1]){for(let f of[-2.8,2.8])vn(t,s(u*l,f),.07,r,r+12,Ct);tn(t,s(u*l,-2.8),s(u*l,2.8),.06,r+2.94,r+3.06,Ct)}return!0}if(e==="track-athletics"){let s=Jo(n,Ia);return s.length<3?!1:(nn(t,n,s,a,Ra,0),nn(t,s,null,a,i,4),t.setMaterial(0),!0)}return!1}var or=[.19,.4,.15],Ta=.012,Xn=2.4,Oa=1,Ca=.75,ka=.15;function wt(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),c=e/2,l=r/2;return[[-c,-l],[c,-l],[c,l],[-c,l]].map(([u,f])=>({x:n.x+u*i-f*s,y:n.y+u*s+f*i}))}function lr(t,n,e,r,o,a,i=!1){let s=wt(n);if(s){if(i){let c=jt(r,o.boothTop),l=Et([...s]);Z(t,_t(l,Fa/R),[l.slice().reverse()],()=>e+.03,e,c,V(c,.8),K);return}if(!(!n.points&&a&&va(t,s,e,r,a))){if(!n.points&&a&&s.length===4){La(t,s,e,r,a);return}Z(t,s,void 0,()=>e+Xn,e,jt(r,o.boothTop),o.boothWall,K)}}}var ye=1.1,rr=[.9,.9,.88],Fa=.1,Dn=[.87,.87,.85],ir=.08;function ur(t,n){let e=c=>({x:(t[c].x+t[(c+1)%4].x)/2,y:(t[c].y+t[(c+1)%4].y)/2}),r=0,o=1/0;for(let c=0;c<4;c++){let l=e(c),u=Math.hypot(l.x-n.x,l.y-n.y);u<o&&(o=u,r=c)}let a=[0,1,2,3].map(c=>t[(r+c)%4]),i=(c,l,u)=>({x:c.x+(l.x-c.x)*u,y:c.y+(l.y-c.y)*u});return{q:a,part:(c,l,u,f)=>{let m=i(a[0],a[1],c),h=i(a[0],a[1],l),d=i(a[3],a[2],c),y=i(a[3],a[2],l);return[i(m,d,u),i(h,y,u),i(h,y,f),i(m,d,f)]},depthM:Math.hypot(a[3].x-a[0].x,a[3].y-a[0].y)*R,widthM:Math.hypot(a[1].x-a[0].x,a[1].y-a[0].y)*R}}function La(t,n,e,r,o){let{q:a,part:i}=ur(n,o),s=r??[.35,.42,.55],c=st(s,[.78,.78,.77],.62),l=st(s,[.95,.95,.94],.45);ot(t,a,e+Dt,e,c,V(c,.8)),ot(t,i(.05,.95,.72,.98),e+ye-.05,e+Dt,l,V(l,.8)),ot(t,i(.03,.97,.7,1),e+ye,e+ye-.05,rr,V(rr,.9))}function va(t,n,e,r,o){if(n.length!==4)return!1;let{q:a,part:i,depthM:s,widthM:c}=ur(n,o);if(s<1||c<1)return!1;let l=r??[.35,.42,.55],u=st(l,[.78,.78,.77],.62),f=e+Xn,m=ir/c,h=ir/s;ot(t,a,e+Dt,e,u,V(u,.8)),ot(t,i(0,1,1-h,1),f,e+Dt,Dn,V(Dn,.9));for(let[b,p]of[[0,m],[1-m,1]])ot(t,i(b,p,0,1-h),f,e+Dt,Dn,V(Dn,.9));ot(t,i(m,1-m,0,Math.min(.5,.06/s)),f,f-.3,l,V(l,.85));let d=Math.min(.4,.6/c),y=Math.min(.12,.3/s);return ot(t,i(.5-d,.5+d,.72-y,.72+y),e+Oa,e+Dt,st(l,[.95,.95,.94],.7),V(l,.75)),!0}function jn(t){if(t.shape==="round"){let u=t.radius;return u?En(t.center.x,t.center.y,u,u,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),c=n/2,l=e/2;return[[-c,-l],[c,-l],[c,l],[-c,l]].map(([u,f])=>({x:o.x+u*i-f*s,y:o.y+u*s+f*i}))}function fr(t,n,e,r,o,a=!0){let i=jn(n);if(!i)return;let s=i.reduce((m,h)=>m+h.x,0)/i.length,c=i.reduce((m,h)=>m+h.y,0)/i.length,l=m=>i.map(h=>({x:s+(h.x-s)*m,y:c+(h.y-c)*m})),u=a&&r?jt(r,o.tableTop):Na,f=e+Ca;Z(t,i,void 0,()=>f,e+Da,u,V(u,.86),K),Z(t,l(.12),void 0,()=>f+.12,f,sr,V(sr,.8),K)}var Na=[.93,.92,.89],sr=[.78,.66,.42],Da=.25,hn={armM:1.1,widthM:.28,insideM:1.4,low:.043,high:.048};function Ga(t,n,e){let r=t.reduce((p,g)=>p+g.x,0)/4,o=t.reduce((p,g)=>p+g.y,0)/4,a=t[3].x-t[0].x,i=t[3].y-t[0].y,s=Math.hypot(a,i)||1;a/=s,i/=s,a*(n.x-r)+i*(n.y-o)<0&&(a=-a,i=-i);let c=-i,l=a,u=hn.armM/R,f=hn.widthM/R,m=s/2+hn.insideM/R,h=e?-1:1,d=r+a*(m+(e?0:u)),y=o+i*(m+(e?0:u)),b=(p,g)=>({x:d+a*p*h+c*g,y:y+i*p*h+l*g});return[b(0,0),b(-u,u),b(-u-f,u),b(-f,0),b(-u-f,-u),b(-u,-u)]}function Ha(t,n,e,r,o){let a=[.94,.95,.96];Z(t,Ga(n,r,o),void 0,()=>e+hn.high,e+hn.low,a,a,K)}function Hn(t,n){let e=it(t);return e?{top:V(It(e,.12),.95),wall:V(It(e,.12),.85)}:{top:n.tierTop,wall:n.tierWall}}function mr(t,n,e,r,o,a,i,s,c=[]){let l=ct(n),u=To(n);if(!n.role&&(!n.fill||n.fill==="none"||n.fill==="transparent")||!l){mn(t,n,e+r+Ta);return}let m=s?s.kind==="stage":n.role==="stage",h=s?s.kind==="screen":n.role==="screen",d=s?{kind:m?"stage":"solid",heightM:s.topY-s.baseY}:At(n),y=s?.baseY??e,b=s?.topY??e+r;if(m&&i){let S=1/0,B=-1/0,T=1/0,F=-1/0;for(let k of l)k.x<S&&(S=k.x),k.x>B&&(B=k.x),k.y<T&&(T=k.y),k.y>F&&(F=k.y);i.push({cx:(S+B)/2*R,cz:(T+F)/2*R,y:b,halfX:Math.max((B-S)/2*R,.5),halfZ:Math.max((F-T)/2*R,.5)})}let p=it(n.fill),g=n.role==="wall"||n.role==="entrance"||n.role==="exit",P=g?Hn(n.fill,o).top:m&&p?st(o.stageTop,V(It(p,.18),.9),.9):!n.role&&p?p:jt(p,m?o.stageTop:o.decorTop),A=h?p:null,M=g?Hn(n.fill,o).wall:m?p?st(o.stageWall,V(p,.58),.82):o.stageWall:h?A?st(V(A,1.42),[.24,.46,.82],.08):[.24,.46,.82]:jt(it(n.fill),o.decorWall);if(n.role==="wall"&&!s){kn(t,l,y,b,c,P,M,a),mn(t,n,b+.012);return}if(h&&l.length===4&&b-y>.2){let S=ue(l,y,b);if(!S)return;let{quad:B,side:T,trim:F,inner:k,panel:w}=S,E=[.12,.15,.18];for(let[C,L]of[[0,T],[1-T,1]])ot(t,dt(B,C,L),b,y,E,E);ot(t,k,y+F,y,E,E),ot(t,k,b,b-F,E,E),ot(t,w,b-F,y+F,M,M),mn(t,n,b+.012);return}let x=p?V(It(p,.15),.82):M,_=p?V(It(p,.1),1.02):P;if(Yo(n.role)&&!s&&zo(t,n.role,l,y,b,x,_,a,n.heightM!==void 0))return;if((n.role==="sound"||s?.kind==="sound_desk")&&l.length===4&&b-y>.3){let S=bt(l),B=Math.hypot(S[1].x-S[0].x,S[1].y-S[0].y)*R,T=Math.min(.12,.09/Math.max(B,.001)),F=[.18,.21,.24],k=b-Math.min(.12,(b-y)*.15);for(let[w,E]of[[0,T],[1-T,1]])ot(t,dt(S,w,E),k,y,F,F);ot(t,S,b,k,P,F);return}if(n.role==="rail"&&l.length===4&&b>y){let S=bt(l),B=Math.hypot(S[1].x-S[0].x,S[1].y-S[0].y)*R,T=Math.max(1,Math.min(128,Math.ceil(B/1.4))),F=Math.min(.08,.055/Math.max(.055,B)),k=[.58,.64,.66];for(let w=0;w<=T;w++){let E=w/T,C=Math.min(1-F,Math.max(0,E-F/2));ot(t,dt(S,C,C+F),b,y,k,V(k,.8))}for(let w of[.52,1]){let E=y+(b-y)*w;ot(t,S,E,Math.max(y,E-.055),k,V(k,.8))}return}if(n.role==="goal"&&l.length===4){let S=bt(l),B=Math.hypot(S[1].x-S[0].x,S[1].y-S[0].y)*R,T=Math.min(.12,.1/Math.max(.1,B)),F=[.9,.94,.94];for(let[k,w]of[[0,T],[1-T,1]])ot(t,dt(S,k,w),Math.max(y,b-.1),y,F,F);ot(t,S,b,Math.max(y,b-.1),F,F);return}if(d.kind==="portal"&&l.length===4){let S=Qt(l,y,b);if(!S)return;let{quad:B,side:T,face:F,openingTop:k}=S;for(let[w,E,C]of[[0,F,1],[F,1-F,.67],[1-F,1,1]]){let L=ln(B,w,E),O=V(P,C),D=V(M,C);for(let[H,j]of[[0,T],[1-T,1]])ot(t,dt(L,H,j),k,y,O,D);ot(t,L,b,k,O,D)}(n.role==="entrance"||n.role==="exit")&&Ha(t,B,y,a,n.role==="exit");return}if(d.kind==="suite"&&l.length===4){let S=l.map((F,k)=>{let w=l[(k+1)%4],E=(F.x+w.x)/2,C=(F.y+w.y)/2;return Math.hypot(E-a.x,C-a.y)}),B=S.indexOf(Math.min(...S)),T=[0,1,2,3].map(F=>l[(B+F)%4]);ot(t,dt(T,0,.08),b,y,P,M),ot(t,dt(T,.92,1),b,y,P,M),ot(t,ln(T,.88,1),b,y,P,M),ot(t,T,b,Math.max(y,b-.18),P,M);return}if(m&&!n.stageKind?.startsWith("pitch-")&&b-y>.12){let S=b-Math.min(.06,(b-y)*.15);ot(t,l,S,y,P,M,u),ot(t,l,b,S,P,st(P,M,.2),u)}else ot(t,l,b,y,P,M,u);if((n.stageKind==="pitch-football"||n.stageKind==="pitch-rugby")&&l.length===4){t.setMaterial(4);let S=bt(l),B=st(p??or,or,p?.45:0);for(let T=0;T<12;T++){let F=dt(S,T/12,(T+1)/12),k=V(B,T%2?1.09:.91),w=F.map(E=>[E.x*R,b+.006,E.y*R]);t.tri(w[0],w[1],w[2],[0,1,0],k),t.tri(w[0],w[2],w[3],[0,1,0],k)}}n.stageKind&&n.stageKind!=="pitch-football"&&er(t,l,n.stageKind,b,p),m&&Kt(n.stageKind)&&nr(t,n,b),t.setMaterial(h?1:0),mn(t,n,b+.012)}function Un(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,c=Math.cos(s),l=Math.sin(s),u=r/2,f=o/2;return[[-u,-f],[u,-f],[u,f],[-u,f]].map(([m,h])=>({x:a+m*c-h*l,y:i+m*l+h*c}))}function Xa(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 it(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 c=it(s[1].trim());c&&i.push(c)}return i.length?i.reduce((s,c,l)=>st(s,c,1/(l+1)),i[0]):null}function hr(t,n,e,r){if(n.layer==="foreground")return;let o=Un(n);if(!o)return;let a=e+ka,i=jt(Xa(n.href),r.decorTop),s=Math.max(0,Math.min(1,n.opacity??1));s<1&&(i=st(r.ground,i,s)),Z(t,o,void 0,()=>a,e,i,st(i,r.decorWall,.5),K)}function yr(t,n,e,r,o){if(!n.points||n.points.length<3)return;let a=lo(r,o.gaTop);Z(t,n.points,n.holes,()=>e+ar,e,a,o.gaWall,K),Wa(t,n.points,e+ar)}var ar=.15,Gn=[.72,.74,.76],de=1.1,cr=.12,pe=.05,ja=.06,Ua=2.4;function Wa(t,n,e){let r=Et([...n]),o=Lt(r,cr/R),a=Lt(r,(cr+pe)/R);if(o.length<3||a.length<3)return;for(let s of[e+de,e+de*.5])Z(t,o,[a.slice().reverse()],()=>s,s-pe,Gn,V(Gn,.85),K);let i=ja/2/R;for(let s=0;s<o.length;s++){let c=o[s],l=o[(s+1)%o.length],u=Math.hypot(l.x-c.x,l.y-c.y)*R,f=Math.max(1,Math.round(u/Ua));for(let m=0;m<f;m++){let h=m/f,d=c.x+(l.x-c.x)*h,y=c.y+(l.y-c.y)*h,b=[{x:d-i,y:y-i},{x:d+i,y:y-i},{x:d+i,y:y+i},{x:d-i,y:y+i}];Z(t,b,void 0,()=>e+de-pe,e,Gn,V(Gn,.8),K)}}}var Ya=1.5,za=30,Ka=4,Va=3.6,Za=6,xe=15,qa=3,$a=1;function Qa(t){return Math.max(Va,Math.min(Za,2.4+.15*t))}var yn=Math.PI*2;function Ja(t,n){let e=0,r=0;for(let f of t)e+=f.x,r+=f.y;let o=Math.atan2(r/t.length-n.y,e/t.length-n.x),a=t.map(f=>{let m=Math.atan2(f.y-n.y,f.x-n.x)-o;for(;m>Math.PI;)m-=yn;for(;m<-Math.PI;)m+=yn;return m+o}),i=a.map((f,m)=>m).sort((f,m)=>a[f]-a[m]),s=a[i[0]],c=a[i[i.length-1]];if(c-s>Math.PI)return null;let l=f=>Math.hypot(f.x-n.x,f.y-n.y),u=f=>{let m=t[f],h=(f+t.length-1)%t.length,d=(f+1)%t.length,y=Math.abs(a[h]-a[f])<=Math.abs(a[d]-a[f])?h:d,b=t[y];return l(m)<=l(b)?[m,b]:[b,m]};return{start:s,end:c,startEdge:u(i[0]),endEdge:u(i[i.length-1])}}function dr(t){return t.type==="shape"&&t.role==="wall"&&t.heightM===void 0}function be(t,n,e=()=>!0){let r=[];for(let c of t){if(!dr(c)||!e(c))continue;let l=ct(c);if(!l||l.length<3)continue;let u=Ja(l,n);if(!u)return[];r.push(u)}if(r.length<2)return[];let o=t.flatMap(c=>{if(c.type!=="shape"||c.role!=="entrance"&&c.role!=="exit")return[];let l=ct(c);if(!l?.length)return[];let u=0,f=0;for(let m of l)u+=m.x,f+=m.y;return[{x:u/l.length,y:f/l.length}]}),a=c=>(c%yn+yn)%yn;r.sort((c,l)=>a(c.start)-a(l.start));let i=c=>Math.hypot(c.x-n.x,c.y-n.y),s=[];for(let c=0;c<r.length;c++){let l=r[c],u=r[(c+1)%r.length],f=a(u.start-l.end);if(f<=0||f>=Math.PI/2)continue;let m=x=>a(x-l.end)<f;if(r.some(x=>x!==l&&x!==u&&(m(x.start)||m(x.end)||a(l.end-x.start)<x.end-x.start)))continue;let[d,y]=l.endEdge,[b,p]=u.startEdge,g={x:(d.x+y.x)/2,y:(d.y+y.y)/2},P={x:(b.x+p.x)/2,y:(b.y+p.y)/2},A=Math.hypot(P.x-g.x,P.y-g.y)*R;if(A<Ya||A>za||Math.abs(i(g)-i(P))*R>Ka+.2*A)continue;let M={x:(g.x+P.x)/2,y:(g.y+P.y)/2};o.some(x=>m(Math.atan2(x.y-n.y,x.x-n.x))&&Math.abs(i(x)-i(M))*R<=qa)||s.push({quad:[d,y,p,b],mid:M,widthM:A,openingM:Qa(A)})}return s}function pr(t,n){let e=[];for(let a of n)if(a.text?.trim())for(let i of t){let s=Math.hypot(a.position.x-i.mid.x,a.position.y-i.mid.y)*R;s<=xe&&e.push({text:a,gate:i,d:s})}e.sort((a,i)=>a.d-i.d);let r=new Map,o=new Set;for(let{text:a,gate:i}of e)r.has(a.id)||o.has(i)||(r.set(a.id,i),o.add(i));return r}function xr(t,n,e,r,o,a,i,s=()=>!0){let c=be(n,$t(e),s);if(!c.length)return;let l=n.find(f=>dr(f)&&s(f)),u=Hn(l?.fill,i);t.setMaterial(Cn);for(let f of c)o-f.openingM<$a||kn(t,f.quad,r+f.openingM,r+o,[],u.top,u.wall,a,o);t.setMaterial(0)}var tc=6,nc=2.2,Wn=.1,ec=/^(gate|entrance|entry|exit|way in|way out|door)s?$/i,oc=new Set(["stage","entrance","exit","screen","suite","obstruction","sound","bar","concession","restroom","coat"]),rc=.3,ic=1.8,sc=.9,ac=.55,cc=1,br=4e3,lc=6,gr="#d8a425",uc="#e8c15a",ge="#1c1608";function Mr(t){let n=fc(t);if(!n)return null;let e=De(t).find(r=>r.icon===n.icon);return{...n,name:e?.titleFallback??n.icon}}function fc(t){let n=t.accessibility;if(n?.length)return{icon:n.includes("wheelchair")?"wheelchair":n[0],color:Mn(n)};let e=t.commercial;return e?.obstructedView?{icon:"obstructedView",color:gr,ink:ge}:e?.restrictedView?{icon:"restrictedView",color:gr,ink:ge}:e?.premium?{icon:"premium",color:uc,ink:ge}:null}function mc(t,n){if(!t)return;let e,r=0;for(let[a,i]of t)i>r&&(r=i,e=a);let o=n.categories?.find(a=>a.key===e)?.color;return o&&/^#[0-9a-f]{6}$/i.test(o)?o:void 0}var hc=6e3,yc=.25,Pr=[-90,90,-135,135,-45,45];function dc(t,n,e,r){let o=t.flatMap(({id:i,a:s,members:c})=>{let l=(s.minX+s.maxX)/2,u=(s.minY+s.maxY)/2,f=.5*Math.hypot(s.maxX-s.minX,s.maxY-s.minY),m=1/0;for(let h of c)m=Math.min(m,Math.hypot(n[h].x-l,n[h].y-u));return c.length&&m>=f*yc?[{id:i,cx:l,cy:u,half:f,members:c}]:[]}).sort((i,s)=>i.half-s.half),a=new Map;return o.forEach(({id:i,cx:s,cy:c,members:l},u)=>{let f=r.x-s,m=r.y-c,y=(Math.hypot(f,m)>1e-6?Math.atan2(m,f):0)+Pr[u%Pr.length]*Math.PI/180,b=Math.cos(y),p=Math.sin(y),g=-1,P=-1/0;for(let A of l){let M=(n[A].x-s)*b+(n[A].y-c)*p;M>P&&(P=M,g=A)}a.set(i,[n[g].x*R,e.seatDeckY(g),n[g].y*R])}),a}function Sr(t){let{doc:n,units:e,seats:r,surfaces:o,focal:a}=t,i=n.zones??[],s=[];if(i.length){let c=new Map;for(let m of e)for(let h of m.objects)h.type==="section"&&h.zone&&c.set(h.id,h.zone);let l=new Map,u=new Map;for(let m=0;m<r.length;m++){let h=r[m],d=o.seatOwner[m],y=h.zoneId??(d?c.get(d):void 0);if(!y)continue;let b=l.get(y);b||(b={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},l.set(y,b));let p=u.get(y);p||u.set(y,p=[]),p.push(m),b.n++,h.x<b.minX&&(b.minX=h.x),h.y<b.minY&&(b.minY=h.y),h.x>b.maxX&&(b.maxX=h.x),h.y>b.maxY&&(b.maxY=h.y),b.sumY+=o.seatDeckY(m)}let f=dc(i.flatMap(m=>{let h=l.get(m.id);return h?[{id:m.id,a:h,members:u.get(m.id)??[]}]:[]}),r,o,a);for(let m of i){let h=l.get(m.id),d=[];for(let[y,b]of c)b===m.id&&d.push(y);if(!h||h.n===0){s.push({id:m.id,label:m.label,color:it(m.color),sectionIds:d,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(m.focalPoint??a).x*R,1.5,(m.focalPoint??a).y*R]});continue}s.push({id:m.id,label:m.label,color:it(m.color),sectionIds:d,seatCount:h.n,...f.has(m.id)?{labelAt:f.get(m.id)}:{},center:[(h.minX+h.maxX)/2*R,h.sumY/h.n,(h.minY+h.maxY)/2*R],radius:.5*Math.hypot((h.maxX-h.minX)*R,(h.maxY-h.minY)*R)||1,focalWorld:[(m.focalPoint??a).x*R,1.5,(m.focalPoint??a).y*R]})}}return s}function Ir(t){let{doc:n,units:e,seats:r,surfaces:o,seatData:a,hintedSeatFloor:i,zones:s,focal:c}=t,l=[],u=[],f=[],m=new Map;for(let h of e)for(let d of h.objects){if(d.type!=="section"||!d.zone)continue;let y=(d.displayLabel||d.label||"").trim().toLocaleLowerCase();if(!y)continue;let b=n.floors?.[h.index]?.name?.trim().toLocaleLowerCase();if(e.length>1&&b===y)continue;let p=m.get(d.zone);p||m.set(d.zone,p=new Set),p.add(y)}for(let h of s)h.seatCount!==0&&(m.get(h.id)?.has(h.label.trim().toLocaleLowerCase())||l.push({id:`zone:${h.id}`,kind:"zone",text:h.label,anchor:[(h.labelAt??h.center)[0],(h.labelAt??h.center)[1]+tc,(h.labelAt??h.center)[2]],color:n.zones?.find(d=>d.id===h.id)?.color}));{let h=new Map,d=new Map,y=new Map,b=new Map;for(let p=0;p<r.length;p++){let g=o.seatOwner[p];if(!g)continue;let P=h.get(g);P||(P={n:0,x:0,y:0,deck:0},h.set(g,P)),P.n++,P.x+=r[p].x,P.y+=r[p].y,P.deck+=o.seatDeckY(p);let A=r[p].categoryKey;if(A){let x=d.get(g);x||(x=new Map,d.set(g,x)),x.set(A,(x.get(A)??0)+1)}if(r[p].accessibility?.includes("wheelchair")){let x=y.get(g);x?x.push(p):y.set(g,[p])}let M=b.get(g);M||(M={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0,minDeck:1/0,maxDeck:-1/0},b.set(g,M)),M.minDeck=Math.min(M.minDeck,o.seatDeckY(p)),M.maxDeck=Math.max(M.maxDeck,o.seatDeckY(p)),r[p].x<M.minX&&(M.minX=r[p].x),r[p].x>M.maxX&&(M.maxX=r[p].x),r[p].y<M.minY&&(M.minY=r[p].y),r[p].y>M.maxY&&(M.maxY=r[p].y)}for(let p of e)for(let g of p.objects){if(g.type!=="section"||No(g))continue;let P=h.get(g.id);if(!P||P.n===0)continue;let A=b.get(g.id),M=[P.x/P.n*R,P.deck/P.n,P.y/P.n*R],x=g.displayLabel||g.label||g.id;u.push({id:g.id,floorIndex:p.index,label:x,seatCount:P.n,center:M,radius:Math.max(1,Math.hypot(A.maxX-A.minX,A.maxY-A.minY)*.5*R),box:{min:[A.minX*R-.4,A.minDeck,A.minY*R-.4],max:[A.maxX*R+.4,A.maxDeck+1,A.maxY*R+.4]},focalWorld:[p.focal.x*R,p.baseHeightM+1.5,p.focal.y*R]});let _=n.floors?.[p.index]?.name?.trim().toLocaleLowerCase();if(!(e.length>1&&_===x.trim().toLocaleLowerCase())){let I=mc(d.get(g.id),n),S=y.get(g.id);l.push({id:`section:${g.id}`,kind:"section",text:x,anchor:[M[0],M[1]+nc,M[2]],floorIndex:p.index,...I?{tint:I}:{},...S?{wheelchairSeats:S}:{}})}}}{for(let M of e)for(let x of M.objects){if(x.type!=="gaArea")continue;let _=Yt(x.points);if(!_)continue;let I=x.labelPresentation?.visible===!1?"":x.displayLabel||x.label||x.id,S=x.capacity>0?[I,x.capacity.toLocaleString()].filter(Boolean).join(" \xB7 "):I;S&&l.push({id:`ga:${x.id}`,kind:"ga",text:S,anchor:[_.x*R,M.baseHeightM+ic,_.y*R],floorIndex:M.index})}let h=new Map,d=new Map;for(let M of e)for(let x of M.objects)if(x.type==="section"&&h.set(x.id,x.displayLabel||x.label||x.id),x.type==="row"){let _=x.displayLabel?.trim()||x.segmentedRow?.displayLabel?.trim();_&&d.set(x.id,_)}let y=new Map;for(let M=0;M<r.length;M++){let x=r[M],_=Math.hypot(x.x-c.x,x.y-c.y),I=y.get(x.rowId);(!I||_>I.far)&&y.set(x.rowId,{seat:x,index:M,far:_})}for(let[M,x]of y){let _=o.seatOwner[x.index]??x.seat.sectionId,I=Rr(x.seat.label,M,h.get(_??""),d.get(M));I&&l.push({id:`row:${M}`,kind:"row",text:I,anchor:[x.seat.x*R,o.seatDeckY(x.index)+sc,x.seat.y*R],floorIndex:i[x.index]})}let b=new Map;for(let M=0;M<r.length;M++){let x=r[M],_=b.get(x.rowId);_||(_={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:Rr(x.label,x.rowId,h.get(o.seatOwner[M]??x.sectionId??""),d.get(x.rowId)),sectionId:o.seatOwner[M]??x.sectionId},b.set(x.rowId,_));let I=M*3,S=a.iPosition[I],B=a.iPosition[I+1],T=a.iPosition[I+2];_.n++,_.x+=S,_.y+=B,_.z+=T,_.minX=Math.min(_.minX,S),_.maxX=Math.max(_.maxX,S),_.minZ=Math.min(_.minZ,T),_.maxZ=Math.max(_.maxZ,T)}for(let[M,x]of b)f.push({id:M,label:x.label,sectionId:x.sectionId,seatCount:x.n,center:[x.x/x.n,x.y/x.n,x.z/x.n],radius:Math.max(.8,Math.hypot(x.maxX-x.minX,x.maxZ-x.minZ)*.5)});let p=0,g=(M,x)=>{p++,l.push({id:`access:${r[M].id}`,kind:"access",text:x.name,icon:x.icon,color:x.color,...x.ink?{ink:x.ink}:{},seatWidthM:a.iChairWidth[M]*2,anchor:[r[M].x*R,o.seatDeckY(M)+cc,r[M].y*R],floorIndex:i[M],rowId:r[M].rowId})},P=null,A=()=>{if(P){let M=Mr(r[P.seats[0]]),x=P.seats.length,_=Math.max(1,Math.round(x/lc));for(let I=0;I<_&&p<br;I++)g(P.seats[Math.min(x-1,Math.floor((I+.5)*x/_))],M)}P=null};for(let M=0;M<r.length&&p<br;M++){let x=Mr(r[M]);if(x&&r[M].accessibility?.length){A(),g(M,x);continue}if(!x){A();continue}P&&P.rowId===r[M].rowId&&P.icon===x.icon?P.seats.push(M):(A(),P={rowId:r[M].rowId,icon:x.icon,seats:[M]})}if(A(),r.length<=hc)for(let M=0;M<r.length;M++){let x=r[M],_=pc(x.displayLabel||x.label);_&&l.push({id:`seat:${x.id}`,kind:"seat",seatWidthM:a.iChairWidth[M]*2,text:_,anchor:[x.x*R,o.seatDeckY(M)+ac,x.y*R],floorIndex:i[M],rowId:x.rowId})}}for(let h of e){let d=Nt(h,e.length===1?r:r.filter((p,g)=>i[g]===h.index)),y=d?pr(be(h.objects,$t(d)),h.objects.filter(p=>p.type==="text")):new Map,b=[...y.values()];for(let p of h.objects){let g=p.type==="text"?y.get(p.id):void 0;if(p.type==="shape"&&(p.role==="entrance"||p.role==="exit")&&ec.test(p.label?.trim()??"")){let P=ct(p),A=P?Yt(P):null;if(A&&b.some(M=>Math.hypot(A.x-M.mid.x,A.y-M.mid.y)*R<=xe+M.widthM))continue}if(g&&p.type==="text")l.push({id:`text:${p.id}`,kind:"gate",text:p.text,icon:"entrance",anchor:[g.mid.x*R,h.baseHeightM+g.openingM+Wn,g.mid.y*R],color:p.color,floorIndex:h.index});else if(p.type==="shape"&&p.role&&oc.has(p.role)){let P=ct(p),A=P?Yt(P):null;if(!A||!p.label||p.gate?.hideFromBuyers)continue;l.push({id:`architecture:${p.id}`,kind:p.role==="stage"?"stage":p.role==="entrance"||p.role==="exit"?"gate":"annotation",text:p.label,...p.role==="entrance"||p.role==="exit"?{icon:p.role}:{},...p.gate?.stepFree?{stepFree:!0}:{},anchor:[A.x*R,h.baseHeightM+At(p).heightM+Wn,A.y*R],color:p.fill,floorIndex:h.index})}else if(p.type==="text"){let P=p.semanticKind==="icon"?Vn(p.iconKey)?.key:void 0,A=p.text||(P?Vn(P).label:"");if(!A)continue;l.push({id:`text:${p.id}`,kind:"annotation",text:A,...P?{venueIcon:P}:{},anchor:P?[(p.position.x+p.fontSize/2)*R,h.baseHeightM+Wn,(p.position.y+p.fontSize/2)*R]:[p.position.x*R,h.baseHeightM+Wn,p.position.y*R],color:p.color,rotation:p.rotation,floorIndex:h.index})}else if(p.type==="booth"){if(p.labelPresentation?.visible===!1)continue;let P=wt(p);if(!P)continue;let A=Yt(P);if(!A)continue;l.push({id:`booth:${p.id}`,kind:"booth",text:p.displayLabel||p.label||p.id,anchor:[A.x*R,h.baseHeightM+Xn+rc,A.y*R],floorIndex:h.index})}}}return{labels:l,sections:u,rows:f}}function _r(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 pc(t){let n=t.lastIndexOf("-");return n>=0&&n<t.length-1?t.slice(n+1):t}function Rr(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&&Ue(a,e)}var dn=3,Ut=.38,pn=.24;function xc(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)*R,a=(e.y-n.y)*R,i=(r.x-n.x)*R,s=(r.y-n.y)*R,c=2*(o*s-a*i);if(Math.abs(c)<1e-7)return null;let l=o*o+a*a,u=i*i+s*s,f=(l*s-u*a)/c+n.x*R,m=(o*u-i*l)/c+n.y*R,h=Math.hypot(n.x*R-f,n.y*R-m);return h<1||h>200||!Number.isFinite(h)||t.some(d=>Math.abs(Math.hypot(d.x*R-f,d.y*R-m)-h)>.03)?null:{x:f,z:m,radius:h}}function Ar(t){let n=[],e=new Map,r=(c,l)=>`${Math.floor(c/dn)},${Math.floor(l/dn)}`;for(let c of t)for(let l of c.rows){for(let f of l.pts){let m=f.x*R,h=f.y*R,d=r(m,h),y=e.get(d)??[];y.push({x:m,z:h,y:l.y,floor:c.floorIndex}),e.set(d,y)}if(l.patch||l.pts.length<2)continue;let u=xc(l.pts);for(let f of[0,l.pts.length-1]){let m=l.pts[f],h=l.pts[f===0?1:f-1],d=m.x-h.x,y=m.y-h.y,b=Math.hypot(d,y);b<1e-6||n.push({sectionId:c.sectionId,floorIndex:c.floorIndex,curve:u,row:l,point:m,x:m.x*R,z:m.y*R,dx:d/b,dz:y/b})}}let o=new Map;n.forEach((c,l)=>{let u=r(c.x,c.z),f=o.get(u)??[];f.push(l),o.set(u,f)});let a=(c,l)=>{let u=Math.floor(c/dn),f=Math.floor(l/dn);return[-1,0,1].flatMap(m=>[-1,0,1].map(h=>`${u+m},${f+h}`))},i=new Map;n.forEach((c,l)=>{let u=-1,f=1/0,m=!1;for(let h of a(c.x,c.z))for(let d of o.get(h)??[]){let y=n[d];if(c.sectionId===y.sectionId&&c.row.blockId===y.row.blockId||c.floorIndex!==y.floorIndex||Math.abs(c.row.y-y.row.y)>.05)continue;let b=y.x-c.x,p=y.z-c.z,g=Math.hypot(b,p);if(g<Ut*2+.45||g>dn)continue;let P=c.curve&&y.curve&&Math.hypot(c.curve.x-y.curve.x,c.curve.z-y.curve.z)<=.05&&Math.abs(c.curve.radius-y.curve.radius)<=.05,A=Math.min((b*c.dx+p*c.dz)/g,(-b*y.dx-p*y.dz)/g);(P?A<.8:A<.98)||!P&&(Math.abs(b*c.dz-p*c.dx)>.15||Math.abs(b*y.dz-p*y.dx)>.15)||(g<f-.02?(u=d,f=g,m=!1):Math.abs(g-f)<=.02&&(m=!0))}u>=0&&!m&&i.set(l,u)});let s=[];for(let[c,l]of i){if(c>=l||i.get(l)!==c)continue;let u=n[c],f=n[l],m=Math.hypot(f.x-u.x,f.z-u.z),h=(f.x-u.x)/m,d=(f.z-u.z)/m,y=!1;for(let p of a((u.x+f.x)/2,(u.z+f.z)/2))for(let g of e.get(p)??[]){if(g.floor!==u.floorIndex||Math.abs(g.y-u.row.y)>.75)continue;let P=(g.x-u.x)*h+(g.z-u.z)*d,A=Math.abs((g.x-u.x)*d-(g.z-u.z)*h);P>.01&&P<m-.01&&A<pn+Ut&&(y=!0)}if(y)continue;let b=(p,g)=>({x:(u.x+h*p-d*g)/R,y:(u.z+d*p+h*g)/R});s.push({sections:[u.sectionId,f.sectionId],blocks:[u.row.blockId,f.row.blockId],floorIndex:u.floorIndex,ends:[u.point,f.point],clearWidthM:m-2*Ut,heightM:(u.row.y+f.row.y)/2,outline:[b(Ut,-pn),b(m-Ut,-pn),b(m-Ut,pn),b(Ut,pn)]})}return s}var bc=.15,gc=.9,Mc=1.76;function wr(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 Pc(){return{background:{top:[...$n.top],bottom:[...$n.bottom]},sky:wr(null),structure:qn,seatStates:{...Je},seatScale:1,materials:{seat:null,shell:null,roughness:.78}}}function Rc(t){return!!t&&t[0]*.2126+t[1]*.7152+t[2]*.0722>.55?{deck:"#c9ccc8",fascia:"#b4bab8",shell:"#c3c9c8",roughness:.87}:{deck:"#69747b",fascia:"#3e4d58",shell:"#526572",roughness:.87}}function Er(t){let n=Pc();t??={};let e=it(t.background);if(e){n.background={top:V(e,gc),bottom:V(e,Mc)},n.sky=wr(e);let s={};for(let[l,u]of Object.entries(qn))s[l]=st(u,e,bc);e[0]*.2126+e[1]*.7152+e[2]*.0722>.55&&(s.ground=V(e,.86)),n.structure=s}let r=it(t.selectionColor)??it(t.accent);r&&(n.seatStates={...n.seatStates,selected:r});let o=t.seatScale;typeof o=="number"&&Number.isFinite(o)&&(n.seatScale=Ye(o));let a=Object.fromEntries(Object.entries(t.venue3d??{}).filter(([,s])=>s!=null)),i={...Rc(e),...a};if(i){let s=it(i.deck),c=it(i.fascia);s&&(n.structure={...n.structure,tierTop:s,gaTop:s}),c&&(n.structure={...n.structure,tierWall:c,gaWall:c}),n.materials.seat=it(i.seat),n.materials.shell=it(i.shell),typeof i.roughness=="number"&&Number.isFinite(i.roughness)&&(n.materials.roughness=Math.min(1,Math.max(0,i.roughness)))}return n}function Br(t,n){let e=[];for(let r of n)e.push(...t.seatStates[r]);return e}var Me=.6,Tr=3,Sc=.25;function Ic(t,n){if(xt(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,c=i.y-a.y,l=s*s+c*c||1,u=Math.max(0,Math.min(1,((t.x-a.x)*s+(t.y-a.y)*c)/l));e=Math.min(e,Math.hypot(t.x-(a.x+u*s),t.y-(a.y+u*c)))}return e}function Or(t,n){let e=t.map(i=>({booth:i,ring:wt(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=(Tr+Me)/R,a=new Map;return e.forEach(({booth:i,ring:s},c)=>{let l={x:s.reduce((h,d)=>h+d.x,0)/4,y:s.reduce((h,d)=>h+d.y,0)/4},u=[0,1,2,3].map(h=>{let d=s[h],y=s[(h+1)%4],b={x:(d.x+y.x)/2,y:(d.y+y.y)/2},p=b.x-l.x,g=b.y-l.y,P=Math.hypot(p,g)||1,A={x:b.x+p/P*Me/R,y:b.y+g/P*Me/R},M=Tr/R;return r.forEach((x,_)=>{_===c||A.x<x.minX-o||A.x>x.maxX+o||A.y<x.minY-o||A.y>x.maxY+o||(M=Math.min(M,Ic(A,e[_].ring)))}),{open:M*R,toward:{x:b.x+p/P*10/R,y:b.y+g/P*10/R},focal:Math.hypot(b.x-n.x,b.y-n.y)}}),f=Math.max(...u.map(h=>h.open)),m=u.filter(h=>h.open>=f-Sc).sort((h,d)=>h.focal-d.focal)[0];a.set(i.id,m.toward)}),a}import _c from"polygon-clipping";var Ac=.45,wc=1500,Ec=200;function Cr(t,n){if(t.role!=="stage"||Kt(t.stageKind))return t;let e=ct(t);if(!e||e.length<3||Math.abs(pt(e))*R*R>wc)return t;let r=n.filter(i=>xt(e,i.x,i.y));if(!r.length||r.length>Ec)return t;let o=Ac/R,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=_c.difference([[...e.map(l=>[l.x,l.y]),[e[0].x,e[0].y]]],...a),s=null,c=0;for(let l of i){let u=l[0].slice(0,-1).map(([m,h])=>({x:m,y:h})),f=Math.abs(pt(u));f>c&&(c=f,s=u)}return!s||s.length<3?t:{...t,kind:"polygon",points:s,rotation:0}}catch{return t}}function Pe(t,n,e,r,o,a,i,s,c,l=[],u=o){if(n.length!==e.length||n.length<2||a-o<1.5)return;let f=(y,b,p)=>{Ot(t,y,b,p,l,i,s,{portalBase:u,ao:c})||Z(t,y,void 0,()=>p,b,i,s,c)},m=(y,b,p)=>({x:y.x+(b.x-y.x)*p,y:y.y+(b.y-y.y)*p}),h=r?n.length:n.length-1,d=0;for(let y=0;y<h;y++){let b=(y+1)%n.length,p=Math.hypot(e[b].x-e[y].x,e[b].y-e[y].y)*$;if(p<1e-5)continue;let g=(x,_)=>[m(n[y],n[b],x),m(n[y],n[b],_),m(e[y],e[b],_),m(e[y],e[b],x)];f(g(0,1),o,o+.95),f(g(0,1),a-.22,a);let P=Math.ceil((d-.32)/6)*6,A=!1,M=!1;for(let x=P;x<d+p;x+=6){let _=Math.max(0,(x-d)/p),I=Math.min(1,(x+.32-d)/p);I<=_||(f(g(_,I),o+.95,a-.22),A||=_<1e-6,M||=I>1-1e-6)}if(!r&&(y===0&&!A||y===h-1&&!M)){let x=Math.min(1,.32/p);f(g(y===0?0:1-x,y===0?x:1),o+.95,a-.22)}d+=p}}import Wt from"polygon-clipping";var bn=.65;function Re(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,c=i.y-a.y,l=Math.max(0,Math.min(1,((t.x-a.x)*s+(t.y-a.y)*c)/(s*s+c*c||1)));e=Math.min(e,Math.hypot(t.x-a.x-l*s,t.y-a.y-l*c))}return e}var Se=.01;function kr(t,n,e,r,o,a,i,s=[],c=!0,l={bays:[],walls:[]}){if(r-o<=1e-5)return;let u=r-o>=3,f=u?r-bn:o;t.setMaterial(5);let m=u?[]:s.filter(x=>{if(x.role!=="entrance"&&x.role!=="exit")return!1;let _=ct(x);if(!_)return!1;let I=Qt(_,o,o+At(x).heightM);return I!==null&&I.openingTop<=r-.12});if((!m.length||!Ot(t,n,f,r,m,a,i,{holes:e,portalBase:o}))&&Z(t,n,e,()=>r,f,a,i,K,void 0,()=>[0,1,0]),!u){t.setMaterial(0);return}let h=c&&l.bays.length?Bc(n,e,Lt(n,xn/R),l):null,d=6/R,y=.22/R,b=s.flatMap(x=>{if(x.role!=="entrance"&&x.role!=="exit")return[];let _=ct(x);return _?.length?[{minX:Math.min(..._.map(I=>I.x)),maxX:Math.max(..._.map(I=>I.x)),minY:Math.min(..._.map(I=>I.y)),maxY:Math.max(..._.map(I=>I.y))}]:[]}),p=Math.min(...n.map(x=>x.x)),g=Math.max(...n.map(x=>x.x)),P=Math.min(...n.map(x=>x.y)),A=Math.max(...n.map(x=>x.y));for(let x=p+d/2;x<g;x+=d)for(let _=P+d/2;_<A;_+=d){if(b.some(S=>x+y>=S.minX&&x-y<=S.maxX&&_+y>=S.minY&&_-y<=S.maxY))continue;let I=[{x:x-y,y:_-y},{x:x+y,y:_-y},{x:x+y,y:_+y},{x:x-y,y:_+y}];!Rt({x,y:_},n,e)||Re({x,y:_},[n,...e??[]])<y*Math.SQRT2+(c?xn/R:0)||h&&Re({x,y:_},h.flat())<y*Math.SQRT2+xn/R||Z(t,I,void 0,()=>f,o,a,i,K)}if(h){for(let[x,..._]of h)Z(t,x,_,()=>f,o-Se,a,i,K);t.setMaterial(0);return}let M=Lt(n,xn/R);if(c&&M.length>=3){let x=s.filter(S=>{if(S.role!=="entrance"&&S.role!=="exit")return!1;let B=ct(S);return!!B&&B.some(T=>!Rt(T,n,void 0)||Re(T,[n])<=xn/R)}),_=[M.slice().reverse()],I=o-Se;(!x.length||!Ot(t,n,I,f,x,a,i,{holes:_,portalBase:o+Se}))&&Z(t,n,_,()=>f,I,a,i,K)}t.setMaterial(0)}var Ie=.25,xn=Ie;function Bc(t,n,e,r){if(e.length<3)return null;let o=i=>{let s=i.map(c=>[c.x,c.y]);return s.push(s[0]),s},a=i=>{let[s,...c]=i.map(l=>[o(l)]);return Wt.union(s,...c)};try{let i=[o(t),...(n??[]).map(o)],s=Wt.difference(i,[o(e)]),c=Wt.intersection(i,a(r.bays));if(!c.length)return null;let l=Wt.difference(Wt.intersection(i,a(r.walls)),c);return Wt.union(Wt.difference(s,c),l).map(f=>f.map(m=>m.slice(0,-1).map(([h,d])=>({x:h,y:d}))))}catch{return null}}var Tc=.02,Oc=.25,Cc=1.2,kc=.6,Fc=.45,Lc=2.3,vc=Math.PI/180,Fr=.005;function Bt(t,n,e){let r=e*vc;return{x:t.x+n*Math.sin(r),y:t.y+n*Math.cos(r)}}function Nc(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 Dc=24,Gc=.01;function Hc(t,n,e,r,o,a,i,s,c){let l=e.binCount,u=Dc,f=$,m=a+.02,h=a-Gc,d=[];for(let w=0;w<l;w++){let E=(e.startBin+w+.5)*n.binStepDeg,C=new Float64Array(u+1);for(let L=0;L<=u;L++){let O=r[w]+(o[w]-r[w])*L/u;C[L]=Math.max(m,$e(n,e,E,O)-Oc)}d.push(C)}if(c){let w=0;for(let E=0;E+1<l;E++)for(let C=0;C<u;C++){let L=Bt(n.centre,r[E]+(o[E]-r[E])*C/u,(e.startBin+E+.5)*n.binStepDeg),O=Bt(n.centre,r[E+1]+(o[E+1]-r[E+1])*(C+1)/u,(e.startBin+E+1.5)*n.binStepDeg);w=Math.max(w,Math.hypot(O.x-L.x,O.y-L.y))}for(let E=0;E<l;E++){let C=(e.startBin+E+.5)*n.binStepDeg;for(let L=0;L<=u;L++){let O=Bt(n.centre,r[E]+(o[E]-r[E])*L/u,C),D=c(O.x,O.y,w*1.01);D!==null&&(d[E][L]=Math.min(d[E][L],Math.max(h+Fr,D-Fr)))}}}let y=[i.bandTop[0]*s.top,i.bandTop[1]*s.top,i.bandTop[2]*s.top],b=[i.bandTop[0]*s.bottomCap,i.bandTop[1]*s.bottomCap,i.bandTop[2]*s.bottomCap],p=[i.bandWall[0]*s.top,i.bandWall[1]*s.top,i.bandWall[2]*s.top],g=[i.bandWall[0]*s.wallBottom,i.bandWall[1]*s.wallBottom,i.bandWall[2]*s.wallBottom],P=(w,E)=>{let C=(e.startBin+w+.5)*n.binStepDeg,L=r[w]+(o[w]-r[w])*E/u,O=Bt(n.centre,L,C);return[O.x*f,d[w][E],O.y*f]};{let w=Math.tan(12*Math.PI/180);for(let E=0;E<6;E++){let C=!1;for(let O=0;O<l;O++)for(let D=u-1;D>=0;D--)d[O][D]>d[O][D+1]&&(d[O][D]=d[O][D+1],C=!0);let L=e.closed?l:l-1;for(let O=0;O<L;O++){let D=(O+1)%l;for(let H=0;H<=u;H++){let j=d[D][H]-d[O][H];if(Math.abs(j)>1)continue;let G=r[O]+(o[O]-r[O])*H/u,U=r[D]+(o[D]-r[D])*H/u,X=Bt(n.centre,G,(e.startBin+O+.5)*n.binStepDeg),Y=Bt(n.centre,U,(e.startBin+D+.5)*n.binStepDeg),nt=w*Math.hypot(Y.x-X.x,Y.y-X.y)*f;j>nt?(d[D][H]=d[O][H]+nt,C=!0):-j>nt&&(d[O][H]=d[D][H]+nt,C=!0)}}if(!C)break}}let A=1,M=(w,E)=>{for(let C=0;C<=u;C+=4)if(Math.abs(d[w][C]-d[E][C])>A)return!0;return Math.abs(d[w][u]-d[E][u])>A},x=Math.tan(38*Math.PI/180),_=w=>(o[w]-r[w])/u*f,I=(w,E)=>d[w][E+1]-d[w][E]>x*Math.max(1e-6,_(w)),S=(w,E)=>{let C=e.closed?(w-1+l)%l:Math.max(0,w-1),L=e.closed?(w+1)%l:Math.min(l-1,w+1);Math.abs(d[C][E]-d[w][E])>A&&(C=w),Math.abs(d[L][E]-d[w][E])>A&&(L=w);let O=Math.max(0,E-1),D=Math.min(u,E+1);O<E&&I(w,O)&&(O=E),D>E&&I(w,E)&&(D=E);let H=P(C,E),j=P(L,E),G=P(w,O),U=P(w,D),X=j[0]-H[0],Y=j[1]-H[1],nt=j[2]-H[2],rt=U[0]-G[0],q=U[1]-G[1],Q=U[2]-G[2],J=Y*Q-nt*q,v=nt*rt-X*Q,N=X*q-Y*rt,W=Math.hypot(J,v,N);return W>1e-12?(J/=W,v/=W,N/=W,v<0&&(J=-J,v=-v,N=-N),[J,v,N]):[0,1,0]},B=(w,E,C=!1)=>{let L=C&&Math.min(w[1],E[1])-a>=3,O=[w[0],L?w[1]-bn:h,w[2]],D=[E[0],L?E[1]-bn:h,E[2]],H=E[0]-w[0],j=E[2]-w[2],G=Math.hypot(H,j);if(!(G>1e-12))return;let U=[j/G,0,-H/G];t.tri(w,E,D,U,p,p,g),t.tri(w,D,O,U,p,g,g)},T=.05*Pt,F=w=>o[w]-r[w]<T,k=e.closed?l:l-1;for(let w=0;w<k;w++){let E=(w+1)%l;if(F(w)||F(E))continue;if(M(w,E)){let j=(e.startBin+w+1)*n.binStepDeg,G=(q,Q)=>{let J=(r[w]+r[E])/2,v=(o[w]+o[E])/2,N=J+(v-J)*Q/u,W=Bt(n.centre,N,j);return[W.x*f,d[q][Q],W.y*f]};for(let q=0;q<u;q++){let Q=P(w,q),J=P(w,q+1),v=G(w,q),N=G(w,q+1),W=S(w,q),lt=S(w,q+1);t.triN(Q,v,N,W,W,lt,y),t.triN(Q,N,J,W,lt,lt,y);let ft=P(E,q),at=P(E,q+1),tt=G(E,q),et=G(E,q+1),ht=S(E,q),z=S(E,q+1);t.triN(tt,ft,at,ht,ht,z,y),t.triN(tt,at,et,ht,z,z,y);let mt=G(w,q),yt=G(w,q+1),Gt=G(E,q+1),Ht=G(E,q),kt=yt[0]-mt[0],Ft=yt[2]-mt[2],on=Math.hypot(kt,Ft);if(on>1e-12){let gn=[Ft/on,0,-kt/on];t.tri(mt,yt,Gt,gn,p),t.tri(mt,Gt,Ht,gn,p)}}let U=P(w,0),X=P(E,0),Y=P(E,u),nt=P(w,u),rt=q=>[q[0],h,q[2]];Math.min(U[1],X[1])-a<3&&(t.tri(rt(U),rt(Y),rt(X),[0,-1,0],b),t.tri(rt(U),rt(nt),rt(Y),[0,-1,0],b)),B(U,X,!0),B(nt,Y,!0);continue}for(let j=0;j<u;j++){let G=S(w,j),U=S(E,j),X=S(E,j+1),Y=S(w,j+1);if(I(w,j)||I(E,j)){let J=(yt,Gt)=>{let Ht=(e.startBin+yt+.5)*n.binStepDeg,kt=r[yt]+(o[yt]-r[yt])*(j+.5)/u,Ft=Bt(n.centre,kt,Ht);return[Ft.x*f,Gt,Ft.y*f]},v=P(w,j),N=P(E,j),W=J(w,d[w][j]),lt=J(E,d[E][j]);t.triN(v,N,lt,G,U,U,y),t.triN(v,lt,W,G,U,G,y);let ft=P(E,j+1),at=P(w,j+1),tt=J(w,d[w][j+1]),et=J(E,d[E][j+1]);t.triN(tt,et,ft,Y,X,X,y),t.triN(tt,ft,at,Y,X,Y,y);let ht=lt[0]-W[0],z=lt[2]-W[2],mt=Math.hypot(ht,z);if(mt>1e-12){let yt=[-z/mt,0,ht/mt];t.tri(W,lt,et,yt,p),t.tri(W,et,tt,yt,p)}continue}let nt=P(w,j),rt=P(E,j),q=P(E,j+1),Q=P(w,j+1);t.triN(nt,rt,q,G,U,X,y),t.triN(nt,q,Q,G,X,Y,y)}let C=P(w,0),L=P(E,0),O=P(E,u),D=P(w,u),H=j=>[j[0],h,j[2]];Math.min(C[1],L[1])-a<3&&(t.tri(H(C),H(O),H(L),[0,-1,0],b),t.tri(H(C),H(D),H(O),[0,-1,0],b)),B(C,L,!0),B(D,O,!0)}if(!e.closed)for(let w of[0,l-1])for(let E=0;E<u;E++)B(P(w,E),P(w,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 u of n.rings)for(let f of u.arcs){let m=new Float64Array(f.binCount),h=new Float64Array(f.binCount);for(let y=0;y<f.binCount;y++){let b=(f.startBin+y)%n.binCount,p=Math.max(0,f.innerR[y]-St);m[y]=Math.max(p,i[b]+.001),h[y]=Math.max(m[y]+.001,f.outerR[y]+St)}let d=0;for(let y=0;y<f.binCount;y++){let b=f.topLevelM[y]-r;b>d&&(d=b)}d>=Cc&&Hc(t,n,f,m,h,r,o,a,e.standTopNear);for(let y=0;y<f.binCount;y++){let b=(f.startBin+y)%n.binCount;h[y]>i[b]&&(i[b]=h[y])}}if(e.deriveShell===!1||Nc(e.shapes,n))return;let s=n.rings[n.rings.length-1],c=kc*Pt,l=Fc*Pt;for(let u of s.arcs){let f=[],m=[];for(let S=0;S<u.binCount;S++){let B=(u.startBin+S+.5)*n.binStepDeg,T=u.outerR[S]+St+c;f.push(Bt(n.centre,T,B)),m.push(Bt(n.centre,T+l,B))}let h=-1/0;for(let S=0;S<u.binCount;S++)u.topLevelM[S]>h&&(h=u.topLevelM[S]);let d=h+Lc,y=u.closed?m:[...m,...f.slice().reverse()],b=u.closed?[f.slice().reverse()]:void 0,p=st(o.shellWall,[.66,.71,.72],.62),g=(S,B,T,F,k)=>{let w=Math.abs(F-h)<1e-6?F-Tc:F;Ot(t,S,T,w,e.shapes,o.shellTop,k,{holes:B,portalBase:r,ao:a})||Z(t,S,B,()=>w,T,o.shellTop,k,a)},P=Math.max(1,Math.ceil((h-r)/4.5)),A=(h-r)/P,M=new Set,x=e.tierFrontLevels??n.rings.map(S=>{let B=S.arcs.flatMap(T=>Array.from(T.frontLevelM)).filter(Number.isFinite).sort((T,F)=>T-F);return B[Math.floor(B.length/2)]});for(let S of x)Number.isFinite(S)&&S-r>=3&&S<h&&M.add(Math.max(0,Math.min(P-1,Math.floor((S-r)/A))));let _=Math.min(...x.filter(S=>Number.isFinite(S)&&S-r>=3&&S<h));for(let S=0;S<P;S++)r+(S+1)*A<=_-bn&&Number.isFinite(_)&&M.add(S);for(let S=0;S<P;S++){let B=r+(h-r)*S/P,T=r+(h-r)*(S+1)/P;M.has(S)&&T-B>=3.2?(g(y,b,B,B+.45,p),Pe(t,f,m,u.closed,B+.45,T-.16,o.shellTop,p,a,e.shapes,r)):g(y,b,B,T-.16,p),g(y,b,T-.16,T,V(p,.62))}Pe(t,f,m,u.closed,h,d,o.shellTop,p,a,e.shapes,r);let I=8;for(let S=1;S<m.length;S++){if(I+=Math.hypot(m[S].x-m[S-1].x,m[S].y-m[S-1].y)*$,I<8)continue;I=0;let B=m[S],T=m[S-1],F=B.x-T.x,k=B.y-T.y,w=Math.max(1,Math.hypot(F,k)),E=F/w*.16*Pt,C=k/w*.16*Pt,L=Math.max(1,Math.hypot(B.x-n.centre.x,B.y-n.centre.y)),O=(B.x-n.centre.x)/L*.24*Pt,D=(B.y-n.centre.y)/L*.24*Pt,H=[{x:B.x-E,y:B.y-C},{x:B.x+E,y:B.y+C},{x:B.x+E+O,y:B.y+C+D},{x:B.x-E+O,y:B.y-C+D}];g(H,void 0,r,h,V(p,1.12))}}}var Xc=2.5,vr=.65,jc=2,Uc=.03;function Wc(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 we(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<Xc||i.pts.length<2)continue;let s=i.pts.map(u=>{let f=u.x-n.x,m=u.y-n.y,h=Math.max(1,Math.hypot(f,m));return{x:u.x-f/h*vr/R,y:u.y-m/h*vr/R}}),c=[],l=[s[0]];for(let u=1;u<s.length;u++){let f=s[u-1],m=s[u];Math.hypot(m.x-f.x,m.y-f.y)*R>jc?(l.length>=2&&c.push(l),l=[m]):l.push(m)}l.length>=2&&c.push(l);for(let u of c)Wc(u,Uc/R);c.length&&o.push({blockId:a,y:i.y,runs:c})}return o}var Nr=.1,Yc=1.1,zc=.22,_e=.95,Ae=.05,Dr=1.8;function Gr(t,n,e,r){let o=[.72,.72,.69],a=[.48,.55,.57];for(let i of we(n,e,r)){let s=i.y;for(let c of i.runs){let l=Dr;for(let u=1;u<c.length;u++){let f=c[u-1],m=c[u],h=m.x-f.x,d=m.y-f.y,y=Math.hypot(h,d);if(y<1e-5)continue;let b=p=>{let g=-d/y*p/R/2,P=h/y*p/R/2;return[{x:f.x+g,y:f.y+P},{x:m.x+g,y:m.y+P},{x:m.x-g,y:m.y-P},{x:f.x-g,y:f.y-P}]};if(Z(t,b(zc),void 0,()=>s+Nr,s-Yc,o,o,K),Z(t,b(Ae),void 0,()=>s+_e,s+_e-Ae,a,a,K),l+=y*R,l>=Dr||u===c.length-1){l=0;let p=.028/R,g=[{x:f.x-p,y:f.y-p},{x:f.x+p,y:f.y-p},{x:f.x+p,y:f.y+p},{x:f.x-p,y:f.y+p}];Z(t,g,void 0,()=>s+_e-Ae,s+Nr,a,a,K)}}}}}var Kc=.9,Vc=1.5,Zc=.3;function Hr(t,n,e){let r=[],o=[],a=Kc/R,i=Vc/R,s=Zc/R;for(let c of t)for(let l of c.runs){if(l.length<2)continue;let u=l.slice(),f=(b,p)=>{let g=u[b],P=u[p],A=Math.hypot(g.x-P.x,g.y-P.y)||1;u[b]={x:g.x+(g.x-P.x)/A*s,y:g.y+(g.y-P.y)/A*s}};f(0,1),f(u.length-1,u.length-2);let m=u.map((b,p)=>{let g=u[Math.max(0,p-1)],P=u[Math.min(u.length-1,p+1)],A=P.x-g.x,M=P.y-g.y,x=Math.hypot(A,M)||1,_=-M/x,I=A/x;return _*(b.x-n.x)+I*(b.y-n.y)<0&&(_=-_,I=-I),{nx:_,ny:I}}),h=u.map((b,p)=>({x:b.x-m[p].nx*i,y:b.y-m[p].ny*i})),d=u.map((b,p)=>({x:b.x+m[p].nx*a,y:b.y+m[p].ny*a})),y=u.map((b,p)=>({x:b.x+m[p].nx*(a+e/R),y:b.y+m[p].ny*(a+e/R)}));r.push([...h,...d.slice().reverse()]),o.push([...d,...y.reverse()])}return{bays:r,walls:o}}var Ee=.88,Yn=.27,qc=1.2,$c=.01;function Xr(t,n,e,r,o){let a=[.67,.71,.68],i=[a[0]*Ee,a[1]*Ee,a[2]*Ee],s=c=>!!o&&o.some((l,u)=>u!==c&&l?.belowY!=null&&Math.abs(l.belowY-n[c].y)<1e-6&&n[u].blockId===n[c].blockId);for(let c=0;c<n.length;c++){let l=n[c];if(!(l.pts.length<2))for(let u of[0,l.pts.length-1]){let f=l.pts[u],m=l.pts[u===0?1:u-1],h=f.x-m.x,d=f.y-m.y,y=Math.hypot(h,d);if(y<1e-5)continue;h/=y,d/=y;let b=1/0;for(let E=0;E<e.length;E++){let C=e[E],L=e[(E+1)%e.length],O=L.x-C.x,D=L.y-C.y,H=h*D-d*O;if(Math.abs(H)<1e-8)continue;let j=C.x-f.x,G=C.y-f.y,U=(j*D-G*O)/H,X=(j*d-G*h)/H;U>0&&X>=0&&X<=1&&(b=Math.min(b,U))}let p=.3/R,g=b-.04/R;if(!Number.isFinite(b)||b*R>2||g-p<.12/R)continue;let P=!!r&&s(c),A=o?.[c]?.pitch,M=P&&A&&Number.isFinite(A)?Math.min(qc/R,Math.max(Yn/R,A-Yn/R-$c/R)):Yn/R,x=-d,_=h;r&&x*(r.x-f.x)+_*(r.y-f.y)<0&&(x=-x,_=-_);let I=Yn/R,S=[{x:f.x+h*p+x*I,y:f.y+d*p+_*I},{x:f.x+h*g+x*I,y:f.y+d*g+_*I},{x:f.x+h*g-x*M,y:f.y+d*g-_*M},{x:f.x+h*p-x*M,y:f.y+d*p-_*M}];if(!S.every(E=>xt(e,E.x,E.y)))continue;let B=o?.[c]?.belowY,T=B==null?0:l.y-B,F=!!r&&T>.03&&T<=.65;if(F&&r){let E=(C,L)=>Math.hypot((C.x+L.x)/2-r.x,(C.y+L.y)/2-r.y);E(S[0],S[1])>E(S[3],S[2])&&(S=[S[3],S[2],S[1],S[0]])}let k=F?Math.ceil((T-1e-8)/.2):1,w=(E,C,L)=>({x:E.x+(C.x-E.x)*L,y:E.y+(C.y-E.y)*L});for(let E=0;E<k;E++){let C=E/k,L=(E+1)/k,O=[w(S[0],S[3],C),w(S[1],S[2],C),w(S[1],S[2],L),w(S[0],S[3],L)],D=l.y+.008-(F?T*(1-L):0);Z(t,O,void 0,()=>D,D-(F?T/k+.1:.16),a,i,K)}}}}var Qc=.02,Jc=.012,tl=.01,nl=.3,el=.5;function ol(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,c=i.y-a.y,l=s*s+c*c,u=l>1e-12?((n-a.x)*s+(e-a.y)*c)/l:0;u=Math.max(0,Math.min(1,u)),r=Math.min(r,Math.hypot(n-(a.x+u*s),e-(a.y+u*c)))}return r}function rl(t,n,e,r){let o=1/0,a=Number.NaN;for(let i=0;i<t.length;i++){let s=n[i];if(Math.hypot(e-s.cx,r-s.cy)-s.rad>=o)continue;let c=ol(t[i].pts,e,r);c<o&&(o=c,a=t[i].y)}return a}function jr(t,n,e,r,o,a,i){let s=r.filter(m=>m.pts.length>0);if(s.length<2||n.length<3)return;let c=s.map(m=>{let h=0,d=0;for(let b of m.pts)h+=b.x,d+=b.y;h/=m.pts.length,d/=m.pts.length;let y=0;for(let b of m.pts)y=Math.max(y,Math.hypot(b.x-h,b.y-d));return{cx:h,cy:d,rad:y}}),l=[...n],u=e.map(m=>[...m]),f=Qc/R;for(let m of[l,...u])for(let h=0;h<m.length;h++){let d=m[h],y=m[(h+1)%m.length],b=y.x-d.x,p=y.y-d.y,g=Math.hypot(b,p);if(g*R<.05)continue;let P=(d.x+y.x)/2,A=(d.y+y.y)/2,M=p/g,x=-b/g;Rt({x:P+M*f,y:A+x*f},l,u)&&(M=-M,x=-x);let _=o.x-P,I=o.y-A,S=Math.hypot(_,I)||1;if((M*_+x*I)/S>el)continue;let B=1/0;for(let O of[.2,.5,.8]){let D=rl(s,c,d.x+b*O-M*f*2,d.y+p*O-x*f*2);Number.isFinite(D)&&(B=Math.min(B,D))}if(!Number.isFinite(B)||B-a<nl)continue;let T=a-tl,F=B-Jc,k={x:(d.x-M*f)*R,z:(d.y-x*f)*R},w={x:(y.x-M*f)*R,z:(y.y-x*f)*R},E=[M,0,x],C=V(i,K.wallBottom),L=V(i,K.top);t.tri([k.x,F,k.z],[w.x,F,w.z],[w.x,T,w.z],E,L,L,C),t.tri([k.x,F,k.z],[w.x,T,w.z],[k.x,T,k.z],E,L,C,C)}}function Ur(t,n,e,r,o,a,i,s,c=!1){if(!n.outline||n.outline.length<3)return;let l=e.baseHeightM,u=e.objects.filter(g=>g.type==="shape"&&(g.role==="entrance"||g.role==="exit")),f=uo(r,s.tierTop);if(!o)return;let m=g=>o.deckAt(g.x,g.y),h=Eo(n,i),d=h[0]??n.outline;if(o.rowLevels.length>=2){let g=Tn(o.rowLevels),P=Bo(Ro(o.rowLevels,e.focal,g),h),A=Hr(we(o.rowLevels,e.focal,l),e.focal,Ie);for(let x of P){let _=Math.max(l,x.topY-Wr);for(let I of a.subtract(x.outline,_))kr(t,I,x.holes,_,l,s.tierTop,s.tierWall,u,!c,A);t.setMaterial(5),jr(t,x.outline,x.holes,o.rowLevels,e.focal,_,s.tierWall),t.setMaterial(0)}P.length||Z(t,d,n.holes,()=>o.landingY,l,f,s.tierWall,K);let M={tread:[f[0]*K.top,f[1]*K.top,f[2]*K.top],riser:[f[0]*.72,f[1]*.72,f[2]*.72]};for(let x of h.length?h:[d])Io(t,o.rowLevels,e.focal,o.landingY,M,x,g);Gr(t,o.rowLevels,e.focal,l),Xr(t,o.rowLevels,n.outline,e.focal,g);return}let y=o.flat?1/0:Vo,b=g=>o.normalAt(g.x,g.y),p=o.flat?o.landingY:void 0;for(let g of a.subtract(d,p))Z(t,g,n.holes,m,l,f,s.tierWall,K,y,b)}function il(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 c=e.bySection.get(s);if(c&&c.rowLevels.length>=2)continue;let l=n[i];if(l.kind==="booth")continue;let u=o.get(s);u||(u=new Map,o.set(s,u));let f=l.rowId||`__seat-${i}`,m=u.get(f);m||(m={pts:[],levelM:0,n:0},u.set(f,m)),m.pts.push({x:l.x,y:l.y}),m.levelM+=e.seatDeckY(i),m.n++}let a=[];for(let i of t.objects){if(i.type!=="section")continue;let s=e.bySection.get(i.id);if(s&&s.rowLevels.length>=2){let l=s.rowLevels.filter(u=>!u.patch).map(u=>({pts:u.pts,levelM:u.y}));l.length>=2&&a.push({sectionId:i.id,rows:l});continue}let c=o.get(i.id);c&&a.push({sectionId:i.id,rows:[...c.values()].map(l=>({pts:l.pts,levelM:l.levelM/l.n}))})}return a}function sl(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,c=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-c*i,t.y-o.y-c*s))}return e}var Wr=.02;function al(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,c=-1/0;for(let u of r.outline)u.x<a&&(a=u.x),u.x>i&&(i=u.x),u.y<s&&(s=u.y),u.y>c&&(c=u.y);let l=o.landingY;for(let u of o.rowLevels)l=Math.min(l,u.y-Wr);return[{outline:r.outline,holes:r.holes,surface:o,floorTop:l,minX:a,maxX:i,minY:s,maxY:c}]});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 c={x:r,y:o};if(!Rt(c,s.outline,s.holes)&&sl(c,s.outline)>a)continue;let l=Math.min(s.surface.deckAt(r,o),s.floorTop);(i===null||l<i)&&(i=l)}return i}}var cl=3,ll=.4;function Yr(t,n,e,r,o,a,i=!0){let s=il(n,e,r);if(s.length<cl)return;let c=qe(s,n.focal);if(!c)return;let l=Math.max(0,...c.rings.map(u=>u.arcs.reduce((f,m)=>f+m.binCount,0)))/c.binCount;t.setMaterial(5),Lr(t,c,{bottomY:n.baseHeightM,tierFrontLevels:s.map(u=>Math.min(...u.rows.map(f=>f.levelM))),colors:{bandTop:V(o.tierTop,.8),bandWall:o.tierWall,shellTop:a??V(o.tierWall,1.15),shellWall:a??o.tierWall},ao:K,shapes:n.objects.filter(u=>u.type==="shape"),deriveShell:i&&l>=ll,standTopNear:al(n,r)}),t.setMaterial(0)}function zr(t){let{doc:n,units:e,seats:r,surfaces:o,solids:a,hintedSeatFloor:i,seatFloor:s}=t,c=[];{let l=e.map(()=>({minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}));for(let m=0;m<a.floor.length;m+=1){let h=Math.max(0,Math.min(e.length-1,Math.round(a.floor[m]))),d=m*3,y=l[h];y.minX=Math.min(y.minX,a.position[d]),y.minY=Math.min(y.minY,a.position[d+1]),y.minZ=Math.min(y.minZ,a.position[d+2]),y.maxX=Math.max(y.maxX,a.position[d]),y.maxY=Math.max(y.maxY,a.position[d+1]),y.maxZ=Math.max(y.maxZ,a.position[d+2])}let u=new Map;for(let m=0;m<e.length;m++)for(let h of e[m].objects)h.type==="section"&&u.set(h.id,m);let f=e.map(()=>({n:0,minX:1/0,minY:1/0,minDeck:1/0,maxX:-1/0,maxY:-1/0,maxDeck:-1/0,sumX:0,sumDeck:0,sumZ:0}));for(let m=0;m<r.length;m++){let h=o.seatOwner[m],d=(h!==null?u.get(h):void 0)??i[m];if(d===void 0)continue;let y=f[d],b=r[m];y.n++,b.x<y.minX&&(y.minX=b.x),b.y<y.minY&&(y.minY=b.y),b.x>y.maxX&&(y.maxX=b.x),b.y>y.maxY&&(y.maxY=b.y);let p=o.seatDeckY(m);y.sumX+=b.x*R,y.sumDeck+=p,y.sumZ+=b.y*R,y.minDeck=Math.min(y.minDeck,p),y.maxDeck=Math.max(y.maxDeck,p+1.6),s[m]=d}for(let m=0;m<e.length;m++){let h=f[m],d=n.floors?.[m],y=l[m],b=Math.min(h.n?h.minX*R:e[m].focal.x*R-1,Number.isFinite(y.minX)?y.minX:1/0),p=Math.max(h.n?h.maxX*R:e[m].focal.x*R+1,Number.isFinite(y.maxX)?y.maxX:-1/0),g=Math.min(h.n?h.minY*R:e[m].focal.y*R-1,Number.isFinite(y.minZ)?y.minZ:1/0),P=Math.max(h.n?h.maxY*R:e[m].focal.y*R+1,Number.isFinite(y.maxZ)?y.maxZ:-1/0),A=Math.min(h.n?Math.min(e[m].baseHeightM,h.minDeck):e[m].baseHeightM,Number.isFinite(y.minY)?y.minY:1/0),M=Math.max(h.n?Math.max(h.maxDeck,A+.5):A+.5,Number.isFinite(y.maxY)?y.maxY:-1/0),x=[h.n?h.sumX/h.n:(b+p)/2,h.n?h.sumDeck/h.n:(A+M)/2,h.n?h.sumZ/h.n:(g+P)/2],_=Math.max(1,.5*Math.hypot(p-b,M-A,P-g));c.push({index:m,id:d?.id??`floor-${m}`,label:d?.name??(e.length>1?`Floor ${m+1}`:"Venue"),seatCount:h.n,center:x,radius:_,box:{min:[b,A,g],max:[p,M,P]},focalWorld:[e[m].focal.x*R,e[m].baseHeightM+1.5,e[m].focal.y*R]})}}return c}function Be(t,n){let e=1/0,r=1/0,o=-1/0,a=-1/0,i=(s,c)=>{s<e&&(e=s),c<r&&(r=c),s>o&&(o=s),c>a&&(a=c)};for(let s of n)i(s.x,s.y);for(let s of t)for(let c of s.objects)if(c.type==="section")for(let l of c.outline)i(l.x,l.y);else if(c.type==="shape"&&c.points)for(let l of c.points)i(l.x,l.y);else if(c.type==="gaArea")for(let l of c.points)i(l.x,l.y);else if(c.type==="booth"){let l=wt(c);if(l)for(let u of l)i(u.x,u.y)}else if(c.type==="table"){let l=jn(c);if(l)for(let u of l)i(u.x,u.y)}else if(c.type==="decorImage"){let l=Un(c);if(l)for(let u of l)i(u.x,u.y)}return Number.isFinite(e)||(e=-100,r=-100,o=100,a=100),{minX:e,minY:r,maxX:o,maxY:a}}function Qr(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(...ct(m)??m.points??[]):m.type==="gaArea"?s.push(...m.points):m.type==="booth"?s.push(...wt(m)??[]):m.type==="table"?s.push(...jn(m)??[]):m.type==="decorImage"&&s.push(...Un(m)??[]);if(Zr(t,n[0],e,a)||$r(t,n[0],e,s,a))return!1;if(i&&Vr(t,n[0].baseHeightM,s,a,i))return!0;let c=un(s),l=(o.minX+o.maxX)/2,u=(o.minY+o.maxY)/2,f=c.length>=3?c.map(m=>{let h=m.x-l,d=m.y-u,y=Math.max(1,Math.hypot(h,d));return{x:m.x+h/y*80,y:m.y+d/y*80}}):cn(o.minX-28,o.minY-28,o.maxX-o.minX+56,o.maxY-o.minY+56);return Z(t,f,void 0,()=>-.04,-.22,a.ground,a.ground,K),!1}else{let s=n.reduce((b,p)=>p.baseHeightM<b.baseHeightM?p:b);t.setFloor(s.index);let c={...s,objects:n.flatMap(b=>b.objects)},l=e.map(b=>({x:b.x,y:b.y}));for(let b of c.objects)b.type==="section"&&l.push(...b.outline);if(Zr(t,c,e,a)||$r(t,c,e,l,a))return!1;if(i&&Vr(t,s.baseHeightM,l,a,i))return!0;let u=e.filter((b,p)=>r[p]===s.index),f=Be([s],u),m=Math.hypot(f.maxX-f.minX,f.maxY-f.minY),h=Math.max(28,Math.min(80,m*.04)),d=cn(f.minX-h,f.minY-h,f.maxX-f.minX+h*2,f.maxY-f.minY+h*2),y=s.baseHeightM-.03;return Z(t,d,void 0,()=>y,y-.22,a.ground,a.ground,K),!1}}function Te(t,n,e,r){let{cx:o,cz:a,radius:i}=e,s=1/0,c=1/0,l=1/0,u=-1/0,f=-1/0,m=-1/0,h=(b,p,g)=>{s=Math.min(s,b),u=Math.max(u,b),c=Math.min(c,p),f=Math.max(f,p),l=Math.min(l,g),m=Math.max(m,g)};for(let b=0;b<t.position.length;b+=3){let p=b/3;r&&p>=r[0]&&p<r[1]||h(t.position[b],t.position[b+1],t.position[b+2])}for(let b=0;b<n.count;b++){let p=b*3,g=n.iPosition[p],P=n.iPosition[p+1],A=n.iPosition[p+2],M=Math.max(.35,n.iMaxRadius[b]??.35);h(g-M,P,A-M),h(g+M,P+1.6,A+M)}Number.isFinite(s)||(s=o-i,u=o+i,c=0,f=i*.16,l=a-i,m=a+i);let d=[(s+u)/2,(c+f)/2,(l+m)/2],y=Math.max(1,.5*Math.hypot(u-s,f-c,m-l));return{center:d,radius:y,minY:c,maxY:f}}var ul=4096;function Jr(t,n,e=[]){let r=Math.max(1,Math.ceil(t.count/ul)),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 c=t.iPosition[s*3],l=t.iPosition[s*3+1],u=t.iPosition[s*3+2];a[i++]=c,a[i++]=l,a[i++]=u,a[i++]=c,a[i++]=0,a[i++]=u}for(let[s,c,l]of e)a[i++]=s,a[i++]=c,a[i++]=l;for(let s of n)for(let[c,l]of[[-1,-1],[1,-1],[1,1],[-1,1]])a[i++]=s.cx+c*s.halfX,a[i++]=s.y,a[i++]=s.cz+l*s.halfZ;return a.subarray(0,i)}function ti(t,n,e,r,o,a,i=[]){let s=1/0,c=1/0,l=-1/0,u=-1/0;for(let M=0;M<t.count;M++){let x=M*3,_=t.iPosition[x],I=t.iPosition[x+2];_<s&&(s=_),_>l&&(l=_),I<c&&(c=I),I>u&&(u=I)}for(let[M,,x]of i)M<s&&(s=M),M>l&&(l=M),x<c&&(c=x),x>u&&(u=x);for(let M of n)s=Math.min(s,M.cx-M.halfX),l=Math.max(l,M.cx+M.halfX),c=Math.min(c,M.cz-M.halfZ),u=Math.max(u,M.cz+M.halfZ);let f=e.minX*R,m=e.maxX*R,h=e.minY*R,d=e.maxY*R,y=f,b=m,p=h,g=d;if(Number.isFinite(s)){let M=Math.max(2,.06*Math.hypot(l-s,u-c));y=Math.max(f,s-M),b=Math.min(m,l+M),p=Math.max(h,c-M),g=Math.min(d,u+M)}let P=Math.min(0,r),A=Math.max(o,a*.05);return{min:[y,P,p],max:[b,A,g]}}var Kr=12,fl=.6,ml=40;function Vr(t,n,e,r,o){let a=un([...e]);if(a.length<3)return!1;let i=1/0,s=1/0,c=-1/0,l=-1/0;for(let A of a)i=Math.min(i,A.x),c=Math.max(c,A.x),s=Math.min(s,A.y),l=Math.max(l,A.y);let u=Math.hypot(c-i,l-s)*R,f=_t(a,Kr/R,1.2),m=Math.max(ml,u*fl),h=_t(a,(Kr+m)/R,1.2);if(f.length!==h.length)return!1;let d=st(r.ground,[.78,.76,.72],.35),y=st(r.ground,[.56,.62,.52],.3);Z(t,f,void 0,()=>n-.04,n-.22,d,d,K);let b=n-.05,p=f.map(A=>[A.x*R,b,A.y*R]),g=h.map(A=>[A.x*R,b,A.y*R]),P=[0,1,0];for(let A=0;A<p.length;A++){let M=(A+1)%p.length;t.tri(p[A],g[M],g[A],P,y,o,o),t.tri(p[A],p[M],g[M],P,y,y,o)}return!0}function Zr(t,n,e,r){let o=Nt(n,e);if(!o)return!1;let a=n.baseHeightM,i=st(r.ground,[.62,.55,.47],.4);return Z(t,o,void 0,()=>a-.04,a-.22,i,i,K),!0}var hl=3e3,yl=20,qr=1.5,dl=1.2,pl=.25;function $r(t,n,e,r,o){if(!e.length||e.length>hl||r.length<3)return!1;for(let S of n.objects){if(S.type==="shape"&&Sn(S.stageKind))return!1;if(S.type==="section"){let{height:B}=zt(S,{floorBaseHeightM:n.baseHeightM});if(B-n.baseHeightM>yl)return!1}}let a=0,i=0;for(let S of r)a+=S.x,i+=S.y;a/=r.length,i/=r.length;let s=0,c=0,l=0;for(let S of r){let B=S.x-a,T=S.y-i;s+=B*B,c+=T*T,l+=B*T}let u=.5*Math.atan2(2*l,s-c),f=Math.cos(u),m=Math.sin(u),h=-m,d=f,y=1/0,b=-1/0,p=1/0,g=-1/0;for(let S of r){let B=(S.x-a)*f+(S.y-i)*m,T=(S.x-a)*h+(S.y-i)*d;y=Math.min(y,B),b=Math.max(b,B),p=Math.min(p,T),g=Math.max(g,T)}let P=S=>[[y-S,p-S],[b+S,p-S],[b+S,g+S],[y-S,g+S]].map(([B,T])=>({x:a+f*B+h*T,y:i+m*B+d*T})),A=P(qr/R),M=P((qr+pl)/R),x=n.baseHeightM,_=st(o.ground,[.62,.55,.47],.4),I=st(o.ground,[.86,.86,.84],.55);return Z(t,M,void 0,()=>x-.04,x-.22,_,_,K),Z(t,M,[A.slice().reverse()],()=>x+dl,x-.04,st(I,[1,1,1],.2),I,K),!0}function ni(t,n,e){let r=()=>({byObjectId:new Map,elements:[]});if(!n||!t)return r();let o=Oe(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,c=new Map((n.overlay.productionElements??[]).map(f=>{let m=f.runtimeContentImageUrl;return[f.id,typeof m=="string"&&/^(?:blob:|data:image\/|https:\/\/)/.test(m)?m:void 0]})),l=[];for(let f of o.value.overlay.productionElements??[]){let m=a.get(f.objectId),h=m?ct(m.shape):null,d=f.baseElevationM??0;if(!m||!h||h.length<3||!f.id||i.has(f.id)||s.has(f.objectId)||!Number.isFinite(f.heightM)||f.heightM<.05||f.heightM>50||!Number.isFinite(d)||d<-10||d>100)return r();i.add(f.id),s.add(f.objectId);let y=h.map(I=>I.x*R),b=h.map(I=>I.y*R),p=m.unit.baseHeightM+d,g=Math.min(...y),P=Math.max(...y),A=Math.min(...b),M=Math.max(...b),x,_=c.get(f.id)??f.contentImageUrl;if(f.kind==="screen"&&_&&(x=Wo(h,p,p+f.heightM,m.unit.focal),!x))if(P-g>=M-A){let I=Math.abs(A-m.unit.focal.y*R)<=Math.abs(M-m.unit.focal.y*R)?A-.006:M+.006;x=[[g,p,I],[P,p,I],[g,p+f.heightM,I],[P,p+f.heightM,I]]}else{let I=Math.abs(g-m.unit.focal.x*R)<=Math.abs(P-m.unit.focal.x*R)?g-.006:P+.006;x=[[I,p,A],[I,p,M],[I,p+f.heightM,A],[I,p+f.heightM,M]]}l.push({id:f.id,objectId:f.objectId,kind:f.kind,floorIndex:m.unit.index,baseY:p,topY:p+f.heightM,bounds:{min:[g,p,A],max:[P,p+f.heightM,M]},occlusion:f.occlusion,..._?{contentImageUrl:_}:{},...x?{contentPlane:x}:{}})}let u=l.sort((f,m)=>f.id.localeCompare(m.id));return{byObjectId:new Map(u.map(f=>[f.objectId,f])),elements:u}}var ei=[.13,.14,.17],en=[.4,.43,.47],xl=.18,bl=.02,gl=2.4,Ml=1500,Pl=240,Rl=.25;function oi(t,n,e,r){let o=n.stageKind??"";if(Kt(o)||o==="round"||!r.length)return;let a=ct(n);if(!a||a.length<3)return;let i={x:a.reduce((C,L)=>C+L.x,0)/a.length,y:a.reduce((C,L)=>C+L.y,0)/a.length},s=0,c=0,l=new Set;for(let C of r)s+=C.x,c+=C.y,l.add(Math.floor(Math.atan2(C.y-i.y,C.x-i.x)*180/Math.PI/10));let u=i.x-s/r.length,f=i.y-c/r.length,m=Math.hypot(u,f);if(m<1e-6)return;let h=r.reduce((C,L)=>C+Math.hypot(L.x-i.x,L.y-i.y),0)/r.length;if(l.size*10>Pl&&m<Rl*h)return;let d=u/m,y=f/m,b=-y,p=d,g=-1/0,P=1/0,A=1/0,M=-1/0;for(let C of a){let L=(C.x-i.x)*d+(C.y-i.y)*y,O=(C.x-i.x)*b+(C.y-i.y)*p;g=Math.max(g,L),P=Math.min(P,L),A=Math.min(A,O),M=Math.max(M,O)}let x=(M-A)*R,_=(g-P)*R;if(x<3||_<1.5||x*_>Ml)return;let I=xl/R,S=(C,L)=>({x:i.x+d*C+b*L,y:i.y+y*C+p*L}),B=(C,L,O,D)=>[S(C,O),S(C,D),S(L,D),S(L,O)],T=e+Math.max(3.5,Math.min(8,x*.35)),F=e+Math.min(gl,T-e-1),k=.2/R,w=P+Math.min(_*.25,1.5)/R,E=bl/R;Z(t,B(g-2*I+E,g-I-E,A+I+k,M-I-k),void 0,()=>F,e,ei,ei,K);for(let[C,L]of[[A+I,A+I+k],[M-I-k,M-I]])Z(t,B(g-2*I,g-I,C,L),void 0,()=>T+.3,e,en,en,K),Z(t,B(w+k,g-2*I,C,L),void 0,()=>T+.3,T,en,en,K);Z(t,B(w,w+k,A+I,M-I),void 0,()=>T+.3,T,en,en,K)}function Mt(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function gt(t){return Array.isArray(t)?t:[]}function Sl(t){let n=[t];for(;n.length;){let e=n.pop();if(Array.isArray(e)){n.push(...e);continue}if(!Mt(e))continue;let r=Mt(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 zn(t,n){return!Array.isArray(t)||t.length!==n||!t.every(e=>typeof e=="number"&&Number.isFinite(e))?null:t}function Il(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function _l(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 Al(t){let n=zn(t.matrix,16);if(n)return n;if(t.matrix!==void 0)return null;let e=t.translation===void 0?[0,0,0]:zn(t.translation,3),r=t.rotation===void 0?[0,0,0,1]:zn(t.rotation,4),o=t.scale===void 0?[1,1,1]:zn(t.scale,3);if(!e||!r||!o)return null;let[a,i,s,c]=r,l=Math.hypot(a,i,s,c);if(!(l>1e-8))return null;let u=a/l,f=i/l,m=s/l,h=c/l,d=u+u,y=f+f,b=m+m,p=u*d,g=u*y,P=u*b,A=f*y,M=f*b,x=m*b,_=h*d,I=h*y,S=h*b;return[(1-(A+x))*o[0],(g+S)*o[0],(P-I)*o[0],0,(g-S)*o[1],(1-(p+x))*o[1],(M+_)*o[1],0,(P+I)*o[2],(M-_)*o[2],(1-(p+A))*o[2],0,e[0],e[1],e[2],1]}function wl(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 El(t){let n=t[0],e=t[4],r=t[8],o=t[1],a=t[5],i=t[9],s=t[2],c=t[6],l=t[10],u=a*l-i*c,f=i*s-o*l,m=o*c-a*s,h=n*u+e*f+r*m;if(Math.abs(h)<1e-12)return null;let d=1/h;return[u*d,f*d,m*d,(r*c-e*l)*d,(n*l-r*s)*d,(e*s-n*c)*d,(e*i-r*a)*d,(r*o-n*i)*d,(n*a-e*o)*d]}function ri(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 Bl(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 c=JSON.parse(new TextDecoder().decode(s).replace(/[\u0000 ]+$/g,""));if(!Mt(c))return null;r=c}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 Tl(t){return t===5120||t===5121?1:t===5122||t===5123?2:t===5125||t===5126?4:0}function Ol(t){return t==="SCALAR"?1:t==="VEC2"?2:t==="VEC3"?3:t==="VEC4"?4:0}function Cl(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 kl(t){let n=t instanceof Uint8Array?t:new Uint8Array(t),e=Bl(n);if(!e)return{ok:!1,issue:"invalid_glb"};let{json:r,bin:o}=e;if(!Mt(r.asset)||r.asset.version!=="2.0")return{ok:!1,issue:"unsupported_glb"};let a=gt(r.extensionsUsed).filter(A=>typeof A=="string");if(a.includes("KHR_draco_mesh_compression")||Sl(r))return{ok:!1,issue:"draco_not_allowed"};if(a.length||gt(r.extensionsRequired).length)return{ok:!1,issue:"unsupported_glb"};if(gt(r.images).length||gt(r.textures).length)return{ok:!1,issue:"external_resource"};let i=gt(r.buffers);if(i.length!==1||!Mt(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=gt(r.accessors),c=gt(r.bufferViews),l=gt(r.meshes),u=gt(r.nodes),f=gt(r.scenes),m=typeof r.scene=="number"?r.scene:0;if(!Mt(f[m]))return{ok:!1,issue:"unsupported_glb"};let h=new DataView(o.buffer,o.byteOffset,o.byteLength),d=(A,M,x)=>{if(typeof A!="number"||!Number.isInteger(A)||!Mt(s[A]))return null;let _=s[A];if(_.type!==M||_.sparse!==void 0||_.normalized===!0||typeof _.count!="number"||!Number.isInteger(_.count)||_.count<1||typeof _.componentType!="number"||!x.includes(_.componentType)||typeof _.bufferView!="number")return null;let I=c[_.bufferView];if(!Mt(I)||I.buffer!==0||typeof I.byteLength!="number"||!Number.isInteger(I.byteLength)||I.byteLength<0)return null;let S=Ol(_.type),B=Tl(_.componentType),T=typeof I.byteStride=="number"?I.byteStride:S*B,F=typeof I.byteOffset=="number"?I.byteOffset:0,k=typeof _.byteOffset=="number"?_.byteOffset:0,w=F+k,E=k+(_.count-1)*T+S*B;if(!Number.isInteger(T)||!Number.isInteger(F)||!Number.isInteger(k)||T<S*B||F<0||k<0||F+I.byteLength>o.byteLength||E>I.byteLength)return null;let C=[];for(let L=0;L<_.count;L++){let O=[];for(let D=0;D<S;D++){let H=Cl(h,w+L*T+D*B,_.componentType);if(!Number.isFinite(H))return null;O.push(H)}C.push(O)}return C},y=[],b=[],p=0,g=new Set,P=(A,M)=>{if(typeof A!="number"||!Number.isInteger(A)||!Mt(u[A])||g.has(A))return!1;g.add(A);let x=u[A],_=Al(x);if(!_)return!1;let I=_l(M,_),S=El(I);if(!S)return!1;if(x.mesh!==void 0){if(typeof x.mesh!="number")return!1;let B=l[x.mesh];if(!Mt(B))return!1;for(let T of gt(B.primitives)){if(!Mt(T)||T.mode!==void 0&&T.mode!==4||!Mt(T.attributes))return!1;let F=d(T.attributes.POSITION,"VEC3",[5126]),k=T.attributes.NORMAL===void 0?null:d(T.attributes.NORMAL,"VEC3",[5126]);if(!F||T.attributes.NORMAL!==void 0&&!k)return!1;let w=F.length;if(T.indices!==void 0){let C=typeof T.indices=="number"?s[T.indices]:null;w=Mt(C)?C.count:void 0}if(typeof w!="number"||!Number.isInteger(w)||w%3!==0||(p+=w/3,p>1e5))return!1;let E=T.indices===void 0?F.map((C,L)=>[L]):d(T.indices,"SCALAR",[5121,5123,5125]);if(!E||E.length%3!==0||E.length!==w)return!1;for(let C=0;C<E.length;C+=3){let L=[E[C][0],E[C+1][0],E[C+2][0]];if(L.some(H=>!Number.isInteger(H)||H<0||H>=F.length))return!1;let O=L.map(H=>wl(I,...F[H])),D=null;if(!k){let H=O[1][0]-O[0][0],j=O[1][1]-O[0][1],G=O[1][2]-O[0][2],U=O[2][0]-O[0][0],X=O[2][1]-O[0][1],Y=O[2][2]-O[0][2];D=ri([1,0,0,0,1,0,0,0,1],j*Y-G*X,G*U-H*Y,H*X-j*U)}for(let H=0;H<3;H++)y.push(...O[H]),b.push(...k?ri(S,...k[L[H]]):D)}}}for(let B of gt(x.children))if(!P(B,I))return!1;return g.delete(A),!0};for(let A of gt(f[m].nodes))if(!P(A,Il()))return{ok:!1,issue:p>1e5?"triangle_limit":"unsupported_glb"};return!p||y.length!==p*9||b.length!==y.length?{ok:!1,issue:"unsupported_glb"}:{ok:!0,triangleCount:p,position:new Float32Array(y),normal:new Float32Array(b)}}function ii(t){try{return kl(t)}catch{return{ok:!1,issue:"invalid_glb"}}}function ky(t){let{doc:n}=t,e=Er(n.theme),r=e.structure,o=wo(n,t.eventConfigurationId??n.eventConfigurationId),a=ni(t.eventConfigurationId,t.eventConfiguration,o),i=t.seats,s=new wn,c=null;if(t.registeredShellGlb){let v=ii(t.registeredShellGlb);if(v.ok){let N=v.position.length/3,W=new Float32Array(v.position.length),lt=e.materials.shell??r.tierWall;for(let ft=0;ft<N;ft++){let at=v.normal[ft*3+1],tt=at<-.25?.4:.62+.38*Math.max(0,at);W[ft*3]=lt[0]*tt,W[ft*3+1]=lt[1]*tt,W[ft*3+2]=lt[2]*tt}c={position:v.position,normal:v.normal,color:W,floor:new Float32Array(N).fill(-2),material:new Float32Array(N),count:N}}}let l=new Map;for(let v of o)for(let N of v.objects)l.set(N.id,v.index),N.type==="section"&&l.set(N.logicalSectionId??N.id,v.index);let u=i.map(v=>l.get(v.sectionId??"")??l.get(v.rowId??"")??0),f=Be(o,i),m=s.vertexCount,d=Qr(s,o,i,u,f,r,st(e.background.top,e.background.bottom,.5))?s.vertexCount:m,y=fo(n,i),b=new Map,p=new Map;for(let v of n.categories??[])b.set(v.key,v.color),v.seatGlyph&&p.set(v.key,v.seatGlyph);let g=[],P=Zo(o,i,u),A=new Map;i.forEach((v,N)=>{let W=P.seatDeckY(N);Number.isFinite(W)&&A.set(v.rowId,Math.min(A.get(v.rowId)??1/0,W))});let M=new Float32Array(i.length),x=[],_=new Map((n.floors??[]).map((v,N)=>[v.id,N])),I=o.map(()=>[]);for(let v of i){let N=v.floorId?_.get(v.floorId)??0:0;I[Math.min(N,I.length-1)]?.push(v)}let S=(v,N)=>{if(!N||N.length<3)return!1;let W=Math.min(...N.map(tt=>tt.x)),lt=Math.max(...N.map(tt=>tt.x)),ft=Math.min(...N.map(tt=>tt.y)),at=Math.max(...N.map(tt=>tt.y));for(let tt=0;tt<v;tt++)for(let et of I[tt])if(!(et.x<W||et.x>lt||et.y<ft||et.y>at)&&Rt(et,N,void 0))return!0;return!1},B=null,T=v=>o.length===1?i:i.filter((N,W)=>u[W]===v),F=(v,N)=>{let W=wt(v);if(!W)return!1;let lt=1/0,ft=1/0,at=-1/0,tt=-1/0;for(let et of W)lt=Math.min(lt,et.x),at=Math.max(at,et.x),ft=Math.min(ft,et.y),tt=Math.max(tt,et.y);return i.some((et,ht)=>et.kind!=="booth"&&(o.length===1||u[ht]===N)&&et.x>lt&&et.x<at&&et.y>ft&&et.y<tt&&xt(W,et.x,et.y))},k;for(let v=0;v<o.length;v++){let N=o[v];s.setFloor(v);let W=Nt(N,T(v)),lt=0;if(W){let z=0;for(let mt of N.objects)if(mt.type==="section")for(let yt of P.bySection.get(mt.id)?.rowLevels??[])z=Math.max(z,yt.y-N.baseHeightM);if(lt=ko(z),!k){let mt=$t(W);k={centre:[mt.x*R,mt.y*R]}}}let ft=new On,at=[],tt=N.objects.filter(z=>z.type==="shape"&&(z.role==="entrance"||z.role==="exit")),et=N.objects.filter(z=>z.type==="section"&&!!z.outline&&z.outline.length>=3),ht=Or(N.objects.filter(z=>z.type==="booth"),N.focal);for(let z of N.objects)if(z.type==="section"){let mt=s.vertexCount;Ur(s,z,N,mo(z,y),P.bySection.get(z.id),ft,et,r,v>0&&S(v,z.outline));let yt=s.vertexCount-mt;yt>0&&x.push({sectionId:z.id,start:mt,count:yt})}else if(z.type==="shape"){let mt=a.byObjectId.get(z.id),yt=g.length,Gt=W!==null&&z.role==="wall"&&!mt;s.setMaterial(Gt?Cn:(mt?.kind??z.role)==="screen"?1:0);let Ht=z.role==="stage"&&!mt?Cr(z,T(v)):Gt&&z.heightM===void 0?{...z,heightM:lt}:z,kt=Oo(Ht,at);if(mr(s,Ht,N.baseHeightM+kt.supportOffsetM,kt.topOffsetM-kt.supportOffsetM,r,N.focal,g,mt,tt),s.setMaterial(0),z.role==="stage"&&!mt&&g.length>yt&&(B??v)===v){B=v;let Ft=n.floors?.[v]?.id,on=o.length>1&&Ft?i.filter(gn=>gn.floorId===Ft):i;oi(s,Ht,g[g.length-1].y,on)}}else z.type==="gaArea"?yr(s,z,N.baseHeightM,it(b.get(z.categoryKey)),r):z.type==="booth"?lr(s,z,N.baseHeightM,it(b.get(z.categoryKey)),r,ht.get(z.id)??N.focal,F(z,v)):z.type==="table"?fr(s,z,Math.max(N.baseHeightM,A.get(z.id)??N.baseHeightM),it(z.fill??n.theme?.decorFill??"#232c40"),r,!!(z.fill??n.theme?.decorFill)):z.type==="decorImage"&&hr(s,z,N.baseHeightM,r);W&&xr(s,N.objects,W,N.baseHeightM,lt,N.focal,r,z=>!a.byObjectId.has(z.id)),Yr(s,N,i,P,r,e.materials.shell,!c)}let w=o.length>1?{x:o.reduce((v,N)=>v+N.focal.x,0)/o.length,y:o.reduce((v,N)=>v+N.focal.y,0)/o.length}:n.focalPoint??{x:(f.minX+f.maxX)/2,y:(f.minY+f.maxY)/2},E=oo(c?[s.build(),c]:[s.build()]),C=ao(i,t.initialState,P,M,b,p),L=Sr({doc:n,units:o,seats:i,surfaces:P,focal:w}),{labels:O,sections:D,rows:H}=Ir({doc:n,units:o,seats:i,surfaces:P,seatData:C,hintedSeatFloor:u,zones:L,focal:w}),j=new Map(D.map((v,N)=>[v.id,N]));P.seatOwner.forEach((v,N)=>{C.iSection[N]=v?j.get(v)??-1:-1});let G=zr({doc:n,units:o,seats:i,surfaces:P,solids:E,hintedSeatFloor:u,seatFloor:M});_r(O,G),C.iYaw=so(C.iPosition,i.length,v=>i[v].rowId,v=>{let N=o[M[v]]?.focal??w;return[N.x*R,N.y*R]});let U=(f.minX+f.maxX)/2*R,X=(f.minY+f.maxY)/2*R,Y=.5*Math.hypot((f.maxX-f.minX)*R,(f.maxY-f.minY)*R)||10,nt=Te(E,C,{cx:U,cz:X,radius:Y},[m,d]),rt=Te(E,C,{cx:U,cz:X,radius:Y}),q=Fl(o),Q=ti(C,g,f,nt.minY,nt.maxY,Y,q);return{sharedAisles:Ar(o.flatMap(v=>v.objects.flatMap(N=>{if(N.type!=="section")return[];let W=P.bySection.get(N.id);return W?[{sectionId:N.id,floorIndex:v.index,rows:W.rowLevels}]:[]}))),solids:E,sectionSolidRanges:x,seats:C,seatSectionIds:P.seatOwner,bounds:{center:[(Q.min[0]+Q.max[0])/2,(Q.min[1]+Q.max[1])/2,(Q.min[2]+Q.max[2])/2],radius:Y,groundY:0,box:Q,fitPoints:Jr(C,g,q)},...k?{room:k}:{},...!k&&o.some(v=>v.objects.some(N=>N.type==="shape"&&Sn(N.stageKind)))?{outdoor:!0}:{},renderBounds:{center:nt.center,radius:nt.radius},clipBounds:{center:rt.center,radius:rt.radius},stateColorLUT:Br(e,rn),theme:e,seatCount:i.length,focalWorld:[w.x*R,1.5,w.y*R],zones:L,stages:g,productionElements:a.elements,sections:D,rows:H,labels:O,floors:G}}function Fl(t){let n=[];for(let e of t)for(let r of e.objects){let o=r.type==="gaArea"?r.points:r.type==="booth"?wt(r):null;for(let a of o??[])n.push([a.x*R,e.baseHeightM,a.y*R])}return n}function Ll(t,n){let{doc:e,report:r}=Uo(t),o=r.confident&&(r.sections.length>0||!!r.looseRowBlocks);if(!o&&!r.roles?.length)return null;if(!o){let c=new Map(r.roles.map(h=>[h.id,h.role])),l=h=>h.map(d=>d.type==="shape"&&c.has(d.id)?{...d,role:c.get(d.id)}:d),u=t.floors?.map(h=>({...h,objects:l(h.objects)})),f=new Float64Array(n.length).fill(Number.NaN),m=new Float64Array(n.length*2).fill(Number.NaN);return n.forEach((h,d)=>{h.eyeHeightM!==void 0&&(f[d]=h.eyeHeightM),h.focalPoint&&(m[d*2]=h.focalPoint.x,m[d*2+1]=h.focalPoint.y)}),{doc:{...t,objects:u?.[0]?.objects??l(t.objects),...u?{floors:u}:{}},report:r,eyeHeightM:f,focal:m}}let a=new Map(In(e).map(c=>[c.id,c])),i=new Float64Array(n.length).fill(Number.NaN),s=new Float64Array(n.length*2).fill(Number.NaN);return n.forEach((c,l)=>{let u=a.get(c.id)??c;u.eyeHeightM!==void 0&&(i[l]=u.eyeHeightM),u.focalPoint&&(s[l*2]=u.focalPoint.x,s[l*2+1]=u.focalPoint.y)}),{doc:e,report:r,eyeHeightM:i,focal:s}}function vl(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 Ny(t){let n=t.estimate===!1?null:Ll(t.doc,t.seats);return n?{input:{...t,doc:n.doc,seats:vl(t.seats,n)},estimate:n}:{input:t}}export{Yl as a,gi as b,Mi as c,ro as d,Pi as e,zl as f,rn as g,Zn as h,to as i,$n as j,R as k,Bn as l,nu as m,eu as n,Uo as o,Uu as p,Wu as q,Yu as r,zu as s,Ku as t,Vu as u,le as v,Zu as w,qu as x,$u as y,Qu as z,Ju as A,pc as B,ky as C,Ll as D,vl as E,Ny as F};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Sa as K,bb as F,eb as j}from"./chunk-
|
|
1
|
+
import{Sa as K,bb as F,eb as j}from"./chunk-J33DNOMI.js";function C(t){let o=Number(t.slice(t.lastIndexOf(":")+1));return Number.isFinite(o)?o:-1}function se(t,o,n){let e=new Map;for(let s of t){if(s.kind==="booth")continue;let r=e.get(s.rowId);r?r.push(s):e.set(s.rowId,[s])}let c=s=>n.has(s.id)||o(s.id)!=="free",a=[];for(let s of e.values())if(!(s.length<3)){s.sort((r,l)=>C(r.id)-C(l.id));for(let r=1;r<s.length-1;r++){let l=s[r];if(c(l))continue;let g=s[r-1],m=s[r+1];C(l.id)-C(g.id)!==1||C(m.id)-C(l.id)!==1||!c(g)||!c(m)||!n.has(g.id)&&!n.has(m.id)||a.push(l)}}return a}function X(t){return Array.isArray(t.objects)}function z(t,o){if(o.seatsByLabel)return o.seatsByLabel;if(!X(t))throw new Error("ticketRestrictions: a categories-only chart document requires options.seatsByLabel");return new Map(j(t,{resolveEyeHeights:!1}).map(n=>[n.label,n]))}function Z(t){return{code:"ticket_option_not_applicable",labels:t,message:"That ticket choice is not available for the selected seat."}}function D(t,o){let n=t.applicability;return n?!(n.seatLabels?.length&&!n.seatLabels.includes(o.label)||n.accessibility?.length&&!n.accessibility.some(e=>o.accessibility?.includes(e))):!0}function de(t,o){return(t.categories.find(n=>n.key===o.categoryKey)?.tiers??[]).filter(n=>D(n,o))}function G(t,o,n){let e=t.categories.find(a=>a.key===o.categoryKey)?.tiers;if(!e?.length)return{kind:"none"};let c=n==null?e.find(a=>D(a,o)):e.find(a=>a.id===n&&D(a,o));return c?{kind:"resolved",tier:c}:{kind:"invalid"}}function ee(t,o){return(t.logicalRowId??t.rowId)===(o.logicalRowId??o.rowId)}function q(t){if(Number.isInteger(t.logicalSeatIndex))return t.logicalSeatIndex;let o=t.id.slice(t.id.lastIndexOf(":")+1),n=Number(o);return Number.isInteger(n)?n:void 0}function te(t,o){if(!ee(t,o))return!1;let n=q(t),e=q(o);return n!=null&&e!=null&&Math.abs(n-e)===1}function ne(t,o,n={}){if(!o.length)return null;let e=z(t,n),c=o.flatMap(r=>{let l=e.get(r.label);return l?[{selection:r,seat:l}]:[]}),a=c.map(({seat:r})=>r).filter(r=>r.accessibility?.includes("wheelchair")),s=[];for(let{selection:r,seat:l}of c){let g=G(t,l,r.tierId),m=g.kind==="resolved"?g.tier:void 0;(l.accessibility?.includes("companion")||m?.restriction==="companion")&&!a.some(x=>x.id!==l.id&&te(l,x))&&s.push(l.label)}return s.length?{code:"companion_pair_required",labels:s,message:"Select the adjacent wheelchair place with each companion ticket."}:null}function ue(t,o,n={}){if(!o.length)return null;let e=z(t,n),c=new Set(t.categories.filter(r=>r.notForSale).map(r=>r.key)),a=[],s=[];for(let r of o){let l=e.get(r.label);if(!l)continue;if(c.has(l.categoryKey)){a.push(l.label);continue}G(t,l,r.tierId).kind==="invalid"&&s.push(l.label)}return a.length?{code:"not_for_sale",labels:a,message:"These seats are not for sale."}:s.length?Z(s):ne(t,o,{seatsByLabel:e})}function $(t){return t.sectionId?`s:${t.sectionId}`:`r:${t.logicalRowId??t.rowId}`}function ie(t,o){let n=new Set,e=new Map;for(let c of t){let a=c.focalPoint??o,s=`${a.x},${a.y}`,r=e.get(s);r||(r={focal:a,seats:[]},e.set(s,r)),r.seats.push(c)}for(let{focal:c,seats:a}of e.values()){let s=E(a),r=s.x-c.x,l=s.y-c.y,g=Math.hypot(r,l),m=0;for(let y of a)m=Math.max(m,Math.abs(y.x-c.x),Math.abs(y.y-c.y));let u=Math.max(m,1)*1e-6;if(!(g>u))continue;let x=0,T=new Set;for(let y of a)((y.x-c.x)*r+(y.y-c.y)*l)/g<-u&&(x+=1,T.add($(y)));if(!T.size||x*10>a.length)continue;let w=a.filter(y=>T.has($(y)));if(!(w.length*4>a.length))for(let y of w)n.add(y.label)}return n}function O(t,o){if(Number.isInteger(t.logicalSeatIndex))return t.logicalSeatIndex;let n=t.id.lastIndexOf(":");if(n<0)return o;let e=Number(t.id.slice(n+1));return Number.isFinite(e)?e:o}function A(t,o){let n=t.x-o.x,e=t.y-o.y;return n*n+e*e}function E(t){let o=0,n=0;for(let e of t)o+=e.x,n+=e.y;return{x:o/t.length,y:n/t.length}}function U(t,o){return t.find(n=>n.focalPoint)?.focalPoint??o}function M(t){return t.commercial?.premium===!0}function oe(t,o,n){let e=Math.floor(n.qty);if(!Number.isFinite(e)||e<=0)return{labels:[],reason:"sold_out"};let{categoryKey:c,zoneId:a,focal:s,preferPremium:r,preferNearest:l,preferredRowIds:g,accessibility:m,requireContiguous:u}=n,x=n.preferAisle&&n.aisleLabels?.size?n.aisleLabels:null,T=i=>x&&!i.some(d=>x.has(d.label))?1:0,w=new Map,y=[];if(t.forEach((i,d)=>{let b=o.has(i.label)&&(!c||i.categoryKey===c)&&(!a||i.zoneId===a)&&(!m||m.some(S=>i.accessibility?.includes(S))),h=i.logicalRowId??i.rowId,f=w.get(h);f||(f=[],w.set(h,f)),f.push({seat:i,index:O(i,d),elig:b}),b&&y.push(i)}),y.length===0)return{labels:[],reason:"sold_out"};let v=!c&&!a&&!l?ie(t,s):new Set,V=i=>v.size?i.reduce((d,b)=>d+(v.has(b.label)?1:0),0):0,_=new Map([...w].map(([i,d])=>[i,E(d.map(b=>b.seat))])),L=(g??[]).map(i=>_.get(i)).filter(i=>!!i),N=i=>{let d=_.get(i);return!d||!L.length?0:Math.min(...L.map(b=>A(d,b)))},p=null,W=i=>{if(!p)return!0;if(r&&i.nonPremium!==p.nonPremium)return i.nonPremium<p.nonPremium;if(l&&i.rowD2!==p.rowD2)return i.rowD2<p.rowD2;if(l&&i.d2!==p.d2)return i.d2<p.d2;if(i.behind!==p.behind)return i.behind<p.behind;if(i.noAisle!==p.noAisle)return i.noAisle<p.noAisle;if(i.orphan!==p.orphan)return i.orphan<p.orphan;if(i.d2!==p.d2)return i.d2<p.d2;let d=i.rowId.localeCompare(p.rowId);return d!==0?d<0:i.startIndex<p.startIndex};for(let[i,d]of w){let b=[...d].sort((f,S)=>f.index-S.index),h=0;for(;h<b.length;){if(!b[h].elig){h++;continue}let f=h;for(;f<b.length&&b[f].elig&&(f===h||b[f].index===b[f-1].index+1);)f++;let S=f-h;for(let I=0;I+e<=S;I++){let H=I,Y=S-(I+e),J=H===1||Y===1?1:0,k=b.slice(h+I,h+I+e).map(R=>R.seat),B={labels:k.map(R=>R.label),seats:k,rowId:i,startIndex:b[h+I].index,orphan:J,nonPremium:r?k.reduce((R,Q)=>R+(M(Q)?0:1),0):0,behind:V(k),noAisle:T(k),rowD2:N(i),d2:A(E(k),l?s:U(k,s))};W(B)&&(p=B)}h=f}}return p?{labels:p.labels}:u?{labels:[],reason:y.length?"not_enough_together":"sold_out"}:y.length<e?{labels:[],reason:"not_enough_together"}:{labels:y.map((i,d)=>({seat:i,i:d,rowD2:N(i.logicalRowId??i.rowId),d2:A(i,l?s:i.focalPoint??s)})).sort((i,d)=>{if(r){let S=M(i.seat)?0:1,I=M(d.seat)?0:1;if(S!==I)return S-I}if(l&&i.rowD2!==d.rowD2)return i.rowD2-d.rowD2;let b=v.has(i.seat.label)?1:0,h=v.has(d.seat.label)?1:0;if(b!==h)return b-h;if(x){let S=x.has(i.seat.label)?0:1,I=x.has(d.seat.label)?0:1;if(S!==I)return S-I}if(i.d2!==d.d2)return i.d2-d.d2;let f=(i.seat.logicalRowId??i.seat.rowId).localeCompare(d.seat.logicalRowId??d.seat.rowId);return f!==0?f:O(i.seat,i.i)-O(d.seat,d.i)}).slice(0,e).map(i=>i.seat.label)}}function be(t,o,n,e){let c=Math.floor(e.qty),a=oe(t,n,e),r=o.filter(u=>u.bookingMode==="whole"&&u.capacity===c&&n.has(u.label)&&(!e.categoryKey||u.categoryKey===e.categoryKey)&&(!e.zoneId||u.zoneId===e.zoneId)&&!e.accessibility).map(u=>({table:u,d2:A(u.center,e.preferNearest?e.focal:u.focalPoint??e.focal)})).sort((u,x)=>u.d2-x.d2||u.table.label.localeCompare(x.table.label))[0];if(!r)return a;if(!a.labels.length)return{labels:[r.table.label]};if(e.preferAisle&&e.aisleLabels&&a.labels.some(u=>e.aisleLabels.has(u)))return a;let l=new Map(t.map(u=>[u.label,u])),g=a.labels.map(u=>l.get(u)).filter(u=>!!u),m=g.length?A(E(g),U(g,e.focal)):Number.POSITIVE_INFINITY;return r.d2<m?{labels:[r.table.label]}:a}var P=class extends Error{constructor(n,e){super(e);this.objectId=n;this.name="GroupedTableProjectionError"}};function re(t){let o=t.minOccupancy,n=t.maxOccupancy;if(!Number.isInteger(o)||!Number.isInteger(n)||o<1||n<o||n>t.seatCount)throw new P(t.id,`Table "${t.label}" has invalid variable-occupancy bounds`);return{min:o,max:n}}function ye(t,o){if(o!==2)return[];let n=[];for(let e of F(t)){if(e.type!=="table"||!e.bookAsWhole&&!e.variableOccupancy)continue;if(e.bookAsWhole&&e.variableOccupancy)throw new P(e.id,`Table "${e.label}" cannot be whole-table and variable-occupancy inventory`);if(!Number.isInteger(e.seatCount)||e.seatCount<1||!e.label.trim())throw new P(e.id,"Grouped tables require a label and at least one chair");let c=e.variableOccupancy?"variable":"whole",a=c==="variable"?re(e):{min:e.seatCount,max:e.seatCount};n.push({objectId:e.id,label:e.label,...e.displayLabel?{displayLabel:e.displayLabel}:{},...e.displayType?{displayType:e.displayType}:{},categoryKey:e.categoryKey,mode:c,capacity:e.seatCount,minOccupancy:a.min,maxOccupancy:a.max,chairs:K(e)})}return n}export{se as a,X as b,Z as c,D as d,de as e,G as f,ne as g,ue as h,ie as i,oe as j,be as k,P as l,ye as m};
|