@seatlayer/core 0.53.0 → 0.55.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 (78) hide show
  1. package/README.md +2 -2
  2. package/dist/categoryInventory-BwarniiK.d.ts +109 -0
  3. package/dist/categoryInventory-D3qPwfKz.d.cts +109 -0
  4. package/dist/chunk-55NOSZK5.js +1 -0
  5. package/dist/chunk-6VTTBC5F.js +1 -0
  6. package/dist/chunk-6XJN4REG.js +1 -0
  7. package/dist/chunk-7PT7OQUO.js +1 -0
  8. package/dist/chunk-AQKYUJBX.js +1 -0
  9. package/dist/chunk-CXF32VPG.js +1 -0
  10. package/dist/chunk-DNGP2HDT.js +1 -0
  11. package/dist/chunk-EQM4FFN5.js +1 -0
  12. package/dist/chunk-HHM3PB66.js +1 -0
  13. package/dist/chunk-PXWKSYCK.js +1 -0
  14. package/dist/chunk-VDZ24QVV.js +1 -0
  15. package/dist/chunk-VI2CLV3Y.js +1 -0
  16. package/dist/core/chart-ops/index.cjs +1 -0
  17. package/dist/core/chart-ops/index.d.cts +1235 -0
  18. package/dist/core/chart-ops/index.d.ts +1235 -0
  19. package/dist/core/chart-ops/index.js +1 -0
  20. package/dist/core/color.cjs +1 -0
  21. package/dist/core/color.d.cts +192 -0
  22. package/dist/core/color.d.ts +192 -0
  23. package/dist/core/color.js +1 -0
  24. package/dist/core/inventory/index.cjs +1 -0
  25. package/dist/core/inventory/index.d.cts +209 -0
  26. package/dist/core/inventory/index.d.ts +209 -0
  27. package/dist/core/inventory/index.js +1 -0
  28. package/dist/core/layout/index.cjs +1 -0
  29. package/dist/core/layout/index.d.cts +376 -0
  30. package/dist/core/layout/index.d.ts +376 -0
  31. package/dist/core/layout/index.js +1 -0
  32. package/dist/core/quality/index.cjs +1 -0
  33. package/dist/core/quality/index.d.cts +132 -0
  34. package/dist/core/quality/index.d.ts +132 -0
  35. package/dist/core/quality/index.js +1 -0
  36. package/dist/core/render-assets/index.cjs +1 -0
  37. package/dist/core/render-assets/index.d.cts +99 -0
  38. package/dist/core/render-assets/index.d.ts +99 -0
  39. package/dist/core/render-assets/index.js +1 -0
  40. package/dist/core/seatConfidence.cjs +1 -1
  41. package/dist/core/seatConfidence.d.cts +1 -1
  42. package/dist/core/seatConfidence.d.ts +1 -1
  43. package/dist/core/seatConfidence.js +1 -1
  44. package/dist/core/sections/index.cjs +1 -0
  45. package/dist/core/sections/index.d.cts +346 -0
  46. package/dist/core/sections/index.d.ts +346 -0
  47. package/dist/core/sections/index.js +1 -0
  48. package/dist/{de-75NWRKC5.js → de-WPX4D3SY.js} +1 -1
  49. package/dist/{es-BM7EJ7PW.js → es-6KAJQVVX.js} +1 -1
  50. package/dist/{fr-HPXQHIB4.js → fr-5DTMRBN5.js} +1 -1
  51. package/dist/index.cjs +1 -1
  52. package/dist/index.d.cts +85 -534
  53. package/dist/index.d.ts +85 -534
  54. package/dist/index.js +1 -1
  55. package/dist/labeling-BmCzW50y.d.ts +90 -0
  56. package/dist/labeling-VfJBEOn0.d.cts +90 -0
  57. package/dist/layout-ClQkmixY.d.ts +181 -0
  58. package/dist/layout-Dlv5bIf2.d.cts +181 -0
  59. package/dist/renderedQuality-B3jgdgPO.d.ts +113 -0
  60. package/dist/renderedQuality-bDkUOyBL.d.cts +113 -0
  61. package/dist/renderer-B_g-W_QB.d.ts +534 -0
  62. package/dist/renderer-DySMcKAR.d.cts +534 -0
  63. package/dist/sections-DIzgtDjF.d.ts +123 -0
  64. package/dist/sections-Dna1nZgR.d.cts +123 -0
  65. package/dist/segmentedRowModel-BNXEUeHp.d.cts +75 -0
  66. package/dist/segmentedRowModel-COXw4GCh.d.ts +75 -0
  67. package/dist/ticketRestrictions-CzchbX_o.d.cts +72 -0
  68. package/dist/ticketRestrictions-DaYOCpEw.d.ts +72 -0
  69. package/dist/{types-tLOunI-B.d.cts → types-DTSG6_Hq.d.cts} +238 -761
  70. package/dist/{types-tLOunI-B.d.ts → types-DTSG6_Hq.d.ts} +238 -761
  71. package/dist/view3d/crossfade/panorama.d.cts +1 -1
  72. package/dist/view3d/crossfade/panorama.d.ts +1 -1
  73. package/dist/view3d/index.cjs +27 -27
  74. package/dist/view3d/index.d.cts +109 -2
  75. package/dist/view3d/index.d.ts +109 -2
  76. package/dist/view3d/index.js +26 -26
  77. package/package.json +94 -5
  78. package/dist/chunk-54A7LIL5.js +0 -1
@@ -1,12 +1,12 @@
1
- import{K as Tn,Y as ne,_ as Fn,d as Pn,fa as fe,ha as ot,ja as Ge,l as An,la as rt,m as nt,ma as Dn,oa as gt,r as Be,s as Oe,u as yt,w as Cn,x as xt,y as Rn,z as In}from"../chunk-54A7LIL5.js";import{a as Ln,c as Bn,d as On,e as Re,j as Nn}from"../chunk-XPPT3OGQ.js";import{c as kn,d as En,e as Wt,f as _n}from"../chunk-IJI4WU57.js";import{Renderer as Hr}from"ogl";var Me=["available","held","sold","selected","dimmed"];function it(t){let e=Me.indexOf(t);return e<0?0:e}var zn={available:[.24,.82,.52],held:[.95,.66,.22],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};function Vn(t){let e=.2126*t[0]+.7152*t[1]+.0722*t[2],n=.42,i=.62;return[(e+(t[0]-e)*n)*i,(e+(t[1]-e)*n)*i,(e+(t[2]-e)*n)*i]}var jt={ground:[.07,.085,.11],tierTop:[.24,.28,.34],tierWall:[.17,.2,.25],stageTop:[.94,.7,.38],stageWall:[.48,.33,.18],decorTop:[.22,.25,.29],decorWall:[.15,.17,.2],gaTop:[.24,.28,.33],gaWall:[.16,.19,.23],boothTop:[.3,.33,.38],boothWall:[.2,.23,.27],tableTop:[.38,.34,.29],tableWall:[.24,.21,.18]},He={top:[.05,.06,.08],bottom:[.1,.12,.15]};function pe(t,e){return[Math.min(1,t[0]*e),Math.min(1,t[1]*e),Math.min(1,t[2]*e)]}function Ur(){let t=typeof window<"u"&&window.devicePixelRatio||1,e=navigator.deviceMemory,n=typeof e=="number"&&e<=4?1.5:2;return Math.min(t,n)}var vt=class{constructor(e,n){this.clearRgb=[0,0,0];this.container=e,this.canvas=document.createElement("canvas"),this.canvas.style.display="block",this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.touchAction="none",this.canvas.tabIndex=0,this.canvas.setAttribute("role","application"),this.canvas.setAttribute("aria-label","Interactive 3D venue. Drag or use arrow keys to look around; pinch, scroll, plus or minus to zoom."),this.renderer=new Hr({canvas:this.canvas,dpr:Ur(),alpha:!1,antialias:!1,depth:!0,stencil:!1,powerPreference:"high-performance",webgl:2}),this.gl=this.renderer.gl,this.clearRgb=[He.top[0],He.top[1],He.top[2]],this.gl.clearColor(this.clearRgb[0],this.clearRgb[1],this.clearRgb[2],1),e.appendChild(this.canvas),this.lostHandler=i=>{i.preventDefault(),n.onContextLost()},this.restoredHandler=()=>n.onContextRestored(),this.canvas.addEventListener("webglcontextlost",this.lostHandler,!1),this.canvas.addEventListener("webglcontextrestored",this.restoredHandler,!1),this.resize()}setClearColor(e){this.clearRgb=[e[0],e[1],e[2]],this.gl.clearColor(e[0],e[1],e[2],1)}get clearColor(){return this.clearRgb}resize(){let e=Math.max(1,this.container.clientWidth||this.canvas.clientWidth||1),n=Math.max(1,this.container.clientHeight||this.canvas.clientHeight||1);return this.renderer.setSize(e,n),{width:e,height:n}}get pixelHeight(){return this.renderer.height*this.renderer.dpr}get aspect(){return this.renderer.width/Math.max(1,this.renderer.height)}dispose(){this.canvas.removeEventListener("webglcontextlost",this.lostHandler,!1),this.canvas.removeEventListener("webglcontextrestored",this.restoredHandler,!1);let e=this.gl.getExtension("WEBGL_lose_context");e&&e.loseContext(),this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}simulateContextLossCycle(){let e=this.gl.getExtension("WEBGL_lose_context");e&&(e.loseContext(),setTimeout(()=>{e.restoreContext&&e.restoreContext()},300))}};import{Camera as Yr,Vec3 as qt}from"ogl";var me=Math.PI/180,Zt=15*me,Kt=80*me,je=.12,Gn=35,Hn=1.25,Mt=class{constructor(e,n,i,o){this.fovY=Gn;this.target=new qt;this.azimuth=-30*me;this.polar=55*me;this.distance=10;this.azT=-30*me;this.polT=55*me;this.distT=10;this.minDist=1;this.maxDist=100;this.gestureFired=!1;this.interactionEnabled=!0;this.dragging=!1;this.panning=!1;this.lastX=0;this.lastY=0;this.activePointers=new Map;this.pinchDist=0;this.pinchCx=0;this.pinchCy=0;this.targetT=new qt;this.panAnchor=new qt;this.panLimit=0;this.primaryDragMode="orbit";this.camera=new Yr(e,{fov:Gn,near:.1,far:5e3,aspect:1}),this.canvas=n,this.requestRender=i,this.onGesture=o,this.onPointerDown=r=>{if(this.interactionEnabled){try{this.canvas.setPointerCapture?.(r.pointerId)}catch{}if(this.activePointers.set(r.pointerId,{x:r.clientX,y:r.clientY}),this.activePointers.size===1){let a=r.button===2||r.button===1,s=r.button===0&&(r.shiftKey?this.primaryDragMode==="orbit":this.primaryDragMode==="pan");this.panning=a||s,this.dragging=!this.panning,this.lastX=r.clientX,this.lastY=r.clientY}else if(this.activePointers.size===2){this.dragging=!1,this.panning=!1,this.pinchDist=this.currentPinchDistance();let a=this.pinchCentroid();this.pinchCx=a.x,this.pinchCy=a.y}}},this.onPointerMove=r=>{if(!this.interactionEnabled||!this.activePointers.has(r.pointerId))return;if(this.activePointers.set(r.pointerId,{x:r.clientX,y:r.clientY}),this.activePointers.size>=2){let u=this.currentPinchDistance();this.pinchDist>0&&(this.dollyBy(Math.exp((this.pinchDist-u)*.005)),this.fireGesture()),this.pinchDist=u;let l=this.pinchCentroid();this.panBy(l.x-this.pinchCx,l.y-this.pinchCy),this.pinchCx=l.x,this.pinchCy=l.y;return}let a=r.clientX-this.lastX,s=r.clientY-this.lastY;if(this.panning){this.lastX=r.clientX,this.lastY=r.clientY,(a!==0||s!==0)&&(this.panBy(a,s),this.fireGesture());return}this.dragging&&(this.lastX=r.clientX,this.lastY=r.clientY,(a!==0||s!==0)&&this.fireGesture(),this.azT-=a*.006,this.polT=Math.max(Zt,Math.min(Kt,this.polT-s*.006)),this.requestRender())},this.onPointerUp=r=>{this.activePointers.delete(r.pointerId);try{this.canvas.releasePointerCapture?.(r.pointerId)}catch{}this.activePointers.size<2&&(this.pinchDist=0),this.activePointers.size===0&&(this.dragging=!1,this.panning=!1)},this.onContextMenu=r=>{r.preventDefault()},this.onWheel=r=>{if(r.preventDefault(),!this.interactionEnabled)return;let a=r.deltaMode===1?16:r.deltaMode===2?100:1,s=Math.max(-2,Math.min(2,r.deltaY*a/100));this.dollyBy(Math.exp(s*.22)),this.fireGesture()},this.onKeyDown=r=>{if(!this.interactionEnabled)return;let a=7*me;if(r.shiftKey&&(r.key==="ArrowLeft"||r.key==="ArrowRight"||r.key==="ArrowUp"||r.key==="ArrowDown"))this.panBy(r.key==="ArrowLeft"?-32:r.key==="ArrowRight"?32:0,r.key==="ArrowUp"?-32:r.key==="ArrowDown"?32:0);else if(r.key==="ArrowLeft"||r.key==="ArrowRight")this.azT+=r.key==="ArrowLeft"?-a:a;else if(r.key==="ArrowUp"||r.key==="ArrowDown")this.polT=Math.max(Zt,Math.min(Kt,this.polT+(r.key==="ArrowUp"?-a:a)));else if(r.key==="+"||r.key==="=")this.dollyBy(.82);else if(r.key==="-"||r.key==="_")this.dollyBy(1.22);else return;r.preventDefault(),this.fireGesture(),this.requestRender()},n.addEventListener("pointerdown",this.onPointerDown),n.addEventListener("pointermove",this.onPointerMove),n.addEventListener("pointerup",this.onPointerUp),n.addEventListener("pointercancel",this.onPointerUp),n.addEventListener("wheel",this.onWheel,{passive:!1}),n.addEventListener("keydown",this.onKeyDown),n.addEventListener("contextmenu",this.onContextMenu)}pinchCentroid(){let e=[...this.activePointers.values()];if(!e.length)return{x:0,y:0};let n=0,i=0;for(let o of e)n+=o.x,i+=o.y;return{x:n/e.length,y:i/e.length}}panBy(e,n){let i=this.canvas.clientHeight||1,o=2*this.distance*Math.tan(this.fovY*me/2)/i,r=Math.sin(this.azimuth),a=Math.cos(this.azimuth),s=a,u=-r,l=Math.cos(this.polar),h=Math.sin(this.polar),d=-r*l,f=-a*l;this.targetT.x+=(-e*s+n*d)*o,this.targetT.z+=(-e*u+n*f)*o,this.targetT.y+=n*h*o,this.clampPan(),this.requestRender()}clampPan(){if(this.panLimit<=0)return;let e=this.panLimit,n=this.panAnchor.x,i=this.panAnchor.y,o=this.panAnchor.z;this.targetT.x=Math.max(n-e,Math.min(n+e,this.targetT.x)),this.targetT.z=Math.max(o-e,Math.min(o+e,this.targetT.z)),this.targetT.y=Math.max(i-e*.5,Math.min(i+e,this.targetT.y))}fireGesture(){this.gestureFired||(this.gestureFired=!0,this.onGesture?.())}currentPinchDistance(){let e=[...this.activePointers.values()];return e.length<2?0:Math.hypot(e[0].x-e[1].x,e[0].y-e[1].y)}dollyBy(e){this.distT=Math.max(this.minDist,Math.min(this.maxDist,this.distT*e)),this.requestRender()}zoomBy(e){this.interactionEnabled&&(this.dollyBy(e),this.fireGesture())}setPrimaryDragMode(e){this.primaryDragMode=e}setInteractionEnabled(e){this.interactionEnabled=e,!e&&(this.activePointers.clear(),this.dragging=!1,this.panning=!1,this.pinchDist=0)}frame(e,n=!1,i,o=!1,r){this.target.set(e.center[0],e.center[1],e.center[2]),this.targetT.copy(this.target),this.panAnchor.copy(this.target),this.panLimit=Math.max(1,e.radius)*1.5;let a=Math.max(1,e.radius),s=this.fovY*me/2,u=o?Math.max(.82,this.camera.aspect||1):this.camera.aspect||1,l=Math.atan(Math.tan(s)*u);this.azT=i??-30*me,this.polT=Math.max(15,Math.min(80,r?.polarDeg??55))*me;let h=this.fitDistance(e,s,l,this.azT,this.polT);this.distT=h*Math.max(1.05,Math.min(2,r?.margin??Hn)),this.minDist=Math.max(2,a*.12),this.maxDist=h*4,n?(this.azimuth=this.azT,this.polar=12*me,this.distance=this.distT*1.7):(this.azimuth=this.azT,this.polar=this.polT,this.distance=this.distT),this.applyPosition()}setAspect(e){this.camera.perspective({aspect:e})}frameSoft(e,n,i=!1,o){this.target.set(e.center[0],e.center[1],e.center[2]),this.targetT.copy(this.target),this.panAnchor.copy(this.target),this.panLimit=Math.max(1,e.radius)*1.5,this.syncFromCamera(),this.camera.perspective({fov:this.fovY,aspect:this.camera.aspect});let r=this.fovY*me/2,a=i?Math.max(.82,this.camera.aspect||1):this.camera.aspect||1,s=Math.atan(Math.tan(r)*a);this.azT=n??this.azimuth,this.polT=Math.max(15,Math.min(80,o?.polarDeg??55))*me;let u=this.fitDistance(e,r,s,this.azT,this.polT);this.distT=u*Math.max(1.05,Math.min(2,o?.margin??Hn))}fitDistance(e,n,i,o,r){let a=Math.max(1,e.radius),s=Math.max(a/Math.tan(n),a/Math.tan(i)),u=e.box;if(!u)return s;let l=Math.sin(r),h=-l*Math.sin(o),d=-Math.cos(r),f=-l*Math.cos(o);if(Math.abs(d)>.999)return s;let c=-f,m=h,p=Math.hypot(c,m);c/=p,m/=p;let b=-m*d,g=m*h-c*f,y=c*d,w=Math.tan(i),E=Math.tan(n),I=1;for(let A=0;A<8;A++){let k=(A&1?u.max[0]:u.min[0])-e.center[0],B=(A&2?u.max[1]:u.min[1])-e.center[1],L=(A&4?u.max[2]:u.min[2])-e.center[2],U=k*h+B*d+L*f,N=Math.abs(k*c+L*m),z=Math.abs(k*b+B*g+L*y);I=Math.max(I,N/w-U,z/E-U)}return Math.min(s,Math.max(I,a*.35))}updateClipping(e){let n=this.camera.position.x-e.center[0],i=this.camera.position.y-e.center[1],o=this.camera.position.z-e.center[2],r=Math.hypot(n,i,o),a=Math.max(1,e.radius)*1.18,s=Math.max(.05,r-a),u=Math.max(s+10,r+a);this.camera.perspective({near:s,far:u,aspect:this.camera.aspect})}update(){let e=this.azT-this.azimuth,n=this.polT-this.polar,i=this.distT-this.distance,o=this.targetT.x-this.target.x,r=this.targetT.y-this.target.y,a=this.targetT.z-this.target.z,s=Math.max(1e-4,this.distance*1e-4),u=Math.abs(e)>1e-4||Math.abs(n)>1e-4||Math.abs(i)>1e-4||Math.abs(o)>s||Math.abs(r)>s||Math.abs(a)>s;return this.azimuth+=e*je,this.polar+=n*je,this.distance+=i*je,this.target.x+=o*je,this.target.y+=r*je,this.target.z+=a*je,u&&this.applyPosition(),u}get currentDistance(){return this.distance}syncFromCamera(){let e=this.camera.position.x-this.target.x,n=this.camera.position.y-this.target.y,i=this.camera.position.z-this.target.z,o=Math.hypot(e,n,i)||1,r=Math.max(Zt,Math.min(Kt,Math.acos(Math.max(-1,Math.min(1,n/o)))));this.distance=this.distT=o,this.polar=this.polT=r,this.azimuth=this.azT=Math.atan2(e,i)}setTarget(e){this.target.set(e[0],e[1],e[2]),this.targetT.copy(this.target)}resumeAfterFlight(e){this.camera.perspective({fov:this.fovY,aspect:this.camera.aspect}),e&&this.target.set(e[0],e[1],e[2]),this.targetT.copy(this.target),this.syncFromCamera()}applyPosition(){let e=Math.sin(this.polar),n=this.target.x+this.distance*e*Math.sin(this.azimuth),i=this.target.y+this.distance*Math.cos(this.polar),o=this.target.z+this.distance*e*Math.cos(this.azimuth);this.camera.position.set(n,i,o),this.camera.lookAt(this.target)}dispose(){this.canvas.removeEventListener("pointerdown",this.onPointerDown),this.canvas.removeEventListener("pointermove",this.onPointerMove),this.canvas.removeEventListener("pointerup",this.onPointerUp),this.canvas.removeEventListener("pointercancel",this.onPointerUp),this.canvas.removeEventListener("wheel",this.onWheel),this.canvas.removeEventListener("keydown",this.onKeyDown),this.canvas.removeEventListener("contextmenu",this.onContextMenu),this.activePointers.clear()}};var St=class{constructor(e){this.rafId=0;this.running=!1;this.lastTime=0;this.fpsEma=0;this.rendered=0;this.tick=e=>{let n=this.lastTime?(e-this.lastTime)/1e3:.016666666666666666;if(this.lastTime=e,n>0){let o=1/n;this.fpsEma=this.fpsEma?this.fpsEma*.9+o*.1:o}this.rendered++,this.frame(n)?this.rafId=requestAnimationFrame(this.tick):(this.running=!1,this.rafId=0)};this.frame=e}requestRender(){this.running||(this.running=!0,this.lastTime=0,this.rafId=requestAnimationFrame(this.tick))}stats(){return{fps:this.running?Math.round(this.fpsEma):0,rendered:this.rendered,idle:!this.running}}stop(){this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=0,this.running=!1}};var qe=2.5,Xr=1.15,at=6,Ze=10,Un=6,Yn=9.5,Xn=.9,Wn=2.2,$t=30,Qt=4,wt=8192;var ys=Ze+Qt;function jn(t,e){let n=e*1.4,i=e*3.2;if(t<=n)return{scale:1,fade:0,minPixels:qe};let o=Math.min(1,(t-n)/Math.max(.001,i-n));return{scale:1-o*.4,fade:o*.55,minPixels:qe+o*(Xr-qe)}}function qn(t,e,n){return!(t>0)||!(e>0)||!(n>0)?!1:e*n/t>=64}function Zn(t,e,n,i,o){if(!(t>0)||!(e>0)||!(n>0)||!(i>0)||!(o>0))return!1;let r=Math.tan(i/2*Math.PI/180);if(!(r>0))return!1;let a=e/(n*r)*(o/2);return Math.PI*a*a/t>=64}import Wr from"earcut";import jr from"polygon-clipping";var D=Be,qr=.002;function Zr(t,e,n){let i=Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2]),o=Math.hypot(n[0]-e[0],n[1]-e[1],n[2]-e[2]),r=Math.hypot(t[0]-n[0],t[1]-n[1],t[2]-n[2]),a=Math.max(i,o,r);if(a<1e-9)return!0;let s=(i+o+r)/2;return 2*Math.sqrt(Math.max(0,s*(s-i)*(s-o)*(s-r)))/a<qr}var Ue=class{constructor(e=16384){this.len=0;this.buf=new Float32Array(e)}push3(e,n,i){this.len+3>this.buf.length&&this.grow(this.len+3),this.buf[this.len++]=e,this.buf[this.len++]=n,this.buf[this.len++]=i}push1(e){this.len+1>this.buf.length&&this.grow(this.len+1),this.buf[this.len++]=e}grow(e){let n=this.buf.length*2;for(;n<e;)n*=2;let i=new Float32Array(n);i.set(this.buf.subarray(0,this.len)),this.buf=i}get length(){return this.len}toArray(){return this.buf.slice(0,this.len)}},Ct=class{constructor(){this.pos=new Ue;this.nor=new Ue;this.col=new Ue;this.flr=new Ue;this.mat=new Ue;this.currentFloor=0;this.currentMaterial=0}setFloor(e){this.currentFloor=e}setMaterial(e){this.currentMaterial=e}tri(e,n,i,o,r,a=r,s=r){Zr(e,n,i)||(this.pos.push3(e[0],e[1],e[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(i[0],i[1],i[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(r[0],r[1],r[2]),this.col.push3(a[0],a[1],a[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(e,n,i,o,r,a,s,u=s,l=s){[...e,...n,...i].every(Number.isFinite)&&(this.pos.push3(e[0],e[1],e[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(i[0],i[1],i[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(a[0],a[1],a[2]),this.col.push3(s[0],s[1],s[2]),this.col.push3(u[0],u[1],u[2]),this.col.push3(l[0],l[1],l[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}get vertexCount(){return this.pos.length/3}build(){return{position:this.pos.toArray(),normal:this.nor.toArray(),color:this.col.toArray(),floor:this.flr.toArray(),material:this.mat.toArray(),count:this.pos.length/3}}};function Kr(t,e,n){let i=e[0]-t[0],o=e[1]-t[1],r=e[2]-t[2],a=n[0]-t[0],s=n[1]-t[1],u=n[2]-t[2],l=o*u-r*s,h=r*a-i*u,d=i*s-o*a,f=Math.hypot(l,h,d)||1;return l/=f,h/=f,d/=f,[l,h,d]}function $r(t,e){let n=[...t],i=[];for(let a of t)i.push(a.x,a.y);let o=[];if(e){for(let a of e)if(!(a.length<3)){o.push(n.length);for(let s of a)n.push(s),i.push(s.x,s.y)}}let r=Wr(i,o.length?o:void 0,2);return{pts:n,tris:r}}function Jt(t){return Ge(t)<0?[...t].reverse():t}var Qr=3;function Jr(t,e,n,i){let o=i(t),r=i(e),a=i(n),s=(c,m,p,b)=>Math.abs(i({x:(c.x+m.x)/2,y:(c.y+m.y)/2})-(p+b)/2),u=(t.x+e.x+n.x)/3,l=(t.y+e.y+n.y)/3,h=(o+r+a)/3,d=Math.max(s(t,e,o,r),s(e,n,r,a),s(n,t,a,o),Math.abs(i({x:u,y:l})-h)),f=(c,m,p)=>{let b=Math.abs(i({x:(c+u)/2,y:(m+l)/2})-(p+h)/2);b>d&&(d=b)};return f((t.x+e.x)/2,(t.y+e.y)/2,(o+r)/2),f((e.x+n.x)/2,(e.y+n.y)/2,(r+a)/2),f((n.x+t.x)/2,(n.y+t.y)/2,(a+o)/2),d}function st(t,e,n,i,o){if(o<=0)return Jr(t,e,n,i);let r={x:(t.x+e.x)/2,y:(t.y+e.y)/2},a={x:(e.x+n.x)/2,y:(e.y+n.y)/2},s={x:(n.x+t.x)/2,y:(n.y+t.y)/2};return Math.max(st(t,r,s,i,o-1),st(r,e,a,i,o-1),st(s,a,n,i,o-1),st(r,a,s,i,o-1))}function ct(t,e,n,i,o,r,a,s){if(a>0){let f={x:(e.x+n.x)/2,y:(e.y+n.y)/2},c={x:(n.x+i.x)/2,y:(n.y+i.y)/2},m={x:(i.x+e.x)/2,y:(i.y+e.y)/2};ct(t,e,f,m,o,r,a-1,s),ct(t,f,n,c,o,r,a-1,s),ct(t,m,c,i,o,r,a-1,s),ct(t,f,c,m,o,r,a-1,s);return}let u=[e.x*D,o(e),e.y*D],l=[n.x*D,o(n),n.y*D],h=[i.x*D,o(i),i.y*D];if(s){t.triN(u,l,h,s(e),s(n),s(i),r);return}let d=Kr(u,l,h);d[1]<0&&(d=[-d[0],-d[1],-d[2]]),t.tri(u,l,h,d,r)}var ei=8;function Kn(t,e,n){if(!Number.isFinite(n))return t;let i=[],o=(r,a,s,u,l)=>{if(l>0){let h={x:(r.x+a.x)/2,y:(r.y+a.y)/2},d=e(h);if(Math.abs(d-(s+u)/2)>n){o(r,h,s,d,l-1),o(h,a,d,u,l-1);return}}i.push(r)};for(let r=0;r<t.length;r++){let a=t[r],s=t[(r+1)%t.length];o(a,s,e(a),e(s),ei)}return i}function Pt(t,e){if(t.length<3)return t;let n=[];for(let o of t){let r=n[n.length-1];r&&Math.hypot(o.x-r.x,o.y-r.y)<e||n.push(o)}for(;n.length>2&&Math.hypot(n[0].x-n[n.length-1].x,n[0].y-n[n.length-1].y)<e;)n.pop();if(n.length<3)return t;let i=[];for(let o=0;o<n.length;o++){let r=i.length?i[i.length-1]:n[(o-1+n.length)%n.length],a=n[o],s=n[(o+1)%n.length],u=s.x-r.x,l=s.y-r.y,h=Math.hypot(u,l);h>e&&Math.abs((a.x-r.x)*l-(a.y-r.y)*u)/h<e||i.push(a)}return i.length>=3?i:n}var At=.001*Oe*.1;function se(t,e,n,i,o,r,a,s,u=1/0,l){if(!e||e.length<3||(u===void 0&&(u=1/0),Math.abs(Ge(e))<1e-4))return;let h=Pt(Kn(Pt(Jt(e),At),i,u),At),d=n?.map(A=>Pt(Kn(Pt(Jt(A),At),i,u),At)).filter(A=>A.length>=3&&Math.abs(Ge(A))>=1e-4),{pts:f,tris:c}=$r(h,d),m=[r[0]*s.top,r[1]*s.top,r[2]*s.top],p=[r[0]*s.bottomCap,r[1]*s.bottomCap,r[2]*s.bottomCap],b=[a[0]*s.top,a[1]*s.top,a[2]*s.top],g=[a[0]*s.wallBottom,a[1]*s.wallBottom,a[2]*s.wallBottom],y=0;if(Number.isFinite(u))for(;y<Qr;y++){let A=0;for(let k=0;k<c.length;k+=3){let B=st(f[c[k]],f[c[k+1]],f[c[k+2]],i,y);B>A&&(A=B)}if(A<=u)break}for(let A=0;A<c.length;A+=3){let k=f[c[A]],B=f[c[A+1]],L=f[c[A+2]];ct(t,k,B,L,i,m,y,l);let U=[k.x*D,o,k.y*D],N=[B.x*D,o,B.y*D],z=[L.x*D,o,L.y*D];t.tri(U,z,N,[0,-1,0],p)}let w=A=>{if(y<=0)return A;let k=1<<y,B=[];for(let L=0;L<A.length;L++){let U=A[L],N=A[(L+1)%A.length];for(let z=0;z<k;z++){let x=z/k;B.push({x:U.x+(N.x-U.x)*x,y:U.y+(N.y-U.y)*x})}}return B},E=An(h),I=[{ring:w(h),flip:!1}];if(d)for(let A of d)A.length>=3&&I.push({ring:w(A),flip:!0});for(let{ring:A,flip:k}of I)for(let B=0;B<A.length;B++){let L=A[B],U=A[(B+1)%A.length],N=(U.x-L.x)*D,x=(U.y-L.y)*D,v=-N,S=Math.hypot(x,v)||1;x/=S,v/=S;let O=(L.x+U.x)/2-E.x,M=(L.y+U.y)/2-E.y,R=x*O+v*M;k&&(R=-R),R<0&&(x=-x,v=-v);let C=[x,0,v],T=[L.x*D,i(L),L.y*D],P=[U.x*D,i(U),U.y*D],F=[L.x*D,o,L.y*D],_=[U.x*D,o,U.y*D];t.tri(T,P,_,C,b,b,g),t.tri(T,_,F,C,b,g,g)}}function $n(t){let e=0;for(let u of t)e+=u.count;let n=new Float32Array(e*3),i=new Float32Array(e*3),o=new Float32Array(e*3),r=new Float32Array(e),a=new Float32Array(e),s=0;for(let u of t)n.set(u.position,s*3),i.set(u.normal,s*3),o.set(u.color,s*3),r.set(u.floor,s),a.set(u.material,s),s+=u.count;return{position:n,normal:i,color:o,floor:r,material:a,count:e}}function Rt(t,e,n=2.5){if(e<=0||t.length<3)return t;let i=Jt(t),o=i.length,r=[];for(let s=0;s<o;s++){let u=i[s],l=i[(s+1)%o],h=l.x-u.x,d=l.y-u.y,f=Math.hypot(h,d)||1;r.push({x:d/f,y:-h/f})}let a=[];for(let s=0;s<o;s++){let u=i[s],l=r[(s-1+o)%o],h=r[s],d=l.x+h.x,f=l.y+h.y,c=Math.hypot(d,f),m=()=>{a.push([u.x+l.x*e,u.y+l.y*e]),a.push([u.x+h.x*e,u.y+h.y*e])};if(c<1e-9){m();continue}d/=c,f/=c;let p=d*l.x+f*l.y,b=1/Math.max(p,1e-6);if(!Number.isFinite(b)||b>n){m();continue}a.push([u.x+d*e*b,u.y+f*e*b])}if(a.length<3)return t;try{let s=jr.union([[...a,a[0]]]),u=null,l=-1/0;for(let d of s){let f=Math.abs(Ge(d[0].map(([c,m])=>({x:c,y:m}))));f>l&&(l=f,u=d[0])}if(!u)return t;let h=u.map(([d,f])=>({x:d,y:f}));if(h.length>1){let d=h[0],f=h[h.length-1];Math.abs(d.x-f.x)<1e-9&&Math.abs(d.y-f.y)<1e-9&&h.pop()}return h.length>=3?h:t}catch{return t}}function It(t,e,n,i,o=28){let r=[];for(let a=0;a<o;a++){let s=a/o*Math.PI*2;r.push({x:t+n*Math.cos(s),y:e+i*Math.sin(s)})}return r}function lt(t,e,n,i){return[{x:t,y:e},{x:t+n,y:e},{x:t+n,y:e+i},{x:t,y:e+i}]}var le={pedestal:0,pad:1,back:2,body:3,head:4},ti=.44,ni=.15,oi=.3,ri=.24;function Qn(t){return t===void 0||!Number.isFinite(t)||t<=0?ri:Math.min(oi,Math.max(ni,t*ti))}var en=.21,ii=.05,tn=.45,Tt=tn+ii,ai=[{part:le.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:le.pad,min:[-1,.36,-.95],max:[1,tn,1]},{part:le.back,min:[-1,Tt,-1],max:[1,.92,-.72]}],si=[{part:le.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:le.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:le.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:le.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:le.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}],ci=[{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 Jn(){let t=[],e=[],n=[],i=[],o=(S,O,M)=>{let R=n.length,[C,T,P]=S,F=[T[0]-C[0],T[1]-C[1],T[2]-C[2]],_=[P[0]-C[0],P[1]-C[1],P[2]-C[2]],Y=F[1]*_[2]-F[2]*_[1],W=F[2]*_[0]-F[0]*_[2],G=F[0]*_[1]-F[1]*_[0],H=Math.hypot(Y,W,G);H>1e-9?(Y/=H,W/=H,G/=H):[Y,W,G]=O,Y*O[0]+W*O[1]+G*O[2]<0&&(Y=-Y,W=-W,G=-G);for(let Z of S)t.push(...Z),e.push(Y,W,G),n.push(M);i.push(R,R+1,R+2,R,R+2,R+3)},r=S=>{for(let O of ci){let M=O.c.map(R=>R.map((C,T)=>C?S.max[T]:S.min[T]));o(M,O.n,S.part)}};for(let S of ai)r(S);for(let S of si)r(S);let a=tn,s=1.08,u=.47,l=.69,h=-.55,d=.08,f=-.48,c=.01,m=[-u,a,h],p=[u,a,h],b=[-u,a,d],g=[u,a,d],y=[-l,s,f],w=[l,s,f],E=[-l,s,c],I=[l,s,c];o([p,w,I,g],[1,0,0],le.body),o([b,E,y,m],[-1,0,0],le.body),o([E,I,w,y],[0,1,0],le.body),o([m,p,g,b],[0,-1,0],le.body),o([g,I,E,b],[0,0,1],le.body),o([m,y,w,p],[0,0,-1],le.body);let A=10,k=8,B=[0,1.205,-.23],L=[.42,.115,.38],U=n.length;for(let S=0;S<=k;S++){let O=Math.PI*S/k,M=Math.cos(O),R=Math.sin(O);for(let C=0;C<=A;C++){let T=Math.PI*2*C/A,P=R*Math.cos(T),F=R*Math.sin(T);t.push(B[0]+L[0]*P,B[1]+L[1]*M,B[2]+L[2]*F);let _=P/L[0],Y=M/L[1],W=F/L[2],G=Math.hypot(_,Y,W)||1;_/=G,Y/=G,W/=G,e.push(_,Y,W),n.push(le.head)}}for(let S=0;S<k;S++)for(let O=0;O<A;O++){let M=U+S*(A+1)+O,R=M+A+1;i.push(M,R,M+1,M+1,R,R+1)}let N=new Float32Array(t),z=new Float32Array(e),x=new Float32Array(n),v=new Uint16Array(i);return{position:N,normal:z,part:x,index:v,vertexCount:n.length,indexCount:i.length}}function eo(t,e,n,i){let o=new Float32Array(e),r=l=>t[l*3],a=l=>t[l*3+2],s=0,u=(l,h)=>{let d=h-l;for(let f=l;f<h;f++){let[c,m]=i(f),p=c-r(f),b=m-a(f);if(d>=2){let g=Math.max(l,f-1),y=Math.min(h-1,f+1),w=r(y)-r(g),E=a(y)-a(g),I=Math.hypot(w,E);if(I>1e-6){let A=-E/I,k=w/I;A*p+k*b<0&&(A=-A,k=-k),p=A,b=k}}o[f]=p===0&&b===0?0:Math.atan2(p,b)}};for(let l=1;l<=e;l++)(l===e||n(l)!==n(s))&&(u(s,l),s=l);return o}var Ie=.22;function to(t,e){let n=Me[t];if(n!=="sold"&&n!=="held")return-1;let i=(e+1)*2654435761;return i^=i>>>15,i=Math.imul(i,2246822519),i^=i>>>13,(i>>>0)%1e5/1e5}var li=.42;function ui(t){let e=t.length,n=new Float64Array(e);if(e<2)return n.fill(1/0),n;let i=1/0,o=1/0,r=-1/0,a=-1/0;for(let m of t)m.x<i&&(i=m.x),m.y<o&&(o=m.y),m.x>r&&(r=m.x),m.y>a&&(a=m.y);let s=Math.max(r-i,1e-6),u=Math.max(a-o,1e-6),l=Math.max(Math.sqrt(s*u/e),1e-6),h=Math.max(1,Math.ceil(s/l)+1),d=Math.max(1,Math.ceil(u/l)+1),f=new Map,c=(m,p)=>{let b=Math.min(h-1,Math.max(0,Math.floor((m-i)/l)));return Math.min(d-1,Math.max(0,Math.floor((p-o)/l)))*h+b};for(let m=0;m<e;m++){let p=c(t[m].x,t[m].y),b=f.get(p);b?b.push(m):f.set(p,[m])}for(let m=0;m<e;m++){let p=t[m],b=Math.min(h-1,Math.max(0,Math.floor((p.x-i)/l))),g=Math.min(d-1,Math.max(0,Math.floor((p.y-o)/l))),y=1/0;for(let w=1;w<=4;w++){for(let E=g-w;E<=g+w;E++)if(!(E<0||E>=d))for(let I=b-w;I<=b+w;I++){if(I<0||I>=h||w>1&&Math.abs(E-g)<w&&Math.abs(I-b)<w)continue;let A=f.get(E*h+I);if(A)for(let k of A){if(k===m)continue;let B=Math.hypot(t[k].x-p.x,t[k].y-p.y);B<y&&(y=B)}}if(Number.isFinite(y)&&y<=w*l)break}n[m]=y}return n}function mi(t){let e=t.eyeHeightM;return Number.isFinite(e)?Math.max(0,e-yt):0}function no(t,e,n,i,o){let r=t.length,a=new Float32Array(r*3),s=new Float32Array(r),u=new Float32Array(r*3),l=new Float32Array(r),h=new Float32Array(r),d=new Float32Array(r),f=new Float32Array(r*3),c=new Map,m=ui(t);for(let p=0;p<r;p++){let b=t[p],y=(n?.seatPitchU(p)??m[p])*D;l[p]=Number.isFinite(y)?Math.max(.06,Math.min(Ie,y*li)):Ie,h[p]=Qn(Number.isFinite(y)?y:void 0),d[p]=b.wheelchairSpaceType==="no-seat"?0:1,a[p*3]=b.x*D,a[p*3+1]=n?n.seatDeckY(p):mi(b),a[p*3+2]=b.y*D,s[p]=it(e?e(b):"available");let w=ne(o?.get(b.categoryKey)??"#6e7bff")??[.43,.48,1];if(u[p*3]=w[0],u[p*3+1]=w[1],u[p*3+2]=w[2],b.accessibility?.length){let E=ne(Pn(b.accessibility));E&&(f[p*3]=E[0],f[p*3+1]=E[1],f[p*3+2]=E[2])}c.set(b.id,p)}return{count:r,iPosition:a,iState:s,iCategory:u,iMaxRadius:l,iRing:f,idToIndex:c,iChairWidth:h,iPhysicalSeat:d,iFloor:i??new Float32Array(r),iYaw:new Float32Array(r)}}var di=64;function nn(t,e){let n=[];for(let a of e){let s=t.idToIndex.get(a.seatId);if(s===void 0)continue;let u=it(a.state);t.iState[s]!==u&&(t.iState[s]=u,n.push(s))}if(!n.length)return[];n.sort((a,s)=>a-s);let i=[],o=n[0],r=n[0];for(let a=1;a<n.length;a++){let s=n[a];if(s!==r){if(s<=r+di){r=s;continue}i.push({start:o,length:r-o+1}),o=s,r=s}}return i.push({start:o,length:r-o+1}),i}var hi=.15,fi=.9,pi=1.76,bi=.7,yi=1.6;function xi(){return{background:{top:[...He.top],bottom:[...He.bottom]},structure:jt,seatStates:{...zn},seatScale:1}}function oo(t){let e=xi();if(!t)return e;let n=ne(t.background);if(n){e.background={top:pe(n,fi),bottom:pe(n,pi)};let r={};for(let[a,s]of Object.entries(jt))r[a]=fe(s,n,hi);e.structure=r}let i=ne(t.selectionColor)??ne(t.accent);i&&(e.seatStates={...e.seatStates,selected:i});let o=t.seatScale;return typeof o=="number"&&Number.isFinite(o)&&(e.seatScale=Math.min(yi,Math.max(bi,o))),e}function ro(t,e){let n=[];for(let i of e)n.push(...t.seatStates[i]);return n}function gi(t){return{kind:"radial",rowCount:0,rows:[],nearestRow:()=>-1,depthAt:(e,n)=>Math.hypot(e-t.x,n-t.y),gradientAt:(e,n)=>{let i=e-t.x,o=n-t.y,r=Math.hypot(i,o);return r<1e-9?[0,0]:[i/r,o/r]}}}function vi(t,e){if(!t.length)return null;let n=0,i=0,o=0;for(let c of t)n+=c.x,i+=c.y,o+=Math.hypot(c.x-e.x,c.y-e.y);let r=t.length;n/=r,i/=r,o/=r;let a=t[0],s=-1;for(let c of t){let m=Math.hypot(c.x-n,c.y-i);m>s&&(s=m,a=c)}let u=a.x-n,l=a.y-i,h=Math.hypot(u,l);h>1e-9?(u/=h,l/=h):(u=1,l=0);let d=[...t].sort((c,m)=>(c.x-n)*u+(c.y-i)*l-((m.x-n)*u+(m.y-i)*l)),f=0;for(let c of d){let m=Math.hypot(c.x-n,c.y-i);m>f&&(f=m)}return{pts:d,cx:n,cy:i,radius:f,depth:o}}function io(t,e,n){let i=t.pts;if(i.length===1)return Math.hypot(e-i[0].x,n-i[0].y);let o=1/0;for(let r=0;r+1<i.length;r++){let a=i[r],s=i[r+1],u=s.x-a.x,l=s.y-a.y,h=u*u+l*l,d=h>1e-12?((e-a.x)*u+(n-a.y)*l)/h:0;d<0?d=0:d>1&&(d=1);let f=Math.hypot(e-(a.x+d*u),n-(a.y+d*l));f<o&&(o=f)}return o}var Ft=8;function Mi(t,e,n){let i=new Array(Ft).fill(1/0),o=new Array(Ft).fill(-1);for(let h=0;h<t.length;h++){let d=t[h],f=Math.hypot(e-d.cx,n-d.cy)-d.radius;for(let c=0;c<Ft;c++)if(f<i[c]){for(let m=Ft-1;m>c;m--)i[m]=i[m-1],o[m]=o[m-1];i[c]=f,o[c]=h;break}}let r=new Array(3).fill(1/0),a=new Array(3).fill(-1);for(let h of o){if(h<0)continue;let d=io(t[h],e,n);for(let f=0;f<3;f++)if(d<r[f]){for(let c=2;c>f;c--)r[c]=r[c-1],a[c]=a[c-1];r[f]=d,a[f]=h;break}}if(a[0]<0)return 0;if(r[0]<1e-6)return t[a[0]].depth;let s=r[0]*2.2,u=0,l=0;for(let h=0;h<3;h++){let d=a[h];if(d<0||r[h]>s)continue;let f=1/(r[h]*r[h]);u+=f*t[d].depth,l+=f}return l>0?u/l:t[a[0]].depth}function Si(t){let e=(i,o)=>Mi(t,i,o),n=(i,o)=>{let r=1/0,a=-1;for(let s=0;s<t.length;s++){let u=t[s];if(Math.hypot(i-u.cx,o-u.cy)-u.radius>=r)continue;let l=io(u,i,o);l<r&&(r=l,a=s)}return a};return{kind:"rows",rowCount:t.length,rows:t,nearestRow:n,depthAt:e,gradientAt:(i,o)=>{let r=(e(i+.5,o)-e(i-.5,o))/1,a=(e(i,o+.5)-e(i,o-.5))/(2*.5),s=Math.hypot(r,a);return s<1e-9?[0,0]:[r/s,a/s]}}}function ao(t,e){let n=[];for(let i of t){let o=vi(i.points,e);o&&n.push(o)}return n.length<2?gi(e):(n.sort((i,o)=>i.depth-o.depth),Si(n))}import uo from"polygon-clipping";import wi from"earcut";var Pi=.58,so=.01,be=Ie*1.5*Oe,Ai=.5,Ci=.6;function Ri(t,e){let n=t.length,i=[];for(let a=0;a<n;a++){let s=t[Math.max(0,a-1)],u=t[Math.min(n-1,a+1)],l=u.x-s.x,h=u.y-s.y,d=Math.hypot(l,h);if(d<1e-9){i.push([0,0]);continue}l/=d,h/=d,i.push([-h,l])}let o=0;for(let a=0;a<n;a++)o+=(t[a].x-e.x)*i[a][0]+(t[a].y-e.y)*i[a][1];return o<0?i.map(([a,s])=>[-a,-s]):i}function Ii(t,e){if(t.length<2||e<=0)return[...t];let n=[...t],i=(a,s)=>{let u=s.x-a.x,l=s.y-a.y,h=Math.hypot(u,l)||1;return{x:u/h,y:l/h}},o=i(n[1],n[0]),r=i(n[n.length-2],n[n.length-1]);return n.unshift({x:n[0].x+o.x*e,y:n[0].y+o.y*e}),n.push({x:n[n.length-1].x+r.x*e,y:n[n.length-1].y+r.y*e}),n}var co=Math.PI/12;function Ti(t){if(t.length<3)return[...t];let e=[...t].sort((r,a)=>r.x-a.x||r.y-a.y),n=(r,a,s)=>(a.x-r.x)*(s.y-r.y)-(a.y-r.y)*(s.x-r.x),i=r=>{let a=[];for(let s of r){for(;a.length>=2&&n(a[a.length-2],a[a.length-1],s)<=0;)a.pop();a.push(s)}return a.pop(),a},o=[...i(e),...i([...e].reverse())];return o.length>=3?o:[...t]}function mo(t,e){if(!t.length||!(e>0))return[];let n=Ti(t),i=(s,u,l,h)=>{let d=l-u;for(;d<0;)d+=Math.PI*2;for(;d>Math.PI*2;)d-=Math.PI*2;let f=Math.max(1,Math.ceil(d/co)),c=e/Math.cos(d/f/2);for(let m=0;m<=f;m++){let p=u+d*m/f;h.push({x:s.x+Math.cos(p)*c,y:s.y+Math.sin(p)*c})}};if(n.length<3){let s=0,u=0;for(let c of n)s+=c.x,u+=c.y;s/=n.length||1,u/=n.length||1;let l=0;for(let c of n)l=Math.max(l,Math.hypot(c.x-s,c.y-u));let h=[],d=Math.max(3,Math.ceil(Math.PI*2/co)),f=(l+e)/Math.cos(Math.PI/d);for(let c=0;c<d;c++){let m=c/d*Math.PI*2;h.push({x:s+Math.cos(m)*f,y:u+Math.sin(m)*f})}return h}let o=n.length,r=[];for(let s=0;s<o;s++){let u=n[s],l=n[(s+1)%o];r.push(Math.atan2(-(l.x-u.x),l.y-u.y))}let a=[];for(let s=0;s<o;s++)i(n[s],r[(s+o-1)%o],r[s],a);return yo(a)}function Fi(t,e,n){if(t.length===1)return Math.hypot(e-t[0].x,n-t[0].y);let i=1/0;for(let o=0;o+1<t.length;o++){let r=t[o],a=t[o+1],s=a.x-r.x,u=a.y-r.y,l=s*s+u*u,h=l>1e-12?((e-r.x)*s+(n-r.y)*u)/l:0;h<0?h=0:h>1&&(h=1);let d=Math.hypot(e-(r.x+h*s),n-(r.y+h*u));d<i&&(i=d)}return i}function Dt(t){let e=t.map(o=>{let r=0,a=0;for(let l of o.pts)r+=l.x,a+=l.y;let s=o.pts.length||1;r/=s,a/=s;let u=0;for(let l of o.pts){let h=Math.hypot(l.x-r,l.y-a);h>u&&(u=h)}return{cx:r,cy:a,rad:u}}),n=o=>{let r=o.length;return r<=2?[...o]:[o[Math.floor(r*.25)],o[Math.floor(r*.5)],o[Math.floor(r*.75)]]},i=[];for(let o=0;o<t.length;o++){let r=n(t[o].pts),a=[],s=1/0,u=null;for(let h of r){let d=1/0;for(let f=0;f<t.length;f++){if(f===o||Math.abs(t[f].y-t[o].y)<.001)continue;let c=e[f],m=Math.hypot(h.x-c.cx,h.y-c.cy)-c.rad;if(m>=d&&m>=s)continue;let p=Fi(t[f].pts,h.x,h.y);p<d&&(d=p),t[f].depth<t[o].depth&&p<s&&(s=p,u=t[f].y)}Number.isFinite(d)&&d>0&&a.push(d)}a.sort((h,d)=>h-d);let l=a.length?a[Math.floor(a.length/2)]:1;i.push({pitch:l,belowY:u})}return i}function ho(t,e,n,i){let o=t[e],r=o.pts.length>=2?[...o.pts]:o.pts.length===1?(()=>{let h=o.pts[0],d=h.x-i.x,f=h.y-i.y,c=Math.hypot(d,f)||1;d/=c,f/=c;let m=Math.max(n[e].pitch,.001)*.5;return[{x:h.x+f*m,y:h.y-d*m},{x:h.x-f*m,y:h.y+d*m}]})():[];if(r.length<2)return null;let a=0,s=0;for(let h=1;h<r.length;h++){let d=Math.hypot(r[h].x-r[h-1].x,r[h].y-r[h-1].y);d>1e-6&&(a+=d,s++)}let u=s>0?a/s:0,l=Ii(r,Math.max(u*Ci,be));return{pts:l,nrm:Ri(l,i),front:Math.max(n[e].pitch*Pi,be),back:Math.max(n[e].pitch*Ai,be)}}var Ke=1.5,fo=.3;function on(t,e){if(t.length<3)return t;let n=t[0],i=t[t.length-1],o=i.x-n.x,r=i.y-n.y,a=Math.hypot(o,r),s=-1,u=-1;for(let d=1;d<t.length-1;d++){let f=t[d],c=a>1e-12?Math.abs((f.x-n.x)*r-(f.y-n.y)*o)/a:Math.hypot(f.x-n.x,f.y-n.y);c>s&&(s=c,u=d)}if(s<=e||u<0)return[n,i];let l=on(t.slice(0,u+1),e),h=on(t.slice(u),e);return[...l.slice(0,-1),...h]}function po(t,e){if(t.length<4)return t;let n=on([...t,t[0]],e);return n.pop(),n.length>=3?n:t}function bo(t,e,n){if(t.length<2)return[];let i=n??Dt(t),o=new Map;for(let a=0;a<t.length;a++){let s=o.get(t[a].blockId);s?s.push(a):o.set(t[a].blockId,[a])}let r=[];for(let[,a]of o){let s=[];for(let y of a){let w=t[y].patch;w&&w.length>=3?r.push({outline:[...w],holes:[],topY:t[y].y}):s.push(y)}if(!s.length)continue;s.sort((y,w)=>t[y].depth-t[w].depth);let l=s.map(y=>ho(t,y,i,e)).filter(y=>y!==null);if(!l.length)continue;let h=(y,w)=>({x:y.pts[w].x-y.nrm[w][0]*(y.front+Ke),y:y.pts[w].y-y.nrm[w][1]*(y.front+Ke)}),d=(y,w)=>({x:y.pts[w].x+y.nrm[w][0]*(y.back+Ke),y:y.pts[w].y+y.nrm[w][1]*(y.back+Ke)}),f=l[0],c=l[l.length-1],m=[];for(let y=0;y<f.pts.length;y++)m.push(h(f,y));for(let y of l)m.push(d(y,y.pts.length-1));for(let y=c.pts.length-1;y>=0;y--)m.push(d(c,y));for(let y=l.length-1;y>=0;y--)m.push(h(l[y],0));let p=yo(m),b=1/0;for(let y of s)t[y].y<b&&(b=t[y].y);if(!Number.isFinite(b))continue;if(p.length>=3&&Math.abs(Ge(p))>1e-6&&l.every(y=>{let w=y.pts[Math.floor(y.pts.length/2)];return rt(p,w.x,w.y)})){r.push({outline:po(p,fo),holes:[],topY:b});continue}for(let y of Di(l))r.push({outline:y,holes:[],topY:b})}return r}function Di(t){let e=[];for(let n of t){let i=[],o=[],r=n.front+Ke,a=n.back+Ke;for(let u=0;u<n.pts.length;u++){let l=n.pts[u],h=n.nrm[u];i.push([l.x-h[0]*r,l.y-h[1]*r]),o.push([l.x+h[0]*a,l.y+h[1]*a])}let s=[...i,...o.reverse()];s.length<3||(s.push(s[0]),e.push([s]))}if(!e.length)return[];try{let n=uo.union(e[0],...e.slice(1)),i=[];for(let o of n){if(!o.length||o[0].length<4)continue;let r=o[0].map(([u,l])=>({x:u,y:l})),a=r[0],s=r[r.length-1];r.length>1&&Math.abs(a.x-s.x)<1e-9&&Math.abs(a.y-s.y)<1e-9&&r.pop(),r.length>=3&&i.push(po(r,fo))}return i}catch{return[]}}function yo(t){let e=[];for(let n of t){let i=e[e.length-1];i&&Math.hypot(n.x-i.x,n.y-i.y)<1e-9||e.push(n)}for(;e.length>2&&Math.hypot(e[0].x-e[e.length-1].x,e[0].y-e[e.length-1].y)<1e-9;)e.pop();return e}var rn=class{constructor(e){this.minX=1/0;this.minY=1/0;this.maxX=-1/0;this.maxY=-1/0;this.rings=e;for(let n of e)for(let i of n)i.x<this.minX&&(this.minX=i.x),i.y<this.minY&&(this.minY=i.y),i.x>this.maxX&&(this.maxX=i.x),i.y>this.maxY&&(this.maxY=i.y)}containsAll(e){for(let n of e)if(n.x<this.minX||n.x>this.maxX||n.y<this.minY||n.y>this.maxY)return!1;for(let n of this.rings){let i=!0;for(let o of e)if(!rt(n,o.x,o.y)){i=!1;break}if(i)return!0}return!1}};function lo(t,e,n,i,o,r){if(i.length<3)return;if(n.containsAll(i)){let l=[0,1,0],h=i[0];for(let d=1;d+1<i.length;d++){let f=i[d],c=i[d+1];t.tri([h.x*D,o,h.y*D],[f.x*D,o,f.y*D],[c.x*D,o,c.y*D],l,r)}return}let a=i.map(l=>[l.x,l.y]);a.push(a[0]);let s;try{s=uo.intersection([a],e)}catch{return}let u=[0,1,0];for(let l of s){if(!l.length||l[0].length<4)continue;let h=l[0],d=[],f=[];for(let m=0;m<h.length-1;m++)d.push(h[m][0],h[m][1]),f.push([h[m][0],h[m][1]]);if(f.length<3)continue;let c=wi(d,void 0,2);for(let m=0;m<c.length;m+=3){let p=f[c[m]],b=f[c[m+1]],g=f[c[m+2]];t.tri([p[0]*D,o,p[1]*D],[b[0]*D,o,b[1]*D],[g[0]*D,o,g[1]*D],u,r)}}}function xo(t,e,n,i,o,r,a){if(e.length<2)return;let s=a??Dt(e),u=[0,1,0],l=r&&r.length>=3?[[...r.map(c=>[c.x,c.y]),[r[0].x,r[0].y]]]:null,h=r&&r.length>=3?new rn([[...r]]):null,d=c=>{t.setMaterial(2),c(),t.setMaterial(0)},f=c=>{t.setMaterial(3),c(),t.setMaterial(0)};for(let c=0;c<e.length;c++){let m=e[c];if(m.patch&&m.patch.length>=3){let I=[...m.patch],A=s[c].belowY??i;if(f(()=>{if(l&&h)lo(t,l,h,I,m.y,o.tread);else{let k=I[0];for(let B=1;B+1<I.length;B++){let L=I[B],U=I[B+1];t.tri([k.x*D,m.y,k.y*D],[L.x*D,m.y,L.y*D],[U.x*D,m.y,U.y*D],u,o.tread)}}}),m.y>A+so){let k=0,B=0;for(let L of I)k+=L.x,B+=L.y;k/=I.length,B/=I.length,d(()=>{for(let L=0;L<I.length;L++){let U=I[L],N=I[(L+1)%I.length],z=N.x-U.x,x=N.y-U.y,v=Math.hypot(z,x);if(v<1e-6)continue;let S=x/v,O=-z/v;(U.x-k)*S+(U.y-B)*O<0&&(S=-S,O=-O);let M=[S,0,O],R=[U.x*D,m.y,U.y*D],C=[N.x*D,m.y,N.y*D],T=[U.x*D,A,U.y*D],P=[N.x*D,A,N.y*D];t.tri(R,C,P,M,o.riser),t.tri(R,P,T,M,o.riser)}})}continue}let p=ho(e,c,s,n);if(!p)continue;let{pts:b,nrm:g,front:y,back:w}=p,E=s[c].belowY??i;for(let I=0;I+1<b.length;I++){let A=b[I],k=b[I+1],B=g[I],L=g[I+1];if(Math.hypot(k.x-A.x,k.y-A.y)<1e-6||B[0]===0&&B[1]===0||L[0]===0&&L[1]===0)continue;let U=[(A.x-B[0]*y)*D,m.y,(A.y-B[1]*y)*D],N=[(k.x-L[0]*y)*D,m.y,(k.y-L[1]*y)*D],z=[(A.x+B[0]*w)*D,m.y,(A.y+B[1]*w)*D],x=[(k.x+L[0]*w)*D,m.y,(k.y+L[1]*w)*D];if(f(()=>{l&&h?lo(t,l,h,[{x:A.x-B[0]*y,y:A.y-B[1]*y},{x:k.x-L[0]*y,y:k.y-L[1]*y},{x:k.x+L[0]*w,y:k.y+L[1]*w},{x:A.x+B[0]*w,y:A.y+B[1]*w}],m.y,o.tread):(t.tri(U,N,x,u,o.tread),t.tri(U,x,z,u,o.tread))}),m.y>E+so){let v=[U[0],E,U[2]],S=[N[0],E,N[2]],O=[-B[0],0,-B[1]];d(()=>{t.tri(U,N,S,O,o.riser),t.tri(U,S,v,O,o.riser)})}}}}import vo from"polygon-clipping";function ki(t,e){let n=t.eventConfigurationIds;return!n?.length||!!e&&n.includes(e)}function go(t,e){return t.filter(n=>n.type!=="shape"||ki(n,e))}function Mo(t,e){let n=t.focalPoint??{x:0,y:0};return t.floors?.length?t.floors.map((i,o)=>({objects:go(i.objects,e),focal:{x:(i.focalPoint??n).x,y:(i.focalPoint??n).y},baseHeightM:i.baseHeightM??0,index:o})):[{objects:go(t.objects,e),focal:n,baseHeightM:0,index:0}]}var Ei={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function $e(t){return Dn(t)??Ei}function So(t,e){let n=Rt(t.outline,be),i=$e(n),o=e.filter(a=>a!==t&&a.outline&&a.outline.length>=3&&gt(i,$e(a.outline)));if(!o.length)return[n];let r=a=>{let s=a.map(u=>[u.x,u.y]);return s.push(s[0]),s};try{let a=vo.difference([r(n)],...o.map(u=>[r(u.outline)])),s=[];for(let u of a){if(!u.length)continue;let l=u[0].map(([h,d])=>({x:h,y:d}));if(l.length>1){let h=l[0],d=l[l.length-1];Math.abs(h.x-d.x)<1e-9&&Math.abs(h.y-d.y)<1e-9&&l.pop()}l.length>=3&&s.push(l)}return s.length?s:[n]}catch{return[n]}}function wo(t,e){if(!e.length)return t;let n=r=>{let a=r.map(s=>[s.x,s.y]);return a.push(a[0]),a},i=e.map(r=>[n(r)]),o=[];for(let r of t){let a;try{a=vo.intersection([n(r.outline)],i.flat())}catch{o.push(r);continue}for(let s of a){if(!s.length)continue;let u=s[0].map(([l,h])=>({x:l,y:h}));if(u.length>1){let l=u[0],h=u[u.length-1];Math.abs(l.x-h.x)<1e-9&&Math.abs(l.y-h.y)<1e-9&&u.pop()}u.length>=3&&o.push({outline:u,holes:[],topY:r.topY})}}return o.length?o:t}var _i=.05,Po=.05,Li=.15,an=25;function Ao(t,e,n){let i=new Map,o=new Array(e.length).fill(null),r=new Float64Array(e.length),a=new Array(e.length).fill(void 0),s=new Array(e.length).fill(void 0),u=new Map,l=[],h=new Set;for(let d=0;d<t.length;d+=1){let f=t[d];for(let c of f.objects){if(c.type==="table"&&h.add(c.id),c.type!=="section"||!c.outline||c.outline.length<3)continue;let m=Rt(c.outline,be);u.set(c.id,{section:c,unit:f,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),l.push({id:c.id,floorIndex:d,box:$e(m),section:c,unit:f,outline:m})}}for(let d=0;d<e.length;d++){let f=e[d];for(let c of l){if(n&&c.floorIndex!==n[d]||f.x<c.box.minX||f.x>c.box.maxX||f.y<c.box.minY||f.y>c.box.maxY||!Tn({x:f.x,y:f.y},c.outline,c.section.holes))continue;o[d]=c.id;let m=u.get(c.id);m.hasSeats=!0;let p=f.focalPoint??c.unit.focal,b=Math.hypot(f.x-p.x,f.y-p.y);b<m.frontU&&(m.frontU=b),m.seatIndices.push(d);let g=f.rowId||`__seat-${d}`,y=m.rows.get(g);y?y.push({x:f.x,y:f.y}):m.rows.set(g,[{x:f.x,y:f.y}]);break}}for(let[d,f]of u){let c=Cn(f.section,{floorBaseHeightM:f.unit.baseHeightM}),m=f.unit.baseHeightM,p=c.rake>0?Math.tan(c.rake*Math.PI/180):0,b=c.rake<=.01&&c.height<=m+.001,g=f.section.surfaceKind,y=g==="flat"?!0:g==="rakedRows"&&c.rake>.01?!1:b,w=f.hasSeats?In(d,e,f.seatIndices,f.unit.focal):{sectionId:d,rows:[],blockCount:0},I=w.rows.length<2?ao([...f.rows.values()].map(M=>({points:M})),f.unit.focal):null,A=1/0;if(I){if(f.hasSeats)for(let M of f.rows.values())for(let R of M){let C=I.depthAt(R.x,R.y);C<A&&(A=C)}if(!f.hasSeats||!Number.isFinite(A)){A=1/0;for(let M of f.section.outline){let R=I.depthAt(M.x,M.y);R<A&&(A=R)}}}let k=m+_i,B=Math.max(k,c.height),L=M=>{let R=Math.max(0,M-A)*Be,C=Math.min(R*p,an);return Math.max(k,c.height+C)},U=M=>{let R=Math.max(0,M)*Be,C=Math.min(R*p,an);return Math.max(k,c.height+C)},N=y?[]:w.rows.map(M=>({pts:M.pts,y:U(M.blockDepth),depth:M.blockDepth,blockId:M.blockId,...h.has(M.id)?{patch:mo(M.pts,be)}:{}})),z=N.length?N[0].y:B,x=N.map(M=>{let R=M.patch&&M.patch.length>=3?M.patch:M.pts,C=0,T=0;for(let _ of R)C+=_.x,T+=_.y;let P=R.length||1;C/=P,T/=P;let F=0;for(let _ of R){let Y=Math.hypot(_.x-C,_.y-T);Y>F&&(F=Y)}return{cx:C,cy:T,rad:F}}),v=y?()=>B:N.length>=2?(M,R)=>{let C=1/0,T=z;for(let P=0;P<N.length;P++){let F=x[P];if(Math.hypot(M-F.cx,R-F.cy)-F.rad>=C)continue;let _=N[P].patch,Y=_&&_.length>=3?rt(_,M,R)?0:xt(_,M,R):xt(N[P].pts,M,R);Y<C&&(C=Y,T=N[P].y)}return T}:(M,R)=>I?L(I.depthAt(M,R)):B,S=[0,1,0],O=N.length>=2||y?()=>S:(M,R)=>{if(!I)return S;let C=I.depthAt(M,R);if(C<=A)return S;let T=(C-A)*Be;if(T*p>=an||c.height+T*p<=k)return S;let[P,F]=I.gradientAt(M,R);if(P===0&&F===0)return S;let _=1/Math.hypot(p,1);return[-P*p*_,_,-F*p*_]};if(!y)for(let M of w.rows){let R=U(M.blockDepth);for(let C of M.seatIndices)a[C]=R}for(let M of w.rows){let R=[];for(let _=1;_<M.pts.length;_++){let Y=Math.hypot(M.pts[_].x-M.pts[_-1].x,M.pts[_].y-M.pts[_-1].y);Y>1e-6&&R.push(Y)}R.sort((_,Y)=>_-Y);let C=R.length?R[Math.floor(R.length/2)]:1/0,T=1/0,P=M.pts[Math.floor(M.pts.length/2)];if(P)for(let _ of w.rows){if(_===M||_.blockId!==M.blockId)continue;let Y=xt(_.pts,P.x,P.y);Y>1e-6&&Y<T&&(T=Y)}let F=Math.min(C,Math.max(T,C*.5));if(Number.isFinite(F)&&F>0)for(let _ of M.seatIndices)s[_]=F}i.set(d,{sectionId:d,deckAt:v,normalAt:O,flat:y,bottomY:m,rowLevels:N,landingY:z})}for(let d=0;d<e.length;d++){let f=o[d],c=e[d];if(f){let p=a[d];r[d]=(p??i.get(f).deckAt(c.x,c.y))+Li;continue}let m=c.eyeHeightM;r[d]=Number.isFinite(m)?Math.max(0,m-yt):0}return{bySection:i,seatOwner:o,seatDeckY:d=>r[d],seatPitchU:d=>s[d]}}var ae={top:1,wallBottom:.5,bottomCap:.4};function Te(t,e){if(!t)return e;let n=pe(ot(t,.4),.62);return fe(e,n,.72)}function Co(t,e){let n=new Map;for(let r of t.categories??[])n.set(r.key,r.color);let i=new Map;for(let r of e){if(!r.sectionId)continue;let a=i.get(r.sectionId);a||(a=new Map,i.set(r.sectionId,a)),a.set(r.categoryKey,(a.get(r.categoryKey)??0)+1)}let o=new Map;for(let[r,a]of i){let s=0,u=0,l=0,h=0;for(let[d,f]of a){let c=ne(n.get(d));c&&(s+=c[0]*f,u+=c[1]*f,l+=c[2]*f,h+=f)}h>0&&o.set(r,[s/h,u/h,l/h])}return o}function Ro(t,e){return ne(t.color)??e.get(t.logicalSectionId??t.id)??null}import Bi from"polygon-clipping";function Oi(t,e){return t===void 0||e===void 0?!0:Math.abs(t-e)<.001}var kt=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(e,n){let i=e.map(u=>[u.x,u.y]);if(i.length<3)return[];i.push(i[0]);let o=$e(e),r=this.rings.filter((u,l)=>gt(o,this.boxes[l])&&Oi(n,this.levels[l])),a=[[i]];if(r.length)try{a=Bi.difference([i],...r).map(l=>l.map(h=>h.map(([d,f])=>[d,f])))}catch{a=[[i]]}this.rings.push([i]),this.boxes.push(o),this.levels.push(n);let s=[];for(let u of a){if(!u.length)continue;let l=u[0].map(([h,d])=>({x:h,y:d}));if(l.length>1){let h=l[0],d=l[l.length-1];Math.abs(h.x-d.x)<1e-9&&Math.abs(h.y-d.y)<1e-9&&l.pop()}l.length>=3&&s.push(l)}return s}};function Ni(t,e){if(!e)return t;let n=1/0,i=-1/0,o=1/0,r=-1/0;for(let d of t)n=Math.min(n,d.x),i=Math.max(i,d.x),o=Math.min(o,d.y),r=Math.max(r,d.y);let a=(n+i)/2,s=(o+r)/2,u=e*Math.PI/180,l=Math.cos(u),h=Math.sin(u);return t.map(d=>{let f=d.x-a,c=d.y-s;return{x:a+f*l-c*h,y:s+f*h+c*l}})}function ut(t){let e=null;if(t.kind==="polygon"&&t.points&&t.points.length>=3&&(e=t.points),t.kind==="rect"&&t.width&&t.height&&(e=lt(t.x??0,t.y??0,t.width,t.height)),t.kind==="ellipse"&&t.width&&t.height){let n=(t.x??0)+t.width/2,i=(t.y??0)+t.height/2;e=It(n,i,t.width/2,t.height/2)}return e?Ni(e,t.rotation):null}function mt(t){let e=t.role??"",i={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}}[e]??{kind:"plate",heightM:.25};return{...i,heightM:t.heightM??i.heightM}}var zi=.08;function Io(t,e){let n=ut(t),i=mt(t),o=i.heightM;if(!n||i.kind!=="plate"&&i.kind!=="stage")return o;let r=1/0,a=1/0,s=-1/0,u=-1/0;for(let h of n)r=Math.min(r,h.x),a=Math.min(a,h.y),s=Math.max(s,h.x),u=Math.max(u,h.y);let l=o;for(let h of e)s>h.minX&&r<h.maxX&&u>h.minY&&a<h.maxY&&l<=h.topOffsetM+1e-6&&(l=h.topOffsetM+zi);return e.push({minX:r,minY:a,maxX:s,maxY:u,topOffsetM:l}),l}function Ne(t,e,n){return{x:t.x+(e.x-t.x)*n,y:t.y+(e.y-t.y)*n}}function To(t){if(t.length!==4)return t;let e=Math.hypot(t[1].x-t[0].x,t[1].y-t[0].y),n=Math.hypot(t[2].x-t[1].x,t[2].y-t[1].y);return e>=n?t:[t[1],t[2],t[3],t[0]]}function dt(t,e,n){return[Ne(t[0],t[1],e),Ne(t[0],t[1],n),Ne(t[3],t[2],n),Ne(t[3],t[2],e)]}function Fo(t,e,n){return[Ne(t[0],t[3],e),Ne(t[1],t[2],e),Ne(t[1],t[2],n),Ne(t[0],t[3],n)]}function Fe(t,e,n,i,o,r){se(t,e,void 0,()=>n,i,o,r,ae)}var sn=2.4,Vi=.75,Gi=.15;function ht(t){if(t.points&&t.points.length>=3)return t.points;let{center:e,width:n,height:i,rotation:o}=t;if(!n||!i)return null;let r=(o??0)*Math.PI/180,a=Math.cos(r),s=Math.sin(r),u=n/2,l=i/2;return[[-u,-l],[u,-l],[u,l],[-u,l]].map(([h,d])=>({x:e.x+h*a-d*s,y:e.y+h*s+d*a}))}function Do(t,e,n,i,o){let r=ht(e);r&&se(t,r,void 0,()=>n+sn,n,Te(i,o.boothTop),o.boothWall,ae)}function cn(t){if(t.shape==="round"){let h=t.radius;return h?It(t.center.x,t.center.y,h,h,24):null}let{width:e,height:n,rotation:i,center:o}=t;if(!e||!n)return null;let r=(i??0)*Math.PI/180,a=Math.cos(r),s=Math.sin(r),u=e/2,l=n/2;return[[-u,-l],[u,-l],[u,l],[-u,l]].map(([h,d])=>({x:o.x+h*a-d*s,y:o.y+h*s+d*a}))}function ko(t,e,n,i,o){let r=cn(e);r&&se(t,r,void 0,()=>n+Vi,n,Te(i,o.tableTop),o.tableWall,ae)}function Eo(t,e,n,i,o,r,a){let s=ut(e);if(!s)return;let u=e.role==="stage",l=mt(e),h=n+i;if(u&&a){let p=1/0,b=-1/0,g=1/0,y=-1/0;for(let w of s)w.x<p&&(p=w.x),w.x>b&&(b=w.x),w.y<g&&(g=w.y),w.y>y&&(y=w.y);a.push({cx:(p+b)/2*D,cz:(g+y)/2*D,y:h,halfX:Math.max((b-p)/2*D,.5),halfZ:Math.max((y-g)/2*D,.5)})}let d=ne(e.fill),f=u&&d?fe(o.stageTop,pe(ot(d,.18),.9),.9):Te(d,u?o.stageTop:o.decorTop),c=e.role==="screen"?d:null,m=u?d?fe(o.stageWall,pe(d,.58),.82):o.stageWall:e.role==="screen"?c?fe(pe(c,1.42),[.24,.46,.82],.08):[.24,.46,.82]:Te(ne(e.fill),o.decorWall);if(l.kind==="portal"&&s.length===4){let p=To(s);Fe(t,dt(p,0,.16),h,n,f,m),Fe(t,dt(p,.84,1),h,n,f,m),Fe(t,p,h,Math.max(n,h-.35),f,m);return}if(l.kind==="suite"&&s.length===4){let p=s.map((y,w)=>{let E=s[(w+1)%4],I=(y.x+E.x)/2,A=(y.y+E.y)/2;return Math.hypot(I-r.x,A-r.y)}),b=p.indexOf(Math.min(...p)),g=[0,1,2,3].map(y=>s[(b+y)%4]);Fe(t,dt(g,0,.08),h,n,f,m),Fe(t,dt(g,.92,1),h,n,f,m),Fe(t,Fo(g,.88,1),h,n,f,m),Fe(t,g,h,Math.max(n,h-.18),f,m);return}Fe(t,s,h,n,f,m)}function ln(t){let{x:e,y:n,width:i,height:o}=t;if(!i||!o)return null;let r=e+i/2,a=n+o/2,s=(t.rotation??0)*Math.PI/180,u=Math.cos(s),l=Math.sin(s),h=i/2,d=o/2;return[[-h,-d],[h,-d],[h,d],[-h,d]].map(([f,c])=>({x:r+f*u-c*l,y:a+f*l+c*u}))}function Hi(t){if(!t||!t.startsWith("data:image/svg+xml"))return null;let e=t.slice(t.indexOf(",")+1);if(/;base64/i.test(t.slice(0,t.indexOf(","))))try{e=atob(e)}catch{return null}else try{e=decodeURIComponent(e)}catch{}let n=e.match(/<(?:rect|path)\b[^>]*\bfill="([^"]+)"/i);if(!n)return null;let i=n[1].trim();if(i==="none"||i==="transparent")return null;let o=i.match(/^url\(#([^)]+)\)$/);if(!o)return ne(i);let r=e.match(new RegExp(`<(?:linear|radial)Gradient\\b[^>]*\\bid="${o[1]}"[^>]*>([\\s\\S]*?)</(?:linear|radial)Gradient>`,"i"));if(!r)return null;let a=[];for(let s of r[1].matchAll(/stop-color="([^"]+)"/gi)){let u=ne(s[1].trim());u&&a.push(u)}return a.length?a.reduce((s,u,l)=>fe(s,u,1/(l+1)),a[0]):null}function _o(t,e,n,i){if(e.layer==="foreground")return;let o=ln(e);if(!o)return;let r=n+Gi,a=Te(Hi(e.href),i.decorTop),s=Math.max(0,Math.min(1,e.opacity??1));s<1&&(a=fe(i.ground,a,s)),se(t,o,void 0,()=>r,n,a,fe(a,i.decorWall,.5),ae)}function Lo(t,e,n,i,o){if(!e.points||e.points.length<3)return;let r=Te(i,o.gaTop);se(t,e.points,e.holes,()=>n+.15,n,r,o.gaWall,ae)}var Ui=Math.PI/180,ee=96,Yi=6,Xi=60,Wi=150,Bo=.2,ji=.35;function un(t,e){let n=Math.atan2(e.x-t.x,e.y-t.y)/Ui;return n<0?n+360:n}function Et(t){if(!t.length)return NaN;let e=[...t].sort((n,i)=>n-i);return e[Math.floor(e.length/2)]}function _t(t,e,n=2){let i=t.length,o=new Float64Array(i);for(let r=0;r<i;r++){let a=0,s=0;for(let u=-n;u<=n;u++){let l=r+u;if(e)l=(l%i+i)%i;else if(l<0||l>=i)continue;a+=t[l],s++}o[r]=a/s}return o}function Oo(t,e){let n=t.filter(f=>f.rows.length>=1);if(n.length<1)return null;let i=[],o=0,r=0,a=0;for(let f of n)for(let c of f.rows){for(let m of c.pts)o+=m.x,r+=m.y,a++;if(c.pts.length>=4){let m=Rn(c.pts);m&&Number.isFinite(m.cx)&&Number.isFinite(m.cy)&&i.push({x:m.cx,y:m.cy})}}if(!a)return null;let s={x:o/a,y:r/a},u=s;if(i.length>=8){let f=Et(i.map(g=>g.x)),c=Et(i.map(g=>g.y)),m=0;for(let g of n)for(let y of g.rows)for(let w of y.pts){let E=Math.hypot(w.x-s.x,w.y-s.y);E>m&&(m=E)}let p=0,b=m*.2;for(let g of n)for(let y of g.rows)for(let w of y.pts)Math.hypot(w.x-f,w.y-c)<b&&p++;Math.hypot(f-s.x,c-s.y)<=m&&p/a<.01&&(u={x:f,y:c})}let l=[];for(let f of n){let c={sectionId:f.sectionId,rMin:1/0,rMax:-1/0,samples:[]};for(let m of f.rows)for(let p of m.pts){let b=Math.hypot(p.x-u.x,p.y-u.y),g=Math.min(ee-1,Math.floor(un(u,p)/(360/ee)));c.samples.push({r:b,bin:g,levelM:m.levelM}),b<c.rMin&&(c.rMin=b),b>c.rMax&&(c.rMax=b)}c.samples.length&&l.push(c)}if(!l.length)return null;l.sort((f,c)=>f.rMin+f.rMax-(c.rMin+c.rMax));let h=[];for(let f of l){let c=!1;for(let m of h){let p=Math.min(f.rMax,m.rMax)-Math.max(f.rMin,m.rMin),b=Math.min(f.rMax-f.rMin,m.rMax-m.rMin);if(b>1e-9&&p>=ji*b){m.members.push(f),m.rMin=Math.min(m.rMin,f.rMin),m.rMax=Math.max(m.rMax,f.rMax),c=!0;break}}c||h.push({members:[f],rMin:f.rMin,rMax:f.rMax})}let d=[];for(let f of h){let c=new Array(ee).fill(null);for(let x of f.members)for(let v of x.samples){let S=c[v.bin];S||(S={samples:[]},c[v.bin]=S),S.samples.push({r:v.r,levelM:v.levelM})}let m=c.map(x=>!!x);if(!m.filter(Boolean).length)continue;let b=[],g=[];for(let x of c){if(!x)continue;let v=1/0,S=-1/0;for(let O of x.samples)O.r<v&&(v=O.r),O.r>S&&(S=O.r);b.push(v),g.push(S)}let y=Et(b),w=Et(g);if(!(y>=Bo*w)||!(w>0))continue;let E=[...b].sort((x,v)=>x-v);if(!(E[Math.floor(E.length*.1)]>=Bo*w))continue;let A=c.map(x=>{if(!x)return null;let v=[...x.samples].sort((F,_)=>F.r-_.r),S=v[0].r,O=v[v.length-1].r,M=v[0].levelM,R=-1/0;for(let F of v)F.levelM>R&&(R=F.levelM);let C=[];for(let F of v){let _={r:F.r,l:F.levelM};for(;C.length&&Math.abs(C[C.length-1].r-_.r)<1e-9;){if(C[C.length-1].l<=_.l){_.skip=!0;break}C.pop()}if(!_.skip){for(;C.length>=2;){let Y=C[C.length-2],W=C[C.length-1];if((W.r-Y.r)*(_.l-Y.l)-(W.l-Y.l)*(_.r-Y.r)<=0)C.pop();else break}C.push(_)}}let T=C.map(F=>F.r),P=C.map(F=>F.l);return{inner:S,outer:O,front:M,top:R,profile:{rs:T,ls:P}}}),k=m.slice();for(let x=0;x<ee;x++){if(k[x])continue;let v=-1,S=-1,O=0;for(let G=1;G<=ee;G++){let H=(x-G+ee*2)%ee;if(k[H]){v=H;break}}for(let G=1;G<=ee;G++){let H=(x+G)%ee;if(k[H]){S=H,O=G;break}}if(v<0||S<0)continue;let M=0;for(let G=1;G<=ee;G++){let H=(x-G+ee*2)%ee;if(m[H]){M=G;break}}if(M-1+O>Yi)continue;let C=A[v],T=A[S],P=M/(M+O),F=C.inner+(T.inner-C.inner)*P,_=C.outer+(T.outer-C.outer)*P,Y=C.front+(T.front-C.front)*P,W=C.top+(T.top-C.top)*P;A[x]={inner:F,outer:_,front:Y,top:W,profile:{rs:[F,_],ls:[Y,W]}}}for(let x=0;x<ee;x++)A[x]&&(k[x]=!0);let B=360/ee,L=[],U=k.filter(Boolean).length,N=[];if(U===ee)N.push({start:0,len:ee});else{let x=0;for(;k[x];)x=(x+1)%ee;let v=-1;for(let S=0;S<=ee;S++){let O=(x+S)%ee,M=S<ee&&k[O];if(M&&v<0)v=O;else if(!M&&v>=0){let R=(O-v+ee)%ee||ee;N.push({start:v,len:R}),v=-1}}}for(let x of N){if(x.len*B<Xi&&x.len<ee)continue;let v=x.len===ee,S=new Float64Array(x.len),O=new Float64Array(x.len),M=new Float64Array(x.len),R=new Float64Array(x.len),C=[];for(let G=0;G<x.len;G++){let H=A[(x.start+G)%ee];S[G]=H.inner,O[G]=H.outer,M[G]=H.front,R[G]=H.top,C.push(H.profile??{rs:[H.inner,H.outer],ls:[H.front,H.top]})}let T=_t(S,v),P=_t(O,v),F=_t(M,v),_=_t(R,v);for(let G=0;G<x.len;G++)T[G]>S[G]&&(T[G]=S[G]),P[G]<O[G]&&(P[G]=O[G]),T[G]>P[G]-1e-6&&(T[G]=Math.max(0,P[G]-1e-6)),_[G]<F[G]&&(_[G]=F[G]);let Y={startBin:x.start,binCount:x.len,closed:v,innerR:T,outerR:P,frontLevelM:F,topLevelM:_,profiles:C},W=(G,H,Z)=>{let te=C[G],Q=te.rs,J=te.ls;if(H<=Q[0]){J[0]>Z&&(J[0]=Z);return}if(H>=Q[Q.length-1]){J[J.length-1]>Z&&(J[J.length-1]=Z);return}for(let $=0;$+1<Q.length;$++)if(H<=Q[$+1]){J[$]>Z&&(J[$]=Z),J[$+1]>Z&&(J[$+1]=Z);return}};for(let G=0;G<x.len;G++){let H=c[(x.start+G)%ee];if(H)for(let Z of H.samples){W(G,Z.r,Z.levelM);let te=v?(G-1+x.len)%x.len:G-1,Q=v?(G+1)%x.len:G+1;te>=0&&W(te,Z.r,Z.levelM),Q<x.len&&W(Q,Z.r,Z.levelM)}}L.push(Y)}L.reduce((x,v)=>x+v.binCount*B,0)<Wi||d.push({arcs:L,sectionIds:f.members.map(x=>x.sectionId),innerRMedian:y,outerRMedian:w})}if(!d.length)return null;if(d.sort((f,c)=>f.innerRMedian-c.innerRMedian),e){let f=d[d.length-1].outerRMedian;if(Math.hypot(e.x-u.x,e.y-u.y)>.9*f)return null}return{centre:u,binCount:ee,binStepDeg:360/ee,rings:d}}function No(t,e,n,i){let o=t.binStepDeg,r=n/o-.5-e.startBin;r=(r%t.binCount+t.binCount)%t.binCount,r>e.binCount-1&&(e.closed?r=r-e.binCount<e.binCount-r?0:e.binCount-1:r=r-(e.binCount-1)<t.binCount-r?e.binCount-1:0);let a=Math.floor(r),s=e.closed?(a+1)%e.binCount:Math.min(e.binCount-1,a+1),u=r-a,l=h=>{let d=e.profiles[h],f=d.rs,c=d.ls;if(i<=f[0])return c[0];if(i>=f[f.length-1])return c[c.length-1];for(let m=0;m+1<f.length;m++)if(i<=f[m+1]){let p=f[m+1]-f[m],b=p>1e-9?(i-f[m])/p:0;return c[m]+(c[m+1]-c[m])*b}return c[c.length-1]};return l(a)*(1-u)+l(s)*u}var zo=.25,qi=1.2,Zi=.6,Ki=.45,$i=2.3,Qi=Math.PI/180;function Ye(t,e,n){let i=n*Qi;return{x:t.x+e*Math.sin(i),y:t.y+e*Math.cos(i)}}function Ji(t,e){let n=e.rings[e.rings.length-1];if(!n)return!1;let i=n.outerRMedian*.85;for(let o of t){if(o.role!=="wall")continue;let r=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(r.length<2)continue;let a=0;for(let s of r)Math.hypot(s.x-e.centre.x,s.y-e.centre.y)>=i&&a++;if(a>=r.length/2)return!0}return!1}var ea=24;function ta(t,e,n,i,o,r,a,s,u){let l=n.binCount,h=ea,d=Be,f=r+.02,c=[];for(let x=0;x<l;x++){let v=(n.startBin+x+.5)*e.binStepDeg,S=new Float64Array(h+1);for(let O=0;O<=h;O++){let M=i[x]+(o[x]-i[x])*O/h;S[O]=Math.max(f,No(e,n,v,M)-zo)}c.push(S)}for(let x of u){let v=un(e.centre,x),S=Math.hypot(x.x-e.centre.x,x.y-e.centre.y),O=v/e.binStepDeg-.5-n.startBin;if(O=(O%e.binCount+e.binCount)%e.binCount,O>l-1&&!n.closed&&!(O<l-.5||O>e.binCount-.5))continue;let M=x.deckY-zo,R=Math.min(l-1,Math.max(0,Math.floor(O))),C=[R,n.closed?(R+1)%l:Math.min(l-1,R+1)];for(let T of C){let P=o[T]-i[T];if(!(P>1e-9))continue;let F=(S-i[T])/P*h;if(F<-.75||F>h+.75)continue;let _=Math.min(h,Math.max(0,Math.floor(F))),Y=Math.min(h,_+1);c[T][_]>M&&(c[T][_]=Math.max(f,M)),c[T][Y]>M&&(c[T][Y]=Math.max(f,M))}}let m=[a.bandTop[0]*s.top,a.bandTop[1]*s.top,a.bandTop[2]*s.top],p=[a.bandTop[0]*s.bottomCap,a.bandTop[1]*s.bottomCap,a.bandTop[2]*s.bottomCap],b=[a.bandWall[0]*s.top,a.bandWall[1]*s.top,a.bandWall[2]*s.top],g=[a.bandWall[0]*s.wallBottom,a.bandWall[1]*s.wallBottom,a.bandWall[2]*s.wallBottom],y=(x,v)=>{let S=(n.startBin+x+.5)*e.binStepDeg,O=i[x]+(o[x]-i[x])*v/h,M=Ye(e.centre,O,S);return[M.x*d,c[x][v],M.y*d]};{let x=Math.tan(12*Math.PI/180);for(let v=0;v<6;v++){let S=!1;for(let M=0;M<l;M++)for(let R=h-1;R>=0;R--)c[M][R]>c[M][R+1]&&(c[M][R]=c[M][R+1],S=!0);let O=n.closed?l:l-1;for(let M=0;M<O;M++){let R=(M+1)%l;for(let C=0;C<=h;C++){let T=c[R][C]-c[M][C];if(Math.abs(T)>1)continue;let P=i[M]+(o[M]-i[M])*C/h,F=i[R]+(o[R]-i[R])*C/h,_=Ye(e.centre,P,(n.startBin+M+.5)*e.binStepDeg),Y=Ye(e.centre,F,(n.startBin+R+.5)*e.binStepDeg),W=x*Math.hypot(Y.x-_.x,Y.y-_.y)*d;T>W?(c[R][C]=c[M][C]+W,S=!0):-T>W&&(c[M][C]=c[R][C]+W,S=!0)}}if(!S)break}}let w=1,E=(x,v)=>{for(let S=0;S<=h;S+=4)if(Math.abs(c[x][S]-c[v][S])>w)return!0;return Math.abs(c[x][h]-c[v][h])>w},I=Math.tan(38*Math.PI/180),A=x=>(o[x]-i[x])/h*d,k=(x,v)=>c[x][v+1]-c[x][v]>I*Math.max(1e-6,A(x)),B=(x,v)=>{let S=n.closed?(x-1+l)%l:Math.max(0,x-1),O=n.closed?(x+1)%l:Math.min(l-1,x+1);Math.abs(c[S][v]-c[x][v])>w&&(S=x),Math.abs(c[O][v]-c[x][v])>w&&(O=x);let M=Math.max(0,v-1),R=Math.min(h,v+1);M<v&&k(x,M)&&(M=v),R>v&&k(x,v)&&(R=v);let C=y(S,v),T=y(O,v),P=y(x,M),F=y(x,R),_=T[0]-C[0],Y=T[1]-C[1],W=T[2]-C[2],G=F[0]-P[0],H=F[1]-P[1],Z=F[2]-P[2],te=Y*Z-W*H,Q=W*G-_*Z,J=_*H-Y*G,$=Math.hypot(te,Q,J);return $>1e-12?(te/=$,Q/=$,J/=$,Q<0&&(te=-te,Q=-Q,J=-J),[te,Q,J]):[0,1,0]},L=(x,v)=>{let S=[x[0],r,x[2]],O=[v[0],r,v[2]],M=v[0]-x[0],R=v[2]-x[2],C=Math.hypot(M,R);if(!(C>1e-12))return;let T=[R/C,0,-M/C];t.tri(x,v,O,T,b,b,g),t.tri(x,O,S,T,b,g,g)},U=.05*Oe,N=x=>o[x]-i[x]<U,z=n.closed?l:l-1;for(let x=0;x<z;x++){let v=(x+1)%l;if(N(x)||N(v))continue;if(E(x,v)){let T=(n.startBin+x+1)*e.binStepDeg,P=(H,Z)=>{let te=(i[x]+i[v])/2,Q=(o[x]+o[v])/2,J=te+(Q-te)*Z/h,$=Ye(e.centre,J,T);return[$.x*d,c[H][Z],$.y*d]};for(let H=0;H<h;H++){let Z=y(x,H),te=y(x,H+1),Q=P(x,H),J=P(x,H+1),$=B(x,H),he=B(x,H+1);t.triN(Z,Q,J,$,$,he,m),t.triN(Z,J,te,$,he,he,m);let ze=y(v,H),De=y(v,H+1),ye=P(v,H),Pe=P(v,H+1),ke=B(v,H),de=B(v,H+1);t.triN(ye,ze,De,ke,ke,de,m),t.triN(ye,De,Pe,ke,de,de,m);let Se=P(x,H),ce=P(x,H+1),Ae=P(v,H+1),et=P(v,H),We=ce[0]-Se[0],ie=ce[2]-Se[2],we=Math.hypot(We,ie);if(we>1e-12){let bt=[ie/we,0,-We/we];t.tri(Se,ce,Ae,bt,b),t.tri(Se,Ae,et,bt,b)}}let F=y(x,0),_=y(v,0),Y=y(v,h),W=y(x,h),G=H=>[H[0],r,H[2]];t.tri(G(F),G(Y),G(_),[0,-1,0],p),t.tri(G(F),G(W),G(Y),[0,-1,0],p),L(F,_),L(W,Y);continue}for(let T=0;T<h;T++){let P=B(x,T),F=B(v,T),_=B(v,T+1),Y=B(x,T+1);if(k(x,T)||k(v,T)){let te=(ce,Ae)=>{let et=(n.startBin+ce+.5)*e.binStepDeg,We=i[ce]+(o[ce]-i[ce])*(T+.5)/h,ie=Ye(e.centre,We,et);return[ie.x*d,Ae,ie.y*d]},Q=y(x,T),J=y(v,T),$=te(x,c[x][T]),he=te(v,c[v][T]);t.triN(Q,J,he,P,F,F,m),t.triN(Q,he,$,P,F,P,m);let ze=y(v,T+1),De=y(x,T+1),ye=te(x,c[x][T+1]),Pe=te(v,c[v][T+1]);t.triN(ye,Pe,ze,Y,_,_,m),t.triN(ye,ze,De,Y,_,Y,m);let ke=he[0]-$[0],de=he[2]-$[2],Se=Math.hypot(ke,de);if(Se>1e-12){let ce=[-de/Se,0,ke/Se];t.tri($,he,Pe,ce,b),t.tri($,Pe,ye,ce,b)}continue}let W=y(x,T),G=y(v,T),H=y(v,T+1),Z=y(x,T+1);t.triN(W,G,H,P,F,_,m),t.triN(W,H,Z,P,_,Y,m)}let S=y(x,0),O=y(v,0),M=y(v,h),R=y(x,h),C=T=>[T[0],r,T[2]];t.tri(C(S),C(M),C(O),[0,-1,0],p),t.tri(C(S),C(R),C(M),[0,-1,0],p),L(S,O),L(R,M)}if(!n.closed)for(let x of[0,l-1])for(let v=0;v<h;v++)L(y(x,v),y(x,v+1))}function Vo(t,e,n){let{bottomY:i,colors:o,ao:r}=n,a=new Float64Array(e.binCount).fill(-1/0);for(let h of e.rings)for(let d of h.arcs){let f=new Float64Array(d.binCount),c=new Float64Array(d.binCount);for(let p=0;p<d.binCount;p++){let b=(d.startBin+p)%e.binCount,g=Math.max(0,d.innerR[p]-be);f[p]=Math.max(g,a[b]+.001),c[p]=Math.max(f[p]+.001,d.outerR[p]+be)}let m=0;for(let p=0;p<d.binCount;p++){let b=d.topLevelM[p]-i;b>m&&(m=b)}m>=qi&&ta(t,e,d,f,c,i,o,r,n.seatGuards);for(let p=0;p<d.binCount;p++){let b=(d.startBin+p)%e.binCount;c[p]>a[b]&&(a[b]=c[p])}}if(Ji(n.shapes,e))return;let s=e.rings[e.rings.length-1],u=Zi*Oe,l=Ki*Oe;for(let h of s.arcs){let d=[],f=[];for(let p=0;p<h.binCount;p++){let b=(h.startBin+p+.5)*e.binStepDeg,g=h.outerR[p]+be+u;d.push(Ye(e.centre,g,b)),f.push(Ye(e.centre,g+l,b))}let c=-1/0;for(let p=0;p<h.binCount;p++)h.topLevelM[p]>c&&(c=h.topLevelM[p]);let m=()=>c+$i;h.closed?se(t,f,[d.slice().reverse()],m,i,o.shellTop,o.shellWall,r):se(t,[...f,...d.slice().reverse()],void 0,m,i,o.shellTop,o.shellWall,r)}}function Go(t,e,n,i,o,r,a,s){if(!e.outline||e.outline.length<3)return;let u=n.baseHeightM,l=Te(i,s.tierTop);if(!o)return;let h=b=>o.deckAt(b.x,b.y),d=So(e,a),f=d[0]??e.outline;if(o.rowLevels.length>=2){let b=Dt(o.rowLevels),g=wo(bo(o.rowLevels,n.focal,b),d),y=()=>[0,1,0];for(let E of g){let I=Math.max(u,E.topY-.02);for(let A of r.subtract(E.outline,I))se(t,A,E.holes,()=>I,u,l,s.tierWall,ae,void 0,y)}g.length||se(t,f,e.holes,()=>o.landingY,u,l,s.tierWall,ae);let w={tread:[l[0]*ae.top,l[1]*ae.top,l[2]*ae.top],riser:[l[0]*.72,l[1]*.72,l[2]*.72]};for(let E of d.length?d:[f])xo(t,o.rowLevels,n.focal,o.landingY,w,E,b);return}let c=o.flat?1/0:Po,m=b=>o.normalAt(b.x,b.y),p=o.flat?o.landingY:void 0;for(let b of r.subtract(f,p))se(t,b,e.holes,h,u,l,s.tierWall,ae,c,m)}function na(t,e,n){let i=new Set;for(let a of t.objects)a.type==="section"&&i.add(a.id);let o=new Map;for(let a=0;a<e.length;a++){let s=n.seatOwner[a];if(!s||!i.has(s))continue;let u=n.bySection.get(s);if(u&&u.rowLevels.length>=2)continue;let l=e[a],h=o.get(s);h||(h=new Map,o.set(s,h));let d=l.rowId||`__seat-${a}`,f=h.get(d);f||(f={pts:[],levelM:0,n:0},h.set(d,f)),f.pts.push({x:l.x,y:l.y}),f.levelM+=n.seatDeckY(a),f.n++}let r=[];for(let a of t.objects){if(a.type!=="section")continue;let s=n.bySection.get(a.id);if(s&&s.rowLevels.length>=2){let l=s.rowLevels.filter(h=>!h.patch).map(h=>({pts:h.pts,levelM:h.y}));l.length>=2&&r.push({sectionId:a.id,rows:l});continue}let u=o.get(a.id);u&&r.push({sectionId:a.id,rows:[...u.values()].map(l=>({pts:l.pts,levelM:l.levelM/l.n}))})}return r}function Ho(t,e,n,i,o){let r=na(e,n,i);if(!r.length)return;let a=Oo(r,e.focal);if(!a)return;let s=new Set;for(let l of e.objects)l.type==="section"&&s.add(l.id);let u=[];for(let l=0;l<n.length;l++){let h=i.seatOwner[l];(!h||s.has(h))&&u.push({x:n[l].x,y:n[l].y,deckY:i.seatDeckY(l)})}t.setMaterial(0),Vo(t,a,{bottomY:e.baseHeightM,colors:{bandTop:pe(o.tierTop,.8),bandWall:o.tierWall,shellTop:pe(o.tierWall,1.15),shellWall:o.tierWall},ao:ae,shapes:e.objects.filter(l=>l.type==="shape"),seatGuards:u})}function Uo(t,e,n){return n<0?e>1?t.filter(i=>i.kind==="floor"):[...t]:t.filter(i=>i.floorIndex===void 0||i.floorIndex===n)}function Yo(t,e){let n=[...t].sort((o,r)=>o.screen.y-r.screen.y),i=[];for(let o of n){let r=i.find(a=>a.some(s=>Math.abs(s.screen.x-o.screen.x)<104&&Math.abs(s.screen.y-o.screen.y)<34));r?r.push(o):i.push([o])}return i.flatMap(o=>o.length<2?o:o.map((r,a)=>({...r,screen:{...r.screen,x:Math.max(54,Math.min(e-54,r.screen.x+(a-(o.length-1)/2)*104))}})))}var oa=1.15,ra=3.25,ia=4.5,aa=.85,sa=.5,ca=.26;function Xo(t,e,n){let i=Math.max(1e-6,e),o=t/i,r=n?.hasZoneLabels??!0,a=new Set;return o>=.75&&a.add("floor"),o>=oa&&a.add("zone"),o<=(r?ra:ia)&&(a.add("section"),a.add("ga")),o<=aa&&(a.add("annotation"),a.add("booth")),o<=sa&&a.add("row"),o<=ca&&a.add("seat"),a}function Lt(t,e,n,i){let o=t,r=e[0],a=e[1],s=e[2],u=o[0]*r+o[4]*a+o[8]*s+o[12],l=o[1]*r+o[5]*a+o[9]*s+o[13],h=o[2]*r+o[6]*a+o[10]*s+o[14],d=o[3]*r+o[7]*a+o[11]*s+o[15];if(!(d>1e-6))return{x:0,y:0,depth:1/0,visible:!1};let f=u/d,c=l/d,m=h/d,p=f>=-1.05&&f<=1.05&&c>=-1.05&&c<=1.05&&m<=1;return{x:(f*.5+.5)*n,y:(1-(c*.5+.5))*i,depth:m,visible:p}}function Wo(t,e,n=e){let i=[],o=[...t].sort((r,a)=>r.screen.depth-a.screen.depth);for(let r of o){let a=!1;for(let s of i){let u=Math.abs(r.screen.x-s.screen.x),l=Math.abs(r.screen.y-s.screen.y);if(u<e&&l<n){a=!0;break}}a||i.push(r)}return i}var jo={row:8,seat:14};function qo(t,e,n,i){let o=Math.max(1,Math.min(n,i)*.5),r=Math.min(2,Math.hypot(t.x-n/2,t.y-i/2)/o);return e*(1+1.5*r)}function Zo(t,e,n,i){let o=[...t].sort((a,s)=>(s.priority??0)-(a.priority??0)||a.focus-s.focus),r=[];for(let a of o){if(r.length>=i)break;let s=!1;for(let u of r)if(Math.abs(a.screen.x-u.screen.x)<e&&Math.abs(a.screen.y-u.screen.y)<n){s=!0;break}s||r.push(a)}return r}var la=6,ua=2.2,Ko=.1,ma=.3,da=1.8,ha=.9,fa=.55,pa=6e3;function $o(t){let{doc:e,units:n,seats:i,surfaces:o,focal:r}=t,a=e.zones??[],s=[];if(a.length){let u=new Map;for(let h of n)for(let d of h.objects)d.type==="section"&&d.zone&&u.set(d.id,d.zone);let l=new Map;for(let h=0;h<i.length;h++){let d=i[h],f=o.seatOwner[h],c=d.zoneId??(f?u.get(f):void 0);if(!c)continue;let m=l.get(c);m||(m={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},l.set(c,m)),m.n++,d.x<m.minX&&(m.minX=d.x),d.y<m.minY&&(m.minY=d.y),d.x>m.maxX&&(m.maxX=d.x),d.y>m.maxY&&(m.maxY=d.y),m.sumY+=o.seatDeckY(h)}for(let h of a){let d=l.get(h.id),f=[];for(let[c,m]of u)m===h.id&&f.push(c);if(!d||d.n===0){s.push({id:h.id,label:h.label,color:ne(h.color),sectionIds:f,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(h.focalPoint??r).x*D,1.5,(h.focalPoint??r).y*D]});continue}s.push({id:h.id,label:h.label,color:ne(h.color),sectionIds:f,seatCount:d.n,center:[(d.minX+d.maxX)/2*D,d.sumY/d.n,(d.minY+d.maxY)/2*D],radius:.5*Math.hypot((d.maxX-d.minX)*D,(d.maxY-d.minY)*D)||1,focalWorld:[(h.focalPoint??r).x*D,1.5,(h.focalPoint??r).y*D]})}}return s}function Qo(t){let{doc:e,units:n,seats:i,surfaces:o,seatData:r,hintedSeatFloor:a,zones:s,focal:u}=t,l=[],h=[],d=[];for(let f of s)f.seatCount!==0&&l.push({id:`zone:${f.id}`,kind:"zone",text:f.label,anchor:[f.center[0],f.center[1]+la,f.center[2]],color:e.zones?.find(c=>c.id===f.id)?.color});{let f=new Map,c=new Map;for(let m=0;m<i.length;m++){let p=o.seatOwner[m];if(!p)continue;let b=f.get(p);b||(b={n:0,x:0,y:0,deck:0},f.set(p,b)),b.n++,b.x+=i[m].x,b.y+=i[m].y,b.deck+=o.seatDeckY(m);let g=c.get(p);g||(g={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0},c.set(p,g)),i[m].x<g.minX&&(g.minX=i[m].x),i[m].x>g.maxX&&(g.maxX=i[m].x),i[m].y<g.minY&&(g.minY=i[m].y),i[m].y>g.maxY&&(g.maxY=i[m].y)}for(let m of n)for(let p of m.objects){if(p.type!=="section")continue;let b=f.get(p.id);if(!b||b.n===0)continue;let g=c.get(p.id),y=[b.x/b.n*D,b.deck/b.n,b.y/b.n*D],w=p.displayLabel||p.label||p.id;h.push({id:p.id,floorIndex:m.index,label:w,seatCount:b.n,center:y,radius:Math.max(1,Math.hypot(g.maxX-g.minX,g.maxY-g.minY)*.5*D),focalWorld:[m.focal.x*D,m.baseHeightM+1.5,m.focal.y*D]});let E=e.floors?.[m.index]?.name?.trim().toLocaleLowerCase();n.length>1&&E===w.trim().toLocaleLowerCase()||l.push({id:`section:${p.id}`,kind:"section",text:w,anchor:[y[0],y[1]+ua,y[2]],floorIndex:m.index})}}{for(let m of n)for(let p of m.objects){if(p.type!=="gaArea")continue;let b=nt(p.points);if(!b)continue;let g=p.displayLabel||p.label||p.id;l.push({id:`ga:${p.id}`,kind:"ga",text:p.capacity>0?`${g} \xB7 ${p.capacity.toLocaleString()}`:g,anchor:[b.x*D,m.baseHeightM+da,b.y*D],floorIndex:m.index})}let f=new Map;for(let m=0;m<i.length;m++){let p=i[m],b=Math.hypot(p.x-u.x,p.y-u.y),g=f.get(p.rowId);(!g||b>g.far)&&f.set(p.rowId,{seat:p,index:m,far:b})}for(let[m,p]of f){let b=p.seat.label?p.seat.label.lastIndexOf("-"):-1,g=b>0?p.seat.label.slice(0,b):m;g&&l.push({id:`row:${m}`,kind:"row",text:g,anchor:[p.seat.x*D,o.seatDeckY(p.index)+ha,p.seat.y*D],floorIndex:a[p.index]})}let c=new Map;for(let m=0;m<i.length;m++){let p=i[m],b=p.label?p.label.lastIndexOf("-"):-1,g=c.get(p.rowId);g||(g={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:b>0?p.label.slice(0,b):p.rowId,sectionId:p.sectionId},c.set(p.rowId,g));let y=m*3,w=r.iPosition[y],E=r.iPosition[y+1],I=r.iPosition[y+2];g.n++,g.x+=w,g.y+=E,g.z+=I,g.minX=Math.min(g.minX,w),g.maxX=Math.max(g.maxX,w),g.minZ=Math.min(g.minZ,I),g.maxZ=Math.max(g.maxZ,I)}for(let[m,p]of c)d.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)});if(i.length<=pa)for(let m=0;m<i.length;m++){let p=i[m],b=p.displayLabel||p.label;b&&l.push({id:`seat:${p.id}`,kind:"seat",text:b,anchor:[p.x*D,o.seatDeckY(m)+fa,p.y*D],floorIndex:a[m]})}}for(let f of n)for(let c of f.objects)if(c.type==="shape"&&c.role&&["entrance","exit","screen","suite","obstruction"].includes(c.role)){let m=ut(c),p=m?nt(m):null;if(!p||!c.label)continue;l.push({id:`architecture:${c.id}`,kind:"annotation",text:c.label,anchor:[p.x*D,f.baseHeightM+mt(c).heightM+Ko,p.y*D],color:c.fill,floorIndex:f.index})}else if(c.type==="text"){if(!c.text)continue;l.push({id:`text:${c.id}`,kind:"annotation",text:c.text,anchor:[c.position.x*D,f.baseHeightM+Ko,c.position.y*D],color:c.color,rotation:c.rotation,floorIndex:f.index})}else if(c.type==="booth"){let m=ht(c);if(!m)continue;let p=nt(m);if(!p)continue;l.push({id:`booth:${c.id}`,kind:"booth",text:c.displayLabel||c.label||c.id,anchor:[p.x*D,f.baseHeightM+sn+ma,p.y*D],floorIndex:f.index})}return{labels:l,sections:h,rows:d}}function Jo(t,e){if(e.length>1)for(let n of e)t.push({id:`floor:${n.id}`,kind:"floor",text:n.label,anchor:[n.center[0],n.box.max[1]+1.2,n.center[2]],floorIndex:n.index})}function er(t){let{doc:e,units:n,seats:i,surfaces:o,solids:r,hintedSeatFloor:a,seatFloor:s}=t,u=[];{let l=n.map(()=>({minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}));for(let f=0;f<r.floor.length;f+=1){let c=Math.max(0,Math.min(n.length-1,Math.round(r.floor[f]))),m=f*3,p=l[c];p.minX=Math.min(p.minX,r.position[m]),p.minY=Math.min(p.minY,r.position[m+1]),p.minZ=Math.min(p.minZ,r.position[m+2]),p.maxX=Math.max(p.maxX,r.position[m]),p.maxY=Math.max(p.maxY,r.position[m+1]),p.maxZ=Math.max(p.maxZ,r.position[m+2])}let h=new Map;for(let f=0;f<n.length;f++)for(let c of n[f].objects)c.type==="section"&&h.set(c.id,f);let d=n.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 f=0;f<i.length;f++){let c=o.seatOwner[f],m=(c!==null?h.get(c):void 0)??a[f];if(m===void 0)continue;let p=d[m],b=i[f];p.n++,b.x<p.minX&&(p.minX=b.x),b.y<p.minY&&(p.minY=b.y),b.x>p.maxX&&(p.maxX=b.x),b.y>p.maxY&&(p.maxY=b.y);let g=o.seatDeckY(f);p.sumX+=b.x*D,p.sumDeck+=g,p.sumZ+=b.y*D,p.minDeck=Math.min(p.minDeck,g),p.maxDeck=Math.max(p.maxDeck,g+1.6),s[f]=m}for(let f=0;f<n.length;f++){let c=d[f],m=e.floors?.[f],p=l[f],b=Math.min(c.n?c.minX*D:n[f].focal.x*D-1,Number.isFinite(p.minX)?p.minX:1/0),g=Math.max(c.n?c.maxX*D:n[f].focal.x*D+1,Number.isFinite(p.maxX)?p.maxX:-1/0),y=Math.min(c.n?c.minY*D:n[f].focal.y*D-1,Number.isFinite(p.minZ)?p.minZ:1/0),w=Math.max(c.n?c.maxY*D:n[f].focal.y*D+1,Number.isFinite(p.maxZ)?p.maxZ:-1/0),E=Math.min(c.n?Math.min(n[f].baseHeightM,c.minDeck):n[f].baseHeightM,Number.isFinite(p.minY)?p.minY:1/0),I=Math.max(c.n?Math.max(c.maxDeck,E+.5):E+.5,Number.isFinite(p.maxY)?p.maxY:-1/0),A=[c.n?c.sumX/c.n:(b+g)/2,c.n?c.sumDeck/c.n:(E+I)/2,c.n?c.sumZ/c.n:(y+w)/2],k=Math.max(1,.5*Math.hypot(g-b,I-E,w-y));u.push({index:f,id:m?.id??`floor-${f}`,label:m?.name??(n.length>1?`Floor ${f+1}`:"Venue"),seatCount:c.n,center:A,radius:k,box:{min:[b,E,y],max:[g,I,w]},focalWorld:[n[f].focal.x*D,n[f].baseHeightM+1.5,n[f].focal.y*D]})}}return u}function mn(t,e){let n=1/0,i=1/0,o=-1/0,r=-1/0,a=(s,u)=>{s<n&&(n=s),u<i&&(i=u),s>o&&(o=s),u>r&&(r=u)};for(let s of e)a(s.x,s.y);for(let s of t)for(let u of s.objects)if(u.type==="section")for(let l of u.outline)a(l.x,l.y);else if(u.type==="shape"&&u.points)for(let l of u.points)a(l.x,l.y);else if(u.type==="gaArea")for(let l of u.points)a(l.x,l.y);else if(u.type==="booth"){let l=ht(u);if(l)for(let h of l)a(h.x,h.y)}else if(u.type==="table"){let l=cn(u);if(l)for(let h of l)a(h.x,h.y)}else if(u.type==="decorImage"){let l=ln(u);if(l)for(let h of l)a(h.x,h.y)}return Number.isFinite(n)||(n=-100,i=-100,o=100,r=100),{minX:n,minY:i,maxX:o,maxY:r}}function tr(t,e,n,i,o,r){if(e.length===1){let a=Math.max(60,(o.maxX-o.minX+o.maxY-o.minY)*.06),s=lt(o.minX-a,o.minY-a,o.maxX-o.minX+a*2,o.maxY-o.minY+a*2);se(t,s,void 0,()=>0,-.4,r.ground,r.ground,ae)}else{let a=e.reduce((c,m)=>m.baseHeightM<c.baseHeightM?m:c);t.setFloor(a.index);let s=n.filter((c,m)=>i[m]===a.index),u=mn([a],s),l=Math.hypot(u.maxX-u.minX,u.maxY-u.minY),h=Math.max(28,Math.min(80,l*.04)),d=lt(u.minX-h,u.minY-h,u.maxX-u.minX+h*2,u.maxY-u.minY+h*2),f=a.baseHeightM-.03;se(t,d,void 0,()=>f,f-.22,r.ground,r.ground,ae)}}function nr(t,e,n){let{cx:i,cz:o,radius:r}=n,a=1/0,s=1/0,u=1/0,l=-1/0,h=-1/0,d=-1/0,f=(p,b,g)=>{a=Math.min(a,p),l=Math.max(l,p),s=Math.min(s,b),h=Math.max(h,b),u=Math.min(u,g),d=Math.max(d,g)};for(let p=0;p<t.position.length;p+=3)f(t.position[p],t.position[p+1],t.position[p+2]);for(let p=0;p<e.count;p++){let b=p*3,g=e.iPosition[b],y=e.iPosition[b+1],w=e.iPosition[b+2],E=Math.max(.35,e.iMaxRadius[p]??.35);f(g-E,y,w-E),f(g+E,y+1.6,w+E)}Number.isFinite(a)||(a=i-r,l=i+r,s=0,h=r*.16,u=o-r,d=o+r);let c=[(a+l)/2,(s+h)/2,(u+d)/2],m=Math.max(1,.5*Math.hypot(l-a,h-s,d-u));return{center:c,radius:m,minY:s,maxY:h}}function or(t,e,n,i,o,r){let a=1/0,s=1/0,u=-1/0,l=-1/0;for(let E=0;E<t.count;E++){let I=E*3,A=t.iPosition[I],k=t.iPosition[I+2];A<a&&(a=A),A>u&&(u=A),k<s&&(s=k),k>l&&(l=k)}for(let E of e)a=Math.min(a,E.cx-E.halfX),u=Math.max(u,E.cx+E.halfX),s=Math.min(s,E.cz-E.halfZ),l=Math.max(l,E.cz+E.halfZ);let h=n.minX*D,d=n.maxX*D,f=n.minY*D,c=n.maxY*D,m=h,p=d,b=f,g=c;if(Number.isFinite(a)){let E=Math.max(2,.06*Math.hypot(u-a,l-s));m=Math.max(h,a-E),p=Math.min(d,u+E),b=Math.max(f,s-E),g=Math.min(c,l+E)}let y=Math.min(0,i),w=Math.max(o,r*.05);return{min:[m,y,b],max:[p,w,g]}}function ft(t){let{doc:e}=t,n=oo(e.theme),i=n.structure,o=Mo(e,t.eventConfigurationId??e.eventConfigurationId),r=t.seats,a=new Ct,s=new Map;for(let z of o)for(let x of z.objects)s.set(x.id,z.index),x.type==="section"&&s.set(x.logicalSectionId??x.id,z.index);let u=r.map(z=>s.get(z.sectionId??"")??s.get(z.rowId??"")??0),l=mn(o,r);tr(a,o,r,u,l,i);let h=Co(e,r),d=new Map;for(let z of e.categories??[])d.set(z.key,z.color);let f=[],c=Ao(o,r,u),m=new Float32Array(r.length);for(let z=0;z<o.length;z++){let x=o[z];a.setFloor(z);let v=new kt,S=[],O=x.objects.filter(M=>M.type==="section"&&!!M.outline&&M.outline.length>=3);for(let M of x.objects)M.type==="section"?Go(a,M,x,Ro(M,h),c.bySection.get(M.id),v,O,i):M.type==="shape"?(a.setMaterial(M.role==="screen"?1:0),Eo(a,M,x.baseHeightM,Io(M,S),i,x.focal,f),a.setMaterial(0)):M.type==="gaArea"?Lo(a,M,x.baseHeightM,ne(d.get(M.categoryKey)),i):M.type==="booth"?Do(a,M,x.baseHeightM,ne(d.get(M.categoryKey)),i):M.type==="table"?ko(a,M,x.baseHeightM,ne(d.get(M.categoryKey)),i):M.type==="decorImage"&&_o(a,M,x.baseHeightM,i);Ho(a,x,r,c,i)}let p=o.length>1?{x:o.reduce((z,x)=>z+x.focal.x,0)/o.length,y:o.reduce((z,x)=>z+x.focal.y,0)/o.length}:e.focalPoint??{x:(l.minX+l.maxX)/2,y:(l.minY+l.maxY)/2},b=$n([a.build()]),g=no(r,t.initialState,c,m,d),y=$o({doc:e,units:o,seats:r,surfaces:c,focal:p}),{labels:w,sections:E,rows:I}=Qo({doc:e,units:o,seats:r,surfaces:c,seatData:g,hintedSeatFloor:u,zones:y,focal:p}),A=er({doc:e,units:o,seats:r,surfaces:c,solids:b,hintedSeatFloor:u,seatFloor:m});Jo(w,A),g.iYaw=eo(g.iPosition,r.length,z=>r[z].rowId,z=>{let x=o[m[z]]?.focal??p;return[x.x*D,x.y*D]});let k=(l.minX+l.maxX)/2*D,B=(l.minY+l.maxY)/2*D,L=.5*Math.hypot((l.maxX-l.minX)*D,(l.maxY-l.minY)*D)||10,U=nr(b,g,{cx:k,cz:B,radius:L}),N=or(g,f,l,U.minY,U.maxY,L);return{solids:b,seats:g,bounds:{center:[(N.min[0]+N.max[0])/2,(N.min[1]+N.max[1])/2,(N.min[2]+N.max[2])/2],radius:L,groundY:0,box:N},renderBounds:{center:U.center,radius:U.radius},stateColorLUT:ro(n,Me),theme:n,seatCount:r.length,focalWorld:[p.x*D,1.5,p.y*D],zones:y,stages:f,sections:E,rows:I,labels:w,floors:A}}var ba=88,ya=20,xa={floor:{size:14,weight:"700",opacity:.98},zone:{size:15,weight:"600",opacity:.95},section:{size:12,weight:"500",opacity:.88},ga:{size:12,weight:"500",opacity:.88},booth:{size:11,weight:"500",opacity:.85},annotation:{size:11,weight:"400",opacity:.75},row:{size:10.5,weight:"600",opacity:.8},seat:{size:9.5,weight:"500",opacity:.72}},rr=new Set(["row","seat"]),ir={row:{x:62,y:16},seat:{x:46,y:18}},ga=ne,dn=t=>Fn(t);function va(t,e){let n=dn(t),i=dn(e);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function Ma(t,e=[.04,.06,.1]){let n=dn(e)<.42,i=n?"#f4f7fb":"#0b1220",o=ga(t),r=o&&va(o,e)>=4.5?t:i;return n?{ink:r,backing:"rgba(8,12,22,.78)",border:"rgba(210,222,245,.24)"}:{ink:r,backing:"rgba(255,255,255,.84)",border:"rgba(11,18,32,.22)"}}var Bt=class{constructor(e,n={}){this.nodes=new Map;this.labels=[];this.forcedDense=!1;this.selectedSeatLabelIds=new Set;this.opts=n,this.root=document.createElement("div"),this.root.setAttribute("data-view3d-labels","");let i=this.root.style;i.position="absolute",i.inset="0",i.pointerEvents="none",i.overflow="hidden",n.fontFamily&&(i.fontFamily=n.fontFamily),e.appendChild(this.root)}setVisible(e){this.root.style.visibility=e?"":"hidden"}setLabels(e){this.labels=e;for(let[n,i]of this.nodes)e.some(o=>o.id===n)||(i.remove(),this.nodes.delete(n))}setForcedDense(e){this.forcedDense=e}setSelectedSeatIds(e){this.selectedSeatLabelIds=new Set(Array.from(e,n=>`seat:${n}`))}update(e,n,i,o,r,a){if(!this.labels.length)return;let s=Xo(o,r,{hasZoneLabels:this.labels.some(c=>c.kind==="zone")});this.forcedDense&&(s.add("row"),s.add("seat"));let u=[];for(let c of this.labels){if(!s.has(c.kind))continue;let m=Lt(e,c.anchor,n,i);if(!m.visible)continue;let p=a?Math.hypot(c.anchor[0]-a[0],c.anchor[1]-a[1],c.anchor[2]-a[2]):1;u.push({label:c,screen:m,focus:qo(m,p,n,i),...this.selectedSeatLabelIds.has(c.id)?{priority:1}:{}})}let l=Yo(u.filter(c=>c.label.kind==="floor"),n),h=[...u.filter(c=>!rr.has(c.label.kind)&&c.label.kind!=="floor"),...l],d=[...Wo(h,ba,ya),...["row","seat"].flatMap(c=>Zo(u.filter(m=>m.label.kind===c),ir[c].x,ir[c].y,jo[c]))],f=new Set(d.map(c=>c.label.id));for(let{label:c,screen:m}of d){let b=this.nodeFor(c).style;b.display="",b.transform=`translate(-50%, -50%) translate(${m.x.toFixed(1)}px, ${m.y.toFixed(1)}px)`}for(let[c,m]of this.nodes)f.has(c)||(m.style.display="none")}nodeFor(e){let n=this.nodes.get(e.id);if(!n){n=document.createElement("div");let u=n.style;u.position="absolute",u.left="0",u.top="0",u.whiteSpace="nowrap",u.textShadow="0 1px 3px rgba(0,0,0,0.85), 0 0 8px rgba(0,0,0,0.55)",u.display="none",this.root.appendChild(n),this.nodes.set(e.id,n)}n.textContent=e.text,n.setAttribute("data-label-kind",e.kind);let i=this.selectedSeatLabelIds.has(e.id);n.toggleAttribute("data-selected-seat",i);let o=xa[e.kind],r=n.style;r.fontSize=`${o.size}px`,r.fontWeight=i?"800":o.weight,r.opacity=i?"1":String(o.opacity);let a=Ma(e.color??this.opts.ink,this.opts.backgroundRgb),s=!rr.has(e.kind);return r.color=i?"#ecf8ff":a.ink,r.background=i?"rgba(10,28,45,.9)":s?a.backing:"",r.border=i?"1px solid rgba(89,199,255,.92)":s?`1px solid ${a.border}`:"",r.borderRadius=i||s?"999px":"",r.padding=i||s?"3px 7px":"",r.boxShadow=i?"0 0 0 2px rgba(41,176,255,.18), 0 5px 14px rgba(0,0,0,.35)":s?"0 3px 10px rgba(0,0,0,.24)":"",r.letterSpacing=e.kind==="zone"||e.kind==="floor"?"0.08em":"0.02em",(e.kind==="zone"||e.kind==="floor")&&(r.textTransform="uppercase"),n}dispose(){this.root.remove(),this.nodes.clear()}};import{Geometry as Nt,Mesh as zt,Transform as fr}from"ogl";import{Program as Xe}from"ogl";var Ot=`
1
+ import{a as kn,c as Ln,d as _n}from"../chunk-55NOSZK5.js";import{a as Nn,c as zn,d as Gn,e as Ce,j as Hn}from"../chunk-XPPT3OGQ.js";import{c as On,d as Bn,e as Zt,f as Vn}from"../chunk-IJI4WU57.js";import{e as Cn,l as He,n as st,o as Dn,q as Pt}from"../chunk-6XJN4REG.js";import{V as ke,W as Le,da as St,fa as In,ga as wt,ia as Tn,l as Rn,m as it,ta as Fn}from"../chunk-VDZ24QVV.js";import{d as K,k as En,x as he,z as at}from"../chunk-CXF32VPG.js";import{Renderer as Yr}from"ogl";var be=["available","held","sold","selected","dimmed"];function ct(t){let e=be.indexOf(t);return e<0?0:e}var Un={available:[.24,.82,.52],held:[.95,.66,.22],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};function Xn(t){let e=.2126*t[0]+.7152*t[1]+.0722*t[2],n=.42,i=.62;return[(e+(t[0]-e)*n)*i,(e+(t[1]-e)*n)*i,(e+(t[2]-e)*n)*i]}var Kt={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]},Ue={top:[.05,.06,.08],bottom:[.1,.12,.15]};function pe(t,e){return[Math.min(1,t[0]*e),Math.min(1,t[1]*e),Math.min(1,t[2]*e)]}function Wr(){let t=typeof window<"u"&&window.devicePixelRatio||1,e=navigator.deviceMemory,n=typeof e=="number"&&e<=4?1.5:2;return Math.min(t,n)}var At=class{constructor(e,n){this.clearRgb=[0,0,0];this.container=e,this.canvas=document.createElement("canvas"),this.canvas.style.display="block",this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.touchAction="none",this.canvas.tabIndex=0,this.canvas.setAttribute("role","application"),this.canvas.setAttribute("aria-label","Interactive 3D venue. Drag or use arrow keys to look around; pinch, scroll, plus or minus to zoom."),this.renderer=new Yr({canvas:this.canvas,dpr:Wr(),alpha:!1,antialias:!1,depth:!0,stencil:!1,powerPreference:"high-performance",webgl:2}),this.gl=this.renderer.gl,this.clearRgb=[Ue.top[0],Ue.top[1],Ue.top[2]],this.gl.clearColor(this.clearRgb[0],this.clearRgb[1],this.clearRgb[2],1),e.appendChild(this.canvas),this.lostHandler=i=>{i.preventDefault(),n.onContextLost()},this.restoredHandler=()=>n.onContextRestored(),this.canvas.addEventListener("webglcontextlost",this.lostHandler,!1),this.canvas.addEventListener("webglcontextrestored",this.restoredHandler,!1),this.resize()}setClearColor(e){this.clearRgb=[e[0],e[1],e[2]],this.gl.clearColor(e[0],e[1],e[2],1)}get clearColor(){return this.clearRgb}resize(){let e=Math.max(1,this.container.clientWidth||this.canvas.clientWidth||1),n=Math.max(1,this.container.clientHeight||this.canvas.clientHeight||1);return this.renderer.setSize(e,n),{width:e,height:n}}get pixelHeight(){return this.renderer.height*this.renderer.dpr}get aspect(){return this.renderer.width/Math.max(1,this.renderer.height)}dispose(){this.canvas.removeEventListener("webglcontextlost",this.lostHandler,!1),this.canvas.removeEventListener("webglcontextrestored",this.restoredHandler,!1);let e=this.gl.getExtension("WEBGL_lose_context");e&&e.loseContext(),this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}simulateContextLossCycle(){let e=this.gl.getExtension("WEBGL_lose_context");e&&(e.loseContext(),setTimeout(()=>{e.restoreContext&&e.restoreContext()},300))}};import{Camera as jr,Vec3 as Qt}from"ogl";var ue=Math.PI/180,$t=15*ue,Jt=80*ue,Ze=.12,Yn=35,Wn=1.25,Ct=class{constructor(e,n,i,o){this.fovY=Yn;this.target=new Qt;this.azimuth=-30*ue;this.polar=55*ue;this.distance=10;this.azT=-30*ue;this.polT=55*ue;this.distT=10;this.minDist=1;this.maxDist=100;this.gestureFired=!1;this.interactionEnabled=!0;this.dragging=!1;this.panning=!1;this.lastX=0;this.lastY=0;this.activePointers=new Map;this.pinchDist=0;this.pinchCx=0;this.pinchCy=0;this.targetT=new Qt;this.panAnchor=new Qt;this.panLimit=0;this.primaryDragMode="orbit";this.camera=new jr(e,{fov:Yn,near:.1,far:5e3,aspect:1}),this.canvas=n,this.requestRender=i,this.onGesture=o,this.onPointerDown=r=>{if(this.interactionEnabled){try{this.canvas.setPointerCapture?.(r.pointerId)}catch{}if(this.activePointers.set(r.pointerId,{x:r.clientX,y:r.clientY}),this.activePointers.size===1){let a=r.button===2||r.button===1,s=r.button===0&&(r.shiftKey?this.primaryDragMode==="orbit":this.primaryDragMode==="pan");this.panning=a||s,this.dragging=!this.panning,this.lastX=r.clientX,this.lastY=r.clientY}else if(this.activePointers.size===2){this.dragging=!1,this.panning=!1,this.pinchDist=this.currentPinchDistance();let a=this.pinchCentroid();this.pinchCx=a.x,this.pinchCy=a.y}}},this.onPointerMove=r=>{if(!this.interactionEnabled||!this.activePointers.has(r.pointerId))return;if(this.activePointers.set(r.pointerId,{x:r.clientX,y:r.clientY}),this.activePointers.size>=2){let l=this.currentPinchDistance();this.pinchDist>0&&(this.dollyBy(Math.exp((this.pinchDist-l)*.005)),this.fireGesture()),this.pinchDist=l;let c=this.pinchCentroid();this.panBy(c.x-this.pinchCx,c.y-this.pinchCy),this.pinchCx=c.x,this.pinchCy=c.y;return}let a=r.clientX-this.lastX,s=r.clientY-this.lastY;if(this.panning){this.lastX=r.clientX,this.lastY=r.clientY,(a!==0||s!==0)&&(this.panBy(a,s),this.fireGesture());return}this.dragging&&(this.lastX=r.clientX,this.lastY=r.clientY,(a!==0||s!==0)&&this.fireGesture(),this.azT-=a*.006,this.polT=Math.max($t,Math.min(Jt,this.polT-s*.006)),this.requestRender())},this.onPointerUp=r=>{this.activePointers.delete(r.pointerId);try{this.canvas.releasePointerCapture?.(r.pointerId)}catch{}this.activePointers.size<2&&(this.pinchDist=0),this.activePointers.size===0&&(this.dragging=!1,this.panning=!1)},this.onContextMenu=r=>{r.preventDefault()},this.onWheel=r=>{if(r.preventDefault(),!this.interactionEnabled)return;let a=r.deltaMode===1?16:r.deltaMode===2?100:1,s=Math.max(-2,Math.min(2,r.deltaY*a/100));this.dollyBy(Math.exp(s*.22)),this.fireGesture()},this.onKeyDown=r=>{if(!this.interactionEnabled)return;let a=7*ue;if(r.shiftKey&&(r.key==="ArrowLeft"||r.key==="ArrowRight"||r.key==="ArrowUp"||r.key==="ArrowDown"))this.panBy(r.key==="ArrowLeft"?-32:r.key==="ArrowRight"?32:0,r.key==="ArrowUp"?-32:r.key==="ArrowDown"?32:0);else if(r.key==="ArrowLeft"||r.key==="ArrowRight")this.azT+=r.key==="ArrowLeft"?-a:a;else if(r.key==="ArrowUp"||r.key==="ArrowDown")this.polT=Math.max($t,Math.min(Jt,this.polT+(r.key==="ArrowUp"?-a:a)));else if(r.key==="+"||r.key==="=")this.dollyBy(.82);else if(r.key==="-"||r.key==="_")this.dollyBy(1.22);else return;r.preventDefault(),this.fireGesture(),this.requestRender()},n.addEventListener("pointerdown",this.onPointerDown),n.addEventListener("pointermove",this.onPointerMove),n.addEventListener("pointerup",this.onPointerUp),n.addEventListener("pointercancel",this.onPointerUp),n.addEventListener("wheel",this.onWheel,{passive:!1}),n.addEventListener("keydown",this.onKeyDown),n.addEventListener("contextmenu",this.onContextMenu)}pinchCentroid(){let e=[...this.activePointers.values()];if(!e.length)return{x:0,y:0};let n=0,i=0;for(let o of e)n+=o.x,i+=o.y;return{x:n/e.length,y:i/e.length}}panBy(e,n){let i=this.canvas.clientHeight||1,o=2*this.distance*Math.tan(this.fovY*ue/2)/i,r=Math.sin(this.azimuth),a=Math.cos(this.azimuth),s=a,l=-r,c=Math.cos(this.polar),h=Math.sin(this.polar),m=-r*c,d=-a*c;this.targetT.x+=(-e*s+n*m)*o,this.targetT.z+=(-e*l+n*d)*o,this.targetT.y+=n*h*o,this.clampPan(),this.requestRender()}clampPan(){if(this.panLimit<=0)return;let e=this.panLimit,n=this.panAnchor.x,i=this.panAnchor.y,o=this.panAnchor.z;this.targetT.x=Math.max(n-e,Math.min(n+e,this.targetT.x)),this.targetT.z=Math.max(o-e,Math.min(o+e,this.targetT.z)),this.targetT.y=Math.max(i-e*.5,Math.min(i+e,this.targetT.y))}fireGesture(){this.gestureFired||(this.gestureFired=!0,this.onGesture?.())}currentPinchDistance(){let e=[...this.activePointers.values()];return e.length<2?0:Math.hypot(e[0].x-e[1].x,e[0].y-e[1].y)}dollyBy(e){this.distT=Math.max(this.minDist,Math.min(this.maxDist,this.distT*e)),this.requestRender()}zoomBy(e){this.interactionEnabled&&(this.dollyBy(e),this.fireGesture())}setPrimaryDragMode(e){this.primaryDragMode=e}setInteractionEnabled(e){this.interactionEnabled=e,!e&&(this.activePointers.clear(),this.dragging=!1,this.panning=!1,this.pinchDist=0)}frame(e,n=!1,i,o=!1,r){this.target.set(e.center[0],e.center[1],e.center[2]),this.targetT.copy(this.target),this.panAnchor.copy(this.target),this.panLimit=Math.max(1,e.radius)*1.5;let a=Math.max(1,e.radius),s=this.fovY*ue/2,l=o?Math.max(.82,this.camera.aspect||1):this.camera.aspect||1,c=Math.atan(Math.tan(s)*l);this.azT=i??-30*ue,this.polT=Math.max(15,Math.min(80,r?.polarDeg??55))*ue;let h=this.fitDistance(e,s,c,this.azT,this.polT);this.distT=h*Math.max(1.05,Math.min(2,r?.margin??Wn)),this.minDist=Math.max(2,a*.12),this.maxDist=h*4,n?(this.azimuth=this.azT,this.polar=12*ue,this.distance=this.distT*1.7):(this.azimuth=this.azT,this.polar=this.polT,this.distance=this.distT),this.applyPosition()}setAspect(e){this.camera.perspective({aspect:e})}frameSoft(e,n,i=!1,o){this.target.set(e.center[0],e.center[1],e.center[2]),this.targetT.copy(this.target),this.panAnchor.copy(this.target),this.panLimit=Math.max(1,e.radius)*1.5,this.syncFromCamera(),this.camera.perspective({fov:this.fovY,aspect:this.camera.aspect});let r=this.fovY*ue/2,a=i?Math.max(.82,this.camera.aspect||1):this.camera.aspect||1,s=Math.atan(Math.tan(r)*a);this.azT=n??this.azimuth,this.polT=Math.max(15,Math.min(80,o?.polarDeg??55))*ue;let l=this.fitDistance(e,r,s,this.azT,this.polT);this.distT=l*Math.max(1.05,Math.min(2,o?.margin??Wn))}fitDistance(e,n,i,o,r){let a=Math.max(1,e.radius),s=Math.max(a/Math.tan(n),a/Math.tan(i)),l=e.box;if(!l)return s;let c=Math.sin(r),h=-c*Math.sin(o),m=-Math.cos(r),d=-c*Math.cos(o);if(Math.abs(m)>.999)return s;let p=-d,f=h,u=Math.hypot(p,f);p/=u,f/=u;let b=-f*m,y=f*h-p*d,x=p*m,v=Math.tan(i),k=Math.tan(n),P=1;for(let M=0;M<8;M++){let F=(M&1?l.max[0]:l.min[0])-e.center[0],O=(M&2?l.max[1]:l.min[1])-e.center[1],L=(M&4?l.max[2]:l.min[2])-e.center[2],H=F*h+O*m+L*d,_=Math.abs(F*p+L*f),g=Math.abs(F*b+O*y+L*x);P=Math.max(P,_/v-H,g/k-H)}return Math.min(s,Math.max(P,a*.35))}updateClipping(e){let n=this.camera.position.x-e.center[0],i=this.camera.position.y-e.center[1],o=this.camera.position.z-e.center[2],r=Math.hypot(n,i,o),a=Math.max(1,e.radius)*1.18,s=Math.max(.05,r-a),l=Math.max(s+10,r+a);this.camera.perspective({near:s,far:l,aspect:this.camera.aspect})}update(){let e=this.azT-this.azimuth,n=this.polT-this.polar,i=this.distT-this.distance,o=this.targetT.x-this.target.x,r=this.targetT.y-this.target.y,a=this.targetT.z-this.target.z,s=Math.max(1e-4,this.distance*1e-4),l=Math.abs(e)>1e-4||Math.abs(n)>1e-4||Math.abs(i)>1e-4||Math.abs(o)>s||Math.abs(r)>s||Math.abs(a)>s;return this.azimuth+=e*Ze,this.polar+=n*Ze,this.distance+=i*Ze,this.target.x+=o*Ze,this.target.y+=r*Ze,this.target.z+=a*Ze,l&&this.applyPosition(),l}get currentDistance(){return this.distance}syncFromCamera(){let e=this.camera.position.x-this.target.x,n=this.camera.position.y-this.target.y,i=this.camera.position.z-this.target.z,o=Math.hypot(e,n,i)||1,r=Math.max($t,Math.min(Jt,Math.acos(Math.max(-1,Math.min(1,n/o)))));this.distance=this.distT=o,this.polar=this.polT=r,this.azimuth=this.azT=Math.atan2(e,i)}setTarget(e){this.target.set(e[0],e[1],e[2]),this.targetT.copy(this.target)}resumeAfterFlight(e){this.camera.perspective({fov:this.fovY,aspect:this.camera.aspect}),e&&this.target.set(e[0],e[1],e[2]),this.targetT.copy(this.target),this.syncFromCamera()}applyPosition(){let e=Math.sin(this.polar),n=this.target.x+this.distance*e*Math.sin(this.azimuth),i=this.target.y+this.distance*Math.cos(this.polar),o=this.target.z+this.distance*e*Math.cos(this.azimuth);this.camera.position.set(n,i,o),this.camera.lookAt(this.target)}dispose(){this.canvas.removeEventListener("pointerdown",this.onPointerDown),this.canvas.removeEventListener("pointermove",this.onPointerMove),this.canvas.removeEventListener("pointerup",this.onPointerUp),this.canvas.removeEventListener("pointercancel",this.onPointerUp),this.canvas.removeEventListener("wheel",this.onWheel),this.canvas.removeEventListener("keydown",this.onKeyDown),this.canvas.removeEventListener("contextmenu",this.onContextMenu),this.activePointers.clear()}};var Rt=class{constructor(e){this.rafId=0;this.running=!1;this.lastTime=0;this.fpsEma=0;this.rendered=0;this.tick=e=>{let n=this.lastTime?(e-this.lastTime)/1e3:.016666666666666666;if(this.lastTime=e,n>0){let o=1/n;this.fpsEma=this.fpsEma?this.fpsEma*.9+o*.1:o}this.rendered++,this.frame(n)?this.rafId=requestAnimationFrame(this.tick):(this.running=!1,this.rafId=0)};this.frame=e}requestRender(){this.running||(this.running=!0,this.lastTime=0,this.rafId=requestAnimationFrame(this.tick))}stats(){return{fps:this.running?Math.round(this.fpsEma):0,rendered:this.rendered,idle:!this.running}}stop(){this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=0,this.running=!1}};var Ke=2.5,qr=1.15,lt=6,Qe=10,jn=6,qn=9.5,Zn=.9,Kn=2.2,en=30,tn=4,It=8192;var ps=Qe+tn;function Qn(t,e){let n=e*1.4,i=e*3.2;if(t<=n)return{scale:1,fade:0,minPixels:Ke};let o=Math.min(1,(t-n)/Math.max(.001,i-n));return{scale:1-o*.4,fade:o*.55,minPixels:Ke+o*(qr-Ke)}}function $n(t,e,n){return!(t>0)||!(e>0)||!(n>0)?!1:e*n/t>=64}function Jn(t,e,n,i,o){if(!(t>0)||!(e>0)||!(n>0)||!(i>0)||!(o>0))return!1;let r=Math.tan(i/2*Math.PI/180);if(!(r>0))return!1;let a=e/(n*r)*(o/2);return Math.PI*a*a/t>=64}import Zr from"earcut";import Kr from"polygon-clipping";var R=ke,Qr=.002;function $r(t,e,n){let i=Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2]),o=Math.hypot(n[0]-e[0],n[1]-e[1],n[2]-e[2]),r=Math.hypot(t[0]-n[0],t[1]-n[1],t[2]-n[2]),a=Math.max(i,o,r);if(a<1e-9)return!0;let s=(i+o+r)/2;return 2*Math.sqrt(Math.max(0,s*(s-i)*(s-o)*(s-r)))/a<Qr}var Xe=class{constructor(e=16384){this.len=0;this.buf=new Float32Array(e)}push3(e,n,i){this.len+3>this.buf.length&&this.grow(this.len+3),this.buf[this.len++]=e,this.buf[this.len++]=n,this.buf[this.len++]=i}push1(e){this.len+1>this.buf.length&&this.grow(this.len+1),this.buf[this.len++]=e}grow(e){let n=this.buf.length*2;for(;n<e;)n*=2;let i=new Float32Array(n);i.set(this.buf.subarray(0,this.len)),this.buf=i}get length(){return this.len}toArray(){return this.buf.slice(0,this.len)}},Et=class{constructor(){this.pos=new Xe;this.nor=new Xe;this.col=new Xe;this.flr=new Xe;this.mat=new Xe;this.currentFloor=0;this.currentMaterial=0}setFloor(e){this.currentFloor=e}setMaterial(e){this.currentMaterial=e}tri(e,n,i,o,r,a=r,s=r){$r(e,n,i)||(this.pos.push3(e[0],e[1],e[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(i[0],i[1],i[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(r[0],r[1],r[2]),this.col.push3(a[0],a[1],a[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(e,n,i,o,r,a,s,l=s,c=s){[...e,...n,...i].every(Number.isFinite)&&(this.pos.push3(e[0],e[1],e[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(i[0],i[1],i[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(a[0],a[1],a[2]),this.col.push3(s[0],s[1],s[2]),this.col.push3(l[0],l[1],l[2]),this.col.push3(c[0],c[1],c[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}get vertexCount(){return this.pos.length/3}build(){return{position:this.pos.toArray(),normal:this.nor.toArray(),color:this.col.toArray(),floor:this.flr.toArray(),material:this.mat.toArray(),count:this.pos.length/3}}};function Jr(t,e,n){let i=e[0]-t[0],o=e[1]-t[1],r=e[2]-t[2],a=n[0]-t[0],s=n[1]-t[1],l=n[2]-t[2],c=o*l-r*s,h=r*a-i*l,m=i*s-o*a,d=Math.hypot(c,h,m)||1;return c/=d,h/=d,m/=d,[c,h,m]}function ei(t,e){let n=[...t],i=[];for(let a of t)i.push(a.x,a.y);let o=[];if(e){for(let a of e)if(!(a.length<3)){o.push(n.length);for(let s of a)n.push(s),i.push(s.x,s.y)}}let r=Zr(i,o.length?o:void 0,2);return{pts:n,tris:r}}function nn(t){return He(t)<0?[...t].reverse():t}var ti=3;function ni(t,e,n,i){let o=i(t),r=i(e),a=i(n),s=(p,f,u,b)=>Math.abs(i({x:(p.x+f.x)/2,y:(p.y+f.y)/2})-(u+b)/2),l=(t.x+e.x+n.x)/3,c=(t.y+e.y+n.y)/3,h=(o+r+a)/3,m=Math.max(s(t,e,o,r),s(e,n,r,a),s(n,t,a,o),Math.abs(i({x:l,y:c})-h)),d=(p,f,u)=>{let b=Math.abs(i({x:(p+l)/2,y:(f+c)/2})-(u+h)/2);b>m&&(m=b)};return d((t.x+e.x)/2,(t.y+e.y)/2,(o+r)/2),d((e.x+n.x)/2,(e.y+n.y)/2,(r+a)/2),d((n.x+t.x)/2,(n.y+t.y)/2,(a+o)/2),m}function ut(t,e,n,i,o){if(o<=0)return ni(t,e,n,i);let r={x:(t.x+e.x)/2,y:(t.y+e.y)/2},a={x:(e.x+n.x)/2,y:(e.y+n.y)/2},s={x:(n.x+t.x)/2,y:(n.y+t.y)/2};return Math.max(ut(t,r,s,i,o-1),ut(r,e,a,i,o-1),ut(s,a,n,i,o-1),ut(r,a,s,i,o-1))}function mt(t,e,n,i,o,r,a,s){if(a>0){let d={x:(e.x+n.x)/2,y:(e.y+n.y)/2},p={x:(n.x+i.x)/2,y:(n.y+i.y)/2},f={x:(i.x+e.x)/2,y:(i.y+e.y)/2};mt(t,e,d,f,o,r,a-1,s),mt(t,d,n,p,o,r,a-1,s),mt(t,f,p,i,o,r,a-1,s),mt(t,d,p,f,o,r,a-1,s);return}let l=[e.x*R,o(e),e.y*R],c=[n.x*R,o(n),n.y*R],h=[i.x*R,o(i),i.y*R];if(s){t.triN(l,c,h,s(e),s(n),s(i),r);return}let m=Jr(l,c,h);m[1]<0&&(m=[-m[0],-m[1],-m[2]]),t.tri(l,c,h,m,r)}var oi=8;function eo(t,e,n){if(!Number.isFinite(n))return t;let i=[],o=(r,a,s,l,c)=>{if(c>0){let h={x:(r.x+a.x)/2,y:(r.y+a.y)/2},m=e(h);if(Math.abs(m-(s+l)/2)>n){o(r,h,s,m,c-1),o(h,a,m,l,c-1);return}}i.push(r)};for(let r=0;r<t.length;r++){let a=t[r],s=t[(r+1)%t.length];o(a,s,e(a),e(s),oi)}return i}function Tt(t,e){if(t.length<3)return t;let n=[];for(let o of t){let r=n[n.length-1];r&&Math.hypot(o.x-r.x,o.y-r.y)<e||n.push(o)}for(;n.length>2&&Math.hypot(n[0].x-n[n.length-1].x,n[0].y-n[n.length-1].y)<e;)n.pop();if(n.length<3)return t;let i=[];for(let o=0;o<n.length;o++){let r=i.length?i[i.length-1]:n[(o-1+n.length)%n.length],a=n[o],s=n[(o+1)%n.length],l=s.x-r.x,c=s.y-r.y,h=Math.hypot(l,c);h>e&&Math.abs((a.x-r.x)*c-(a.y-r.y)*l)/h<e||i.push(a)}return i.length>=3?i:n}var Ft=.001*Le*.1;function ie(t,e,n,i,o,r,a,s,l=1/0,c){if(!e||e.length<3||(l===void 0&&(l=1/0),Math.abs(He(e))<1e-4))return;let h=Tt(eo(Tt(nn(e),Ft),i,l),Ft),m=n?.map(M=>Tt(eo(Tt(nn(M),Ft),i,l),Ft)).filter(M=>M.length>=3&&Math.abs(He(M))>=1e-4),{pts:d,tris:p}=ei(h,m),f=[r[0]*s.top,r[1]*s.top,r[2]*s.top],u=[r[0]*s.bottomCap,r[1]*s.bottomCap,r[2]*s.bottomCap],b=[a[0]*s.top,a[1]*s.top,a[2]*s.top],y=[a[0]*s.wallBottom,a[1]*s.wallBottom,a[2]*s.wallBottom],x=0;if(Number.isFinite(l))for(;x<ti;x++){let M=0;for(let F=0;F<p.length;F+=3){let O=ut(d[p[F]],d[p[F+1]],d[p[F+2]],i,x);O>M&&(M=O)}if(M<=l)break}for(let M=0;M<p.length;M+=3){let F=d[p[M]],O=d[p[M+1]],L=d[p[M+2]];mt(t,F,O,L,i,f,x,c);let H=[F.x*R,o,F.y*R],_=[O.x*R,o,O.y*R],g=[L.x*R,o,L.y*R];t.tri(H,g,_,[0,-1,0],u)}let v=M=>{if(x<=0)return M;let F=1<<x,O=[];for(let L=0;L<M.length;L++){let H=M[L],_=M[(L+1)%M.length];for(let g=0;g<F;g++){let w=g/F;O.push({x:H.x+(_.x-H.x)*w,y:H.y+(_.y-H.y)*w})}}return O},k=Rn(h),P=[{ring:v(h),flip:!1}];if(m)for(let M of m)M.length>=3&&P.push({ring:v(M),flip:!0});for(let{ring:M,flip:F}of P)for(let O=0;O<M.length;O++){let L=M[O],H=M[(O+1)%M.length],_=(H.x-L.x)*R,w=(H.y-L.y)*R,E=-_,C=Math.hypot(w,E)||1;w/=C,E/=C;let N=(L.x+H.x)/2-k.x,S=(L.y+H.y)/2-k.y,I=w*N+E*S;F&&(I=-I),I<0&&(w=-w,E=-E);let T=[w,0,E],B=[L.x*R,i(L),L.y*R],A=[H.x*R,i(H),H.y*R],D=[L.x*R,o,L.y*R],V=[H.x*R,o,H.y*R];t.tri(B,A,V,T,b,b,y),t.tri(B,V,D,T,b,y,y)}}function to(t){let e=0;for(let l of t)e+=l.count;let n=new Float32Array(e*3),i=new Float32Array(e*3),o=new Float32Array(e*3),r=new Float32Array(e),a=new Float32Array(e),s=0;for(let l of t)n.set(l.position,s*3),i.set(l.normal,s*3),o.set(l.color,s*3),r.set(l.floor,s),a.set(l.material,s),s+=l.count;return{position:n,normal:i,color:o,floor:r,material:a,count:e}}function Dt(t,e,n=2.5){if(e<=0||t.length<3)return t;let i=nn(t),o=i.length,r=[];for(let s=0;s<o;s++){let l=i[s],c=i[(s+1)%o],h=c.x-l.x,m=c.y-l.y,d=Math.hypot(h,m)||1;r.push({x:m/d,y:-h/d})}let a=[];for(let s=0;s<o;s++){let l=i[s],c=r[(s-1+o)%o],h=r[s],m=c.x+h.x,d=c.y+h.y,p=Math.hypot(m,d),f=()=>{a.push([l.x+c.x*e,l.y+c.y*e]),a.push([l.x+h.x*e,l.y+h.y*e])};if(p<1e-9){f();continue}m/=p,d/=p;let u=m*c.x+d*c.y,b=1/Math.max(u,1e-6);if(!Number.isFinite(b)||b>n){f();continue}a.push([l.x+m*e*b,l.y+d*e*b])}if(a.length<3)return t;try{let s=Kr.union([[...a,a[0]]]),l=null,c=-1/0;for(let m of s){let d=Math.abs(He(m[0].map(([p,f])=>({x:p,y:f}))));d>c&&(c=d,l=m[0])}if(!l)return t;let h=l.map(([m,d])=>({x:m,y:d}));if(h.length>1){let m=h[0],d=h[h.length-1];Math.abs(m.x-d.x)<1e-9&&Math.abs(m.y-d.y)<1e-9&&h.pop()}return h.length>=3?h:t}catch{return t}}function kt(t,e,n,i,o=28){let r=[];for(let a=0;a<o;a++){let s=a/o*Math.PI*2;r.push({x:t+n*Math.cos(s),y:e+i*Math.sin(s)})}return r}function dt(t,e,n,i){return[{x:t,y:e},{x:t+n,y:e},{x:t+n,y:e+i},{x:t,y:e+i}]}var ce={pedestal:0,pad:1,back:2,body:3,head:4},ri=.44,ii=.15,ai=.3,si=.24;function no(t){return t===void 0||!Number.isFinite(t)||t<=0?si:Math.min(ai,Math.max(ii,t*ri))}var on=.21,ci=.05,rn=.45,Lt=rn+ci,li=[{part:ce.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:ce.pad,min:[-1,.36,-.95],max:[1,rn,1]},{part:ce.back,min:[-1,Lt,-1],max:[1,.92,-.72]}],ui=[{part:ce.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:ce.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:ce.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:ce.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:ce.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}],mi=[{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 oo(){let t=[],e=[],n=[],i=[],o=(C,N,S)=>{let I=n.length,[T,B,A]=C,D=[B[0]-T[0],B[1]-T[1],B[2]-T[2]],V=[A[0]-T[0],A[1]-T[1],A[2]-T[2]],U=D[1]*V[2]-D[2]*V[1],Y=D[2]*V[0]-D[0]*V[2],X=D[0]*V[1]-D[1]*V[0],j=Math.hypot(U,Y,X);j>1e-9?(U/=j,Y/=j,X/=j):[U,Y,X]=N,U*N[0]+Y*N[1]+X*N[2]<0&&(U=-U,Y=-Y,X=-X);for(let Z of C)t.push(...Z),e.push(U,Y,X),n.push(S);i.push(I,I+1,I+2,I,I+2,I+3)},r=C=>{for(let N of mi){let S=N.c.map(I=>I.map((T,B)=>T?C.max[B]:C.min[B]));o(S,N.n,C.part)}};for(let C of li)r(C);for(let C of ui)r(C);let a=rn,s=1.08,l=.47,c=.69,h=-.55,m=.08,d=-.48,p=.01,f=[-l,a,h],u=[l,a,h],b=[-l,a,m],y=[l,a,m],x=[-c,s,d],v=[c,s,d],k=[-c,s,p],P=[c,s,p];o([u,v,P,y],[1,0,0],ce.body),o([b,k,x,f],[-1,0,0],ce.body),o([k,P,v,x],[0,1,0],ce.body),o([f,u,y,b],[0,-1,0],ce.body),o([y,P,k,b],[0,0,1],ce.body),o([f,x,v,u],[0,0,-1],ce.body);let M=10,F=8,O=[0,1.205,-.23],L=[.42,.115,.38],H=n.length;for(let C=0;C<=F;C++){let N=Math.PI*C/F,S=Math.cos(N),I=Math.sin(N);for(let T=0;T<=M;T++){let B=Math.PI*2*T/M,A=I*Math.cos(B),D=I*Math.sin(B);t.push(O[0]+L[0]*A,O[1]+L[1]*S,O[2]+L[2]*D);let V=A/L[0],U=S/L[1],Y=D/L[2],X=Math.hypot(V,U,Y)||1;V/=X,U/=X,Y/=X,e.push(V,U,Y),n.push(ce.head)}}for(let C=0;C<F;C++)for(let N=0;N<M;N++){let S=H+C*(M+1)+N,I=S+M+1;i.push(S,I,S+1,S+1,I,I+1)}let _=new Float32Array(t),g=new Float32Array(e),w=new Float32Array(n),E=new Uint16Array(i);return{position:_,normal:g,part:w,index:E,vertexCount:n.length,indexCount:i.length}}function ro(t,e,n,i){let o=new Float32Array(e),r=c=>t[c*3],a=c=>t[c*3+2],s=0,l=(c,h)=>{let m=h-c;for(let d=c;d<h;d++){let[p,f]=i(d),u=p-r(d),b=f-a(d);if(m>=2){let y=Math.max(c,d-1),x=Math.min(h-1,d+1),v=r(x)-r(y),k=a(x)-a(y),P=Math.hypot(v,k);if(P>1e-6){let M=-k/P,F=v/P;M*u+F*b<0&&(M=-M,F=-F),u=M,b=F}}o[d]=u===0&&b===0?0:Math.atan2(u,b)}};for(let c=1;c<=e;c++)(c===e||n(c)!==n(s))&&(l(s,c),s=c);return o}var Re=.22;function io(t,e){let n=be[t];if(n!=="sold"&&n!=="held")return-1;let i=(e+1)*2654435761;return i^=i>>>15,i=Math.imul(i,2246822519),i^=i>>>13,(i>>>0)%1e5/1e5}var di=.42;function hi(t){let e=t.length,n=new Float64Array(e);if(e<2)return n.fill(1/0),n;let i=1/0,o=1/0,r=-1/0,a=-1/0;for(let f of t)f.x<i&&(i=f.x),f.y<o&&(o=f.y),f.x>r&&(r=f.x),f.y>a&&(a=f.y);let s=Math.max(r-i,1e-6),l=Math.max(a-o,1e-6),c=Math.max(Math.sqrt(s*l/e),1e-6),h=Math.max(1,Math.ceil(s/c)+1),m=Math.max(1,Math.ceil(l/c)+1),d=new Map,p=(f,u)=>{let b=Math.min(h-1,Math.max(0,Math.floor((f-i)/c)));return Math.min(m-1,Math.max(0,Math.floor((u-o)/c)))*h+b};for(let f=0;f<e;f++){let u=p(t[f].x,t[f].y),b=d.get(u);b?b.push(f):d.set(u,[f])}for(let f=0;f<e;f++){let u=t[f],b=Math.min(h-1,Math.max(0,Math.floor((u.x-i)/c))),y=Math.min(m-1,Math.max(0,Math.floor((u.y-o)/c))),x=1/0;for(let v=1;v<=4;v++){for(let k=y-v;k<=y+v;k++)if(!(k<0||k>=m))for(let P=b-v;P<=b+v;P++){if(P<0||P>=h||v>1&&Math.abs(k-y)<v&&Math.abs(P-b)<v)continue;let M=d.get(k*h+P);if(M)for(let F of M){if(F===f)continue;let O=Math.hypot(t[F].x-u.x,t[F].y-u.y);O<x&&(x=O)}}if(Number.isFinite(x)&&x<=v*c)break}n[f]=x}return n}function pi(t){let e=t.eyeHeightM;return Number.isFinite(e)?Math.max(0,e-St):0}function ao(t,e,n,i,o){let r=t.length,a=new Float32Array(r*3),s=new Float32Array(r),l=new Float32Array(r*3),c=new Float32Array(r),h=new Float32Array(r),m=new Float32Array(r),d=new Float32Array(r*3),p=new Map,f=hi(t);for(let u=0;u<r;u++){let b=t[u],x=(n?.seatPitchU(u)??f[u])*R;c[u]=Number.isFinite(x)?Math.max(.06,Math.min(Re,x*di)):Re,h[u]=no(Number.isFinite(x)?x:void 0),m[u]=b.wheelchairSpaceType==="no-seat"?0:1,a[u*3]=b.x*R,a[u*3+1]=n?n.seatDeckY(u):pi(b),a[u*3+2]=b.y*R,s[u]=ct(e?e(b):"available");let v=K(o?.get(b.categoryKey)??"#6e7bff")??[.43,.48,1];if(l[u*3]=v[0],l[u*3+1]=v[1],l[u*3+2]=v[2],b.accessibility?.length){let k=K(Cn(b.accessibility));k&&(d[u*3]=k[0],d[u*3+1]=k[1],d[u*3+2]=k[2])}p.set(b.id,u)}return{count:r,iPosition:a,iState:s,iCategory:l,iMaxRadius:c,iRing:d,idToIndex:p,iChairWidth:h,iPhysicalSeat:m,iFloor:i??new Float32Array(r),iYaw:new Float32Array(r)}}var fi=64;function an(t,e){let n=[];for(let a of e){let s=t.idToIndex.get(a.seatId);if(s===void 0)continue;let l=ct(a.state);t.iState[s]!==l&&(t.iState[s]=l,n.push(s))}if(!n.length)return[];n.sort((a,s)=>a-s);let i=[],o=n[0],r=n[0];for(let a=1;a<n.length;a++){let s=n[a];if(s!==r){if(s<=r+fi){r=s;continue}i.push({start:o,length:r-o+1}),o=s,r=s}}return i.push({start:o,length:r-o+1}),i}var bi=.15,yi=.9,xi=1.76,gi=.7,vi=1.6;function Mi(){return{background:{top:[...Ue.top],bottom:[...Ue.bottom]},structure:Kt,seatStates:{...Un},seatScale:1}}function so(t){let e=Mi();if(!t)return e;let n=K(t.background);if(n){e.background={top:pe(n,yi),bottom:pe(n,xi)};let r={};for(let[a,s]of Object.entries(Kt))r[a]=he(s,n,bi);e.structure=r}let i=K(t.selectionColor)??K(t.accent);i&&(e.seatStates={...e.seatStates,selected:i});let o=t.seatScale;return typeof o=="number"&&Number.isFinite(o)&&(e.seatScale=Math.min(vi,Math.max(gi,o))),e}function co(t,e){let n=[];for(let i of e)n.push(...t.seatStates[i]);return n}import ho from"polygon-clipping";import Si from"earcut";var wi=.58,lo=.01,fe=Re*1.5*Le,Pi=.5,Ai=.6;function Ci(t,e){let n=t.length,i=[];for(let a=0;a<n;a++){let s=t[Math.max(0,a-1)],l=t[Math.min(n-1,a+1)],c=l.x-s.x,h=l.y-s.y,m=Math.hypot(c,h);if(m<1e-9){i.push([0,0]);continue}c/=m,h/=m,i.push([-h,c])}let o=0;for(let a=0;a<n;a++)o+=(t[a].x-e.x)*i[a][0]+(t[a].y-e.y)*i[a][1];return o<0?i.map(([a,s])=>[-a,-s]):i}function Ri(t,e){if(t.length<2||e<=0)return[...t];let n=[...t],i=(a,s)=>{let l=s.x-a.x,c=s.y-a.y,h=Math.hypot(l,c)||1;return{x:l/h,y:c/h}},o=i(n[1],n[0]),r=i(n[n.length-2],n[n.length-1]);return n.unshift({x:n[0].x+o.x*e,y:n[0].y+o.y*e}),n.push({x:n[n.length-1].x+r.x*e,y:n[n.length-1].y+r.y*e}),n}var uo=Math.PI/12;function Ii(t){if(t.length<3)return[...t];let e=[...t].sort((r,a)=>r.x-a.x||r.y-a.y),n=(r,a,s)=>(a.x-r.x)*(s.y-r.y)-(a.y-r.y)*(s.x-r.x),i=r=>{let a=[];for(let s of r){for(;a.length>=2&&n(a[a.length-2],a[a.length-1],s)<=0;)a.pop();a.push(s)}return a.pop(),a},o=[...i(e),...i([...e].reverse())];return o.length>=3?o:[...t]}function po(t,e){if(!t.length||!(e>0))return[];let n=Ii(t),i=(s,l,c,h)=>{let m=c-l;for(;m<0;)m+=Math.PI*2;for(;m>Math.PI*2;)m-=Math.PI*2;let d=Math.max(1,Math.ceil(m/uo)),p=e/Math.cos(m/d/2);for(let f=0;f<=d;f++){let u=l+m*f/d;h.push({x:s.x+Math.cos(u)*p,y:s.y+Math.sin(u)*p})}};if(n.length<3){let s=0,l=0;for(let p of n)s+=p.x,l+=p.y;s/=n.length||1,l/=n.length||1;let c=0;for(let p of n)c=Math.max(c,Math.hypot(p.x-s,p.y-l));let h=[],m=Math.max(3,Math.ceil(Math.PI*2/uo)),d=(c+e)/Math.cos(Math.PI/m);for(let p=0;p<m;p++){let f=p/m*Math.PI*2;h.push({x:s+Math.cos(f)*d,y:l+Math.sin(f)*d})}return h}let o=n.length,r=[];for(let s=0;s<o;s++){let l=n[s],c=n[(s+1)%o];r.push(Math.atan2(-(c.x-l.x),c.y-l.y))}let a=[];for(let s=0;s<o;s++)i(n[s],r[(s+o-1)%o],r[s],a);return go(a)}function Ti(t,e,n){if(t.length===1)return Math.hypot(e-t[0].x,n-t[0].y);let i=1/0;for(let o=0;o+1<t.length;o++){let r=t[o],a=t[o+1],s=a.x-r.x,l=a.y-r.y,c=s*s+l*l,h=c>1e-12?((e-r.x)*s+(n-r.y)*l)/c:0;h<0?h=0:h>1&&(h=1);let m=Math.hypot(e-(r.x+h*s),n-(r.y+h*l));m<i&&(i=m)}return i}function _t(t){let e=t.map(o=>{let r=0,a=0;for(let c of o.pts)r+=c.x,a+=c.y;let s=o.pts.length||1;r/=s,a/=s;let l=0;for(let c of o.pts){let h=Math.hypot(c.x-r,c.y-a);h>l&&(l=h)}return{cx:r,cy:a,rad:l}}),n=o=>{let r=o.length;return r<=2?[...o]:[o[Math.floor(r*.25)],o[Math.floor(r*.5)],o[Math.floor(r*.75)]]},i=[];for(let o=0;o<t.length;o++){let r=n(t[o].pts),a=[],s=1/0,l=null;for(let h of r){let m=1/0;for(let d=0;d<t.length;d++){if(d===o||Math.abs(t[d].y-t[o].y)<.001)continue;let p=e[d],f=Math.hypot(h.x-p.cx,h.y-p.cy)-p.rad;if(f>=m&&f>=s)continue;let u=Ti(t[d].pts,h.x,h.y);u<m&&(m=u),t[d].depth<t[o].depth&&u<s&&(s=u,l=t[d].y)}Number.isFinite(m)&&m>0&&a.push(m)}a.sort((h,m)=>h-m);let c=a.length?a[Math.floor(a.length/2)]:1;i.push({pitch:c,belowY:l})}return i}function fo(t,e,n,i){let o=t[e],r=o.pts.length>=2?[...o.pts]:o.pts.length===1?(()=>{let h=o.pts[0],m=h.x-i.x,d=h.y-i.y,p=Math.hypot(m,d)||1;m/=p,d/=p;let f=Math.max(n[e].pitch,.001)*.5;return[{x:h.x+d*f,y:h.y-m*f},{x:h.x-d*f,y:h.y+m*f}]})():[];if(r.length<2)return null;let a=0,s=0;for(let h=1;h<r.length;h++){let m=Math.hypot(r[h].x-r[h-1].x,r[h].y-r[h-1].y);m>1e-6&&(a+=m,s++)}let l=s>0?a/s:0,c=Ri(r,Math.max(l*Ai,fe));return{pts:c,nrm:Ci(c,i),front:Math.max(n[e].pitch*wi,fe),back:Math.max(n[e].pitch*Pi,fe)}}var $e=1.5,bo=.3;function sn(t,e){if(t.length<3)return t;let n=t[0],i=t[t.length-1],o=i.x-n.x,r=i.y-n.y,a=Math.hypot(o,r),s=-1,l=-1;for(let m=1;m<t.length-1;m++){let d=t[m],p=a>1e-12?Math.abs((d.x-n.x)*r-(d.y-n.y)*o)/a:Math.hypot(d.x-n.x,d.y-n.y);p>s&&(s=p,l=m)}if(s<=e||l<0)return[n,i];let c=sn(t.slice(0,l+1),e),h=sn(t.slice(l),e);return[...c.slice(0,-1),...h]}function yo(t,e){if(t.length<4)return t;let n=sn([...t,t[0]],e);return n.pop(),n.length>=3?n:t}function xo(t,e,n){if(t.length<2)return[];let i=n??_t(t),o=new Map;for(let a=0;a<t.length;a++){let s=o.get(t[a].blockId);s?s.push(a):o.set(t[a].blockId,[a])}let r=[];for(let[,a]of o){let s=[];for(let x of a){let v=t[x].patch;v&&v.length>=3?r.push({outline:[...v],holes:[],topY:t[x].y}):s.push(x)}if(!s.length)continue;s.sort((x,v)=>t[x].depth-t[v].depth);let c=s.map(x=>fo(t,x,i,e)).filter(x=>x!==null);if(!c.length)continue;let h=(x,v)=>({x:x.pts[v].x-x.nrm[v][0]*(x.front+$e),y:x.pts[v].y-x.nrm[v][1]*(x.front+$e)}),m=(x,v)=>({x:x.pts[v].x+x.nrm[v][0]*(x.back+$e),y:x.pts[v].y+x.nrm[v][1]*(x.back+$e)}),d=c[0],p=c[c.length-1],f=[];for(let x=0;x<d.pts.length;x++)f.push(h(d,x));for(let x of c)f.push(m(x,x.pts.length-1));for(let x=p.pts.length-1;x>=0;x--)f.push(m(p,x));for(let x=c.length-1;x>=0;x--)f.push(h(c[x],0));let u=go(f),b=1/0;for(let x of s)t[x].y<b&&(b=t[x].y);if(!Number.isFinite(b))continue;if(u.length>=3&&Math.abs(He(u))>1e-6&&c.every(x=>{let v=x.pts[Math.floor(x.pts.length/2)];return st(u,v.x,v.y)})){r.push({outline:yo(u,bo),holes:[],topY:b});continue}for(let x of Fi(c))r.push({outline:x,holes:[],topY:b})}return r}function Fi(t){let e=[];for(let n of t){let i=[],o=[],r=n.front+$e,a=n.back+$e;for(let l=0;l<n.pts.length;l++){let c=n.pts[l],h=n.nrm[l];i.push([c.x-h[0]*r,c.y-h[1]*r]),o.push([c.x+h[0]*a,c.y+h[1]*a])}let s=[...i,...o.reverse()];s.length<3||(s.push(s[0]),e.push([s]))}if(!e.length)return[];try{let n=ho.union(e[0],...e.slice(1)),i=[];for(let o of n){if(!o.length||o[0].length<4)continue;let r=o[0].map(([l,c])=>({x:l,y:c})),a=r[0],s=r[r.length-1];r.length>1&&Math.abs(a.x-s.x)<1e-9&&Math.abs(a.y-s.y)<1e-9&&r.pop(),r.length>=3&&i.push(yo(r,bo))}return i}catch{return[]}}function go(t){let e=[];for(let n of t){let i=e[e.length-1];i&&Math.hypot(n.x-i.x,n.y-i.y)<1e-9||e.push(n)}for(;e.length>2&&Math.hypot(e[0].x-e[e.length-1].x,e[0].y-e[e.length-1].y)<1e-9;)e.pop();return e}var cn=class{constructor(e){this.minX=1/0;this.minY=1/0;this.maxX=-1/0;this.maxY=-1/0;this.rings=e;for(let n of e)for(let i of n)i.x<this.minX&&(this.minX=i.x),i.y<this.minY&&(this.minY=i.y),i.x>this.maxX&&(this.maxX=i.x),i.y>this.maxY&&(this.maxY=i.y)}containsAll(e){for(let n of e)if(n.x<this.minX||n.x>this.maxX||n.y<this.minY||n.y>this.maxY)return!1;for(let n of this.rings){let i=!0;for(let o of e)if(!st(n,o.x,o.y)){i=!1;break}if(i)return!0}return!1}};function mo(t,e,n,i,o,r){if(i.length<3)return;if(n.containsAll(i)){let c=[0,1,0],h=i[0];for(let m=1;m+1<i.length;m++){let d=i[m],p=i[m+1];t.tri([h.x*R,o,h.y*R],[d.x*R,o,d.y*R],[p.x*R,o,p.y*R],c,r)}return}let a=i.map(c=>[c.x,c.y]);a.push(a[0]);let s;try{s=ho.intersection([a],e)}catch{return}let l=[0,1,0];for(let c of s){if(!c.length||c[0].length<4)continue;let h=c[0],m=[],d=[];for(let f=0;f<h.length-1;f++)m.push(h[f][0],h[f][1]),d.push([h[f][0],h[f][1]]);if(d.length<3)continue;let p=Si(m,void 0,2);for(let f=0;f<p.length;f+=3){let u=d[p[f]],b=d[p[f+1]],y=d[p[f+2]];t.tri([u[0]*R,o,u[1]*R],[b[0]*R,o,b[1]*R],[y[0]*R,o,y[1]*R],l,r)}}}function vo(t,e,n,i,o,r,a){if(e.length<2)return;let s=a??_t(e),l=[0,1,0],c=r&&r.length>=3?[[...r.map(p=>[p.x,p.y]),[r[0].x,r[0].y]]]:null,h=r&&r.length>=3?new cn([[...r]]):null,m=p=>{t.setMaterial(2),p(),t.setMaterial(0)},d=p=>{t.setMaterial(3),p(),t.setMaterial(0)};for(let p=0;p<e.length;p++){let f=e[p];if(f.patch&&f.patch.length>=3){let P=[...f.patch],M=s[p].belowY??i;if(d(()=>{if(c&&h)mo(t,c,h,P,f.y,o.tread);else{let F=P[0];for(let O=1;O+1<P.length;O++){let L=P[O],H=P[O+1];t.tri([F.x*R,f.y,F.y*R],[L.x*R,f.y,L.y*R],[H.x*R,f.y,H.y*R],l,o.tread)}}}),f.y>M+lo){let F=0,O=0;for(let L of P)F+=L.x,O+=L.y;F/=P.length,O/=P.length,m(()=>{for(let L=0;L<P.length;L++){let H=P[L],_=P[(L+1)%P.length],g=_.x-H.x,w=_.y-H.y,E=Math.hypot(g,w);if(E<1e-6)continue;let C=w/E,N=-g/E;(H.x-F)*C+(H.y-O)*N<0&&(C=-C,N=-N);let S=[C,0,N],I=[H.x*R,f.y,H.y*R],T=[_.x*R,f.y,_.y*R],B=[H.x*R,M,H.y*R],A=[_.x*R,M,_.y*R];t.tri(I,T,A,S,o.riser),t.tri(I,A,B,S,o.riser)}})}continue}let u=fo(e,p,s,n);if(!u)continue;let{pts:b,nrm:y,front:x,back:v}=u,k=s[p].belowY??i;for(let P=0;P+1<b.length;P++){let M=b[P],F=b[P+1],O=y[P],L=y[P+1];if(Math.hypot(F.x-M.x,F.y-M.y)<1e-6||O[0]===0&&O[1]===0||L[0]===0&&L[1]===0)continue;let H=[(M.x-O[0]*x)*R,f.y,(M.y-O[1]*x)*R],_=[(F.x-L[0]*x)*R,f.y,(F.y-L[1]*x)*R],g=[(M.x+O[0]*v)*R,f.y,(M.y+O[1]*v)*R],w=[(F.x+L[0]*v)*R,f.y,(F.y+L[1]*v)*R];if(d(()=>{c&&h?mo(t,c,h,[{x:M.x-O[0]*x,y:M.y-O[1]*x},{x:F.x-L[0]*x,y:F.y-L[1]*x},{x:F.x+L[0]*v,y:F.y+L[1]*v},{x:M.x+O[0]*v,y:M.y+O[1]*v}],f.y,o.tread):(t.tri(H,_,w,l,o.tread),t.tri(H,w,g,l,o.tread))}),f.y>k+lo){let E=[H[0],k,H[2]],C=[_[0],k,_[2]],N=[-O[0],0,-O[1]];m(()=>{t.tri(H,_,C,N,o.riser),t.tri(H,C,E,N,o.riser)})}}}}import So from"polygon-clipping";function Ei(t,e){let n=t.eventConfigurationIds;return!n?.length||!!e&&n.includes(e)}function Mo(t,e){return t.filter(n=>n.type!=="shape"||Ei(n,e))}function wo(t,e){let n=t.focalPoint??{x:0,y:0};return t.floors?.length?t.floors.map((i,o)=>({objects:Mo(i.objects,e),focal:{x:(i.focalPoint??n).x,y:(i.focalPoint??n).y},baseHeightM:i.baseHeightM??0,index:o})):[{objects:Mo(t.objects,e),focal:n,baseHeightM:0,index:0}]}var Di={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Je(t){return Dn(t)??Di}function Po(t,e){let n=Dt(t.outline,fe),i=Je(n),o=e.filter(a=>a!==t&&a.outline&&a.outline.length>=3&&Pt(i,Je(a.outline)));if(!o.length)return[n];let r=a=>{let s=a.map(l=>[l.x,l.y]);return s.push(s[0]),s};try{let a=So.difference([r(n)],...o.map(l=>[r(l.outline)])),s=[];for(let l of a){if(!l.length)continue;let c=l[0].map(([h,m])=>({x:h,y:m}));if(c.length>1){let h=c[0],m=c[c.length-1];Math.abs(h.x-m.x)<1e-9&&Math.abs(h.y-m.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s.length?s:[n]}catch{return[n]}}function Ao(t,e){if(!e.length)return t;let n=r=>{let a=r.map(s=>[s.x,s.y]);return a.push(a[0]),a},i=e.map(r=>[n(r)]),o=[];for(let r of t){let a;try{a=So.intersection([n(r.outline)],i.flat())}catch{o.push(r);continue}for(let s of a){if(!s.length)continue;let l=s[0].map(([c,h])=>({x:c,y:h}));if(l.length>1){let c=l[0],h=l[l.length-1];Math.abs(c.x-h.x)<1e-9&&Math.abs(c.y-h.y)<1e-9&&l.pop()}l.length>=3&&o.push({outline:l,holes:[],topY:r.topY})}}return o.length?o:t}var ki=.05,Co=.05,Li=.15,ln=25;function Ro(t,e,n){let i=new Map,o=new Array(e.length).fill(null),r=new Float64Array(e.length),a=new Array(e.length).fill(void 0),s=new Array(e.length).fill(void 0),l=new Map,c=[],h=new Set;for(let m=0;m<t.length;m+=1){let d=t[m];for(let p of d.objects){if(p.type==="table"&&h.add(p.id),p.type!=="section"||!p.outline||p.outline.length<3)continue;let f=Dt(p.outline,fe);l.set(p.id,{section:p,unit:d,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),c.push({id:p.id,floorIndex:m,box:Je(f),section:p,unit:d,outline:f})}}for(let m=0;m<e.length;m++){let d=e[m];for(let p of c){if(n&&p.floorIndex!==n[m]||d.x<p.box.minX||d.x>p.box.maxX||d.y<p.box.minY||d.y>p.box.maxY||!Fn({x:d.x,y:d.y},p.outline,p.section.holes))continue;o[m]=p.id;let f=l.get(p.id);f.hasSeats=!0;let u=d.focalPoint??p.unit.focal,b=Math.hypot(d.x-u.x,d.y-u.y);b<f.frontU&&(f.frontU=b),f.seatIndices.push(m);let y=d.rowId||`__seat-${m}`,x=f.rows.get(y);x?x.push({x:d.x,y:d.y}):f.rows.set(y,[{x:d.x,y:d.y}]);break}}for(let[m,d]of l){let p=In(d.section,{floorBaseHeightM:d.unit.baseHeightM}),f=d.unit.baseHeightM,u=p.rake>0?Math.tan(p.rake*Math.PI/180):0,b=p.rake<=.01&&p.height<=f+.001,y=d.section.surfaceKind,x=y==="flat"?!0:y==="rakedRows"&&p.rake>.01?!1:b,v=d.hasSeats?Tn(m,e,d.seatIndices,d.unit.focal):{sectionId:m,rows:[],blockCount:0},P=v.rows.length<2?kn([...d.rows.values()].map(S=>({points:S})),d.unit.focal):null,M=1/0;if(P){if(d.hasSeats)for(let S of d.rows.values())for(let I of S){let T=P.depthAt(I.x,I.y);T<M&&(M=T)}if(!d.hasSeats||!Number.isFinite(M)){M=1/0;for(let S of d.section.outline){let I=P.depthAt(S.x,S.y);I<M&&(M=I)}}}let F=f+ki,O=Math.max(F,p.height),L=S=>{let I=Math.max(0,S-M)*ke,T=Math.min(I*u,ln);return Math.max(F,p.height+T)},H=S=>{let I=Math.max(0,S)*ke,T=Math.min(I*u,ln);return Math.max(F,p.height+T)},_=x?[]:v.rows.map(S=>({pts:S.pts,y:H(S.blockDepth),depth:S.blockDepth,blockId:S.blockId,...h.has(S.id)?{patch:po(S.pts,fe)}:{}})),g=_.length?_[0].y:O,w=_.map(S=>{let I=S.patch&&S.patch.length>=3?S.patch:S.pts,T=0,B=0;for(let V of I)T+=V.x,B+=V.y;let A=I.length||1;T/=A,B/=A;let D=0;for(let V of I){let U=Math.hypot(V.x-T,V.y-B);U>D&&(D=U)}return{cx:T,cy:B,rad:D}}),E=x?()=>O:_.length>=2?(S,I)=>{let T=1/0,B=g;for(let A=0;A<_.length;A++){let D=w[A];if(Math.hypot(S-D.cx,I-D.cy)-D.rad>=T)continue;let V=_[A].patch,U=V&&V.length>=3?st(V,S,I)?0:wt(V,S,I):wt(_[A].pts,S,I);U<T&&(T=U,B=_[A].y)}return B}:(S,I)=>P?L(P.depthAt(S,I)):O,C=[0,1,0],N=_.length>=2||x?()=>C:(S,I)=>{if(!P)return C;let T=P.depthAt(S,I);if(T<=M)return C;let B=(T-M)*ke;if(B*u>=ln||p.height+B*u<=F)return C;let[A,D]=P.gradientAt(S,I);if(A===0&&D===0)return C;let V=1/Math.hypot(u,1);return[-A*u*V,V,-D*u*V]};if(!x)for(let S of v.rows){let I=H(S.blockDepth);for(let T of S.seatIndices)a[T]=I}for(let S of v.rows){let I=[];for(let V=1;V<S.pts.length;V++){let U=Math.hypot(S.pts[V].x-S.pts[V-1].x,S.pts[V].y-S.pts[V-1].y);U>1e-6&&I.push(U)}I.sort((V,U)=>V-U);let T=I.length?I[Math.floor(I.length/2)]:1/0,B=1/0,A=S.pts[Math.floor(S.pts.length/2)];if(A)for(let V of v.rows){if(V===S||V.blockId!==S.blockId)continue;let U=wt(V.pts,A.x,A.y);U>1e-6&&U<B&&(B=U)}let D=Math.min(T,Math.max(B,T*.5));if(Number.isFinite(D)&&D>0)for(let V of S.seatIndices)s[V]=D}i.set(m,{sectionId:m,deckAt:E,normalAt:N,flat:x,bottomY:f,rowLevels:_,landingY:g})}for(let m=0;m<e.length;m++){let d=o[m],p=e[m];if(d){let u=a[m];r[m]=(u??i.get(d).deckAt(p.x,p.y))+Li;continue}let f=p.eyeHeightM;r[m]=Number.isFinite(f)?Math.max(0,f-St):0}return{bySection:i,seatOwner:o,seatDeckY:m=>r[m],seatPitchU:m=>s[m]}}var re={top:1,wallBottom:.5,bottomCap:.4};function Ie(t,e){if(!t)return e;let n=pe(at(t,.4),.62);return he(e,n,.72)}function Io(t,e){let n=new Map;for(let r of t.categories??[])n.set(r.key,r.color);let i=new Map;for(let r of e){if(!r.sectionId)continue;let a=i.get(r.sectionId);a||(a=new Map,i.set(r.sectionId,a)),a.set(r.categoryKey,(a.get(r.categoryKey)??0)+1)}let o=new Map;for(let[r,a]of i){let s=0,l=0,c=0,h=0;for(let[m,d]of a){let p=K(n.get(m));p&&(s+=p[0]*d,l+=p[1]*d,c+=p[2]*d,h+=d)}h>0&&o.set(r,[s/h,l/h,c/h])}return o}function To(t,e){return K(t.color)??e.get(t.logicalSectionId??t.id)??null}import _i from"polygon-clipping";function Oi(t,e){return t===void 0||e===void 0?!0:Math.abs(t-e)<.001}var Ot=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(e,n){let i=e.map(l=>[l.x,l.y]);if(i.length<3)return[];i.push(i[0]);let o=Je(e),r=this.rings.filter((l,c)=>Pt(o,this.boxes[c])&&Oi(n,this.levels[c])),a=[[i]];if(r.length)try{a=_i.difference([i],...r).map(c=>c.map(h=>h.map(([m,d])=>[m,d])))}catch{a=[[i]]}this.rings.push([i]),this.boxes.push(o),this.levels.push(n);let s=[];for(let l of a){if(!l.length)continue;let c=l[0].map(([h,m])=>({x:h,y:m}));if(c.length>1){let h=c[0],m=c[c.length-1];Math.abs(h.x-m.x)<1e-9&&Math.abs(h.y-m.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s}};function Bi(t,e){if(!e)return t;let n=1/0,i=-1/0,o=1/0,r=-1/0;for(let m of t)n=Math.min(n,m.x),i=Math.max(i,m.x),o=Math.min(o,m.y),r=Math.max(r,m.y);let a=(n+i)/2,s=(o+r)/2,l=e*Math.PI/180,c=Math.cos(l),h=Math.sin(l);return t.map(m=>{let d=m.x-a,p=m.y-s;return{x:a+d*c-p*h,y:s+d*h+p*c}})}function ht(t){let e=null;if(t.kind==="polygon"&&t.points&&t.points.length>=3&&(e=t.points),t.kind==="rect"&&t.width&&t.height&&(e=dt(t.x??0,t.y??0,t.width,t.height)),t.kind==="ellipse"&&t.width&&t.height){let n=(t.x??0)+t.width/2,i=(t.y??0)+t.height/2;e=kt(n,i,t.width/2,t.height/2)}return e?Bi(e,t.rotation):null}function pt(t){let e=t.role??"",i={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}}[e]??{kind:"plate",heightM:.25};return{...i,heightM:t.heightM??i.heightM}}var Vi=.08;function Fo(t,e){let n=ht(t),i=pt(t),o=i.heightM;if(!n||i.kind!=="plate"&&i.kind!=="stage")return o;let r=1/0,a=1/0,s=-1/0,l=-1/0;for(let h of n)r=Math.min(r,h.x),a=Math.min(a,h.y),s=Math.max(s,h.x),l=Math.max(l,h.y);let c=o;for(let h of e)s>h.minX&&r<h.maxX&&l>h.minY&&a<h.maxY&&c<=h.topOffsetM+1e-6&&(c=h.topOffsetM+Vi);return e.push({minX:r,minY:a,maxX:s,maxY:l,topOffsetM:c}),c}function _e(t,e,n){return{x:t.x+(e.x-t.x)*n,y:t.y+(e.y-t.y)*n}}function Eo(t){if(t.length!==4)return t;let e=Math.hypot(t[1].x-t[0].x,t[1].y-t[0].y),n=Math.hypot(t[2].x-t[1].x,t[2].y-t[1].y);return e>=n?t:[t[1],t[2],t[3],t[0]]}function ft(t,e,n){return[_e(t[0],t[1],e),_e(t[0],t[1],n),_e(t[3],t[2],n),_e(t[3],t[2],e)]}function Do(t,e,n){return[_e(t[0],t[3],e),_e(t[1],t[2],e),_e(t[1],t[2],n),_e(t[0],t[3],n)]}function Te(t,e,n,i,o,r){ie(t,e,void 0,()=>n,i,o,r,re)}var un=2.4,Ni=.75,zi=.15;function bt(t){if(t.points&&t.points.length>=3)return t.points;let{center:e,width:n,height:i,rotation:o}=t;if(!n||!i)return null;let r=(o??0)*Math.PI/180,a=Math.cos(r),s=Math.sin(r),l=n/2,c=i/2;return[[-l,-c],[l,-c],[l,c],[-l,c]].map(([h,m])=>({x:e.x+h*a-m*s,y:e.y+h*s+m*a}))}function ko(t,e,n,i,o){let r=bt(e);r&&ie(t,r,void 0,()=>n+un,n,Ie(i,o.boothTop),o.boothWall,re)}function mn(t){if(t.shape==="round"){let h=t.radius;return h?kt(t.center.x,t.center.y,h,h,24):null}let{width:e,height:n,rotation:i,center:o}=t;if(!e||!n)return null;let r=(i??0)*Math.PI/180,a=Math.cos(r),s=Math.sin(r),l=e/2,c=n/2;return[[-l,-c],[l,-c],[l,c],[-l,c]].map(([h,m])=>({x:o.x+h*a-m*s,y:o.y+h*s+m*a}))}function Lo(t,e,n,i,o){let r=mn(e);r&&ie(t,r,void 0,()=>n+Ni,n,Ie(i,o.tableTop),o.tableWall,re)}function _o(t,e,n,i,o,r,a){let s=ht(e);if(!s)return;let l=e.role==="stage",c=pt(e),h=n+i;if(l&&a){let u=1/0,b=-1/0,y=1/0,x=-1/0;for(let v of s)v.x<u&&(u=v.x),v.x>b&&(b=v.x),v.y<y&&(y=v.y),v.y>x&&(x=v.y);a.push({cx:(u+b)/2*R,cz:(y+x)/2*R,y:h,halfX:Math.max((b-u)/2*R,.5),halfZ:Math.max((x-y)/2*R,.5)})}let m=K(e.fill),d=l&&m?he(o.stageTop,pe(at(m,.18),.9),.9):Ie(m,l?o.stageTop:o.decorTop),p=e.role==="screen"?m:null,f=l?m?he(o.stageWall,pe(m,.58),.82):o.stageWall:e.role==="screen"?p?he(pe(p,1.42),[.24,.46,.82],.08):[.24,.46,.82]:Ie(K(e.fill),o.decorWall);if(c.kind==="portal"&&s.length===4){let u=Eo(s);Te(t,ft(u,0,.16),h,n,d,f),Te(t,ft(u,.84,1),h,n,d,f),Te(t,u,h,Math.max(n,h-.35),d,f);return}if(c.kind==="suite"&&s.length===4){let u=s.map((x,v)=>{let k=s[(v+1)%4],P=(x.x+k.x)/2,M=(x.y+k.y)/2;return Math.hypot(P-r.x,M-r.y)}),b=u.indexOf(Math.min(...u)),y=[0,1,2,3].map(x=>s[(b+x)%4]);Te(t,ft(y,0,.08),h,n,d,f),Te(t,ft(y,.92,1),h,n,d,f),Te(t,Do(y,.88,1),h,n,d,f),Te(t,y,h,Math.max(n,h-.18),d,f);return}Te(t,s,h,n,d,f)}function dn(t){let{x:e,y:n,width:i,height:o}=t;if(!i||!o)return null;let r=e+i/2,a=n+o/2,s=(t.rotation??0)*Math.PI/180,l=Math.cos(s),c=Math.sin(s),h=i/2,m=o/2;return[[-h,-m],[h,-m],[h,m],[-h,m]].map(([d,p])=>({x:r+d*l-p*c,y:a+d*c+p*l}))}function Gi(t){if(!t||!t.startsWith("data:image/svg+xml"))return null;let e=t.slice(t.indexOf(",")+1);if(/;base64/i.test(t.slice(0,t.indexOf(","))))try{e=atob(e)}catch{return null}else try{e=decodeURIComponent(e)}catch{}let n=e.match(/<(?:rect|path)\b[^>]*\bfill="([^"]+)"/i);if(!n)return null;let i=n[1].trim();if(i==="none"||i==="transparent")return null;let o=i.match(/^url\(#([^)]+)\)$/);if(!o)return K(i);let r=e.match(new RegExp(`<(?:linear|radial)Gradient\\b[^>]*\\bid="${o[1]}"[^>]*>([\\s\\S]*?)</(?:linear|radial)Gradient>`,"i"));if(!r)return null;let a=[];for(let s of r[1].matchAll(/stop-color="([^"]+)"/gi)){let l=K(s[1].trim());l&&a.push(l)}return a.length?a.reduce((s,l,c)=>he(s,l,1/(c+1)),a[0]):null}function Oo(t,e,n,i){if(e.layer==="foreground")return;let o=dn(e);if(!o)return;let r=n+zi,a=Ie(Gi(e.href),i.decorTop),s=Math.max(0,Math.min(1,e.opacity??1));s<1&&(a=he(i.ground,a,s)),ie(t,o,void 0,()=>r,n,a,he(a,i.decorWall,.5),re)}function Bo(t,e,n,i,o){if(!e.points||e.points.length<3)return;let r=Ie(i,o.gaTop);ie(t,e.points,e.holes,()=>n+.15,n,r,o.gaWall,re)}var Hi=.25,Ui=1.2,Xi=.6,Yi=.45,Wi=2.3,ji=Math.PI/180;function Ye(t,e,n){let i=n*ji;return{x:t.x+e*Math.sin(i),y:t.y+e*Math.cos(i)}}function qi(t,e){let n=e.rings[e.rings.length-1];if(!n)return!1;let i=n.outerRMedian*.85;for(let o of t){if(o.role!=="wall")continue;let r=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(r.length<2)continue;let a=0;for(let s of r)Math.hypot(s.x-e.centre.x,s.y-e.centre.y)>=i&&a++;if(a>=r.length/2)return!0}return!1}var Zi=24;function Ki(t,e,n,i,o,r,a,s){let l=n.binCount,c=Zi,h=ke,m=r+.02,d=[];for(let g=0;g<l;g++){let w=(n.startBin+g+.5)*e.binStepDeg,E=new Float64Array(c+1);for(let C=0;C<=c;C++){let N=i[g]+(o[g]-i[g])*C/c;E[C]=Math.max(m,_n(e,n,w,N)-Hi)}d.push(E)}let p=[a.bandTop[0]*s.top,a.bandTop[1]*s.top,a.bandTop[2]*s.top],f=[a.bandTop[0]*s.bottomCap,a.bandTop[1]*s.bottomCap,a.bandTop[2]*s.bottomCap],u=[a.bandWall[0]*s.top,a.bandWall[1]*s.top,a.bandWall[2]*s.top],b=[a.bandWall[0]*s.wallBottom,a.bandWall[1]*s.wallBottom,a.bandWall[2]*s.wallBottom],y=(g,w)=>{let E=(n.startBin+g+.5)*e.binStepDeg,C=i[g]+(o[g]-i[g])*w/c,N=Ye(e.centre,C,E);return[N.x*h,d[g][w],N.y*h]};{let g=Math.tan(12*Math.PI/180);for(let w=0;w<6;w++){let E=!1;for(let N=0;N<l;N++)for(let S=c-1;S>=0;S--)d[N][S]>d[N][S+1]&&(d[N][S]=d[N][S+1],E=!0);let C=n.closed?l:l-1;for(let N=0;N<C;N++){let S=(N+1)%l;for(let I=0;I<=c;I++){let T=d[S][I]-d[N][I];if(Math.abs(T)>1)continue;let B=i[N]+(o[N]-i[N])*I/c,A=i[S]+(o[S]-i[S])*I/c,D=Ye(e.centre,B,(n.startBin+N+.5)*e.binStepDeg),V=Ye(e.centre,A,(n.startBin+S+.5)*e.binStepDeg),U=g*Math.hypot(V.x-D.x,V.y-D.y)*h;T>U?(d[S][I]=d[N][I]+U,E=!0):-T>U&&(d[N][I]=d[S][I]+U,E=!0)}}if(!E)break}}let x=1,v=(g,w)=>{for(let E=0;E<=c;E+=4)if(Math.abs(d[g][E]-d[w][E])>x)return!0;return Math.abs(d[g][c]-d[w][c])>x},k=Math.tan(38*Math.PI/180),P=g=>(o[g]-i[g])/c*h,M=(g,w)=>d[g][w+1]-d[g][w]>k*Math.max(1e-6,P(g)),F=(g,w)=>{let E=n.closed?(g-1+l)%l:Math.max(0,g-1),C=n.closed?(g+1)%l:Math.min(l-1,g+1);Math.abs(d[E][w]-d[g][w])>x&&(E=g),Math.abs(d[C][w]-d[g][w])>x&&(C=g);let N=Math.max(0,w-1),S=Math.min(c,w+1);N<w&&M(g,N)&&(N=w),S>w&&M(g,w)&&(S=w);let I=y(E,w),T=y(C,w),B=y(g,N),A=y(g,S),D=T[0]-I[0],V=T[1]-I[1],U=T[2]-I[2],Y=A[0]-B[0],X=A[1]-B[1],j=A[2]-B[2],Z=V*j-U*X,te=U*Y-D*j,ne=D*X-V*Y,Q=Math.hypot(Z,te,ne);return Q>1e-12?(Z/=Q,te/=Q,ne/=Q,te<0&&(Z=-Z,te=-te,ne=-ne),[Z,te,ne]):[0,1,0]},O=(g,w)=>{let E=[g[0],r,g[2]],C=[w[0],r,w[2]],N=w[0]-g[0],S=w[2]-g[2],I=Math.hypot(N,S);if(!(I>1e-12))return;let T=[S/I,0,-N/I];t.tri(g,w,C,T,u,u,b),t.tri(g,C,E,T,u,b,b)},L=.05*Le,H=g=>o[g]-i[g]<L,_=n.closed?l:l-1;for(let g=0;g<_;g++){let w=(g+1)%l;if(H(g)||H(w))continue;if(v(g,w)){let T=(n.startBin+g+1)*e.binStepDeg,B=(X,j)=>{let Z=(i[g]+i[w])/2,te=(o[g]+o[w])/2,ne=Z+(te-Z)*j/c,Q=Ye(e.centre,ne,T);return[Q.x*h,d[X][j],Q.y*h]};for(let X=0;X<c;X++){let j=y(g,X),Z=y(g,X+1),te=B(g,X),ne=B(g,X+1),Q=F(g,X),ae=F(g,X+1);t.triN(j,te,ne,Q,Q,ae,p),t.triN(j,ne,Z,Q,ae,ae,p);let Be=y(w,X),Ve=y(w,X+1),Se=B(w,X),we=B(w,X+1),Pe=F(w,X),ye=F(w,X+1);t.triN(Se,Be,Ve,Pe,Pe,ye,p),t.triN(Se,Ve,we,Pe,ye,ye,p);let xe=B(g,X),oe=B(g,X+1),qe=B(w,X+1),Fe=B(w,X),Ae=oe[0]-xe[0],Ne=oe[2]-xe[2],nt=Math.hypot(Ae,Ne);if(nt>1e-12){let me=[Ne/nt,0,-Ae/nt];t.tri(xe,oe,qe,me,u),t.tri(xe,qe,Fe,me,u)}}let A=y(g,0),D=y(w,0),V=y(w,c),U=y(g,c),Y=X=>[X[0],r,X[2]];t.tri(Y(A),Y(V),Y(D),[0,-1,0],f),t.tri(Y(A),Y(U),Y(V),[0,-1,0],f),O(A,D),O(U,V);continue}for(let T=0;T<c;T++){let B=F(g,T),A=F(w,T),D=F(w,T+1),V=F(g,T+1);if(M(g,T)||M(w,T)){let Z=(oe,qe)=>{let Fe=(n.startBin+oe+.5)*e.binStepDeg,Ae=i[oe]+(o[oe]-i[oe])*(T+.5)/c,Ne=Ye(e.centre,Ae,Fe);return[Ne.x*h,qe,Ne.y*h]},te=y(g,T),ne=y(w,T),Q=Z(g,d[g][T]),ae=Z(w,d[w][T]);t.triN(te,ne,ae,B,A,A,p),t.triN(te,ae,Q,B,A,B,p);let Be=y(w,T+1),Ve=y(g,T+1),Se=Z(g,d[g][T+1]),we=Z(w,d[w][T+1]);t.triN(Se,we,Be,V,D,D,p),t.triN(Se,Be,Ve,V,D,V,p);let Pe=ae[0]-Q[0],ye=ae[2]-Q[2],xe=Math.hypot(Pe,ye);if(xe>1e-12){let oe=[-ye/xe,0,Pe/xe];t.tri(Q,ae,we,oe,u),t.tri(Q,we,Se,oe,u)}continue}let U=y(g,T),Y=y(w,T),X=y(w,T+1),j=y(g,T+1);t.triN(U,Y,X,B,A,D,p),t.triN(U,X,j,B,D,V,p)}let E=y(g,0),C=y(w,0),N=y(w,c),S=y(g,c),I=T=>[T[0],r,T[2]];t.tri(I(E),I(N),I(C),[0,-1,0],f),t.tri(I(E),I(S),I(N),[0,-1,0],f),O(E,C),O(S,N)}if(!n.closed)for(let g of[0,l-1])for(let w=0;w<c;w++)O(y(g,w),y(g,w+1))}function Vo(t,e,n){let{bottomY:i,colors:o,ao:r}=n,a=new Float64Array(e.binCount).fill(-1/0);for(let h of e.rings)for(let m of h.arcs){let d=new Float64Array(m.binCount),p=new Float64Array(m.binCount);for(let u=0;u<m.binCount;u++){let b=(m.startBin+u)%e.binCount,y=Math.max(0,m.innerR[u]-fe);d[u]=Math.max(y,a[b]+.001),p[u]=Math.max(d[u]+.001,m.outerR[u]+fe)}let f=0;for(let u=0;u<m.binCount;u++){let b=m.topLevelM[u]-i;b>f&&(f=b)}f>=Ui&&Ki(t,e,m,d,p,i,o,r);for(let u=0;u<m.binCount;u++){let b=(m.startBin+u)%e.binCount;p[u]>a[b]&&(a[b]=p[u])}}if(qi(n.shapes,e))return;let s=e.rings[e.rings.length-1],l=Xi*Le,c=Yi*Le;for(let h of s.arcs){let m=[],d=[];for(let u=0;u<h.binCount;u++){let b=(h.startBin+u+.5)*e.binStepDeg,y=h.outerR[u]+fe+l;m.push(Ye(e.centre,y,b)),d.push(Ye(e.centre,y+c,b))}let p=-1/0;for(let u=0;u<h.binCount;u++)h.topLevelM[u]>p&&(p=h.topLevelM[u]);let f=()=>p+Wi;h.closed?ie(t,d,[m.slice().reverse()],f,i,o.shellTop,o.shellWall,r):ie(t,[...d,...m.slice().reverse()],void 0,f,i,o.shellTop,o.shellWall,r)}}function No(t,e,n,i,o,r,a,s){if(!e.outline||e.outline.length<3)return;let l=n.baseHeightM,c=Ie(i,s.tierTop);if(!o)return;let h=b=>o.deckAt(b.x,b.y),m=Po(e,a),d=m[0]??e.outline;if(o.rowLevels.length>=2){let b=_t(o.rowLevels),y=Ao(xo(o.rowLevels,n.focal,b),m),x=()=>[0,1,0];for(let k of y){let P=Math.max(l,k.topY-.02);for(let M of r.subtract(k.outline,P))ie(t,M,k.holes,()=>P,l,c,s.tierWall,re,void 0,x)}y.length||ie(t,d,e.holes,()=>o.landingY,l,c,s.tierWall,re);let v={tread:[c[0]*re.top,c[1]*re.top,c[2]*re.top],riser:[c[0]*.72,c[1]*.72,c[2]*.72]};for(let k of m.length?m:[d])vo(t,o.rowLevels,n.focal,o.landingY,v,k,b);return}let p=o.flat?1/0:Co,f=b=>o.normalAt(b.x,b.y),u=o.flat?o.landingY:void 0;for(let b of r.subtract(d,u))ie(t,b,e.holes,h,l,c,s.tierWall,re,p,f)}function Qi(t,e,n){let i=new Set;for(let a of t.objects)a.type==="section"&&i.add(a.id);let o=new Map;for(let a=0;a<e.length;a++){let s=n.seatOwner[a];if(!s||!i.has(s))continue;let l=n.bySection.get(s);if(l&&l.rowLevels.length>=2)continue;let c=e[a],h=o.get(s);h||(h=new Map,o.set(s,h));let m=c.rowId||`__seat-${a}`,d=h.get(m);d||(d={pts:[],levelM:0,n:0},h.set(m,d)),d.pts.push({x:c.x,y:c.y}),d.levelM+=n.seatDeckY(a),d.n++}let r=[];for(let a of t.objects){if(a.type!=="section")continue;let s=n.bySection.get(a.id);if(s&&s.rowLevels.length>=2){let c=s.rowLevels.filter(h=>!h.patch).map(h=>({pts:h.pts,levelM:h.y}));c.length>=2&&r.push({sectionId:a.id,rows:c});continue}let l=o.get(a.id);l&&r.push({sectionId:a.id,rows:[...l.values()].map(c=>({pts:c.pts,levelM:c.levelM/c.n}))})}return r}function zo(t,e,n,i,o){let r=Qi(e,n,i);if(!r.length)return;let a=Ln(r,e.focal);a&&(t.setMaterial(0),Vo(t,a,{bottomY:e.baseHeightM,colors:{bandTop:pe(o.tierTop,.8),bandWall:o.tierWall,shellTop:pe(o.tierWall,1.15),shellWall:o.tierWall},ao:re,shapes:e.objects.filter(s=>s.type==="shape")}))}function Go(t,e,n){return n<0?e>1?t.filter(i=>i.kind==="floor"):[...t]:t.filter(i=>i.floorIndex===void 0||i.floorIndex===n)}function Ho(t,e){let n=[...t].sort((o,r)=>o.screen.y-r.screen.y),i=[];for(let o of n){let r=i.find(a=>a.some(s=>Math.abs(s.screen.x-o.screen.x)<104&&Math.abs(s.screen.y-o.screen.y)<34));r?r.push(o):i.push([o])}return i.flatMap(o=>o.length<2?o:o.map((r,a)=>({...r,screen:{...r.screen,x:Math.max(54,Math.min(e-54,r.screen.x+(a-(o.length-1)/2)*104))}})))}var $i=1.15,Ji=3.25,ea=4.5,ta=.85,na=.5,oa=.26;function Uo(t,e,n){let i=Math.max(1e-6,e),o=t/i,r=n?.hasZoneLabels??!0,a=new Set;return o>=.75&&a.add("floor"),o>=$i&&a.add("zone"),o<=(r?Ji:ea)&&(a.add("section"),a.add("ga")),o<=ta&&(a.add("annotation"),a.add("booth")),o<=na&&a.add("row"),o<=oa&&a.add("seat"),a}function Oe(t,e,n,i){let o=t,r=e[0],a=e[1],s=e[2],l=o[0]*r+o[4]*a+o[8]*s+o[12],c=o[1]*r+o[5]*a+o[9]*s+o[13],h=o[2]*r+o[6]*a+o[10]*s+o[14],m=o[3]*r+o[7]*a+o[11]*s+o[15];if(!(m>1e-6))return{x:0,y:0,depth:1/0,visible:!1};let d=l/m,p=c/m,f=h/m,u=d>=-1.05&&d<=1.05&&p>=-1.05&&p<=1.05&&f<=1;return{x:(d*.5+.5)*n,y:(1-(p*.5+.5))*i,depth:f,visible:u}}function Xo(t,e,n=e){let i=[],o=[...t].sort((r,a)=>r.screen.depth-a.screen.depth);for(let r of o){let a=!1;for(let s of i){let l=Math.abs(r.screen.x-s.screen.x),c=Math.abs(r.screen.y-s.screen.y);if(l<e&&c<n){a=!0;break}}a||i.push(r)}return i}var Yo={row:8,seat:14};function Wo(t,e,n,i){let o=Math.max(1,Math.min(n,i)*.5),r=Math.min(2,Math.hypot(t.x-n/2,t.y-i/2)/o);return e*(1+1.5*r)}function jo(t,e,n,i){let o=[...t].sort((a,s)=>(s.priority??0)-(a.priority??0)||a.focus-s.focus),r=[];for(let a of o){if(r.length>=i)break;let s=!1;for(let l of r)if(Math.abs(a.screen.x-l.screen.x)<e&&Math.abs(a.screen.y-l.screen.y)<n){s=!0;break}s||r.push(a)}return r}var ra=6,ia=2.2,qo=.1,aa=.3,sa=1.8,ca=.9,la=.55,ua=6e3;function Zo(t){let{doc:e,units:n,seats:i,surfaces:o,focal:r}=t,a=e.zones??[],s=[];if(a.length){let l=new Map;for(let h of n)for(let m of h.objects)m.type==="section"&&m.zone&&l.set(m.id,m.zone);let c=new Map;for(let h=0;h<i.length;h++){let m=i[h],d=o.seatOwner[h],p=m.zoneId??(d?l.get(d):void 0);if(!p)continue;let f=c.get(p);f||(f={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},c.set(p,f)),f.n++,m.x<f.minX&&(f.minX=m.x),m.y<f.minY&&(f.minY=m.y),m.x>f.maxX&&(f.maxX=m.x),m.y>f.maxY&&(f.maxY=m.y),f.sumY+=o.seatDeckY(h)}for(let h of a){let m=c.get(h.id),d=[];for(let[p,f]of l)f===h.id&&d.push(p);if(!m||m.n===0){s.push({id:h.id,label:h.label,color:K(h.color),sectionIds:d,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(h.focalPoint??r).x*R,1.5,(h.focalPoint??r).y*R]});continue}s.push({id:h.id,label:h.label,color:K(h.color),sectionIds:d,seatCount:m.n,center:[(m.minX+m.maxX)/2*R,m.sumY/m.n,(m.minY+m.maxY)/2*R],radius:.5*Math.hypot((m.maxX-m.minX)*R,(m.maxY-m.minY)*R)||1,focalWorld:[(h.focalPoint??r).x*R,1.5,(h.focalPoint??r).y*R]})}}return s}function Ko(t){let{doc:e,units:n,seats:i,surfaces:o,seatData:r,hintedSeatFloor:a,zones:s,focal:l}=t,c=[],h=[],m=[];for(let d of s)d.seatCount!==0&&c.push({id:`zone:${d.id}`,kind:"zone",text:d.label,anchor:[d.center[0],d.center[1]+ra,d.center[2]],color:e.zones?.find(p=>p.id===d.id)?.color});{let d=new Map,p=new Map;for(let f=0;f<i.length;f++){let u=o.seatOwner[f];if(!u)continue;let b=d.get(u);b||(b={n:0,x:0,y:0,deck:0},d.set(u,b)),b.n++,b.x+=i[f].x,b.y+=i[f].y,b.deck+=o.seatDeckY(f);let y=p.get(u);y||(y={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0},p.set(u,y)),i[f].x<y.minX&&(y.minX=i[f].x),i[f].x>y.maxX&&(y.maxX=i[f].x),i[f].y<y.minY&&(y.minY=i[f].y),i[f].y>y.maxY&&(y.maxY=i[f].y)}for(let f of n)for(let u of f.objects){if(u.type!=="section")continue;let b=d.get(u.id);if(!b||b.n===0)continue;let y=p.get(u.id),x=[b.x/b.n*R,b.deck/b.n,b.y/b.n*R],v=u.displayLabel||u.label||u.id;h.push({id:u.id,floorIndex:f.index,label:v,seatCount:b.n,center:x,radius:Math.max(1,Math.hypot(y.maxX-y.minX,y.maxY-y.minY)*.5*R),focalWorld:[f.focal.x*R,f.baseHeightM+1.5,f.focal.y*R]});let k=e.floors?.[f.index]?.name?.trim().toLocaleLowerCase();n.length>1&&k===v.trim().toLocaleLowerCase()||c.push({id:`section:${u.id}`,kind:"section",text:v,anchor:[x[0],x[1]+ia,x[2]],floorIndex:f.index})}}{for(let f of n)for(let u of f.objects){if(u.type!=="gaArea")continue;let b=it(u.points);if(!b)continue;let y=u.displayLabel||u.label||u.id;c.push({id:`ga:${u.id}`,kind:"ga",text:u.capacity>0?`${y} \xB7 ${u.capacity.toLocaleString()}`:y,anchor:[b.x*R,f.baseHeightM+sa,b.y*R],floorIndex:f.index})}let d=new Map;for(let f=0;f<i.length;f++){let u=i[f],b=Math.hypot(u.x-l.x,u.y-l.y),y=d.get(u.rowId);(!y||b>y.far)&&d.set(u.rowId,{seat:u,index:f,far:b})}for(let[f,u]of d){let b=u.seat.label?u.seat.label.lastIndexOf("-"):-1,y=b>0?u.seat.label.slice(0,b):f;y&&c.push({id:`row:${f}`,kind:"row",text:y,anchor:[u.seat.x*R,o.seatDeckY(u.index)+ca,u.seat.y*R],floorIndex:a[u.index]})}let p=new Map;for(let f=0;f<i.length;f++){let u=i[f],b=u.label?u.label.lastIndexOf("-"):-1,y=p.get(u.rowId);y||(y={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:b>0?u.label.slice(0,b):u.rowId,sectionId:u.sectionId},p.set(u.rowId,y));let x=f*3,v=r.iPosition[x],k=r.iPosition[x+1],P=r.iPosition[x+2];y.n++,y.x+=v,y.y+=k,y.z+=P,y.minX=Math.min(y.minX,v),y.maxX=Math.max(y.maxX,v),y.minZ=Math.min(y.minZ,P),y.maxZ=Math.max(y.maxZ,P)}for(let[f,u]of p)m.push({id:f,label:u.label,sectionId:u.sectionId,seatCount:u.n,center:[u.x/u.n,u.y/u.n,u.z/u.n],radius:Math.max(.8,Math.hypot(u.maxX-u.minX,u.maxZ-u.minZ)*.5)});if(i.length<=ua)for(let f=0;f<i.length;f++){let u=i[f],b=u.displayLabel||u.label;b&&c.push({id:`seat:${u.id}`,kind:"seat",text:b,anchor:[u.x*R,o.seatDeckY(f)+la,u.y*R],floorIndex:a[f]})}}for(let d of n)for(let p of d.objects)if(p.type==="shape"&&p.role&&["entrance","exit","screen","suite","obstruction"].includes(p.role)){let f=ht(p),u=f?it(f):null;if(!u||!p.label)continue;c.push({id:`architecture:${p.id}`,kind:"annotation",text:p.label,anchor:[u.x*R,d.baseHeightM+pt(p).heightM+qo,u.y*R],color:p.fill,floorIndex:d.index})}else if(p.type==="text"){if(!p.text)continue;c.push({id:`text:${p.id}`,kind:"annotation",text:p.text,anchor:[p.position.x*R,d.baseHeightM+qo,p.position.y*R],color:p.color,rotation:p.rotation,floorIndex:d.index})}else if(p.type==="booth"){let f=bt(p);if(!f)continue;let u=it(f);if(!u)continue;c.push({id:`booth:${p.id}`,kind:"booth",text:p.displayLabel||p.label||p.id,anchor:[u.x*R,d.baseHeightM+un+aa,u.y*R],floorIndex:d.index})}return{labels:c,sections:h,rows:m}}function Qo(t,e){if(e.length>1)for(let n of e)t.push({id:`floor:${n.id}`,kind:"floor",text:n.label,anchor:[n.center[0],n.box.max[1]+1.2,n.center[2]],floorIndex:n.index})}function $o(t){let{doc:e,units:n,seats:i,surfaces:o,solids:r,hintedSeatFloor:a,seatFloor:s}=t,l=[];{let c=n.map(()=>({minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}));for(let d=0;d<r.floor.length;d+=1){let p=Math.max(0,Math.min(n.length-1,Math.round(r.floor[d]))),f=d*3,u=c[p];u.minX=Math.min(u.minX,r.position[f]),u.minY=Math.min(u.minY,r.position[f+1]),u.minZ=Math.min(u.minZ,r.position[f+2]),u.maxX=Math.max(u.maxX,r.position[f]),u.maxY=Math.max(u.maxY,r.position[f+1]),u.maxZ=Math.max(u.maxZ,r.position[f+2])}let h=new Map;for(let d=0;d<n.length;d++)for(let p of n[d].objects)p.type==="section"&&h.set(p.id,d);let m=n.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 d=0;d<i.length;d++){let p=o.seatOwner[d],f=(p!==null?h.get(p):void 0)??a[d];if(f===void 0)continue;let u=m[f],b=i[d];u.n++,b.x<u.minX&&(u.minX=b.x),b.y<u.minY&&(u.minY=b.y),b.x>u.maxX&&(u.maxX=b.x),b.y>u.maxY&&(u.maxY=b.y);let y=o.seatDeckY(d);u.sumX+=b.x*R,u.sumDeck+=y,u.sumZ+=b.y*R,u.minDeck=Math.min(u.minDeck,y),u.maxDeck=Math.max(u.maxDeck,y+1.6),s[d]=f}for(let d=0;d<n.length;d++){let p=m[d],f=e.floors?.[d],u=c[d],b=Math.min(p.n?p.minX*R:n[d].focal.x*R-1,Number.isFinite(u.minX)?u.minX:1/0),y=Math.max(p.n?p.maxX*R:n[d].focal.x*R+1,Number.isFinite(u.maxX)?u.maxX:-1/0),x=Math.min(p.n?p.minY*R:n[d].focal.y*R-1,Number.isFinite(u.minZ)?u.minZ:1/0),v=Math.max(p.n?p.maxY*R:n[d].focal.y*R+1,Number.isFinite(u.maxZ)?u.maxZ:-1/0),k=Math.min(p.n?Math.min(n[d].baseHeightM,p.minDeck):n[d].baseHeightM,Number.isFinite(u.minY)?u.minY:1/0),P=Math.max(p.n?Math.max(p.maxDeck,k+.5):k+.5,Number.isFinite(u.maxY)?u.maxY:-1/0),M=[p.n?p.sumX/p.n:(b+y)/2,p.n?p.sumDeck/p.n:(k+P)/2,p.n?p.sumZ/p.n:(x+v)/2],F=Math.max(1,.5*Math.hypot(y-b,P-k,v-x));l.push({index:d,id:f?.id??`floor-${d}`,label:f?.name??(n.length>1?`Floor ${d+1}`:"Venue"),seatCount:p.n,center:M,radius:F,box:{min:[b,k,x],max:[y,P,v]},focalWorld:[n[d].focal.x*R,n[d].baseHeightM+1.5,n[d].focal.y*R]})}}return l}function hn(t,e){let n=1/0,i=1/0,o=-1/0,r=-1/0,a=(s,l)=>{s<n&&(n=s),l<i&&(i=l),s>o&&(o=s),l>r&&(r=l)};for(let s of e)a(s.x,s.y);for(let s of t)for(let l of s.objects)if(l.type==="section")for(let c of l.outline)a(c.x,c.y);else if(l.type==="shape"&&l.points)for(let c of l.points)a(c.x,c.y);else if(l.type==="gaArea")for(let c of l.points)a(c.x,c.y);else if(l.type==="booth"){let c=bt(l);if(c)for(let h of c)a(h.x,h.y)}else if(l.type==="table"){let c=mn(l);if(c)for(let h of c)a(h.x,h.y)}else if(l.type==="decorImage"){let c=dn(l);if(c)for(let h of c)a(h.x,h.y)}return Number.isFinite(n)||(n=-100,i=-100,o=100,r=100),{minX:n,minY:i,maxX:o,maxY:r}}function Jo(t,e,n,i,o,r){if(e.length===1){let a=Math.max(60,(o.maxX-o.minX+o.maxY-o.minY)*.06),s=dt(o.minX-a,o.minY-a,o.maxX-o.minX+a*2,o.maxY-o.minY+a*2);ie(t,s,void 0,()=>0,-.4,r.ground,r.ground,re)}else{let a=e.reduce((p,f)=>f.baseHeightM<p.baseHeightM?f:p);t.setFloor(a.index);let s=n.filter((p,f)=>i[f]===a.index),l=hn([a],s),c=Math.hypot(l.maxX-l.minX,l.maxY-l.minY),h=Math.max(28,Math.min(80,c*.04)),m=dt(l.minX-h,l.minY-h,l.maxX-l.minX+h*2,l.maxY-l.minY+h*2),d=a.baseHeightM-.03;ie(t,m,void 0,()=>d,d-.22,r.ground,r.ground,re)}}function er(t,e,n){let{cx:i,cz:o,radius:r}=n,a=1/0,s=1/0,l=1/0,c=-1/0,h=-1/0,m=-1/0,d=(u,b,y)=>{a=Math.min(a,u),c=Math.max(c,u),s=Math.min(s,b),h=Math.max(h,b),l=Math.min(l,y),m=Math.max(m,y)};for(let u=0;u<t.position.length;u+=3)d(t.position[u],t.position[u+1],t.position[u+2]);for(let u=0;u<e.count;u++){let b=u*3,y=e.iPosition[b],x=e.iPosition[b+1],v=e.iPosition[b+2],k=Math.max(.35,e.iMaxRadius[u]??.35);d(y-k,x,v-k),d(y+k,x+1.6,v+k)}Number.isFinite(a)||(a=i-r,c=i+r,s=0,h=r*.16,l=o-r,m=o+r);let p=[(a+c)/2,(s+h)/2,(l+m)/2],f=Math.max(1,.5*Math.hypot(c-a,h-s,m-l));return{center:p,radius:f,minY:s,maxY:h}}function tr(t,e,n,i,o,r){let a=1/0,s=1/0,l=-1/0,c=-1/0;for(let k=0;k<t.count;k++){let P=k*3,M=t.iPosition[P],F=t.iPosition[P+2];M<a&&(a=M),M>l&&(l=M),F<s&&(s=F),F>c&&(c=F)}for(let k of e)a=Math.min(a,k.cx-k.halfX),l=Math.max(l,k.cx+k.halfX),s=Math.min(s,k.cz-k.halfZ),c=Math.max(c,k.cz+k.halfZ);let h=n.minX*R,m=n.maxX*R,d=n.minY*R,p=n.maxY*R,f=h,u=m,b=d,y=p;if(Number.isFinite(a)){let k=Math.max(2,.06*Math.hypot(l-a,c-s));f=Math.max(h,a-k),u=Math.min(m,l+k),b=Math.max(d,s-k),y=Math.min(p,c+k)}let x=Math.min(0,i),v=Math.max(o,r*.05);return{min:[f,x,b],max:[u,v,y]}}function yt(t){let{doc:e}=t,n=so(e.theme),i=n.structure,o=wo(e,t.eventConfigurationId??e.eventConfigurationId),r=t.seats,a=new Et,s=new Map;for(let g of o)for(let w of g.objects)s.set(w.id,g.index),w.type==="section"&&s.set(w.logicalSectionId??w.id,g.index);let l=r.map(g=>s.get(g.sectionId??"")??s.get(g.rowId??"")??0),c=hn(o,r);Jo(a,o,r,l,c,i);let h=Io(e,r),m=new Map;for(let g of e.categories??[])m.set(g.key,g.color);let d=[],p=Ro(o,r,l),f=new Float32Array(r.length);for(let g=0;g<o.length;g++){let w=o[g];a.setFloor(g);let E=new Ot,C=[],N=w.objects.filter(S=>S.type==="section"&&!!S.outline&&S.outline.length>=3);for(let S of w.objects)S.type==="section"?No(a,S,w,To(S,h),p.bySection.get(S.id),E,N,i):S.type==="shape"?(a.setMaterial(S.role==="screen"?1:0),_o(a,S,w.baseHeightM,Fo(S,C),i,w.focal,d),a.setMaterial(0)):S.type==="gaArea"?Bo(a,S,w.baseHeightM,K(m.get(S.categoryKey)),i):S.type==="booth"?ko(a,S,w.baseHeightM,K(m.get(S.categoryKey)),i):S.type==="table"?Lo(a,S,w.baseHeightM,K(m.get(S.categoryKey)),i):S.type==="decorImage"&&Oo(a,S,w.baseHeightM,i);zo(a,w,r,p,i)}let u=o.length>1?{x:o.reduce((g,w)=>g+w.focal.x,0)/o.length,y:o.reduce((g,w)=>g+w.focal.y,0)/o.length}:e.focalPoint??{x:(c.minX+c.maxX)/2,y:(c.minY+c.maxY)/2},b=to([a.build()]),y=ao(r,t.initialState,p,f,m),x=Zo({doc:e,units:o,seats:r,surfaces:p,focal:u}),{labels:v,sections:k,rows:P}=Ko({doc:e,units:o,seats:r,surfaces:p,seatData:y,hintedSeatFloor:l,zones:x,focal:u}),M=$o({doc:e,units:o,seats:r,surfaces:p,solids:b,hintedSeatFloor:l,seatFloor:f});Qo(v,M),y.iYaw=ro(y.iPosition,r.length,g=>r[g].rowId,g=>{let w=o[f[g]]?.focal??u;return[w.x*R,w.y*R]});let F=(c.minX+c.maxX)/2*R,O=(c.minY+c.maxY)/2*R,L=.5*Math.hypot((c.maxX-c.minX)*R,(c.maxY-c.minY)*R)||10,H=er(b,y,{cx:F,cz:O,radius:L}),_=tr(y,d,c,H.minY,H.maxY,L);return{solids:b,seats:y,bounds:{center:[(_.min[0]+_.max[0])/2,(_.min[1]+_.max[1])/2,(_.min[2]+_.max[2])/2],radius:L,groundY:0,box:_},renderBounds:{center:H.center,radius:H.radius},stateColorLUT:co(n,be),theme:n,seatCount:r.length,focalWorld:[u.x*R,1.5,u.y*R],zones:x,stages:d,sections:k,rows:P,labels:v,floors:M}}var ma=88,da=20,ha={floor:{size:14,weight:"700",opacity:.98},zone:{size:15,weight:"600",opacity:.95},section:{size:12,weight:"500",opacity:.88},ga:{size:12,weight:"500",opacity:.88},booth:{size:11,weight:"500",opacity:.85},annotation:{size:11,weight:"400",opacity:.75},row:{size:10.5,weight:"600",opacity:.8},seat:{size:9.5,weight:"500",opacity:.72}},pn=new Set(["row","seat"]),nr={floor:5,zone:4,section:3,ga:3,booth:2,annotation:1},or={row:{x:62,y:16},seat:{x:46,y:18}},ir=K,fn=t=>En(t);function ar(t,e){let n=fn(t),i=fn(e);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function rr(t,e){let n=/rgba\((\d+),(\d+),(\d+),([\d.]+)\)/.exec(t.replace(/\s/g,""));if(!n)return e;let i=Math.max(0,Math.min(1,Number(n[4])));return[1,2,3].map(o=>Number(n[o])/255*i+e[o-1]*(1-i))}function pa(t,e=[.04,.06,.1]){let n=fn(e)<.42,i=n?"#f4f7fb":"#0b1220",o=ir(t),r=o&&ar(o,e)>=4.5?t:i;return n?{ink:r,backing:"rgba(8,12,22,.78)",border:"rgba(210,222,245,.24)"}:{ink:r,backing:"rgba(255,255,255,.84)",border:"rgba(11,18,32,.22)"}}var Bt=class{constructor(e,n={}){this.nodes=new Map;this.labels=[];this.forcedDense=!1;this.selectedSeatLabelIds=new Set;this.opts=n,this.root=document.createElement("div"),this.root.setAttribute("data-view3d-labels","");let i=this.root.style;i.position="absolute",i.inset="0",i.pointerEvents="none",i.overflow="hidden",n.fontFamily&&(i.fontFamily=n.fontFamily),e.appendChild(this.root)}setVisible(e){this.root.style.visibility=e?"":"hidden"}setLabels(e){this.labels=e;for(let[n,i]of this.nodes)e.some(o=>o.id===n)||(i.remove(),this.nodes.delete(n))}setForcedDense(e){this.forcedDense=e}setSelectedSeatIds(e){this.selectedSeatLabelIds=new Set(Array.from(e,n=>`seat:${n}`))}qualityEvidence(){let e=this.root.getBoundingClientRect(),n=this.root.style.visibility!=="hidden";return this.labels.map(i=>{let o=this.nodes.get(i.id),r=o?.getBoundingClientRect(),a=!!(n&&o&&o.style.display!=="none"&&r&&r.width>0&&r.height>0);return{id:i.id,kind:i.kind,text:i.text,visible:a,renderedFontPx:o&&Number.parseFloat(o.style.fontSize)||0,contrast:o?Number(o.dataset.qualityContrast??0):0,...a&&r?{screenBox:{x:r.x-e.x,y:r.y-e.y,width:r.width,height:r.height}}:{}}})}update(e,n,i,o,r,a){if(!this.labels.length)return;let s=Uo(o,r,{hasZoneLabels:this.labels.some(u=>u.kind==="zone")});this.forcedDense&&(s.add("row"),s.add("seat"));let l=[];for(let u of this.labels){if(!s.has(u.kind))continue;let b=Oe(e,u.anchor,n,i);if(!b.visible)continue;let y=a?Math.hypot(u.anchor[0]-a[0],u.anchor[1]-a[1],u.anchor[2]-a[2]):1;l.push({label:u,screen:b,focus:Wo(b,y,n,i),...this.selectedSeatLabelIds.has(u.id)?{priority:1}:{}})}let c=Ho(l.filter(u=>u.label.kind==="floor"),n),h=[...l.filter(u=>!pn.has(u.label.kind)&&u.label.kind!=="floor"),...c],m=[...Xo(h,ma,da),...["row","seat"].flatMap(u=>jo(l.filter(b=>b.label.kind===u),or[u].x,or[u].y,Yo[u]))],d=new Set(m.map(u=>u.label.id));for(let{label:u,screen:b}of m){let x=this.nodeFor(u).style;x.display="",x.transform=`translate(-50%, -50%) translate(${b.x.toFixed(1)}px, ${b.y.toFixed(1)}px)`}let p=m.filter(({label:u})=>!pn.has(u.kind)).sort((u,b)=>nr[b.label.kind]-nr[u.label.kind]||u.screen.depth-b.screen.depth||u.focus-b.focus),f=[];for(let{label:u}of p){let b=this.nodes.get(u.id);if(!b||b.style.display==="none")continue;let y=b.getBoundingClientRect();f.some(v=>y.left<v.right+3&&y.right+3>v.left&&y.top<v.bottom+3&&y.bottom+3>v.top)?b.style.display="none":f.push(y)}for(let[u,b]of this.nodes)d.has(u)||(b.style.display="none")}nodeFor(e){let n=this.nodes.get(e.id);if(!n){n=document.createElement("div");let m=n.style;m.position="absolute",m.left="0",m.top="0",m.whiteSpace="nowrap",m.textShadow="0 1px 3px rgba(0,0,0,0.85), 0 0 8px rgba(0,0,0,0.55)",m.display="none",this.root.appendChild(n),this.nodes.set(e.id,n)}n.textContent=e.text,n.setAttribute("data-label-kind",e.kind);let i=this.selectedSeatLabelIds.has(e.id);n.toggleAttribute("data-selected-seat",i);let o=ha[e.kind],r=n.style;r.fontSize=`${o.size}px`,r.fontWeight=i?"800":o.weight,r.opacity=i?"1":String(o.opacity);let a=pa(e.color??this.opts.ink,this.opts.backgroundRgb),s=!pn.has(e.kind);r.color=i?"#ecf8ff":a.ink,r.background=i?"rgba(10,28,45,.9)":s?a.backing:"",r.border=i?"1px solid rgba(89,199,255,.92)":s?`1px solid ${a.border}`:"",r.borderRadius=i||s?"999px":"",r.padding=i||s?"3px 7px":"",r.boxShadow=i?"0 0 0 2px rgba(41,176,255,.18), 0 5px 14px rgba(0,0,0,.35)":s?"0 3px 10px rgba(0,0,0,.24)":"",r.letterSpacing=e.kind==="zone"||e.kind==="floor"?"0.08em":"0.02em";let l=this.opts.backgroundRgb??[.04,.06,.1],c=ir(i?"#ecf8ff":a.ink)??[1,1,1],h=i?rr("rgba(10,28,45,.9)",l):s?rr(a.backing,l):l;return n.dataset.qualityContrast=ar(c,h).toFixed(3),(e.kind==="zone"||e.kind==="floor")&&(r.textTransform="uppercase"),n}dispose(){this.root.remove(),this.nodes.clear()}};var fa=1;var ba=new Set(["floor","zone","section","ga","booth","annotation"]);function ya(t){return t.every(e=>Number.isFinite(e))}function xa(t,e){return t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y}function sr(t){return t.length?Math.round(Math.min(...t)*100)/100:null}function We(t){return Math.round(t*1e4)/1e4}function ga(t){if(t)return{box:{x:We(t.box.x),y:We(t.box.y),width:We(t.box.width),height:We(t.box.height)},horizontalFillRatio:We(t.horizontalFillRatio),verticalFillRatio:We(t.verticalFillRatio),visibleAreaRatio:We(t.visibleAreaRatio),clippedEdges:[...t.clippedEdges]}}function Me(t,e,n){return n.length?{code:t,message:e,count:n.length,samples:n.slice(0,20)}:null}function bn(t){let e=t.labels.filter(s=>s.visible&&s.screenBox),n=e.filter(s=>ba.has(s.kind)),i=t.scene.floorCount>1?t.scene.floorCount:t.scene.zoneCount||t.scene.sectionCount,o=[];for(let s=0;s<n.length;s+=1)for(let l=0;l<s;l+=1)xa(n[s].screenBox,n[l].screenBox)&&o.push({primaryId:n[s].id,primaryLabel:n[s].text,secondaryId:n[l].id});let r=[...t.camera.position,t.camera.distance,t.camera.verticalFovDeg],a=[Me("webgl2-unavailable","The venue scene must render through WebGL2",t.context.webgl2?[]:[{primaryId:"renderer",primaryLabel:"WebGL2"}]),Me("context-lost","The WebGL context must be live at capture",t.context.lost?[{primaryId:"renderer",primaryLabel:"context lost"}]:[]),Me("frame-not-stable","The captured 3D frame must be rendered and parked",t.frame.rendered>0&&t.frame.idle?[]:[{primaryId:"renderer",primaryLabel:"unstable frame"}]),Me("viewport-empty","The 3D viewport must have visible dimensions",t.viewport.width>1&&t.viewport.height>1?[]:[{primaryId:"viewport",primaryLabel:`${t.viewport.width}\xD7${t.viewport.height}`}]),Me("camera-invalid","The capture camera must have a finite physical pose",ya(r)&&t.camera.distance>0&&t.camera.verticalFovDeg>0&&t.camera.verticalFovDeg<180?[]:[{primaryId:"camera",primaryLabel:"invalid pose"}]),Me("authored-relief-not-visible","Authored 3D height or rake must produce visible screen-space relief",!t.scene.authoredRelief||t.scene.renderedVerticalSpanM>.05&&t.scene.projectedReliefPx>=2?[]:[{primaryId:"scene",primaryLabel:"authored relief",measured:t.scene.projectedReliefPx,minimum:2}]),Me("hierarchy-label-missing","A venue with authored hierarchy must show at least one structural label",i===0||n.length>0?[]:[{primaryId:"labels",primaryLabel:`${i} expected hierarchy labels`}]),Me("hierarchy-label-undersized","Visible 3D hierarchy labels must remain readable",n.filter(s=>s.renderedFontPx<11).map(s=>({primaryId:s.id,primaryLabel:s.text,measured:s.renderedFontPx,minimum:11}))),Me("hierarchy-label-contrast-low","Visible 3D hierarchy labels must meet text contrast",n.filter(s=>s.contrast<4.5).map(s=>({primaryId:s.id,primaryLabel:s.text,measured:s.contrast,minimum:4.5}))),Me("hierarchy-label-collision","Visible 3D hierarchy labels must not overlap",o)].filter(s=>!!s);return{version:1,state:"venue3d",passed:a.length===0,resolvedRules:["rendered-3d-webgl-context","rendered-3d-stable-frame","rendered-3d-camera-pose","rendered-3d-relief-projection","rendered-3d-label-size","rendered-3d-label-contrast","rendered-3d-label-collision"],viewport:t.viewport,context:t.context,frame:t.frame,camera:t.camera,scene:t.scene,composition:{visibleLabels:e.map(({id:s,kind:l,text:c})=>({id:s,kind:l,text:c})).sort((s,l)=>s.kind.localeCompare(l.kind)||s.id.localeCompare(l.id)),framing:ga(t.framing)},metrics:{minimumHierarchyFontPx:sr(n.map(s=>s.renderedFontPx)),minimumHierarchyContrast:sr(n.map(s=>s.contrast)),projectedReliefPx:Math.round(t.scene.projectedReliefPx*100)/100},findings:a}}import{Geometry as Nt,Mesh as zt,Transform as br}from"ogl";import{Program as je}from"ogl";var Vt=`
2
2
  float chairWeight(float depth) {
3
3
  return 1.0 - smoothstep(uChairFull, uChairNone, depth);
4
- }`,ar=`
4
+ }`,cr=`
5
5
  float occupantWeight(float depth) {
6
- float nearWeight = smoothstep(${Xn.toFixed(1)}, ${Wn.toFixed(1)}, depth);
7
- float farWeight = 1.0 - smoothstep(${Un.toFixed(1)}, ${Yn.toFixed(1)}, depth);
6
+ float nearWeight = smoothstep(${Zn.toFixed(1)}, ${Kn.toFixed(1)}, depth);
7
+ float farWeight = 1.0 - smoothstep(${jn.toFixed(1)}, ${qn.toFixed(1)}, depth);
8
8
  return nearWeight * farWeight;
9
- }`,Sa=`#version 300 es
9
+ }`,va=`#version 300 es
10
10
  precision highp float;
11
11
  in vec3 position;
12
12
  in vec3 normal;
@@ -42,7 +42,7 @@ void main() {
42
42
  vNormalWorld = normalize(mat3(modelMatrix) * normal);
43
43
  vColor = color;
44
44
  gl_Position = projectionMatrix * mv;
45
- }`,wa=`#version 300 es
45
+ }`,Ma=`#version 300 es
46
46
  precision highp float;
47
47
  in vec3 vColor;
48
48
  in vec3 vNormalWorld;
@@ -104,7 +104,7 @@ void main() {
104
104
  + vec3(0.20, 0.10, 0.34) * focalHalo;
105
105
  base = mix(base, display, poweredDisplay * verticalFace * 0.92);
106
106
  fragColor = vec4(base, 1.0);
107
- }`,Pa=`#version 300 es
107
+ }`,Sa=`#version 300 es
108
108
  precision highp float;
109
109
  in vec2 position; // quad corner in [-1,1]
110
110
  in vec3 iOffset; // per-instance world position
@@ -130,7 +130,7 @@ out float vDim;
130
130
  out float vDotWeight; // 1 = the dot IS this seat, 0 = the chair has taken over
131
131
  out float vPhysicalSeat;
132
132
  out float vPixelRadius;
133
- ${Ot}
133
+ ${Vt}
134
134
  void main() {
135
135
  vec4 mv = modelViewMatrix * vec4(iOffset, 1.0);
136
136
  float depth = max(-mv.z, 0.001);
@@ -163,7 +163,7 @@ void main() {
163
163
  vPhysicalSeat = iPhysicalSeat;
164
164
  vDim = (uFocusFloor < -0.5 || abs(iFloor - uFocusFloor) < 0.5) ? 0.0 : 1.0;
165
165
  gl_Position = projectionMatrix * mv;
166
- }`,Aa=`#version 300 es
166
+ }`,wa=`#version 300 es
167
167
  precision highp float;
168
168
  in vec2 vUv;
169
169
  in vec3 vColor;
@@ -221,7 +221,7 @@ void main() {
221
221
  alpha *= vDotWeight;
222
222
  if (alpha <= 0.0) discard;
223
223
  fragColor = vec4(c, alpha);
224
- }`,Ca=`#version 300 es
224
+ }`,Pa=`#version 300 es
225
225
  precision highp float;
226
226
  in vec3 position; // local: x/z in units of the seat radius, y in METRES
227
227
  in vec3 normal;
@@ -251,8 +251,8 @@ out vec3 vRing;
251
251
  out float vDim;
252
252
  out float vOccupant; // 1 = this vertex belongs to a person, not to the chair
253
253
  out vec3 vOccupantTint;
254
- ${Ot}
255
- ${ar}
254
+ ${Vt}
255
+ ${cr}
256
256
  void main() {
257
257
  vec4 anchor = modelViewMatrix * vec4(iOffset, 1.0);
258
258
  float viewDepth = -anchor.z;
@@ -335,7 +335,7 @@ void main() {
335
335
  vRing = iRing;
336
336
  vDim = (uFocusFloor < -0.5 || abs(iFloor - uFocusFloor) < 0.5) ? 0.0 : 1.0;
337
337
  gl_Position = projectionMatrix * mv;
338
- }`,Ra=`#version 300 es
338
+ }`,Aa=`#version 300 es
339
339
  precision highp float;
340
340
  in vec3 vColor;
341
341
  in vec3 vNormalWorld;
@@ -385,14 +385,14 @@ void main() {
385
385
  // which is what stops a block of them merging into one mass up close.
386
386
  base += vec3(0.26, 0.31, 0.38) * fres * 0.55;
387
387
  fragColor = vec4(base, 1.0);
388
- }`,Ia=`#version 300 es
388
+ }`,Ca=`#version 300 es
389
389
  precision highp float;
390
390
  in vec2 position;
391
391
  out vec2 vUv;
392
392
  void main() {
393
393
  vUv = position * 0.5 + 0.5;
394
394
  gl_Position = vec4(position, 0.999, 1.0);
395
- }`,Ta=`#version 300 es
395
+ }`,Ra=`#version 300 es
396
396
  precision highp float;
397
397
  in vec2 vUv;
398
398
  uniform vec3 uTop;
@@ -403,7 +403,7 @@ void main() {
403
403
  vec2 c = vUv - 0.5;
404
404
  float vig = 1.0 - dot(c, c) * 0.85; // soft vignette
405
405
  fragColor = vec4(col * vig, 1.0);
406
- }`,Fa=`#version 300 es
406
+ }`,Ia=`#version 300 es
407
407
  precision highp float;
408
408
  in vec2 position;
409
409
  in vec3 iOffset;
@@ -424,7 +424,7 @@ out float vPhysicalSeat;
424
424
  out float vDotWeight;
425
425
  out float vHidden;
426
426
  flat out vec3 vPick;
427
- ${Ot}
427
+ ${Vt}
428
428
  void main() {
429
429
  int id = gl_InstanceID + 1; // 0 reserved for no-hit
430
430
  vPick = vec3(float(id & 255), float((id >> 8) & 255), float((id >> 16) & 255)) / 255.0;
@@ -440,7 +440,7 @@ void main() {
440
440
  vPhysicalSeat = iPhysicalSeat;
441
441
  vHidden = (uFocusFloor > -0.5 && abs(iFloor - uFocusFloor) > 0.5) ? 1.0 : 0.0;
442
442
  gl_Position = projectionMatrix * mv;
443
- }`,Da=`#version 300 es
443
+ }`,Ta=`#version 300 es
444
444
  precision highp float;
445
445
  in vec2 vUv;
446
446
  in float vPhysicalSeat;
@@ -454,7 +454,7 @@ void main() {
454
454
  float d = mix(max(abs(vUv.x), abs(vUv.y)), length(vUv), vPhysicalSeat);
455
455
  if (d > 1.0) discard; // hit-mask matches chair/bay shape
456
456
  fragColor = vec4(vPick, 1.0);
457
- }`,ka=`#version 300 es
457
+ }`,Fa=`#version 300 es
458
458
  precision highp float;
459
459
  in vec3 position;
460
460
  in float part;
@@ -474,8 +474,8 @@ uniform float uBackBase;
474
474
  uniform float uFocusFloor;
475
475
  flat out vec3 vPick;
476
476
  out float vHidden;
477
- ${Ot}
478
- ${ar}
477
+ ${Vt}
478
+ ${cr}
479
479
  void main() {
480
480
  int id = int(iPickIndex + 0.5); // already global index + 1
481
481
  vPick = vec3(float(id & 255), float((id >> 8) & 255), float((id >> 16) & 255)) / 255.0;
@@ -513,7 +513,7 @@ out vec4 fragColor;
513
513
  void main() {
514
514
  if (vHidden > 0.5) discard;
515
515
  fragColor = vec4(vPick, 1.0);
516
- }`,_a=`#version 300 es
516
+ }`,Da=`#version 300 es
517
517
  precision highp float;
518
518
  in vec3 position;
519
519
  in float floorIndex;
@@ -524,14 +524,14 @@ out float vHidden;
524
524
  void main() {
525
525
  vHidden = (uFocusFloor > -0.5 && abs(floorIndex - uFocusFloor) > 0.5) ? 1.0 : 0.0;
526
526
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
527
- }`,La=`#version 300 es
527
+ }`,ka=`#version 300 es
528
528
  precision highp float;
529
529
  in float vHidden;
530
530
  out vec4 fragColor;
531
531
  void main() {
532
532
  if (vHidden > 0.5) discard;
533
533
  fragColor = vec4(0.0, 0.0, 0.0, 1.0);
534
- }`;function sr(t){return new Xe(t,{vertex:Fa,fragment:Da,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uSeatRadius:{value:Ie},uSeatScale:{value:1},uMinPixels:{value:qe},uPixelToWorld:{value:.002},uChairFull:{value:at},uChairNone:{value:Ze},uFocusFloor:{value:-1}}})}function cr(t){return new Xe(t,{vertex:ka,fragment:Ea,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uChairFull:{value:at},uChairNone:{value:Ze},uBackRake:{value:en},uBackBase:{value:Tt},uFocusFloor:{value:-1}}})}function lr(t){return new Xe(t,{vertex:_a,fragment:La,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uFocusFloor:{value:-1}}})}function ur(t){return new Xe(t,{vertex:Sa,fragment:wa,cullFace:!1,depthTest:!0,depthWrite:!0,uniforms:{uKeyDir:{value:new Float32Array([.38,.86,.34])},uFocusFloor:{value:-1},uStructureDetail:{value:0}}})}function mr(t){return new Xe(t,{vertex:Pa,fragment:Aa,transparent:!0,depthTest:!0,depthWrite:!1,cullFace:!1,uniforms:{uSeatRadius:{value:Ie},uSeatScale:{value:1},uMinPixels:{value:qe},uPixelToWorld:{value:.002},uSeatFade:{value:0},uSeatDetail:{value:0},uFocusFloor:{value:-1},uFadeColor:{value:new Float32Array([.32,.37,.43])},uChairFull:{value:at},uChairNone:{value:Ze}}})}function dr(t){return new Xe(t,{vertex:Ca,fragment:Ra,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uKeyDir:{value:new Float32Array([.38,.86,.34])},uFadeColor:{value:new Float32Array([.32,.37,.43])},uChairFull:{value:at},uChairNone:{value:Ze},uBackRake:{value:en},uBackBase:{value:Tt},uFocusFloor:{value:-1}}})}function hr(t,e,n){return new Xe(t,{vertex:Ia,fragment:Ta,depthTest:!1,depthWrite:!1,cullFace:!1,uniforms:{uTop:{value:new Float32Array(e)},uBottom:{value:new Float32Array(n)}}})}function pr(t,e,n,i,o,r){for(let a=n;a<n+i;a++){let u=r&&e[a]===0?null:o[e[a]]??o[0];t[a*3]=u?u[0]:r[a*3],t[a*3+1]=u?u[1]:r[a*3+1],t[a*3+2]=u?u[2]:r[a*3+2]}}var Ba=new Float32Array([-1,-1,1,-1,1,1,-1,-1,1,1,-1,1]),Oa=new Float32Array([-1,-1,3,-1,-1,3]);function br(t,e){let n=new fr,i=new fr,o=new Nt(t,{position:{size:2,data:Oa}}),r=hr(t,e.theme.background.top,e.theme.background.bottom),a=new zt(t,{geometry:o,program:r});a.frustumCulled=!1,a.setParent(i);let s=new Nt(t,{position:{size:3,data:e.solids.position},normal:{size:3,data:e.solids.normal},color:{size:3,data:e.solids.color},floorIndex:{size:1,data:e.solids.floor},materialIndex:{size:1,data:e.solids.material}}),u=ur(t),l=new zt(t,{geometry:s,program:u});l.frustumCulled=!1,l.setParent(n);let h=mr(t),d=new Float32Array(e.seats.count*3),f=Me.map(R=>e.theme.seatStates[R]);pr(d,e.seats.iState,0,e.seats.count,f,e.seats.iCategory);let c=new Nt(t,{position:{size:2,data:Ba},iOffset:{size:3,data:e.seats.iPosition,instanced:1},iColor:{size:3,data:d,instanced:1},iMaxRadius:{size:1,data:e.seats.iMaxRadius,instanced:1},iPhysicalSeat:{size:1,data:e.seats.iPhysicalSeat,instanced:1},iRing:{size:3,data:e.seats.iRing,instanced:1},iFloor:{size:1,data:e.seats.iFloor,instanced:1}}),m=new zt(t,{geometry:c,program:h});m.frustumCulled=!1,e.seats.count>0&&m.setParent(n);let p=c.attributes.iColor,b=Jn(),g=dr(t),y=wt,w=new Float32Array(y*3),E=new Float32Array(y*3),I=new Float32Array(y),A=new Float32Array(y),k=new Float32Array(y*3),B=new Float32Array(y),L=new Float32Array(y),U=new Float32Array(y),N=new Float32Array(y),z=new Nt(t,{position:{size:3,data:b.position},normal:{size:3,data:b.normal},part:{size:1,data:b.part},index:{data:b.index},iOffset:{size:3,data:w,instanced:1},iColor:{size:3,data:E,instanced:1},iRadius:{size:1,data:I,instanced:1},iYaw:{size:1,data:A,instanced:1},iRing:{size:3,data:k,instanced:1},iFloor:{size:1,data:B,instanced:1},iPhysicalSeat:{size:1,data:L,instanced:1},iSeed:{size:1,data:N,instanced:1},iPickIndex:{size:1,data:U,instanced:1}}),x=new zt(t,{geometry:z,program:g});x.frustumCulled=!1;let v=0,S=new Int32Array(0),O=()=>{let R=e.seats;for(let C=0;C<v;C++){let T=S[C];N[C]=to(R.iState[T],T);let F=R.iCategory&&R.iState[T]===0?null:f[R.iState[T]]??f[0];if(F)E[C*3]=F[0],E[C*3+1]=F[1],E[C*3+2]=F[2];else{let _=Vn([R.iCategory[T*3],R.iCategory[T*3+1],R.iCategory[T*3+2]]);E[C*3]=_[0],E[C*3+1]=_[1],E[C*3+2]=_[2]}}z.attributes.iColor.needsUpdate=!0,z.attributes.iSeed.needsUpdate=!0},M={main:n,background:i,seatProgram:h,solidProgram:u,chairProgram:g,seatGeometry:c,chairGeometry:z,solidGeometry:s,drawCalls:3,setNearSeats(R,C){let T=Math.min(C,y);if(S=R,v=T,T===0){x.parent&&x.setParent(null),z.instancedCount=0,M.drawCalls=3;return}let P=e.seats;for(let F=0;F<T;F++){let _=R[F];w[F*3]=P.iPosition[_*3],w[F*3+1]=P.iPosition[_*3+1],w[F*3+2]=P.iPosition[_*3+2],I[F]=P.iChairWidth[_],A[F]=P.iYaw[_],k[F*3]=P.iRing[_*3],k[F*3+1]=P.iRing[_*3+1],k[F*3+2]=P.iRing[_*3+2],B[F]=P.iFloor[_],L[F]=P.iPhysicalSeat[_],U[F]=_+1}O(),z.attributes.iOffset.needsUpdate=!0,z.attributes.iRadius.needsUpdate=!0,z.attributes.iYaw.needsUpdate=!0,z.attributes.iRing.needsUpdate=!0,z.attributes.iFloor.needsUpdate=!0,z.attributes.iPhysicalSeat.needsUpdate=!0,z.attributes.iSeed.needsUpdate=!0,z.attributes.iPickIndex.needsUpdate=!0,z.instancedCount=T,x.parent||x.setParent(n),M.drawCalls=4},nearSeatCount(){return v},uploadSeatStateRuns(R){if(!R.length)return;v&&O();for(let T of R)pr(d,e.seats.iState,T.start,T.length,f,e.seats.iCategory);let C=p.buffer;if(!C){p.needsUpdate=!0;return}t.bindBuffer(t.ARRAY_BUFFER,C);for(let T of R){let P=d.subarray(T.start*3,(T.start+T.length)*3);t.bufferSubData(t.ARRAY_BUFFER,T.start*3*Float32Array.BYTES_PER_ELEMENT,P)}},dispose(){o.remove(),r.remove(),s.remove(),u.remove(),c.remove(),h.remove(),z.remove(),g.remove()}};return M}import{Mesh as hn,RenderTarget as za,Transform as fn}from"ogl";function Na(t,e,n){let i=t+(e<<8)+(n<<16);return i===0?-1:i-1}function yr(t,e,n,i,o,r){let a=-1,s=1/0;for(let u=0;u<n;u++)for(let l=0;l<e;l++){let h=(u*e+l)*4,d=Na(t[h],t[h+1],t[h+2]);if(d<0||d>=r)continue;let f=l-i,c=u-o,m=f*f+c*c;m<s&&(s=m,a=d)}return a}function xr(t,e,n,i,o,r){let a=t-n.left,s=e-n.top,u=Math.round(a*i),l=Math.round((n.height-s)*i);return{x:Math.max(0,Math.min(o-1,u)),y:Math.max(0,Math.min(r-1,l))}}var Va=["uSeatRadius","uSeatScale","uMinPixels","uPixelToWorld"],Vt=class{constructor(e,n,i,o,r){this.seatScene=new fn;this.chairScene=new fn;this.solidScene=new fn;this.target=null;this.restoreClear=[0,0,0];this.renderer=e,this.gl=e.gl,this.maxIndex=r,this.seatProg=sr(this.gl),this.chairProg=cr(this.gl),this.depthProg=lr(this.gl);let a=new hn(this.gl,{geometry:n,program:this.seatProg});a.frustumCulled=!1,a.setParent(this.seatScene);let s=new hn(this.gl,{geometry:i,program:this.chairProg});s.frustumCulled=!1,s.setParent(this.chairScene);let u=new hn(this.gl,{geometry:o,program:this.depthProg});u.frustumCulled=!1,u.setParent(this.solidScene)}setRestoreClear(e){this.restoreClear=[e[0],e[1],e[2]]}syncFromSeatProgram(e){for(let i of Va)this.seatProg.uniforms[i].value=e.uniforms[i].value;let n=e.uniforms.uFocusFloor.value;this.seatProg.uniforms.uFocusFloor.value=n,this.chairProg.uniforms.uFocusFloor.value=n,this.depthProg.uniforms.uFocusFloor.value=n}ensureTarget(){let e=this.gl.drawingBufferWidth,n=this.gl.drawingBufferHeight;return this.target&&(this.target.width!==e||this.target.height!==n)&&this.destroyTarget(),this.target||(this.target=new za(this.gl,{width:e,height:n,depth:!0})),this.target}destroyTarget(){if(!this.target)return;let e=this.gl;this.target.buffer&&e.deleteFramebuffer(this.target.buffer);for(let n of this.target.textures??[])n.texture&&e.deleteTexture(n.texture);this.target.depthBuffer&&e.deleteRenderbuffer(this.target.depthBuffer),this.target=null}pick(e,n,i,o){let r=this.gl,a=this.ensureTarget(),s=r.drawingBufferWidth,u=r.drawingBufferHeight,l=Math.max(0,n-o),h=Math.max(0,i-o),d=Math.max(1,Math.min(s,n+o+1)-l),f=Math.max(1,Math.min(u,i+o+1)-h);r.enable(r.SCISSOR_TEST),r.scissor(l,h,d,f);let[c,m,p]=this.restoreClear;r.clearColor(0,0,0,1),this.renderer.render({scene:this.solidScene,camera:e,target:a,clear:!0}),this.renderer.render({scene:this.seatScene,camera:e,target:a,clear:!1}),this.renderer.render({scene:this.chairScene,camera:e,target:a,clear:!1}),r.clearColor(c,m,p,1),r.disable(r.SCISSOR_TEST);let b=new Uint8Array(d*f*4);return this.renderer.bindFramebuffer(a),r.readPixels(l,h,d,f,r.RGBA,r.UNSIGNED_BYTE,b),this.renderer.bindFramebuffer(),yr(b,d,f,n-l,i-h,this.maxIndex)}dispose(){this.destroyTarget(),this.seatProg.remove(),this.chairProg.remove(),this.depthProg.remove()}};function gr(t,e){let n=[];for(let i of e)t.has(i.seatId)?t.set(i.seatId,it(i.state)):n.push(i);return n}function vr(t,e,n){let i=new Set;for(let a of e)(t.has(a)||n(a)!==void 0)&&i.add(a);let o=new Map(t),r=[];for(let[a,s]of t)i.has(a)||(r.push({seatId:a,state:Me[s]??"available"}),o.delete(a));for(let a of i){if(o.has(a))continue;let s=n(a);s!==void 0&&(o.set(a,s),r.push({seatId:a,state:"selected"}))}return{updates:r,next:o}}import{Quat as pt,Vec3 as Ua}from"ogl";function Ga(t,e){return[t[0]-e[0],t[1]-e[1],t[2]-e[2]]}function Mr(t,e){return[t[0]+e[0],t[1]+e[1],t[2]+e[2]]}function Ha(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Sr(t){let e=Math.hypot(t[0],t[1],t[2]);return e>1e-6?[t[0]/e,t[1]/e,t[2]/e]:[0,0,0]}function pn(t){let e=Math.max(0,Math.min(1,t));return e*e*e*(e*(e*6-15)+10)}function bn(t,e){return Math.max(0,Math.min(1,t+e))}function wr(t,e){let n=t.length;if(n===0)return[0,0,0];if(n===1)return[...t[0]];let i=Math.max(0,Math.min(1,e)),o=n-1,r=Math.floor(i*o);r>=o&&(r=o-1);let a=i*o-r,s=t[Math.max(0,r-1)],u=t[r],l=t[r+1],h=t[Math.min(n-1,r+2)],d=a*a,f=d*a,c=[0,0,0];for(let m=0;m<3;m++)c[m]=.5*(2*u[m]+(-s[m]+l[m])*a+(2*s[m]-5*u[m]+4*l[m]-h[m])*d+(-s[m]+3*u[m]-3*l[m]+h[m])*f);return c}function yn(t,e,n,i,o){let r=Sr(Ga(e,n));r[0]===0&&r[1]===0&&r[2]===0&&(r=[0,0,1]);let a=Mr(Mr(e,Ha(r,2.5)),[0,1.5,0]),s=[e[0]-i[0],0,e[2]-i[2]],u=Sr(s);u[0]===0&&u[2]===0&&(u=[r[0],0,r[2]]);let l=Math.max(1,o),h=[i[0]+u[0]*l*1.3,i[1]+l*.75,i[2]+u[2]*l*1.3];return{waypoints:[t,h,a],finalPos:a}}function xn(t,e,n=35,i=28){let o=pn(e),r=wr(t,o),a=pn(Math.max(0,Math.min(1,(e-.66)/.34)));return{pos:r,fov:n+(i-n)*a,eased:o}}function Cr(t,e,n){let i=t.position.clone(),o=new pt().copy(t.quaternion);t.position.set(e[0],e[1],e[2]),t.lookAt(new Ua(n[0],n[1],n[2]));let r=new pt().copy(t.quaternion);return t.position.copy(i),t.quaternion.copy(o),r}var Gt=class{constructor(e){this.active=!1;this.waypoints=[];this.startQuat=new pt;this.endQuat=new pt;this.outQuat=new pt;this.startTime=0;this.duration=2500;this.endFov=28;this.resolveFn=null;this.camera=e}start(e,n,i,o=2500,r=28){return this.settle(),this.waypoints=e,this.startQuat.copy(n),this.endQuat.copy(i),this.duration=o,this.endFov=r,this.startTime=performance.now(),this.active=!0,new Promise(a=>{this.resolveFn=a})}update(e){if(!this.active)return!1;let n=Math.min(1,(e-this.startTime)/this.duration),{pos:i,fov:o,eased:r}=xn(this.waypoints,n,35,this.endFov);return this.camera.position.set(i[0],i[1],i[2]),this.outQuat.copy(this.startQuat).slerp(this.endQuat,bn(r,.15)),this.camera.quaternion.copy(this.outQuat),this.camera.fov=o,this.camera.updateProjectionMatrix(),n>=1?(this.settle(),!1):!0}cancel(){this.settle()}settle(){this.active=!1;let e=this.resolveFn;this.resolveFn=null,e&&e()}};var Ya=1.02,Xa=1.5;function Rr(t,e,n=0,i){let o=Number.isFinite(i)?n+i:t[1]+Ya;return{eye:[t[0],o,t[2]],focal:[e.x*D,n+Xa,e.y*D]}}import{Geometry as Wa,Mesh as ja,Program as qa,Texture as Za}from"ogl";var Ka=64,$a=32,Qa=500;function Ja(t=Ka,e=$a,n=Qa){let i=t+1,o=e+1,r=i*o,a=new Float32Array(r*3),s=new Float32Array(r*2);for(let h=0;h<o;h++){let d=h/e,f=d*Math.PI,c=Math.sin(f),m=Math.cos(f);for(let p=0;p<i;p++){let b=p/t,g=(b-.5)*Math.PI*2,y=h*i+p;a[y*3]=n*c*Math.sin(g),a[y*3+1]=n*m,a[y*3+2]=-n*c*Math.cos(g),s[y*2]=b,s[y*2+1]=d}}let u=new Uint16Array(t*e*6),l=0;for(let h=0;h<e;h++)for(let d=0;d<t;d++){let f=h*i+d,c=f+i;u[l++]=f,u[l++]=c,u[l++]=f+1,u[l++]=f+1,u[l++]=c,u[l++]=c+1}return{position:a,uv:s,index:u}}function Ir(t,e){let n=t*Math.PI/180,i=e*Math.PI/180,o=Math.cos(i);return[o*Math.sin(n),Math.sin(i),-o*Math.cos(n)]}var es=`#version 300 es
534
+ }`;function lr(t){return new je(t,{vertex:Ia,fragment:Ta,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uSeatRadius:{value:Re},uSeatScale:{value:1},uMinPixels:{value:Ke},uPixelToWorld:{value:.002},uChairFull:{value:lt},uChairNone:{value:Qe},uFocusFloor:{value:-1}}})}function ur(t){return new je(t,{vertex:Fa,fragment:Ea,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uChairFull:{value:lt},uChairNone:{value:Qe},uBackRake:{value:on},uBackBase:{value:Lt},uFocusFloor:{value:-1}}})}function mr(t){return new je(t,{vertex:Da,fragment:ka,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uFocusFloor:{value:-1}}})}function dr(t){return new je(t,{vertex:va,fragment:Ma,cullFace:!1,depthTest:!0,depthWrite:!0,uniforms:{uKeyDir:{value:new Float32Array([.38,.86,.34])},uFocusFloor:{value:-1},uStructureDetail:{value:0}}})}function hr(t){return new je(t,{vertex:Sa,fragment:wa,transparent:!0,depthTest:!0,depthWrite:!1,cullFace:!1,uniforms:{uSeatRadius:{value:Re},uSeatScale:{value:1},uMinPixels:{value:Ke},uPixelToWorld:{value:.002},uSeatFade:{value:0},uSeatDetail:{value:0},uFocusFloor:{value:-1},uFadeColor:{value:new Float32Array([.32,.37,.43])},uChairFull:{value:lt},uChairNone:{value:Qe}}})}function pr(t){return new je(t,{vertex:Pa,fragment:Aa,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uKeyDir:{value:new Float32Array([.38,.86,.34])},uFadeColor:{value:new Float32Array([.32,.37,.43])},uChairFull:{value:lt},uChairNone:{value:Qe},uBackRake:{value:on},uBackBase:{value:Lt},uFocusFloor:{value:-1}}})}function fr(t,e,n){return new je(t,{vertex:Ca,fragment:Ra,depthTest:!1,depthWrite:!1,cullFace:!1,uniforms:{uTop:{value:new Float32Array(e)},uBottom:{value:new Float32Array(n)}}})}function yr(t,e,n,i,o,r){for(let a=n;a<n+i;a++){let l=r&&e[a]===0?null:o[e[a]]??o[0];t[a*3]=l?l[0]:r[a*3],t[a*3+1]=l?l[1]:r[a*3+1],t[a*3+2]=l?l[2]:r[a*3+2]}}var La=new Float32Array([-1,-1,1,-1,1,1,-1,-1,1,1,-1,1]),_a=new Float32Array([-1,-1,3,-1,-1,3]);function xr(t,e){let n=new br,i=new br,o=new Nt(t,{position:{size:2,data:_a}}),r=fr(t,e.theme.background.top,e.theme.background.bottom),a=new zt(t,{geometry:o,program:r});a.frustumCulled=!1,a.setParent(i);let s=new Nt(t,{position:{size:3,data:e.solids.position},normal:{size:3,data:e.solids.normal},color:{size:3,data:e.solids.color},floorIndex:{size:1,data:e.solids.floor},materialIndex:{size:1,data:e.solids.material}}),l=dr(t),c=new zt(t,{geometry:s,program:l});c.frustumCulled=!1,c.setParent(n);let h=hr(t),m=new Float32Array(e.seats.count*3),d=be.map(I=>e.theme.seatStates[I]);yr(m,e.seats.iState,0,e.seats.count,d,e.seats.iCategory);let p=new Nt(t,{position:{size:2,data:La},iOffset:{size:3,data:e.seats.iPosition,instanced:1},iColor:{size:3,data:m,instanced:1},iMaxRadius:{size:1,data:e.seats.iMaxRadius,instanced:1},iPhysicalSeat:{size:1,data:e.seats.iPhysicalSeat,instanced:1},iRing:{size:3,data:e.seats.iRing,instanced:1},iFloor:{size:1,data:e.seats.iFloor,instanced:1}}),f=new zt(t,{geometry:p,program:h});f.frustumCulled=!1,e.seats.count>0&&f.setParent(n);let u=p.attributes.iColor,b=oo(),y=pr(t),x=It,v=new Float32Array(x*3),k=new Float32Array(x*3),P=new Float32Array(x),M=new Float32Array(x),F=new Float32Array(x*3),O=new Float32Array(x),L=new Float32Array(x),H=new Float32Array(x),_=new Float32Array(x),g=new Nt(t,{position:{size:3,data:b.position},normal:{size:3,data:b.normal},part:{size:1,data:b.part},index:{data:b.index},iOffset:{size:3,data:v,instanced:1},iColor:{size:3,data:k,instanced:1},iRadius:{size:1,data:P,instanced:1},iYaw:{size:1,data:M,instanced:1},iRing:{size:3,data:F,instanced:1},iFloor:{size:1,data:O,instanced:1},iPhysicalSeat:{size:1,data:L,instanced:1},iSeed:{size:1,data:_,instanced:1},iPickIndex:{size:1,data:H,instanced:1}}),w=new zt(t,{geometry:g,program:y});w.frustumCulled=!1;let E=0,C=new Int32Array(0),N=()=>{let I=e.seats;for(let T=0;T<E;T++){let B=C[T];_[T]=io(I.iState[B],B);let D=I.iCategory&&I.iState[B]===0?null:d[I.iState[B]]??d[0];if(D)k[T*3]=D[0],k[T*3+1]=D[1],k[T*3+2]=D[2];else{let V=Xn([I.iCategory[B*3],I.iCategory[B*3+1],I.iCategory[B*3+2]]);k[T*3]=V[0],k[T*3+1]=V[1],k[T*3+2]=V[2]}}g.attributes.iColor.needsUpdate=!0,g.attributes.iSeed.needsUpdate=!0},S={main:n,background:i,seatProgram:h,solidProgram:l,chairProgram:y,seatGeometry:p,chairGeometry:g,solidGeometry:s,drawCalls:3,setNearSeats(I,T){let B=Math.min(T,x);if(C=I,E=B,B===0){w.parent&&w.setParent(null),g.instancedCount=0,S.drawCalls=3;return}let A=e.seats;for(let D=0;D<B;D++){let V=I[D];v[D*3]=A.iPosition[V*3],v[D*3+1]=A.iPosition[V*3+1],v[D*3+2]=A.iPosition[V*3+2],P[D]=A.iChairWidth[V],M[D]=A.iYaw[V],F[D*3]=A.iRing[V*3],F[D*3+1]=A.iRing[V*3+1],F[D*3+2]=A.iRing[V*3+2],O[D]=A.iFloor[V],L[D]=A.iPhysicalSeat[V],H[D]=V+1}N(),g.attributes.iOffset.needsUpdate=!0,g.attributes.iRadius.needsUpdate=!0,g.attributes.iYaw.needsUpdate=!0,g.attributes.iRing.needsUpdate=!0,g.attributes.iFloor.needsUpdate=!0,g.attributes.iPhysicalSeat.needsUpdate=!0,g.attributes.iSeed.needsUpdate=!0,g.attributes.iPickIndex.needsUpdate=!0,g.instancedCount=B,w.parent||w.setParent(n),S.drawCalls=4},nearSeatCount(){return E},uploadSeatStateRuns(I){if(!I.length)return;E&&N();for(let B of I)yr(m,e.seats.iState,B.start,B.length,d,e.seats.iCategory);let T=u.buffer;if(!T){u.needsUpdate=!0;return}t.bindBuffer(t.ARRAY_BUFFER,T);for(let B of I){let A=m.subarray(B.start*3,(B.start+B.length)*3);t.bufferSubData(t.ARRAY_BUFFER,B.start*3*Float32Array.BYTES_PER_ELEMENT,A)}},dispose(){o.remove(),r.remove(),s.remove(),l.remove(),p.remove(),h.remove(),g.remove(),y.remove()}};return S}import{Mesh as yn,RenderTarget as Ba,Transform as xn}from"ogl";function Oa(t,e,n){let i=t+(e<<8)+(n<<16);return i===0?-1:i-1}function gr(t,e,n,i,o,r){let a=-1,s=1/0;for(let l=0;l<n;l++)for(let c=0;c<e;c++){let h=(l*e+c)*4,m=Oa(t[h],t[h+1],t[h+2]);if(m<0||m>=r)continue;let d=c-i,p=l-o,f=d*d+p*p;f<s&&(s=f,a=m)}return a}function vr(t,e,n,i,o,r){let a=t-n.left,s=e-n.top,l=Math.round(a*i),c=Math.round((n.height-s)*i);return{x:Math.max(0,Math.min(o-1,l)),y:Math.max(0,Math.min(r-1,c))}}var Va=["uSeatRadius","uSeatScale","uMinPixels","uPixelToWorld"],Gt=class{constructor(e,n,i,o,r){this.seatScene=new xn;this.chairScene=new xn;this.solidScene=new xn;this.target=null;this.restoreClear=[0,0,0];this.renderer=e,this.gl=e.gl,this.maxIndex=r,this.seatProg=lr(this.gl),this.chairProg=ur(this.gl),this.depthProg=mr(this.gl);let a=new yn(this.gl,{geometry:n,program:this.seatProg});a.frustumCulled=!1,a.setParent(this.seatScene);let s=new yn(this.gl,{geometry:i,program:this.chairProg});s.frustumCulled=!1,s.setParent(this.chairScene);let l=new yn(this.gl,{geometry:o,program:this.depthProg});l.frustumCulled=!1,l.setParent(this.solidScene)}setRestoreClear(e){this.restoreClear=[e[0],e[1],e[2]]}syncFromSeatProgram(e){for(let i of Va)this.seatProg.uniforms[i].value=e.uniforms[i].value;let n=e.uniforms.uFocusFloor.value;this.seatProg.uniforms.uFocusFloor.value=n,this.chairProg.uniforms.uFocusFloor.value=n,this.depthProg.uniforms.uFocusFloor.value=n}ensureTarget(){let e=this.gl.drawingBufferWidth,n=this.gl.drawingBufferHeight;return this.target&&(this.target.width!==e||this.target.height!==n)&&this.destroyTarget(),this.target||(this.target=new Ba(this.gl,{width:e,height:n,depth:!0})),this.target}destroyTarget(){if(!this.target)return;let e=this.gl;this.target.buffer&&e.deleteFramebuffer(this.target.buffer);for(let n of this.target.textures??[])n.texture&&e.deleteTexture(n.texture);this.target.depthBuffer&&e.deleteRenderbuffer(this.target.depthBuffer),this.target=null}pick(e,n,i,o){let r=this.gl,a=this.ensureTarget(),s=r.drawingBufferWidth,l=r.drawingBufferHeight,c=Math.max(0,n-o),h=Math.max(0,i-o),m=Math.max(1,Math.min(s,n+o+1)-c),d=Math.max(1,Math.min(l,i+o+1)-h);r.enable(r.SCISSOR_TEST),r.scissor(c,h,m,d);let[p,f,u]=this.restoreClear;r.clearColor(0,0,0,1),this.renderer.render({scene:this.solidScene,camera:e,target:a,clear:!0}),this.renderer.render({scene:this.seatScene,camera:e,target:a,clear:!1}),this.renderer.render({scene:this.chairScene,camera:e,target:a,clear:!1}),r.clearColor(p,f,u,1),r.disable(r.SCISSOR_TEST);let b=new Uint8Array(m*d*4);return this.renderer.bindFramebuffer(a),r.readPixels(c,h,m,d,r.RGBA,r.UNSIGNED_BYTE,b),this.renderer.bindFramebuffer(),gr(b,m,d,n-c,i-h,this.maxIndex)}dispose(){this.destroyTarget(),this.seatProg.remove(),this.chairProg.remove(),this.depthProg.remove()}};function Mr(t,e){let n=[];for(let i of e)t.has(i.seatId)?t.set(i.seatId,ct(i.state)):n.push(i);return n}function Sr(t,e,n){let i=new Set;for(let a of e)(t.has(a)||n(a)!==void 0)&&i.add(a);let o=new Map(t),r=[];for(let[a,s]of t)i.has(a)||(r.push({seatId:a,state:be[s]??"available"}),o.delete(a));for(let a of i){if(o.has(a))continue;let s=n(a);s!==void 0&&(o.set(a,s),r.push({seatId:a,state:"selected"}))}return{updates:r,next:o}}import{Quat as xt,Vec3 as Ga}from"ogl";function Na(t,e){return[t[0]-e[0],t[1]-e[1],t[2]-e[2]]}function wr(t,e){return[t[0]+e[0],t[1]+e[1],t[2]+e[2]]}function za(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Pr(t){let e=Math.hypot(t[0],t[1],t[2]);return e>1e-6?[t[0]/e,t[1]/e,t[2]/e]:[0,0,0]}function gn(t){let e=Math.max(0,Math.min(1,t));return e*e*e*(e*(e*6-15)+10)}function vn(t,e){return Math.max(0,Math.min(1,t+e))}function Ar(t,e){let n=t.length;if(n===0)return[0,0,0];if(n===1)return[...t[0]];let i=Math.max(0,Math.min(1,e)),o=n-1,r=Math.floor(i*o);r>=o&&(r=o-1);let a=i*o-r,s=t[Math.max(0,r-1)],l=t[r],c=t[r+1],h=t[Math.min(n-1,r+2)],m=a*a,d=m*a,p=[0,0,0];for(let f=0;f<3;f++)p[f]=.5*(2*l[f]+(-s[f]+c[f])*a+(2*s[f]-5*l[f]+4*c[f]-h[f])*m+(-s[f]+3*l[f]-3*c[f]+h[f])*d);return p}function Mn(t,e,n,i,o){let r=Pr(Na(e,n));r[0]===0&&r[1]===0&&r[2]===0&&(r=[0,0,1]);let a=wr(wr(e,za(r,2.5)),[0,1.5,0]),s=[e[0]-i[0],0,e[2]-i[2]],l=Pr(s);l[0]===0&&l[2]===0&&(l=[r[0],0,r[2]]);let c=Math.max(1,o),h=[i[0]+l[0]*c*1.3,i[1]+c*.75,i[2]+l[2]*c*1.3];return{waypoints:[t,h,a],finalPos:a}}function Sn(t,e,n=35,i=28){let o=gn(e),r=Ar(t,o),a=gn(Math.max(0,Math.min(1,(e-.66)/.34)));return{pos:r,fov:n+(i-n)*a,eased:o}}function Ir(t,e,n){let i=t.position.clone(),o=new xt().copy(t.quaternion);t.position.set(e[0],e[1],e[2]),t.lookAt(new Ga(n[0],n[1],n[2]));let r=new xt().copy(t.quaternion);return t.position.copy(i),t.quaternion.copy(o),r}var Ht=class{constructor(e){this.active=!1;this.waypoints=[];this.startQuat=new xt;this.endQuat=new xt;this.outQuat=new xt;this.startTime=0;this.duration=2500;this.endFov=28;this.resolveFn=null;this.camera=e}start(e,n,i,o=2500,r=28){return this.settle(),this.waypoints=e,this.startQuat.copy(n),this.endQuat.copy(i),this.duration=o,this.endFov=r,this.startTime=performance.now(),this.active=!0,new Promise(a=>{this.resolveFn=a})}update(e){if(!this.active)return!1;let n=Math.min(1,(e-this.startTime)/this.duration),{pos:i,fov:o,eased:r}=Sn(this.waypoints,n,35,this.endFov);return this.camera.position.set(i[0],i[1],i[2]),this.outQuat.copy(this.startQuat).slerp(this.endQuat,vn(r,.15)),this.camera.quaternion.copy(this.outQuat),this.camera.fov=o,this.camera.updateProjectionMatrix(),n>=1?(this.settle(),!1):!0}cancel(){this.settle()}settle(){this.active=!1;let e=this.resolveFn;this.resolveFn=null,e&&e()}};var Ha=1.02,Ua=1.5;function Tr(t,e,n=0,i){let o=Number.isFinite(i)?n+i:t[1]+Ha;return{eye:[t[0],o,t[2]],focal:[e.x*R,n+Ua,e.y*R]}}import{Geometry as Xa,Mesh as Ya,Program as Wa,Texture as ja}from"ogl";var qa=64,Za=32,Ka=500;function Qa(t=qa,e=Za,n=Ka){let i=t+1,o=e+1,r=i*o,a=new Float32Array(r*3),s=new Float32Array(r*2);for(let h=0;h<o;h++){let m=h/e,d=m*Math.PI,p=Math.sin(d),f=Math.cos(d);for(let u=0;u<i;u++){let b=u/t,y=(b-.5)*Math.PI*2,x=h*i+u;a[x*3]=n*p*Math.sin(y),a[x*3+1]=n*f,a[x*3+2]=-n*p*Math.cos(y),s[x*2]=b,s[x*2+1]=m}}let l=new Uint16Array(t*e*6),c=0;for(let h=0;h<e;h++)for(let m=0;m<t;m++){let d=h*i+m,p=d+i;l[c++]=d,l[c++]=p,l[c++]=d+1,l[c++]=d+1,l[c++]=p,l[c++]=p+1}return{position:a,uv:s,index:l}}function Fr(t,e){let n=t*Math.PI/180,i=e*Math.PI/180,o=Math.cos(i);return[o*Math.sin(n),Math.sin(i),-o*Math.cos(n)]}var $a=`#version 300 es
535
535
  precision highp float;
536
536
  in vec3 position;
537
537
  in vec2 uv;
@@ -541,7 +541,7 @@ out vec2 vUv;
541
541
  void main() {
542
542
  vUv = uv;
543
543
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
544
- }`,ts=`#version 300 es
544
+ }`,Ja=`#version 300 es
545
545
  precision highp float;
546
546
  in vec2 vUv;
547
547
  uniform sampler2D uPano;
@@ -550,4 +550,4 @@ out vec4 fragColor;
550
550
  void main() {
551
551
  vec3 rgb = texture(uPano, vUv).rgb;
552
552
  fragColor = vec4(rgb, uOpacity);
553
- }`;function Tr(t,e){let{position:n,uv:i,index:o}=Ja(),r=new Wa(t,{position:{size:3,data:n},uv:{size:2,data:i},index:{data:o}}),a=new Za(t,{image:e,wrapS:t.CLAMP_TO_EDGE,wrapT:t.CLAMP_TO_EDGE,generateMipmaps:!0,flipY:!1}),s=new qa(t,{vertex:es,fragment:ts,uniforms:{uPano:{value:a},uOpacity:{value:0}},transparent:!0,depthTest:!1,depthWrite:!1}),u=new ja(t,{geometry:r,program:s});return{mesh:u,setOpacity(l){s.uniforms.uOpacity.value=Math.max(0,Math.min(1,l))},setImage(l){a.image=l,a.needsUpdate=!0},dispose(){u.setParent(null),r.remove(),a.texture&&t.deleteTexture(a.texture),s.remove()}}}var Fr=.15;async function Dr(t,e,n,i={}){let o=i.fadeMs??400,r=e?.initialBearingDeg??0,a=Math.max(-Re,Math.min(Re,e?.initialPitchDeg??0)),s=Bn,u=!1,l=new AbortController,h=()=>l.abort();i.signal?.addEventListener("abort",h,{once:!0});let d=()=>{},f=[n.camera.position.x,n.camera.position.y,n.camera.position.z];if(!e&&n.cameraOriginWorld&&n.camera.position.set(n.cameraOriginWorld[0],n.cameraOriginWorld[1],n.cameraOriginWorld[2]),!e&&n.focalWorld){let P=n.camera.position,F=n.focalWorld[0]-P.x,_=n.focalWorld[1]-P.y,Y=n.focalWorld[2]-P.z,W=Math.hypot(F,Y);W>.001&&(r=Math.atan2(F,-Y)*180/Math.PI,a=Math.max(-Re,Math.min(Re,Math.atan2(_,W)*180/Math.PI)))}let c=null;if(e){let P=n.gl.getParameter(n.gl.MAX_TEXTURE_SIZE),F=En(e,kn(P)),_;try{let Y=e.resolveUrl?await e.resolveUrl(F.initialUrl):F.initialUrl;if(!Y)throw new Error("panorama_asset_unavailable");_=await Wt(Y,l.signal)}catch{return i.signal?.removeEventListener("abort",h),null}try{c=Tr(n.gl,_)}catch{return l.abort(),i.signal?.removeEventListener("abort",h),null}c.mesh.renderOrder=999,c.mesh.setParent(n.scene),F.upgradeUrl&&(d=_n(()=>{(e.resolveUrl?e.resolveUrl(F.upgradeUrl):Promise.resolve(F.upgradeUrl)).then(W=>!W||l.signal.aborted?null:Wt(W,l.signal)).then(W=>{W&&(u||l.signal.aborted||(c?.setImage(W),n.requestRender()))}).catch(()=>{})}))}let m=n.camera.fov;n.camera.perspective({fov:s,aspect:n.camera.aspect});let p=n.camera.quaternion.slice(),b=()=>{let P=n.camera.position;c?.mesh.position.set(P.x,P.y,P.z);let[F,_,Y]=Ir(r,a);n.camera.lookAt([P.x+F,P.y+_,P.z+Y]),n.requestRender()};b();let g=document.createElement("div"),y=document.activeElement instanceof HTMLElement?document.activeElement:null;g.setAttribute("role","dialog"),g.setAttribute("aria-modal","true"),g.setAttribute("aria-label",i.seatLabel?`View from ${i.seatLabel}`:"View from seat"),g.tabIndex=-1,Object.assign(g.style,{position:"absolute",inset:"0",zIndex:"10",cursor:"grab",touchAction:"none"});let w=document.createElement("button");if(w.type="button",w.setAttribute("aria-label","Close"),w.textContent="\u2715",Object.assign(w.style,{position:"absolute",top:"12px",right:"12px",zIndex:"2",width:"44px",height:"44px",borderRadius:"999px",cursor:"pointer",border:"1px solid rgba(255,255,255,0.25)",background:"rgba(8,12,18,0.6)",color:"#e6edf3",fontSize:"15px",lineHeight:"1"}),g.appendChild(w),i.disclosure){let P=document.createElement("div");P.textContent=`${i.disclosurePrefix??"360\xB0 panorama"} \xB7 ${i.disclosure}`,Object.assign(P.style,{position:"absolute",top:"12px",left:"12px",zIndex:"2",maxWidth:"calc(100% - 88px)",padding:"8px 11px",borderRadius:"999px",overflow:"hidden",color:"#dce6f8",background:"rgba(8,12,18,0.68)",font:"600 11px/1.2 ui-sans-serif, system-ui, sans-serif",textOverflow:"ellipsis",whiteSpace:"nowrap",pointerEvents:"none",backdropFilter:"blur(6px)"}),g.appendChild(P)}let E=document.createElement("div");E.textContent="Drag to look \xB7 pinch or scroll to zoom \xB7 Esc to close",Object.assign(E.style,{position:"absolute",bottom:"12px",left:"0",right:"0",textAlign:"center",color:"rgba(230,237,243,0.7)",font:"12px ui-sans-serif, system-ui, sans-serif",pointerEvents:"none"}),g.appendChild(E),t.appendChild(g),w.focus({preventScroll:!0});let I=!1,A=0,k=0,B=0,L=new Map,U=()=>{let[P,F]=[...L.values()];return P&&F?Math.hypot(P.x-F.x,P.y-F.y):0},N=P=>{let F=On(P);F!==s&&(s=F,n.camera.perspective({fov:s,aspect:n.camera.aspect}),b())},z=P=>{P.target!==w&&(L.set(P.pointerId,{x:P.clientX,y:P.clientY}),I=L.size===1,A=P.clientX,k=P.clientY,L.size===2&&(B=U()),g.setPointerCapture?.(P.pointerId),g.style.cursor="grabbing")},x=P=>{if(L.has(P.pointerId)){if(L.set(P.pointerId,{x:P.clientX,y:P.clientY}),L.size>=2){let F=U();B>0&&F>0&&N(s*(B/F)),B=F,I=!1;return}I&&(r+=(P.clientX-A)*Fr,a=Math.max(-Re,Math.min(Re,a+(P.clientY-k)*Fr)),A=P.clientX,k=P.clientY,b())}},v=P=>{L.delete(P.pointerId),B=L.size===2?U():0;let F=L.values().next().value;I=L.size===1,F?(A=F.x,k=F.y):g.style.cursor="grab";try{g.releasePointerCapture?.(P.pointerId)}catch{}},S=P=>{P.preventDefault(),N(s+P.deltaY*.04)};g.addEventListener("pointerdown",z),g.addEventListener("pointermove",x),g.addEventListener("pointerup",v),g.addEventListener("pointercancel",v),g.addEventListener("wheel",S,{passive:!1});let O=P=>{if(!u){if(P.key==="Tab"){P.preventDefault(),w.focus({preventScroll:!0});return}if(P.key==="Escape"){P.stopPropagation(),T.close();return}if(P.key==="ArrowLeft"||P.key==="ArrowRight")r+=P.key==="ArrowLeft"?-4:4;else if(P.key==="ArrowUp"||P.key==="ArrowDown")a=Math.max(-Re,Math.min(Re,a+(P.key==="ArrowUp"?4:-4)));else if(P.key==="+"||P.key==="="){N(s-5),P.preventDefault();return}else if(P.key==="-"){N(s+5),P.preventDefault();return}else return;P.preventDefault(),b()}};window.addEventListener("keydown",O);let M=0,R=(P,F)=>{if(!c){F?.();return}let _=P===1?0:1,Y=performance.now(),W=()=>{if(u)return;let G=o<=0?1:Math.min(1,(performance.now()-Y)/o);c?.setOpacity(_+(P-_)*G),n.requestRender(),G<1?M=requestAnimationFrame(W):F?.()};M=requestAnimationFrame(W)};R(1);let C=()=>{u||(u=!0,d(),l.abort(),i.signal?.removeEventListener("abort",h),cancelAnimationFrame(M),g.removeEventListener("pointerdown",z),g.removeEventListener("pointermove",x),g.removeEventListener("pointerup",v),g.removeEventListener("pointercancel",v),g.removeEventListener("wheel",S),window.removeEventListener("keydown",O),g.remove(),y?.isConnected&&y.focus({preventScroll:!0}),c?.dispose(),n.camera.position.set(f[0],f[1],f[2]),n.camera.perspective({fov:m,aspect:n.camera.aspect}),n.camera.quaternion.set(p[0],p[1],p[2],p[3]),n.requestRender())},T={close(){if(u)return;let P=()=>{C(),i.onClose?.()};cancelAnimationFrame(M),R(0,P)},dispose:C};return w.addEventListener("click",()=>T.close()),T}var kr=()=>typeof performance<"u"&&performance.now?performance.now():Date.now(),Ht=class{constructor(e){this.orbitLatched=!1;this.panoramaOpenedAt=0;this.cb=e}emit(e,n){if(this.cb)try{this.cb(e,n)}catch{}}opened(e,n,i,o){this.emit("3d_opened",{seats:e,hasHeights:n,...i===void 0?{}:{buildMs:Math.round(i)},...o===void 0?{}:{prepSource:o}})}orbitEngaged(){this.orbitLatched||(this.orbitLatched=!0,this.emit("3d_orbit_engaged"))}seatPicked(e,n){this.emit("3d_seat_picked",{seatId:e,sectionId:n})}cinematicPlayed(e){this.emit("3d_cinematic_played",{durationMs:e,reducedMotion:!1})}cinematicSkipped(){this.emit("3d_cinematic_skipped",{reducedMotion:!0})}cinematicCancelled(){this.emit("3d_cinematic_cancelled")}panoramaOpened(){this.panoramaOpenedAt=kr(),this.emit("3d_panorama_opened")}panoramaClosed(){let e=this.panoramaOpenedAt?Math.round(kr()-this.panoramaOpenedAt):0;this.panoramaOpenedAt=0,this.emit("3d_panorama_closed",{viewMs:e})}panoramaFailed(e,n){this.emit("3d_panorama_failed",{seatId:e,phase:n})}panoramaFallback(e){this.emit("3d_panorama_fallback",{seatId:e})}contextLost(){this.emit("3d_context_lost")}contextRestored(){this.emit("3d_context_restored")}};function Er(t){let e=t.style.position;return getComputedStyle(t).position!=="static"?()=>{}:(t.style.position="relative",()=>{t.style.position==="relative"&&(t.style.position=e)})}function _r(t){let{container:e,model:n,opts:i,expandedSeatById:o,seatIdsByRow:r,isNarrow:a}=t,s=null,u=()=>{if(!s)return;let d=a();Object.assign(s.style,d?{left:"12px",right:"12px",bottom:"70px",transform:"none",justifyContent:"center"}:{left:"50%",right:"auto",bottom:"18px",transform:"translateX(-50%)",justifyContent:"initial"})},l=()=>{s?.remove(),s=null};return{show:(d,f,c=!1)=>{if(l(),t.isDisposed())return null;let m=document.createElement("div");m.setAttribute("role","group"),Object.assign(m.style,{position:"absolute",display:"flex",flexDirection:"column",alignItems:"center",gap:"6px",zIndex:"4"});let p=o.get(d),b=p?.sectionId?n.sections.find(B=>B.id===p.sectionId):void 0,g=p?.label??d;m.setAttribute("aria-label",`Explore views near ${b?.label?`${b.label}, `:""}seat ${g}`);let y=document.createElement("span");y.textContent=["Live 3D seat view",b?.label,g].filter(Boolean).join(" \xB7 "),Object.assign(y.style,{maxWidth:"min(320px, calc(100vw - 32px))",padding:"5px 10px",borderRadius:"999px",overflow:"hidden",color:"#d9e3f5",background:"rgba(12,18,32,0.72)",font:"600 11px/1.2 inherit",textOverflow:"ellipsis",whiteSpace:"nowrap",backdropFilter:"blur(6px)"}),m.appendChild(y);let w=document.createElement("div");Object.assign(w.style,{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px"}),m.appendChild(w);let E=p?.rowId?r.get(p.rowId):void 0,I=E?.indexOf(d)??-1,A=I>=0?[E?.[I-1],E?.[I+1]]:[void 0,void 0],k=(B,L,U,N=!1)=>{let z=document.createElement("button");z.type="button",z.textContent=B,z.setAttribute("aria-label",L),Object.assign(z.style,{minHeight:"44px",padding:N?"10px 16px":"10px",borderRadius:"999px",background:"rgba(12,18,32,0.78)",color:"#eef1f8",border:"1px solid rgba(150,165,205,0.4)",backdropFilter:"blur(6px)",font:"600 13px/1 inherit",cursor:"pointer",whiteSpace:"nowrap"}),N||(z.style.minWidth="44px"),N&&(z.dataset.panoramaTrigger=""),z.addEventListener("click",U),w.appendChild(z)};if(A[0]){let B=o.get(A[0])?.label??A[0];k("\u2039",`View previous seat ${B}`,()=>{t.flyToSeat(A[0])})}if(i.getSeatView){let B=i.seatViewActionLabel?.(d)??"Open 360\xB0 panorama";k(c?`\u21BB Retry ${B}`:`\u25C9 ${B}`,`${c?"Retry":B} from seat ${g}`,()=>{if(t.isDisposed()||f!==t.flightGen()){l();return}l(),t.openPanorama(d,400,f)},!0)}if(A[1]){let B=o.get(A[1])?.label??A[1];k("\u203A",`View next seat ${B}`,()=>{t.flyToSeat(A[1])})}return w.childElementCount?(e.appendChild(m),s=m,u(),m):null},remove:l,layout:u}}function Lr(t){let{container:e,orbit:n,isNarrow:i}=t,o=document.createElement("div"),r=!1;o.className="sl-3d-navigation-controls",Object.assign(o.style,{position:"absolute",right:"14px",bottom:"14px",display:"flex",zIndex:"4",flexDirection:"column",alignItems:"flex-end",gap:"7px"});let a=document.createElement("div");a.setAttribute("role","group"),a.setAttribute("aria-label","3D drag mode"),Object.assign(a.style,{display:"flex",flexDirection:"column",gap:"6px",alignItems:"flex-end"});let s=document.createElement("div");s.setAttribute("role","group"),s.setAttribute("aria-label","3D view controls"),Object.assign(s.style,{display:"flex",flexDirection:"column",gap:"6px",alignItems:"flex-end"});let u=document.createElement("button");u.type="button",u.textContent="\u21BB",u.setAttribute("aria-label","Drag to rotate the 3D venue"),u.dataset.tooltip="Rotate venue";let l=document.createElement("button");l.type="button",l.textContent="\u2725",l.setAttribute("aria-label","Drag to move the 3D venue left, right, up or down"),l.dataset.tooltip="Move venue";let h=document.createElement("button");h.type="button",h.textContent="\u2212",h.setAttribute("aria-label","Zoom out of the 3D venue"),h.dataset.tooltip="Zoom out";let d=document.createElement("button");d.type="button",d.textContent="+",d.setAttribute("aria-label","Zoom into the 3D venue"),d.dataset.tooltip="Zoom in";for(let p of[u,l,h,d])p.className="sl-3d-icon-control",Object.assign(p.style,{width:"44px",minWidth:"44px",minHeight:"44px",padding:"9px",border:"1px solid rgba(150,165,205,0.35)",borderRadius:"999px",color:"#c9d4ea",background:"rgba(12,18,32,0.82)",font:"600 17px/1 inherit",backdropFilter:"blur(6px)",cursor:"pointer",whiteSpace:"nowrap"});a.append(u,l),s.append(d,h);let f=p=>{n.setPrimaryDragMode(p);let b=p==="orbit";u.setAttribute("aria-pressed",String(b)),l.setAttribute("aria-pressed",String(!b)),u.style.background=b?"rgba(96,110,150,0.68)":"rgba(12,18,32,0.82)",l.style.background=b?"rgba(12,18,32,0.82)":"rgba(96,110,150,0.68)",o.title=b?"Drag to rotate \xB7 Shift-drag to move":"Drag to move \xB7 Shift-drag to rotate"};u.addEventListener("click",()=>f("orbit")),l.addEventListener("click",()=>f("pan")),h.addEventListener("click",()=>n.zoomBy(1.22)),d.addEventListener("click",()=>n.zoomBy(.82)),o.append(a,s),f("orbit"),e.appendChild(o);let c=()=>{let p=i();o.style.display=r?"none":"flex",o.style.right=p?"12px":"14px",o.style.bottom=p?"calc(env(safe-area-inset-bottom, 0px) + 76px)":"14px",a.style.display=p?"none":"flex",d.style.display=p?"none":"",h.style.display=p?"none":""};return c(),{element:o,utilityControls:s,setNavigationMode:f,setSeatViewLocked:p=>{r=p,n.setInteractionEnabled(!p),c()},seatViewLocked:()=>r,layout:c}}function Br(t){let{glctx:e,orbit:n,model:i,seats:o,opts:r,cinematic:a,analytics:s,seatIdByIndex:u,sectionIdBySeatId:l,tapSlop:h,tapMs:d,cancelFlight:f,focusSectionCamera:c,setSelection:m,ensureSeatView:p}=t,b=0,g=0,y=0,w=-1,E=!1,I=!1,A=N=>{t.seatViewLocked()||w===-1&&(w=N.pointerId,b=N.clientX,g=N.clientY,y=performance.now(),E=!1,I=a.active,a.active&&(s.cinematicCancelled(),f(),r.onViewTargetChange?.(null)))},k=N=>{N.pointerId===w&&Math.hypot(N.clientX-b,N.clientY-g)>h&&(E=!0)},B=(N,z,x,v,S)=>{let O=e.canvas.getBoundingClientRect(),M=e.canvas.clientWidth||O.width||1,R=e.canvas.clientHeight||O.height||1,C=N-O.left,T=z-O.top,P=v*v,F=-1,_=P,Y=1/0;for(let W of o){if(x&&W.sectionId!==x)continue;let G=i.seats.idToIndex.get(W.id);if(G===void 0)continue;if(S){let $=Math.round(i.seats.iState[G]??0);if($!==0&&$!==3)continue}let H=G*3,Z=Lt(n.camera.projectionViewMatrix,[i.seats.iPosition[H],i.seats.iPosition[H+1]+.55,i.seats.iPosition[H+2]],M,R);if(!Z.visible)continue;let te=Z.x-C,Q=Z.y-T,J=te*te+Q*Q;(J<_||Math.abs(J-_)<1&&Z.depth<Y)&&(F=G,_=J,Y=Z.depth)}return F},L=(N,z)=>{let x=t.gpu(),v=t.pick();if(!x||!v)return-1;v.syncFromSeatProgram(x.seatProgram);let S=e.canvas.getBoundingClientRect(),O=e.renderer.dpr,{x:M,y:R}=xr(N,z,S,O,e.gl.drawingBufferWidth,e.gl.drawingBufferHeight),C=Math.max(2,Math.round(8*O));return v.pick(n.camera,M,R,C)};return{onDown:A,onMove:k,onUp:N=>{if(N.pointerId!==w)return;let z=!E&&performance.now()-y<d;if(w=-1,I){I=!1;return}let x=t.gpu(),v=t.pick();if(!z||!x||!v)return;let S=L(N.clientX,N.clientY);if(t.focusedSectionId()&&S>=0){let R=u[S],C=R?l.get(R):void 0;if(C&&C!==t.focusedSectionId()&&c(C))return}if(t.focusedSectionId()&&S<0&&(S=B(N.clientX,N.clientY,t.focusedSectionId(),44,!1)),t.focusedSectionId()&&S<0){let R=B(N.clientX,N.clientY,null,72,!1),C=R>=0?u[R]:void 0,T=C?l.get(C):void 0;if(T&&T!==t.focusedSectionId()&&c(T))return}if(!t.focusedSectionId()){S<0&&(S=B(N.clientX,N.clientY,null,42,!1));let R=S>=0?u[S]:void 0,C=R?l.get(R):void 0;if(C&&c(C))return}if(S<0||S>=u.length){t.selection().size&&(m([]),r.onViewTargetChange?.(null));return}let O=u[S],M=Me[Math.round(i.seats.iState[S]??0)]??"available";if(M!=="available"&&M!=="selected"){r.onSeatInspect?.(O,M);return}if(t.selection().has(O)&&t.selection().size===1){m([]),r.onViewTargetChange?.(null);return}m([O]),p(O),s.seatPicked(O,l.get(O)),r.onSeatPick?.(O)}}}var Ut=class{constructor(e,n){this.minX=0;this.minZ=0;this.cell=1;this.cols=1;this.rows=1;this.cellStart=null;this.cellItems=null;this.iPosition=e,this.count=n}ensureGrid(){if(this.cellStart||this.count===0)return;let e=this.iPosition,n=1/0,i=1/0,o=-1/0,r=-1/0;for(let c=0;c<this.count;c++){let m=e[c*3],p=e[c*3+2];m<n&&(n=m),m>o&&(o=m),p<i&&(i=p),p>r&&(r=p)}let a=Math.max(o-n,.001),s=Math.max(r-i,.001);this.cell=Math.max(Math.sqrt(a*s*4/this.count),.25),this.cols=Math.max(1,Math.ceil(a/this.cell)+1),this.rows=Math.max(1,Math.ceil(s/this.cell)+1),this.minX=n,this.minZ=i;let u=this.cols*this.rows,l=new Int32Array(u+1),h=c=>{let m=Math.min(this.cols-1,Math.max(0,Math.floor((e[c*3]-n)/this.cell)));return Math.min(this.rows-1,Math.max(0,Math.floor((e[c*3+2]-i)/this.cell)))*this.cols+m};for(let c=0;c<this.count;c++)l[h(c)+1]++;for(let c=0;c<u;c++)l[c+1]+=l[c];let d=new Int32Array(this.count),f=l.slice(0,u);for(let c=0;c<this.count;c++)d[f[h(c)]++]=c;this.cellStart=l,this.cellItems=d}gather(e,n,i,o){this.ensureGrid();let r=this.cellStart,a=this.cellItems;if(!r||!a)return 0;let s=o.length,u=i*i,l=Math.floor((e-this.minX)/this.cell),h=Math.floor((n-this.minZ)/this.cell),d=Math.ceil(i/this.cell)+1,f=this.iPosition,c=0;for(let m=0;m<=d&&c<s;m++){let p=h-m,b=h+m,g=l-m,y=l+m;for(let w=p;w<=b&&c<s;w++){if(w<0||w>=this.rows)continue;let E=w===p||w===b;for(let I=g;I<=y&&c<s;I++){if(!E&&I!==g&&I!==y){I=y-1;continue}if(I<0||I>=this.cols)continue;let A=w*this.cols+I;for(let k=r[A],B=r[A+1];k<B&&c<s;k++){let L=a[k],U=f[L*3]-e,N=f[L*3+2]-n;U*U+N*N<=u&&(o[c++]=L)}}}}return c}};var Yt=class{constructor(e){this.ctx=e;this.detailVisible=!1;this.seatDetailMix=0;this.structureDetailMix=0;this.nearBuf=new Int32Array(wt);this.lastGatherX=1/0;this.lastGatherZ=1/0;this.nearIndex=new Ut(e.model.seats.iPosition,e.model.seats.count)}forceRegather(){this.lastGatherX=1/0}setDetailEnabled(e){let n=this.ctx.gpu();e||(this.detailVisible=!1),this.lastGatherX=1/0,this.lastGatherZ=1/0,!e&&n?.nearSeatCount()&&n.setNearSeats(this.nearBuf,0)}update(e){let{model:n}=this.ctx,i=this.ctx.gpu();if(!i)return;if(!e){i.nearSeatCount()&&i.setNearSeats(this.nearBuf,0);return}let o=this.ctx.orbit().camera.position;if(Math.hypot(o.x-this.lastGatherX,o.z-this.lastGatherZ)<Qt)return;if(this.lastGatherX=o.x,this.lastGatherZ=o.z,Math.hypot(o.x-n.bounds.center[0],o.z-n.bounds.center[2])-n.bounds.radius>$t){i.nearSeatCount()&&i.setNearSeats(this.nearBuf,0);return}let s=this.nearIndex.gather(o.x,o.z,$t,this.nearBuf);s===0&&i.nearSeatCount()===0||i.setNearSeats(this.nearBuf,s)}ease(e,n,i){let o=1-Math.exp(-e*9),r=1-Math.exp(-e*20);this.seatDetailMix+=(n-this.seatDetailMix)*(n>this.seatDetailMix?o:r),this.structureDetailMix+=(i-this.structureDetailMix)*(i>this.structureDetailMix?o:r),Math.abs(n-this.seatDetailMix)<.01&&(this.seatDetailMix=n),Math.abs(i-this.structureDetailMix)<.01&&(this.structureDetailMix=i)}};import{Quat as ns,Vec3 as os}from"ogl";function Or(t){let{container:e,model:n,opts:i,orbit:o,cinematic:r,analytics:a,loop:s,labelOverlay:u,stageAzimuth:l,overviewFraming:h}=t,d=0,f=-1,c=(I,A,k=28)=>{o.camera.position.set(I[0],I[1],I[2]),o.camera.lookAt(new os(A[0],A[1],A[2])),o.camera.fov=k,o.camera.updateProjectionMatrix()},m=document.createElement("button");m.className="sl-3d-overview-control sl-3d-icon-control",m.type="button",m.textContent="\u2302",m.setAttribute("aria-label","Fit the active level or whole venue in view"),m.dataset.tooltip="Fit view",Object.assign(m.style,{width:"44px",minWidth:"44px",minHeight:"44px",padding:"9px",borderRadius:"999px",background:"rgba(12,18,32,0.72)",color:"#c9d4ea",border:"1px solid rgba(150,165,205,0.35)",backdropFilter:"blur(6px)",font:"600 11px/1 inherit",cursor:"pointer",whiteSpace:"nowrap"});let p=()=>{m.textContent="\u2302"};p();let b=I=>{f=I;let A=t.gpu();A&&(A.seatProgram.uniforms.uFocusFloor.value=I,A.solidProgram.uniforms.uFocusFloor.value=I,A.chairProgram.uniforms.uFocusFloor.value=I),t.showSectionSeatLabels(null)},g=()=>{if(t.isDisposed())return;i.onViewTargetChange?.(null),i.onSectionFocusChange?.(null),t.panorama()&&(t.panorama().dispose(),t.setPanorama(null),a.panoramaClosed()),t.setPanoramaSphereVisible(!1),t.panoramaLoadAbort()?.abort(),t.setPanoramaLoadAbort(null),t.restorePanoramaLayer(),m.style.display="",u.setVisible(!0),t.setFrozen(!1);let I=f>=0?n.floors[f]:null;if(t.setNearFieldDetailEnabled(!!I),t.setSeatViewLocked(!1),y(),t.removeArriveChip(),t.setNavigationMode("orbit"),I){let A=I.focalWorld[0]-I.center[0],k=I.focalWorld[2]-I.center[2],B=Math.hypot(A,k)>I.radius*.12?Math.atan2(A,k):l,L={center:I.center,radius:I.radius,box:I.box},U={polarDeg:58,margin:1.12};t.reducedMotion()?o.frame(L,!1,B,!1,U):o.frameSoft(L,B,!1,U)}else t.reducedMotion()?o.frame(n.bounds,!1,l,i.portraitOverviewCrop===!0,h):o.frameSoft(n.bounds,l,i.portraitOverviewCrop===!0,h);t.showSectionSeatLabels(null),s.requestRender()},y=()=>{d++,t.panoramaLoadAbort()?.abort(),t.setPanoramaLoadAbort(null),r.active&&(r.cancel(),o.resumeAfterFlight(n.focalWorld))},w=I=>{if(t.isDisposed()||!t.gpu())return Promise.resolve();let A=n.seats.idToIndex.get(I);if(A===void 0)return Promise.resolve();t.setNearFieldDetailEnabled(!0),i.onViewTargetChange?.(I),t.panorama()&&(t.panorama().dispose(),t.setPanorama(null),t.setPanoramaSphereVisible(!1),m.style.display="",t.restorePanoramaLayer()),t.panoramaLoadAbort()?.abort(),t.setPanoramaLoadAbort(null),t.setFrozen(!1),t.setSeatViewLocked(!1);let k=++d;t.removeArriveChip();let{eye:B,focal:L}=t.resolvedSeatViewPose(I,A),U=[o.camera.position.x,o.camera.position.y,o.camera.position.z],N=yn(U,B,L,n.bounds.center,n.bounds.radius),z=i.arriveAtSeatEye?B:N.finalPos,x=i.arriveAtSeatEye?e.clientWidth/Math.max(1,e.clientHeight)<.7?90:65:28,v=[N.waypoints[0],N.waypoints[1],z];if(u.setVisible(!1),t.reducedMotion())return c(z,L,x),s.requestRender(),a.cinematicSkipped(),t.isDisposed()||o.syncFromCamera(),t.setSeatViewLocked(i.arriveAtSeatEye===!0),t.showArriveChip(I,k),Promise.resolve();let S=new ns().copy(o.camera.quaternion),O=Cr(o.camera,z,L);return s.requestRender(),r.start(v,S,O,2500,x).then(()=>{t.isDisposed()||k!==d||(a.cinematicPlayed(2500),o.resumeAfterFlight(L),t.setSeatViewLocked(i.arriveAtSeatEye===!0),s.requestRender(),t.showArriveChip(I,k))})},E=I=>{let A=n.sections.find(U=>U.id===I);if(!A||A.seatCount===0)return!1;t.setNearFieldDetailEnabled(!0),t.setSeatViewLocked(!1),r.cancel(),t.removeArriveChip(),n.floors.length>1&&f!==A.floorIndex&&b(A.floorIndex),t.setNavigationMode("pan"),t.showSectionSeatLabels(I);let k=A.focalWorld[0]-A.center[0],B=A.focalWorld[2]-A.center[2],L=Math.hypot(k,B)>A.radius*.12?Math.atan2(k,B):void 0;return o.frame({center:A.center,radius:Math.max(5,A.radius*.5)},!1,L),i.onSectionFocusChange?.(I),s.requestRender(),!0};return m.addEventListener("click",g),{overviewChip:m,layoutOverviewChip:p,flightGen:()=>d,focusedFloor:()=>f,applyFloorFocus:b,placeCameraFinal:c,cancelFlight:y,focusOverview:g,flyToSeat:w,focusSectionCamera:E}}function Nr(t){let e=performance.now();return{model:ft(t),buildMs:performance.now()-e,source:"main"}}function rs(t){return typeof Worker>"u"?Promise.resolve(Nr(t)):new Promise(e=>{let n=new Worker(new URL("./scene/scene.worker.ts",import.meta.url),{type:"module"}),i=!1,o=s=>{i||(i=!0,clearTimeout(a),n.terminate(),e(s))},r=()=>o(Nr(t)),a=window.setTimeout(r,15e3);n.onerror=r,n.onmessage=s=>{o({model:s.data.model,buildMs:s.data.buildMs,source:"worker"})},n.postMessage(t)})}var is=Math.PI/180,as=6,ss=500;function Vu(t,e,n={}){let i=performance.now(),o=e.prepared?.model??ft(e),r=new Ht(n.onAnalytics),a=new Array(o.seats.count);for(let[V,X]of o.seats.idToIndex)a[X]=V;let s=new Map(e.seats.map(V=>[V.id,V])),u=new Map;for(let V of e.seats){if(!V.rowId)continue;let X=u.get(V.rowId);X?X.push(V.id):u.set(V.rowId,[V.id])}let l=new Map;for(let V of e.seats)l.set(V.id,V.sectionId);let h=e.doc.floors?.some(X=>(X.baseHeightM??0)>0)?!0:(e.doc.floors?.flatMap(X=>X.objects)??e.doc.objects).some(X=>X.type==="section"&&((X.height??0)>0||(X.rake??0)>0)),d=null,f=null,c=!1,m=!1,p=!1,b=new Map,g=null,y=null,w=null,E=new Map,I=null,A=()=>{w===null&&(w=t.style.zIndex,t.style.zIndex="20")},k=()=>{w!==null&&(t.style.zIndex==="20"&&(t.style.zIndex=w),w=null)},B=!1,L=()=>B?ie.focusedFloor():-1,U=()=>{d=br(v.gl,o),f=new Vt(v.renderer,d.seatGeometry,d.chairGeometry,d.solidGeometry,o.seats.count),v.setClearColor(o.theme.background.top),f.setRestoreClear(o.theme.background.top),d.seatProgram.uniforms.uSeatRadius.value=Ie*o.theme.seatScale,d.seatProgram.uniforms.uFocusFloor.value=L(),d.solidProgram.uniforms.uFocusFloor.value=L(),d.chairProgram.uniforms.uFocusFloor.value=L(),z.forceRegather()},N=!1,z=new Yt({model:o,orbit:()=>S,gpu:()=>d}),x=V=>z.setDetailEnabled(V),v=new vt(t,{onContextLost:()=>{p||r.contextLost(),c=!0,H.stop(),d=null,f=null},onContextRestored:()=>{U(),c=!1,p||r.contextRestored(),H.requestRender()}}),S=new Mt(v.gl,v.canvas,()=>H.requestRender(),()=>r.orbitEngaged());S.setAspect(v.aspect);let O=(e.doc.floors?.flatMap(V=>V.objects)??e.doc.objects).some(V=>V.type==="section"&&V.physical3dProvenance?.surfaceKind?.status==="inferred"),M=(()=>{if(O&&o.stages.length===0)return;let V=o.focalWorld[0]-o.bounds.center[0],X=o.focalWorld[2]-o.bounds.center[2];return Math.hypot(V,X)>o.bounds.radius*.12?Math.atan2(V,X):void 0})(),R=o.floors.length>1?{polarDeg:48,margin:1.1}:void 0,C=typeof window<"u"&&!!window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;S.frame(o.bounds,!C,M,n.portraitOverviewCrop===!0,R);let T=new Gt(S.camera),P=Er(t),F=new Bt(t,{fontFamily:e.doc.theme?.fontFamily,ink:e.doc.theme?.textColor,backgroundRgb:o.theme.background.top}),_=o.labels,Y=()=>Uo(_,o.floors.length,L());F.setLabels(Y());let W=null,G=V=>{if(W=V,F.setForcedDense(!!V),!V){F.setLabels(Y());return}let X=e.seats.filter(q=>q.sectionId===V),j=new Set(X.map(q=>q.id)),K=new Set(X.map(q=>q.rowId)),re=new Set(b.keys()),oe=new Set(X.filter(q=>re.has(q.id)).map(q=>q.id)),ue=Y().filter(q=>q.kind!=="row"&&q.kind!=="seat"||(q.kind==="row"?K.has(q.id.slice(4)):j.has(q.id.slice(5))&&(oe.size===0||oe.has(q.id.slice(5)))));if(o.seatCount<=6e3&&oe.size===0){F.setLabels(ue);return}let xe=oe.size?X.filter(q=>oe.has(q.id)):X,ge=new Set(xe.map(q=>`seat:${q.id}`)),Ce=xe.flatMap(q=>{let ve=o.seats.idToIndex.get(q.id);if(ve===void 0)return[];let _e=ve*3;return[{id:`seat:${q.id}`,kind:"seat",text:q.displayLabel||q.label,anchor:[o.seats.iPosition[_e],o.seats.iPosition[_e+1]+(re.has(q.id)?1.05:.55),o.seats.iPosition[_e+2]]}]});F.setLabels([...ue.filter(q=>!ge.has(q.id)),...Ce])};U();let H=new St(V=>{if(c||!d||m)return!1;let j=T.active?T.update(performance.now()):S.update(),K=L()>=0?o.floors[L()]:null,re=K?.radius??o.bounds.radius,oe=jn(S.currentDistance,re),ue=N?{center:[S.camera.position.x,S.camera.position.y,S.camera.position.z],radius:520}:o.renderBounds;S.updateClipping(ue);let xe=K?.center??o.renderBounds.center,ge=K?.radius??o.renderBounds.radius,Ce=(Ve,Xt)=>Math.hypot(S.camera.position.x-Ve[0],S.camera.position.y-Ve[1],S.camera.position.z-Ve[2])<=Xt*(z.detailVisible?1.8:1.55),q=Ce(xe,ge);if(!q&&W){let Ve=o.sections.find(Xt=>Xt.id===W);Ve&&(q=Ce(Ve.center,Math.max(12,Ve.radius*2)))}z.detailVisible=q;let ve=d.seatProgram.uniforms;ve.uSeatScale.value=oe.scale,ve.uSeatFade.value=oe.fade;let _e=!!K&&qn(K.seatCount,v.canvas.clientWidth||1,v.canvas.clientHeight||1),tt=Zn(o.seats.count,re,S.currentDistance,S.camera.fov,v.canvas.clientHeight||1),Le=z.detailVisible||_e||tt?1:0,wn=z.detailVisible||L()>=0||o.floors.length>1?1:0;return z.ease(V,Le,wn),ve.uSeatDetail.value=z.seatDetailMix,d.solidProgram.uniforms.uStructureDetail.value=z.structureDetailMix,ve.uMinPixels.value=oe.minPixels,ve.uPixelToWorld.value=2*Math.tan(S.camera.fov*is/2)/Math.max(1,v.pixelHeight),z.update(z.detailVisible),v.renderer.render({scene:d.background,clear:!0}),v.renderer.render({scene:d.main,camera:S.camera,clear:!1}),F.update(S.camera.projectionViewMatrix,v.canvas.clientWidth||1,v.canvas.clientHeight||1,S.currentDistance,re,[S.camera.position.x,S.camera.position.y,S.camera.position.z]),j||z.seatDetailMix!==Le||z.structureDetailMix!==wn}),Z=typeof ResizeObserver<"u"?new ResizeObserver(()=>Sn.resize()):null;Z?.observe(t);let te=V=>{let X=re=>{let oe=o.seats.idToIndex.get(re);return oe===void 0?void 0:o.seats.iState[oe]},{updates:j,next:K}=vr(b,V,X);if(b=K,F.setSelectedSeatIds(b.keys()),W&&G(W),j.length){let re=nn(o.seats,j);d&&d.uploadSeatStateRuns(re),H.requestRender()}},Q=()=>I!==null?I:typeof window<"u"&&!!window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,J=8,$=V=>{if(!n.getSeatView)return null;let X=E.get(V);if(!X)for(X=Promise.resolve(n.getSeatView(V)),E.set(V,X),X.catch(()=>{E.get(V)===X&&E.delete(V)});E.size>J;){let j=E.keys().next().value;if(j===void 0)break;E.delete(j)}return X},he=(V,X)=>{let j=s.get(V),K=Math.max(0,Math.round(o.seats.iFloor[X]??0)),re=e.doc.floors?.[K],oe=o.floors[K],ue=re?.focalPoint??e.doc.focalPoint,xe=oe?{x:oe.focalWorld[0]/D,y:oe.focalWorld[2]/D}:ue,ge=j?.focalPoint?{x:j.focalPoint.x+xe.x-ue.x,y:j.focalPoint.y+xe.y-ue.y}:xe,Ce=[o.seats.iPosition[X*3],o.seats.iPosition[X*3+1],o.seats.iPosition[X*3+2]];return Rr(Ce,ge,re?.baseHeightM??0,j?.eyeHeightM)},ze=()=>(t.clientWidth||v.canvas.clientWidth)<=520,De=_r({container:t,model:o,opts:n,expandedSeatById:s,seatIdsByRow:u,isNarrow:ze,isDisposed:()=>p,flightGen:()=>ie.flightGen(),flyToSeat:V=>vn(V),openPanorama:(V,X,j)=>Gr(V,X,j)}),ye=De.show,Pe=De.remove,ke=De.layout,de=Lr({container:t,orbit:S,isNarrow:ze}),Se=de.element,ce=de.setNavigationMode,Ae=de.setSeatViewLocked,et=de.layout,We=de.utilityControls,ie=Or({container:t,model:o,opts:n,orbit:S,cinematic:T,analytics:r,loop:H,labelOverlay:F,stageAzimuth:M,overviewFraming:R,gpu:()=>d,isDisposed:()=>p,panorama:()=>g,setPanorama:V=>{g=V},setPanoramaSphereVisible:V=>{N=V},panoramaLoadAbort:()=>y,setPanoramaLoadAbort:V=>{y=V},setFrozen:V=>{m=V},restorePanoramaLayer:k,reducedMotion:Q,resolvedSeatViewPose:he,showSectionSeatLabels:G,setNearFieldDetailEnabled:x,setSeatViewLocked:Ae,setNavigationMode:ce,showArriveChip:ye,removeArriveChip:Pe});B=!0;let we=ie.overviewChip,bt=ie.layoutOverviewChip,zr=ie.applyFloorFocus,Vr=ie.focusOverview,gn=ie.cancelFlight,vn=ie.flyToSeat,Mn=ie.focusSectionCamera;We.appendChild(we);let Gr=async(V,X,j)=>{y?.abort();let K=new AbortController;y=K;let re=o.seats.idToIndex.get(V);if(re===void 0){S.syncFromCamera();return}let oe=s.get(V)?.label??V,ue=he(V,re),xe=$(V);if(!xe){K.abort(),y===K&&(y=null),S.syncFromCamera();return}m=!0,H.stop();let ge;try{ge=await xe}catch{if(y===K&&(y=null),r.panoramaFailed(V,"source"),!p&&j===ie.flightGen()){m=!1,S.resumeAfterFlight(ue.focal),H.requestRender();let Le=ye(V,j,!0);requestAnimationFrame(()=>Le?.querySelector("[data-panorama-trigger]")?.focus())}return}if(p||j!==ie.flightGen()){K.abort(),y===K&&(y=null);return}Pe();let Ce=()=>{K.abort(),y===K&&(y=null),g=null,N=!1,k(),we.style.display="",F.setVisible(!n.arriveAtSeatEye),m=!1,r.panoramaClosed(),S.resumeAfterFlight(ue.focal),H.requestRender();let Le=ye(V,ie.flightGen());requestAnimationFrame(()=>Le?.querySelector("[data-panorama-trigger]")?.focus())},q=ge.generated===!0,ve=Ln(ge);A(),N=!q,we.style.display="none";let _e=Q()?0:X,tt=d&&!c?await Dr(t,q?null:ge,{gl:v.gl,scene:d.main,camera:S.camera,requestRender:()=>H.requestRender(),cameraOriginWorld:q?ue.eye:void 0,focalWorld:ue.focal},{fadeMs:_e,seatLabel:oe,disclosure:ve,disclosurePrefix:q?"Live seat-eye view":"360\xB0 panorama",onClose:Ce,signal:K.signal}):null;if(p||j!==ie.flightGen()){K.abort(),N=!1,y===K&&(y=null),tt?.dispose(),we.style.display="",k();return}if(tt)S.syncFromCamera(),F.setVisible(!1),m=!1,H.requestRender(),g=tt;else if(q){k(),we.style.display="",m=!1,S.resumeAfterFlight(ue.focal),H.requestRender(),g=null,N=!1,r.panoramaFailed(V,"mount");let Le=ye(V,ie.flightGen(),!0);requestAnimationFrame(()=>Le?.querySelector("[data-panorama-trigger]")?.focus()),y===K&&(y=null);return}else N=!1,r.panoramaFallback(V),g=Nn(t,ge,{fadeMs:_e,seatLabel:oe,disclosure:ve,onClose:Ce,signal:K.signal});r.panoramaOpened()},Ee=Br({glctx:v,orbit:S,model:o,seats:e.seats,opts:n,cinematic:T,analytics:r,seatIdByIndex:a,sectionIdBySeatId:l,tapSlop:as,tapMs:ss,gpu:()=>d,pick:()=>f,seatViewLocked:()=>de.seatViewLocked(),focusedSectionId:()=>W,selection:()=>b,cancelFlight:gn,focusSectionCamera:Mn,setSelection:te,ensureSeatView:$});v.canvas.addEventListener("pointerdown",Ee.onDown),v.canvas.addEventListener("pointermove",Ee.onMove),v.canvas.addEventListener("pointerup",Ee.onUp),v.canvas.addEventListener("pointercancel",Ee.onUp),H.requestRender();let Sn={setAvailability(V){let X=gr(b,V),j=nn(o.seats,X);j.length&&d&&d.uploadSeatStateRuns(j),H.requestRender()},setSelection:te,flyToSeat:vn,focusOverview:Vr,resize(){let{width:V,height:X}=v.resize();S.setAspect(V/Math.max(1,X)),ke(),et(),bt(),H.requestRender()},stats(){return{...H.stats(),drawCalls:d?d.drawCalls:0,seatCount:o.seatCount}},loseContextForTest(){v.simulateContextLossCycle()},floors(){return o.floors},focusFloor(V){if(V!==null&&!o.floors.some(j=>j.index===V))return!1;let X=V??-1;if(x(V!==null),Ae(!1),zr(X),ce("orbit"),V===null)T.cancel(),Q()?S.frame(o.bounds,!1,M,n.portraitOverviewCrop===!0,R):S.frameSoft(o.bounds,M,n.portraitOverviewCrop===!0,R);else{let j=o.floors[V];if(j.seatCount>0){T.cancel();let K=j.focalWorld[0]-j.center[0],re=j.focalWorld[2]-j.center[2],oe=Math.hypot(K,re)>j.radius*.12?Math.atan2(K,re):M;S.frame({center:j.center,radius:j.radius,box:j.box},!1,oe,!1,{polarDeg:58,margin:1.12})}}return H.requestRender(),!0},zones(){return o.zones},focusZone(V){let X=o.zones.find(oe=>oe.id===V);if(!X||X.seatCount===0)return!1;x(!1),Ae(!1),T.cancel(),ce("orbit"),G(null),n.onSectionFocusChange?.(null);let j=X.focalWorld[0]-X.center[0],K=X.focalWorld[2]-X.center[2],re=Math.hypot(j,K)>X.radius*.12?Math.atan2(j,K):void 0;return S.frame({center:X.center,radius:X.radius*1.25},!1,re),H.requestRender(),!0},sections(){return o.sections},focusSection(V){return Mn(V)},rows(V){return V?o.rows.filter(X=>X.sectionId===V):o.rows},seatsInRow(V){return e.seats.filter(X=>X.rowId===V).map(X=>({id:X.id,label:X.displayLabel||X.label}))},focusRow(V){let X=o.rows.find(j=>j.id===V);return!X||X.seatCount===0?!1:(x(!0),Ae(!1),T.cancel(),ce("pan"),X.sectionId&&(G(X.sectionId),n.onSectionFocusChange?.(X.sectionId)),S.frame({center:X.center,radius:Math.max(2.5,X.radius*.65)}),H.requestRender(),!0)},setReducedMotionForTest(V){I=V},dispose(){p=!0,Pe(),we.remove(),Se.remove(),gn(),H.stop(),F.dispose(),Z?.disconnect(),g&&(g.dispose(),g=null),k(),P(),v.canvas.removeEventListener("pointerdown",Ee.onDown),v.canvas.removeEventListener("pointermove",Ee.onMove),v.canvas.removeEventListener("pointerup",Ee.onUp),v.canvas.removeEventListener("pointercancel",Ee.onUp),S.dispose(),f&&f.dispose(),d&&d.dispose(),d=null,f=null,v.dispose()}};return r.opened(o.seatCount,h,e.prepared?.buildMs??performance.now()-i,e.prepared?.source??"inline"),Sn}export{ft as buildSceneModel,Vu as mountVenue3D,rs as prepareVenue3D};
553
+ }`;function Er(t,e){let{position:n,uv:i,index:o}=Qa(),r=new Xa(t,{position:{size:3,data:n},uv:{size:2,data:i},index:{data:o}}),a=new ja(t,{image:e,wrapS:t.CLAMP_TO_EDGE,wrapT:t.CLAMP_TO_EDGE,generateMipmaps:!0,flipY:!1}),s=new Wa(t,{vertex:$a,fragment:Ja,uniforms:{uPano:{value:a},uOpacity:{value:0}},transparent:!0,depthTest:!1,depthWrite:!1}),l=new Ya(t,{geometry:r,program:s});return{mesh:l,setOpacity(c){s.uniforms.uOpacity.value=Math.max(0,Math.min(1,c))},setImage(c){a.image=c,a.needsUpdate=!0},dispose(){l.setParent(null),r.remove(),a.texture&&t.deleteTexture(a.texture),s.remove()}}}var Dr=.15;async function kr(t,e,n,i={}){let o=i.fadeMs??400,r=e?.initialBearingDeg??0,a=Math.max(-Ce,Math.min(Ce,e?.initialPitchDeg??0)),s=zn,l=!1,c=new AbortController,h=()=>c.abort();i.signal?.addEventListener("abort",h,{once:!0});let m=()=>{},d=[n.camera.position.x,n.camera.position.y,n.camera.position.z];if(!e&&n.cameraOriginWorld&&n.camera.position.set(n.cameraOriginWorld[0],n.cameraOriginWorld[1],n.cameraOriginWorld[2]),!e&&n.focalWorld){let A=n.camera.position,D=n.focalWorld[0]-A.x,V=n.focalWorld[1]-A.y,U=n.focalWorld[2]-A.z,Y=Math.hypot(D,U);Y>.001&&(r=Math.atan2(D,-U)*180/Math.PI,a=Math.max(-Ce,Math.min(Ce,Math.atan2(V,Y)*180/Math.PI)))}let p=null;if(e){let A=n.gl.getParameter(n.gl.MAX_TEXTURE_SIZE),D=Bn(e,On(A)),V;try{let U=e.resolveUrl?await e.resolveUrl(D.initialUrl):D.initialUrl;if(!U)throw new Error("panorama_asset_unavailable");V=await Zt(U,c.signal)}catch{return i.signal?.removeEventListener("abort",h),null}try{p=Er(n.gl,V)}catch{return c.abort(),i.signal?.removeEventListener("abort",h),null}p.mesh.renderOrder=999,p.mesh.setParent(n.scene),D.upgradeUrl&&(m=Vn(()=>{(e.resolveUrl?e.resolveUrl(D.upgradeUrl):Promise.resolve(D.upgradeUrl)).then(Y=>!Y||c.signal.aborted?null:Zt(Y,c.signal)).then(Y=>{Y&&(l||c.signal.aborted||(p?.setImage(Y),n.requestRender()))}).catch(()=>{})}))}let f=n.camera.fov;n.camera.perspective({fov:s,aspect:n.camera.aspect});let u=n.camera.quaternion.slice(),b=()=>{let A=n.camera.position;p?.mesh.position.set(A.x,A.y,A.z);let[D,V,U]=Fr(r,a);n.camera.lookAt([A.x+D,A.y+V,A.z+U]),n.requestRender()};b();let y=document.createElement("div"),x=document.activeElement instanceof HTMLElement?document.activeElement:null;y.setAttribute("role","dialog"),y.setAttribute("aria-modal","true"),y.setAttribute("aria-label",i.seatLabel?`View from ${i.seatLabel}`:"View from seat"),y.tabIndex=-1,Object.assign(y.style,{position:"absolute",inset:"0",zIndex:"10",cursor:"grab",touchAction:"none"});let v=document.createElement("button");if(v.type="button",v.setAttribute("aria-label","Close"),v.textContent="\u2715",Object.assign(v.style,{position:"absolute",top:"12px",right:"12px",zIndex:"2",width:"44px",height:"44px",borderRadius:"999px",cursor:"pointer",border:"1px solid rgba(255,255,255,0.25)",background:"rgba(8,12,18,0.6)",color:"#e6edf3",fontSize:"15px",lineHeight:"1"}),y.appendChild(v),i.disclosure){let A=document.createElement("div");A.textContent=`${i.disclosurePrefix??"360\xB0 panorama"} \xB7 ${i.disclosure}`,Object.assign(A.style,{position:"absolute",top:"12px",left:"12px",zIndex:"2",maxWidth:"calc(100% - 88px)",padding:"8px 11px",borderRadius:"999px",overflow:"hidden",color:"#dce6f8",background:"rgba(8,12,18,0.68)",font:"600 11px/1.2 ui-sans-serif, system-ui, sans-serif",textOverflow:"ellipsis",whiteSpace:"nowrap",pointerEvents:"none",backdropFilter:"blur(6px)"}),y.appendChild(A)}let k=document.createElement("div");k.textContent="Drag to look \xB7 pinch or scroll to zoom \xB7 Esc to close",Object.assign(k.style,{position:"absolute",bottom:"12px",left:"0",right:"0",textAlign:"center",color:"rgba(230,237,243,0.7)",font:"12px ui-sans-serif, system-ui, sans-serif",pointerEvents:"none"}),y.appendChild(k),t.appendChild(y),v.focus({preventScroll:!0});let P=!1,M=0,F=0,O=0,L=new Map,H=()=>{let[A,D]=[...L.values()];return A&&D?Math.hypot(A.x-D.x,A.y-D.y):0},_=A=>{let D=Gn(A);D!==s&&(s=D,n.camera.perspective({fov:s,aspect:n.camera.aspect}),b())},g=A=>{A.target!==v&&(L.set(A.pointerId,{x:A.clientX,y:A.clientY}),P=L.size===1,M=A.clientX,F=A.clientY,L.size===2&&(O=H()),y.setPointerCapture?.(A.pointerId),y.style.cursor="grabbing")},w=A=>{if(L.has(A.pointerId)){if(L.set(A.pointerId,{x:A.clientX,y:A.clientY}),L.size>=2){let D=H();O>0&&D>0&&_(s*(O/D)),O=D,P=!1;return}P&&(r+=(A.clientX-M)*Dr,a=Math.max(-Ce,Math.min(Ce,a+(A.clientY-F)*Dr)),M=A.clientX,F=A.clientY,b())}},E=A=>{L.delete(A.pointerId),O=L.size===2?H():0;let D=L.values().next().value;P=L.size===1,D?(M=D.x,F=D.y):y.style.cursor="grab";try{y.releasePointerCapture?.(A.pointerId)}catch{}},C=A=>{A.preventDefault(),_(s+A.deltaY*.04)};y.addEventListener("pointerdown",g),y.addEventListener("pointermove",w),y.addEventListener("pointerup",E),y.addEventListener("pointercancel",E),y.addEventListener("wheel",C,{passive:!1});let N=A=>{if(!l){if(A.key==="Tab"){A.preventDefault(),v.focus({preventScroll:!0});return}if(A.key==="Escape"){A.stopPropagation(),B.close();return}if(A.key==="ArrowLeft"||A.key==="ArrowRight")r+=A.key==="ArrowLeft"?-4:4;else if(A.key==="ArrowUp"||A.key==="ArrowDown")a=Math.max(-Ce,Math.min(Ce,a+(A.key==="ArrowUp"?4:-4)));else if(A.key==="+"||A.key==="="){_(s-5),A.preventDefault();return}else if(A.key==="-"){_(s+5),A.preventDefault();return}else return;A.preventDefault(),b()}};window.addEventListener("keydown",N);let S=0,I=(A,D)=>{if(!p){D?.();return}let V=A===1?0:1,U=performance.now(),Y=()=>{if(l)return;let X=o<=0?1:Math.min(1,(performance.now()-U)/o);p?.setOpacity(V+(A-V)*X),n.requestRender(),X<1?S=requestAnimationFrame(Y):D?.()};S=requestAnimationFrame(Y)};I(1);let T=()=>{l||(l=!0,m(),c.abort(),i.signal?.removeEventListener("abort",h),cancelAnimationFrame(S),y.removeEventListener("pointerdown",g),y.removeEventListener("pointermove",w),y.removeEventListener("pointerup",E),y.removeEventListener("pointercancel",E),y.removeEventListener("wheel",C),window.removeEventListener("keydown",N),y.remove(),x?.isConnected&&x.focus({preventScroll:!0}),p?.dispose(),n.camera.position.set(d[0],d[1],d[2]),n.camera.perspective({fov:f,aspect:n.camera.aspect}),n.camera.quaternion.set(u[0],u[1],u[2],u[3]),n.requestRender())},B={close(){if(l)return;let A=()=>{T(),i.onClose?.()};cancelAnimationFrame(S),I(0,A)},dispose:T};return v.addEventListener("click",()=>B.close()),B}function Lr(t){let{container:e,model:n,opts:i,analytics:o,orbit:r,loop:a,seatsById:s,ensureSeatView:l,resolvedSeatViewPose:c,gpu:h,gl:m,isContextLost:d,isDisposed:p,flightGen:f,setPanorama:u,getLoadAbort:b,setLoadAbort:y,setPanoramaSphereVisible:x,setFrozen:v,raisePanoramaLayer:k,restorePanoramaLayer:P,getOverviewChip:M,labelOverlay:F,reducedMotion:O,removeArriveChip:L,showArriveChip:H}=t;return async(_,g,w)=>{b()?.abort();let E=new AbortController;y(E);let C=n.seats.idToIndex.get(_);if(C===void 0){r.syncFromCamera();return}let N=s.get(_)?.label??_,S=c(_,C),I=l(_);if(!I){E.abort(),b()===E&&y(null),r.syncFromCamera();return}v(!0),a.stop();let T;try{T=await I}catch{if(b()===E&&y(null),o.panoramaFailed(_,"source"),!p()&&w===f()){v(!1),r.resumeAfterFlight(S.focal),a.requestRender();let j=H(_,w,!0);requestAnimationFrame(()=>j?.querySelector("[data-panorama-trigger]")?.focus())}return}if(p()||w!==f()){E.abort(),b()===E&&y(null);return}L();let B=M(),A=()=>{E.abort(),b()===E&&y(null),u(null),x(!1),P(),B.style.display="",F.setVisible(!i.arriveAtSeatEye),v(!1),o.panoramaClosed(),r.resumeAfterFlight(S.focal),a.requestRender();let j=H(_,f());requestAnimationFrame(()=>j?.querySelector("[data-panorama-trigger]")?.focus())},D=T.generated===!0,V=Nn(T);k(),x(!D),B.style.display="none";let U=O()?0:g,Y=h(),X=Y&&!d()?await kr(e,D?null:T,{gl:m,scene:Y.main,camera:r.camera,requestRender:()=>a.requestRender(),cameraOriginWorld:D?S.eye:void 0,focalWorld:S.focal},{fadeMs:U,seatLabel:N,disclosure:V,disclosurePrefix:D?"Live seat-eye view":"360\xB0 panorama",onClose:A,signal:E.signal}):null;if(p()||w!==f()){E.abort(),x(!1),b()===E&&y(null),X?.dispose(),B.style.display="",P();return}if(X)r.syncFromCamera(),F.setVisible(!1),v(!1),a.requestRender(),u(X);else if(D){P(),B.style.display="",v(!1),r.resumeAfterFlight(S.focal),a.requestRender(),u(null),x(!1),o.panoramaFailed(_,"mount");let j=H(_,f(),!0);requestAnimationFrame(()=>j?.querySelector("[data-panorama-trigger]")?.focus()),b()===E&&y(null);return}else x(!1),o.panoramaFallback(_),u(Hn(e,T,{fadeMs:U,seatLabel:N,disclosure:V,onClose:A,signal:E.signal}));o.panoramaOpened()}}var _r=()=>typeof performance<"u"&&performance.now?performance.now():Date.now(),Ut=class{constructor(e){this.orbitLatched=!1;this.panoramaOpenedAt=0;this.cb=e}emit(e,n){if(this.cb)try{this.cb(e,n)}catch{}}opened(e,n,i,o){this.emit("3d_opened",{seats:e,hasHeights:n,...i===void 0?{}:{buildMs:Math.round(i)},...o===void 0?{}:{prepSource:o}})}orbitEngaged(){this.orbitLatched||(this.orbitLatched=!0,this.emit("3d_orbit_engaged"))}seatPicked(e,n){this.emit("3d_seat_picked",{seatId:e,sectionId:n})}cinematicPlayed(e){this.emit("3d_cinematic_played",{durationMs:e,reducedMotion:!1})}cinematicSkipped(){this.emit("3d_cinematic_skipped",{reducedMotion:!0})}cinematicCancelled(){this.emit("3d_cinematic_cancelled")}panoramaOpened(){this.panoramaOpenedAt=_r(),this.emit("3d_panorama_opened")}panoramaClosed(){let e=this.panoramaOpenedAt?Math.round(_r()-this.panoramaOpenedAt):0;this.panoramaOpenedAt=0,this.emit("3d_panorama_closed",{viewMs:e})}panoramaFailed(e,n){this.emit("3d_panorama_failed",{seatId:e,phase:n})}panoramaFallback(e){this.emit("3d_panorama_fallback",{seatId:e})}contextLost(){this.emit("3d_context_lost")}contextRestored(){this.emit("3d_context_restored")}};function Or(t){let e=t.style.position;return getComputedStyle(t).position!=="static"?()=>{}:(t.style.position="relative",()=>{t.style.position==="relative"&&(t.style.position=e)})}function Br(t){let{container:e,model:n,opts:i,expandedSeatById:o,seatIdsByRow:r,isNarrow:a}=t,s=null,l=()=>{if(!s)return;let m=a();Object.assign(s.style,m?{left:"12px",right:"12px",bottom:"70px",transform:"none",justifyContent:"center"}:{left:"50%",right:"auto",bottom:"18px",transform:"translateX(-50%)",justifyContent:"initial"})},c=()=>{s?.remove(),s=null};return{show:(m,d,p=!1)=>{if(c(),t.isDisposed())return null;let f=document.createElement("div");f.setAttribute("role","group"),Object.assign(f.style,{position:"absolute",display:"flex",flexDirection:"column",alignItems:"center",gap:"6px",zIndex:"4"});let u=o.get(m),b=u?.sectionId?n.sections.find(O=>O.id===u.sectionId):void 0,y=u?.label??m;f.setAttribute("aria-label",`Explore views near ${b?.label?`${b.label}, `:""}seat ${y}`);let x=document.createElement("span");x.textContent=["Live 3D seat view",b?.label,y].filter(Boolean).join(" \xB7 "),Object.assign(x.style,{maxWidth:"min(320px, calc(100vw - 32px))",padding:"5px 10px",borderRadius:"999px",overflow:"hidden",color:"#d9e3f5",background:"rgba(12,18,32,0.72)",font:"600 11px/1.2 inherit",textOverflow:"ellipsis",whiteSpace:"nowrap",backdropFilter:"blur(6px)"}),f.appendChild(x);let v=document.createElement("div");Object.assign(v.style,{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px"}),f.appendChild(v);let k=u?.rowId?r.get(u.rowId):void 0,P=k?.indexOf(m)??-1,M=P>=0?[k?.[P-1],k?.[P+1]]:[void 0,void 0],F=(O,L,H,_=!1)=>{let g=document.createElement("button");g.type="button",g.textContent=O,g.setAttribute("aria-label",L),Object.assign(g.style,{minHeight:"44px",padding:_?"10px 16px":"10px",borderRadius:"999px",background:"rgba(12,18,32,0.78)",color:"#eef1f8",border:"1px solid rgba(150,165,205,0.4)",backdropFilter:"blur(6px)",font:"600 13px/1 inherit",cursor:"pointer",whiteSpace:"nowrap"}),_||(g.style.minWidth="44px"),_&&(g.dataset.panoramaTrigger=""),g.addEventListener("click",H),v.appendChild(g)};if(M[0]){let O=o.get(M[0])?.label??M[0];F("\u2039",`View previous seat ${O}`,()=>{t.flyToSeat(M[0])})}if(i.getSeatView){let O=i.seatViewActionLabel?.(m)??"Open 360\xB0 panorama";F(p?`\u21BB Retry ${O}`:`\u25C9 ${O}`,`${p?"Retry":O} from seat ${y}`,()=>{if(t.isDisposed()||d!==t.flightGen()){c();return}c(),t.openPanorama(m,400,d)},!0)}if(M[1]){let O=o.get(M[1])?.label??M[1];F("\u203A",`View next seat ${O}`,()=>{t.flyToSeat(M[1])})}return v.childElementCount?(e.appendChild(f),s=f,l(),f):null},remove:c,layout:l}}function Vr(t){let{container:e,orbit:n,isNarrow:i}=t,o=document.createElement("div"),r=!1;o.className="sl-3d-navigation-controls",Object.assign(o.style,{position:"absolute",right:"14px",bottom:"14px",display:"flex",zIndex:"4",flexDirection:"column",alignItems:"flex-end",gap:"7px"});let a=document.createElement("div");a.setAttribute("role","group"),a.setAttribute("aria-label","3D drag mode"),Object.assign(a.style,{display:"flex",flexDirection:"column",gap:"6px",alignItems:"flex-end"});let s=document.createElement("div");s.setAttribute("role","group"),s.setAttribute("aria-label","3D view controls"),Object.assign(s.style,{display:"flex",flexDirection:"column",gap:"6px",alignItems:"flex-end"});let l=document.createElement("button");l.type="button",l.textContent="\u21BB",l.setAttribute("aria-label","Drag to rotate the 3D venue"),l.dataset.tooltip="Rotate venue";let c=document.createElement("button");c.type="button",c.textContent="\u2725",c.setAttribute("aria-label","Drag to move the 3D venue left, right, up or down"),c.dataset.tooltip="Move venue";let h=document.createElement("button");h.type="button",h.textContent="\u2212",h.setAttribute("aria-label","Zoom out of the 3D venue"),h.dataset.tooltip="Zoom out";let m=document.createElement("button");m.type="button",m.textContent="+",m.setAttribute("aria-label","Zoom into the 3D venue"),m.dataset.tooltip="Zoom in";for(let u of[l,c,h,m])u.className="sl-3d-icon-control",Object.assign(u.style,{width:"44px",minWidth:"44px",minHeight:"44px",padding:"9px",border:"1px solid rgba(150,165,205,0.35)",borderRadius:"999px",color:"#c9d4ea",background:"rgba(12,18,32,0.82)",font:"600 17px/1 inherit",backdropFilter:"blur(6px)",cursor:"pointer",whiteSpace:"nowrap"});a.append(l,c),s.append(m,h);let d=u=>{n.setPrimaryDragMode(u);let b=u==="orbit";l.setAttribute("aria-pressed",String(b)),c.setAttribute("aria-pressed",String(!b)),l.style.background=b?"rgba(96,110,150,0.68)":"rgba(12,18,32,0.82)",c.style.background=b?"rgba(12,18,32,0.82)":"rgba(96,110,150,0.68)",o.title=b?"Drag to rotate \xB7 Shift-drag to move":"Drag to move \xB7 Shift-drag to rotate"};l.addEventListener("click",()=>d("orbit")),c.addEventListener("click",()=>d("pan")),h.addEventListener("click",()=>n.zoomBy(1.22)),m.addEventListener("click",()=>n.zoomBy(.82)),o.append(a,s),d("orbit"),e.appendChild(o);let p=()=>{let u=i();o.style.display=r?"none":"flex",o.style.right=u?"12px":"14px",o.style.bottom=u?"calc(env(safe-area-inset-bottom, 0px) + 76px)":"14px",a.style.display=u?"none":"flex",m.style.display=u?"none":"",h.style.display=u?"none":""};return p(),{element:o,utilityControls:s,setNavigationMode:d,setSeatViewLocked:u=>{r=u,n.setInteractionEnabled(!u),p()},seatViewLocked:()=>r,layout:p}}function Nr(t){let{glctx:e,orbit:n,model:i,seats:o,opts:r,cinematic:a,analytics:s,seatIdByIndex:l,sectionIdBySeatId:c,tapSlop:h,tapMs:m,cancelFlight:d,focusSectionCamera:p,setSelection:f,ensureSeatView:u}=t,b=0,y=0,x=0,v=-1,k=!1,P=!1,M=_=>{t.seatViewLocked()||v===-1&&(v=_.pointerId,b=_.clientX,y=_.clientY,x=performance.now(),k=!1,P=a.active,a.active&&(s.cinematicCancelled(),d(),r.onViewTargetChange?.(null)))},F=_=>{_.pointerId===v&&Math.hypot(_.clientX-b,_.clientY-y)>h&&(k=!0)},O=(_,g,w,E,C)=>{let N=e.canvas.getBoundingClientRect(),S=e.canvas.clientWidth||N.width||1,I=e.canvas.clientHeight||N.height||1,T=_-N.left,B=g-N.top,A=E*E,D=-1,V=A,U=1/0;for(let Y of o){if(w&&Y.sectionId!==w)continue;let X=i.seats.idToIndex.get(Y.id);if(X===void 0)continue;if(C){let ae=Math.round(i.seats.iState[X]??0);if(ae!==0&&ae!==3)continue}let j=X*3,Z=Oe(n.camera.projectionViewMatrix,[i.seats.iPosition[j],i.seats.iPosition[j+1]+.55,i.seats.iPosition[j+2]],S,I);if(!Z.visible)continue;let te=Z.x-T,ne=Z.y-B,Q=te*te+ne*ne;(Q<V||Math.abs(Q-V)<1&&Z.depth<U)&&(D=X,V=Q,U=Z.depth)}return D},L=(_,g)=>{let w=t.gpu(),E=t.pick();if(!w||!E)return-1;E.syncFromSeatProgram(w.seatProgram);let C=e.canvas.getBoundingClientRect(),N=e.renderer.dpr,{x:S,y:I}=vr(_,g,C,N,e.gl.drawingBufferWidth,e.gl.drawingBufferHeight),T=Math.max(2,Math.round(8*N));return E.pick(n.camera,S,I,T)};return{onDown:M,onMove:F,onUp:_=>{if(_.pointerId!==v)return;let g=!k&&performance.now()-x<m;if(v=-1,P){P=!1;return}let w=t.gpu(),E=t.pick();if(!g||!w||!E)return;let C=L(_.clientX,_.clientY);if(t.focusedSectionId()&&C>=0){let I=l[C],T=I?c.get(I):void 0;if(T&&T!==t.focusedSectionId()&&p(T))return}if(t.focusedSectionId()&&C<0&&(C=O(_.clientX,_.clientY,t.focusedSectionId(),44,!1)),t.focusedSectionId()&&C<0){let I=O(_.clientX,_.clientY,null,72,!1),T=I>=0?l[I]:void 0,B=T?c.get(T):void 0;if(B&&B!==t.focusedSectionId()&&p(B))return}if(!t.focusedSectionId()){C<0&&(C=O(_.clientX,_.clientY,null,42,!1));let I=C>=0?l[C]:void 0,T=I?c.get(I):void 0;if(T&&p(T))return}if(C<0||C>=l.length){t.selection().size&&(f([]),r.onViewTargetChange?.(null));return}let N=l[C],S=be[Math.round(i.seats.iState[C]??0)]??"available";if(S!=="available"&&S!=="selected"){r.onSeatInspect?.(N,S);return}if(t.selection().has(N)&&t.selection().size===1){f([]),r.onViewTargetChange?.(null);return}f([N]),u(N),s.seatPicked(N,c.get(N)),r.onSeatPick?.(N)}}}var Xt=class{constructor(e,n){this.minX=0;this.minZ=0;this.cell=1;this.cols=1;this.rows=1;this.cellStart=null;this.cellItems=null;this.iPosition=e,this.count=n}ensureGrid(){if(this.cellStart||this.count===0)return;let e=this.iPosition,n=1/0,i=1/0,o=-1/0,r=-1/0;for(let p=0;p<this.count;p++){let f=e[p*3],u=e[p*3+2];f<n&&(n=f),f>o&&(o=f),u<i&&(i=u),u>r&&(r=u)}let a=Math.max(o-n,.001),s=Math.max(r-i,.001);this.cell=Math.max(Math.sqrt(a*s*4/this.count),.25),this.cols=Math.max(1,Math.ceil(a/this.cell)+1),this.rows=Math.max(1,Math.ceil(s/this.cell)+1),this.minX=n,this.minZ=i;let l=this.cols*this.rows,c=new Int32Array(l+1),h=p=>{let f=Math.min(this.cols-1,Math.max(0,Math.floor((e[p*3]-n)/this.cell)));return Math.min(this.rows-1,Math.max(0,Math.floor((e[p*3+2]-i)/this.cell)))*this.cols+f};for(let p=0;p<this.count;p++)c[h(p)+1]++;for(let p=0;p<l;p++)c[p+1]+=c[p];let m=new Int32Array(this.count),d=c.slice(0,l);for(let p=0;p<this.count;p++)m[d[h(p)]++]=p;this.cellStart=c,this.cellItems=m}gather(e,n,i,o){this.ensureGrid();let r=this.cellStart,a=this.cellItems;if(!r||!a)return 0;let s=o.length,l=i*i,c=Math.floor((e-this.minX)/this.cell),h=Math.floor((n-this.minZ)/this.cell),m=Math.ceil(i/this.cell)+1,d=this.iPosition,p=0;for(let f=0;f<=m&&p<s;f++){let u=h-f,b=h+f,y=c-f,x=c+f;for(let v=u;v<=b&&p<s;v++){if(v<0||v>=this.rows)continue;let k=v===u||v===b;for(let P=y;P<=x&&p<s;P++){if(!k&&P!==y&&P!==x){P=x-1;continue}if(P<0||P>=this.cols)continue;let M=v*this.cols+P;for(let F=r[M],O=r[M+1];F<O&&p<s;F++){let L=a[F],H=d[L*3]-e,_=d[L*3+2]-n;H*H+_*_<=l&&(o[p++]=L)}}}}return p}};var Yt=class{constructor(e){this.ctx=e;this.detailVisible=!1;this.seatDetailMix=0;this.structureDetailMix=0;this.nearBuf=new Int32Array(It);this.lastGatherX=1/0;this.lastGatherZ=1/0;this.nearIndex=new Xt(e.model.seats.iPosition,e.model.seats.count)}forceRegather(){this.lastGatherX=1/0}setDetailEnabled(e){let n=this.ctx.gpu();e||(this.detailVisible=!1),this.lastGatherX=1/0,this.lastGatherZ=1/0,!e&&n?.nearSeatCount()&&n.setNearSeats(this.nearBuf,0)}update(e){let{model:n}=this.ctx,i=this.ctx.gpu();if(!i)return;if(!e){i.nearSeatCount()&&i.setNearSeats(this.nearBuf,0);return}let o=this.ctx.orbit().camera.position;if(Math.hypot(o.x-this.lastGatherX,o.z-this.lastGatherZ)<tn)return;if(this.lastGatherX=o.x,this.lastGatherZ=o.z,Math.hypot(o.x-n.bounds.center[0],o.z-n.bounds.center[2])-n.bounds.radius>en){i.nearSeatCount()&&i.setNearSeats(this.nearBuf,0);return}let s=this.nearIndex.gather(o.x,o.z,en,this.nearBuf);s===0&&i.nearSeatCount()===0||i.setNearSeats(this.nearBuf,s)}ease(e,n,i){let o=1-Math.exp(-e*9),r=1-Math.exp(-e*20);this.seatDetailMix+=(n-this.seatDetailMix)*(n>this.seatDetailMix?o:r),this.structureDetailMix+=(i-this.structureDetailMix)*(i>this.structureDetailMix?o:r),Math.abs(n-this.seatDetailMix)<.01&&(this.seatDetailMix=n),Math.abs(i-this.structureDetailMix)<.01&&(this.structureDetailMix=i)}};import{Quat as es,Vec3 as ts}from"ogl";function zr(t){let{container:e,model:n,opts:i,orbit:o,cinematic:r,analytics:a,loop:s,labelOverlay:l,stageAzimuth:c,overviewFraming:h}=t,m=0,d=-1,p=(P,M,F=28)=>{o.camera.position.set(P[0],P[1],P[2]),o.camera.lookAt(new ts(M[0],M[1],M[2])),o.camera.fov=F,o.camera.updateProjectionMatrix()},f=document.createElement("button");f.className="sl-3d-overview-control sl-3d-icon-control",f.type="button",f.textContent="\u2302",f.setAttribute("aria-label","Fit the active level or whole venue in view"),f.dataset.tooltip="Fit view",Object.assign(f.style,{width:"44px",minWidth:"44px",minHeight:"44px",padding:"9px",borderRadius:"999px",background:"rgba(12,18,32,0.72)",color:"#c9d4ea",border:"1px solid rgba(150,165,205,0.35)",backdropFilter:"blur(6px)",font:"600 11px/1 inherit",cursor:"pointer",whiteSpace:"nowrap"});let u=()=>{f.textContent="\u2302"};u();let b=P=>{d=P;let M=t.gpu();M&&(M.seatProgram.uniforms.uFocusFloor.value=P,M.solidProgram.uniforms.uFocusFloor.value=P,M.chairProgram.uniforms.uFocusFloor.value=P),t.showSectionSeatLabels(null)},y=()=>{if(t.isDisposed())return;i.onViewTargetChange?.(null),i.onSectionFocusChange?.(null),t.panorama()&&(t.panorama().dispose(),t.setPanorama(null),a.panoramaClosed()),t.setPanoramaSphereVisible(!1),t.panoramaLoadAbort()?.abort(),t.setPanoramaLoadAbort(null),t.restorePanoramaLayer(),f.style.display="",l.setVisible(!0),t.setFrozen(!1);let P=d>=0?n.floors[d]:null;if(t.setNearFieldDetailEnabled(!!P),t.setSeatViewLocked(!1),x(),t.removeArriveChip(),t.setNavigationMode("orbit"),P){let M=P.focalWorld[0]-P.center[0],F=P.focalWorld[2]-P.center[2],O=Math.hypot(M,F)>P.radius*.12?Math.atan2(M,F):c,L={center:P.center,radius:P.radius,box:P.box},H={polarDeg:58,margin:1.12};t.reducedMotion()?o.frame(L,!1,O,!1,H):o.frameSoft(L,O,!1,H)}else t.reducedMotion()?o.frame(n.bounds,!1,c,i.portraitOverviewCrop===!0,h):o.frameSoft(n.bounds,c,i.portraitOverviewCrop===!0,h);t.showSectionSeatLabels(null),s.requestRender()},x=()=>{m++,t.panoramaLoadAbort()?.abort(),t.setPanoramaLoadAbort(null),r.active&&(r.cancel(),o.resumeAfterFlight(n.focalWorld))},v=P=>{if(t.isDisposed()||!t.gpu())return Promise.resolve();let M=n.seats.idToIndex.get(P);if(M===void 0)return Promise.resolve();t.setNearFieldDetailEnabled(!0),i.onViewTargetChange?.(P),t.panorama()&&(t.panorama().dispose(),t.setPanorama(null),t.setPanoramaSphereVisible(!1),f.style.display="",t.restorePanoramaLayer()),t.panoramaLoadAbort()?.abort(),t.setPanoramaLoadAbort(null),t.setFrozen(!1),t.setSeatViewLocked(!1);let F=++m;t.removeArriveChip();let{eye:O,focal:L}=t.resolvedSeatViewPose(P,M),H=[o.camera.position.x,o.camera.position.y,o.camera.position.z],_=Mn(H,O,L,n.bounds.center,n.bounds.radius),g=i.arriveAtSeatEye?O:_.finalPos,w=i.arriveAtSeatEye?e.clientWidth/Math.max(1,e.clientHeight)<.7?90:65:28,E=[_.waypoints[0],_.waypoints[1],g];if(l.setVisible(!1),t.reducedMotion())return p(g,L,w),s.requestRender(),a.cinematicSkipped(),t.isDisposed()||o.syncFromCamera(),t.setSeatViewLocked(i.arriveAtSeatEye===!0),t.showArriveChip(P,F),Promise.resolve();let C=new es().copy(o.camera.quaternion),N=Ir(o.camera,g,L);return s.requestRender(),r.start(E,C,N,2500,w).then(()=>{t.isDisposed()||F!==m||(a.cinematicPlayed(2500),o.resumeAfterFlight(L),t.setSeatViewLocked(i.arriveAtSeatEye===!0),s.requestRender(),t.showArriveChip(P,F))})},k=P=>{let M=n.sections.find(H=>H.id===P);if(!M||M.seatCount===0)return!1;t.setNearFieldDetailEnabled(!0),t.setSeatViewLocked(!1),r.cancel(),t.removeArriveChip(),n.floors.length>1&&d!==M.floorIndex&&b(M.floorIndex),t.setNavigationMode("pan"),t.showSectionSeatLabels(P);let F=M.focalWorld[0]-M.center[0],O=M.focalWorld[2]-M.center[2],L=Math.hypot(F,O)>M.radius*.12?Math.atan2(F,O):void 0;return o.frame({center:M.center,radius:Math.max(5,M.radius*.5)},!1,L),i.onSectionFocusChange?.(P),s.requestRender(),!0};return f.addEventListener("click",y),{overviewChip:f,layoutOverviewChip:u,flightGen:()=>m,focusedFloor:()=>d,applyFloorFocus:b,placeCameraFinal:p,cancelFlight:x,focusOverview:y,flyToSeat:v,focusSectionCamera:k}}function Gr(t){let e=performance.now();return{model:yt(t),buildMs:performance.now()-e,source:"main"}}function ns(t){return typeof Worker>"u"?Promise.resolve(Gr(t)):new Promise(e=>{let n=new Worker(new URL("./scene/scene.worker.ts",import.meta.url),{type:"module"}),i=!1,o=s=>{i||(i=!0,clearTimeout(a),n.terminate(),e(s))},r=()=>o(Gr(t)),a=window.setTimeout(r,15e3);n.onerror=r,n.onmessage=s=>{o({model:s.data.model,buildMs:s.data.buildMs,source:"worker"})},n.postMessage(t)})}var os=Math.PI/180,rs=6,is=500;function Nu(t,e,n={}){let i=performance.now(),o=e.prepared?.model??yt(e),r=new Ut(n.onAnalytics),a=new Array(o.seats.count);for(let[z,G]of o.seats.idToIndex)a[G]=z;let s=new Map(e.seats.map(z=>[z.id,z])),l=new Map;for(let z of e.seats){if(!z.rowId)continue;let G=l.get(z.rowId);G?G.push(z.id):l.set(z.rowId,[z.id])}let c=new Map;for(let z of e.seats)c.set(z.id,z.sectionId);let h=e.doc.floors?.some(G=>(G.baseHeightM??0)>0)?!0:(e.doc.floors?.flatMap(G=>G.objects)??e.doc.objects).some(G=>G.type==="section"&&((G.height??0)>0||(G.rake??0)>0)),m=null,d=null,p=!1,f=!1,u=!1,b=new Map,y=null,x=null,v=null,k=new Map,P=null,M=()=>{v===null&&(v=t.style.zIndex,t.style.zIndex="20")},F=()=>{v!==null&&(t.style.zIndex==="20"&&(t.style.zIndex=v),v=null)},O=!1,L=()=>O?me.focusedFloor():-1,H=()=>{m=xr(E.gl,o),d=new Gt(E.renderer,m.seatGeometry,m.chairGeometry,m.solidGeometry,o.seats.count),E.setClearColor(o.theme.background.top),d.setRestoreClear(o.theme.background.top),m.seatProgram.uniforms.uSeatRadius.value=Re*o.theme.seatScale,m.seatProgram.uniforms.uFocusFloor.value=L(),m.solidProgram.uniforms.uFocusFloor.value=L(),m.chairProgram.uniforms.uFocusFloor.value=L(),g.forceRegather()},_=!1,g=new Yt({model:o,orbit:()=>C,gpu:()=>m}),w=z=>g.setDetailEnabled(z),E=new At(t,{onContextLost:()=>{u||r.contextLost(),p=!0,j.stop(),m=null,d=null},onContextRestored:()=>{H(),p=!1,u||r.contextRestored(),j.requestRender()}}),C=new Ct(E.gl,E.canvas,()=>j.requestRender(),()=>r.orbitEngaged());C.setAspect(E.aspect);let N=(e.doc.floors?.flatMap(z=>z.objects)??e.doc.objects).some(z=>z.type==="section"&&z.physical3dProvenance?.surfaceKind?.status==="inferred"),S=(()=>{if(N&&o.stages.length===0)return;let z=o.focalWorld[0]-o.bounds.center[0],G=o.focalWorld[2]-o.bounds.center[2];return Math.hypot(z,G)>o.bounds.radius*.12?Math.atan2(z,G):void 0})(),I=o.floors.length>1?{polarDeg:48,margin:1.1}:void 0,T=typeof window<"u"&&!!window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;C.frame(o.bounds,!T&&n.skipInitialOverviewAnimation!==!0,S,n.portraitOverviewCrop===!0,I);let B=new Ht(C.camera),A=Or(t),D=new Bt(t,{fontFamily:e.doc.theme?.fontFamily,ink:e.doc.theme?.textColor,backgroundRgb:o.theme.background.top}),V=o.labels,U=()=>Go(V,o.floors.length,L());D.setLabels(U());let Y=null,X=z=>{if(Y=z,D.setForcedDense(!!z),!z){D.setLabels(U());return}let G=e.seats.filter(q=>q.sectionId===z),W=new Set(G.map(q=>q.id)),$=new Set(G.map(q=>q.rowId)),ee=new Set(b.keys()),J=new Set(G.filter(q=>ee.has(q.id)).map(q=>q.id)),se=U().filter(q=>q.kind!=="row"&&q.kind!=="seat"||(q.kind==="row"?$.has(q.id.slice(4)):W.has(q.id.slice(5))&&(J.size===0||J.has(q.id.slice(5)))));if(o.seatCount<=6e3&&J.size===0){D.setLabels(se);return}let le=J.size?G.filter(q=>J.has(q.id)):G,ze=new Set(le.map(q=>`seat:${q.id}`)),De=le.flatMap(q=>{let de=o.seats.idToIndex.get(q.id);if(de===void 0)return[];let ge=de*3;return[{id:`seat:${q.id}`,kind:"seat",text:q.displayLabel||q.label,anchor:[o.seats.iPosition[ge],o.seats.iPosition[ge+1]+(ee.has(q.id)?1.05:.55),o.seats.iPosition[ge+2]]}]});D.setLabels([...se.filter(q=>!ze.has(q.id)),...De])};H();let j=new Rt(z=>{if(p||!m||f)return!1;let W=B.active?B.update(performance.now()):C.update(),$=L()>=0?o.floors[L()]:null,ee=$?.radius??o.bounds.radius,J=Qn(C.currentDistance,ee),se=_?{center:[C.camera.position.x,C.camera.position.y,C.camera.position.z],radius:520}:o.renderBounds;C.updateClipping(se);let le=$?.center??o.renderBounds.center,ze=$?.radius??o.renderBounds.radius,De=(ve,rt)=>Math.hypot(C.camera.position.x-ve[0],C.camera.position.y-ve[1],C.camera.position.z-ve[2])<=rt*(g.detailVisible?1.8:1.55),q=De(le,ze);if(!q&&Y){let ve=o.sections.find(rt=>rt.id===Y);ve&&(q=De(ve.center,Math.max(12,ve.radius*2)))}g.detailVisible=q;let de=m.seatProgram.uniforms;de.uSeatScale.value=J.scale,de.uSeatFade.value=J.fade;let ge=!!$&&$n($.seatCount,E.canvas.clientWidth||1,E.canvas.clientHeight||1),gt=Jn(o.seats.count,ee,C.currentDistance,C.camera.fov,E.canvas.clientHeight||1),ot=g.detailVisible||ge||gt?1:0,vt=g.detailVisible||L()>=0||o.floors.length>1?1:0;return g.ease(z,ot,vt),de.uSeatDetail.value=g.seatDetailMix,m.solidProgram.uniforms.uStructureDetail.value=g.structureDetailMix,de.uMinPixels.value=J.minPixels,de.uPixelToWorld.value=2*Math.tan(C.camera.fov*os/2)/Math.max(1,E.pixelHeight),g.update(g.detailVisible),E.renderer.render({scene:m.background,clear:!0}),E.renderer.render({scene:m.main,camera:C.camera,clear:!1}),D.update(C.camera.projectionViewMatrix,E.canvas.clientWidth||1,E.canvas.clientHeight||1,C.currentDistance,ee,[C.camera.position.x,C.camera.position.y,C.camera.position.z]),W||g.seatDetailMix!==ot||g.structureDetailMix!==vt}),Z=typeof ResizeObserver<"u"?new ResizeObserver(()=>jt.resize()):null;Z?.observe(t);let te=z=>{let G=ee=>{let J=o.seats.idToIndex.get(ee);return J===void 0?void 0:o.seats.iState[J]},{updates:W,next:$}=Sr(b,z,G);if(b=$,D.setSelectedSeatIds(b.keys()),Y&&X(Y),W.length){let ee=an(o.seats,W);m&&m.uploadSeatStateRuns(ee),j.requestRender()}},ne=()=>P!==null?P:typeof window<"u"&&!!window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,Q=8,ae=z=>{if(!n.getSeatView)return null;let G=k.get(z);if(!G)for(G=Promise.resolve(n.getSeatView(z)),k.set(z,G),G.catch(()=>{k.get(z)===G&&k.delete(z)});k.size>Q;){let W=k.keys().next().value;if(W===void 0)break;k.delete(W)}return G},Be=(z,G)=>{let W=s.get(z),$=Math.max(0,Math.round(o.seats.iFloor[G]??0)),ee=e.doc.floors?.[$],J=o.floors[$],se=ee?.focalPoint??e.doc.focalPoint,le=J?{x:J.focalWorld[0]/R,y:J.focalWorld[2]/R}:se,ze=W?.focalPoint?{x:W.focalPoint.x+le.x-se.x,y:W.focalPoint.y+le.y-se.y}:le,De=[o.seats.iPosition[G*3],o.seats.iPosition[G*3+1],o.seats.iPosition[G*3+2]];return Tr(De,ze,ee?.baseHeightM??0,W?.eyeHeightM)},Ve=()=>(t.clientWidth||E.canvas.clientWidth)<=520,Se,we=Br({container:t,model:o,opts:n,expandedSeatById:s,seatIdsByRow:l,isNarrow:Ve,isDisposed:()=>u,flightGen:()=>me.flightGen(),flyToSeat:z=>Pn(z),openPanorama:(z,G,W)=>Se(z,G,W)}),Pe=we.show,ye=we.remove,xe=we.layout,oe=Vr({container:t,orbit:C,isNarrow:Ve}),qe=oe.element,Fe=oe.setNavigationMode,Ae=oe.setSeatViewLocked,Ne=oe.layout,nt=oe.utilityControls,me=zr({container:t,model:o,opts:n,orbit:C,cinematic:B,analytics:r,loop:j,labelOverlay:D,stageAzimuth:S,overviewFraming:I,gpu:()=>m,isDisposed:()=>u,panorama:()=>y,setPanorama:z=>{y=z},setPanoramaSphereVisible:z=>{_=z},panoramaLoadAbort:()=>x,setPanoramaLoadAbort:z=>{x=z},setFrozen:z=>{f=z},restorePanoramaLayer:F,reducedMotion:ne,resolvedSeatViewPose:Be,showSectionSeatLabels:X,setNearFieldDetailEnabled:w,setSeatViewLocked:Ae,setNavigationMode:Fe,showArriveChip:Pe,removeArriveChip:ye});O=!0;let Wt=me.overviewChip,Hr=me.layoutOverviewChip,Ur=me.applyFloorFocus,Xr=me.focusOverview,wn=me.cancelFlight,Pn=me.flyToSeat,An=me.focusSectionCamera;nt.appendChild(Wt),Se=Lr({container:t,model:o,opts:n,analytics:r,orbit:C,loop:j,seatsById:s,ensureSeatView:ae,resolvedSeatViewPose:Be,gpu:()=>m,gl:E.gl,isContextLost:()=>p,isDisposed:()=>u,flightGen:()=>me.flightGen(),setPanorama:z=>{y=z},getLoadAbort:()=>x,setLoadAbort:z=>{x=z},setPanoramaSphereVisible:z=>{_=z},setFrozen:z=>{f=z},raisePanoramaLayer:M,restorePanoramaLayer:F,getOverviewChip:()=>Wt,labelOverlay:D,reducedMotion:ne,removeArriveChip:ye,showArriveChip:Pe});let Ee=Nr({glctx:E,orbit:C,model:o,seats:e.seats,opts:n,cinematic:B,analytics:r,seatIdByIndex:a,sectionIdBySeatId:c,tapSlop:rs,tapMs:is,gpu:()=>m,pick:()=>d,seatViewLocked:()=>oe.seatViewLocked(),focusedSectionId:()=>Y,selection:()=>b,cancelFlight:wn,focusSectionCamera:An,setSelection:te,ensureSeatView:ae});E.canvas.addEventListener("pointerdown",Ee.onDown),E.canvas.addEventListener("pointermove",Ee.onMove),E.canvas.addEventListener("pointerup",Ee.onUp),E.canvas.addEventListener("pointercancel",Ee.onUp),j.requestRender();let jt={setAvailability(z){let G=Mr(b,z),W=an(o.seats,G);W.length&&m&&m.uploadSeatStateRuns(W),j.requestRender()},setSelection:te,flyToSeat:Pn,focusOverview:Xr,resize(){let{width:z,height:G}=E.resize();C.setAspect(z/Math.max(1,G)),xe(),Ne(),Hr(),j.requestRender()},stats(){return{...j.stats(),drawCalls:m?m.drawCalls:0,seatCount:o.seatCount}},getQualityEvidence(){let z=j.stats(),G=E.canvas.clientWidth||1,W=E.canvas.clientHeight||1,$=o.bounds.center,ee=Oe(C.camera.projectionViewMatrix,[$[0],o.bounds.box.min[1],$[2]],G,W),J=Oe(C.camera.projectionViewMatrix,[$[0],o.bounds.box.max[1],$[2]],G,W),se=o.bounds.box,le=[se.min[0],se.max[0]].flatMap(q=>[se.min[1],se.max[1]].flatMap(de=>[se.min[2],se.max[2]].map(ge=>Oe(C.camera.projectionViewMatrix,[q,de,ge],G,W)))).filter(q=>Number.isFinite(q.x)&&Number.isFinite(q.y)&&Number.isFinite(q.depth)),ze=le.length?(()=>{let q=Math.min(...le.map(Ge=>Ge.x)),de=Math.max(...le.map(Ge=>Ge.x)),ge=Math.min(...le.map(Ge=>Ge.y)),gt=Math.max(...le.map(Ge=>Ge.y)),ot=Math.max(0,q),vt=Math.min(G,de),ve=Math.max(0,ge),rt=Math.min(W,gt),Mt=Math.max(0,vt-ot),qt=Math.max(0,rt-ve);return{box:{x:ot,y:ve,width:Mt,height:qt},horizontalFillRatio:Mt/G,verticalFillRatio:qt/W,visibleAreaRatio:Mt*qt/(G*W),clippedEdges:[...ge<0?["top"]:[],...de>G?["right"]:[],...gt>W?["bottom"]:[],...q<0?["left"]:[]]}})():void 0,De=String(E.gl.getParameter(E.gl.VERSION)??"");return{viewport:{width:G,height:W},context:{webgl2:/webgl\s*2/i.test(De),lost:p},frame:{rendered:z.rendered,idle:z.idle},camera:{position:[C.camera.position.x,C.camera.position.y,C.camera.position.z],distance:C.currentDistance,verticalFovDeg:C.fovY},scene:{seatCount:o.seatCount,floorCount:o.floors.length,zoneCount:o.zones.length,sectionCount:o.sections.length,authoredRelief:h,renderedVerticalSpanM:Math.max(0,o.bounds.box.max[1]-o.bounds.box.min[1]),projectedReliefPx:ee.visible&&J.visible?Math.abs(ee.y-J.y):0},labels:D.qualityEvidence(),framing:ze}},getQualityReport(){return bn(jt.getQualityEvidence())},loseContextForTest(){E.simulateContextLossCycle()},floors(){return o.floors},focusFloor(z){if(z!==null&&!o.floors.some(W=>W.index===z))return!1;let G=z??-1;if(w(z!==null),Ae(!1),Ur(G),Fe("orbit"),z===null)B.cancel(),ne()?C.frame(o.bounds,!1,S,n.portraitOverviewCrop===!0,I):C.frameSoft(o.bounds,S,n.portraitOverviewCrop===!0,I);else{let W=o.floors[z];if(W.seatCount>0){B.cancel();let $=W.focalWorld[0]-W.center[0],ee=W.focalWorld[2]-W.center[2],J=Math.hypot($,ee)>W.radius*.12?Math.atan2($,ee):S;C.frame({center:W.center,radius:W.radius,box:W.box},!1,J,!1,{polarDeg:58,margin:1.12})}}return j.requestRender(),!0},zones(){return o.zones},focusZone(z){let G=o.zones.find(J=>J.id===z);if(!G||G.seatCount===0)return!1;w(!1),Ae(!1),B.cancel(),Fe("orbit"),X(null),n.onSectionFocusChange?.(null);let W=G.focalWorld[0]-G.center[0],$=G.focalWorld[2]-G.center[2],ee=Math.hypot(W,$)>G.radius*.12?Math.atan2(W,$):void 0;return C.frame({center:G.center,radius:G.radius*1.25},!1,ee),j.requestRender(),!0},sections(){return o.sections},focusSection(z){return An(z)},rows(z){return z?o.rows.filter(G=>G.sectionId===z):o.rows},seatsInRow(z){return e.seats.filter(G=>G.rowId===z).map(G=>({id:G.id,label:G.displayLabel||G.label}))},focusRow(z){let G=o.rows.find(W=>W.id===z);return!G||G.seatCount===0?!1:(w(!0),Ae(!1),B.cancel(),Fe("pan"),G.sectionId&&(X(G.sectionId),n.onSectionFocusChange?.(G.sectionId)),C.frame({center:G.center,radius:Math.max(2.5,G.radius*.65)}),j.requestRender(),!0)},setReducedMotionForTest(z){P=z},dispose(){u=!0,ye(),Wt.remove(),qe.remove(),wn(),j.stop(),D.dispose(),Z?.disconnect(),y&&(y.dispose(),y=null),F(),A(),E.canvas.removeEventListener("pointerdown",Ee.onDown),E.canvas.removeEventListener("pointermove",Ee.onMove),E.canvas.removeEventListener("pointerup",Ee.onUp),E.canvas.removeEventListener("pointercancel",Ee.onUp),C.dispose(),d&&d.dispose(),m&&m.dispose(),m=null,d=null,E.dispose()}};return r.opened(o.seatCount,h,e.prepared?.buildMs??performance.now()-i,e.prepared?.source??"inline"),jt}export{fa as VENUE3D_QUALITY_REPORT_VERSION,yt as buildSceneModel,bn as inspectVenue3DQualityEvidence,Nu as mountVenue3D,ns as prepareVenue3D};