@seatlayer/core 0.70.0 → 0.71.2

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.
@@ -1,12 +1,12 @@
1
- import{a as Jn,c as eo,d as to}from"../chunk-7OJ6SB6V.js";import{c as Xn}from"../chunk-UHPX2P7O.js";import{d as $n}from"../chunk-T2LWVOQ3.js";import{e as Hn,o as Kn,q as Dt,r as Ye,t as mt}from"../chunk-AWPHGLTU.js";import{e as Zn,k as Qn}from"../chunk-UL5OIGIF.js";import{W as Be,X as Ne,ea as Ft,ga as Wn,ha as _t,ja as jn,l as Yn,m as lt,va as sn}from"../chunk-X3K36XZM.js";import{d as ee,k as qn,x as ye,z as ut}from"../chunk-CXF32VPG.js";import"../chunk-CRCGO52K.js";import{Renderer as wi}from"ogl";var we=["available","held","sold","selected","dimmed"];function dt(e){let t=we.indexOf(e);return t<0?0:t}var no={available:[.24,.82,.52],held:[.95,.66,.22],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};function oo(e){let t=.2126*e[0]+.7152*e[1]+.0722*e[2],n=.42,r=.62;return[(t+(e[0]-t)*n)*r,(t+(e[1]-t)*n)*r,(t+(e[2]-t)*n)*r]}var cn={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]},We={top:[.05,.06,.08],bottom:[.1,.12,.15]};function ge(e,t){return[Math.min(1,e[0]*t),Math.min(1,e[1]*t),Math.min(1,e[2]*t)]}function Pi(){let e=typeof window<"u"&&window.devicePixelRatio||1,t=navigator.deviceMemory,n=typeof t=="number"&&t<=4?1.5:2;return Math.min(e,n)}var kt=class{constructor(t,n){this.clearRgb=[0,0,0];this.container=t,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 wi({canvas:this.canvas,dpr:Pi(),alpha:!1,antialias:!1,depth:!0,stencil:!1,powerPreference:"high-performance",webgl:2}),this.gl=this.renderer.gl,this.clearRgb=[We.top[0],We.top[1],We.top[2]],this.gl.clearColor(this.clearRgb[0],this.clearRgb[1],this.clearRgb[2],1),t.appendChild(this.canvas),this.lostHandler=r=>{r.preventDefault(),n.onContextLost()},this.restoredHandler=()=>n.onContextRestored(),this.canvas.addEventListener("webglcontextlost",this.lostHandler,!1),this.canvas.addEventListener("webglcontextrestored",this.restoredHandler,!1),this.resize()}setClearColor(t){this.clearRgb=[t[0],t[1],t[2]],this.gl.clearColor(t[0],t[1],t[2],1)}get clearColor(){return this.clearRgb}resize(){let t=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(t,n),{width:t,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 t=this.gl.getExtension("WEBGL_lose_context");t&&t.loseContext(),this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}simulateContextLossCycle(){let t=this.gl.getExtension("WEBGL_lose_context");t&&(t.loseContext(),setTimeout(()=>{t.restoreContext&&t.restoreContext()},300))}};import{Camera as Ai,Vec3 as ln}from"ogl";var ue=Math.PI/180,un=15*ue,mn=80*ue,$e=.12,ro=35,io=1.25,Lt=class{constructor(t,n,r,o){this.fovY=ro;this.target=new ln;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 ln;this.panAnchor=new ln;this.panLimit=0;this.primaryDragMode="orbit";this.camera=new Ai(t,{fov:ro,near:.1,far:5e3,aspect:1}),this.canvas=n,this.requestRender=r,this.onGesture=o,this.onPointerDown=i=>{if(this.interactionEnabled){try{this.canvas.setPointerCapture?.(i.pointerId)}catch{}if(this.activePointers.set(i.pointerId,{x:i.clientX,y:i.clientY}),this.activePointers.size===1){let a=i.button===2||i.button===1,s=i.button===0&&(i.shiftKey?this.primaryDragMode==="orbit":this.primaryDragMode==="pan");this.panning=a||s,this.dragging=!this.panning,this.lastX=i.clientX,this.lastY=i.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=i=>{if(!this.interactionEnabled||!this.activePointers.has(i.pointerId))return;if(this.activePointers.set(i.pointerId,{x:i.clientX,y:i.clientY}),this.activePointers.size>=2){let c=this.currentPinchDistance();this.pinchDist>0&&(this.dollyBy(Math.exp((this.pinchDist-c)*.005)),this.fireGesture()),this.pinchDist=c;let l=this.pinchCentroid();this.panBy(l.x-this.pinchCx,l.y-this.pinchCy),this.pinchCx=l.x,this.pinchCy=l.y;return}let a=i.clientX-this.lastX,s=i.clientY-this.lastY;if(this.panning){this.lastX=i.clientX,this.lastY=i.clientY,(a!==0||s!==0)&&(this.panBy(a,s),this.fireGesture());return}this.dragging&&(this.lastX=i.clientX,this.lastY=i.clientY,(a!==0||s!==0)&&this.fireGesture(),this.azT-=a*.006,this.polT=Math.max(un,Math.min(mn,this.polT-s*.006)),this.requestRender())},this.onPointerUp=i=>{this.activePointers.delete(i.pointerId);try{this.canvas.releasePointerCapture?.(i.pointerId)}catch{}this.activePointers.size<2&&(this.pinchDist=0),this.activePointers.size===0&&(this.dragging=!1,this.panning=!1)},this.onContextMenu=i=>{i.preventDefault()},this.onWheel=i=>{if(i.preventDefault(),!this.interactionEnabled)return;let a=i.deltaMode===1?16:i.deltaMode===2?100:1,s=Math.max(-2,Math.min(2,i.deltaY*a/100));this.dollyBy(Math.exp(s*.22)),this.fireGesture()},this.onKeyDown=i=>{if(!this.interactionEnabled)return;let a=7*ue;if(i.shiftKey&&(i.key==="ArrowLeft"||i.key==="ArrowRight"||i.key==="ArrowUp"||i.key==="ArrowDown"))this.panBy(i.key==="ArrowLeft"?-32:i.key==="ArrowRight"?32:0,i.key==="ArrowUp"?-32:i.key==="ArrowDown"?32:0);else if(i.key==="ArrowLeft"||i.key==="ArrowRight")this.azT+=i.key==="ArrowLeft"?-a:a;else if(i.key==="ArrowUp"||i.key==="ArrowDown")this.polT=Math.max(un,Math.min(mn,this.polT+(i.key==="ArrowUp"?-a:a)));else if(i.key==="+"||i.key==="=")this.dollyBy(.82);else if(i.key==="-"||i.key==="_")this.dollyBy(1.22);else return;i.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 t=[...this.activePointers.values()];if(!t.length)return{x:0,y:0};let n=0,r=0;for(let o of t)n+=o.x,r+=o.y;return{x:n/t.length,y:r/t.length}}panBy(t,n){let r=this.canvas.clientHeight||1,o=2*this.distance*Math.tan(this.fovY*ue/2)/r,i=Math.sin(this.azimuth),a=Math.cos(this.azimuth),s=a,c=-i,l=Math.cos(this.polar),f=Math.sin(this.polar),u=-i*l,m=-a*l;this.targetT.x+=(-t*s+n*u)*o,this.targetT.z+=(-t*c+n*m)*o,this.targetT.y+=n*f*o,this.clampPan(),this.requestRender()}clampPan(){if(this.panLimit<=0)return;let t=this.panLimit,n=this.panAnchor.x,r=this.panAnchor.y,o=this.panAnchor.z;this.targetT.x=Math.max(n-t,Math.min(n+t,this.targetT.x)),this.targetT.z=Math.max(o-t,Math.min(o+t,this.targetT.z)),this.targetT.y=Math.max(r-t*.5,Math.min(r+t,this.targetT.y))}fireGesture(){this.gestureFired||(this.gestureFired=!0,this.onGesture?.())}currentPinchDistance(){let t=[...this.activePointers.values()];return t.length<2?0:Math.hypot(t[0].x-t[1].x,t[0].y-t[1].y)}dollyBy(t){this.distT=Math.max(this.minDist,Math.min(this.maxDist,this.distT*t)),this.requestRender()}zoomBy(t){this.interactionEnabled&&(this.dollyBy(t),this.fireGesture())}setPrimaryDragMode(t){this.primaryDragMode=t}setInteractionEnabled(t){this.interactionEnabled=t,!t&&(this.activePointers.clear(),this.dragging=!1,this.panning=!1,this.pinchDist=0)}frame(t,n=!1,r,o=!1,i){this.target.set(t.center[0],t.center[1],t.center[2]),this.targetT.copy(this.target),this.panAnchor.copy(this.target),this.panLimit=Math.max(1,t.radius)*1.5;let a=Math.max(1,t.radius),s=this.fovY*ue/2,c=o?Math.max(.82,this.camera.aspect||1):this.camera.aspect||1,l=Math.atan(Math.tan(s)*c);this.azT=r??-30*ue,this.polT=Math.max(15,Math.min(80,i?.polarDeg??55))*ue;let f=this.fitDistance(t,s,l,this.azT,this.polT);this.distT=f*Math.max(1.05,Math.min(2,i?.margin??io)),this.minDist=Math.max(2,a*.12),this.maxDist=f*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(t){this.camera.perspective({aspect:t})}frameSoft(t,n,r=!1,o){this.target.set(t.center[0],t.center[1],t.center[2]),this.targetT.copy(this.target),this.panAnchor.copy(this.target),this.panLimit=Math.max(1,t.radius)*1.5,this.syncFromCamera(),this.camera.perspective({fov:this.fovY,aspect:this.camera.aspect});let i=this.fovY*ue/2,a=r?Math.max(.82,this.camera.aspect||1):this.camera.aspect||1,s=Math.atan(Math.tan(i)*a);this.azT=n??this.azimuth,this.polT=Math.max(15,Math.min(80,o?.polarDeg??55))*ue;let c=this.fitDistance(t,i,s,this.azT,this.polT);this.distT=c*Math.max(1.05,Math.min(2,o?.margin??io))}fitDistance(t,n,r,o,i){let a=Math.max(1,t.radius),s=Math.max(a/Math.tan(n),a/Math.tan(r)),c=t.box;if(!c)return s;let l=Math.sin(i),f=-l*Math.sin(o),u=-Math.cos(i),m=-l*Math.cos(o);if(Math.abs(u)>.999)return s;let h=-m,d=f,p=Math.hypot(h,d);h/=p,d/=p;let g=-d*u,b=d*f-h*m,y=h*u,P=Math.tan(r),S=Math.tan(n),A=1;for(let v=0;v<8;v++){let I=(v&1?c.max[0]:c.min[0])-t.center[0],T=(v&2?c.max[1]:c.min[1])-t.center[1],k=(v&4?c.max[2]:c.min[2])-t.center[2],z=I*f+T*u+k*m,V=Math.abs(I*h+k*d),w=Math.abs(I*g+T*b+k*y);A=Math.max(A,V/P-z,w/S-z)}return Math.min(s,Math.max(A,a*.35))}updateClipping(t){let n=this.camera.position.x-t.center[0],r=this.camera.position.y-t.center[1],o=this.camera.position.z-t.center[2],i=Math.hypot(n,r,o),a=Math.max(1,t.radius)*1.18,s=Math.max(.05,i-a),c=Math.max(s+10,i+a);this.camera.perspective({near:s,far:c,aspect:this.camera.aspect})}update(){let t=this.azT-this.azimuth,n=this.polT-this.polar,r=this.distT-this.distance,o=this.targetT.x-this.target.x,i=this.targetT.y-this.target.y,a=this.targetT.z-this.target.z,s=Math.max(1e-4,this.distance*1e-4),c=Math.abs(t)>1e-4||Math.abs(n)>1e-4||Math.abs(r)>1e-4||Math.abs(o)>s||Math.abs(i)>s||Math.abs(a)>s;return this.azimuth+=t*$e,this.polar+=n*$e,this.distance+=r*$e,this.target.x+=o*$e,this.target.y+=i*$e,this.target.z+=a*$e,c&&this.applyPosition(),c}get currentDistance(){return this.distance}syncFromCamera(){let t=this.camera.position.x-this.target.x,n=this.camera.position.y-this.target.y,r=this.camera.position.z-this.target.z,o=Math.hypot(t,n,r)||1,i=Math.max(un,Math.min(mn,Math.acos(Math.max(-1,Math.min(1,n/o)))));this.distance=this.distT=o,this.polar=this.polT=i,this.azimuth=this.azT=Math.atan2(t,r)}setTarget(t){this.target.set(t[0],t[1],t[2]),this.targetT.copy(this.target)}resumeAfterFlight(t){this.camera.perspective({fov:this.fovY,aspect:this.camera.aspect}),t&&this.target.set(t[0],t[1],t[2]),this.targetT.copy(this.target),this.syncFromCamera()}applyPosition(){let t=Math.sin(this.polar),n=this.target.x+this.distance*t*Math.sin(this.azimuth),r=this.target.y+this.distance*Math.cos(this.polar),o=this.target.z+this.distance*t*Math.cos(this.azimuth);this.camera.position.set(n,r,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 Vt=class{constructor(t){this.rafId=0;this.running=!1;this.lastTime=0;this.fpsEma=0;this.rendered=0;this.tick=t=>{let n=this.lastTime?(t-this.lastTime)/1e3:.016666666666666666;if(this.lastTime=t,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=t}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 Je=2.5,Ri=1.15,ht=6,et=10,ao=6,so=9.5,co=.9,lo=2.2,dn=30,hn=4,Ot=8192;var yc=et+hn;function uo(e,t){let n=t*1.4,r=t*3.2;if(e<=n)return{scale:1,fade:0,minPixels:Je};let o=Math.min(1,(e-n)/Math.max(.001,r-n));return{scale:1-o*.4,fade:o*.55,minPixels:Je+o*(Ri-Je)}}function mo(e,t,n){return!(e>0)||!(t>0)||!(n>0)?!1:t*n/e>=64}function ho(e,t,n,r,o){if(!(e>0)||!(t>0)||!(n>0)||!(r>0)||!(o>0))return!1;let i=Math.tan(r/2*Math.PI/180);if(!(i>0))return!1;let a=t/(n*i)*(o/2);return Math.PI*a*a/e>=64}import Ci from"earcut";import Ii from"polygon-clipping";var _=Be,Ei=.002;function Ti(e,t,n){let r=Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2]),o=Math.hypot(n[0]-t[0],n[1]-t[1],n[2]-t[2]),i=Math.hypot(e[0]-n[0],e[1]-n[1],e[2]-n[2]),a=Math.max(r,o,i);if(a<1e-9)return!0;let s=(r+o+i)/2;return 2*Math.sqrt(Math.max(0,s*(s-r)*(s-o)*(s-i)))/a<Ei}var je=class{constructor(t=16384){this.len=0;this.buf=new Float32Array(t)}push3(t,n,r){this.len+3>this.buf.length&&this.grow(this.len+3),this.buf[this.len++]=t,this.buf[this.len++]=n,this.buf[this.len++]=r}push1(t){this.len+1>this.buf.length&&this.grow(this.len+1),this.buf[this.len++]=t}grow(t){let n=this.buf.length*2;for(;n<t;)n*=2;let r=new Float32Array(n);r.set(this.buf.subarray(0,this.len)),this.buf=r}get length(){return this.len}toArray(){return this.buf.slice(0,this.len)}},zt=class{constructor(){this.pos=new je;this.nor=new je;this.col=new je;this.flr=new je;this.mat=new je;this.currentFloor=0;this.currentMaterial=0}setFloor(t){this.currentFloor=t}setMaterial(t){this.currentMaterial=t}tri(t,n,r,o,i,a=i,s=i){Ti(t,n,r)||(this.pos.push3(t[0],t[1],t[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(r[0],r[1],r[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.col.push3(i[0],i[1],i[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(t,n,r,o,i,a,s,c=s,l=s){[...t,...n,...r].every(Number.isFinite)&&(this.pos.push3(t[0],t[1],t[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(r[0],r[1],r[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(i[0],i[1],i[2]),this.nor.push3(a[0],a[1],a[2]),this.col.push3(s[0],s[1],s[2]),this.col.push3(c[0],c[1],c[2]),this.col.push3(l[0],l[1],l[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}get vertexCount(){return this.pos.length/3}build(){return{position:this.pos.toArray(),normal:this.nor.toArray(),color:this.col.toArray(),floor:this.flr.toArray(),material:this.mat.toArray(),count:this.pos.length/3}}};function Fi(e,t,n){let r=t[0]-e[0],o=t[1]-e[1],i=t[2]-e[2],a=n[0]-e[0],s=n[1]-e[1],c=n[2]-e[2],l=o*c-i*s,f=i*a-r*c,u=r*s-o*a,m=Math.hypot(l,f,u)||1;return l/=m,f/=m,u/=m,[l,f,u]}function _i(e,t){let n=[...e],r=[];for(let a of e)r.push(a.x,a.y);let o=[];if(t){for(let a of t)if(!(a.length<3)){o.push(n.length);for(let s of a)n.push(s),r.push(s.x,s.y)}}let i=Ci(r,o.length?o:void 0,2);return{pts:n,tris:i}}function fn(e){return Ye(e)<0?[...e].reverse():e}var Di=3;function ki(e,t,n,r){let o=r(e),i=r(t),a=r(n),s=(h,d,p,g)=>Math.abs(r({x:(h.x+d.x)/2,y:(h.y+d.y)/2})-(p+g)/2),c=(e.x+t.x+n.x)/3,l=(e.y+t.y+n.y)/3,f=(o+i+a)/3,u=Math.max(s(e,t,o,i),s(t,n,i,a),s(n,e,a,o),Math.abs(r({x:c,y:l})-f)),m=(h,d,p)=>{let g=Math.abs(r({x:(h+c)/2,y:(d+l)/2})-(p+f)/2);g>u&&(u=g)};return m((e.x+t.x)/2,(e.y+t.y)/2,(o+i)/2),m((t.x+n.x)/2,(t.y+n.y)/2,(i+a)/2),m((n.x+e.x)/2,(n.y+e.y)/2,(a+o)/2),u}function ft(e,t,n,r,o){if(o<=0)return ki(e,t,n,r);let i={x:(e.x+t.x)/2,y:(e.y+t.y)/2},a={x:(t.x+n.x)/2,y:(t.y+n.y)/2},s={x:(n.x+e.x)/2,y:(n.y+e.y)/2};return Math.max(ft(e,i,s,r,o-1),ft(i,t,a,r,o-1),ft(s,a,n,r,o-1),ft(i,a,s,r,o-1))}function pt(e,t,n,r,o,i,a,s){if(a>0){let m={x:(t.x+n.x)/2,y:(t.y+n.y)/2},h={x:(n.x+r.x)/2,y:(n.y+r.y)/2},d={x:(r.x+t.x)/2,y:(r.y+t.y)/2};pt(e,t,m,d,o,i,a-1,s),pt(e,m,n,h,o,i,a-1,s),pt(e,d,h,r,o,i,a-1,s),pt(e,m,h,d,o,i,a-1,s);return}let c=[t.x*_,o(t),t.y*_],l=[n.x*_,o(n),n.y*_],f=[r.x*_,o(r),r.y*_];if(s){e.triN(c,l,f,s(t),s(n),s(r),i);return}let u=Fi(c,l,f);u[1]<0&&(u=[-u[0],-u[1],-u[2]]),e.tri(c,l,f,u,i)}var Li=8;function fo(e,t,n){if(!Number.isFinite(n))return e;let r=[],o=(i,a,s,c,l)=>{if(l>0){let f={x:(i.x+a.x)/2,y:(i.y+a.y)/2},u=t(f);if(Math.abs(u-(s+c)/2)>n){o(i,f,s,u,l-1),o(f,a,u,c,l-1);return}}r.push(i)};for(let i=0;i<e.length;i++){let a=e[i],s=e[(i+1)%e.length];o(a,s,t(a),t(s),Li)}return r}function Bt(e,t){if(e.length<3)return e;let n=[];for(let o of e){let i=n[n.length-1];i&&Math.hypot(o.x-i.x,o.y-i.y)<t||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)<t;)n.pop();if(n.length<3)return e;let r=[];for(let o=0;o<n.length;o++){let i=r.length?r[r.length-1]:n[(o-1+n.length)%n.length],a=n[o],s=n[(o+1)%n.length],c=s.x-i.x,l=s.y-i.y,f=Math.hypot(c,l);f>t&&Math.abs((a.x-i.x)*l-(a.y-i.y)*c)/f<t||r.push(a)}return r.length>=3?r:n}var Nt=.001*Ne*.1;function se(e,t,n,r,o,i,a,s,c=1/0,l){if(!t||t.length<3||(c===void 0&&(c=1/0),Math.abs(Ye(t))<1e-4))return;let f=Bt(fo(Bt(fn(t),Nt),r,c),Nt),u=n?.map(v=>Bt(fo(Bt(fn(v),Nt),r,c),Nt)).filter(v=>v.length>=3&&Math.abs(Ye(v))>=1e-4),{pts:m,tris:h}=_i(f,u),d=[i[0]*s.top,i[1]*s.top,i[2]*s.top],p=[i[0]*s.bottomCap,i[1]*s.bottomCap,i[2]*s.bottomCap],g=[a[0]*s.top,a[1]*s.top,a[2]*s.top],b=[a[0]*s.wallBottom,a[1]*s.wallBottom,a[2]*s.wallBottom],y=0;if(Number.isFinite(c))for(;y<Di;y++){let v=0;for(let I=0;I<h.length;I+=3){let T=ft(m[h[I]],m[h[I+1]],m[h[I+2]],r,y);T>v&&(v=T)}if(v<=c)break}for(let v=0;v<h.length;v+=3){let I=m[h[v]],T=m[h[v+1]],k=m[h[v+2]];pt(e,I,T,k,r,d,y,l);let z=[I.x*_,o,I.y*_],V=[T.x*_,o,T.y*_],w=[k.x*_,o,k.y*_];e.tri(z,w,V,[0,-1,0],p)}let P=v=>{if(y<=0)return v;let I=1<<y,T=[];for(let k=0;k<v.length;k++){let z=v[k],V=v[(k+1)%v.length];for(let w=0;w<I;w++){let F=w/I;T.push({x:z.x+(V.x-z.x)*F,y:z.y+(V.y-z.y)*F})}}return T},S=Yn(f),A=[{ring:P(f),flip:!1}];if(u)for(let v of u)v.length>=3&&A.push({ring:P(v),flip:!0});for(let{ring:v,flip:I}of A)for(let T=0;T<v.length;T++){let k=v[T],z=v[(T+1)%v.length],V=(z.x-k.x)*_,F=(z.y-k.y)*_,D=-V,M=Math.hypot(F,D)||1;F/=M,D/=M;let E=(k.x+z.x)/2-S.x,B=(k.y+z.y)/2-S.y,R=F*E+D*B;I&&(R=-R),R<0&&(F=-F,D=-D);let x=[F,0,D],C=[k.x*_,r(k),k.y*_],X=[z.x*_,r(z),z.y*_],G=[k.x*_,o,k.y*_],Y=[z.x*_,o,z.y*_];e.tri(C,X,Y,x,g,g,b),e.tri(C,Y,G,x,g,b,b)}}function po(e){let t=0;for(let c of e)t+=c.count;let n=new Float32Array(t*3),r=new Float32Array(t*3),o=new Float32Array(t*3),i=new Float32Array(t),a=new Float32Array(t),s=0;for(let c of e)n.set(c.position,s*3),r.set(c.normal,s*3),o.set(c.color,s*3),i.set(c.floor,s),a.set(c.material,s),s+=c.count;return{position:n,normal:r,color:o,floor:i,material:a,count:t}}function Gt(e,t,n=2.5){if(t<=0||e.length<3)return e;let r=fn(e),o=r.length,i=[];for(let s=0;s<o;s++){let c=r[s],l=r[(s+1)%o],f=l.x-c.x,u=l.y-c.y,m=Math.hypot(f,u)||1;i.push({x:u/m,y:-f/m})}let a=[];for(let s=0;s<o;s++){let c=r[s],l=i[(s-1+o)%o],f=i[s],u=l.x+f.x,m=l.y+f.y,h=Math.hypot(u,m),d=()=>{a.push([c.x+l.x*t,c.y+l.y*t]),a.push([c.x+f.x*t,c.y+f.y*t])};if(h<1e-9){d();continue}u/=h,m/=h;let p=u*l.x+m*l.y,g=1/Math.max(p,1e-6);if(!Number.isFinite(g)||g>n){d();continue}a.push([c.x+u*t*g,c.y+m*t*g])}if(a.length<3)return e;try{let s=Ii.union([[...a,a[0]]]),c=null,l=-1/0;for(let u of s){let m=Math.abs(Ye(u[0].map(([h,d])=>({x:h,y:d}))));m>l&&(l=m,c=u[0])}if(!c)return e;let f=c.map(([u,m])=>({x:u,y:m}));if(f.length>1){let u=f[0],m=f[f.length-1];Math.abs(u.x-m.x)<1e-9&&Math.abs(u.y-m.y)<1e-9&&f.pop()}return f.length>=3?f:e}catch{return e}}function Ut(e,t,n,r,o=28){let i=[];for(let a=0;a<o;a++){let s=a/o*Math.PI*2;i.push({x:e+n*Math.cos(s),y:t+r*Math.sin(s)})}return i}function bt(e,t,n,r){return[{x:e,y:t},{x:e+n,y:t},{x:e+n,y:t+r},{x:e,y:t+r}]}var oe={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,body:10,head:11},Vi=.44,Oi=.15,Bi=.3,Ni=.24;function bo(e){return e===void 0||!Number.isFinite(e)||e<=0?Ni:Math.min(Bi,Math.max(Oi,e*Vi))}var pn=.21,zi=.05,bn=.45,Ht=bn+zi,Gi=[{part:oe.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:oe.pad,min:[-1,.36,-.95],max:[1,bn,1]},{part:oe.back,min:[-1,Ht,-1],max:[1,.92,-.72]},{part:oe.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:oe.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:oe.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:oe.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:oe.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:oe.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:oe.leg,min:[.62,0,.48],max:[.82,.37,.7]}],Ui=[{part:oe.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:oe.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:oe.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:oe.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:oe.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}],Hi=[{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 yo(){let e=[],t=[],n=[],r=[],o=(M,E,B)=>{let R=n.length,[x,C,X]=M,G=[C[0]-x[0],C[1]-x[1],C[2]-x[2]],Y=[X[0]-x[0],X[1]-x[1],X[2]-x[2]],U=G[1]*Y[2]-G[2]*Y[1],N=G[2]*Y[0]-G[0]*Y[2],H=G[0]*Y[1]-G[1]*Y[0],j=Math.hypot(U,N,H);j>1e-9?(U/=j,N/=j,H/=j):[U,N,H]=E,U*E[0]+N*E[1]+H*E[2]<0&&(U=-U,N=-N,H=-H);for(let W of M)e.push(...W),t.push(U,N,H),n.push(B);r.push(R,R+1,R+2,R,R+2,R+3)},i=M=>{for(let E of Hi){let B=E.c.map(R=>R.map((x,C)=>x?M.max[C]:M.min[C]));o(B,E.n,M.part)}};for(let M of Gi)i(M);for(let M of Ui)i(M);let a=bn,s=1.08,c=.47,l=.69,f=-.55,u=.08,m=-.48,h=.01,d=[-c,a,f],p=[c,a,f],g=[-c,a,u],b=[c,a,u],y=[-l,s,m],P=[l,s,m],S=[-l,s,h],A=[l,s,h];o([p,P,A,b],[1,0,0],oe.body),o([g,S,y,d],[-1,0,0],oe.body),o([S,A,P,y],[0,1,0],oe.body),o([d,p,b,g],[0,-1,0],oe.body),o([b,A,S,g],[0,0,1],oe.body),o([d,y,P,p],[0,0,-1],oe.body);let v=10,I=8,T=[0,1.205,-.23],k=[.42,.115,.38],z=n.length;for(let M=0;M<=I;M++){let E=Math.PI*M/I,B=Math.cos(E),R=Math.sin(E);for(let x=0;x<=v;x++){let C=Math.PI*2*x/v,X=R*Math.cos(C),G=R*Math.sin(C);e.push(T[0]+k[0]*X,T[1]+k[1]*B,T[2]+k[2]*G);let Y=X/k[0],U=B/k[1],N=G/k[2],H=Math.hypot(Y,U,N)||1;Y/=H,U/=H,N/=H,t.push(Y,U,N),n.push(oe.head)}}for(let M=0;M<I;M++)for(let E=0;E<v;E++){let B=z+M*(v+1)+E,R=B+v+1;r.push(B,R,B+1,B+1,R,R+1)}let V=new Float32Array(e),w=new Float32Array(t),F=new Float32Array(n),D=new Uint16Array(r);return{position:V,normal:w,part:F,index:D,vertexCount:n.length,indexCount:r.length}}function go(e,t,n,r){let o=new Float32Array(t),i=l=>e[l*3],a=l=>e[l*3+2],s=0,c=(l,f)=>{let u=f-l;for(let m=l;m<f;m++){let[h,d]=r(m),p=h-i(m),g=d-a(m);if(u>=2){let b=Math.max(l,m-1),y=Math.min(f-1,m+1),P=i(y)-i(b),S=a(y)-a(b),A=Math.hypot(P,S);if(A>1e-6){let v=-S/A,I=P/A;v*p+I*g<0&&(v=-v,I=-I),p=v,g=I}}o[m]=p===0&&g===0?0:Math.atan2(p,g)}};for(let l=1;l<=t;l++)(l===t||n(l)!==n(s))&&(c(s,l),s=l);return o}var Fe=.22;function xo(e,t){let n=we[e];if(n!=="sold"&&n!=="held")return-1;let r=(t+1)*2654435761;return r^=r>>>15,r=Math.imul(r,2246822519),r^=r>>>13,(r>>>0)%1e5/1e5}var Xi=.42;function Yi(e){let t=e.length,n=new Float64Array(t);if(t<2)return n.fill(1/0),n;let r=1/0,o=1/0,i=-1/0,a=-1/0;for(let d of e)d.x<r&&(r=d.x),d.y<o&&(o=d.y),d.x>i&&(i=d.x),d.y>a&&(a=d.y);let s=Math.max(i-r,1e-6),c=Math.max(a-o,1e-6),l=Math.max(Math.sqrt(s*c/t),1e-6),f=Math.max(1,Math.ceil(s/l)+1),u=Math.max(1,Math.ceil(c/l)+1),m=new Map,h=(d,p)=>{let g=Math.min(f-1,Math.max(0,Math.floor((d-r)/l)));return Math.min(u-1,Math.max(0,Math.floor((p-o)/l)))*f+g};for(let d=0;d<t;d++){let p=h(e[d].x,e[d].y),g=m.get(p);g?g.push(d):m.set(p,[d])}for(let d=0;d<t;d++){let p=e[d],g=Math.min(f-1,Math.max(0,Math.floor((p.x-r)/l))),b=Math.min(u-1,Math.max(0,Math.floor((p.y-o)/l))),y=1/0;for(let P=1;P<=4;P++){for(let S=b-P;S<=b+P;S++)if(!(S<0||S>=u))for(let A=g-P;A<=g+P;A++){if(A<0||A>=f||P>1&&Math.abs(S-b)<P&&Math.abs(A-g)<P)continue;let v=m.get(S*f+A);if(v)for(let I of v){if(I===d)continue;let T=Math.hypot(e[I].x-p.x,e[I].y-p.y);T<y&&(y=T)}}if(Number.isFinite(y)&&y<=P*l)break}n[d]=y}return n}function Wi(e){let t=e.eyeHeightM;return Number.isFinite(t)?Math.max(0,t-Ft):0}function vo(e,t,n,r,o,i){let a=e.length,s=new Float32Array(a*3),c=new Float32Array(a),l=new Float32Array(a*3),f=new Float32Array(a),u=new Float32Array(a),m=new Float32Array(a),h=new Float32Array(a),d=new Float32Array(a*3),p=new Map,g=Yi(e);for(let b=0;b<a;b++){let y=e[b],S=(n?.seatPitchU(b)??g[b])*_;f[b]=Number.isFinite(S)?Math.max(.06,Math.min(Fe,S*Xi)):Fe,u[b]=bo(Number.isFinite(S)?S:void 0);let A=Qn(y.glyph,{seatGlyph:i?.get(y.categoryKey)});m[b]=Zn.indexOf(A),h[b]=y.wheelchairSpaceType==="no-seat"?0:1,s[b*3]=y.x*_,s[b*3+1]=n?n.seatDeckY(b):Wi(y),s[b*3+2]=y.y*_,c[b]=dt(t?t(y):"available");let v=ee(o?.get(y.categoryKey)??"#6e7bff")??[.43,.48,1];if(l[b*3]=v[0],l[b*3+1]=v[1],l[b*3+2]=v[2],y.accessibility?.length){let I=ee(Hn(y.accessibility));I&&(d[b*3]=I[0],d[b*3+1]=I[1],d[b*3+2]=I[2])}p.set(y.id,b)}return{count:a,iPosition:s,iState:c,iCategory:l,iMaxRadius:f,iRing:d,idToIndex:p,iChairWidth:u,iGlyph:m,iPhysicalSeat:h,iFloor:r??new Float32Array(a),iYaw:new Float32Array(a)}}var ji=64;function yn(e,t){let n=[];for(let a of t){let s=e.idToIndex.get(a.seatId);if(s===void 0)continue;let c=dt(a.state);e.iState[s]!==c&&(e.iState[s]=c,n.push(s))}if(!n.length)return[];n.sort((a,s)=>a-s);let r=[],o=n[0],i=n[0];for(let a=1;a<n.length;a++){let s=n[a];if(s!==i){if(s<=i+ji){i=s;continue}r.push({start:o,length:i-o+1}),o=s,i=s}}return r.push({start:o,length:i-o+1}),r}var qi=.15,Ki=.9,Zi=1.76,Qi=.7,$i=1.6;function Ji(){return{background:{top:[...We.top],bottom:[...We.bottom]},structure:cn,seatStates:{...no},seatScale:1,materials:{seat:null,shell:null,roughness:.78}}}function Mo(e){let t=Ji();if(!e)return t;let n=ee(e.background);if(n){t.background={top:ge(n,Ki),bottom:ge(n,Zi)};let a={};for(let[s,c]of Object.entries(cn))a[s]=ye(c,n,qi);t.structure=a}let r=ee(e.selectionColor)??ee(e.accent);r&&(t.seatStates={...t.seatStates,selected:r});let o=e.seatScale;typeof o=="number"&&Number.isFinite(o)&&(t.seatScale=Math.min($i,Math.max(Qi,o)));let i=e.venue3d;if(i){let a=ee(i.deck),s=ee(i.fascia);a&&(t.structure={...t.structure,tierTop:a,gaTop:a}),s&&(t.structure={...t.structure,tierWall:s,gaWall:s}),t.materials.seat=ee(i.seat),t.materials.shell=ee(i.shell),typeof i.roughness=="number"&&Number.isFinite(i.roughness)&&(t.materials.roughness=Math.min(1,Math.max(0,i.roughness)))}return t}function So(e,t){let n=[];for(let r of t)n.push(...e.seatStates[r]);return n}import Ro from"polygon-clipping";import ea from"earcut";var ta=.58,wo=.01,xe=Fe*1.5*Ne,na=.5,oa=.6;function ra(e,t){let n=e.length,r=[];for(let a=0;a<n;a++){let s=e[Math.max(0,a-1)],c=e[Math.min(n-1,a+1)],l=c.x-s.x,f=c.y-s.y,u=Math.hypot(l,f);if(u<1e-9){r.push([0,0]);continue}l/=u,f/=u,r.push([-f,l])}let o=0;for(let a=0;a<n;a++)o+=(e[a].x-t.x)*r[a][0]+(e[a].y-t.y)*r[a][1];return o<0?r.map(([a,s])=>[-a,-s]):r}function ia(e,t){if(e.length<2||t<=0)return[...e];let n=[...e],r=(a,s)=>{let c=s.x-a.x,l=s.y-a.y,f=Math.hypot(c,l)||1;return{x:c/f,y:l/f}},o=r(n[1],n[0]),i=r(n[n.length-2],n[n.length-1]);return n.unshift({x:n[0].x+o.x*t,y:n[0].y+o.y*t}),n.push({x:n[n.length-1].x+i.x*t,y:n[n.length-1].y+i.y*t}),n}var Po=Math.PI/12;function aa(e){if(e.length<3)return[...e];let t=[...e].sort((i,a)=>i.x-a.x||i.y-a.y),n=(i,a,s)=>(a.x-i.x)*(s.y-i.y)-(a.y-i.y)*(s.x-i.x),r=i=>{let a=[];for(let s of i){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=[...r(t),...r([...t].reverse())];return o.length>=3?o:[...e]}function Co(e,t){if(!e.length||!(t>0))return[];let n=aa(e),r=(s,c,l,f)=>{let u=l-c;for(;u<0;)u+=Math.PI*2;for(;u>Math.PI*2;)u-=Math.PI*2;let m=Math.max(1,Math.ceil(u/Po)),h=t/Math.cos(u/m/2);for(let d=0;d<=m;d++){let p=c+u*d/m;f.push({x:s.x+Math.cos(p)*h,y:s.y+Math.sin(p)*h})}};if(n.length<3){let s=0,c=0;for(let h of n)s+=h.x,c+=h.y;s/=n.length||1,c/=n.length||1;let l=0;for(let h of n)l=Math.max(l,Math.hypot(h.x-s,h.y-c));let f=[],u=Math.max(3,Math.ceil(Math.PI*2/Po)),m=(l+t)/Math.cos(Math.PI/u);for(let h=0;h<u;h++){let d=h/u*Math.PI*2;f.push({x:s+Math.cos(d)*m,y:c+Math.sin(d)*m})}return f}let o=n.length,i=[];for(let s=0;s<o;s++){let c=n[s],l=n[(s+1)%o];i.push(Math.atan2(-(l.x-c.x),l.y-c.y))}let a=[];for(let s=0;s<o;s++)r(n[s],i[(s+o-1)%o],i[s],a);return _o(a)}function sa(e,t,n){if(e.length===1)return Math.hypot(t-e[0].x,n-e[0].y);let r=1/0;for(let o=0;o+1<e.length;o++){let i=e[o],a=e[o+1],s=a.x-i.x,c=a.y-i.y,l=s*s+c*c,f=l>1e-12?((t-i.x)*s+(n-i.y)*c)/l:0;f<0?f=0:f>1&&(f=1);let u=Math.hypot(t-(i.x+f*s),n-(i.y+f*c));u<r&&(r=u)}return r}function Xt(e){let t=e.map(o=>{let i=0,a=0;for(let l of o.pts)i+=l.x,a+=l.y;let s=o.pts.length||1;i/=s,a/=s;let c=0;for(let l of o.pts){let f=Math.hypot(l.x-i,l.y-a);f>c&&(c=f)}return{cx:i,cy:a,rad:c}}),n=o=>{let i=o.length;return i<=2?[...o]:[o[Math.floor(i*.25)],o[Math.floor(i*.5)],o[Math.floor(i*.75)]]},r=[];for(let o=0;o<e.length;o++){let i=n(e[o].pts),a=[],s=1/0,c=null;for(let f of i){let u=1/0;for(let m=0;m<e.length;m++){if(m===o||Math.abs(e[m].y-e[o].y)<.001)continue;let h=t[m],d=Math.hypot(f.x-h.cx,f.y-h.cy)-h.rad;if(d>=u&&d>=s)continue;let p=sa(e[m].pts,f.x,f.y);p<u&&(u=p),e[m].depth<e[o].depth&&p<s&&(s=p,c=e[m].y)}Number.isFinite(u)&&u>0&&a.push(u)}a.sort((f,u)=>f-u);let l=a.length?a[Math.floor(a.length/2)]:1;r.push({pitch:l,belowY:c})}return r}function Io(e,t,n,r){let o=e[t],i=o.pts.length>=2?[...o.pts]:o.pts.length===1?(()=>{let f=o.pts[0],u=f.x-r.x,m=f.y-r.y,h=Math.hypot(u,m)||1;u/=h,m/=h;let d=Math.max(n[t].pitch,.001)*.5;return[{x:f.x+m*d,y:f.y-u*d},{x:f.x-m*d,y:f.y+u*d}]})():[];if(i.length<2)return null;let a=0,s=0;for(let f=1;f<i.length;f++){let u=Math.hypot(i[f].x-i[f-1].x,i[f].y-i[f-1].y);u>1e-6&&(a+=u,s++)}let c=s>0?a/s:0,l=ia(i,Math.max(c*oa,xe));return{pts:l,nrm:ra(l,r),front:Math.max(n[t].pitch*ta,xe),back:Math.max(n[t].pitch*na,xe)}}var tt=1.5,Eo=.3;function gn(e,t){if(e.length<3)return e;let n=e[0],r=e[e.length-1],o=r.x-n.x,i=r.y-n.y,a=Math.hypot(o,i),s=-1,c=-1;for(let u=1;u<e.length-1;u++){let m=e[u],h=a>1e-12?Math.abs((m.x-n.x)*i-(m.y-n.y)*o)/a:Math.hypot(m.x-n.x,m.y-n.y);h>s&&(s=h,c=u)}if(s<=t||c<0)return[n,r];let l=gn(e.slice(0,c+1),t),f=gn(e.slice(c),t);return[...l.slice(0,-1),...f]}function To(e,t){if(e.length<4)return e;let n=gn([...e,e[0]],t);return n.pop(),n.length>=3?n:e}function Fo(e,t,n){if(e.length<2)return[];let r=n??Xt(e),o=new Map;for(let a=0;a<e.length;a++){let s=o.get(e[a].blockId);s?s.push(a):o.set(e[a].blockId,[a])}let i=[];for(let[,a]of o){let s=[];for(let y of a){let P=e[y].patch;P&&P.length>=3?i.push({outline:[...P],holes:[],topY:e[y].y}):s.push(y)}if(!s.length)continue;s.sort((y,P)=>e[y].depth-e[P].depth);let l=s.map(y=>Io(e,y,r,t)).filter(y=>y!==null);if(!l.length)continue;let f=(y,P)=>({x:y.pts[P].x-y.nrm[P][0]*(y.front+tt),y:y.pts[P].y-y.nrm[P][1]*(y.front+tt)}),u=(y,P)=>({x:y.pts[P].x+y.nrm[P][0]*(y.back+tt),y:y.pts[P].y+y.nrm[P][1]*(y.back+tt)}),m=l[0],h=l[l.length-1],d=[];for(let y=0;y<m.pts.length;y++)d.push(f(m,y));for(let y of l)d.push(u(y,y.pts.length-1));for(let y=h.pts.length-1;y>=0;y--)d.push(u(h,y));for(let y=l.length-1;y>=0;y--)d.push(f(l[y],0));let p=_o(d),g=1/0;for(let y of s)e[y].y<g&&(g=e[y].y);if(!Number.isFinite(g))continue;if(p.length>=3&&Math.abs(Ye(p))>1e-6&&l.every(y=>{let P=y.pts[Math.floor(y.pts.length/2)];return mt(p,P.x,P.y)})){i.push({outline:To(p,Eo),holes:[],topY:g});continue}for(let y of ca(l))i.push({outline:y,holes:[],topY:g})}return i}function ca(e){let t=[];for(let n of e){let r=[],o=[],i=n.front+tt,a=n.back+tt;for(let c=0;c<n.pts.length;c++){let l=n.pts[c],f=n.nrm[c];r.push([l.x-f[0]*i,l.y-f[1]*i]),o.push([l.x+f[0]*a,l.y+f[1]*a])}let s=[...r,...o.reverse()];s.length<3||(s.push(s[0]),t.push([s]))}if(!t.length)return[];try{let n=Ro.union(t[0],...t.slice(1)),r=[];for(let o of n){if(!o.length||o[0].length<4)continue;let i=o[0].map(([c,l])=>({x:c,y:l})),a=i[0],s=i[i.length-1];i.length>1&&Math.abs(a.x-s.x)<1e-9&&Math.abs(a.y-s.y)<1e-9&&i.pop(),i.length>=3&&r.push(To(i,Eo))}return r}catch{return[]}}function _o(e){let t=[];for(let n of e){let r=t[t.length-1];r&&Math.hypot(n.x-r.x,n.y-r.y)<1e-9||t.push(n)}for(;t.length>2&&Math.hypot(t[0].x-t[t.length-1].x,t[0].y-t[t.length-1].y)<1e-9;)t.pop();return t}var xn=class{constructor(t){this.minX=1/0;this.minY=1/0;this.maxX=-1/0;this.maxY=-1/0;this.rings=t;for(let n of t)for(let r of n)r.x<this.minX&&(this.minX=r.x),r.y<this.minY&&(this.minY=r.y),r.x>this.maxX&&(this.maxX=r.x),r.y>this.maxY&&(this.maxY=r.y)}containsAll(t){for(let n of t)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 r=!0;for(let o of t)if(!mt(n,o.x,o.y)){r=!1;break}if(r)return!0}return!1}};function Ao(e,t,n,r,o,i){if(r.length<3)return;if(n.containsAll(r)){let l=[0,1,0],f=r[0];for(let u=1;u+1<r.length;u++){let m=r[u],h=r[u+1];e.tri([f.x*_,o,f.y*_],[m.x*_,o,m.y*_],[h.x*_,o,h.y*_],l,i)}return}let a=r.map(l=>[l.x,l.y]);a.push(a[0]);let s;try{s=Ro.intersection([a],t)}catch{return}let c=[0,1,0];for(let l of s){if(!l.length||l[0].length<4)continue;let f=l[0],u=[],m=[];for(let d=0;d<f.length-1;d++)u.push(f[d][0],f[d][1]),m.push([f[d][0],f[d][1]]);if(m.length<3)continue;let h=ea(u,void 0,2);for(let d=0;d<h.length;d+=3){let p=m[h[d]],g=m[h[d+1]],b=m[h[d+2]];e.tri([p[0]*_,o,p[1]*_],[g[0]*_,o,g[1]*_],[b[0]*_,o,b[1]*_],c,i)}}}function Do(e,t,n,r,o,i,a){if(t.length<2)return;let s=a??Xt(t),c=[0,1,0],l=i&&i.length>=3?[[...i.map(h=>[h.x,h.y]),[i[0].x,i[0].y]]]:null,f=i&&i.length>=3?new xn([[...i]]):null,u=h=>{e.setMaterial(2),h(),e.setMaterial(0)},m=h=>{e.setMaterial(3),h(),e.setMaterial(0)};for(let h=0;h<t.length;h++){let d=t[h];if(d.patch&&d.patch.length>=3){let A=[...d.patch],v=s[h].belowY??r;if(m(()=>{if(l&&f)Ao(e,l,f,A,d.y,o.tread);else{let I=A[0];for(let T=1;T+1<A.length;T++){let k=A[T],z=A[T+1];e.tri([I.x*_,d.y,I.y*_],[k.x*_,d.y,k.y*_],[z.x*_,d.y,z.y*_],c,o.tread)}}}),d.y>v+wo){let I=0,T=0;for(let k of A)I+=k.x,T+=k.y;I/=A.length,T/=A.length,u(()=>{for(let k=0;k<A.length;k++){let z=A[k],V=A[(k+1)%A.length],w=V.x-z.x,F=V.y-z.y,D=Math.hypot(w,F);if(D<1e-6)continue;let M=F/D,E=-w/D;(z.x-I)*M+(z.y-T)*E<0&&(M=-M,E=-E);let B=[M,0,E],R=[z.x*_,d.y,z.y*_],x=[V.x*_,d.y,V.y*_],C=[z.x*_,v,z.y*_],X=[V.x*_,v,V.y*_];e.tri(R,x,X,B,o.riser),e.tri(R,X,C,B,o.riser)}})}continue}let p=Io(t,h,s,n);if(!p)continue;let{pts:g,nrm:b,front:y,back:P}=p,S=s[h].belowY??r;for(let A=0;A+1<g.length;A++){let v=g[A],I=g[A+1],T=b[A],k=b[A+1];if(Math.hypot(I.x-v.x,I.y-v.y)<1e-6||T[0]===0&&T[1]===0||k[0]===0&&k[1]===0)continue;let z=[(v.x-T[0]*y)*_,d.y,(v.y-T[1]*y)*_],V=[(I.x-k[0]*y)*_,d.y,(I.y-k[1]*y)*_],w=[(v.x+T[0]*P)*_,d.y,(v.y+T[1]*P)*_],F=[(I.x+k[0]*P)*_,d.y,(I.y+k[1]*P)*_];if(m(()=>{l&&f?Ao(e,l,f,[{x:v.x-T[0]*y,y:v.y-T[1]*y},{x:I.x-k[0]*y,y:I.y-k[1]*y},{x:I.x+k[0]*P,y:I.y+k[1]*P},{x:v.x+T[0]*P,y:v.y+T[1]*P}],d.y,o.tread):(e.tri(z,V,F,c,o.tread),e.tri(z,F,w,c,o.tread))}),d.y>S+wo){let D=[z[0],S,z[2]],M=[V[0],S,V[2]],E=[-T[0],0,-T[1]];u(()=>{e.tri(z,V,M,E,o.riser),e.tri(z,M,D,E,o.riser)})}}}}import Lo from"polygon-clipping";function la(e,t){let n=e.eventConfigurationIds;return!n?.length||!!t&&n.includes(t)}function ko(e,t){return e.filter(n=>n.type!=="shape"||la(n,t))}function Vo(e,t){let n=e.focalPoint??{x:0,y:0};return e.floors?.length?e.floors.map((r,o)=>({objects:ko(r.objects,t),focal:{x:(r.focalPoint??n).x,y:(r.focalPoint??n).y},baseHeightM:r.baseHeightM??0,index:o})):[{objects:ko(e.objects,t),focal:n,baseHeightM:0,index:0}]}var ua={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function nt(e){return Kn(e)??ua}function Oo(e,t){let n=Gt(e.outline,xe),r=nt(n),o=t.filter(a=>a!==e&&a.outline&&a.outline.length>=3&&Dt(r,nt(a.outline)));if(!o.length)return[n];let i=a=>{let s=a.map(c=>[c.x,c.y]);return s.push(s[0]),s};try{let a=Lo.difference([i(n)],...o.map(c=>[i(c.outline)])),s=[];for(let c of a){if(!c.length)continue;let l=c[0].map(([f,u])=>({x:f,y:u}));if(l.length>1){let f=l[0],u=l[l.length-1];Math.abs(f.x-u.x)<1e-9&&Math.abs(f.y-u.y)<1e-9&&l.pop()}l.length>=3&&s.push(l)}return s.length?s:[n]}catch{return[n]}}function Bo(e,t){if(!t.length)return e;let n=i=>{let a=i.map(s=>[s.x,s.y]);return a.push(a[0]),a},r=t.map(i=>[n(i)]),o=[];for(let i of e){let a;try{a=Lo.intersection([n(i.outline)],r.flat())}catch{o.push(i);continue}for(let s of a){if(!s.length)continue;let c=s[0].map(([l,f])=>({x:l,y:f}));if(c.length>1){let l=c[0],f=c[c.length-1];Math.abs(l.x-f.x)<1e-9&&Math.abs(l.y-f.y)<1e-9&&c.pop()}c.length>=3&&o.push({outline:c,holes:[],topY:i.topY})}}return o.length?o:e}var ma=.05,No=.05,da=.15,vn=25;function zo(e,t,n){let r=new Map,o=new Array(t.length).fill(null),i=new Float64Array(t.length),a=new Array(t.length).fill(void 0),s=new Array(t.length).fill(void 0),c=new Map,l=[],f=new Set;for(let m=0;m<e.length;m+=1){let h=e[m];for(let d of h.objects){if(d.type==="table"&&f.add(d.id),d.type!=="section"||!d.outline||d.outline.length<3)continue;let p=Gt(d.outline,xe);c.set(d.id,{section:d,unit:h,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),l.push({id:d.id,floorIndex:m,box:nt(p),section:d,unit:h,outline:p})}}let u=new Map;for(let m of l){let h=u.get(m.floorIndex);h?h.push(m):u.set(m.floorIndex,[m])}for(let m=0;m<t.length;m++){let h=t[m],d=n?u.get(n[m])??[]:l,p=h.sectionId?d.find(b=>b.id===h.sectionId)??d.find(b=>b.section.logicalSectionId===h.sectionId&&sn({x:h.x,y:h.y},b.outline,b.section.holes)):void 0,g=p?[p]:d;for(let b of g){if(n&&b.floorIndex!==n[m]||!p&&(h.x<b.box.minX||h.x>b.box.maxX||h.y<b.box.minY||h.y>b.box.maxY||!sn({x:h.x,y:h.y},b.outline,b.section.holes)))continue;o[m]=b.id;let y=c.get(b.id);y.hasSeats=!0;let P=h.focalPoint??b.unit.focal,S=Math.hypot(h.x-P.x,h.y-P.y);S<y.frontU&&(y.frontU=S),y.seatIndices.push(m);let A=h.rowId||`__seat-${m}`,v=y.rows.get(A);v?v.push({x:h.x,y:h.y}):y.rows.set(A,[{x:h.x,y:h.y}]);break}}for(let[m,h]of c){let d=Wn(h.section,{floorBaseHeightM:h.unit.baseHeightM}),p=h.unit.baseHeightM,g=d.rake>0?Math.tan(d.rake*Math.PI/180):0,b=d.rake<=.01&&d.height<=p+.001,y=h.section.surfaceKind,P=y==="flat"?!0:y==="rakedRows"&&d.rake>.01?!1:b,S=h.hasSeats?jn(m,t,h.seatIndices,h.unit.focal):{sectionId:m,rows:[],blockCount:0},v=S.rows.length<2?Jn([...h.rows.values()].map(R=>({points:R})),h.unit.focal):null,I=1/0;if(v){if(h.hasSeats)for(let R of h.rows.values())for(let x of R){let C=v.depthAt(x.x,x.y);C<I&&(I=C)}if(!h.hasSeats||!Number.isFinite(I)){I=1/0;for(let R of h.section.outline){let x=v.depthAt(R.x,R.y);x<I&&(I=x)}}}let T=p+ma,k=Math.max(T,d.height),z=R=>{let x=Math.max(0,R-I)*Be,C=Math.min(x*g,vn);return Math.max(T,d.height+C)},V=R=>{let x=Math.max(0,R)*Be,C=Math.min(x*g,vn);return Math.max(T,d.height+C)},w=P?[]:S.rows.map(R=>({pts:R.pts,y:V(R.blockDepth),depth:R.blockDepth,blockId:R.blockId,...f.has(R.id)?{patch:Co(R.pts,xe)}:{}})),F=w.length?w[0].y:k,D=w.map(R=>{let x=R.patch&&R.patch.length>=3?R.patch:R.pts,C=0,X=0;for(let U of x)C+=U.x,X+=U.y;let G=x.length||1;C/=G,X/=G;let Y=0;for(let U of x){let N=Math.hypot(U.x-C,U.y-X);N>Y&&(Y=N)}return{cx:C,cy:X,rad:Y}}),M=P?()=>k:w.length>=2?(R,x)=>{let C=1/0,X=F;for(let G=0;G<w.length;G++){let Y=D[G];if(Math.hypot(R-Y.cx,x-Y.cy)-Y.rad>=C)continue;let U=w[G].patch,N=U&&U.length>=3?mt(U,R,x)?0:_t(U,R,x):_t(w[G].pts,R,x);N<C&&(C=N,X=w[G].y)}return X}:(R,x)=>v?z(v.depthAt(R,x)):k,E=[0,1,0],B=w.length>=2||P?()=>E:(R,x)=>{if(!v)return E;let C=v.depthAt(R,x);if(C<=I)return E;let X=(C-I)*Be;if(X*g>=vn||d.height+X*g<=T)return E;let[G,Y]=v.gradientAt(R,x);if(G===0&&Y===0)return E;let U=1/Math.hypot(g,1);return[-G*g*U,U,-Y*g*U]};if(!P)for(let R of S.rows){let x=V(R.blockDepth);for(let C of R.seatIndices)a[C]=x}for(let R of S.rows){let x=[];for(let U=1;U<R.pts.length;U++){let N=Math.hypot(R.pts[U].x-R.pts[U-1].x,R.pts[U].y-R.pts[U-1].y);N>1e-6&&x.push(N)}x.sort((U,N)=>U-N);let C=x.length?x[Math.floor(x.length/2)]:1/0,X=1/0,G=R.pts[Math.floor(R.pts.length/2)];if(G)for(let U of S.rows){if(U===R||U.blockId!==R.blockId)continue;let N=_t(U.pts,G.x,G.y);N>1e-6&&N<X&&(X=N)}let Y=Math.min(C,Math.max(X,C*.5));if(Number.isFinite(Y)&&Y>0)for(let U of R.seatIndices)s[U]=Y}r.set(m,{sectionId:m,deckAt:M,normalAt:B,flat:P,bottomY:p,rowLevels:w,landingY:F})}for(let m=0;m<t.length;m++){let h=o[m],d=t[m];if(h){let g=a[m];i[m]=(g??r.get(h).deckAt(d.x,d.y))+da;continue}let p=d.eyeHeightM;i[m]=Number.isFinite(p)?Math.max(0,p-Ft):0}return{bySection:r,seatOwner:o,seatDeckY:m=>i[m],seatPitchU:m=>s[m]}}var ie={top:1,wallBottom:.5,bottomCap:.4};function _e(e,t){if(!e)return t;let n=ge(ut(e,.4),.62);return ye(t,n,.72)}function Go(e,t){let n=new Map;for(let i of e.categories??[])n.set(i.key,i.color);let r=new Map;for(let i of t){if(!i.sectionId)continue;let a=r.get(i.sectionId);a||(a=new Map,r.set(i.sectionId,a)),a.set(i.categoryKey,(a.get(i.categoryKey)??0)+1)}let o=new Map;for(let[i,a]of r){let s=0,c=0,l=0,f=0;for(let[u,m]of a){let h=ee(n.get(u));h&&(s+=h[0]*m,c+=h[1]*m,l+=h[2]*m,f+=m)}f>0&&o.set(i,[s/f,c/f,l/f])}return o}function Uo(e,t){return ee(e.color)??t.get(e.logicalSectionId??e.id)??null}import ha from"polygon-clipping";function fa(e,t){return e===void 0||t===void 0?!0:Math.abs(e-t)<.001}var Yt=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(t,n){let r=t.map(c=>[c.x,c.y]);if(r.length<3)return[];r.push(r[0]);let o=nt(t),i=this.rings.filter((c,l)=>Dt(o,this.boxes[l])&&fa(n,this.levels[l])),a=[[r]];if(i.length)try{a=ha.difference([r],...i).map(l=>l.map(f=>f.map(([u,m])=>[u,m])))}catch{a=[[r]]}this.rings.push([r]),this.boxes.push(o),this.levels.push(n);let s=[];for(let c of a){if(!c.length)continue;let l=c[0].map(([f,u])=>({x:f,y:u}));if(l.length>1){let f=l[0],u=l[l.length-1];Math.abs(f.x-u.x)<1e-9&&Math.abs(f.y-u.y)<1e-9&&l.pop()}l.length>=3&&s.push(l)}return s}};function pa(e,t){if(!t)return e;let n=1/0,r=-1/0,o=1/0,i=-1/0;for(let u of e)n=Math.min(n,u.x),r=Math.max(r,u.x),o=Math.min(o,u.y),i=Math.max(i,u.y);let a=(n+r)/2,s=(o+i)/2,c=t*Math.PI/180,l=Math.cos(c),f=Math.sin(c);return e.map(u=>{let m=u.x-a,h=u.y-s;return{x:a+m*l-h*f,y:s+m*f+h*l}})}function qe(e){let t=null;if(e.kind==="polygon"&&e.points&&e.points.length>=3&&(t=e.points),e.kind==="rect"&&e.width&&e.height&&(t=bt(e.x??0,e.y??0,e.width,e.height)),e.kind==="ellipse"&&e.width&&e.height){let n=(e.x??0)+e.width/2,r=(e.y??0)+e.height/2;t=Ut(n,r,e.width/2,e.height/2)}return t?pa(t,e.rotation):null}function yt(e){let t=e.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}},r=t==="stage"&&$n(e.stageKind)?{kind:"stage",heightM:.06}:n[t]??{kind:"plate",heightM:.25};return{...r,heightM:e.heightM??r.heightM}}var ba=.08;function Ho(e,t){let n=qe(e),r=yt(e),o=r.heightM;if(!n||r.kind!=="plate"&&r.kind!=="stage")return o;let i=1/0,a=1/0,s=-1/0,c=-1/0;for(let f of n)i=Math.min(i,f.x),a=Math.min(a,f.y),s=Math.max(s,f.x),c=Math.max(c,f.y);let l=o;for(let f of t)s>f.minX&&i<f.maxX&&c>f.minY&&a<f.maxY&&l<=f.topOffsetM+1e-6&&(l=f.topOffsetM+ba);return t.push({minX:i,minY:a,maxX:s,maxY:c,topOffsetM:l}),l}function ze(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function Xo(e){if(e.length!==4)return e;let t=Math.hypot(e[1].x-e[0].x,e[1].y-e[0].y),n=Math.hypot(e[2].x-e[1].x,e[2].y-e[1].y);return t>=n?e:[e[1],e[2],e[3],e[0]]}function gt(e,t,n){return[ze(e[0],e[1],t),ze(e[0],e[1],n),ze(e[3],e[2],n),ze(e[3],e[2],t)]}function Yo(e,t,n){return[ze(e[0],e[3],t),ze(e[1],e[2],t),ze(e[1],e[2],n),ze(e[0],e[3],n)]}function De(e,t,n,r,o,i){se(e,t,void 0,()=>n,r,o,i,ie)}var Mn=2.4,ya=.75,ga=.15;function xt(e){if(e.points&&e.points.length>=3)return e.points;let{center:t,width:n,height:r,rotation:o}=e;if(!n||!r)return null;let i=(o??0)*Math.PI/180,a=Math.cos(i),s=Math.sin(i),c=n/2,l=r/2;return[[-c,-l],[c,-l],[c,l],[-c,l]].map(([f,u])=>({x:t.x+f*a-u*s,y:t.y+f*s+u*a}))}function Wo(e,t,n,r,o){let i=xt(t);i&&se(e,i,void 0,()=>n+Mn,n,_e(r,o.boothTop),o.boothWall,ie)}function Sn(e){if(e.shape==="round"){let f=e.radius;return f?Ut(e.center.x,e.center.y,f,f,24):null}let{width:t,height:n,rotation:r,center:o}=e;if(!t||!n)return null;let i=(r??0)*Math.PI/180,a=Math.cos(i),s=Math.sin(i),c=t/2,l=n/2;return[[-c,-l],[c,-l],[c,l],[-c,l]].map(([f,u])=>({x:o.x+f*a-u*s,y:o.y+f*s+u*a}))}function jo(e,t,n,r,o){let i=Sn(t);i&&se(e,i,void 0,()=>n+ya,n,_e(r,o.tableTop),o.tableWall,ie)}function qo(e,t,n,r,o,i,a,s){let c=qe(t);if(!c)return;let l=s?s.kind==="stage":t.role==="stage",f=s?s.kind==="screen":t.role==="screen",u=s?{kind:l?"stage":"solid",heightM:s.topY-s.baseY}:yt(t),m=s?.baseY??n,h=s?.topY??n+r;if(l&&a){let y=1/0,P=-1/0,S=1/0,A=-1/0;for(let v of c)v.x<y&&(y=v.x),v.x>P&&(P=v.x),v.y<S&&(S=v.y),v.y>A&&(A=v.y);a.push({cx:(y+P)/2*_,cz:(S+A)/2*_,y:h,halfX:Math.max((P-y)/2*_,.5),halfZ:Math.max((A-S)/2*_,.5)})}let d=ee(t.fill),p=l&&d?ye(o.stageTop,ge(ut(d,.18),.9),.9):_e(d,l?o.stageTop:o.decorTop),g=f?d:null,b=l?d?ye(o.stageWall,ge(d,.58),.82):o.stageWall:f?g?ye(ge(g,1.42),[.24,.46,.82],.08):[.24,.46,.82]:_e(ee(t.fill),o.decorWall);if(u.kind==="portal"&&c.length===4){let y=Xo(c);De(e,gt(y,0,.16),h,m,p,b),De(e,gt(y,.84,1),h,m,p,b),De(e,y,h,Math.max(m,h-.35),p,b);return}if(u.kind==="suite"&&c.length===4){let y=c.map((A,v)=>{let I=c[(v+1)%4],T=(A.x+I.x)/2,k=(A.y+I.y)/2;return Math.hypot(T-i.x,k-i.y)}),P=y.indexOf(Math.min(...y)),S=[0,1,2,3].map(A=>c[(P+A)%4]);De(e,gt(S,0,.08),h,m,p,b),De(e,gt(S,.92,1),h,m,p,b),De(e,Yo(S,.88,1),h,m,p,b),De(e,S,h,Math.max(m,h-.18),p,b);return}De(e,c,h,m,p,b)}function wn(e){let{x:t,y:n,width:r,height:o}=e;if(!r||!o)return null;let i=t+r/2,a=n+o/2,s=(e.rotation??0)*Math.PI/180,c=Math.cos(s),l=Math.sin(s),f=r/2,u=o/2;return[[-f,-u],[f,-u],[f,u],[-f,u]].map(([m,h])=>({x:i+m*c-h*l,y:a+m*l+h*c}))}function xa(e){if(!e||!e.startsWith("data:image/svg+xml"))return null;let t=e.slice(e.indexOf(",")+1);if(/;base64/i.test(e.slice(0,e.indexOf(","))))try{t=atob(t)}catch{return null}else try{t=decodeURIComponent(t)}catch{}let n=t.match(/<(?:rect|path)\b[^>]*\bfill="([^"]+)"/i);if(!n)return null;let r=n[1].trim();if(r==="none"||r==="transparent")return null;let o=r.match(/^url\(#([^)]+)\)$/);if(!o)return ee(r);let i=t.match(new RegExp(`<(?:linear|radial)Gradient\\b[^>]*\\bid="${o[1]}"[^>]*>([\\s\\S]*?)</(?:linear|radial)Gradient>`,"i"));if(!i)return null;let a=[];for(let s of i[1].matchAll(/stop-color="([^"]+)"/gi)){let c=ee(s[1].trim());c&&a.push(c)}return a.length?a.reduce((s,c,l)=>ye(s,c,1/(l+1)),a[0]):null}function Ko(e,t,n,r){if(t.layer==="foreground")return;let o=wn(t);if(!o)return;let i=n+ga,a=_e(xa(t.href),r.decorTop),s=Math.max(0,Math.min(1,t.opacity??1));s<1&&(a=ye(r.ground,a,s)),se(e,o,void 0,()=>i,n,a,ye(a,r.decorWall,.5),ie)}function Zo(e,t,n,r,o){if(!t.points||t.points.length<3)return;let i=_e(r,o.gaTop);se(e,t.points,t.holes,()=>n+.15,n,i,o.gaWall,ie)}var va=.25,Ma=1.2,Sa=.6,wa=.45,Pa=2.3,Aa=Math.PI/180;function Ke(e,t,n){let r=n*Aa;return{x:e.x+t*Math.sin(r),y:e.y+t*Math.cos(r)}}function Ra(e,t){let n=t.rings[t.rings.length-1];if(!n)return!1;let r=n.outerRMedian*.85;for(let o of e){if(o.role!=="wall")continue;let i=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(i.length<2)continue;let a=0;for(let s of i)Math.hypot(s.x-t.centre.x,s.y-t.centre.y)>=r&&a++;if(a>=i.length/2)return!0}return!1}var Ca=24;function Ia(e,t,n,r,o,i,a,s){let c=n.binCount,l=Ca,f=Be,u=i+.02,m=[];for(let w=0;w<c;w++){let F=(n.startBin+w+.5)*t.binStepDeg,D=new Float64Array(l+1);for(let M=0;M<=l;M++){let E=r[w]+(o[w]-r[w])*M/l;D[M]=Math.max(u,to(t,n,F,E)-va)}m.push(D)}let h=[a.bandTop[0]*s.top,a.bandTop[1]*s.top,a.bandTop[2]*s.top],d=[a.bandTop[0]*s.bottomCap,a.bandTop[1]*s.bottomCap,a.bandTop[2]*s.bottomCap],p=[a.bandWall[0]*s.top,a.bandWall[1]*s.top,a.bandWall[2]*s.top],g=[a.bandWall[0]*s.wallBottom,a.bandWall[1]*s.wallBottom,a.bandWall[2]*s.wallBottom],b=(w,F)=>{let D=(n.startBin+w+.5)*t.binStepDeg,M=r[w]+(o[w]-r[w])*F/l,E=Ke(t.centre,M,D);return[E.x*f,m[w][F],E.y*f]};{let w=Math.tan(12*Math.PI/180);for(let F=0;F<6;F++){let D=!1;for(let E=0;E<c;E++)for(let B=l-1;B>=0;B--)m[E][B]>m[E][B+1]&&(m[E][B]=m[E][B+1],D=!0);let M=n.closed?c:c-1;for(let E=0;E<M;E++){let B=(E+1)%c;for(let R=0;R<=l;R++){let x=m[B][R]-m[E][R];if(Math.abs(x)>1)continue;let C=r[E]+(o[E]-r[E])*R/l,X=r[B]+(o[B]-r[B])*R/l,G=Ke(t.centre,C,(n.startBin+E+.5)*t.binStepDeg),Y=Ke(t.centre,X,(n.startBin+B+.5)*t.binStepDeg),U=w*Math.hypot(Y.x-G.x,Y.y-G.y)*f;x>U?(m[B][R]=m[E][R]+U,D=!0):-x>U&&(m[E][R]=m[B][R]+U,D=!0)}}if(!D)break}}let y=1,P=(w,F)=>{for(let D=0;D<=l;D+=4)if(Math.abs(m[w][D]-m[F][D])>y)return!0;return Math.abs(m[w][l]-m[F][l])>y},S=Math.tan(38*Math.PI/180),A=w=>(o[w]-r[w])/l*f,v=(w,F)=>m[w][F+1]-m[w][F]>S*Math.max(1e-6,A(w)),I=(w,F)=>{let D=n.closed?(w-1+c)%c:Math.max(0,w-1),M=n.closed?(w+1)%c:Math.min(c-1,w+1);Math.abs(m[D][F]-m[w][F])>y&&(D=w),Math.abs(m[M][F]-m[w][F])>y&&(M=w);let E=Math.max(0,F-1),B=Math.min(l,F+1);E<F&&v(w,E)&&(E=F),B>F&&v(w,F)&&(B=F);let R=b(D,F),x=b(M,F),C=b(w,E),X=b(w,B),G=x[0]-R[0],Y=x[1]-R[1],U=x[2]-R[2],N=X[0]-C[0],H=X[1]-C[1],j=X[2]-C[2],W=Y*j-U*H,K=U*N-G*j,Q=G*H-Y*N,$=Math.hypot(W,K,Q);return $>1e-12?(W/=$,K/=$,Q/=$,K<0&&(W=-W,K=-K,Q=-Q),[W,K,Q]):[0,1,0]},T=(w,F)=>{let D=[w[0],i,w[2]],M=[F[0],i,F[2]],E=F[0]-w[0],B=F[2]-w[2],R=Math.hypot(E,B);if(!(R>1e-12))return;let x=[B/R,0,-E/R];e.tri(w,F,M,x,p,p,g),e.tri(w,M,D,x,p,g,g)},k=.05*Ne,z=w=>o[w]-r[w]<k,V=n.closed?c:c-1;for(let w=0;w<V;w++){let F=(w+1)%c;if(z(w)||z(F))continue;if(P(w,F)){let x=(n.startBin+w+1)*t.binStepDeg,C=(H,j)=>{let W=(r[w]+r[F])/2,K=(o[w]+o[F])/2,Q=W+(K-W)*j/l,$=Ke(t.centre,Q,x);return[$.x*f,m[H][j],$.y*f]};for(let H=0;H<l;H++){let j=b(w,H),W=b(w,H+1),K=C(w,H),Q=C(w,H+1),$=I(w,H),ae=I(w,H+1);e.triN(j,K,Q,$,$,ae,h),e.triN(j,Q,W,$,ae,ae,h);let Pe=b(F,H),ve=b(F,H+1),Me=C(F,H),Ie=C(F,H+1),Ee=I(F,H),ke=I(F,H+1);e.triN(Me,Pe,ve,Ee,Ee,ke,h),e.triN(Me,ve,Ie,Ee,ke,ke,h);let be=C(w,H),le=C(w,H+1),Le=C(F,H+1),it=C(F,H),Se=le[0]-be[0],Ue=le[2]-be[2],Te=Math.hypot(Se,Ue);if(Te>1e-12){let Rt=[Ue/Te,0,-Se/Te];e.tri(be,le,Le,Rt,p),e.tri(be,Le,it,Rt,p)}}let X=b(w,0),G=b(F,0),Y=b(F,l),U=b(w,l),N=H=>[H[0],i,H[2]];e.tri(N(X),N(Y),N(G),[0,-1,0],d),e.tri(N(X),N(U),N(Y),[0,-1,0],d),T(X,G),T(U,Y);continue}for(let x=0;x<l;x++){let C=I(w,x),X=I(F,x),G=I(F,x+1),Y=I(w,x+1);if(v(w,x)||v(F,x)){let W=(le,Le)=>{let it=(n.startBin+le+.5)*t.binStepDeg,Se=r[le]+(o[le]-r[le])*(x+.5)/l,Ue=Ke(t.centre,Se,it);return[Ue.x*f,Le,Ue.y*f]},K=b(w,x),Q=b(F,x),$=W(w,m[w][x]),ae=W(F,m[F][x]);e.triN(K,Q,ae,C,X,X,h),e.triN(K,ae,$,C,X,C,h);let Pe=b(F,x+1),ve=b(w,x+1),Me=W(w,m[w][x+1]),Ie=W(F,m[F][x+1]);e.triN(Me,Ie,Pe,Y,G,G,h),e.triN(Me,Pe,ve,Y,G,Y,h);let Ee=ae[0]-$[0],ke=ae[2]-$[2],be=Math.hypot(Ee,ke);if(be>1e-12){let le=[-ke/be,0,Ee/be];e.tri($,ae,Ie,le,p),e.tri($,Ie,Me,le,p)}continue}let U=b(w,x),N=b(F,x),H=b(F,x+1),j=b(w,x+1);e.triN(U,N,H,C,X,G,h),e.triN(U,H,j,C,G,Y,h)}let D=b(w,0),M=b(F,0),E=b(F,l),B=b(w,l),R=x=>[x[0],i,x[2]];e.tri(R(D),R(E),R(M),[0,-1,0],d),e.tri(R(D),R(B),R(E),[0,-1,0],d),T(D,M),T(B,E)}if(!n.closed)for(let w of[0,c-1])for(let F=0;F<l;F++)T(b(w,F),b(w,F+1))}function Qo(e,t,n){let{bottomY:r,colors:o,ao:i}=n,a=new Float64Array(t.binCount).fill(-1/0);for(let f of t.rings)for(let u of f.arcs){let m=new Float64Array(u.binCount),h=new Float64Array(u.binCount);for(let p=0;p<u.binCount;p++){let g=(u.startBin+p)%t.binCount,b=Math.max(0,u.innerR[p]-xe);m[p]=Math.max(b,a[g]+.001),h[p]=Math.max(m[p]+.001,u.outerR[p]+xe)}let d=0;for(let p=0;p<u.binCount;p++){let g=u.topLevelM[p]-r;g>d&&(d=g)}d>=Ma&&Ia(e,t,u,m,h,r,o,i);for(let p=0;p<u.binCount;p++){let g=(u.startBin+p)%t.binCount;h[p]>a[g]&&(a[g]=h[p])}}if(n.deriveShell===!1||Ra(n.shapes,t))return;let s=t.rings[t.rings.length-1],c=Sa*Ne,l=wa*Ne;for(let f of s.arcs){let u=[],m=[];for(let p=0;p<f.binCount;p++){let g=(f.startBin+p+.5)*t.binStepDeg,b=f.outerR[p]+xe+c;u.push(Ke(t.centre,b,g)),m.push(Ke(t.centre,b+l,g))}let h=-1/0;for(let p=0;p<f.binCount;p++)f.topLevelM[p]>h&&(h=f.topLevelM[p]);let d=()=>h+Pa;f.closed?se(e,m,[u.slice().reverse()],d,r,o.shellTop,o.shellWall,i):se(e,[...m,...u.slice().reverse()],void 0,d,r,o.shellTop,o.shellWall,i)}}function $o(e,t,n,r,o,i,a,s){if(!t.outline||t.outline.length<3)return;let c=n.baseHeightM,l=_e(r,s.tierTop);if(!o)return;let f=g=>o.deckAt(g.x,g.y),u=Oo(t,a),m=u[0]??t.outline;if(o.rowLevels.length>=2){let g=Xt(o.rowLevels),b=Bo(Fo(o.rowLevels,n.focal,g),u),y=()=>[0,1,0];for(let S of b){let A=Math.max(c,S.topY-.02);for(let v of i.subtract(S.outline,A))se(e,v,S.holes,()=>A,c,l,s.tierWall,ie,void 0,y)}b.length||se(e,m,t.holes,()=>o.landingY,c,l,s.tierWall,ie);let P={tread:[l[0]*ie.top,l[1]*ie.top,l[2]*ie.top],riser:[l[0]*.72,l[1]*.72,l[2]*.72]};for(let S of u.length?u:[m])Do(e,o.rowLevels,n.focal,o.landingY,P,S,g);return}let h=o.flat?1/0:No,d=g=>o.normalAt(g.x,g.y),p=o.flat?o.landingY:void 0;for(let g of i.subtract(m,p))se(e,g,t.holes,f,c,l,s.tierWall,ie,h,d)}function Ea(e,t,n){let r=new Set;for(let a of e.objects)a.type==="section"&&r.add(a.id);let o=new Map;for(let a=0;a<t.length;a++){let s=n.seatOwner[a];if(!s||!r.has(s))continue;let c=n.bySection.get(s);if(c&&c.rowLevels.length>=2)continue;let l=t[a],f=o.get(s);f||(f=new Map,o.set(s,f));let u=l.rowId||`__seat-${a}`,m=f.get(u);m||(m={pts:[],levelM:0,n:0},f.set(u,m)),m.pts.push({x:l.x,y:l.y}),m.levelM+=n.seatDeckY(a),m.n++}let i=[];for(let a of e.objects){if(a.type!=="section")continue;let s=n.bySection.get(a.id);if(s&&s.rowLevels.length>=2){let l=s.rowLevels.filter(f=>!f.patch).map(f=>({pts:f.pts,levelM:f.y}));l.length>=2&&i.push({sectionId:a.id,rows:l});continue}let c=o.get(a.id);c&&i.push({sectionId:a.id,rows:[...c.values()].map(l=>({pts:l.pts,levelM:l.levelM/l.n}))})}return i}function Jo(e,t,n,r,o,i,a=!0){let s=Ea(t,n,r);if(!s.length)return;let c=eo(s,t.focal);c&&(e.setMaterial(0),Qo(e,c,{bottomY:t.baseHeightM,colors:{bandTop:ge(o.tierTop,.8),bandWall:o.tierWall,shellTop:i??ge(o.tierWall,1.15),shellWall:i??o.tierWall},ao:ie,shapes:t.objects.filter(l=>l.type==="shape"),deriveShell:a}))}function er(e,t,n){return n<0?t>1?e.filter(r=>r.kind==="floor"):[...e]:e.filter(r=>r.floorIndex===void 0||r.floorIndex===n)}function tr(e,t){let n=[...e].sort((o,i)=>o.screen.y-i.screen.y),r=[];for(let o of n){let i=r.find(a=>a.some(s=>Math.abs(s.screen.x-o.screen.x)<104&&Math.abs(s.screen.y-o.screen.y)<34));i?i.push(o):r.push([o])}return r.flatMap(o=>o.length<2?o:o.map((i,a)=>({...i,screen:{...i.screen,x:Math.max(54,Math.min(t-54,i.screen.x+(a-(o.length-1)/2)*104))}})))}var Ta=1.15,Fa=3.25,_a=4.5,Da=.85,ka=.5,La=.26;function nr(e,t,n){let r=Math.max(1e-6,t),o=e/r,i=n?.hasZoneLabels??!0,a=new Set;return o>=.75&&a.add("floor"),o>=Ta&&a.add("zone"),o<=(i?Fa:_a)&&(a.add("section"),a.add("ga")),o<=Da&&(a.add("annotation"),a.add("booth")),o<=ka&&a.add("row"),o<=La&&a.add("seat"),a}function Ge(e,t,n,r){let o=e,i=t[0],a=t[1],s=t[2],c=o[0]*i+o[4]*a+o[8]*s+o[12],l=o[1]*i+o[5]*a+o[9]*s+o[13],f=o[2]*i+o[6]*a+o[10]*s+o[14],u=o[3]*i+o[7]*a+o[11]*s+o[15];if(!(u>1e-6))return{x:0,y:0,depth:1/0,visible:!1};let m=c/u,h=l/u,d=f/u,p=m>=-1.05&&m<=1.05&&h>=-1.05&&h<=1.05&&d<=1;return{x:(m*.5+.5)*n,y:(1-(h*.5+.5))*r,depth:d,visible:p}}function or(e,t,n=t){let r=[],o=[...e].sort((i,a)=>i.screen.depth-a.screen.depth);for(let i of o){let a=!1;for(let s of r)if(Pn(i,s,t,n)){a=!0;break}a||r.push(i)}return r}var Va=6;function Pn(e,t,n,r){let o=Math.abs(e.screen.x-t.screen.x),i=Math.abs(e.screen.y-t.screen.y),a=e.halfWidth!=null&&t.halfWidth!=null?Math.max(n,e.halfWidth+t.halfWidth+Va):n;return o<a&&i<r}function rr(e,t,n){return e.length*t*.58+(n?14:0)}var An={row:8,seat:14};function ir(e,t,n,r){let o=Math.max(1,Math.min(n,r)*.5),i=Math.min(2,Math.hypot(e.x-n/2,e.y-r/2)/o);return t*(1+1.5*i)}function Rn(e,t,n,r,o=[]){let i=[...e].sort((s,c)=>(c.priority??0)-(s.priority??0)||s.focus-c.focus),a=[];for(let s of i){if(a.length>=r)break;let c=!1;for(let l of o)if(Pn(s,l,t,n)){c=!0;break}if(!c){for(let l of a)if(Pn(s,l,t,n)){c=!0;break}}c||a.push(s)}return a}var Oa=6,Ba=2.2,ar=.1,Na=.3,za=1.8,Ga=.9,Ua=.55,Ha=6e3;function sr(e){let{doc:t,units:n,seats:r,surfaces:o,focal:i}=e,a=t.zones??[],s=[];if(a.length){let c=new Map;for(let f of n)for(let u of f.objects)u.type==="section"&&u.zone&&c.set(u.id,u.zone);let l=new Map;for(let f=0;f<r.length;f++){let u=r[f],m=o.seatOwner[f],h=u.zoneId??(m?c.get(m):void 0);if(!h)continue;let d=l.get(h);d||(d={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},l.set(h,d)),d.n++,u.x<d.minX&&(d.minX=u.x),u.y<d.minY&&(d.minY=u.y),u.x>d.maxX&&(d.maxX=u.x),u.y>d.maxY&&(d.maxY=u.y),d.sumY+=o.seatDeckY(f)}for(let f of a){let u=l.get(f.id),m=[];for(let[h,d]of c)d===f.id&&m.push(h);if(!u||u.n===0){s.push({id:f.id,label:f.label,color:ee(f.color),sectionIds:m,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(f.focalPoint??i).x*_,1.5,(f.focalPoint??i).y*_]});continue}s.push({id:f.id,label:f.label,color:ee(f.color),sectionIds:m,seatCount:u.n,center:[(u.minX+u.maxX)/2*_,u.sumY/u.n,(u.minY+u.maxY)/2*_],radius:.5*Math.hypot((u.maxX-u.minX)*_,(u.maxY-u.minY)*_)||1,focalWorld:[(f.focalPoint??i).x*_,1.5,(f.focalPoint??i).y*_]})}}return s}function cr(e){let{doc:t,units:n,seats:r,surfaces:o,seatData:i,hintedSeatFloor:a,zones:s,focal:c}=e,l=[],f=[],u=[];for(let m of s)m.seatCount!==0&&l.push({id:`zone:${m.id}`,kind:"zone",text:m.label,anchor:[m.center[0],m.center[1]+Oa,m.center[2]],color:t.zones?.find(h=>h.id===m.id)?.color});{let m=new Map,h=new Map;for(let d=0;d<r.length;d++){let p=o.seatOwner[d];if(!p)continue;let g=m.get(p);g||(g={n:0,x:0,y:0,deck:0},m.set(p,g)),g.n++,g.x+=r[d].x,g.y+=r[d].y,g.deck+=o.seatDeckY(d);let b=h.get(p);b||(b={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0},h.set(p,b)),r[d].x<b.minX&&(b.minX=r[d].x),r[d].x>b.maxX&&(b.maxX=r[d].x),r[d].y<b.minY&&(b.minY=r[d].y),r[d].y>b.maxY&&(b.maxY=r[d].y)}for(let d of n)for(let p of d.objects){if(p.type!=="section")continue;let g=m.get(p.id);if(!g||g.n===0)continue;let b=h.get(p.id),y=[g.x/g.n*_,g.deck/g.n,g.y/g.n*_],P=p.displayLabel||p.label||p.id;f.push({id:p.id,floorIndex:d.index,label:P,seatCount:g.n,center:y,radius:Math.max(1,Math.hypot(b.maxX-b.minX,b.maxY-b.minY)*.5*_),focalWorld:[d.focal.x*_,d.baseHeightM+1.5,d.focal.y*_]});let S=t.floors?.[d.index]?.name?.trim().toLocaleLowerCase();n.length>1&&S===P.trim().toLocaleLowerCase()||l.push({id:`section:${p.id}`,kind:"section",text:P,anchor:[y[0],y[1]+Ba,y[2]],floorIndex:d.index})}}{for(let d of n)for(let p of d.objects){if(p.type!=="gaArea")continue;let g=lt(p.points);if(!g)continue;let b=p.displayLabel||p.label||p.id;l.push({id:`ga:${p.id}`,kind:"ga",text:p.capacity>0?`${b} \xB7 ${p.capacity.toLocaleString()}`:b,anchor:[g.x*_,d.baseHeightM+za,g.y*_],floorIndex:d.index})}let m=new Map;for(let d=0;d<r.length;d++){let p=r[d],g=Math.hypot(p.x-c.x,p.y-c.y),b=m.get(p.rowId);(!b||g>b.far)&&m.set(p.rowId,{seat:p,index:d,far:g})}for(let[d,p]of m){let g=p.seat.label?p.seat.label.lastIndexOf("-"):-1,b=g>0?p.seat.label.slice(0,g):d;b&&l.push({id:`row:${d}`,kind:"row",text:b,anchor:[p.seat.x*_,o.seatDeckY(p.index)+Ga,p.seat.y*_],floorIndex:a[p.index]})}let h=new Map;for(let d=0;d<r.length;d++){let p=r[d],g=p.label?p.label.lastIndexOf("-"):-1,b=h.get(p.rowId);b||(b={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:g>0?p.label.slice(0,g):p.rowId,sectionId:p.sectionId},h.set(p.rowId,b));let y=d*3,P=i.iPosition[y],S=i.iPosition[y+1],A=i.iPosition[y+2];b.n++,b.x+=P,b.y+=S,b.z+=A,b.minX=Math.min(b.minX,P),b.maxX=Math.max(b.maxX,P),b.minZ=Math.min(b.minZ,A),b.maxZ=Math.max(b.maxZ,A)}for(let[d,p]of h)u.push({id:d,label:p.label,sectionId:p.sectionId,seatCount:p.n,center:[p.x/p.n,p.y/p.n,p.z/p.n],radius:Math.max(.8,Math.hypot(p.maxX-p.minX,p.maxZ-p.minZ)*.5)});if(r.length<=Ha)for(let d=0;d<r.length;d++){let p=r[d],g=p.displayLabel||p.label;g&&l.push({id:`seat:${p.id}`,kind:"seat",text:g,anchor:[p.x*_,o.seatDeckY(d)+Ua,p.y*_],floorIndex:a[d]})}}for(let m of n)for(let h of m.objects)if(h.type==="shape"&&h.role&&["entrance","exit","screen","suite","obstruction"].includes(h.role)){let d=qe(h),p=d?lt(d):null;if(!p||!h.label)continue;l.push({id:`architecture:${h.id}`,kind:"annotation",text:h.label,anchor:[p.x*_,m.baseHeightM+yt(h).heightM+ar,p.y*_],color:h.fill,floorIndex:m.index})}else if(h.type==="text"){if(!h.text)continue;l.push({id:`text:${h.id}`,kind:"annotation",text:h.text,anchor:[h.position.x*_,m.baseHeightM+ar,h.position.y*_],color:h.color,rotation:h.rotation,floorIndex:m.index})}else if(h.type==="booth"){let d=xt(h);if(!d)continue;let p=lt(d);if(!p)continue;l.push({id:`booth:${h.id}`,kind:"booth",text:h.displayLabel||h.label||h.id,anchor:[p.x*_,m.baseHeightM+Mn+Na,p.y*_],floorIndex:m.index})}return{labels:l,sections:f,rows:u}}function lr(e,t){if(t.length>1)for(let n of t)e.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 ur(e){let{doc:t,units:n,seats:r,surfaces:o,solids:i,hintedSeatFloor:a,seatFloor:s}=e,c=[];{let l=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<i.floor.length;m+=1){let h=Math.max(0,Math.min(n.length-1,Math.round(i.floor[m]))),d=m*3,p=l[h];p.minX=Math.min(p.minX,i.position[d]),p.minY=Math.min(p.minY,i.position[d+1]),p.minZ=Math.min(p.minZ,i.position[d+2]),p.maxX=Math.max(p.maxX,i.position[d]),p.maxY=Math.max(p.maxY,i.position[d+1]),p.maxZ=Math.max(p.maxZ,i.position[d+2])}let f=new Map;for(let m=0;m<n.length;m++)for(let h of n[m].objects)h.type==="section"&&f.set(h.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<r.length;m++){let h=o.seatOwner[m],d=(h!==null?f.get(h):void 0)??a[m];if(d===void 0)continue;let p=u[d],g=r[m];p.n++,g.x<p.minX&&(p.minX=g.x),g.y<p.minY&&(p.minY=g.y),g.x>p.maxX&&(p.maxX=g.x),g.y>p.maxY&&(p.maxY=g.y);let b=o.seatDeckY(m);p.sumX+=g.x*_,p.sumDeck+=b,p.sumZ+=g.y*_,p.minDeck=Math.min(p.minDeck,b),p.maxDeck=Math.max(p.maxDeck,b+1.6),s[m]=d}for(let m=0;m<n.length;m++){let h=u[m],d=t.floors?.[m],p=l[m],g=Math.min(h.n?h.minX*_:n[m].focal.x*_-1,Number.isFinite(p.minX)?p.minX:1/0),b=Math.max(h.n?h.maxX*_:n[m].focal.x*_+1,Number.isFinite(p.maxX)?p.maxX:-1/0),y=Math.min(h.n?h.minY*_:n[m].focal.y*_-1,Number.isFinite(p.minZ)?p.minZ:1/0),P=Math.max(h.n?h.maxY*_:n[m].focal.y*_+1,Number.isFinite(p.maxZ)?p.maxZ:-1/0),S=Math.min(h.n?Math.min(n[m].baseHeightM,h.minDeck):n[m].baseHeightM,Number.isFinite(p.minY)?p.minY:1/0),A=Math.max(h.n?Math.max(h.maxDeck,S+.5):S+.5,Number.isFinite(p.maxY)?p.maxY:-1/0),v=[h.n?h.sumX/h.n:(g+b)/2,h.n?h.sumDeck/h.n:(S+A)/2,h.n?h.sumZ/h.n:(y+P)/2],I=Math.max(1,.5*Math.hypot(b-g,A-S,P-y));c.push({index:m,id:d?.id??`floor-${m}`,label:d?.name??(n.length>1?`Floor ${m+1}`:"Venue"),seatCount:h.n,center:v,radius:I,box:{min:[g,S,y],max:[b,A,P]},focalWorld:[n[m].focal.x*_,n[m].baseHeightM+1.5,n[m].focal.y*_]})}}return c}function Cn(e,t){let n=1/0,r=1/0,o=-1/0,i=-1/0,a=(s,c)=>{s<n&&(n=s),c<r&&(r=c),s>o&&(o=s),c>i&&(i=c)};for(let s of t)a(s.x,s.y);for(let s of e)for(let c of s.objects)if(c.type==="section")for(let l of c.outline)a(l.x,l.y);else if(c.type==="shape"&&c.points)for(let l of c.points)a(l.x,l.y);else if(c.type==="gaArea")for(let l of c.points)a(l.x,l.y);else if(c.type==="booth"){let l=xt(c);if(l)for(let f of l)a(f.x,f.y)}else if(c.type==="table"){let l=Sn(c);if(l)for(let f of l)a(f.x,f.y)}else if(c.type==="decorImage"){let l=wn(c);if(l)for(let f of l)a(f.x,f.y)}return Number.isFinite(n)||(n=-100,r=-100,o=100,i=100),{minX:n,minY:r,maxX:o,maxY:i}}function mr(e,t,n,r,o,i){if(t.length===1){let a=Math.max(60,(o.maxX-o.minX+o.maxY-o.minY)*.06),s=bt(o.minX-a,o.minY-a,o.maxX-o.minX+a*2,o.maxY-o.minY+a*2);se(e,s,void 0,()=>0,-.4,i.ground,i.ground,ie)}else{let a=t.reduce((h,d)=>d.baseHeightM<h.baseHeightM?d:h);e.setFloor(a.index);let s=n.filter((h,d)=>r[d]===a.index),c=Cn([a],s),l=Math.hypot(c.maxX-c.minX,c.maxY-c.minY),f=Math.max(28,Math.min(80,l*.04)),u=bt(c.minX-f,c.minY-f,c.maxX-c.minX+f*2,c.maxY-c.minY+f*2),m=a.baseHeightM-.03;se(e,u,void 0,()=>m,m-.22,i.ground,i.ground,ie)}}function dr(e,t,n){let{cx:r,cz:o,radius:i}=n,a=1/0,s=1/0,c=1/0,l=-1/0,f=-1/0,u=-1/0,m=(p,g,b)=>{a=Math.min(a,p),l=Math.max(l,p),s=Math.min(s,g),f=Math.max(f,g),c=Math.min(c,b),u=Math.max(u,b)};for(let p=0;p<e.position.length;p+=3)m(e.position[p],e.position[p+1],e.position[p+2]);for(let p=0;p<t.count;p++){let g=p*3,b=t.iPosition[g],y=t.iPosition[g+1],P=t.iPosition[g+2],S=Math.max(.35,t.iMaxRadius[p]??.35);m(b-S,y,P-S),m(b+S,y+1.6,P+S)}Number.isFinite(a)||(a=r-i,l=r+i,s=0,f=i*.16,c=o-i,u=o+i);let h=[(a+l)/2,(s+f)/2,(c+u)/2],d=Math.max(1,.5*Math.hypot(l-a,f-s,u-c));return{center:h,radius:d,minY:s,maxY:f}}function hr(e,t,n,r,o,i){let a=1/0,s=1/0,c=-1/0,l=-1/0;for(let S=0;S<e.count;S++){let A=S*3,v=e.iPosition[A],I=e.iPosition[A+2];v<a&&(a=v),v>c&&(c=v),I<s&&(s=I),I>l&&(l=I)}for(let S of t)a=Math.min(a,S.cx-S.halfX),c=Math.max(c,S.cx+S.halfX),s=Math.min(s,S.cz-S.halfZ),l=Math.max(l,S.cz+S.halfZ);let f=n.minX*_,u=n.maxX*_,m=n.minY*_,h=n.maxY*_,d=f,p=u,g=m,b=h;if(Number.isFinite(a)){let S=Math.max(2,.06*Math.hypot(c-a,l-s));d=Math.max(f,a-S),p=Math.min(u,c+S),g=Math.max(m,s-S),b=Math.min(h,l+S)}let y=Math.min(0,r),P=Math.max(o,i*.05);return{min:[d,y,g],max:[p,P,b]}}function fr(e,t,n){let r=()=>({byObjectId:new Map,elements:[]});if(!t||!e)return r();let o=Xn(t);if(!o.ok||o.value.id!==e)return r();let i=new Map;for(let u of n)for(let m of u.objects)m.type==="shape"&&i.set(m.id,{shape:m,unit:u});let a=new Set,s=new Set,c=new Map((t.overlay.productionElements??[]).map(u=>{let m=u.runtimeContentImageUrl;return[u.id,typeof m=="string"&&/^(?:blob:|data:image\/|https:\/\/)/.test(m)?m:void 0]})),l=[];for(let u of o.value.overlay.productionElements??[]){let m=i.get(u.objectId),h=m?qe(m.shape):null,d=u.baseElevationM??0;if(!m||!h||h.length<3||!u.id||a.has(u.id)||s.has(u.objectId)||!Number.isFinite(u.heightM)||u.heightM<.05||u.heightM>50||!Number.isFinite(d)||d<-10||d>100)return r();a.add(u.id),s.add(u.objectId);let p=h.map(T=>T.x*_),g=h.map(T=>T.y*_),b=m.unit.baseHeightM+d,y=Math.min(...p),P=Math.max(...p),S=Math.min(...g),A=Math.max(...g),v,I=c.get(u.id)??u.contentImageUrl;if(u.kind==="screen"&&I)if(P-y>=A-S){let T=Math.abs(S-m.unit.focal.y*_)<=Math.abs(A-m.unit.focal.y*_)?S-.006:A+.006;v=[[y,b,T],[P,b,T],[y,b+u.heightM,T],[P,b+u.heightM,T]]}else{let T=Math.abs(y-m.unit.focal.x*_)<=Math.abs(P-m.unit.focal.x*_)?y-.006:P+.006;v=[[T,b,S],[T,b,A],[T,b+u.heightM,S],[T,b+u.heightM,A]]}l.push({id:u.id,objectId:u.objectId,kind:u.kind,floorIndex:m.unit.index,baseY:b,topY:b+u.heightM,bounds:{min:[y,b,S],max:[P,b+u.heightM,A]},occlusion:u.occlusion,...I?{contentImageUrl:I}:{},...v?{contentPlane:v}:{}})}let f=l.sort((u,m)=>u.id.localeCompare(m.id));return{byObjectId:new Map(f.map(u=>[u.objectId,u])),elements:f}}function fe(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function he(e){return Array.isArray(e)?e:[]}function Xa(e){let t=[e];for(;t.length;){let n=t.pop();if(Array.isArray(n)){t.push(...n);continue}if(!fe(n))continue;let r=fe(n.extensions)?n.extensions:null;if(r&&Object.prototype.hasOwnProperty.call(r,"KHR_draco_mesh_compression"))return!0;t.push(...Object.values(n))}return!1}function Wt(e,t){return!Array.isArray(e)||e.length!==t||!e.every(n=>typeof n=="number"&&Number.isFinite(n))?null:e}function Ya(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Wa(e,t){let n=new Array(16).fill(0);for(let r=0;r<4;r++)for(let o=0;o<4;o++)for(let i=0;i<4;i++)n[r*4+o]+=e[i*4+o]*t[r*4+i];return n}function ja(e){let t=Wt(e.matrix,16);if(t)return t;if(e.matrix!==void 0)return null;let n=e.translation===void 0?[0,0,0]:Wt(e.translation,3),r=e.rotation===void 0?[0,0,0,1]:Wt(e.rotation,4),o=e.scale===void 0?[1,1,1]:Wt(e.scale,3);if(!n||!r||!o)return null;let[i,a,s,c]=r,l=Math.hypot(i,a,s,c);if(!(l>1e-8))return null;let f=i/l,u=a/l,m=s/l,h=c/l,d=f+f,p=u+u,g=m+m,b=f*d,y=f*p,P=f*g,S=u*p,A=u*g,v=m*g,I=h*d,T=h*p,k=h*g;return[(1-(S+v))*o[0],(y+k)*o[0],(P-T)*o[0],0,(y-k)*o[1],(1-(b+v))*o[1],(A+I)*o[1],0,(P+T)*o[2],(A-I)*o[2],(1-(b+S))*o[2],0,n[0],n[1],n[2],1]}function qa(e,t,n,r){return[e[0]*t+e[4]*n+e[8]*r+e[12],e[1]*t+e[5]*n+e[9]*r+e[13],e[2]*t+e[6]*n+e[10]*r+e[14]]}function Ka(e){let t=e[0],n=e[4],r=e[8],o=e[1],i=e[5],a=e[9],s=e[2],c=e[6],l=e[10],f=i*l-a*c,u=a*s-o*l,m=o*c-i*s,h=t*f+n*u+r*m;if(Math.abs(h)<1e-12)return null;let d=1/h;return[f*d,u*d,m*d,(r*c-n*l)*d,(t*l-r*s)*d,(n*s-t*c)*d,(n*a-r*i)*d,(r*o-t*a)*d,(t*i-n*o)*d]}function pr(e,t,n,r){let o=e[0]*t+e[1]*n+e[2]*r,i=e[3]*t+e[4]*n+e[5]*r,a=e[6]*t+e[7]*n+e[8]*r,s=Math.hypot(o,i,a)||1;return o/=s,i/=s,a/=s,[o,i,a]}function Za(e){if(e.byteLength<20||e.byteLength>8388608)return null;let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getUint32(0,!0)!==1179937895||t.getUint32(4,!0)!==2||t.getUint32(8,!0)!==e.byteLength)return null;let n=12,r=null,o=null;for(;n+8<=e.byteLength;){let i=t.getUint32(n,!0),a=t.getUint32(n+4,!0);if(n+=8,i%4!==0||n+i>e.byteLength)return null;let s=e.subarray(n,n+i);if(a===1313821514&&!r)try{let c=JSON.parse(new TextDecoder().decode(s).replace(/[\u0000 ]+$/g,""));if(!fe(c))return null;r=c}catch{return null}else if(a===5130562&&!o)o=s;else return null;n+=i}return n===e.byteLength&&r&&o?{json:r,bin:o}:null}function Qa(e){return e===5120||e===5121?1:e===5122||e===5123?2:e===5125||e===5126?4:0}function $a(e){return e==="SCALAR"?1:e==="VEC2"?2:e==="VEC3"?3:e==="VEC4"?4:0}function Ja(e,t,n){return n===5120?e.getInt8(t):n===5121?e.getUint8(t):n===5122?e.getInt16(t,!0):n===5123?e.getUint16(t,!0):n===5125?e.getUint32(t,!0):e.getFloat32(t,!0)}function es(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=Za(t);if(!n)return{ok:!1,issue:"invalid_glb"};let{json:r,bin:o}=n;if(!fe(r.asset)||r.asset.version!=="2.0")return{ok:!1,issue:"unsupported_glb"};let i=he(r.extensionsUsed).filter(S=>typeof S=="string");if(i.includes("KHR_draco_mesh_compression")||Xa(r))return{ok:!1,issue:"draco_not_allowed"};if(i.length||he(r.extensionsRequired).length)return{ok:!1,issue:"unsupported_glb"};if(he(r.images).length||he(r.textures).length)return{ok:!1,issue:"external_resource"};let a=he(r.buffers);if(a.length!==1||!fe(a[0])||a[0].uri!==void 0||typeof a[0].byteLength!="number"||!Number.isInteger(a[0].byteLength)||a[0].byteLength<0||a[0].byteLength>o.byteLength)return{ok:!1,issue:"external_resource"};let s=he(r.accessors),c=he(r.bufferViews),l=he(r.meshes),f=he(r.nodes),u=he(r.scenes),m=typeof r.scene=="number"?r.scene:0;if(!fe(u[m]))return{ok:!1,issue:"unsupported_glb"};let h=new DataView(o.buffer,o.byteOffset,o.byteLength),d=(S,A,v)=>{if(typeof S!="number"||!Number.isInteger(S)||!fe(s[S]))return null;let I=s[S];if(I.type!==A||I.sparse!==void 0||I.normalized===!0||typeof I.count!="number"||!Number.isInteger(I.count)||I.count<1||typeof I.componentType!="number"||!v.includes(I.componentType)||typeof I.bufferView!="number")return null;let T=c[I.bufferView];if(!fe(T)||T.buffer!==0||typeof T.byteLength!="number"||!Number.isInteger(T.byteLength)||T.byteLength<0)return null;let k=$a(I.type),z=Qa(I.componentType),V=typeof T.byteStride=="number"?T.byteStride:k*z,w=typeof T.byteOffset=="number"?T.byteOffset:0,F=typeof I.byteOffset=="number"?I.byteOffset:0,D=w+F,M=F+(I.count-1)*V+k*z;if(!Number.isInteger(V)||!Number.isInteger(w)||!Number.isInteger(F)||V<k*z||w<0||F<0||w+T.byteLength>o.byteLength||M>T.byteLength)return null;let E=[];for(let B=0;B<I.count;B++){let R=[];for(let x=0;x<k;x++){let C=Ja(h,D+B*V+x*z,I.componentType);if(!Number.isFinite(C))return null;R.push(C)}E.push(R)}return E},p=[],g=[],b=0,y=new Set,P=(S,A)=>{if(typeof S!="number"||!Number.isInteger(S)||!fe(f[S])||y.has(S))return!1;y.add(S);let v=f[S],I=ja(v);if(!I)return!1;let T=Wa(A,I),k=Ka(T);if(!k)return!1;if(v.mesh!==void 0){if(typeof v.mesh!="number")return!1;let z=l[v.mesh];if(!fe(z))return!1;for(let V of he(z.primitives)){if(!fe(V)||V.mode!==void 0&&V.mode!==4||!fe(V.attributes))return!1;let w=d(V.attributes.POSITION,"VEC3",[5126]),F=V.attributes.NORMAL===void 0?null:d(V.attributes.NORMAL,"VEC3",[5126]);if(!w||V.attributes.NORMAL!==void 0&&!F)return!1;let D=w.length;if(V.indices!==void 0){let E=typeof V.indices=="number"?s[V.indices]:null;D=fe(E)?E.count:void 0}if(typeof D!="number"||!Number.isInteger(D)||D%3!==0||(b+=D/3,b>1e5))return!1;let M=V.indices===void 0?w.map((E,B)=>[B]):d(V.indices,"SCALAR",[5121,5123,5125]);if(!M||M.length%3!==0||M.length!==D)return!1;for(let E=0;E<M.length;E+=3){let B=[M[E][0],M[E+1][0],M[E+2][0]];if(B.some(C=>!Number.isInteger(C)||C<0||C>=w.length))return!1;let R=B.map(C=>qa(T,...w[C])),x=null;if(!F){let C=R[1][0]-R[0][0],X=R[1][1]-R[0][1],G=R[1][2]-R[0][2],Y=R[2][0]-R[0][0],U=R[2][1]-R[0][1],N=R[2][2]-R[0][2];x=pr([1,0,0,0,1,0,0,0,1],X*N-G*U,G*Y-C*N,C*U-X*Y)}for(let C=0;C<3;C++)p.push(...R[C]),g.push(...F?pr(k,...F[B[C]]):x)}}}for(let z of he(v.children))if(!P(z,T))return!1;return y.delete(S),!0};for(let S of he(u[m].nodes))if(!P(S,Ya()))return{ok:!1,issue:b>1e5?"triangle_limit":"unsupported_glb"};return!b||p.length!==b*9||g.length!==p.length?{ok:!1,issue:"unsupported_glb"}:{ok:!0,triangleCount:b,position:new Float32Array(p),normal:new Float32Array(g)}}function br(e){try{return es(e)}catch{return{ok:!1,issue:"invalid_glb"}}}function vt(e){let{doc:t}=e,n=Mo(t.theme),r=n.structure,o=Vo(t,e.eventConfigurationId??t.eventConfigurationId),i=fr(e.eventConfigurationId,e.eventConfiguration,o),a=e.seats,s=new zt,c=null;if(e.registeredShellGlb){let M=br(e.registeredShellGlb);if(M.ok){let E=M.position.length/3,B=new Float32Array(M.position.length),R=n.materials.shell??r.tierWall;for(let x=0;x<E;x++){let C=M.normal[x*3+1],X=C<-.25?.4:.62+.38*Math.max(0,C);B[x*3]=R[0]*X,B[x*3+1]=R[1]*X,B[x*3+2]=R[2]*X}c={position:M.position,normal:M.normal,color:B,floor:new Float32Array(E).fill(-2),material:new Float32Array(E),count:E}}}let l=new Map;for(let M of o)for(let E of M.objects)l.set(E.id,M.index),E.type==="section"&&l.set(E.logicalSectionId??E.id,M.index);let f=a.map(M=>l.get(M.sectionId??"")??l.get(M.rowId??"")??0),u=Cn(o,a);mr(s,o,a,f,u,r);let m=Go(t,a),h=new Map,d=new Map;for(let M of t.categories??[])h.set(M.key,M.color),M.seatGlyph&&d.set(M.key,M.seatGlyph);let p=[],g=zo(o,a,f),b=new Float32Array(a.length);for(let M=0;M<o.length;M++){let E=o[M];s.setFloor(M);let B=new Yt,R=[],x=E.objects.filter(C=>C.type==="section"&&!!C.outline&&C.outline.length>=3);for(let C of E.objects)if(C.type==="section")$o(s,C,E,Uo(C,m),g.bySection.get(C.id),B,x,r);else if(C.type==="shape"){let X=i.byObjectId.get(C.id);s.setMaterial((X?.kind??C.role)==="screen"?1:0),qo(s,C,E.baseHeightM,Ho(C,R),r,E.focal,p,X),s.setMaterial(0)}else C.type==="gaArea"?Zo(s,C,E.baseHeightM,ee(h.get(C.categoryKey)),r):C.type==="booth"?Wo(s,C,E.baseHeightM,ee(h.get(C.categoryKey)),r):C.type==="table"?jo(s,C,E.baseHeightM,ee(h.get(C.categoryKey)),r):C.type==="decorImage"&&Ko(s,C,E.baseHeightM,r);Jo(s,E,a,g,r,n.materials.shell,!c)}let y=o.length>1?{x:o.reduce((M,E)=>M+E.focal.x,0)/o.length,y:o.reduce((M,E)=>M+E.focal.y,0)/o.length}:t.focalPoint??{x:(u.minX+u.maxX)/2,y:(u.minY+u.maxY)/2},P=po(c?[s.build(),c]:[s.build()]),S=vo(a,e.initialState,g,b,h,d),A=sr({doc:t,units:o,seats:a,surfaces:g,focal:y}),{labels:v,sections:I,rows:T}=cr({doc:t,units:o,seats:a,surfaces:g,seatData:S,hintedSeatFloor:f,zones:A,focal:y}),k=ur({doc:t,units:o,seats:a,surfaces:g,solids:P,hintedSeatFloor:f,seatFloor:b});lr(v,k),S.iYaw=go(S.iPosition,a.length,M=>a[M].rowId,M=>{let E=o[b[M]]?.focal??y;return[E.x*_,E.y*_]});let z=(u.minX+u.maxX)/2*_,V=(u.minY+u.maxY)/2*_,w=.5*Math.hypot((u.maxX-u.minX)*_,(u.maxY-u.minY)*_)||10,F=dr(P,S,{cx:z,cz:V,radius:w}),D=hr(S,p,u,F.minY,F.maxY,w);return{solids:P,seats:S,bounds:{center:[(D.min[0]+D.max[0])/2,(D.min[1]+D.max[1])/2,(D.min[2]+D.max[2])/2],radius:w,groundY:0,box:D},renderBounds:{center:F.center,radius:F.radius},stateColorLUT:So(n,we),theme:n,seatCount:a.length,focalWorld:[y.x*_,1.5,y.y*_],zones:A,stages:p,productionElements:i.elements,sections:I,rows:T,labels:v,floors:k}}var ts=88,ns=20,yr={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}},jt=new Set(["row","seat"]),gr={floor:5,zone:4,section:3,ga:3,booth:2,annotation:1},qt={row:{x:62,y:16},seat:{x:46,y:18}},xr=ee,In=e=>qn(e);function vr(e,t){let n=In(e),r=In(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function En(e,t){let n=/rgba\((\d+),(\d+),(\d+),([\d.]+)\)/.exec(e.replace(/\s/g,""));if(!n)return t;let r=Math.max(0,Math.min(1,Number(n[4])));return[1,2,3].map(o=>Number(n[o])/255*r+t[o-1]*(1-r))}function os(e,t=[.04,.06,.1],n=!0){let r=In(t)<.42,o=r?"#f4f7fb":"#0b1220",i=r?"rgba(8,12,22,.78)":"rgba(255,255,255,.84)",a=n?En(i,t):t,s=xr(e),c=n?7:4.5,l=s&&vr(s,a)>=c?e:o;return r?{ink:l,backing:i,border:"rgba(210,222,245,.24)"}:{ink:l,backing:i,border:"rgba(11,18,32,.22)"}}var Kt=class{constructor(t,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 r=this.root.style;r.position="absolute",r.inset="0",r.pointerEvents="none",r.overflow="hidden",n.fontFamily&&(r.fontFamily=n.fontFamily),t.appendChild(this.root)}setVisible(t){this.root.style.visibility=t?"":"hidden"}setLabels(t){this.labels=t;for(let[n,r]of this.nodes)t.some(o=>o.id===n)||(r.remove(),this.nodes.delete(n))}setForcedDense(t){this.forcedDense=t}setSelectedSeatIds(t){this.selectedSeatLabelIds=new Set(Array.from(t,n=>`seat:${n}`))}qualityEvidence(){let t=this.root.getBoundingClientRect(),n=this.root.style.visibility!=="hidden";return this.labels.map(r=>{let o=this.nodes.get(r.id),i=o?.getBoundingClientRect(),a=!!(n&&o&&o.style.display!=="none"&&i&&i.width>0&&i.height>0);return{id:r.id,kind:r.kind,text:r.text,visible:a,renderedFontPx:o&&Number.parseFloat(o.style.fontSize)||0,contrast:o?Number(o.dataset.qualityContrast??0):0,...a&&i?{screenBox:{x:i.x-t.x,y:i.y-t.y,width:i.width,height:i.height}}:{}}})}update(t,n,r,o,i,a){if(!this.labels.length)return;let s=nr(o,i,{hasZoneLabels:this.labels.some(y=>y.kind==="zone")});this.forcedDense&&(s.add("row"),s.add("seat"));let c=[];for(let y of this.labels){if(!s.has(y.kind))continue;let P=Ge(t,y.anchor,n,r);if(!P.visible)continue;let S=a?Math.hypot(y.anchor[0]-a[0],y.anchor[1]-a[1],y.anchor[2]-a[2]):1;c.push({label:y,screen:P,focus:ir(P,S,n,r),halfWidth:rr(y.text,yr[y.kind].size,!jt.has(y.kind))/2,...this.selectedSeatLabelIds.has(y.id)?{priority:1}:{}})}let l=tr(c.filter(y=>y.label.kind==="floor"),n),f=[...c.filter(y=>!jt.has(y.label.kind)&&y.label.kind!=="floor"),...l],u=or(f,ts,ns),m=Rn(c.filter(y=>y.label.kind==="row"),qt.row.x,qt.row.y,An.row,u),h=Rn(c.filter(y=>y.label.kind==="seat"),qt.seat.x,qt.seat.y,An.seat,[...u,...m]),d=[...u,...m,...h],p=new Set(d.map(y=>y.label.id));for(let{label:y,screen:P}of d){let A=this.nodeFor(y).style;A.display="",A.transform=`translate(-50%, -50%) translate(${P.x.toFixed(1)}px, ${P.y.toFixed(1)}px)`}let g=d.filter(({label:y})=>!jt.has(y.kind)).sort((y,P)=>gr[P.label.kind]-gr[y.label.kind]||y.screen.depth-P.screen.depth||y.focus-P.focus),b=[];for(let{label:y}of g){let P=this.nodes.get(y.id);if(!P||P.style.display==="none")continue;let S=P.getBoundingClientRect();b.some(v=>S.left<v.right+3&&S.right+3>v.left&&S.top<v.bottom+3&&S.bottom+3>v.top)?P.style.display="none":b.push(S)}for(let[y,P]of this.nodes)p.has(y)||(P.style.display="none")}nodeFor(t){let n=this.nodes.get(t.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(t.id,n)}n.textContent=t.text,n.setAttribute("data-label-kind",t.kind);let r=this.selectedSeatLabelIds.has(t.id);n.toggleAttribute("data-selected-seat",r);let o=yr[t.kind],i=n.style;i.fontSize=`${o.size}px`,i.fontWeight=r?"800":o.weight,i.opacity=r?"1":String(o.opacity);let a=!jt.has(t.kind),s=os(t.color??this.opts.ink,this.opts.backgroundRgb,a);i.color=r?"#ecf8ff":s.ink,i.background=r?"rgba(10,28,45,.9)":a?s.backing:"",i.border=r?"1px solid rgba(89,199,255,.92)":a?`1px solid ${s.border}`:"",i.borderRadius=r||a?"999px":"",i.padding=r||a?"3px 7px":"",i.boxShadow=r?"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)":"",i.letterSpacing=t.kind==="zone"||t.kind==="floor"?"0.08em":"0.02em";let c=this.opts.backgroundRgb??[.04,.06,.1],l=xr(r?"#ecf8ff":s.ink)??[1,1,1],f=r?En("rgba(10,28,45,.9)",c):a?En(s.backing,c):c;return n.dataset.qualityContrast=vr(l,f).toFixed(3),(t.kind==="zone"||t.kind==="floor")&&(i.textTransform="uppercase"),n}dispose(){this.root.remove(),this.nodes.clear()}};var rs=1;var is=new Set(["floor","zone","section","ga","booth","annotation"]);function as(e){return e.every(t=>Number.isFinite(t))}function ss(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Mr(e){return e.length?Math.round(Math.min(...e)*100)/100:null}function Ze(e){return Math.round(e*1e4)/1e4}function cs(e){if(e)return{box:{x:Ze(e.box.x),y:Ze(e.box.y),width:Ze(e.box.width),height:Ze(e.box.height)},horizontalFillRatio:Ze(e.horizontalFillRatio),verticalFillRatio:Ze(e.verticalFillRatio),visibleAreaRatio:Ze(e.visibleAreaRatio),clippedEdges:[...e.clippedEdges]}}function Ce(e,t,n){return n.length?{code:e,message:t,count:n.length,samples:n.slice(0,20)}:null}function Tn(e){let t=e.labels.filter(s=>s.visible&&s.screenBox),n=t.filter(s=>is.has(s.kind)),r=e.scene.floorCount>1?e.scene.floorCount:e.scene.zoneCount||e.scene.sectionCount,o=[];for(let s=0;s<n.length;s+=1)for(let c=0;c<s;c+=1)ss(n[s].screenBox,n[c].screenBox)&&o.push({primaryId:n[s].id,primaryLabel:n[s].text,secondaryId:n[c].id});let i=[...e.camera.position,e.camera.distance,e.camera.verticalFovDeg],a=[Ce("webgl2-unavailable","The venue scene must render through WebGL2",e.context.webgl2?[]:[{primaryId:"renderer",primaryLabel:"WebGL2"}]),Ce("context-lost","The WebGL context must be live at capture",e.context.lost?[{primaryId:"renderer",primaryLabel:"context lost"}]:[]),Ce("frame-not-stable","The captured 3D frame must be rendered and parked",e.frame.rendered>0&&e.frame.idle?[]:[{primaryId:"renderer",primaryLabel:"unstable frame"}]),Ce("viewport-empty","The 3D viewport must have visible dimensions",e.viewport.width>1&&e.viewport.height>1?[]:[{primaryId:"viewport",primaryLabel:`${e.viewport.width}\xD7${e.viewport.height}`}]),Ce("camera-invalid","The capture camera must have a finite physical pose",as(i)&&e.camera.distance>0&&e.camera.verticalFovDeg>0&&e.camera.verticalFovDeg<180?[]:[{primaryId:"camera",primaryLabel:"invalid pose"}]),Ce("authored-relief-not-visible","Authored 3D height or rake must produce visible screen-space relief",!e.scene.authoredRelief||e.scene.renderedVerticalSpanM>.05&&e.scene.projectedReliefPx>=2?[]:[{primaryId:"scene",primaryLabel:"authored relief",measured:e.scene.projectedReliefPx,minimum:2}]),Ce("hierarchy-label-missing","A venue with authored hierarchy must show at least one structural label",r===0||n.length>0?[]:[{primaryId:"labels",primaryLabel:`${r} expected hierarchy labels`}]),Ce("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}))),Ce("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}))),Ce("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:e.viewport,context:e.context,frame:e.frame,camera:e.camera,scene:e.scene,composition:{visibleLabels:t.map(({id:s,kind:c,text:l})=>({id:s,kind:c,text:l})).sort((s,c)=>s.kind.localeCompare(c.kind)||s.id.localeCompare(c.id)),framing:cs(e.framing)},metrics:{minimumHierarchyFontPx:Mr(n.map(s=>s.renderedFontPx)),minimumHierarchyContrast:Mr(n.map(s=>s.contrast)),projectedReliefPx:Math.round(e.scene.projectedReliefPx*100)/100},findings:a}}import{Geometry as Mt,Mesh as St,Program as ws,Texture as Ps,Transform as Fr}from"ogl";import{Program as Qe}from"ogl";var Zt=`
1
+ import{a as xe,b as Ht,c as Wt,d as Ye,e as we,f as pt,g as ht,h as Ut,i as Ie,j as Yt,k as ft,l as Xt,m as qt,n as jt,o as me,p as Qt,q as Kt,r as vt,s as $t,t as gt,u as Te}from"../chunk-WYXHD6J2.js";import"../chunk-7OJ6SB6V.js";import"../chunk-UHPX2P7O.js";import"../chunk-T2LWVOQ3.js";import"../chunk-AWPHGLTU.js";import"../chunk-UL5OIGIF.js";import"../chunk-X3K36XZM.js";import{d as Gt,k as Bt}from"../chunk-CXF32VPG.js";import"../chunk-CRCGO52K.js";import{Renderer as bn}from"ogl";function yn(){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 Xe=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 bn({canvas:this.canvas,dpr:yn(),alpha:!1,antialias:!1,depth:!0,stencil:!1,powerPreference:"high-performance",webgl:2}),this.gl=this.renderer.gl,this.clearRgb=[Ye.top[0],Ye.top[1],Ye.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 xn,Vec3 as bt}from"ogl";var oe=Math.PI/180,yt=15*oe,xt=80*oe,Se=.12,Zt=35,Jt=1.25,qe=class{constructor(e,n,i,o){this.fovY=Zt;this.target=new bt;this.azimuth=-30*oe;this.polar=55*oe;this.distance=10;this.azT=-30*oe;this.polT=55*oe;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 bt;this.panAnchor=new bt;this.panLimit=0;this.primaryDragMode="orbit";this.camera=new xn(e,{fov:Zt,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 s=r.button===2||r.button===1,a=r.button===0&&(r.shiftKey?this.primaryDragMode==="orbit":this.primaryDragMode==="pan");this.panning=s||a,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 s=this.pinchCentroid();this.pinchCx=s.x,this.pinchCy=s.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 m=this.pinchCentroid();this.panBy(m.x-this.pinchCx,m.y-this.pinchCy),this.pinchCx=m.x,this.pinchCy=m.y;return}let s=r.clientX-this.lastX,a=r.clientY-this.lastY;if(this.panning){this.lastX=r.clientX,this.lastY=r.clientY,(s!==0||a!==0)&&(this.panBy(s,a),this.fireGesture());return}this.dragging&&(this.lastX=r.clientX,this.lastY=r.clientY,(s!==0||a!==0)&&this.fireGesture(),this.azT-=s*.006,this.polT=Math.max(yt,Math.min(xt,this.polT-a*.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 s=r.deltaMode===1?16:r.deltaMode===2?100:1,a=Math.max(-2,Math.min(2,r.deltaY*s/100));this.dollyBy(Math.exp(a*.22)),this.fireGesture()},this.onKeyDown=r=>{if(!this.interactionEnabled)return;let s=7*oe;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"?-s:s;else if(r.key==="ArrowUp"||r.key==="ArrowDown")this.polT=Math.max(yt,Math.min(xt,this.polT+(r.key==="ArrowUp"?-s:s)));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*oe/2)/i,r=Math.sin(this.azimuth),s=Math.cos(this.azimuth),a=s,l=-r,m=Math.cos(this.polar),b=Math.sin(this.polar),c=-r*m,f=-s*m;this.targetT.x+=(-e*a+n*c)*o,this.targetT.z+=(-e*l+n*f)*o,this.targetT.y+=n*b*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 s=Math.max(1,e.radius),a=this.fovY*oe/2,l=o?Math.max(.82,this.camera.aspect||1):this.camera.aspect||1,m=Math.atan(Math.tan(a)*l);this.azT=i??-30*oe,this.polT=Math.max(15,Math.min(80,r?.polarDeg??55))*oe;let b=this.fitDistance(e,a,m,this.azT,this.polT);this.distT=b*Math.max(1.05,Math.min(2,r?.margin??Jt)),this.minDist=Math.max(2,s*.12),this.maxDist=b*4,n?(this.azimuth=this.azT,this.polar=12*oe,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*oe/2,s=i?Math.max(.82,this.camera.aspect||1):this.camera.aspect||1,a=Math.atan(Math.tan(r)*s);this.azT=n??this.azimuth,this.polT=Math.max(15,Math.min(80,o?.polarDeg??55))*oe;let l=this.fitDistance(e,r,a,this.azT,this.polT);this.distT=l*Math.max(1.05,Math.min(2,o?.margin??Jt))}fitDistance(e,n,i,o,r){let s=Math.max(1,e.radius),a=Math.max(s/Math.tan(n),s/Math.tan(i)),l=e.box;if(!l)return a;let m=Math.sin(r),b=-m*Math.sin(o),c=-Math.cos(r),f=-m*Math.cos(o);if(Math.abs(c)>.999)return a;let p=-f,u=b,x=Math.hypot(p,u);p/=x,u/=x;let C=-u*c,F=u*b-p*f,v=p*c,M=Math.tan(i),R=Math.tan(n),w=1;for(let S=0;S<8;S++){let O=(S&1?l.max[0]:l.min[0])-e.center[0],D=(S&2?l.max[1]:l.min[1])-e.center[1],z=(S&4?l.max[2]:l.min[2])-e.center[2],j=O*b+D*c+z*f,E=Math.abs(O*p+z*u),_=Math.abs(O*C+D*F+z*v);w=Math.max(w,E/M-j,_/R-j)}return Math.min(a,Math.max(w,s*.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),s=Math.max(1,e.radius)*1.18,a=Math.max(.05,r-s),l=Math.max(a+10,r+s);this.camera.perspective({near:a,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,s=this.targetT.z-this.target.z,a=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)>a||Math.abs(r)>a||Math.abs(s)>a;return this.azimuth+=e*Se,this.polar+=n*Se,this.distance+=i*Se,this.target.x+=o*Se,this.target.y+=r*Se,this.target.z+=s*Se,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(yt,Math.min(xt,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 je=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 Me=2.5,wn=1.15,ke=6,Pe=10,eo=6,to=9.5,oo=.9,no=2.2,wt=30,St=4,Qe=8192;var Lr=Pe+St;function ro(t,e){let n=e*1.4,i=e*3.2;if(t<=n)return{scale:1,fade:0,minPixels:Me};let o=Math.min(1,(t-n)/Math.max(.001,i-n));return{scale:1-o*.4,fade:o*.55,minPixels:Me+o*(wn-Me)}}function io(t,e,n){return!(t>0)||!(e>0)||!(n>0)?!1:e*n/t>=64}function ao(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 s=e/(n*r)*(o/2);return Math.PI*s*s/t>=64}var Sn=88,Mn=20,so={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}},Ke=new Set(["row","seat"]),lo={floor:5,zone:4,section:3,ga:3,booth:2,annotation:1},$e={row:{x:62,y:16},seat:{x:46,y:18}},co=Gt,Mt=t=>Bt(t);function uo(t,e){let n=Mt(t),i=Mt(e);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function Pt(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 Pn(t,e=[.04,.06,.1],n=!0){let i=Mt(e)<.42,o=i?"#f4f7fb":"#0b1220",r=i?"rgba(8,12,22,.78)":"rgba(255,255,255,.84)",s=n?Pt(r,e):e,a=co(t),l=n?7:4.5,m=a&&uo(a,s)>=l?t:o;return i?{ink:m,backing:r,border:"rgba(210,222,245,.24)"}:{ink:m,backing:r,border:"rgba(11,18,32,.22)"}}var Ze=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(),s=!!(n&&o&&o.style.display!=="none"&&r&&r.width>0&&r.height>0);return{id:i.id,kind:i.kind,text:i.text,visible:s,renderedFontPx:o&&Number.parseFloat(o.style.fontSize)||0,contrast:o?Number(o.dataset.qualityContrast??0):0,...s&&r?{screenBox:{x:r.x-e.x,y:r.y-e.y,width:r.width,height:r.height}}:{}}})}update(e,n,i,o,r,s){if(!this.labels.length)return;let a=jt(o,r,{hasZoneLabels:this.labels.some(v=>v.kind==="zone")});this.forcedDense&&(a.add("row"),a.add("seat"));let l=[];for(let v of this.labels){if(!a.has(v.kind))continue;let M=me(e,v.anchor,n,i);if(!M.visible)continue;let R=s?Math.hypot(v.anchor[0]-s[0],v.anchor[1]-s[1],v.anchor[2]-s[2]):1;l.push({label:v,screen:M,focus:$t(M,R,n,i),halfWidth:Kt(v.text,so[v.kind].size,!Ke.has(v.kind))/2,...this.selectedSeatLabelIds.has(v.id)?{priority:1}:{}})}let m=qt(l.filter(v=>v.label.kind==="floor"),n),b=[...l.filter(v=>!Ke.has(v.label.kind)&&v.label.kind!=="floor"),...m],c=Qt(b,Sn,Mn),f=gt(l.filter(v=>v.label.kind==="row"),$e.row.x,$e.row.y,vt.row,c),p=gt(l.filter(v=>v.label.kind==="seat"),$e.seat.x,$e.seat.y,vt.seat,[...c,...f]),u=[...c,...f,...p],x=new Set(u.map(v=>v.label.id));for(let{label:v,screen:M}of u){let w=this.nodeFor(v).style;w.display="",w.transform=`translate(-50%, -50%) translate(${M.x.toFixed(1)}px, ${M.y.toFixed(1)}px)`}let C=u.filter(({label:v})=>!Ke.has(v.kind)).sort((v,M)=>lo[M.label.kind]-lo[v.label.kind]||v.screen.depth-M.screen.depth||v.focus-M.focus),F=[];for(let{label:v}of C){let M=this.nodes.get(v.id);if(!M||M.style.display==="none")continue;let R=M.getBoundingClientRect();F.some(S=>R.left<S.right+3&&R.right+3>S.left&&R.top<S.bottom+3&&R.bottom+3>S.top)?M.style.display="none":F.push(R)}for(let[v,M]of this.nodes)x.has(v)||(M.style.display="none")}nodeFor(e){let n=this.nodes.get(e.id);if(!n){n=document.createElement("div");let c=n.style;c.position="absolute",c.left="0",c.top="0",c.whiteSpace="nowrap",c.textShadow="0 1px 3px rgba(0,0,0,0.85), 0 0 8px rgba(0,0,0,0.55)",c.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=so[e.kind],r=n.style;r.fontSize=`${o.size}px`,r.fontWeight=i?"800":o.weight,r.opacity=i?"1":String(o.opacity);let s=!Ke.has(e.kind),a=Pn(e.color??this.opts.ink,this.opts.backgroundRgb,s);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],m=co(i?"#ecf8ff":a.ink)??[1,1,1],b=i?Pt("rgba(10,28,45,.9)",l):s?Pt(a.backing,l):l;return n.dataset.qualityContrast=uo(m,b).toFixed(3),(e.kind==="zone"||e.kind==="floor")&&(r.textTransform="uppercase"),n}dispose(){this.root.remove(),this.nodes.clear()}};var Cn=1;var An=new Set(["floor","zone","section","ga","booth","annotation"]);function En(t){return t.every(e=>Number.isFinite(e))}function Fn(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 mo(t){return t.length?Math.round(Math.min(...t)*100)/100:null}function ve(t){return Math.round(t*1e4)/1e4}function Rn(t){if(t)return{box:{x:ve(t.box.x),y:ve(t.box.y),width:ve(t.box.width),height:ve(t.box.height)},horizontalFillRatio:ve(t.horizontalFillRatio),verticalFillRatio:ve(t.verticalFillRatio),visibleAreaRatio:ve(t.visibleAreaRatio),clippedEdges:[...t.clippedEdges]}}function ce(t,e,n){return n.length?{code:t,message:e,count:n.length,samples:n.slice(0,20)}:null}function Ct(t){let e=t.labels.filter(a=>a.visible&&a.screenBox),n=e.filter(a=>An.has(a.kind)),i=t.scene.floorCount>1?t.scene.floorCount:t.scene.zoneCount||t.scene.sectionCount,o=[];for(let a=0;a<n.length;a+=1)for(let l=0;l<a;l+=1)Fn(n[a].screenBox,n[l].screenBox)&&o.push({primaryId:n[a].id,primaryLabel:n[a].text,secondaryId:n[l].id});let r=[...t.camera.position,t.camera.distance,t.camera.verticalFovDeg],s=[ce("webgl2-unavailable","The venue scene must render through WebGL2",t.context.webgl2?[]:[{primaryId:"renderer",primaryLabel:"WebGL2"}]),ce("context-lost","The WebGL context must be live at capture",t.context.lost?[{primaryId:"renderer",primaryLabel:"context lost"}]:[]),ce("frame-not-stable","The captured 3D frame must be rendered and parked",t.frame.rendered>0&&t.frame.idle?[]:[{primaryId:"renderer",primaryLabel:"unstable frame"}]),ce("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}`}]),ce("camera-invalid","The capture camera must have a finite physical pose",En(r)&&t.camera.distance>0&&t.camera.verticalFovDeg>0&&t.camera.verticalFovDeg<180?[]:[{primaryId:"camera",primaryLabel:"invalid pose"}]),ce("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}]),ce("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`}]),ce("hierarchy-label-undersized","Visible 3D hierarchy labels must remain readable",n.filter(a=>a.renderedFontPx<11).map(a=>({primaryId:a.id,primaryLabel:a.text,measured:a.renderedFontPx,minimum:11}))),ce("hierarchy-label-contrast-low","Visible 3D hierarchy labels must meet text contrast",n.filter(a=>a.contrast<4.5).map(a=>({primaryId:a.id,primaryLabel:a.text,measured:a.contrast,minimum:4.5}))),ce("hierarchy-label-collision","Visible 3D hierarchy labels must not overlap",o)].filter(a=>!!a);return{version:1,state:"venue3d",passed:s.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:a,kind:l,text:m})=>({id:a,kind:l,text:m})).sort((a,l)=>a.kind.localeCompare(l.kind)||a.id.localeCompare(l.id)),framing:Rn(t.framing)},metrics:{minimumHierarchyFontPx:mo(n.map(a=>a.renderedFontPx)),minimumHierarchyContrast:mo(n.map(a=>a.contrast)),projectedReliefPx:Math.round(t.scene.projectedReliefPx*100)/100},findings:s}}import{Geometry as _e,Mesh as Le,Program as Un,Texture as Yn,Transform as So}from"ogl";import{Program as ge}from"ogl";var Je=`
2
2
  float chairWeight(float depth) {
3
3
  return 1.0 - smoothstep(uChairFull, uChairNone, depth);
4
- }`,Sr=`
4
+ }`,po=`
5
5
  float occupantWeight(float depth) {
6
- float nearWeight = smoothstep(${co.toFixed(1)}, ${lo.toFixed(1)}, depth);
7
- float farWeight = 1.0 - smoothstep(${ao.toFixed(1)}, ${so.toFixed(1)}, depth);
6
+ float nearWeight = smoothstep(${oo.toFixed(1)}, ${no.toFixed(1)}, depth);
7
+ float farWeight = 1.0 - smoothstep(${eo.toFixed(1)}, ${to.toFixed(1)}, depth);
8
8
  return nearWeight * farWeight;
9
- }`,wr=`
9
+ }`,ho=`
10
10
  float glyphEq(float glyph, float expected) {
11
11
  return 1.0 - step(0.25, abs(glyph - expected));
12
12
  }
@@ -55,7 +55,7 @@ vec3 glyphChairPosition(vec3 p, float partId, float glyph) {
55
55
  p.y += 0.16;
56
56
  }
57
57
  return p;
58
- }`,ls=`#version 300 es
58
+ }`,Dn=`#version 300 es
59
59
  precision highp float;
60
60
  in vec3 position;
61
61
  in vec3 normal;
@@ -93,7 +93,7 @@ void main() {
93
93
  vNormalWorld = normalize(mat3(modelMatrix) * normal);
94
94
  vColor = color;
95
95
  gl_Position = projectionMatrix * mv;
96
- }`,us=`#version 300 es
96
+ }`,Vn=`#version 300 es
97
97
  precision highp float;
98
98
  in vec3 vColor;
99
99
  in vec3 vNormalWorld;
@@ -166,7 +166,7 @@ void main() {
166
166
  + vec3(0.20, 0.10, 0.34) * focalHalo;
167
167
  base = mix(base, display, poweredDisplay * verticalFace * 0.92);
168
168
  fragColor = vec4(base, 1.0);
169
- }`,ms=`#version 300 es
169
+ }`,In=`#version 300 es
170
170
  precision highp float;
171
171
  in vec2 position; // quad corner in [-1,1]
172
172
  in vec3 iOffset; // per-instance world position
@@ -192,7 +192,7 @@ out float vDim;
192
192
  out float vDotWeight; // 1 = the dot IS this seat, 0 = the chair has taken over
193
193
  out float vPhysicalSeat;
194
194
  out float vPixelRadius;
195
- ${Zt}
195
+ ${Je}
196
196
  void main() {
197
197
  vec4 mv = modelViewMatrix * vec4(iOffset, 1.0);
198
198
  float depth = max(-mv.z, 0.001);
@@ -225,7 +225,7 @@ void main() {
225
225
  vPhysicalSeat = iPhysicalSeat;
226
226
  vDim = (uFocusFloor < -0.5 || abs(iFloor - uFocusFloor) < 0.5) ? 0.0 : 1.0;
227
227
  gl_Position = projectionMatrix * mv;
228
- }`,ds=`#version 300 es
228
+ }`,Tn=`#version 300 es
229
229
  precision highp float;
230
230
  in vec2 vUv;
231
231
  in vec3 vColor;
@@ -284,7 +284,7 @@ void main() {
284
284
  alpha *= vDotWeight;
285
285
  if (alpha <= 0.0) discard;
286
286
  fragColor = vec4(c, alpha);
287
- }`,hs=`#version 300 es
287
+ }`,kn=`#version 300 es
288
288
  precision highp float;
289
289
  in vec3 position; // local: x/z in units of the seat radius, y in METRES
290
290
  in vec3 normal;
@@ -315,9 +315,9 @@ out vec3 vRing;
315
315
  out float vDim;
316
316
  out float vOccupant; // 1 = this vertex belongs to a person, not to the chair
317
317
  out vec3 vOccupantTint;
318
- ${Zt}
319
- ${Sr}
320
- ${wr}
318
+ ${Je}
319
+ ${po}
320
+ ${ho}
321
321
  void main() {
322
322
  vec4 anchor = modelViewMatrix * vec4(iOffset, 1.0);
323
323
  float viewDepth = -anchor.z;
@@ -403,7 +403,7 @@ void main() {
403
403
  vRing = iRing;
404
404
  vDim = (uFocusFloor < -0.5 || abs(iFloor - uFocusFloor) < 0.5) ? 0.0 : 1.0;
405
405
  gl_Position = projectionMatrix * mv;
406
- }`,fs=`#version 300 es
406
+ }`,_n=`#version 300 es
407
407
  precision highp float;
408
408
  in vec3 vColor;
409
409
  in vec3 vNormalWorld;
@@ -460,14 +460,14 @@ void main() {
460
460
  float sheen = clamp((1.0 - uRoughness) / 0.22, 0.15, 2.0);
461
461
  base += vec3(0.26, 0.31, 0.38) * fres * 0.55 * mix(sheen, 1.0, vOccupant);
462
462
  fragColor = vec4(base, 1.0);
463
- }`,ps=`#version 300 es
463
+ }`,Ln=`#version 300 es
464
464
  precision highp float;
465
465
  in vec2 position;
466
466
  out vec2 vUv;
467
467
  void main() {
468
468
  vUv = position * 0.5 + 0.5;
469
469
  gl_Position = vec4(position, 0.999, 1.0);
470
- }`,bs=`#version 300 es
470
+ }`,zn=`#version 300 es
471
471
  precision highp float;
472
472
  in vec2 vUv;
473
473
  uniform vec3 uTop;
@@ -478,7 +478,7 @@ void main() {
478
478
  vec2 c = vUv - 0.5;
479
479
  float vig = 1.0 - dot(c, c) * 0.85; // soft vignette
480
480
  fragColor = vec4(col * vig, 1.0);
481
- }`,ys=`#version 300 es
481
+ }`,On=`#version 300 es
482
482
  precision highp float;
483
483
  in vec2 position;
484
484
  in vec3 iOffset;
@@ -499,7 +499,7 @@ out float vPhysicalSeat;
499
499
  out float vDotWeight;
500
500
  out float vHidden;
501
501
  flat out vec3 vPick;
502
- ${Zt}
502
+ ${Je}
503
503
  void main() {
504
504
  int id = gl_InstanceID + 1; // 0 reserved for no-hit
505
505
  vPick = vec3(float(id & 255), float((id >> 8) & 255), float((id >> 16) & 255)) / 255.0;
@@ -515,7 +515,7 @@ void main() {
515
515
  vPhysicalSeat = iPhysicalSeat;
516
516
  vHidden = (uFocusFloor > -0.5 && abs(iFloor - uFocusFloor) > 0.5) ? 1.0 : 0.0;
517
517
  gl_Position = projectionMatrix * mv;
518
- }`,gs=`#version 300 es
518
+ }`,Nn=`#version 300 es
519
519
  precision highp float;
520
520
  in vec2 vUv;
521
521
  in float vPhysicalSeat;
@@ -529,7 +529,7 @@ void main() {
529
529
  float d = mix(max(abs(vUv.x), abs(vUv.y)), length(vUv), vPhysicalSeat);
530
530
  if (d > 1.0) discard; // hit-mask matches chair/bay shape
531
531
  fragColor = vec4(vPick, 1.0);
532
- }`,xs=`#version 300 es
532
+ }`,Gn=`#version 300 es
533
533
  precision highp float;
534
534
  in vec3 position;
535
535
  in float part;
@@ -550,9 +550,9 @@ uniform float uBackBase;
550
550
  uniform float uFocusFloor;
551
551
  flat out vec3 vPick;
552
552
  out float vHidden;
553
- ${Zt}
554
- ${Sr}
555
- ${wr}
553
+ ${Je}
554
+ ${po}
555
+ ${ho}
556
556
  void main() {
557
557
  int id = int(iPickIndex + 0.5); // already global index + 1
558
558
  vPick = vec3(float(id & 255), float((id >> 8) & 255), float((id >> 16) & 255)) / 255.0;
@@ -585,7 +585,7 @@ void main() {
585
585
  float c = cos(iYaw), s = sin(iYaw);
586
586
  vec3 rp = vec3(p.x * c + p.z * s, p.y, -p.x * s + p.z * c);
587
587
  gl_Position = projectionMatrix * modelViewMatrix * vec4(iOffset + rp, 1.0);
588
- }`,vs=`#version 300 es
588
+ }`,Bn=`#version 300 es
589
589
  precision highp float;
590
590
  flat in vec3 vPick;
591
591
  in float vHidden;
@@ -593,7 +593,7 @@ out vec4 fragColor;
593
593
  void main() {
594
594
  if (vHidden > 0.5) discard;
595
595
  fragColor = vec4(vPick, 1.0);
596
- }`,Ms=`#version 300 es
596
+ }`,Hn=`#version 300 es
597
597
  precision highp float;
598
598
  in vec3 position;
599
599
  in float floorIndex;
@@ -604,14 +604,14 @@ out float vHidden;
604
604
  void main() {
605
605
  vHidden = (uFocusFloor > -0.5 && abs(floorIndex - uFocusFloor) > 0.5) ? 1.0 : 0.0;
606
606
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
607
- }`,Ss=`#version 300 es
607
+ }`,Wn=`#version 300 es
608
608
  precision highp float;
609
609
  in float vHidden;
610
610
  out vec4 fragColor;
611
611
  void main() {
612
612
  if (vHidden > 0.5) discard;
613
613
  fragColor = vec4(0.0, 0.0, 0.0, 1.0);
614
- }`;function Pr(e){return new Qe(e,{vertex:ys,fragment:gs,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uSeatRadius:{value:Fe},uSeatScale:{value:1},uMinPixels:{value:Je},uPixelToWorld:{value:.002},uChairFull:{value:ht},uChairNone:{value:et},uFocusFloor:{value:-1}}})}function Ar(e){return new Qe(e,{vertex:xs,fragment:vs,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uChairFull:{value:ht},uChairNone:{value:et},uBackRake:{value:pn},uBackBase:{value:Ht},uFocusFloor:{value:-1}}})}function Rr(e){return new Qe(e,{vertex:Ms,fragment:Ss,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uFocusFloor:{value:-1}}})}function Cr(e,t=.78){return new Qe(e,{vertex:ls,fragment:us,cullFace:!1,depthTest:!0,depthWrite:!0,uniforms:{uKeyDir:{value:new Float32Array([.38,.86,.34])},uFocusFloor:{value:-1},uStructureDetail:{value:0},uRoughness:{value:t}}})}function Ir(e){return new Qe(e,{vertex:ms,fragment:ds,transparent:!0,depthTest:!0,depthWrite:!1,cullFace:!1,uniforms:{uSeatRadius:{value:Fe},uSeatScale:{value:1},uMinPixels:{value:Je},uPixelToWorld:{value:.002},uSeatFade:{value:0},uSeatDetail:{value:0},uFocusFloor:{value:-1},uFadeColor:{value:new Float32Array([.32,.37,.43])},uChairFull:{value:ht},uChairNone:{value:et}}})}function Er(e,t=.78){return new Qe(e,{vertex:hs,fragment:fs,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:ht},uChairNone:{value:et},uBackRake:{value:pn},uBackBase:{value:Ht},uFocusFloor:{value:-1},uRoughness:{value:t}}})}function Tr(e,t,n){return new Qe(e,{vertex:ps,fragment:bs,depthTest:!1,depthWrite:!1,cullFace:!1,uniforms:{uTop:{value:new Float32Array(t)},uBottom:{value:new Float32Array(n)}}})}function _r(e,t,n,r,o,i){for(let a=n;a<n+r;a++){let c=i&&t[a]===0?null:o[t[a]]??o[0];e[a*3]=c?c[0]:i[a*3],e[a*3+1]=c?c[1]:i[a*3+1],e[a*3+2]=c?c[2]:i[a*3+2]}}var As=new Float32Array([-1,-1,1,-1,1,1,-1,-1,1,1,-1,1]),Rs=new Float32Array([-1,-1,3,-1,-1,3]);function Dr(e,t){let n=new Fr,r=new Fr,o=new Mt(e,{position:{size:2,data:Rs}}),i=Tr(e,t.theme.background.top,t.theme.background.bottom),a=new St(e,{geometry:o,program:i});a.frustumCulled=!1,a.setParent(r);let s=new Mt(e,{position:{size:3,data:t.solids.position},normal:{size:3,data:t.solids.normal},color:{size:3,data:t.solids.color},floorIndex:{size:1,data:t.solids.floor},materialIndex:{size:1,data:t.solids.material}}),c=Cr(e,t.theme.materials.roughness),l=new St(e,{geometry:s,program:c});l.frustumCulled=!1,l.setParent(n);let f=Ir(e),u=new Float32Array(t.seats.count*3),m=we.map(N=>t.theme.seatStates[N]);_r(u,t.seats.iState,0,t.seats.count,m,t.seats.iCategory);let h=new Mt(e,{position:{size:2,data:As},iOffset:{size:3,data:t.seats.iPosition,instanced:1},iColor:{size:3,data:u,instanced:1},iMaxRadius:{size:1,data:t.seats.iMaxRadius,instanced:1},iPhysicalSeat:{size:1,data:t.seats.iPhysicalSeat,instanced:1},iRing:{size:3,data:t.seats.iRing,instanced:1},iFloor:{size:1,data:t.seats.iFloor,instanced:1}}),d=new St(e,{geometry:h,program:f});d.frustumCulled=!1,t.seats.count>0&&d.setParent(n);let p=h.attributes.iColor,g=yo(),b=Er(e,t.theme.materials.roughness),y=Ot,P=new Float32Array(y*3),S=new Float32Array(y*3),A=new Float32Array(y),v=new Float32Array(y),I=new Float32Array(y),T=new Float32Array(y*3),k=new Float32Array(y),z=new Float32Array(y),V=new Float32Array(y),w=new Float32Array(y),F=new Mt(e,{position:{size:3,data:g.position},normal:{size:3,data:g.normal},part:{size:1,data:g.part},index:{data:g.index},iOffset:{size:3,data:P,instanced:1},iColor:{size:3,data:S,instanced:1},iRadius:{size:1,data:A,instanced:1},iYaw:{size:1,data:v,instanced:1},iGlyph:{size:1,data:I,instanced:1},iRing:{size:3,data:T,instanced:1},iFloor:{size:1,data:k,instanced:1},iPhysicalSeat:{size:1,data:z,instanced:1},iSeed:{size:1,data:w,instanced:1},iPickIndex:{size:1,data:V,instanced:1}}),D=new St(e,{geometry:F,program:b});D.frustumCulled=!1;let M=0,E=!1,B=!1,R=null,x=null,C=null,X=new Int32Array(0),G=()=>{let N=t.seats;for(let H=0;H<M;H++){let j=X[H];w[H]=xo(N.iState[j],j);let K=N.iCategory&&N.iState[j]===0?null:m[N.iState[j]]??m[0];if(K)S[H*3]=K[0],S[H*3+1]=K[1],S[H*3+2]=K[2];else{let Q=t.theme.materials.seat??oo([N.iCategory[j*3],N.iCategory[j*3+1],N.iCategory[j*3+2]]);S[H*3]=Q[0],S[H*3+1]=Q[1],S[H*3+2]=Q[2]}}F.attributes.iColor.needsUpdate=!0,F.attributes.iSeed.needsUpdate=!0},Y={main:n,background:r,seatProgram:f,solidProgram:c,chairProgram:b,seatGeometry:h,chairGeometry:F,solidGeometry:s,drawCalls:3,setNearSeats(N,H){let j=Math.min(H,y);if(X=N,M=j,j===0){D.parent&&D.setParent(null),F.instancedCount=0,Y.drawCalls=3+(E?1:0);return}let W=t.seats;for(let K=0;K<j;K++){let Q=N[K];P[K*3]=W.iPosition[Q*3],P[K*3+1]=W.iPosition[Q*3+1],P[K*3+2]=W.iPosition[Q*3+2],A[K]=W.iChairWidth[Q],v[K]=W.iYaw[Q],I[K]=W.iGlyph[Q],T[K*3]=W.iRing[Q*3],T[K*3+1]=W.iRing[Q*3+1],T[K*3+2]=W.iRing[Q*3+2],k[K]=W.iFloor[Q],z[K]=W.iPhysicalSeat[Q],V[K]=Q+1}G(),F.attributes.iOffset.needsUpdate=!0,F.attributes.iRadius.needsUpdate=!0,F.attributes.iYaw.needsUpdate=!0,F.attributes.iGlyph.needsUpdate=!0,F.attributes.iRing.needsUpdate=!0,F.attributes.iFloor.needsUpdate=!0,F.attributes.iPhysicalSeat.needsUpdate=!0,F.attributes.iSeed.needsUpdate=!0,F.attributes.iPickIndex.needsUpdate=!0,F.instancedCount=j,D.parent||D.setParent(n),Y.drawCalls=4+(E?1:0)},nearSeatCount(){return M},uploadSeatStateRuns(N){if(!N.length)return;M&&G();for(let j of N)_r(u,t.seats.iState,j.start,j.length,m,t.seats.iCategory);let H=p.buffer;if(!H){p.needsUpdate=!0;return}e.bindBuffer(e.ARRAY_BUFFER,H);for(let j of N){let W=u.subarray(j.start*3,(j.start+j.length)*3);e.bufferSubData(e.ARRAY_BUFFER,j.start*3*Float32Array.BYTES_PER_ELEMENT,W)}},dispose(){B=!0,o.remove(),i.remove(),s.remove(),c.remove(),h.remove(),f.remove(),F.remove(),b.remove(),R?.remove(),x?.remove(),C?.texture&&e.deleteTexture(C.texture)}},U=t.productionElements.find(N=>N.contentImageUrl&&N.contentPlane);if(U?.contentImageUrl&&U.contentPlane?.length===4&&typeof Image<"u"){let N=new Image;N.crossOrigin="anonymous",N.onload=()=>{if(B)return;let H=U.contentPlane;R=new Mt(e,{position:{size:3,data:new Float32Array(H.flat())},uv:{size:2,data:new Float32Array([0,1,1,1,0,0,1,0])},floorIndex:{size:1,data:new Float32Array(4).fill(U.floorIndex)},index:{data:new Uint16Array([0,1,2,2,1,3])}}),C=new Ps(e,{image:N,generateMipmaps:!0,wrapS:e.CLAMP_TO_EDGE,wrapT:e.CLAMP_TO_EDGE,flipY:!1}),x=new ws(e,{vertex:`#version 300 es
614
+ }`;function fo(t){return new ge(t,{vertex:On,fragment:Nn,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uSeatRadius:{value:Ie},uSeatScale:{value:1},uMinPixels:{value:Me},uPixelToWorld:{value:.002},uChairFull:{value:ke},uChairNone:{value:Pe},uFocusFloor:{value:-1}}})}function vo(t){return new ge(t,{vertex:Gn,fragment:Bn,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uChairFull:{value:ke},uChairNone:{value:Pe},uBackRake:{value:pt},uBackBase:{value:ht},uFocusFloor:{value:-1}}})}function go(t){return new ge(t,{vertex:Hn,fragment:Wn,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uFocusFloor:{value:-1}}})}function bo(t,e=.78){return new ge(t,{vertex:Dn,fragment:Vn,cullFace:!1,depthTest:!0,depthWrite:!0,uniforms:{uKeyDir:{value:new Float32Array([.38,.86,.34])},uFocusFloor:{value:-1},uStructureDetail:{value:0},uRoughness:{value:e}}})}function yo(t){return new ge(t,{vertex:In,fragment:Tn,transparent:!0,depthTest:!0,depthWrite:!1,cullFace:!1,uniforms:{uSeatRadius:{value:Ie},uSeatScale:{value:1},uMinPixels:{value:Me},uPixelToWorld:{value:.002},uSeatFade:{value:0},uSeatDetail:{value:0},uFocusFloor:{value:-1},uFadeColor:{value:new Float32Array([.32,.37,.43])},uChairFull:{value:ke},uChairNone:{value:Pe}}})}function xo(t,e=.78){return new ge(t,{vertex:kn,fragment:_n,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:ke},uChairNone:{value:Pe},uBackRake:{value:pt},uBackBase:{value:ht},uFocusFloor:{value:-1},uRoughness:{value:e}}})}function wo(t,e,n){return new ge(t,{vertex:Ln,fragment:zn,depthTest:!1,depthWrite:!1,cullFace:!1,uniforms:{uTop:{value:new Float32Array(e)},uBottom:{value:new Float32Array(n)}}})}function Mo(t,e,n,i,o,r){for(let s=n;s<n+i;s++){let l=r&&e[s]===0?null:o[e[s]]??o[0];t[s*3]=l?l[0]:r[s*3],t[s*3+1]=l?l[1]:r[s*3+1],t[s*3+2]=l?l[2]:r[s*3+2]}}var Xn=new Float32Array([-1,-1,1,-1,1,1,-1,-1,1,1,-1,1]),qn=new Float32Array([-1,-1,3,-1,-1,3]);function Po(t,e){let n=new So,i=new So,o=new _e(t,{position:{size:2,data:qn}}),r=wo(t,e.theme.background.top,e.theme.background.bottom),s=new Le(t,{geometry:o,program:r});s.frustumCulled=!1,s.setParent(i);let a=new _e(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=bo(t,e.theme.materials.roughness),m=new Le(t,{geometry:a,program:l});m.frustumCulled=!1,m.setParent(n);let b=yo(t),c=new Float32Array(e.seats.count*3),f=xe.map(L=>e.theme.seatStates[L]);Mo(c,e.seats.iState,0,e.seats.count,f,e.seats.iCategory);let p=new _e(t,{position:{size:2,data:Xn},iOffset:{size:3,data:e.seats.iPosition,instanced:1},iColor:{size:3,data:c,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}}),u=new Le(t,{geometry:p,program:b});u.frustumCulled=!1,e.seats.count>0&&u.setParent(n);let x=p.attributes.iColor,C=Ut(),F=xo(t,e.theme.materials.roughness),v=Qe,M=new Float32Array(v*3),R=new Float32Array(v*3),w=new Float32Array(v),S=new Float32Array(v),O=new Float32Array(v),D=new Float32Array(v*3),z=new Float32Array(v),j=new Float32Array(v),E=new Float32Array(v),_=new Float32Array(v),N=new _e(t,{position:{size:3,data:C.position},normal:{size:3,data:C.normal},part:{size:1,data:C.part},index:{data:C.index},iOffset:{size:3,data:M,instanced:1},iColor:{size:3,data:R,instanced:1},iRadius:{size:1,data:w,instanced:1},iYaw:{size:1,data:S,instanced:1},iGlyph:{size:1,data:O,instanced:1},iRing:{size:3,data:D,instanced:1},iFloor:{size:1,data:z,instanced:1},iPhysicalSeat:{size:1,data:j,instanced:1},iSeed:{size:1,data:_,instanced:1},iPickIndex:{size:1,data:E,instanced:1}}),P=new Le(t,{geometry:N,program:F});P.frustumCulled=!1;let g=0,H=!1,K=!1,Y=null,y=null,I=null,J=new Int32Array(0),B=()=>{let L=e.seats;for(let G=0;G<g;G++){let T=J[G];_[G]=Yt(L.iState[T],T);let U=L.iCategory&&L.iState[T]===0?null:f[L.iState[T]]??f[0];if(U)R[G*3]=U[0],R[G*3+1]=U[1],R[G*3+2]=U[2];else{let Q=e.theme.materials.seat??Wt([L.iCategory[T*3],L.iCategory[T*3+1],L.iCategory[T*3+2]]);R[G*3]=Q[0],R[G*3+1]=Q[1],R[G*3+2]=Q[2]}}N.attributes.iColor.needsUpdate=!0,N.attributes.iSeed.needsUpdate=!0},$={main:n,background:i,seatProgram:b,solidProgram:l,chairProgram:F,seatGeometry:p,chairGeometry:N,solidGeometry:a,drawCalls:3,setNearSeats(L,G){let T=Math.min(G,v);if(J=L,g=T,T===0){P.parent&&P.setParent(null),N.instancedCount=0,$.drawCalls=3+(H?1:0);return}let V=e.seats;for(let U=0;U<T;U++){let Q=L[U];M[U*3]=V.iPosition[Q*3],M[U*3+1]=V.iPosition[Q*3+1],M[U*3+2]=V.iPosition[Q*3+2],w[U]=V.iChairWidth[Q],S[U]=V.iYaw[Q],O[U]=V.iGlyph[Q],D[U*3]=V.iRing[Q*3],D[U*3+1]=V.iRing[Q*3+1],D[U*3+2]=V.iRing[Q*3+2],z[U]=V.iFloor[Q],j[U]=V.iPhysicalSeat[Q],E[U]=Q+1}B(),N.attributes.iOffset.needsUpdate=!0,N.attributes.iRadius.needsUpdate=!0,N.attributes.iYaw.needsUpdate=!0,N.attributes.iGlyph.needsUpdate=!0,N.attributes.iRing.needsUpdate=!0,N.attributes.iFloor.needsUpdate=!0,N.attributes.iPhysicalSeat.needsUpdate=!0,N.attributes.iSeed.needsUpdate=!0,N.attributes.iPickIndex.needsUpdate=!0,N.instancedCount=T,P.parent||P.setParent(n),$.drawCalls=4+(H?1:0)},nearSeatCount(){return g},uploadSeatStateRuns(L){if(!L.length)return;g&&B();for(let T of L)Mo(c,e.seats.iState,T.start,T.length,f,e.seats.iCategory);let G=x.buffer;if(!G){x.needsUpdate=!0;return}t.bindBuffer(t.ARRAY_BUFFER,G);for(let T of L){let V=c.subarray(T.start*3,(T.start+T.length)*3);t.bufferSubData(t.ARRAY_BUFFER,T.start*3*Float32Array.BYTES_PER_ELEMENT,V)}},dispose(){K=!0,o.remove(),r.remove(),a.remove(),l.remove(),p.remove(),b.remove(),N.remove(),F.remove(),Y?.remove(),y?.remove(),I?.texture&&t.deleteTexture(I.texture)}},ee=e.productionElements.find(L=>L.contentImageUrl&&L.contentPlane);if(ee?.contentImageUrl&&ee.contentPlane?.length===4&&typeof Image<"u"){let L=new Image;L.crossOrigin="anonymous",L.onload=()=>{if(K)return;let G=ee.contentPlane;Y=new _e(t,{position:{size:3,data:new Float32Array(G.flat())},uv:{size:2,data:new Float32Array([0,1,1,1,0,0,1,0])},floorIndex:{size:1,data:new Float32Array(4).fill(ee.floorIndex)},index:{data:new Uint16Array([0,1,2,2,1,3])}}),I=new Yn(t,{image:L,generateMipmaps:!0,wrapS:t.CLAMP_TO_EDGE,wrapT:t.CLAMP_TO_EDGE,flipY:!1}),y=new Un(t,{vertex:`#version 300 es
615
615
  precision highp float;
616
616
  in vec3 position; in vec2 uv; in float floorIndex;
617
617
  uniform mat4 modelViewMatrix; uniform mat4 projectionMatrix; uniform float uFocusFloor;
@@ -619,4 +619,4 @@ void main() {
619
619
  void main(){ vUv=uv; vDim=(uFocusFloor < -0.5 || abs(floorIndex-uFocusFloor)<0.5)?0.0:1.0; gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.0); }`,fragment:`#version 300 es
620
620
  precision highp float;
621
621
  in vec2 vUv; in float vDim; uniform sampler2D uImage; out vec4 fragColor;
622
- void main(){ if(vDim>0.5) discard; vec4 c=texture(uImage,vUv); if(c.a<0.01) discard; fragColor=c; }`,uniforms:{uImage:{value:C},uFocusFloor:{value:-1}},transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1});let j=new St(e,{geometry:R,program:x});j.frustumCulled=!1,j.setParent(n),Y.screenProgram=x,E=!0,Y.drawCalls=3+(M?1:0)+1},N.src=U.contentImageUrl}return Y}import{Mesh as Fn,RenderTarget as Is,Transform as _n}from"ogl";function Cs(e,t,n){let r=e+(t<<8)+(n<<16);return r===0?-1:r-1}function kr(e,t,n,r,o,i){let a=-1,s=1/0;for(let c=0;c<n;c++)for(let l=0;l<t;l++){let f=(c*t+l)*4,u=Cs(e[f],e[f+1],e[f+2]);if(u<0||u>=i)continue;let m=l-r,h=c-o,d=m*m+h*h;d<s&&(s=d,a=u)}return a}function Lr(e,t,n,r,o,i){let a=e-n.left,s=t-n.top,c=Math.round(a*r),l=Math.round((n.height-s)*r);return{x:Math.max(0,Math.min(o-1,c)),y:Math.max(0,Math.min(i-1,l))}}var Es=["uSeatRadius","uSeatScale","uMinPixels","uPixelToWorld"],Qt=class{constructor(t,n,r,o,i){this.seatScene=new _n;this.chairScene=new _n;this.solidScene=new _n;this.target=null;this.restoreClear=[0,0,0];this.renderer=t,this.gl=t.gl,this.maxIndex=i,this.seatProg=Pr(this.gl),this.chairProg=Ar(this.gl),this.depthProg=Rr(this.gl);let a=new Fn(this.gl,{geometry:n,program:this.seatProg});a.frustumCulled=!1,a.setParent(this.seatScene);let s=new Fn(this.gl,{geometry:r,program:this.chairProg});s.frustumCulled=!1,s.setParent(this.chairScene);let c=new Fn(this.gl,{geometry:o,program:this.depthProg});c.frustumCulled=!1,c.setParent(this.solidScene)}setRestoreClear(t){this.restoreClear=[t[0],t[1],t[2]]}syncFromSeatProgram(t){for(let r of Es)this.seatProg.uniforms[r].value=t.uniforms[r].value;let n=t.uniforms.uFocusFloor.value;this.seatProg.uniforms.uFocusFloor.value=n,this.chairProg.uniforms.uFocusFloor.value=n,this.depthProg.uniforms.uFocusFloor.value=n}ensureTarget(){let t=this.gl.drawingBufferWidth,n=this.gl.drawingBufferHeight;return this.target&&(this.target.width!==t||this.target.height!==n)&&this.destroyTarget(),this.target||(this.target=new Is(this.gl,{width:t,height:n,depth:!0})),this.target}destroyTarget(){if(!this.target)return;let t=this.gl;this.target.buffer&&t.deleteFramebuffer(this.target.buffer);for(let n of this.target.textures??[])n.texture&&t.deleteTexture(n.texture);this.target.depthBuffer&&t.deleteRenderbuffer(this.target.depthBuffer),this.target=null}pick(t,n,r,o){let i=this.gl,a=this.ensureTarget(),s=i.drawingBufferWidth,c=i.drawingBufferHeight,l=Math.max(0,n-o),f=Math.max(0,r-o),u=Math.max(1,Math.min(s,n+o+1)-l),m=Math.max(1,Math.min(c,r+o+1)-f);i.enable(i.SCISSOR_TEST),i.scissor(l,f,u,m);let[h,d,p]=this.restoreClear;i.clearColor(0,0,0,1),this.renderer.render({scene:this.solidScene,camera:t,target:a,clear:!0}),this.renderer.render({scene:this.seatScene,camera:t,target:a,clear:!1}),this.renderer.render({scene:this.chairScene,camera:t,target:a,clear:!1}),i.clearColor(h,d,p,1),i.disable(i.SCISSOR_TEST);let g=new Uint8Array(u*m*4);return this.renderer.bindFramebuffer(a),i.readPixels(l,f,u,m,i.RGBA,i.UNSIGNED_BYTE,g),this.renderer.bindFramebuffer(),kr(g,u,m,n-l,r-f,this.maxIndex)}dispose(){this.destroyTarget(),this.seatProg.remove(),this.chairProg.remove(),this.depthProg.remove()}};function Vr(e,t){let n=[];for(let r of t)e.has(r.seatId)?e.set(r.seatId,dt(r.state)):n.push(r);return n}function Or(e,t,n){let r=new Set;for(let a of t)(e.has(a)||n(a)!==void 0)&&r.add(a);let o=new Map(e),i=[];for(let[a,s]of e)r.has(a)||(i.push({seatId:a,state:we[s]??"available"}),o.delete(a));for(let a of r){if(o.has(a))continue;let s=n(a);s!==void 0&&(o.set(a,s),i.push({seatId:a,state:"selected"}))}return{updates:i,next:o}}import{Quat as wt,Vec3 as _s}from"ogl";function Ts(e,t){return[e[0]-t[0],e[1]-t[1],e[2]-t[2]]}function Br(e,t){return[e[0]+t[0],e[1]+t[1],e[2]+t[2]]}function Fs(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function Nr(e){let t=Math.hypot(e[0],e[1],e[2]);return t>1e-6?[e[0]/t,e[1]/t,e[2]/t]:[0,0,0]}function Dn(e){let t=Math.max(0,Math.min(1,e));return t*t*t*(t*(t*6-15)+10)}function kn(e,t){return Math.max(0,Math.min(1,e+t))}function zr(e,t){let n=e.length;if(n===0)return[0,0,0];if(n===1)return[...e[0]];let r=Math.max(0,Math.min(1,t)),o=n-1,i=Math.floor(r*o);i>=o&&(i=o-1);let a=r*o-i,s=e[Math.max(0,i-1)],c=e[i],l=e[i+1],f=e[Math.min(n-1,i+2)],u=a*a,m=u*a,h=[0,0,0];for(let d=0;d<3;d++)h[d]=.5*(2*c[d]+(-s[d]+l[d])*a+(2*s[d]-5*c[d]+4*l[d]-f[d])*u+(-s[d]+3*c[d]-3*l[d]+f[d])*m);return h}function Ln(e,t,n,r,o){let i=Nr(Ts(t,n));i[0]===0&&i[1]===0&&i[2]===0&&(i=[0,0,1]);let a=Br(Br(t,Fs(i,2.5)),[0,1.5,0]),s=[t[0]-r[0],0,t[2]-r[2]],c=Nr(s);c[0]===0&&c[2]===0&&(c=[i[0],0,i[2]]);let l=Math.max(1,o),f=[r[0]+c[0]*l*1.3,r[1]+l*.75,r[2]+c[2]*l*1.3];return{waypoints:[e,f,a],finalPos:a}}function Vn(e,t,n=35,r=28){let o=Dn(t),i=zr(e,o),a=Dn(Math.max(0,Math.min(1,(t-.66)/.34)));return{pos:i,fov:n+(r-n)*a,eased:o}}function Xr(e,t,n){let r=e.position.clone(),o=new wt().copy(e.quaternion);e.position.set(t[0],t[1],t[2]),e.lookAt(new _s(n[0],n[1],n[2]));let i=new wt().copy(e.quaternion);return e.position.copy(r),e.quaternion.copy(o),i}var $t=class{constructor(t){this.active=!1;this.waypoints=[];this.startQuat=new wt;this.endQuat=new wt;this.outQuat=new wt;this.startTime=0;this.duration=2500;this.endFov=28;this.resolveFn=null;this.camera=t}start(t,n,r,o=2500,i=28){return this.settle(),this.waypoints=t,this.startQuat.copy(n),this.endQuat.copy(r),this.duration=o,this.endFov=i,this.startTime=performance.now(),this.active=!0,new Promise(a=>{this.resolveFn=a})}update(t){if(!this.active)return!1;let n=Math.min(1,(t-this.startTime)/this.duration),{pos:r,fov:o,eased:i}=Vn(this.waypoints,n,35,this.endFov);return this.camera.position.set(r[0],r[1],r[2]),this.outQuat.copy(this.startQuat).slerp(this.endQuat,kn(i,.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 t=this.resolveFn;this.resolveFn=null,t&&t()}};var Ds=1.02,ks=1.5;function Yr(e,t,n=0,r){let o=Number.isFinite(r)?n+r:e[1]+Ds;return{eye:[e[0],o,e[2]],focal:[t.x*_,n+ks,t.y*_]}}var rt=Math.PI/180,Ls=45,Wr=80,Vs=.25,On=1,Os=.25,Bs=12*rt,Ns=.2,zs=1.5,jr=.8,qr=6,$r=1.9,Gs=2/3,Us=.12,Hs=.9,Xs=1.2,Ys=2,Jr=.05,Ws=6;function ei(e,t,n=0){if(!e.length)return{min:[t[0]-6,n,t[2]-6],max:[t[0]+6,Math.max(n+jr,t[1]),t[2]+6]};let r=1/0,o=-1/0,i=1/0,a=-1/0,s=n;for(let d of e)r=Math.min(r,d.cx-d.halfX),o=Math.max(o,d.cx+d.halfX),i=Math.min(i,d.cz-d.halfZ),a=Math.max(a,d.cz+d.halfZ),s=Math.max(s,d.y);let c=o-r,l=a-i,f=Math.max(c,Math.min(l,qr))/2,u=Math.max(l,Math.min(c,qr))/2,m=(r+o)/2,h=(i+a)/2;return{min:[m-f,n,h-u],max:[m+f,Math.max(n+jr,s),h+u]}}function js(e){return{min:[e.min[0],e.min[1],e.min[2]],max:[e.max[0],e.max[1]+$r,e.max[2]]}}function qs(e){let t=e.max[1];return[(e.min[0]+e.max[0])/2,Math.max(e.min[1]+zs,t+Ns,t+$r*Gs),(e.min[2]+e.max[2])/2]}function ti(e,t){let n=e[0]-t[0],r=e[2]-t[2],o=Math.hypot(n,r);return o<.001?{x:0,z:1}:{x:n/o,z:r/o}}function Kr(e,t,n){let r=t[0]-e[0],o=t[1]-e[1],i=t[2]-e[2],a=Math.hypot(r,o,i)||1;r/=a,o/=a,i/=a;let s=-i,c=r,l=Math.hypot(s,c);if(l<1e-6)return 1/0;s/=l,c/=l;let f=1/0,u=-1/0;for(let m=0;m<8;m++){let h=(m&1?n.max[0]:n.min[0])-e[0],d=(m&2?n.max[1]:n.min[1])-e[1],p=(m&4?n.max[2]:n.min[2])-e[2],g=Math.max(Jr,h*r+d*o+p*i),b=(h*s+p*c)/g;b<f&&(f=b),b>u&&(u=b)}return u-f}function Zr(e,t,n){let r=t[0]-e[0],o=t[1]-e[1],i=t[2]-e[2],a=Math.hypot(r,o,i)||1;r/=a,o/=a,i/=a;let s=-i,c=r,l=Math.hypot(s,c);if(l<1e-6)return 1/0;s/=l,c/=l;let f=-c*o,u=c*r-s*i,m=s*o,h=1/0,d=-1/0;for(let p=0;p<8;p++){let g=(p&1?n.max[0]:n.min[0])-e[0],b=(p&2?n.max[1]:n.min[1])-e[1],y=(p&4?n.max[2]:n.min[2])-e[2],P=Math.max(Jr,g*r+b*o+y*i),S=(g*f+b*u+y*m)/P;S<h&&(h=S),S>d&&(d=S)}return d-h}function Jt(e,t){return Math.tan(e*rt/2)*Math.max(.05,t)}function Qr(e,t,n){let r=s=>Math.max(Ls,Math.min(Wr,s)),o=s=>2*Math.atan(s)/rt,i=Number.isFinite(e)&&e>0?r(o(e/(2*Vs)/Math.max(.05,n))):Wr;if(!(Number.isFinite(t)&&t>0))return i;let a=Math.min(i,r(o(t/(2*Us))));return e/(2*Jt(a,n))>On?i:a}function ni(e,t,n){let r=qs(t),o=[e[0],e[1],e[2]],i=0,a=0,s=h=>{if(!(h>0))return;let d=ti(o,r);o[0]+=d.x*h,o[2]+=d.z*h,a+=h},c=t.max[1]+Os-o[1];c>0&&(o[1]+=c,i=c,s(c/Math.tan(Bs)));let l=js(t),f=Kr(o,r,t),u=Qr(f,Zr(o,r,l),n),m=f/(2*Jt(u,n));for(let h=0;h<Ws&&m>On;h++){let d=Math.max(1,Math.hypot(o[0]-r[0],o[2]-r[2])),p=Number.isFinite(m)?m/On:2;s(Math.min(60,d*(Math.min(4,p)-1)+.5)),f=Kr(o,r,t),u=Qr(f,Zr(o,r,l),n),m=f/(2*Jt(u,n))}return{eye:o,focal:r,fov:u,raisedM:i,pulledBackM:a,stageFrameWidth:m}}function Ks(e,t,n){let r=Math.tan(t*rt/2),o=Jt(t,n);return Math.max(1,e/Math.max(.05,Math.min(r,o)))}function oi(e,t){let{aspect:n,venue:r}=t,o=e.focal,i=ti(e.eye,o),a=m=>(m[0]-o[0])*i.x+(m[2]-o[2])*i.z,s=[{name:"seat",eye:e.eye,focal:o,fov:e.fov}],c=Ys*(t.rowDepthM??Hs);s.push({name:"row",eye:[e.eye[0]+i.x*c,e.eye[1]+Xs,e.eye[2]+i.z*c],focal:o,fov:e.fov});let l=(m,h,d,p)=>{let g=Ks(d,e.fov,n)*1.08,b=g*Math.sin(p*rt),y=g*Math.cos(p*rt);return{name:m,eye:[h[0]+i.x*y,h[1]+b,h[2]+i.z*y],focal:h,fov:e.fov}};t.section&&t.section.radius>0&&s.push(l("section",t.section.center,t.section.radius,14)),s.push(l("venue",r.center,Math.max(1,r.radius),26));let f=[],u=-1/0;for(let m of s){let h=a(m.eye);f.length&&h<=u+.5||(f.push(m),u=h)}return f}import{Vec3 as Zs}from"ogl";var At=Math.PI/180,ri=320,ii=70*At,Qs=32*At,$s=24*At,ai=.0026,Js=.22,ec=.006,tc=180,nc=4,pe=(e,t,n)=>Math.max(t,Math.min(n,e)),si=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2;function ci(e){let{canvas:t,camera:n}=e,r=[],o=!1,i=0,a=0,s=0,c=0,l=0,f=0,u=!1,m=[0,0],h=0,d=!1,p=null,g=null,b=new Map,y=!1,P=0,S=0,A=0,v=0,I=()=>o&&r.length?r[pe(Math.round(i),0,r.length-1)].name:null,T=()=>{let x=I();x!==p&&(p=x,e.onStopChange?.(x))},k=()=>{if(!o||!r.length)return;let x=r[pe(Math.floor(i),0,r.length-1)],C=r[pe(Math.ceil(i),0,r.length-1)],X=pe(i-Math.floor(i),0,1),G=(ve,Me)=>ve+(Me-ve)*X,Y=[G(x.eye[0],C.eye[0]),G(x.eye[1],C.eye[1]),G(x.eye[2],C.eye[2])],U=[G(x.focal[0],C.focal[0]),G(x.focal[1],C.focal[1]),G(x.focal[2],C.focal[2])],N=U[0]-Y[0],H=U[1]-Y[1],j=U[2]-Y[2],W=Math.hypot(N,H,j)||1,K=Math.atan2(N,j),Q=Math.asin(pe(H/W,-1,1)),$=K+a,ae=pe(Q+s,-80*At,80*At),Pe=Math.cos(ae)*W;N=Math.sin($)*Pe,H=Math.sin(ae)*W,j=Math.cos($)*Pe,n.position.set(Y[0],Y[1],Y[2]),n.fov=G(x.fov,C.fov),n.updateProjectionMatrix(),n.lookAt(new Zs(Y[0]+N,Y[1]+H,Y[2]+j)),e.onApplied?.()},z=()=>{if(!o||!r.length)return;let x=pe(Math.round(i),0,r.length-1);if(e.reducedMotion()){u=!1,i=x,k(),T(),e.requestRender();return}if(Math.abs(x-i)<.001){u=!1,T();return}c=i,l=x,f=performance.now(),u=!0,e.requestRender()},V=x=>{!o||r.length<2||(u=!1,i=pe(i+x,0,r.length-1),k(),T(),e.requestRender())},w=(x,C)=>{o&&(u=!1,d=!1,a=pe(a-x*ai,-ii,ii),s=pe(s-C*ai,-$s,Qs),k(),e.requestRender())},F=x=>{o&&(b.set(x.pointerId,{x:x.clientX,y:x.clientY}),b.size===1?(y=!0,v=0,P=x.clientX,S=x.clientY):b.size===2&&(y=!1,A=D()))},D=()=>{let x=[...b.values()];return x.length<2?0:Math.hypot(x[0].x-x[1].x,x[0].y-x[1].y)},M=x=>{if(!o||!b.has(x.pointerId))return;if(b.set(x.pointerId,{x:x.clientX,y:x.clientY}),b.size>=2){let G=D();A>0&&V((A-G)*ec),A=G;return}if(!y)return;let C=x.clientX-P,X=x.clientY-S;P=x.clientX,S=x.clientY,v+=Math.abs(C)+Math.abs(X),!(v<=nc)&&w(C,X)},E=x=>{b.delete(x.pointerId)&&(b.size<2&&(A=0),b.size===0&&(y=!1,z()))},B=x=>{if(!o)return;x.preventDefault();let C=x.deltaMode===1?16:x.deltaMode===2?100:1,X=pe(x.deltaY*C/100,-2,2);V(X*Js),g&&clearTimeout(g),g=setTimeout(()=>{g=null,z()},tc)},R=()=>{o&&(o=!1,u=!1,d=!1,r=[],b.clear(),y=!1,g&&(clearTimeout(g),g=null),p!==null&&(p=null,e.onStopChange?.(null)))};return t.addEventListener("pointerdown",F),t.addEventListener("pointermove",M),t.addEventListener("pointerup",E),t.addEventListener("pointercancel",E),t.addEventListener("wheel",B,{passive:!1}),{get active(){return o},enter(x){if(x.length<2){R();return}r=x,o=!0,i=0,a=0,s=0,u=!1,d=!1,p=null,k(),T(),e.requestRender()},exit:R,recentre(){return o?Math.abs(a)<1e-4&&Math.abs(s)<1e-4?!0:e.reducedMotion()?(d=!1,a=0,s=0,k(),e.requestRender(),!0):(m=[a,s],h=performance.now(),d=!0,e.requestRender(),!0):!1},update(x){if(!o)return!1;let C=!1;if(d){let X=pe((x-h)/ri,0,1),G=1-si(X);a=m[0]*G,s=m[1]*G,X>=1?(d=!1,a=0,s=0):C=!0}if(u){let X=pe((x-f)/ri,0,1);i=c+(l-c)*si(X),X>=1?(u=!1,i=l,T()):C=!0}return k(),C},currentStop:I,dispose(){R(),t.removeEventListener("pointerdown",F),t.removeEventListener("pointermove",M),t.removeEventListener("pointerup",E),t.removeEventListener("pointercancel",E),t.removeEventListener("wheel",B)}}}var Bn=null;function li(){return Bn??=import("../openPanorama-HGRYMWKC.js").catch(e=>{throw Bn=null,e}),Bn}var ui=()=>typeof performance<"u"&&performance.now?performance.now():Date.now(),en=class{constructor(t){this.orbitLatched=!1;this.panoramaOpenedAt=0;this.cb=t}emit(t,n){if(this.cb)try{this.cb(t,n)}catch{}}opened(t,n,r,o){this.emit("3d_opened",{seats:t,hasHeights:n,...r===void 0?{}:{buildMs:Math.round(r)},...o===void 0?{}:{prepSource:o}})}orbitEngaged(){this.orbitLatched||(this.orbitLatched=!0,this.emit("3d_orbit_engaged"))}seatPicked(t,n){this.emit("3d_seat_picked",{seatId:t,sectionId:n})}cinematicPlayed(t){this.emit("3d_cinematic_played",{durationMs:t,reducedMotion:!1})}cinematicSkipped(){this.emit("3d_cinematic_skipped",{reducedMotion:!0})}cinematicCancelled(){this.emit("3d_cinematic_cancelled")}panoramaOpened(){this.panoramaOpenedAt=ui(),this.emit("3d_panorama_opened")}panoramaClosed(){let t=this.panoramaOpenedAt?Math.round(ui()-this.panoramaOpenedAt):0;this.panoramaOpenedAt=0,this.emit("3d_panorama_closed",{viewMs:t})}panoramaFailed(t,n){this.emit("3d_panorama_failed",{seatId:t,phase:n})}panoramaFallback(t){this.emit("3d_panorama_fallback",{seatId:t})}contextLost(){this.emit("3d_context_lost")}contextRestored(){this.emit("3d_context_restored")}};function mi(e){let t=e.style.position;return getComputedStyle(e).position!=="static"?()=>{}:(e.style.position="relative",()=>{e.style.position==="relative"&&(e.style.position=t)})}function di(e){let{container:t,model:n,opts:r,expandedSeatById:o,seatIdsByRow:i,isNarrow:a}=e,s=null,c=()=>{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"})},l=()=>{s?.remove(),s=null};return{show:(u,m,h=!1)=>{if(l(),e.isDisposed())return null;let d=document.createElement("div");d.setAttribute("role","group"),Object.assign(d.style,{position:"absolute",display:"flex",flexDirection:"column",alignItems:"center",gap:"6px",zIndex:"4"});let p=o.get(u),g=p?.sectionId?n.sections.find(T=>T.id===p.sectionId):void 0,b=p?.label??u;d.setAttribute("aria-label",`Explore views near ${g?.label?`${g.label}, `:""}seat ${b}`);let y=document.createElement("span");y.textContent=r.seatViewCaption?.(u)??["Live 3D seat view",g?.label,b].filter(Boolean).join(" \xB7 "),Object.assign(y.style,{maxWidth:"min(70vw, 560px)",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)"}),d.appendChild(y);let P=document.createElement("div");Object.assign(P.style,{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px"}),d.appendChild(P);let S=p?.rowId?i.get(p.rowId):void 0,A=S?.indexOf(u)??-1,v=A>=0?[S?.[A-1],S?.[A+1]]:[void 0,void 0],I=(T,k,z,V=!1)=>{let w=document.createElement("button");w.type="button",w.textContent=T,w.setAttribute("aria-label",k),Object.assign(w.style,{minHeight:"44px",padding:V?"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"}),V||(w.style.minWidth="44px"),V&&(w.dataset.panoramaTrigger=""),w.addEventListener("click",z),P.appendChild(w)};if(v[0]){let T=o.get(v[0])?.label??v[0];I("\u2039",`View previous seat ${T}`,()=>{e.flyToSeat(v[0])})}if(r.getSeatView){let T=r.seatViewActionLabel?.(u)??"Open 360\xB0 panorama";I(h?`\u21BB Retry ${T}`:`\u25C9 ${T}`,`${h?"Retry":T} from seat ${b}`,()=>{if(e.isDisposed()||m!==e.flightGen()){l();return}l(),e.openPanorama(u,400,m)},!0)}if(v[1]){let T=o.get(v[1])?.label??v[1];I("\u203A",`View next seat ${T}`,()=>{e.flyToSeat(v[1])})}return P.childElementCount?(t.appendChild(d),s=d,c(),d):null},remove:l,layout:c}}function hi(e){let{container:t,orbit:n,isNarrow:r}=e,o=document.createElement("div"),i=!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 c=document.createElement("button");c.type="button",c.textContent="\u21BB",c.setAttribute("aria-label","Drag to rotate the 3D venue"),c.dataset.tooltip="Rotate venue";let l=document.createElement("button");l.type="button",l.textContent="\u2725",l.setAttribute("aria-label","Drag to move the 3D venue left, right, up or down"),l.dataset.tooltip="Move venue";let f=document.createElement("button");f.type="button",f.textContent="\u2212",f.setAttribute("aria-label","Zoom out of the 3D venue"),f.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 p of[c,l,f,u])p.className="sl-3d-icon-control",Object.assign(p.style,{width:"44px",minWidth:"44px",minHeight:"44px",padding:"9px",border:"1px solid rgba(150,165,205,0.35)",borderRadius:"999px",color:"#c9d4ea",background:"rgba(12,18,32,0.82)",font:"600 17px/1 inherit",backdropFilter:"blur(6px)",cursor:"pointer",whiteSpace:"nowrap"});a.append(c,l),s.append(u,f);let m=p=>{n.setPrimaryDragMode(p);let g=p==="orbit";c.setAttribute("aria-pressed",String(g)),l.setAttribute("aria-pressed",String(!g)),c.style.background=g?"rgba(96,110,150,0.68)":"rgba(12,18,32,0.82)",l.style.background=g?"rgba(12,18,32,0.82)":"rgba(96,110,150,0.68)",o.title=g?"Drag to rotate \xB7 Shift-drag to move":"Drag to move \xB7 Shift-drag to rotate"};c.addEventListener("click",()=>m("orbit")),l.addEventListener("click",()=>m("pan")),f.addEventListener("click",()=>n.zoomBy(1.22)),u.addEventListener("click",()=>n.zoomBy(.82)),o.append(a,s),m("orbit"),t.appendChild(o);let h=()=>{let p=r();o.style.display=i?"none":"flex",o.style.right=p?"12px":"14px",o.style.bottom=p?"calc(env(safe-area-inset-bottom, 0px) + 76px)":"14px",a.style.display=p?"none":"flex",u.style.display=p?"none":"",f.style.display=p?"none":""};return h(),{element:o,utilityControls:s,setNavigationMode:m,setSeatViewLocked:p=>{i=p,n.setInteractionEnabled(!p),h()},seatViewLocked:()=>i,layout:h}}function fi(e){let{glctx:t,orbit:n,model:r,seats:o,opts:i,cinematic:a,analytics:s,seatIdByIndex:c,sectionIdBySeatId:l,tapSlop:f,tapMs:u,cancelFlight:m,focusSectionCamera:h,setSelection:d,ensureSeatView:p}=e,g=0,b=0,y=0,P=-1,S=!1,A=!1,v=V=>{e.seatViewLocked()||P===-1&&(P=V.pointerId,g=V.clientX,b=V.clientY,y=performance.now(),S=!1,A=a.active,a.active&&(s.cinematicCancelled(),m(),i.onViewTargetChange?.(null)))},I=V=>{V.pointerId===P&&Math.hypot(V.clientX-g,V.clientY-b)>f&&(S=!0)},T=(V,w,F,D,M)=>{let E=t.canvas.getBoundingClientRect(),B=t.canvas.clientWidth||E.width||1,R=t.canvas.clientHeight||E.height||1,x=V-E.left,C=w-E.top,X=D*D,G=-1,Y=X,U=1/0;for(let N of o){if(F&&N.sectionId!==F)continue;let H=r.seats.idToIndex.get(N.id);if(H===void 0)continue;if(M){let ae=Math.round(r.seats.iState[H]??0);if(ae!==0&&ae!==3)continue}let j=H*3,W=Ge(n.camera.projectionViewMatrix,[r.seats.iPosition[j],r.seats.iPosition[j+1]+.55,r.seats.iPosition[j+2]],B,R);if(!W.visible)continue;let K=W.x-x,Q=W.y-C,$=K*K+Q*Q;($<Y||Math.abs($-Y)<1&&W.depth<U)&&(G=H,Y=$,U=W.depth)}return G},k=(V,w)=>{let F=e.gpu(),D=e.pick();if(!F||!D)return-1;D.syncFromSeatProgram(F.seatProgram);let M=t.canvas.getBoundingClientRect(),E=t.renderer.dpr,{x:B,y:R}=Lr(V,w,M,E,t.gl.drawingBufferWidth,t.gl.drawingBufferHeight),x=Math.max(2,Math.round(8*E));return D.pick(n.camera,B,R,x)};return{onDown:v,onMove:I,onUp:V=>{if(V.pointerId!==P)return;let w=!S&&performance.now()-y<u;if(P=-1,A){A=!1;return}let F=e.gpu(),D=e.pick();if(!w||!F||!D)return;let M=k(V.clientX,V.clientY);if(e.focusedSectionId()&&M>=0){let R=c[M],x=R?l.get(R):void 0;if(x&&x!==e.focusedSectionId()&&h(x))return}if(e.focusedSectionId()&&M<0&&(M=T(V.clientX,V.clientY,e.focusedSectionId(),44,!1)),e.focusedSectionId()&&M<0){let R=T(V.clientX,V.clientY,null,72,!1),x=R>=0?c[R]:void 0,C=x?l.get(x):void 0;if(C&&C!==e.focusedSectionId()&&h(C))return}if(!e.focusedSectionId()){M<0&&(M=T(V.clientX,V.clientY,null,42,!1));let R=M>=0?c[M]:void 0,x=R?l.get(R):void 0;if(x&&h(x))return}if(M<0||M>=c.length){e.selection().size&&(d([]),i.onViewTargetChange?.(null));return}let E=c[M],B=we[Math.round(r.seats.iState[M]??0)]??"available";if(B!=="available"&&B!=="selected"){i.onSeatInspect?.(E,B);return}if(e.selection().has(E)&&e.selection().size===1){d([]),i.onViewTargetChange?.(null),i.onSeatPick?.(E);return}d([E]),p(E),s.seatPicked(E,l.get(E)),i.onSeatPick?.(E)}}}var tn=class{constructor(t,n){this.minX=0;this.minZ=0;this.cell=1;this.cols=1;this.rows=1;this.cellStart=null;this.cellItems=null;this.iPosition=t,this.count=n}ensureGrid(){if(this.cellStart||this.count===0)return;let t=this.iPosition,n=1/0,r=1/0,o=-1/0,i=-1/0;for(let h=0;h<this.count;h++){let d=t[h*3],p=t[h*3+2];d<n&&(n=d),d>o&&(o=d),p<r&&(r=p),p>i&&(i=p)}let a=Math.max(o-n,.001),s=Math.max(i-r,.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=r;let c=this.cols*this.rows,l=new Int32Array(c+1),f=h=>{let d=Math.min(this.cols-1,Math.max(0,Math.floor((t[h*3]-n)/this.cell)));return Math.min(this.rows-1,Math.max(0,Math.floor((t[h*3+2]-r)/this.cell)))*this.cols+d};for(let h=0;h<this.count;h++)l[f(h)+1]++;for(let h=0;h<c;h++)l[h+1]+=l[h];let u=new Int32Array(this.count),m=l.slice(0,c);for(let h=0;h<this.count;h++)u[m[f(h)]++]=h;this.cellStart=l,this.cellItems=u}gather(t,n,r,o){this.ensureGrid();let i=this.cellStart,a=this.cellItems;if(!i||!a)return 0;let s=o.length,c=r*r,l=Math.floor((t-this.minX)/this.cell),f=Math.floor((n-this.minZ)/this.cell),u=Math.ceil(r/this.cell)+1,m=this.iPosition,h=0;for(let d=0;d<=u&&h<s;d++){let p=f-d,g=f+d,b=l-d,y=l+d;for(let P=p;P<=g&&h<s;P++){if(P<0||P>=this.rows)continue;let S=P===p||P===g;for(let A=b;A<=y&&h<s;A++){if(!S&&A!==b&&A!==y){A=y-1;continue}if(A<0||A>=this.cols)continue;let v=P*this.cols+A;for(let I=i[v],T=i[v+1];I<T&&h<s;I++){let k=a[I],z=m[k*3]-t,V=m[k*3+2]-n;z*z+V*V<=c&&(o[h++]=k)}}}}return h}};var nn=class{constructor(t){this.ctx=t;this.detailVisible=!1;this.seatDetailMix=0;this.structureDetailMix=0;this.nearBuf=new Int32Array(Ot);this.lastGatherX=1/0;this.lastGatherZ=1/0;this.nearIndex=new tn(t.model.seats.iPosition,t.model.seats.count)}forceRegather(){this.lastGatherX=1/0}setDetailEnabled(t){let n=this.ctx.gpu();t||(this.detailVisible=!1),this.lastGatherX=1/0,this.lastGatherZ=1/0,!t&&n?.nearSeatCount()&&n.setNearSeats(this.nearBuf,0)}update(t){let{model:n}=this.ctx,r=this.ctx.gpu();if(!r)return;if(!t){r.nearSeatCount()&&r.setNearSeats(this.nearBuf,0);return}let o=this.ctx.orbit().camera.position;if(Math.hypot(o.x-this.lastGatherX,o.z-this.lastGatherZ)<hn)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>dn){r.nearSeatCount()&&r.setNearSeats(this.nearBuf,0);return}let s=this.nearIndex.gather(o.x,o.z,dn,this.nearBuf);s===0&&r.nearSeatCount()===0||r.setNearSeats(this.nearBuf,s)}ease(t,n,r){let o=1-Math.exp(-t*9),i=1-Math.exp(-t*20);this.seatDetailMix+=(n-this.seatDetailMix)*(n>this.seatDetailMix?o:i),this.structureDetailMix+=(r-this.structureDetailMix)*(r>this.structureDetailMix?o:i),Math.abs(n-this.seatDetailMix)<.01&&(this.seatDetailMix=n),Math.abs(r-this.structureDetailMix)<.01&&(this.structureDetailMix=r)}};import{Quat as oc,Vec3 as rc}from"ogl";function pi(e){let{container:t,model:n,opts:r,orbit:o,cinematic:i,analytics:a,loop:s,labelOverlay:c,stageAzimuth:l,overviewFraming:f}=e,u=0,m=-1,h=(A,v,I=28)=>{o.camera.position.set(A[0],A[1],A[2]),o.camera.lookAt(new rc(v[0],v[1],v[2])),o.camera.fov=I,o.camera.updateProjectionMatrix()},d=document.createElement("button");d.className="sl-3d-overview-control sl-3d-icon-control",d.type="button",d.textContent="\u2302",d.setAttribute("aria-label","Fit the active level or whole venue in view"),d.dataset.tooltip="Fit view",Object.assign(d.style,{width:"44px",minWidth:"44px",minHeight:"44px",padding:"9px",borderRadius:"999px",background:"rgba(12,18,32,0.72)",color:"#c9d4ea",border:"1px solid rgba(150,165,205,0.35)",backdropFilter:"blur(6px)",font:"600 11px/1 inherit",cursor:"pointer",whiteSpace:"nowrap"});let p=()=>{d.textContent="\u2302"};p();let g=A=>{m=A;let v=e.gpu();v&&(v.seatProgram.uniforms.uFocusFloor.value=A,v.solidProgram.uniforms.uFocusFloor.value=A,v.chairProgram.uniforms.uFocusFloor.value=A),e.showSectionSeatLabels(null)},b=()=>{if(e.isDisposed())return;r.onViewTargetChange?.(null),r.onSectionFocusChange?.(null),e.panorama()&&(e.panorama().dispose(),e.setPanorama(null),a.panoramaClosed()),e.setPanoramaSphereVisible(!1),e.panoramaLoadAbort()?.abort(),e.setPanoramaLoadAbort(null),e.restorePanoramaLayer(),d.style.display="",c.setVisible(!0),e.setFrozen(!1);let A=m>=0?n.floors[m]:null;if(e.setNearFieldDetailEnabled(!!A),e.setSeatViewLocked(!1),y(),e.removeArriveChip(),e.setNavigationMode("orbit"),A){let v=A.focalWorld[0]-A.center[0],I=A.focalWorld[2]-A.center[2],T=Math.hypot(v,I)>A.radius*.12?Math.atan2(v,I):l,k={center:A.center,radius:A.radius,box:A.box},z={polarDeg:58,margin:1.12};e.reducedMotion()?o.frame(k,!1,T,!1,z):o.frameSoft(k,T,!1,z)}else e.reducedMotion()?o.frame(n.bounds,!1,l,r.portraitOverviewCrop===!0,f):o.frameSoft(n.bounds,l,r.portraitOverviewCrop===!0,f);e.showSectionSeatLabels(null),s.requestRender()},y=()=>{u++,e.setSeatStepping(!1),e.panoramaLoadAbort()?.abort(),e.setPanoramaLoadAbort(null),i.active&&(i.cancel(),o.resumeAfterFlight(n.focalWorld))},P=A=>{if(e.isDisposed()||!e.gpu())return Promise.resolve();let v=n.seats.idToIndex.get(A);if(v===void 0)return Promise.resolve();e.setNearFieldDetailEnabled(!0),r.onViewTargetChange?.(A),e.panorama()&&(e.panorama().dispose(),e.setPanorama(null),e.setPanoramaSphereVisible(!1),d.style.display="",e.restorePanoramaLayer()),e.panoramaLoadAbort()?.abort(),e.setPanoramaLoadAbort(null),e.setFrozen(!1);let I=e.inSeatView()&&r.arriveAtSeatEye===!0;e.setSeatStepping(I),e.setSeatViewLocked(!1);let T=++u;I?e.showArriveChip(A,T):e.removeArriveChip();let{eye:k,focal:z}=e.resolvedSeatViewPose(A,v),V=r.arriveAtSeatEye?e.seatViewArrival(A,v):null,w=V?V.focal:z,F=[o.camera.position.x,o.camera.position.y,o.camera.position.z],D=Ln(F,V?.eye??k,w,n.bounds.center,n.bounds.radius),M=V?V.eye:r.arriveAtSeatEye?k:D.finalPos,E=V?V.fov:r.arriveAtSeatEye?t.clientWidth/Math.max(1,t.clientHeight)<.7?90:65:28,B=[D.waypoints[0],D.waypoints[1],M];if(c.setVisible(!1),e.reducedMotion())return e.setSeatStepping(!1),h(M,w,E),s.requestRender(),a.cinematicSkipped(),e.isDisposed()||o.syncFromCamera(),e.setSeatViewLocked(r.arriveAtSeatEye===!0),V&&e.enterSeatView(V.stops),e.showArriveChip(A,T),Promise.resolve();let R=new oc().copy(o.camera.quaternion),x=Xr(o.camera,M,w);s.requestRender();let C=I?700:2500;return i.start(B,R,x,C,E).then(()=>{e.isDisposed()||T!==u||(e.setSeatStepping(!1),a.cinematicPlayed(C),o.resumeAfterFlight(w),e.setSeatViewLocked(r.arriveAtSeatEye===!0),V&&e.enterSeatView(V.stops),s.requestRender(),e.showArriveChip(A,T))})},S=A=>{let v=n.sections.find(z=>z.id===A);if(!v||v.seatCount===0)return!1;e.setNearFieldDetailEnabled(!0),e.setSeatStepping(!1),e.setSeatViewLocked(!1),i.cancel(),e.removeArriveChip(),n.floors.length>1&&m!==v.floorIndex&&g(v.floorIndex),e.setNavigationMode("pan"),e.showSectionSeatLabels(A);let I=v.focalWorld[0]-v.center[0],T=v.focalWorld[2]-v.center[2],k=Math.hypot(I,T)>v.radius*.12?Math.atan2(I,T):void 0;return o.frame({center:v.center,radius:Math.max(5,v.radius*.5)},!1,k),r.onSectionFocusChange?.(A),s.requestRender(),!0};return d.addEventListener("click",b),{overviewChip:d,layoutOverviewChip:p,flightGen:()=>u,focusedFloor:()=>m,applyFloorFocus:g,placeCameraFinal:h,cancelFlight:y,focusOverview:b,flyToSeat:P,focusSectionCamera:S}}function bi(e){let t=performance.now();return{model:vt(e),buildMs:performance.now()-t,source:"main"}}function ic(e){return typeof Worker>"u"?Promise.resolve(bi(e)):new Promise(t=>{let n=new Worker(new URL("./scene/scene.worker.ts",import.meta.url),{type:"module"}),r=!1,o=s=>{r||(r=!0,clearTimeout(a),n.terminate(),t(s))},i=()=>o(bi(e)),a=window.setTimeout(i,15e3);n.onerror=i,n.onmessage=s=>{o({model:s.data.model,buildMs:s.data.buildMs,source:"worker"})},n.postMessage(e)})}var ac=Math.PI/180,sc=6,cc=500;function jm(e,t,n={}){let r=performance.now(),o=t.prepared?.model??vt(t),i=new en(n.onAnalytics),a=new Array(o.seats.count);for(let[L,O]of o.seats.idToIndex)a[O]=L;let s=new Map(t.seats.map(L=>[L.id,L])),c=new Map;for(let L of t.seats){if(!L.rowId)continue;let O=c.get(L.rowId);O?O.push(L.id):c.set(L.rowId,[L.id])}let l=new Map;for(let L of t.seats)l.set(L.id,L.sectionId);let f=t.doc.floors?.some(O=>(O.baseHeightM??0)>0)?!0:(t.doc.floors?.flatMap(O=>O.objects)??t.doc.objects).some(O=>O.type==="section"&&((O.height??0)>0||(O.rake??0)>0)),u=null,m=null,h=!1,d=!1,p=!1,g=new Map,b=null,y=null,P=null,S=new Map,A=null,v=()=>{P===null&&(P=e.style.zIndex,e.style.zIndex="20")},I=()=>{P!==null&&(e.style.zIndex==="20"&&(e.style.zIndex=P),P=null)},T=!1,k=()=>T?me.focusedFloor():-1,z=()=>{u=Dr(D.gl,o),m=new Qt(D.renderer,u.seatGeometry,u.chairGeometry,u.solidGeometry,o.seats.count),D.setClearColor(o.theme.background.top),m.setRestoreClear(o.theme.background.top),u.seatProgram.uniforms.uSeatRadius.value=Fe*o.theme.seatScale,u.seatProgram.uniforms.uFocusFloor.value=k(),u.solidProgram.uniforms.uFocusFloor.value=k(),u.chairProgram.uniforms.uFocusFloor.value=k(),u.screenProgram&&(u.screenProgram.uniforms.uFocusFloor.value=k()),w.forceRegather()},V=!1,w=new nn({model:o,orbit:()=>M,gpu:()=>u}),F=L=>w.setDetailEnabled(L),D=new kt(e,{onContextLost:()=>{p||i.contextLost(),h=!0,W.stop(),u=null,m=null},onContextRestored:()=>{z(),h=!1,p||i.contextRestored(),W.requestRender()}}),M=new Lt(D.gl,D.canvas,()=>W.requestRender(),()=>i.orbitEngaged());M.setAspect(D.aspect);let E=(t.doc.floors?.flatMap(L=>L.objects)??t.doc.objects).some(L=>L.type==="section"&&L.physical3dProvenance?.surfaceKind?.status==="inferred"),B=(()=>{if(E&&o.stages.length===0)return;let L=o.focalWorld[0]-o.bounds.center[0],O=o.focalWorld[2]-o.bounds.center[2];return Math.hypot(L,O)>o.bounds.radius*.12?Math.atan2(L,O):void 0})(),R=o.floors.length>1?{polarDeg:48,margin:1.1}:void 0,x=typeof window<"u"&&!!window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;M.frame(o.bounds,!x&&n.skipInitialOverviewAnimation!==!0,B,n.portraitOverviewCrop===!0,R);let C=new $t(M.camera),X=mi(e),G=new Kt(e,{fontFamily:t.doc.theme?.fontFamily,ink:t.doc.theme?.textColor,backgroundRgb:o.theme.background.top}),Y=o.labels,U=()=>er(Y,o.floors.length,k());G.setLabels(U());let N=null,H=L=>{if(N=L,G.setForcedDense(!!L),!L){G.setLabels(U());return}let O=t.seats.filter(Z=>Z.sectionId===L),q=new Set(O.map(Z=>Z.id)),J=new Set(O.map(Z=>Z.rowId)),te=new Set(g.keys()),ne=new Set(O.filter(Z=>te.has(Z.id)).map(Z=>Z.id)),re=U().filter(Z=>Z.kind!=="row"&&Z.kind!=="seat"||(Z.kind==="row"?J.has(Z.id.slice(4)):q.has(Z.id.slice(5))&&(ne.size===0||ne.has(Z.id.slice(5)))));if(o.seatCount<=6e3&&ne.size===0){G.setLabels(re);return}let ce=ne.size?O.filter(Z=>ne.has(Z.id)):O,He=new Set(ce.map(Z=>`seat:${Z.id}`)),Oe=ce.flatMap(Z=>{let de=o.seats.idToIndex.get(Z.id);if(de===void 0)return[];let Ae=de*3;return[{id:`seat:${Z.id}`,kind:"seat",text:Z.displayLabel||Z.label,anchor:[o.seats.iPosition[Ae],o.seats.iPosition[Ae+1]+(te.has(Z.id)?1.05:.55),o.seats.iPosition[Ae+2]]}]});G.setLabels([...re.filter(Z=>!He.has(Z.id)),...Oe])};z();let j=null,W=new Vt(L=>{if(h||!u||d)return!1;let q=C.active?C.update(performance.now()):j?.active?j.update(performance.now()):M.update(),J=k()>=0?o.floors[k()]:null,te=J?.radius??o.bounds.radius,ne=uo(M.currentDistance,te),re=V?{center:[M.camera.position.x,M.camera.position.y,M.camera.position.z],radius:520}:o.renderBounds;M.updateClipping(re);let ce=J?.center??o.renderBounds.center,He=J?.radius??o.renderBounds.radius,Oe=(Re,ct)=>Math.hypot(M.camera.position.x-Re[0],M.camera.position.y-Re[1],M.camera.position.z-Re[2])<=ct*(w.detailVisible?1.8:1.55),Z=Oe(ce,He);if(!Z&&N){let Re=o.sections.find(ct=>ct.id===N);Re&&(Z=Oe(Re.center,Math.max(12,Re.radius*2)))}w.detailVisible=Z;let de=u.seatProgram.uniforms;de.uSeatScale.value=ne.scale,de.uSeatFade.value=ne.fade;let Ae=!!J&&mo(J.seatCount,D.canvas.clientWidth||1,D.canvas.clientHeight||1),It=ho(o.seats.count,te,M.currentDistance,M.camera.fov,D.canvas.clientHeight||1),st=w.detailVisible||Ae||It?1:0,Et=w.detailVisible||k()>=0||o.floors.length>1?1:0;return w.ease(L,st,Et),de.uSeatDetail.value=w.seatDetailMix,u.solidProgram.uniforms.uStructureDetail.value=w.structureDetailMix,de.uMinPixels.value=ne.minPixels,de.uPixelToWorld.value=2*Math.tan(M.camera.fov*ac/2)/Math.max(1,D.pixelHeight),w.update(w.detailVisible),D.renderer.render({scene:u.background,clear:!0}),D.renderer.render({scene:u.main,camera:M.camera,clear:!1}),G.update(M.camera.projectionViewMatrix,D.canvas.clientWidth||1,D.canvas.clientHeight||1,M.currentDistance,te,[M.camera.position.x,M.camera.position.y,M.camera.position.z]),q||w.seatDetailMix!==st||w.structureDetailMix!==Et}),K=typeof ResizeObserver<"u"?new ResizeObserver(()=>rn.resize()):null;K?.observe(e);let Q=L=>{let O=te=>{let ne=o.seats.idToIndex.get(te);return ne===void 0?void 0:o.seats.iState[ne]},{updates:q,next:J}=Or(g,L,O);if(g=J,G.setSelectedSeatIds(g.keys()),N&&H(N),q.length){let te=yn(o.seats,q);u&&u.uploadSeatStateRuns(te),W.requestRender()}},$=()=>A!==null?A:typeof window<"u"&&!!window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,ae=8,Pe=L=>{if(!n.getSeatView)return null;let O=S.get(L);if(!O)for(O=Promise.resolve(n.getSeatView(L)),S.set(L,O),O.catch(()=>{S.get(L)===O&&S.delete(L)});S.size>ae;){let q=S.keys().next().value;if(q===void 0)break;S.delete(q)}return O},ve=(L,O)=>{let q=s.get(L),J=Math.max(0,Math.round(o.seats.iFloor[O]??0)),te=t.doc.floors?.[J],ne=o.floors[J],re=te?.focalPoint??t.doc.focalPoint,ce=ne?{x:ne.focalWorld[0]/_,y:ne.focalWorld[2]/_}:re,He=q?.focalPoint?{x:q.focalPoint.x+ce.x-re.x,y:q.focalPoint.y+ce.y-re.y}:ce,Oe=[o.seats.iPosition[O*3],o.seats.iPosition[O*3+1],o.seats.iPosition[O*3+2]];return Yr(Oe,He,te?.baseHeightM??0,q?.eyeHeightM)},Me=()=>(e.clientWidth||D.canvas.clientWidth)<=520,Ie=null,Ee=null,ke=async(L,O,q)=>{if(!n.getSeatView||p||q!==me.flightGen())return;let J;try{J=await li()}catch{if(i.panoramaFailed(L,"mount"),!p&&q===me.flightGen()){let te=le(L,q,!0);requestAnimationFrame(()=>te?.querySelector("[data-panorama-trigger]")?.focus())}return}if(!(p||q!==me.flightGen()||!Ie))return Ee??=J.createOpenPanorama(Ie),Ee(L,O,q)},be=di({container:e,model:o,opts:n,expandedSeatById:s,seatIdsByRow:c,isNarrow:Me,isDisposed:()=>p,flightGen:()=>me.flightGen(),flyToSeat:L=>Gn(L),openPanorama:(L,O,q)=>ke(L,O,q)}),le=be.show,Le=be.remove,it=be.layout,Se=hi({container:e,orbit:M,isNarrow:Me}),Ue=Se.element,Te=Se.setNavigationMode,Rt=Se.layout,yi=Se.utilityControls,at=null,Nn=!1,Ct=L=>{Se.setSeatViewLocked(L),L||j?.exit()};j=ci({canvas:D.canvas,camera:M.camera,requestRender:()=>W.requestRender(),reducedMotion:$,onStopChange:L=>{let O=L??(Nn?"seat":null);at=O;try{n.onSeatViewStopChange?.(O)}catch{}},onApplied:()=>{p||M.syncFromCamera()}});let gi=ei(o.stages,o.focalWorld,o.bounds.groundY??0),xi=(L,O)=>{let{eye:q}=ve(L,O),J=(e.clientWidth||D.canvas.clientWidth||1)/Math.max(1,e.clientHeight||D.canvas.clientHeight||1),te=ni(q,gi,J);if(n.seatViewStops===!1)return{...te,stops:[]};let ne=l.get(L),re=ne?o.sections.find(ce=>ce.id===ne):void 0;return{...te,stops:oi(te,{aspect:J,section:re&&re.seatCount>0?{center:re.center,radius:re.radius}:null,venue:{center:o.bounds.center,radius:o.bounds.radius}})}},me=pi({container:e,model:o,opts:n,orbit:M,cinematic:C,analytics:i,loop:W,labelOverlay:G,stageAzimuth:B,overviewFraming:R,gpu:()=>u,isDisposed:()=>p,panorama:()=>b,setPanorama:L=>{b=L},setPanoramaSphereVisible:L=>{V=L},panoramaLoadAbort:()=>y,setPanoramaLoadAbort:L=>{y=L},setFrozen:L=>{d=L},restorePanoramaLayer:I,reducedMotion:$,resolvedSeatViewPose:ve,showSectionSeatLabels:H,setNearFieldDetailEnabled:F,setSeatViewLocked:Ct,setNavigationMode:Te,showArriveChip:le,removeArriveChip:Le,inSeatView:()=>at!==null,setSeatStepping:L=>{Nn=L},seatViewArrival:(L,O)=>n.arriveAtSeatEye?xi(L,O):null,enterSeatView:L=>j?.enter(L)});T=!0;let on=me.overviewChip,vi=me.layoutOverviewChip,Mi=me.applyFloorFocus,Si=me.focusOverview,zn=me.cancelFlight,Gn=me.flyToSeat,Un=me.focusSectionCamera;yi.appendChild(on),Ie={container:e,model:o,opts:n,analytics:i,orbit:M,loop:W,seatsById:s,ensureSeatView:Pe,resolvedSeatViewPose:ve,gpu:()=>u,gl:D.gl,isContextLost:()=>h,isDisposed:()=>p,flightGen:()=>me.flightGen(),setPanorama:L=>{b=L},getLoadAbort:()=>y,setLoadAbort:L=>{y=L},setPanoramaSphereVisible:L=>{V=L,L&&j?.exit()},setFrozen:L=>{d=L},raisePanoramaLayer:v,restorePanoramaLayer:I,getOverviewChip:()=>on,labelOverlay:G,reducedMotion:$,removeArriveChip:Le,showArriveChip:le};let Ve=fi({glctx:D,orbit:M,model:o,seats:t.seats,opts:n,cinematic:C,analytics:i,seatIdByIndex:a,sectionIdBySeatId:l,tapSlop:sc,tapMs:cc,gpu:()=>u,pick:()=>m,seatViewLocked:()=>Se.seatViewLocked(),focusedSectionId:()=>N,selection:()=>g,cancelFlight:zn,focusSectionCamera:Un,setSelection:Q,ensureSeatView:Pe});D.canvas.addEventListener("pointerdown",Ve.onDown),D.canvas.addEventListener("pointermove",Ve.onMove),D.canvas.addEventListener("pointerup",Ve.onUp),D.canvas.addEventListener("pointercancel",Ve.onUp),W.requestRender();let rn={setAvailability(L){let O=Vr(g,L),q=yn(o.seats,O);q.length&&u&&u.uploadSeatStateRuns(q),W.requestRender()},setSelection:Q,setNavigationMode:Te,zoomIn(){M.zoomBy(.82),W.requestRender()},zoomOut(){M.zoomBy(1.22),W.requestRender()},flyToSeat:Gn,focusOverview:Si,seatViewStop:()=>at,recentreSeatView:()=>j?.recentre()??!1,resize(){let{width:L,height:O}=D.resize();M.setAspect(L/Math.max(1,O)),it(),Rt(),vi(),W.requestRender()},stats(){return{...W.stats(),drawCalls:u?u.drawCalls:0,seatCount:o.seatCount}},getQualityEvidence(){let L=W.stats(),O=D.canvas.clientWidth||1,q=D.canvas.clientHeight||1,J=o.bounds.center,te=Ge(M.camera.projectionViewMatrix,[J[0],o.bounds.box.min[1],J[2]],O,q),ne=Ge(M.camera.projectionViewMatrix,[J[0],o.bounds.box.max[1],J[2]],O,q),re=o.bounds.box,ce=[re.min[0],re.max[0]].flatMap(Z=>[re.min[1],re.max[1]].flatMap(de=>[re.min[2],re.max[2]].map(Ae=>Ge(M.camera.projectionViewMatrix,[Z,de,Ae],O,q)))).filter(Z=>Number.isFinite(Z.x)&&Number.isFinite(Z.y)&&Number.isFinite(Z.depth)),He=ce.length?(()=>{let Z=Math.min(...ce.map(Xe=>Xe.x)),de=Math.max(...ce.map(Xe=>Xe.x)),Ae=Math.min(...ce.map(Xe=>Xe.y)),It=Math.max(...ce.map(Xe=>Xe.y)),st=Math.max(0,Z),Et=Math.min(O,de),Re=Math.max(0,Ae),ct=Math.min(q,It),Tt=Math.max(0,Et-st),an=Math.max(0,ct-Re);return{box:{x:st,y:Re,width:Tt,height:an},horizontalFillRatio:Tt/O,verticalFillRatio:an/q,visibleAreaRatio:Tt*an/(O*q),clippedEdges:[...Ae<0?["top"]:[],...de>O?["right"]:[],...It>q?["bottom"]:[],...Z<0?["left"]:[]]}})():void 0,Oe=String(D.gl.getParameter(D.gl.VERSION)??"");return{viewport:{width:O,height:q},context:{webgl2:/webgl\s*2/i.test(Oe),lost:h},frame:{rendered:L.rendered,idle:L.idle},camera:{position:[M.camera.position.x,M.camera.position.y,M.camera.position.z],distance:M.currentDistance,verticalFovDeg:M.fovY},scene:{seatCount:o.seatCount,floorCount:o.floors.length,zoneCount:o.zones.length,sectionCount:o.sections.length,authoredRelief:f,renderedVerticalSpanM:Math.max(0,o.bounds.box.max[1]-o.bounds.box.min[1]),projectedReliefPx:te.visible&&ne.visible?Math.abs(te.y-ne.y):0},labels:G.qualityEvidence(),framing:He,...at?{seatView:{fovDeg:M.camera.fov,stop:at}}:{}}},getQualityReport(){return Tn(rn.getQualityEvidence())},loseContextForTest(){D.simulateContextLossCycle()},floors(){return o.floors},focusFloor(L){if(L!==null&&!o.floors.some(q=>q.index===L))return!1;let O=L??-1;if(F(L!==null),Ct(!1),Mi(O),Te("orbit"),L===null)C.cancel(),$()?M.frame(o.bounds,!1,B,n.portraitOverviewCrop===!0,R):M.frameSoft(o.bounds,B,n.portraitOverviewCrop===!0,R);else{let q=o.floors[L];if(q.seatCount>0){C.cancel();let J=q.focalWorld[0]-q.center[0],te=q.focalWorld[2]-q.center[2],ne=Math.hypot(J,te)>q.radius*.12?Math.atan2(J,te):B;M.frame({center:q.center,radius:q.radius,box:q.box},!1,ne,!1,{polarDeg:58,margin:1.12})}}return W.requestRender(),!0},zones(){return o.zones},focusZone(L){let O=o.zones.find(ne=>ne.id===L);if(!O||O.seatCount===0)return!1;F(!1),Ct(!1),C.cancel(),Te("orbit"),H(null),n.onSectionFocusChange?.(null);let q=O.focalWorld[0]-O.center[0],J=O.focalWorld[2]-O.center[2],te=Math.hypot(q,J)>O.radius*.12?Math.atan2(q,J):void 0;return M.frame({center:O.center,radius:O.radius*1.25},!1,te),W.requestRender(),!0},sections(){return o.sections},focusSection(L){return Un(L)},rows(L){return L?o.rows.filter(O=>O.sectionId===L):o.rows},seatsInRow(L){return t.seats.filter(O=>O.rowId===L).map(O=>({id:O.id,label:O.displayLabel||O.label}))},focusRow(L){let O=o.rows.find(q=>q.id===L);return!O||O.seatCount===0?!1:(F(!0),Ct(!1),C.cancel(),Te("pan"),O.sectionId&&(H(O.sectionId),n.onSectionFocusChange?.(O.sectionId)),M.frame({center:O.center,radius:Math.max(2.5,O.radius*.65)}),W.requestRender(),!0)},setReducedMotionForTest(L){A=L},dispose(){p=!0,Le(),on.remove(),Ue.remove(),zn(),j?.dispose(),W.stop(),G.dispose(),K?.disconnect(),b&&(b.dispose(),b=null),I(),X(),D.canvas.removeEventListener("pointerdown",Ve.onDown),D.canvas.removeEventListener("pointermove",Ve.onMove),D.canvas.removeEventListener("pointerup",Ve.onUp),D.canvas.removeEventListener("pointercancel",Ve.onUp),M.dispose(),m&&m.dispose(),u&&u.dispose(),u=null,m=null,D.dispose()}};return i.opened(o.seatCount,f,t.prepared?.buildMs??performance.now()-r,t.prepared?.source??"inline"),rn}export{rs as VENUE3D_QUALITY_REPORT_VERSION,vt as buildSceneModel,Tn as inspectVenue3DQualityEvidence,jm as mountVenue3D,ic as prepareVenue3D};
622
+ void main(){ if(vDim>0.5) discard; vec4 c=texture(uImage,vUv); if(c.a<0.01) discard; fragColor=c; }`,uniforms:{uImage:{value:I},uFocusFloor:{value:-1}},transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1});let T=new Le(t,{geometry:Y,program:y});T.frustumCulled=!1,T.setParent(n),$.screenProgram=y,H=!0,$.drawCalls=3+(g?1:0)+1},L.src=ee.contentImageUrl}return $}import{Mesh as At,RenderTarget as Qn,Transform as Et}from"ogl";function jn(t,e,n){let i=t+(e<<8)+(n<<16);return i===0?-1:i-1}function Co(t,e,n,i,o,r){let s=-1,a=1/0;for(let l=0;l<n;l++)for(let m=0;m<e;m++){let b=(l*e+m)*4,c=jn(t[b],t[b+1],t[b+2]);if(c<0||c>=r)continue;let f=m-i,p=l-o,u=f*f+p*p;u<a&&(a=u,s=c)}return s}function Ao(t,e,n,i,o,r){let s=t-n.left,a=e-n.top,l=Math.round(s*i),m=Math.round((n.height-a)*i);return{x:Math.max(0,Math.min(o-1,l)),y:Math.max(0,Math.min(r-1,m))}}var Kn=["uSeatRadius","uSeatScale","uMinPixels","uPixelToWorld"],et=class{constructor(e,n,i,o,r){this.seatScene=new Et;this.chairScene=new Et;this.solidScene=new Et;this.target=null;this.restoreClear=[0,0,0];this.renderer=e,this.gl=e.gl,this.maxIndex=r,this.seatProg=fo(this.gl),this.chairProg=vo(this.gl),this.depthProg=go(this.gl);let s=new At(this.gl,{geometry:n,program:this.seatProg});s.frustumCulled=!1,s.setParent(this.seatScene);let a=new At(this.gl,{geometry:i,program:this.chairProg});a.frustumCulled=!1,a.setParent(this.chairScene);let l=new At(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 Kn)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 Qn(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,s=this.ensureTarget(),a=r.drawingBufferWidth,l=r.drawingBufferHeight,m=Math.max(0,n-o),b=Math.max(0,i-o),c=Math.max(1,Math.min(a,n+o+1)-m),f=Math.max(1,Math.min(l,i+o+1)-b);r.enable(r.SCISSOR_TEST),r.scissor(m,b,c,f);let[p,u,x]=this.restoreClear;r.clearColor(0,0,0,1),this.renderer.render({scene:this.solidScene,camera:e,target:s,clear:!0}),this.renderer.render({scene:this.seatScene,camera:e,target:s,clear:!1}),this.renderer.render({scene:this.chairScene,camera:e,target:s,clear:!1}),r.clearColor(p,u,x,1),r.disable(r.SCISSOR_TEST);let C=new Uint8Array(c*f*4);return this.renderer.bindFramebuffer(s),r.readPixels(m,b,c,f,r.RGBA,r.UNSIGNED_BYTE,C),this.renderer.bindFramebuffer(),Co(C,c,f,n-m,i-b,this.maxIndex)}dispose(){this.destroyTarget(),this.seatProg.remove(),this.chairProg.remove(),this.depthProg.remove()}};function Eo(t,e){let n=[];for(let i of e)t.has(i.seatId)?t.set(i.seatId,Ht(i.state)):n.push(i);return n}function Fo(t,e,n){let i=new Set;for(let s of e)(t.has(s)||n(s)!==void 0)&&i.add(s);let o=new Map(t),r=[];for(let[s,a]of t)i.has(s)||(r.push({seatId:s,state:xe[a]??"available"}),o.delete(s));for(let s of i){if(o.has(s))continue;let a=n(s);a!==void 0&&(o.set(s,a),r.push({seatId:s,state:"selected"}))}return{updates:r,next:o}}import{Quat as ze,Vec3 as Jn}from"ogl";function $n(t,e){return[t[0]-e[0],t[1]-e[1],t[2]-e[2]]}function Ro(t,e){return[t[0]+e[0],t[1]+e[1],t[2]+e[2]]}function Zn(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Do(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 Ft(t){let e=Math.max(0,Math.min(1,t));return e*e*e*(e*(e*6-15)+10)}function Rt(t,e){return Math.max(0,Math.min(1,t+e))}function Vo(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 s=i*o-r,a=t[Math.max(0,r-1)],l=t[r],m=t[r+1],b=t[Math.min(n-1,r+2)],c=s*s,f=c*s,p=[0,0,0];for(let u=0;u<3;u++)p[u]=.5*(2*l[u]+(-a[u]+m[u])*s+(2*a[u]-5*l[u]+4*m[u]-b[u])*c+(-a[u]+3*l[u]-3*m[u]+b[u])*f);return p}function Dt(t,e,n,i,o){let r=Do($n(e,n));r[0]===0&&r[1]===0&&r[2]===0&&(r=[0,0,1]);let s=Ro(Ro(e,Zn(r,2.5)),[0,1.5,0]),a=[e[0]-i[0],0,e[2]-i[2]],l=Do(a);l[0]===0&&l[2]===0&&(l=[r[0],0,r[2]]);let m=Math.max(1,o),b=[i[0]+l[0]*m*1.3,i[1]+m*.75,i[2]+l[2]*m*1.3];return{waypoints:[t,b,s],finalPos:s}}function Vt(t,e,n=35,i=28){let o=Ft(e),r=Vo(t,o),s=Ft(Math.max(0,Math.min(1,(e-.66)/.34)));return{pos:r,fov:n+(i-n)*s,eased:o}}function _o(t,e,n){let i=t.position.clone(),o=new ze().copy(t.quaternion);t.position.set(e[0],e[1],e[2]),t.lookAt(new Jn(n[0],n[1],n[2]));let r=new ze().copy(t.quaternion);return t.position.copy(i),t.quaternion.copy(o),r}var tt=class{constructor(e){this.active=!1;this.waypoints=[];this.startQuat=new ze;this.endQuat=new ze;this.outQuat=new ze;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(s=>{this.resolveFn=s})}update(e){if(!this.active)return!1;let n=Math.min(1,(e-this.startTime)/this.duration),{pos:i,fov:o,eased:r}=Vt(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,Rt(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 er=1.02,tr=1.5;function Lo(t,e,n=0,i){let o=Number.isFinite(i)?n+i:t[1]+er;return{eye:[t[0],o,t[2]],focal:[e.x*we,n+tr,e.y*we]}}var Ae=Math.PI/180,or=45,zo=80,nr=.25,It=1,rr=.25,ir=12*Ae,ar=.2,sr=1.5,Oo=.8,No=6,Wo=1.9,lr=2/3,cr=.12,ur=.9,dr=1.2,mr=2,Uo=.05,pr=6;function Yo(t,e,n=0){if(!t.length)return{min:[e[0]-6,n,e[2]-6],max:[e[0]+6,Math.max(n+Oo,e[1]),e[2]+6]};let i=1/0,o=-1/0,r=1/0,s=-1/0,a=n;for(let u of t)i=Math.min(i,u.cx-u.halfX),o=Math.max(o,u.cx+u.halfX),r=Math.min(r,u.cz-u.halfZ),s=Math.max(s,u.cz+u.halfZ),a=Math.max(a,u.y);let l=o-i,m=s-r,b=Math.max(l,Math.min(m,No))/2,c=Math.max(m,Math.min(l,No))/2,f=(i+o)/2,p=(r+s)/2;return{min:[f-b,n,p-c],max:[f+b,Math.max(n+Oo,a),p+c]}}function hr(t){return{min:[t.min[0],t.min[1],t.min[2]],max:[t.max[0],t.max[1]+Wo,t.max[2]]}}function fr(t){let e=t.max[1];return[(t.min[0]+t.max[0])/2,Math.max(t.min[1]+sr,e+ar,e+Wo*lr),(t.min[2]+t.max[2])/2]}function Xo(t,e){let n=t[0]-e[0],i=t[2]-e[2],o=Math.hypot(n,i);return o<.001?{x:0,z:1}:{x:n/o,z:i/o}}function Go(t,e,n){let i=e[0]-t[0],o=e[1]-t[1],r=e[2]-t[2],s=Math.hypot(i,o,r)||1;i/=s,o/=s,r/=s;let a=-r,l=i,m=Math.hypot(a,l);if(m<1e-6)return 1/0;a/=m,l/=m;let b=1/0,c=-1/0;for(let f=0;f<8;f++){let p=(f&1?n.max[0]:n.min[0])-t[0],u=(f&2?n.max[1]:n.min[1])-t[1],x=(f&4?n.max[2]:n.min[2])-t[2],C=Math.max(Uo,p*i+u*o+x*r),F=(p*a+x*l)/C;F<b&&(b=F),F>c&&(c=F)}return c-b}function Bo(t,e,n){let i=e[0]-t[0],o=e[1]-t[1],r=e[2]-t[2],s=Math.hypot(i,o,r)||1;i/=s,o/=s,r/=s;let a=-r,l=i,m=Math.hypot(a,l);if(m<1e-6)return 1/0;a/=m,l/=m;let b=-l*o,c=l*i-a*r,f=a*o,p=1/0,u=-1/0;for(let x=0;x<8;x++){let C=(x&1?n.max[0]:n.min[0])-t[0],F=(x&2?n.max[1]:n.min[1])-t[1],v=(x&4?n.max[2]:n.min[2])-t[2],M=Math.max(Uo,C*i+F*o+v*r),R=(C*b+F*c+v*f)/M;R<p&&(p=R),R>u&&(u=R)}return u-p}function ot(t,e){return Math.tan(t*Ae/2)*Math.max(.05,e)}function Ho(t,e,n){let i=a=>Math.max(or,Math.min(zo,a)),o=a=>2*Math.atan(a)/Ae,r=Number.isFinite(t)&&t>0?i(o(t/(2*nr)/Math.max(.05,n))):zo;if(!(Number.isFinite(e)&&e>0))return r;let s=Math.min(r,i(o(e/(2*cr))));return t/(2*ot(s,n))>It?r:s}function qo(t,e,n){let i=fr(e),o=[t[0],t[1],t[2]],r=0,s=0,a=p=>{if(!(p>0))return;let u=Xo(o,i);o[0]+=u.x*p,o[2]+=u.z*p,s+=p},l=e.max[1]+rr-o[1];l>0&&(o[1]+=l,r=l,a(l/Math.tan(ir)));let m=hr(e),b=Go(o,i,e),c=Ho(b,Bo(o,i,m),n),f=b/(2*ot(c,n));for(let p=0;p<pr&&f>It;p++){let u=Math.max(1,Math.hypot(o[0]-i[0],o[2]-i[2])),x=Number.isFinite(f)?f/It:2;a(Math.min(60,u*(Math.min(4,x)-1)+.5)),b=Go(o,i,e),c=Ho(b,Bo(o,i,m),n),f=b/(2*ot(c,n))}return{eye:o,focal:i,fov:c,raisedM:r,pulledBackM:s,stageFrameWidth:f}}function vr(t,e,n){let i=Math.tan(e*Ae/2),o=ot(e,n);return Math.max(1,t/Math.max(.05,Math.min(i,o)))}function jo(t,e){let{aspect:n,venue:i}=e,o=t.focal,r=Xo(t.eye,o),s=f=>(f[0]-o[0])*r.x+(f[2]-o[2])*r.z,a=[{name:"seat",eye:t.eye,focal:o,fov:t.fov}],l=mr*(e.rowDepthM??ur);a.push({name:"row",eye:[t.eye[0]+r.x*l,t.eye[1]+dr,t.eye[2]+r.z*l],focal:o,fov:t.fov});let m=(f,p,u,x)=>{let C=vr(u,t.fov,n)*1.08,F=C*Math.sin(x*Ae),v=C*Math.cos(x*Ae);return{name:f,eye:[p[0]+r.x*v,p[1]+F,p[2]+r.z*v],focal:p,fov:t.fov}};e.section&&e.section.radius>0&&a.push(m("section",e.section.center,e.section.radius,14)),a.push(m("venue",i.center,Math.max(1,i.radius),26));let b=[],c=-1/0;for(let f of a){let p=s(f.eye);b.length&&p<=c+.5||(b.push(f),c=p)}return b}import{Vec3 as gr}from"ogl";var Ne=Math.PI/180,Qo=320,Ko=70*Ne,br=32*Ne,yr=24*Ne,$o=.0026,xr=.22,wr=.006,Sr=180,Mr=4,ie=(t,e,n)=>Math.max(e,Math.min(n,t)),Zo=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2;function Jo(t){let{canvas:e,camera:n}=t,i=[],o=!1,r=0,s=0,a=0,l=0,m=0,b=0,c=!1,f=[0,0],p=0,u=!1,x=null,C=null,F=new Map,v=!1,M=0,R=0,w=0,S=0,O=()=>o&&i.length?i[ie(Math.round(r),0,i.length-1)].name:null,D=()=>{let y=O();y!==x&&(x=y,t.onStopChange?.(y))},z=()=>{if(!o||!i.length)return;let y=i[ie(Math.floor(r),0,i.length-1)],I=i[ie(Math.ceil(r),0,i.length-1)],J=ie(r-Math.floor(r),0,1),B=(be,Ge)=>be+(Ge-be)*J,$=[B(y.eye[0],I.eye[0]),B(y.eye[1],I.eye[1]),B(y.eye[2],I.eye[2])],ee=[B(y.focal[0],I.focal[0]),B(y.focal[1],I.focal[1]),B(y.focal[2],I.focal[2])],L=ee[0]-$[0],G=ee[1]-$[1],T=ee[2]-$[2],V=Math.hypot(L,G,T)||1,U=Math.atan2(L,T),Q=Math.asin(ie(G/V,-1,1)),ae=U+s,pe=ie(Q+a,-80*Ne,80*Ne),Ee=Math.cos(pe)*V;L=Math.sin(ae)*Ee,G=Math.sin(pe)*V,T=Math.cos(ae)*Ee,n.position.set($[0],$[1],$[2]),n.fov=B(y.fov,I.fov),n.updateProjectionMatrix(),n.lookAt(new gr($[0]+L,$[1]+G,$[2]+T)),t.onApplied?.()},j=()=>{if(!o||!i.length)return;let y=ie(Math.round(r),0,i.length-1);if(t.reducedMotion()){c=!1,r=y,z(),D(),t.requestRender();return}if(Math.abs(y-r)<.001){c=!1,D();return}l=r,m=y,b=performance.now(),c=!0,t.requestRender()},E=y=>{!o||i.length<2||(c=!1,r=ie(r+y,0,i.length-1),z(),D(),t.requestRender())},_=(y,I)=>{o&&(c=!1,u=!1,s=ie(s-y*$o,-Ko,Ko),a=ie(a-I*$o,-yr,br),z(),t.requestRender())},N=y=>{o&&(F.set(y.pointerId,{x:y.clientX,y:y.clientY}),F.size===1?(v=!0,S=0,M=y.clientX,R=y.clientY):F.size===2&&(v=!1,w=P()))},P=()=>{let y=[...F.values()];return y.length<2?0:Math.hypot(y[0].x-y[1].x,y[0].y-y[1].y)},g=y=>{if(!o||!F.has(y.pointerId))return;if(F.set(y.pointerId,{x:y.clientX,y:y.clientY}),F.size>=2){let B=P();w>0&&E((w-B)*wr),w=B;return}if(!v)return;let I=y.clientX-M,J=y.clientY-R;M=y.clientX,R=y.clientY,S+=Math.abs(I)+Math.abs(J),!(S<=Mr)&&_(I,J)},H=y=>{F.delete(y.pointerId)&&(F.size<2&&(w=0),F.size===0&&(v=!1,j()))},K=y=>{if(!o)return;y.preventDefault();let I=y.deltaMode===1?16:y.deltaMode===2?100:1,J=ie(y.deltaY*I/100,-2,2);E(J*xr),C&&clearTimeout(C),C=setTimeout(()=>{C=null,j()},Sr)},Y=()=>{o&&(o=!1,c=!1,u=!1,i=[],F.clear(),v=!1,C&&(clearTimeout(C),C=null),x!==null&&(x=null,t.onStopChange?.(null)))};return e.addEventListener("pointerdown",N),e.addEventListener("pointermove",g),e.addEventListener("pointerup",H),e.addEventListener("pointercancel",H),e.addEventListener("wheel",K,{passive:!1}),{get active(){return o},enter(y){if(y.length<2){Y();return}i=y,o=!0,r=0,s=0,a=0,c=!1,u=!1,x=null,z(),D(),t.requestRender()},exit:Y,recentre(){return o?Math.abs(s)<1e-4&&Math.abs(a)<1e-4?!0:t.reducedMotion()?(u=!1,s=0,a=0,z(),t.requestRender(),!0):(f=[s,a],p=performance.now(),u=!0,t.requestRender(),!0):!1},update(y){if(!o)return!1;let I=!1;if(u){let J=ie((y-p)/Qo,0,1),B=1-Zo(J);s=f[0]*B,a=f[1]*B,J>=1?(u=!1,s=0,a=0):I=!0}if(c){let J=ie((y-b)/Qo,0,1);r=l+(m-l)*Zo(J),J>=1?(c=!1,r=m,D()):I=!0}return z(),I},currentStop:O,dispose(){Y(),e.removeEventListener("pointerdown",N),e.removeEventListener("pointermove",g),e.removeEventListener("pointerup",H),e.removeEventListener("pointercancel",H),e.removeEventListener("wheel",K)}}}var Tt=null;function en(){return Tt??=import("../openPanorama-HGRYMWKC.js").catch(t=>{throw Tt=null,t}),Tt}var tn=()=>typeof performance<"u"&&performance.now?performance.now():Date.now(),nt=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=tn(),this.emit("3d_panorama_opened")}panoramaClosed(){let e=this.panoramaOpenedAt?Math.round(tn()-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 on(t){let e=t.style.position;return getComputedStyle(t).position!=="static"?()=>{}:(t.style.position="relative",()=>{t.style.position==="relative"&&(t.style.position=e)})}function nn(t){let{container:e,model:n,opts:i,expandedSeatById:o,seatIdsByRow:r,isNarrow:s}=t,a=null,l=()=>{if(!a)return;let c=s();Object.assign(a.style,c?{left:"12px",right:"12px",bottom:"70px",transform:"none",justifyContent:"center"}:{left:"50%",right:"auto",bottom:"18px",transform:"translateX(-50%)",justifyContent:"initial"})},m=()=>{a?.remove(),a=null};return{show:(c,f,p=!1)=>{if(m(),t.isDisposed())return null;let u=document.createElement("div");u.setAttribute("role","group"),Object.assign(u.style,{position:"absolute",display:"flex",flexDirection:"column",alignItems:"center",gap:"6px",zIndex:"4"});let x=o.get(c),C=x?.sectionId?n.sections.find(D=>D.id===x.sectionId):void 0,F=x?.label??c;u.setAttribute("aria-label",`Explore views near ${C?.label?`${C.label}, `:""}seat ${F}`);let v=document.createElement("span");v.textContent=i.seatViewCaption?.(c)??["Live 3D seat view",C?.label,F].filter(Boolean).join(" \xB7 "),Object.assign(v.style,{maxWidth:"min(70vw, 560px)",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)"}),u.appendChild(v);let M=document.createElement("div");Object.assign(M.style,{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px"}),u.appendChild(M);let R=x?.rowId?r.get(x.rowId):void 0,w=R?.indexOf(c)??-1,S=w>=0?[R?.[w-1],R?.[w+1]]:[void 0,void 0],O=(D,z,j,E=!1)=>{let _=document.createElement("button");_.type="button",_.textContent=D,_.setAttribute("aria-label",z),Object.assign(_.style,{minHeight:"44px",padding:E?"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"}),E||(_.style.minWidth="44px"),E&&(_.dataset.panoramaTrigger=""),_.addEventListener("click",j),M.appendChild(_)};if(S[0]){let D=o.get(S[0])?.label??S[0];O("\u2039",`View previous seat ${D}`,()=>{t.flyToSeat(S[0])})}if(i.getSeatView){let D=i.seatViewActionLabel?.(c)??"Open 360\xB0 panorama";O(p?`\u21BB Retry ${D}`:`\u25C9 ${D}`,`${p?"Retry":D} from seat ${F}`,()=>{if(t.isDisposed()||f!==t.flightGen()){m();return}m(),t.openPanorama(c,400,f)},!0)}if(S[1]){let D=o.get(S[1])?.label??S[1];O("\u203A",`View next seat ${D}`,()=>{t.flyToSeat(S[1])})}return M.childElementCount?(e.appendChild(u),a=u,l(),u):null},remove:m,layout:l}}function rn(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 s=document.createElement("div");s.setAttribute("role","group"),s.setAttribute("aria-label","3D drag mode"),Object.assign(s.style,{display:"flex",flexDirection:"column",gap:"6px",alignItems:"flex-end"});let a=document.createElement("div");a.setAttribute("role","group"),a.setAttribute("aria-label","3D view controls"),Object.assign(a.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 m=document.createElement("button");m.type="button",m.textContent="\u2725",m.setAttribute("aria-label","Drag to move the 3D venue left, right, up or down"),m.dataset.tooltip="Move venue";let b=document.createElement("button");b.type="button",b.textContent="\u2212",b.setAttribute("aria-label","Zoom out of the 3D venue"),b.dataset.tooltip="Zoom out";let c=document.createElement("button");c.type="button",c.textContent="+",c.setAttribute("aria-label","Zoom into the 3D venue"),c.dataset.tooltip="Zoom in";for(let x of[l,m,b,c])x.className="sl-3d-icon-control",Object.assign(x.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"});s.append(l,m),a.append(c,b);let f=x=>{n.setPrimaryDragMode(x);let C=x==="orbit";l.setAttribute("aria-pressed",String(C)),m.setAttribute("aria-pressed",String(!C)),l.style.background=C?"rgba(96,110,150,0.68)":"rgba(12,18,32,0.82)",m.style.background=C?"rgba(12,18,32,0.82)":"rgba(96,110,150,0.68)",o.title=C?"Drag to rotate \xB7 Shift-drag to move":"Drag to move \xB7 Shift-drag to rotate"};l.addEventListener("click",()=>f("orbit")),m.addEventListener("click",()=>f("pan")),b.addEventListener("click",()=>n.zoomBy(1.22)),c.addEventListener("click",()=>n.zoomBy(.82)),o.append(s,a),f("orbit"),e.appendChild(o);let p=()=>{let x=i();o.style.display=r?"none":"flex",o.style.right=x?"12px":"14px",o.style.bottom=x?"calc(env(safe-area-inset-bottom, 0px) + 76px)":"14px",s.style.display=x?"none":"flex",c.style.display=x?"none":"",b.style.display=x?"none":""};return p(),{element:o,utilityControls:a,setNavigationMode:f,setSeatViewLocked:x=>{r=x,n.setInteractionEnabled(!x),p()},seatViewLocked:()=>r,layout:p}}function an(t){let{glctx:e,orbit:n,model:i,seats:o,opts:r,cinematic:s,analytics:a,seatIdByIndex:l,sectionIdBySeatId:m,tapSlop:b,tapMs:c,cancelFlight:f,focusSectionCamera:p,setSelection:u,ensureSeatView:x}=t,C=0,F=0,v=0,M=-1,R=!1,w=!1,S=E=>{t.seatViewLocked()||M===-1&&(M=E.pointerId,C=E.clientX,F=E.clientY,v=performance.now(),R=!1,w=s.active,s.active&&(a.cinematicCancelled(),f(),r.onViewTargetChange?.(null)))},O=E=>{E.pointerId===M&&Math.hypot(E.clientX-C,E.clientY-F)>b&&(R=!0)},D=(E,_,N,P,g)=>{let H=e.canvas.getBoundingClientRect(),K=e.canvas.clientWidth||H.width||1,Y=e.canvas.clientHeight||H.height||1,y=E-H.left,I=_-H.top,J=P*P,B=-1,$=J,ee=1/0;for(let L of o){if(N&&L.sectionId!==N)continue;let G=i.seats.idToIndex.get(L.id);if(G===void 0)continue;if(g){let pe=Math.round(i.seats.iState[G]??0);if(pe!==0&&pe!==3)continue}let T=G*3,V=me(n.camera.projectionViewMatrix,[i.seats.iPosition[T],i.seats.iPosition[T+1]+.55,i.seats.iPosition[T+2]],K,Y);if(!V.visible)continue;let U=V.x-y,Q=V.y-I,ae=U*U+Q*Q;(ae<$||Math.abs(ae-$)<1&&V.depth<ee)&&(B=G,$=ae,ee=V.depth)}return B},z=(E,_)=>{let N=t.gpu(),P=t.pick();if(!N||!P)return-1;P.syncFromSeatProgram(N.seatProgram);let g=e.canvas.getBoundingClientRect(),H=e.renderer.dpr,{x:K,y:Y}=Ao(E,_,g,H,e.gl.drawingBufferWidth,e.gl.drawingBufferHeight),y=Math.max(2,Math.round(8*H));return P.pick(n.camera,K,Y,y)};return{onDown:S,onMove:O,onUp:E=>{if(E.pointerId!==M)return;let _=!R&&performance.now()-v<c;if(M=-1,w){w=!1;return}let N=t.gpu(),P=t.pick();if(!_||!N||!P)return;let g=z(E.clientX,E.clientY);if(t.focusedSectionId()&&g>=0){let Y=l[g],y=Y?m.get(Y):void 0;if(y&&y!==t.focusedSectionId()&&p(y))return}if(t.focusedSectionId()&&g<0&&(g=D(E.clientX,E.clientY,t.focusedSectionId(),44,!1)),t.focusedSectionId()&&g<0){let Y=D(E.clientX,E.clientY,null,72,!1),y=Y>=0?l[Y]:void 0,I=y?m.get(y):void 0;if(I&&I!==t.focusedSectionId()&&p(I))return}if(!t.focusedSectionId()){g<0&&(g=D(E.clientX,E.clientY,null,42,!1));let Y=g>=0?l[g]:void 0,y=Y?m.get(Y):void 0;if(y&&p(y))return}if(g<0||g>=l.length){t.selection().size&&(u([]),r.onViewTargetChange?.(null));return}let H=l[g],K=xe[Math.round(i.seats.iState[g]??0)]??"available";if(K!=="available"&&K!=="selected"){r.onSeatInspect?.(H,K);return}if(t.selection().has(H)&&t.selection().size===1){u([]),r.onViewTargetChange?.(null),r.onSeatPick?.(H);return}u([H]),x(H),a.seatPicked(H,m.get(H)),r.onSeatPick?.(H)}}}var rt=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 u=e[p*3],x=e[p*3+2];u<n&&(n=u),u>o&&(o=u),x<i&&(i=x),x>r&&(r=x)}let s=Math.max(o-n,.001),a=Math.max(r-i,.001);this.cell=Math.max(Math.sqrt(s*a*4/this.count),.25),this.cols=Math.max(1,Math.ceil(s/this.cell)+1),this.rows=Math.max(1,Math.ceil(a/this.cell)+1),this.minX=n,this.minZ=i;let l=this.cols*this.rows,m=new Int32Array(l+1),b=p=>{let u=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+u};for(let p=0;p<this.count;p++)m[b(p)+1]++;for(let p=0;p<l;p++)m[p+1]+=m[p];let c=new Int32Array(this.count),f=m.slice(0,l);for(let p=0;p<this.count;p++)c[f[b(p)]++]=p;this.cellStart=m,this.cellItems=c}gather(e,n,i,o){this.ensureGrid();let r=this.cellStart,s=this.cellItems;if(!r||!s)return 0;let a=o.length,l=i*i,m=Math.floor((e-this.minX)/this.cell),b=Math.floor((n-this.minZ)/this.cell),c=Math.ceil(i/this.cell)+1,f=this.iPosition,p=0;for(let u=0;u<=c&&p<a;u++){let x=b-u,C=b+u,F=m-u,v=m+u;for(let M=x;M<=C&&p<a;M++){if(M<0||M>=this.rows)continue;let R=M===x||M===C;for(let w=F;w<=v&&p<a;w++){if(!R&&w!==F&&w!==v){w=v-1;continue}if(w<0||w>=this.cols)continue;let S=M*this.cols+w;for(let O=r[S],D=r[S+1];O<D&&p<a;O++){let z=s[O],j=f[z*3]-e,E=f[z*3+2]-n;j*j+E*E<=l&&(o[p++]=z)}}}}return p}};var it=class{constructor(e){this.ctx=e;this.detailVisible=!1;this.seatDetailMix=0;this.structureDetailMix=0;this.nearBuf=new Int32Array(Qe);this.lastGatherX=1/0;this.lastGatherZ=1/0;this.nearIndex=new rt(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)<St)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>wt){i.nearSeatCount()&&i.setNearSeats(this.nearBuf,0);return}let a=this.nearIndex.gather(o.x,o.z,wt,this.nearBuf);a===0&&i.nearSeatCount()===0||i.setNearSeats(this.nearBuf,a)}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 Pr,Vec3 as Cr}from"ogl";function sn(t){let{container:e,model:n,opts:i,orbit:o,cinematic:r,analytics:s,loop:a,labelOverlay:l,stageAzimuth:m,overviewFraming:b}=t,c=0,f=-1,p=(w,S,O=28)=>{o.camera.position.set(w[0],w[1],w[2]),o.camera.lookAt(new Cr(S[0],S[1],S[2])),o.camera.fov=O,o.camera.updateProjectionMatrix()},u=document.createElement("button");u.className="sl-3d-overview-control sl-3d-icon-control",u.type="button",u.textContent="\u2302",u.setAttribute("aria-label","Fit the active level or whole venue in view"),u.dataset.tooltip="Fit view",Object.assign(u.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 x=()=>{u.textContent="\u2302"};x();let C=w=>{f=w;let S=t.gpu();S&&(S.seatProgram.uniforms.uFocusFloor.value=w,S.solidProgram.uniforms.uFocusFloor.value=w,S.chairProgram.uniforms.uFocusFloor.value=w),t.showSectionSeatLabels(null)},F=()=>{if(t.isDisposed())return;i.onViewTargetChange?.(null),i.onSectionFocusChange?.(null),t.panorama()&&(t.panorama().dispose(),t.setPanorama(null),s.panoramaClosed()),t.setPanoramaSphereVisible(!1),t.panoramaLoadAbort()?.abort(),t.setPanoramaLoadAbort(null),t.restorePanoramaLayer(),u.style.display="",l.setVisible(!0),t.setFrozen(!1);let w=f>=0?n.floors[f]:null;if(t.setNearFieldDetailEnabled(!!w),t.setSeatViewLocked(!1),v(),t.removeArriveChip(),t.setNavigationMode("orbit"),w){let S=w.focalWorld[0]-w.center[0],O=w.focalWorld[2]-w.center[2],D=Math.hypot(S,O)>w.radius*.12?Math.atan2(S,O):m,z={center:w.center,radius:w.radius,box:w.box},j={polarDeg:58,margin:1.12};t.reducedMotion()?o.frame(z,!1,D,!1,j):o.frameSoft(z,D,!1,j)}else t.reducedMotion()?o.frame(n.bounds,!1,m,i.portraitOverviewCrop===!0,b):o.frameSoft(n.bounds,m,i.portraitOverviewCrop===!0,b);t.showSectionSeatLabels(null),a.requestRender()},v=()=>{c++,t.setSeatStepping(!1),t.panoramaLoadAbort()?.abort(),t.setPanoramaLoadAbort(null),r.active&&(r.cancel(),o.resumeAfterFlight(n.focalWorld))},M=w=>{if(t.isDisposed()||!t.gpu())return Promise.resolve();let S=n.seats.idToIndex.get(w);if(S===void 0)return Promise.resolve();t.setNearFieldDetailEnabled(!0),i.onViewTargetChange?.(w),t.panorama()&&(t.panorama().dispose(),t.setPanorama(null),t.setPanoramaSphereVisible(!1),u.style.display="",t.restorePanoramaLayer()),t.panoramaLoadAbort()?.abort(),t.setPanoramaLoadAbort(null),t.setFrozen(!1);let O=t.inSeatView()&&i.arriveAtSeatEye===!0;t.setSeatStepping(O),t.setSeatViewLocked(!1);let D=++c;O?t.showArriveChip(w,D):t.removeArriveChip();let{eye:z,focal:j}=t.resolvedSeatViewPose(w,S),E=i.arriveAtSeatEye?t.seatViewArrival(w,S):null,_=E?E.focal:j,N=[o.camera.position.x,o.camera.position.y,o.camera.position.z],P=Dt(N,E?.eye??z,_,n.bounds.center,n.bounds.radius),g=E?E.eye:i.arriveAtSeatEye?z:P.finalPos,H=E?E.fov:i.arriveAtSeatEye?e.clientWidth/Math.max(1,e.clientHeight)<.7?90:65:28,K=[P.waypoints[0],P.waypoints[1],g];if(l.setVisible(!1),t.reducedMotion())return t.setSeatStepping(!1),p(g,_,H),a.requestRender(),s.cinematicSkipped(),t.isDisposed()||o.syncFromCamera(),t.setSeatViewLocked(i.arriveAtSeatEye===!0),E&&t.enterSeatView(E.stops),t.showArriveChip(w,D),Promise.resolve();let Y=new Pr().copy(o.camera.quaternion),y=_o(o.camera,g,_);a.requestRender();let I=O?700:2500;return r.start(K,Y,y,I,H).then(()=>{t.isDisposed()||D!==c||(t.setSeatStepping(!1),s.cinematicPlayed(I),o.resumeAfterFlight(_),t.setSeatViewLocked(i.arriveAtSeatEye===!0),E&&t.enterSeatView(E.stops),a.requestRender(),t.showArriveChip(w,D))})},R=w=>{let S=n.sections.find(j=>j.id===w);if(!S||S.seatCount===0)return!1;t.setNearFieldDetailEnabled(!0),t.setSeatStepping(!1),t.setSeatViewLocked(!1),r.cancel(),t.removeArriveChip(),n.floors.length>1&&f!==S.floorIndex&&C(S.floorIndex),t.setNavigationMode("pan"),t.showSectionSeatLabels(w);let O=S.focalWorld[0]-S.center[0],D=S.focalWorld[2]-S.center[2],z=Math.hypot(O,D)>S.radius*.12?Math.atan2(O,D):void 0;return o.frame({center:S.center,radius:Math.max(5,S.radius*.5)},!1,z),i.onSectionFocusChange?.(w),a.requestRender(),!0};return u.addEventListener("click",F),{overviewChip:u,layoutOverviewChip:x,flightGen:()=>c,focusedFloor:()=>f,applyFloorFocus:C,placeCameraFinal:p,cancelFlight:v,focusOverview:F,flyToSeat:M,focusSectionCamera:R}}function kt(t){let e=performance.now();return{model:Te(t),buildMs:performance.now()-e,source:"main"}}function Ar(t){if(typeof Worker>"u")return Promise.resolve(kt(t));let e;try{e=new Worker(new URL("./scene/scene.worker.js",import.meta.url),{type:"module"})}catch{return Promise.resolve(kt(t))}return new Promise(n=>{let i=!1,o=a=>{i||(i=!0,clearTimeout(s),e.terminate(),n(a))},r=()=>o(kt(t)),s=window.setTimeout(r,15e3);e.onerror=r,e.onmessage=a=>{o({model:a.data.model,buildMs:a.data.buildMs,source:"worker"})},e.postMessage(t)})}var Er=Math.PI/180,Fr=6,Rr=500;function da(t,e,n={}){let i=performance.now(),o=e.prepared?.model??Te(e),r=new nt(n.onAnalytics),s=new Array(o.seats.count);for(let[d,h]of o.seats.idToIndex)s[h]=d;let a=new Map(e.seats.map(d=>[d.id,d])),l=new Map;for(let d of e.seats){if(!d.rowId)continue;let h=l.get(d.rowId);h?h.push(d.id):l.set(d.rowId,[d.id])}let m=new Map;for(let d of e.seats)m.set(d.id,d.sectionId);let b=e.doc.floors?.some(h=>(h.baseHeightM??0)>0)?!0:(e.doc.floors?.flatMap(h=>h.objects)??e.doc.objects).some(h=>h.type==="section"&&((h.height??0)>0||(h.rake??0)>0)),c=null,f=null,p=!1,u=!1,x=!1,C=new Map,F=null,v=null,M=null,R=new Map,w=null,S=()=>{M===null&&(M=t.style.zIndex,t.style.zIndex="20")},O=()=>{M!==null&&(t.style.zIndex==="20"&&(t.style.zIndex=M),M=null)},D=!1,z=()=>D?ne.focusedFloor():-1,j=()=>{c=Po(P.gl,o),f=new et(P.renderer,c.seatGeometry,c.chairGeometry,c.solidGeometry,o.seats.count),P.setClearColor(o.theme.background.top),f.setRestoreClear(o.theme.background.top),c.seatProgram.uniforms.uSeatRadius.value=Ie*o.theme.seatScale,c.seatProgram.uniforms.uFocusFloor.value=z(),c.solidProgram.uniforms.uFocusFloor.value=z(),c.chairProgram.uniforms.uFocusFloor.value=z(),c.screenProgram&&(c.screenProgram.uniforms.uFocusFloor.value=z()),_.forceRegather()},E=!1,_=new it({model:o,orbit:()=>g,gpu:()=>c}),N=d=>_.setDetailEnabled(d),P=new Xe(t,{onContextLost:()=>{x||r.contextLost(),p=!0,V.stop(),c=null,f=null},onContextRestored:()=>{j(),p=!1,x||r.contextRestored(),V.requestRender()}}),g=new qe(P.gl,P.canvas,()=>V.requestRender(),()=>r.orbitEngaged());g.setAspect(P.aspect);let H=(e.doc.floors?.flatMap(d=>d.objects)??e.doc.objects).some(d=>d.type==="section"&&d.physical3dProvenance?.surfaceKind?.status==="inferred"),K=(()=>{if(H&&o.stages.length===0)return;let d=o.focalWorld[0]-o.bounds.center[0],h=o.focalWorld[2]-o.bounds.center[2];return Math.hypot(d,h)>o.bounds.radius*.12?Math.atan2(d,h):void 0})(),Y=o.floors.length>1?{polarDeg:48,margin:1.1}:void 0,y=typeof window<"u"&&!!window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;g.frame(o.bounds,!y&&n.skipInitialOverviewAnimation!==!0,K,n.portraitOverviewCrop===!0,Y);let I=new tt(g.camera),J=on(t),B=new Ze(t,{fontFamily:e.doc.theme?.fontFamily,ink:e.doc.theme?.textColor,backgroundRgb:o.theme.background.top}),$=o.labels,ee=()=>Xt($,o.floors.length,z());B.setLabels(ee());let L=null,G=d=>{if(L=d,B.setForcedDense(!!d),!d){B.setLabels(ee());return}let h=e.seats.filter(k=>k.sectionId===d),A=new Set(h.map(k=>k.id)),W=new Set(h.map(k=>k.rowId)),X=new Set(C.keys()),q=new Set(h.filter(k=>X.has(k.id)).map(k=>k.id)),Z=ee().filter(k=>k.kind!=="row"&&k.kind!=="seat"||(k.kind==="row"?W.has(k.id.slice(4)):A.has(k.id.slice(5))&&(q.size===0||q.has(k.id.slice(5)))));if(o.seatCount<=6e3&&q.size===0){B.setLabels(Z);return}let te=q.size?h.filter(k=>q.has(k.id)):h,he=new Set(te.map(k=>`seat:${k.id}`)),de=te.flatMap(k=>{let re=o.seats.idToIndex.get(k.id);if(re===void 0)return[];let se=re*3;return[{id:`seat:${k.id}`,kind:"seat",text:k.displayLabel||k.label,anchor:[o.seats.iPosition[se],o.seats.iPosition[se+1]+(X.has(k.id)?1.05:.55),o.seats.iPosition[se+2]]}]});B.setLabels([...Z.filter(k=>!he.has(k.id)),...de])};j();let T=null,V=new je(d=>{if(p||!c||u)return!1;let A=I.active?I.update(performance.now()):T?.active?T.update(performance.now()):g.update(),W=z()>=0?o.floors[z()]:null,X=W?.radius??o.bounds.radius,q=ro(g.currentDistance,X),Z=E?{center:[g.camera.position.x,g.camera.position.y,g.camera.position.z],radius:520}:o.renderBounds;g.updateClipping(Z);let te=W?.center??o.renderBounds.center,he=W?.radius??o.renderBounds.radius,de=(le,Ve)=>Math.hypot(g.camera.position.x-le[0],g.camera.position.y-le[1],g.camera.position.z-le[2])<=Ve*(_.detailVisible?1.8:1.55),k=de(te,he);if(!k&&L){let le=o.sections.find(Ve=>Ve.id===L);le&&(k=de(le.center,Math.max(12,le.radius*2)))}_.detailVisible=k;let re=c.seatProgram.uniforms;re.uSeatScale.value=q.scale,re.uSeatFade.value=q.fade;let se=!!W&&io(W.seatCount,P.canvas.clientWidth||1,P.canvas.clientHeight||1),He=ao(o.seats.count,X,g.currentDistance,g.camera.fov,P.canvas.clientHeight||1),De=_.detailVisible||se||He?1:0,We=_.detailVisible||z()>=0||o.floors.length>1?1:0;return _.ease(d,De,We),re.uSeatDetail.value=_.seatDetailMix,c.solidProgram.uniforms.uStructureDetail.value=_.structureDetailMix,re.uMinPixels.value=q.minPixels,re.uPixelToWorld.value=2*Math.tan(g.camera.fov*Er/2)/Math.max(1,P.pixelHeight),_.update(_.detailVisible),P.renderer.render({scene:c.background,clear:!0}),P.renderer.render({scene:c.main,camera:g.camera,clear:!1}),B.update(g.camera.projectionViewMatrix,P.canvas.clientWidth||1,P.canvas.clientHeight||1,g.currentDistance,X,[g.camera.position.x,g.camera.position.y,g.camera.position.z]),A||_.seatDetailMix!==De||_.structureDetailMix!==We}),U=typeof ResizeObserver<"u"?new ResizeObserver(()=>dt.resize()):null;U?.observe(t);let Q=d=>{let h=X=>{let q=o.seats.idToIndex.get(X);return q===void 0?void 0:o.seats.iState[q]},{updates:A,next:W}=Fo(C,d,h);if(C=W,B.setSelectedSeatIds(C.keys()),L&&G(L),A.length){let X=ft(o.seats,A);c&&c.uploadSeatStateRuns(X),V.requestRender()}},ae=()=>w!==null?w:typeof window<"u"&&!!window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,pe=8,Ee=d=>{if(!n.getSeatView)return null;let h=R.get(d);if(!h)for(h=Promise.resolve(n.getSeatView(d)),R.set(d,h),h.catch(()=>{R.get(d)===h&&R.delete(d)});R.size>pe;){let A=R.keys().next().value;if(A===void 0)break;R.delete(A)}return h},be=(d,h)=>{let A=a.get(d),W=Math.max(0,Math.round(o.seats.iFloor[h]??0)),X=e.doc.floors?.[W],q=o.floors[W],Z=X?.focalPoint??e.doc.focalPoint,te=q?{x:q.focalWorld[0]/we,y:q.focalWorld[2]/we}:Z,he=A?.focalPoint?{x:A.focalPoint.x+te.x-Z.x,y:A.focalPoint.y+te.y-Z.y}:te,de=[o.seats.iPosition[h*3],o.seats.iPosition[h*3+1],o.seats.iPosition[h*3+2]];return Lo(de,he,X?.baseHeightM??0,A?.eyeHeightM)},Ge=()=>(t.clientWidth||P.canvas.clientWidth)<=520,at=null,_t=null,ln=async(d,h,A)=>{if(!n.getSeatView||x||A!==ne.flightGen())return;let W;try{W=await en()}catch{if(r.panoramaFailed(d,"mount"),!x&&A===ne.flightGen()){let X=lt(d,A,!0);requestAnimationFrame(()=>X?.querySelector("[data-panorama-trigger]")?.focus())}return}if(!(x||A!==ne.flightGen()||!at))return _t??=W.createOpenPanorama(at),_t(d,h,A)},st=nn({container:t,model:o,opts:n,expandedSeatById:a,seatIdsByRow:l,isNarrow:Ge,isDisposed:()=>x,flightGen:()=>ne.flightGen(),flyToSeat:d=>Ot(d),openPanorama:(d,h,A)=>ln(d,h,A)}),lt=st.show,ct=st.remove,cn=st.layout,ye=rn({container:t,orbit:g,isNarrow:Ge}),un=ye.element,Fe=ye.setNavigationMode,dn=ye.layout,mn=ye.utilityControls,Re=null,Lt=!1,Be=d=>{ye.setSeatViewLocked(d),d||T?.exit()};T=Jo({canvas:P.canvas,camera:g.camera,requestRender:()=>V.requestRender(),reducedMotion:ae,onStopChange:d=>{let h=d??(Lt?"seat":null);Re=h;try{n.onSeatViewStopChange?.(h)}catch{}},onApplied:()=>{x||g.syncFromCamera()}});let pn=Yo(o.stages,o.focalWorld,o.bounds.groundY??0),hn=(d,h)=>{let{eye:A}=be(d,h),W=(t.clientWidth||P.canvas.clientWidth||1)/Math.max(1,t.clientHeight||P.canvas.clientHeight||1),X=qo(A,pn,W);if(n.seatViewStops===!1)return{...X,stops:[]};let q=m.get(d),Z=q?o.sections.find(te=>te.id===q):void 0;return{...X,stops:jo(X,{aspect:W,section:Z&&Z.seatCount>0?{center:Z.center,radius:Z.radius}:null,venue:{center:o.bounds.center,radius:o.bounds.radius}})}},ne=sn({container:t,model:o,opts:n,orbit:g,cinematic:I,analytics:r,loop:V,labelOverlay:B,stageAzimuth:K,overviewFraming:Y,gpu:()=>c,isDisposed:()=>x,panorama:()=>F,setPanorama:d=>{F=d},setPanoramaSphereVisible:d=>{E=d},panoramaLoadAbort:()=>v,setPanoramaLoadAbort:d=>{v=d},setFrozen:d=>{u=d},restorePanoramaLayer:O,reducedMotion:ae,resolvedSeatViewPose:be,showSectionSeatLabels:G,setNearFieldDetailEnabled:N,setSeatViewLocked:Be,setNavigationMode:Fe,showArriveChip:lt,removeArriveChip:ct,inSeatView:()=>Re!==null,setSeatStepping:d=>{Lt=d},seatViewArrival:(d,h)=>n.arriveAtSeatEye?hn(d,h):null,enterSeatView:d=>T?.enter(d)});D=!0;let ut=ne.overviewChip,fn=ne.layoutOverviewChip,vn=ne.applyFloorFocus,gn=ne.focusOverview,zt=ne.cancelFlight,Ot=ne.flyToSeat,Nt=ne.focusSectionCamera;mn.appendChild(ut),at={container:t,model:o,opts:n,analytics:r,orbit:g,loop:V,seatsById:a,ensureSeatView:Ee,resolvedSeatViewPose:be,gpu:()=>c,gl:P.gl,isContextLost:()=>p,isDisposed:()=>x,flightGen:()=>ne.flightGen(),setPanorama:d=>{F=d},getLoadAbort:()=>v,setLoadAbort:d=>{v=d},setPanoramaSphereVisible:d=>{E=d,d&&T?.exit()},setFrozen:d=>{u=d},raisePanoramaLayer:S,restorePanoramaLayer:O,getOverviewChip:()=>ut,labelOverlay:B,reducedMotion:ae,removeArriveChip:ct,showArriveChip:lt};let ue=an({glctx:P,orbit:g,model:o,seats:e.seats,opts:n,cinematic:I,analytics:r,seatIdByIndex:s,sectionIdBySeatId:m,tapSlop:Fr,tapMs:Rr,gpu:()=>c,pick:()=>f,seatViewLocked:()=>ye.seatViewLocked(),focusedSectionId:()=>L,selection:()=>C,cancelFlight:zt,focusSectionCamera:Nt,setSelection:Q,ensureSeatView:Ee});P.canvas.addEventListener("pointerdown",ue.onDown),P.canvas.addEventListener("pointermove",ue.onMove),P.canvas.addEventListener("pointerup",ue.onUp),P.canvas.addEventListener("pointercancel",ue.onUp),V.requestRender();let dt={setAvailability(d){let h=Eo(C,d),A=ft(o.seats,h);A.length&&c&&c.uploadSeatStateRuns(A),V.requestRender()},setSelection:Q,setNavigationMode:Fe,zoomIn(){g.zoomBy(.82),V.requestRender()},zoomOut(){g.zoomBy(1.22),V.requestRender()},flyToSeat:Ot,focusOverview:gn,seatViewStop:()=>Re,recentreSeatView:()=>T?.recentre()??!1,resize(){let{width:d,height:h}=P.resize();g.setAspect(d/Math.max(1,h)),cn(),dn(),fn(),V.requestRender()},stats(){return{...V.stats(),drawCalls:c?c.drawCalls:0,seatCount:o.seatCount}},getQualityEvidence(){let d=V.stats(),h=P.canvas.clientWidth||1,A=P.canvas.clientHeight||1,W=o.bounds.center,X=me(g.camera.projectionViewMatrix,[W[0],o.bounds.box.min[1],W[2]],h,A),q=me(g.camera.projectionViewMatrix,[W[0],o.bounds.box.max[1],W[2]],h,A),Z=o.bounds.box,te=[Z.min[0],Z.max[0]].flatMap(k=>[Z.min[1],Z.max[1]].flatMap(re=>[Z.min[2],Z.max[2]].map(se=>me(g.camera.projectionViewMatrix,[k,re,se],h,A)))).filter(k=>Number.isFinite(k.x)&&Number.isFinite(k.y)&&Number.isFinite(k.depth)),he=te.length?(()=>{let k=Math.min(...te.map(fe=>fe.x)),re=Math.max(...te.map(fe=>fe.x)),se=Math.min(...te.map(fe=>fe.y)),He=Math.max(...te.map(fe=>fe.y)),De=Math.max(0,k),We=Math.min(h,re),le=Math.max(0,se),Ve=Math.min(A,He),Ue=Math.max(0,We-De),mt=Math.max(0,Ve-le);return{box:{x:De,y:le,width:Ue,height:mt},horizontalFillRatio:Ue/h,verticalFillRatio:mt/A,visibleAreaRatio:Ue*mt/(h*A),clippedEdges:[...se<0?["top"]:[],...re>h?["right"]:[],...He>A?["bottom"]:[],...k<0?["left"]:[]]}})():void 0,de=String(P.gl.getParameter(P.gl.VERSION)??"");return{viewport:{width:h,height:A},context:{webgl2:/webgl\s*2/i.test(de),lost:p},frame:{rendered:d.rendered,idle:d.idle},camera:{position:[g.camera.position.x,g.camera.position.y,g.camera.position.z],distance:g.currentDistance,verticalFovDeg:g.fovY},scene:{seatCount:o.seatCount,floorCount:o.floors.length,zoneCount:o.zones.length,sectionCount:o.sections.length,authoredRelief:b,renderedVerticalSpanM:Math.max(0,o.bounds.box.max[1]-o.bounds.box.min[1]),projectedReliefPx:X.visible&&q.visible?Math.abs(X.y-q.y):0},labels:B.qualityEvidence(),framing:he,...Re?{seatView:{fovDeg:g.camera.fov,stop:Re}}:{}}},getQualityReport(){return Ct(dt.getQualityEvidence())},loseContextForTest(){P.simulateContextLossCycle()},floors(){return o.floors},focusFloor(d){if(d!==null&&!o.floors.some(A=>A.index===d))return!1;let h=d??-1;if(N(d!==null),Be(!1),vn(h),Fe("orbit"),d===null)I.cancel(),ae()?g.frame(o.bounds,!1,K,n.portraitOverviewCrop===!0,Y):g.frameSoft(o.bounds,K,n.portraitOverviewCrop===!0,Y);else{let A=o.floors[d];if(A.seatCount>0){I.cancel();let W=A.focalWorld[0]-A.center[0],X=A.focalWorld[2]-A.center[2],q=Math.hypot(W,X)>A.radius*.12?Math.atan2(W,X):K;g.frame({center:A.center,radius:A.radius,box:A.box},!1,q,!1,{polarDeg:58,margin:1.12})}}return V.requestRender(),!0},zones(){return o.zones},focusZone(d){let h=o.zones.find(q=>q.id===d);if(!h||h.seatCount===0)return!1;N(!1),Be(!1),I.cancel(),Fe("orbit"),G(null),n.onSectionFocusChange?.(null);let A=h.focalWorld[0]-h.center[0],W=h.focalWorld[2]-h.center[2],X=Math.hypot(A,W)>h.radius*.12?Math.atan2(A,W):void 0;return g.frame({center:h.center,radius:h.radius*1.25},!1,X),V.requestRender(),!0},sections(){return o.sections},focusSection(d){return Nt(d)},rows(d){return d?o.rows.filter(h=>h.sectionId===d):o.rows},seatsInRow(d){return e.seats.filter(h=>h.rowId===d).map(h=>({id:h.id,label:h.displayLabel||h.label}))},focusRow(d){let h=o.rows.find(A=>A.id===d);return!h||h.seatCount===0?!1:(N(!0),Be(!1),I.cancel(),Fe("pan"),h.sectionId&&(G(h.sectionId),n.onSectionFocusChange?.(h.sectionId)),g.frame({center:h.center,radius:Math.max(2.5,h.radius*.65)}),V.requestRender(),!0)},setReducedMotionForTest(d){w=d},dispose(){x=!0,ct(),ut.remove(),un.remove(),zt(),T?.dispose(),V.stop(),B.dispose(),U?.disconnect(),F&&(F.dispose(),F=null),O(),J(),P.canvas.removeEventListener("pointerdown",ue.onDown),P.canvas.removeEventListener("pointermove",ue.onMove),P.canvas.removeEventListener("pointerup",ue.onUp),P.canvas.removeEventListener("pointercancel",ue.onUp),g.dispose(),f&&f.dispose(),c&&c.dispose(),c=null,f=null,P.dispose()}};return r.opened(o.seatCount,b,e.prepared?.buildMs??performance.now()-i,e.prepared?.source??"inline"),dt}export{Cn as VENUE3D_QUALITY_REPORT_VERSION,Te as buildSceneModel,Ct as inspectVenue3DQualityEvidence,da as mountVenue3D,Ar as prepareVenue3D};