@seatlayer/core 0.96.0 → 0.98.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ar-Q44JP5JY.js +1 -0
- package/dist/be-CGFFSIQL.js +1 -0
- package/dist/bg-WOYK6OLH.js +1 -0
- package/dist/ca-77ZVI3X5.js +1 -0
- package/dist/chunk-2MXDWZQ4.js +1 -0
- package/dist/chunk-2P72QUJR.js +1 -0
- package/dist/chunk-5N4H3KMR.js +1 -0
- package/dist/chunk-ASIIXY5M.js +1 -0
- package/dist/{chunk-O3DGXAIC.js → chunk-CUACREZL.js} +1 -1
- package/dist/{chunk-CEIVHWRB.js → chunk-FLMKHAUT.js} +1 -1
- package/dist/{chunk-TKYTTEJ2.js → chunk-IW7QZIMF.js} +1 -1
- package/dist/chunk-M5VINTGE.js +1 -0
- package/dist/{chunk-U7CVRE4P.js → chunk-OLGPAFXW.js} +1 -1
- package/dist/{chunk-M5X6G7FD.js → chunk-P4C24CIZ.js} +1 -1
- package/dist/{chunk-A3ZL3R75.js → chunk-QEPYNCBJ.js} +1 -1
- package/dist/chunk-VAI2VDQR.js +1 -0
- package/dist/{chunk-Q3MSDG4S.js → chunk-YPESNMTC.js} +1 -1
- package/dist/chunk-Z43H6AWN.js +1 -0
- package/dist/core/chart-ops/index.cjs +1 -1
- package/dist/core/chart-ops/index.d.cts +40 -18
- package/dist/core/chart-ops/index.d.ts +40 -18
- 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/quality/index.js +1 -1
- package/dist/core/render-assets/index.js +1 -1
- package/dist/core/sections/index.js +1 -1
- package/dist/cs-OSBZYCSR.js +1 -0
- package/dist/cy-ZCOJW2WH.js +1 -0
- package/dist/da-2PDK6JTR.js +1 -0
- package/dist/de-R5LLVFUU.js +1 -0
- package/dist/el-ZPFVDCWA.js +1 -0
- package/dist/es-7YASJP32.js +1 -0
- package/dist/et-J4TV6KQL.js +1 -0
- package/dist/fa-4TEO7UGM.js +1 -0
- package/dist/fi-GIUDDKMH.js +1 -0
- package/dist/fr-J5J2XJLA.js +1 -0
- package/dist/he-OCEHSVUJ.js +1 -0
- package/dist/hi-EK5CTBW5.js +1 -0
- package/dist/hr-SLDTQOYC.js +1 -0
- package/dist/hu-2QNE77NO.js +1 -0
- package/dist/id-LGDAFQJK.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +8 -16
- package/dist/index.d.ts +8 -16
- package/dist/index.js +1 -1
- package/dist/it-DT4Y3IYB.js +1 -0
- package/dist/ja-D5EY2XCQ.js +1 -0
- package/dist/ko-DD2NV45Q.js +1 -0
- package/dist/ku-KZCMVLBE.js +1 -0
- package/dist/localeLoaders-GGAKX22E.js +1 -0
- package/dist/lt-QWGTJ47Y.js +1 -0
- package/dist/lv-LYAIG3VK.js +1 -0
- package/dist/ms-XTF4KNGD.js +1 -0
- package/dist/nl-QEXY6XHS.js +1 -0
- package/dist/no-HCOXN2CN.js +1 -0
- package/dist/pl-BWY53TSD.js +1 -0
- package/dist/pt-2UJUBCPL.js +1 -0
- package/dist/ro-GGXOLTED.js +1 -0
- package/dist/ru-ZTFK3WCU.js +1 -0
- package/dist/sk-KU543Y2U.js +1 -0
- package/dist/sl-FT576R7A.js +1 -0
- package/dist/sr-WE3J46JE.js +1 -0
- package/dist/stage-CKb7aNoH.d.cts +18 -0
- package/dist/stage-CKb7aNoH.d.ts +18 -0
- package/dist/sv-YEAOPSEB.js +1 -0
- package/dist/th-BEBRDHJA.js +1 -0
- package/dist/tr-LOAHUPSH.js +1 -0
- package/dist/uk-2GMICSHN.js +1 -0
- package/dist/vi-TC5B6AUR.js +1 -0
- package/dist/view3d/index.cjs +283 -78
- package/dist/view3d/index.d.cts +152 -78
- package/dist/view3d/index.d.ts +152 -78
- package/dist/view3d/index.js +281 -76
- package/dist/view3d/scene/scene.worker.cjs +1 -1
- package/dist/view3d/scene/scene.worker.js +1 -1
- package/dist/zh-Hans-TSZWTZQY.js +1 -0
- package/dist/zh-Hant-TLB4FZYM.js +1 -0
- package/package.json +1 -1
- package/dist/ar-3S65PDDG.js +0 -1
- package/dist/be-WJKGEBTI.js +0 -1
- package/dist/bg-TZUF36MP.js +0 -1
- package/dist/ca-WLW64J7W.js +0 -1
- package/dist/chunk-F2EXXZSZ.js +0 -1
- package/dist/chunk-F7TP67LK.js +0 -1
- package/dist/chunk-LAX7F5ML.js +0 -1
- package/dist/chunk-LFJUXTIO.js +0 -1
- package/dist/chunk-M7JA4BGP.js +0 -1
- package/dist/cs-HQXANWJA.js +0 -1
- package/dist/cy-EG5BJOG7.js +0 -1
- package/dist/da-5XEBRUEE.js +0 -1
- package/dist/de-SCVAU32D.js +0 -1
- package/dist/el-KBW7YAF5.js +0 -1
- package/dist/es-IFLC65KX.js +0 -1
- package/dist/et-OXB22VMP.js +0 -1
- package/dist/fa-GFAZXHP6.js +0 -1
- package/dist/fi-AI67VYYH.js +0 -1
- package/dist/fr-V3RG2KYP.js +0 -1
- package/dist/he-J3I6MRUR.js +0 -1
- package/dist/hr-SA4WZ3AG.js +0 -1
- package/dist/hu-TM35NZ4U.js +0 -1
- package/dist/it-E4QYIYC4.js +0 -1
- package/dist/ja-S5M7EINH.js +0 -1
- package/dist/ku-DNZQIUUG.js +0 -1
- package/dist/localeLoaders-JTNNRDK2.js +0 -1
- package/dist/lt-ETQDX2HL.js +0 -1
- package/dist/lv-FYFIWI4F.js +0 -1
- package/dist/nl-XOG5SBZQ.js +0 -1
- package/dist/no-7UGUTFXW.js +0 -1
- package/dist/pl-5HR7DQIK.js +0 -1
- package/dist/pt-L4CCONDZ.js +0 -1
- package/dist/ro-KZVPOCZ6.js +0 -1
- package/dist/ru-CD7HYORB.js +0 -1
- package/dist/sk-AQZOHJYW.js +0 -1
- package/dist/sl-XYRITXI6.js +0 -1
- package/dist/sr-6VTXFVHT.js +0 -1
- package/dist/sv-EJWP7WJV.js +0 -1
- package/dist/tr-VKVADTIZ.js +0 -1
- package/dist/uk-QSJV3LDS.js +0 -1
- package/dist/zh-Hans-2FN4LFAW.js +0 -1
- package/dist/zh-Hant-5T2AB4FR.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as Pe,c as Se,d as Ie}from"./chunk-OLGPAFXW.js";import{a as be}from"./chunk-QJXSZT3H.js";import{v as Re}from"./chunk-ASIIXY5M.js";import{a as ge,c as jt,d as mt,f as ht,i as Me}from"./chunk-P4C24CIZ.js";import{f as se}from"./chunk-Z43H6AWN.js";import{e as de,l as xe}from"./chunk-4N5CHKHD.js";import{B as ce,C as qt,Ma as At,Va as fn,ba as et,ca as xt,j as ae,la as ln,na as Xt,oa as un,qa as le,sa as Ht,ta as ue,ua as fe,wa as Fn,xa as me,ya as he}from"./chunk-VAI2VDQR.js";import{A as _t,D as pe,b as ye,d as ot,y as rt}from"./chunk-JBOTRSMY.js";import xr from"earcut";import _e from"polygon-clipping";var P=et,br=.002;function gr(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<br}var Lt=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)}},yn=class{constructor(){this.pos=new Lt;this.nor=new Lt;this.col=new Lt;this.flr=new Lt;this.mat=new Lt;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){gr(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,u=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(u[0],u[1],u[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 Mr(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],u=o*c-a*s,l=a*i-r*c,f=r*s-o*i,m=Math.hypot(u,l,f)||1;return u/=m,l/=m,f/=m,[u,l,f]}function Pr(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=xr(r,o.length?o:void 0,2);return{pts:e,tris:a}}function wt(t){return mt(t)<0?[...t].reverse():t}var Sr=3;function Ir(t,n,e,r){let o=r(t),a=r(n),i=r(e),s=(h,y,p,x)=>Math.abs(r({x:(h.x+y.x)/2,y:(h.y+y.y)/2})-(p+x)/2),c=(t.x+n.x+e.x)/3,u=(t.y+n.y+e.y)/3,l=(o+a+i)/3,f=Math.max(s(t,n,o,a),s(n,e,a,i),s(e,t,i,o),Math.abs(r({x:c,y:u})-l)),m=(h,y,p)=>{let x=Math.abs(r({x:(h+c)/2,y:(y+u)/2})-(p+l)/2);x>f&&(f=x)};return m((t.x+n.x)/2,(t.y+n.y)/2,(o+a)/2),m((n.x+e.x)/2,(n.y+e.y)/2,(a+i)/2),m((e.x+t.x)/2,(e.y+t.y)/2,(i+o)/2),f}function $t(t,n,e,r,o){if(o<=0)return Ir(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($t(t,a,s,r,o-1),$t(a,n,i,r,o-1),$t(s,i,e,r,o-1),$t(a,i,s,r,o-1))}function Qt(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},y={x:(r.x+n.x)/2,y:(r.y+n.y)/2};Qt(t,n,m,y,o,a,i-1,s),Qt(t,m,e,h,o,a,i-1,s),Qt(t,y,h,r,o,a,i-1,s),Qt(t,m,h,y,o,a,i-1,s);return}let c=[n.x*P,o(n),n.y*P],u=[e.x*P,o(e),e.y*P],l=[r.x*P,o(r),r.y*P];if(s){t.triN(c,u,l,s(n),s(e),s(r),a);return}let f=Mr(c,u,l);f[1]<0&&(f=[-f[0],-f[1],-f[2]]),t.tri(c,u,l,f,a)}var Rr=8;function Ae(t,n,e){if(!Number.isFinite(e))return t;let r=[],o=(a,i,s,c,u)=>{if(u>0){let l={x:(a.x+i.x)/2,y:(a.y+i.y)/2},f=n(l);if(Math.abs(f-(s+c)/2)>e){o(a,l,s,f,u-1),o(l,i,f,c,u-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),Rr)}return r}function mn(t,n){if(t.length<3)return t;let e=[];for(let o of t){let a=e[e.length-1];a&&Math.hypot(o.x-a.x,o.y-a.y)<n||e.push(o)}for(;e.length>2&&Math.hypot(e[0].x-e[e.length-1].x,e[0].y-e[e.length-1].y)<n;)e.pop();if(e.length<3)return t;let r=[];for(let o=0;o<e.length;o++){let a=r.length?r[r.length-1]:e[(o-1+e.length)%e.length],i=e[o],s=e[(o+1)%e.length],c=s.x-a.x,u=s.y-a.y,l=Math.hypot(c,u);l>n&&Math.abs((i.x-a.x)*u-(i.y-a.y)*c)/l<n||r.push(i)}return r.length>=3?r:e}var hn=.001*xt*.1;function V(t,n,e,r,o,a,i,s,c=1/0,u){if(!n||n.length<3||(c===void 0&&(c=1/0),Math.abs(mt(n))<1e-4))return;let l=mn(Ae(mn(wt(n),hn),r,c),hn),f=e?.map(R=>mn(Ae(mn(wt(R),hn),r,c),hn)).filter(R=>R.length>=3&&Math.abs(mt(R))>=1e-4),{pts:m,tris:h}=Pr(l,f),y=[a[0]*s.top,a[1]*s.top,a[2]*s.top],p=[a[0]*s.bottomCap,a[1]*s.bottomCap,a[2]*s.bottomCap],x=[i[0]*s.top,i[1]*s.top,i[2]*s.top],b=[i[0]*s.wallBottom,i[1]*s.wallBottom,i[2]*s.wallBottom],d=0;if(Number.isFinite(c))for(;d<Sr;d++){let R=0;for(let A=0;A<h.length;A+=3){let S=$t(m[h[A]],m[h[A+1]],m[h[A+2]],r,d);S>R&&(R=S)}if(R<=c)break}for(let R=0;R<h.length;R+=3){let A=m[h[R]],S=m[h[R+1]],I=m[h[R+2]];Qt(t,A,S,I,r,y,d,u);let w=[A.x*P,o,A.y*P],T=[S.x*P,o,S.y*P],k=[I.x*P,o,I.y*P];t.tri(w,k,T,[0,-1,0],p)}let M=R=>{if(d<=0)return R;let A=1<<d,S=[];for(let I=0;I<R.length;I++){let w=R[I],T=R[(I+1)%R.length];for(let k=0;k<A;k++){let N=k/A;S.push({x:w.x+(T.x-w.x)*N,y:w.y+(T.y-w.y)*N})}}return S},g=ce(l),_=[{ring:M(l),flip:!1}];if(f)for(let R of f)R.length>=3&&_.push({ring:M(R),flip:!0});for(let{ring:R,flip:A}of _)for(let S=0;S<R.length;S++){let I=R[S],w=R[(S+1)%R.length],T=(w.x-I.x)*P,N=(w.y-I.y)*P,B=-T,E=Math.hypot(N,B)||1;N/=E,B/=E;let O=(I.x+w.x)/2-g.x,L=(I.y+w.y)/2-g.y,C=N*O+B*L;A&&(C=-C),C<0&&(N=-N,B=-B);let F=[N,0,B],v=[I.x*P,r(I),I.y*P],G=[w.x*P,r(w),w.y*P],j=[I.x*P,o,I.y*P],U=[w.x*P,o,w.y*P];t.tri(v,G,U,F,x,x,b),t.tri(v,U,j,F,x,b,b)}}function we(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 Mt(t,n,e=2.5){if(n<=0||t.length<3)return t;let r=wt(t),o=r.length,a=[];for(let s=0;s<o;s++){let c=r[s],u=r[(s+1)%o],l=u.x-c.x,f=u.y-c.y,m=Math.hypot(l,f)||1;a.push({x:f/m,y:-l/m})}let i=[];for(let s=0;s<o;s++){let c=r[s],u=a[(s-1+o)%o],l=a[s],f=u.x+l.x,m=u.y+l.y,h=Math.hypot(f,m),y=()=>{i.push([c.x+u.x*n,c.y+u.y*n]),i.push([c.x+l.x*n,c.y+l.y*n])};if(h<1e-9){y();continue}f/=h,m/=h;let p=f*u.x+m*u.y,x=1/Math.max(p,1e-6);if(!Number.isFinite(x)||x>e){y();continue}i.push([c.x+f*n*x,c.y+m*n*x])}if(i.length<3)return t;try{let s=_e.union([[...i,i[0]]]),c=null,u=-1/0;for(let f of s){let m=Math.abs(mt(f[0].map(([h,y])=>({x:h,y}))));m>u&&(u=m,c=f[0])}if(!c)return t;let l=c.map(([f,m])=>({x:f,y:m}));if(l.length>1){let f=l[0],m=l[l.length-1];Math.abs(f.x-m.x)<1e-9&&Math.abs(f.y-m.y)<1e-9&&l.pop()}return l.length>=3?l:t}catch{return t}}function Dt(t,n,e=2.5){if(t.length<3)return[];if(n<=0)return t;let r=wt(t),o=r.length,a=[];for(let c=0;c<o;c++){let u=r[c],l=r[(c+1)%o],f=Math.hypot(l.x-u.x,l.y-u.y)||1;a.push({x:-(l.y-u.y)/f,y:(l.x-u.x)/f})}let i=[],s=[];for(let c=0;c<o;c++){let u=r[c],l=a[(c-1+o)%o],f=a[c],m=l.x+f.x,h=l.y+f.y,y=Math.hypot(m,h),p=y<1e-9?1/0:1/Math.max(m/y*l.x+h/y*l.y,1e-6);if(!Number.isFinite(p)||p>e){i.push({x:u.x+l.x*n,y:u.y+l.y*n},{x:u.x+f.x*n,y:u.y+f.y*n}),s.push(c,c);continue}m/=y,h/=y,i.push({x:u.x+m*n*p,y:u.y+h*n*p}),s.push(c)}for(let c=0;c<i.length;c++){let u=(c+1)%i.length,l=s[c],f=s[u];if(f!==(l+1)%o)continue;let m=r[l],h=r[f];if((i[u].x-i[c].x)*(h.x-m.x)+(i[u].y-i[c].y)*(h.y-m.y)<=0)return[]}try{let c=_e.intersection([[...i.map(y=>[y.x,y.y]),[i[0].x,i[0].y]]],[[...r.map(y=>[y.x,y.y]),[r[0].x,r[0].y]]]),u=null,l=0;for(let y of c){let p=Math.abs(mt(y[0].map(([x,b])=>({x,y:b}))));p>l&&(l=p,u=y[0])}if(!u)return[];let f=u.map(([y,p])=>({x:y,y:p})),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?wt(f):[]}catch{return[]}}function pn(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 Jt(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 tn=["available","held","sold","selected","dimmed"];function vn(t){let n=tn.indexOf(t);return n<0?0:n}var Ee={available:[.24,.82,.52],held:[.34,.39,.45],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};function Ua(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 Ln={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]},Dn={top:[.05,.06,.08],bottom:[.1,.12,.15]};function K(t,n){return[Math.min(1,t[0]*n),Math.min(1,t[1]*n),Math.min(1,t[2]*n)]}var at={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,body:10,head:11},Ar=.44,_r=.15,wr=.3,Er=.24;function Te(t){return t===void 0||!Number.isFinite(t)||t<=0?Er:Math.min(wr,Math.max(_r,t*Ar))}var Wa=.21,Br=.05,Nn=.45,Tr=Nn+Br,Cr=.92,Be=.66,Or=1.205,kr=-.23,Fr=.38,vr=[{part:at.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:at.pad,min:[-1,.36,-.95],max:[1,Nn,1]},{part:at.back,min:[-1,Tr,-1],max:[1,Cr,-.72]},{part:at.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:at.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:at.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:at.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:at.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:at.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:at.leg,min:[.62,0,.48],max:[.82,.37,.7]}],Lr=[{part:at.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:at.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:at.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:at.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:at.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}],Dr=[{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 za(){let t=[],n=[],e=[],r=[],o=(O,L,C)=>{let F=e.length,[v,G,j]=O,U=[G[0]-v[0],G[1]-v[1],G[2]-v[2]],H=[j[0]-v[0],j[1]-v[1],j[2]-v[2]],W=U[1]*H[2]-U[2]*H[1],nt=U[2]*H[0]-U[0]*H[2],$=U[0]*H[1]-U[1]*H[0],Q=Math.hypot(W,nt,$);Q>1e-9?(W/=Q,nt/=Q,$/=Q):[W,nt,$]=L,W*L[0]+nt*L[1]+$*L[2]<0&&(W=-W,nt=-nt,$=-$);for(let X of O)t.push(...X),n.push(W,nt,$),e.push(C);r.push(F,F+1,F+2,F,F+2,F+3)},a=O=>{for(let L of Dr){let C=L.c.map(F=>F.map((v,G)=>v?O.max[G]:O.min[G]));o(C,L.n,O.part)}},i=(O,L)=>{let[C,F,v]=L?[0,1,2]:[0,2,1],G=O.min[C],j=O.max[C],U=O.min[F],H=O.max[F],W=(j-G)*.1,nt=(H-U)*.1,$=L?[[G+W,U],[j-W,U],[j,U+nt],[j*.94,H-(H-U)*.23],[j*Be,H],[G*Be,H],[G*.94,H-(H-U)*.23],[G,U+nt]]:[[G+W,U],[j-W,U],[j,U+nt],[j,H-nt],[j-W,H],[G+W,H],[G,H-nt],[G,U+nt]],Q=(D,Z,J)=>{let q=[0,0,0];return q[C]=D,q[F]=Z,q[v]=J,q},X=[O.min[v],O.max[v]].map(D=>$.map(([Z,J])=>Q(Z,J,D)));for(let D=0;D<$.length;D++){let Z=(D+1)%$.length,J=[0,0,0];J[C]=($[D][0]+$[Z][0])/2-(G+j)/2,J[F]=($[D][1]+$[Z][1])/2-(U+H)/2,o([X[0][D],X[0][Z],X[1][Z],X[1][D]],J,O.part)}for(let D=0;D<2;D++){let Z=[0,0,0];Z[v]=D?1:-1;let J=X[D];for(let q=1;q<J.length-1;q++){let ct=e.length;for(let it of[J[0],J[q],J[q+1]])t.push(...it),n.push(...Z),e.push(O.part);r.push(ct,ct+1,ct+2)}}};for(let O of vr)O.part===at.pad||O.part===at.back?i(O,O.part===at.back):a(O);for(let O of Lr)a(O);let s=Nn,c=1.08,u=.47,l=.69,f=-.55,m=.08,h=-.48,y=.01,p=[-u,s,f],x=[u,s,f],b=[-u,s,m],d=[u,s,m],M=[-l,c,h],g=[l,c,h],_=[-l,c,y],R=[l,c,y];o([x,g,R,d],[1,0,0],at.body),o([b,_,M,p],[-1,0,0],at.body),o([_,R,g,M],[0,1,0],at.body),o([p,x,d,b],[0,-1,0],at.body),o([d,R,_,b],[0,0,1],at.body),o([p,M,g,x],[0,0,-1],at.body);let A=10,S=8,I=[0,Or,kr],w=[.42,.115,Fr],T=e.length;for(let O=0;O<=S;O++){let L=Math.PI*O/S,C=Math.cos(L),F=Math.sin(L);for(let v=0;v<=A;v++){let G=Math.PI*2*v/A,j=F*Math.cos(G),U=F*Math.sin(G);t.push(I[0]+w[0]*j,I[1]+w[1]*C,I[2]+w[2]*U);let H=j/w[0],W=C/w[1],nt=U/w[2],$=Math.hypot(H,W,nt)||1;H/=$,W/=$,nt/=$,n.push(H,W,nt),e.push(at.head)}}for(let O=0;O<S;O++)for(let L=0;L<A;L++){let C=T+O*(A+1)+L,F=C+A+1;r.push(C,F,C+1,C+1,F,F+1)}let k=new Float32Array(t),N=new Float32Array(n),B=new Float32Array(e),E=new Uint16Array(r);return{position:k,normal:N,part:B,index:E,vertexCount:e.length,indexCount:r.length}}function Ce(t,n,e,r){let o=new Float32Array(n),a=u=>t[u*3],i=u=>t[u*3+2],s=0,c=(u,l)=>{let f=l-u;for(let m=u;m<l;m++){let[h,y]=r(m),p=h-a(m),x=y-i(m);if(f>=2){let b=Math.max(u,m-1),d=Math.min(l-1,m+1),M=a(d)-a(b),g=i(d)-i(b),_=Math.hypot(M,g);if(_>1e-6){let R=-g/_,A=M/_;R*p+A*x<0&&(R=-R,A=-A),p=R,x=A}}o[m]=p===0&&x===0?0:Math.atan2(p,x)}};for(let u=1;u<=n;u++)(u===n||e(u)!==e(s))&&(c(s,u),s=u);return o}var dn=.22;function nc(t,n){let e=tn[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 Nr=.42;function Gr(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 y of t)y.x<r&&(r=y.x),y.y<o&&(o=y.y),y.x>a&&(a=y.x),y.y>i&&(i=y.y);let s=Math.max(a-r,1e-6),c=Math.max(i-o,1e-6),u=Math.max(Math.sqrt(s*c/n),1e-6),l=Math.max(1,Math.ceil(s/u)+1),f=Math.max(1,Math.ceil(c/u)+1),m=new Map,h=(y,p)=>{let x=Math.min(l-1,Math.max(0,Math.floor((y-r)/u)));return Math.min(f-1,Math.max(0,Math.floor((p-o)/u)))*l+x};for(let y=0;y<n;y++){let p=h(t[y].x,t[y].y),x=m.get(p);x?x.push(y):m.set(p,[y])}for(let y=0;y<n;y++){let p=t[y],x=Math.min(l-1,Math.max(0,Math.floor((p.x-r)/u))),b=Math.min(f-1,Math.max(0,Math.floor((p.y-o)/u))),d=1/0;for(let M=1;M<=4;M++){for(let g=b-M;g<=b+M;g++)if(!(g<0||g>=f))for(let _=x-M;_<=x+M;_++){if(_<0||_>=l||M>1&&Math.abs(g-b)<M&&Math.abs(_-x)<M)continue;let R=m.get(g*l+_);if(R)for(let A of R){if(A===y)continue;let S=Math.hypot(t[A].x-p.x,t[A].y-p.y);S<d&&(d=S)}}if(Number.isFinite(d)&&d<=M*u)break}e[y]=d}return e}function Xr(t){let n=t.eyeHeightM;return Number.isFinite(n)?Math.max(0,n-ln):0}function Oe(t,n,e,r,o,a){let i=t.length,s=new Float32Array(i*3),c=new Float32Array(i),u=new Float32Array(i*3),l=new Float32Array(i),f=new Float32Array(i),m=new Float32Array(i),h=new Float32Array(i),y=new Float32Array(i*3),p=new Map,x=Gr(t);for(let b=0;b<i;b++){let d=t[b],g=(e?.seatPitchU(b)??x[b])*P;l[b]=Number.isFinite(g)?Math.max(.06,Math.min(dn,g*Nr)):dn,f[b]=Te(Number.isFinite(g)?g:void 0);let _=xe(d.glyph,{seatGlyph:a?.get(d.categoryKey)});m[b]=de.indexOf(_),h[b]=d.wheelchairSpaceType==="no-seat"?0:1,s[b*3]=d.x*P,s[b*3+1]=e?e.seatDeckY(b):Xr(d),s[b*3+2]=d.y*P,c[b]=vn(n?n(d):"available");let R=ot(o?.get(d.categoryKey)??"#6e7bff")??[.43,.48,1];if(u[b*3]=R[0],u[b*3+1]=R[1],u[b*3+2]=R[2],d.accessibility?.length){let A=ot(se(d.accessibility));A&&(y[b*3]=A[0],y[b*3+1]=A[1],y[b*3+2]=A[2])}p.set(d.id,b)}return{count:i,iPosition:s,iState:c,iCategory:u,iMaxRadius:l,iRing:y,idToIndex:p,iChairWidth:f,iGlyph:m,iPhysicalSeat:h,iFloor:r??new Float32Array(i),iSection:new Float32Array(i).fill(-1),iYaw:new Float32Array(i)}}var Hr=64;function ec(t,n){let e=[];for(let i of n){let s=t.idToIndex.get(i.seatId);if(s===void 0)continue;let c=vn(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+Hr){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 ti from"polygon-clipping";var z={top:1,wallBottom:.58,bottomCap:.4};function kt(t,n){if(!t)return n;let e=K(_t(t,.4),.62);return rt(n,e,.22)}function ke(t,n){return t?rt(n,K(_t(t,.08),.9),.82):n}function Fe(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,u=0,l=0;for(let[f,m]of i){let h=ot(e.get(f));h&&(s+=h[0]*m,c+=h[1]*m,u+=h[2]*m,l+=m)}l>0&&o.set(a,[s/l,c/l,u/l])}return o}function ve(t,n){return ot(t.color)??n.get(t.logicalSectionId??t.id)??null}import Ke from"polygon-clipping";import Ge from"polygon-clipping";import jr from"earcut";var Ur=.58,Le=.01,bt=dn*1.5*xt,Yr=.5,Wr=.6;function zr(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)],u=c.x-s.x,l=c.y-s.y,f=Math.hypot(u,l);if(f<1e-9){r.push([0,0]);continue}u/=f,l/=f,r.push([-l,u])}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 Vr(t,n){if(t.length<2||n<=0)return[...t];let e=[...t],r=(i,s)=>{let c=s.x-i.x,u=s.y-i.y,l=Math.hypot(c,u)||1;return{x:c/l,y:u/l}},o=r(e[1],e[0]),a=r(e[e.length-2],e[e.length-1]);return e.unshift({x:e[0].x+o.x*n,y:e[0].y+o.y*n}),e.push({x:e[e.length-1].x+a.x*n,y:e[e.length-1].y+a.y*n}),e}var De=Math.PI/12;function Kr(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 Xe(t,n){if(!t.length||!(n>0))return[];let e=Kr(t),r=(s,c,u,l)=>{let f=u-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/De)),h=n/Math.cos(f/m/2);for(let y=0;y<=m;y++){let p=c+f*y/m;l.push({x:s.x+Math.cos(p)*h,y:s.y+Math.sin(p)*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 u=0;for(let h of e)u=Math.max(u,Math.hypot(h.x-s,h.y-c));let l=[],f=Math.max(3,Math.ceil(Math.PI*2/De)),m=(u+n)/Math.cos(Math.PI/f);for(let h=0;h<f;h++){let y=h/f*Math.PI*2;l.push({x:s+Math.cos(y)*m,y:c+Math.sin(y)*m})}return l}let o=e.length,a=[];for(let s=0;s<o;s++){let c=e[s],u=e[(s+1)%o];a.push(Math.atan2(-(u.x-c.x),u.y-c.y))}let i=[];for(let s=0;s<o;s++)r(e[s],a[(s+o-1)%o],a[s],i);return We(i)}function Zr(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,u=s*s+c*c,l=u>1e-12?((n-a.x)*s+(e-a.y)*c)/u:0;l<0?l=0:l>1&&(l=1);let f=Math.hypot(n-(a.x+l*s),e-(a.y+l*c));f<r&&(r=f)}return r}function xn(t){let n=t.map(o=>{let a=0,i=0;for(let u of o.pts)a+=u.x,i+=u.y;let s=o.pts.length||1;a/=s,i/=s;let c=0;for(let u of o.pts){let l=Math.hypot(u.x-a,u.y-i);l>c&&(c=l)}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 l of a){let f=1/0;for(let m=0;m<t.length;m++){if(m===o||Math.abs(t[m].y-t[o].y)<.001)continue;let h=n[m],y=Math.hypot(l.x-h.cx,l.y-h.cy)-h.rad;if(y>=f&&y>=s)continue;let p=Zr(t[m].pts,l.x,l.y);p<f&&(f=p),t[m].depth<t[o].depth&&p<s&&(s=p,c=t[m].y)}Number.isFinite(f)&&f>0&&i.push(f)}i.sort((l,f)=>l-f);let u=i.length?i[Math.floor(i.length/2)]:1;r.push({pitch:u,belowY:c})}return r}function He(t,n,e,r){let o=t[n],a=o.pts.length>=2?[...o.pts]:o.pts.length===1?(()=>{let l=o.pts[0],f=l.x-r.x,m=l.y-r.y,h=Math.hypot(f,m)||1;f/=h,m/=h;let y=Math.max(e[n].pitch,.001)*.5;return[{x:l.x+m*y,y:l.y-f*y},{x:l.x-m*y,y:l.y+f*y}]})():[];if(a.length<2)return null;let i=0,s=0;for(let l=1;l<a.length;l++){let f=Math.hypot(a[l].x-a[l-1].x,a[l].y-a[l-1].y);f>1e-6&&(i+=f,s++)}let c=s>0?i/s:0,u=Vr(a,Math.max(c*Wr,bt));return{pts:u,nrm:zr(u,r),front:Math.max(e[n].pitch*Ur,bt),back:Math.max(e[n].pitch*Yr,bt)}}var Ut=1.5,je=.3;function Gn(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 u=Gn(t.slice(0,c+1),n),l=Gn(t.slice(c),n);return[...u.slice(0,-1),...l]}function Ue(t,n){if(t.length<4)return t;let e=Gn([...t,t[0]],n);return e.pop(),e.length>=3?e:t}function qr(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 Ye(t,n,e){if(t.length<2)return[];let r=e??xn(t),o=new Map;for(let i=0;i<t.length;i++){let s=o.get(t[i].blockId);s?s.push(i):o.set(t[i].blockId,[i])}let a=[];for(let[,i]of o){let s=[];for(let d of i){let M=t[d].patch;M&&M.length>=3?a.push({outline:[...M],holes:[],topY:t[d].y}):s.push(d)}if(!s.length)continue;s.sort((d,M)=>t[d].depth-t[M].depth);let u=s.map(d=>He(t,d,r,n)).filter(d=>d!==null);if(!u.length)continue;let l=(d,M)=>({x:d.pts[M].x-d.nrm[M][0]*(d.front+Ut),y:d.pts[M].y-d.nrm[M][1]*(d.front+Ut)}),f=(d,M)=>({x:d.pts[M].x+d.nrm[M][0]*(d.back+Ut),y:d.pts[M].y+d.nrm[M][1]*(d.back+Ut)}),m=u[0],h=u[u.length-1],y=[];for(let d=0;d<m.pts.length;d++)y.push(l(m,d));for(let d of u)y.push(f(d,d.pts.length-1));for(let d=h.pts.length-1;d>=0;d--)y.push(f(h,d));for(let d=u.length-1;d>=0;d--)y.push(l(u[d],0));let p=We(y),x=1/0;for(let d of s)t[d].y<x&&(x=t[d].y);if(!Number.isFinite(x))continue;if(p.length>=3&&Math.abs(mt(p))>1e-6&&u.every(d=>{let M=d.pts[Math.floor(d.pts.length/2)];return ht(p,M.x,M.y)})&&!qr(p)){a.push({outline:Ue(p,je),holes:[],topY:x});continue}for(let d of $r(u))a.push({outline:d,holes:[],topY:x})}return a}function $r(t){let n=[];for(let e of t){let r=[],o=[],a=e.front+Ut,i=e.back+Ut;for(let c=0;c<e.pts.length;c++){let u=e.pts[c],l=e.nrm[c];r.push([u.x-l[0]*a,u.y-l[1]*a]),o.push([u.x+l[0]*i,u.y+l[1]*i])}let s=[...r,...o.reverse()];s.length<3||(s.push(s[0]),n.push([s]))}if(!n.length)return[];try{let e=Ge.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,u])=>({x:c,y:u})),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(Ue(a,je))}return r}catch{return[]}}function We(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 Xn=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(!ht(e,o.x,o.y)){r=!1;break}if(r)return!0}return!1}};function Ne(t,n,e,r,o,a){if(r.length<3)return;if(e.containsAll(r)){let u=[0,1,0],l=r[0];for(let f=1;f+1<r.length;f++){let m=r[f],h=r[f+1];t.tri([l.x*P,o,l.y*P],[m.x*P,o,m.y*P],[h.x*P,o,h.y*P],u,a)}return}let i=r.map(u=>[u.x,u.y]);i.push(i[0]);let s;try{s=Ge.intersection([i],n)}catch{return}let c=[0,1,0];for(let u of s){if(!u.length||u[0].length<4)continue;let l=u[0],f=[],m=[];for(let y=0;y<l.length-1;y++)f.push(l[y][0],l[y][1]),m.push([l[y][0],l[y][1]]);if(m.length<3)continue;let h=jr(f,void 0,2);for(let y=0;y<h.length;y+=3){let p=m[h[y]],x=m[h[y+1]],b=m[h[y+2]];t.tri([p[0]*P,o,p[1]*P],[x[0]*P,o,x[1]*P],[b[0]*P,o,b[1]*P],c,a)}}}function ze(t,n,e,r,o,a,i){if(n.length<2)return;let s=i??xn(n),c=[0,1,0],u=a&&a.length>=3?[[...a.map(h=>[h.x,h.y]),[a[0].x,a[0].y]]]:null,l=a&&a.length>=3?new Xn([[...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 y=n[h];if(y.patch&&y.patch.length>=3){let _=[...y.patch],R=s[h].belowY??r;if(m(()=>{if(u&&l)Ne(t,u,l,_,y.y,o.tread);else{let A=_[0];for(let S=1;S+1<_.length;S++){let I=_[S],w=_[S+1];t.tri([A.x*P,y.y,A.y*P],[I.x*P,y.y,I.y*P],[w.x*P,y.y,w.y*P],c,o.tread)}}}),y.y>R+Le){let A=0,S=0;for(let I of _)A+=I.x,S+=I.y;A/=_.length,S/=_.length,f(()=>{for(let I=0;I<_.length;I++){let w=_[I],T=_[(I+1)%_.length],k=T.x-w.x,N=T.y-w.y,B=Math.hypot(k,N);if(B<1e-6)continue;let E=N/B,O=-k/B;(w.x-A)*E+(w.y-S)*O<0&&(E=-E,O=-O);let L=[E,0,O],C=[w.x*P,y.y,w.y*P],F=[T.x*P,y.y,T.y*P],v=[w.x*P,R,w.y*P],G=[T.x*P,R,T.y*P];t.tri(C,F,G,L,o.riser),t.tri(C,G,v,L,o.riser)}})}continue}let p=He(n,h,s,e);if(!p)continue;let{pts:x,nrm:b,front:d,back:M}=p,g=s[h].belowY??r;for(let _=0;_+1<x.length;_++){let R=x[_],A=x[_+1],S=b[_],I=b[_+1];if(Math.hypot(A.x-R.x,A.y-R.y)<1e-6||S[0]===0&&S[1]===0||I[0]===0&&I[1]===0)continue;let w=[(R.x-S[0]*d)*P,y.y,(R.y-S[1]*d)*P],T=[(A.x-I[0]*d)*P,y.y,(A.y-I[1]*d)*P],k=[(R.x+S[0]*M)*P,y.y,(R.y+S[1]*M)*P],N=[(A.x+I[0]*M)*P,y.y,(A.y+I[1]*M)*P];if(m(()=>{u&&l?Ne(t,u,l,[{x:R.x-S[0]*d,y:R.y-S[1]*d},{x:A.x-I[0]*d,y:A.y-I[1]*d},{x:A.x+I[0]*M,y:A.y+I[1]*M},{x:R.x+S[0]*M,y:R.y+S[1]*M}],y.y,o.tread):(t.tri(w,T,N,c,o.tread),t.tri(w,N,k,c,o.tread))}),y.y>g+Le){let B=[w[0],g,w[2]],E=[T[0],g,T[2]],O=[-S[0],0,-S[1]];f(()=>{t.tri(w,T,E,O,o.riser),t.tri(w,E,B,O,o.riser)})}}}}function Qr(t,n){let e=t.eventConfigurationIds;return!e?.length||!!n&&e.includes(n)}function Ve(t,n){return t.filter(e=>e.type!=="shape"||Qr(e,n))}function Ze(t,n){let e=t.focalPoint??{x:0,y:0};return t.floors?.length?t.floors.map((r,o)=>({objects:Ve(r.objects,n),focal:{x:(r.focalPoint??e).x,y:(r.focalPoint??e).y},baseHeightM:r.baseHeightM??0,index:o})):[{objects:Ve(t.objects,n),focal:e,baseHeightM:0,index:0}]}var Jr={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Tt(t){return ge(t)??Jr}function qe(t,n){let e=Mt(t.outline,bt),r=Tt(e),o=n.filter(i=>i!==t&&i.outline&&i.outline.length>=3&&jt(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=Ke.difference([a(e)],...o.map(c=>[a(c.outline)])),s=[];for(let c of i){if(!c.length)continue;let u=c[0].map(([l,f])=>({x:l,y:f}));if(u.length>1){let l=u[0],f=u[u.length-1];Math.abs(l.x-f.x)<1e-9&&Math.abs(l.y-f.y)<1e-9&&u.pop()}u.length>=3&&s.push(u)}return s.length?s:[e]}catch{return[e]}}function $e(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=Ke.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(([u,l])=>({x:u,y:l}));if(c.length>1){let u=c[0],l=c[c.length-1];Math.abs(u.x-l.x)<1e-9&&Math.abs(u.y-l.y)<1e-9&&c.pop()}c.length>=3&&o.push({outline:c,holes:[],topY:a.topY})}}return o.length?o:t}function ni(t,n){return t===void 0||n===void 0?!0:Math.abs(t-n)<.001}var bn=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,u)=>jt(o,this.boxes[u])&&ni(e,this.levels[u])),i=[[r]];if(a.length)try{i=ti.difference([r],...a).map(u=>u.map(l=>l.map(([f,m])=>[f,m])))}catch{i=[[r]]}this.rings.push([r]),this.boxes.push(o),this.levels.push(e);let s=[];for(let c of i){if(!c.length)continue;let u=c[0].map(([l,f])=>({x:l,y:f}));if(u.length>1){let l=u[0],f=u[u.length-1];Math.abs(l.x-f.x)<1e-9&&Math.abs(l.y-f.y)<1e-9&&u.pop()}u.length>=3&&s.push(u)}return s}};function gn(t,n){if(!n)return t;let e=1/0,r=-1/0,o=1/0,a=-1/0;for(let f of t)e=Math.min(e,f.x),r=Math.max(r,f.x),o=Math.min(o,f.y),a=Math.max(a,f.y);let i=(e+r)/2,s=(o+a)/2,c=n*Math.PI/180,u=Math.cos(c),l=Math.sin(c);return t.map(f=>{let m=f.x-i,h=f.y-s;return{x:i+m*u-h*l,y:s+m*l+h*u}})}function st(t){let n=null;if(t.kind==="polygon"&&t.points&&t.points.length>=3&&(n=t.points),t.kind==="rect"&&t.width&&t.height&&(n=Jt(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=pn(e,r,t.width/2,t.height/2)}return n?gn(n,t.rotation):null}function Pt(t){let n=t.role??"",e={stage:{kind:"stage",heightM:1},entrance:{kind:"portal",heightM:2.7},exit:{kind:"portal",heightM:2.7},screen:{kind:"solid",heightM:6},wall:{kind:"solid",heightM:2.8},rail:{kind:"solid",heightM:1.1},suite:{kind:"suite",heightM:3},obstruction:{kind:"solid",heightM:4.5},sound:{kind:"solid",heightM:1.45},restroom:{kind:"solid",heightM:2.4},bar:{kind:"solid",heightM:1.1},concession:{kind:"solid",heightM:1.1},coat:{kind:"solid",heightM:1.1},goal:{kind:"portal",heightM:1.8}},r=n==="stage"&&me(t.stageKind)?{kind:"stage",heightM:t.stageKind==="ring-boxing"?fe:.06}:e[n]??{kind:"plate",heightM:.25};return{...r,heightM:t.heightM??r.heightM}}var ei=.08,oi=30,ri=.015;function ii(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 Qe(t,n){let e=st(t)??(t.points?.length?gn(t.points,t.rotation):null),r=Pt(t),a=!t.role&&r.kind==="plate"&&t.heightM===void 0&&!!e&&Math.abs(mt(e))*et**2>=oi?ri: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,u=-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),u=Math.max(u,h.y);let l=a,f=0,m=1e-6*Math.max(1,c-i,u-s);for(let h of n)c>h.minX&&i<h.maxX&&u>h.minY&&s<h.maxY&&l<=h.topOffsetM+1e-6&&(l=h.topOffsetM+ei),i>=h.minX-m&&c<=h.maxX+m&&s>=h.minY-m&&u<=h.maxY+m&&(!h.poly||e.every(x=>ii(x,h.poly)||si(x,h.poly,m)))&&(f=Math.max(f,h.topOffsetM));return t.fill&&t.fill!=="none"&&t.fill!=="transparent"&&n.push({minX:i,minY:s,maxX:c,maxY:u,topOffsetM:l,poly:e}),{topOffsetM:l,supportOffsetM:Math.min(f,l)}}function si(t,n,e){for(let r=0,o=n.length-1;r<n.length;o=r++){let a=n[o],i=n[r],s=i.x-a.x,c=i.y-a.y,u=s*s+c*c,l=u?Math.max(0,Math.min(1,((t.x-a.x)*s+(t.y-a.y)*c)/u)):0;if(Math.hypot(t.x-(a.x+l*s),t.y-(a.y+l*c))<=e)return!0}return!1}function Ft(t,n,e){return{x:t.x+(n.x-t.x)*e,y:t.y+(n.y-t.y)*e}}function yt(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 ut(t,n,e){return[Ft(t[0],t[1],n),Ft(t[0],t[1],e),Ft(t[3],t[2],e),Ft(t[3],t[2],n)]}function nn(t,n,e){return[Ft(t[0],t[3],n),Ft(t[1],t[2],n),Ft(t[1],t[2],e),Ft(t[0],t[3],e)]}function tt(t,n,e,r,o,a){V(t,n,void 0,()=>e,r,o,a,z)}function en(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 ai=.8,ci=.6,li=2;function Mn(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=st(i)??[],c=Je(s)/2;!(c>0)||ui(s)/c*P>li||(e.push(...s),r+=c)}if(e.length<3)return null;let o=en(e);if(o.length<3||r<Je(o)*ci)return null;let a=0;for(let i of n)fi(i,o)&&(a+=1);return a>=n.length*ai?o:null}function ui(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 Je(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 fi(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 mi=[[/\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"]],hi=1.2,yi=12;function to(t){if(t.heightM!==void 0)return!1;let n=st(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*et<yi*2?!1:2*Pn(n)/e*et<=hi}function Hn(t){if(!t)return null;for(let[n,e]of mi)if(n.test(t))return e;return null}var oo="auto-rows-";function ro(t){return t.id.startsWith(oo)&&!t.label}var pi=1.15,di=.09,io=6,xi=34,bi=.35,gi=6,Mi=.35,Pi=.75,Si=12,Ii=2.5,Ri=40,Ai=[18,24],_i=[12,16],no=14,wi=.8,Ei=.6,Bi=5,Ti=.3,so=.4,Ci=2,Oi=400,ki=2.6,Fi=1.6,vi=6e3,Li=.6,Di="#c3c7cd",eo=300,Ni=240;function Gi(t,n,e,r){if(!t.fill||!/^#[0-9a-f]{6}$/i.test(t.fill))return null;let o=Un([...n]),a=new Set;for(let l of r)a.add(Math.floor(Math.atan2(l.y-o.y,l.x-o.x)*180/Math.PI/10));if(a.size*10<Ni)return null;let{h:i,s,l:c}=pe(ye(t.fill));return i<70/360||i>170/360||s<.2||c<.08||c>.75||e.some(l=>l!==t&&l.type==="shape"&&st(l)?.some(f=>Wn(f,n)))?null:t.kind==="ellipse"?"oval-cricket":t.kind==="rect"?"pitch-football":null}var Xi="Estimated from the drawing; confirm with the venue.",ao=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},Un=t=>({x:t.reduce((n,e)=>n+e.x,0)/t.length,y:t.reduce((n,e)=>n+e.y,0)/t.length}),Pn=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 Hi(t){return t.height!==void 0||t.rake!==void 0||t.elevation!==void 0||t.surfaceKind!==void 0}function Yn(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 Wn(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 zn(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,u=s*s+c*c,l=u>0?Math.max(0,Math.min(1,((t.x-a.x)*s+(t.y-a.y)*c)/u)):0,f={x:a.x+s*l,y:a.y+c*l},m=Math.hypot(t.x-f.x,t.y-f.y);m<r&&(r=m,e=f)}return e}function co(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,u=Math.hypot(s,c);if(u<1e-6)continue;let l={x:(a.x+i.x)/2,y:(a.y+i.y)/2},f=zn(l,n),m=f.x-l.x,h=f.y-l.y,y=Math.hypot(m,h);y<1e-6||(r+=Math.abs((-c*m+s*h)/(u*y))*o.length,e+=o.length)}return e?r/e:0}function ji(t,n,e){let r=t.filter(p=>p.type==="shape"),o=r.find(p=>p.role==="stage");if(o){let p=st(o);return p?{shape:o,centre:Un(p),outline:p,inferred:!1}:null}if(!e.length)return null;let a=1/0,i=-1/0,s=1/0,c=-1/0;for(let p of e)a=Math.min(a,p.x),i=Math.max(i,p.x),s=Math.min(s,p.y),c=Math.max(c,p.y);let u=(i-a)*(c-s),l=[];for(let p of r){if(p.role)continue;let x=st(p);if(!x)continue;let b=Pn(x);if(b*et*et<6||b>u)continue;let d=Math.min(...x.map(I=>I.x)),M=Math.max(...x.map(I=>I.x)),g=Math.min(...x.map(I=>I.y)),_=Math.max(...x.map(I=>I.y)),R=0;for(let I of e)I.x>d&&I.x<M&&I.y>g&&I.y<_&&Wn(I,x)&&R++;if(R>e.length*.05)continue;let A=Un(x),S=co(n,x);S>=wi&&l.push({shape:p,centre:A,outline:x,score:S,area:b,box:[d,g,M,_]})}let f=(p,x)=>x!==p&&x.area>p.area&&p.box[0]>=x.box[0]-1e-6&&p.box[1]>=x.box[1]-1e-6&&p.box[2]<=x.box[2]+1e-6&&p.box[3]<=x.box[3]+1e-6,m=l.filter(p=>!l.some(x=>f(p,x))),h=Math.max(0,...m.map(p=>p.score)),y=m.filter(p=>p.score>=h-.03).sort((p,x)=>x.area-p.area)[0]??null;return y?{shape:y.shape,centre:y.centre,outline:y.outline,inferred:!0}:null}function Ui(t,n,e){if(!e||e.length<3)return Math.hypot(t.x-n.x,t.y-n.y);let r=zn(t,e);return Math.hypot(t.x-r.x,t.y-r.y)}function lo(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 Yi(t){if(!t.length||t.length>vi)return[];let n=[...Yn(t).values()],e=n.map((s,c)=>c),r=s=>e[s]===s?s:e[s]=r(e[s]),o=Fi/et,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 u=a[s],l=a[c];if(u.maxX<l.minX||l.maxX<u.minX||u.maxY<l.minY||l.maxY<u.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 u=r(c),l=i.get(u);l?l.push(...s):i.set(u,[...s])}),[...i.values()].filter(s=>new Set(s.map(c=>c.rowId)).size>=2)}function Wi(t,n,e){if(!n.length)return null;let r=n.filter(S=>e.tableIds.has(S.rowId)||S.kind==="booth").length>n.length/2,o=Yn(n),a=!e.outline||co(o,e.outline)>=Ei,i=0,s=0;for(let S of o.values()){if(S.length<2)continue;let I=S[0],w=S[S.length-1],T=w.x-I.x,k=w.y-I.y,N=Math.hypot(T,k);if(N<1e-6)continue;let B={x:(I.x+w.x)/2,y:(I.y+w.y)/2},E=a?e.outline?zn(B,e.outline):e.focal:e.middle,O=-k/N,L=T/N;O*(E.x-B.x)+L*(E.y-B.y)<0&&(O=-O,L=-L),i+=O*S.length,s+=L*S.length}let c={x:n.reduce((S,I)=>S+I.x,0)/n.length,y:n.reduce((S,I)=>S+I.y,0)/n.length};if(Math.hypot(i,s)<1e-9){let S=a?e.focal:e.middle;i=S.x-c.x,s=S.y-c.y}let u=Math.hypot(i,s)||1,l={x:i/u,y:s/u},f=S=>-(S.x*l.x+S.y*l.y),m=S=>-S.x*l.y+S.y*l.x,h=1/0,y=-1/0,p=1/0,x=-1/0,b=1/0,d=new Map;for(let S of n){let I=f(S),w=m(S);h=Math.min(h,I),y=Math.max(y,I),p=Math.min(p,w),x=Math.max(x,w),a&&(b=Math.min(b,Ui(S,e.focal,e.outline)));let T=S.logicalRowId??S.rowId,k=d.get(T);k?k.push(I):d.set(T,[I])}a||(b=Math.max(0,h-f(e.middle)));let M=[...d.values()].map(S=>ao(S)).sort((S,I)=>S-I),g=[];if(!r)for(let S of M)g.length&&S-g[g.length-1]<Mi/et||g.push(S);let _=Hi(t),R=Xt(t,{floorBaseHeightM:e.baseHeightM}),A={id:t.id,section:t,authored:_,plane:e,facing:l,facesAction:a,hull:lo(n),sample:n.filter((S,I)=>I%Math.ceil(n.length/Oi)===0),frontD:h,backD:y,latMin:p,latMax:x,frontDistance:b,rowDepths:g,rowCount:g.length,level:0,height:R.height,rake:_?R.rake:0,backHeight:0};return A.backHeight=A.height+(y-h)*et*Math.tan(A.rake*Math.PI/180),A}function zi(t,n,e,r){if(t.length<2)return 0;let o=Math.max(1,n*et),a=e+pi-r,i=0,s=0;for(let u=1;u<t.length;u++){let l=Math.max(Pi,(t[u]-t[u-1])*et),f=(a+di)*(o+l)/o;i+=f-a,s+=l,a=f,o+=l}let c=Math.atan(i/s)*180/Math.PI;return Math.round(Math.max(io,Math.min(xi,c))*10)/10}function Vi(t,n){if(t.facing.x*n.facing.x+t.facing.y*n.facing.y<Ti)return null;let e=-1/0,r=1/0,o=-1/0;for(let f of n.hull){e=Math.max(e,-(f.x*t.facing.x+f.y*t.facing.y));let m=-f.x*t.facing.y+f.y*t.facing.x;r=Math.min(r,m),o=Math.max(o,m)}if(Math.min(t.latMax,o)-Math.max(t.latMin,r)<so*(t.latMax-t.latMin))return null;let i=Ci/et,s=new Map,c=new Map;for(let f of t.sample){let m=Math.floor((-f.x*t.facing.y+f.y*t.facing.x)/i),h=-(f.x*t.facing.x+f.y*t.facing.y);s.set(m,Math.min(s.get(m)??1/0,h))}for(let f of n.sample){let m=Math.floor((-f.x*t.facing.y+f.y*t.facing.x)/i),h=-(f.x*t.facing.x+f.y*t.facing.y);c.set(m,Math.max(c.get(m)??-1/0,h))}let u=[];for(let[f,m]of s){let h=c.get(f);h!==void 0&&u.push(m-h)}let l=u.length?ao(u):t.frontD-e;return l<-1/et?null:l}function Ki(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 u=-(c.x*t.facing.x+c.y*t.facing.y);e=Math.max(e,u),r=Math.min(r,u);let l=-c.x*t.facing.y+c.y*t.facing.x;o=Math.min(o,l),a=Math.max(a,l)}let i=Math.min(t.latMax,a)-Math.max(t.latMin,o),s=Math.min(t.backD,e)-Math.max(t.frontD,r);return i>so*(t.latMax-t.latMin)&&s>1/et}function Zi(t,n=!1){let e=n?_i:Ai,r=new Map,o=[...t].sort((c,u)=>c.plane.floorIndex-u.plane.floorIndex||c.frontDistance-u.frontDistance),a=[],i=new Map,s=c=>{if(c.plane.floorIndex===0||c.plane.baseHeightM>0)return c.plane.baseHeightM;let u=i.get(c.plane.floorIndex-1);return u===void 0?c.plane.baseHeightM:u+Re};for(let c of o){if(!c.authored){let l=s(c),f;for(let y of a){if(y.plane.floorIndex>c.plane.floorIndex)continue;if(Ki(c,y)){let b=y.backHeight+ki;b>l&&(l=b,f=y);continue}let p=Vi(c,y);if(p==null)continue;let x=y.backHeight+bi+Math.min(gi,Math.max(0,p)*et)*Math.tan(y.rake*Math.PI/180);x>l&&(l=x,f=y)}c.height=Math.round(Math.min(l,c.plane.baseHeightM+Ri)*100)/100;let m=!f&&c.height>c.plane.baseHeightM;if(c.level=f?f.level+1:m?1:0,c.rake=zi(c.rowDepths,c.frontDistance,c.height,c.plane.focalHeightM),!c.facesAction&&c.rowCount<Bi)c.rake=0;else if(!f&&!m){let y=Math.max(1e-6,(c.backD-c.frontD)*et);c.rake=Math.min(c.rake,Si,Math.round(Math.atan(Ii/y)*1800/Math.PI)/10)}else c.rowCount>=2&&(c.rake=Math.max(c.rake,e[Math.min(c.level,e.length)-1]));let h=(c.backD-c.frontD)*et;if(n&&h>0&&c.height+h*Math.tan(c.rake*Math.PI/180)>c.plane.baseHeightM+no){let y=Math.max(0,c.plane.baseHeightM+no-c.height);c.rake=Math.max(io,Math.round(Math.atan(y/h)*1800/Math.PI)/10)}c.backHeight=c.height+h*Math.tan(c.rake*Math.PI/180),r.set(c.id,f?.id)}let u=c.plane.floorIndex;i.set(u,Math.min(i.get(u)??1/0,c.height)),a.push(c)}return r}var jn=(t,n)=>!!t&&t.x===n.x&&t.y===n.y;function uo(t,n={x:0,y:-40}){let e=fn(t),r=new Map;for(let x of e){if(!x.sectionId)continue;let b=r.get(x.sectionId);b?b.push(x):r.set(x.sectionId,[x])}let o={focalInferred:!1,confident:!1,sections:[]},a=t.floors?.length?t.floors.map((x,b)=>({objects:x.objects,floorIndex:b,floorId:x.id,baseHeightM:x.baseHeightM??0,focal:x.focalPoint??t.focalPoint})):[{objects:t.objects,floorIndex:0,floorId:void 0,baseHeightM:0,focal:t.focalPoint}],i=new Set(a.flatMap(x=>x.objects.filter(b=>b.type==="table").map(b=>b.id))),s=[],c,u=new Set,l=a.map(x=>{let b=k=>!t.floors?.length||k.floorId===x.floorId,d=Yi(e.filter(k=>!k.sectionId&&k.kind!=="booth"&&!i.has(k.rowId)&&b(k))),M=[];for(let k of d){let N=Mt(wt(lo(k)),Li/et);if(e.some(E=>!b(E)&&Wn(E,N)))continue;let B=`${oo}${x.floorIndex}-${M.length}`;u.add(B),r.set(B,k),M.push({type:"section",id:B,label:"",color:Di,outline:N})}let g=M.length?{...x,objects:[...x.objects,...M]}:x,_=new Set(g.objects.filter(k=>k.type==="section").map(k=>k.logicalSectionId??k.id)),R=[...r.entries()].filter(([k])=>_.has(k)).flatMap(([,k])=>k),A=ji(g.objects,Yn(R),R),S=g.focal;(A||g.focal&&!jn(g.focal,n))&&(o.confident=!0),A&&(o.stage??={id:A.shape.id,inferred:A.inferred,...g.floorId?{floorId:g.floorId}:{}},(A.inferred||jn(g.focal,n))&&(S=A.centre,o.focalInferred=!0));let I=A&&(!A.inferred||Pn(A.outline)*et*et<=eo),w=A?void 0:c,T={tableIds:i,floorIndex:g.floorIndex,floorId:g.floorId,baseHeightM:g.baseHeightM,focal:w?.focal??S,outline:A?.outline??w?.outline,focalHeightM:w?.focalHeightM??g.baseHeightM+(A&&I?Pt({...A.shape,role:"stage"}).heightM:0),middle:R.length?{x:R.reduce((k,N)=>k+N.x,0)/R.length,y:R.reduce((k,N)=>k+N.y,0)/R.length}:S};for(let k of g.objects){if(k.type!=="section")continue;let N=Wi(k,r.get(k.logicalSectionId??k.id)??[],T);N&&s.push(N)}return T.outline&&(c=T),jn(g.focal,T.focal)||(o.focal??=[]).push({...g.floorId?{floorId:g.floorId}:{},point:{...T.focal}}),{unit:g,plane:T,stage:A,planeSeats:R}}),f=a.flatMap(x=>x.objects).map(x=>x.type==="shape"&&!x.role&&(Hn(x.label)==="wall"||!Hn(x.label)&&to(x))?{...x,role:"wall"}:x),m=Mn({objects:f},e)!==null;m&&(o.indoor=!0);let h=Zi(s,m),y=new Map(s.filter(x=>!x.authored).map(x=>[x.id,x])),p=l.map(({unit:x,plane:b,stage:d,planeSeats:M})=>x.objects.map(g=>{let _=g.type==="shape"&&!g.role&&g.id!==d?.shape.id?Hn(g.label):null;if(g.type==="shape"&&!g.role&&g.id!==d?.shape.id&&(_==="wall"||!_&&to(g))&&g.type==="shape"){(o.roles??=[]).push({id:g.id,...b.floorId?{floorId:b.floorId}:{},role:"wall"});let{fill:T,...k}=g;return{...k,role:"wall"}}if(_&&g.type==="shape")return(o.roles??=[]).push({id:g.id,...b.floorId?{floorId:b.floorId}:{},role:_}),{...g,role:_};let A=d?.inferred&&g.id===d.shape.id&&g.type==="shape"?Gi(g,d.outline,x.objects,M):null;if(A&&g.type==="shape")return o.stage?.id===g.id&&(o.stage.field=A),{...g,role:"stage",stageKind:A};if(d?.inferred&&g.id===d.shape.id&&g.type==="shape"&&Pn(d.outline)*et*et<=eo)return o.stage?.id===g.id&&(o.stage.deck=!0),{...g,role:"stage"};let S=g.type==="section"?y.get(g.id):void 0;if(!S||g.type!=="section")return g;let I=S.rowCount>=2&&S.rake>0;u.has(S.id)?o.looseRowBlocks=(o.looseRowBlocks??0)+1:o.sections.push({id:S.id,floorId:b.floorId,surfaceKind:I?"rakedRows":"flat",height:S.height,rake:S.rake,stackedOn:h.get(S.id)});let w={status:"inferred",source:"public-2d-topology",note:Xi};return{...g,height:S.height,rake:S.rake,surfaceKind:I?"rakedRows":"flat",physical3dProvenance:{height:w,rake:w,surfaceKind:w}}}));if(t.floors?.length){let x=t.floors.map((b,d)=>({...b,objects:p[d],focalPoint:l[d].plane.focal}));return{doc:{...t,floors:x,objects:x[0].objects,focalPoint:x[0].focalPoint},report:o}}return{doc:{...t,objects:p[0],focalPoint:l[0].plane.focal},report:o}}function jc(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 Uc(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 qi=1.15,$i=2.75,Qi=4.5,Ji=.85,ts=.5,ns=.26;function Yc(t,n,e){let r=Math.max(1e-6,n),o=t/r,a=e?.hasZoneLabels??!0,i=new Set;return o>=.75&&i.add("floor"),o>=qi&&i.add("zone"),o<=(a?$i:Qi)&&(i.add("section"),i.add("ga")),o<=Ji&&(i.add("annotation"),i.add("booth")),o<=ts&&i.add("row"),o<=ns&&i.add("seat"),i}function Wc(t,n,e,r,o,a=6){let i=a+n,s=r-a-n,c=a+e,u=o-a-e;return{...t,x:i>s?r/2:Math.max(i,Math.min(s,t.x)),y:c>u?o/2:Math.max(c,Math.min(u,t.y))}}function zc(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],u=o[1]*a+o[5]*i+o[9]*s+o[13],l=o[2]*a+o[6]*i+o[10]*s+o[14],f=o[3]*a+o[7]*i+o[11]*s+o[15];if(!(f>1e-6))return{x:0,y:0,depth:1/0,visible:!1};let m=c/f,h=u/f,y=l/f,p=m>=-1.05&&m<=1.05&&h>=-1.05&&h<=1.05&&y<=1;return{x:(m*.5+.5)*e,y:(1-(h*.5+.5))*r,depth:y,visible:p}}function Vc(t,n,e=n){let r=[],o=[...t].sort((a,i)=>a.screen.depth-i.screen.depth);for(let a of o){let i=!1;for(let s of r)if(Vn(a,s,n,e)){i=!0;break}i||r.push(a)}return r}var es=6;function Vn(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+es):e;return o<i&&a<r}function Kc(t,n,e){return t.length*n*.58+(e?14:0)}var os={row:8,seat:14};function Zc(t){return t<480?{row:5,seat:8}:t<768?{row:6,seat:10}:os}function qc(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 $c(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 u of o)if(Vn(s,u,n,e)){c=!0;break}if(!c){for(let u of i)if(Vn(s,u,n,e)){c=!0;break}}c||i.push(s)}return i}function Qc(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 Yt(t,n,e){if(t.length!==4||e<=n)return null;let r=yt(t),o=Math.hypot(r[1].x-r[0].x,r[1].y-r[0].y)*P,a=Math.hypot(r[3].x-r[0].x,r[3].y-r[0].y)*P;if(o<1e-6||a<1e-6)return null;let i=Math.min(.22/o,.16),s=Math.min(.28,(e-n)*.13),c=Math.min(.065/a,.2);return{quad:r,side:i,face:c,opening:ut(r,i,1-i),openingTop:e-s}}function Kn(t,n,e){if(t.length!==4||e-n<=.2)return null;let r=yt(t),o=Math.hypot(r[1].x-r[0].x,r[1].y-r[0].y)*P;if(o<=1e-6)return null;let a=Math.min(.14,(e-n)*.08,o*.08),i=a/o,s=ut(r,i,1-i);return{quad:r,side:i,trim:a,inner:s,panel:nn(s,.15,.85),bottom:n+a,top:e-a}}function fo(t,n,e,r){let o=Kn(t,n,e);if(!o)return;let{panel:a}=o,i=(d,M)=>({x:(d.x+M.x)/2,y:(d.y+M.y)/2}),s=i(a[0],a[1]),c=i(a[3],a[2]),u=Math.hypot(s.x-r.x,s.y-r.y)<=Math.hypot(c.x-r.x,c.y-r.y),[l,f]=u?[a[0],a[1]]:[a[3],a[2]],m=u?{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-l.y)*m.x+(f.x-l.x)*m.y<0&&([l,f]=[f,l]);let y=Math.min(.006,h*P*.05),p=m.x/h*y,x=m.y/h*y,b=(d,M)=>[d.x*P+p,M,d.y*P+x];return[b(l,o.bottom),b(f,o.bottom),b(l,o.top),b(f,o.top)]}import rs from"polygon-clipping";function Ct(t,n,e,r,o,a,i,s={}){let c=Tt(n),u=s.ao??z,l=o.flatMap(p=>{if(p.role!=="entrance"&&p.role!=="exit")return[];let x=st(p);if(!x||x.length!==4||!jt(c,Tt(x)))return[];let b=s.portalBase??e,d=Yt(x,b,b+Pt(p).heightM);if(!d)return[];let M=Math.min(r,d.openingTop);return M<=e?[]:[{poly:d.opening,height:M}]});if(!l.length)return!1;let f=p=>p.map(x=>[x.x,x.y]),m=[f(n),...(s.holes??[]).map(f)],h=[e,...new Set(l.map(p=>p.height)),r].sort((p,x)=>p-x),y=[];try{for(let p=1;p<h.length;p++){let x=h[p-1],b=h[p];if(b-x<1e-6)continue;let d=l.filter(g=>g.height>x+1e-6).map(g=>[f(g.poly)]),M=d.length?rs.difference(m,...d):[m];y.push({low:x,high:b,polys:M})}}catch{return!1}for(let p of y)for(let x of p.polys){let[b,...d]=x.map(g=>g.map(([_,R])=>({x:_,y:R}))),M=g=>u.wallBottom+(u.top-u.wallBottom)*(g-e)/(r-e);V(t,b,d,()=>p.high,p.low,a,i,{...u,top:M(p.high),wallBottom:M(p.low)})}return!0}function mo(t,n,e,r,o,a,i){let s=r-e;if(s<=0)return;let c=s<1.5?[[e,r,1]]:[[e,e+Math.min(.9,s*.18),.82],[e+Math.min(.9,s*.18),r-.1,1],[r-.1,r,1.1]],u=l=>z.wallBottom+(z.top-z.wallBottom)*(l-e)/s;for(let[l,f,m]of c){let h={...z,top:u(f),wallBottom:u(l)},y=K(a,m),p=K(i,m);Ct(t,n,l,f,o,y,p,{portalBase:e,ao:h})||V(t,n,void 0,()=>f,l,y,p,h)}}function on(t,n,e){let r=ot(n.stroke?.color),o=n.stroke?.width??0;if(!r||!Number.isFinite(o)||o<=0)return;let a=n.kind==="line"||n.kind==="polyline",i=a?gn(n.points??[],n.rotation):st(n);if(!i||i.length<2)return;let s=a?i.length-1:i.length,c=o*.5;for(let u=0;u<s;u++){let l=i[u],f=i[(u+1)%i.length],m=Math.hypot(f.x-l.x,f.y-l.y);if(m<1e-6)continue;let h=-(f.y-l.y)/m*c,y=(f.x-l.x)/m*c,p=[(l.x+h)*P,e,(l.y+y)*P],x=[(f.x+h)*P,e,(f.y+y)*P],b=[(f.x-h)*P,e,(f.y-y)*P],d=[(l.x-h)*P,e,(l.y-y)*P];t.tri(p,x,b,[0,1,0],r),t.tri(p,b,d,[0,1,0],r)}}function ho(t){return t==="bar"||t==="concession"||t==="coat"||t==="restroom"}var Wt=(t,n,e)=>({x:t.x+(n.x-t.x)*e,y:t.y+(n.y-t.y)*e});function Sn(t,n,e,r){let[o,a,i,s]=n?t:[t[3],t[2],t[1],t[0]];return[Wt(o,s,e),Wt(a,i,e),Wt(a,i,r),Wt(o,s,r)]}function yo(t,n,e,r,o,a,i,s,c=!1){if(e.length!==4||o-r<.4)return!1;let u=S=>c?Math.min(S,o):S,l=yt(e),f=Math.hypot(l[3].x-l[0].x,l[3].y-l[0].y)*P;if(f<.4)return!1;let m=Wt(l[0],l[1],.5),h=Wt(l[3],l[2],.5),y=Math.hypot(m.x-s.x,m.y-s.y)<=Math.hypot(h.x-s.x,h.y-s.y),p=rt(i,[.92,.9,.86],.35),x=K(a,.72),b=o-r;if(n==="restroom"){let S=Math.min(.18,b*.08);return tt(t,l,o-S,r,i,a),tt(t,l,o,o-S,p,p),!0}let d=r+Math.min(1.1,b),M=n==="coat"?1:Math.min(.5,.75/f),g=Sn(l,y,0,M);if(tt(t,g,d-.05,r,x,a),tt(t,g,d,d-.05,p,p),n==="coat"||f<1.2)return!0;if(n==="bar"){let S=Sn(l,y,Math.max(M+.2,1-.45/f),1),I=u(r+Math.max(Math.min(2.2,b*2),d-r+.6));return tt(t,S,I,r,i,x),!0}let _=Sn(l,y,Math.max(M+.25,.55),1),R=u(r+Math.max(2.6,d-r+1.4));if(R-.14<=d)return!0;tt(t,_,R-.14,r,i,a),tt(t,l,R,R-.14,p,x);let A=Math.min(.08,.1/Math.max(.1,Math.hypot(l[1].x-l[0].x,l[1].y-l[0].y)*P));for(let[S,I]of[[0,A],[1-A,1]])tt(t,Sn(ut(l,S,I),y,0,Math.min(.08,.1/f)),R-.14,d,x,x);return!0}var vt=.06,is=.05,xo=.05,po=.15,Zn=25;function bo(t,n,e){let r=new Map,o=new Array(n.length).fill(null),a=new Float64Array(n.length),i=new Array(n.length).fill(void 0),s=new Array(n.length).fill(void 0),c=new Map,u=[],l=new Set;for(let m=0;m<t.length;m+=1){let h=t[m];for(let y of h.objects){if(y.type==="table"&&l.add(y.id),y.type!=="section"||!y.outline||y.outline.length<3)continue;let p=Mt(y.outline,bt);c.set(y.id,{section:y,unit:h,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),u.push({id:y.id,floorIndex:m,box:Tt(p),section:y,unit:h,outline:p})}}let f=new Map;for(let m of u){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],y=e?f.get(e[m])??[]:u,p=h.sectionId?y.find(b=>b.id===h.sectionId)??y.find(b=>b.section.logicalSectionId===h.sectionId&&At({x:h.x,y:h.y},b.outline,b.section.holes)):void 0,x=p?[p]:y;for(let b of x){if(e&&b.floorIndex!==e[m]||!p&&(h.x<b.box.minX||h.x>b.box.maxX||h.y<b.box.minY||h.y>b.box.maxY||!At({x:h.x,y:h.y},b.outline,b.section.holes)))continue;o[m]=b.id;let d=c.get(b.id);d.hasSeats=!0;let M=h.focalPoint??b.unit.focal,g=Math.hypot(h.x-M.x,h.y-M.y);g<d.frontU&&(d.frontU=g),d.seatIndices.push(m);let _=h.rowId||`__seat-${m}`,R=d.rows.get(_);R?R.push({x:h.x,y:h.y}):d.rows.set(_,[{x:h.x,y:h.y}]);break}}for(let[m,h]of c){let y=Xt(h.section,{floorBaseHeightM:h.unit.baseHeightM}),p=h.unit.baseHeightM,x=y.rake>0?Math.tan(y.rake*Math.PI/180):0,b=y.rake<=.01&&y.height<=p+.001,d=h.section.surfaceKind,M=d==="flat"?!0:d==="rakedRows"&&y.rake>.01?!1:b,g=h.hasSeats?le(m,n,h.seatIndices,h.unit.focal):{sectionId:m,rows:[],blockCount:0},R=g.rows.length<2?Pe([...h.rows.values()].map(C=>({points:C})),h.unit.focal):null,A=1/0;if(R){if(h.hasSeats)for(let C of h.rows.values())for(let F of C){let v=R.depthAt(F.x,F.y);v<A&&(A=v)}if(!h.hasSeats||!Number.isFinite(A)){A=1/0;for(let C of h.section.outline){let F=R.depthAt(C.x,C.y);F<A&&(A=F)}}}let S=p+is,I=Math.max(S,y.height),w=C=>{let F=Math.max(0,C-A)*et,v=Math.min(F*x,Zn);return Math.max(S,y.height+v)},T=C=>{let F=Math.max(0,C)*et,v=Math.min(F*x,Zn);return Math.max(S,y.height+v)},k=M?[]:g.rows.map(C=>({pts:C.pts,y:T(C.blockDepth),depth:C.blockDepth,blockId:C.blockId,...l.has(C.id)?{patch:Xe(C.pts,bt)}:{}})),N=k.length?k[0].y:I,B=k.map(C=>{let F=C.patch&&C.patch.length>=3?C.patch:C.pts,v=0,G=0;for(let H of F)v+=H.x,G+=H.y;let j=F.length||1;v/=j,G/=j;let U=0;for(let H of F){let W=Math.hypot(H.x-v,H.y-G);W>U&&(U=W)}return{cx:v,cy:G,rad:U}}),E=M?()=>I:k.length>=2?(C,F)=>{let v=1/0,G=N;for(let j=0;j<k.length;j++){let U=B[j];if(Math.hypot(C-U.cx,F-U.cy)-U.rad>=v)continue;let H=k[j].patch,W=H&&H.length>=3?ht(H,C,F)?0:un(H,C,F):un(k[j].pts,C,F);W<v&&(v=W,G=k[j].y)}return G}:(C,F)=>R?w(R.depthAt(C,F)):I,O=[0,1,0],L=k.length>=2||M?()=>O:(C,F)=>{if(!R)return O;let v=R.depthAt(C,F);if(v<=A)return O;let G=(v-A)*et;if(G*x>=Zn||y.height+G*x<=S)return O;let[j,U]=R.gradientAt(C,F);if(j===0&&U===0)return O;let H=1/Math.hypot(x,1);return[-j*x*H,H,-U*x*H]};if(!M)for(let C of g.rows){let F=T(C.blockDepth);for(let v of C.seatIndices)i[v]=F}for(let C of g.rows){let F=[];for(let H=1;H<C.pts.length;H++){let W=Math.hypot(C.pts[H].x-C.pts[H-1].x,C.pts[H].y-C.pts[H-1].y);W>1e-6&&F.push(W)}F.sort((H,W)=>H-W);let v=F.length?F[Math.floor(F.length/2)]:1/0,G=1/0,j=C.pts[Math.floor(C.pts.length/2)];if(j)for(let H of g.rows){if(H===C||H.blockId!==C.blockId)continue;let W=un(H.pts,j.x,j.y);W>1e-6&&W<G&&(G=W)}let U=Math.min(v,Math.max(G,v*.5));if(Number.isFinite(U)&&U>0)for(let H of C.seatIndices)s[H]=U}r.set(m,{sectionId:m,deckAt:E,normalAt:L,flat:M,bottomY:p,rowLevels:k,landingY:N})}for(let m=0;m<n.length;m++){let h=o[m],y=n[m];if(h){let b=i[m];a[m]=(b??r.get(h).deckAt(y.x,y.y))+po;continue}let p=y.eyeHeightM,x=Number.isFinite(p)?Math.max(0,p-ln):0;a[m]=y.kind==="booth"?x+vt+po:x}return{bySection:r,seatOwner:o,seatDeckY:m=>a[m],seatPitchU:m=>s[m]}}var ss=[.12,.38,.16],as=[.72,.62,.45],cs=[.88,.93,.96],go=[.95,.95,.94],ls=[.66,.29,.22],qn={length:20.12,width:3.05},us=.14,fs=9.76,Ot=[.93,.94,.95],In=[.1,.11,.13],ms=[.45,.85,1.25],hs=1.45,Mo=.012,Po=.004,ys=1.07,ps=.15;function Vt(t,n,e,r,o,a){t.setMaterial(a),V(t,n,e?[e.slice().reverse()]:void 0,()=>r,r-.004,o,o,z)}var So=(t,n)=>Dt(t,n/P);function Io(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 ds(t,n,e,r){let o=n.map(a=>[a.x*P,e,a.y*P]);t.tri(o[0],o[1],o[2],[0,1,0],r),t.tri(o[0],o[2],o[3],[0,1,0],r)}function Rn(t,n,e,r,o,a){let i=e/P,s=[{x:n.x-i,y:n.y-i},{x:n.x+i,y:n.y-i},{x:n.x+i,y:n.y+i},{x:n.x-i,y:n.y+i}];V(t,s,void 0,()=>o,r,a,K(a,.85),z)}function zt(t,n,e,r,o,a,i){let s=Io(n,e,r/P);s&&V(t,s,void 0,()=>a,o,i,K(i,.85),z)}function An(t){let n=yt(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,u)=>({x:e.x+(a.x*c+i.x*u)/P,y:e.y+(a.y*c+i.y*u)/P}),lengthM:r*P,widthM:o*P}}function Ro(t,n,e){let r=he(n);if(!r.length)return;let o=1/0,a=-1/0,i=1/0,s=-1/0;for(let M of n.points??[])o=Math.min(o,M.x),a=Math.max(a,M.x),i=Math.min(i,M.y),s=Math.max(s,M.y);let c=(n.rotation??0)*Math.PI/180,u=Math.cos(c),l=Math.sin(c),f=(o+a)/2,m=(i+s)/2,h=M=>c?{x:f+(M.x-f)*u-(M.y-m)*l,y:m+(M.x-f)*l+(M.y-m)*u}:M,y=Math.min(a-o,s-i)*P,p=Math.max(.04,Math.min(.3,y*.004))/P,x=0;t.setMaterial(0);for(let M of r){if(!M.fill)continue;let g=M.points.map(h);Vt(t,g,null,e+Mo+x*Po,ot(M.fill)??Ot,0),x++}let b=r.filter(M=>!(M.fill&&M.ink===M.fill)),d=[...new Set(b.map(M=>M.ink??Fn))];for(let M of d){let g=e+Mo+x++*Po,_=ot(M)??Ot;for(let R of b){if((R.ink??Fn)!==M)continue;let A=R.points.map(h),S=R.closed?A.length:A.length-1;for(let I=0;I<S;I++){let w=Io(A[I],A[(I+1)%A.length],p);w&&ds(t,w,g,_)}}}}function Ao(t,n,e,r,o){if(n.length<3)return!1;let a=r+.006,i=o??ss;if(e==="oval-cricket"){let s=n.reduce((_,R)=>_+R.x,0)/n.length,c=n.reduce((_,R)=>_+R.y,0)/n.length,u=_=>n.map(R=>({x:s+(R.x-s)*_,y:c+(R.y-c)*_})),l=8;for(let _=0;_<l;_++){let R=u(1-_/l),A=_===l-1?null:u(1-(_+1)/l);Vt(t,R,A,a,K(i,_%2?1.04:.96),4)}let f=n[0];for(let _ of n)Math.hypot(_.x-s,_.y-c)>Math.hypot(f.x-s,f.y-c)&&(f=_);let m=Math.hypot(f.x-s,f.y-c)||1,h=(f.x-s)/m,y=(f.y-c)/m,p=-y,x=h,b=Math.min(1,2*m*P*us/qn.length),d=qn.length*b/2/P,M=qn.width*b/2/P,g=[[-d,-M],[d,-M],[d,M],[-d,M]].map(([_,R])=>({x:s+h*_+p*R,y:c+y*_+x*R}));return Vt(t,g,null,a+.004,as,0),t.setMaterial(0),!0}if(e==="rink-hockey"){let s=So(n,ps);return Vt(t,s,null,a,cs,0),t.setMaterial(0),V(t,n,[s.slice().reverse()],()=>r+ys,r,go,K(go,.9),z),!0}if(e==="ring-boxing"&&n.length===4){let{at:s}=An(n),c=[s(-3.05,-3.05),s(3.05,-3.05),s(3.05,3.05),s(-3.05,3.05)],u=[[.77,.19,.19],Ot,[.17,.42,.69],Ot];t.setMaterial(0),c.forEach((l,f)=>Rn(t,l,.07,r,r+hs,u[f]));for(let l of ms)for(let f=0;f<4;f++)zt(t,c[f],c[(f+1)%4],.025,r+l-.025,r+l+.025,Ot);return!0}if(e==="court-tennis"&&n.length===4){let{at:s}=An(n);t.setMaterial(0),zt(t,s(0,-6.4),s(0,6.4),.015,r,r+.95,In),zt(t,s(0,-6.4),s(0,6.4),.03,r+.95,r+1,Ot);for(let c of[-1,1])Rn(t,s(0,c*6.4),.05,r,r+1.07,In);return!0}if(e==="court-basketball"&&n.length===4){let{at:s,lengthM:c}=An(n),u=Math.min(14,c/2-.5);t.setMaterial(0);for(let l of[-1,1]){let f=s(l*(u+1.2),0),m=s(l*(u-1.2),0);Rn(t,f,.12,r,r+3.4,In),zt(t,f,m,.06,r+3.25,r+3.4,In),zt(t,s(l*(u-1.2),-.9),s(l*(u-1.2),.9),.03,r+2.9,r+3.95,Ot)}return!0}if(e==="pitch-rugby"&&n.length===4){let{at:s,lengthM:c}=An(n),u=c*(50/120);t.setMaterial(0);for(let l of[-1,1]){for(let f of[-2.8,2.8])Rn(t,s(l*u,f),.07,r,r+12,Ot);zt(t,s(l*u,-2.8),s(l*u,2.8),.06,r+2.94,r+3.06,Ot)}return!0}if(e==="track-athletics"){let s=So(n,fs);return s.length<3?!1:(Vt(t,n,s,a,ls,0),Vt(t,s,null,a,i,4),t.setMaterial(0),!0)}return!1}var xs=.012,En=2.4,bs=1,gs=.75,Ms=.15;function Et(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,u=r/2;return[[-c,-u],[c,-u],[c,u],[-c,u]].map(([l,f])=>({x:n.x+l*i-f*s,y:n.y+l*s+f*i}))}function Co(t,n,e,r,o,a,i=!1){let s=Et(n);if(s){if(i){let c=kt(r,o.boothTop),u=wt([...s]);V(t,Mt(u,Ps/P),[u.slice().reverse()],()=>e+.03,e,c,K(c,.8),z);return}if(!(!n.points&&a&&Is(t,s,e,r,a))){if(!n.points&&a&&s.length===4){Ss(t,s,e,r,a);return}V(t,s,void 0,()=>e+En,e,kt(r,o.boothTop),o.boothWall,z)}}}var $n=1.1,_o=[.9,.9,.88],Ps=.1,_n=[.87,.87,.85],wo=.08;function Oo(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 u=e(c),l=Math.hypot(u.x-n.x,u.y-n.y);l<o&&(o=l,r=c)}let a=[0,1,2,3].map(c=>t[(r+c)%4]),i=(c,u,l)=>({x:c.x+(u.x-c.x)*l,y:c.y+(u.y-c.y)*l});return{q:a,part:(c,u,l,f)=>{let m=i(a[0],a[1],c),h=i(a[0],a[1],u),y=i(a[3],a[2],c),p=i(a[3],a[2],u);return[i(m,y,l),i(h,p,l),i(h,p,f),i(m,y,f)]},depthM:Math.hypot(a[3].x-a[0].x,a[3].y-a[0].y)*P,widthM:Math.hypot(a[1].x-a[0].x,a[1].y-a[0].y)*P}}function Ss(t,n,e,r,o){let{q:a,part:i}=Oo(n,o),s=r??[.35,.42,.55],c=rt(s,[.78,.78,.77],.62),u=rt(s,[.95,.95,.94],.45);tt(t,a,e+vt,e,c,K(c,.8)),tt(t,i(.05,.95,.72,.98),e+$n-.05,e+vt,u,K(u,.8)),tt(t,i(.03,.97,.7,1),e+$n,e+$n-.05,_o,K(_o,.9))}function Is(t,n,e,r,o){if(n.length!==4)return!1;let{q:a,part:i,depthM:s,widthM:c}=Oo(n,o);if(s<1||c<1)return!1;let u=r??[.35,.42,.55],l=rt(u,[.78,.78,.77],.62),f=e+En,m=wo/c,h=wo/s;tt(t,a,e+vt,e,l,K(l,.8)),tt(t,i(0,1,1-h,1),f,e+vt,_n,K(_n,.9));for(let[x,b]of[[0,m],[1-m,1]])tt(t,i(x,b,0,1-h),f,e+vt,_n,K(_n,.9));tt(t,i(m,1-m,0,Math.min(.5,.06/s)),f,f-.3,u,K(u,.85));let y=Math.min(.4,.6/c),p=Math.min(.12,.3/s);return tt(t,i(.5-y,.5+y,.72-p,.72+p),e+bs,e+vt,rt(u,[.95,.95,.94],.7),K(u,.75)),!0}function Bn(t){if(t.shape==="round"){let l=t.radius;return l?pn(t.center.x,t.center.y,l,l,24):null}let{width:n,height:e,rotation:r,center:o}=t;if(!n||!e)return null;let a=(r??0)*Math.PI/180,i=Math.cos(a),s=Math.sin(a),c=n/2,u=e/2;return[[-c,-u],[c,-u],[c,u],[-c,u]].map(([l,f])=>({x:o.x+l*i-f*s,y:o.y+l*s+f*i}))}function ko(t,n,e,r,o,a=!0){let i=Bn(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,u=m=>i.map(h=>({x:s+(h.x-s)*m,y:c+(h.y-c)*m})),l=a&&r?kt(r,o.tableTop):Rs,f=e+gs;V(t,i,void 0,()=>f,e+As,l,K(l,.86),z),V(t,u(.12),void 0,()=>f+.12,f,Eo,K(Eo,.8),z)}var Rs=[.93,.92,.89],Eo=[.78,.66,.42],As=.25;function Fo(t,n,e,r,o,a,i,s,c=[]){let u=st(n);if(!n.role&&(!n.fill||n.fill==="none"||n.fill==="transparent")||!u){on(t,n,e+r+xs);return}let f=s?s.kind==="stage":n.role==="stage",m=s?s.kind==="screen":n.role==="screen",h=s?{kind:f?"stage":"solid",heightM:s.topY-s.baseY}:Pt(n),y=s?.baseY??e,p=s?.topY??e+r;if(f&&i){let S=1/0,I=-1/0,w=1/0,T=-1/0;for(let k of u)k.x<S&&(S=k.x),k.x>I&&(I=k.x),k.y<w&&(w=k.y),k.y>T&&(T=k.y);i.push({cx:(S+I)/2*P,cz:(w+T)/2*P,y:p,halfX:Math.max((I-S)/2*P,.5),halfZ:Math.max((T-w)/2*P,.5)})}let x=ot(n.fill),b=n.role==="wall"||n.role==="entrance"||n.role==="exit",d=b?x?K(_t(x,.12),.95):o.tierTop:f&&x?rt(o.stageTop,K(_t(x,.18),.9),.9):!n.role&&x?x:kt(x,f?o.stageTop:o.decorTop),M=m?x:null,g=b?x?K(_t(x,.12),.85):o.tierWall:f?x?rt(o.stageWall,K(x,.58),.82):o.stageWall:m?M?rt(K(M,1.42),[.24,.46,.82],.08):[.24,.46,.82]:kt(ot(n.fill),o.decorWall);if(n.role==="wall"&&!s){mo(t,u,y,p,c,d,g),on(t,n,p+.012);return}if(m&&u.length===4&&p-y>.2){let S=Kn(u,y,p);if(!S)return;let{quad:I,side:w,trim:T,inner:k,panel:N}=S,B=[.12,.15,.18];for(let[E,O]of[[0,w],[1-w,1]])tt(t,ut(I,E,O),p,y,B,B);tt(t,k,y+T,y,B,B),tt(t,k,p,p-T,B,B),tt(t,N,p-T,y+T,g,g),on(t,n,p+.012);return}let _=x?K(_t(x,.15),.82):g,R=x?K(_t(x,.1),1.02):d;if(ho(n.role)&&!s&&yo(t,n.role,u,y,p,_,R,a,n.heightM!==void 0))return;if((n.role==="sound"||s?.kind==="sound_desk")&&u.length===4&&p-y>.3){let S=yt(u),I=Math.hypot(S[1].x-S[0].x,S[1].y-S[0].y)*P,w=Math.min(.12,.09/Math.max(I,.001)),T=[.18,.21,.24],k=p-Math.min(.12,(p-y)*.15);for(let[N,B]of[[0,w],[1-w,1]])tt(t,ut(S,N,B),k,y,T,T);tt(t,S,p,k,d,T);return}if(n.role==="rail"&&u.length===4&&p>y){let S=yt(u),I=Math.hypot(S[1].x-S[0].x,S[1].y-S[0].y)*P,w=Math.max(1,Math.min(128,Math.ceil(I/1.4))),T=Math.min(.08,.055/Math.max(.055,I)),k=[.58,.64,.66];for(let N=0;N<=w;N++){let B=N/w,E=Math.min(1-T,Math.max(0,B-T/2));tt(t,ut(S,E,E+T),p,y,k,K(k,.8))}for(let N of[.52,1]){let B=y+(p-y)*N;tt(t,S,B,Math.max(y,B-.055),k,K(k,.8))}return}if(n.role==="goal"&&u.length===4){let S=yt(u),I=Math.hypot(S[1].x-S[0].x,S[1].y-S[0].y)*P,w=Math.min(.12,.1/Math.max(.1,I)),T=[.9,.94,.94];for(let[k,N]of[[0,w],[1-w,1]])tt(t,ut(S,k,N),Math.max(y,p-.1),y,T,T);tt(t,S,p,Math.max(y,p-.1),T,T);return}if(h.kind==="portal"&&u.length===4){let S=Yt(u,y,p);if(!S)return;let{quad:I,side:w,face:T,openingTop:k}=S;for(let[N,B,E]of[[0,T,1],[T,1-T,.67],[1-T,1,1]]){let O=nn(I,N,B),L=K(d,E),C=K(g,E);for(let[F,v]of[[0,w],[1-w,1]])tt(t,ut(O,F,v),k,y,L,C);tt(t,O,p,k,L,C)}return}if(h.kind==="suite"&&u.length===4){let S=u.map((T,k)=>{let N=u[(k+1)%4],B=(T.x+N.x)/2,E=(T.y+N.y)/2;return Math.hypot(B-a.x,E-a.y)}),I=S.indexOf(Math.min(...S)),w=[0,1,2,3].map(T=>u[(I+T)%4]);tt(t,ut(w,0,.08),p,y,d,g),tt(t,ut(w,.92,1),p,y,d,g),tt(t,nn(w,.88,1),p,y,d,g),tt(t,w,p,Math.max(y,p-.18),d,g);return}if(f&&!n.stageKind?.startsWith("pitch-")&&p-y>.12){let S=p-Math.min(.06,(p-y)*.15);tt(t,u,S,y,d,g),tt(t,u,p,S,d,rt(d,g,.2))}else tt(t,u,p,y,d,g);if((n.stageKind==="pitch-football"||n.stageKind==="pitch-rugby")&&u.length===4){t.setMaterial(4);let S=yt(u);for(let I=0;I<12;I++){let w=ut(S,I/12,(I+1)/12),T=K(x??[.12,.38,.16],I%2?1.035:.965),k=w.map(N=>[N.x*P,p+.006,N.y*P]);t.tri(k[0],k[1],k[2],[0,1,0],T),t.tri(k[0],k[2],k[3],[0,1,0],T)}}n.stageKind&&n.stageKind!=="pitch-football"&&Ao(t,u,n.stageKind,p,x),f&&Ht(n.stageKind)&&Ro(t,n,p),t.setMaterial(m?1:0),on(t,n,p+.012)}function Tn(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),u=Math.sin(s),l=r/2,f=o/2;return[[-l,-f],[l,-f],[l,f],[-l,f]].map(([m,h])=>({x:a+m*c-h*u,y:i+m*u+h*c}))}function _s(t){if(!t||!t.startsWith("data:image/svg+xml"))return null;let n=t.slice(t.indexOf(",")+1);if(/;base64/i.test(t.slice(0,t.indexOf(","))))try{n=atob(n)}catch{return null}else try{n=decodeURIComponent(n)}catch{}let e=n.match(/<(?:rect|path)\b[^>]*\bfill="([^"]+)"/i);if(!e)return null;let r=e[1].trim();if(r==="none"||r==="transparent")return null;let o=r.match(/^url\(#([^)]+)\)$/);if(!o)return ot(r);let a=n.match(new RegExp(`<(?:linear|radial)Gradient\\b[^>]*\\bid="${o[1]}"[^>]*>([\\s\\S]*?)</(?:linear|radial)Gradient>`,"i"));if(!a)return null;let i=[];for(let s of a[1].matchAll(/stop-color="([^"]+)"/gi)){let c=ot(s[1].trim());c&&i.push(c)}return i.length?i.reduce((s,c,u)=>rt(s,c,1/(u+1)),i[0]):null}function vo(t,n,e,r){if(n.layer==="foreground")return;let o=Tn(n);if(!o)return;let a=e+Ms,i=kt(_s(n.href),r.decorTop),s=Math.max(0,Math.min(1,n.opacity??1));s<1&&(i=rt(r.ground,i,s)),V(t,o,void 0,()=>a,e,i,rt(i,r.decorWall,.5),z)}function Lo(t,n,e,r,o){if(!n.points||n.points.length<3)return;let a=kt(r,o.gaTop);V(t,n.points,n.holes,()=>e+Bo,e,a,o.gaWall,z),Bs(t,n.points,e+Bo)}var Bo=.15,wn=[.72,.74,.76],Qn=1.1,To=.12,Jn=.05,ws=.06,Es=2.4;function Bs(t,n,e){let r=wt([...n]),o=Dt(r,To/P),a=Dt(r,(To+Jn)/P);if(o.length<3||a.length<3)return;for(let s of[e+Qn,e+Qn*.5])V(t,o,[a.slice().reverse()],()=>s,s-Jn,wn,K(wn,.85),z);let i=ws/2/P;for(let s=0;s<o.length;s++){let c=o[s],u=o[(s+1)%o.length],l=Math.hypot(u.x-c.x,u.y-c.y)*P,f=Math.max(1,Math.round(l/Es));for(let m=0;m<f;m++){let h=m/f,y=c.x+(u.x-c.x)*h,p=c.y+(u.y-c.y)*h,x=[{x:y-i,y:p-i},{x:y+i,y:p-i},{x:y+i,y:p+i},{x:y-i,y:p+i}];V(t,x,void 0,()=>e+Qn-Jn,e,wn,K(wn,.8),z)}}}var Ts=6,Cs=2.2,Do=.1,Os=.3,ks=1.8,Fs=.9,vs=.55,Ls=6e3;function Go(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 l of e)for(let f of l.objects)f.type==="section"&&f.zone&&c.set(f.id,f.zone);let u=new Map;for(let l=0;l<r.length;l++){let f=r[l],m=o.seatOwner[l],h=f.zoneId??(m?c.get(m):void 0);if(!h)continue;let y=u.get(h);y||(y={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},u.set(h,y)),y.n++,f.x<y.minX&&(y.minX=f.x),f.y<y.minY&&(y.minY=f.y),f.x>y.maxX&&(y.maxX=f.x),f.y>y.maxY&&(y.maxY=f.y),y.sumY+=o.seatDeckY(l)}for(let l of i){let f=u.get(l.id),m=[];for(let[h,y]of c)y===l.id&&m.push(h);if(!f||f.n===0){s.push({id:l.id,label:l.label,color:ot(l.color),sectionIds:m,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(l.focalPoint??a).x*P,1.5,(l.focalPoint??a).y*P]});continue}s.push({id:l.id,label:l.label,color:ot(l.color),sectionIds:m,seatCount:f.n,center:[(f.minX+f.maxX)/2*P,f.sumY/f.n,(f.minY+f.maxY)/2*P],radius:.5*Math.hypot((f.maxX-f.minX)*P,(f.maxY-f.minY)*P)||1,focalWorld:[(l.focalPoint??a).x*P,1.5,(l.focalPoint??a).y*P]})}}return s}function Xo(t){let{doc:n,units:e,seats:r,surfaces:o,seatData:a,hintedSeatFloor:i,zones:s,focal:c}=t,u=[],l=[],f=[],m=new Map;for(let h of e)for(let y of h.objects){if(y.type!=="section"||!y.zone)continue;let p=(y.displayLabel||y.label||"").trim().toLocaleLowerCase();if(!p)continue;let x=n.floors?.[h.index]?.name?.trim().toLocaleLowerCase();if(e.length>1&&x===p)continue;let b=m.get(y.zone);b||m.set(y.zone,b=new Set),b.add(p)}for(let h of s)h.seatCount!==0&&(m.get(h.id)?.has(h.label.trim().toLocaleLowerCase())||u.push({id:`zone:${h.id}`,kind:"zone",text:h.label,anchor:[h.center[0],h.center[1]+Ts,h.center[2]],color:n.zones?.find(y=>y.id===h.id)?.color}));{let h=new Map,y=new Map;for(let p=0;p<r.length;p++){let x=o.seatOwner[p];if(!x)continue;let b=h.get(x);b||(b={n:0,x:0,y:0,deck:0},h.set(x,b)),b.n++,b.x+=r[p].x,b.y+=r[p].y,b.deck+=o.seatDeckY(p);let d=y.get(x);d||(d={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0,minDeck:1/0,maxDeck:-1/0},y.set(x,d)),d.minDeck=Math.min(d.minDeck,o.seatDeckY(p)),d.maxDeck=Math.max(d.maxDeck,o.seatDeckY(p)),r[p].x<d.minX&&(d.minX=r[p].x),r[p].x>d.maxX&&(d.maxX=r[p].x),r[p].y<d.minY&&(d.minY=r[p].y),r[p].y>d.maxY&&(d.maxY=r[p].y)}for(let p of e)for(let x of p.objects){if(x.type!=="section"||ro(x))continue;let b=h.get(x.id);if(!b||b.n===0)continue;let d=y.get(x.id),M=[b.x/b.n*P,b.deck/b.n,b.y/b.n*P],g=x.displayLabel||x.label||x.id;l.push({id:x.id,floorIndex:p.index,label:g,seatCount:b.n,center:M,radius:Math.max(1,Math.hypot(d.maxX-d.minX,d.maxY-d.minY)*.5*P),box:{min:[d.minX*P-.4,d.minDeck,d.minY*P-.4],max:[d.maxX*P+.4,d.maxDeck+1,d.maxY*P+.4]},focalWorld:[p.focal.x*P,p.baseHeightM+1.5,p.focal.y*P]});let _=n.floors?.[p.index]?.name?.trim().toLocaleLowerCase();e.length>1&&_===g.trim().toLocaleLowerCase()||u.push({id:`section:${x.id}`,kind:"section",text:g,anchor:[M[0],M[1]+Cs,M[2]],floorIndex:p.index})}}{for(let b of e)for(let d of b.objects){if(d.type!=="gaArea")continue;let M=qt(d.points);if(!M)continue;let g=d.displayLabel||d.label||d.id;u.push({id:`ga:${d.id}`,kind:"ga",text:d.capacity>0?`${g} \xB7 ${d.capacity.toLocaleString()}`:g,anchor:[M.x*P,b.baseHeightM+ks,M.y*P],floorIndex:b.index})}let h=new Map,y=new Map;for(let b of e)for(let d of b.objects)if(d.type==="section"&&h.set(d.id,d.displayLabel||d.label||d.id),d.type==="row"){let M=d.displayLabel?.trim()||d.segmentedRow?.displayLabel?.trim();M&&y.set(d.id,M)}let p=new Map;for(let b=0;b<r.length;b++){let d=r[b],M=Math.hypot(d.x-c.x,d.y-c.y),g=p.get(d.rowId);(!g||M>g.far)&&p.set(d.rowId,{seat:d,index:b,far:M})}for(let[b,d]of p){let M=o.seatOwner[d.index]??d.seat.sectionId,g=No(d.seat.label,b,h.get(M??""),y.get(b));g&&u.push({id:`row:${b}`,kind:"row",text:g,anchor:[d.seat.x*P,o.seatDeckY(d.index)+Fs,d.seat.y*P],floorIndex:i[d.index]})}let x=new Map;for(let b=0;b<r.length;b++){let d=r[b],M=x.get(d.rowId);M||(M={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:No(d.label,d.rowId,h.get(o.seatOwner[b]??d.sectionId??""),y.get(d.rowId)),sectionId:o.seatOwner[b]??d.sectionId},x.set(d.rowId,M));let g=b*3,_=a.iPosition[g],R=a.iPosition[g+1],A=a.iPosition[g+2];M.n++,M.x+=_,M.y+=R,M.z+=A,M.minX=Math.min(M.minX,_),M.maxX=Math.max(M.maxX,_),M.minZ=Math.min(M.minZ,A),M.maxZ=Math.max(M.maxZ,A)}for(let[b,d]of x)f.push({id:b,label:d.label,sectionId:d.sectionId,seatCount:d.n,center:[d.x/d.n,d.y/d.n,d.z/d.n],radius:Math.max(.8,Math.hypot(d.maxX-d.minX,d.maxZ-d.minZ)*.5)});if(r.length<=Ls)for(let b=0;b<r.length;b++){let d=r[b],M=Ds(d.displayLabel||d.label);M&&u.push({id:`seat:${d.id}`,kind:"seat",seatWidthM:a.iChairWidth[b]*2,text:M,anchor:[d.x*P,o.seatDeckY(b)+vs,d.y*P],floorIndex:i[b],rowId:d.rowId})}}for(let h of e)for(let y of h.objects)if(y.type==="shape"&&y.role&&["entrance","exit","screen","suite","obstruction"].includes(y.role)){let p=st(y),x=p?qt(p):null;if(!x||!y.label)continue;u.push({id:`architecture:${y.id}`,kind:"annotation",text:y.label,anchor:[x.x*P,h.baseHeightM+Pt(y).heightM+Do,x.y*P],color:y.fill,floorIndex:h.index})}else if(y.type==="text"){if(!y.text)continue;u.push({id:`text:${y.id}`,kind:"annotation",text:y.text,anchor:[y.position.x*P,h.baseHeightM+Do,y.position.y*P],color:y.color,rotation:y.rotation,floorIndex:h.index})}else if(y.type==="booth"){let p=Et(y);if(!p)continue;let x=qt(p);if(!x)continue;u.push({id:`booth:${y.id}`,kind:"booth",text:y.displayLabel||y.label||y.id,anchor:[x.x*P,h.baseHeightM+En+Os,x.y*P],floorIndex:h.index})}return{labels:u,sections:l,rows:f}}function Ho(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 Ds(t){let n=t.lastIndexOf("-");return n>=0&&n<t.length-1?t.slice(n+1):t}function No(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&&be(a,e)}var rn=3,Nt=.38,sn=.24;function Ns(t){if(t.length<3)return null;let n=t[0],e=t[Math.floor(t.length/2)],r=t[t.length-1],o=(e.x-n.x)*P,a=(e.y-n.y)*P,i=(r.x-n.x)*P,s=(r.y-n.y)*P,c=2*(o*s-a*i);if(Math.abs(c)<1e-7)return null;let u=o*o+a*a,l=i*i+s*s,f=(u*s-l*a)/c+n.x*P,m=(o*l-i*u)/c+n.y*P,h=Math.hypot(n.x*P-f,n.y*P-m);return h<1||h>200||!Number.isFinite(h)||t.some(y=>Math.abs(Math.hypot(y.x*P-f,y.y*P-m)-h)>.03)?null:{x:f,z:m,radius:h}}function jo(t){let n=[],e=new Map,r=(c,u)=>`${Math.floor(c/rn)},${Math.floor(u/rn)}`;for(let c of t)for(let u of c.rows){for(let f of u.pts){let m=f.x*P,h=f.y*P,y=r(m,h),p=e.get(y)??[];p.push({x:m,z:h,y:u.y,floor:c.floorIndex}),e.set(y,p)}if(u.patch||u.pts.length<2)continue;let l=Ns(u.pts);for(let f of[0,u.pts.length-1]){let m=u.pts[f],h=u.pts[f===0?1:f-1],y=m.x-h.x,p=m.y-h.y,x=Math.hypot(y,p);x<1e-6||n.push({sectionId:c.sectionId,floorIndex:c.floorIndex,curve:l,row:u,point:m,x:m.x*P,z:m.y*P,dx:y/x,dz:p/x})}}let o=new Map;n.forEach((c,u)=>{let l=r(c.x,c.z),f=o.get(l)??[];f.push(u),o.set(l,f)});let a=(c,u)=>{let l=Math.floor(c/rn),f=Math.floor(u/rn);return[-1,0,1].flatMap(m=>[-1,0,1].map(h=>`${l+m},${f+h}`))},i=new Map;n.forEach((c,u)=>{let l=-1,f=1/0,m=!1;for(let h of a(c.x,c.z))for(let y of o.get(h)??[]){let p=n[y];if(c.sectionId===p.sectionId&&c.row.blockId===p.row.blockId||c.floorIndex!==p.floorIndex||Math.abs(c.row.y-p.row.y)>.05)continue;let x=p.x-c.x,b=p.z-c.z,d=Math.hypot(x,b);if(d<Nt*2+.45||d>rn)continue;let M=c.curve&&p.curve&&Math.hypot(c.curve.x-p.curve.x,c.curve.z-p.curve.z)<=.05&&Math.abs(c.curve.radius-p.curve.radius)<=.05,g=Math.min((x*c.dx+b*c.dz)/d,(-x*p.dx-b*p.dz)/d);(M?g<.8:g<.98)||!M&&(Math.abs(x*c.dz-b*c.dx)>.15||Math.abs(x*p.dz-b*p.dx)>.15)||(d<f-.02?(l=y,f=d,m=!1):Math.abs(d-f)<=.02&&(m=!0))}l>=0&&!m&&i.set(u,l)});let s=[];for(let[c,u]of i){if(c>=u||i.get(u)!==c)continue;let l=n[c],f=n[u],m=Math.hypot(f.x-l.x,f.z-l.z),h=(f.x-l.x)/m,y=(f.z-l.z)/m,p=!1;for(let b of a((l.x+f.x)/2,(l.z+f.z)/2))for(let d of e.get(b)??[]){if(d.floor!==l.floorIndex||Math.abs(d.y-l.row.y)>.75)continue;let M=(d.x-l.x)*h+(d.z-l.z)*y,g=Math.abs((d.x-l.x)*y-(d.z-l.z)*h);M>.01&&M<m-.01&&g<sn+Nt&&(p=!0)}if(p)continue;let x=(b,d)=>({x:(l.x+h*b-y*d)/P,y:(l.z+y*b+h*d)/P});s.push({sections:[l.sectionId,f.sectionId],blocks:[l.row.blockId,f.row.blockId],floorIndex:l.floorIndex,ends:[l.point,f.point],clearWidthM:m-2*Nt,heightM:(l.row.y+f.row.y)/2,outline:[x(Nt,-sn),x(m-Nt,-sn),x(m-Nt,sn),x(Nt,sn)]})}return s}var Gs=.15,Xs=.9,Hs=1.76;function js(){return{background:{top:[...Dn.top],bottom:[...Dn.bottom]},structure:Ln,seatStates:{...Ee},seatScale:1,materials:{seat:null,shell:null,roughness:.78}}}function Us(t){return!!t&&t[0]*.2126+t[1]*.7152+t[2]*.0722>.55?{deck:"#a8ada9",fascia:"#69777c",shell:"#8d9ca0",roughness:.87}:{deck:"#69747b",fascia:"#3e4d58",shell:"#526572",roughness:.87}}function Uo(t){let n=js();t??={};let e=ot(t.background);if(e){n.background={top:K(e,Xs),bottom:K(e,Hs)};let s={};for(let[u,l]of Object.entries(Ln))s[u]=rt(l,e,Gs);e[0]*.2126+e[1]*.7152+e[2]*.0722>.55&&(s.ground=K(e,.86)),n.structure=s}let r=ot(t.selectionColor)??ot(t.accent);r&&(n.seatStates={...n.seatStates,selected:r});let o=t.seatScale;typeof o=="number"&&Number.isFinite(o)&&(n.seatScale=Me(o));let a=Object.fromEntries(Object.entries(t.venue3d??{}).filter(([,s])=>s!=null)),i={...Us(e),...a};if(i){let s=ot(i.deck),c=ot(i.fascia);s&&(n.structure={...n.structure,tierTop:s,gaTop:s}),c&&(n.structure={...n.structure,tierWall:c,gaWall:c}),n.materials.seat=ot(i.seat),n.materials.shell=ot(i.shell),typeof i.roughness=="number"&&Number.isFinite(i.roughness)&&(n.materials.roughness=Math.min(1,Math.max(0,i.roughness)))}return n}function Yo(t,n){let e=[];for(let r of n)e.push(...t.seatStates[r]);return e}var te=.6,Wo=3,Ys=.25;function Ws(t,n){if(ht(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,u=s*s+c*c||1,l=Math.max(0,Math.min(1,((t.x-a.x)*s+(t.y-a.y)*c)/u));e=Math.min(e,Math.hypot(t.x-(a.x+l*s),t.y-(a.y+l*c)))}return e}function zo(t,n){let e=t.map(i=>({booth:i,ring:Et(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=(Wo+te)/P,a=new Map;return e.forEach(({booth:i,ring:s},c)=>{let u={x:s.reduce((h,y)=>h+y.x,0)/4,y:s.reduce((h,y)=>h+y.y,0)/4},l=[0,1,2,3].map(h=>{let y=s[h],p=s[(h+1)%4],x={x:(y.x+p.x)/2,y:(y.y+p.y)/2},b=x.x-u.x,d=x.y-u.y,M=Math.hypot(b,d)||1,g={x:x.x+b/M*te/P,y:x.y+d/M*te/P},_=Wo/P;return r.forEach((R,A)=>{A===c||g.x<R.minX-o||g.x>R.maxX+o||g.y<R.minY-o||g.y>R.maxY+o||(_=Math.min(_,Ws(g,e[A].ring)))}),{open:_*P,toward:{x:x.x+b/M*10/P,y:x.y+d/M*10/P},focal:Math.hypot(x.x-n.x,x.y-n.y)}}),f=Math.max(...l.map(h=>h.open)),m=l.filter(h=>h.open>=f-Ys).sort((h,y)=>h.focal-y.focal)[0];a.set(i.id,m.toward)}),a}import zs from"polygon-clipping";var Vs=.45,Ks=1500,Zs=200;function Vo(t,n){if(t.role!=="stage"||Ht(t.stageKind))return t;let e=st(t);if(!e||e.length<3||Math.abs(mt(e))*P*P>Ks)return t;let r=n.filter(i=>ht(e,i.x,i.y));if(!r.length||r.length>Zs)return t;let o=Vs/P,a=r.map(i=>[[[i.x-o,i.y-o],[i.x+o,i.y-o],[i.x+o,i.y+o],[i.x-o,i.y+o],[i.x-o,i.y-o]]]);try{let i=zs.difference([[...e.map(u=>[u.x,u.y]),[e[0].x,e[0].y]]],...a),s=null,c=0;for(let u of i){let l=u[0].slice(0,-1).map(([m,h])=>({x:m,y:h})),f=Math.abs(mt(l));f>c&&(c=f,s=l)}return!s||s.length<3?t:{...t,kind:"polygon",points:s,rotation:0}}catch{return t}}function ne(t,n,e,r,o,a,i,s,c,u=[],l=o){if(n.length!==e.length||n.length<2||a-o<1.5)return;let f=(p,x,b)=>{Ct(t,p,x,b,u,i,s,{portalBase:l,ao:c})||V(t,p,void 0,()=>b,x,i,s,c)},m=(p,x,b)=>({x:p.x+(x.x-p.x)*b,y:p.y+(x.y-p.y)*b}),h=r?n.length:n.length-1,y=0;for(let p=0;p<h;p++){let x=(p+1)%n.length,b=Math.hypot(e[x].x-e[p].x,e[x].y-e[p].y)*et;if(b<1e-5)continue;let d=(R,A)=>[m(n[p],n[x],R),m(n[p],n[x],A),m(e[p],e[x],A),m(e[p],e[x],R)];f(d(0,1),o,o+.95),f(d(0,1),a-.22,a);let M=Math.ceil((y-.32)/6)*6,g=!1,_=!1;for(let R=M;R<y+b;R+=6){let A=Math.max(0,(R-y)/b),S=Math.min(1,(R+.32-y)/b);S<=A||(f(d(A,S),o+.95,a-.22),g||=A<1e-6,_||=S>1-1e-6)}if(!r&&(p===0&&!g||p===h-1&&!_)){let R=Math.min(1,.32/b);f(d(p===0?0:1-R,p===0?R:1),o+.95,a-.22)}y+=b}}var an=.65;function Ko(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,u=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-u*s,t.y-a.y-u*c))}return e}var Zo=.01;function qo(t,n,e,r,o,a,i,s=[],c=!0){if(r-o<=1e-5)return;let u=r-o>=3,l=u?r-an:o;t.setMaterial(5);let f=u?[]:s.filter(g=>{if(g.role!=="entrance"&&g.role!=="exit")return!1;let _=st(g);if(!_)return!1;let R=Yt(_,o,o+Pt(g).heightM);return R!==null&&R.openingTop<=r-.12});if((!f.length||!Ct(t,n,l,r,f,a,i,{holes:e,portalBase:o}))&&V(t,n,e,()=>r,l,a,i,z,void 0,()=>[0,1,0]),!u){t.setMaterial(0);return}let m=6/P,h=.22/P,y=s.flatMap(g=>{if(g.role!=="entrance"&&g.role!=="exit")return[];let _=st(g);return _?.length?[{minX:Math.min(..._.map(R=>R.x)),maxX:Math.max(..._.map(R=>R.x)),minY:Math.min(..._.map(R=>R.y)),maxY:Math.max(..._.map(R=>R.y))}]:[]}),p=Math.min(...n.map(g=>g.x)),x=Math.max(...n.map(g=>g.x)),b=Math.min(...n.map(g=>g.y)),d=Math.max(...n.map(g=>g.y));for(let g=p+m/2;g<x;g+=m)for(let _=b+m/2;_<d;_+=m){if(y.some(A=>g+h>=A.minX&&g-h<=A.maxX&&_+h>=A.minY&&_-h<=A.maxY))continue;let R=[{x:g-h,y:_-h},{x:g+h,y:_-h},{x:g+h,y:_+h},{x:g-h,y:_+h}];!At({x:g,y:_},n,e)||Ko({x:g,y:_},[n,...e??[]])<h*Math.SQRT2+(c?ee/P:0)||V(t,R,void 0,()=>l,o,a,i,z)}let M=Dt(n,ee/P);if(c&&M.length>=3){let g=s.filter(A=>{if(A.role!=="entrance"&&A.role!=="exit")return!1;let S=st(A);return!!S&&S.some(I=>!At(I,n,void 0)||Ko(I,[n])<=ee/P)}),_=[M.slice().reverse()],R=o-Zo;(!g.length||!Ct(t,n,R,l,g,a,i,{holes:_,portalBase:o+Zo}))&&V(t,n,_,()=>l,R,a,i,z)}t.setMaterial(0)}var ee=.25;var qs=.02,$s=.25,Qs=1.2,Js=.6,ta=.45,na=2.3,ea=Math.PI/180,$o=.005;function Bt(t,n,e){let r=e*ea;return{x:t.x+n*Math.sin(r),y:t.y+n*Math.cos(r)}}function oa(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 ra=24,ia=.01;function sa(t,n,e,r,o,a,i,s,c){let u=e.binCount,l=ra,f=et,m=a+.02,h=a-ia,y=[];for(let B=0;B<u;B++){let E=(e.startBin+B+.5)*n.binStepDeg,O=new Float64Array(l+1);for(let L=0;L<=l;L++){let C=r[B]+(o[B]-r[B])*L/l;O[L]=Math.max(m,Ie(n,e,E,C)-$s)}y.push(O)}if(c){let B=0;for(let E=0;E+1<u;E++)for(let O=0;O<l;O++){let L=Bt(n.centre,r[E]+(o[E]-r[E])*O/l,(e.startBin+E+.5)*n.binStepDeg),C=Bt(n.centre,r[E+1]+(o[E+1]-r[E+1])*(O+1)/l,(e.startBin+E+1.5)*n.binStepDeg);B=Math.max(B,Math.hypot(C.x-L.x,C.y-L.y))}for(let E=0;E<u;E++){let O=(e.startBin+E+.5)*n.binStepDeg;for(let L=0;L<=l;L++){let C=Bt(n.centre,r[E]+(o[E]-r[E])*L/l,O),F=c(C.x,C.y,B*1.01);F!==null&&(y[E][L]=Math.min(y[E][L],Math.max(h+$o,F-$o)))}}}let p=[i.bandTop[0]*s.top,i.bandTop[1]*s.top,i.bandTop[2]*s.top],x=[i.bandTop[0]*s.bottomCap,i.bandTop[1]*s.bottomCap,i.bandTop[2]*s.bottomCap],b=[i.bandWall[0]*s.top,i.bandWall[1]*s.top,i.bandWall[2]*s.top],d=[i.bandWall[0]*s.wallBottom,i.bandWall[1]*s.wallBottom,i.bandWall[2]*s.wallBottom],M=(B,E)=>{let O=(e.startBin+B+.5)*n.binStepDeg,L=r[B]+(o[B]-r[B])*E/l,C=Bt(n.centre,L,O);return[C.x*f,y[B][E],C.y*f]};{let B=Math.tan(12*Math.PI/180);for(let E=0;E<6;E++){let O=!1;for(let C=0;C<u;C++)for(let F=l-1;F>=0;F--)y[C][F]>y[C][F+1]&&(y[C][F]=y[C][F+1],O=!0);let L=e.closed?u:u-1;for(let C=0;C<L;C++){let F=(C+1)%u;for(let v=0;v<=l;v++){let G=y[F][v]-y[C][v];if(Math.abs(G)>1)continue;let j=r[C]+(o[C]-r[C])*v/l,U=r[F]+(o[F]-r[F])*v/l,H=Bt(n.centre,j,(e.startBin+C+.5)*n.binStepDeg),W=Bt(n.centre,U,(e.startBin+F+.5)*n.binStepDeg),nt=B*Math.hypot(W.x-H.x,W.y-H.y)*f;G>nt?(y[F][v]=y[C][v]+nt,O=!0):-G>nt&&(y[C][v]=y[F][v]+nt,O=!0)}}if(!O)break}}let g=1,_=(B,E)=>{for(let O=0;O<=l;O+=4)if(Math.abs(y[B][O]-y[E][O])>g)return!0;return Math.abs(y[B][l]-y[E][l])>g},R=Math.tan(38*Math.PI/180),A=B=>(o[B]-r[B])/l*f,S=(B,E)=>y[B][E+1]-y[B][E]>R*Math.max(1e-6,A(B)),I=(B,E)=>{let O=e.closed?(B-1+u)%u:Math.max(0,B-1),L=e.closed?(B+1)%u:Math.min(u-1,B+1);Math.abs(y[O][E]-y[B][E])>g&&(O=B),Math.abs(y[L][E]-y[B][E])>g&&(L=B);let C=Math.max(0,E-1),F=Math.min(l,E+1);C<E&&S(B,C)&&(C=E),F>E&&S(B,E)&&(F=E);let v=M(O,E),G=M(L,E),j=M(B,C),U=M(B,F),H=G[0]-v[0],W=G[1]-v[1],nt=G[2]-v[2],$=U[0]-j[0],Q=U[1]-j[1],X=U[2]-j[2],D=W*X-nt*Q,Z=nt*$-H*X,J=H*Q-W*$,q=Math.hypot(D,Z,J);return q>1e-12?(D/=q,Z/=q,J/=q,Z<0&&(D=-D,Z=-Z,J=-J),[D,Z,J]):[0,1,0]},w=(B,E,O=!1)=>{let L=O&&Math.min(B[1],E[1])-a>=3,C=[B[0],L?B[1]-an:h,B[2]],F=[E[0],L?E[1]-an:h,E[2]],v=E[0]-B[0],G=E[2]-B[2],j=Math.hypot(v,G);if(!(j>1e-12))return;let U=[G/j,0,-v/j];t.tri(B,E,F,U,b,b,d),t.tri(B,F,C,U,b,d,d)},T=.05*xt,k=B=>o[B]-r[B]<T,N=e.closed?u:u-1;for(let B=0;B<N;B++){let E=(B+1)%u;if(k(B)||k(E))continue;if(_(B,E)){let G=(e.startBin+B+1)*n.binStepDeg,j=(Q,X)=>{let D=(r[B]+r[E])/2,Z=(o[B]+o[E])/2,J=D+(Z-D)*X/l,q=Bt(n.centre,J,G);return[q.x*f,y[Q][X],q.y*f]};for(let Q=0;Q<l;Q++){let X=M(B,Q),D=M(B,Q+1),Z=j(B,Q),J=j(B,Q+1),q=I(B,Q),ct=I(B,Q+1);t.triN(X,Z,J,q,q,ct,p),t.triN(X,J,D,q,ct,ct,p);let it=M(E,Q),Y=M(E,Q+1),lt=j(E,Q),St=j(E,Q+1),It=I(E,Q),Rt=I(E,Q+1);t.triN(lt,it,Y,It,It,Rt,p),t.triN(lt,Y,St,It,Rt,Rt,p);let gt=j(B,Q),ft=j(B,Q+1),Gt=j(E,Q+1),On=j(E,Q),cn=ft[0]-gt[0],Zt=ft[2]-gt[2],kn=Math.hypot(cn,Zt);if(kn>1e-12){let ie=[Zt/kn,0,-cn/kn];t.tri(gt,ft,Gt,ie,b),t.tri(gt,Gt,On,ie,b)}}let U=M(B,0),H=M(E,0),W=M(E,l),nt=M(B,l),$=Q=>[Q[0],h,Q[2]];Math.min(U[1],H[1])-a<3&&(t.tri($(U),$(W),$(H),[0,-1,0],x),t.tri($(U),$(nt),$(W),[0,-1,0],x)),w(U,H,!0),w(nt,W,!0);continue}for(let G=0;G<l;G++){let j=I(B,G),U=I(E,G),H=I(E,G+1),W=I(B,G+1);if(S(B,G)||S(E,G)){let D=(ft,Gt)=>{let On=(e.startBin+ft+.5)*n.binStepDeg,cn=r[ft]+(o[ft]-r[ft])*(G+.5)/l,Zt=Bt(n.centre,cn,On);return[Zt.x*f,Gt,Zt.y*f]},Z=M(B,G),J=M(E,G),q=D(B,y[B][G]),ct=D(E,y[E][G]);t.triN(Z,J,ct,j,U,U,p),t.triN(Z,ct,q,j,U,j,p);let it=M(E,G+1),Y=M(B,G+1),lt=D(B,y[B][G+1]),St=D(E,y[E][G+1]);t.triN(lt,St,it,W,H,H,p),t.triN(lt,it,Y,W,H,W,p);let It=ct[0]-q[0],Rt=ct[2]-q[2],gt=Math.hypot(It,Rt);if(gt>1e-12){let ft=[-Rt/gt,0,It/gt];t.tri(q,ct,St,ft,b),t.tri(q,St,lt,ft,b)}continue}let nt=M(B,G),$=M(E,G),Q=M(E,G+1),X=M(B,G+1);t.triN(nt,$,Q,j,U,H,p),t.triN(nt,Q,X,j,H,W,p)}let O=M(B,0),L=M(E,0),C=M(E,l),F=M(B,l),v=G=>[G[0],h,G[2]];Math.min(O[1],L[1])-a<3&&(t.tri(v(O),v(C),v(L),[0,-1,0],x),t.tri(v(O),v(F),v(C),[0,-1,0],x)),w(O,L,!0),w(F,C,!0)}if(!e.closed)for(let B of[0,u-1])for(let E=0;E<l;E++)w(M(B,E),M(B,E+1))}function Qo(t,n,e){let{bottomY:r,colors:o,ao:a}=e,i=new Float64Array(n.binCount).fill(-1/0);for(let l of n.rings)for(let f of l.arcs){let m=new Float64Array(f.binCount),h=new Float64Array(f.binCount);for(let p=0;p<f.binCount;p++){let x=(f.startBin+p)%n.binCount,b=Math.max(0,f.innerR[p]-bt);m[p]=Math.max(b,i[x]+.001),h[p]=Math.max(m[p]+.001,f.outerR[p]+bt)}let y=0;for(let p=0;p<f.binCount;p++){let x=f.topLevelM[p]-r;x>y&&(y=x)}y>=Qs&&sa(t,n,f,m,h,r,o,a,e.standTopNear);for(let p=0;p<f.binCount;p++){let x=(f.startBin+p)%n.binCount;h[p]>i[x]&&(i[x]=h[p])}}if(e.deriveShell===!1||oa(e.shapes,n))return;let s=n.rings[n.rings.length-1],c=Js*xt,u=ta*xt;for(let l of s.arcs){let f=[],m=[];for(let I=0;I<l.binCount;I++){let w=(l.startBin+I+.5)*n.binStepDeg,T=l.outerR[I]+bt+c;f.push(Bt(n.centre,T,w)),m.push(Bt(n.centre,T+u,w))}let h=-1/0;for(let I=0;I<l.binCount;I++)l.topLevelM[I]>h&&(h=l.topLevelM[I]);let y=h+na,p=l.closed?m:[...m,...f.slice().reverse()],x=l.closed?[f.slice().reverse()]:void 0,b=rt(o.shellWall,[.66,.71,.72],.62),d=(I,w,T,k,N)=>{let B=Math.abs(k-h)<1e-6?k-qs:k;Ct(t,I,T,B,e.shapes,o.shellTop,N,{holes:w,portalBase:r,ao:a})||V(t,I,w,()=>B,T,o.shellTop,N,a)},M=Math.max(1,Math.ceil((h-r)/4.5)),g=(h-r)/M,_=new Set,R=e.tierFrontLevels??n.rings.map(I=>{let w=I.arcs.flatMap(T=>Array.from(T.frontLevelM)).filter(Number.isFinite).sort((T,k)=>T-k);return w[Math.floor(w.length/2)]});for(let I of R)Number.isFinite(I)&&I-r>=3&&I<h&&_.add(Math.max(0,Math.min(M-1,Math.floor((I-r)/g))));let A=Math.min(...R.filter(I=>Number.isFinite(I)&&I-r>=3&&I<h));for(let I=0;I<M;I++)r+(I+1)*g<=A-an&&Number.isFinite(A)&&_.add(I);for(let I=0;I<M;I++){let w=r+(h-r)*I/M,T=r+(h-r)*(I+1)/M;_.has(I)&&T-w>=3.2?(d(p,x,w,w+.45,b),ne(t,f,m,l.closed,w+.45,T-.16,o.shellTop,b,a,e.shapes,r)):d(p,x,w,T-.16,b),d(p,x,T-.16,T,K(b,.62))}ne(t,f,m,l.closed,h,y,o.shellTop,b,a,e.shapes,r);let S=8;for(let I=1;I<m.length;I++){if(S+=Math.hypot(m[I].x-m[I-1].x,m[I].y-m[I-1].y)*et,S<8)continue;S=0;let w=m[I],T=m[I-1],k=w.x-T.x,N=w.y-T.y,B=Math.max(1,Math.hypot(k,N)),E=k/B*.16*xt,O=N/B*.16*xt,L=Math.max(1,Math.hypot(w.x-n.centre.x,w.y-n.centre.y)),C=(w.x-n.centre.x)/L*.24*xt,F=(w.y-n.centre.y)/L*.24*xt,v=[{x:w.x-E,y:w.y-O},{x:w.x+E,y:w.y+O},{x:w.x+E+C,y:w.y+O+F},{x:w.x-E+C,y:w.y-O+F}];d(v,void 0,r,h,K(b,1.12))}}}function Jo(t,n,e,r){let o=new Map;for(let s of n){let c=o.get(s.blockId);(!c||s.depth<c.depth)&&o.set(s.blockId,s)}let a=[.68,.72,.72],i=[.48,.55,.57];for(let s of o.values()){if(s.y-r<2.5||s.pts.length<2)continue;let c=s.pts.map(l=>{let f=l.x-e.x,m=l.y-e.y,h=Math.max(1,Math.hypot(f,m));return{x:l.x-f/h*.65/P,y:l.y-m/h*.65/P}}),u=2;for(let l=1;l<c.length;l++){let f=c[l-1],m=c[l],h=m.x-f.x,y=m.y-f.y,p=Math.hypot(h,y);if(p<1e-5||p*P>2)continue;let x=b=>{let d=-y/p*b/P/2,M=h/p*b/P/2;return[{x:f.x+d,y:f.y+M},{x:m.x+d,y:m.y+M},{x:m.x-d,y:m.y-M},{x:f.x-d,y:f.y-M}]};V(t,x(.22),void 0,()=>s.y-.06,s.y-.56,a,a,z);for(let b of[.5,.95])V(t,x(.045),void 0,()=>s.y+b,s.y+b-.045,i,i,z);if(u+=p*P,u>=1.8||l===c.length-1){u=0;let b=.028/P,d=[{x:f.x-b,y:f.y-b},{x:f.x+b,y:f.y-b},{x:f.x+b,y:f.y+b},{x:f.x-b,y:f.y+b}];V(t,d,void 0,()=>s.y+.95-.045,s.y-.06,i,i,z)}}}}function tr(t,n,e,r,o){let a=[.67,.71,.68];for(let i=0;i<n.length;i++){let s=n[i];if(!(s.pts.length<2))for(let c of[0,s.pts.length-1]){let u=s.pts[c],l=s.pts[c===0?1:c-1],f=u.x-l.x,m=u.y-l.y,h=Math.hypot(f,m);if(h<1e-5)continue;f/=h,m/=h;let y=1/0;for(let S=0;S<e.length;S++){let I=e[S],w=e[(S+1)%e.length],T=w.x-I.x,k=w.y-I.y,N=f*k-m*T;if(Math.abs(N)<1e-8)continue;let B=I.x-u.x,E=I.y-u.y,O=(B*k-E*T)/N,L=(B*m-E*f)/N;O>0&&L>=0&&L<=1&&(y=Math.min(y,O))}let p=.3/P,x=y-.04/P;if(!Number.isFinite(y)||y*P>2||x-p<.12/P)continue;let b=.27/P,d=[{x:u.x+f*p-m*b,y:u.y+m*p+f*b},{x:u.x+f*x-m*b,y:u.y+m*x+f*b},{x:u.x+f*x+m*b,y:u.y+m*x-f*b},{x:u.x+f*p+m*b,y:u.y+m*p-f*b}];if(!d.every(S=>ht(e,S.x,S.y)))continue;let M=o?.[i]?.belowY,g=M==null?0:s.y-M,_=!!r&&g>.03&&g<=.65;if(_&&r){let S=(I,w)=>Math.hypot((I.x+w.x)/2-r.x,(I.y+w.y)/2-r.y);S(d[0],d[1])>S(d[3],d[2])&&(d=[d[3],d[2],d[1],d[0]])}let R=_?Math.ceil((g-1e-8)/.2):1,A=(S,I,w)=>({x:S.x+(I.x-S.x)*w,y:S.y+(I.y-S.y)*w});for(let S=0;S<R;S++){let I=S/R,w=(S+1)/R,T=[A(d[0],d[3],I),A(d[1],d[2],I),A(d[1],d[2],w),A(d[0],d[3],w)],k=s.y+.008-(_?g*(1-w):0);if(V(t,T,void 0,()=>k,k-(_?g/R+.1:.16),a,[.43,.47,.46],z),!_)continue;let N=Math.hypot(T[3].x-T[0].x,T[3].y-T[0].y)*P,B=Math.min(.04/N,.25),E=A(T[0],T[3],B),O=A(T[1],T[2],B),L=F=>[F.x*P,k+.004,F.y*P],C=[.66,.59,.39];t.tri(L(T[0]),L(T[1]),L(O),[0,1,0],C),t.tri(L(T[0]),L(O),L(E),[0,1,0],C)}}}}function nr(t,n,e,r,o,a,i,s,c=!1){if(!n.outline||n.outline.length<3)return;let u=e.baseHeightM,l=e.objects.filter(d=>d.type==="shape"&&(d.role==="entrance"||d.role==="exit")),f=ke(r,s.tierTop);if(!o)return;let m=d=>o.deckAt(d.x,d.y),h=qe(n,i),y=h[0]??n.outline;if(o.rowLevels.length>=2){let d=xn(o.rowLevels),M=$e(Ye(o.rowLevels,e.focal,d),h);for(let _ of M){let R=Math.max(u,_.topY-er);for(let A of a.subtract(_.outline,R))qo(t,A,_.holes,R,u,s.tierTop,s.tierWall,l,!c)}M.length||V(t,y,n.holes,()=>o.landingY,u,f,s.tierWall,z);let g={tread:[f[0]*z.top,f[1]*z.top,f[2]*z.top],riser:[f[0]*.72,f[1]*.72,f[2]*.72]};for(let _ of h.length?h:[y])ze(t,o.rowLevels,e.focal,o.landingY,g,_,d);Jo(t,o.rowLevels,e.focal,u),tr(t,o.rowLevels,n.outline,e.focal,d);return}let p=o.flat?1/0:xo,x=d=>o.normalAt(d.x,d.y),b=o.flat?o.landingY:void 0;for(let d of a.subtract(y,b))V(t,d,n.holes,m,u,f,s.tierWall,z,p,x)}function aa(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 u=n[i];if(u.kind==="booth")continue;let l=o.get(s);l||(l=new Map,o.set(s,l));let f=u.rowId||`__seat-${i}`,m=l.get(f);m||(m={pts:[],levelM:0,n:0},l.set(f,m)),m.pts.push({x:u.x,y:u.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 u=s.rowLevels.filter(l=>!l.patch).map(l=>({pts:l.pts,levelM:l.y}));u.length>=2&&a.push({sectionId:i.id,rows:u});continue}let c=o.get(i.id);c&&a.push({sectionId:i.id,rows:[...c.values()].map(u=>({pts:u.pts,levelM:u.levelM/u.n}))})}return a}function ca(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 er=.02;function la(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 l of r.outline)l.x<a&&(a=l.x),l.x>i&&(i=l.x),l.y<s&&(s=l.y),l.y>c&&(c=l.y);let u=o.landingY;for(let l of o.rowLevels)u=Math.min(u,l.y-er);return[{outline:r.outline,holes:r.holes,surface:o,floorTop:u,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(!At(c,s.outline,s.holes)&&ca(c,s.outline)>a)continue;let u=Math.min(s.surface.deckAt(r,o),s.floorTop);(i===null||u<i)&&(i=u)}return i}}var ua=3,fa=.4;function or(t,n,e,r,o,a,i=!0){let s=aa(n,e,r);if(s.length<ua)return;let c=Se(s,n.focal);if(!c)return;let u=Math.max(0,...c.rings.map(l=>l.arcs.reduce((f,m)=>f+m.binCount,0)))/c.binCount;t.setMaterial(5),Qo(t,c,{bottomY:n.baseHeightM,tierFrontLevels:s.map(l=>Math.min(...l.rows.map(f=>f.levelM))),colors:{bandTop:K(o.tierTop,.8),bandWall:o.tierWall,shellTop:a??K(o.tierWall,1.15),shellWall:a??o.tierWall},ao:z,shapes:n.objects.filter(l=>l.type==="shape"),deriveShell:i&&u>=fa,standTopNear:la(n,r)}),t.setMaterial(0)}function rr(t){let{doc:n,units:e,seats:r,surfaces:o,solids:a,hintedSeatFloor:i,seatFloor:s}=t,c=[];{let u=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]))),y=m*3,p=u[h];p.minX=Math.min(p.minX,a.position[y]),p.minY=Math.min(p.minY,a.position[y+1]),p.minZ=Math.min(p.minZ,a.position[y+2]),p.maxX=Math.max(p.maxX,a.position[y]),p.maxY=Math.max(p.maxY,a.position[y+1]),p.maxZ=Math.max(p.maxZ,a.position[y+2])}let l=new Map;for(let m=0;m<e.length;m++)for(let h of e[m].objects)h.type==="section"&&l.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],y=(h!==null?l.get(h):void 0)??i[m];if(y===void 0)continue;let p=f[y],x=r[m];p.n++,x.x<p.minX&&(p.minX=x.x),x.y<p.minY&&(p.minY=x.y),x.x>p.maxX&&(p.maxX=x.x),x.y>p.maxY&&(p.maxY=x.y);let b=o.seatDeckY(m);p.sumX+=x.x*P,p.sumDeck+=b,p.sumZ+=x.y*P,p.minDeck=Math.min(p.minDeck,b),p.maxDeck=Math.max(p.maxDeck,b+1.6),s[m]=y}for(let m=0;m<e.length;m++){let h=f[m],y=n.floors?.[m],p=u[m],x=Math.min(h.n?h.minX*P:e[m].focal.x*P-1,Number.isFinite(p.minX)?p.minX:1/0),b=Math.max(h.n?h.maxX*P:e[m].focal.x*P+1,Number.isFinite(p.maxX)?p.maxX:-1/0),d=Math.min(h.n?h.minY*P:e[m].focal.y*P-1,Number.isFinite(p.minZ)?p.minZ:1/0),M=Math.max(h.n?h.maxY*P:e[m].focal.y*P+1,Number.isFinite(p.maxZ)?p.maxZ:-1/0),g=Math.min(h.n?Math.min(e[m].baseHeightM,h.minDeck):e[m].baseHeightM,Number.isFinite(p.minY)?p.minY:1/0),_=Math.max(h.n?Math.max(h.maxDeck,g+.5):g+.5,Number.isFinite(p.maxY)?p.maxY:-1/0),R=[h.n?h.sumX/h.n:(x+b)/2,h.n?h.sumDeck/h.n:(g+_)/2,h.n?h.sumZ/h.n:(d+M)/2],A=Math.max(1,.5*Math.hypot(b-x,_-g,M-d));c.push({index:m,id:y?.id??`floor-${m}`,label:y?.name??(e.length>1?`Floor ${m+1}`:"Venue"),seatCount:h.n,center:R,radius:A,box:{min:[x,g,d],max:[b,_,M]},focalWorld:[e[m].focal.x*P,e[m].baseHeightM+1.5,e[m].focal.y*P]})}}return c}function oe(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 u of c.outline)i(u.x,u.y);else if(c.type==="shape"&&c.points)for(let u of c.points)i(u.x,u.y);else if(c.type==="gaArea")for(let u of c.points)i(u.x,u.y);else if(c.type==="booth"){let u=Et(c);if(u)for(let l of u)i(l.x,l.y)}else if(c.type==="table"){let u=Bn(c);if(u)for(let l of u)i(l.x,l.y)}else if(c.type==="decorImage"){let u=Tn(c);if(u)for(let l of u)i(l.x,l.y)}return Number.isFinite(e)||(e=-100,r=-100,o=100,a=100),{minX:e,minY:r,maxX:o,maxY:a}}function ur(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(...st(m)??m.points??[]):m.type==="gaArea"?s.push(...m.points):m.type==="booth"?s.push(...Et(m)??[]):m.type==="table"?s.push(...Bn(m)??[]):m.type==="decorImage"&&s.push(...Tn(m)??[]);if(ar(t,n[0],e,a)||lr(t,n[0],e,s,a))return!1;if(i&&sr(t,n[0].baseHeightM,s,a,i))return!0;let c=en(s),u=(o.minX+o.maxX)/2,l=(o.minY+o.maxY)/2,f=c.length>=3?c.map(m=>{let h=m.x-u,y=m.y-l,p=Math.max(1,Math.hypot(h,y));return{x:m.x+h/p*80,y:m.y+y/p*80}}):Jt(o.minX-28,o.minY-28,o.maxX-o.minX+56,o.maxY-o.minY+56);return V(t,f,void 0,()=>-.04,-.22,a.ground,a.ground,z),!1}else{let s=n.reduce((x,b)=>b.baseHeightM<x.baseHeightM?b:x);t.setFloor(s.index);let c={...s,objects:n.flatMap(x=>x.objects)},u=e.map(x=>({x:x.x,y:x.y}));for(let x of c.objects)x.type==="section"&&u.push(...x.outline);if(ar(t,c,e,a)||lr(t,c,e,u,a))return!1;if(i&&sr(t,s.baseHeightM,u,a,i))return!0;let l=e.filter((x,b)=>r[b]===s.index),f=oe([s],l),m=Math.hypot(f.maxX-f.minX,f.maxY-f.minY),h=Math.max(28,Math.min(80,m*.04)),y=Jt(f.minX-h,f.minY-h,f.maxX-f.minX+h*2,f.maxY-f.minY+h*2),p=s.baseHeightM-.03;return V(t,y,void 0,()=>p,p-.22,a.ground,a.ground,z),!1}}function re(t,n,e,r){let{cx:o,cz:a,radius:i}=e,s=1/0,c=1/0,u=1/0,l=-1/0,f=-1/0,m=-1/0,h=(x,b,d)=>{s=Math.min(s,x),l=Math.max(l,x),c=Math.min(c,b),f=Math.max(f,b),u=Math.min(u,d),m=Math.max(m,d)};for(let x=0;x<t.position.length;x+=3){let b=x/3;r&&b>=r[0]&&b<r[1]||h(t.position[x],t.position[x+1],t.position[x+2])}for(let x=0;x<n.count;x++){let b=x*3,d=n.iPosition[b],M=n.iPosition[b+1],g=n.iPosition[b+2],_=Math.max(.35,n.iMaxRadius[x]??.35);h(d-_,M,g-_),h(d+_,M+1.6,g+_)}Number.isFinite(s)||(s=o-i,l=o+i,c=0,f=i*.16,u=a-i,m=a+i);let y=[(s+l)/2,(c+f)/2,(u+m)/2],p=Math.max(1,.5*Math.hypot(l-s,f-c,m-u));return{center:y,radius:p,minY:c,maxY:f}}function fr(t,n,e,r,o,a){let i=1/0,s=1/0,c=-1/0,u=-1/0;for(let g=0;g<t.count;g++){let _=g*3,R=t.iPosition[_],A=t.iPosition[_+2];R<i&&(i=R),R>c&&(c=R),A<s&&(s=A),A>u&&(u=A)}for(let g of n)i=Math.min(i,g.cx-g.halfX),c=Math.max(c,g.cx+g.halfX),s=Math.min(s,g.cz-g.halfZ),u=Math.max(u,g.cz+g.halfZ);let l=e.minX*P,f=e.maxX*P,m=e.minY*P,h=e.maxY*P,y=l,p=f,x=m,b=h;if(Number.isFinite(i)){let g=Math.max(2,.06*Math.hypot(c-i,u-s));y=Math.max(l,i-g),p=Math.min(f,c+g),x=Math.max(m,s-g),b=Math.min(h,u+g)}let d=Math.min(0,r),M=Math.max(o,a*.05);return{min:[y,d,x],max:[p,M,b]}}var ir=12,ma=.6,ha=40;function sr(t,n,e,r,o){let a=en([...e]);if(a.length<3)return!1;let i=1/0,s=1/0,c=-1/0,u=-1/0;for(let g of a)i=Math.min(i,g.x),c=Math.max(c,g.x),s=Math.min(s,g.y),u=Math.max(u,g.y);let l=Math.hypot(c-i,u-s)*P,f=Mt(a,ir/P,1.2),m=Math.max(ha,l*ma),h=Mt(a,(ir+m)/P,1.2);if(f.length!==h.length)return!1;let y=rt(r.ground,[.78,.76,.72],.35),p=rt(r.ground,[.56,.62,.52],.3);V(t,f,void 0,()=>n-.04,n-.22,y,y,z);let x=n-.05,b=f.map(g=>[g.x*P,x,g.y*P]),d=h.map(g=>[g.x*P,x,g.y*P]),M=[0,1,0];for(let g=0;g<b.length;g++){let _=(g+1)%b.length;t.tri(b[g],d[_],d[g],M,p,o,o),t.tri(b[g],b[_],d[_],M,p,p,o)}return!0}function ar(t,n,e,r){let o=Mn(n,e);if(!o)return!1;let a=n.baseHeightM,i=rt(r.ground,[.62,.55,.47],.4);return V(t,o,void 0,()=>a-.04,a-.22,i,i,z),!0}var ya=3e3,pa=20,cr=1.5,da=1.2,xa=.25;function lr(t,n,e,r,o){if(!e.length||e.length>ya||r.length<3)return!1;for(let I of n.objects){if(I.type==="shape"&&ue(I.stageKind))return!1;if(I.type==="section"){let{height:w}=Xt(I,{floorBaseHeightM:n.baseHeightM});if(w-n.baseHeightM>pa)return!1}}let a=0,i=0;for(let I of r)a+=I.x,i+=I.y;a/=r.length,i/=r.length;let s=0,c=0,u=0;for(let I of r){let w=I.x-a,T=I.y-i;s+=w*w,c+=T*T,u+=w*T}let l=.5*Math.atan2(2*u,s-c),f=Math.cos(l),m=Math.sin(l),h=-m,y=f,p=1/0,x=-1/0,b=1/0,d=-1/0;for(let I of r){let w=(I.x-a)*f+(I.y-i)*m,T=(I.x-a)*h+(I.y-i)*y;p=Math.min(p,w),x=Math.max(x,w),b=Math.min(b,T),d=Math.max(d,T)}let M=I=>[[p-I,b-I],[x+I,b-I],[x+I,d+I],[p-I,d+I]].map(([w,T])=>({x:a+f*w+h*T,y:i+m*w+y*T})),g=M(cr/P),_=M((cr+xa)/P),R=n.baseHeightM,A=rt(o.ground,[.62,.55,.47],.4),S=rt(o.ground,[.86,.86,.84],.55);return V(t,_,void 0,()=>R-.04,R-.22,A,A,z),V(t,_,[g.slice().reverse()],()=>R+da,R-.04,rt(S,[1,1,1],.2),S,z),!0}function mr(t,n,e){let r=()=>({byObjectId:new Map,elements:[]});if(!n||!t)return r();let o=ae(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]})),u=[];for(let f of o.value.overlay.productionElements??[]){let m=a.get(f.objectId),h=m?st(m.shape):null,y=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(y)||y<-10||y>100)return r();i.add(f.id),s.add(f.objectId);let p=h.map(S=>S.x*P),x=h.map(S=>S.y*P),b=m.unit.baseHeightM+y,d=Math.min(...p),M=Math.max(...p),g=Math.min(...x),_=Math.max(...x),R,A=c.get(f.id)??f.contentImageUrl;if(f.kind==="screen"&&A&&(R=fo(h,b,b+f.heightM,m.unit.focal),!R))if(M-d>=_-g){let S=Math.abs(g-m.unit.focal.y*P)<=Math.abs(_-m.unit.focal.y*P)?g-.006:_+.006;R=[[d,b,S],[M,b,S],[d,b+f.heightM,S],[M,b+f.heightM,S]]}else{let S=Math.abs(d-m.unit.focal.x*P)<=Math.abs(M-m.unit.focal.x*P)?d-.006:M+.006;R=[[S,b,g],[S,b,_],[S,b+f.heightM,g],[S,b+f.heightM,_]]}u.push({id:f.id,objectId:f.objectId,kind:f.kind,floorIndex:m.unit.index,baseY:b,topY:b+f.heightM,bounds:{min:[d,b,g],max:[M,b+f.heightM,_]},occlusion:f.occlusion,...A?{contentImageUrl:A}:{},...R?{contentPlane:R}:{}})}let l=u.sort((f,m)=>f.id.localeCompare(m.id));return{byObjectId:new Map(l.map(f=>[f.objectId,f])),elements:l}}var hr=[.13,.14,.17],Kt=[.4,.43,.47],ba=.18,ga=.02,Ma=2.4,Pa=1500,Sa=240;function yr(t,n,e,r){let o=n.stageKind??"";if(Ht(o)||o==="round"||!r.length)return;let a=st(n);if(!a||a.length<3)return;let i={x:a.reduce((E,O)=>E+O.x,0)/a.length,y:a.reduce((E,O)=>E+O.y,0)/a.length},s=0,c=0,u=new Set;for(let E of r)s+=E.x,c+=E.y,u.add(Math.floor(Math.atan2(E.y-i.y,E.x-i.x)*180/Math.PI/10));if(u.size*10>Sa)return;let l=i.x-s/r.length,f=i.y-c/r.length,m=Math.hypot(l,f);if(m<1e-6)return;let h=l/m,y=f/m,p=-y,x=h,b=-1/0,d=1/0,M=1/0,g=-1/0;for(let E of a){let O=(E.x-i.x)*h+(E.y-i.y)*y,L=(E.x-i.x)*p+(E.y-i.y)*x;b=Math.max(b,O),d=Math.min(d,O),M=Math.min(M,L),g=Math.max(g,L)}let _=(g-M)*P,R=(b-d)*P;if(_<3||R<1.5||_*R>Pa)return;let A=ba/P,S=(E,O)=>({x:i.x+h*E+p*O,y:i.y+y*E+x*O}),I=(E,O,L,C)=>[S(E,L),S(E,C),S(O,C),S(O,L)],w=e+Math.max(3.5,Math.min(8,_*.35)),T=e+Math.min(Ma,w-e-1),k=.2/P,N=d+Math.min(R*.25,1.5)/P,B=ga/P;V(t,I(b-2*A+B,b-A-B,M+A+k,g-A-k),void 0,()=>T,e,hr,hr,z);for(let[E,O]of[[M+A,M+A+k],[g-A-k,g-A]])V(t,I(b-2*A,b-A,E,O),void 0,()=>w+.3,e,Kt,Kt,z),V(t,I(N+k,b-2*A,E,O),void 0,()=>w+.3,w,Kt,Kt,z);V(t,I(N,N+k,M+A,g-A),void 0,()=>w+.3,w,Kt,Kt,z)}function dt(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function pt(t){return Array.isArray(t)?t:[]}function Ia(t){let n=[t];for(;n.length;){let e=n.pop();if(Array.isArray(e)){n.push(...e);continue}if(!dt(e))continue;let r=dt(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 Cn(t,n){return!Array.isArray(t)||t.length!==n||!t.every(e=>typeof e=="number"&&Number.isFinite(e))?null:t}function Ra(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Aa(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 _a(t){let n=Cn(t.matrix,16);if(n)return n;if(t.matrix!==void 0)return null;let e=t.translation===void 0?[0,0,0]:Cn(t.translation,3),r=t.rotation===void 0?[0,0,0,1]:Cn(t.rotation,4),o=t.scale===void 0?[1,1,1]:Cn(t.scale,3);if(!e||!r||!o)return null;let[a,i,s,c]=r,u=Math.hypot(a,i,s,c);if(!(u>1e-8))return null;let l=a/u,f=i/u,m=s/u,h=c/u,y=l+l,p=f+f,x=m+m,b=l*y,d=l*p,M=l*x,g=f*p,_=f*x,R=m*x,A=h*y,S=h*p,I=h*x;return[(1-(g+R))*o[0],(d+I)*o[0],(M-S)*o[0],0,(d-I)*o[1],(1-(b+R))*o[1],(_+A)*o[1],0,(M+S)*o[2],(_-A)*o[2],(1-(b+g))*o[2],0,e[0],e[1],e[2],1]}function wa(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 Ea(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],u=t[10],l=a*u-i*c,f=i*s-o*u,m=o*c-a*s,h=n*l+e*f+r*m;if(Math.abs(h)<1e-12)return null;let y=1/h;return[l*y,f*y,m*y,(r*c-e*u)*y,(n*u-r*s)*y,(e*s-n*c)*y,(e*i-r*a)*y,(r*o-n*i)*y,(n*a-e*o)*y]}function pr(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 Ba(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(!dt(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 Ta(t){return t===5120||t===5121?1:t===5122||t===5123?2:t===5125||t===5126?4:0}function Ca(t){return t==="SCALAR"?1:t==="VEC2"?2:t==="VEC3"?3:t==="VEC4"?4:0}function Oa(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 ka(t){let n=t instanceof Uint8Array?t:new Uint8Array(t),e=Ba(n);if(!e)return{ok:!1,issue:"invalid_glb"};let{json:r,bin:o}=e;if(!dt(r.asset)||r.asset.version!=="2.0")return{ok:!1,issue:"unsupported_glb"};let a=pt(r.extensionsUsed).filter(g=>typeof g=="string");if(a.includes("KHR_draco_mesh_compression")||Ia(r))return{ok:!1,issue:"draco_not_allowed"};if(a.length||pt(r.extensionsRequired).length)return{ok:!1,issue:"unsupported_glb"};if(pt(r.images).length||pt(r.textures).length)return{ok:!1,issue:"external_resource"};let i=pt(r.buffers);if(i.length!==1||!dt(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=pt(r.accessors),c=pt(r.bufferViews),u=pt(r.meshes),l=pt(r.nodes),f=pt(r.scenes),m=typeof r.scene=="number"?r.scene:0;if(!dt(f[m]))return{ok:!1,issue:"unsupported_glb"};let h=new DataView(o.buffer,o.byteOffset,o.byteLength),y=(g,_,R)=>{if(typeof g!="number"||!Number.isInteger(g)||!dt(s[g]))return null;let A=s[g];if(A.type!==_||A.sparse!==void 0||A.normalized===!0||typeof A.count!="number"||!Number.isInteger(A.count)||A.count<1||typeof A.componentType!="number"||!R.includes(A.componentType)||typeof A.bufferView!="number")return null;let S=c[A.bufferView];if(!dt(S)||S.buffer!==0||typeof S.byteLength!="number"||!Number.isInteger(S.byteLength)||S.byteLength<0)return null;let I=Ca(A.type),w=Ta(A.componentType),T=typeof S.byteStride=="number"?S.byteStride:I*w,k=typeof S.byteOffset=="number"?S.byteOffset:0,N=typeof A.byteOffset=="number"?A.byteOffset:0,B=k+N,E=N+(A.count-1)*T+I*w;if(!Number.isInteger(T)||!Number.isInteger(k)||!Number.isInteger(N)||T<I*w||k<0||N<0||k+S.byteLength>o.byteLength||E>S.byteLength)return null;let O=[];for(let L=0;L<A.count;L++){let C=[];for(let F=0;F<I;F++){let v=Oa(h,B+L*T+F*w,A.componentType);if(!Number.isFinite(v))return null;C.push(v)}O.push(C)}return O},p=[],x=[],b=0,d=new Set,M=(g,_)=>{if(typeof g!="number"||!Number.isInteger(g)||!dt(l[g])||d.has(g))return!1;d.add(g);let R=l[g],A=_a(R);if(!A)return!1;let S=Aa(_,A),I=Ea(S);if(!I)return!1;if(R.mesh!==void 0){if(typeof R.mesh!="number")return!1;let w=u[R.mesh];if(!dt(w))return!1;for(let T of pt(w.primitives)){if(!dt(T)||T.mode!==void 0&&T.mode!==4||!dt(T.attributes))return!1;let k=y(T.attributes.POSITION,"VEC3",[5126]),N=T.attributes.NORMAL===void 0?null:y(T.attributes.NORMAL,"VEC3",[5126]);if(!k||T.attributes.NORMAL!==void 0&&!N)return!1;let B=k.length;if(T.indices!==void 0){let O=typeof T.indices=="number"?s[T.indices]:null;B=dt(O)?O.count:void 0}if(typeof B!="number"||!Number.isInteger(B)||B%3!==0||(b+=B/3,b>1e5))return!1;let E=T.indices===void 0?k.map((O,L)=>[L]):y(T.indices,"SCALAR",[5121,5123,5125]);if(!E||E.length%3!==0||E.length!==B)return!1;for(let O=0;O<E.length;O+=3){let L=[E[O][0],E[O+1][0],E[O+2][0]];if(L.some(v=>!Number.isInteger(v)||v<0||v>=k.length))return!1;let C=L.map(v=>wa(S,...k[v])),F=null;if(!N){let v=C[1][0]-C[0][0],G=C[1][1]-C[0][1],j=C[1][2]-C[0][2],U=C[2][0]-C[0][0],H=C[2][1]-C[0][1],W=C[2][2]-C[0][2];F=pr([1,0,0,0,1,0,0,0,1],G*W-j*H,j*U-v*W,v*H-G*U)}for(let v=0;v<3;v++)p.push(...C[v]),x.push(...N?pr(I,...N[L[v]]):F)}}}for(let w of pt(R.children))if(!M(w,S))return!1;return d.delete(g),!0};for(let g of pt(f[m].nodes))if(!M(g,Ra()))return{ok:!1,issue:b>1e5?"triangle_limit":"unsupported_glb"};return!b||p.length!==b*9||x.length!==p.length?{ok:!1,issue:"unsupported_glb"}:{ok:!0,triangleCount:b,position:new Float32Array(p),normal:new Float32Array(x)}}function dr(t){try{return ka(t)}catch{return{ok:!1,issue:"invalid_glb"}}}function lm(t){let{doc:n}=t,e=Uo(n.theme),r=e.structure,o=Ze(n,t.eventConfigurationId??n.eventConfigurationId),a=mr(t.eventConfigurationId,t.eventConfiguration,o),i=t.seats,s=new yn,c=null;if(t.registeredShellGlb){let X=dr(t.registeredShellGlb);if(X.ok){let D=X.position.length/3,Z=new Float32Array(X.position.length),J=e.materials.shell??r.tierWall;for(let q=0;q<D;q++){let ct=X.normal[q*3+1],it=ct<-.25?.4:.62+.38*Math.max(0,ct);Z[q*3]=J[0]*it,Z[q*3+1]=J[1]*it,Z[q*3+2]=J[2]*it}c={position:X.position,normal:X.normal,color:Z,floor:new Float32Array(D).fill(-2),material:new Float32Array(D),count:D}}}let u=new Map;for(let X of o)for(let D of X.objects)u.set(D.id,X.index),D.type==="section"&&u.set(D.logicalSectionId??D.id,X.index);let l=i.map(X=>u.get(X.sectionId??"")??u.get(X.rowId??"")??0),f=oe(o,i),m=s.vertexCount,y=ur(s,o,i,l,f,r,rt(e.background.top,e.background.bottom,.5))?s.vertexCount:m,p=Fe(n,i),x=new Map,b=new Map;for(let X of n.categories??[])x.set(X.key,X.color),X.seatGlyph&&b.set(X.key,X.seatGlyph);let d=[],M=bo(o,i,l),g=new Map;i.forEach((X,D)=>{let Z=M.seatDeckY(D);Number.isFinite(Z)&&g.set(X.rowId,Math.min(g.get(X.rowId)??1/0,Z))});let _=new Float32Array(i.length),R=[],A=new Map((n.floors??[]).map((X,D)=>[X.id,D])),S=o.map(()=>[]);for(let X of i){let D=X.floorId?A.get(X.floorId)??0:0;S[Math.min(D,S.length-1)]?.push(X)}let I=(X,D)=>{if(!D||D.length<3)return!1;let Z=Math.min(...D.map(it=>it.x)),J=Math.max(...D.map(it=>it.x)),q=Math.min(...D.map(it=>it.y)),ct=Math.max(...D.map(it=>it.y));for(let it=0;it<X;it++)for(let Y of S[it])if(!(Y.x<Z||Y.x>J||Y.y<q||Y.y>ct)&&At(Y,D,void 0))return!0;return!1},w=null,T=X=>o.length===1?i:i.filter((D,Z)=>l[Z]===X),k=(X,D)=>{let Z=Et(X);if(!Z)return!1;let J=1/0,q=1/0,ct=-1/0,it=-1/0;for(let Y of Z)J=Math.min(J,Y.x),ct=Math.max(ct,Y.x),q=Math.min(q,Y.y),it=Math.max(it,Y.y);return i.some((Y,lt)=>Y.kind!=="booth"&&(o.length===1||l[lt]===D)&&Y.x>J&&Y.x<ct&&Y.y>q&&Y.y<it&&ht(Z,Y.x,Y.y))};for(let X=0;X<o.length;X++){let D=o[X];s.setFloor(X);let Z=new bn,J=[],q=D.objects.filter(Y=>Y.type==="shape"&&(Y.role==="entrance"||Y.role==="exit")),ct=D.objects.filter(Y=>Y.type==="section"&&!!Y.outline&&Y.outline.length>=3),it=zo(D.objects.filter(Y=>Y.type==="booth"),D.focal);for(let Y of D.objects)if(Y.type==="section"){let lt=s.vertexCount;nr(s,Y,D,ve(Y,p),M.bySection.get(Y.id),Z,ct,r,X>0&&I(X,Y.outline));let St=s.vertexCount-lt;St>0&&R.push({sectionId:Y.id,start:lt,count:St})}else if(Y.type==="shape"){let lt=a.byObjectId.get(Y.id),St=d.length;s.setMaterial((lt?.kind??Y.role)==="screen"?1:0);let It=Y.role==="stage"&&!lt?Vo(Y,T(X)):Y,Rt=Qe(It,J);if(Fo(s,It,D.baseHeightM+Rt.supportOffsetM,Rt.topOffsetM-Rt.supportOffsetM,r,D.focal,d,lt,q),s.setMaterial(0),Y.role==="stage"&&!lt&&d.length>St&&(w??X)===X){w=X;let gt=n.floors?.[X]?.id,ft=o.length>1&>?i.filter(Gt=>Gt.floorId===gt):i;yr(s,It,d[d.length-1].y,ft)}}else Y.type==="gaArea"?Lo(s,Y,D.baseHeightM,ot(x.get(Y.categoryKey)),r):Y.type==="booth"?Co(s,Y,D.baseHeightM,ot(x.get(Y.categoryKey)),r,it.get(Y.id)??D.focal,k(Y,X)):Y.type==="table"?ko(s,Y,Math.max(D.baseHeightM,g.get(Y.id)??D.baseHeightM),ot(Y.fill??n.theme?.decorFill??"#232c40"),r,!!(Y.fill??n.theme?.decorFill)):Y.type==="decorImage"&&vo(s,Y,D.baseHeightM,r);or(s,D,i,M,r,e.materials.shell,!c)}let N=o.length>1?{x:o.reduce((X,D)=>X+D.focal.x,0)/o.length,y:o.reduce((X,D)=>X+D.focal.y,0)/o.length}:n.focalPoint??{x:(f.minX+f.maxX)/2,y:(f.minY+f.maxY)/2},B=we(c?[s.build(),c]:[s.build()]),E=Oe(i,t.initialState,M,_,x,b),O=Go({doc:n,units:o,seats:i,surfaces:M,focal:N}),{labels:L,sections:C,rows:F}=Xo({doc:n,units:o,seats:i,surfaces:M,seatData:E,hintedSeatFloor:l,zones:O,focal:N}),v=new Map(C.map((X,D)=>[X.id,D]));M.seatOwner.forEach((X,D)=>{E.iSection[D]=X?v.get(X)??-1:-1});let G=rr({doc:n,units:o,seats:i,surfaces:M,solids:B,hintedSeatFloor:l,seatFloor:_});Ho(L,G),E.iYaw=Ce(E.iPosition,i.length,X=>i[X].rowId,X=>{let D=o[_[X]]?.focal??N;return[D.x*P,D.y*P]});let j=(f.minX+f.maxX)/2*P,U=(f.minY+f.maxY)/2*P,H=.5*Math.hypot((f.maxX-f.minX)*P,(f.maxY-f.minY)*P)||10,W=re(B,E,{cx:j,cz:U,radius:H},[m,y]),nt=re(B,E,{cx:j,cz:U,radius:H}),$=fr(E,d,f,W.minY,W.maxY,H);return{sharedAisles:jo(o.flatMap(X=>X.objects.flatMap(D=>{if(D.type!=="section")return[];let Z=M.bySection.get(D.id);return Z?[{sectionId:D.id,floorIndex:X.index,rows:Z.rowLevels}]:[]}))),solids:B,sectionSolidRanges:R,seats:E,seatSectionIds:M.seatOwner,bounds:{center:[($.min[0]+$.max[0])/2,($.min[1]+$.max[1])/2,($.min[2]+$.max[2])/2],radius:H,groundY:0,box:$},renderBounds:{center:W.center,radius:W.radius},clipBounds:{center:nt.center,radius:nt.radius},stateColorLUT:Yo(e,tn),theme:e,seatCount:i.length,focalWorld:[N.x*P,1.5,N.y*P],zones:O,stages:d,productionElements:a.elements,sections:C,rows:F,labels:L,floors:G}}function Fa(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])),u=h=>h.map(y=>y.type==="shape"&&c.has(y.id)?{...y,role:c.get(y.id)}:y),l=t.floors?.map(h=>({...h,objects:u(h.objects)})),f=new Float64Array(n.length).fill(Number.NaN),m=new Float64Array(n.length*2).fill(Number.NaN);return n.forEach((h,y)=>{h.eyeHeightM!==void 0&&(f[y]=h.eyeHeightM),h.focalPoint&&(m[y*2]=h.focalPoint.x,m[y*2+1]=h.focalPoint.y)}),{doc:{...t,objects:l?.[0]?.objects??u(t.objects),...l?{floors:l}:{}},report:r,eyeHeightM:f,focal:m}}let a=new Map(fn(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,u)=>{let l=a.get(c.id)??c;l.eyeHeightM!==void 0&&(i[u]=l.eyeHeightM),l.focalPoint&&(s[u*2]=l.focalPoint.x,s[u*2+1]=l.focalPoint.y)}),{doc:e,report:r,eyeHeightM:i,focal:s}}function va(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 hm(t){let n=t.estimate===!1?null:Fa(t.doc,t.seats);return n?{input:{...t,doc:n.doc,seats:va(t.seats,n)},estimate:n}:{input:t}}export{Wa as a,Tr as b,Cr as c,Be as d,Or as e,za as f,tn as g,vn as h,Ua as i,Dn as j,P as k,dn as l,nc as m,ec as n,uo as o,jc as p,Uc as q,Yc as r,Wc as s,zc as t,Vc as u,Vn as v,Kc as w,Zc as x,qc as y,$c as z,Qc as A,Ds as B,lm as C,Fa as D,va as E,hm as F};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as D}from"./chunk-M5VINTGE.js";import{B as v,Ca as w,Ea as C,Fa as S,Ha as j,Ia as A,M}from"./chunk-VAI2VDQR.js";function g(a){return a.floors?.length?a.floors.flatMap(o=>o.objects):a.objects}function K(a){return g(a).reduce((o,n)=>n.type==="row"?o+w(n):n.type==="table"?o+j(n):n.type==="gaArea"?o+Math.max(0,Math.floor(n.capacity)):n.type==="booth"?o+1:o,0)}function Q(a){let o={};for(let e of a.categories??[])o[e.key]=0;let n=(e,c)=>{c>0&&(o[e]=(o[e]??0)+c)};for(let e of g(a))if(e.type==="row")for(let c of C(e))n(c.categoryKey,1);else if(e.type==="table")if(e.bookAsWhole||e.variableOccupancy)n(e.categoryKey,Math.max(0,Math.round(e.seatCount)));else for(let c of A(e))n(c.categoryKey,1);else e.type==="gaArea"?n(e.categoryKey,Math.max(0,Math.floor(e.capacity))):e.type==="booth"&&n(e.categoryKey,1);return o}function P(a){if(!a.template)return null;let o=g(a),n=o.filter(s=>s.type==="row"||s.type==="table"||s.type==="gaArea");if(!n.length)return null;let c=o.filter(s=>s.type==="booth").length+n.reduce((s,l)=>s+(l.type==="table"?2:1),0),y=K(a),h=Math.max(c+1,Math.min(5e4,y*4)),d=[.5,1,1.5,2].map(s=>M(Math.round(y*s),c,h));return{family:a.template.family,display:a.template.family.replace(/-/g," ").replace(/\b\w/g,s=>s.toUpperCase()),min:c,max:h,presets:["S","M","L","XL"].map((s,l)=>({size:s,seats:d[l]}))}}function O(a){let o=C(a);return o.length?v(o):{...a.origin}}function U(a,o){let n=P(a);if(!n)return structuredClone(a);let e=structuredClone(a),c=g(e),y=c.filter(t=>t.type==="row"||t.type==="table"||t.type==="gaArea"),h=c.filter(t=>t.type==="booth").length,d=Math.max(n.min,Math.min(n.max,Math.round(o))),s=d-h,l=y.map((t,r)=>{let u=t.type==="gaArea"?Math.max(0,Math.floor(t.capacity)):t.seatCount,p=t.type==="table"?2:1;return{object:t,index:r,current:u,minimum:p,value:p,fraction:0}}),R=l.reduce((t,r)=>t+r.minimum,0),b=Math.max(0,s-R),z=l.reduce((t,r)=>t+Math.max(1,r.current-r.minimum),0);for(let t of l){let r=b*Math.max(1,t.current-t.minimum)/z,u=Math.floor(r);t.value+=u,t.fraction=r-u}b=s-l.reduce((t,r)=>t+r.value,0),l.sort((t,r)=>r.fraction-t.fraction||t.index-r.index);for(let t=0;t<b;t++)l[t%l.length].value++;l.sort((t,r)=>t.index-r.index);for(let t of l)if(t.object.type==="row"){let r=O(t.object);t.object.seatCount=t.value;let u=O(t.object);t.object.origin.x+=r.x-u.x,t.object.origin.y+=r.y-u.y}else if(t.object.type==="table"){let r=t.object;if(r.seatCountsBySide){let u=["top","bottom","left","right"],p=S(r),B=u.reduce((i,f)=>i+p[f],0)||1,m=u.map((i,f)=>{let x=t.value*p[i]/B;return{side:i,index:f,value:Math.floor(x),fraction:x-Math.floor(x)}}),L=t.value-m.reduce((i,f)=>i+f.value,0);m.sort((i,f)=>f.fraction-i.fraction||i.index-f.index);for(let i=0;i<L;i++)m[i%m.length].value+=1;m.sort((i,f)=>i.index-f.index),r.seatCountsBySide={top:m[0].value,bottom:m[1].value,left:m[2].value,right:m[3].value},r.sides=u.filter(i=>r.seatCountsBySide[i]>0)}r.seatCount=t.value,r.overrides&&(r.overrides=r.overrides.filter(u=>u.index<t.value),r.overrides.length||delete r.overrides)}else t.object.capacity=t.value;return e.floors?.length&&(e.objects=e.floors[0].objects),e.template={family:e.template.family,targetSeats:d},e=D(e).doc,e.template={family:a.template.family,targetSeats:K(e)},e}export{K as a,Q as b,P as c,U as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function o(e){let n=(e%360+360)%360,t=n>=180?n-360:n;return Object.is(t,-0)||Math.abs(t)<1e-9?0:t}export{o as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as c,j as u}from"./chunk-Z43H6AWN.js";import{Ea as h,Ia as b,Qa as s}from"./chunk-VAI2VDQR.js";var l=class extends Error{constructor(n,t,r={}){super(t);this.code=n;this.details=r;this.name="ChartOperationError"}};function P(e,o){let n=s(e),t=o?n.find(r=>r.id===o):n[0];if(!t)throw new l("floor_not_found",`Unknown chart floor: ${o}`,{floorId:o});return{floorId:t.id,objects:t.objects}}function D(e,o){if(!e.categories.some(n=>n.key===o))throw new l("category_not_found",`Unknown chart category: ${o}. Call get_chart to list valid category keys.`,{categoryKey:o})}function y(e,o,n,t){let r=new Set([...t,...e.categories.map(i=>i.key),...e.zones?.map(i=>i.id)??[],...e.floors?.map(i=>i.id)??[],...e.floors?.length?e.floors.flatMap(i=>i.objects.map(a=>a.id)):e.objects.map(i=>i.id)]);for(let i=0;i<100;i++){let a=n(o);if(a&&!r.has(a))return t.add(a),a}throw new l("id_generation_failed",`Unable to allocate a unique ${o} id`)}function L(e){let o=e.slice().sort((i,a)=>i.x-a.x||i.y-a.y);if(o.length<3)return o;let n=(i,a,f)=>(a.x-i.x)*(f.y-i.y)-(a.y-i.y)*(f.x-i.x),t=[];for(let i of o){for(;t.length>=2&&n(t[t.length-2],t[t.length-1],i)<=0;)t.pop();t.push(i)}let r=[];for(let i=o.length-1;i>=0;i--){let a=o[i];for(;r.length>=2&&n(r[r.length-2],r[r.length-1],a)<=0;)r.pop();r.push(a)}return t.pop(),r.pop(),t.concat(r)}function C(e,o){if(!e.length)return e;let n={x:e.reduce((t,r)=>t+r.x,0)/e.length,y:e.reduce((t,r)=>t+r.y,0)/e.length};return e.map(t=>{let r=t.x-n.x,i=t.y-n.y,a=Math.hypot(r,i)||1;return{x:t.x+r/a*o,y:t.y+i/a*o}})}function O(e){let o=[];for(let t of e)t.type==="row"?o.push(...h(t).map(r=>({x:r.x,y:r.y}))):t.type==="table"?o.push(...b(t).map(r=>({x:r.x,y:r.y}))):t.type==="gaArea"?o.push(...t.points):t.type==="booth"&&o.push(t.center);if(o.length<3)return null;let n=C(L(o),22);return n.length>=3?n:null}function z(e,o){let n=P(e,o),t=s(e).find(r=>r.id===n.floorId);return{...e,objects:n.objects,floors:void 0,focalPoint:t.focalPoint,referenceImage:t.referenceImage,backgroundImage:t.backgroundImage}}var p=24,m=80;function v(e,o){let n=e.normalize("NFKC").trim();if(n.length>p)throw new l("invalid_operation",`${o} displayed type must be at most ${p} characters`);return n}function H(e,o){if(e.displayType===void 0)return!1;let n=v(e.displayType,o);return n?(e.displayType=n,!1):(delete e.displayType,!0)}function A(e,o){if(e.displayLabel===void 0)return!1;let n=e.displayLabel.normalize("NFKC").trim();if(n.length>m)throw new l("invalid_operation",`${o} displayed label must be at most ${m} characters`);return n?(e.displayLabel=n,!1):(delete e.displayLabel,!0)}function d(e,o){let n=e.trim().toLowerCase();if(!/^#[0-9a-f]{6}$/.test(n))throw new l("invalid_operation",`${o} must use a six-digit hex color`);return n}function x(e,o){if(!Number.isFinite(e)||e<c||e>u)throw new l("invalid_operation",`${o} label size must be from ${c} to ${u}`)}function $(e,o){e.size!==void 0&&e.size!==null&&x(e.size,o),e.color!==void 0&&e.color!==null&&d(e.color,`${o} label color`)}function k(e,o){if(e?.positionPreset!==void 0&&!["start","end","both","none"].includes(e.positionPreset))throw new l("invalid_operation",`${o} label positionPreset must be one of start, end, both, none`);let n=e?.labelStyle;n&&(n.size!==void 0&&x(n.size,o),n.color!==void 0&&d(n.color,`${o} label color`))}function E(e,o){let n=e?structuredClone(e):{},t=n.labelStyle?{...n.labelStyle}:{};return o.size===null?delete t.size:o.size!==void 0&&(t.size=o.size),o.color===null?delete t.color:o.color!==void 0&&(t.color=d(o.color,"Label color")),t.size===void 0&&t.color===void 0?delete n.labelStyle:n.labelStyle=t,o.visible!==void 0&&(n.visible=o.visible),Object.keys(n).length?n:void 0}function T(e,o,n){let t=o.normalize("NFKC").trim();if(!t||t.length>80)throw new l("invalid_operation","Zone labels must contain 1 to 80 characters");if((e.zones??[]).some(r=>r.id!==n&&r.label.normalize("NFKC").trim().toLocaleLowerCase("en")===t.toLocaleLowerCase("en")))throw new l("invalid_operation",`Zone label already exists: ${t}`);return t}function N(e,o){if(!Number.isFinite(e?.x)||!Number.isFinite(e?.y))throw new l("invalid_operation",`${o} must contain finite x and y values`);return{x:e.x,y:e.y}}function U(e,o,n){return(o.x-e.x)*(n.y-e.y)-(o.y-e.y)*(n.x-e.x)}var B=Math.PI/180,Z=Math.PI/180;function K(e){return e.type==="row"||e.type==="table"?e.seatCount:e.type==="gaArea"?Math.max(0,Math.floor(e.capacity)):e.type==="booth"?1:0}function _(e){if(e.floors?.length){let o=e.floors[0];e.objects=o.objects,e.focalPoint=o.focalPoint,e.referenceImage=o.referenceImage,e.backgroundImage=o.backgroundImage}return e}var S=0,g=120,w=4;function F(e){if(!Number.isFinite(e)||e<S||e>g)throw new l("invalid_operation","Floor base height must be a number from 0 to 120 metres")}function X(e,o){let n=s(e);if(n.length>=5)throw new l("invalid_operation","A chart can contain at most five physical floors");let t=(o.name??String(n.length+1)).normalize("NFKC").trim();if(!t||t.length>80)throw new l("invalid_operation","Floor names must contain 1 to 80 characters");if(n.some(I=>I.name.toLocaleLowerCase("en")===t.toLocaleLowerCase("en")))throw new l("invalid_operation",`Floor name already exists: ${t}`);e.floors?.length||(e.floors=[{id:"floor-0",name:"1",objects:e.objects,baseHeightM:0,focalPoint:e.focalPoint,referenceImage:e.referenceImage,backgroundImage:e.backgroundImage}]);let i=e.floors[e.floors.length-1].baseHeightM??Math.min(g,(e.floors.length-1)*w),a=Math.min(g,i+w),f=y(e,"floor",o.idFactory,new Set);return e.floors.push({id:f,name:t,baseHeightM:a,objects:[],focalPoint:{...e.focalPoint}}),_(e),{changed:!0,floorId:f,floorCount:e.floors.length,baseHeightM:a}}function q(e,o){let n=s(e),t=n.find(a=>a.id===o.floorId);if(!t)throw new l("floor_not_found",`Unknown chart floor: ${o.floorId}`,{floorId:o.floorId});let r=o.name.normalize("NFKC").trim();if(!r||r.length>80)throw new l("invalid_operation","Floor names must contain 1 to 80 characters");if(n.some(a=>a.id!==t.id&&a.name.toLocaleLowerCase("en")===r.toLocaleLowerCase("en")))throw new l("invalid_operation",`Floor name already exists: ${r}`);let i=t.name!==r;return i&&(t.name=r),{changed:i,floorId:t.id,floorName:r}}function V(e,o){if(!e.floors?.length)throw new l("invalid_operation","A single-floor chart has an implicit base height of 0 metres");let n=e.floors.find(r=>r.id===o.floorId);if(!n)throw new l("floor_not_found",`Unknown chart floor: ${o.floorId}`,{floorId:o.floorId});F(o.baseHeightM);let t=n.baseHeightM!==o.baseHeightM;return t&&(n.baseHeightM=o.baseHeightM,n.physical3dProvenance={...n.physical3dProvenance,baseHeightM:{status:"confirmed",source:"user-review",note:"Physical floor height reviewed through the shared Designer/Copilot operation."}}),{changed:t,floorId:n.id,baseHeightM:o.baseHeightM}}function W(e,o){if(!e.floors?.length)throw new l("invalid_operation","A single-floor chart cannot remove its only floor");let n=e.floors.findIndex(r=>r.id===o.floorId);if(n<0)throw new l("floor_not_found",`Unknown chart floor: ${o.floorId}`,{floorId:o.floorId});let[t]=e.floors.splice(n,1);if(e.floors.length===1){let[r]=e.floors;e.objects=r.objects,e.focalPoint=r.focalPoint,e.referenceImage=r.referenceImage,e.backgroundImage=r.backgroundImage,e.floors=void 0}else _(e);return{changed:!0,floorId:t.id,removedObjects:t.objects.length,floorCount:s(e).length}}export{l as a,P as b,D as c,y as d,O as e,z as f,v as g,H as h,A as i,d as j,$ as k,k as l,E as m,T as n,N as o,U as p,B as q,Z as r,K as s,_ as t,g as u,w as v,X as w,q as x,V as y,W as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Ia as B,Sa as M,Va as K}from"./chunk-VAI2VDQR.js";function S(t){let n=Number(t.slice(t.lastIndexOf(":")+1));return Number.isFinite(n)?n:-1}function te(t,n,i){let e=new Map;for(let a of t){if(a.kind==="booth")continue;let r=e.get(a.rowId);r?r.push(a):e.set(a.rowId,[a])}let u=a=>i.has(a.id)||n(a.id)!=="free",s=[];for(let a of e.values())if(!(a.length<3)){a.sort((r,l)=>S(r.id)-S(l.id));for(let r=1;r<a.length-1;r++){let l=a[r];if(u(l))continue;let g=a[r-1],m=a[r+1];S(l.id)-S(g.id)!==1||S(m.id)-S(l.id)!==1||!u(g)||!u(m)||!i.has(g.id)&&!i.has(m.id)||s.push(l)}}return s}function $(t){return Array.isArray(t.objects)}function j(t,n){if(n.seatsByLabel)return n.seatsByLabel;if(!$(t))throw new Error("ticketRestrictions: a categories-only chart document requires options.seatsByLabel");return new Map(K(t,{resolveEyeHeights:!1}).map(i=>[i.label,i]))}function H(t){return{code:"ticket_option_not_applicable",labels:t,message:"That ticket choice is not available for the selected seat."}}function R(t,n){let i=t.applicability;return i?!(i.seatLabels?.length&&!i.seatLabels.includes(n.label)||i.accessibility?.length&&!i.accessibility.some(e=>n.accessibility?.includes(e))):!0}function oe(t,n){return(t.categories.find(i=>i.key===n.categoryKey)?.tiers??[]).filter(i=>R(i,n))}function F(t,n,i){let e=t.categories.find(s=>s.key===n.categoryKey)?.tiers;if(!e?.length)return{kind:"none"};let u=i==null?e.find(s=>R(s,n)):e.find(s=>s.id===i&&R(s,n));return u?{kind:"resolved",tier:u}:{kind:"invalid"}}function Y(t,n){return(t.logicalRowId??t.rowId)===(n.logicalRowId??n.rowId)}function L(t){if(Number.isInteger(t.logicalSeatIndex))return t.logicalSeatIndex;let n=t.id.slice(t.id.lastIndexOf(":")+1),i=Number(n);return Number.isInteger(i)?i:void 0}function J(t,n){if(!Y(t,n))return!1;let i=L(t),e=L(n);return i!=null&&e!=null&&Math.abs(i-e)===1}function Q(t,n,i={}){if(!n.length)return null;let e=j(t,i),u=n.flatMap(r=>{let l=e.get(r.label);return l?[{selection:r,seat:l}]:[]}),s=u.map(({seat:r})=>r).filter(r=>r.accessibility?.includes("wheelchair")),a=[];for(let{selection:r,seat:l}of u){let g=F(t,l,r.tierId),m=g.kind==="resolved"?g.tier:void 0;(l.accessibility?.includes("companion")||m?.restriction==="companion")&&!s.some(h=>h.id!==l.id&&J(l,h))&&a.push(l.label)}return a.length?{code:"companion_pair_required",labels:a,message:"Select the adjacent wheelchair place with each companion ticket."}:null}function re(t,n,i={}){if(!n.length)return null;let e=j(t,i),u=new Set(t.categories.filter(r=>r.notForSale).map(r=>r.key)),s=[],a=[];for(let r of n){let l=e.get(r.label);if(!l)continue;if(u.has(l.categoryKey)){s.push(l.label);continue}F(t,l,r.tierId).kind==="invalid"&&a.push(l.label)}return s.length?{code:"not_for_sale",labels:s,message:"These seats are not for sale."}:a.length?H(a):Q(t,n,{seatsByLabel:e})}function D(t,n){if(Number.isInteger(t.logicalSeatIndex))return t.logicalSeatIndex;let i=t.id.lastIndexOf(":");if(i<0)return n;let e=Number(t.id.slice(i+1));return Number.isFinite(e)?e:n}function T(t,n){let i=t.x-n.x,e=t.y-n.y;return i*i+e*e}function E(t){let n=0,i=0;for(let e of t)n+=e.x,i+=e.y;return{x:n/t.length,y:i/t.length}}function q(t,n){return t.find(i=>i.focalPoint)?.focalPoint??n}function P(t){return t.commercial?.premium===!0}function X(t,n,i){let e=Math.floor(i.qty);if(!Number.isFinite(e)||e<=0)return{labels:[],reason:"sold_out"};let{categoryKey:u,zoneId:s,focal:a,preferPremium:r,preferNearest:l,preferredRowIds:g,accessibility:m,requireContiguous:d}=i,h=new Map,w=[];if(t.forEach((o,c)=>{let p=n.has(o.label)&&(!u||o.categoryKey===u)&&(!s||o.zoneId===s)&&(!m||m.some(I=>o.accessibility?.includes(I))),y=o.logicalRowId??o.rowId,b=h.get(y);b||(b=[],h.set(y,b)),b.push({seat:o,index:D(o,c),elig:p}),p&&w.push(o)}),w.length===0)return{labels:[],reason:"sold_out"};let O=new Map([...h].map(([o,c])=>[o,E(c.map(p=>p.seat))])),A=(g??[]).map(o=>O.get(o)).filter(o=>!!o),_=o=>{let c=O.get(o);return!c||!A.length?0:Math.min(...A.map(p=>T(c,p)))},f=null,z=o=>{if(!f)return!0;if(r&&o.nonPremium!==f.nonPremium)return o.nonPremium<f.nonPremium;if(l&&o.rowD2!==f.rowD2)return o.rowD2<f.rowD2;if(l&&o.d2!==f.d2)return o.d2<f.d2;if(o.orphan!==f.orphan)return o.orphan<f.orphan;if(o.d2!==f.d2)return o.d2<f.d2;let c=o.rowId.localeCompare(f.rowId);return c!==0?c<0:o.startIndex<f.startIndex};for(let[o,c]of h){let p=[...c].sort((b,I)=>b.index-I.index),y=0;for(;y<p.length;){if(!p[y].elig){y++;continue}let b=y;for(;b<p.length&&p[b].elig&&(b===y||p[b].index===p[b-1].index+1);)b++;let I=b-y;for(let x=0;x+e<=I;x++){let G=x,U=I-(x+e),V=G===1||U===1?1:0,k=p.slice(y+x,y+x+e).map(C=>C.seat),N={labels:k.map(C=>C.label),seats:k,rowId:o,startIndex:p[y+x].index,orphan:V,nonPremium:r?k.reduce((C,W)=>C+(P(W)?0:1),0):0,rowD2:_(o),d2:T(E(k),l?a:q(k,a))};z(N)&&(f=N)}y=b}}return f?{labels:f.labels}:d?{labels:[],reason:w.length?"not_enough_together":"sold_out"}:w.length<e?{labels:[],reason:"not_enough_together"}:{labels:w.map((o,c)=>({seat:o,i:c,rowD2:_(o.logicalRowId??o.rowId),d2:T(o,l?a:o.focalPoint??a)})).sort((o,c)=>{if(r){let y=P(o.seat)?0:1,b=P(c.seat)?0:1;if(y!==b)return y-b}if(l&&o.rowD2!==c.rowD2)return o.rowD2-c.rowD2;if(o.d2!==c.d2)return o.d2-c.d2;let p=(o.seat.logicalRowId??o.seat.rowId).localeCompare(c.seat.logicalRowId??c.seat.rowId);return p!==0?p:D(o.seat,o.i)-D(c.seat,c.i)}).slice(0,e).map(o=>o.seat.label)}}function le(t,n,i,e){let u=Math.floor(e.qty),s=X(t,i,e),r=n.filter(d=>d.bookingMode==="whole"&&d.capacity===u&&i.has(d.label)&&(!e.categoryKey||d.categoryKey===e.categoryKey)&&(!e.zoneId||d.zoneId===e.zoneId)&&!e.accessibility).map(d=>({table:d,d2:T(d.center,e.preferNearest?e.focal:d.focalPoint??e.focal)})).sort((d,h)=>d.d2-h.d2||d.table.label.localeCompare(h.table.label))[0];if(!r)return s;if(!s.labels.length)return{labels:[r.table.label]};let l=new Map(t.map(d=>[d.label,d])),g=s.labels.map(d=>l.get(d)).filter(d=>!!d),m=g.length?T(E(g),q(g,e.focal)):Number.POSITIVE_INFINITY;return r.d2<m?{labels:[r.table.label]}:s}var v=class extends Error{constructor(i,e){super(e);this.objectId=i;this.name="GroupedTableProjectionError"}};function Z(t){let n=t.minOccupancy,i=t.maxOccupancy;if(!Number.isInteger(n)||!Number.isInteger(i)||n<1||i<n||i>t.seatCount)throw new v(t.id,`Table "${t.label}" has invalid variable-occupancy bounds`);return{min:n,max:i}}function de(t,n){if(n!==2)return[];let i=[];for(let e of M(t)){if(e.type!=="table"||!e.bookAsWhole&&!e.variableOccupancy)continue;if(e.bookAsWhole&&e.variableOccupancy)throw new v(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 v(e.id,"Grouped tables require a label and at least one chair");let u=e.variableOccupancy?"variable":"whole",s=u==="variable"?Z(e):{min:e.seatCount,max:e.seatCount};i.push({objectId:e.id,label:e.label,...e.displayLabel?{displayLabel:e.displayLabel}:{},...e.displayType?{displayType:e.displayType}:{},categoryKey:e.categoryKey,mode:u,capacity:e.seatCount,minOccupancy:s.min,maxOccupancy:s.max,chairs:B(e)})}return i}export{te as a,$ as b,H as c,R as d,oe as e,F as f,Q as g,re as h,X as i,le as j,v as k,de as l};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Ea as h,Ia as m,Ja as y,Pa as b,Qa as S,Sa as f}from"./chunk-VAI2VDQR.js";var g="__sl_ga__";function M(t){return t.startsWith(g)}var C=g,p=1e5;function L(t,e){return`${C}${encodeURIComponent(t)}__${e+1}`}function w(t){let e=t.inventorySegments;if(e===void 0)return!0;if(!Array.isArray(e)||e.length<1||e.length>256)return!1;let n=0,r=new Map;for(let o of e){if(!o||typeof o.sourceAreaId!="string"||!o.sourceAreaId.trim()||o.sourceAreaId.length>160||!Number.isInteger(o.startIndex)||o.startIndex<0||!Number.isInteger(o.count)||o.count<1||o.startIndex+o.count>p||(n+=o.count,n>p))return!1;let c=r.get(o.sourceAreaId)??[],i=o.startIndex+o.count;if(c.some(s=>o.startIndex<s.end&&i>s.start))return!1;c.push({start:o.startIndex,end:i}),r.set(o.sourceAreaId,c)}return n===t.capacity}function j(t){let e=Math.min(p,Math.max(0,Math.floor(t.capacity)));return t.inventorySegments===void 0?e?[{sourceAreaId:t.id,startIndex:0,count:e}]:[]:w(t)?t.inventorySegments.map(n=>({...n})):[]}function A(t){return j(t).flatMap(e=>Array.from({length:e.count},(n,r)=>L(e.sourceAreaId,e.startIndex+r)))}function H(t,e){if(t.inventorySegments===void 0||e===t.capacity)return t.inventorySegments;if(e<t.capacity)return;let n=j(t);if(!n.length)return;let r=e-t.capacity;if(!r)return n;let c=n.filter(s=>s.sourceAreaId===t.id).reduce((s,a)=>Math.max(s,a.startIndex+a.count),0),i=n[n.length-1];if(i?.sourceAreaId===t.id&&i.startIndex+i.count===c)i.count+=r;else{if(n.length>=256)return;n.push({sourceAreaId:t.id,startIndex:c,count:r})}return n}function X(t){return f(t).filter(e=>e.type==="gaArea")}var I="__ungrouped__";function E(t){return t.type==="row"?h(t).map(e=>e.label):t.type==="table"?m(t).map(e=>e.label):t.type==="booth"?y(t).map(e=>e.label):t.type==="gaArea"?A(t):[]}function x(t){return t.type==="row"||t.type==="table"||t.type==="booth"||t.type==="gaArea"}function G(t){return t.displayLabel||t.label||"Section"}function O(t){let e=new Map;for(let n of f(t)){if(n.type!=="section")continue;let r=n.logicalSectionId??n.id;e.has(r)||e.set(r,{id:r,label:G(n),zone:n.zone})}return e}function K(t){let e=new Map;for(let[n,r]of O(t))e.set(n,r.label);return e}function N(t){let e=new Map;for(let n of S(t)){let r=n.objects.filter(o=>o.type==="section");if(r.length)for(let o of n.objects){if(!x(o))continue;let c=b(n.objects,o,r);c&&e.set(o.id,c.logicalSectionId??c.id)}}return e}function _(t,e){let n=f(t),r=n.filter(s=>s.type==="section"),o=new Map;for(let[s,a]of O(t))o.set(s,{id:s,label:a.label,zone:a.zone,seatCount:0,objectIds:[],seatLabels:[]});let c={id:I,label:"Other seats",seatCount:0,objectIds:[],seatLabels:[]},i=new Map;for(let s of n){if(!x(s))continue;let a=E(s);if(a.length===0)continue;let u;if(e)u=e.get(s.id);else{let d=b(n,s,r);u=d?d.logicalSectionId??d.id:void 0}let l=u?o.get(u):c;l.seatCount+=a.length,l.objectIds.push(s.id),l.seatLabels.push(...a),i.set(s.id,l.id)}return{sections:[...o.values()],ungrouped:c.objectIds.length?c:null,objectToSection:i}}function Q(t){return _(t,null)}function R(t){return _(t,N(t))}function v(t,e){return e.has(t.id)||!!t.logicalSectionId&&e.has(t.logicalSectionId)||!!t.zone&&e.has(t.zone)}function D(t,e){let n=new Set;if(!e.size)return n;let{sections:r,ungrouped:o,objectToSection:c}=R(t),i=new Set,s=new Map(r.map(u=>[u.id,u.zone]));for(let u of r){let l=s.get(u.id);(e.has(u.id)||l&&e.has(l))&&i.add(u.id)}let a=!!o&&e.has(I);for(let[u,l]of c)(i.has(l)||a&&l===I)&&n.add(u);return n}function Z(t,e){if(!e.size)return t;let n=D(t,e),r=e instanceof Set?e:new Set(e),o=i=>!(n.has(i.id)||i.type==="section"&&v(i,r));if(t.floors&&t.floors.length){let i=!1,s=t.floors.map(a=>{let u=a.objects.filter(o);return u.length!==a.objects.length&&(i=!0),u.length===a.objects.length?a:{...a,objects:u}});return i?{...t,floors:s,objects:s[0].objects}:t}let c=t.objects.filter(o);return c.length===t.objects.length?t:{...t,objects:c}}export{g as a,M as b,p as c,L as d,w as e,j as f,A as g,H as h,X as i,I as j,O as k,K as l,N as m,Q as n,R as o,v as p,D as q,Z as r};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{M as o}from"./chunk-
|
|
1
|
+
import{M as o}from"./chunk-VAI2VDQR.js";var u=36,c=160;function A(r,n=360){let t=o(Math.round(Number.isFinite(r)?r:1),1,40),i=o(Number.isFinite(n)?n:360,120,360);return Math.round(o(t*4*(360/i),u,c))}export{u as a,c as b,A as c};
|