@seatlayer/core 0.100.0 → 0.101.0

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