@seatlayer/core 0.67.8 → 0.67.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/view3d/index.cjs +5 -5
- package/dist/view3d/index.js +4 -4
- package/package.json +1 -1
package/dist/view3d/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{a as zn,c as Gn,d as Hn}from"../chunk-QHWOX6PN.js";import{d as Nn}from"../chunk-T2LWVOQ3.js";import{e as Tn,l as Ge,n as at,o as Vn,q as Pt}from"../chunk-VI3IZS2B.js";import{e as Bn,k as On}from"../chunk-UL5OIGIF.js";import{W as ke,X as _e,ea as St,ga as Dn,ha as wt,ja as kn,l as En,m as rt,va as _n}from"../chunk-RZLIIQDP.js";import{d as Q,k as Ln,x as pe,z as it}from"../chunk-CXF32VPG.js";import{Renderer as Hr}from"ogl";var ye=["available","held","sold","selected","dimmed"];function st(t){let e=ye.indexOf(t);return e<0?0:e}var Un={available:[.24,.82,.52],held:[.95,.66,.22],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};function Yn(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 Qt={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 fe(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 At=class{constructor(e,n){this.clearRgb=[0,0,0];this.container=e,this.canvas=document.createElement("canvas"),this.canvas.style.display="block",this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.touchAction="none",this.canvas.tabIndex=0,this.canvas.setAttribute("role","application"),this.canvas.setAttribute("aria-label","Interactive 3D venue. Drag or use arrow keys to look around; pinch, scroll, plus or minus to zoom."),this.renderer=new 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 $t}from"ogl";var ue=Math.PI/180,Jt=15*ue,en=80*ue,qe=.12,Xn=35,Wn=1.25,Ct=class{constructor(e,n,i,o){this.fovY=Xn;this.target=new $t;this.azimuth=-30*ue;this.polar=55*ue;this.distance=10;this.azT=-30*ue;this.polT=55*ue;this.distT=10;this.minDist=1;this.maxDist=100;this.gestureFired=!1;this.interactionEnabled=!0;this.dragging=!1;this.panning=!1;this.lastX=0;this.lastY=0;this.activePointers=new Map;this.pinchDist=0;this.pinchCx=0;this.pinchCy=0;this.targetT=new $t;this.panAnchor=new $t;this.panLimit=0;this.primaryDragMode="orbit";this.camera=new Yr(e,{fov:Xn,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(Jt,Math.min(en,this.polT-s*.006)),this.requestRender())},this.onPointerUp=r=>{this.activePointers.delete(r.pointerId);try{this.canvas.releasePointerCapture?.(r.pointerId)}catch{}this.activePointers.size<2&&(this.pinchDist=0),this.activePointers.size===0&&(this.dragging=!1,this.panning=!1)},this.onContextMenu=r=>{r.preventDefault()},this.onWheel=r=>{if(r.preventDefault(),!this.interactionEnabled)return;let a=r.deltaMode===1?16:r.deltaMode===2?100:1,s=Math.max(-2,Math.min(2,r.deltaY*a/100));this.dollyBy(Math.exp(s*.22)),this.fireGesture()},this.onKeyDown=r=>{if(!this.interactionEnabled)return;let a=7*ue;if(r.shiftKey&&(r.key==="ArrowLeft"||r.key==="ArrowRight"||r.key==="ArrowUp"||r.key==="ArrowDown"))this.panBy(r.key==="ArrowLeft"?-32:r.key==="ArrowRight"?32:0,r.key==="ArrowUp"?-32:r.key==="ArrowDown"?32:0);else if(r.key==="ArrowLeft"||r.key==="ArrowRight")this.azT+=r.key==="ArrowLeft"?-a:a;else if(r.key==="ArrowUp"||r.key==="ArrowDown")this.polT=Math.max(Jt,Math.min(en,this.polT+(r.key==="ArrowUp"?-a:a)));else if(r.key==="+"||r.key==="=")this.dollyBy(.82);else if(r.key==="-"||r.key==="_")this.dollyBy(1.22);else return;r.preventDefault(),this.fireGesture(),this.requestRender()},n.addEventListener("pointerdown",this.onPointerDown),n.addEventListener("pointermove",this.onPointerMove),n.addEventListener("pointerup",this.onPointerUp),n.addEventListener("pointercancel",this.onPointerUp),n.addEventListener("wheel",this.onWheel,{passive:!1}),n.addEventListener("keydown",this.onKeyDown),n.addEventListener("contextmenu",this.onContextMenu)}pinchCentroid(){let e=[...this.activePointers.values()];if(!e.length)return{x:0,y:0};let n=0,i=0;for(let o of e)n+=o.x,i+=o.y;return{x:n/e.length,y:i/e.length}}panBy(e,n){let i=this.canvas.clientHeight||1,o=2*this.distance*Math.tan(this.fovY*ue/2)/i,r=Math.sin(this.azimuth),a=Math.cos(this.azimuth),s=a,l=-r,c=Math.cos(this.polar),d=Math.sin(this.polar),u=-r*c,m=-a*c;this.targetT.x+=(-e*s+n*u)*o,this.targetT.z+=(-e*l+n*m)*o,this.targetT.y+=n*d*o,this.clampPan(),this.requestRender()}clampPan(){if(this.panLimit<=0)return;let e=this.panLimit,n=this.panAnchor.x,i=this.panAnchor.y,o=this.panAnchor.z;this.targetT.x=Math.max(n-e,Math.min(n+e,this.targetT.x)),this.targetT.z=Math.max(o-e,Math.min(o+e,this.targetT.z)),this.targetT.y=Math.max(i-e*.5,Math.min(i+e,this.targetT.y))}fireGesture(){this.gestureFired||(this.gestureFired=!0,this.onGesture?.())}currentPinchDistance(){let e=[...this.activePointers.values()];return e.length<2?0:Math.hypot(e[0].x-e[1].x,e[0].y-e[1].y)}dollyBy(e){this.distT=Math.max(this.minDist,Math.min(this.maxDist,this.distT*e)),this.requestRender()}zoomBy(e){this.interactionEnabled&&(this.dollyBy(e),this.fireGesture())}setPrimaryDragMode(e){this.primaryDragMode=e}setInteractionEnabled(e){this.interactionEnabled=e,!e&&(this.activePointers.clear(),this.dragging=!1,this.panning=!1,this.pinchDist=0)}frame(e,n=!1,i,o=!1,r){this.target.set(e.center[0],e.center[1],e.center[2]),this.targetT.copy(this.target),this.panAnchor.copy(this.target),this.panLimit=Math.max(1,e.radius)*1.5;let a=Math.max(1,e.radius),s=this.fovY*ue/2,l=o?Math.max(.82,this.camera.aspect||1):this.camera.aspect||1,c=Math.atan(Math.tan(s)*l);this.azT=i??-30*ue,this.polT=Math.max(15,Math.min(80,r?.polarDeg??55))*ue;let d=this.fitDistance(e,s,c,this.azT,this.polT);this.distT=d*Math.max(1.05,Math.min(2,r?.margin??Wn)),this.minDist=Math.max(2,a*.12),this.maxDist=d*4,n?(this.azimuth=this.azT,this.polar=12*ue,this.distance=this.distT*1.7):(this.azimuth=this.azT,this.polar=this.polT,this.distance=this.distT),this.applyPosition()}setAspect(e){this.camera.perspective({aspect:e})}frameSoft(e,n,i=!1,o){this.target.set(e.center[0],e.center[1],e.center[2]),this.targetT.copy(this.target),this.panAnchor.copy(this.target),this.panLimit=Math.max(1,e.radius)*1.5,this.syncFromCamera(),this.camera.perspective({fov:this.fovY,aspect:this.camera.aspect});let r=this.fovY*ue/2,a=i?Math.max(.82,this.camera.aspect||1):this.camera.aspect||1,s=Math.atan(Math.tan(r)*a);this.azT=n??this.azimuth,this.polT=Math.max(15,Math.min(80,o?.polarDeg??55))*ue;let l=this.fitDistance(e,r,s,this.azT,this.polT);this.distT=l*Math.max(1.05,Math.min(2,o?.margin??Wn))}fitDistance(e,n,i,o,r){let a=Math.max(1,e.radius),s=Math.max(a/Math.tan(n),a/Math.tan(i)),l=e.box;if(!l)return s;let c=Math.sin(r),d=-c*Math.sin(o),u=-Math.cos(r),m=-c*Math.cos(o);if(Math.abs(u)>.999)return s;let p=-m,h=d,f=Math.hypot(p,h);p/=f,h/=f;let y=-h*u,x=h*d-p*m,b=p*u,S=Math.tan(i),I=Math.tan(n),w=1;for(let g=0;g<8;g++){let T=(g&1?l.max[0]:l.min[0])-e.center[0],D=(g&2?l.max[1]:l.min[1])-e.center[1],_=(g&4?l.max[2]:l.min[2])-e.center[2],G=T*d+D*u+_*m,N=Math.abs(T*p+_*h),v=Math.abs(T*y+D*x+_*b);w=Math.max(w,N/S-G,v/I-G)}return Math.min(s,Math.max(w,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*qe,this.polar+=n*qe,this.distance+=i*qe,this.target.x+=o*qe,this.target.y+=r*qe,this.target.z+=a*qe,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(Jt,Math.min(en,Math.acos(Math.max(-1,Math.min(1,n/o)))));this.distance=this.distT=o,this.polar=this.polT=r,this.azimuth=this.azT=Math.atan2(e,i)}setTarget(e){this.target.set(e[0],e[1],e[2]),this.targetT.copy(this.target)}resumeAfterFlight(e){this.camera.perspective({fov:this.fovY,aspect:this.camera.aspect}),e&&this.target.set(e[0],e[1],e[2]),this.targetT.copy(this.target),this.syncFromCamera()}applyPosition(){let e=Math.sin(this.polar),n=this.target.x+this.distance*e*Math.sin(this.azimuth),i=this.target.y+this.distance*Math.cos(this.polar),o=this.target.z+this.distance*e*Math.cos(this.azimuth);this.camera.position.set(n,i,o),this.camera.lookAt(this.target)}dispose(){this.canvas.removeEventListener("pointerdown",this.onPointerDown),this.canvas.removeEventListener("pointermove",this.onPointerMove),this.canvas.removeEventListener("pointerup",this.onPointerUp),this.canvas.removeEventListener("pointercancel",this.onPointerUp),this.canvas.removeEventListener("wheel",this.onWheel),this.canvas.removeEventListener("keydown",this.onKeyDown),this.canvas.removeEventListener("contextmenu",this.onContextMenu),this.activePointers.clear()}};var Rt=class{constructor(e){this.rafId=0;this.running=!1;this.lastTime=0;this.fpsEma=0;this.rendered=0;this.tick=e=>{let n=this.lastTime?(e-this.lastTime)/1e3:.016666666666666666;if(this.lastTime=e,n>0){let o=1/n;this.fpsEma=this.fpsEma?this.fpsEma*.9+o*.1:o}this.rendered++,this.frame(n)?this.rafId=requestAnimationFrame(this.tick):(this.running=!1,this.rafId=0)};this.frame=e}requestRender(){this.running||(this.running=!0,this.lastTime=0,this.rafId=requestAnimationFrame(this.tick))}stats(){return{fps:this.running?Math.round(this.fpsEma):0,rendered:this.rendered,idle:!this.running}}stop(){this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=0,this.running=!1}};var Ze=2.5,Xr=1.15,ct=6,Qe=10,jn=6,Kn=9.5,qn=.9,Zn=2.2,tn=30,nn=4,It=8192;var ts=Qe+nn;function Qn(t,e){let n=e*1.4,i=e*3.2;if(t<=n)return{scale:1,fade:0,minPixels:Ze};let o=Math.min(1,(t-n)/Math.max(.001,i-n));return{scale:1-o*.4,fade:o*.55,minPixels:Ze+o*(Xr-Ze)}}function $n(t,e,n){return!(t>0)||!(e>0)||!(n>0)?!1:e*n/t>=64}function Jn(t,e,n,i,o){if(!(t>0)||!(e>0)||!(n>0)||!(i>0)||!(o>0))return!1;let r=Math.tan(i/2*Math.PI/180);if(!(r>0))return!1;let a=e/(n*r)*(o/2);return Math.PI*a*a/t>=64}import Wr from"earcut";import jr from"polygon-clipping";var A=ke,Kr=.002;function qr(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<Kr}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)}},Et=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){qr(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 Zr(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,d=r*a-i*l,u=i*s-o*a,m=Math.hypot(c,d,u)||1;return c/=m,d/=m,u/=m,[c,d,u]}function Qr(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 on(t){return Ge(t)<0?[...t].reverse():t}var $r=3;function Jr(t,e,n,i){let o=i(t),r=i(e),a=i(n),s=(p,h,f,y)=>Math.abs(i({x:(p.x+h.x)/2,y:(p.y+h.y)/2})-(f+y)/2),l=(t.x+e.x+n.x)/3,c=(t.y+e.y+n.y)/3,d=(o+r+a)/3,u=Math.max(s(t,e,o,r),s(e,n,r,a),s(n,t,a,o),Math.abs(i({x:l,y:c})-d)),m=(p,h,f)=>{let y=Math.abs(i({x:(p+l)/2,y:(h+c)/2})-(f+d)/2);y>u&&(u=y)};return m((t.x+e.x)/2,(t.y+e.y)/2,(o+r)/2),m((e.x+n.x)/2,(e.y+n.y)/2,(r+a)/2),m((n.x+t.x)/2,(n.y+t.y)/2,(a+o)/2),u}function lt(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(lt(t,r,s,i,o-1),lt(r,e,a,i,o-1),lt(s,a,n,i,o-1),lt(r,a,s,i,o-1))}function ut(t,e,n,i,o,r,a,s){if(a>0){let m={x:(e.x+n.x)/2,y:(e.y+n.y)/2},p={x:(n.x+i.x)/2,y:(n.y+i.y)/2},h={x:(i.x+e.x)/2,y:(i.y+e.y)/2};ut(t,e,m,h,o,r,a-1,s),ut(t,m,n,p,o,r,a-1,s),ut(t,h,p,i,o,r,a-1,s),ut(t,m,p,h,o,r,a-1,s);return}let l=[e.x*A,o(e),e.y*A],c=[n.x*A,o(n),n.y*A],d=[i.x*A,o(i),i.y*A];if(s){t.triN(l,c,d,s(e),s(n),s(i),r);return}let u=Zr(l,c,d);u[1]<0&&(u=[-u[0],-u[1],-u[2]]),t.tri(l,c,d,u,r)}var ei=8;function eo(t,e,n){if(!Number.isFinite(n))return t;let i=[],o=(r,a,s,l,c)=>{if(c>0){let d={x:(r.x+a.x)/2,y:(r.y+a.y)/2},u=e(d);if(Math.abs(u-(s+l)/2)>n){o(r,d,s,u,c-1),o(d,a,u,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),ei)}return i}function Ft(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,d=Math.hypot(l,c);d>e&&Math.abs((a.x-r.x)*c-(a.y-r.y)*l)/d<e||i.push(a)}return i.length>=3?i:n}var Tt=.001*_e*.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(Ge(e))<1e-4))return;let d=Ft(eo(Ft(on(e),Tt),i,l),Tt),u=n?.map(g=>Ft(eo(Ft(on(g),Tt),i,l),Tt)).filter(g=>g.length>=3&&Math.abs(Ge(g))>=1e-4),{pts:m,tris:p}=Qr(d,u),h=[r[0]*s.top,r[1]*s.top,r[2]*s.top],f=[r[0]*s.bottomCap,r[1]*s.bottomCap,r[2]*s.bottomCap],y=[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],b=0;if(Number.isFinite(l))for(;b<$r;b++){let g=0;for(let T=0;T<p.length;T+=3){let D=lt(m[p[T]],m[p[T+1]],m[p[T+2]],i,b);D>g&&(g=D)}if(g<=l)break}for(let g=0;g<p.length;g+=3){let T=m[p[g]],D=m[p[g+1]],_=m[p[g+2]];ut(t,T,D,_,i,h,b,c);let G=[T.x*A,o,T.y*A],N=[D.x*A,o,D.y*A],v=[_.x*A,o,_.y*A];t.tri(G,v,N,[0,-1,0],f)}let S=g=>{if(b<=0)return g;let T=1<<b,D=[];for(let _=0;_<g.length;_++){let G=g[_],N=g[(_+1)%g.length];for(let v=0;v<T;v++){let M=v/T;D.push({x:G.x+(N.x-G.x)*M,y:G.y+(N.y-G.y)*M})}}return D},I=En(d),w=[{ring:S(d),flip:!1}];if(u)for(let g of u)g.length>=3&&w.push({ring:S(g),flip:!0});for(let{ring:g,flip:T}of w)for(let D=0;D<g.length;D++){let _=g[D],G=g[(D+1)%g.length],N=(G.x-_.x)*A,M=(G.y-_.y)*A,R=-N,C=Math.hypot(M,R)||1;M/=C,R/=C;let L=(_.x+G.x)/2-I.x,E=(_.y+G.y)/2-I.y,P=M*L+R*E;T&&(P=-P),P<0&&(M=-M,R=-R);let F=[M,0,R],O=[_.x*A,i(_),_.y*A],H=[G.x*A,i(G),G.y*A],z=[_.x*A,o,_.y*A],B=[G.x*A,o,G.y*A];t.tri(O,H,B,F,y,y,x),t.tri(O,B,z,F,y,x,x)}}function to(t){let e=0;for(let l of t)e+=l.count;let n=new Float32Array(e*3),i=new Float32Array(e*3),o=new Float32Array(e*3),r=new Float32Array(e),a=new Float32Array(e),s=0;for(let l of t)n.set(l.position,s*3),i.set(l.normal,s*3),o.set(l.color,s*3),r.set(l.floor,s),a.set(l.material,s),s+=l.count;return{position:n,normal:i,color:o,floor:r,material:a,count:e}}function Dt(t,e,n=2.5){if(e<=0||t.length<3)return t;let i=on(t),o=i.length,r=[];for(let s=0;s<o;s++){let l=i[s],c=i[(s+1)%o],d=c.x-l.x,u=c.y-l.y,m=Math.hypot(d,u)||1;r.push({x:u/m,y:-d/m})}let a=[];for(let s=0;s<o;s++){let l=i[s],c=r[(s-1+o)%o],d=r[s],u=c.x+d.x,m=c.y+d.y,p=Math.hypot(u,m),h=()=>{a.push([l.x+c.x*e,l.y+c.y*e]),a.push([l.x+d.x*e,l.y+d.y*e])};if(p<1e-9){h();continue}u/=p,m/=p;let f=u*c.x+m*c.y,y=1/Math.max(f,1e-6);if(!Number.isFinite(y)||y>n){h();continue}a.push([l.x+u*e*y,l.y+m*e*y])}if(a.length<3)return t;try{let s=jr.union([[...a,a[0]]]),l=null,c=-1/0;for(let u of s){let m=Math.abs(Ge(u[0].map(([p,h])=>({x:p,y:h}))));m>c&&(c=m,l=u[0])}if(!l)return t;let d=l.map(([u,m])=>({x:u,y:m}));if(d.length>1){let u=d[0],m=d[d.length-1];Math.abs(u.x-m.x)<1e-9&&Math.abs(u.y-m.y)<1e-9&&d.pop()}return d.length>=3?d:t}catch{return t}}function kt(t,e,n,i,o=28){let r=[];for(let a=0;a<o;a++){let s=a/o*Math.PI*2;r.push({x:t+n*Math.cos(s),y:e+i*Math.sin(s)})}return r}function mt(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 te={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,body:10,head:11},ti=.44,ni=.15,oi=.3,ri=.24;function no(t){return t===void 0||!Number.isFinite(t)||t<=0?ri:Math.min(oi,Math.max(ni,t*ti))}var rn=.21,ii=.05,an=.45,_t=an+ii,ai=[{part:te.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:te.pad,min:[-1,.36,-.95],max:[1,an,1]},{part:te.back,min:[-1,_t,-1],max:[1,.92,-.72]},{part:te.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:te.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:te.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:te.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:te.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:te.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:te.leg,min:[.62,0,.48],max:[.82,.37,.7]}],si=[{part:te.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:te.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:te.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:te.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:te.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 oo(){let t=[],e=[],n=[],i=[],o=(C,L,E)=>{let P=n.length,[F,O,H]=C,z=[O[0]-F[0],O[1]-F[1],O[2]-F[2]],B=[H[0]-F[0],H[1]-F[1],H[2]-F[2]],U=z[1]*B[2]-z[2]*B[1],K=z[2]*B[0]-z[0]*B[2],Y=z[0]*B[1]-z[1]*B[0],j=Math.hypot(U,K,Y);j>1e-9?(U/=j,K/=j,Y/=j):[U,K,Y]=L,U*L[0]+K*L[1]+Y*L[2]<0&&(U=-U,K=-K,Y=-Y);for(let q of C)t.push(...q),e.push(U,K,Y),n.push(E);i.push(P,P+1,P+2,P,P+2,P+3)},r=C=>{for(let L of ci){let E=L.c.map(P=>P.map((F,O)=>F?C.max[O]:C.min[O]));o(E,L.n,C.part)}};for(let C of ai)r(C);for(let C of si)r(C);let a=an,s=1.08,l=.47,c=.69,d=-.55,u=.08,m=-.48,p=.01,h=[-l,a,d],f=[l,a,d],y=[-l,a,u],x=[l,a,u],b=[-c,s,m],S=[c,s,m],I=[-c,s,p],w=[c,s,p];o([f,S,w,x],[1,0,0],te.body),o([y,I,b,h],[-1,0,0],te.body),o([I,w,S,b],[0,1,0],te.body),o([h,f,x,y],[0,-1,0],te.body),o([x,w,I,y],[0,0,1],te.body),o([h,b,S,f],[0,0,-1],te.body);let g=10,T=8,D=[0,1.205,-.23],_=[.42,.115,.38],G=n.length;for(let C=0;C<=T;C++){let L=Math.PI*C/T,E=Math.cos(L),P=Math.sin(L);for(let F=0;F<=g;F++){let O=Math.PI*2*F/g,H=P*Math.cos(O),z=P*Math.sin(O);t.push(D[0]+_[0]*H,D[1]+_[1]*E,D[2]+_[2]*z);let B=H/_[0],U=E/_[1],K=z/_[2],Y=Math.hypot(B,U,K)||1;B/=Y,U/=Y,K/=Y,e.push(B,U,K),n.push(te.head)}}for(let C=0;C<T;C++)for(let L=0;L<g;L++){let E=G+C*(g+1)+L,P=E+g+1;i.push(E,P,E+1,E+1,P,P+1)}let N=new Float32Array(t),v=new Float32Array(e),M=new Float32Array(n),R=new Uint16Array(i);return{position:N,normal:v,part:M,index:R,vertexCount:n.length,indexCount:i.length}}function ro(t,e,n,i){let o=new Float32Array(e),r=c=>t[c*3],a=c=>t[c*3+2],s=0,l=(c,d)=>{let u=d-c;for(let m=c;m<d;m++){let[p,h]=i(m),f=p-r(m),y=h-a(m);if(u>=2){let x=Math.max(c,m-1),b=Math.min(d-1,m+1),S=r(b)-r(x),I=a(b)-a(x),w=Math.hypot(S,I);if(w>1e-6){let g=-I/w,T=S/w;g*f+T*y<0&&(g=-g,T=-T),f=g,y=T}}o[m]=f===0&&y===0?0:Math.atan2(f,y)}};for(let c=1;c<=e;c++)(c===e||n(c)!==n(s))&&(l(s,c),s=c);return o}var Ae=.22;function io(t,e){let n=ye[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 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),d=Math.max(1,Math.ceil(s/c)+1),u=Math.max(1,Math.ceil(l/c)+1),m=new Map,p=(h,f)=>{let y=Math.min(d-1,Math.max(0,Math.floor((h-i)/c)));return Math.min(u-1,Math.max(0,Math.floor((f-o)/c)))*d+y};for(let h=0;h<e;h++){let f=p(t[h].x,t[h].y),y=m.get(f);y?y.push(h):m.set(f,[h])}for(let h=0;h<e;h++){let f=t[h],y=Math.min(d-1,Math.max(0,Math.floor((f.x-i)/c))),x=Math.min(u-1,Math.max(0,Math.floor((f.y-o)/c))),b=1/0;for(let S=1;S<=4;S++){for(let I=x-S;I<=x+S;I++)if(!(I<0||I>=u))for(let w=y-S;w<=y+S;w++){if(w<0||w>=d||S>1&&Math.abs(I-x)<S&&Math.abs(w-y)<S)continue;let g=m.get(I*d+w);if(g)for(let T of g){if(T===h)continue;let D=Math.hypot(t[T].x-f.x,t[T].y-f.y);D<b&&(b=D)}}if(Number.isFinite(b)&&b<=S*c)break}n[h]=b}return n}function mi(t){let e=t.eyeHeightM;return Number.isFinite(e)?Math.max(0,e-St):0}function ao(t,e,n,i,o,r){let a=t.length,s=new Float32Array(a*3),l=new Float32Array(a),c=new Float32Array(a*3),d=new Float32Array(a),u=new Float32Array(a),m=new Float32Array(a),p=new Float32Array(a),h=new Float32Array(a*3),f=new Map,y=ui(t);for(let x=0;x<a;x++){let b=t[x],I=(n?.seatPitchU(x)??y[x])*A;d[x]=Number.isFinite(I)?Math.max(.06,Math.min(Ae,I*li)):Ae,u[x]=no(Number.isFinite(I)?I:void 0);let w=On(b.glyph,{seatGlyph:r?.get(b.categoryKey)});m[x]=Bn.indexOf(w),p[x]=b.wheelchairSpaceType==="no-seat"?0:1,s[x*3]=b.x*A,s[x*3+1]=n?n.seatDeckY(x):mi(b),s[x*3+2]=b.y*A,l[x]=st(e?e(b):"available");let g=Q(o?.get(b.categoryKey)??"#6e7bff")??[.43,.48,1];if(c[x*3]=g[0],c[x*3+1]=g[1],c[x*3+2]=g[2],b.accessibility?.length){let T=Q(Tn(b.accessibility));T&&(h[x*3]=T[0],h[x*3+1]=T[1],h[x*3+2]=T[2])}f.set(b.id,x)}return{count:a,iPosition:s,iState:l,iCategory:c,iMaxRadius:d,iRing:h,idToIndex:f,iChairWidth:u,iGlyph:m,iPhysicalSeat:p,iFloor:i??new Float32Array(a),iYaw:new Float32Array(a)}}var di=64;function sn(t,e){let n=[];for(let a of e){let s=t.idToIndex.get(a.seatId);if(s===void 0)continue;let l=st(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+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,pi=.9,fi=1.76,bi=.7,yi=1.6;function xi(){return{background:{top:[...He.top],bottom:[...He.bottom]},structure:Qt,seatStates:{...Un},seatScale:1}}function so(t){let e=xi();if(!t)return e;let n=Q(t.background);if(n){e.background={top:fe(n,pi),bottom:fe(n,fi)};let r={};for(let[a,s]of Object.entries(Qt))r[a]=pe(s,n,hi);e.structure=r}let i=Q(t.selectionColor)??Q(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 co(t,e){let n=[];for(let i of e)n.push(...t.seatStates[i]);return n}import ho from"polygon-clipping";import gi from"earcut";var vi=.58,lo=.01,be=Ae*1.5*_e,Mi=.5,Si=.6;function wi(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,d=l.y-s.y,u=Math.hypot(c,d);if(u<1e-9){i.push([0,0]);continue}c/=u,d/=u,i.push([-d,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 Pi(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,d=Math.hypot(l,c)||1;return{x:l/d,y:c/d}},o=i(n[1],n[0]),r=i(n[n.length-2],n[n.length-1]);return n.unshift({x:n[0].x+o.x*e,y:n[0].y+o.y*e}),n.push({x:n[n.length-1].x+r.x*e,y:n[n.length-1].y+r.y*e}),n}var uo=Math.PI/12;function Ai(t){if(t.length<3)return[...t];let e=[...t].sort((r,a)=>r.x-a.x||r.y-a.y),n=(r,a,s)=>(a.x-r.x)*(s.y-r.y)-(a.y-r.y)*(s.x-r.x),i=r=>{let a=[];for(let s of r){for(;a.length>=2&&n(a[a.length-2],a[a.length-1],s)<=0;)a.pop();a.push(s)}return a.pop(),a},o=[...i(e),...i([...e].reverse())];return o.length>=3?o:[...t]}function po(t,e){if(!t.length||!(e>0))return[];let n=Ai(t),i=(s,l,c,d)=>{let u=c-l;for(;u<0;)u+=Math.PI*2;for(;u>Math.PI*2;)u-=Math.PI*2;let m=Math.max(1,Math.ceil(u/uo)),p=e/Math.cos(u/m/2);for(let h=0;h<=m;h++){let f=l+u*h/m;d.push({x:s.x+Math.cos(f)*p,y:s.y+Math.sin(f)*p})}};if(n.length<3){let s=0,l=0;for(let p of n)s+=p.x,l+=p.y;s/=n.length||1,l/=n.length||1;let c=0;for(let p of n)c=Math.max(c,Math.hypot(p.x-s,p.y-l));let d=[],u=Math.max(3,Math.ceil(Math.PI*2/uo)),m=(c+e)/Math.cos(Math.PI/u);for(let p=0;p<u;p++){let h=p/u*Math.PI*2;d.push({x:s+Math.cos(h)*m,y:l+Math.sin(h)*m})}return d}let o=n.length,r=[];for(let s=0;s<o;s++){let l=n[s],c=n[(s+1)%o];r.push(Math.atan2(-(c.x-l.x),c.y-l.y))}let a=[];for(let s=0;s<o;s++)i(n[s],r[(s+o-1)%o],r[s],a);return go(a)}function Ci(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,d=c>1e-12?((e-r.x)*s+(n-r.y)*l)/c:0;d<0?d=0:d>1&&(d=1);let u=Math.hypot(e-(r.x+d*s),n-(r.y+d*l));u<i&&(i=u)}return i}function Lt(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 d=Math.hypot(c.x-r,c.y-a);d>l&&(l=d)}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 d of r){let u=1/0;for(let m=0;m<t.length;m++){if(m===o||Math.abs(t[m].y-t[o].y)<.001)continue;let p=e[m],h=Math.hypot(d.x-p.cx,d.y-p.cy)-p.rad;if(h>=u&&h>=s)continue;let f=Ci(t[m].pts,d.x,d.y);f<u&&(u=f),t[m].depth<t[o].depth&&f<s&&(s=f,l=t[m].y)}Number.isFinite(u)&&u>0&&a.push(u)}a.sort((d,u)=>d-u);let c=a.length?a[Math.floor(a.length/2)]:1;i.push({pitch:c,belowY:l})}return i}function fo(t,e,n,i){let o=t[e],r=o.pts.length>=2?[...o.pts]:o.pts.length===1?(()=>{let d=o.pts[0],u=d.x-i.x,m=d.y-i.y,p=Math.hypot(u,m)||1;u/=p,m/=p;let h=Math.max(n[e].pitch,.001)*.5;return[{x:d.x+m*h,y:d.y-u*h},{x:d.x-m*h,y:d.y+u*h}]})():[];if(r.length<2)return null;let a=0,s=0;for(let d=1;d<r.length;d++){let u=Math.hypot(r[d].x-r[d-1].x,r[d].y-r[d-1].y);u>1e-6&&(a+=u,s++)}let l=s>0?a/s:0,c=Pi(r,Math.max(l*Si,be));return{pts:c,nrm:wi(c,i),front:Math.max(n[e].pitch*vi,be),back:Math.max(n[e].pitch*Mi,be)}}var $e=1.5,bo=.3;function cn(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 u=1;u<t.length-1;u++){let m=t[u],p=a>1e-12?Math.abs((m.x-n.x)*r-(m.y-n.y)*o)/a:Math.hypot(m.x-n.x,m.y-n.y);p>s&&(s=p,l=u)}if(s<=e||l<0)return[n,i];let c=cn(t.slice(0,l+1),e),d=cn(t.slice(l),e);return[...c.slice(0,-1),...d]}function yo(t,e){if(t.length<4)return t;let n=cn([...t,t[0]],e);return n.pop(),n.length>=3?n:t}function xo(t,e,n){if(t.length<2)return[];let i=n??Lt(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 b of a){let S=t[b].patch;S&&S.length>=3?r.push({outline:[...S],holes:[],topY:t[b].y}):s.push(b)}if(!s.length)continue;s.sort((b,S)=>t[b].depth-t[S].depth);let c=s.map(b=>fo(t,b,i,e)).filter(b=>b!==null);if(!c.length)continue;let d=(b,S)=>({x:b.pts[S].x-b.nrm[S][0]*(b.front+$e),y:b.pts[S].y-b.nrm[S][1]*(b.front+$e)}),u=(b,S)=>({x:b.pts[S].x+b.nrm[S][0]*(b.back+$e),y:b.pts[S].y+b.nrm[S][1]*(b.back+$e)}),m=c[0],p=c[c.length-1],h=[];for(let b=0;b<m.pts.length;b++)h.push(d(m,b));for(let b of c)h.push(u(b,b.pts.length-1));for(let b=p.pts.length-1;b>=0;b--)h.push(u(p,b));for(let b=c.length-1;b>=0;b--)h.push(d(c[b],0));let f=go(h),y=1/0;for(let b of s)t[b].y<y&&(y=t[b].y);if(!Number.isFinite(y))continue;if(f.length>=3&&Math.abs(Ge(f))>1e-6&&c.every(b=>{let S=b.pts[Math.floor(b.pts.length/2)];return at(f,S.x,S.y)})){r.push({outline:yo(f,bo),holes:[],topY:y});continue}for(let b of Ri(c))r.push({outline:b,holes:[],topY:y})}return r}function Ri(t){let e=[];for(let n of t){let i=[],o=[],r=n.front+$e,a=n.back+$e;for(let l=0;l<n.pts.length;l++){let c=n.pts[l],d=n.nrm[l];i.push([c.x-d[0]*r,c.y-d[1]*r]),o.push([c.x+d[0]*a,c.y+d[1]*a])}let s=[...i,...o.reverse()];s.length<3||(s.push(s[0]),e.push([s]))}if(!e.length)return[];try{let n=ho.union(e[0],...e.slice(1)),i=[];for(let o of n){if(!o.length||o[0].length<4)continue;let r=o[0].map(([l,c])=>({x:l,y:c})),a=r[0],s=r[r.length-1];r.length>1&&Math.abs(a.x-s.x)<1e-9&&Math.abs(a.y-s.y)<1e-9&&r.pop(),r.length>=3&&i.push(yo(r,bo))}return i}catch{return[]}}function go(t){let e=[];for(let n of t){let i=e[e.length-1];i&&Math.hypot(n.x-i.x,n.y-i.y)<1e-9||e.push(n)}for(;e.length>2&&Math.hypot(e[0].x-e[e.length-1].x,e[0].y-e[e.length-1].y)<1e-9;)e.pop();return e}var ln=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(!at(n,o.x,o.y)){i=!1;break}if(i)return!0}return!1}};function mo(t,e,n,i,o,r){if(i.length<3)return;if(n.containsAll(i)){let c=[0,1,0],d=i[0];for(let u=1;u+1<i.length;u++){let m=i[u],p=i[u+1];t.tri([d.x*A,o,d.y*A],[m.x*A,o,m.y*A],[p.x*A,o,p.y*A],c,r)}return}let a=i.map(c=>[c.x,c.y]);a.push(a[0]);let s;try{s=ho.intersection([a],e)}catch{return}let l=[0,1,0];for(let c of s){if(!c.length||c[0].length<4)continue;let d=c[0],u=[],m=[];for(let h=0;h<d.length-1;h++)u.push(d[h][0],d[h][1]),m.push([d[h][0],d[h][1]]);if(m.length<3)continue;let p=gi(u,void 0,2);for(let h=0;h<p.length;h+=3){let f=m[p[h]],y=m[p[h+1]],x=m[p[h+2]];t.tri([f[0]*A,o,f[1]*A],[y[0]*A,o,y[1]*A],[x[0]*A,o,x[1]*A],l,r)}}}function vo(t,e,n,i,o,r,a){if(e.length<2)return;let s=a??Lt(e),l=[0,1,0],c=r&&r.length>=3?[[...r.map(p=>[p.x,p.y]),[r[0].x,r[0].y]]]:null,d=r&&r.length>=3?new ln([[...r]]):null,u=p=>{t.setMaterial(2),p(),t.setMaterial(0)},m=p=>{t.setMaterial(3),p(),t.setMaterial(0)};for(let p=0;p<e.length;p++){let h=e[p];if(h.patch&&h.patch.length>=3){let w=[...h.patch],g=s[p].belowY??i;if(m(()=>{if(c&&d)mo(t,c,d,w,h.y,o.tread);else{let T=w[0];for(let D=1;D+1<w.length;D++){let _=w[D],G=w[D+1];t.tri([T.x*A,h.y,T.y*A],[_.x*A,h.y,_.y*A],[G.x*A,h.y,G.y*A],l,o.tread)}}}),h.y>g+lo){let T=0,D=0;for(let _ of w)T+=_.x,D+=_.y;T/=w.length,D/=w.length,u(()=>{for(let _=0;_<w.length;_++){let G=w[_],N=w[(_+1)%w.length],v=N.x-G.x,M=N.y-G.y,R=Math.hypot(v,M);if(R<1e-6)continue;let C=M/R,L=-v/R;(G.x-T)*C+(G.y-D)*L<0&&(C=-C,L=-L);let E=[C,0,L],P=[G.x*A,h.y,G.y*A],F=[N.x*A,h.y,N.y*A],O=[G.x*A,g,G.y*A],H=[N.x*A,g,N.y*A];t.tri(P,F,H,E,o.riser),t.tri(P,H,O,E,o.riser)}})}continue}let f=fo(e,p,s,n);if(!f)continue;let{pts:y,nrm:x,front:b,back:S}=f,I=s[p].belowY??i;for(let w=0;w+1<y.length;w++){let g=y[w],T=y[w+1],D=x[w],_=x[w+1];if(Math.hypot(T.x-g.x,T.y-g.y)<1e-6||D[0]===0&&D[1]===0||_[0]===0&&_[1]===0)continue;let G=[(g.x-D[0]*b)*A,h.y,(g.y-D[1]*b)*A],N=[(T.x-_[0]*b)*A,h.y,(T.y-_[1]*b)*A],v=[(g.x+D[0]*S)*A,h.y,(g.y+D[1]*S)*A],M=[(T.x+_[0]*S)*A,h.y,(T.y+_[1]*S)*A];if(m(()=>{c&&d?mo(t,c,d,[{x:g.x-D[0]*b,y:g.y-D[1]*b},{x:T.x-_[0]*b,y:T.y-_[1]*b},{x:T.x+_[0]*S,y:T.y+_[1]*S},{x:g.x+D[0]*S,y:g.y+D[1]*S}],h.y,o.tread):(t.tri(G,N,M,l,o.tread),t.tri(G,M,v,l,o.tread))}),h.y>I+lo){let R=[G[0],I,G[2]],C=[N[0],I,N[2]],L=[-D[0],0,-D[1]];u(()=>{t.tri(G,N,C,L,o.riser),t.tri(G,C,R,L,o.riser)})}}}}import So from"polygon-clipping";function Ii(t,e){let n=t.eventConfigurationIds;return!n?.length||!!e&&n.includes(e)}function Mo(t,e){return t.filter(n=>n.type!=="shape"||Ii(n,e))}function wo(t,e){let n=t.focalPoint??{x:0,y:0};return t.floors?.length?t.floors.map((i,o)=>({objects:Mo(i.objects,e),focal:{x:(i.focalPoint??n).x,y:(i.focalPoint??n).y},baseHeightM:i.baseHeightM??0,index:o})):[{objects:Mo(t.objects,e),focal:n,baseHeightM:0,index:0}]}var Fi={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Je(t){return Vn(t)??Fi}function Po(t,e){let n=Dt(t.outline,be),i=Je(n),o=e.filter(a=>a!==t&&a.outline&&a.outline.length>=3&&Pt(i,Je(a.outline)));if(!o.length)return[n];let r=a=>{let s=a.map(l=>[l.x,l.y]);return s.push(s[0]),s};try{let a=So.difference([r(n)],...o.map(l=>[r(l.outline)])),s=[];for(let l of a){if(!l.length)continue;let c=l[0].map(([d,u])=>({x:d,y:u}));if(c.length>1){let d=c[0],u=c[c.length-1];Math.abs(d.x-u.x)<1e-9&&Math.abs(d.y-u.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s.length?s:[n]}catch{return[n]}}function Ao(t,e){if(!e.length)return t;let n=r=>{let a=r.map(s=>[s.x,s.y]);return a.push(a[0]),a},i=e.map(r=>[n(r)]),o=[];for(let r of t){let a;try{a=So.intersection([n(r.outline)],i.flat())}catch{o.push(r);continue}for(let s of a){if(!s.length)continue;let l=s[0].map(([c,d])=>({x:c,y:d}));if(l.length>1){let c=l[0],d=l[l.length-1];Math.abs(c.x-d.x)<1e-9&&Math.abs(c.y-d.y)<1e-9&&l.pop()}l.length>=3&&o.push({outline:l,holes:[],topY:r.topY})}}return o.length?o:t}var Ti=.05,Co=.05,Ei=.15,un=25;function Ro(t,e,n){let i=new Map,o=new Array(e.length).fill(null),r=new Float64Array(e.length),a=new Array(e.length).fill(void 0),s=new Array(e.length).fill(void 0),l=new Map,c=[],d=new Set;for(let u=0;u<t.length;u+=1){let m=t[u];for(let p of m.objects){if(p.type==="table"&&d.add(p.id),p.type!=="section"||!p.outline||p.outline.length<3)continue;let h=Dt(p.outline,be);l.set(p.id,{section:p,unit:m,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),c.push({id:p.id,floorIndex:u,box:Je(h),section:p,unit:m,outline:h})}}for(let u=0;u<e.length;u++){let m=e[u];for(let p of c){if(n&&p.floorIndex!==n[u]||m.x<p.box.minX||m.x>p.box.maxX||m.y<p.box.minY||m.y>p.box.maxY||!_n({x:m.x,y:m.y},p.outline,p.section.holes))continue;o[u]=p.id;let h=l.get(p.id);h.hasSeats=!0;let f=m.focalPoint??p.unit.focal,y=Math.hypot(m.x-f.x,m.y-f.y);y<h.frontU&&(h.frontU=y),h.seatIndices.push(u);let x=m.rowId||`__seat-${u}`,b=h.rows.get(x);b?b.push({x:m.x,y:m.y}):h.rows.set(x,[{x:m.x,y:m.y}]);break}}for(let[u,m]of l){let p=Dn(m.section,{floorBaseHeightM:m.unit.baseHeightM}),h=m.unit.baseHeightM,f=p.rake>0?Math.tan(p.rake*Math.PI/180):0,y=p.rake<=.01&&p.height<=h+.001,x=m.section.surfaceKind,b=x==="flat"?!0:x==="rakedRows"&&p.rake>.01?!1:y,S=m.hasSeats?kn(u,e,m.seatIndices,m.unit.focal):{sectionId:u,rows:[],blockCount:0},w=S.rows.length<2?zn([...m.rows.values()].map(E=>({points:E})),m.unit.focal):null,g=1/0;if(w){if(m.hasSeats)for(let E of m.rows.values())for(let P of E){let F=w.depthAt(P.x,P.y);F<g&&(g=F)}if(!m.hasSeats||!Number.isFinite(g)){g=1/0;for(let E of m.section.outline){let P=w.depthAt(E.x,E.y);P<g&&(g=P)}}}let T=h+Ti,D=Math.max(T,p.height),_=E=>{let P=Math.max(0,E-g)*ke,F=Math.min(P*f,un);return Math.max(T,p.height+F)},G=E=>{let P=Math.max(0,E)*ke,F=Math.min(P*f,un);return Math.max(T,p.height+F)},N=b?[]:S.rows.map(E=>({pts:E.pts,y:G(E.blockDepth),depth:E.blockDepth,blockId:E.blockId,...d.has(E.id)?{patch:po(E.pts,be)}:{}})),v=N.length?N[0].y:D,M=N.map(E=>{let P=E.patch&&E.patch.length>=3?E.patch:E.pts,F=0,O=0;for(let B of P)F+=B.x,O+=B.y;let H=P.length||1;F/=H,O/=H;let z=0;for(let B of P){let U=Math.hypot(B.x-F,B.y-O);U>z&&(z=U)}return{cx:F,cy:O,rad:z}}),R=b?()=>D:N.length>=2?(E,P)=>{let F=1/0,O=v;for(let H=0;H<N.length;H++){let z=M[H];if(Math.hypot(E-z.cx,P-z.cy)-z.rad>=F)continue;let B=N[H].patch,U=B&&B.length>=3?at(B,E,P)?0:wt(B,E,P):wt(N[H].pts,E,P);U<F&&(F=U,O=N[H].y)}return O}:(E,P)=>w?_(w.depthAt(E,P)):D,C=[0,1,0],L=N.length>=2||b?()=>C:(E,P)=>{if(!w)return C;let F=w.depthAt(E,P);if(F<=g)return C;let O=(F-g)*ke;if(O*f>=un||p.height+O*f<=T)return C;let[H,z]=w.gradientAt(E,P);if(H===0&&z===0)return C;let B=1/Math.hypot(f,1);return[-H*f*B,B,-z*f*B]};if(!b)for(let E of S.rows){let P=G(E.blockDepth);for(let F of E.seatIndices)a[F]=P}for(let E of S.rows){let P=[];for(let B=1;B<E.pts.length;B++){let U=Math.hypot(E.pts[B].x-E.pts[B-1].x,E.pts[B].y-E.pts[B-1].y);U>1e-6&&P.push(U)}P.sort((B,U)=>B-U);let F=P.length?P[Math.floor(P.length/2)]:1/0,O=1/0,H=E.pts[Math.floor(E.pts.length/2)];if(H)for(let B of S.rows){if(B===E||B.blockId!==E.blockId)continue;let U=wt(B.pts,H.x,H.y);U>1e-6&&U<O&&(O=U)}let z=Math.min(F,Math.max(O,F*.5));if(Number.isFinite(z)&&z>0)for(let B of E.seatIndices)s[B]=z}i.set(u,{sectionId:u,deckAt:R,normalAt:L,flat:b,bottomY:h,rowLevels:N,landingY:v})}for(let u=0;u<e.length;u++){let m=o[u],p=e[u];if(m){let f=a[u];r[u]=(f??i.get(m).deckAt(p.x,p.y))+Ei;continue}let h=p.eyeHeightM;r[u]=Number.isFinite(h)?Math.max(0,h-St):0}return{bySection:i,seatOwner:o,seatDeckY:u=>r[u],seatPitchU:u=>s[u]}}var re={top:1,wallBottom:.5,bottomCap:.4};function Ce(t,e){if(!t)return e;let n=fe(it(t,.4),.62);return pe(e,n,.72)}function Io(t,e){let n=new Map;for(let r of t.categories??[])n.set(r.key,r.color);let i=new Map;for(let r of e){if(!r.sectionId)continue;let a=i.get(r.sectionId);a||(a=new Map,i.set(r.sectionId,a)),a.set(r.categoryKey,(a.get(r.categoryKey)??0)+1)}let o=new Map;for(let[r,a]of i){let s=0,l=0,c=0,d=0;for(let[u,m]of a){let p=Q(n.get(u));p&&(s+=p[0]*m,l+=p[1]*m,c+=p[2]*m,d+=m)}d>0&&o.set(r,[s/d,l/d,c/d])}return o}function Fo(t,e){return Q(t.color)??e.get(t.logicalSectionId??t.id)??null}import Di from"polygon-clipping";function ki(t,e){return t===void 0||e===void 0?!0:Math.abs(t-e)<.001}var Bt=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(e,n){let i=e.map(l=>[l.x,l.y]);if(i.length<3)return[];i.push(i[0]);let o=Je(e),r=this.rings.filter((l,c)=>Pt(o,this.boxes[c])&&ki(n,this.levels[c])),a=[[i]];if(r.length)try{a=Di.difference([i],...r).map(c=>c.map(d=>d.map(([u,m])=>[u,m])))}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(([d,u])=>({x:d,y:u}));if(c.length>1){let d=c[0],u=c[c.length-1];Math.abs(d.x-u.x)<1e-9&&Math.abs(d.y-u.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s}};function _i(t,e){if(!e)return t;let n=1/0,i=-1/0,o=1/0,r=-1/0;for(let u of t)n=Math.min(n,u.x),i=Math.max(i,u.x),o=Math.min(o,u.y),r=Math.max(r,u.y);let a=(n+i)/2,s=(o+r)/2,l=e*Math.PI/180,c=Math.cos(l),d=Math.sin(l);return t.map(u=>{let m=u.x-a,p=u.y-s;return{x:a+m*c-p*d,y:s+m*d+p*c}})}function dt(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=mt(t.x??0,t.y??0,t.width,t.height)),t.kind==="ellipse"&&t.width&&t.height){let n=(t.x??0)+t.width/2,i=(t.y??0)+t.height/2;e=kt(n,i,t.width/2,t.height/2)}return e?_i(e,t.rotation):null}function ht(t){let e=t.role??"",n={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}},i=e==="stage"&&Nn(t.stageKind)?{kind:"stage",heightM:.06}:n[e]??{kind:"plate",heightM:.25};return{...i,heightM:t.heightM??i.heightM}}var Li=.08;function To(t,e){let n=dt(t),i=ht(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 d of n)r=Math.min(r,d.x),a=Math.min(a,d.y),s=Math.max(s,d.x),l=Math.max(l,d.y);let c=o;for(let d of e)s>d.minX&&r<d.maxX&&l>d.minY&&a<d.maxY&&c<=d.topOffsetM+1e-6&&(c=d.topOffsetM+Li);return e.push({minX:r,minY:a,maxX:s,maxY:l,topOffsetM:c}),c}function Le(t,e,n){return{x:t.x+(e.x-t.x)*n,y:t.y+(e.y-t.y)*n}}function Eo(t){if(t.length!==4)return t;let e=Math.hypot(t[1].x-t[0].x,t[1].y-t[0].y),n=Math.hypot(t[2].x-t[1].x,t[2].y-t[1].y);return e>=n?t:[t[1],t[2],t[3],t[0]]}function pt(t,e,n){return[Le(t[0],t[1],e),Le(t[0],t[1],n),Le(t[3],t[2],n),Le(t[3],t[2],e)]}function Do(t,e,n){return[Le(t[0],t[3],e),Le(t[1],t[2],e),Le(t[1],t[2],n),Le(t[0],t[3],n)]}function Re(t,e,n,i,o,r){ie(t,e,void 0,()=>n,i,o,r,re)}var mn=2.4,Bi=.75,Oi=.15;function ft(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(([d,u])=>({x:e.x+d*a-u*s,y:e.y+d*s+u*a}))}function ko(t,e,n,i,o){let r=ft(e);r&&ie(t,r,void 0,()=>n+mn,n,Ce(i,o.boothTop),o.boothWall,re)}function dn(t){if(t.shape==="round"){let d=t.radius;return d?kt(t.center.x,t.center.y,d,d,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(([d,u])=>({x:o.x+d*a-u*s,y:o.y+d*s+u*a}))}function _o(t,e,n,i,o){let r=dn(e);r&&ie(t,r,void 0,()=>n+Bi,n,Ce(i,o.tableTop),o.tableWall,re)}function Lo(t,e,n,i,o,r,a){let s=dt(e);if(!s)return;let l=e.role==="stage",c=ht(e),d=n+i;if(l&&a){let f=1/0,y=-1/0,x=1/0,b=-1/0;for(let S of s)S.x<f&&(f=S.x),S.x>y&&(y=S.x),S.y<x&&(x=S.y),S.y>b&&(b=S.y);a.push({cx:(f+y)/2*A,cz:(x+b)/2*A,y:d,halfX:Math.max((y-f)/2*A,.5),halfZ:Math.max((b-x)/2*A,.5)})}let u=Q(e.fill),m=l&&u?pe(o.stageTop,fe(it(u,.18),.9),.9):Ce(u,l?o.stageTop:o.decorTop),p=e.role==="screen"?u:null,h=l?u?pe(o.stageWall,fe(u,.58),.82):o.stageWall:e.role==="screen"?p?pe(fe(p,1.42),[.24,.46,.82],.08):[.24,.46,.82]:Ce(Q(e.fill),o.decorWall);if(c.kind==="portal"&&s.length===4){let f=Eo(s);Re(t,pt(f,0,.16),d,n,m,h),Re(t,pt(f,.84,1),d,n,m,h),Re(t,f,d,Math.max(n,d-.35),m,h);return}if(c.kind==="suite"&&s.length===4){let f=s.map((b,S)=>{let I=s[(S+1)%4],w=(b.x+I.x)/2,g=(b.y+I.y)/2;return Math.hypot(w-r.x,g-r.y)}),y=f.indexOf(Math.min(...f)),x=[0,1,2,3].map(b=>s[(y+b)%4]);Re(t,pt(x,0,.08),d,n,m,h),Re(t,pt(x,.92,1),d,n,m,h),Re(t,Do(x,.88,1),d,n,m,h),Re(t,x,d,Math.max(n,d-.18),m,h);return}Re(t,s,d,n,m,h)}function hn(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),d=i/2,u=o/2;return[[-d,-u],[d,-u],[d,u],[-d,u]].map(([m,p])=>({x:r+m*l-p*c,y:a+m*c+p*l}))}function Vi(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 Q(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=Q(s[1].trim());l&&a.push(l)}return a.length?a.reduce((s,l,c)=>pe(s,l,1/(c+1)),a[0]):null}function Bo(t,e,n,i){if(e.layer==="foreground")return;let o=hn(e);if(!o)return;let r=n+Oi,a=Ce(Vi(e.href),i.decorTop),s=Math.max(0,Math.min(1,e.opacity??1));s<1&&(a=pe(i.ground,a,s)),ie(t,o,void 0,()=>r,n,a,pe(a,i.decorWall,.5),re)}function Oo(t,e,n,i,o){if(!e.points||e.points.length<3)return;let r=Ce(i,o.gaTop);ie(t,e.points,e.holes,()=>n+.15,n,r,o.gaWall,re)}var Ni=.25,zi=1.2,Gi=.6,Hi=.45,Ui=2.3,Yi=Math.PI/180;function Ye(t,e,n){let i=n*Yi;return{x:t.x+e*Math.sin(i),y:t.y+e*Math.cos(i)}}function Xi(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 Wi=24;function ji(t,e,n,i,o,r,a,s){let l=n.binCount,c=Wi,d=ke,u=r+.02,m=[];for(let v=0;v<l;v++){let M=(n.startBin+v+.5)*e.binStepDeg,R=new Float64Array(c+1);for(let C=0;C<=c;C++){let L=i[v]+(o[v]-i[v])*C/c;R[C]=Math.max(u,Hn(e,n,M,L)-Ni)}m.push(R)}let p=[a.bandTop[0]*s.top,a.bandTop[1]*s.top,a.bandTop[2]*s.top],h=[a.bandTop[0]*s.bottomCap,a.bandTop[1]*s.bottomCap,a.bandTop[2]*s.bottomCap],f=[a.bandWall[0]*s.top,a.bandWall[1]*s.top,a.bandWall[2]*s.top],y=[a.bandWall[0]*s.wallBottom,a.bandWall[1]*s.wallBottom,a.bandWall[2]*s.wallBottom],x=(v,M)=>{let R=(n.startBin+v+.5)*e.binStepDeg,C=i[v]+(o[v]-i[v])*M/c,L=Ye(e.centre,C,R);return[L.x*d,m[v][M],L.y*d]};{let v=Math.tan(12*Math.PI/180);for(let M=0;M<6;M++){let R=!1;for(let L=0;L<l;L++)for(let E=c-1;E>=0;E--)m[L][E]>m[L][E+1]&&(m[L][E]=m[L][E+1],R=!0);let C=n.closed?l:l-1;for(let L=0;L<C;L++){let E=(L+1)%l;for(let P=0;P<=c;P++){let F=m[E][P]-m[L][P];if(Math.abs(F)>1)continue;let O=i[L]+(o[L]-i[L])*P/c,H=i[E]+(o[E]-i[E])*P/c,z=Ye(e.centre,O,(n.startBin+L+.5)*e.binStepDeg),B=Ye(e.centre,H,(n.startBin+E+.5)*e.binStepDeg),U=v*Math.hypot(B.x-z.x,B.y-z.y)*d;F>U?(m[E][P]=m[L][P]+U,R=!0):-F>U&&(m[L][P]=m[E][P]+U,R=!0)}}if(!R)break}}let b=1,S=(v,M)=>{for(let R=0;R<=c;R+=4)if(Math.abs(m[v][R]-m[M][R])>b)return!0;return Math.abs(m[v][c]-m[M][c])>b},I=Math.tan(38*Math.PI/180),w=v=>(o[v]-i[v])/c*d,g=(v,M)=>m[v][M+1]-m[v][M]>I*Math.max(1e-6,w(v)),T=(v,M)=>{let R=n.closed?(v-1+l)%l:Math.max(0,v-1),C=n.closed?(v+1)%l:Math.min(l-1,v+1);Math.abs(m[R][M]-m[v][M])>b&&(R=v),Math.abs(m[C][M]-m[v][M])>b&&(C=v);let L=Math.max(0,M-1),E=Math.min(c,M+1);L<M&&g(v,L)&&(L=M),E>M&&g(v,M)&&(E=M);let P=x(R,M),F=x(C,M),O=x(v,L),H=x(v,E),z=F[0]-P[0],B=F[1]-P[1],U=F[2]-P[2],K=H[0]-O[0],Y=H[1]-O[1],j=H[2]-O[2],q=B*j-U*Y,ne=U*K-z*j,oe=z*Y-B*K,$=Math.hypot(q,ne,oe);return $>1e-12?(q/=$,ne/=$,oe/=$,ne<0&&(q=-q,ne=-ne,oe=-oe),[q,ne,oe]):[0,1,0]},D=(v,M)=>{let R=[v[0],r,v[2]],C=[M[0],r,M[2]],L=M[0]-v[0],E=M[2]-v[2],P=Math.hypot(L,E);if(!(P>1e-12))return;let F=[E/P,0,-L/P];t.tri(v,M,C,F,f,f,y),t.tri(v,C,R,F,f,y,y)},_=.05*_e,G=v=>o[v]-i[v]<_,N=n.closed?l:l-1;for(let v=0;v<N;v++){let M=(v+1)%l;if(G(v)||G(M))continue;if(S(v,M)){let F=(n.startBin+v+1)*e.binStepDeg,O=(Y,j)=>{let q=(i[v]+i[M])/2,ne=(o[v]+o[M])/2,oe=q+(ne-q)*j/c,$=Ye(e.centre,oe,F);return[$.x*d,m[Y][j],$.y*d]};for(let Y=0;Y<c;Y++){let j=x(v,Y),q=x(v,Y+1),ne=O(v,Y),oe=O(v,Y+1),$=T(v,Y),ae=T(v,Y+1);t.triN(j,ne,oe,$,$,ae,p),t.triN(j,oe,q,$,ae,ae,p);let Oe=x(M,Y),Ve=x(M,Y+1),xe=O(M,Y),Ie=O(M,Y+1),Fe=T(M,Y),ge=T(M,Y+1);t.triN(xe,Oe,Ve,Fe,Fe,ge,p),t.triN(xe,Ve,Ie,Fe,ge,ge,p);let he=O(v,Y),se=O(v,Y+1),je=O(M,Y+1),ve=O(M,Y),Ke=se[0]-he[0],Me=se[2]-he[2],Te=Math.hypot(Ke,Me);if(Te>1e-12){let xt=[Me/Te,0,-Ke/Te];t.tri(he,se,je,xt,f),t.tri(he,je,ve,xt,f)}}let H=x(v,0),z=x(M,0),B=x(M,c),U=x(v,c),K=Y=>[Y[0],r,Y[2]];t.tri(K(H),K(B),K(z),[0,-1,0],h),t.tri(K(H),K(U),K(B),[0,-1,0],h),D(H,z),D(U,B);continue}for(let F=0;F<c;F++){let O=T(v,F),H=T(M,F),z=T(M,F+1),B=T(v,F+1);if(g(v,F)||g(M,F)){let q=(se,je)=>{let ve=(n.startBin+se+.5)*e.binStepDeg,Ke=i[se]+(o[se]-i[se])*(F+.5)/c,Me=Ye(e.centre,Ke,ve);return[Me.x*d,je,Me.y*d]},ne=x(v,F),oe=x(M,F),$=q(v,m[v][F]),ae=q(M,m[M][F]);t.triN(ne,oe,ae,O,H,H,p),t.triN(ne,ae,$,O,H,O,p);let Oe=x(M,F+1),Ve=x(v,F+1),xe=q(v,m[v][F+1]),Ie=q(M,m[M][F+1]);t.triN(xe,Ie,Oe,B,z,z,p),t.triN(xe,Oe,Ve,B,z,B,p);let Fe=ae[0]-$[0],ge=ae[2]-$[2],he=Math.hypot(Fe,ge);if(he>1e-12){let se=[-ge/he,0,Fe/he];t.tri($,ae,Ie,se,f),t.tri($,Ie,xe,se,f)}continue}let U=x(v,F),K=x(M,F),Y=x(M,F+1),j=x(v,F+1);t.triN(U,K,Y,O,H,z,p),t.triN(U,Y,j,O,z,B,p)}let R=x(v,0),C=x(M,0),L=x(M,c),E=x(v,c),P=F=>[F[0],r,F[2]];t.tri(P(R),P(L),P(C),[0,-1,0],h),t.tri(P(R),P(E),P(L),[0,-1,0],h),D(R,C),D(E,L)}if(!n.closed)for(let v of[0,l-1])for(let M=0;M<c;M++)D(x(v,M),x(v,M+1))}function Vo(t,e,n){let{bottomY:i,colors:o,ao:r}=n,a=new Float64Array(e.binCount).fill(-1/0);for(let d of e.rings)for(let u of d.arcs){let m=new Float64Array(u.binCount),p=new Float64Array(u.binCount);for(let f=0;f<u.binCount;f++){let y=(u.startBin+f)%e.binCount,x=Math.max(0,u.innerR[f]-be);m[f]=Math.max(x,a[y]+.001),p[f]=Math.max(m[f]+.001,u.outerR[f]+be)}let h=0;for(let f=0;f<u.binCount;f++){let y=u.topLevelM[f]-i;y>h&&(h=y)}h>=zi&&ji(t,e,u,m,p,i,o,r);for(let f=0;f<u.binCount;f++){let y=(u.startBin+f)%e.binCount;p[f]>a[y]&&(a[y]=p[f])}}if(Xi(n.shapes,e))return;let s=e.rings[e.rings.length-1],l=Gi*_e,c=Hi*_e;for(let d of s.arcs){let u=[],m=[];for(let f=0;f<d.binCount;f++){let y=(d.startBin+f+.5)*e.binStepDeg,x=d.outerR[f]+be+l;u.push(Ye(e.centre,x,y)),m.push(Ye(e.centre,x+c,y))}let p=-1/0;for(let f=0;f<d.binCount;f++)d.topLevelM[f]>p&&(p=d.topLevelM[f]);let h=()=>p+Ui;d.closed?ie(t,m,[u.slice().reverse()],h,i,o.shellTop,o.shellWall,r):ie(t,[...m,...u.slice().reverse()],void 0,h,i,o.shellTop,o.shellWall,r)}}function No(t,e,n,i,o,r,a,s){if(!e.outline||e.outline.length<3)return;let l=n.baseHeightM,c=Ce(i,s.tierTop);if(!o)return;let d=y=>o.deckAt(y.x,y.y),u=Po(e,a),m=u[0]??e.outline;if(o.rowLevels.length>=2){let y=Lt(o.rowLevels),x=Ao(xo(o.rowLevels,n.focal,y),u),b=()=>[0,1,0];for(let I of x){let w=Math.max(l,I.topY-.02);for(let g of r.subtract(I.outline,w))ie(t,g,I.holes,()=>w,l,c,s.tierWall,re,void 0,b)}x.length||ie(t,m,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 I of u.length?u:[m])vo(t,o.rowLevels,n.focal,o.landingY,S,I,y);return}let p=o.flat?1/0:Co,h=y=>o.normalAt(y.x,y.y),f=o.flat?o.landingY:void 0;for(let y of r.subtract(m,f))ie(t,y,e.holes,d,l,c,s.tierWall,re,p,h)}function Ki(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],d=o.get(s);d||(d=new Map,o.set(s,d));let u=c.rowId||`__seat-${a}`,m=d.get(u);m||(m={pts:[],levelM:0,n:0},d.set(u,m)),m.pts.push({x:c.x,y:c.y}),m.levelM+=n.seatDeckY(a),m.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(d=>!d.patch).map(d=>({pts:d.pts,levelM:d.y}));c.length>=2&&r.push({sectionId:a.id,rows:c});continue}let l=o.get(a.id);l&&r.push({sectionId:a.id,rows:[...l.values()].map(c=>({pts:c.pts,levelM:c.levelM/c.n}))})}return r}function zo(t,e,n,i,o){let r=Ki(e,n,i);if(!r.length)return;let a=Gn(r,e.focal);a&&(t.setMaterial(0),Vo(t,a,{bottomY:e.baseHeightM,colors:{bandTop:fe(o.tierTop,.8),bandWall:o.tierWall,shellTop:fe(o.tierWall,1.15),shellWall:o.tierWall},ao:re,shapes:e.objects.filter(s=>s.type==="shape")}))}function Go(t,e,n){return n<0?e>1?t.filter(i=>i.kind==="floor"):[...t]:t.filter(i=>i.floorIndex===void 0||i.floorIndex===n)}function Ho(t,e){let n=[...t].sort((o,r)=>o.screen.y-r.screen.y),i=[];for(let o of n){let r=i.find(a=>a.some(s=>Math.abs(s.screen.x-o.screen.x)<104&&Math.abs(s.screen.y-o.screen.y)<34));r?r.push(o):i.push([o])}return i.flatMap(o=>o.length<2?o:o.map((r,a)=>({...r,screen:{...r.screen,x:Math.max(54,Math.min(e-54,r.screen.x+(a-(o.length-1)/2)*104))}})))}var qi=1.15,Zi=3.25,Qi=4.5,$i=.85,Ji=.5,ea=.26;function Uo(t,e,n){let i=Math.max(1e-6,e),o=t/i,r=n?.hasZoneLabels??!0,a=new Set;return o>=.75&&a.add("floor"),o>=qi&&a.add("zone"),o<=(r?Zi:Qi)&&(a.add("section"),a.add("ga")),o<=$i&&(a.add("annotation"),a.add("booth")),o<=Ji&&a.add("row"),o<=ea&&a.add("seat"),a}function Be(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],d=o[2]*r+o[6]*a+o[10]*s+o[14],u=o[3]*r+o[7]*a+o[11]*s+o[15];if(!(u>1e-6))return{x:0,y:0,depth:1/0,visible:!1};let m=l/u,p=c/u,h=d/u,f=m>=-1.05&&m<=1.05&&p>=-1.05&&p<=1.05&&h<=1;return{x:(m*.5+.5)*n,y:(1-(p*.5+.5))*i,depth:h,visible:f}}function Yo(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)if(pn(r,s,e,n)){a=!0;break}a||i.push(r)}return i}var ta=6;function pn(t,e,n,i){let o=Math.abs(t.screen.x-e.screen.x),r=Math.abs(t.screen.y-e.screen.y),a=t.halfWidth!=null&&e.halfWidth!=null?Math.max(n,t.halfWidth+e.halfWidth+ta):n;return o<a&&r<i}function Xo(t,e,n){return t.length*e*.58+(n?14:0)}var fn={row:8,seat:14};function Wo(t,e,n,i){let o=Math.max(1,Math.min(n,i)*.5),r=Math.min(2,Math.hypot(t.x-n/2,t.y-i/2)/o);return e*(1+1.5*r)}function bn(t,e,n,i,o=[]){let r=[...t].sort((s,l)=>(l.priority??0)-(s.priority??0)||s.focus-l.focus),a=[];for(let s of r){if(a.length>=i)break;let l=!1;for(let c of o)if(pn(s,c,e,n)){l=!0;break}if(!l){for(let c of a)if(pn(s,c,e,n)){l=!0;break}}l||a.push(s)}return a}var na=6,oa=2.2,jo=.1,ra=.3,ia=1.8,aa=.9,sa=.55,ca=6e3;function Ko(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 d of n)for(let u of d.objects)u.type==="section"&&u.zone&&l.set(u.id,u.zone);let c=new Map;for(let d=0;d<i.length;d++){let u=i[d],m=o.seatOwner[d],p=u.zoneId??(m?l.get(m):void 0);if(!p)continue;let h=c.get(p);h||(h={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},c.set(p,h)),h.n++,u.x<h.minX&&(h.minX=u.x),u.y<h.minY&&(h.minY=u.y),u.x>h.maxX&&(h.maxX=u.x),u.y>h.maxY&&(h.maxY=u.y),h.sumY+=o.seatDeckY(d)}for(let d of a){let u=c.get(d.id),m=[];for(let[p,h]of l)h===d.id&&m.push(p);if(!u||u.n===0){s.push({id:d.id,label:d.label,color:Q(d.color),sectionIds:m,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(d.focalPoint??r).x*A,1.5,(d.focalPoint??r).y*A]});continue}s.push({id:d.id,label:d.label,color:Q(d.color),sectionIds:m,seatCount:u.n,center:[(u.minX+u.maxX)/2*A,u.sumY/u.n,(u.minY+u.maxY)/2*A],radius:.5*Math.hypot((u.maxX-u.minX)*A,(u.maxY-u.minY)*A)||1,focalWorld:[(d.focalPoint??r).x*A,1.5,(d.focalPoint??r).y*A]})}}return s}function qo(t){let{doc:e,units:n,seats:i,surfaces:o,seatData:r,hintedSeatFloor:a,zones:s,focal:l}=t,c=[],d=[],u=[];for(let m of s)m.seatCount!==0&&c.push({id:`zone:${m.id}`,kind:"zone",text:m.label,anchor:[m.center[0],m.center[1]+na,m.center[2]],color:e.zones?.find(p=>p.id===m.id)?.color});{let m=new Map,p=new Map;for(let h=0;h<i.length;h++){let f=o.seatOwner[h];if(!f)continue;let y=m.get(f);y||(y={n:0,x:0,y:0,deck:0},m.set(f,y)),y.n++,y.x+=i[h].x,y.y+=i[h].y,y.deck+=o.seatDeckY(h);let x=p.get(f);x||(x={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0},p.set(f,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 f of h.objects){if(f.type!=="section")continue;let y=m.get(f.id);if(!y||y.n===0)continue;let x=p.get(f.id),b=[y.x/y.n*A,y.deck/y.n,y.y/y.n*A],S=f.displayLabel||f.label||f.id;d.push({id:f.id,floorIndex:h.index,label:S,seatCount:y.n,center:b,radius:Math.max(1,Math.hypot(x.maxX-x.minX,x.maxY-x.minY)*.5*A),focalWorld:[h.focal.x*A,h.baseHeightM+1.5,h.focal.y*A]});let I=e.floors?.[h.index]?.name?.trim().toLocaleLowerCase();n.length>1&&I===S.trim().toLocaleLowerCase()||c.push({id:`section:${f.id}`,kind:"section",text:S,anchor:[b[0],b[1]+oa,b[2]],floorIndex:h.index})}}{for(let h of n)for(let f of h.objects){if(f.type!=="gaArea")continue;let y=rt(f.points);if(!y)continue;let x=f.displayLabel||f.label||f.id;c.push({id:`ga:${f.id}`,kind:"ga",text:f.capacity>0?`${x} \xB7 ${f.capacity.toLocaleString()}`:x,anchor:[y.x*A,h.baseHeightM+ia,y.y*A],floorIndex:h.index})}let m=new Map;for(let h=0;h<i.length;h++){let f=i[h],y=Math.hypot(f.x-l.x,f.y-l.y),x=m.get(f.rowId);(!x||y>x.far)&&m.set(f.rowId,{seat:f,index:h,far:y})}for(let[h,f]of m){let y=f.seat.label?f.seat.label.lastIndexOf("-"):-1,x=y>0?f.seat.label.slice(0,y):h;x&&c.push({id:`row:${h}`,kind:"row",text:x,anchor:[f.seat.x*A,o.seatDeckY(f.index)+aa,f.seat.y*A],floorIndex:a[f.index]})}let p=new Map;for(let h=0;h<i.length;h++){let f=i[h],y=f.label?f.label.lastIndexOf("-"):-1,x=p.get(f.rowId);x||(x={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:y>0?f.label.slice(0,y):f.rowId,sectionId:f.sectionId},p.set(f.rowId,x));let b=h*3,S=r.iPosition[b],I=r.iPosition[b+1],w=r.iPosition[b+2];x.n++,x.x+=S,x.y+=I,x.z+=w,x.minX=Math.min(x.minX,S),x.maxX=Math.max(x.maxX,S),x.minZ=Math.min(x.minZ,w),x.maxZ=Math.max(x.maxZ,w)}for(let[h,f]of p)u.push({id:h,label:f.label,sectionId:f.sectionId,seatCount:f.n,center:[f.x/f.n,f.y/f.n,f.z/f.n],radius:Math.max(.8,Math.hypot(f.maxX-f.minX,f.maxZ-f.minZ)*.5)});if(i.length<=ca)for(let h=0;h<i.length;h++){let f=i[h],y=f.displayLabel||f.label;y&&c.push({id:`seat:${f.id}`,kind:"seat",text:y,anchor:[f.x*A,o.seatDeckY(h)+sa,f.y*A],floorIndex:a[h]})}}for(let m of n)for(let p of m.objects)if(p.type==="shape"&&p.role&&["entrance","exit","screen","suite","obstruction"].includes(p.role)){let h=dt(p),f=h?rt(h):null;if(!f||!p.label)continue;c.push({id:`architecture:${p.id}`,kind:"annotation",text:p.label,anchor:[f.x*A,m.baseHeightM+ht(p).heightM+jo,f.y*A],color:p.fill,floorIndex:m.index})}else if(p.type==="text"){if(!p.text)continue;c.push({id:`text:${p.id}`,kind:"annotation",text:p.text,anchor:[p.position.x*A,m.baseHeightM+jo,p.position.y*A],color:p.color,rotation:p.rotation,floorIndex:m.index})}else if(p.type==="booth"){let h=ft(p);if(!h)continue;let f=rt(h);if(!f)continue;c.push({id:`booth:${p.id}`,kind:"booth",text:p.displayLabel||p.label||p.id,anchor:[f.x*A,m.baseHeightM+mn+ra,f.y*A],floorIndex:m.index})}return{labels:c,sections:d,rows:u}}function Zo(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 Qo(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 m=0;m<r.floor.length;m+=1){let p=Math.max(0,Math.min(n.length-1,Math.round(r.floor[m]))),h=m*3,f=c[p];f.minX=Math.min(f.minX,r.position[h]),f.minY=Math.min(f.minY,r.position[h+1]),f.minZ=Math.min(f.minZ,r.position[h+2]),f.maxX=Math.max(f.maxX,r.position[h]),f.maxY=Math.max(f.maxY,r.position[h+1]),f.maxZ=Math.max(f.maxZ,r.position[h+2])}let d=new Map;for(let m=0;m<n.length;m++)for(let p of n[m].objects)p.type==="section"&&d.set(p.id,m);let u=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 m=0;m<i.length;m++){let p=o.seatOwner[m],h=(p!==null?d.get(p):void 0)??a[m];if(h===void 0)continue;let f=u[h],y=i[m];f.n++,y.x<f.minX&&(f.minX=y.x),y.y<f.minY&&(f.minY=y.y),y.x>f.maxX&&(f.maxX=y.x),y.y>f.maxY&&(f.maxY=y.y);let x=o.seatDeckY(m);f.sumX+=y.x*A,f.sumDeck+=x,f.sumZ+=y.y*A,f.minDeck=Math.min(f.minDeck,x),f.maxDeck=Math.max(f.maxDeck,x+1.6),s[m]=h}for(let m=0;m<n.length;m++){let p=u[m],h=e.floors?.[m],f=c[m],y=Math.min(p.n?p.minX*A:n[m].focal.x*A-1,Number.isFinite(f.minX)?f.minX:1/0),x=Math.max(p.n?p.maxX*A:n[m].focal.x*A+1,Number.isFinite(f.maxX)?f.maxX:-1/0),b=Math.min(p.n?p.minY*A:n[m].focal.y*A-1,Number.isFinite(f.minZ)?f.minZ:1/0),S=Math.max(p.n?p.maxY*A:n[m].focal.y*A+1,Number.isFinite(f.maxZ)?f.maxZ:-1/0),I=Math.min(p.n?Math.min(n[m].baseHeightM,p.minDeck):n[m].baseHeightM,Number.isFinite(f.minY)?f.minY:1/0),w=Math.max(p.n?Math.max(p.maxDeck,I+.5):I+.5,Number.isFinite(f.maxY)?f.maxY:-1/0),g=[p.n?p.sumX/p.n:(y+x)/2,p.n?p.sumDeck/p.n:(I+w)/2,p.n?p.sumZ/p.n:(b+S)/2],T=Math.max(1,.5*Math.hypot(x-y,w-I,S-b));l.push({index:m,id:h?.id??`floor-${m}`,label:h?.name??(n.length>1?`Floor ${m+1}`:"Venue"),seatCount:p.n,center:g,radius:T,box:{min:[y,I,b],max:[x,w,S]},focalWorld:[n[m].focal.x*A,n[m].baseHeightM+1.5,n[m].focal.y*A]})}}return l}function yn(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=ft(l);if(c)for(let d of c)a(d.x,d.y)}else if(l.type==="table"){let c=dn(l);if(c)for(let d of c)a(d.x,d.y)}else if(l.type==="decorImage"){let c=hn(l);if(c)for(let d of c)a(d.x,d.y)}return Number.isFinite(n)||(n=-100,i=-100,o=100,r=100),{minX:n,minY:i,maxX:o,maxY:r}}function $o(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=mt(o.minX-a,o.minY-a,o.maxX-o.minX+a*2,o.maxY-o.minY+a*2);ie(t,s,void 0,()=>0,-.4,r.ground,r.ground,re)}else{let a=e.reduce((p,h)=>h.baseHeightM<p.baseHeightM?h:p);t.setFloor(a.index);let s=n.filter((p,h)=>i[h]===a.index),l=yn([a],s),c=Math.hypot(l.maxX-l.minX,l.maxY-l.minY),d=Math.max(28,Math.min(80,c*.04)),u=mt(l.minX-d,l.minY-d,l.maxX-l.minX+d*2,l.maxY-l.minY+d*2),m=a.baseHeightM-.03;ie(t,u,void 0,()=>m,m-.22,r.ground,r.ground,re)}}function Jo(t,e,n){let{cx:i,cz:o,radius:r}=n,a=1/0,s=1/0,l=1/0,c=-1/0,d=-1/0,u=-1/0,m=(f,y,x)=>{a=Math.min(a,f),c=Math.max(c,f),s=Math.min(s,y),d=Math.max(d,y),l=Math.min(l,x),u=Math.max(u,x)};for(let f=0;f<t.position.length;f+=3)m(t.position[f],t.position[f+1],t.position[f+2]);for(let f=0;f<e.count;f++){let y=f*3,x=e.iPosition[y],b=e.iPosition[y+1],S=e.iPosition[y+2],I=Math.max(.35,e.iMaxRadius[f]??.35);m(x-I,b,S-I),m(x+I,b+1.6,S+I)}Number.isFinite(a)||(a=i-r,c=i+r,s=0,d=r*.16,l=o-r,u=o+r);let p=[(a+c)/2,(s+d)/2,(l+u)/2],h=Math.max(1,.5*Math.hypot(c-a,d-s,u-l));return{center:p,radius:h,minY:s,maxY:d}}function er(t,e,n,i,o,r){let a=1/0,s=1/0,l=-1/0,c=-1/0;for(let I=0;I<t.count;I++){let w=I*3,g=t.iPosition[w],T=t.iPosition[w+2];g<a&&(a=g),g>l&&(l=g),T<s&&(s=T),T>c&&(c=T)}for(let I of e)a=Math.min(a,I.cx-I.halfX),l=Math.max(l,I.cx+I.halfX),s=Math.min(s,I.cz-I.halfZ),c=Math.max(c,I.cz+I.halfZ);let d=n.minX*A,u=n.maxX*A,m=n.minY*A,p=n.maxY*A,h=d,f=u,y=m,x=p;if(Number.isFinite(a)){let I=Math.max(2,.06*Math.hypot(l-a,c-s));h=Math.max(d,a-I),f=Math.min(u,l+I),y=Math.max(m,s-I),x=Math.min(p,c+I)}let b=Math.min(0,i),S=Math.max(o,r*.05);return{min:[h,b,y],max:[f,S,x]}}function bt(t){let{doc:e}=t,n=so(e.theme),i=n.structure,o=wo(e,t.eventConfigurationId??e.eventConfigurationId),r=t.seats,a=new Et,s=new Map;for(let M of o)for(let R of M.objects)s.set(R.id,M.index),R.type==="section"&&s.set(R.logicalSectionId??R.id,M.index);let l=r.map(M=>s.get(M.sectionId??"")??s.get(M.rowId??"")??0),c=yn(o,r);$o(a,o,r,l,c,i);let d=Io(e,r),u=new Map,m=new Map;for(let M of e.categories??[])u.set(M.key,M.color),M.seatGlyph&&m.set(M.key,M.seatGlyph);let p=[],h=Ro(o,r,l),f=new Float32Array(r.length);for(let M=0;M<o.length;M++){let R=o[M];a.setFloor(M);let C=new Bt,L=[],E=R.objects.filter(P=>P.type==="section"&&!!P.outline&&P.outline.length>=3);for(let P of R.objects)P.type==="section"?No(a,P,R,Fo(P,d),h.bySection.get(P.id),C,E,i):P.type==="shape"?(a.setMaterial(P.role==="screen"?1:0),Lo(a,P,R.baseHeightM,To(P,L),i,R.focal,p),a.setMaterial(0)):P.type==="gaArea"?Oo(a,P,R.baseHeightM,Q(u.get(P.categoryKey)),i):P.type==="booth"?ko(a,P,R.baseHeightM,Q(u.get(P.categoryKey)),i):P.type==="table"?_o(a,P,R.baseHeightM,Q(u.get(P.categoryKey)),i):P.type==="decorImage"&&Bo(a,P,R.baseHeightM,i);zo(a,R,r,h,i)}let y=o.length>1?{x:o.reduce((M,R)=>M+R.focal.x,0)/o.length,y:o.reduce((M,R)=>M+R.focal.y,0)/o.length}:e.focalPoint??{x:(c.minX+c.maxX)/2,y:(c.minY+c.maxY)/2},x=to([a.build()]),b=ao(r,t.initialState,h,f,u,m),S=Ko({doc:e,units:o,seats:r,surfaces:h,focal:y}),{labels:I,sections:w,rows:g}=qo({doc:e,units:o,seats:r,surfaces:h,seatData:b,hintedSeatFloor:l,zones:S,focal:y}),T=Qo({doc:e,units:o,seats:r,surfaces:h,solids:x,hintedSeatFloor:l,seatFloor:f});Zo(I,T),b.iYaw=ro(b.iPosition,r.length,M=>r[M].rowId,M=>{let R=o[f[M]]?.focal??y;return[R.x*A,R.y*A]});let D=(c.minX+c.maxX)/2*A,_=(c.minY+c.maxY)/2*A,G=.5*Math.hypot((c.maxX-c.minX)*A,(c.maxY-c.minY)*A)||10,N=Jo(x,b,{cx:D,cz:_,radius:G}),v=er(b,p,c,N.minY,N.maxY,G);return{solids:x,seats:b,bounds:{center:[(v.min[0]+v.max[0])/2,(v.min[1]+v.max[1])/2,(v.min[2]+v.max[2])/2],radius:G,groundY:0,box:v},renderBounds:{center:N.center,radius:N.radius},stateColorLUT:co(n,ye),theme:n,seatCount:r.length,focalWorld:[y.x*A,1.5,y.y*A],zones:S,stages:p,sections:w,rows:g,labels:I,floors:T}}var la=88,ua=20,tr={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}},Ot=new Set(["row","seat"]),nr={floor:5,zone:4,section:3,ga:3,booth:2,annotation:1},Vt={row:{x:62,y:16},seat:{x:46,y:18}},rr=Q,xn=t=>Ln(t);function ir(t,e){let n=xn(t),i=xn(e);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function or(t,e){let n=/rgba\((\d+),(\d+),(\d+),([\d.]+)\)/.exec(t.replace(/\s/g,""));if(!n)return e;let i=Math.max(0,Math.min(1,Number(n[4])));return[1,2,3].map(o=>Number(n[o])/255*i+e[o-1]*(1-i))}function ma(t,e=[.04,.06,.1]){let n=xn(e)<.42,i=n?"#f4f7fb":"#0b1220",o=rr(t),r=o&&ir(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 Nt=class{constructor(e,n={}){this.nodes=new Map;this.labels=[];this.forcedDense=!1;this.selectedSeatLabelIds=new Set;this.opts=n,this.root=document.createElement("div"),this.root.setAttribute("data-view3d-labels","");let i=this.root.style;i.position="absolute",i.inset="0",i.pointerEvents="none",i.overflow="hidden",n.fontFamily&&(i.fontFamily=n.fontFamily),e.appendChild(this.root)}setVisible(e){this.root.style.visibility=e?"":"hidden"}setLabels(e){this.labels=e;for(let[n,i]of this.nodes)e.some(o=>o.id===n)||(i.remove(),this.nodes.delete(n))}setForcedDense(e){this.forcedDense=e}setSelectedSeatIds(e){this.selectedSeatLabelIds=new Set(Array.from(e,n=>`seat:${n}`))}qualityEvidence(){let e=this.root.getBoundingClientRect(),n=this.root.style.visibility!=="hidden";return this.labels.map(i=>{let o=this.nodes.get(i.id),r=o?.getBoundingClientRect(),a=!!(n&&o&&o.style.display!=="none"&&r&&r.width>0&&r.height>0);return{id:i.id,kind:i.kind,text:i.text,visible:a,renderedFontPx:o&&Number.parseFloat(o.style.fontSize)||0,contrast:o?Number(o.dataset.qualityContrast??0):0,...a&&r?{screenBox:{x:r.x-e.x,y:r.y-e.y,width:r.width,height:r.height}}:{}}})}update(e,n,i,o,r,a){if(!this.labels.length)return;let s=Uo(o,r,{hasZoneLabels:this.labels.some(b=>b.kind==="zone")});this.forcedDense&&(s.add("row"),s.add("seat"));let l=[];for(let b of this.labels){if(!s.has(b.kind))continue;let S=Be(e,b.anchor,n,i);if(!S.visible)continue;let I=a?Math.hypot(b.anchor[0]-a[0],b.anchor[1]-a[1],b.anchor[2]-a[2]):1;l.push({label:b,screen:S,focus:Wo(S,I,n,i),halfWidth:Xo(b.text,tr[b.kind].size,!Ot.has(b.kind))/2,...this.selectedSeatLabelIds.has(b.id)?{priority:1}:{}})}let c=Ho(l.filter(b=>b.label.kind==="floor"),n),d=[...l.filter(b=>!Ot.has(b.label.kind)&&b.label.kind!=="floor"),...c],u=Yo(d,la,ua),m=bn(l.filter(b=>b.label.kind==="row"),Vt.row.x,Vt.row.y,fn.row,u),p=bn(l.filter(b=>b.label.kind==="seat"),Vt.seat.x,Vt.seat.y,fn.seat,[...u,...m]),h=[...u,...m,...p],f=new Set(h.map(b=>b.label.id));for(let{label:b,screen:S}of h){let w=this.nodeFor(b).style;w.display="",w.transform=`translate(-50%, -50%) translate(${S.x.toFixed(1)}px, ${S.y.toFixed(1)}px)`}let y=h.filter(({label:b})=>!Ot.has(b.kind)).sort((b,S)=>nr[S.label.kind]-nr[b.label.kind]||b.screen.depth-S.screen.depth||b.focus-S.focus),x=[];for(let{label:b}of y){let S=this.nodes.get(b.id);if(!S||S.style.display==="none")continue;let I=S.getBoundingClientRect();x.some(g=>I.left<g.right+3&&I.right+3>g.left&&I.top<g.bottom+3&&I.bottom+3>g.top)?S.style.display="none":x.push(I)}for(let[b,S]of this.nodes)f.has(b)||(S.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=tr[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=!Ot.has(e.kind);r.color=i?"#ecf8ff":a.ink,r.background=i?"rgba(10,28,45,.9)":s?a.backing:"",r.border=i?"1px solid rgba(89,199,255,.92)":s?`1px solid ${a.border}`:"",r.borderRadius=i||s?"999px":"",r.padding=i||s?"3px 7px":"",r.boxShadow=i?"0 0 0 2px rgba(41,176,255,.18), 0 5px 14px rgba(0,0,0,.35)":s?"0 3px 10px rgba(0,0,0,.24)":"",r.letterSpacing=e.kind==="zone"||e.kind==="floor"?"0.08em":"0.02em";let l=this.opts.backgroundRgb??[.04,.06,.1],c=rr(i?"#ecf8ff":a.ink)??[1,1,1],d=i?or("rgba(10,28,45,.9)",l):s?or(a.backing,l):l;return n.dataset.qualityContrast=ir(c,d).toFixed(3),(e.kind==="zone"||e.kind==="floor")&&(r.textTransform="uppercase"),n}dispose(){this.root.remove(),this.nodes.clear()}};var da=1;var ha=new Set(["floor","zone","section","ga","booth","annotation"]);function pa(t){return t.every(e=>Number.isFinite(e))}function fa(t,e){return t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y}function ar(t){return t.length?Math.round(Math.min(...t)*100)/100:null}function Xe(t){return Math.round(t*1e4)/1e4}function ba(t){if(t)return{box:{x:Xe(t.box.x),y:Xe(t.box.y),width:Xe(t.box.width),height:Xe(t.box.height)},horizontalFillRatio:Xe(t.horizontalFillRatio),verticalFillRatio:Xe(t.verticalFillRatio),visibleAreaRatio:Xe(t.visibleAreaRatio),clippedEdges:[...t.clippedEdges]}}function Pe(t,e,n){return n.length?{code:t,message:e,count:n.length,samples:n.slice(0,20)}:null}function gn(t){let e=t.labels.filter(s=>s.visible&&s.screenBox),n=e.filter(s=>ha.has(s.kind)),i=t.scene.floorCount>1?t.scene.floorCount:t.scene.zoneCount||t.scene.sectionCount,o=[];for(let s=0;s<n.length;s+=1)for(let l=0;l<s;l+=1)fa(n[s].screenBox,n[l].screenBox)&&o.push({primaryId:n[s].id,primaryLabel:n[s].text,secondaryId:n[l].id});let r=[...t.camera.position,t.camera.distance,t.camera.verticalFovDeg],a=[Pe("webgl2-unavailable","The venue scene must render through WebGL2",t.context.webgl2?[]:[{primaryId:"renderer",primaryLabel:"WebGL2"}]),Pe("context-lost","The WebGL context must be live at capture",t.context.lost?[{primaryId:"renderer",primaryLabel:"context lost"}]:[]),Pe("frame-not-stable","The captured 3D frame must be rendered and parked",t.frame.rendered>0&&t.frame.idle?[]:[{primaryId:"renderer",primaryLabel:"unstable frame"}]),Pe("viewport-empty","The 3D viewport must have visible dimensions",t.viewport.width>1&&t.viewport.height>1?[]:[{primaryId:"viewport",primaryLabel:`${t.viewport.width}\xD7${t.viewport.height}`}]),Pe("camera-invalid","The capture camera must have a finite physical pose",pa(r)&&t.camera.distance>0&&t.camera.verticalFovDeg>0&&t.camera.verticalFovDeg<180?[]:[{primaryId:"camera",primaryLabel:"invalid pose"}]),Pe("authored-relief-not-visible","Authored 3D height or rake must produce visible screen-space relief",!t.scene.authoredRelief||t.scene.renderedVerticalSpanM>.05&&t.scene.projectedReliefPx>=2?[]:[{primaryId:"scene",primaryLabel:"authored relief",measured:t.scene.projectedReliefPx,minimum:2}]),Pe("hierarchy-label-missing","A venue with authored hierarchy must show at least one structural label",i===0||n.length>0?[]:[{primaryId:"labels",primaryLabel:`${i} expected hierarchy labels`}]),Pe("hierarchy-label-undersized","Visible 3D hierarchy labels must remain readable",n.filter(s=>s.renderedFontPx<11).map(s=>({primaryId:s.id,primaryLabel:s.text,measured:s.renderedFontPx,minimum:11}))),Pe("hierarchy-label-contrast-low","Visible 3D hierarchy labels must meet text contrast",n.filter(s=>s.contrast<4.5).map(s=>({primaryId:s.id,primaryLabel:s.text,measured:s.contrast,minimum:4.5}))),Pe("hierarchy-label-collision","Visible 3D hierarchy labels must not overlap",o)].filter(s=>!!s);return{version:1,state:"venue3d",passed:a.length===0,resolvedRules:["rendered-3d-webgl-context","rendered-3d-stable-frame","rendered-3d-camera-pose","rendered-3d-relief-projection","rendered-3d-label-size","rendered-3d-label-contrast","rendered-3d-label-collision"],viewport:t.viewport,context:t.context,frame:t.frame,camera:t.camera,scene:t.scene,composition:{visibleLabels:e.map(({id:s,kind:l,text:c})=>({id:s,kind:l,text:c})).sort((s,l)=>s.kind.localeCompare(l.kind)||s.id.localeCompare(l.id)),framing:ba(t.framing)},metrics:{minimumHierarchyFontPx:ar(n.map(s=>s.renderedFontPx)),minimumHierarchyContrast:ar(n.map(s=>s.contrast)),projectedReliefPx:Math.round(t.scene.projectedReliefPx*100)/100},findings:a}}import{Geometry as Gt,Mesh as Ht,Transform as br}from"ogl";import{Program as We}from"ogl";var zt=`
|
|
1
|
+
import{a as Gn,c as Hn,d as Un}from"../chunk-QHWOX6PN.js";import{d as zn}from"../chunk-T2LWVOQ3.js";import{e as En,l as Ge,n as at,o as Nn,q as Pt}from"../chunk-VI3IZS2B.js";import{e as On,k as Vn}from"../chunk-UL5OIGIF.js";import{W as ke,X as _e,ea as St,ga as kn,ha as wt,ja as _n,l as Dn,m as rt,va as Ln}from"../chunk-RZLIIQDP.js";import{d as Q,k as Bn,x as pe,z as it}from"../chunk-CXF32VPG.js";import{Renderer as Hr}from"ogl";var ye=["available","held","sold","selected","dimmed"];function st(t){let e=ye.indexOf(t);return e<0?0:e}var Yn={available:[.24,.82,.52],held:[.95,.66,.22],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};function Xn(t){let e=.2126*t[0]+.7152*t[1]+.0722*t[2],n=.42,i=.62;return[(e+(t[0]-e)*n)*i,(e+(t[1]-e)*n)*i,(e+(t[2]-e)*n)*i]}var Qt={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 fe(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 At=class{constructor(e,n){this.clearRgb=[0,0,0];this.container=e,this.canvas=document.createElement("canvas"),this.canvas.style.display="block",this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.touchAction="none",this.canvas.tabIndex=0,this.canvas.setAttribute("role","application"),this.canvas.setAttribute("aria-label","Interactive 3D venue. Drag or use arrow keys to look around; pinch, scroll, plus or minus to zoom."),this.renderer=new 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 $t}from"ogl";var ue=Math.PI/180,Jt=15*ue,en=80*ue,qe=.12,Wn=35,jn=1.25,Ct=class{constructor(e,n,i,o){this.fovY=Wn;this.target=new $t;this.azimuth=-30*ue;this.polar=55*ue;this.distance=10;this.azT=-30*ue;this.polT=55*ue;this.distT=10;this.minDist=1;this.maxDist=100;this.gestureFired=!1;this.interactionEnabled=!0;this.dragging=!1;this.panning=!1;this.lastX=0;this.lastY=0;this.activePointers=new Map;this.pinchDist=0;this.pinchCx=0;this.pinchCy=0;this.targetT=new $t;this.panAnchor=new $t;this.panLimit=0;this.primaryDragMode="orbit";this.camera=new Yr(e,{fov:Wn,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(Jt,Math.min(en,this.polT-s*.006)),this.requestRender())},this.onPointerUp=r=>{this.activePointers.delete(r.pointerId);try{this.canvas.releasePointerCapture?.(r.pointerId)}catch{}this.activePointers.size<2&&(this.pinchDist=0),this.activePointers.size===0&&(this.dragging=!1,this.panning=!1)},this.onContextMenu=r=>{r.preventDefault()},this.onWheel=r=>{if(r.preventDefault(),!this.interactionEnabled)return;let a=r.deltaMode===1?16:r.deltaMode===2?100:1,s=Math.max(-2,Math.min(2,r.deltaY*a/100));this.dollyBy(Math.exp(s*.22)),this.fireGesture()},this.onKeyDown=r=>{if(!this.interactionEnabled)return;let a=7*ue;if(r.shiftKey&&(r.key==="ArrowLeft"||r.key==="ArrowRight"||r.key==="ArrowUp"||r.key==="ArrowDown"))this.panBy(r.key==="ArrowLeft"?-32:r.key==="ArrowRight"?32:0,r.key==="ArrowUp"?-32:r.key==="ArrowDown"?32:0);else if(r.key==="ArrowLeft"||r.key==="ArrowRight")this.azT+=r.key==="ArrowLeft"?-a:a;else if(r.key==="ArrowUp"||r.key==="ArrowDown")this.polT=Math.max(Jt,Math.min(en,this.polT+(r.key==="ArrowUp"?-a:a)));else if(r.key==="+"||r.key==="=")this.dollyBy(.82);else if(r.key==="-"||r.key==="_")this.dollyBy(1.22);else return;r.preventDefault(),this.fireGesture(),this.requestRender()},n.addEventListener("pointerdown",this.onPointerDown),n.addEventListener("pointermove",this.onPointerMove),n.addEventListener("pointerup",this.onPointerUp),n.addEventListener("pointercancel",this.onPointerUp),n.addEventListener("wheel",this.onWheel,{passive:!1}),n.addEventListener("keydown",this.onKeyDown),n.addEventListener("contextmenu",this.onContextMenu)}pinchCentroid(){let e=[...this.activePointers.values()];if(!e.length)return{x:0,y:0};let n=0,i=0;for(let o of e)n+=o.x,i+=o.y;return{x:n/e.length,y:i/e.length}}panBy(e,n){let i=this.canvas.clientHeight||1,o=2*this.distance*Math.tan(this.fovY*ue/2)/i,r=Math.sin(this.azimuth),a=Math.cos(this.azimuth),s=a,l=-r,c=Math.cos(this.polar),d=Math.sin(this.polar),u=-r*c,m=-a*c;this.targetT.x+=(-e*s+n*u)*o,this.targetT.z+=(-e*l+n*m)*o,this.targetT.y+=n*d*o,this.clampPan(),this.requestRender()}clampPan(){if(this.panLimit<=0)return;let e=this.panLimit,n=this.panAnchor.x,i=this.panAnchor.y,o=this.panAnchor.z;this.targetT.x=Math.max(n-e,Math.min(n+e,this.targetT.x)),this.targetT.z=Math.max(o-e,Math.min(o+e,this.targetT.z)),this.targetT.y=Math.max(i-e*.5,Math.min(i+e,this.targetT.y))}fireGesture(){this.gestureFired||(this.gestureFired=!0,this.onGesture?.())}currentPinchDistance(){let e=[...this.activePointers.values()];return e.length<2?0:Math.hypot(e[0].x-e[1].x,e[0].y-e[1].y)}dollyBy(e){this.distT=Math.max(this.minDist,Math.min(this.maxDist,this.distT*e)),this.requestRender()}zoomBy(e){this.interactionEnabled&&(this.dollyBy(e),this.fireGesture())}setPrimaryDragMode(e){this.primaryDragMode=e}setInteractionEnabled(e){this.interactionEnabled=e,!e&&(this.activePointers.clear(),this.dragging=!1,this.panning=!1,this.pinchDist=0)}frame(e,n=!1,i,o=!1,r){this.target.set(e.center[0],e.center[1],e.center[2]),this.targetT.copy(this.target),this.panAnchor.copy(this.target),this.panLimit=Math.max(1,e.radius)*1.5;let a=Math.max(1,e.radius),s=this.fovY*ue/2,l=o?Math.max(.82,this.camera.aspect||1):this.camera.aspect||1,c=Math.atan(Math.tan(s)*l);this.azT=i??-30*ue,this.polT=Math.max(15,Math.min(80,r?.polarDeg??55))*ue;let d=this.fitDistance(e,s,c,this.azT,this.polT);this.distT=d*Math.max(1.05,Math.min(2,r?.margin??jn)),this.minDist=Math.max(2,a*.12),this.maxDist=d*4,n?(this.azimuth=this.azT,this.polar=12*ue,this.distance=this.distT*1.7):(this.azimuth=this.azT,this.polar=this.polT,this.distance=this.distT),this.applyPosition()}setAspect(e){this.camera.perspective({aspect:e})}frameSoft(e,n,i=!1,o){this.target.set(e.center[0],e.center[1],e.center[2]),this.targetT.copy(this.target),this.panAnchor.copy(this.target),this.panLimit=Math.max(1,e.radius)*1.5,this.syncFromCamera(),this.camera.perspective({fov:this.fovY,aspect:this.camera.aspect});let r=this.fovY*ue/2,a=i?Math.max(.82,this.camera.aspect||1):this.camera.aspect||1,s=Math.atan(Math.tan(r)*a);this.azT=n??this.azimuth,this.polT=Math.max(15,Math.min(80,o?.polarDeg??55))*ue;let l=this.fitDistance(e,r,s,this.azT,this.polT);this.distT=l*Math.max(1.05,Math.min(2,o?.margin??jn))}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),d=-c*Math.sin(o),u=-Math.cos(r),m=-c*Math.cos(o);if(Math.abs(u)>.999)return s;let p=-m,h=d,f=Math.hypot(p,h);p/=f,h/=f;let y=-h*u,x=h*d-p*m,b=p*u,S=Math.tan(i),I=Math.tan(n),w=1;for(let g=0;g<8;g++){let T=(g&1?l.max[0]:l.min[0])-e.center[0],D=(g&2?l.max[1]:l.min[1])-e.center[1],_=(g&4?l.max[2]:l.min[2])-e.center[2],G=T*d+D*u+_*m,N=Math.abs(T*p+_*h),v=Math.abs(T*y+D*x+_*b);w=Math.max(w,N/S-G,v/I-G)}return Math.min(s,Math.max(w,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*qe,this.polar+=n*qe,this.distance+=i*qe,this.target.x+=o*qe,this.target.y+=r*qe,this.target.z+=a*qe,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(Jt,Math.min(en,Math.acos(Math.max(-1,Math.min(1,n/o)))));this.distance=this.distT=o,this.polar=this.polT=r,this.azimuth=this.azT=Math.atan2(e,i)}setTarget(e){this.target.set(e[0],e[1],e[2]),this.targetT.copy(this.target)}resumeAfterFlight(e){this.camera.perspective({fov:this.fovY,aspect:this.camera.aspect}),e&&this.target.set(e[0],e[1],e[2]),this.targetT.copy(this.target),this.syncFromCamera()}applyPosition(){let e=Math.sin(this.polar),n=this.target.x+this.distance*e*Math.sin(this.azimuth),i=this.target.y+this.distance*Math.cos(this.polar),o=this.target.z+this.distance*e*Math.cos(this.azimuth);this.camera.position.set(n,i,o),this.camera.lookAt(this.target)}dispose(){this.canvas.removeEventListener("pointerdown",this.onPointerDown),this.canvas.removeEventListener("pointermove",this.onPointerMove),this.canvas.removeEventListener("pointerup",this.onPointerUp),this.canvas.removeEventListener("pointercancel",this.onPointerUp),this.canvas.removeEventListener("wheel",this.onWheel),this.canvas.removeEventListener("keydown",this.onKeyDown),this.canvas.removeEventListener("contextmenu",this.onContextMenu),this.activePointers.clear()}};var Rt=class{constructor(e){this.rafId=0;this.running=!1;this.lastTime=0;this.fpsEma=0;this.rendered=0;this.tick=e=>{let n=this.lastTime?(e-this.lastTime)/1e3:.016666666666666666;if(this.lastTime=e,n>0){let o=1/n;this.fpsEma=this.fpsEma?this.fpsEma*.9+o*.1:o}this.rendered++,this.frame(n)?this.rafId=requestAnimationFrame(this.tick):(this.running=!1,this.rafId=0)};this.frame=e}requestRender(){this.running||(this.running=!0,this.lastTime=0,this.rafId=requestAnimationFrame(this.tick))}stats(){return{fps:this.running?Math.round(this.fpsEma):0,rendered:this.rendered,idle:!this.running}}stop(){this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=0,this.running=!1}};var Ze=2.5,Xr=1.15,ct=6,Qe=10,Kn=6,qn=9.5,Zn=.9,Qn=2.2,tn=30,nn=4,It=8192;var ts=Qe+nn;function $n(t,e){let n=e*1.4,i=e*3.2;if(t<=n)return{scale:1,fade:0,minPixels:Ze};let o=Math.min(1,(t-n)/Math.max(.001,i-n));return{scale:1-o*.4,fade:o*.55,minPixels:Ze+o*(Xr-Ze)}}function Jn(t,e,n){return!(t>0)||!(e>0)||!(n>0)?!1:e*n/t>=64}function eo(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 A=ke,Kr=.002;function qr(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<Kr}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)}},Et=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){qr(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 Zr(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,d=r*a-i*l,u=i*s-o*a,m=Math.hypot(c,d,u)||1;return c/=m,d/=m,u/=m,[c,d,u]}function Qr(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 on(t){return Ge(t)<0?[...t].reverse():t}var $r=3;function Jr(t,e,n,i){let o=i(t),r=i(e),a=i(n),s=(p,h,f,y)=>Math.abs(i({x:(p.x+h.x)/2,y:(p.y+h.y)/2})-(f+y)/2),l=(t.x+e.x+n.x)/3,c=(t.y+e.y+n.y)/3,d=(o+r+a)/3,u=Math.max(s(t,e,o,r),s(e,n,r,a),s(n,t,a,o),Math.abs(i({x:l,y:c})-d)),m=(p,h,f)=>{let y=Math.abs(i({x:(p+l)/2,y:(h+c)/2})-(f+d)/2);y>u&&(u=y)};return m((t.x+e.x)/2,(t.y+e.y)/2,(o+r)/2),m((e.x+n.x)/2,(e.y+n.y)/2,(r+a)/2),m((n.x+t.x)/2,(n.y+t.y)/2,(a+o)/2),u}function lt(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(lt(t,r,s,i,o-1),lt(r,e,a,i,o-1),lt(s,a,n,i,o-1),lt(r,a,s,i,o-1))}function ut(t,e,n,i,o,r,a,s){if(a>0){let m={x:(e.x+n.x)/2,y:(e.y+n.y)/2},p={x:(n.x+i.x)/2,y:(n.y+i.y)/2},h={x:(i.x+e.x)/2,y:(i.y+e.y)/2};ut(t,e,m,h,o,r,a-1,s),ut(t,m,n,p,o,r,a-1,s),ut(t,h,p,i,o,r,a-1,s),ut(t,m,p,h,o,r,a-1,s);return}let l=[e.x*A,o(e),e.y*A],c=[n.x*A,o(n),n.y*A],d=[i.x*A,o(i),i.y*A];if(s){t.triN(l,c,d,s(e),s(n),s(i),r);return}let u=Zr(l,c,d);u[1]<0&&(u=[-u[0],-u[1],-u[2]]),t.tri(l,c,d,u,r)}var ei=8;function to(t,e,n){if(!Number.isFinite(n))return t;let i=[],o=(r,a,s,l,c)=>{if(c>0){let d={x:(r.x+a.x)/2,y:(r.y+a.y)/2},u=e(d);if(Math.abs(u-(s+l)/2)>n){o(r,d,s,u,c-1),o(d,a,u,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),ei)}return i}function Ft(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,d=Math.hypot(l,c);d>e&&Math.abs((a.x-r.x)*c-(a.y-r.y)*l)/d<e||i.push(a)}return i.length>=3?i:n}var Tt=.001*_e*.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(Ge(e))<1e-4))return;let d=Ft(to(Ft(on(e),Tt),i,l),Tt),u=n?.map(g=>Ft(to(Ft(on(g),Tt),i,l),Tt)).filter(g=>g.length>=3&&Math.abs(Ge(g))>=1e-4),{pts:m,tris:p}=Qr(d,u),h=[r[0]*s.top,r[1]*s.top,r[2]*s.top],f=[r[0]*s.bottomCap,r[1]*s.bottomCap,r[2]*s.bottomCap],y=[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],b=0;if(Number.isFinite(l))for(;b<$r;b++){let g=0;for(let T=0;T<p.length;T+=3){let D=lt(m[p[T]],m[p[T+1]],m[p[T+2]],i,b);D>g&&(g=D)}if(g<=l)break}for(let g=0;g<p.length;g+=3){let T=m[p[g]],D=m[p[g+1]],_=m[p[g+2]];ut(t,T,D,_,i,h,b,c);let G=[T.x*A,o,T.y*A],N=[D.x*A,o,D.y*A],v=[_.x*A,o,_.y*A];t.tri(G,v,N,[0,-1,0],f)}let S=g=>{if(b<=0)return g;let T=1<<b,D=[];for(let _=0;_<g.length;_++){let G=g[_],N=g[(_+1)%g.length];for(let v=0;v<T;v++){let M=v/T;D.push({x:G.x+(N.x-G.x)*M,y:G.y+(N.y-G.y)*M})}}return D},I=Dn(d),w=[{ring:S(d),flip:!1}];if(u)for(let g of u)g.length>=3&&w.push({ring:S(g),flip:!0});for(let{ring:g,flip:T}of w)for(let D=0;D<g.length;D++){let _=g[D],G=g[(D+1)%g.length],N=(G.x-_.x)*A,M=(G.y-_.y)*A,R=-N,C=Math.hypot(M,R)||1;M/=C,R/=C;let L=(_.x+G.x)/2-I.x,E=(_.y+G.y)/2-I.y,P=M*L+R*E;T&&(P=-P),P<0&&(M=-M,R=-R);let F=[M,0,R],O=[_.x*A,i(_),_.y*A],H=[G.x*A,i(G),G.y*A],z=[_.x*A,o,_.y*A],B=[G.x*A,o,G.y*A];t.tri(O,H,B,F,y,y,x),t.tri(O,B,z,F,y,x,x)}}function no(t){let e=0;for(let l of t)e+=l.count;let n=new Float32Array(e*3),i=new Float32Array(e*3),o=new Float32Array(e*3),r=new Float32Array(e),a=new Float32Array(e),s=0;for(let l of t)n.set(l.position,s*3),i.set(l.normal,s*3),o.set(l.color,s*3),r.set(l.floor,s),a.set(l.material,s),s+=l.count;return{position:n,normal:i,color:o,floor:r,material:a,count:e}}function Dt(t,e,n=2.5){if(e<=0||t.length<3)return t;let i=on(t),o=i.length,r=[];for(let s=0;s<o;s++){let l=i[s],c=i[(s+1)%o],d=c.x-l.x,u=c.y-l.y,m=Math.hypot(d,u)||1;r.push({x:u/m,y:-d/m})}let a=[];for(let s=0;s<o;s++){let l=i[s],c=r[(s-1+o)%o],d=r[s],u=c.x+d.x,m=c.y+d.y,p=Math.hypot(u,m),h=()=>{a.push([l.x+c.x*e,l.y+c.y*e]),a.push([l.x+d.x*e,l.y+d.y*e])};if(p<1e-9){h();continue}u/=p,m/=p;let f=u*c.x+m*c.y,y=1/Math.max(f,1e-6);if(!Number.isFinite(y)||y>n){h();continue}a.push([l.x+u*e*y,l.y+m*e*y])}if(a.length<3)return t;try{let s=jr.union([[...a,a[0]]]),l=null,c=-1/0;for(let u of s){let m=Math.abs(Ge(u[0].map(([p,h])=>({x:p,y:h}))));m>c&&(c=m,l=u[0])}if(!l)return t;let d=l.map(([u,m])=>({x:u,y:m}));if(d.length>1){let u=d[0],m=d[d.length-1];Math.abs(u.x-m.x)<1e-9&&Math.abs(u.y-m.y)<1e-9&&d.pop()}return d.length>=3?d:t}catch{return t}}function kt(t,e,n,i,o=28){let r=[];for(let a=0;a<o;a++){let s=a/o*Math.PI*2;r.push({x:t+n*Math.cos(s),y:e+i*Math.sin(s)})}return r}function mt(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 te={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,body:10,head:11},ti=.44,ni=.15,oi=.3,ri=.24;function oo(t){return t===void 0||!Number.isFinite(t)||t<=0?ri:Math.min(oi,Math.max(ni,t*ti))}var rn=.21,ii=.05,an=.45,_t=an+ii,ai=[{part:te.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:te.pad,min:[-1,.36,-.95],max:[1,an,1]},{part:te.back,min:[-1,_t,-1],max:[1,.92,-.72]},{part:te.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:te.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:te.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:te.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:te.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:te.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:te.leg,min:[.62,0,.48],max:[.82,.37,.7]}],si=[{part:te.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:te.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:te.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:te.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:te.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 ro(){let t=[],e=[],n=[],i=[],o=(C,L,E)=>{let P=n.length,[F,O,H]=C,z=[O[0]-F[0],O[1]-F[1],O[2]-F[2]],B=[H[0]-F[0],H[1]-F[1],H[2]-F[2]],U=z[1]*B[2]-z[2]*B[1],K=z[2]*B[0]-z[0]*B[2],Y=z[0]*B[1]-z[1]*B[0],j=Math.hypot(U,K,Y);j>1e-9?(U/=j,K/=j,Y/=j):[U,K,Y]=L,U*L[0]+K*L[1]+Y*L[2]<0&&(U=-U,K=-K,Y=-Y);for(let q of C)t.push(...q),e.push(U,K,Y),n.push(E);i.push(P,P+1,P+2,P,P+2,P+3)},r=C=>{for(let L of ci){let E=L.c.map(P=>P.map((F,O)=>F?C.max[O]:C.min[O]));o(E,L.n,C.part)}};for(let C of ai)r(C);for(let C of si)r(C);let a=an,s=1.08,l=.47,c=.69,d=-.55,u=.08,m=-.48,p=.01,h=[-l,a,d],f=[l,a,d],y=[-l,a,u],x=[l,a,u],b=[-c,s,m],S=[c,s,m],I=[-c,s,p],w=[c,s,p];o([f,S,w,x],[1,0,0],te.body),o([y,I,b,h],[-1,0,0],te.body),o([I,w,S,b],[0,1,0],te.body),o([h,f,x,y],[0,-1,0],te.body),o([x,w,I,y],[0,0,1],te.body),o([h,b,S,f],[0,0,-1],te.body);let g=10,T=8,D=[0,1.205,-.23],_=[.42,.115,.38],G=n.length;for(let C=0;C<=T;C++){let L=Math.PI*C/T,E=Math.cos(L),P=Math.sin(L);for(let F=0;F<=g;F++){let O=Math.PI*2*F/g,H=P*Math.cos(O),z=P*Math.sin(O);t.push(D[0]+_[0]*H,D[1]+_[1]*E,D[2]+_[2]*z);let B=H/_[0],U=E/_[1],K=z/_[2],Y=Math.hypot(B,U,K)||1;B/=Y,U/=Y,K/=Y,e.push(B,U,K),n.push(te.head)}}for(let C=0;C<T;C++)for(let L=0;L<g;L++){let E=G+C*(g+1)+L,P=E+g+1;i.push(E,P,E+1,E+1,P,P+1)}let N=new Float32Array(t),v=new Float32Array(e),M=new Float32Array(n),R=new Uint16Array(i);return{position:N,normal:v,part:M,index:R,vertexCount:n.length,indexCount:i.length}}function io(t,e,n,i){let o=new Float32Array(e),r=c=>t[c*3],a=c=>t[c*3+2],s=0,l=(c,d)=>{let u=d-c;for(let m=c;m<d;m++){let[p,h]=i(m),f=p-r(m),y=h-a(m);if(u>=2){let x=Math.max(c,m-1),b=Math.min(d-1,m+1),S=r(b)-r(x),I=a(b)-a(x),w=Math.hypot(S,I);if(w>1e-6){let g=-I/w,T=S/w;g*f+T*y<0&&(g=-g,T=-T),f=g,y=T}}o[m]=f===0&&y===0?0:Math.atan2(f,y)}};for(let c=1;c<=e;c++)(c===e||n(c)!==n(s))&&(l(s,c),s=c);return o}var Ae=.22;function ao(t,e){let n=ye[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 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),d=Math.max(1,Math.ceil(s/c)+1),u=Math.max(1,Math.ceil(l/c)+1),m=new Map,p=(h,f)=>{let y=Math.min(d-1,Math.max(0,Math.floor((h-i)/c)));return Math.min(u-1,Math.max(0,Math.floor((f-o)/c)))*d+y};for(let h=0;h<e;h++){let f=p(t[h].x,t[h].y),y=m.get(f);y?y.push(h):m.set(f,[h])}for(let h=0;h<e;h++){let f=t[h],y=Math.min(d-1,Math.max(0,Math.floor((f.x-i)/c))),x=Math.min(u-1,Math.max(0,Math.floor((f.y-o)/c))),b=1/0;for(let S=1;S<=4;S++){for(let I=x-S;I<=x+S;I++)if(!(I<0||I>=u))for(let w=y-S;w<=y+S;w++){if(w<0||w>=d||S>1&&Math.abs(I-x)<S&&Math.abs(w-y)<S)continue;let g=m.get(I*d+w);if(g)for(let T of g){if(T===h)continue;let D=Math.hypot(t[T].x-f.x,t[T].y-f.y);D<b&&(b=D)}}if(Number.isFinite(b)&&b<=S*c)break}n[h]=b}return n}function mi(t){let e=t.eyeHeightM;return Number.isFinite(e)?Math.max(0,e-St):0}function so(t,e,n,i,o,r){let a=t.length,s=new Float32Array(a*3),l=new Float32Array(a),c=new Float32Array(a*3),d=new Float32Array(a),u=new Float32Array(a),m=new Float32Array(a),p=new Float32Array(a),h=new Float32Array(a*3),f=new Map,y=ui(t);for(let x=0;x<a;x++){let b=t[x],I=(n?.seatPitchU(x)??y[x])*A;d[x]=Number.isFinite(I)?Math.max(.06,Math.min(Ae,I*li)):Ae,u[x]=oo(Number.isFinite(I)?I:void 0);let w=Vn(b.glyph,{seatGlyph:r?.get(b.categoryKey)});m[x]=On.indexOf(w),p[x]=b.wheelchairSpaceType==="no-seat"?0:1,s[x*3]=b.x*A,s[x*3+1]=n?n.seatDeckY(x):mi(b),s[x*3+2]=b.y*A,l[x]=st(e?e(b):"available");let g=Q(o?.get(b.categoryKey)??"#6e7bff")??[.43,.48,1];if(c[x*3]=g[0],c[x*3+1]=g[1],c[x*3+2]=g[2],b.accessibility?.length){let T=Q(En(b.accessibility));T&&(h[x*3]=T[0],h[x*3+1]=T[1],h[x*3+2]=T[2])}f.set(b.id,x)}return{count:a,iPosition:s,iState:l,iCategory:c,iMaxRadius:d,iRing:h,idToIndex:f,iChairWidth:u,iGlyph:m,iPhysicalSeat:p,iFloor:i??new Float32Array(a),iYaw:new Float32Array(a)}}var di=64;function sn(t,e){let n=[];for(let a of e){let s=t.idToIndex.get(a.seatId);if(s===void 0)continue;let l=st(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+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,pi=.9,fi=1.76,bi=.7,yi=1.6;function xi(){return{background:{top:[...He.top],bottom:[...He.bottom]},structure:Qt,seatStates:{...Yn},seatScale:1}}function co(t){let e=xi();if(!t)return e;let n=Q(t.background);if(n){e.background={top:fe(n,pi),bottom:fe(n,fi)};let r={};for(let[a,s]of Object.entries(Qt))r[a]=pe(s,n,hi);e.structure=r}let i=Q(t.selectionColor)??Q(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 lo(t,e){let n=[];for(let i of e)n.push(...t.seatStates[i]);return n}import po from"polygon-clipping";import gi from"earcut";var vi=.58,uo=.01,be=Ae*1.5*_e,Mi=.5,Si=.6;function wi(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,d=l.y-s.y,u=Math.hypot(c,d);if(u<1e-9){i.push([0,0]);continue}c/=u,d/=u,i.push([-d,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 Pi(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,d=Math.hypot(l,c)||1;return{x:l/d,y:c/d}},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 mo=Math.PI/12;function Ai(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 fo(t,e){if(!t.length||!(e>0))return[];let n=Ai(t),i=(s,l,c,d)=>{let u=c-l;for(;u<0;)u+=Math.PI*2;for(;u>Math.PI*2;)u-=Math.PI*2;let m=Math.max(1,Math.ceil(u/mo)),p=e/Math.cos(u/m/2);for(let h=0;h<=m;h++){let f=l+u*h/m;d.push({x:s.x+Math.cos(f)*p,y:s.y+Math.sin(f)*p})}};if(n.length<3){let s=0,l=0;for(let p of n)s+=p.x,l+=p.y;s/=n.length||1,l/=n.length||1;let c=0;for(let p of n)c=Math.max(c,Math.hypot(p.x-s,p.y-l));let d=[],u=Math.max(3,Math.ceil(Math.PI*2/mo)),m=(c+e)/Math.cos(Math.PI/u);for(let p=0;p<u;p++){let h=p/u*Math.PI*2;d.push({x:s+Math.cos(h)*m,y:l+Math.sin(h)*m})}return d}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 vo(a)}function Ci(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,d=c>1e-12?((e-r.x)*s+(n-r.y)*l)/c:0;d<0?d=0:d>1&&(d=1);let u=Math.hypot(e-(r.x+d*s),n-(r.y+d*l));u<i&&(i=u)}return i}function Lt(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 d=Math.hypot(c.x-r,c.y-a);d>l&&(l=d)}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 d of r){let u=1/0;for(let m=0;m<t.length;m++){if(m===o||Math.abs(t[m].y-t[o].y)<.001)continue;let p=e[m],h=Math.hypot(d.x-p.cx,d.y-p.cy)-p.rad;if(h>=u&&h>=s)continue;let f=Ci(t[m].pts,d.x,d.y);f<u&&(u=f),t[m].depth<t[o].depth&&f<s&&(s=f,l=t[m].y)}Number.isFinite(u)&&u>0&&a.push(u)}a.sort((d,u)=>d-u);let c=a.length?a[Math.floor(a.length/2)]:1;i.push({pitch:c,belowY:l})}return i}function bo(t,e,n,i){let o=t[e],r=o.pts.length>=2?[...o.pts]:o.pts.length===1?(()=>{let d=o.pts[0],u=d.x-i.x,m=d.y-i.y,p=Math.hypot(u,m)||1;u/=p,m/=p;let h=Math.max(n[e].pitch,.001)*.5;return[{x:d.x+m*h,y:d.y-u*h},{x:d.x-m*h,y:d.y+u*h}]})():[];if(r.length<2)return null;let a=0,s=0;for(let d=1;d<r.length;d++){let u=Math.hypot(r[d].x-r[d-1].x,r[d].y-r[d-1].y);u>1e-6&&(a+=u,s++)}let l=s>0?a/s:0,c=Pi(r,Math.max(l*Si,be));return{pts:c,nrm:wi(c,i),front:Math.max(n[e].pitch*vi,be),back:Math.max(n[e].pitch*Mi,be)}}var $e=1.5,yo=.3;function cn(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 u=1;u<t.length-1;u++){let m=t[u],p=a>1e-12?Math.abs((m.x-n.x)*r-(m.y-n.y)*o)/a:Math.hypot(m.x-n.x,m.y-n.y);p>s&&(s=p,l=u)}if(s<=e||l<0)return[n,i];let c=cn(t.slice(0,l+1),e),d=cn(t.slice(l),e);return[...c.slice(0,-1),...d]}function xo(t,e){if(t.length<4)return t;let n=cn([...t,t[0]],e);return n.pop(),n.length>=3?n:t}function go(t,e,n){if(t.length<2)return[];let i=n??Lt(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 b of a){let S=t[b].patch;S&&S.length>=3?r.push({outline:[...S],holes:[],topY:t[b].y}):s.push(b)}if(!s.length)continue;s.sort((b,S)=>t[b].depth-t[S].depth);let c=s.map(b=>bo(t,b,i,e)).filter(b=>b!==null);if(!c.length)continue;let d=(b,S)=>({x:b.pts[S].x-b.nrm[S][0]*(b.front+$e),y:b.pts[S].y-b.nrm[S][1]*(b.front+$e)}),u=(b,S)=>({x:b.pts[S].x+b.nrm[S][0]*(b.back+$e),y:b.pts[S].y+b.nrm[S][1]*(b.back+$e)}),m=c[0],p=c[c.length-1],h=[];for(let b=0;b<m.pts.length;b++)h.push(d(m,b));for(let b of c)h.push(u(b,b.pts.length-1));for(let b=p.pts.length-1;b>=0;b--)h.push(u(p,b));for(let b=c.length-1;b>=0;b--)h.push(d(c[b],0));let f=vo(h),y=1/0;for(let b of s)t[b].y<y&&(y=t[b].y);if(!Number.isFinite(y))continue;if(f.length>=3&&Math.abs(Ge(f))>1e-6&&c.every(b=>{let S=b.pts[Math.floor(b.pts.length/2)];return at(f,S.x,S.y)})){r.push({outline:xo(f,yo),holes:[],topY:y});continue}for(let b of Ri(c))r.push({outline:b,holes:[],topY:y})}return r}function Ri(t){let e=[];for(let n of t){let i=[],o=[],r=n.front+$e,a=n.back+$e;for(let l=0;l<n.pts.length;l++){let c=n.pts[l],d=n.nrm[l];i.push([c.x-d[0]*r,c.y-d[1]*r]),o.push([c.x+d[0]*a,c.y+d[1]*a])}let s=[...i,...o.reverse()];s.length<3||(s.push(s[0]),e.push([s]))}if(!e.length)return[];try{let n=po.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(xo(r,yo))}return i}catch{return[]}}function vo(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 ln=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(!at(n,o.x,o.y)){i=!1;break}if(i)return!0}return!1}};function ho(t,e,n,i,o,r){if(i.length<3)return;if(n.containsAll(i)){let c=[0,1,0],d=i[0];for(let u=1;u+1<i.length;u++){let m=i[u],p=i[u+1];t.tri([d.x*A,o,d.y*A],[m.x*A,o,m.y*A],[p.x*A,o,p.y*A],c,r)}return}let a=i.map(c=>[c.x,c.y]);a.push(a[0]);let s;try{s=po.intersection([a],e)}catch{return}let l=[0,1,0];for(let c of s){if(!c.length||c[0].length<4)continue;let d=c[0],u=[],m=[];for(let h=0;h<d.length-1;h++)u.push(d[h][0],d[h][1]),m.push([d[h][0],d[h][1]]);if(m.length<3)continue;let p=gi(u,void 0,2);for(let h=0;h<p.length;h+=3){let f=m[p[h]],y=m[p[h+1]],x=m[p[h+2]];t.tri([f[0]*A,o,f[1]*A],[y[0]*A,o,y[1]*A],[x[0]*A,o,x[1]*A],l,r)}}}function Mo(t,e,n,i,o,r,a){if(e.length<2)return;let s=a??Lt(e),l=[0,1,0],c=r&&r.length>=3?[[...r.map(p=>[p.x,p.y]),[r[0].x,r[0].y]]]:null,d=r&&r.length>=3?new ln([[...r]]):null,u=p=>{t.setMaterial(2),p(),t.setMaterial(0)},m=p=>{t.setMaterial(3),p(),t.setMaterial(0)};for(let p=0;p<e.length;p++){let h=e[p];if(h.patch&&h.patch.length>=3){let w=[...h.patch],g=s[p].belowY??i;if(m(()=>{if(c&&d)ho(t,c,d,w,h.y,o.tread);else{let T=w[0];for(let D=1;D+1<w.length;D++){let _=w[D],G=w[D+1];t.tri([T.x*A,h.y,T.y*A],[_.x*A,h.y,_.y*A],[G.x*A,h.y,G.y*A],l,o.tread)}}}),h.y>g+uo){let T=0,D=0;for(let _ of w)T+=_.x,D+=_.y;T/=w.length,D/=w.length,u(()=>{for(let _=0;_<w.length;_++){let G=w[_],N=w[(_+1)%w.length],v=N.x-G.x,M=N.y-G.y,R=Math.hypot(v,M);if(R<1e-6)continue;let C=M/R,L=-v/R;(G.x-T)*C+(G.y-D)*L<0&&(C=-C,L=-L);let E=[C,0,L],P=[G.x*A,h.y,G.y*A],F=[N.x*A,h.y,N.y*A],O=[G.x*A,g,G.y*A],H=[N.x*A,g,N.y*A];t.tri(P,F,H,E,o.riser),t.tri(P,H,O,E,o.riser)}})}continue}let f=bo(e,p,s,n);if(!f)continue;let{pts:y,nrm:x,front:b,back:S}=f,I=s[p].belowY??i;for(let w=0;w+1<y.length;w++){let g=y[w],T=y[w+1],D=x[w],_=x[w+1];if(Math.hypot(T.x-g.x,T.y-g.y)<1e-6||D[0]===0&&D[1]===0||_[0]===0&&_[1]===0)continue;let G=[(g.x-D[0]*b)*A,h.y,(g.y-D[1]*b)*A],N=[(T.x-_[0]*b)*A,h.y,(T.y-_[1]*b)*A],v=[(g.x+D[0]*S)*A,h.y,(g.y+D[1]*S)*A],M=[(T.x+_[0]*S)*A,h.y,(T.y+_[1]*S)*A];if(m(()=>{c&&d?ho(t,c,d,[{x:g.x-D[0]*b,y:g.y-D[1]*b},{x:T.x-_[0]*b,y:T.y-_[1]*b},{x:T.x+_[0]*S,y:T.y+_[1]*S},{x:g.x+D[0]*S,y:g.y+D[1]*S}],h.y,o.tread):(t.tri(G,N,M,l,o.tread),t.tri(G,M,v,l,o.tread))}),h.y>I+uo){let R=[G[0],I,G[2]],C=[N[0],I,N[2]],L=[-D[0],0,-D[1]];u(()=>{t.tri(G,N,C,L,o.riser),t.tri(G,C,R,L,o.riser)})}}}}import wo from"polygon-clipping";function Ii(t,e){let n=t.eventConfigurationIds;return!n?.length||!!e&&n.includes(e)}function So(t,e){return t.filter(n=>n.type!=="shape"||Ii(n,e))}function Po(t,e){let n=t.focalPoint??{x:0,y:0};return t.floors?.length?t.floors.map((i,o)=>({objects:So(i.objects,e),focal:{x:(i.focalPoint??n).x,y:(i.focalPoint??n).y},baseHeightM:i.baseHeightM??0,index:o})):[{objects:So(t.objects,e),focal:n,baseHeightM:0,index:0}]}var Fi={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Je(t){return Nn(t)??Fi}function Ao(t,e){let n=Dt(t.outline,be),i=Je(n),o=e.filter(a=>a!==t&&a.outline&&a.outline.length>=3&&Pt(i,Je(a.outline)));if(!o.length)return[n];let r=a=>{let s=a.map(l=>[l.x,l.y]);return s.push(s[0]),s};try{let a=wo.difference([r(n)],...o.map(l=>[r(l.outline)])),s=[];for(let l of a){if(!l.length)continue;let c=l[0].map(([d,u])=>({x:d,y:u}));if(c.length>1){let d=c[0],u=c[c.length-1];Math.abs(d.x-u.x)<1e-9&&Math.abs(d.y-u.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s.length?s:[n]}catch{return[n]}}function Co(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=wo.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,d])=>({x:c,y:d}));if(l.length>1){let c=l[0],d=l[l.length-1];Math.abs(c.x-d.x)<1e-9&&Math.abs(c.y-d.y)<1e-9&&l.pop()}l.length>=3&&o.push({outline:l,holes:[],topY:r.topY})}}return o.length?o:t}var Ti=.05,Ro=.05,Ei=.15,un=25;function Io(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=[],d=new Set;for(let u=0;u<t.length;u+=1){let m=t[u];for(let p of m.objects){if(p.type==="table"&&d.add(p.id),p.type!=="section"||!p.outline||p.outline.length<3)continue;let h=Dt(p.outline,be);l.set(p.id,{section:p,unit:m,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),c.push({id:p.id,floorIndex:u,box:Je(h),section:p,unit:m,outline:h})}}for(let u=0;u<e.length;u++){let m=e[u];for(let p of c){if(n&&p.floorIndex!==n[u]||m.x<p.box.minX||m.x>p.box.maxX||m.y<p.box.minY||m.y>p.box.maxY||!Ln({x:m.x,y:m.y},p.outline,p.section.holes))continue;o[u]=p.id;let h=l.get(p.id);h.hasSeats=!0;let f=m.focalPoint??p.unit.focal,y=Math.hypot(m.x-f.x,m.y-f.y);y<h.frontU&&(h.frontU=y),h.seatIndices.push(u);let x=m.rowId||`__seat-${u}`,b=h.rows.get(x);b?b.push({x:m.x,y:m.y}):h.rows.set(x,[{x:m.x,y:m.y}]);break}}for(let[u,m]of l){let p=kn(m.section,{floorBaseHeightM:m.unit.baseHeightM}),h=m.unit.baseHeightM,f=p.rake>0?Math.tan(p.rake*Math.PI/180):0,y=p.rake<=.01&&p.height<=h+.001,x=m.section.surfaceKind,b=x==="flat"?!0:x==="rakedRows"&&p.rake>.01?!1:y,S=m.hasSeats?_n(u,e,m.seatIndices,m.unit.focal):{sectionId:u,rows:[],blockCount:0},w=S.rows.length<2?Gn([...m.rows.values()].map(E=>({points:E})),m.unit.focal):null,g=1/0;if(w){if(m.hasSeats)for(let E of m.rows.values())for(let P of E){let F=w.depthAt(P.x,P.y);F<g&&(g=F)}if(!m.hasSeats||!Number.isFinite(g)){g=1/0;for(let E of m.section.outline){let P=w.depthAt(E.x,E.y);P<g&&(g=P)}}}let T=h+Ti,D=Math.max(T,p.height),_=E=>{let P=Math.max(0,E-g)*ke,F=Math.min(P*f,un);return Math.max(T,p.height+F)},G=E=>{let P=Math.max(0,E)*ke,F=Math.min(P*f,un);return Math.max(T,p.height+F)},N=b?[]:S.rows.map(E=>({pts:E.pts,y:G(E.blockDepth),depth:E.blockDepth,blockId:E.blockId,...d.has(E.id)?{patch:fo(E.pts,be)}:{}})),v=N.length?N[0].y:D,M=N.map(E=>{let P=E.patch&&E.patch.length>=3?E.patch:E.pts,F=0,O=0;for(let B of P)F+=B.x,O+=B.y;let H=P.length||1;F/=H,O/=H;let z=0;for(let B of P){let U=Math.hypot(B.x-F,B.y-O);U>z&&(z=U)}return{cx:F,cy:O,rad:z}}),R=b?()=>D:N.length>=2?(E,P)=>{let F=1/0,O=v;for(let H=0;H<N.length;H++){let z=M[H];if(Math.hypot(E-z.cx,P-z.cy)-z.rad>=F)continue;let B=N[H].patch,U=B&&B.length>=3?at(B,E,P)?0:wt(B,E,P):wt(N[H].pts,E,P);U<F&&(F=U,O=N[H].y)}return O}:(E,P)=>w?_(w.depthAt(E,P)):D,C=[0,1,0],L=N.length>=2||b?()=>C:(E,P)=>{if(!w)return C;let F=w.depthAt(E,P);if(F<=g)return C;let O=(F-g)*ke;if(O*f>=un||p.height+O*f<=T)return C;let[H,z]=w.gradientAt(E,P);if(H===0&&z===0)return C;let B=1/Math.hypot(f,1);return[-H*f*B,B,-z*f*B]};if(!b)for(let E of S.rows){let P=G(E.blockDepth);for(let F of E.seatIndices)a[F]=P}for(let E of S.rows){let P=[];for(let B=1;B<E.pts.length;B++){let U=Math.hypot(E.pts[B].x-E.pts[B-1].x,E.pts[B].y-E.pts[B-1].y);U>1e-6&&P.push(U)}P.sort((B,U)=>B-U);let F=P.length?P[Math.floor(P.length/2)]:1/0,O=1/0,H=E.pts[Math.floor(E.pts.length/2)];if(H)for(let B of S.rows){if(B===E||B.blockId!==E.blockId)continue;let U=wt(B.pts,H.x,H.y);U>1e-6&&U<O&&(O=U)}let z=Math.min(F,Math.max(O,F*.5));if(Number.isFinite(z)&&z>0)for(let B of E.seatIndices)s[B]=z}i.set(u,{sectionId:u,deckAt:R,normalAt:L,flat:b,bottomY:h,rowLevels:N,landingY:v})}for(let u=0;u<e.length;u++){let m=o[u],p=e[u];if(m){let f=a[u];r[u]=(f??i.get(m).deckAt(p.x,p.y))+Ei;continue}let h=p.eyeHeightM;r[u]=Number.isFinite(h)?Math.max(0,h-St):0}return{bySection:i,seatOwner:o,seatDeckY:u=>r[u],seatPitchU:u=>s[u]}}var re={top:1,wallBottom:.5,bottomCap:.4};function Ce(t,e){if(!t)return e;let n=fe(it(t,.4),.62);return pe(e,n,.72)}function Fo(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,d=0;for(let[u,m]of a){let p=Q(n.get(u));p&&(s+=p[0]*m,l+=p[1]*m,c+=p[2]*m,d+=m)}d>0&&o.set(r,[s/d,l/d,c/d])}return o}function To(t,e){return Q(t.color)??e.get(t.logicalSectionId??t.id)??null}import Di from"polygon-clipping";function ki(t,e){return t===void 0||e===void 0?!0:Math.abs(t-e)<.001}var Bt=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(e,n){let i=e.map(l=>[l.x,l.y]);if(i.length<3)return[];i.push(i[0]);let o=Je(e),r=this.rings.filter((l,c)=>Pt(o,this.boxes[c])&&ki(n,this.levels[c])),a=[[i]];if(r.length)try{a=Di.difference([i],...r).map(c=>c.map(d=>d.map(([u,m])=>[u,m])))}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(([d,u])=>({x:d,y:u}));if(c.length>1){let d=c[0],u=c[c.length-1];Math.abs(d.x-u.x)<1e-9&&Math.abs(d.y-u.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s}};function _i(t,e){if(!e)return t;let n=1/0,i=-1/0,o=1/0,r=-1/0;for(let u of t)n=Math.min(n,u.x),i=Math.max(i,u.x),o=Math.min(o,u.y),r=Math.max(r,u.y);let a=(n+i)/2,s=(o+r)/2,l=e*Math.PI/180,c=Math.cos(l),d=Math.sin(l);return t.map(u=>{let m=u.x-a,p=u.y-s;return{x:a+m*c-p*d,y:s+m*d+p*c}})}function dt(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=mt(t.x??0,t.y??0,t.width,t.height)),t.kind==="ellipse"&&t.width&&t.height){let n=(t.x??0)+t.width/2,i=(t.y??0)+t.height/2;e=kt(n,i,t.width/2,t.height/2)}return e?_i(e,t.rotation):null}function ht(t){let e=t.role??"",n={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}},i=e==="stage"&&zn(t.stageKind)?{kind:"stage",heightM:.06}:n[e]??{kind:"plate",heightM:.25};return{...i,heightM:t.heightM??i.heightM}}var Li=.08;function Eo(t,e){let n=dt(t),i=ht(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 d of n)r=Math.min(r,d.x),a=Math.min(a,d.y),s=Math.max(s,d.x),l=Math.max(l,d.y);let c=o;for(let d of e)s>d.minX&&r<d.maxX&&l>d.minY&&a<d.maxY&&c<=d.topOffsetM+1e-6&&(c=d.topOffsetM+Li);return e.push({minX:r,minY:a,maxX:s,maxY:l,topOffsetM:c}),c}function Le(t,e,n){return{x:t.x+(e.x-t.x)*n,y:t.y+(e.y-t.y)*n}}function Do(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 pt(t,e,n){return[Le(t[0],t[1],e),Le(t[0],t[1],n),Le(t[3],t[2],n),Le(t[3],t[2],e)]}function ko(t,e,n){return[Le(t[0],t[3],e),Le(t[1],t[2],e),Le(t[1],t[2],n),Le(t[0],t[3],n)]}function Re(t,e,n,i,o,r){ie(t,e,void 0,()=>n,i,o,r,re)}var mn=2.4,Bi=.75,Oi=.15;function ft(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(([d,u])=>({x:e.x+d*a-u*s,y:e.y+d*s+u*a}))}function _o(t,e,n,i,o){let r=ft(e);r&&ie(t,r,void 0,()=>n+mn,n,Ce(i,o.boothTop),o.boothWall,re)}function dn(t){if(t.shape==="round"){let d=t.radius;return d?kt(t.center.x,t.center.y,d,d,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(([d,u])=>({x:o.x+d*a-u*s,y:o.y+d*s+u*a}))}function Lo(t,e,n,i,o){let r=dn(e);r&&ie(t,r,void 0,()=>n+Bi,n,Ce(i,o.tableTop),o.tableWall,re)}function Bo(t,e,n,i,o,r,a){let s=dt(e);if(!s)return;let l=e.role==="stage",c=ht(e),d=n+i;if(l&&a){let f=1/0,y=-1/0,x=1/0,b=-1/0;for(let S of s)S.x<f&&(f=S.x),S.x>y&&(y=S.x),S.y<x&&(x=S.y),S.y>b&&(b=S.y);a.push({cx:(f+y)/2*A,cz:(x+b)/2*A,y:d,halfX:Math.max((y-f)/2*A,.5),halfZ:Math.max((b-x)/2*A,.5)})}let u=Q(e.fill),m=l&&u?pe(o.stageTop,fe(it(u,.18),.9),.9):Ce(u,l?o.stageTop:o.decorTop),p=e.role==="screen"?u:null,h=l?u?pe(o.stageWall,fe(u,.58),.82):o.stageWall:e.role==="screen"?p?pe(fe(p,1.42),[.24,.46,.82],.08):[.24,.46,.82]:Ce(Q(e.fill),o.decorWall);if(c.kind==="portal"&&s.length===4){let f=Do(s);Re(t,pt(f,0,.16),d,n,m,h),Re(t,pt(f,.84,1),d,n,m,h),Re(t,f,d,Math.max(n,d-.35),m,h);return}if(c.kind==="suite"&&s.length===4){let f=s.map((b,S)=>{let I=s[(S+1)%4],w=(b.x+I.x)/2,g=(b.y+I.y)/2;return Math.hypot(w-r.x,g-r.y)}),y=f.indexOf(Math.min(...f)),x=[0,1,2,3].map(b=>s[(y+b)%4]);Re(t,pt(x,0,.08),d,n,m,h),Re(t,pt(x,.92,1),d,n,m,h),Re(t,ko(x,.88,1),d,n,m,h),Re(t,x,d,Math.max(n,d-.18),m,h);return}Re(t,s,d,n,m,h)}function hn(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),d=i/2,u=o/2;return[[-d,-u],[d,-u],[d,u],[-d,u]].map(([m,p])=>({x:r+m*l-p*c,y:a+m*c+p*l}))}function Vi(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 Q(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=Q(s[1].trim());l&&a.push(l)}return a.length?a.reduce((s,l,c)=>pe(s,l,1/(c+1)),a[0]):null}function Oo(t,e,n,i){if(e.layer==="foreground")return;let o=hn(e);if(!o)return;let r=n+Oi,a=Ce(Vi(e.href),i.decorTop),s=Math.max(0,Math.min(1,e.opacity??1));s<1&&(a=pe(i.ground,a,s)),ie(t,o,void 0,()=>r,n,a,pe(a,i.decorWall,.5),re)}function Vo(t,e,n,i,o){if(!e.points||e.points.length<3)return;let r=Ce(i,o.gaTop);ie(t,e.points,e.holes,()=>n+.15,n,r,o.gaWall,re)}var Ni=.25,zi=1.2,Gi=.6,Hi=.45,Ui=2.3,Yi=Math.PI/180;function Ye(t,e,n){let i=n*Yi;return{x:t.x+e*Math.sin(i),y:t.y+e*Math.cos(i)}}function Xi(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 Wi=24;function ji(t,e,n,i,o,r,a,s){let l=n.binCount,c=Wi,d=ke,u=r+.02,m=[];for(let v=0;v<l;v++){let M=(n.startBin+v+.5)*e.binStepDeg,R=new Float64Array(c+1);for(let C=0;C<=c;C++){let L=i[v]+(o[v]-i[v])*C/c;R[C]=Math.max(u,Un(e,n,M,L)-Ni)}m.push(R)}let p=[a.bandTop[0]*s.top,a.bandTop[1]*s.top,a.bandTop[2]*s.top],h=[a.bandTop[0]*s.bottomCap,a.bandTop[1]*s.bottomCap,a.bandTop[2]*s.bottomCap],f=[a.bandWall[0]*s.top,a.bandWall[1]*s.top,a.bandWall[2]*s.top],y=[a.bandWall[0]*s.wallBottom,a.bandWall[1]*s.wallBottom,a.bandWall[2]*s.wallBottom],x=(v,M)=>{let R=(n.startBin+v+.5)*e.binStepDeg,C=i[v]+(o[v]-i[v])*M/c,L=Ye(e.centre,C,R);return[L.x*d,m[v][M],L.y*d]};{let v=Math.tan(12*Math.PI/180);for(let M=0;M<6;M++){let R=!1;for(let L=0;L<l;L++)for(let E=c-1;E>=0;E--)m[L][E]>m[L][E+1]&&(m[L][E]=m[L][E+1],R=!0);let C=n.closed?l:l-1;for(let L=0;L<C;L++){let E=(L+1)%l;for(let P=0;P<=c;P++){let F=m[E][P]-m[L][P];if(Math.abs(F)>1)continue;let O=i[L]+(o[L]-i[L])*P/c,H=i[E]+(o[E]-i[E])*P/c,z=Ye(e.centre,O,(n.startBin+L+.5)*e.binStepDeg),B=Ye(e.centre,H,(n.startBin+E+.5)*e.binStepDeg),U=v*Math.hypot(B.x-z.x,B.y-z.y)*d;F>U?(m[E][P]=m[L][P]+U,R=!0):-F>U&&(m[L][P]=m[E][P]+U,R=!0)}}if(!R)break}}let b=1,S=(v,M)=>{for(let R=0;R<=c;R+=4)if(Math.abs(m[v][R]-m[M][R])>b)return!0;return Math.abs(m[v][c]-m[M][c])>b},I=Math.tan(38*Math.PI/180),w=v=>(o[v]-i[v])/c*d,g=(v,M)=>m[v][M+1]-m[v][M]>I*Math.max(1e-6,w(v)),T=(v,M)=>{let R=n.closed?(v-1+l)%l:Math.max(0,v-1),C=n.closed?(v+1)%l:Math.min(l-1,v+1);Math.abs(m[R][M]-m[v][M])>b&&(R=v),Math.abs(m[C][M]-m[v][M])>b&&(C=v);let L=Math.max(0,M-1),E=Math.min(c,M+1);L<M&&g(v,L)&&(L=M),E>M&&g(v,M)&&(E=M);let P=x(R,M),F=x(C,M),O=x(v,L),H=x(v,E),z=F[0]-P[0],B=F[1]-P[1],U=F[2]-P[2],K=H[0]-O[0],Y=H[1]-O[1],j=H[2]-O[2],q=B*j-U*Y,ne=U*K-z*j,oe=z*Y-B*K,$=Math.hypot(q,ne,oe);return $>1e-12?(q/=$,ne/=$,oe/=$,ne<0&&(q=-q,ne=-ne,oe=-oe),[q,ne,oe]):[0,1,0]},D=(v,M)=>{let R=[v[0],r,v[2]],C=[M[0],r,M[2]],L=M[0]-v[0],E=M[2]-v[2],P=Math.hypot(L,E);if(!(P>1e-12))return;let F=[E/P,0,-L/P];t.tri(v,M,C,F,f,f,y),t.tri(v,C,R,F,f,y,y)},_=.05*_e,G=v=>o[v]-i[v]<_,N=n.closed?l:l-1;for(let v=0;v<N;v++){let M=(v+1)%l;if(G(v)||G(M))continue;if(S(v,M)){let F=(n.startBin+v+1)*e.binStepDeg,O=(Y,j)=>{let q=(i[v]+i[M])/2,ne=(o[v]+o[M])/2,oe=q+(ne-q)*j/c,$=Ye(e.centre,oe,F);return[$.x*d,m[Y][j],$.y*d]};for(let Y=0;Y<c;Y++){let j=x(v,Y),q=x(v,Y+1),ne=O(v,Y),oe=O(v,Y+1),$=T(v,Y),ae=T(v,Y+1);t.triN(j,ne,oe,$,$,ae,p),t.triN(j,oe,q,$,ae,ae,p);let Oe=x(M,Y),Ve=x(M,Y+1),xe=O(M,Y),Ie=O(M,Y+1),Fe=T(M,Y),ge=T(M,Y+1);t.triN(xe,Oe,Ve,Fe,Fe,ge,p),t.triN(xe,Ve,Ie,Fe,ge,ge,p);let he=O(v,Y),se=O(v,Y+1),je=O(M,Y+1),ve=O(M,Y),Ke=se[0]-he[0],Me=se[2]-he[2],Te=Math.hypot(Ke,Me);if(Te>1e-12){let xt=[Me/Te,0,-Ke/Te];t.tri(he,se,je,xt,f),t.tri(he,je,ve,xt,f)}}let H=x(v,0),z=x(M,0),B=x(M,c),U=x(v,c),K=Y=>[Y[0],r,Y[2]];t.tri(K(H),K(B),K(z),[0,-1,0],h),t.tri(K(H),K(U),K(B),[0,-1,0],h),D(H,z),D(U,B);continue}for(let F=0;F<c;F++){let O=T(v,F),H=T(M,F),z=T(M,F+1),B=T(v,F+1);if(g(v,F)||g(M,F)){let q=(se,je)=>{let ve=(n.startBin+se+.5)*e.binStepDeg,Ke=i[se]+(o[se]-i[se])*(F+.5)/c,Me=Ye(e.centre,Ke,ve);return[Me.x*d,je,Me.y*d]},ne=x(v,F),oe=x(M,F),$=q(v,m[v][F]),ae=q(M,m[M][F]);t.triN(ne,oe,ae,O,H,H,p),t.triN(ne,ae,$,O,H,O,p);let Oe=x(M,F+1),Ve=x(v,F+1),xe=q(v,m[v][F+1]),Ie=q(M,m[M][F+1]);t.triN(xe,Ie,Oe,B,z,z,p),t.triN(xe,Oe,Ve,B,z,B,p);let Fe=ae[0]-$[0],ge=ae[2]-$[2],he=Math.hypot(Fe,ge);if(he>1e-12){let se=[-ge/he,0,Fe/he];t.tri($,ae,Ie,se,f),t.tri($,Ie,xe,se,f)}continue}let U=x(v,F),K=x(M,F),Y=x(M,F+1),j=x(v,F+1);t.triN(U,K,Y,O,H,z,p),t.triN(U,Y,j,O,z,B,p)}let R=x(v,0),C=x(M,0),L=x(M,c),E=x(v,c),P=F=>[F[0],r,F[2]];t.tri(P(R),P(L),P(C),[0,-1,0],h),t.tri(P(R),P(E),P(L),[0,-1,0],h),D(R,C),D(E,L)}if(!n.closed)for(let v of[0,l-1])for(let M=0;M<c;M++)D(x(v,M),x(v,M+1))}function No(t,e,n){let{bottomY:i,colors:o,ao:r}=n,a=new Float64Array(e.binCount).fill(-1/0);for(let d of e.rings)for(let u of d.arcs){let m=new Float64Array(u.binCount),p=new Float64Array(u.binCount);for(let f=0;f<u.binCount;f++){let y=(u.startBin+f)%e.binCount,x=Math.max(0,u.innerR[f]-be);m[f]=Math.max(x,a[y]+.001),p[f]=Math.max(m[f]+.001,u.outerR[f]+be)}let h=0;for(let f=0;f<u.binCount;f++){let y=u.topLevelM[f]-i;y>h&&(h=y)}h>=zi&&ji(t,e,u,m,p,i,o,r);for(let f=0;f<u.binCount;f++){let y=(u.startBin+f)%e.binCount;p[f]>a[y]&&(a[y]=p[f])}}if(Xi(n.shapes,e))return;let s=e.rings[e.rings.length-1],l=Gi*_e,c=Hi*_e;for(let d of s.arcs){let u=[],m=[];for(let f=0;f<d.binCount;f++){let y=(d.startBin+f+.5)*e.binStepDeg,x=d.outerR[f]+be+l;u.push(Ye(e.centre,x,y)),m.push(Ye(e.centre,x+c,y))}let p=-1/0;for(let f=0;f<d.binCount;f++)d.topLevelM[f]>p&&(p=d.topLevelM[f]);let h=()=>p+Ui;d.closed?ie(t,m,[u.slice().reverse()],h,i,o.shellTop,o.shellWall,r):ie(t,[...m,...u.slice().reverse()],void 0,h,i,o.shellTop,o.shellWall,r)}}function zo(t,e,n,i,o,r,a,s){if(!e.outline||e.outline.length<3)return;let l=n.baseHeightM,c=Ce(i,s.tierTop);if(!o)return;let d=y=>o.deckAt(y.x,y.y),u=Ao(e,a),m=u[0]??e.outline;if(o.rowLevels.length>=2){let y=Lt(o.rowLevels),x=Co(go(o.rowLevels,n.focal,y),u),b=()=>[0,1,0];for(let I of x){let w=Math.max(l,I.topY-.02);for(let g of r.subtract(I.outline,w))ie(t,g,I.holes,()=>w,l,c,s.tierWall,re,void 0,b)}x.length||ie(t,m,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 I of u.length?u:[m])Mo(t,o.rowLevels,n.focal,o.landingY,S,I,y);return}let p=o.flat?1/0:Ro,h=y=>o.normalAt(y.x,y.y),f=o.flat?o.landingY:void 0;for(let y of r.subtract(m,f))ie(t,y,e.holes,d,l,c,s.tierWall,re,p,h)}function Ki(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],d=o.get(s);d||(d=new Map,o.set(s,d));let u=c.rowId||`__seat-${a}`,m=d.get(u);m||(m={pts:[],levelM:0,n:0},d.set(u,m)),m.pts.push({x:c.x,y:c.y}),m.levelM+=n.seatDeckY(a),m.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(d=>!d.patch).map(d=>({pts:d.pts,levelM:d.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 Go(t,e,n,i,o){let r=Ki(e,n,i);if(!r.length)return;let a=Hn(r,e.focal);a&&(t.setMaterial(0),No(t,a,{bottomY:e.baseHeightM,colors:{bandTop:fe(o.tierTop,.8),bandWall:o.tierWall,shellTop:fe(o.tierWall,1.15),shellWall:o.tierWall},ao:re,shapes:e.objects.filter(s=>s.type==="shape")}))}function Ho(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 Uo(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 qi=1.15,Zi=3.25,Qi=4.5,$i=.85,Ji=.5,ea=.26;function Yo(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>=qi&&a.add("zone"),o<=(r?Zi:Qi)&&(a.add("section"),a.add("ga")),o<=$i&&(a.add("annotation"),a.add("booth")),o<=Ji&&a.add("row"),o<=ea&&a.add("seat"),a}function Be(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],d=o[2]*r+o[6]*a+o[10]*s+o[14],u=o[3]*r+o[7]*a+o[11]*s+o[15];if(!(u>1e-6))return{x:0,y:0,depth:1/0,visible:!1};let m=l/u,p=c/u,h=d/u,f=m>=-1.05&&m<=1.05&&p>=-1.05&&p<=1.05&&h<=1;return{x:(m*.5+.5)*n,y:(1-(p*.5+.5))*i,depth:h,visible:f}}function Xo(t,e,n=e){let i=[],o=[...t].sort((r,a)=>r.screen.depth-a.screen.depth);for(let r of o){let a=!1;for(let s of i)if(pn(r,s,e,n)){a=!0;break}a||i.push(r)}return i}var ta=6;function pn(t,e,n,i){let o=Math.abs(t.screen.x-e.screen.x),r=Math.abs(t.screen.y-e.screen.y),a=t.halfWidth!=null&&e.halfWidth!=null?Math.max(n,t.halfWidth+e.halfWidth+ta):n;return o<a&&r<i}function Wo(t,e,n){return t.length*e*.58+(n?14:0)}var fn={row:8,seat:14};function jo(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 bn(t,e,n,i,o=[]){let r=[...t].sort((s,l)=>(l.priority??0)-(s.priority??0)||s.focus-l.focus),a=[];for(let s of r){if(a.length>=i)break;let l=!1;for(let c of o)if(pn(s,c,e,n)){l=!0;break}if(!l){for(let c of a)if(pn(s,c,e,n)){l=!0;break}}l||a.push(s)}return a}var na=6,oa=2.2,Ko=.1,ra=.3,ia=1.8,aa=.9,sa=.55,ca=6e3;function qo(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 d of n)for(let u of d.objects)u.type==="section"&&u.zone&&l.set(u.id,u.zone);let c=new Map;for(let d=0;d<i.length;d++){let u=i[d],m=o.seatOwner[d],p=u.zoneId??(m?l.get(m):void 0);if(!p)continue;let h=c.get(p);h||(h={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},c.set(p,h)),h.n++,u.x<h.minX&&(h.minX=u.x),u.y<h.minY&&(h.minY=u.y),u.x>h.maxX&&(h.maxX=u.x),u.y>h.maxY&&(h.maxY=u.y),h.sumY+=o.seatDeckY(d)}for(let d of a){let u=c.get(d.id),m=[];for(let[p,h]of l)h===d.id&&m.push(p);if(!u||u.n===0){s.push({id:d.id,label:d.label,color:Q(d.color),sectionIds:m,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(d.focalPoint??r).x*A,1.5,(d.focalPoint??r).y*A]});continue}s.push({id:d.id,label:d.label,color:Q(d.color),sectionIds:m,seatCount:u.n,center:[(u.minX+u.maxX)/2*A,u.sumY/u.n,(u.minY+u.maxY)/2*A],radius:.5*Math.hypot((u.maxX-u.minX)*A,(u.maxY-u.minY)*A)||1,focalWorld:[(d.focalPoint??r).x*A,1.5,(d.focalPoint??r).y*A]})}}return s}function Zo(t){let{doc:e,units:n,seats:i,surfaces:o,seatData:r,hintedSeatFloor:a,zones:s,focal:l}=t,c=[],d=[],u=[];for(let m of s)m.seatCount!==0&&c.push({id:`zone:${m.id}`,kind:"zone",text:m.label,anchor:[m.center[0],m.center[1]+na,m.center[2]],color:e.zones?.find(p=>p.id===m.id)?.color});{let m=new Map,p=new Map;for(let h=0;h<i.length;h++){let f=o.seatOwner[h];if(!f)continue;let y=m.get(f);y||(y={n:0,x:0,y:0,deck:0},m.set(f,y)),y.n++,y.x+=i[h].x,y.y+=i[h].y,y.deck+=o.seatDeckY(h);let x=p.get(f);x||(x={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0},p.set(f,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 f of h.objects){if(f.type!=="section")continue;let y=m.get(f.id);if(!y||y.n===0)continue;let x=p.get(f.id),b=[y.x/y.n*A,y.deck/y.n,y.y/y.n*A],S=f.displayLabel||f.label||f.id;d.push({id:f.id,floorIndex:h.index,label:S,seatCount:y.n,center:b,radius:Math.max(1,Math.hypot(x.maxX-x.minX,x.maxY-x.minY)*.5*A),focalWorld:[h.focal.x*A,h.baseHeightM+1.5,h.focal.y*A]});let I=e.floors?.[h.index]?.name?.trim().toLocaleLowerCase();n.length>1&&I===S.trim().toLocaleLowerCase()||c.push({id:`section:${f.id}`,kind:"section",text:S,anchor:[b[0],b[1]+oa,b[2]],floorIndex:h.index})}}{for(let h of n)for(let f of h.objects){if(f.type!=="gaArea")continue;let y=rt(f.points);if(!y)continue;let x=f.displayLabel||f.label||f.id;c.push({id:`ga:${f.id}`,kind:"ga",text:f.capacity>0?`${x} \xB7 ${f.capacity.toLocaleString()}`:x,anchor:[y.x*A,h.baseHeightM+ia,y.y*A],floorIndex:h.index})}let m=new Map;for(let h=0;h<i.length;h++){let f=i[h],y=Math.hypot(f.x-l.x,f.y-l.y),x=m.get(f.rowId);(!x||y>x.far)&&m.set(f.rowId,{seat:f,index:h,far:y})}for(let[h,f]of m){let y=f.seat.label?f.seat.label.lastIndexOf("-"):-1,x=y>0?f.seat.label.slice(0,y):h;x&&c.push({id:`row:${h}`,kind:"row",text:x,anchor:[f.seat.x*A,o.seatDeckY(f.index)+aa,f.seat.y*A],floorIndex:a[f.index]})}let p=new Map;for(let h=0;h<i.length;h++){let f=i[h],y=f.label?f.label.lastIndexOf("-"):-1,x=p.get(f.rowId);x||(x={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:y>0?f.label.slice(0,y):f.rowId,sectionId:f.sectionId},p.set(f.rowId,x));let b=h*3,S=r.iPosition[b],I=r.iPosition[b+1],w=r.iPosition[b+2];x.n++,x.x+=S,x.y+=I,x.z+=w,x.minX=Math.min(x.minX,S),x.maxX=Math.max(x.maxX,S),x.minZ=Math.min(x.minZ,w),x.maxZ=Math.max(x.maxZ,w)}for(let[h,f]of p)u.push({id:h,label:f.label,sectionId:f.sectionId,seatCount:f.n,center:[f.x/f.n,f.y/f.n,f.z/f.n],radius:Math.max(.8,Math.hypot(f.maxX-f.minX,f.maxZ-f.minZ)*.5)});if(i.length<=ca)for(let h=0;h<i.length;h++){let f=i[h],y=f.displayLabel||f.label;y&&c.push({id:`seat:${f.id}`,kind:"seat",text:y,anchor:[f.x*A,o.seatDeckY(h)+sa,f.y*A],floorIndex:a[h]})}}for(let m of n)for(let p of m.objects)if(p.type==="shape"&&p.role&&["entrance","exit","screen","suite","obstruction"].includes(p.role)){let h=dt(p),f=h?rt(h):null;if(!f||!p.label)continue;c.push({id:`architecture:${p.id}`,kind:"annotation",text:p.label,anchor:[f.x*A,m.baseHeightM+ht(p).heightM+Ko,f.y*A],color:p.fill,floorIndex:m.index})}else if(p.type==="text"){if(!p.text)continue;c.push({id:`text:${p.id}`,kind:"annotation",text:p.text,anchor:[p.position.x*A,m.baseHeightM+Ko,p.position.y*A],color:p.color,rotation:p.rotation,floorIndex:m.index})}else if(p.type==="booth"){let h=ft(p);if(!h)continue;let f=rt(h);if(!f)continue;c.push({id:`booth:${p.id}`,kind:"booth",text:p.displayLabel||p.label||p.id,anchor:[f.x*A,m.baseHeightM+mn+ra,f.y*A],floorIndex:m.index})}return{labels:c,sections:d,rows:u}}function Qo(t,e){if(e.length>1)for(let n of e)t.push({id:`floor:${n.id}`,kind:"floor",text:n.label,anchor:[n.center[0],n.box.max[1]+1.2,n.center[2]],floorIndex:n.index})}function $o(t){let{doc:e,units:n,seats:i,surfaces:o,solids:r,hintedSeatFloor:a,seatFloor:s}=t,l=[];{let c=n.map(()=>({minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}));for(let m=0;m<r.floor.length;m+=1){let p=Math.max(0,Math.min(n.length-1,Math.round(r.floor[m]))),h=m*3,f=c[p];f.minX=Math.min(f.minX,r.position[h]),f.minY=Math.min(f.minY,r.position[h+1]),f.minZ=Math.min(f.minZ,r.position[h+2]),f.maxX=Math.max(f.maxX,r.position[h]),f.maxY=Math.max(f.maxY,r.position[h+1]),f.maxZ=Math.max(f.maxZ,r.position[h+2])}let d=new Map;for(let m=0;m<n.length;m++)for(let p of n[m].objects)p.type==="section"&&d.set(p.id,m);let u=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 m=0;m<i.length;m++){let p=o.seatOwner[m],h=(p!==null?d.get(p):void 0)??a[m];if(h===void 0)continue;let f=u[h],y=i[m];f.n++,y.x<f.minX&&(f.minX=y.x),y.y<f.minY&&(f.minY=y.y),y.x>f.maxX&&(f.maxX=y.x),y.y>f.maxY&&(f.maxY=y.y);let x=o.seatDeckY(m);f.sumX+=y.x*A,f.sumDeck+=x,f.sumZ+=y.y*A,f.minDeck=Math.min(f.minDeck,x),f.maxDeck=Math.max(f.maxDeck,x+1.6),s[m]=h}for(let m=0;m<n.length;m++){let p=u[m],h=e.floors?.[m],f=c[m],y=Math.min(p.n?p.minX*A:n[m].focal.x*A-1,Number.isFinite(f.minX)?f.minX:1/0),x=Math.max(p.n?p.maxX*A:n[m].focal.x*A+1,Number.isFinite(f.maxX)?f.maxX:-1/0),b=Math.min(p.n?p.minY*A:n[m].focal.y*A-1,Number.isFinite(f.minZ)?f.minZ:1/0),S=Math.max(p.n?p.maxY*A:n[m].focal.y*A+1,Number.isFinite(f.maxZ)?f.maxZ:-1/0),I=Math.min(p.n?Math.min(n[m].baseHeightM,p.minDeck):n[m].baseHeightM,Number.isFinite(f.minY)?f.minY:1/0),w=Math.max(p.n?Math.max(p.maxDeck,I+.5):I+.5,Number.isFinite(f.maxY)?f.maxY:-1/0),g=[p.n?p.sumX/p.n:(y+x)/2,p.n?p.sumDeck/p.n:(I+w)/2,p.n?p.sumZ/p.n:(b+S)/2],T=Math.max(1,.5*Math.hypot(x-y,w-I,S-b));l.push({index:m,id:h?.id??`floor-${m}`,label:h?.name??(n.length>1?`Floor ${m+1}`:"Venue"),seatCount:p.n,center:g,radius:T,box:{min:[y,I,b],max:[x,w,S]},focalWorld:[n[m].focal.x*A,n[m].baseHeightM+1.5,n[m].focal.y*A]})}}return l}function yn(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=ft(l);if(c)for(let d of c)a(d.x,d.y)}else if(l.type==="table"){let c=dn(l);if(c)for(let d of c)a(d.x,d.y)}else if(l.type==="decorImage"){let c=hn(l);if(c)for(let d of c)a(d.x,d.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=mt(o.minX-a,o.minY-a,o.maxX-o.minX+a*2,o.maxY-o.minY+a*2);ie(t,s,void 0,()=>0,-.4,r.ground,r.ground,re)}else{let a=e.reduce((p,h)=>h.baseHeightM<p.baseHeightM?h:p);t.setFloor(a.index);let s=n.filter((p,h)=>i[h]===a.index),l=yn([a],s),c=Math.hypot(l.maxX-l.minX,l.maxY-l.minY),d=Math.max(28,Math.min(80,c*.04)),u=mt(l.minX-d,l.minY-d,l.maxX-l.minX+d*2,l.maxY-l.minY+d*2),m=a.baseHeightM-.03;ie(t,u,void 0,()=>m,m-.22,r.ground,r.ground,re)}}function er(t,e,n){let{cx:i,cz:o,radius:r}=n,a=1/0,s=1/0,l=1/0,c=-1/0,d=-1/0,u=-1/0,m=(f,y,x)=>{a=Math.min(a,f),c=Math.max(c,f),s=Math.min(s,y),d=Math.max(d,y),l=Math.min(l,x),u=Math.max(u,x)};for(let f=0;f<t.position.length;f+=3)m(t.position[f],t.position[f+1],t.position[f+2]);for(let f=0;f<e.count;f++){let y=f*3,x=e.iPosition[y],b=e.iPosition[y+1],S=e.iPosition[y+2],I=Math.max(.35,e.iMaxRadius[f]??.35);m(x-I,b,S-I),m(x+I,b+1.6,S+I)}Number.isFinite(a)||(a=i-r,c=i+r,s=0,d=r*.16,l=o-r,u=o+r);let p=[(a+c)/2,(s+d)/2,(l+u)/2],h=Math.max(1,.5*Math.hypot(c-a,d-s,u-l));return{center:p,radius:h,minY:s,maxY:d}}function tr(t,e,n,i,o,r){let a=1/0,s=1/0,l=-1/0,c=-1/0;for(let I=0;I<t.count;I++){let w=I*3,g=t.iPosition[w],T=t.iPosition[w+2];g<a&&(a=g),g>l&&(l=g),T<s&&(s=T),T>c&&(c=T)}for(let I of e)a=Math.min(a,I.cx-I.halfX),l=Math.max(l,I.cx+I.halfX),s=Math.min(s,I.cz-I.halfZ),c=Math.max(c,I.cz+I.halfZ);let d=n.minX*A,u=n.maxX*A,m=n.minY*A,p=n.maxY*A,h=d,f=u,y=m,x=p;if(Number.isFinite(a)){let I=Math.max(2,.06*Math.hypot(l-a,c-s));h=Math.max(d,a-I),f=Math.min(u,l+I),y=Math.max(m,s-I),x=Math.min(p,c+I)}let b=Math.min(0,i),S=Math.max(o,r*.05);return{min:[h,b,y],max:[f,S,x]}}function bt(t){let{doc:e}=t,n=co(e.theme),i=n.structure,o=Po(e,t.eventConfigurationId??e.eventConfigurationId),r=t.seats,a=new Et,s=new Map;for(let M of o)for(let R of M.objects)s.set(R.id,M.index),R.type==="section"&&s.set(R.logicalSectionId??R.id,M.index);let l=r.map(M=>s.get(M.sectionId??"")??s.get(M.rowId??"")??0),c=yn(o,r);Jo(a,o,r,l,c,i);let d=Fo(e,r),u=new Map,m=new Map;for(let M of e.categories??[])u.set(M.key,M.color),M.seatGlyph&&m.set(M.key,M.seatGlyph);let p=[],h=Io(o,r,l),f=new Float32Array(r.length);for(let M=0;M<o.length;M++){let R=o[M];a.setFloor(M);let C=new Bt,L=[],E=R.objects.filter(P=>P.type==="section"&&!!P.outline&&P.outline.length>=3);for(let P of R.objects)P.type==="section"?zo(a,P,R,To(P,d),h.bySection.get(P.id),C,E,i):P.type==="shape"?(a.setMaterial(P.role==="screen"?1:0),Bo(a,P,R.baseHeightM,Eo(P,L),i,R.focal,p),a.setMaterial(0)):P.type==="gaArea"?Vo(a,P,R.baseHeightM,Q(u.get(P.categoryKey)),i):P.type==="booth"?_o(a,P,R.baseHeightM,Q(u.get(P.categoryKey)),i):P.type==="table"?Lo(a,P,R.baseHeightM,Q(u.get(P.categoryKey)),i):P.type==="decorImage"&&Oo(a,P,R.baseHeightM,i);Go(a,R,r,h,i)}let y=o.length>1?{x:o.reduce((M,R)=>M+R.focal.x,0)/o.length,y:o.reduce((M,R)=>M+R.focal.y,0)/o.length}:e.focalPoint??{x:(c.minX+c.maxX)/2,y:(c.minY+c.maxY)/2},x=no([a.build()]),b=so(r,t.initialState,h,f,u,m),S=qo({doc:e,units:o,seats:r,surfaces:h,focal:y}),{labels:I,sections:w,rows:g}=Zo({doc:e,units:o,seats:r,surfaces:h,seatData:b,hintedSeatFloor:l,zones:S,focal:y}),T=$o({doc:e,units:o,seats:r,surfaces:h,solids:x,hintedSeatFloor:l,seatFloor:f});Qo(I,T),b.iYaw=io(b.iPosition,r.length,M=>r[M].rowId,M=>{let R=o[f[M]]?.focal??y;return[R.x*A,R.y*A]});let D=(c.minX+c.maxX)/2*A,_=(c.minY+c.maxY)/2*A,G=.5*Math.hypot((c.maxX-c.minX)*A,(c.maxY-c.minY)*A)||10,N=er(x,b,{cx:D,cz:_,radius:G}),v=tr(b,p,c,N.minY,N.maxY,G);return{solids:x,seats:b,bounds:{center:[(v.min[0]+v.max[0])/2,(v.min[1]+v.max[1])/2,(v.min[2]+v.max[2])/2],radius:G,groundY:0,box:v},renderBounds:{center:N.center,radius:N.radius},stateColorLUT:lo(n,ye),theme:n,seatCount:r.length,focalWorld:[y.x*A,1.5,y.y*A],zones:S,stages:p,sections:w,rows:g,labels:I,floors:T}}var la=88,ua=20,nr={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}},Ot=new Set(["row","seat"]),or={floor:5,zone:4,section:3,ga:3,booth:2,annotation:1},Vt={row:{x:62,y:16},seat:{x:46,y:18}},rr=Q,xn=t=>Bn(t);function ir(t,e){let n=xn(t),i=xn(e);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function gn(t,e){let n=/rgba\((\d+),(\d+),(\d+),([\d.]+)\)/.exec(t.replace(/\s/g,""));if(!n)return e;let i=Math.max(0,Math.min(1,Number(n[4])));return[1,2,3].map(o=>Number(n[o])/255*i+e[o-1]*(1-i))}function ma(t,e=[.04,.06,.1],n=!0){let i=xn(e)<.42,o=i?"#f4f7fb":"#0b1220",r=i?"rgba(8,12,22,.78)":"rgba(255,255,255,.84)",a=n?gn(r,e):e,s=rr(t),l=n?7:4.5,c=s&&ir(s,a)>=l?t:o;return i?{ink:c,backing:r,border:"rgba(210,222,245,.24)"}:{ink:c,backing:r,border:"rgba(11,18,32,.22)"}}var Nt=class{constructor(e,n={}){this.nodes=new Map;this.labels=[];this.forcedDense=!1;this.selectedSeatLabelIds=new Set;this.opts=n,this.root=document.createElement("div"),this.root.setAttribute("data-view3d-labels","");let i=this.root.style;i.position="absolute",i.inset="0",i.pointerEvents="none",i.overflow="hidden",n.fontFamily&&(i.fontFamily=n.fontFamily),e.appendChild(this.root)}setVisible(e){this.root.style.visibility=e?"":"hidden"}setLabels(e){this.labels=e;for(let[n,i]of this.nodes)e.some(o=>o.id===n)||(i.remove(),this.nodes.delete(n))}setForcedDense(e){this.forcedDense=e}setSelectedSeatIds(e){this.selectedSeatLabelIds=new Set(Array.from(e,n=>`seat:${n}`))}qualityEvidence(){let e=this.root.getBoundingClientRect(),n=this.root.style.visibility!=="hidden";return this.labels.map(i=>{let o=this.nodes.get(i.id),r=o?.getBoundingClientRect(),a=!!(n&&o&&o.style.display!=="none"&&r&&r.width>0&&r.height>0);return{id:i.id,kind:i.kind,text:i.text,visible:a,renderedFontPx:o&&Number.parseFloat(o.style.fontSize)||0,contrast:o?Number(o.dataset.qualityContrast??0):0,...a&&r?{screenBox:{x:r.x-e.x,y:r.y-e.y,width:r.width,height:r.height}}:{}}})}update(e,n,i,o,r,a){if(!this.labels.length)return;let s=Yo(o,r,{hasZoneLabels:this.labels.some(b=>b.kind==="zone")});this.forcedDense&&(s.add("row"),s.add("seat"));let l=[];for(let b of this.labels){if(!s.has(b.kind))continue;let S=Be(e,b.anchor,n,i);if(!S.visible)continue;let I=a?Math.hypot(b.anchor[0]-a[0],b.anchor[1]-a[1],b.anchor[2]-a[2]):1;l.push({label:b,screen:S,focus:jo(S,I,n,i),halfWidth:Wo(b.text,nr[b.kind].size,!Ot.has(b.kind))/2,...this.selectedSeatLabelIds.has(b.id)?{priority:1}:{}})}let c=Uo(l.filter(b=>b.label.kind==="floor"),n),d=[...l.filter(b=>!Ot.has(b.label.kind)&&b.label.kind!=="floor"),...c],u=Xo(d,la,ua),m=bn(l.filter(b=>b.label.kind==="row"),Vt.row.x,Vt.row.y,fn.row,u),p=bn(l.filter(b=>b.label.kind==="seat"),Vt.seat.x,Vt.seat.y,fn.seat,[...u,...m]),h=[...u,...m,...p],f=new Set(h.map(b=>b.label.id));for(let{label:b,screen:S}of h){let w=this.nodeFor(b).style;w.display="",w.transform=`translate(-50%, -50%) translate(${S.x.toFixed(1)}px, ${S.y.toFixed(1)}px)`}let y=h.filter(({label:b})=>!Ot.has(b.kind)).sort((b,S)=>or[S.label.kind]-or[b.label.kind]||b.screen.depth-S.screen.depth||b.focus-S.focus),x=[];for(let{label:b}of y){let S=this.nodes.get(b.id);if(!S||S.style.display==="none")continue;let I=S.getBoundingClientRect();x.some(g=>I.left<g.right+3&&I.right+3>g.left&&I.top<g.bottom+3&&I.bottom+3>g.top)?S.style.display="none":x.push(I)}for(let[b,S]of this.nodes)f.has(b)||(S.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=nr[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=!Ot.has(e.kind),s=ma(e.color??this.opts.ink,this.opts.backgroundRgb,a);r.color=i?"#ecf8ff":s.ink,r.background=i?"rgba(10,28,45,.9)":a?s.backing:"",r.border=i?"1px solid rgba(89,199,255,.92)":a?`1px solid ${s.border}`:"",r.borderRadius=i||a?"999px":"",r.padding=i||a?"3px 7px":"",r.boxShadow=i?"0 0 0 2px rgba(41,176,255,.18), 0 5px 14px rgba(0,0,0,.35)":a?"0 3px 10px rgba(0,0,0,.24)":"",r.letterSpacing=e.kind==="zone"||e.kind==="floor"?"0.08em":"0.02em";let l=this.opts.backgroundRgb??[.04,.06,.1],c=rr(i?"#ecf8ff":s.ink)??[1,1,1],d=i?gn("rgba(10,28,45,.9)",l):a?gn(s.backing,l):l;return n.dataset.qualityContrast=ir(c,d).toFixed(3),(e.kind==="zone"||e.kind==="floor")&&(r.textTransform="uppercase"),n}dispose(){this.root.remove(),this.nodes.clear()}};var da=1;var ha=new Set(["floor","zone","section","ga","booth","annotation"]);function pa(t){return t.every(e=>Number.isFinite(e))}function fa(t,e){return t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y}function ar(t){return t.length?Math.round(Math.min(...t)*100)/100:null}function Xe(t){return Math.round(t*1e4)/1e4}function ba(t){if(t)return{box:{x:Xe(t.box.x),y:Xe(t.box.y),width:Xe(t.box.width),height:Xe(t.box.height)},horizontalFillRatio:Xe(t.horizontalFillRatio),verticalFillRatio:Xe(t.verticalFillRatio),visibleAreaRatio:Xe(t.visibleAreaRatio),clippedEdges:[...t.clippedEdges]}}function Pe(t,e,n){return n.length?{code:t,message:e,count:n.length,samples:n.slice(0,20)}:null}function vn(t){let e=t.labels.filter(s=>s.visible&&s.screenBox),n=e.filter(s=>ha.has(s.kind)),i=t.scene.floorCount>1?t.scene.floorCount:t.scene.zoneCount||t.scene.sectionCount,o=[];for(let s=0;s<n.length;s+=1)for(let l=0;l<s;l+=1)fa(n[s].screenBox,n[l].screenBox)&&o.push({primaryId:n[s].id,primaryLabel:n[s].text,secondaryId:n[l].id});let r=[...t.camera.position,t.camera.distance,t.camera.verticalFovDeg],a=[Pe("webgl2-unavailable","The venue scene must render through WebGL2",t.context.webgl2?[]:[{primaryId:"renderer",primaryLabel:"WebGL2"}]),Pe("context-lost","The WebGL context must be live at capture",t.context.lost?[{primaryId:"renderer",primaryLabel:"context lost"}]:[]),Pe("frame-not-stable","The captured 3D frame must be rendered and parked",t.frame.rendered>0&&t.frame.idle?[]:[{primaryId:"renderer",primaryLabel:"unstable frame"}]),Pe("viewport-empty","The 3D viewport must have visible dimensions",t.viewport.width>1&&t.viewport.height>1?[]:[{primaryId:"viewport",primaryLabel:`${t.viewport.width}\xD7${t.viewport.height}`}]),Pe("camera-invalid","The capture camera must have a finite physical pose",pa(r)&&t.camera.distance>0&&t.camera.verticalFovDeg>0&&t.camera.verticalFovDeg<180?[]:[{primaryId:"camera",primaryLabel:"invalid pose"}]),Pe("authored-relief-not-visible","Authored 3D height or rake must produce visible screen-space relief",!t.scene.authoredRelief||t.scene.renderedVerticalSpanM>.05&&t.scene.projectedReliefPx>=2?[]:[{primaryId:"scene",primaryLabel:"authored relief",measured:t.scene.projectedReliefPx,minimum:2}]),Pe("hierarchy-label-missing","A venue with authored hierarchy must show at least one structural label",i===0||n.length>0?[]:[{primaryId:"labels",primaryLabel:`${i} expected hierarchy labels`}]),Pe("hierarchy-label-undersized","Visible 3D hierarchy labels must remain readable",n.filter(s=>s.renderedFontPx<11).map(s=>({primaryId:s.id,primaryLabel:s.text,measured:s.renderedFontPx,minimum:11}))),Pe("hierarchy-label-contrast-low","Visible 3D hierarchy labels must meet text contrast",n.filter(s=>s.contrast<4.5).map(s=>({primaryId:s.id,primaryLabel:s.text,measured:s.contrast,minimum:4.5}))),Pe("hierarchy-label-collision","Visible 3D hierarchy labels must not overlap",o)].filter(s=>!!s);return{version:1,state:"venue3d",passed:a.length===0,resolvedRules:["rendered-3d-webgl-context","rendered-3d-stable-frame","rendered-3d-camera-pose","rendered-3d-relief-projection","rendered-3d-label-size","rendered-3d-label-contrast","rendered-3d-label-collision"],viewport:t.viewport,context:t.context,frame:t.frame,camera:t.camera,scene:t.scene,composition:{visibleLabels:e.map(({id:s,kind:l,text:c})=>({id:s,kind:l,text:c})).sort((s,l)=>s.kind.localeCompare(l.kind)||s.id.localeCompare(l.id)),framing:ba(t.framing)},metrics:{minimumHierarchyFontPx:ar(n.map(s=>s.renderedFontPx)),minimumHierarchyContrast:ar(n.map(s=>s.contrast)),projectedReliefPx:Math.round(t.scene.projectedReliefPx*100)/100},findings:a}}import{Geometry as Gt,Mesh as Ht,Transform as br}from"ogl";import{Program as We}from"ogl";var zt=`
|
|
2
2
|
float chairWeight(float depth) {
|
|
3
3
|
return 1.0 - smoothstep(uChairFull, uChairNone, depth);
|
|
4
4
|
}`,sr=`
|
|
5
5
|
float occupantWeight(float depth) {
|
|
6
|
-
float nearWeight = smoothstep(${
|
|
7
|
-
float farWeight = 1.0 - smoothstep(${
|
|
6
|
+
float nearWeight = smoothstep(${Zn.toFixed(1)}, ${Qn.toFixed(1)}, depth);
|
|
7
|
+
float farWeight = 1.0 - smoothstep(${Kn.toFixed(1)}, ${qn.toFixed(1)}, depth);
|
|
8
8
|
return nearWeight * farWeight;
|
|
9
9
|
}`,cr=`
|
|
10
10
|
float glyphEq(float glyph, float expected) {
|
|
@@ -600,4 +600,4 @@ out vec4 fragColor;
|
|
|
600
600
|
void main() {
|
|
601
601
|
if (vHidden > 0.5) discard;
|
|
602
602
|
fragColor = vec4(0.0, 0.0, 0.0, 1.0);
|
|
603
|
-
}`;function lr(t){return new We(t,{vertex:Aa,fragment:Ca,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uSeatRadius:{value:Ae},uSeatScale:{value:1},uMinPixels:{value:Ze},uPixelToWorld:{value:.002},uChairFull:{value:ct},uChairNone:{value:Qe},uFocusFloor:{value:-1}}})}function ur(t){return new We(t,{vertex:Ra,fragment:Ia,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uChairFull:{value:ct},uChairNone:{value:Qe},uBackRake:{value:rn},uBackBase:{value:_t},uFocusFloor:{value:-1}}})}function mr(t){return new We(t,{vertex:Fa,fragment:Ta,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uFocusFloor:{value:-1}}})}function dr(t){return new We(t,{vertex:ya,fragment:xa,cullFace:!1,depthTest:!0,depthWrite:!0,uniforms:{uKeyDir:{value:new Float32Array([.38,.86,.34])},uFocusFloor:{value:-1},uStructureDetail:{value:0}}})}function hr(t){return new We(t,{vertex:ga,fragment:va,transparent:!0,depthTest:!0,depthWrite:!1,cullFace:!1,uniforms:{uSeatRadius:{value:Ae},uSeatScale:{value:1},uMinPixels:{value:Ze},uPixelToWorld:{value:.002},uSeatFade:{value:0},uSeatDetail:{value:0},uFocusFloor:{value:-1},uFadeColor:{value:new Float32Array([.32,.37,.43])},uChairFull:{value:ct},uChairNone:{value:Qe}}})}function pr(t){return new We(t,{vertex:Ma,fragment:Sa,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:ct},uChairNone:{value:Qe},uBackRake:{value:rn},uBackBase:{value:_t},uFocusFloor:{value:-1}}})}function fr(t,e,n){return new We(t,{vertex:wa,fragment:Pa,depthTest:!1,depthWrite:!1,cullFace:!1,uniforms:{uTop:{value:new Float32Array(e)},uBottom:{value:new Float32Array(n)}}})}function yr(t,e,n,i,o,r){for(let a=n;a<n+i;a++){let l=r&&e[a]===0?null:o[e[a]]??o[0];t[a*3]=l?l[0]:r[a*3],t[a*3+1]=l?l[1]:r[a*3+1],t[a*3+2]=l?l[2]:r[a*3+2]}}var Ea=new Float32Array([-1,-1,1,-1,1,1,-1,-1,1,1,-1,1]),Da=new Float32Array([-1,-1,3,-1,-1,3]);function xr(t,e){let n=new br,i=new br,o=new Gt(t,{position:{size:2,data:Da}}),r=fr(t,e.theme.background.top,e.theme.background.bottom),a=new Ht(t,{geometry:o,program:r});a.frustumCulled=!1,a.setParent(i);let s=new Gt(t,{position:{size:3,data:e.solids.position},normal:{size:3,data:e.solids.normal},color:{size:3,data:e.solids.color},floorIndex:{size:1,data:e.solids.floor},materialIndex:{size:1,data:e.solids.material}}),l=dr(t),c=new Ht(t,{geometry:s,program:l});c.frustumCulled=!1,c.setParent(n);let d=hr(t),u=new Float32Array(e.seats.count*3),m=ye.map(F=>e.theme.seatStates[F]);yr(u,e.seats.iState,0,e.seats.count,m,e.seats.iCategory);let p=new Gt(t,{position:{size:2,data:Ea},iOffset:{size:3,data:e.seats.iPosition,instanced:1},iColor:{size:3,data:u,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 Ht(t,{geometry:p,program:d});h.frustumCulled=!1,e.seats.count>0&&h.setParent(n);let f=p.attributes.iColor,y=oo(),x=pr(t),b=It,S=new Float32Array(b*3),I=new Float32Array(b*3),w=new Float32Array(b),g=new Float32Array(b),T=new Float32Array(b),D=new Float32Array(b*3),_=new Float32Array(b),G=new Float32Array(b),N=new Float32Array(b),v=new Float32Array(b),M=new Gt(t,{position:{size:3,data:y.position},normal:{size:3,data:y.normal},part:{size:1,data:y.part},index:{data:y.index},iOffset:{size:3,data:S,instanced:1},iColor:{size:3,data:I,instanced:1},iRadius:{size:1,data:w,instanced:1},iYaw:{size:1,data:g,instanced:1},iGlyph:{size:1,data:T,instanced:1},iRing:{size:3,data:D,instanced:1},iFloor:{size:1,data:_,instanced:1},iPhysicalSeat:{size:1,data:G,instanced:1},iSeed:{size:1,data:v,instanced:1},iPickIndex:{size:1,data:N,instanced:1}}),R=new Ht(t,{geometry:M,program:x});R.frustumCulled=!1;let C=0,L=new Int32Array(0),E=()=>{let F=e.seats;for(let O=0;O<C;O++){let H=L[O];v[O]=io(F.iState[H],H);let B=F.iCategory&&F.iState[H]===0?null:m[F.iState[H]]??m[0];if(B)I[O*3]=B[0],I[O*3+1]=B[1],I[O*3+2]=B[2];else{let U=Yn([F.iCategory[H*3],F.iCategory[H*3+1],F.iCategory[H*3+2]]);I[O*3]=U[0],I[O*3+1]=U[1],I[O*3+2]=U[2]}}M.attributes.iColor.needsUpdate=!0,M.attributes.iSeed.needsUpdate=!0},P={main:n,background:i,seatProgram:d,solidProgram:l,chairProgram:x,seatGeometry:p,chairGeometry:M,solidGeometry:s,drawCalls:3,setNearSeats(F,O){let H=Math.min(O,b);if(L=F,C=H,H===0){R.parent&&R.setParent(null),M.instancedCount=0,P.drawCalls=3;return}let z=e.seats;for(let B=0;B<H;B++){let U=F[B];S[B*3]=z.iPosition[U*3],S[B*3+1]=z.iPosition[U*3+1],S[B*3+2]=z.iPosition[U*3+2],w[B]=z.iChairWidth[U],g[B]=z.iYaw[U],T[B]=z.iGlyph[U],D[B*3]=z.iRing[U*3],D[B*3+1]=z.iRing[U*3+1],D[B*3+2]=z.iRing[U*3+2],_[B]=z.iFloor[U],G[B]=z.iPhysicalSeat[U],N[B]=U+1}E(),M.attributes.iOffset.needsUpdate=!0,M.attributes.iRadius.needsUpdate=!0,M.attributes.iYaw.needsUpdate=!0,M.attributes.iGlyph.needsUpdate=!0,M.attributes.iRing.needsUpdate=!0,M.attributes.iFloor.needsUpdate=!0,M.attributes.iPhysicalSeat.needsUpdate=!0,M.attributes.iSeed.needsUpdate=!0,M.attributes.iPickIndex.needsUpdate=!0,M.instancedCount=H,R.parent||R.setParent(n),P.drawCalls=4},nearSeatCount(){return C},uploadSeatStateRuns(F){if(!F.length)return;C&&E();for(let H of F)yr(u,e.seats.iState,H.start,H.length,m,e.seats.iCategory);let O=f.buffer;if(!O){f.needsUpdate=!0;return}t.bindBuffer(t.ARRAY_BUFFER,O);for(let H of F){let z=u.subarray(H.start*3,(H.start+H.length)*3);t.bufferSubData(t.ARRAY_BUFFER,H.start*3*Float32Array.BYTES_PER_ELEMENT,z)}},dispose(){o.remove(),r.remove(),s.remove(),l.remove(),p.remove(),d.remove(),M.remove(),x.remove()}};return P}import{Mesh as vn,RenderTarget as _a,Transform as Mn}from"ogl";function ka(t,e,n){let i=t+(e<<8)+(n<<16);return i===0?-1:i-1}function gr(t,e,n,i,o,r){let a=-1,s=1/0;for(let l=0;l<n;l++)for(let c=0;c<e;c++){let d=(l*e+c)*4,u=ka(t[d],t[d+1],t[d+2]);if(u<0||u>=r)continue;let m=c-i,p=l-o,h=m*m+p*p;h<s&&(s=h,a=u)}return a}function vr(t,e,n,i,o,r){let a=t-n.left,s=e-n.top,l=Math.round(a*i),c=Math.round((n.height-s)*i);return{x:Math.max(0,Math.min(o-1,l)),y:Math.max(0,Math.min(r-1,c))}}var La=["uSeatRadius","uSeatScale","uMinPixels","uPixelToWorld"],Ut=class{constructor(e,n,i,o,r){this.seatScene=new Mn;this.chairScene=new Mn;this.solidScene=new Mn;this.target=null;this.restoreClear=[0,0,0];this.renderer=e,this.gl=e.gl,this.maxIndex=r,this.seatProg=lr(this.gl),this.chairProg=ur(this.gl),this.depthProg=mr(this.gl);let a=new vn(this.gl,{geometry:n,program:this.seatProg});a.frustumCulled=!1,a.setParent(this.seatScene);let s=new vn(this.gl,{geometry:i,program:this.chairProg});s.frustumCulled=!1,s.setParent(this.chairScene);let l=new vn(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 La)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 _a(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),d=Math.max(0,i-o),u=Math.max(1,Math.min(s,n+o+1)-c),m=Math.max(1,Math.min(l,i+o+1)-d);r.enable(r.SCISSOR_TEST),r.scissor(c,d,u,m);let[p,h,f]=this.restoreClear;r.clearColor(0,0,0,1),this.renderer.render({scene:this.solidScene,camera:e,target:a,clear:!0}),this.renderer.render({scene:this.seatScene,camera:e,target:a,clear:!1}),this.renderer.render({scene:this.chairScene,camera:e,target:a,clear:!1}),r.clearColor(p,h,f,1),r.disable(r.SCISSOR_TEST);let y=new Uint8Array(u*m*4);return this.renderer.bindFramebuffer(a),r.readPixels(c,d,u,m,r.RGBA,r.UNSIGNED_BYTE,y),this.renderer.bindFramebuffer(),gr(y,u,m,n-c,i-d,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,st(i.state)):n.push(i);return n}function Sr(t,e,n){let i=new Set;for(let a of e)(t.has(a)||n(a)!==void 0)&&i.add(a);let o=new Map(t),r=[];for(let[a,s]of t)i.has(a)||(r.push({seatId:a,state:ye[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 yt,Vec3 as Va}from"ogl";function Ba(t,e){return[t[0]-e[0],t[1]-e[1],t[2]-e[2]]}function wr(t,e){return[t[0]+e[0],t[1]+e[1],t[2]+e[2]]}function Oa(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 Sn(t){let e=Math.max(0,Math.min(1,t));return e*e*e*(e*(e*6-15)+10)}function wn(t,e){return Math.max(0,Math.min(1,t+e))}function Ar(t,e){let n=t.length;if(n===0)return[0,0,0];if(n===1)return[...t[0]];let i=Math.max(0,Math.min(1,e)),o=n-1,r=Math.floor(i*o);r>=o&&(r=o-1);let a=i*o-r,s=t[Math.max(0,r-1)],l=t[r],c=t[r+1],d=t[Math.min(n-1,r+2)],u=a*a,m=u*a,p=[0,0,0];for(let h=0;h<3;h++)p[h]=.5*(2*l[h]+(-s[h]+c[h])*a+(2*s[h]-5*l[h]+4*c[h]-d[h])*u+(-s[h]+3*l[h]-3*c[h]+d[h])*m);return p}function Pn(t,e,n,i,o){let r=Pr(Ba(e,n));r[0]===0&&r[1]===0&&r[2]===0&&(r=[0,0,1]);let a=wr(wr(e,Oa(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),d=[i[0]+l[0]*c*1.3,i[1]+c*.75,i[2]+l[2]*c*1.3];return{waypoints:[t,d,a],finalPos:a}}function An(t,e,n=35,i=28){let o=Sn(e),r=Ar(t,o),a=Sn(Math.max(0,Math.min(1,(e-.66)/.34)));return{pos:r,fov:n+(i-n)*a,eased:o}}function Ir(t,e,n){let i=t.position.clone(),o=new yt().copy(t.quaternion);t.position.set(e[0],e[1],e[2]),t.lookAt(new Va(n[0],n[1],n[2]));let r=new yt().copy(t.quaternion);return t.position.copy(i),t.quaternion.copy(o),r}var Yt=class{constructor(e){this.active=!1;this.waypoints=[];this.startQuat=new yt;this.endQuat=new yt;this.outQuat=new yt;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}=An(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,wn(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 Na=1.02,za=1.5;function Fr(t,e,n=0,i){let o=Number.isFinite(i)?n+i:t[1]+Na;return{eye:[t[0],o,t[2]],focal:[e.x*A,n+za,e.y*A]}}var Cn=null;function Tr(){return Cn??=import("../openPanorama-ALLZ6ADE.js").catch(t=>{throw Cn=null,t}),Cn}var Er=()=>typeof performance<"u"&&performance.now?performance.now():Date.now(),Xt=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=Er(),this.emit("3d_panorama_opened")}panoramaClosed(){let e=this.panoramaOpenedAt?Math.round(Er()-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 Dr(t){let e=t.style.position;return getComputedStyle(t).position!=="static"?()=>{}:(t.style.position="relative",()=>{t.style.position==="relative"&&(t.style.position=e)})}function kr(t){let{container:e,model:n,opts:i,expandedSeatById:o,seatIdsByRow:r,isNarrow:a}=t,s=null,l=()=>{if(!s)return;let u=a();Object.assign(s.style,u?{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:(u,m,p=!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 f=o.get(u),y=f?.sectionId?n.sections.find(D=>D.id===f.sectionId):void 0,x=f?.label??u;h.setAttribute("aria-label",`Explore views near ${y?.label?`${y.label}, `:""}seat ${x}`);let b=document.createElement("span");b.textContent=["Live 3D seat view",y?.label,x].filter(Boolean).join(" \xB7 "),Object.assign(b.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(b);let S=document.createElement("div");Object.assign(S.style,{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px"}),h.appendChild(S);let I=f?.rowId?r.get(f.rowId):void 0,w=I?.indexOf(u)??-1,g=w>=0?[I?.[w-1],I?.[w+1]]:[void 0,void 0],T=(D,_,G,N=!1)=>{let v=document.createElement("button");v.type="button",v.textContent=D,v.setAttribute("aria-label",_),Object.assign(v.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||(v.style.minWidth="44px"),N&&(v.dataset.panoramaTrigger=""),v.addEventListener("click",G),S.appendChild(v)};if(g[0]){let D=o.get(g[0])?.label??g[0];T("\u2039",`View previous seat ${D}`,()=>{t.flyToSeat(g[0])})}if(i.getSeatView){let D=i.seatViewActionLabel?.(u)??"Open 360\xB0 panorama";T(p?`\u21BB Retry ${D}`:`\u25C9 ${D}`,`${p?"Retry":D} from seat ${x}`,()=>{if(t.isDisposed()||m!==t.flightGen()){c();return}c(),t.openPanorama(u,400,m)},!0)}if(g[1]){let D=o.get(g[1])?.label??g[1];T("\u203A",`View next seat ${D}`,()=>{t.flyToSeat(g[1])})}return S.childElementCount?(e.appendChild(h),s=h,l(),h):null},remove:c,layout:l}}function _r(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 d=document.createElement("button");d.type="button",d.textContent="\u2212",d.setAttribute("aria-label","Zoom out of the 3D venue"),d.dataset.tooltip="Zoom out";let u=document.createElement("button");u.type="button",u.textContent="+",u.setAttribute("aria-label","Zoom into the 3D venue"),u.dataset.tooltip="Zoom in";for(let f of[l,c,d,u])f.className="sl-3d-icon-control",Object.assign(f.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(u,d);let m=f=>{n.setPrimaryDragMode(f);let y=f==="orbit";l.setAttribute("aria-pressed",String(y)),c.setAttribute("aria-pressed",String(!y)),l.style.background=y?"rgba(96,110,150,0.68)":"rgba(12,18,32,0.82)",c.style.background=y?"rgba(12,18,32,0.82)":"rgba(96,110,150,0.68)",o.title=y?"Drag to rotate \xB7 Shift-drag to move":"Drag to move \xB7 Shift-drag to rotate"};l.addEventListener("click",()=>m("orbit")),c.addEventListener("click",()=>m("pan")),d.addEventListener("click",()=>n.zoomBy(1.22)),u.addEventListener("click",()=>n.zoomBy(.82)),o.append(a,s),m("orbit"),e.appendChild(o);let p=()=>{let f=i();o.style.display=r?"none":"flex",o.style.right=f?"12px":"14px",o.style.bottom=f?"calc(env(safe-area-inset-bottom, 0px) + 76px)":"14px",a.style.display=f?"none":"flex",u.style.display=f?"none":"",d.style.display=f?"none":""};return p(),{element:o,utilityControls:s,setNavigationMode:m,setSeatViewLocked:f=>{r=f,n.setInteractionEnabled(!f),p()},seatViewLocked:()=>r,layout:p}}function Lr(t){let{glctx:e,orbit:n,model:i,seats:o,opts:r,cinematic:a,analytics:s,seatIdByIndex:l,sectionIdBySeatId:c,tapSlop:d,tapMs:u,cancelFlight:m,focusSectionCamera:p,setSelection:h,ensureSeatView:f}=t,y=0,x=0,b=0,S=-1,I=!1,w=!1,g=N=>{t.seatViewLocked()||S===-1&&(S=N.pointerId,y=N.clientX,x=N.clientY,b=performance.now(),I=!1,w=a.active,a.active&&(s.cinematicCancelled(),m(),r.onViewTargetChange?.(null)))},T=N=>{N.pointerId===S&&Math.hypot(N.clientX-y,N.clientY-x)>d&&(I=!0)},D=(N,v,M,R,C)=>{let L=e.canvas.getBoundingClientRect(),E=e.canvas.clientWidth||L.width||1,P=e.canvas.clientHeight||L.height||1,F=N-L.left,O=v-L.top,H=R*R,z=-1,B=H,U=1/0;for(let K of o){if(M&&K.sectionId!==M)continue;let Y=i.seats.idToIndex.get(K.id);if(Y===void 0)continue;if(C){let ae=Math.round(i.seats.iState[Y]??0);if(ae!==0&&ae!==3)continue}let j=Y*3,q=Be(n.camera.projectionViewMatrix,[i.seats.iPosition[j],i.seats.iPosition[j+1]+.55,i.seats.iPosition[j+2]],E,P);if(!q.visible)continue;let ne=q.x-F,oe=q.y-O,$=ne*ne+oe*oe;($<B||Math.abs($-B)<1&&q.depth<U)&&(z=Y,B=$,U=q.depth)}return z},_=(N,v)=>{let M=t.gpu(),R=t.pick();if(!M||!R)return-1;R.syncFromSeatProgram(M.seatProgram);let C=e.canvas.getBoundingClientRect(),L=e.renderer.dpr,{x:E,y:P}=vr(N,v,C,L,e.gl.drawingBufferWidth,e.gl.drawingBufferHeight),F=Math.max(2,Math.round(8*L));return R.pick(n.camera,E,P,F)};return{onDown:g,onMove:T,onUp:N=>{if(N.pointerId!==S)return;let v=!I&&performance.now()-b<u;if(S=-1,w){w=!1;return}let M=t.gpu(),R=t.pick();if(!v||!M||!R)return;let C=_(N.clientX,N.clientY);if(t.focusedSectionId()&&C>=0){let P=l[C],F=P?c.get(P):void 0;if(F&&F!==t.focusedSectionId()&&p(F))return}if(t.focusedSectionId()&&C<0&&(C=D(N.clientX,N.clientY,t.focusedSectionId(),44,!1)),t.focusedSectionId()&&C<0){let P=D(N.clientX,N.clientY,null,72,!1),F=P>=0?l[P]:void 0,O=F?c.get(F):void 0;if(O&&O!==t.focusedSectionId()&&p(O))return}if(!t.focusedSectionId()){C<0&&(C=D(N.clientX,N.clientY,null,42,!1));let P=C>=0?l[C]:void 0,F=P?c.get(P):void 0;if(F&&p(F))return}if(C<0||C>=l.length){t.selection().size&&(h([]),r.onViewTargetChange?.(null));return}let L=l[C],E=ye[Math.round(i.seats.iState[C]??0)]??"available";if(E!=="available"&&E!=="selected"){r.onSeatInspect?.(L,E);return}if(t.selection().has(L)&&t.selection().size===1){h([]),r.onViewTargetChange?.(null);return}h([L]),f(L),s.seatPicked(L,c.get(L)),r.onSeatPick?.(L)}}}var Wt=class{constructor(e,n){this.minX=0;this.minZ=0;this.cell=1;this.cols=1;this.rows=1;this.cellStart=null;this.cellItems=null;this.iPosition=e,this.count=n}ensureGrid(){if(this.cellStart||this.count===0)return;let e=this.iPosition,n=1/0,i=1/0,o=-1/0,r=-1/0;for(let p=0;p<this.count;p++){let h=e[p*3],f=e[p*3+2];h<n&&(n=h),h>o&&(o=h),f<i&&(i=f),f>r&&(r=f)}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),d=p=>{let h=Math.min(this.cols-1,Math.max(0,Math.floor((e[p*3]-n)/this.cell)));return Math.min(this.rows-1,Math.max(0,Math.floor((e[p*3+2]-i)/this.cell)))*this.cols+h};for(let p=0;p<this.count;p++)c[d(p)+1]++;for(let p=0;p<l;p++)c[p+1]+=c[p];let u=new Int32Array(this.count),m=c.slice(0,l);for(let p=0;p<this.count;p++)u[m[d(p)]++]=p;this.cellStart=c,this.cellItems=u}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),d=Math.floor((n-this.minZ)/this.cell),u=Math.ceil(i/this.cell)+1,m=this.iPosition,p=0;for(let h=0;h<=u&&p<s;h++){let f=d-h,y=d+h,x=c-h,b=c+h;for(let S=f;S<=y&&p<s;S++){if(S<0||S>=this.rows)continue;let I=S===f||S===y;for(let w=x;w<=b&&p<s;w++){if(!I&&w!==x&&w!==b){w=b-1;continue}if(w<0||w>=this.cols)continue;let g=S*this.cols+w;for(let T=r[g],D=r[g+1];T<D&&p<s;T++){let _=a[T],G=m[_*3]-e,N=m[_*3+2]-n;G*G+N*N<=l&&(o[p++]=_)}}}}return p}};var jt=class{constructor(e){this.ctx=e;this.detailVisible=!1;this.seatDetailMix=0;this.structureDetailMix=0;this.nearBuf=new Int32Array(It);this.lastGatherX=1/0;this.lastGatherZ=1/0;this.nearIndex=new Wt(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)<nn)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>tn){i.nearSeatCount()&&i.setNearSeats(this.nearBuf,0);return}let s=this.nearIndex.gather(o.x,o.z,tn,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 Ga,Vec3 as Ha}from"ogl";function Br(t){let{container:e,model:n,opts:i,orbit:o,cinematic:r,analytics:a,loop:s,labelOverlay:l,stageAzimuth:c,overviewFraming:d}=t,u=0,m=-1,p=(w,g,T=28)=>{o.camera.position.set(w[0],w[1],w[2]),o.camera.lookAt(new Ha(g[0],g[1],g[2])),o.camera.fov=T,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 f=()=>{h.textContent="\u2302"};f();let y=w=>{m=w;let g=t.gpu();g&&(g.seatProgram.uniforms.uFocusFloor.value=w,g.solidProgram.uniforms.uFocusFloor.value=w,g.chairProgram.uniforms.uFocusFloor.value=w),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 w=m>=0?n.floors[m]:null;if(t.setNearFieldDetailEnabled(!!w),t.setSeatViewLocked(!1),b(),t.removeArriveChip(),t.setNavigationMode("orbit"),w){let g=w.focalWorld[0]-w.center[0],T=w.focalWorld[2]-w.center[2],D=Math.hypot(g,T)>w.radius*.12?Math.atan2(g,T):c,_={center:w.center,radius:w.radius,box:w.box},G={polarDeg:58,margin:1.12};t.reducedMotion()?o.frame(_,!1,D,!1,G):o.frameSoft(_,D,!1,G)}else t.reducedMotion()?o.frame(n.bounds,!1,c,i.portraitOverviewCrop===!0,d):o.frameSoft(n.bounds,c,i.portraitOverviewCrop===!0,d);t.showSectionSeatLabels(null),s.requestRender()},b=()=>{u++,t.panoramaLoadAbort()?.abort(),t.setPanoramaLoadAbort(null),r.active&&(r.cancel(),o.resumeAfterFlight(n.focalWorld))},S=w=>{if(t.isDisposed()||!t.gpu())return Promise.resolve();let g=n.seats.idToIndex.get(w);if(g===void 0)return Promise.resolve();t.setNearFieldDetailEnabled(!0),i.onViewTargetChange?.(w),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 T=++u;t.removeArriveChip();let{eye:D,focal:_}=t.resolvedSeatViewPose(w,g),G=[o.camera.position.x,o.camera.position.y,o.camera.position.z],N=Pn(G,D,_,n.bounds.center,n.bounds.radius),v=i.arriveAtSeatEye?D:N.finalPos,M=i.arriveAtSeatEye?e.clientWidth/Math.max(1,e.clientHeight)<.7?90:65:28,R=[N.waypoints[0],N.waypoints[1],v];if(l.setVisible(!1),t.reducedMotion())return p(v,_,M),s.requestRender(),a.cinematicSkipped(),t.isDisposed()||o.syncFromCamera(),t.setSeatViewLocked(i.arriveAtSeatEye===!0),t.showArriveChip(w,T),Promise.resolve();let C=new Ga().copy(o.camera.quaternion),L=Ir(o.camera,v,_);return s.requestRender(),r.start(R,C,L,2500,M).then(()=>{t.isDisposed()||T!==u||(a.cinematicPlayed(2500),o.resumeAfterFlight(_),t.setSeatViewLocked(i.arriveAtSeatEye===!0),s.requestRender(),t.showArriveChip(w,T))})},I=w=>{let g=n.sections.find(G=>G.id===w);if(!g||g.seatCount===0)return!1;t.setNearFieldDetailEnabled(!0),t.setSeatViewLocked(!1),r.cancel(),t.removeArriveChip(),n.floors.length>1&&m!==g.floorIndex&&y(g.floorIndex),t.setNavigationMode("pan"),t.showSectionSeatLabels(w);let T=g.focalWorld[0]-g.center[0],D=g.focalWorld[2]-g.center[2],_=Math.hypot(T,D)>g.radius*.12?Math.atan2(T,D):void 0;return o.frame({center:g.center,radius:Math.max(5,g.radius*.5)},!1,_),i.onSectionFocusChange?.(w),s.requestRender(),!0};return h.addEventListener("click",x),{overviewChip:h,layoutOverviewChip:f,flightGen:()=>u,focusedFloor:()=>m,applyFloorFocus:y,placeCameraFinal:p,cancelFlight:b,focusOverview:x,flyToSeat:S,focusSectionCamera:I}}function Or(t){let e=performance.now();return{model:bt(t),buildMs:performance.now()-e,source:"main"}}function Ua(t){return typeof Worker>"u"?Promise.resolve(Or(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(Or(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 vu(t,e,n={}){let i=performance.now(),o=e.prepared?.model??bt(e),r=new Xt(n.onAnalytics),a=new Array(o.seats.count);for(let[k,V]of o.seats.idToIndex)a[V]=k;let s=new Map(e.seats.map(k=>[k.id,k])),l=new Map;for(let k of e.seats){if(!k.rowId)continue;let V=l.get(k.rowId);V?V.push(k.id):l.set(k.rowId,[k.id])}let c=new Map;for(let k of e.seats)c.set(k.id,k.sectionId);let d=e.doc.floors?.some(V=>(V.baseHeightM??0)>0)?!0:(e.doc.floors?.flatMap(V=>V.objects)??e.doc.objects).some(V=>V.type==="section"&&((V.height??0)>0||(V.rake??0)>0)),u=null,m=null,p=!1,h=!1,f=!1,y=new Map,x=null,b=null,S=null,I=new Map,w=null,g=()=>{S===null&&(S=t.style.zIndex,t.style.zIndex="20")},T=()=>{S!==null&&(t.style.zIndex==="20"&&(t.style.zIndex=S),S=null)},D=!1,_=()=>D?me.focusedFloor():-1,G=()=>{u=xr(R.gl,o),m=new Ut(R.renderer,u.seatGeometry,u.chairGeometry,u.solidGeometry,o.seats.count),R.setClearColor(o.theme.background.top),m.setRestoreClear(o.theme.background.top),u.seatProgram.uniforms.uSeatRadius.value=Ae*o.theme.seatScale,u.seatProgram.uniforms.uFocusFloor.value=_(),u.solidProgram.uniforms.uFocusFloor.value=_(),u.chairProgram.uniforms.uFocusFloor.value=_(),v.forceRegather()},N=!1,v=new jt({model:o,orbit:()=>C,gpu:()=>u}),M=k=>v.setDetailEnabled(k),R=new At(t,{onContextLost:()=>{f||r.contextLost(),p=!0,j.stop(),u=null,m=null},onContextRestored:()=>{G(),p=!1,f||r.contextRestored(),j.requestRender()}}),C=new Ct(R.gl,R.canvas,()=>j.requestRender(),()=>r.orbitEngaged());C.setAspect(R.aspect);let L=(e.doc.floors?.flatMap(k=>k.objects)??e.doc.objects).some(k=>k.type==="section"&&k.physical3dProvenance?.surfaceKind?.status==="inferred"),E=(()=>{if(L&&o.stages.length===0)return;let k=o.focalWorld[0]-o.bounds.center[0],V=o.focalWorld[2]-o.bounds.center[2];return Math.hypot(k,V)>o.bounds.radius*.12?Math.atan2(k,V):void 0})(),P=o.floors.length>1?{polarDeg:48,margin:1.1}:void 0,F=typeof window<"u"&&!!window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;C.frame(o.bounds,!F&&n.skipInitialOverviewAnimation!==!0,E,n.portraitOverviewCrop===!0,P);let O=new Yt(C.camera),H=Dr(t),z=new Nt(t,{fontFamily:e.doc.theme?.fontFamily,ink:e.doc.theme?.textColor,backgroundRgb:o.theme.background.top}),B=o.labels,U=()=>Go(B,o.floors.length,_());z.setLabels(U());let K=null,Y=k=>{if(K=k,z.setForcedDense(!!k),!k){z.setLabels(U());return}let V=e.seats.filter(W=>W.sectionId===k),X=new Set(V.map(W=>W.id)),Z=new Set(V.map(W=>W.rowId)),J=new Set(y.keys()),ee=new Set(V.filter(W=>J.has(W.id)).map(W=>W.id)),ce=U().filter(W=>W.kind!=="row"&&W.kind!=="seat"||(W.kind==="row"?Z.has(W.id.slice(4)):X.has(W.id.slice(5))&&(ee.size===0||ee.has(W.id.slice(5)))));if(o.seatCount<=6e3&&ee.size===0){z.setLabels(ce);return}let le=ee.size?V.filter(W=>ee.has(W.id)):V,Ne=new Set(le.map(W=>`seat:${W.id}`)),De=le.flatMap(W=>{let de=o.seats.idToIndex.get(W.id);if(de===void 0)return[];let Se=de*3;return[{id:`seat:${W.id}`,kind:"seat",text:W.displayLabel||W.label,anchor:[o.seats.iPosition[Se],o.seats.iPosition[Se+1]+(J.has(W.id)?1.05:.55),o.seats.iPosition[Se+2]]}]});z.setLabels([...ce.filter(W=>!Ne.has(W.id)),...De])};G();let j=new Rt(k=>{if(p||!u||h)return!1;let X=O.active?O.update(performance.now()):C.update(),Z=_()>=0?o.floors[_()]:null,J=Z?.radius??o.bounds.radius,ee=Qn(C.currentDistance,J),ce=N?{center:[C.camera.position.x,C.camera.position.y,C.camera.position.z],radius:520}:o.renderBounds;C.updateClipping(ce);let le=Z?.center??o.renderBounds.center,Ne=Z?.radius??o.renderBounds.radius,De=(we,ot)=>Math.hypot(C.camera.position.x-we[0],C.camera.position.y-we[1],C.camera.position.z-we[2])<=ot*(v.detailVisible?1.8:1.55),W=De(le,Ne);if(!W&&K){let we=o.sections.find(ot=>ot.id===K);we&&(W=De(we.center,Math.max(12,we.radius*2)))}v.detailVisible=W;let de=u.seatProgram.uniforms;de.uSeatScale.value=ee.scale,de.uSeatFade.value=ee.fade;let Se=!!Z&&$n(Z.seatCount,R.canvas.clientWidth||1,R.canvas.clientHeight||1),gt=Jn(o.seats.count,J,C.currentDistance,C.camera.fov,R.canvas.clientHeight||1),nt=v.detailVisible||Se||gt?1:0,vt=v.detailVisible||_()>=0||o.floors.length>1?1:0;return v.ease(k,nt,vt),de.uSeatDetail.value=v.seatDetailMix,u.solidProgram.uniforms.uStructureDetail.value=v.structureDetailMix,de.uMinPixels.value=ee.minPixels,de.uPixelToWorld.value=2*Math.tan(C.camera.fov*Ya/2)/Math.max(1,R.pixelHeight),v.update(v.detailVisible),R.renderer.render({scene:u.background,clear:!0}),R.renderer.render({scene:u.main,camera:C.camera,clear:!1}),z.update(C.camera.projectionViewMatrix,R.canvas.clientWidth||1,R.canvas.clientHeight||1,C.currentDistance,J,[C.camera.position.x,C.camera.position.y,C.camera.position.z]),X||v.seatDetailMix!==nt||v.structureDetailMix!==vt}),q=typeof ResizeObserver<"u"?new ResizeObserver(()=>qt.resize()):null;q?.observe(t);let ne=k=>{let V=J=>{let ee=o.seats.idToIndex.get(J);return ee===void 0?void 0:o.seats.iState[ee]},{updates:X,next:Z}=Sr(y,k,V);if(y=Z,z.setSelectedSeatIds(y.keys()),K&&Y(K),X.length){let J=sn(o.seats,X);u&&u.uploadSeatStateRuns(J),j.requestRender()}},oe=()=>w!==null?w:typeof window<"u"&&!!window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,$=8,ae=k=>{if(!n.getSeatView)return null;let V=I.get(k);if(!V)for(V=Promise.resolve(n.getSeatView(k)),I.set(k,V),V.catch(()=>{I.get(k)===V&&I.delete(k)});I.size>$;){let X=I.keys().next().value;if(X===void 0)break;I.delete(X)}return V},Oe=(k,V)=>{let X=s.get(k),Z=Math.max(0,Math.round(o.seats.iFloor[V]??0)),J=e.doc.floors?.[Z],ee=o.floors[Z],ce=J?.focalPoint??e.doc.focalPoint,le=ee?{x:ee.focalWorld[0]/A,y:ee.focalWorld[2]/A}:ce,Ne=X?.focalPoint?{x:X.focalPoint.x+le.x-ce.x,y:X.focalPoint.y+le.y-ce.y}:le,De=[o.seats.iPosition[V*3],o.seats.iPosition[V*3+1],o.seats.iPosition[V*3+2]];return Fr(De,Ne,J?.baseHeightM??0,X?.eyeHeightM)},Ve=()=>(t.clientWidth||R.canvas.clientWidth)<=520,xe=null,Ie=null,Fe=async(k,V,X)=>{if(!n.getSeatView||f||X!==me.flightGen())return;let Z;try{Z=await Tr()}catch{if(r.panoramaFailed(k,"mount"),!f&&X===me.flightGen()){let J=he(k,X,!0);requestAnimationFrame(()=>J?.querySelector("[data-panorama-trigger]")?.focus())}return}if(!(f||X!==me.flightGen()||!xe))return Ie??=Z.createOpenPanorama(xe),Ie(k,V,X)},ge=kr({container:t,model:o,opts:n,expandedSeatById:s,seatIdsByRow:l,isNarrow:Ve,isDisposed:()=>f,flightGen:()=>me.flightGen(),flyToSeat:k=>In(k),openPanorama:(k,V,X)=>Fe(k,V,X)}),he=ge.show,se=ge.remove,je=ge.layout,ve=_r({container:t,orbit:C,isNarrow:Ve}),Ke=ve.element,Me=ve.setNavigationMode,Te=ve.setSeatViewLocked,xt=ve.layout,Vr=ve.utilityControls,me=Br({container:t,model:o,opts:n,orbit:C,cinematic:O,analytics:r,loop:j,labelOverlay:z,stageAzimuth:E,overviewFraming:P,gpu:()=>u,isDisposed:()=>f,panorama:()=>x,setPanorama:k=>{x=k},setPanoramaSphereVisible:k=>{N=k},panoramaLoadAbort:()=>b,setPanoramaLoadAbort:k=>{b=k},setFrozen:k=>{h=k},restorePanoramaLayer:T,reducedMotion:oe,resolvedSeatViewPose:Oe,showSectionSeatLabels:Y,setNearFieldDetailEnabled:M,setSeatViewLocked:Te,setNavigationMode:Me,showArriveChip:he,removeArriveChip:se});D=!0;let Kt=me.overviewChip,Nr=me.layoutOverviewChip,zr=me.applyFloorFocus,Gr=me.focusOverview,Rn=me.cancelFlight,In=me.flyToSeat,Fn=me.focusSectionCamera;Vr.appendChild(Kt),xe={container:t,model:o,opts:n,analytics:r,orbit:C,loop:j,seatsById:s,ensureSeatView:ae,resolvedSeatViewPose:Oe,gpu:()=>u,gl:R.gl,isContextLost:()=>p,isDisposed:()=>f,flightGen:()=>me.flightGen(),setPanorama:k=>{x=k},getLoadAbort:()=>b,setLoadAbort:k=>{b=k},setPanoramaSphereVisible:k=>{N=k},setFrozen:k=>{h=k},raisePanoramaLayer:g,restorePanoramaLayer:T,getOverviewChip:()=>Kt,labelOverlay:z,reducedMotion:oe,removeArriveChip:se,showArriveChip:he};let Ee=Lr({glctx:R,orbit:C,model:o,seats:e.seats,opts:n,cinematic:O,analytics:r,seatIdByIndex:a,sectionIdBySeatId:c,tapSlop:Xa,tapMs:Wa,gpu:()=>u,pick:()=>m,seatViewLocked:()=>ve.seatViewLocked(),focusedSectionId:()=>K,selection:()=>y,cancelFlight:Rn,focusSectionCamera:Fn,setSelection:ne,ensureSeatView:ae});R.canvas.addEventListener("pointerdown",Ee.onDown),R.canvas.addEventListener("pointermove",Ee.onMove),R.canvas.addEventListener("pointerup",Ee.onUp),R.canvas.addEventListener("pointercancel",Ee.onUp),j.requestRender();let qt={setAvailability(k){let V=Mr(y,k),X=sn(o.seats,V);X.length&&u&&u.uploadSeatStateRuns(X),j.requestRender()},setSelection:ne,flyToSeat:In,focusOverview:Gr,resize(){let{width:k,height:V}=R.resize();C.setAspect(k/Math.max(1,V)),je(),xt(),Nr(),j.requestRender()},stats(){return{...j.stats(),drawCalls:u?u.drawCalls:0,seatCount:o.seatCount}},getQualityEvidence(){let k=j.stats(),V=R.canvas.clientWidth||1,X=R.canvas.clientHeight||1,Z=o.bounds.center,J=Be(C.camera.projectionViewMatrix,[Z[0],o.bounds.box.min[1],Z[2]],V,X),ee=Be(C.camera.projectionViewMatrix,[Z[0],o.bounds.box.max[1],Z[2]],V,X),ce=o.bounds.box,le=[ce.min[0],ce.max[0]].flatMap(W=>[ce.min[1],ce.max[1]].flatMap(de=>[ce.min[2],ce.max[2]].map(Se=>Be(C.camera.projectionViewMatrix,[W,de,Se],V,X)))).filter(W=>Number.isFinite(W.x)&&Number.isFinite(W.y)&&Number.isFinite(W.depth)),Ne=le.length?(()=>{let W=Math.min(...le.map(ze=>ze.x)),de=Math.max(...le.map(ze=>ze.x)),Se=Math.min(...le.map(ze=>ze.y)),gt=Math.max(...le.map(ze=>ze.y)),nt=Math.max(0,W),vt=Math.min(V,de),we=Math.max(0,Se),ot=Math.min(X,gt),Mt=Math.max(0,vt-nt),Zt=Math.max(0,ot-we);return{box:{x:nt,y:we,width:Mt,height:Zt},horizontalFillRatio:Mt/V,verticalFillRatio:Zt/X,visibleAreaRatio:Mt*Zt/(V*X),clippedEdges:[...Se<0?["top"]:[],...de>V?["right"]:[],...gt>X?["bottom"]:[],...W<0?["left"]:[]]}})():void 0,De=String(R.gl.getParameter(R.gl.VERSION)??"");return{viewport:{width:V,height:X},context:{webgl2:/webgl\s*2/i.test(De),lost:p},frame:{rendered:k.rendered,idle:k.idle},camera:{position:[C.camera.position.x,C.camera.position.y,C.camera.position.z],distance:C.currentDistance,verticalFovDeg:C.fovY},scene:{seatCount:o.seatCount,floorCount:o.floors.length,zoneCount:o.zones.length,sectionCount:o.sections.length,authoredRelief:d,renderedVerticalSpanM:Math.max(0,o.bounds.box.max[1]-o.bounds.box.min[1]),projectedReliefPx:J.visible&&ee.visible?Math.abs(J.y-ee.y):0},labels:z.qualityEvidence(),framing:Ne}},getQualityReport(){return gn(qt.getQualityEvidence())},loseContextForTest(){R.simulateContextLossCycle()},floors(){return o.floors},focusFloor(k){if(k!==null&&!o.floors.some(X=>X.index===k))return!1;let V=k??-1;if(M(k!==null),Te(!1),zr(V),Me("orbit"),k===null)O.cancel(),oe()?C.frame(o.bounds,!1,E,n.portraitOverviewCrop===!0,P):C.frameSoft(o.bounds,E,n.portraitOverviewCrop===!0,P);else{let X=o.floors[k];if(X.seatCount>0){O.cancel();let Z=X.focalWorld[0]-X.center[0],J=X.focalWorld[2]-X.center[2],ee=Math.hypot(Z,J)>X.radius*.12?Math.atan2(Z,J):E;C.frame({center:X.center,radius:X.radius,box:X.box},!1,ee,!1,{polarDeg:58,margin:1.12})}}return j.requestRender(),!0},zones(){return o.zones},focusZone(k){let V=o.zones.find(ee=>ee.id===k);if(!V||V.seatCount===0)return!1;M(!1),Te(!1),O.cancel(),Me("orbit"),Y(null),n.onSectionFocusChange?.(null);let X=V.focalWorld[0]-V.center[0],Z=V.focalWorld[2]-V.center[2],J=Math.hypot(X,Z)>V.radius*.12?Math.atan2(X,Z):void 0;return C.frame({center:V.center,radius:V.radius*1.25},!1,J),j.requestRender(),!0},sections(){return o.sections},focusSection(k){return Fn(k)},rows(k){return k?o.rows.filter(V=>V.sectionId===k):o.rows},seatsInRow(k){return e.seats.filter(V=>V.rowId===k).map(V=>({id:V.id,label:V.displayLabel||V.label}))},focusRow(k){let V=o.rows.find(X=>X.id===k);return!V||V.seatCount===0?!1:(M(!0),Te(!1),O.cancel(),Me("pan"),V.sectionId&&(Y(V.sectionId),n.onSectionFocusChange?.(V.sectionId)),C.frame({center:V.center,radius:Math.max(2.5,V.radius*.65)}),j.requestRender(),!0)},setReducedMotionForTest(k){w=k},dispose(){f=!0,se(),Kt.remove(),Ke.remove(),Rn(),j.stop(),z.dispose(),q?.disconnect(),x&&(x.dispose(),x=null),T(),H(),R.canvas.removeEventListener("pointerdown",Ee.onDown),R.canvas.removeEventListener("pointermove",Ee.onMove),R.canvas.removeEventListener("pointerup",Ee.onUp),R.canvas.removeEventListener("pointercancel",Ee.onUp),C.dispose(),m&&m.dispose(),u&&u.dispose(),u=null,m=null,R.dispose()}};return r.opened(o.seatCount,d,e.prepared?.buildMs??performance.now()-i,e.prepared?.source??"inline"),qt}export{da as VENUE3D_QUALITY_REPORT_VERSION,bt as buildSceneModel,gn as inspectVenue3DQualityEvidence,vu as mountVenue3D,Ua as prepareVenue3D};
|
|
603
|
+
}`;function lr(t){return new We(t,{vertex:Aa,fragment:Ca,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uSeatRadius:{value:Ae},uSeatScale:{value:1},uMinPixels:{value:Ze},uPixelToWorld:{value:.002},uChairFull:{value:ct},uChairNone:{value:Qe},uFocusFloor:{value:-1}}})}function ur(t){return new We(t,{vertex:Ra,fragment:Ia,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uChairFull:{value:ct},uChairNone:{value:Qe},uBackRake:{value:rn},uBackBase:{value:_t},uFocusFloor:{value:-1}}})}function mr(t){return new We(t,{vertex:Fa,fragment:Ta,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uFocusFloor:{value:-1}}})}function dr(t){return new We(t,{vertex:ya,fragment:xa,cullFace:!1,depthTest:!0,depthWrite:!0,uniforms:{uKeyDir:{value:new Float32Array([.38,.86,.34])},uFocusFloor:{value:-1},uStructureDetail:{value:0}}})}function hr(t){return new We(t,{vertex:ga,fragment:va,transparent:!0,depthTest:!0,depthWrite:!1,cullFace:!1,uniforms:{uSeatRadius:{value:Ae},uSeatScale:{value:1},uMinPixels:{value:Ze},uPixelToWorld:{value:.002},uSeatFade:{value:0},uSeatDetail:{value:0},uFocusFloor:{value:-1},uFadeColor:{value:new Float32Array([.32,.37,.43])},uChairFull:{value:ct},uChairNone:{value:Qe}}})}function pr(t){return new We(t,{vertex:Ma,fragment:Sa,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:ct},uChairNone:{value:Qe},uBackRake:{value:rn},uBackBase:{value:_t},uFocusFloor:{value:-1}}})}function fr(t,e,n){return new We(t,{vertex:wa,fragment:Pa,depthTest:!1,depthWrite:!1,cullFace:!1,uniforms:{uTop:{value:new Float32Array(e)},uBottom:{value:new Float32Array(n)}}})}function yr(t,e,n,i,o,r){for(let a=n;a<n+i;a++){let l=r&&e[a]===0?null:o[e[a]]??o[0];t[a*3]=l?l[0]:r[a*3],t[a*3+1]=l?l[1]:r[a*3+1],t[a*3+2]=l?l[2]:r[a*3+2]}}var Ea=new Float32Array([-1,-1,1,-1,1,1,-1,-1,1,1,-1,1]),Da=new Float32Array([-1,-1,3,-1,-1,3]);function xr(t,e){let n=new br,i=new br,o=new Gt(t,{position:{size:2,data:Da}}),r=fr(t,e.theme.background.top,e.theme.background.bottom),a=new Ht(t,{geometry:o,program:r});a.frustumCulled=!1,a.setParent(i);let s=new Gt(t,{position:{size:3,data:e.solids.position},normal:{size:3,data:e.solids.normal},color:{size:3,data:e.solids.color},floorIndex:{size:1,data:e.solids.floor},materialIndex:{size:1,data:e.solids.material}}),l=dr(t),c=new Ht(t,{geometry:s,program:l});c.frustumCulled=!1,c.setParent(n);let d=hr(t),u=new Float32Array(e.seats.count*3),m=ye.map(F=>e.theme.seatStates[F]);yr(u,e.seats.iState,0,e.seats.count,m,e.seats.iCategory);let p=new Gt(t,{position:{size:2,data:Ea},iOffset:{size:3,data:e.seats.iPosition,instanced:1},iColor:{size:3,data:u,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 Ht(t,{geometry:p,program:d});h.frustumCulled=!1,e.seats.count>0&&h.setParent(n);let f=p.attributes.iColor,y=ro(),x=pr(t),b=It,S=new Float32Array(b*3),I=new Float32Array(b*3),w=new Float32Array(b),g=new Float32Array(b),T=new Float32Array(b),D=new Float32Array(b*3),_=new Float32Array(b),G=new Float32Array(b),N=new Float32Array(b),v=new Float32Array(b),M=new Gt(t,{position:{size:3,data:y.position},normal:{size:3,data:y.normal},part:{size:1,data:y.part},index:{data:y.index},iOffset:{size:3,data:S,instanced:1},iColor:{size:3,data:I,instanced:1},iRadius:{size:1,data:w,instanced:1},iYaw:{size:1,data:g,instanced:1},iGlyph:{size:1,data:T,instanced:1},iRing:{size:3,data:D,instanced:1},iFloor:{size:1,data:_,instanced:1},iPhysicalSeat:{size:1,data:G,instanced:1},iSeed:{size:1,data:v,instanced:1},iPickIndex:{size:1,data:N,instanced:1}}),R=new Ht(t,{geometry:M,program:x});R.frustumCulled=!1;let C=0,L=new Int32Array(0),E=()=>{let F=e.seats;for(let O=0;O<C;O++){let H=L[O];v[O]=ao(F.iState[H],H);let B=F.iCategory&&F.iState[H]===0?null:m[F.iState[H]]??m[0];if(B)I[O*3]=B[0],I[O*3+1]=B[1],I[O*3+2]=B[2];else{let U=Xn([F.iCategory[H*3],F.iCategory[H*3+1],F.iCategory[H*3+2]]);I[O*3]=U[0],I[O*3+1]=U[1],I[O*3+2]=U[2]}}M.attributes.iColor.needsUpdate=!0,M.attributes.iSeed.needsUpdate=!0},P={main:n,background:i,seatProgram:d,solidProgram:l,chairProgram:x,seatGeometry:p,chairGeometry:M,solidGeometry:s,drawCalls:3,setNearSeats(F,O){let H=Math.min(O,b);if(L=F,C=H,H===0){R.parent&&R.setParent(null),M.instancedCount=0,P.drawCalls=3;return}let z=e.seats;for(let B=0;B<H;B++){let U=F[B];S[B*3]=z.iPosition[U*3],S[B*3+1]=z.iPosition[U*3+1],S[B*3+2]=z.iPosition[U*3+2],w[B]=z.iChairWidth[U],g[B]=z.iYaw[U],T[B]=z.iGlyph[U],D[B*3]=z.iRing[U*3],D[B*3+1]=z.iRing[U*3+1],D[B*3+2]=z.iRing[U*3+2],_[B]=z.iFloor[U],G[B]=z.iPhysicalSeat[U],N[B]=U+1}E(),M.attributes.iOffset.needsUpdate=!0,M.attributes.iRadius.needsUpdate=!0,M.attributes.iYaw.needsUpdate=!0,M.attributes.iGlyph.needsUpdate=!0,M.attributes.iRing.needsUpdate=!0,M.attributes.iFloor.needsUpdate=!0,M.attributes.iPhysicalSeat.needsUpdate=!0,M.attributes.iSeed.needsUpdate=!0,M.attributes.iPickIndex.needsUpdate=!0,M.instancedCount=H,R.parent||R.setParent(n),P.drawCalls=4},nearSeatCount(){return C},uploadSeatStateRuns(F){if(!F.length)return;C&&E();for(let H of F)yr(u,e.seats.iState,H.start,H.length,m,e.seats.iCategory);let O=f.buffer;if(!O){f.needsUpdate=!0;return}t.bindBuffer(t.ARRAY_BUFFER,O);for(let H of F){let z=u.subarray(H.start*3,(H.start+H.length)*3);t.bufferSubData(t.ARRAY_BUFFER,H.start*3*Float32Array.BYTES_PER_ELEMENT,z)}},dispose(){o.remove(),r.remove(),s.remove(),l.remove(),p.remove(),d.remove(),M.remove(),x.remove()}};return P}import{Mesh as Mn,RenderTarget as _a,Transform as Sn}from"ogl";function ka(t,e,n){let i=t+(e<<8)+(n<<16);return i===0?-1:i-1}function gr(t,e,n,i,o,r){let a=-1,s=1/0;for(let l=0;l<n;l++)for(let c=0;c<e;c++){let d=(l*e+c)*4,u=ka(t[d],t[d+1],t[d+2]);if(u<0||u>=r)continue;let m=c-i,p=l-o,h=m*m+p*p;h<s&&(s=h,a=u)}return a}function vr(t,e,n,i,o,r){let a=t-n.left,s=e-n.top,l=Math.round(a*i),c=Math.round((n.height-s)*i);return{x:Math.max(0,Math.min(o-1,l)),y:Math.max(0,Math.min(r-1,c))}}var La=["uSeatRadius","uSeatScale","uMinPixels","uPixelToWorld"],Ut=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=lr(this.gl),this.chairProg=ur(this.gl),this.depthProg=mr(this.gl);let a=new Mn(this.gl,{geometry:n,program:this.seatProg});a.frustumCulled=!1,a.setParent(this.seatScene);let s=new Mn(this.gl,{geometry:i,program:this.chairProg});s.frustumCulled=!1,s.setParent(this.chairScene);let l=new Mn(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 La)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 _a(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),d=Math.max(0,i-o),u=Math.max(1,Math.min(s,n+o+1)-c),m=Math.max(1,Math.min(l,i+o+1)-d);r.enable(r.SCISSOR_TEST),r.scissor(c,d,u,m);let[p,h,f]=this.restoreClear;r.clearColor(0,0,0,1),this.renderer.render({scene:this.solidScene,camera:e,target:a,clear:!0}),this.renderer.render({scene:this.seatScene,camera:e,target:a,clear:!1}),this.renderer.render({scene:this.chairScene,camera:e,target:a,clear:!1}),r.clearColor(p,h,f,1),r.disable(r.SCISSOR_TEST);let y=new Uint8Array(u*m*4);return this.renderer.bindFramebuffer(a),r.readPixels(c,d,u,m,r.RGBA,r.UNSIGNED_BYTE,y),this.renderer.bindFramebuffer(),gr(y,u,m,n-c,i-d,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,st(i.state)):n.push(i);return n}function Sr(t,e,n){let i=new Set;for(let a of e)(t.has(a)||n(a)!==void 0)&&i.add(a);let o=new Map(t),r=[];for(let[a,s]of t)i.has(a)||(r.push({seatId:a,state:ye[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 yt,Vec3 as Va}from"ogl";function Ba(t,e){return[t[0]-e[0],t[1]-e[1],t[2]-e[2]]}function wr(t,e){return[t[0]+e[0],t[1]+e[1],t[2]+e[2]]}function Oa(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 wn(t){let e=Math.max(0,Math.min(1,t));return e*e*e*(e*(e*6-15)+10)}function Pn(t,e){return Math.max(0,Math.min(1,t+e))}function Ar(t,e){let n=t.length;if(n===0)return[0,0,0];if(n===1)return[...t[0]];let i=Math.max(0,Math.min(1,e)),o=n-1,r=Math.floor(i*o);r>=o&&(r=o-1);let a=i*o-r,s=t[Math.max(0,r-1)],l=t[r],c=t[r+1],d=t[Math.min(n-1,r+2)],u=a*a,m=u*a,p=[0,0,0];for(let h=0;h<3;h++)p[h]=.5*(2*l[h]+(-s[h]+c[h])*a+(2*s[h]-5*l[h]+4*c[h]-d[h])*u+(-s[h]+3*l[h]-3*c[h]+d[h])*m);return p}function An(t,e,n,i,o){let r=Pr(Ba(e,n));r[0]===0&&r[1]===0&&r[2]===0&&(r=[0,0,1]);let a=wr(wr(e,Oa(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),d=[i[0]+l[0]*c*1.3,i[1]+c*.75,i[2]+l[2]*c*1.3];return{waypoints:[t,d,a],finalPos:a}}function Cn(t,e,n=35,i=28){let o=wn(e),r=Ar(t,o),a=wn(Math.max(0,Math.min(1,(e-.66)/.34)));return{pos:r,fov:n+(i-n)*a,eased:o}}function Ir(t,e,n){let i=t.position.clone(),o=new yt().copy(t.quaternion);t.position.set(e[0],e[1],e[2]),t.lookAt(new Va(n[0],n[1],n[2]));let r=new yt().copy(t.quaternion);return t.position.copy(i),t.quaternion.copy(o),r}var Yt=class{constructor(e){this.active=!1;this.waypoints=[];this.startQuat=new yt;this.endQuat=new yt;this.outQuat=new yt;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}=Cn(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,Pn(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 Na=1.02,za=1.5;function Fr(t,e,n=0,i){let o=Number.isFinite(i)?n+i:t[1]+Na;return{eye:[t[0],o,t[2]],focal:[e.x*A,n+za,e.y*A]}}var Rn=null;function Tr(){return Rn??=import("../openPanorama-ALLZ6ADE.js").catch(t=>{throw Rn=null,t}),Rn}var Er=()=>typeof performance<"u"&&performance.now?performance.now():Date.now(),Xt=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=Er(),this.emit("3d_panorama_opened")}panoramaClosed(){let e=this.panoramaOpenedAt?Math.round(Er()-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 Dr(t){let e=t.style.position;return getComputedStyle(t).position!=="static"?()=>{}:(t.style.position="relative",()=>{t.style.position==="relative"&&(t.style.position=e)})}function kr(t){let{container:e,model:n,opts:i,expandedSeatById:o,seatIdsByRow:r,isNarrow:a}=t,s=null,l=()=>{if(!s)return;let u=a();Object.assign(s.style,u?{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:(u,m,p=!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 f=o.get(u),y=f?.sectionId?n.sections.find(D=>D.id===f.sectionId):void 0,x=f?.label??u;h.setAttribute("aria-label",`Explore views near ${y?.label?`${y.label}, `:""}seat ${x}`);let b=document.createElement("span");b.textContent=["Live 3D seat view",y?.label,x].filter(Boolean).join(" \xB7 "),Object.assign(b.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(b);let S=document.createElement("div");Object.assign(S.style,{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px"}),h.appendChild(S);let I=f?.rowId?r.get(f.rowId):void 0,w=I?.indexOf(u)??-1,g=w>=0?[I?.[w-1],I?.[w+1]]:[void 0,void 0],T=(D,_,G,N=!1)=>{let v=document.createElement("button");v.type="button",v.textContent=D,v.setAttribute("aria-label",_),Object.assign(v.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||(v.style.minWidth="44px"),N&&(v.dataset.panoramaTrigger=""),v.addEventListener("click",G),S.appendChild(v)};if(g[0]){let D=o.get(g[0])?.label??g[0];T("\u2039",`View previous seat ${D}`,()=>{t.flyToSeat(g[0])})}if(i.getSeatView){let D=i.seatViewActionLabel?.(u)??"Open 360\xB0 panorama";T(p?`\u21BB Retry ${D}`:`\u25C9 ${D}`,`${p?"Retry":D} from seat ${x}`,()=>{if(t.isDisposed()||m!==t.flightGen()){c();return}c(),t.openPanorama(u,400,m)},!0)}if(g[1]){let D=o.get(g[1])?.label??g[1];T("\u203A",`View next seat ${D}`,()=>{t.flyToSeat(g[1])})}return S.childElementCount?(e.appendChild(h),s=h,l(),h):null},remove:c,layout:l}}function _r(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 d=document.createElement("button");d.type="button",d.textContent="\u2212",d.setAttribute("aria-label","Zoom out of the 3D venue"),d.dataset.tooltip="Zoom out";let u=document.createElement("button");u.type="button",u.textContent="+",u.setAttribute("aria-label","Zoom into the 3D venue"),u.dataset.tooltip="Zoom in";for(let f of[l,c,d,u])f.className="sl-3d-icon-control",Object.assign(f.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(u,d);let m=f=>{n.setPrimaryDragMode(f);let y=f==="orbit";l.setAttribute("aria-pressed",String(y)),c.setAttribute("aria-pressed",String(!y)),l.style.background=y?"rgba(96,110,150,0.68)":"rgba(12,18,32,0.82)",c.style.background=y?"rgba(12,18,32,0.82)":"rgba(96,110,150,0.68)",o.title=y?"Drag to rotate \xB7 Shift-drag to move":"Drag to move \xB7 Shift-drag to rotate"};l.addEventListener("click",()=>m("orbit")),c.addEventListener("click",()=>m("pan")),d.addEventListener("click",()=>n.zoomBy(1.22)),u.addEventListener("click",()=>n.zoomBy(.82)),o.append(a,s),m("orbit"),e.appendChild(o);let p=()=>{let f=i();o.style.display=r?"none":"flex",o.style.right=f?"12px":"14px",o.style.bottom=f?"calc(env(safe-area-inset-bottom, 0px) + 76px)":"14px",a.style.display=f?"none":"flex",u.style.display=f?"none":"",d.style.display=f?"none":""};return p(),{element:o,utilityControls:s,setNavigationMode:m,setSeatViewLocked:f=>{r=f,n.setInteractionEnabled(!f),p()},seatViewLocked:()=>r,layout:p}}function Lr(t){let{glctx:e,orbit:n,model:i,seats:o,opts:r,cinematic:a,analytics:s,seatIdByIndex:l,sectionIdBySeatId:c,tapSlop:d,tapMs:u,cancelFlight:m,focusSectionCamera:p,setSelection:h,ensureSeatView:f}=t,y=0,x=0,b=0,S=-1,I=!1,w=!1,g=N=>{t.seatViewLocked()||S===-1&&(S=N.pointerId,y=N.clientX,x=N.clientY,b=performance.now(),I=!1,w=a.active,a.active&&(s.cinematicCancelled(),m(),r.onViewTargetChange?.(null)))},T=N=>{N.pointerId===S&&Math.hypot(N.clientX-y,N.clientY-x)>d&&(I=!0)},D=(N,v,M,R,C)=>{let L=e.canvas.getBoundingClientRect(),E=e.canvas.clientWidth||L.width||1,P=e.canvas.clientHeight||L.height||1,F=N-L.left,O=v-L.top,H=R*R,z=-1,B=H,U=1/0;for(let K of o){if(M&&K.sectionId!==M)continue;let Y=i.seats.idToIndex.get(K.id);if(Y===void 0)continue;if(C){let ae=Math.round(i.seats.iState[Y]??0);if(ae!==0&&ae!==3)continue}let j=Y*3,q=Be(n.camera.projectionViewMatrix,[i.seats.iPosition[j],i.seats.iPosition[j+1]+.55,i.seats.iPosition[j+2]],E,P);if(!q.visible)continue;let ne=q.x-F,oe=q.y-O,$=ne*ne+oe*oe;($<B||Math.abs($-B)<1&&q.depth<U)&&(z=Y,B=$,U=q.depth)}return z},_=(N,v)=>{let M=t.gpu(),R=t.pick();if(!M||!R)return-1;R.syncFromSeatProgram(M.seatProgram);let C=e.canvas.getBoundingClientRect(),L=e.renderer.dpr,{x:E,y:P}=vr(N,v,C,L,e.gl.drawingBufferWidth,e.gl.drawingBufferHeight),F=Math.max(2,Math.round(8*L));return R.pick(n.camera,E,P,F)};return{onDown:g,onMove:T,onUp:N=>{if(N.pointerId!==S)return;let v=!I&&performance.now()-b<u;if(S=-1,w){w=!1;return}let M=t.gpu(),R=t.pick();if(!v||!M||!R)return;let C=_(N.clientX,N.clientY);if(t.focusedSectionId()&&C>=0){let P=l[C],F=P?c.get(P):void 0;if(F&&F!==t.focusedSectionId()&&p(F))return}if(t.focusedSectionId()&&C<0&&(C=D(N.clientX,N.clientY,t.focusedSectionId(),44,!1)),t.focusedSectionId()&&C<0){let P=D(N.clientX,N.clientY,null,72,!1),F=P>=0?l[P]:void 0,O=F?c.get(F):void 0;if(O&&O!==t.focusedSectionId()&&p(O))return}if(!t.focusedSectionId()){C<0&&(C=D(N.clientX,N.clientY,null,42,!1));let P=C>=0?l[C]:void 0,F=P?c.get(P):void 0;if(F&&p(F))return}if(C<0||C>=l.length){t.selection().size&&(h([]),r.onViewTargetChange?.(null));return}let L=l[C],E=ye[Math.round(i.seats.iState[C]??0)]??"available";if(E!=="available"&&E!=="selected"){r.onSeatInspect?.(L,E);return}if(t.selection().has(L)&&t.selection().size===1){h([]),r.onViewTargetChange?.(null);return}h([L]),f(L),s.seatPicked(L,c.get(L)),r.onSeatPick?.(L)}}}var Wt=class{constructor(e,n){this.minX=0;this.minZ=0;this.cell=1;this.cols=1;this.rows=1;this.cellStart=null;this.cellItems=null;this.iPosition=e,this.count=n}ensureGrid(){if(this.cellStart||this.count===0)return;let e=this.iPosition,n=1/0,i=1/0,o=-1/0,r=-1/0;for(let p=0;p<this.count;p++){let h=e[p*3],f=e[p*3+2];h<n&&(n=h),h>o&&(o=h),f<i&&(i=f),f>r&&(r=f)}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),d=p=>{let h=Math.min(this.cols-1,Math.max(0,Math.floor((e[p*3]-n)/this.cell)));return Math.min(this.rows-1,Math.max(0,Math.floor((e[p*3+2]-i)/this.cell)))*this.cols+h};for(let p=0;p<this.count;p++)c[d(p)+1]++;for(let p=0;p<l;p++)c[p+1]+=c[p];let u=new Int32Array(this.count),m=c.slice(0,l);for(let p=0;p<this.count;p++)u[m[d(p)]++]=p;this.cellStart=c,this.cellItems=u}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),d=Math.floor((n-this.minZ)/this.cell),u=Math.ceil(i/this.cell)+1,m=this.iPosition,p=0;for(let h=0;h<=u&&p<s;h++){let f=d-h,y=d+h,x=c-h,b=c+h;for(let S=f;S<=y&&p<s;S++){if(S<0||S>=this.rows)continue;let I=S===f||S===y;for(let w=x;w<=b&&p<s;w++){if(!I&&w!==x&&w!==b){w=b-1;continue}if(w<0||w>=this.cols)continue;let g=S*this.cols+w;for(let T=r[g],D=r[g+1];T<D&&p<s;T++){let _=a[T],G=m[_*3]-e,N=m[_*3+2]-n;G*G+N*N<=l&&(o[p++]=_)}}}}return p}};var jt=class{constructor(e){this.ctx=e;this.detailVisible=!1;this.seatDetailMix=0;this.structureDetailMix=0;this.nearBuf=new Int32Array(It);this.lastGatherX=1/0;this.lastGatherZ=1/0;this.nearIndex=new Wt(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)<nn)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>tn){i.nearSeatCount()&&i.setNearSeats(this.nearBuf,0);return}let s=this.nearIndex.gather(o.x,o.z,tn,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 Ga,Vec3 as Ha}from"ogl";function Br(t){let{container:e,model:n,opts:i,orbit:o,cinematic:r,analytics:a,loop:s,labelOverlay:l,stageAzimuth:c,overviewFraming:d}=t,u=0,m=-1,p=(w,g,T=28)=>{o.camera.position.set(w[0],w[1],w[2]),o.camera.lookAt(new Ha(g[0],g[1],g[2])),o.camera.fov=T,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 f=()=>{h.textContent="\u2302"};f();let y=w=>{m=w;let g=t.gpu();g&&(g.seatProgram.uniforms.uFocusFloor.value=w,g.solidProgram.uniforms.uFocusFloor.value=w,g.chairProgram.uniforms.uFocusFloor.value=w),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 w=m>=0?n.floors[m]:null;if(t.setNearFieldDetailEnabled(!!w),t.setSeatViewLocked(!1),b(),t.removeArriveChip(),t.setNavigationMode("orbit"),w){let g=w.focalWorld[0]-w.center[0],T=w.focalWorld[2]-w.center[2],D=Math.hypot(g,T)>w.radius*.12?Math.atan2(g,T):c,_={center:w.center,radius:w.radius,box:w.box},G={polarDeg:58,margin:1.12};t.reducedMotion()?o.frame(_,!1,D,!1,G):o.frameSoft(_,D,!1,G)}else t.reducedMotion()?o.frame(n.bounds,!1,c,i.portraitOverviewCrop===!0,d):o.frameSoft(n.bounds,c,i.portraitOverviewCrop===!0,d);t.showSectionSeatLabels(null),s.requestRender()},b=()=>{u++,t.panoramaLoadAbort()?.abort(),t.setPanoramaLoadAbort(null),r.active&&(r.cancel(),o.resumeAfterFlight(n.focalWorld))},S=w=>{if(t.isDisposed()||!t.gpu())return Promise.resolve();let g=n.seats.idToIndex.get(w);if(g===void 0)return Promise.resolve();t.setNearFieldDetailEnabled(!0),i.onViewTargetChange?.(w),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 T=++u;t.removeArriveChip();let{eye:D,focal:_}=t.resolvedSeatViewPose(w,g),G=[o.camera.position.x,o.camera.position.y,o.camera.position.z],N=An(G,D,_,n.bounds.center,n.bounds.radius),v=i.arriveAtSeatEye?D:N.finalPos,M=i.arriveAtSeatEye?e.clientWidth/Math.max(1,e.clientHeight)<.7?90:65:28,R=[N.waypoints[0],N.waypoints[1],v];if(l.setVisible(!1),t.reducedMotion())return p(v,_,M),s.requestRender(),a.cinematicSkipped(),t.isDisposed()||o.syncFromCamera(),t.setSeatViewLocked(i.arriveAtSeatEye===!0),t.showArriveChip(w,T),Promise.resolve();let C=new Ga().copy(o.camera.quaternion),L=Ir(o.camera,v,_);return s.requestRender(),r.start(R,C,L,2500,M).then(()=>{t.isDisposed()||T!==u||(a.cinematicPlayed(2500),o.resumeAfterFlight(_),t.setSeatViewLocked(i.arriveAtSeatEye===!0),s.requestRender(),t.showArriveChip(w,T))})},I=w=>{let g=n.sections.find(G=>G.id===w);if(!g||g.seatCount===0)return!1;t.setNearFieldDetailEnabled(!0),t.setSeatViewLocked(!1),r.cancel(),t.removeArriveChip(),n.floors.length>1&&m!==g.floorIndex&&y(g.floorIndex),t.setNavigationMode("pan"),t.showSectionSeatLabels(w);let T=g.focalWorld[0]-g.center[0],D=g.focalWorld[2]-g.center[2],_=Math.hypot(T,D)>g.radius*.12?Math.atan2(T,D):void 0;return o.frame({center:g.center,radius:Math.max(5,g.radius*.5)},!1,_),i.onSectionFocusChange?.(w),s.requestRender(),!0};return h.addEventListener("click",x),{overviewChip:h,layoutOverviewChip:f,flightGen:()=>u,focusedFloor:()=>m,applyFloorFocus:y,placeCameraFinal:p,cancelFlight:b,focusOverview:x,flyToSeat:S,focusSectionCamera:I}}function Or(t){let e=performance.now();return{model:bt(t),buildMs:performance.now()-e,source:"main"}}function Ua(t){return typeof Worker>"u"?Promise.resolve(Or(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(Or(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 vu(t,e,n={}){let i=performance.now(),o=e.prepared?.model??bt(e),r=new Xt(n.onAnalytics),a=new Array(o.seats.count);for(let[k,V]of o.seats.idToIndex)a[V]=k;let s=new Map(e.seats.map(k=>[k.id,k])),l=new Map;for(let k of e.seats){if(!k.rowId)continue;let V=l.get(k.rowId);V?V.push(k.id):l.set(k.rowId,[k.id])}let c=new Map;for(let k of e.seats)c.set(k.id,k.sectionId);let d=e.doc.floors?.some(V=>(V.baseHeightM??0)>0)?!0:(e.doc.floors?.flatMap(V=>V.objects)??e.doc.objects).some(V=>V.type==="section"&&((V.height??0)>0||(V.rake??0)>0)),u=null,m=null,p=!1,h=!1,f=!1,y=new Map,x=null,b=null,S=null,I=new Map,w=null,g=()=>{S===null&&(S=t.style.zIndex,t.style.zIndex="20")},T=()=>{S!==null&&(t.style.zIndex==="20"&&(t.style.zIndex=S),S=null)},D=!1,_=()=>D?me.focusedFloor():-1,G=()=>{u=xr(R.gl,o),m=new Ut(R.renderer,u.seatGeometry,u.chairGeometry,u.solidGeometry,o.seats.count),R.setClearColor(o.theme.background.top),m.setRestoreClear(o.theme.background.top),u.seatProgram.uniforms.uSeatRadius.value=Ae*o.theme.seatScale,u.seatProgram.uniforms.uFocusFloor.value=_(),u.solidProgram.uniforms.uFocusFloor.value=_(),u.chairProgram.uniforms.uFocusFloor.value=_(),v.forceRegather()},N=!1,v=new jt({model:o,orbit:()=>C,gpu:()=>u}),M=k=>v.setDetailEnabled(k),R=new At(t,{onContextLost:()=>{f||r.contextLost(),p=!0,j.stop(),u=null,m=null},onContextRestored:()=>{G(),p=!1,f||r.contextRestored(),j.requestRender()}}),C=new Ct(R.gl,R.canvas,()=>j.requestRender(),()=>r.orbitEngaged());C.setAspect(R.aspect);let L=(e.doc.floors?.flatMap(k=>k.objects)??e.doc.objects).some(k=>k.type==="section"&&k.physical3dProvenance?.surfaceKind?.status==="inferred"),E=(()=>{if(L&&o.stages.length===0)return;let k=o.focalWorld[0]-o.bounds.center[0],V=o.focalWorld[2]-o.bounds.center[2];return Math.hypot(k,V)>o.bounds.radius*.12?Math.atan2(k,V):void 0})(),P=o.floors.length>1?{polarDeg:48,margin:1.1}:void 0,F=typeof window<"u"&&!!window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;C.frame(o.bounds,!F&&n.skipInitialOverviewAnimation!==!0,E,n.portraitOverviewCrop===!0,P);let O=new Yt(C.camera),H=Dr(t),z=new Nt(t,{fontFamily:e.doc.theme?.fontFamily,ink:e.doc.theme?.textColor,backgroundRgb:o.theme.background.top}),B=o.labels,U=()=>Ho(B,o.floors.length,_());z.setLabels(U());let K=null,Y=k=>{if(K=k,z.setForcedDense(!!k),!k){z.setLabels(U());return}let V=e.seats.filter(W=>W.sectionId===k),X=new Set(V.map(W=>W.id)),Z=new Set(V.map(W=>W.rowId)),J=new Set(y.keys()),ee=new Set(V.filter(W=>J.has(W.id)).map(W=>W.id)),ce=U().filter(W=>W.kind!=="row"&&W.kind!=="seat"||(W.kind==="row"?Z.has(W.id.slice(4)):X.has(W.id.slice(5))&&(ee.size===0||ee.has(W.id.slice(5)))));if(o.seatCount<=6e3&&ee.size===0){z.setLabels(ce);return}let le=ee.size?V.filter(W=>ee.has(W.id)):V,Ne=new Set(le.map(W=>`seat:${W.id}`)),De=le.flatMap(W=>{let de=o.seats.idToIndex.get(W.id);if(de===void 0)return[];let Se=de*3;return[{id:`seat:${W.id}`,kind:"seat",text:W.displayLabel||W.label,anchor:[o.seats.iPosition[Se],o.seats.iPosition[Se+1]+(J.has(W.id)?1.05:.55),o.seats.iPosition[Se+2]]}]});z.setLabels([...ce.filter(W=>!Ne.has(W.id)),...De])};G();let j=new Rt(k=>{if(p||!u||h)return!1;let X=O.active?O.update(performance.now()):C.update(),Z=_()>=0?o.floors[_()]:null,J=Z?.radius??o.bounds.radius,ee=$n(C.currentDistance,J),ce=N?{center:[C.camera.position.x,C.camera.position.y,C.camera.position.z],radius:520}:o.renderBounds;C.updateClipping(ce);let le=Z?.center??o.renderBounds.center,Ne=Z?.radius??o.renderBounds.radius,De=(we,ot)=>Math.hypot(C.camera.position.x-we[0],C.camera.position.y-we[1],C.camera.position.z-we[2])<=ot*(v.detailVisible?1.8:1.55),W=De(le,Ne);if(!W&&K){let we=o.sections.find(ot=>ot.id===K);we&&(W=De(we.center,Math.max(12,we.radius*2)))}v.detailVisible=W;let de=u.seatProgram.uniforms;de.uSeatScale.value=ee.scale,de.uSeatFade.value=ee.fade;let Se=!!Z&&Jn(Z.seatCount,R.canvas.clientWidth||1,R.canvas.clientHeight||1),gt=eo(o.seats.count,J,C.currentDistance,C.camera.fov,R.canvas.clientHeight||1),nt=v.detailVisible||Se||gt?1:0,vt=v.detailVisible||_()>=0||o.floors.length>1?1:0;return v.ease(k,nt,vt),de.uSeatDetail.value=v.seatDetailMix,u.solidProgram.uniforms.uStructureDetail.value=v.structureDetailMix,de.uMinPixels.value=ee.minPixels,de.uPixelToWorld.value=2*Math.tan(C.camera.fov*Ya/2)/Math.max(1,R.pixelHeight),v.update(v.detailVisible),R.renderer.render({scene:u.background,clear:!0}),R.renderer.render({scene:u.main,camera:C.camera,clear:!1}),z.update(C.camera.projectionViewMatrix,R.canvas.clientWidth||1,R.canvas.clientHeight||1,C.currentDistance,J,[C.camera.position.x,C.camera.position.y,C.camera.position.z]),X||v.seatDetailMix!==nt||v.structureDetailMix!==vt}),q=typeof ResizeObserver<"u"?new ResizeObserver(()=>qt.resize()):null;q?.observe(t);let ne=k=>{let V=J=>{let ee=o.seats.idToIndex.get(J);return ee===void 0?void 0:o.seats.iState[ee]},{updates:X,next:Z}=Sr(y,k,V);if(y=Z,z.setSelectedSeatIds(y.keys()),K&&Y(K),X.length){let J=sn(o.seats,X);u&&u.uploadSeatStateRuns(J),j.requestRender()}},oe=()=>w!==null?w:typeof window<"u"&&!!window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,$=8,ae=k=>{if(!n.getSeatView)return null;let V=I.get(k);if(!V)for(V=Promise.resolve(n.getSeatView(k)),I.set(k,V),V.catch(()=>{I.get(k)===V&&I.delete(k)});I.size>$;){let X=I.keys().next().value;if(X===void 0)break;I.delete(X)}return V},Oe=(k,V)=>{let X=s.get(k),Z=Math.max(0,Math.round(o.seats.iFloor[V]??0)),J=e.doc.floors?.[Z],ee=o.floors[Z],ce=J?.focalPoint??e.doc.focalPoint,le=ee?{x:ee.focalWorld[0]/A,y:ee.focalWorld[2]/A}:ce,Ne=X?.focalPoint?{x:X.focalPoint.x+le.x-ce.x,y:X.focalPoint.y+le.y-ce.y}:le,De=[o.seats.iPosition[V*3],o.seats.iPosition[V*3+1],o.seats.iPosition[V*3+2]];return Fr(De,Ne,J?.baseHeightM??0,X?.eyeHeightM)},Ve=()=>(t.clientWidth||R.canvas.clientWidth)<=520,xe=null,Ie=null,Fe=async(k,V,X)=>{if(!n.getSeatView||f||X!==me.flightGen())return;let Z;try{Z=await Tr()}catch{if(r.panoramaFailed(k,"mount"),!f&&X===me.flightGen()){let J=he(k,X,!0);requestAnimationFrame(()=>J?.querySelector("[data-panorama-trigger]")?.focus())}return}if(!(f||X!==me.flightGen()||!xe))return Ie??=Z.createOpenPanorama(xe),Ie(k,V,X)},ge=kr({container:t,model:o,opts:n,expandedSeatById:s,seatIdsByRow:l,isNarrow:Ve,isDisposed:()=>f,flightGen:()=>me.flightGen(),flyToSeat:k=>Fn(k),openPanorama:(k,V,X)=>Fe(k,V,X)}),he=ge.show,se=ge.remove,je=ge.layout,ve=_r({container:t,orbit:C,isNarrow:Ve}),Ke=ve.element,Me=ve.setNavigationMode,Te=ve.setSeatViewLocked,xt=ve.layout,Vr=ve.utilityControls,me=Br({container:t,model:o,opts:n,orbit:C,cinematic:O,analytics:r,loop:j,labelOverlay:z,stageAzimuth:E,overviewFraming:P,gpu:()=>u,isDisposed:()=>f,panorama:()=>x,setPanorama:k=>{x=k},setPanoramaSphereVisible:k=>{N=k},panoramaLoadAbort:()=>b,setPanoramaLoadAbort:k=>{b=k},setFrozen:k=>{h=k},restorePanoramaLayer:T,reducedMotion:oe,resolvedSeatViewPose:Oe,showSectionSeatLabels:Y,setNearFieldDetailEnabled:M,setSeatViewLocked:Te,setNavigationMode:Me,showArriveChip:he,removeArriveChip:se});D=!0;let Kt=me.overviewChip,Nr=me.layoutOverviewChip,zr=me.applyFloorFocus,Gr=me.focusOverview,In=me.cancelFlight,Fn=me.flyToSeat,Tn=me.focusSectionCamera;Vr.appendChild(Kt),xe={container:t,model:o,opts:n,analytics:r,orbit:C,loop:j,seatsById:s,ensureSeatView:ae,resolvedSeatViewPose:Oe,gpu:()=>u,gl:R.gl,isContextLost:()=>p,isDisposed:()=>f,flightGen:()=>me.flightGen(),setPanorama:k=>{x=k},getLoadAbort:()=>b,setLoadAbort:k=>{b=k},setPanoramaSphereVisible:k=>{N=k},setFrozen:k=>{h=k},raisePanoramaLayer:g,restorePanoramaLayer:T,getOverviewChip:()=>Kt,labelOverlay:z,reducedMotion:oe,removeArriveChip:se,showArriveChip:he};let Ee=Lr({glctx:R,orbit:C,model:o,seats:e.seats,opts:n,cinematic:O,analytics:r,seatIdByIndex:a,sectionIdBySeatId:c,tapSlop:Xa,tapMs:Wa,gpu:()=>u,pick:()=>m,seatViewLocked:()=>ve.seatViewLocked(),focusedSectionId:()=>K,selection:()=>y,cancelFlight:In,focusSectionCamera:Tn,setSelection:ne,ensureSeatView:ae});R.canvas.addEventListener("pointerdown",Ee.onDown),R.canvas.addEventListener("pointermove",Ee.onMove),R.canvas.addEventListener("pointerup",Ee.onUp),R.canvas.addEventListener("pointercancel",Ee.onUp),j.requestRender();let qt={setAvailability(k){let V=Mr(y,k),X=sn(o.seats,V);X.length&&u&&u.uploadSeatStateRuns(X),j.requestRender()},setSelection:ne,flyToSeat:Fn,focusOverview:Gr,resize(){let{width:k,height:V}=R.resize();C.setAspect(k/Math.max(1,V)),je(),xt(),Nr(),j.requestRender()},stats(){return{...j.stats(),drawCalls:u?u.drawCalls:0,seatCount:o.seatCount}},getQualityEvidence(){let k=j.stats(),V=R.canvas.clientWidth||1,X=R.canvas.clientHeight||1,Z=o.bounds.center,J=Be(C.camera.projectionViewMatrix,[Z[0],o.bounds.box.min[1],Z[2]],V,X),ee=Be(C.camera.projectionViewMatrix,[Z[0],o.bounds.box.max[1],Z[2]],V,X),ce=o.bounds.box,le=[ce.min[0],ce.max[0]].flatMap(W=>[ce.min[1],ce.max[1]].flatMap(de=>[ce.min[2],ce.max[2]].map(Se=>Be(C.camera.projectionViewMatrix,[W,de,Se],V,X)))).filter(W=>Number.isFinite(W.x)&&Number.isFinite(W.y)&&Number.isFinite(W.depth)),Ne=le.length?(()=>{let W=Math.min(...le.map(ze=>ze.x)),de=Math.max(...le.map(ze=>ze.x)),Se=Math.min(...le.map(ze=>ze.y)),gt=Math.max(...le.map(ze=>ze.y)),nt=Math.max(0,W),vt=Math.min(V,de),we=Math.max(0,Se),ot=Math.min(X,gt),Mt=Math.max(0,vt-nt),Zt=Math.max(0,ot-we);return{box:{x:nt,y:we,width:Mt,height:Zt},horizontalFillRatio:Mt/V,verticalFillRatio:Zt/X,visibleAreaRatio:Mt*Zt/(V*X),clippedEdges:[...Se<0?["top"]:[],...de>V?["right"]:[],...gt>X?["bottom"]:[],...W<0?["left"]:[]]}})():void 0,De=String(R.gl.getParameter(R.gl.VERSION)??"");return{viewport:{width:V,height:X},context:{webgl2:/webgl\s*2/i.test(De),lost:p},frame:{rendered:k.rendered,idle:k.idle},camera:{position:[C.camera.position.x,C.camera.position.y,C.camera.position.z],distance:C.currentDistance,verticalFovDeg:C.fovY},scene:{seatCount:o.seatCount,floorCount:o.floors.length,zoneCount:o.zones.length,sectionCount:o.sections.length,authoredRelief:d,renderedVerticalSpanM:Math.max(0,o.bounds.box.max[1]-o.bounds.box.min[1]),projectedReliefPx:J.visible&&ee.visible?Math.abs(J.y-ee.y):0},labels:z.qualityEvidence(),framing:Ne}},getQualityReport(){return vn(qt.getQualityEvidence())},loseContextForTest(){R.simulateContextLossCycle()},floors(){return o.floors},focusFloor(k){if(k!==null&&!o.floors.some(X=>X.index===k))return!1;let V=k??-1;if(M(k!==null),Te(!1),zr(V),Me("orbit"),k===null)O.cancel(),oe()?C.frame(o.bounds,!1,E,n.portraitOverviewCrop===!0,P):C.frameSoft(o.bounds,E,n.portraitOverviewCrop===!0,P);else{let X=o.floors[k];if(X.seatCount>0){O.cancel();let Z=X.focalWorld[0]-X.center[0],J=X.focalWorld[2]-X.center[2],ee=Math.hypot(Z,J)>X.radius*.12?Math.atan2(Z,J):E;C.frame({center:X.center,radius:X.radius,box:X.box},!1,ee,!1,{polarDeg:58,margin:1.12})}}return j.requestRender(),!0},zones(){return o.zones},focusZone(k){let V=o.zones.find(ee=>ee.id===k);if(!V||V.seatCount===0)return!1;M(!1),Te(!1),O.cancel(),Me("orbit"),Y(null),n.onSectionFocusChange?.(null);let X=V.focalWorld[0]-V.center[0],Z=V.focalWorld[2]-V.center[2],J=Math.hypot(X,Z)>V.radius*.12?Math.atan2(X,Z):void 0;return C.frame({center:V.center,radius:V.radius*1.25},!1,J),j.requestRender(),!0},sections(){return o.sections},focusSection(k){return Tn(k)},rows(k){return k?o.rows.filter(V=>V.sectionId===k):o.rows},seatsInRow(k){return e.seats.filter(V=>V.rowId===k).map(V=>({id:V.id,label:V.displayLabel||V.label}))},focusRow(k){let V=o.rows.find(X=>X.id===k);return!V||V.seatCount===0?!1:(M(!0),Te(!1),O.cancel(),Me("pan"),V.sectionId&&(Y(V.sectionId),n.onSectionFocusChange?.(V.sectionId)),C.frame({center:V.center,radius:Math.max(2.5,V.radius*.65)}),j.requestRender(),!0)},setReducedMotionForTest(k){w=k},dispose(){f=!0,se(),Kt.remove(),Ke.remove(),In(),j.stop(),z.dispose(),q?.disconnect(),x&&(x.dispose(),x=null),T(),H(),R.canvas.removeEventListener("pointerdown",Ee.onDown),R.canvas.removeEventListener("pointermove",Ee.onMove),R.canvas.removeEventListener("pointerup",Ee.onUp),R.canvas.removeEventListener("pointercancel",Ee.onUp),C.dispose(),m&&m.dispose(),u&&u.dispose(),u=null,m=null,R.dispose()}};return r.opened(o.seatCount,d,e.prepared?.buildMs??performance.now()-i,e.prepared?.source??"inline"),qt}export{da as VENUE3D_QUALITY_REPORT_VERSION,bt as buildSceneModel,vn as inspectVenue3DQualityEvidence,vu as mountVenue3D,Ua as prepareVenue3D};
|