@seatlayer/core 0.53.0 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/categoryInventory-B4xo7hE2.d.ts +109 -0
- package/dist/categoryInventory-lRtu3VjD.d.cts +109 -0
- package/dist/chunk-3QLFGEQY.js +1 -0
- package/dist/chunk-55NOSZK5.js +1 -0
- package/dist/chunk-6LIPQU4G.js +1 -0
- package/dist/chunk-6VTTBC5F.js +1 -0
- package/dist/chunk-7PT7OQUO.js +1 -0
- package/dist/chunk-AQKYUJBX.js +1 -0
- package/dist/chunk-CXF32VPG.js +1 -0
- package/dist/chunk-DDE7IOFT.js +1 -0
- package/dist/chunk-EQM4FFN5.js +1 -0
- package/dist/chunk-EYROIZGQ.js +1 -0
- package/dist/chunk-QUKWJQLR.js +1 -0
- package/dist/chunk-VDZ24QVV.js +1 -0
- package/dist/core/chart-ops/index.cjs +1 -0
- package/dist/core/chart-ops/index.d.cts +1235 -0
- package/dist/core/chart-ops/index.d.ts +1235 -0
- package/dist/core/chart-ops/index.js +1 -0
- package/dist/core/color.cjs +1 -0
- package/dist/core/color.d.cts +192 -0
- package/dist/core/color.d.ts +192 -0
- package/dist/core/color.js +1 -0
- package/dist/core/inventory/index.cjs +1 -0
- package/dist/core/inventory/index.d.cts +209 -0
- package/dist/core/inventory/index.d.ts +209 -0
- package/dist/core/inventory/index.js +1 -0
- package/dist/core/layout/index.cjs +1 -0
- package/dist/core/layout/index.d.cts +376 -0
- package/dist/core/layout/index.d.ts +376 -0
- package/dist/core/layout/index.js +1 -0
- package/dist/core/quality/index.cjs +1 -0
- package/dist/core/quality/index.d.cts +132 -0
- package/dist/core/quality/index.d.ts +132 -0
- package/dist/core/quality/index.js +1 -0
- package/dist/core/render-assets/index.cjs +1 -0
- package/dist/core/render-assets/index.d.cts +99 -0
- package/dist/core/render-assets/index.d.ts +99 -0
- package/dist/core/render-assets/index.js +1 -0
- package/dist/core/seatConfidence.cjs +1 -1
- package/dist/core/seatConfidence.d.cts +1 -1
- package/dist/core/seatConfidence.d.ts +1 -1
- package/dist/core/seatConfidence.js +1 -1
- package/dist/core/sections/index.cjs +1 -0
- package/dist/core/sections/index.d.cts +346 -0
- package/dist/core/sections/index.d.ts +346 -0
- package/dist/core/sections/index.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +39 -533
- package/dist/index.d.ts +39 -533
- package/dist/index.js +1 -1
- package/dist/labeling-CsPt1mC_.d.cts +90 -0
- package/dist/labeling-w8bl86cb.d.ts +90 -0
- package/dist/layout-B5UYbwnv.d.ts +181 -0
- package/dist/layout-YFmuxw_M.d.cts +181 -0
- package/dist/renderedQuality-CugJarFp.d.cts +113 -0
- package/dist/renderedQuality-DbZM034G.d.ts +113 -0
- package/dist/renderer-DhUHFtsI.d.cts +531 -0
- package/dist/renderer-IBi9YKWR.d.ts +531 -0
- package/dist/sections-B7cDF0Nq.d.cts +123 -0
- package/dist/sections-mLOZrGrI.d.ts +123 -0
- package/dist/segmentedRowModel-BPTnJ7Tz.d.ts +75 -0
- package/dist/segmentedRowModel-CGoH684F.d.cts +75 -0
- package/dist/ticketRestrictions-BwAebpSK.d.cts +72 -0
- package/dist/ticketRestrictions-ChHJwvTq.d.ts +72 -0
- package/dist/{types-tLOunI-B.d.cts → types-COfJorq_.d.cts} +233 -757
- package/dist/{types-tLOunI-B.d.ts → types-COfJorq_.d.ts} +233 -757
- package/dist/view3d/crossfade/panorama.d.cts +1 -1
- package/dist/view3d/crossfade/panorama.d.ts +1 -1
- package/dist/view3d/index.cjs +25 -25
- package/dist/view3d/index.d.cts +2 -1
- package/dist/view3d/index.d.ts +2 -1
- package/dist/view3d/index.js +27 -27
- package/package.json +94 -5
- package/dist/chunk-54A7LIL5.js +0 -1
package/dist/view3d/index.js
CHANGED
|
@@ -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&>(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 In,b as Tn,c as Fn,d as Dn}from"../chunk-55NOSZK5.js";import{a as En,c as kn,d as Ln,e as ge,j as _n}from"../chunk-XPPT3OGQ.js";import{c as An,d as Cn,e as Gt,f as Rn}from"../chunk-IJI4WU57.js";import{e as xn,l as Be,n as nt,o as Pn,q as bt}from"../chunk-DDE7IOFT.js";import{V as Fe,W as De,da as pt,fa as vn,ga as ft,ia as Mn,l as gn,m as et,ta as Sn}from"../chunk-VDZ24QVV.js";import{d as Z,k as wn,x as de,z as tt}from"../chunk-CXF32VPG.js";import{Renderer as Or}from"ogl";var fe=["available","held","sold","selected","dimmed"];function ot(t){let e=fe.indexOf(t);return e<0?0:e}var On={available:[.24,.82,.52],held:[.95,.66,.22],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};function Bn(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 Nt={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]},Ve={top:[.05,.06,.08],bottom:[.1,.12,.15]};function he(t,e){return[Math.min(1,t[0]*e),Math.min(1,t[1]*e),Math.min(1,t[2]*e)]}function Br(){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 yt=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 Or({canvas:this.canvas,dpr:Br(),alpha:!1,antialias:!1,depth:!0,stencil:!1,powerPreference:"high-performance",webgl:2}),this.gl=this.renderer.gl,this.clearRgb=[Ve.top[0],Ve.top[1],Ve.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 Vr,Vec3 as Ht}from"ogl";var le=Math.PI/180,Ut=15*le,Yt=80*le,Xe=.12,Vn=35,zn=1.25,xt=class{constructor(e,n,i,o){this.fovY=Vn;this.target=new Ht;this.azimuth=-30*le;this.polar=55*le;this.distance=10;this.azT=-30*le;this.polT=55*le;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 Ht;this.panAnchor=new Ht;this.panLimit=0;this.primaryDragMode="orbit";this.camera=new Vr(e,{fov:Vn,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(Ut,Math.min(Yt,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*le;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(Ut,Math.min(Yt,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*le/2)/i,r=Math.sin(this.azimuth),a=Math.cos(this.azimuth),s=a,l=-r,c=Math.cos(this.polar),m=Math.sin(this.polar),d=-r*c,f=-a*c;this.targetT.x+=(-e*s+n*d)*o,this.targetT.z+=(-e*l+n*f)*o,this.targetT.y+=n*m*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*le/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*le,this.polT=Math.max(15,Math.min(80,r?.polarDeg??55))*le;let m=this.fitDistance(e,s,c,this.azT,this.polT);this.distT=m*Math.max(1.05,Math.min(2,r?.margin??zn)),this.minDist=Math.max(2,a*.12),this.maxDist=m*4,n?(this.azimuth=this.azT,this.polar=12*le,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*le/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))*le;let l=this.fitDistance(e,r,s,this.azT,this.polT);this.distT=l*Math.max(1.05,Math.min(2,o?.margin??zn))}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),m=-c*Math.sin(o),d=-Math.cos(r),f=-c*Math.cos(o);if(Math.abs(d)>.999)return s;let u=-f,h=m,p=Math.hypot(u,h);u/=p,h/=p;let b=-h*d,x=h*m-u*f,y=u*d,S=Math.tan(i),E=Math.tan(n),A=1;for(let w=0;w<8;w++){let k=(w&1?l.max[0]:l.min[0])-e.center[0],_=(w&2?l.max[1]:l.min[1])-e.center[1],L=(w&4?l.max[2]:l.min[2])-e.center[2],N=k*m+_*d+L*f,O=Math.abs(k*u+L*h),B=Math.abs(k*b+_*x+L*y);A=Math.max(A,O/S-N,B/E-N)}return Math.min(s,Math.max(A,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*Xe,this.polar+=n*Xe,this.distance+=i*Xe,this.target.x+=o*Xe,this.target.y+=r*Xe,this.target.z+=a*Xe,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(Ut,Math.min(Yt,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 gt=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 We=2.5,zr=1.15,rt=6,je=10,Gn=6,Nn=9.5,Hn=.9,Un=2.2,Xt=30,Wt=4,vt=8192;var ns=je+Wt;function Yn(t,e){let n=e*1.4,i=e*3.2;if(t<=n)return{scale:1,fade:0,minPixels:We};let o=Math.min(1,(t-n)/Math.max(.001,i-n));return{scale:1-o*.4,fade:o*.55,minPixels:We+o*(zr-We)}}function Xn(t,e,n){return!(t>0)||!(e>0)||!(n>0)?!1:e*n/t>=64}function Wn(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 Gr from"earcut";import Nr from"polygon-clipping";var R=Fe,Hr=.002;function Ur(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<Hr}var ze=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)}},wt=class{constructor(){this.pos=new ze;this.nor=new ze;this.col=new ze;this.flr=new ze;this.mat=new ze;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){Ur(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 Yr(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,m=r*a-i*l,d=i*s-o*a,f=Math.hypot(c,m,d)||1;return c/=f,m/=f,d/=f,[c,m,d]}function Xr(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=Gr(i,o.length?o:void 0,2);return{pts:n,tris:r}}function jt(t){return Be(t)<0?[...t].reverse():t}var Wr=3;function jr(t,e,n,i){let o=i(t),r=i(e),a=i(n),s=(u,h,p,b)=>Math.abs(i({x:(u.x+h.x)/2,y:(u.y+h.y)/2})-(p+b)/2),l=(t.x+e.x+n.x)/3,c=(t.y+e.y+n.y)/3,m=(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:l,y:c})-m)),f=(u,h,p)=>{let b=Math.abs(i({x:(u+l)/2,y:(h+c)/2})-(p+m)/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 it(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(it(t,r,s,i,o-1),it(r,e,a,i,o-1),it(s,a,n,i,o-1),it(r,a,s,i,o-1))}function at(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},u={x:(n.x+i.x)/2,y:(n.y+i.y)/2},h={x:(i.x+e.x)/2,y:(i.y+e.y)/2};at(t,e,f,h,o,r,a-1,s),at(t,f,n,u,o,r,a-1,s),at(t,h,u,i,o,r,a-1,s),at(t,f,u,h,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],m=[i.x*R,o(i),i.y*R];if(s){t.triN(l,c,m,s(e),s(n),s(i),r);return}let d=Yr(l,c,m);d[1]<0&&(d=[-d[0],-d[1],-d[2]]),t.tri(l,c,m,d,r)}var qr=8;function jn(t,e,n){if(!Number.isFinite(n))return t;let i=[],o=(r,a,s,l,c)=>{if(c>0){let m={x:(r.x+a.x)/2,y:(r.y+a.y)/2},d=e(m);if(Math.abs(d-(s+l)/2)>n){o(r,m,s,d,c-1),o(m,a,d,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),qr)}return i}function Mt(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,m=Math.hypot(l,c);m>e&&Math.abs((a.x-r.x)*c-(a.y-r.y)*l)/m<e||i.push(a)}return i.length>=3?i:n}var St=.001*De*.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(Be(e))<1e-4))return;let m=Mt(jn(Mt(jt(e),St),i,l),St),d=n?.map(w=>Mt(jn(Mt(jt(w),St),i,l),St)).filter(w=>w.length>=3&&Math.abs(Be(w))>=1e-4),{pts:f,tris:u}=Xr(m,d),h=[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],x=[a[0]*s.wallBottom,a[1]*s.wallBottom,a[2]*s.wallBottom],y=0;if(Number.isFinite(l))for(;y<Wr;y++){let w=0;for(let k=0;k<u.length;k+=3){let _=it(f[u[k]],f[u[k+1]],f[u[k+2]],i,y);_>w&&(w=_)}if(w<=l)break}for(let w=0;w<u.length;w+=3){let k=f[u[w]],_=f[u[w+1]],L=f[u[w+2]];at(t,k,_,L,i,h,y,c);let N=[k.x*R,o,k.y*R],O=[_.x*R,o,_.y*R],B=[L.x*R,o,L.y*R];t.tri(N,B,O,[0,-1,0],p)}let S=w=>{if(y<=0)return w;let k=1<<y,_=[];for(let L=0;L<w.length;L++){let N=w[L],O=w[(L+1)%w.length];for(let B=0;B<k;B++){let g=B/k;_.push({x:N.x+(O.x-N.x)*g,y:N.y+(O.y-N.y)*g})}}return _},E=gn(m),A=[{ring:S(m),flip:!1}];if(d)for(let w of d)w.length>=3&&A.push({ring:S(w),flip:!0});for(let{ring:w,flip:k}of A)for(let _=0;_<w.length;_++){let L=w[_],N=w[(_+1)%w.length],O=(N.x-L.x)*R,g=(N.y-L.y)*R,M=-O,C=Math.hypot(g,M)||1;g/=C,M/=C;let G=(L.x+N.x)/2-E.x,v=(L.y+N.y)/2-E.y,I=g*G+M*v;k&&(I=-I),I<0&&(g=-g,M=-M);let D=[g,0,M],T=[L.x*R,i(L),L.y*R],P=[N.x*R,i(N),N.y*R],F=[L.x*R,o,L.y*R],V=[N.x*R,o,N.y*R];t.tri(T,P,V,D,b,b,x),t.tri(T,V,F,D,b,x,x)}}function qn(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 Pt(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 l=i[s],c=i[(s+1)%o],m=c.x-l.x,d=c.y-l.y,f=Math.hypot(m,d)||1;r.push({x:d/f,y:-m/f})}let a=[];for(let s=0;s<o;s++){let l=i[s],c=r[(s-1+o)%o],m=r[s],d=c.x+m.x,f=c.y+m.y,u=Math.hypot(d,f),h=()=>{a.push([l.x+c.x*e,l.y+c.y*e]),a.push([l.x+m.x*e,l.y+m.y*e])};if(u<1e-9){h();continue}d/=u,f/=u;let p=d*c.x+f*c.y,b=1/Math.max(p,1e-6);if(!Number.isFinite(b)||b>n){h();continue}a.push([l.x+d*e*b,l.y+f*e*b])}if(a.length<3)return t;try{let s=Nr.union([[...a,a[0]]]),l=null,c=-1/0;for(let d of s){let f=Math.abs(Be(d[0].map(([u,h])=>({x:u,y:h}))));f>c&&(c=f,l=d[0])}if(!l)return t;let m=l.map(([d,f])=>({x:d,y:f}));if(m.length>1){let d=m[0],f=m[m.length-1];Math.abs(d.x-f.x)<1e-9&&Math.abs(d.y-f.y)<1e-9&&m.pop()}return m.length>=3?m:t}catch{return t}}function At(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 st(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 se={pedestal:0,pad:1,back:2,body:3,head:4},Zr=.44,Kr=.15,$r=.3,Qr=.24;function Zn(t){return t===void 0||!Number.isFinite(t)||t<=0?Qr:Math.min($r,Math.max(Kr,t*Zr))}var qt=.21,Jr=.05,Zt=.45,Ct=Zt+Jr,ei=[{part:se.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:se.pad,min:[-1,.36,-.95],max:[1,Zt,1]},{part:se.back,min:[-1,Ct,-1],max:[1,.92,-.72]}],ti=[{part:se.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:se.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:se.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:se.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:se.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}],ni=[{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 Kn(){let t=[],e=[],n=[],i=[],o=(C,G,v)=>{let I=n.length,[D,T,P]=C,F=[T[0]-D[0],T[1]-D[1],T[2]-D[2]],V=[P[0]-D[0],P[1]-D[1],P[2]-D[2]],U=F[1]*V[2]-F[2]*V[1],X=F[2]*V[0]-F[0]*V[2],W=F[0]*V[1]-F[1]*V[0],Y=Math.hypot(U,X,W);Y>1e-9?(U/=Y,X/=Y,W/=Y):[U,X,W]=G,U*G[0]+X*G[1]+W*G[2]<0&&(U=-U,X=-X,W=-W);for(let $ of C)t.push(...$),e.push(U,X,W),n.push(v);i.push(I,I+1,I+2,I,I+2,I+3)},r=C=>{for(let G of ni){let v=G.c.map(I=>I.map((D,T)=>D?C.max[T]:C.min[T]));o(v,G.n,C.part)}};for(let C of ei)r(C);for(let C of ti)r(C);let a=Zt,s=1.08,l=.47,c=.69,m=-.55,d=.08,f=-.48,u=.01,h=[-l,a,m],p=[l,a,m],b=[-l,a,d],x=[l,a,d],y=[-c,s,f],S=[c,s,f],E=[-c,s,u],A=[c,s,u];o([p,S,A,x],[1,0,0],se.body),o([b,E,y,h],[-1,0,0],se.body),o([E,A,S,y],[0,1,0],se.body),o([h,p,x,b],[0,-1,0],se.body),o([x,A,E,b],[0,0,1],se.body),o([h,y,S,p],[0,0,-1],se.body);let w=10,k=8,_=[0,1.205,-.23],L=[.42,.115,.38],N=n.length;for(let C=0;C<=k;C++){let G=Math.PI*C/k,v=Math.cos(G),I=Math.sin(G);for(let D=0;D<=w;D++){let T=Math.PI*2*D/w,P=I*Math.cos(T),F=I*Math.sin(T);t.push(_[0]+L[0]*P,_[1]+L[1]*v,_[2]+L[2]*F);let V=P/L[0],U=v/L[1],X=F/L[2],W=Math.hypot(V,U,X)||1;V/=W,U/=W,X/=W,e.push(V,U,X),n.push(se.head)}}for(let C=0;C<k;C++)for(let G=0;G<w;G++){let v=N+C*(w+1)+G,I=v+w+1;i.push(v,I,v+1,v+1,I,I+1)}let O=new Float32Array(t),B=new Float32Array(e),g=new Float32Array(n),M=new Uint16Array(i);return{position:O,normal:B,part:g,index:M,vertexCount:n.length,indexCount:i.length}}function $n(t,e,n,i){let o=new Float32Array(e),r=c=>t[c*3],a=c=>t[c*3+2],s=0,l=(c,m)=>{let d=m-c;for(let f=c;f<m;f++){let[u,h]=i(f),p=u-r(f),b=h-a(f);if(d>=2){let x=Math.max(c,f-1),y=Math.min(m-1,f+1),S=r(y)-r(x),E=a(y)-a(x),A=Math.hypot(S,E);if(A>1e-6){let w=-E/A,k=S/A;w*p+k*b<0&&(w=-w,k=-k),p=w,b=k}}o[f]=p===0&&b===0?0:Math.atan2(p,b)}};for(let c=1;c<=e;c++)(c===e||n(c)!==n(s))&&(l(s,c),s=c);return o}var ve=.22;function Qn(t,e){let n=fe[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 oi=.42;function ri(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 h of t)h.x<i&&(i=h.x),h.y<o&&(o=h.y),h.x>r&&(r=h.x),h.y>a&&(a=h.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),m=Math.max(1,Math.ceil(s/c)+1),d=Math.max(1,Math.ceil(l/c)+1),f=new Map,u=(h,p)=>{let b=Math.min(m-1,Math.max(0,Math.floor((h-i)/c)));return Math.min(d-1,Math.max(0,Math.floor((p-o)/c)))*m+b};for(let h=0;h<e;h++){let p=u(t[h].x,t[h].y),b=f.get(p);b?b.push(h):f.set(p,[h])}for(let h=0;h<e;h++){let p=t[h],b=Math.min(m-1,Math.max(0,Math.floor((p.x-i)/c))),x=Math.min(d-1,Math.max(0,Math.floor((p.y-o)/c))),y=1/0;for(let S=1;S<=4;S++){for(let E=x-S;E<=x+S;E++)if(!(E<0||E>=d))for(let A=b-S;A<=b+S;A++){if(A<0||A>=m||S>1&&Math.abs(E-x)<S&&Math.abs(A-b)<S)continue;let w=f.get(E*m+A);if(w)for(let k of w){if(k===h)continue;let _=Math.hypot(t[k].x-p.x,t[k].y-p.y);_<y&&(y=_)}}if(Number.isFinite(y)&&y<=S*c)break}n[h]=y}return n}function ii(t){let e=t.eyeHeightM;return Number.isFinite(e)?Math.max(0,e-pt):0}function Jn(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),m=new Float32Array(r),d=new Float32Array(r),f=new Float32Array(r*3),u=new Map,h=ri(t);for(let p=0;p<r;p++){let b=t[p],y=(n?.seatPitchU(p)??h[p])*R;c[p]=Number.isFinite(y)?Math.max(.06,Math.min(ve,y*oi)):ve,m[p]=Zn(Number.isFinite(y)?y:void 0),d[p]=b.wheelchairSpaceType==="no-seat"?0:1,a[p*3]=b.x*R,a[p*3+1]=n?n.seatDeckY(p):ii(b),a[p*3+2]=b.y*R,s[p]=ot(e?e(b):"available");let S=Z(o?.get(b.categoryKey)??"#6e7bff")??[.43,.48,1];if(l[p*3]=S[0],l[p*3+1]=S[1],l[p*3+2]=S[2],b.accessibility?.length){let E=Z(xn(b.accessibility));E&&(f[p*3]=E[0],f[p*3+1]=E[1],f[p*3+2]=E[2])}u.set(b.id,p)}return{count:r,iPosition:a,iState:s,iCategory:l,iMaxRadius:c,iRing:f,idToIndex:u,iChairWidth:m,iPhysicalSeat:d,iFloor:i??new Float32Array(r),iYaw:new Float32Array(r)}}var ai=64;function Kt(t,e){let n=[];for(let a of e){let s=t.idToIndex.get(a.seatId);if(s===void 0)continue;let l=ot(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+ai){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 si=.15,ci=.9,li=1.76,ui=.7,mi=1.6;function di(){return{background:{top:[...Ve.top],bottom:[...Ve.bottom]},structure:Nt,seatStates:{...On},seatScale:1}}function eo(t){let e=di();if(!t)return e;let n=Z(t.background);if(n){e.background={top:he(n,ci),bottom:he(n,li)};let r={};for(let[a,s]of Object.entries(Nt))r[a]=de(s,n,si);e.structure=r}let i=Z(t.selectionColor)??Z(t.accent);i&&(e.seatStates={...e.seatStates,selected:i});let o=t.seatScale;return typeof o=="number"&&Number.isFinite(o)&&(e.seatScale=Math.min(mi,Math.max(ui,o))),e}function to(t,e){let n=[];for(let i of e)n.push(...t.seatStates[i]);return n}import io from"polygon-clipping";import hi from"earcut";var pi=.58,no=.01,pe=ve*1.5*De,fi=.5,bi=.6;function yi(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,m=l.y-s.y,d=Math.hypot(c,m);if(d<1e-9){i.push([0,0]);continue}c/=d,m/=d,i.push([-m,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 xi(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,m=Math.hypot(l,c)||1;return{x:l/m,y:c/m}},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 oo=Math.PI/12;function gi(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 ao(t,e){if(!t.length||!(e>0))return[];let n=gi(t),i=(s,l,c,m)=>{let d=c-l;for(;d<0;)d+=Math.PI*2;for(;d>Math.PI*2;)d-=Math.PI*2;let f=Math.max(1,Math.ceil(d/oo)),u=e/Math.cos(d/f/2);for(let h=0;h<=f;h++){let p=l+d*h/f;m.push({x:s.x+Math.cos(p)*u,y:s.y+Math.sin(p)*u})}};if(n.length<3){let s=0,l=0;for(let u of n)s+=u.x,l+=u.y;s/=n.length||1,l/=n.length||1;let c=0;for(let u of n)c=Math.max(c,Math.hypot(u.x-s,u.y-l));let m=[],d=Math.max(3,Math.ceil(Math.PI*2/oo)),f=(c+e)/Math.cos(Math.PI/d);for(let u=0;u<d;u++){let h=u/d*Math.PI*2;m.push({x:s+Math.cos(h)*f,y:l+Math.sin(h)*f})}return m}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 mo(a)}function vi(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,m=c>1e-12?((e-r.x)*s+(n-r.y)*l)/c:0;m<0?m=0:m>1&&(m=1);let d=Math.hypot(e-(r.x+m*s),n-(r.y+m*l));d<i&&(i=d)}return i}function Rt(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 m=Math.hypot(c.x-r,c.y-a);m>l&&(l=m)}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 m 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 u=e[f],h=Math.hypot(m.x-u.cx,m.y-u.cy)-u.rad;if(h>=d&&h>=s)continue;let p=vi(t[f].pts,m.x,m.y);p<d&&(d=p),t[f].depth<t[o].depth&&p<s&&(s=p,l=t[f].y)}Number.isFinite(d)&&d>0&&a.push(d)}a.sort((m,d)=>m-d);let c=a.length?a[Math.floor(a.length/2)]:1;i.push({pitch:c,belowY:l})}return i}function so(t,e,n,i){let o=t[e],r=o.pts.length>=2?[...o.pts]:o.pts.length===1?(()=>{let m=o.pts[0],d=m.x-i.x,f=m.y-i.y,u=Math.hypot(d,f)||1;d/=u,f/=u;let h=Math.max(n[e].pitch,.001)*.5;return[{x:m.x+f*h,y:m.y-d*h},{x:m.x-f*h,y:m.y+d*h}]})():[];if(r.length<2)return null;let a=0,s=0;for(let m=1;m<r.length;m++){let d=Math.hypot(r[m].x-r[m-1].x,r[m].y-r[m-1].y);d>1e-6&&(a+=d,s++)}let l=s>0?a/s:0,c=xi(r,Math.max(l*bi,pe));return{pts:c,nrm:yi(c,i),front:Math.max(n[e].pitch*pi,pe),back:Math.max(n[e].pitch*fi,pe)}}var qe=1.5,co=.3;function $t(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 d=1;d<t.length-1;d++){let f=t[d],u=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);u>s&&(s=u,l=d)}if(s<=e||l<0)return[n,i];let c=$t(t.slice(0,l+1),e),m=$t(t.slice(l),e);return[...c.slice(0,-1),...m]}function lo(t,e){if(t.length<4)return t;let n=$t([...t,t[0]],e);return n.pop(),n.length>=3?n:t}function uo(t,e,n){if(t.length<2)return[];let i=n??Rt(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 S=t[y].patch;S&&S.length>=3?r.push({outline:[...S],holes:[],topY:t[y].y}):s.push(y)}if(!s.length)continue;s.sort((y,S)=>t[y].depth-t[S].depth);let c=s.map(y=>so(t,y,i,e)).filter(y=>y!==null);if(!c.length)continue;let m=(y,S)=>({x:y.pts[S].x-y.nrm[S][0]*(y.front+qe),y:y.pts[S].y-y.nrm[S][1]*(y.front+qe)}),d=(y,S)=>({x:y.pts[S].x+y.nrm[S][0]*(y.back+qe),y:y.pts[S].y+y.nrm[S][1]*(y.back+qe)}),f=c[0],u=c[c.length-1],h=[];for(let y=0;y<f.pts.length;y++)h.push(m(f,y));for(let y of c)h.push(d(y,y.pts.length-1));for(let y=u.pts.length-1;y>=0;y--)h.push(d(u,y));for(let y=c.length-1;y>=0;y--)h.push(m(c[y],0));let p=mo(h),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(Be(p))>1e-6&&c.every(y=>{let S=y.pts[Math.floor(y.pts.length/2)];return nt(p,S.x,S.y)})){r.push({outline:lo(p,co),holes:[],topY:b});continue}for(let y of Mi(c))r.push({outline:y,holes:[],topY:b})}return r}function Mi(t){let e=[];for(let n of t){let i=[],o=[],r=n.front+qe,a=n.back+qe;for(let l=0;l<n.pts.length;l++){let c=n.pts[l],m=n.nrm[l];i.push([c.x-m[0]*r,c.y-m[1]*r]),o.push([c.x+m[0]*a,c.y+m[1]*a])}let s=[...i,...o.reverse()];s.length<3||(s.push(s[0]),e.push([s]))}if(!e.length)return[];try{let n=io.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(lo(r,co))}return i}catch{return[]}}function mo(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 Qt=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(!nt(n,o.x,o.y)){i=!1;break}if(i)return!0}return!1}};function ro(t,e,n,i,o,r){if(i.length<3)return;if(n.containsAll(i)){let c=[0,1,0],m=i[0];for(let d=1;d+1<i.length;d++){let f=i[d],u=i[d+1];t.tri([m.x*R,o,m.y*R],[f.x*R,o,f.y*R],[u.x*R,o,u.y*R],c,r)}return}let a=i.map(c=>[c.x,c.y]);a.push(a[0]);let s;try{s=io.intersection([a],e)}catch{return}let l=[0,1,0];for(let c of s){if(!c.length||c[0].length<4)continue;let m=c[0],d=[],f=[];for(let h=0;h<m.length-1;h++)d.push(m[h][0],m[h][1]),f.push([m[h][0],m[h][1]]);if(f.length<3)continue;let u=hi(d,void 0,2);for(let h=0;h<u.length;h+=3){let p=f[u[h]],b=f[u[h+1]],x=f[u[h+2]];t.tri([p[0]*R,o,p[1]*R],[b[0]*R,o,b[1]*R],[x[0]*R,o,x[1]*R],l,r)}}}function ho(t,e,n,i,o,r,a){if(e.length<2)return;let s=a??Rt(e),l=[0,1,0],c=r&&r.length>=3?[[...r.map(u=>[u.x,u.y]),[r[0].x,r[0].y]]]:null,m=r&&r.length>=3?new Qt([[...r]]):null,d=u=>{t.setMaterial(2),u(),t.setMaterial(0)},f=u=>{t.setMaterial(3),u(),t.setMaterial(0)};for(let u=0;u<e.length;u++){let h=e[u];if(h.patch&&h.patch.length>=3){let A=[...h.patch],w=s[u].belowY??i;if(f(()=>{if(c&&m)ro(t,c,m,A,h.y,o.tread);else{let k=A[0];for(let _=1;_+1<A.length;_++){let L=A[_],N=A[_+1];t.tri([k.x*R,h.y,k.y*R],[L.x*R,h.y,L.y*R],[N.x*R,h.y,N.y*R],l,o.tread)}}}),h.y>w+no){let k=0,_=0;for(let L of A)k+=L.x,_+=L.y;k/=A.length,_/=A.length,d(()=>{for(let L=0;L<A.length;L++){let N=A[L],O=A[(L+1)%A.length],B=O.x-N.x,g=O.y-N.y,M=Math.hypot(B,g);if(M<1e-6)continue;let C=g/M,G=-B/M;(N.x-k)*C+(N.y-_)*G<0&&(C=-C,G=-G);let v=[C,0,G],I=[N.x*R,h.y,N.y*R],D=[O.x*R,h.y,O.y*R],T=[N.x*R,w,N.y*R],P=[O.x*R,w,O.y*R];t.tri(I,D,P,v,o.riser),t.tri(I,P,T,v,o.riser)}})}continue}let p=so(e,u,s,n);if(!p)continue;let{pts:b,nrm:x,front:y,back:S}=p,E=s[u].belowY??i;for(let A=0;A+1<b.length;A++){let w=b[A],k=b[A+1],_=x[A],L=x[A+1];if(Math.hypot(k.x-w.x,k.y-w.y)<1e-6||_[0]===0&&_[1]===0||L[0]===0&&L[1]===0)continue;let N=[(w.x-_[0]*y)*R,h.y,(w.y-_[1]*y)*R],O=[(k.x-L[0]*y)*R,h.y,(k.y-L[1]*y)*R],B=[(w.x+_[0]*S)*R,h.y,(w.y+_[1]*S)*R],g=[(k.x+L[0]*S)*R,h.y,(k.y+L[1]*S)*R];if(f(()=>{c&&m?ro(t,c,m,[{x:w.x-_[0]*y,y:w.y-_[1]*y},{x:k.x-L[0]*y,y:k.y-L[1]*y},{x:k.x+L[0]*S,y:k.y+L[1]*S},{x:w.x+_[0]*S,y:w.y+_[1]*S}],h.y,o.tread):(t.tri(N,O,g,l,o.tread),t.tri(N,g,B,l,o.tread))}),h.y>E+no){let M=[N[0],E,N[2]],C=[O[0],E,O[2]],G=[-_[0],0,-_[1]];d(()=>{t.tri(N,O,C,G,o.riser),t.tri(N,C,M,G,o.riser)})}}}}import fo from"polygon-clipping";function Si(t,e){let n=t.eventConfigurationIds;return!n?.length||!!e&&n.includes(e)}function po(t,e){return t.filter(n=>n.type!=="shape"||Si(n,e))}function bo(t,e){let n=t.focalPoint??{x:0,y:0};return t.floors?.length?t.floors.map((i,o)=>({objects:po(i.objects,e),focal:{x:(i.focalPoint??n).x,y:(i.focalPoint??n).y},baseHeightM:i.baseHeightM??0,index:o})):[{objects:po(t.objects,e),focal:n,baseHeightM:0,index:0}]}var wi={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Ze(t){return Pn(t)??wi}function yo(t,e){let n=Pt(t.outline,pe),i=Ze(n),o=e.filter(a=>a!==t&&a.outline&&a.outline.length>=3&&bt(i,Ze(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=fo.difference([r(n)],...o.map(l=>[r(l.outline)])),s=[];for(let l of a){if(!l.length)continue;let c=l[0].map(([m,d])=>({x:m,y:d}));if(c.length>1){let m=c[0],d=c[c.length-1];Math.abs(m.x-d.x)<1e-9&&Math.abs(m.y-d.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s.length?s:[n]}catch{return[n]}}function xo(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=fo.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,m])=>({x:c,y:m}));if(l.length>1){let c=l[0],m=l[l.length-1];Math.abs(c.x-m.x)<1e-9&&Math.abs(c.y-m.y)<1e-9&&l.pop()}l.length>=3&&o.push({outline:l,holes:[],topY:r.topY})}}return o.length?o:t}var Pi=.05,go=.05,Ai=.15,Jt=25;function vo(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=[],m=new Set;for(let d=0;d<t.length;d+=1){let f=t[d];for(let u of f.objects){if(u.type==="table"&&m.add(u.id),u.type!=="section"||!u.outline||u.outline.length<3)continue;let h=Pt(u.outline,pe);l.set(u.id,{section:u,unit:f,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),c.push({id:u.id,floorIndex:d,box:Ze(h),section:u,unit:f,outline:h})}}for(let d=0;d<e.length;d++){let f=e[d];for(let u of c){if(n&&u.floorIndex!==n[d]||f.x<u.box.minX||f.x>u.box.maxX||f.y<u.box.minY||f.y>u.box.maxY||!Sn({x:f.x,y:f.y},u.outline,u.section.holes))continue;o[d]=u.id;let h=l.get(u.id);h.hasSeats=!0;let p=f.focalPoint??u.unit.focal,b=Math.hypot(f.x-p.x,f.y-p.y);b<h.frontU&&(h.frontU=b),h.seatIndices.push(d);let x=f.rowId||`__seat-${d}`,y=h.rows.get(x);y?y.push({x:f.x,y:f.y}):h.rows.set(x,[{x:f.x,y:f.y}]);break}}for(let[d,f]of l){let u=vn(f.section,{floorBaseHeightM:f.unit.baseHeightM}),h=f.unit.baseHeightM,p=u.rake>0?Math.tan(u.rake*Math.PI/180):0,b=u.rake<=.01&&u.height<=h+.001,x=f.section.surfaceKind,y=x==="flat"?!0:x==="rakedRows"&&u.rake>.01?!1:b,S=f.hasSeats?Mn(d,e,f.seatIndices,f.unit.focal):{sectionId:d,rows:[],blockCount:0},A=S.rows.length<2?In([...f.rows.values()].map(v=>({points:v})),f.unit.focal):null,w=1/0;if(A){if(f.hasSeats)for(let v of f.rows.values())for(let I of v){let D=A.depthAt(I.x,I.y);D<w&&(w=D)}if(!f.hasSeats||!Number.isFinite(w)){w=1/0;for(let v of f.section.outline){let I=A.depthAt(v.x,v.y);I<w&&(w=I)}}}let k=h+Pi,_=Math.max(k,u.height),L=v=>{let I=Math.max(0,v-w)*Fe,D=Math.min(I*p,Jt);return Math.max(k,u.height+D)},N=v=>{let I=Math.max(0,v)*Fe,D=Math.min(I*p,Jt);return Math.max(k,u.height+D)},O=y?[]:S.rows.map(v=>({pts:v.pts,y:N(v.blockDepth),depth:v.blockDepth,blockId:v.blockId,...m.has(v.id)?{patch:ao(v.pts,pe)}:{}})),B=O.length?O[0].y:_,g=O.map(v=>{let I=v.patch&&v.patch.length>=3?v.patch:v.pts,D=0,T=0;for(let V of I)D+=V.x,T+=V.y;let P=I.length||1;D/=P,T/=P;let F=0;for(let V of I){let U=Math.hypot(V.x-D,V.y-T);U>F&&(F=U)}return{cx:D,cy:T,rad:F}}),M=y?()=>_:O.length>=2?(v,I)=>{let D=1/0,T=B;for(let P=0;P<O.length;P++){let F=g[P];if(Math.hypot(v-F.cx,I-F.cy)-F.rad>=D)continue;let V=O[P].patch,U=V&&V.length>=3?nt(V,v,I)?0:ft(V,v,I):ft(O[P].pts,v,I);U<D&&(D=U,T=O[P].y)}return T}:(v,I)=>A?L(A.depthAt(v,I)):_,C=[0,1,0],G=O.length>=2||y?()=>C:(v,I)=>{if(!A)return C;let D=A.depthAt(v,I);if(D<=w)return C;let T=(D-w)*Fe;if(T*p>=Jt||u.height+T*p<=k)return C;let[P,F]=A.gradientAt(v,I);if(P===0&&F===0)return C;let V=1/Math.hypot(p,1);return[-P*p*V,V,-F*p*V]};if(!y)for(let v of S.rows){let I=N(v.blockDepth);for(let D of v.seatIndices)a[D]=I}for(let v of S.rows){let I=[];for(let V=1;V<v.pts.length;V++){let U=Math.hypot(v.pts[V].x-v.pts[V-1].x,v.pts[V].y-v.pts[V-1].y);U>1e-6&&I.push(U)}I.sort((V,U)=>V-U);let D=I.length?I[Math.floor(I.length/2)]:1/0,T=1/0,P=v.pts[Math.floor(v.pts.length/2)];if(P)for(let V of S.rows){if(V===v||V.blockId!==v.blockId)continue;let U=ft(V.pts,P.x,P.y);U>1e-6&&U<T&&(T=U)}let F=Math.min(D,Math.max(T,D*.5));if(Number.isFinite(F)&&F>0)for(let V of v.seatIndices)s[V]=F}i.set(d,{sectionId:d,deckAt:M,normalAt:G,flat:y,bottomY:h,rowLevels:O,landingY:B})}for(let d=0;d<e.length;d++){let f=o[d],u=e[d];if(f){let p=a[d];r[d]=(p??i.get(f).deckAt(u.x,u.y))+Ai;continue}let h=u.eyeHeightM;r[d]=Number.isFinite(h)?Math.max(0,h-pt):0}return{bySection:i,seatOwner:o,seatDeckY:d=>r[d],seatPitchU:d=>s[d]}}var re={top:1,wallBottom:.5,bottomCap:.4};function Me(t,e){if(!t)return e;let n=he(tt(t,.4),.62);return de(e,n,.72)}function Mo(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,m=0;for(let[d,f]of a){let u=Z(n.get(d));u&&(s+=u[0]*f,l+=u[1]*f,c+=u[2]*f,m+=f)}m>0&&o.set(r,[s/m,l/m,c/m])}return o}function So(t,e){return Z(t.color)??e.get(t.logicalSectionId??t.id)??null}import Ci from"polygon-clipping";function Ri(t,e){return t===void 0||e===void 0?!0:Math.abs(t-e)<.001}var It=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=Ze(e),r=this.rings.filter((l,c)=>bt(o,this.boxes[c])&&Ri(n,this.levels[c])),a=[[i]];if(r.length)try{a=Ci.difference([i],...r).map(c=>c.map(m=>m.map(([d,f])=>[d,f])))}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(([m,d])=>({x:m,y:d}));if(c.length>1){let m=c[0],d=c[c.length-1];Math.abs(m.x-d.x)<1e-9&&Math.abs(m.y-d.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s}};function Ii(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,l=e*Math.PI/180,c=Math.cos(l),m=Math.sin(l);return t.map(d=>{let f=d.x-a,u=d.y-s;return{x:a+f*c-u*m,y:s+f*m+u*c}})}function ct(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=st(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=At(n,i,t.width/2,t.height/2)}return e?Ii(e,t.rotation):null}function lt(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 Ti=.08;function wo(t,e){let n=ct(t),i=lt(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 m of n)r=Math.min(r,m.x),a=Math.min(a,m.y),s=Math.max(s,m.x),l=Math.max(l,m.y);let c=o;for(let m of e)s>m.minX&&r<m.maxX&&l>m.minY&&a<m.maxY&&c<=m.topOffsetM+1e-6&&(c=m.topOffsetM+Ti);return e.push({minX:r,minY:a,maxX:s,maxY:l,topOffsetM:c}),c}function Ee(t,e,n){return{x:t.x+(e.x-t.x)*n,y:t.y+(e.y-t.y)*n}}function Po(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 ut(t,e,n){return[Ee(t[0],t[1],e),Ee(t[0],t[1],n),Ee(t[3],t[2],n),Ee(t[3],t[2],e)]}function Ao(t,e,n){return[Ee(t[0],t[3],e),Ee(t[1],t[2],e),Ee(t[1],t[2],n),Ee(t[0],t[3],n)]}function Se(t,e,n,i,o,r){ie(t,e,void 0,()=>n,i,o,r,re)}var en=2.4,Fi=.75,Di=.15;function mt(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(([m,d])=>({x:e.x+m*a-d*s,y:e.y+m*s+d*a}))}function Co(t,e,n,i,o){let r=mt(e);r&&ie(t,r,void 0,()=>n+en,n,Me(i,o.boothTop),o.boothWall,re)}function tn(t){if(t.shape==="round"){let m=t.radius;return m?At(t.center.x,t.center.y,m,m,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(([m,d])=>({x:o.x+m*a-d*s,y:o.y+m*s+d*a}))}function Ro(t,e,n,i,o){let r=tn(e);r&&ie(t,r,void 0,()=>n+Fi,n,Me(i,o.tableTop),o.tableWall,re)}function Io(t,e,n,i,o,r,a){let s=ct(e);if(!s)return;let l=e.role==="stage",c=lt(e),m=n+i;if(l&&a){let p=1/0,b=-1/0,x=1/0,y=-1/0;for(let S of s)S.x<p&&(p=S.x),S.x>b&&(b=S.x),S.y<x&&(x=S.y),S.y>y&&(y=S.y);a.push({cx:(p+b)/2*R,cz:(x+y)/2*R,y:m,halfX:Math.max((b-p)/2*R,.5),halfZ:Math.max((y-x)/2*R,.5)})}let d=Z(e.fill),f=l&&d?de(o.stageTop,he(tt(d,.18),.9),.9):Me(d,l?o.stageTop:o.decorTop),u=e.role==="screen"?d:null,h=l?d?de(o.stageWall,he(d,.58),.82):o.stageWall:e.role==="screen"?u?de(he(u,1.42),[.24,.46,.82],.08):[.24,.46,.82]:Me(Z(e.fill),o.decorWall);if(c.kind==="portal"&&s.length===4){let p=Po(s);Se(t,ut(p,0,.16),m,n,f,h),Se(t,ut(p,.84,1),m,n,f,h),Se(t,p,m,Math.max(n,m-.35),f,h);return}if(c.kind==="suite"&&s.length===4){let p=s.map((y,S)=>{let E=s[(S+1)%4],A=(y.x+E.x)/2,w=(y.y+E.y)/2;return Math.hypot(A-r.x,w-r.y)}),b=p.indexOf(Math.min(...p)),x=[0,1,2,3].map(y=>s[(b+y)%4]);Se(t,ut(x,0,.08),m,n,f,h),Se(t,ut(x,.92,1),m,n,f,h),Se(t,Ao(x,.88,1),m,n,f,h),Se(t,x,m,Math.max(n,m-.18),f,h);return}Se(t,s,m,n,f,h)}function nn(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),m=i/2,d=o/2;return[[-m,-d],[m,-d],[m,d],[-m,d]].map(([f,u])=>({x:r+f*l-u*c,y:a+f*c+u*l}))}function Ei(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 Z(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=Z(s[1].trim());l&&a.push(l)}return a.length?a.reduce((s,l,c)=>de(s,l,1/(c+1)),a[0]):null}function To(t,e,n,i){if(e.layer==="foreground")return;let o=nn(e);if(!o)return;let r=n+Di,a=Me(Ei(e.href),i.decorTop),s=Math.max(0,Math.min(1,e.opacity??1));s<1&&(a=de(i.ground,a,s)),ie(t,o,void 0,()=>r,n,a,de(a,i.decorWall,.5),re)}function Fo(t,e,n,i,o){if(!e.points||e.points.length<3)return;let r=Me(i,o.gaTop);ie(t,e.points,e.holes,()=>n+.15,n,r,o.gaWall,re)}var Do=.25,ki=1.2,Li=.6,_i=.45,Oi=2.3,Bi=Math.PI/180;function Ge(t,e,n){let i=n*Bi;return{x:t.x+e*Math.sin(i),y:t.y+e*Math.cos(i)}}function Vi(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 Gi(t,e,n,i,o,r,a,s,l){let c=n.binCount,m=zi,d=Fe,f=r+.02,u=[];for(let g=0;g<c;g++){let M=(n.startBin+g+.5)*e.binStepDeg,C=new Float64Array(m+1);for(let G=0;G<=m;G++){let v=i[g]+(o[g]-i[g])*G/m;C[G]=Math.max(f,Dn(e,n,M,v)-Do)}u.push(C)}for(let g of l){let M=Tn(e.centre,g),C=Math.hypot(g.x-e.centre.x,g.y-e.centre.y),G=M/e.binStepDeg-.5-n.startBin;if(G=(G%e.binCount+e.binCount)%e.binCount,G>c-1&&!n.closed&&!(G<c-.5||G>e.binCount-.5))continue;let v=g.deckY-Do,I=Math.min(c-1,Math.max(0,Math.floor(G))),D=[I,n.closed?(I+1)%c:Math.min(c-1,I+1)];for(let T of D){let P=o[T]-i[T];if(!(P>1e-9))continue;let F=(C-i[T])/P*m;if(F<-.75||F>m+.75)continue;let V=Math.min(m,Math.max(0,Math.floor(F))),U=Math.min(m,V+1);u[T][V]>v&&(u[T][V]=Math.max(f,v)),u[T][U]>v&&(u[T][U]=Math.max(f,v))}}let h=[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],x=[a.bandWall[0]*s.wallBottom,a.bandWall[1]*s.wallBottom,a.bandWall[2]*s.wallBottom],y=(g,M)=>{let C=(n.startBin+g+.5)*e.binStepDeg,G=i[g]+(o[g]-i[g])*M/m,v=Ge(e.centre,G,C);return[v.x*d,u[g][M],v.y*d]};{let g=Math.tan(12*Math.PI/180);for(let M=0;M<6;M++){let C=!1;for(let v=0;v<c;v++)for(let I=m-1;I>=0;I--)u[v][I]>u[v][I+1]&&(u[v][I]=u[v][I+1],C=!0);let G=n.closed?c:c-1;for(let v=0;v<G;v++){let I=(v+1)%c;for(let D=0;D<=m;D++){let T=u[I][D]-u[v][D];if(Math.abs(T)>1)continue;let P=i[v]+(o[v]-i[v])*D/m,F=i[I]+(o[I]-i[I])*D/m,V=Ge(e.centre,P,(n.startBin+v+.5)*e.binStepDeg),U=Ge(e.centre,F,(n.startBin+I+.5)*e.binStepDeg),X=g*Math.hypot(U.x-V.x,U.y-V.y)*d;T>X?(u[I][D]=u[v][D]+X,C=!0):-T>X&&(u[v][D]=u[I][D]+X,C=!0)}}if(!C)break}}let S=1,E=(g,M)=>{for(let C=0;C<=m;C+=4)if(Math.abs(u[g][C]-u[M][C])>S)return!0;return Math.abs(u[g][m]-u[M][m])>S},A=Math.tan(38*Math.PI/180),w=g=>(o[g]-i[g])/m*d,k=(g,M)=>u[g][M+1]-u[g][M]>A*Math.max(1e-6,w(g)),_=(g,M)=>{let C=n.closed?(g-1+c)%c:Math.max(0,g-1),G=n.closed?(g+1)%c:Math.min(c-1,g+1);Math.abs(u[C][M]-u[g][M])>S&&(C=g),Math.abs(u[G][M]-u[g][M])>S&&(G=g);let v=Math.max(0,M-1),I=Math.min(m,M+1);v<M&&k(g,v)&&(v=M),I>M&&k(g,M)&&(I=M);let D=y(C,M),T=y(G,M),P=y(g,v),F=y(g,I),V=T[0]-D[0],U=T[1]-D[1],X=T[2]-D[2],W=F[0]-P[0],Y=F[1]-P[1],$=F[2]-P[2],Q=U*$-X*Y,J=X*W-V*$,te=V*Y-U*W,K=Math.hypot(Q,J,te);return K>1e-12?(Q/=K,J/=K,te/=K,J<0&&(Q=-Q,J=-J,te=-te),[Q,J,te]):[0,1,0]},L=(g,M)=>{let C=[g[0],r,g[2]],G=[M[0],r,M[2]],v=M[0]-g[0],I=M[2]-g[2],D=Math.hypot(v,I);if(!(D>1e-12))return;let T=[I/D,0,-v/D];t.tri(g,M,G,T,b,b,x),t.tri(g,G,C,T,b,x,x)},N=.05*De,O=g=>o[g]-i[g]<N,B=n.closed?c:c-1;for(let g=0;g<B;g++){let M=(g+1)%c;if(O(g)||O(M))continue;if(E(g,M)){let T=(n.startBin+g+1)*e.binStepDeg,P=(Y,$)=>{let Q=(i[g]+i[M])/2,J=(o[g]+o[M])/2,te=Q+(J-Q)*$/m,K=Ge(e.centre,te,T);return[K.x*d,u[Y][$],K.y*d]};for(let Y=0;Y<m;Y++){let $=y(g,Y),Q=y(g,Y+1),J=P(g,Y),te=P(g,Y+1),K=_(g,Y),me=_(g,Y+1);t.triN($,J,te,K,K,me,h),t.triN($,te,Q,K,me,me,h);let ke=y(M,Y),Le=y(M,Y+1),be=P(M,Y),we=P(M,Y+1),ye=_(M,Y),Pe=_(M,Y+1);t.triN(be,ke,Le,ye,ye,Pe,h),t.triN(be,Le,we,ye,Pe,Pe,h);let ae=P(g,Y),ue=P(g,Y+1),xe=P(M,Y+1),Ae=P(M,Y),He=ue[0]-ae[0],_e=ue[2]-ae[2],ce=Math.hypot(He,_e);if(ce>1e-12){let Ue=[_e/ce,0,-He/ce];t.tri(ae,ue,xe,Ue,b),t.tri(ae,xe,Ae,Ue,b)}}let F=y(g,0),V=y(M,0),U=y(M,m),X=y(g,m),W=Y=>[Y[0],r,Y[2]];t.tri(W(F),W(U),W(V),[0,-1,0],p),t.tri(W(F),W(X),W(U),[0,-1,0],p),L(F,V),L(X,U);continue}for(let T=0;T<m;T++){let P=_(g,T),F=_(M,T),V=_(M,T+1),U=_(g,T+1);if(k(g,T)||k(M,T)){let Q=(ue,xe)=>{let Ae=(n.startBin+ue+.5)*e.binStepDeg,He=i[ue]+(o[ue]-i[ue])*(T+.5)/m,_e=Ge(e.centre,He,Ae);return[_e.x*d,xe,_e.y*d]},J=y(g,T),te=y(M,T),K=Q(g,u[g][T]),me=Q(M,u[M][T]);t.triN(J,te,me,P,F,F,h),t.triN(J,me,K,P,F,P,h);let ke=y(M,T+1),Le=y(g,T+1),be=Q(g,u[g][T+1]),we=Q(M,u[M][T+1]);t.triN(be,we,ke,U,V,V,h),t.triN(be,ke,Le,U,V,U,h);let ye=me[0]-K[0],Pe=me[2]-K[2],ae=Math.hypot(ye,Pe);if(ae>1e-12){let ue=[-Pe/ae,0,ye/ae];t.tri(K,me,we,ue,b),t.tri(K,we,be,ue,b)}continue}let X=y(g,T),W=y(M,T),Y=y(M,T+1),$=y(g,T+1);t.triN(X,W,Y,P,F,V,h),t.triN(X,Y,$,P,V,U,h)}let C=y(g,0),G=y(M,0),v=y(M,m),I=y(g,m),D=T=>[T[0],r,T[2]];t.tri(D(C),D(v),D(G),[0,-1,0],p),t.tri(D(C),D(I),D(v),[0,-1,0],p),L(C,G),L(I,v)}if(!n.closed)for(let g of[0,c-1])for(let M=0;M<m;M++)L(y(g,M),y(g,M+1))}function Eo(t,e,n){let{bottomY:i,colors:o,ao:r}=n,a=new Float64Array(e.binCount).fill(-1/0);for(let m of e.rings)for(let d of m.arcs){let f=new Float64Array(d.binCount),u=new Float64Array(d.binCount);for(let p=0;p<d.binCount;p++){let b=(d.startBin+p)%e.binCount,x=Math.max(0,d.innerR[p]-pe);f[p]=Math.max(x,a[b]+.001),u[p]=Math.max(f[p]+.001,d.outerR[p]+pe)}let h=0;for(let p=0;p<d.binCount;p++){let b=d.topLevelM[p]-i;b>h&&(h=b)}h>=ki&&Gi(t,e,d,f,u,i,o,r,n.seatGuards);for(let p=0;p<d.binCount;p++){let b=(d.startBin+p)%e.binCount;u[p]>a[b]&&(a[b]=u[p])}}if(Vi(n.shapes,e))return;let s=e.rings[e.rings.length-1],l=Li*De,c=_i*De;for(let m of s.arcs){let d=[],f=[];for(let p=0;p<m.binCount;p++){let b=(m.startBin+p+.5)*e.binStepDeg,x=m.outerR[p]+pe+l;d.push(Ge(e.centre,x,b)),f.push(Ge(e.centre,x+c,b))}let u=-1/0;for(let p=0;p<m.binCount;p++)m.topLevelM[p]>u&&(u=m.topLevelM[p]);let h=()=>u+Oi;m.closed?ie(t,f,[d.slice().reverse()],h,i,o.shellTop,o.shellWall,r):ie(t,[...f,...d.slice().reverse()],void 0,h,i,o.shellTop,o.shellWall,r)}}function ko(t,e,n,i,o,r,a,s){if(!e.outline||e.outline.length<3)return;let l=n.baseHeightM,c=Me(i,s.tierTop);if(!o)return;let m=b=>o.deckAt(b.x,b.y),d=yo(e,a),f=d[0]??e.outline;if(o.rowLevels.length>=2){let b=Rt(o.rowLevels),x=xo(uo(o.rowLevels,n.focal,b),d),y=()=>[0,1,0];for(let E of x){let A=Math.max(l,E.topY-.02);for(let w of r.subtract(E.outline,A))ie(t,w,E.holes,()=>A,l,c,s.tierWall,re,void 0,y)}x.length||ie(t,f,e.holes,()=>o.landingY,l,c,s.tierWall,re);let S={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 E of d.length?d:[f])ho(t,o.rowLevels,n.focal,o.landingY,S,E,b);return}let u=o.flat?1/0:go,h=b=>o.normalAt(b.x,b.y),p=o.flat?o.landingY:void 0;for(let b of r.subtract(f,p))ie(t,b,e.holes,m,l,c,s.tierWall,re,u,h)}function Ni(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],m=o.get(s);m||(m=new Map,o.set(s,m));let d=c.rowId||`__seat-${a}`,f=m.get(d);f||(f={pts:[],levelM:0,n:0},m.set(d,f)),f.pts.push({x:c.x,y:c.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 c=s.rowLevels.filter(m=>!m.patch).map(m=>({pts:m.pts,levelM:m.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 Lo(t,e,n,i,o){let r=Ni(e,n,i);if(!r.length)return;let a=Fn(r,e.focal);if(!a)return;let s=new Set;for(let c of e.objects)c.type==="section"&&s.add(c.id);let l=[];for(let c=0;c<n.length;c++){let m=i.seatOwner[c];(!m||s.has(m))&&l.push({x:n[c].x,y:n[c].y,deckY:i.seatDeckY(c)})}t.setMaterial(0),Eo(t,a,{bottomY:e.baseHeightM,colors:{bandTop:he(o.tierTop,.8),bandWall:o.tierWall,shellTop:he(o.tierWall,1.15),shellWall:o.tierWall},ao:re,shapes:e.objects.filter(c=>c.type==="shape"),seatGuards:l})}function _o(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 Oo(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 Hi=1.15,Ui=3.25,Yi=4.5,Xi=.85,Wi=.5,ji=.26;function Bo(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>=Hi&&a.add("zone"),o<=(r?Ui:Yi)&&(a.add("section"),a.add("ga")),o<=Xi&&(a.add("annotation"),a.add("booth")),o<=Wi&&a.add("row"),o<=ji&&a.add("seat"),a}function Tt(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],m=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=l/d,u=c/d,h=m/d,p=f>=-1.05&&f<=1.05&&u>=-1.05&&u<=1.05&&h<=1;return{x:(f*.5+.5)*n,y:(1-(u*.5+.5))*i,depth:h,visible:p}}function Vo(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 zo={row:8,seat:14};function Go(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 No(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 qi=6,Zi=2.2,Ho=.1,Ki=.3,$i=1.8,Qi=.9,Ji=.55,ea=6e3;function Uo(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 m of n)for(let d of m.objects)d.type==="section"&&d.zone&&l.set(d.id,d.zone);let c=new Map;for(let m=0;m<i.length;m++){let d=i[m],f=o.seatOwner[m],u=d.zoneId??(f?l.get(f):void 0);if(!u)continue;let h=c.get(u);h||(h={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},c.set(u,h)),h.n++,d.x<h.minX&&(h.minX=d.x),d.y<h.minY&&(h.minY=d.y),d.x>h.maxX&&(h.maxX=d.x),d.y>h.maxY&&(h.maxY=d.y),h.sumY+=o.seatDeckY(m)}for(let m of a){let d=c.get(m.id),f=[];for(let[u,h]of l)h===m.id&&f.push(u);if(!d||d.n===0){s.push({id:m.id,label:m.label,color:Z(m.color),sectionIds:f,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(m.focalPoint??r).x*R,1.5,(m.focalPoint??r).y*R]});continue}s.push({id:m.id,label:m.label,color:Z(m.color),sectionIds:f,seatCount:d.n,center:[(d.minX+d.maxX)/2*R,d.sumY/d.n,(d.minY+d.maxY)/2*R],radius:.5*Math.hypot((d.maxX-d.minX)*R,(d.maxY-d.minY)*R)||1,focalWorld:[(m.focalPoint??r).x*R,1.5,(m.focalPoint??r).y*R]})}}return s}function Yo(t){let{doc:e,units:n,seats:i,surfaces:o,seatData:r,hintedSeatFloor:a,zones:s,focal:l}=t,c=[],m=[],d=[];for(let f of s)f.seatCount!==0&&c.push({id:`zone:${f.id}`,kind:"zone",text:f.label,anchor:[f.center[0],f.center[1]+qi,f.center[2]],color:e.zones?.find(u=>u.id===f.id)?.color});{let f=new Map,u=new Map;for(let h=0;h<i.length;h++){let p=o.seatOwner[h];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[h].x,b.y+=i[h].y,b.deck+=o.seatDeckY(h);let x=u.get(p);x||(x={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0},u.set(p,x)),i[h].x<x.minX&&(x.minX=i[h].x),i[h].x>x.maxX&&(x.maxX=i[h].x),i[h].y<x.minY&&(x.minY=i[h].y),i[h].y>x.maxY&&(x.maxY=i[h].y)}for(let h of n)for(let p of h.objects){if(p.type!=="section")continue;let b=f.get(p.id);if(!b||b.n===0)continue;let x=u.get(p.id),y=[b.x/b.n*R,b.deck/b.n,b.y/b.n*R],S=p.displayLabel||p.label||p.id;m.push({id:p.id,floorIndex:h.index,label:S,seatCount:b.n,center:y,radius:Math.max(1,Math.hypot(x.maxX-x.minX,x.maxY-x.minY)*.5*R),focalWorld:[h.focal.x*R,h.baseHeightM+1.5,h.focal.y*R]});let E=e.floors?.[h.index]?.name?.trim().toLocaleLowerCase();n.length>1&&E===S.trim().toLocaleLowerCase()||c.push({id:`section:${p.id}`,kind:"section",text:S,anchor:[y[0],y[1]+Zi,y[2]],floorIndex:h.index})}}{for(let h of n)for(let p of h.objects){if(p.type!=="gaArea")continue;let b=et(p.points);if(!b)continue;let x=p.displayLabel||p.label||p.id;c.push({id:`ga:${p.id}`,kind:"ga",text:p.capacity>0?`${x} \xB7 ${p.capacity.toLocaleString()}`:x,anchor:[b.x*R,h.baseHeightM+$i,b.y*R],floorIndex:h.index})}let f=new Map;for(let h=0;h<i.length;h++){let p=i[h],b=Math.hypot(p.x-l.x,p.y-l.y),x=f.get(p.rowId);(!x||b>x.far)&&f.set(p.rowId,{seat:p,index:h,far:b})}for(let[h,p]of f){let b=p.seat.label?p.seat.label.lastIndexOf("-"):-1,x=b>0?p.seat.label.slice(0,b):h;x&&c.push({id:`row:${h}`,kind:"row",text:x,anchor:[p.seat.x*R,o.seatDeckY(p.index)+Qi,p.seat.y*R],floorIndex:a[p.index]})}let u=new Map;for(let h=0;h<i.length;h++){let p=i[h],b=p.label?p.label.lastIndexOf("-"):-1,x=u.get(p.rowId);x||(x={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},u.set(p.rowId,x));let y=h*3,S=r.iPosition[y],E=r.iPosition[y+1],A=r.iPosition[y+2];x.n++,x.x+=S,x.y+=E,x.z+=A,x.minX=Math.min(x.minX,S),x.maxX=Math.max(x.maxX,S),x.minZ=Math.min(x.minZ,A),x.maxZ=Math.max(x.maxZ,A)}for(let[h,p]of u)d.push({id:h,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<=ea)for(let h=0;h<i.length;h++){let p=i[h],b=p.displayLabel||p.label;b&&c.push({id:`seat:${p.id}`,kind:"seat",text:b,anchor:[p.x*R,o.seatDeckY(h)+Ji,p.y*R],floorIndex:a[h]})}}for(let f of n)for(let u of f.objects)if(u.type==="shape"&&u.role&&["entrance","exit","screen","suite","obstruction"].includes(u.role)){let h=ct(u),p=h?et(h):null;if(!p||!u.label)continue;c.push({id:`architecture:${u.id}`,kind:"annotation",text:u.label,anchor:[p.x*R,f.baseHeightM+lt(u).heightM+Ho,p.y*R],color:u.fill,floorIndex:f.index})}else if(u.type==="text"){if(!u.text)continue;c.push({id:`text:${u.id}`,kind:"annotation",text:u.text,anchor:[u.position.x*R,f.baseHeightM+Ho,u.position.y*R],color:u.color,rotation:u.rotation,floorIndex:f.index})}else if(u.type==="booth"){let h=mt(u);if(!h)continue;let p=et(h);if(!p)continue;c.push({id:`booth:${u.id}`,kind:"booth",text:u.displayLabel||u.label||u.id,anchor:[p.x*R,f.baseHeightM+en+Ki,p.y*R],floorIndex:f.index})}return{labels:c,sections:m,rows:d}}function Xo(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 Wo(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 f=0;f<r.floor.length;f+=1){let u=Math.max(0,Math.min(n.length-1,Math.round(r.floor[f]))),h=f*3,p=c[u];p.minX=Math.min(p.minX,r.position[h]),p.minY=Math.min(p.minY,r.position[h+1]),p.minZ=Math.min(p.minZ,r.position[h+2]),p.maxX=Math.max(p.maxX,r.position[h]),p.maxY=Math.max(p.maxY,r.position[h+1]),p.maxZ=Math.max(p.maxZ,r.position[h+2])}let m=new Map;for(let f=0;f<n.length;f++)for(let u of n[f].objects)u.type==="section"&&m.set(u.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 u=o.seatOwner[f],h=(u!==null?m.get(u):void 0)??a[f];if(h===void 0)continue;let p=d[h],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 x=o.seatDeckY(f);p.sumX+=b.x*R,p.sumDeck+=x,p.sumZ+=b.y*R,p.minDeck=Math.min(p.minDeck,x),p.maxDeck=Math.max(p.maxDeck,x+1.6),s[f]=h}for(let f=0;f<n.length;f++){let u=d[f],h=e.floors?.[f],p=c[f],b=Math.min(u.n?u.minX*R:n[f].focal.x*R-1,Number.isFinite(p.minX)?p.minX:1/0),x=Math.max(u.n?u.maxX*R:n[f].focal.x*R+1,Number.isFinite(p.maxX)?p.maxX:-1/0),y=Math.min(u.n?u.minY*R:n[f].focal.y*R-1,Number.isFinite(p.minZ)?p.minZ:1/0),S=Math.max(u.n?u.maxY*R:n[f].focal.y*R+1,Number.isFinite(p.maxZ)?p.maxZ:-1/0),E=Math.min(u.n?Math.min(n[f].baseHeightM,u.minDeck):n[f].baseHeightM,Number.isFinite(p.minY)?p.minY:1/0),A=Math.max(u.n?Math.max(u.maxDeck,E+.5):E+.5,Number.isFinite(p.maxY)?p.maxY:-1/0),w=[u.n?u.sumX/u.n:(b+x)/2,u.n?u.sumDeck/u.n:(E+A)/2,u.n?u.sumZ/u.n:(y+S)/2],k=Math.max(1,.5*Math.hypot(x-b,A-E,S-y));l.push({index:f,id:h?.id??`floor-${f}`,label:h?.name??(n.length>1?`Floor ${f+1}`:"Venue"),seatCount:u.n,center:w,radius:k,box:{min:[b,E,y],max:[x,A,S]},focalWorld:[n[f].focal.x*R,n[f].baseHeightM+1.5,n[f].focal.y*R]})}}return l}function on(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=mt(l);if(c)for(let m of c)a(m.x,m.y)}else if(l.type==="table"){let c=tn(l);if(c)for(let m of c)a(m.x,m.y)}else if(l.type==="decorImage"){let c=nn(l);if(c)for(let m of c)a(m.x,m.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=st(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((u,h)=>h.baseHeightM<u.baseHeightM?h:u);t.setFloor(a.index);let s=n.filter((u,h)=>i[h]===a.index),l=on([a],s),c=Math.hypot(l.maxX-l.minX,l.maxY-l.minY),m=Math.max(28,Math.min(80,c*.04)),d=st(l.minX-m,l.minY-m,l.maxX-l.minX+m*2,l.maxY-l.minY+m*2),f=a.baseHeightM-.03;ie(t,d,void 0,()=>f,f-.22,r.ground,r.ground,re)}}function qo(t,e,n){let{cx:i,cz:o,radius:r}=n,a=1/0,s=1/0,l=1/0,c=-1/0,m=-1/0,d=-1/0,f=(p,b,x)=>{a=Math.min(a,p),c=Math.max(c,p),s=Math.min(s,b),m=Math.max(m,b),l=Math.min(l,x),d=Math.max(d,x)};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,x=e.iPosition[b],y=e.iPosition[b+1],S=e.iPosition[b+2],E=Math.max(.35,e.iMaxRadius[p]??.35);f(x-E,y,S-E),f(x+E,y+1.6,S+E)}Number.isFinite(a)||(a=i-r,c=i+r,s=0,m=r*.16,l=o-r,d=o+r);let u=[(a+c)/2,(s+m)/2,(l+d)/2],h=Math.max(1,.5*Math.hypot(c-a,m-s,d-l));return{center:u,radius:h,minY:s,maxY:m}}function Zo(t,e,n,i,o,r){let a=1/0,s=1/0,l=-1/0,c=-1/0;for(let E=0;E<t.count;E++){let A=E*3,w=t.iPosition[A],k=t.iPosition[A+2];w<a&&(a=w),w>l&&(l=w),k<s&&(s=k),k>c&&(c=k)}for(let E of e)a=Math.min(a,E.cx-E.halfX),l=Math.max(l,E.cx+E.halfX),s=Math.min(s,E.cz-E.halfZ),c=Math.max(c,E.cz+E.halfZ);let m=n.minX*R,d=n.maxX*R,f=n.minY*R,u=n.maxY*R,h=m,p=d,b=f,x=u;if(Number.isFinite(a)){let E=Math.max(2,.06*Math.hypot(l-a,c-s));h=Math.max(m,a-E),p=Math.min(d,l+E),b=Math.max(f,s-E),x=Math.min(u,c+E)}let y=Math.min(0,i),S=Math.max(o,r*.05);return{min:[h,y,b],max:[p,S,x]}}function dt(t){let{doc:e}=t,n=eo(e.theme),i=n.structure,o=bo(e,t.eventConfigurationId??e.eventConfigurationId),r=t.seats,a=new wt,s=new Map;for(let B of o)for(let g of B.objects)s.set(g.id,B.index),g.type==="section"&&s.set(g.logicalSectionId??g.id,B.index);let l=r.map(B=>s.get(B.sectionId??"")??s.get(B.rowId??"")??0),c=on(o,r);jo(a,o,r,l,c,i);let m=Mo(e,r),d=new Map;for(let B of e.categories??[])d.set(B.key,B.color);let f=[],u=vo(o,r,l),h=new Float32Array(r.length);for(let B=0;B<o.length;B++){let g=o[B];a.setFloor(B);let M=new It,C=[],G=g.objects.filter(v=>v.type==="section"&&!!v.outline&&v.outline.length>=3);for(let v of g.objects)v.type==="section"?ko(a,v,g,So(v,m),u.bySection.get(v.id),M,G,i):v.type==="shape"?(a.setMaterial(v.role==="screen"?1:0),Io(a,v,g.baseHeightM,wo(v,C),i,g.focal,f),a.setMaterial(0)):v.type==="gaArea"?Fo(a,v,g.baseHeightM,Z(d.get(v.categoryKey)),i):v.type==="booth"?Co(a,v,g.baseHeightM,Z(d.get(v.categoryKey)),i):v.type==="table"?Ro(a,v,g.baseHeightM,Z(d.get(v.categoryKey)),i):v.type==="decorImage"&&To(a,v,g.baseHeightM,i);Lo(a,g,r,u,i)}let p=o.length>1?{x:o.reduce((B,g)=>B+g.focal.x,0)/o.length,y:o.reduce((B,g)=>B+g.focal.y,0)/o.length}:e.focalPoint??{x:(c.minX+c.maxX)/2,y:(c.minY+c.maxY)/2},b=qn([a.build()]),x=Jn(r,t.initialState,u,h,d),y=Uo({doc:e,units:o,seats:r,surfaces:u,focal:p}),{labels:S,sections:E,rows:A}=Yo({doc:e,units:o,seats:r,surfaces:u,seatData:x,hintedSeatFloor:l,zones:y,focal:p}),w=Wo({doc:e,units:o,seats:r,surfaces:u,solids:b,hintedSeatFloor:l,seatFloor:h});Xo(S,w),x.iYaw=$n(x.iPosition,r.length,B=>r[B].rowId,B=>{let g=o[h[B]]?.focal??p;return[g.x*R,g.y*R]});let k=(c.minX+c.maxX)/2*R,_=(c.minY+c.maxY)/2*R,L=.5*Math.hypot((c.maxX-c.minX)*R,(c.maxY-c.minY)*R)||10,N=qo(b,x,{cx:k,cz:_,radius:L}),O=Zo(x,f,c,N.minY,N.maxY,L);return{solids:b,seats:x,bounds:{center:[(O.min[0]+O.max[0])/2,(O.min[1]+O.max[1])/2,(O.min[2]+O.max[2])/2],radius:L,groundY:0,box:O},renderBounds:{center:N.center,radius:N.radius},stateColorLUT:to(n,fe),theme:n,seatCount:r.length,focalWorld:[p.x*R,1.5,p.y*R],zones:y,stages:f,sections:E,rows:A,labels:S,floors:w}}var ta=88,na=20,oa={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}},Ko=new Set(["row","seat"]),$o={row:{x:62,y:16},seat:{x:46,y:18}},ra=Z,rn=t=>wn(t);function ia(t,e){let n=rn(t),i=rn(e);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function aa(t,e=[.04,.06,.1]){let n=rn(e)<.42,i=n?"#f4f7fb":"#0b1220",o=ra(t),r=o&&ia(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 Ft=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=Bo(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 h=Tt(e,u.anchor,n,i);if(!h.visible)continue;let p=a?Math.hypot(u.anchor[0]-a[0],u.anchor[1]-a[1],u.anchor[2]-a[2]):1;l.push({label:u,screen:h,focus:Go(h,p,n,i),...this.selectedSeatLabelIds.has(u.id)?{priority:1}:{}})}let c=Oo(l.filter(u=>u.label.kind==="floor"),n),m=[...l.filter(u=>!Ko.has(u.label.kind)&&u.label.kind!=="floor"),...c],d=[...Vo(m,ta,na),...["row","seat"].flatMap(u=>No(l.filter(h=>h.label.kind===u),$o[u].x,$o[u].y,zo[u]))],f=new Set(d.map(u=>u.label.id));for(let{label:u,screen:h}of d){let b=this.nodeFor(u).style;b.display="",b.transform=`translate(-50%, -50%) translate(${h.x.toFixed(1)}px, ${h.y.toFixed(1)}px)`}for(let[u,h]of this.nodes)f.has(u)||(h.style.display="none")}nodeFor(e){let n=this.nodes.get(e.id);if(!n){n=document.createElement("div");let l=n.style;l.position="absolute",l.left="0",l.top="0",l.whiteSpace="nowrap",l.textShadow="0 1px 3px rgba(0,0,0,0.85), 0 0 8px rgba(0,0,0,0.55)",l.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=oa[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=aa(e.color??this.opts.ink,this.opts.backgroundRgb),s=!Ko.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 Et,Mesh as kt,Transform as ar}from"ogl";import{Program as Ne}from"ogl";var Dt=`
|
|
2
2
|
float chairWeight(float depth) {
|
|
3
3
|
return 1.0 - smoothstep(uChairFull, uChairNone, depth);
|
|
4
|
-
}`,
|
|
4
|
+
}`,Qo=`
|
|
5
5
|
float occupantWeight(float depth) {
|
|
6
|
-
float nearWeight = smoothstep(${
|
|
7
|
-
float farWeight = 1.0 - smoothstep(${
|
|
6
|
+
float nearWeight = smoothstep(${Hn.toFixed(1)}, ${Un.toFixed(1)}, depth);
|
|
7
|
+
float farWeight = 1.0 - smoothstep(${Gn.toFixed(1)}, ${Nn.toFixed(1)}, depth);
|
|
8
8
|
return nearWeight * farWeight;
|
|
9
|
-
}`,
|
|
9
|
+
}`,sa=`#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
|
-
}`,
|
|
45
|
+
}`,ca=`#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
|
-
}`,
|
|
107
|
+
}`,la=`#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
|
-
${
|
|
133
|
+
${Dt}
|
|
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
|
-
}`,
|
|
166
|
+
}`,ua=`#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
|
-
}`,
|
|
224
|
+
}`,ma=`#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
|
-
${
|
|
255
|
-
${
|
|
254
|
+
${Dt}
|
|
255
|
+
${Qo}
|
|
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
|
-
}`,
|
|
338
|
+
}`,da=`#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
|
-
}`,
|
|
388
|
+
}`,ha=`#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
|
-
}`,
|
|
395
|
+
}`,pa=`#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
|
-
}`,
|
|
406
|
+
}`,fa=`#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
|
-
${
|
|
427
|
+
${Dt}
|
|
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
|
-
}`,
|
|
443
|
+
}`,ba=`#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
|
-
}`,
|
|
457
|
+
}`,ya=`#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
|
-
${
|
|
478
|
-
${
|
|
477
|
+
${Dt}
|
|
478
|
+
${Qo}
|
|
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;
|
|
@@ -505,7 +505,7 @@ void main() {
|
|
|
505
505
|
float c = cos(iYaw), s = sin(iYaw);
|
|
506
506
|
vec3 rp = vec3(p.x * c + p.z * s, p.y, -p.x * s + p.z * c);
|
|
507
507
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(iOffset + rp, 1.0);
|
|
508
|
-
}`,
|
|
508
|
+
}`,xa=`#version 300 es
|
|
509
509
|
precision highp float;
|
|
510
510
|
flat in vec3 vPick;
|
|
511
511
|
in float vHidden;
|
|
@@ -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
|
-
}`,
|
|
516
|
+
}`,ga=`#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
|
-
}`,
|
|
527
|
+
}`,va=`#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 Jo(t){return new Ne(t,{vertex:fa,fragment:ba,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uSeatRadius:{value:ve},uSeatScale:{value:1},uMinPixels:{value:We},uPixelToWorld:{value:.002},uChairFull:{value:rt},uChairNone:{value:je},uFocusFloor:{value:-1}}})}function er(t){return new Ne(t,{vertex:ya,fragment:xa,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uChairFull:{value:rt},uChairNone:{value:je},uBackRake:{value:qt},uBackBase:{value:Ct},uFocusFloor:{value:-1}}})}function tr(t){return new Ne(t,{vertex:ga,fragment:va,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uFocusFloor:{value:-1}}})}function nr(t){return new Ne(t,{vertex:sa,fragment:ca,cullFace:!1,depthTest:!0,depthWrite:!0,uniforms:{uKeyDir:{value:new Float32Array([.38,.86,.34])},uFocusFloor:{value:-1},uStructureDetail:{value:0}}})}function or(t){return new Ne(t,{vertex:la,fragment:ua,transparent:!0,depthTest:!0,depthWrite:!1,cullFace:!1,uniforms:{uSeatRadius:{value:ve},uSeatScale:{value:1},uMinPixels:{value:We},uPixelToWorld:{value:.002},uSeatFade:{value:0},uSeatDetail:{value:0},uFocusFloor:{value:-1},uFadeColor:{value:new Float32Array([.32,.37,.43])},uChairFull:{value:rt},uChairNone:{value:je}}})}function rr(t){return new Ne(t,{vertex:ma,fragment:da,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:rt},uChairNone:{value:je},uBackRake:{value:qt},uBackBase:{value:Ct},uFocusFloor:{value:-1}}})}function ir(t,e,n){return new Ne(t,{vertex:ha,fragment:pa,depthTest:!1,depthWrite:!1,cullFace:!1,uniforms:{uTop:{value:new Float32Array(e)},uBottom:{value:new Float32Array(n)}}})}function sr(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 Ma=new Float32Array([-1,-1,1,-1,1,1,-1,-1,1,1,-1,1]),Sa=new Float32Array([-1,-1,3,-1,-1,3]);function cr(t,e){let n=new ar,i=new ar,o=new Et(t,{position:{size:2,data:Sa}}),r=ir(t,e.theme.background.top,e.theme.background.bottom),a=new kt(t,{geometry:o,program:r});a.frustumCulled=!1,a.setParent(i);let s=new Et(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=nr(t),c=new kt(t,{geometry:s,program:l});c.frustumCulled=!1,c.setParent(n);let m=or(t),d=new Float32Array(e.seats.count*3),f=fe.map(I=>e.theme.seatStates[I]);sr(d,e.seats.iState,0,e.seats.count,f,e.seats.iCategory);let u=new Et(t,{position:{size:2,data:Ma},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}}),h=new kt(t,{geometry:u,program:m});h.frustumCulled=!1,e.seats.count>0&&h.setParent(n);let p=u.attributes.iColor,b=Kn(),x=rr(t),y=vt,S=new Float32Array(y*3),E=new Float32Array(y*3),A=new Float32Array(y),w=new Float32Array(y),k=new Float32Array(y*3),_=new Float32Array(y),L=new Float32Array(y),N=new Float32Array(y),O=new Float32Array(y),B=new Et(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:S,instanced:1},iColor:{size:3,data:E,instanced:1},iRadius:{size:1,data:A,instanced:1},iYaw:{size:1,data:w,instanced:1},iRing:{size:3,data:k,instanced:1},iFloor:{size:1,data:_,instanced:1},iPhysicalSeat:{size:1,data:L,instanced:1},iSeed:{size:1,data:O,instanced:1},iPickIndex:{size:1,data:N,instanced:1}}),g=new kt(t,{geometry:B,program:x});g.frustumCulled=!1;let M=0,C=new Int32Array(0),G=()=>{let I=e.seats;for(let D=0;D<M;D++){let T=C[D];O[D]=Qn(I.iState[T],T);let F=I.iCategory&&I.iState[T]===0?null:f[I.iState[T]]??f[0];if(F)E[D*3]=F[0],E[D*3+1]=F[1],E[D*3+2]=F[2];else{let V=Bn([I.iCategory[T*3],I.iCategory[T*3+1],I.iCategory[T*3+2]]);E[D*3]=V[0],E[D*3+1]=V[1],E[D*3+2]=V[2]}}B.attributes.iColor.needsUpdate=!0,B.attributes.iSeed.needsUpdate=!0},v={main:n,background:i,seatProgram:m,solidProgram:l,chairProgram:x,seatGeometry:u,chairGeometry:B,solidGeometry:s,drawCalls:3,setNearSeats(I,D){let T=Math.min(D,y);if(C=I,M=T,T===0){g.parent&&g.setParent(null),B.instancedCount=0,v.drawCalls=3;return}let P=e.seats;for(let F=0;F<T;F++){let V=I[F];S[F*3]=P.iPosition[V*3],S[F*3+1]=P.iPosition[V*3+1],S[F*3+2]=P.iPosition[V*3+2],A[F]=P.iChairWidth[V],w[F]=P.iYaw[V],k[F*3]=P.iRing[V*3],k[F*3+1]=P.iRing[V*3+1],k[F*3+2]=P.iRing[V*3+2],_[F]=P.iFloor[V],L[F]=P.iPhysicalSeat[V],N[F]=V+1}G(),B.attributes.iOffset.needsUpdate=!0,B.attributes.iRadius.needsUpdate=!0,B.attributes.iYaw.needsUpdate=!0,B.attributes.iRing.needsUpdate=!0,B.attributes.iFloor.needsUpdate=!0,B.attributes.iPhysicalSeat.needsUpdate=!0,B.attributes.iSeed.needsUpdate=!0,B.attributes.iPickIndex.needsUpdate=!0,B.instancedCount=T,g.parent||g.setParent(n),v.drawCalls=4},nearSeatCount(){return M},uploadSeatStateRuns(I){if(!I.length)return;M&&G();for(let T of I)sr(d,e.seats.iState,T.start,T.length,f,e.seats.iCategory);let D=p.buffer;if(!D){p.needsUpdate=!0;return}t.bindBuffer(t.ARRAY_BUFFER,D);for(let T of I){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(),l.remove(),u.remove(),m.remove(),B.remove(),x.remove()}};return v}import{Mesh as an,RenderTarget as Pa,Transform as sn}from"ogl";function wa(t,e,n){let i=t+(e<<8)+(n<<16);return i===0?-1:i-1}function lr(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 m=(l*e+c)*4,d=wa(t[m],t[m+1],t[m+2]);if(d<0||d>=r)continue;let f=c-i,u=l-o,h=f*f+u*u;h<s&&(s=h,a=d)}return a}function ur(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 Aa=["uSeatRadius","uSeatScale","uMinPixels","uPixelToWorld"],Lt=class{constructor(e,n,i,o,r){this.seatScene=new sn;this.chairScene=new sn;this.solidScene=new sn;this.target=null;this.restoreClear=[0,0,0];this.renderer=e,this.gl=e.gl,this.maxIndex=r,this.seatProg=Jo(this.gl),this.chairProg=er(this.gl),this.depthProg=tr(this.gl);let a=new an(this.gl,{geometry:n,program:this.seatProg});a.frustumCulled=!1,a.setParent(this.seatScene);let s=new an(this.gl,{geometry:i,program:this.chairProg});s.frustumCulled=!1,s.setParent(this.chairScene);let l=new an(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 Aa)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 Pa(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),m=Math.max(0,i-o),d=Math.max(1,Math.min(s,n+o+1)-c),f=Math.max(1,Math.min(l,i+o+1)-m);r.enable(r.SCISSOR_TEST),r.scissor(c,m,d,f);let[u,h,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(u,h,p,1),r.disable(r.SCISSOR_TEST);let b=new Uint8Array(d*f*4);return this.renderer.bindFramebuffer(a),r.readPixels(c,m,d,f,r.RGBA,r.UNSIGNED_BYTE,b),this.renderer.bindFramebuffer(),lr(b,d,f,n-c,i-m,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,ot(i.state)):n.push(i);return n}function dr(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:fe[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 ht,Vec3 as Ia}from"ogl";function Ca(t,e){return[t[0]-e[0],t[1]-e[1],t[2]-e[2]]}function hr(t,e){return[t[0]+e[0],t[1]+e[1],t[2]+e[2]]}function Ra(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 cn(t){let e=Math.max(0,Math.min(1,t));return e*e*e*(e*(e*6-15)+10)}function ln(t,e){return Math.max(0,Math.min(1,t+e))}function fr(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],m=t[Math.min(n-1,r+2)],d=a*a,f=d*a,u=[0,0,0];for(let h=0;h<3;h++)u[h]=.5*(2*l[h]+(-s[h]+c[h])*a+(2*s[h]-5*l[h]+4*c[h]-m[h])*d+(-s[h]+3*l[h]-3*c[h]+m[h])*f);return u}function un(t,e,n,i,o){let r=pr(Ca(e,n));r[0]===0&&r[1]===0&&r[2]===0&&(r=[0,0,1]);let a=hr(hr(e,Ra(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),m=[i[0]+l[0]*c*1.3,i[1]+c*.75,i[2]+l[2]*c*1.3];return{waypoints:[t,m,a],finalPos:a}}function mn(t,e,n=35,i=28){let o=cn(e),r=fr(t,o),a=cn(Math.max(0,Math.min(1,(e-.66)/.34)));return{pos:r,fov:n+(i-n)*a,eased:o}}function xr(t,e,n){let i=t.position.clone(),o=new ht().copy(t.quaternion);t.position.set(e[0],e[1],e[2]),t.lookAt(new Ia(n[0],n[1],n[2]));let r=new ht().copy(t.quaternion);return t.position.copy(i),t.quaternion.copy(o),r}var _t=class{constructor(e){this.active=!1;this.waypoints=[];this.startQuat=new ht;this.endQuat=new ht;this.outQuat=new ht;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}=mn(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,ln(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 Ta=1.02,Fa=1.5;function gr(t,e,n=0,i){let o=Number.isFinite(i)?n+i:t[1]+Ta;return{eye:[t[0],o,t[2]],focal:[e.x*R,n+Fa,e.y*R]}}import{Geometry as Da,Mesh as Ea,Program as ka,Texture as La}from"ogl";var _a=64,Oa=32,Ba=500;function Va(t=_a,e=Oa,n=Ba){let i=t+1,o=e+1,r=i*o,a=new Float32Array(r*3),s=new Float32Array(r*2);for(let m=0;m<o;m++){let d=m/e,f=d*Math.PI,u=Math.sin(f),h=Math.cos(f);for(let p=0;p<i;p++){let b=p/t,x=(b-.5)*Math.PI*2,y=m*i+p;a[y*3]=n*u*Math.sin(x),a[y*3+1]=n*h,a[y*3+2]=-n*u*Math.cos(x),s[y*2]=b,s[y*2+1]=d}}let l=new Uint16Array(t*e*6),c=0;for(let m=0;m<e;m++)for(let d=0;d<t;d++){let f=m*i+d,u=f+i;l[c++]=f,l[c++]=u,l[c++]=f+1,l[c++]=f+1,l[c++]=u,l[c++]=u+1}return{position:a,uv:s,index:l}}function vr(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 za=`#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
|
-
}`,
|
|
544
|
+
}`,Ga=`#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 Mr(t,e){let{position:n,uv:i,index:o}=Va(),r=new Da(t,{position:{size:3,data:n},uv:{size:2,data:i},index:{data:o}}),a=new La(t,{image:e,wrapS:t.CLAMP_TO_EDGE,wrapT:t.CLAMP_TO_EDGE,generateMipmaps:!0,flipY:!1}),s=new ka(t,{vertex:za,fragment:Ga,uniforms:{uPano:{value:a},uOpacity:{value:0}},transparent:!0,depthTest:!1,depthWrite:!1}),l=new Ea(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 Sr=.15;async function wr(t,e,n,i={}){let o=i.fadeMs??400,r=e?.initialBearingDeg??0,a=Math.max(-ge,Math.min(ge,e?.initialPitchDeg??0)),s=kn,l=!1,c=new AbortController,m=()=>c.abort();i.signal?.addEventListener("abort",m,{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,V=n.focalWorld[1]-P.y,U=n.focalWorld[2]-P.z,X=Math.hypot(F,U);X>.001&&(r=Math.atan2(F,-U)*180/Math.PI,a=Math.max(-ge,Math.min(ge,Math.atan2(V,X)*180/Math.PI)))}let u=null;if(e){let P=n.gl.getParameter(n.gl.MAX_TEXTURE_SIZE),F=Cn(e,An(P)),V;try{let U=e.resolveUrl?await e.resolveUrl(F.initialUrl):F.initialUrl;if(!U)throw new Error("panorama_asset_unavailable");V=await Gt(U,c.signal)}catch{return i.signal?.removeEventListener("abort",m),null}try{u=Mr(n.gl,V)}catch{return c.abort(),i.signal?.removeEventListener("abort",m),null}u.mesh.renderOrder=999,u.mesh.setParent(n.scene),F.upgradeUrl&&(d=Rn(()=>{(e.resolveUrl?e.resolveUrl(F.upgradeUrl):Promise.resolve(F.upgradeUrl)).then(X=>!X||c.signal.aborted?null:Gt(X,c.signal)).then(X=>{X&&(l||c.signal.aborted||(u?.setImage(X),n.requestRender()))}).catch(()=>{})}))}let h=n.camera.fov;n.camera.perspective({fov:s,aspect:n.camera.aspect});let p=n.camera.quaternion.slice(),b=()=>{let P=n.camera.position;u?.mesh.position.set(P.x,P.y,P.z);let[F,V,U]=vr(r,a);n.camera.lookAt([P.x+F,P.y+V,P.z+U]),n.requestRender()};b();let x=document.createElement("div"),y=document.activeElement instanceof HTMLElement?document.activeElement:null;x.setAttribute("role","dialog"),x.setAttribute("aria-modal","true"),x.setAttribute("aria-label",i.seatLabel?`View from ${i.seatLabel}`:"View from seat"),x.tabIndex=-1,Object.assign(x.style,{position:"absolute",inset:"0",zIndex:"10",cursor:"grab",touchAction:"none"});let S=document.createElement("button");if(S.type="button",S.setAttribute("aria-label","Close"),S.textContent="\u2715",Object.assign(S.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"}),x.appendChild(S),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)"}),x.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"}),x.appendChild(E),t.appendChild(x),S.focus({preventScroll:!0});let A=!1,w=0,k=0,_=0,L=new Map,N=()=>{let[P,F]=[...L.values()];return P&&F?Math.hypot(P.x-F.x,P.y-F.y):0},O=P=>{let F=Ln(P);F!==s&&(s=F,n.camera.perspective({fov:s,aspect:n.camera.aspect}),b())},B=P=>{P.target!==S&&(L.set(P.pointerId,{x:P.clientX,y:P.clientY}),A=L.size===1,w=P.clientX,k=P.clientY,L.size===2&&(_=N()),x.setPointerCapture?.(P.pointerId),x.style.cursor="grabbing")},g=P=>{if(L.has(P.pointerId)){if(L.set(P.pointerId,{x:P.clientX,y:P.clientY}),L.size>=2){let F=N();_>0&&F>0&&O(s*(_/F)),_=F,A=!1;return}A&&(r+=(P.clientX-w)*Sr,a=Math.max(-ge,Math.min(ge,a+(P.clientY-k)*Sr)),w=P.clientX,k=P.clientY,b())}},M=P=>{L.delete(P.pointerId),_=L.size===2?N():0;let F=L.values().next().value;A=L.size===1,F?(w=F.x,k=F.y):x.style.cursor="grab";try{x.releasePointerCapture?.(P.pointerId)}catch{}},C=P=>{P.preventDefault(),O(s+P.deltaY*.04)};x.addEventListener("pointerdown",B),x.addEventListener("pointermove",g),x.addEventListener("pointerup",M),x.addEventListener("pointercancel",M),x.addEventListener("wheel",C,{passive:!1});let G=P=>{if(!l){if(P.key==="Tab"){P.preventDefault(),S.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(-ge,Math.min(ge,a+(P.key==="ArrowUp"?4:-4)));else if(P.key==="+"||P.key==="="){O(s-5),P.preventDefault();return}else if(P.key==="-"){O(s+5),P.preventDefault();return}else return;P.preventDefault(),b()}};window.addEventListener("keydown",G);let v=0,I=(P,F)=>{if(!u){F?.();return}let V=P===1?0:1,U=performance.now(),X=()=>{if(l)return;let W=o<=0?1:Math.min(1,(performance.now()-U)/o);u?.setOpacity(V+(P-V)*W),n.requestRender(),W<1?v=requestAnimationFrame(X):F?.()};v=requestAnimationFrame(X)};I(1);let D=()=>{l||(l=!0,d(),c.abort(),i.signal?.removeEventListener("abort",m),cancelAnimationFrame(v),x.removeEventListener("pointerdown",B),x.removeEventListener("pointermove",g),x.removeEventListener("pointerup",M),x.removeEventListener("pointercancel",M),x.removeEventListener("wheel",C),window.removeEventListener("keydown",G),x.remove(),y?.isConnected&&y.focus({preventScroll:!0}),u?.dispose(),n.camera.position.set(f[0],f[1],f[2]),n.camera.perspective({fov:h,aspect:n.camera.aspect}),n.camera.quaternion.set(p[0],p[1],p[2],p[3]),n.requestRender())},T={close(){if(l)return;let P=()=>{D(),i.onClose?.()};cancelAnimationFrame(v),I(0,P)},dispose:D};return S.addEventListener("click",()=>T.close()),T}function Pr(t){let{container:e,model:n,opts:i,analytics:o,orbit:r,loop:a,seatsById:s,ensureSeatView:l,resolvedSeatViewPose:c,gpu:m,gl:d,isContextLost:f,isDisposed:u,flightGen:h,setPanorama:p,getLoadAbort:b,setLoadAbort:x,setPanoramaSphereVisible:y,setFrozen:S,raisePanoramaLayer:E,restorePanoramaLayer:A,getOverviewChip:w,labelOverlay:k,reducedMotion:_,removeArriveChip:L,showArriveChip:N}=t;return async(O,B,g)=>{b()?.abort();let M=new AbortController;x(M);let C=n.seats.idToIndex.get(O);if(C===void 0){r.syncFromCamera();return}let G=s.get(O)?.label??O,v=c(O,C),I=l(O);if(!I){M.abort(),b()===M&&x(null),r.syncFromCamera();return}S(!0),a.stop();let D;try{D=await I}catch{if(b()===M&&x(null),o.panoramaFailed(O,"source"),!u()&&g===h()){S(!1),r.resumeAfterFlight(v.focal),a.requestRender();let Y=N(O,g,!0);requestAnimationFrame(()=>Y?.querySelector("[data-panorama-trigger]")?.focus())}return}if(u()||g!==h()){M.abort(),b()===M&&x(null);return}L();let T=w(),P=()=>{M.abort(),b()===M&&x(null),p(null),y(!1),A(),T.style.display="",k.setVisible(!i.arriveAtSeatEye),S(!1),o.panoramaClosed(),r.resumeAfterFlight(v.focal),a.requestRender();let Y=N(O,h());requestAnimationFrame(()=>Y?.querySelector("[data-panorama-trigger]")?.focus())},F=D.generated===!0,V=En(D);E(),y(!F),T.style.display="none";let U=_()?0:B,X=m(),W=X&&!f()?await wr(e,F?null:D,{gl:d,scene:X.main,camera:r.camera,requestRender:()=>a.requestRender(),cameraOriginWorld:F?v.eye:void 0,focalWorld:v.focal},{fadeMs:U,seatLabel:G,disclosure:V,disclosurePrefix:F?"Live seat-eye view":"360\xB0 panorama",onClose:P,signal:M.signal}):null;if(u()||g!==h()){M.abort(),y(!1),b()===M&&x(null),W?.dispose(),T.style.display="",A();return}if(W)r.syncFromCamera(),k.setVisible(!1),S(!1),a.requestRender(),p(W);else if(F){A(),T.style.display="",S(!1),r.resumeAfterFlight(v.focal),a.requestRender(),p(null),y(!1),o.panoramaFailed(O,"mount");let Y=N(O,h(),!0);requestAnimationFrame(()=>Y?.querySelector("[data-panorama-trigger]")?.focus()),b()===M&&x(null);return}else y(!1),o.panoramaFallback(O),p(_n(e,D,{fadeMs:U,seatLabel:G,disclosure:V,onClose:P,signal:M.signal}));o.panoramaOpened()}}var Ar=()=>typeof performance<"u"&&performance.now?performance.now():Date.now(),Ot=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=Ar(),this.emit("3d_panorama_opened")}panoramaClosed(){let e=this.panoramaOpenedAt?Math.round(Ar()-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 Cr(t){let e=t.style.position;return getComputedStyle(t).position!=="static"?()=>{}:(t.style.position="relative",()=>{t.style.position==="relative"&&(t.style.position=e)})}function Rr(t){let{container:e,model:n,opts:i,expandedSeatById:o,seatIdsByRow:r,isNarrow:a}=t,s=null,l=()=>{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"})},c=()=>{s?.remove(),s=null};return{show:(d,f,u=!1)=>{if(c(),t.isDisposed())return null;let h=document.createElement("div");h.setAttribute("role","group"),Object.assign(h.style,{position:"absolute",display:"flex",flexDirection:"column",alignItems:"center",gap:"6px",zIndex:"4"});let p=o.get(d),b=p?.sectionId?n.sections.find(_=>_.id===p.sectionId):void 0,x=p?.label??d;h.setAttribute("aria-label",`Explore views near ${b?.label?`${b.label}, `:""}seat ${x}`);let y=document.createElement("span");y.textContent=["Live 3D seat view",b?.label,x].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)"}),h.appendChild(y);let S=document.createElement("div");Object.assign(S.style,{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px"}),h.appendChild(S);let E=p?.rowId?r.get(p.rowId):void 0,A=E?.indexOf(d)??-1,w=A>=0?[E?.[A-1],E?.[A+1]]:[void 0,void 0],k=(_,L,N,O=!1)=>{let B=document.createElement("button");B.type="button",B.textContent=_,B.setAttribute("aria-label",L),Object.assign(B.style,{minHeight:"44px",padding:O?"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"}),O||(B.style.minWidth="44px"),O&&(B.dataset.panoramaTrigger=""),B.addEventListener("click",N),S.appendChild(B)};if(w[0]){let _=o.get(w[0])?.label??w[0];k("\u2039",`View previous seat ${_}`,()=>{t.flyToSeat(w[0])})}if(i.getSeatView){let _=i.seatViewActionLabel?.(d)??"Open 360\xB0 panorama";k(u?`\u21BB Retry ${_}`:`\u25C9 ${_}`,`${u?"Retry":_} from seat ${x}`,()=>{if(t.isDisposed()||f!==t.flightGen()){c();return}c(),t.openPanorama(d,400,f)},!0)}if(w[1]){let _=o.get(w[1])?.label??w[1];k("\u203A",`View next seat ${_}`,()=>{t.flyToSeat(w[1])})}return S.childElementCount?(e.appendChild(h),s=h,l(),h):null},remove:c,layout:l}}function Ir(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 m=document.createElement("button");m.type="button",m.textContent="\u2212",m.setAttribute("aria-label","Zoom out of the 3D venue"),m.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[l,c,m,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(l,c),s.append(d,m);let f=p=>{n.setPrimaryDragMode(p);let b=p==="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",()=>f("orbit")),c.addEventListener("click",()=>f("pan")),m.addEventListener("click",()=>n.zoomBy(1.22)),d.addEventListener("click",()=>n.zoomBy(.82)),o.append(a,s),f("orbit"),e.appendChild(o);let u=()=>{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":"",m.style.display=p?"none":""};return u(),{element:o,utilityControls:s,setNavigationMode:f,setSeatViewLocked:p=>{r=p,n.setInteractionEnabled(!p),u()},seatViewLocked:()=>r,layout:u}}function Tr(t){let{glctx:e,orbit:n,model:i,seats:o,opts:r,cinematic:a,analytics:s,seatIdByIndex:l,sectionIdBySeatId:c,tapSlop:m,tapMs:d,cancelFlight:f,focusSectionCamera:u,setSelection:h,ensureSeatView:p}=t,b=0,x=0,y=0,S=-1,E=!1,A=!1,w=O=>{t.seatViewLocked()||S===-1&&(S=O.pointerId,b=O.clientX,x=O.clientY,y=performance.now(),E=!1,A=a.active,a.active&&(s.cinematicCancelled(),f(),r.onViewTargetChange?.(null)))},k=O=>{O.pointerId===S&&Math.hypot(O.clientX-b,O.clientY-x)>m&&(E=!0)},_=(O,B,g,M,C)=>{let G=e.canvas.getBoundingClientRect(),v=e.canvas.clientWidth||G.width||1,I=e.canvas.clientHeight||G.height||1,D=O-G.left,T=B-G.top,P=M*M,F=-1,V=P,U=1/0;for(let X of o){if(g&&X.sectionId!==g)continue;let W=i.seats.idToIndex.get(X.id);if(W===void 0)continue;if(C){let K=Math.round(i.seats.iState[W]??0);if(K!==0&&K!==3)continue}let Y=W*3,$=Tt(n.camera.projectionViewMatrix,[i.seats.iPosition[Y],i.seats.iPosition[Y+1]+.55,i.seats.iPosition[Y+2]],v,I);if(!$.visible)continue;let Q=$.x-D,J=$.y-T,te=Q*Q+J*J;(te<V||Math.abs(te-V)<1&&$.depth<U)&&(F=W,V=te,U=$.depth)}return F},L=(O,B)=>{let g=t.gpu(),M=t.pick();if(!g||!M)return-1;M.syncFromSeatProgram(g.seatProgram);let C=e.canvas.getBoundingClientRect(),G=e.renderer.dpr,{x:v,y:I}=ur(O,B,C,G,e.gl.drawingBufferWidth,e.gl.drawingBufferHeight),D=Math.max(2,Math.round(8*G));return M.pick(n.camera,v,I,D)};return{onDown:w,onMove:k,onUp:O=>{if(O.pointerId!==S)return;let B=!E&&performance.now()-y<d;if(S=-1,A){A=!1;return}let g=t.gpu(),M=t.pick();if(!B||!g||!M)return;let C=L(O.clientX,O.clientY);if(t.focusedSectionId()&&C>=0){let I=l[C],D=I?c.get(I):void 0;if(D&&D!==t.focusedSectionId()&&u(D))return}if(t.focusedSectionId()&&C<0&&(C=_(O.clientX,O.clientY,t.focusedSectionId(),44,!1)),t.focusedSectionId()&&C<0){let I=_(O.clientX,O.clientY,null,72,!1),D=I>=0?l[I]:void 0,T=D?c.get(D):void 0;if(T&&T!==t.focusedSectionId()&&u(T))return}if(!t.focusedSectionId()){C<0&&(C=_(O.clientX,O.clientY,null,42,!1));let I=C>=0?l[C]:void 0,D=I?c.get(I):void 0;if(D&&u(D))return}if(C<0||C>=l.length){t.selection().size&&(h([]),r.onViewTargetChange?.(null));return}let G=l[C],v=fe[Math.round(i.seats.iState[C]??0)]??"available";if(v!=="available"&&v!=="selected"){r.onSeatInspect?.(G,v);return}if(t.selection().has(G)&&t.selection().size===1){h([]),r.onViewTargetChange?.(null);return}h([G]),p(G),s.seatPicked(G,c.get(G)),r.onSeatPick?.(G)}}}var Bt=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 u=0;u<this.count;u++){let h=e[u*3],p=e[u*3+2];h<n&&(n=h),h>o&&(o=h),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 l=this.cols*this.rows,c=new Int32Array(l+1),m=u=>{let h=Math.min(this.cols-1,Math.max(0,Math.floor((e[u*3]-n)/this.cell)));return Math.min(this.rows-1,Math.max(0,Math.floor((e[u*3+2]-i)/this.cell)))*this.cols+h};for(let u=0;u<this.count;u++)c[m(u)+1]++;for(let u=0;u<l;u++)c[u+1]+=c[u];let d=new Int32Array(this.count),f=c.slice(0,l);for(let u=0;u<this.count;u++)d[f[m(u)]++]=u;this.cellStart=c,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,l=i*i,c=Math.floor((e-this.minX)/this.cell),m=Math.floor((n-this.minZ)/this.cell),d=Math.ceil(i/this.cell)+1,f=this.iPosition,u=0;for(let h=0;h<=d&&u<s;h++){let p=m-h,b=m+h,x=c-h,y=c+h;for(let S=p;S<=b&&u<s;S++){if(S<0||S>=this.rows)continue;let E=S===p||S===b;for(let A=x;A<=y&&u<s;A++){if(!E&&A!==x&&A!==y){A=y-1;continue}if(A<0||A>=this.cols)continue;let w=S*this.cols+A;for(let k=r[w],_=r[w+1];k<_&&u<s;k++){let L=a[k],N=f[L*3]-e,O=f[L*3+2]-n;N*N+O*O<=l&&(o[u++]=L)}}}}return u}};var Vt=class{constructor(e){this.ctx=e;this.detailVisible=!1;this.seatDetailMix=0;this.structureDetailMix=0;this.nearBuf=new Int32Array(vt);this.lastGatherX=1/0;this.lastGatherZ=1/0;this.nearIndex=new Bt(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)<Wt)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>Xt){i.nearSeatCount()&&i.setNearSeats(this.nearBuf,0);return}let s=this.nearIndex.gather(o.x,o.z,Xt,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 Na,Vec3 as Ha}from"ogl";function Fr(t){let{container:e,model:n,opts:i,orbit:o,cinematic:r,analytics:a,loop:s,labelOverlay:l,stageAzimuth:c,overviewFraming:m}=t,d=0,f=-1,u=(A,w,k=28)=>{o.camera.position.set(A[0],A[1],A[2]),o.camera.lookAt(new Ha(w[0],w[1],w[2])),o.camera.fov=k,o.camera.updateProjectionMatrix()},h=document.createElement("button");h.className="sl-3d-overview-control sl-3d-icon-control",h.type="button",h.textContent="\u2302",h.setAttribute("aria-label","Fit the active level or whole venue in view"),h.dataset.tooltip="Fit view",Object.assign(h.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=()=>{h.textContent="\u2302"};p();let b=A=>{f=A;let w=t.gpu();w&&(w.seatProgram.uniforms.uFocusFloor.value=A,w.solidProgram.uniforms.uFocusFloor.value=A,w.chairProgram.uniforms.uFocusFloor.value=A),t.showSectionSeatLabels(null)},x=()=>{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(),h.style.display="",l.setVisible(!0),t.setFrozen(!1);let A=f>=0?n.floors[f]:null;if(t.setNearFieldDetailEnabled(!!A),t.setSeatViewLocked(!1),y(),t.removeArriveChip(),t.setNavigationMode("orbit"),A){let w=A.focalWorld[0]-A.center[0],k=A.focalWorld[2]-A.center[2],_=Math.hypot(w,k)>A.radius*.12?Math.atan2(w,k):c,L={center:A.center,radius:A.radius,box:A.box},N={polarDeg:58,margin:1.12};t.reducedMotion()?o.frame(L,!1,_,!1,N):o.frameSoft(L,_,!1,N)}else t.reducedMotion()?o.frame(n.bounds,!1,c,i.portraitOverviewCrop===!0,m):o.frameSoft(n.bounds,c,i.portraitOverviewCrop===!0,m);t.showSectionSeatLabels(null),s.requestRender()},y=()=>{d++,t.panoramaLoadAbort()?.abort(),t.setPanoramaLoadAbort(null),r.active&&(r.cancel(),o.resumeAfterFlight(n.focalWorld))},S=A=>{if(t.isDisposed()||!t.gpu())return Promise.resolve();let w=n.seats.idToIndex.get(A);if(w===void 0)return Promise.resolve();t.setNearFieldDetailEnabled(!0),i.onViewTargetChange?.(A),t.panorama()&&(t.panorama().dispose(),t.setPanorama(null),t.setPanoramaSphereVisible(!1),h.style.display="",t.restorePanoramaLayer()),t.panoramaLoadAbort()?.abort(),t.setPanoramaLoadAbort(null),t.setFrozen(!1),t.setSeatViewLocked(!1);let k=++d;t.removeArriveChip();let{eye:_,focal:L}=t.resolvedSeatViewPose(A,w),N=[o.camera.position.x,o.camera.position.y,o.camera.position.z],O=un(N,_,L,n.bounds.center,n.bounds.radius),B=i.arriveAtSeatEye?_:O.finalPos,g=i.arriveAtSeatEye?e.clientWidth/Math.max(1,e.clientHeight)<.7?90:65:28,M=[O.waypoints[0],O.waypoints[1],B];if(l.setVisible(!1),t.reducedMotion())return u(B,L,g),s.requestRender(),a.cinematicSkipped(),t.isDisposed()||o.syncFromCamera(),t.setSeatViewLocked(i.arriveAtSeatEye===!0),t.showArriveChip(A,k),Promise.resolve();let C=new Na().copy(o.camera.quaternion),G=xr(o.camera,B,L);return s.requestRender(),r.start(M,C,G,2500,g).then(()=>{t.isDisposed()||k!==d||(a.cinematicPlayed(2500),o.resumeAfterFlight(L),t.setSeatViewLocked(i.arriveAtSeatEye===!0),s.requestRender(),t.showArriveChip(A,k))})},E=A=>{let w=n.sections.find(N=>N.id===A);if(!w||w.seatCount===0)return!1;t.setNearFieldDetailEnabled(!0),t.setSeatViewLocked(!1),r.cancel(),t.removeArriveChip(),n.floors.length>1&&f!==w.floorIndex&&b(w.floorIndex),t.setNavigationMode("pan"),t.showSectionSeatLabels(A);let k=w.focalWorld[0]-w.center[0],_=w.focalWorld[2]-w.center[2],L=Math.hypot(k,_)>w.radius*.12?Math.atan2(k,_):void 0;return o.frame({center:w.center,radius:Math.max(5,w.radius*.5)},!1,L),i.onSectionFocusChange?.(A),s.requestRender(),!0};return h.addEventListener("click",x),{overviewChip:h,layoutOverviewChip:p,flightGen:()=>d,focusedFloor:()=>f,applyFloorFocus:b,placeCameraFinal:u,cancelFlight:y,focusOverview:x,flyToSeat:S,focusSectionCamera:E}}function Dr(t){let e=performance.now();return{model:dt(t),buildMs:performance.now()-e,source:"main"}}function Ua(t){return typeof Worker>"u"?Promise.resolve(Dr(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(Dr(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 Ya=Math.PI/180,Xa=6,Wa=500;function Pu(t,e,n={}){let i=performance.now(),o=e.prepared?.model??dt(e),r=new Ot(n.onAnalytics),a=new Array(o.seats.count);for(let[z,H]of o.seats.idToIndex)a[H]=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 H=l.get(z.rowId);H?H.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 m=e.doc.floors?.some(H=>(H.baseHeightM??0)>0)?!0:(e.doc.floors?.flatMap(H=>H.objects)??e.doc.objects).some(H=>H.type==="section"&&((H.height??0)>0||(H.rake??0)>0)),d=null,f=null,u=!1,h=!1,p=!1,b=new Map,x=null,y=null,S=null,E=new Map,A=null,w=()=>{S===null&&(S=t.style.zIndex,t.style.zIndex="20")},k=()=>{S!==null&&(t.style.zIndex==="20"&&(t.style.zIndex=S),S=null)},_=!1,L=()=>_?ce.focusedFloor():-1,N=()=>{d=cr(M.gl,o),f=new Lt(M.renderer,d.seatGeometry,d.chairGeometry,d.solidGeometry,o.seats.count),M.setClearColor(o.theme.background.top),f.setRestoreClear(o.theme.background.top),d.seatProgram.uniforms.uSeatRadius.value=ve*o.theme.seatScale,d.seatProgram.uniforms.uFocusFloor.value=L(),d.solidProgram.uniforms.uFocusFloor.value=L(),d.chairProgram.uniforms.uFocusFloor.value=L(),B.forceRegather()},O=!1,B=new Vt({model:o,orbit:()=>C,gpu:()=>d}),g=z=>B.setDetailEnabled(z),M=new yt(t,{onContextLost:()=>{p||r.contextLost(),u=!0,Y.stop(),d=null,f=null},onContextRestored:()=>{N(),u=!1,p||r.contextRestored(),Y.requestRender()}}),C=new xt(M.gl,M.canvas,()=>Y.requestRender(),()=>r.orbitEngaged());C.setAspect(M.aspect);let G=(e.doc.floors?.flatMap(z=>z.objects)??e.doc.objects).some(z=>z.type==="section"&&z.physical3dProvenance?.surfaceKind?.status==="inferred"),v=(()=>{if(G&&o.stages.length===0)return;let z=o.focalWorld[0]-o.bounds.center[0],H=o.focalWorld[2]-o.bounds.center[2];return Math.hypot(z,H)>o.bounds.radius*.12?Math.atan2(z,H):void 0})(),I=o.floors.length>1?{polarDeg:48,margin:1.1}:void 0,D=typeof window<"u"&&!!window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;C.frame(o.bounds,!D,v,n.portraitOverviewCrop===!0,I);let T=new _t(C.camera),P=Cr(t),F=new Ft(t,{fontFamily:e.doc.theme?.fontFamily,ink:e.doc.theme?.textColor,backgroundRgb:o.theme.background.top}),V=o.labels,U=()=>_o(V,o.floors.length,L());F.setLabels(U());let X=null,W=z=>{if(X=z,F.setForcedDense(!!z),!z){F.setLabels(U());return}let H=e.seats.filter(q=>q.sectionId===z),j=new Set(H.map(q=>q.id)),ne=new Set(H.map(q=>q.rowId)),oe=new Set(b.keys()),ee=new Set(H.filter(q=>oe.has(q.id)).map(q=>q.id)),Re=U().filter(q=>q.kind!=="row"&&q.kind!=="seat"||(q.kind==="row"?ne.has(q.id.slice(4)):j.has(q.id.slice(5))&&(ee.size===0||ee.has(q.id.slice(5)))));if(o.seatCount<=6e3&&ee.size===0){F.setLabels(Re);return}let Ie=ee.size?H.filter(q=>ee.has(q.id)):H,Qe=new Set(Ie.map(q=>`seat:${q.id}`)),Ye=Ie.flatMap(q=>{let Te=o.seats.idToIndex.get(q.id);if(Te===void 0)return[];let Je=Te*3;return[{id:`seat:${q.id}`,kind:"seat",text:q.displayLabel||q.label,anchor:[o.seats.iPosition[Je],o.seats.iPosition[Je+1]+(oe.has(q.id)?1.05:.55),o.seats.iPosition[Je+2]]}]});F.setLabels([...Re.filter(q=>!Qe.has(q.id)),...Ye])};N();let Y=new gt(z=>{if(u||!d||h)return!1;let j=T.active?T.update(performance.now()):C.update(),ne=L()>=0?o.floors[L()]:null,oe=ne?.radius??o.bounds.radius,ee=Yn(C.currentDistance,oe),Re=O?{center:[C.camera.position.x,C.camera.position.y,C.camera.position.z],radius:520}:o.renderBounds;C.updateClipping(Re);let Ie=ne?.center??o.renderBounds.center,Qe=ne?.radius??o.renderBounds.radius,Ye=(Oe,zt)=>Math.hypot(C.camera.position.x-Oe[0],C.camera.position.y-Oe[1],C.camera.position.z-Oe[2])<=zt*(B.detailVisible?1.8:1.55),q=Ye(Ie,Qe);if(!q&&X){let Oe=o.sections.find(zt=>zt.id===X);Oe&&(q=Ye(Oe.center,Math.max(12,Oe.radius*2)))}B.detailVisible=q;let Te=d.seatProgram.uniforms;Te.uSeatScale.value=ee.scale,Te.uSeatFade.value=ee.fade;let Je=!!ne&&Xn(ne.seatCount,M.canvas.clientWidth||1,M.canvas.clientHeight||1),_r=Wn(o.seats.count,oe,C.currentDistance,C.camera.fov,M.canvas.clientHeight||1),bn=B.detailVisible||Je||_r?1:0,yn=B.detailVisible||L()>=0||o.floors.length>1?1:0;return B.ease(z,bn,yn),Te.uSeatDetail.value=B.seatDetailMix,d.solidProgram.uniforms.uStructureDetail.value=B.structureDetailMix,Te.uMinPixels.value=ee.minPixels,Te.uPixelToWorld.value=2*Math.tan(C.camera.fov*Ya/2)/Math.max(1,M.pixelHeight),B.update(B.detailVisible),M.renderer.render({scene:d.background,clear:!0}),M.renderer.render({scene:d.main,camera:C.camera,clear:!1}),F.update(C.camera.projectionViewMatrix,M.canvas.clientWidth||1,M.canvas.clientHeight||1,C.currentDistance,oe,[C.camera.position.x,C.camera.position.y,C.camera.position.z]),j||B.seatDetailMix!==bn||B.structureDetailMix!==yn}),$=typeof ResizeObserver<"u"?new ResizeObserver(()=>fn.resize()):null;$?.observe(t);let Q=z=>{let H=oe=>{let ee=o.seats.idToIndex.get(oe);return ee===void 0?void 0:o.seats.iState[ee]},{updates:j,next:ne}=dr(b,z,H);if(b=ne,F.setSelectedSeatIds(b.keys()),X&&W(X),j.length){let oe=Kt(o.seats,j);d&&d.uploadSeatStateRuns(oe),Y.requestRender()}},J=()=>A!==null?A:typeof window<"u"&&!!window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,te=8,K=z=>{if(!n.getSeatView)return null;let H=E.get(z);if(!H)for(H=Promise.resolve(n.getSeatView(z)),E.set(z,H),H.catch(()=>{E.get(z)===H&&E.delete(z)});E.size>te;){let j=E.keys().next().value;if(j===void 0)break;E.delete(j)}return H},me=(z,H)=>{let j=s.get(z),ne=Math.max(0,Math.round(o.seats.iFloor[H]??0)),oe=e.doc.floors?.[ne],ee=o.floors[ne],Re=oe?.focalPoint??e.doc.focalPoint,Ie=ee?{x:ee.focalWorld[0]/R,y:ee.focalWorld[2]/R}:Re,Qe=j?.focalPoint?{x:j.focalPoint.x+Ie.x-Re.x,y:j.focalPoint.y+Ie.y-Re.y}:Ie,Ye=[o.seats.iPosition[H*3],o.seats.iPosition[H*3+1],o.seats.iPosition[H*3+2]];return gr(Ye,Qe,oe?.baseHeightM??0,j?.eyeHeightM)},ke=()=>(t.clientWidth||M.canvas.clientWidth)<=520,Le,be=Rr({container:t,model:o,opts:n,expandedSeatById:s,seatIdsByRow:l,isNarrow:ke,isDisposed:()=>p,flightGen:()=>ce.flightGen(),flyToSeat:z=>hn(z),openPanorama:(z,H,j)=>Le(z,H,j)}),we=be.show,ye=be.remove,Pe=be.layout,ae=Ir({container:t,orbit:C,isNarrow:ke}),ue=ae.element,xe=ae.setNavigationMode,Ae=ae.setSeatViewLocked,He=ae.layout,_e=ae.utilityControls,ce=Fr({container:t,model:o,opts:n,orbit:C,cinematic:T,analytics:r,loop:Y,labelOverlay:F,stageAzimuth:v,overviewFraming:I,gpu:()=>d,isDisposed:()=>p,panorama:()=>x,setPanorama:z=>{x=z},setPanoramaSphereVisible:z=>{O=z},panoramaLoadAbort:()=>y,setPanoramaLoadAbort:z=>{y=z},setFrozen:z=>{h=z},restorePanoramaLayer:k,reducedMotion:J,resolvedSeatViewPose:me,showSectionSeatLabels:W,setNearFieldDetailEnabled:g,setSeatViewLocked:Ae,setNavigationMode:xe,showArriveChip:we,removeArriveChip:ye});_=!0;let Ue=ce.overviewChip,Er=ce.layoutOverviewChip,kr=ce.applyFloorFocus,Lr=ce.focusOverview,dn=ce.cancelFlight,hn=ce.flyToSeat,pn=ce.focusSectionCamera;_e.appendChild(Ue),Le=Pr({container:t,model:o,opts:n,analytics:r,orbit:C,loop:Y,seatsById:s,ensureSeatView:K,resolvedSeatViewPose:me,gpu:()=>d,gl:M.gl,isContextLost:()=>u,isDisposed:()=>p,flightGen:()=>ce.flightGen(),setPanorama:z=>{x=z},getLoadAbort:()=>y,setLoadAbort:z=>{y=z},setPanoramaSphereVisible:z=>{O=z},setFrozen:z=>{h=z},raisePanoramaLayer:w,restorePanoramaLayer:k,getOverviewChip:()=>Ue,labelOverlay:F,reducedMotion:J,removeArriveChip:ye,showArriveChip:we});let Ce=Tr({glctx:M,orbit:C,model:o,seats:e.seats,opts:n,cinematic:T,analytics:r,seatIdByIndex:a,sectionIdBySeatId:c,tapSlop:Xa,tapMs:Wa,gpu:()=>d,pick:()=>f,seatViewLocked:()=>ae.seatViewLocked(),focusedSectionId:()=>X,selection:()=>b,cancelFlight:dn,focusSectionCamera:pn,setSelection:Q,ensureSeatView:K});M.canvas.addEventListener("pointerdown",Ce.onDown),M.canvas.addEventListener("pointermove",Ce.onMove),M.canvas.addEventListener("pointerup",Ce.onUp),M.canvas.addEventListener("pointercancel",Ce.onUp),Y.requestRender();let fn={setAvailability(z){let H=mr(b,z),j=Kt(o.seats,H);j.length&&d&&d.uploadSeatStateRuns(j),Y.requestRender()},setSelection:Q,flyToSeat:hn,focusOverview:Lr,resize(){let{width:z,height:H}=M.resize();C.setAspect(z/Math.max(1,H)),Pe(),He(),Er(),Y.requestRender()},stats(){return{...Y.stats(),drawCalls:d?d.drawCalls:0,seatCount:o.seatCount}},loseContextForTest(){M.simulateContextLossCycle()},floors(){return o.floors},focusFloor(z){if(z!==null&&!o.floors.some(j=>j.index===z))return!1;let H=z??-1;if(g(z!==null),Ae(!1),kr(H),xe("orbit"),z===null)T.cancel(),J()?C.frame(o.bounds,!1,v,n.portraitOverviewCrop===!0,I):C.frameSoft(o.bounds,v,n.portraitOverviewCrop===!0,I);else{let j=o.floors[z];if(j.seatCount>0){T.cancel();let ne=j.focalWorld[0]-j.center[0],oe=j.focalWorld[2]-j.center[2],ee=Math.hypot(ne,oe)>j.radius*.12?Math.atan2(ne,oe):v;C.frame({center:j.center,radius:j.radius,box:j.box},!1,ee,!1,{polarDeg:58,margin:1.12})}}return Y.requestRender(),!0},zones(){return o.zones},focusZone(z){let H=o.zones.find(ee=>ee.id===z);if(!H||H.seatCount===0)return!1;g(!1),Ae(!1),T.cancel(),xe("orbit"),W(null),n.onSectionFocusChange?.(null);let j=H.focalWorld[0]-H.center[0],ne=H.focalWorld[2]-H.center[2],oe=Math.hypot(j,ne)>H.radius*.12?Math.atan2(j,ne):void 0;return C.frame({center:H.center,radius:H.radius*1.25},!1,oe),Y.requestRender(),!0},sections(){return o.sections},focusSection(z){return pn(z)},rows(z){return z?o.rows.filter(H=>H.sectionId===z):o.rows},seatsInRow(z){return e.seats.filter(H=>H.rowId===z).map(H=>({id:H.id,label:H.displayLabel||H.label}))},focusRow(z){let H=o.rows.find(j=>j.id===z);return!H||H.seatCount===0?!1:(g(!0),Ae(!1),T.cancel(),xe("pan"),H.sectionId&&(W(H.sectionId),n.onSectionFocusChange?.(H.sectionId)),C.frame({center:H.center,radius:Math.max(2.5,H.radius*.65)}),Y.requestRender(),!0)},setReducedMotionForTest(z){A=z},dispose(){p=!0,ye(),Ue.remove(),ue.remove(),dn(),Y.stop(),F.dispose(),$?.disconnect(),x&&(x.dispose(),x=null),k(),P(),M.canvas.removeEventListener("pointerdown",Ce.onDown),M.canvas.removeEventListener("pointermove",Ce.onMove),M.canvas.removeEventListener("pointerup",Ce.onUp),M.canvas.removeEventListener("pointercancel",Ce.onUp),C.dispose(),f&&f.dispose(),d&&d.dispose(),d=null,f=null,M.dispose()}};return r.opened(o.seatCount,m,e.prepared?.buildMs??performance.now()-i,e.prepared?.source??"inline"),fn}export{dt as buildSceneModel,Pu as mountVenue3D,Ua as prepareVenue3D};
|