@seatlayer/core 0.57.0 → 0.59.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/{chunk-AQKYUJBX.js → chunk-4BVXDBFE.js} +1 -1
  2. package/dist/{chunk-6VTTBC5F.js → chunk-66HGMU7D.js} +1 -1
  3. package/dist/chunk-GHJUDU3U.js +1 -0
  4. package/dist/{chunk-55NOSZK5.js → chunk-IRFG5DVH.js} +1 -1
  5. package/dist/{chunk-7PT7OQUO.js → chunk-PMU3VPNK.js} +1 -1
  6. package/dist/{chunk-PXWKSYCK.js → chunk-PSHBUDSB.js} +1 -1
  7. package/dist/core/chart-ops/index.js +1 -1
  8. package/dist/core/inventory/index.cjs +1 -1
  9. package/dist/core/inventory/index.d.cts +2 -2
  10. package/dist/core/inventory/index.d.ts +2 -2
  11. package/dist/core/inventory/index.js +1 -1
  12. package/dist/core/layout/index.cjs +1 -1
  13. package/dist/core/layout/index.d.cts +2 -2
  14. package/dist/core/layout/index.d.ts +2 -2
  15. package/dist/core/layout/index.js +1 -1
  16. package/dist/core/quality/index.d.cts +2 -2
  17. package/dist/core/quality/index.d.ts +2 -2
  18. package/dist/core/sections/index.cjs +1 -1
  19. package/dist/core/sections/index.d.cts +1 -1
  20. package/dist/core/sections/index.d.ts +1 -1
  21. package/dist/core/sections/index.js +1 -1
  22. package/dist/index.cjs +1 -1
  23. package/dist/index.d.cts +9 -8
  24. package/dist/index.d.ts +9 -8
  25. package/dist/index.js +1 -1
  26. package/dist/{layout-Dlv5bIf2.d.cts → layout-Ds42yIZT.d.cts} +1 -1
  27. package/dist/{layout-ClQkmixY.d.ts → layout-GZ2DPliB.d.ts} +1 -1
  28. package/dist/{renderedQuality-bDkUOyBL.d.cts → renderedQuality-CU5I5Hrg.d.cts} +1 -1
  29. package/dist/{renderedQuality-B3jgdgPO.d.ts → renderedQuality-ChkM7pSo.d.ts} +1 -1
  30. package/dist/{renderer-B_g-W_QB.d.ts → renderer-Bk65QPKq.d.ts} +19 -6
  31. package/dist/{renderer-DySMcKAR.d.cts → renderer-C313N0nM.d.cts} +19 -6
  32. package/dist/{ticketRestrictions-CzchbX_o.d.cts → ticketRestrictions-C-ohIpd0.d.cts} +1 -1
  33. package/dist/{ticketRestrictions-DaYOCpEw.d.ts → ticketRestrictions-CC75C4L0.d.ts} +1 -1
  34. package/dist/view3d/index.cjs +25 -20
  35. package/dist/view3d/index.d.cts +1 -1
  36. package/dist/view3d/index.d.ts +1 -1
  37. package/dist/view3d/index.js +18 -13
  38. package/package.json +1 -1
  39. package/dist/chunk-VDZ24QVV.js +0 -1
@@ -1,5 +1,5 @@
1
1
  import { C as ChartDoc } from '../types-DTSG6_Hq.cjs';
2
- import { E as ExpandedSeat } from '../renderer-DySMcKAR.cjs';
2
+ import { E as ExpandedSeat } from '../renderer-C313N0nM.cjs';
3
3
  import { SeatView } from './crossfade/panorama.cjs';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { C as ChartDoc } from '../types-DTSG6_Hq.js';
2
- import { E as ExpandedSeat } from '../renderer-B_g-W_QB.js';
2
+ import { E as ExpandedSeat } from '../renderer-Bk65QPKq.js';
3
3
  import { SeatView } from './crossfade/panorama.js';
4
4
 
5
5
  /**
@@ -1,4 +1,4 @@
1
- import{a as On,c as Bn,d as Vn}from"../chunk-55NOSZK5.js";import{a as Nn,c as zn,d as Gn,e as Ce,j as Hn}from"../chunk-XPPT3OGQ.js";import{c as kn,d as Ln,e as Zt,f as _n}from"../chunk-IJI4WU57.js";import{e as Cn,l as He,n as st,o as Dn,q as Pt}from"../chunk-6XJN4REG.js";import{V as ke,W as Le,da as St,fa as In,ga as wt,ia as Tn,l as Rn,m as it,ta as Fn}from"../chunk-VDZ24QVV.js";import{d as K,k as En,x as he,z as at}from"../chunk-CXF32VPG.js";import{Renderer as Yr}from"ogl";var be=["available","held","sold","selected","dimmed"];function ct(t){let e=be.indexOf(t);return e<0?0:e}var Un={available:[.24,.82,.52],held:[.95,.66,.22],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};function Xn(t){let e=.2126*t[0]+.7152*t[1]+.0722*t[2],n=.42,i=.62;return[(e+(t[0]-e)*n)*i,(e+(t[1]-e)*n)*i,(e+(t[2]-e)*n)*i]}var Kt={ground:[.07,.085,.11],tierTop:[.24,.28,.34],tierWall:[.17,.2,.25],stageTop:[.94,.7,.38],stageWall:[.48,.33,.18],decorTop:[.22,.25,.29],decorWall:[.15,.17,.2],gaTop:[.24,.28,.33],gaWall:[.16,.19,.23],boothTop:[.3,.33,.38],boothWall:[.2,.23,.27],tableTop:[.38,.34,.29],tableWall:[.24,.21,.18]},Ue={top:[.05,.06,.08],bottom:[.1,.12,.15]};function pe(t,e){return[Math.min(1,t[0]*e),Math.min(1,t[1]*e),Math.min(1,t[2]*e)]}function Wr(){let t=typeof window<"u"&&window.devicePixelRatio||1,e=navigator.deviceMemory,n=typeof e=="number"&&e<=4?1.5:2;return Math.min(t,n)}var At=class{constructor(e,n){this.clearRgb=[0,0,0];this.container=e,this.canvas=document.createElement("canvas"),this.canvas.style.display="block",this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.touchAction="none",this.canvas.tabIndex=0,this.canvas.setAttribute("role","application"),this.canvas.setAttribute("aria-label","Interactive 3D venue. Drag or use arrow keys to look around; pinch, scroll, plus or minus to zoom."),this.renderer=new Yr({canvas:this.canvas,dpr:Wr(),alpha:!1,antialias:!1,depth:!0,stencil:!1,powerPreference:"high-performance",webgl:2}),this.gl=this.renderer.gl,this.clearRgb=[Ue.top[0],Ue.top[1],Ue.top[2]],this.gl.clearColor(this.clearRgb[0],this.clearRgb[1],this.clearRgb[2],1),e.appendChild(this.canvas),this.lostHandler=i=>{i.preventDefault(),n.onContextLost()},this.restoredHandler=()=>n.onContextRestored(),this.canvas.addEventListener("webglcontextlost",this.lostHandler,!1),this.canvas.addEventListener("webglcontextrestored",this.restoredHandler,!1),this.resize()}setClearColor(e){this.clearRgb=[e[0],e[1],e[2]],this.gl.clearColor(e[0],e[1],e[2],1)}get clearColor(){return this.clearRgb}resize(){let e=Math.max(1,this.container.clientWidth||this.canvas.clientWidth||1),n=Math.max(1,this.container.clientHeight||this.canvas.clientHeight||1);return this.renderer.setSize(e,n),{width:e,height:n}}get pixelHeight(){return this.renderer.height*this.renderer.dpr}get aspect(){return this.renderer.width/Math.max(1,this.renderer.height)}dispose(){this.canvas.removeEventListener("webglcontextlost",this.lostHandler,!1),this.canvas.removeEventListener("webglcontextrestored",this.restoredHandler,!1);let e=this.gl.getExtension("WEBGL_lose_context");e&&e.loseContext(),this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}simulateContextLossCycle(){let e=this.gl.getExtension("WEBGL_lose_context");e&&(e.loseContext(),setTimeout(()=>{e.restoreContext&&e.restoreContext()},300))}};import{Camera as jr,Vec3 as Qt}from"ogl";var ue=Math.PI/180,$t=15*ue,Jt=80*ue,Ze=.12,Yn=35,Wn=1.25,Ct=class{constructor(e,n,i,o){this.fovY=Yn;this.target=new Qt;this.azimuth=-30*ue;this.polar=55*ue;this.distance=10;this.azT=-30*ue;this.polT=55*ue;this.distT=10;this.minDist=1;this.maxDist=100;this.gestureFired=!1;this.interactionEnabled=!0;this.dragging=!1;this.panning=!1;this.lastX=0;this.lastY=0;this.activePointers=new Map;this.pinchDist=0;this.pinchCx=0;this.pinchCy=0;this.targetT=new Qt;this.panAnchor=new Qt;this.panLimit=0;this.primaryDragMode="orbit";this.camera=new jr(e,{fov:Yn,near:.1,far:5e3,aspect:1}),this.canvas=n,this.requestRender=i,this.onGesture=o,this.onPointerDown=r=>{if(this.interactionEnabled){try{this.canvas.setPointerCapture?.(r.pointerId)}catch{}if(this.activePointers.set(r.pointerId,{x:r.clientX,y:r.clientY}),this.activePointers.size===1){let a=r.button===2||r.button===1,s=r.button===0&&(r.shiftKey?this.primaryDragMode==="orbit":this.primaryDragMode==="pan");this.panning=a||s,this.dragging=!this.panning,this.lastX=r.clientX,this.lastY=r.clientY}else if(this.activePointers.size===2){this.dragging=!1,this.panning=!1,this.pinchDist=this.currentPinchDistance();let a=this.pinchCentroid();this.pinchCx=a.x,this.pinchCy=a.y}}},this.onPointerMove=r=>{if(!this.interactionEnabled||!this.activePointers.has(r.pointerId))return;if(this.activePointers.set(r.pointerId,{x:r.clientX,y:r.clientY}),this.activePointers.size>=2){let l=this.currentPinchDistance();this.pinchDist>0&&(this.dollyBy(Math.exp((this.pinchDist-l)*.005)),this.fireGesture()),this.pinchDist=l;let c=this.pinchCentroid();this.panBy(c.x-this.pinchCx,c.y-this.pinchCy),this.pinchCx=c.x,this.pinchCy=c.y;return}let a=r.clientX-this.lastX,s=r.clientY-this.lastY;if(this.panning){this.lastX=r.clientX,this.lastY=r.clientY,(a!==0||s!==0)&&(this.panBy(a,s),this.fireGesture());return}this.dragging&&(this.lastX=r.clientX,this.lastY=r.clientY,(a!==0||s!==0)&&this.fireGesture(),this.azT-=a*.006,this.polT=Math.max($t,Math.min(Jt,this.polT-s*.006)),this.requestRender())},this.onPointerUp=r=>{this.activePointers.delete(r.pointerId);try{this.canvas.releasePointerCapture?.(r.pointerId)}catch{}this.activePointers.size<2&&(this.pinchDist=0),this.activePointers.size===0&&(this.dragging=!1,this.panning=!1)},this.onContextMenu=r=>{r.preventDefault()},this.onWheel=r=>{if(r.preventDefault(),!this.interactionEnabled)return;let a=r.deltaMode===1?16:r.deltaMode===2?100:1,s=Math.max(-2,Math.min(2,r.deltaY*a/100));this.dollyBy(Math.exp(s*.22)),this.fireGesture()},this.onKeyDown=r=>{if(!this.interactionEnabled)return;let a=7*ue;if(r.shiftKey&&(r.key==="ArrowLeft"||r.key==="ArrowRight"||r.key==="ArrowUp"||r.key==="ArrowDown"))this.panBy(r.key==="ArrowLeft"?-32:r.key==="ArrowRight"?32:0,r.key==="ArrowUp"?-32:r.key==="ArrowDown"?32:0);else if(r.key==="ArrowLeft"||r.key==="ArrowRight")this.azT+=r.key==="ArrowLeft"?-a:a;else if(r.key==="ArrowUp"||r.key==="ArrowDown")this.polT=Math.max($t,Math.min(Jt,this.polT+(r.key==="ArrowUp"?-a:a)));else if(r.key==="+"||r.key==="=")this.dollyBy(.82);else if(r.key==="-"||r.key==="_")this.dollyBy(1.22);else return;r.preventDefault(),this.fireGesture(),this.requestRender()},n.addEventListener("pointerdown",this.onPointerDown),n.addEventListener("pointermove",this.onPointerMove),n.addEventListener("pointerup",this.onPointerUp),n.addEventListener("pointercancel",this.onPointerUp),n.addEventListener("wheel",this.onWheel,{passive:!1}),n.addEventListener("keydown",this.onKeyDown),n.addEventListener("contextmenu",this.onContextMenu)}pinchCentroid(){let e=[...this.activePointers.values()];if(!e.length)return{x:0,y:0};let n=0,i=0;for(let o of e)n+=o.x,i+=o.y;return{x:n/e.length,y:i/e.length}}panBy(e,n){let i=this.canvas.clientHeight||1,o=2*this.distance*Math.tan(this.fovY*ue/2)/i,r=Math.sin(this.azimuth),a=Math.cos(this.azimuth),s=a,l=-r,c=Math.cos(this.polar),h=Math.sin(this.polar),m=-r*c,d=-a*c;this.targetT.x+=(-e*s+n*m)*o,this.targetT.z+=(-e*l+n*d)*o,this.targetT.y+=n*h*o,this.clampPan(),this.requestRender()}clampPan(){if(this.panLimit<=0)return;let e=this.panLimit,n=this.panAnchor.x,i=this.panAnchor.y,o=this.panAnchor.z;this.targetT.x=Math.max(n-e,Math.min(n+e,this.targetT.x)),this.targetT.z=Math.max(o-e,Math.min(o+e,this.targetT.z)),this.targetT.y=Math.max(i-e*.5,Math.min(i+e,this.targetT.y))}fireGesture(){this.gestureFired||(this.gestureFired=!0,this.onGesture?.())}currentPinchDistance(){let e=[...this.activePointers.values()];return e.length<2?0:Math.hypot(e[0].x-e[1].x,e[0].y-e[1].y)}dollyBy(e){this.distT=Math.max(this.minDist,Math.min(this.maxDist,this.distT*e)),this.requestRender()}zoomBy(e){this.interactionEnabled&&(this.dollyBy(e),this.fireGesture())}setPrimaryDragMode(e){this.primaryDragMode=e}setInteractionEnabled(e){this.interactionEnabled=e,!e&&(this.activePointers.clear(),this.dragging=!1,this.panning=!1,this.pinchDist=0)}frame(e,n=!1,i,o=!1,r){this.target.set(e.center[0],e.center[1],e.center[2]),this.targetT.copy(this.target),this.panAnchor.copy(this.target),this.panLimit=Math.max(1,e.radius)*1.5;let a=Math.max(1,e.radius),s=this.fovY*ue/2,l=o?Math.max(.82,this.camera.aspect||1):this.camera.aspect||1,c=Math.atan(Math.tan(s)*l);this.azT=i??-30*ue,this.polT=Math.max(15,Math.min(80,r?.polarDeg??55))*ue;let h=this.fitDistance(e,s,c,this.azT,this.polT);this.distT=h*Math.max(1.05,Math.min(2,r?.margin??Wn)),this.minDist=Math.max(2,a*.12),this.maxDist=h*4,n?(this.azimuth=this.azT,this.polar=12*ue,this.distance=this.distT*1.7):(this.azimuth=this.azT,this.polar=this.polT,this.distance=this.distT),this.applyPosition()}setAspect(e){this.camera.perspective({aspect:e})}frameSoft(e,n,i=!1,o){this.target.set(e.center[0],e.center[1],e.center[2]),this.targetT.copy(this.target),this.panAnchor.copy(this.target),this.panLimit=Math.max(1,e.radius)*1.5,this.syncFromCamera(),this.camera.perspective({fov:this.fovY,aspect:this.camera.aspect});let r=this.fovY*ue/2,a=i?Math.max(.82,this.camera.aspect||1):this.camera.aspect||1,s=Math.atan(Math.tan(r)*a);this.azT=n??this.azimuth,this.polT=Math.max(15,Math.min(80,o?.polarDeg??55))*ue;let l=this.fitDistance(e,r,s,this.azT,this.polT);this.distT=l*Math.max(1.05,Math.min(2,o?.margin??Wn))}fitDistance(e,n,i,o,r){let a=Math.max(1,e.radius),s=Math.max(a/Math.tan(n),a/Math.tan(i)),l=e.box;if(!l)return s;let c=Math.sin(r),h=-c*Math.sin(o),m=-Math.cos(r),d=-c*Math.cos(o);if(Math.abs(m)>.999)return s;let p=-d,f=h,u=Math.hypot(p,f);p/=u,f/=u;let b=-f*m,y=f*h-p*d,x=p*m,v=Math.tan(i),k=Math.tan(n),P=1;for(let M=0;M<8;M++){let F=(M&1?l.max[0]:l.min[0])-e.center[0],O=(M&2?l.max[1]:l.min[1])-e.center[1],L=(M&4?l.max[2]:l.min[2])-e.center[2],H=F*h+O*m+L*d,_=Math.abs(F*p+L*f),g=Math.abs(F*b+O*y+L*x);P=Math.max(P,_/v-H,g/k-H)}return Math.min(s,Math.max(P,a*.35))}updateClipping(e){let n=this.camera.position.x-e.center[0],i=this.camera.position.y-e.center[1],o=this.camera.position.z-e.center[2],r=Math.hypot(n,i,o),a=Math.max(1,e.radius)*1.18,s=Math.max(.05,r-a),l=Math.max(s+10,r+a);this.camera.perspective({near:s,far:l,aspect:this.camera.aspect})}update(){let e=this.azT-this.azimuth,n=this.polT-this.polar,i=this.distT-this.distance,o=this.targetT.x-this.target.x,r=this.targetT.y-this.target.y,a=this.targetT.z-this.target.z,s=Math.max(1e-4,this.distance*1e-4),l=Math.abs(e)>1e-4||Math.abs(n)>1e-4||Math.abs(i)>1e-4||Math.abs(o)>s||Math.abs(r)>s||Math.abs(a)>s;return this.azimuth+=e*Ze,this.polar+=n*Ze,this.distance+=i*Ze,this.target.x+=o*Ze,this.target.y+=r*Ze,this.target.z+=a*Ze,l&&this.applyPosition(),l}get currentDistance(){return this.distance}syncFromCamera(){let e=this.camera.position.x-this.target.x,n=this.camera.position.y-this.target.y,i=this.camera.position.z-this.target.z,o=Math.hypot(e,n,i)||1,r=Math.max($t,Math.min(Jt,Math.acos(Math.max(-1,Math.min(1,n/o)))));this.distance=this.distT=o,this.polar=this.polT=r,this.azimuth=this.azT=Math.atan2(e,i)}setTarget(e){this.target.set(e[0],e[1],e[2]),this.targetT.copy(this.target)}resumeAfterFlight(e){this.camera.perspective({fov:this.fovY,aspect:this.camera.aspect}),e&&this.target.set(e[0],e[1],e[2]),this.targetT.copy(this.target),this.syncFromCamera()}applyPosition(){let e=Math.sin(this.polar),n=this.target.x+this.distance*e*Math.sin(this.azimuth),i=this.target.y+this.distance*Math.cos(this.polar),o=this.target.z+this.distance*e*Math.cos(this.azimuth);this.camera.position.set(n,i,o),this.camera.lookAt(this.target)}dispose(){this.canvas.removeEventListener("pointerdown",this.onPointerDown),this.canvas.removeEventListener("pointermove",this.onPointerMove),this.canvas.removeEventListener("pointerup",this.onPointerUp),this.canvas.removeEventListener("pointercancel",this.onPointerUp),this.canvas.removeEventListener("wheel",this.onWheel),this.canvas.removeEventListener("keydown",this.onKeyDown),this.canvas.removeEventListener("contextmenu",this.onContextMenu),this.activePointers.clear()}};var Rt=class{constructor(e){this.rafId=0;this.running=!1;this.lastTime=0;this.fpsEma=0;this.rendered=0;this.tick=e=>{let n=this.lastTime?(e-this.lastTime)/1e3:.016666666666666666;if(this.lastTime=e,n>0){let o=1/n;this.fpsEma=this.fpsEma?this.fpsEma*.9+o*.1:o}this.rendered++,this.frame(n)?this.rafId=requestAnimationFrame(this.tick):(this.running=!1,this.rafId=0)};this.frame=e}requestRender(){this.running||(this.running=!0,this.lastTime=0,this.rafId=requestAnimationFrame(this.tick))}stats(){return{fps:this.running?Math.round(this.fpsEma):0,rendered:this.rendered,idle:!this.running}}stop(){this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=0,this.running=!1}};var Ke=2.5,qr=1.15,lt=6,Qe=10,jn=6,qn=9.5,Zn=.9,Kn=2.2,en=30,tn=4,It=8192;var ps=Qe+tn;function Qn(t,e){let n=e*1.4,i=e*3.2;if(t<=n)return{scale:1,fade:0,minPixels:Ke};let o=Math.min(1,(t-n)/Math.max(.001,i-n));return{scale:1-o*.4,fade:o*.55,minPixels:Ke+o*(qr-Ke)}}function $n(t,e,n){return!(t>0)||!(e>0)||!(n>0)?!1:e*n/t>=64}function Jn(t,e,n,i,o){if(!(t>0)||!(e>0)||!(n>0)||!(i>0)||!(o>0))return!1;let r=Math.tan(i/2*Math.PI/180);if(!(r>0))return!1;let a=e/(n*r)*(o/2);return Math.PI*a*a/t>=64}import Zr from"earcut";import Kr from"polygon-clipping";var R=ke,Qr=.002;function $r(t,e,n){let i=Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2]),o=Math.hypot(n[0]-e[0],n[1]-e[1],n[2]-e[2]),r=Math.hypot(t[0]-n[0],t[1]-n[1],t[2]-n[2]),a=Math.max(i,o,r);if(a<1e-9)return!0;let s=(i+o+r)/2;return 2*Math.sqrt(Math.max(0,s*(s-i)*(s-o)*(s-r)))/a<Qr}var Xe=class{constructor(e=16384){this.len=0;this.buf=new Float32Array(e)}push3(e,n,i){this.len+3>this.buf.length&&this.grow(this.len+3),this.buf[this.len++]=e,this.buf[this.len++]=n,this.buf[this.len++]=i}push1(e){this.len+1>this.buf.length&&this.grow(this.len+1),this.buf[this.len++]=e}grow(e){let n=this.buf.length*2;for(;n<e;)n*=2;let i=new Float32Array(n);i.set(this.buf.subarray(0,this.len)),this.buf=i}get length(){return this.len}toArray(){return this.buf.slice(0,this.len)}},Et=class{constructor(){this.pos=new Xe;this.nor=new Xe;this.col=new Xe;this.flr=new Xe;this.mat=new Xe;this.currentFloor=0;this.currentMaterial=0}setFloor(e){this.currentFloor=e}setMaterial(e){this.currentMaterial=e}tri(e,n,i,o,r,a=r,s=r){$r(e,n,i)||(this.pos.push3(e[0],e[1],e[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(i[0],i[1],i[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.col.push3(r[0],r[1],r[2]),this.col.push3(a[0],a[1],a[2]),this.col.push3(s[0],s[1],s[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}triN(e,n,i,o,r,a,s,l=s,c=s){[...e,...n,...i].every(Number.isFinite)&&(this.pos.push3(e[0],e[1],e[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(i[0],i[1],i[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(a[0],a[1],a[2]),this.col.push3(s[0],s[1],s[2]),this.col.push3(l[0],l[1],l[2]),this.col.push3(c[0],c[1],c[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}get vertexCount(){return this.pos.length/3}build(){return{position:this.pos.toArray(),normal:this.nor.toArray(),color:this.col.toArray(),floor:this.flr.toArray(),material:this.mat.toArray(),count:this.pos.length/3}}};function Jr(t,e,n){let i=e[0]-t[0],o=e[1]-t[1],r=e[2]-t[2],a=n[0]-t[0],s=n[1]-t[1],l=n[2]-t[2],c=o*l-r*s,h=r*a-i*l,m=i*s-o*a,d=Math.hypot(c,h,m)||1;return c/=d,h/=d,m/=d,[c,h,m]}function ei(t,e){let n=[...t],i=[];for(let a of t)i.push(a.x,a.y);let o=[];if(e){for(let a of e)if(!(a.length<3)){o.push(n.length);for(let s of a)n.push(s),i.push(s.x,s.y)}}let r=Zr(i,o.length?o:void 0,2);return{pts:n,tris:r}}function nn(t){return He(t)<0?[...t].reverse():t}var ti=3;function ni(t,e,n,i){let o=i(t),r=i(e),a=i(n),s=(p,f,u,b)=>Math.abs(i({x:(p.x+f.x)/2,y:(p.y+f.y)/2})-(u+b)/2),l=(t.x+e.x+n.x)/3,c=(t.y+e.y+n.y)/3,h=(o+r+a)/3,m=Math.max(s(t,e,o,r),s(e,n,r,a),s(n,t,a,o),Math.abs(i({x:l,y:c})-h)),d=(p,f,u)=>{let b=Math.abs(i({x:(p+l)/2,y:(f+c)/2})-(u+h)/2);b>m&&(m=b)};return d((t.x+e.x)/2,(t.y+e.y)/2,(o+r)/2),d((e.x+n.x)/2,(e.y+n.y)/2,(r+a)/2),d((n.x+t.x)/2,(n.y+t.y)/2,(a+o)/2),m}function ut(t,e,n,i,o){if(o<=0)return ni(t,e,n,i);let r={x:(t.x+e.x)/2,y:(t.y+e.y)/2},a={x:(e.x+n.x)/2,y:(e.y+n.y)/2},s={x:(n.x+t.x)/2,y:(n.y+t.y)/2};return Math.max(ut(t,r,s,i,o-1),ut(r,e,a,i,o-1),ut(s,a,n,i,o-1),ut(r,a,s,i,o-1))}function mt(t,e,n,i,o,r,a,s){if(a>0){let d={x:(e.x+n.x)/2,y:(e.y+n.y)/2},p={x:(n.x+i.x)/2,y:(n.y+i.y)/2},f={x:(i.x+e.x)/2,y:(i.y+e.y)/2};mt(t,e,d,f,o,r,a-1,s),mt(t,d,n,p,o,r,a-1,s),mt(t,f,p,i,o,r,a-1,s),mt(t,d,p,f,o,r,a-1,s);return}let l=[e.x*R,o(e),e.y*R],c=[n.x*R,o(n),n.y*R],h=[i.x*R,o(i),i.y*R];if(s){t.triN(l,c,h,s(e),s(n),s(i),r);return}let m=Jr(l,c,h);m[1]<0&&(m=[-m[0],-m[1],-m[2]]),t.tri(l,c,h,m,r)}var oi=8;function eo(t,e,n){if(!Number.isFinite(n))return t;let i=[],o=(r,a,s,l,c)=>{if(c>0){let h={x:(r.x+a.x)/2,y:(r.y+a.y)/2},m=e(h);if(Math.abs(m-(s+l)/2)>n){o(r,h,s,m,c-1),o(h,a,m,l,c-1);return}}i.push(r)};for(let r=0;r<t.length;r++){let a=t[r],s=t[(r+1)%t.length];o(a,s,e(a),e(s),oi)}return i}function Tt(t,e){if(t.length<3)return t;let n=[];for(let o of t){let r=n[n.length-1];r&&Math.hypot(o.x-r.x,o.y-r.y)<e||n.push(o)}for(;n.length>2&&Math.hypot(n[0].x-n[n.length-1].x,n[0].y-n[n.length-1].y)<e;)n.pop();if(n.length<3)return t;let i=[];for(let o=0;o<n.length;o++){let r=i.length?i[i.length-1]:n[(o-1+n.length)%n.length],a=n[o],s=n[(o+1)%n.length],l=s.x-r.x,c=s.y-r.y,h=Math.hypot(l,c);h>e&&Math.abs((a.x-r.x)*c-(a.y-r.y)*l)/h<e||i.push(a)}return i.length>=3?i:n}var Ft=.001*Le*.1;function ie(t,e,n,i,o,r,a,s,l=1/0,c){if(!e||e.length<3||(l===void 0&&(l=1/0),Math.abs(He(e))<1e-4))return;let h=Tt(eo(Tt(nn(e),Ft),i,l),Ft),m=n?.map(M=>Tt(eo(Tt(nn(M),Ft),i,l),Ft)).filter(M=>M.length>=3&&Math.abs(He(M))>=1e-4),{pts:d,tris:p}=ei(h,m),f=[r[0]*s.top,r[1]*s.top,r[2]*s.top],u=[r[0]*s.bottomCap,r[1]*s.bottomCap,r[2]*s.bottomCap],b=[a[0]*s.top,a[1]*s.top,a[2]*s.top],y=[a[0]*s.wallBottom,a[1]*s.wallBottom,a[2]*s.wallBottom],x=0;if(Number.isFinite(l))for(;x<ti;x++){let M=0;for(let F=0;F<p.length;F+=3){let O=ut(d[p[F]],d[p[F+1]],d[p[F+2]],i,x);O>M&&(M=O)}if(M<=l)break}for(let M=0;M<p.length;M+=3){let F=d[p[M]],O=d[p[M+1]],L=d[p[M+2]];mt(t,F,O,L,i,f,x,c);let H=[F.x*R,o,F.y*R],_=[O.x*R,o,O.y*R],g=[L.x*R,o,L.y*R];t.tri(H,g,_,[0,-1,0],u)}let v=M=>{if(x<=0)return M;let F=1<<x,O=[];for(let L=0;L<M.length;L++){let H=M[L],_=M[(L+1)%M.length];for(let g=0;g<F;g++){let w=g/F;O.push({x:H.x+(_.x-H.x)*w,y:H.y+(_.y-H.y)*w})}}return O},k=Rn(h),P=[{ring:v(h),flip:!1}];if(m)for(let M of m)M.length>=3&&P.push({ring:v(M),flip:!0});for(let{ring:M,flip:F}of P)for(let O=0;O<M.length;O++){let L=M[O],H=M[(O+1)%M.length],_=(H.x-L.x)*R,w=(H.y-L.y)*R,E=-_,C=Math.hypot(w,E)||1;w/=C,E/=C;let N=(L.x+H.x)/2-k.x,S=(L.y+H.y)/2-k.y,I=w*N+E*S;F&&(I=-I),I<0&&(w=-w,E=-E);let T=[w,0,E],B=[L.x*R,i(L),L.y*R],A=[H.x*R,i(H),H.y*R],D=[L.x*R,o,L.y*R],V=[H.x*R,o,H.y*R];t.tri(B,A,V,T,b,b,y),t.tri(B,V,D,T,b,y,y)}}function to(t){let e=0;for(let l of t)e+=l.count;let n=new Float32Array(e*3),i=new Float32Array(e*3),o=new Float32Array(e*3),r=new Float32Array(e),a=new Float32Array(e),s=0;for(let l of t)n.set(l.position,s*3),i.set(l.normal,s*3),o.set(l.color,s*3),r.set(l.floor,s),a.set(l.material,s),s+=l.count;return{position:n,normal:i,color:o,floor:r,material:a,count:e}}function Dt(t,e,n=2.5){if(e<=0||t.length<3)return t;let i=nn(t),o=i.length,r=[];for(let s=0;s<o;s++){let l=i[s],c=i[(s+1)%o],h=c.x-l.x,m=c.y-l.y,d=Math.hypot(h,m)||1;r.push({x:m/d,y:-h/d})}let a=[];for(let s=0;s<o;s++){let l=i[s],c=r[(s-1+o)%o],h=r[s],m=c.x+h.x,d=c.y+h.y,p=Math.hypot(m,d),f=()=>{a.push([l.x+c.x*e,l.y+c.y*e]),a.push([l.x+h.x*e,l.y+h.y*e])};if(p<1e-9){f();continue}m/=p,d/=p;let u=m*c.x+d*c.y,b=1/Math.max(u,1e-6);if(!Number.isFinite(b)||b>n){f();continue}a.push([l.x+m*e*b,l.y+d*e*b])}if(a.length<3)return t;try{let s=Kr.union([[...a,a[0]]]),l=null,c=-1/0;for(let m of s){let d=Math.abs(He(m[0].map(([p,f])=>({x:p,y:f}))));d>c&&(c=d,l=m[0])}if(!l)return t;let h=l.map(([m,d])=>({x:m,y:d}));if(h.length>1){let m=h[0],d=h[h.length-1];Math.abs(m.x-d.x)<1e-9&&Math.abs(m.y-d.y)<1e-9&&h.pop()}return h.length>=3?h:t}catch{return t}}function kt(t,e,n,i,o=28){let r=[];for(let a=0;a<o;a++){let s=a/o*Math.PI*2;r.push({x:t+n*Math.cos(s),y:e+i*Math.sin(s)})}return r}function dt(t,e,n,i){return[{x:t,y:e},{x:t+n,y:e},{x:t+n,y:e+i},{x:t,y:e+i}]}var ce={pedestal:0,pad:1,back:2,body:3,head:4},ri=.44,ii=.15,ai=.3,si=.24;function no(t){return t===void 0||!Number.isFinite(t)||t<=0?si:Math.min(ai,Math.max(ii,t*ri))}var on=.21,ci=.05,rn=.45,Lt=rn+ci,li=[{part:ce.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:ce.pad,min:[-1,.36,-.95],max:[1,rn,1]},{part:ce.back,min:[-1,Lt,-1],max:[1,.92,-.72]}],ui=[{part:ce.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:ce.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:ce.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:ce.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:ce.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}],mi=[{n:[1,0,0],c:[[1,0,0],[1,1,0],[1,1,1],[1,0,1]]},{n:[-1,0,0],c:[[0,0,1],[0,1,1],[0,1,0],[0,0,0]]},{n:[0,1,0],c:[[0,1,0],[0,1,1],[1,1,1],[1,1,0]]},{n:[0,-1,0],c:[[0,0,1],[0,0,0],[1,0,0],[1,0,1]]},{n:[0,0,1],c:[[0,0,1],[1,0,1],[1,1,1],[0,1,1]]},{n:[0,0,-1],c:[[1,0,0],[0,0,0],[0,1,0],[1,1,0]]}];function oo(){let t=[],e=[],n=[],i=[],o=(C,N,S)=>{let I=n.length,[T,B,A]=C,D=[B[0]-T[0],B[1]-T[1],B[2]-T[2]],V=[A[0]-T[0],A[1]-T[1],A[2]-T[2]],U=D[1]*V[2]-D[2]*V[1],Y=D[2]*V[0]-D[0]*V[2],X=D[0]*V[1]-D[1]*V[0],j=Math.hypot(U,Y,X);j>1e-9?(U/=j,Y/=j,X/=j):[U,Y,X]=N,U*N[0]+Y*N[1]+X*N[2]<0&&(U=-U,Y=-Y,X=-X);for(let Z of C)t.push(...Z),e.push(U,Y,X),n.push(S);i.push(I,I+1,I+2,I,I+2,I+3)},r=C=>{for(let N of mi){let S=N.c.map(I=>I.map((T,B)=>T?C.max[B]:C.min[B]));o(S,N.n,C.part)}};for(let C of li)r(C);for(let C of ui)r(C);let a=rn,s=1.08,l=.47,c=.69,h=-.55,m=.08,d=-.48,p=.01,f=[-l,a,h],u=[l,a,h],b=[-l,a,m],y=[l,a,m],x=[-c,s,d],v=[c,s,d],k=[-c,s,p],P=[c,s,p];o([u,v,P,y],[1,0,0],ce.body),o([b,k,x,f],[-1,0,0],ce.body),o([k,P,v,x],[0,1,0],ce.body),o([f,u,y,b],[0,-1,0],ce.body),o([y,P,k,b],[0,0,1],ce.body),o([f,x,v,u],[0,0,-1],ce.body);let M=10,F=8,O=[0,1.205,-.23],L=[.42,.115,.38],H=n.length;for(let C=0;C<=F;C++){let N=Math.PI*C/F,S=Math.cos(N),I=Math.sin(N);for(let T=0;T<=M;T++){let B=Math.PI*2*T/M,A=I*Math.cos(B),D=I*Math.sin(B);t.push(O[0]+L[0]*A,O[1]+L[1]*S,O[2]+L[2]*D);let V=A/L[0],U=S/L[1],Y=D/L[2],X=Math.hypot(V,U,Y)||1;V/=X,U/=X,Y/=X,e.push(V,U,Y),n.push(ce.head)}}for(let C=0;C<F;C++)for(let N=0;N<M;N++){let S=H+C*(M+1)+N,I=S+M+1;i.push(S,I,S+1,S+1,I,I+1)}let _=new Float32Array(t),g=new Float32Array(e),w=new Float32Array(n),E=new Uint16Array(i);return{position:_,normal:g,part:w,index:E,vertexCount:n.length,indexCount:i.length}}function ro(t,e,n,i){let o=new Float32Array(e),r=c=>t[c*3],a=c=>t[c*3+2],s=0,l=(c,h)=>{let m=h-c;for(let d=c;d<h;d++){let[p,f]=i(d),u=p-r(d),b=f-a(d);if(m>=2){let y=Math.max(c,d-1),x=Math.min(h-1,d+1),v=r(x)-r(y),k=a(x)-a(y),P=Math.hypot(v,k);if(P>1e-6){let M=-k/P,F=v/P;M*u+F*b<0&&(M=-M,F=-F),u=M,b=F}}o[d]=u===0&&b===0?0:Math.atan2(u,b)}};for(let c=1;c<=e;c++)(c===e||n(c)!==n(s))&&(l(s,c),s=c);return o}var Re=.22;function io(t,e){let n=be[t];if(n!=="sold"&&n!=="held")return-1;let i=(e+1)*2654435761;return i^=i>>>15,i=Math.imul(i,2246822519),i^=i>>>13,(i>>>0)%1e5/1e5}var di=.42;function hi(t){let e=t.length,n=new Float64Array(e);if(e<2)return n.fill(1/0),n;let i=1/0,o=1/0,r=-1/0,a=-1/0;for(let f of t)f.x<i&&(i=f.x),f.y<o&&(o=f.y),f.x>r&&(r=f.x),f.y>a&&(a=f.y);let s=Math.max(r-i,1e-6),l=Math.max(a-o,1e-6),c=Math.max(Math.sqrt(s*l/e),1e-6),h=Math.max(1,Math.ceil(s/c)+1),m=Math.max(1,Math.ceil(l/c)+1),d=new Map,p=(f,u)=>{let b=Math.min(h-1,Math.max(0,Math.floor((f-i)/c)));return Math.min(m-1,Math.max(0,Math.floor((u-o)/c)))*h+b};for(let f=0;f<e;f++){let u=p(t[f].x,t[f].y),b=d.get(u);b?b.push(f):d.set(u,[f])}for(let f=0;f<e;f++){let u=t[f],b=Math.min(h-1,Math.max(0,Math.floor((u.x-i)/c))),y=Math.min(m-1,Math.max(0,Math.floor((u.y-o)/c))),x=1/0;for(let v=1;v<=4;v++){for(let k=y-v;k<=y+v;k++)if(!(k<0||k>=m))for(let P=b-v;P<=b+v;P++){if(P<0||P>=h||v>1&&Math.abs(k-y)<v&&Math.abs(P-b)<v)continue;let M=d.get(k*h+P);if(M)for(let F of M){if(F===f)continue;let O=Math.hypot(t[F].x-u.x,t[F].y-u.y);O<x&&(x=O)}}if(Number.isFinite(x)&&x<=v*c)break}n[f]=x}return n}function pi(t){let e=t.eyeHeightM;return Number.isFinite(e)?Math.max(0,e-St):0}function ao(t,e,n,i,o){let r=t.length,a=new Float32Array(r*3),s=new Float32Array(r),l=new Float32Array(r*3),c=new Float32Array(r),h=new Float32Array(r),m=new Float32Array(r),d=new Float32Array(r*3),p=new Map,f=hi(t);for(let u=0;u<r;u++){let b=t[u],x=(n?.seatPitchU(u)??f[u])*R;c[u]=Number.isFinite(x)?Math.max(.06,Math.min(Re,x*di)):Re,h[u]=no(Number.isFinite(x)?x:void 0),m[u]=b.wheelchairSpaceType==="no-seat"?0:1,a[u*3]=b.x*R,a[u*3+1]=n?n.seatDeckY(u):pi(b),a[u*3+2]=b.y*R,s[u]=ct(e?e(b):"available");let v=K(o?.get(b.categoryKey)??"#6e7bff")??[.43,.48,1];if(l[u*3]=v[0],l[u*3+1]=v[1],l[u*3+2]=v[2],b.accessibility?.length){let k=K(Cn(b.accessibility));k&&(d[u*3]=k[0],d[u*3+1]=k[1],d[u*3+2]=k[2])}p.set(b.id,u)}return{count:r,iPosition:a,iState:s,iCategory:l,iMaxRadius:c,iRing:d,idToIndex:p,iChairWidth:h,iPhysicalSeat:m,iFloor:i??new Float32Array(r),iYaw:new Float32Array(r)}}var fi=64;function an(t,e){let n=[];for(let a of e){let s=t.idToIndex.get(a.seatId);if(s===void 0)continue;let l=ct(a.state);t.iState[s]!==l&&(t.iState[s]=l,n.push(s))}if(!n.length)return[];n.sort((a,s)=>a-s);let i=[],o=n[0],r=n[0];for(let a=1;a<n.length;a++){let s=n[a];if(s!==r){if(s<=r+fi){r=s;continue}i.push({start:o,length:r-o+1}),o=s,r=s}}return i.push({start:o,length:r-o+1}),i}var bi=.15,yi=.9,xi=1.76,gi=.7,vi=1.6;function Mi(){return{background:{top:[...Ue.top],bottom:[...Ue.bottom]},structure:Kt,seatStates:{...Un},seatScale:1}}function so(t){let e=Mi();if(!t)return e;let n=K(t.background);if(n){e.background={top:pe(n,yi),bottom:pe(n,xi)};let r={};for(let[a,s]of Object.entries(Kt))r[a]=he(s,n,bi);e.structure=r}let i=K(t.selectionColor)??K(t.accent);i&&(e.seatStates={...e.seatStates,selected:i});let o=t.seatScale;return typeof o=="number"&&Number.isFinite(o)&&(e.seatScale=Math.min(vi,Math.max(gi,o))),e}function co(t,e){let n=[];for(let i of e)n.push(...t.seatStates[i]);return n}import ho from"polygon-clipping";import Si from"earcut";var wi=.58,lo=.01,fe=Re*1.5*Le,Pi=.5,Ai=.6;function Ci(t,e){let n=t.length,i=[];for(let a=0;a<n;a++){let s=t[Math.max(0,a-1)],l=t[Math.min(n-1,a+1)],c=l.x-s.x,h=l.y-s.y,m=Math.hypot(c,h);if(m<1e-9){i.push([0,0]);continue}c/=m,h/=m,i.push([-h,c])}let o=0;for(let a=0;a<n;a++)o+=(t[a].x-e.x)*i[a][0]+(t[a].y-e.y)*i[a][1];return o<0?i.map(([a,s])=>[-a,-s]):i}function Ri(t,e){if(t.length<2||e<=0)return[...t];let n=[...t],i=(a,s)=>{let l=s.x-a.x,c=s.y-a.y,h=Math.hypot(l,c)||1;return{x:l/h,y:c/h}},o=i(n[1],n[0]),r=i(n[n.length-2],n[n.length-1]);return n.unshift({x:n[0].x+o.x*e,y:n[0].y+o.y*e}),n.push({x:n[n.length-1].x+r.x*e,y:n[n.length-1].y+r.y*e}),n}var uo=Math.PI/12;function Ii(t){if(t.length<3)return[...t];let e=[...t].sort((r,a)=>r.x-a.x||r.y-a.y),n=(r,a,s)=>(a.x-r.x)*(s.y-r.y)-(a.y-r.y)*(s.x-r.x),i=r=>{let a=[];for(let s of r){for(;a.length>=2&&n(a[a.length-2],a[a.length-1],s)<=0;)a.pop();a.push(s)}return a.pop(),a},o=[...i(e),...i([...e].reverse())];return o.length>=3?o:[...t]}function po(t,e){if(!t.length||!(e>0))return[];let n=Ii(t),i=(s,l,c,h)=>{let m=c-l;for(;m<0;)m+=Math.PI*2;for(;m>Math.PI*2;)m-=Math.PI*2;let d=Math.max(1,Math.ceil(m/uo)),p=e/Math.cos(m/d/2);for(let f=0;f<=d;f++){let u=l+m*f/d;h.push({x:s.x+Math.cos(u)*p,y:s.y+Math.sin(u)*p})}};if(n.length<3){let s=0,l=0;for(let p of n)s+=p.x,l+=p.y;s/=n.length||1,l/=n.length||1;let c=0;for(let p of n)c=Math.max(c,Math.hypot(p.x-s,p.y-l));let h=[],m=Math.max(3,Math.ceil(Math.PI*2/uo)),d=(c+e)/Math.cos(Math.PI/m);for(let p=0;p<m;p++){let f=p/m*Math.PI*2;h.push({x:s+Math.cos(f)*d,y:l+Math.sin(f)*d})}return h}let o=n.length,r=[];for(let s=0;s<o;s++){let l=n[s],c=n[(s+1)%o];r.push(Math.atan2(-(c.x-l.x),c.y-l.y))}let a=[];for(let s=0;s<o;s++)i(n[s],r[(s+o-1)%o],r[s],a);return go(a)}function Ti(t,e,n){if(t.length===1)return Math.hypot(e-t[0].x,n-t[0].y);let i=1/0;for(let o=0;o+1<t.length;o++){let r=t[o],a=t[o+1],s=a.x-r.x,l=a.y-r.y,c=s*s+l*l,h=c>1e-12?((e-r.x)*s+(n-r.y)*l)/c:0;h<0?h=0:h>1&&(h=1);let m=Math.hypot(e-(r.x+h*s),n-(r.y+h*l));m<i&&(i=m)}return i}function _t(t){let e=t.map(o=>{let r=0,a=0;for(let c of o.pts)r+=c.x,a+=c.y;let s=o.pts.length||1;r/=s,a/=s;let l=0;for(let c of o.pts){let h=Math.hypot(c.x-r,c.y-a);h>l&&(l=h)}return{cx:r,cy:a,rad:l}}),n=o=>{let r=o.length;return r<=2?[...o]:[o[Math.floor(r*.25)],o[Math.floor(r*.5)],o[Math.floor(r*.75)]]},i=[];for(let o=0;o<t.length;o++){let r=n(t[o].pts),a=[],s=1/0,l=null;for(let h of r){let m=1/0;for(let d=0;d<t.length;d++){if(d===o||Math.abs(t[d].y-t[o].y)<.001)continue;let p=e[d],f=Math.hypot(h.x-p.cx,h.y-p.cy)-p.rad;if(f>=m&&f>=s)continue;let u=Ti(t[d].pts,h.x,h.y);u<m&&(m=u),t[d].depth<t[o].depth&&u<s&&(s=u,l=t[d].y)}Number.isFinite(m)&&m>0&&a.push(m)}a.sort((h,m)=>h-m);let c=a.length?a[Math.floor(a.length/2)]:1;i.push({pitch:c,belowY:l})}return i}function fo(t,e,n,i){let o=t[e],r=o.pts.length>=2?[...o.pts]:o.pts.length===1?(()=>{let h=o.pts[0],m=h.x-i.x,d=h.y-i.y,p=Math.hypot(m,d)||1;m/=p,d/=p;let f=Math.max(n[e].pitch,.001)*.5;return[{x:h.x+d*f,y:h.y-m*f},{x:h.x-d*f,y:h.y+m*f}]})():[];if(r.length<2)return null;let a=0,s=0;for(let h=1;h<r.length;h++){let m=Math.hypot(r[h].x-r[h-1].x,r[h].y-r[h-1].y);m>1e-6&&(a+=m,s++)}let l=s>0?a/s:0,c=Ri(r,Math.max(l*Ai,fe));return{pts:c,nrm:Ci(c,i),front:Math.max(n[e].pitch*wi,fe),back:Math.max(n[e].pitch*Pi,fe)}}var $e=1.5,bo=.3;function sn(t,e){if(t.length<3)return t;let n=t[0],i=t[t.length-1],o=i.x-n.x,r=i.y-n.y,a=Math.hypot(o,r),s=-1,l=-1;for(let m=1;m<t.length-1;m++){let d=t[m],p=a>1e-12?Math.abs((d.x-n.x)*r-(d.y-n.y)*o)/a:Math.hypot(d.x-n.x,d.y-n.y);p>s&&(s=p,l=m)}if(s<=e||l<0)return[n,i];let c=sn(t.slice(0,l+1),e),h=sn(t.slice(l),e);return[...c.slice(0,-1),...h]}function yo(t,e){if(t.length<4)return t;let n=sn([...t,t[0]],e);return n.pop(),n.length>=3?n:t}function xo(t,e,n){if(t.length<2)return[];let i=n??_t(t),o=new Map;for(let a=0;a<t.length;a++){let s=o.get(t[a].blockId);s?s.push(a):o.set(t[a].blockId,[a])}let r=[];for(let[,a]of o){let s=[];for(let x of a){let v=t[x].patch;v&&v.length>=3?r.push({outline:[...v],holes:[],topY:t[x].y}):s.push(x)}if(!s.length)continue;s.sort((x,v)=>t[x].depth-t[v].depth);let c=s.map(x=>fo(t,x,i,e)).filter(x=>x!==null);if(!c.length)continue;let h=(x,v)=>({x:x.pts[v].x-x.nrm[v][0]*(x.front+$e),y:x.pts[v].y-x.nrm[v][1]*(x.front+$e)}),m=(x,v)=>({x:x.pts[v].x+x.nrm[v][0]*(x.back+$e),y:x.pts[v].y+x.nrm[v][1]*(x.back+$e)}),d=c[0],p=c[c.length-1],f=[];for(let x=0;x<d.pts.length;x++)f.push(h(d,x));for(let x of c)f.push(m(x,x.pts.length-1));for(let x=p.pts.length-1;x>=0;x--)f.push(m(p,x));for(let x=c.length-1;x>=0;x--)f.push(h(c[x],0));let u=go(f),b=1/0;for(let x of s)t[x].y<b&&(b=t[x].y);if(!Number.isFinite(b))continue;if(u.length>=3&&Math.abs(He(u))>1e-6&&c.every(x=>{let v=x.pts[Math.floor(x.pts.length/2)];return st(u,v.x,v.y)})){r.push({outline:yo(u,bo),holes:[],topY:b});continue}for(let x of Fi(c))r.push({outline:x,holes:[],topY:b})}return r}function Fi(t){let e=[];for(let n of t){let i=[],o=[],r=n.front+$e,a=n.back+$e;for(let l=0;l<n.pts.length;l++){let c=n.pts[l],h=n.nrm[l];i.push([c.x-h[0]*r,c.y-h[1]*r]),o.push([c.x+h[0]*a,c.y+h[1]*a])}let s=[...i,...o.reverse()];s.length<3||(s.push(s[0]),e.push([s]))}if(!e.length)return[];try{let n=ho.union(e[0],...e.slice(1)),i=[];for(let o of n){if(!o.length||o[0].length<4)continue;let r=o[0].map(([l,c])=>({x:l,y:c})),a=r[0],s=r[r.length-1];r.length>1&&Math.abs(a.x-s.x)<1e-9&&Math.abs(a.y-s.y)<1e-9&&r.pop(),r.length>=3&&i.push(yo(r,bo))}return i}catch{return[]}}function go(t){let e=[];for(let n of t){let i=e[e.length-1];i&&Math.hypot(n.x-i.x,n.y-i.y)<1e-9||e.push(n)}for(;e.length>2&&Math.hypot(e[0].x-e[e.length-1].x,e[0].y-e[e.length-1].y)<1e-9;)e.pop();return e}var cn=class{constructor(e){this.minX=1/0;this.minY=1/0;this.maxX=-1/0;this.maxY=-1/0;this.rings=e;for(let n of e)for(let i of n)i.x<this.minX&&(this.minX=i.x),i.y<this.minY&&(this.minY=i.y),i.x>this.maxX&&(this.maxX=i.x),i.y>this.maxY&&(this.maxY=i.y)}containsAll(e){for(let n of e)if(n.x<this.minX||n.x>this.maxX||n.y<this.minY||n.y>this.maxY)return!1;for(let n of this.rings){let i=!0;for(let o of e)if(!st(n,o.x,o.y)){i=!1;break}if(i)return!0}return!1}};function mo(t,e,n,i,o,r){if(i.length<3)return;if(n.containsAll(i)){let c=[0,1,0],h=i[0];for(let m=1;m+1<i.length;m++){let d=i[m],p=i[m+1];t.tri([h.x*R,o,h.y*R],[d.x*R,o,d.y*R],[p.x*R,o,p.y*R],c,r)}return}let a=i.map(c=>[c.x,c.y]);a.push(a[0]);let s;try{s=ho.intersection([a],e)}catch{return}let l=[0,1,0];for(let c of s){if(!c.length||c[0].length<4)continue;let h=c[0],m=[],d=[];for(let f=0;f<h.length-1;f++)m.push(h[f][0],h[f][1]),d.push([h[f][0],h[f][1]]);if(d.length<3)continue;let p=Si(m,void 0,2);for(let f=0;f<p.length;f+=3){let u=d[p[f]],b=d[p[f+1]],y=d[p[f+2]];t.tri([u[0]*R,o,u[1]*R],[b[0]*R,o,b[1]*R],[y[0]*R,o,y[1]*R],l,r)}}}function vo(t,e,n,i,o,r,a){if(e.length<2)return;let s=a??_t(e),l=[0,1,0],c=r&&r.length>=3?[[...r.map(p=>[p.x,p.y]),[r[0].x,r[0].y]]]:null,h=r&&r.length>=3?new cn([[...r]]):null,m=p=>{t.setMaterial(2),p(),t.setMaterial(0)},d=p=>{t.setMaterial(3),p(),t.setMaterial(0)};for(let p=0;p<e.length;p++){let f=e[p];if(f.patch&&f.patch.length>=3){let P=[...f.patch],M=s[p].belowY??i;if(d(()=>{if(c&&h)mo(t,c,h,P,f.y,o.tread);else{let F=P[0];for(let O=1;O+1<P.length;O++){let L=P[O],H=P[O+1];t.tri([F.x*R,f.y,F.y*R],[L.x*R,f.y,L.y*R],[H.x*R,f.y,H.y*R],l,o.tread)}}}),f.y>M+lo){let F=0,O=0;for(let L of P)F+=L.x,O+=L.y;F/=P.length,O/=P.length,m(()=>{for(let L=0;L<P.length;L++){let H=P[L],_=P[(L+1)%P.length],g=_.x-H.x,w=_.y-H.y,E=Math.hypot(g,w);if(E<1e-6)continue;let C=w/E,N=-g/E;(H.x-F)*C+(H.y-O)*N<0&&(C=-C,N=-N);let S=[C,0,N],I=[H.x*R,f.y,H.y*R],T=[_.x*R,f.y,_.y*R],B=[H.x*R,M,H.y*R],A=[_.x*R,M,_.y*R];t.tri(I,T,A,S,o.riser),t.tri(I,A,B,S,o.riser)}})}continue}let u=fo(e,p,s,n);if(!u)continue;let{pts:b,nrm:y,front:x,back:v}=u,k=s[p].belowY??i;for(let P=0;P+1<b.length;P++){let M=b[P],F=b[P+1],O=y[P],L=y[P+1];if(Math.hypot(F.x-M.x,F.y-M.y)<1e-6||O[0]===0&&O[1]===0||L[0]===0&&L[1]===0)continue;let H=[(M.x-O[0]*x)*R,f.y,(M.y-O[1]*x)*R],_=[(F.x-L[0]*x)*R,f.y,(F.y-L[1]*x)*R],g=[(M.x+O[0]*v)*R,f.y,(M.y+O[1]*v)*R],w=[(F.x+L[0]*v)*R,f.y,(F.y+L[1]*v)*R];if(d(()=>{c&&h?mo(t,c,h,[{x:M.x-O[0]*x,y:M.y-O[1]*x},{x:F.x-L[0]*x,y:F.y-L[1]*x},{x:F.x+L[0]*v,y:F.y+L[1]*v},{x:M.x+O[0]*v,y:M.y+O[1]*v}],f.y,o.tread):(t.tri(H,_,w,l,o.tread),t.tri(H,w,g,l,o.tread))}),f.y>k+lo){let E=[H[0],k,H[2]],C=[_[0],k,_[2]],N=[-O[0],0,-O[1]];m(()=>{t.tri(H,_,C,N,o.riser),t.tri(H,C,E,N,o.riser)})}}}}import So from"polygon-clipping";function Ei(t,e){let n=t.eventConfigurationIds;return!n?.length||!!e&&n.includes(e)}function Mo(t,e){return t.filter(n=>n.type!=="shape"||Ei(n,e))}function wo(t,e){let n=t.focalPoint??{x:0,y:0};return t.floors?.length?t.floors.map((i,o)=>({objects:Mo(i.objects,e),focal:{x:(i.focalPoint??n).x,y:(i.focalPoint??n).y},baseHeightM:i.baseHeightM??0,index:o})):[{objects:Mo(t.objects,e),focal:n,baseHeightM:0,index:0}]}var Di={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Je(t){return Dn(t)??Di}function Po(t,e){let n=Dt(t.outline,fe),i=Je(n),o=e.filter(a=>a!==t&&a.outline&&a.outline.length>=3&&Pt(i,Je(a.outline)));if(!o.length)return[n];let r=a=>{let s=a.map(l=>[l.x,l.y]);return s.push(s[0]),s};try{let a=So.difference([r(n)],...o.map(l=>[r(l.outline)])),s=[];for(let l of a){if(!l.length)continue;let c=l[0].map(([h,m])=>({x:h,y:m}));if(c.length>1){let h=c[0],m=c[c.length-1];Math.abs(h.x-m.x)<1e-9&&Math.abs(h.y-m.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s.length?s:[n]}catch{return[n]}}function Ao(t,e){if(!e.length)return t;let n=r=>{let a=r.map(s=>[s.x,s.y]);return a.push(a[0]),a},i=e.map(r=>[n(r)]),o=[];for(let r of t){let a;try{a=So.intersection([n(r.outline)],i.flat())}catch{o.push(r);continue}for(let s of a){if(!s.length)continue;let l=s[0].map(([c,h])=>({x:c,y:h}));if(l.length>1){let c=l[0],h=l[l.length-1];Math.abs(c.x-h.x)<1e-9&&Math.abs(c.y-h.y)<1e-9&&l.pop()}l.length>=3&&o.push({outline:l,holes:[],topY:r.topY})}}return o.length?o:t}var ki=.05,Co=.05,Li=.15,ln=25;function Ro(t,e,n){let i=new Map,o=new Array(e.length).fill(null),r=new Float64Array(e.length),a=new Array(e.length).fill(void 0),s=new Array(e.length).fill(void 0),l=new Map,c=[],h=new Set;for(let m=0;m<t.length;m+=1){let d=t[m];for(let p of d.objects){if(p.type==="table"&&h.add(p.id),p.type!=="section"||!p.outline||p.outline.length<3)continue;let f=Dt(p.outline,fe);l.set(p.id,{section:p,unit:d,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),c.push({id:p.id,floorIndex:m,box:Je(f),section:p,unit:d,outline:f})}}for(let m=0;m<e.length;m++){let d=e[m];for(let p of c){if(n&&p.floorIndex!==n[m]||d.x<p.box.minX||d.x>p.box.maxX||d.y<p.box.minY||d.y>p.box.maxY||!Fn({x:d.x,y:d.y},p.outline,p.section.holes))continue;o[m]=p.id;let f=l.get(p.id);f.hasSeats=!0;let u=d.focalPoint??p.unit.focal,b=Math.hypot(d.x-u.x,d.y-u.y);b<f.frontU&&(f.frontU=b),f.seatIndices.push(m);let y=d.rowId||`__seat-${m}`,x=f.rows.get(y);x?x.push({x:d.x,y:d.y}):f.rows.set(y,[{x:d.x,y:d.y}]);break}}for(let[m,d]of l){let p=In(d.section,{floorBaseHeightM:d.unit.baseHeightM}),f=d.unit.baseHeightM,u=p.rake>0?Math.tan(p.rake*Math.PI/180):0,b=p.rake<=.01&&p.height<=f+.001,y=d.section.surfaceKind,x=y==="flat"?!0:y==="rakedRows"&&p.rake>.01?!1:b,v=d.hasSeats?Tn(m,e,d.seatIndices,d.unit.focal):{sectionId:m,rows:[],blockCount:0},P=v.rows.length<2?On([...d.rows.values()].map(S=>({points:S})),d.unit.focal):null,M=1/0;if(P){if(d.hasSeats)for(let S of d.rows.values())for(let I of S){let T=P.depthAt(I.x,I.y);T<M&&(M=T)}if(!d.hasSeats||!Number.isFinite(M)){M=1/0;for(let S of d.section.outline){let I=P.depthAt(S.x,S.y);I<M&&(M=I)}}}let F=f+ki,O=Math.max(F,p.height),L=S=>{let I=Math.max(0,S-M)*ke,T=Math.min(I*u,ln);return Math.max(F,p.height+T)},H=S=>{let I=Math.max(0,S)*ke,T=Math.min(I*u,ln);return Math.max(F,p.height+T)},_=x?[]:v.rows.map(S=>({pts:S.pts,y:H(S.blockDepth),depth:S.blockDepth,blockId:S.blockId,...h.has(S.id)?{patch:po(S.pts,fe)}:{}})),g=_.length?_[0].y:O,w=_.map(S=>{let I=S.patch&&S.patch.length>=3?S.patch:S.pts,T=0,B=0;for(let V of I)T+=V.x,B+=V.y;let A=I.length||1;T/=A,B/=A;let D=0;for(let V of I){let U=Math.hypot(V.x-T,V.y-B);U>D&&(D=U)}return{cx:T,cy:B,rad:D}}),E=x?()=>O:_.length>=2?(S,I)=>{let T=1/0,B=g;for(let A=0;A<_.length;A++){let D=w[A];if(Math.hypot(S-D.cx,I-D.cy)-D.rad>=T)continue;let V=_[A].patch,U=V&&V.length>=3?st(V,S,I)?0:wt(V,S,I):wt(_[A].pts,S,I);U<T&&(T=U,B=_[A].y)}return B}:(S,I)=>P?L(P.depthAt(S,I)):O,C=[0,1,0],N=_.length>=2||x?()=>C:(S,I)=>{if(!P)return C;let T=P.depthAt(S,I);if(T<=M)return C;let B=(T-M)*ke;if(B*u>=ln||p.height+B*u<=F)return C;let[A,D]=P.gradientAt(S,I);if(A===0&&D===0)return C;let V=1/Math.hypot(u,1);return[-A*u*V,V,-D*u*V]};if(!x)for(let S of v.rows){let I=H(S.blockDepth);for(let T of S.seatIndices)a[T]=I}for(let S of v.rows){let I=[];for(let V=1;V<S.pts.length;V++){let U=Math.hypot(S.pts[V].x-S.pts[V-1].x,S.pts[V].y-S.pts[V-1].y);U>1e-6&&I.push(U)}I.sort((V,U)=>V-U);let T=I.length?I[Math.floor(I.length/2)]:1/0,B=1/0,A=S.pts[Math.floor(S.pts.length/2)];if(A)for(let V of v.rows){if(V===S||V.blockId!==S.blockId)continue;let U=wt(V.pts,A.x,A.y);U>1e-6&&U<B&&(B=U)}let D=Math.min(T,Math.max(B,T*.5));if(Number.isFinite(D)&&D>0)for(let V of S.seatIndices)s[V]=D}i.set(m,{sectionId:m,deckAt:E,normalAt:N,flat:x,bottomY:f,rowLevels:_,landingY:g})}for(let m=0;m<e.length;m++){let d=o[m],p=e[m];if(d){let u=a[m];r[m]=(u??i.get(d).deckAt(p.x,p.y))+Li;continue}let f=p.eyeHeightM;r[m]=Number.isFinite(f)?Math.max(0,f-St):0}return{bySection:i,seatOwner:o,seatDeckY:m=>r[m],seatPitchU:m=>s[m]}}var re={top:1,wallBottom:.5,bottomCap:.4};function Ie(t,e){if(!t)return e;let n=pe(at(t,.4),.62);return he(e,n,.72)}function Io(t,e){let n=new Map;for(let r of t.categories??[])n.set(r.key,r.color);let i=new Map;for(let r of e){if(!r.sectionId)continue;let a=i.get(r.sectionId);a||(a=new Map,i.set(r.sectionId,a)),a.set(r.categoryKey,(a.get(r.categoryKey)??0)+1)}let o=new Map;for(let[r,a]of i){let s=0,l=0,c=0,h=0;for(let[m,d]of a){let p=K(n.get(m));p&&(s+=p[0]*d,l+=p[1]*d,c+=p[2]*d,h+=d)}h>0&&o.set(r,[s/h,l/h,c/h])}return o}function To(t,e){return K(t.color)??e.get(t.logicalSectionId??t.id)??null}import _i from"polygon-clipping";function Oi(t,e){return t===void 0||e===void 0?!0:Math.abs(t-e)<.001}var Ot=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(e,n){let i=e.map(l=>[l.x,l.y]);if(i.length<3)return[];i.push(i[0]);let o=Je(e),r=this.rings.filter((l,c)=>Pt(o,this.boxes[c])&&Oi(n,this.levels[c])),a=[[i]];if(r.length)try{a=_i.difference([i],...r).map(c=>c.map(h=>h.map(([m,d])=>[m,d])))}catch{a=[[i]]}this.rings.push([i]),this.boxes.push(o),this.levels.push(n);let s=[];for(let l of a){if(!l.length)continue;let c=l[0].map(([h,m])=>({x:h,y:m}));if(c.length>1){let h=c[0],m=c[c.length-1];Math.abs(h.x-m.x)<1e-9&&Math.abs(h.y-m.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s}};function Bi(t,e){if(!e)return t;let n=1/0,i=-1/0,o=1/0,r=-1/0;for(let m of t)n=Math.min(n,m.x),i=Math.max(i,m.x),o=Math.min(o,m.y),r=Math.max(r,m.y);let a=(n+i)/2,s=(o+r)/2,l=e*Math.PI/180,c=Math.cos(l),h=Math.sin(l);return t.map(m=>{let d=m.x-a,p=m.y-s;return{x:a+d*c-p*h,y:s+d*h+p*c}})}function ht(t){let e=null;if(t.kind==="polygon"&&t.points&&t.points.length>=3&&(e=t.points),t.kind==="rect"&&t.width&&t.height&&(e=dt(t.x??0,t.y??0,t.width,t.height)),t.kind==="ellipse"&&t.width&&t.height){let n=(t.x??0)+t.width/2,i=(t.y??0)+t.height/2;e=kt(n,i,t.width/2,t.height/2)}return e?Bi(e,t.rotation):null}function pt(t){let e=t.role??"",i={stage:{kind:"stage",heightM:1},entrance:{kind:"portal",heightM:2.7},exit:{kind:"portal",heightM:2.7},screen:{kind:"solid",heightM:6},wall:{kind:"solid",heightM:2.8},rail:{kind:"solid",heightM:1.1},suite:{kind:"suite",heightM:3},obstruction:{kind:"solid",heightM:4.5},sound:{kind:"solid",heightM:1.45},restroom:{kind:"solid",heightM:2.4},bar:{kind:"solid",heightM:1.1},concession:{kind:"solid",heightM:1.1},coat:{kind:"solid",heightM:1.1},goal:{kind:"portal",heightM:1.8}}[e]??{kind:"plate",heightM:.25};return{...i,heightM:t.heightM??i.heightM}}var Vi=.08;function Fo(t,e){let n=ht(t),i=pt(t),o=i.heightM;if(!n||i.kind!=="plate"&&i.kind!=="stage")return o;let r=1/0,a=1/0,s=-1/0,l=-1/0;for(let h of n)r=Math.min(r,h.x),a=Math.min(a,h.y),s=Math.max(s,h.x),l=Math.max(l,h.y);let c=o;for(let h of e)s>h.minX&&r<h.maxX&&l>h.minY&&a<h.maxY&&c<=h.topOffsetM+1e-6&&(c=h.topOffsetM+Vi);return e.push({minX:r,minY:a,maxX:s,maxY:l,topOffsetM:c}),c}function _e(t,e,n){return{x:t.x+(e.x-t.x)*n,y:t.y+(e.y-t.y)*n}}function Eo(t){if(t.length!==4)return t;let e=Math.hypot(t[1].x-t[0].x,t[1].y-t[0].y),n=Math.hypot(t[2].x-t[1].x,t[2].y-t[1].y);return e>=n?t:[t[1],t[2],t[3],t[0]]}function ft(t,e,n){return[_e(t[0],t[1],e),_e(t[0],t[1],n),_e(t[3],t[2],n),_e(t[3],t[2],e)]}function Do(t,e,n){return[_e(t[0],t[3],e),_e(t[1],t[2],e),_e(t[1],t[2],n),_e(t[0],t[3],n)]}function Te(t,e,n,i,o,r){ie(t,e,void 0,()=>n,i,o,r,re)}var un=2.4,Ni=.75,zi=.15;function bt(t){if(t.points&&t.points.length>=3)return t.points;let{center:e,width:n,height:i,rotation:o}=t;if(!n||!i)return null;let r=(o??0)*Math.PI/180,a=Math.cos(r),s=Math.sin(r),l=n/2,c=i/2;return[[-l,-c],[l,-c],[l,c],[-l,c]].map(([h,m])=>({x:e.x+h*a-m*s,y:e.y+h*s+m*a}))}function ko(t,e,n,i,o){let r=bt(e);r&&ie(t,r,void 0,()=>n+un,n,Ie(i,o.boothTop),o.boothWall,re)}function mn(t){if(t.shape==="round"){let h=t.radius;return h?kt(t.center.x,t.center.y,h,h,24):null}let{width:e,height:n,rotation:i,center:o}=t;if(!e||!n)return null;let r=(i??0)*Math.PI/180,a=Math.cos(r),s=Math.sin(r),l=e/2,c=n/2;return[[-l,-c],[l,-c],[l,c],[-l,c]].map(([h,m])=>({x:o.x+h*a-m*s,y:o.y+h*s+m*a}))}function Lo(t,e,n,i,o){let r=mn(e);r&&ie(t,r,void 0,()=>n+Ni,n,Ie(i,o.tableTop),o.tableWall,re)}function _o(t,e,n,i,o,r,a){let s=ht(e);if(!s)return;let l=e.role==="stage",c=pt(e),h=n+i;if(l&&a){let u=1/0,b=-1/0,y=1/0,x=-1/0;for(let v of s)v.x<u&&(u=v.x),v.x>b&&(b=v.x),v.y<y&&(y=v.y),v.y>x&&(x=v.y);a.push({cx:(u+b)/2*R,cz:(y+x)/2*R,y:h,halfX:Math.max((b-u)/2*R,.5),halfZ:Math.max((x-y)/2*R,.5)})}let m=K(e.fill),d=l&&m?he(o.stageTop,pe(at(m,.18),.9),.9):Ie(m,l?o.stageTop:o.decorTop),p=e.role==="screen"?m:null,f=l?m?he(o.stageWall,pe(m,.58),.82):o.stageWall:e.role==="screen"?p?he(pe(p,1.42),[.24,.46,.82],.08):[.24,.46,.82]:Ie(K(e.fill),o.decorWall);if(c.kind==="portal"&&s.length===4){let u=Eo(s);Te(t,ft(u,0,.16),h,n,d,f),Te(t,ft(u,.84,1),h,n,d,f),Te(t,u,h,Math.max(n,h-.35),d,f);return}if(c.kind==="suite"&&s.length===4){let u=s.map((x,v)=>{let k=s[(v+1)%4],P=(x.x+k.x)/2,M=(x.y+k.y)/2;return Math.hypot(P-r.x,M-r.y)}),b=u.indexOf(Math.min(...u)),y=[0,1,2,3].map(x=>s[(b+x)%4]);Te(t,ft(y,0,.08),h,n,d,f),Te(t,ft(y,.92,1),h,n,d,f),Te(t,Do(y,.88,1),h,n,d,f),Te(t,y,h,Math.max(n,h-.18),d,f);return}Te(t,s,h,n,d,f)}function dn(t){let{x:e,y:n,width:i,height:o}=t;if(!i||!o)return null;let r=e+i/2,a=n+o/2,s=(t.rotation??0)*Math.PI/180,l=Math.cos(s),c=Math.sin(s),h=i/2,m=o/2;return[[-h,-m],[h,-m],[h,m],[-h,m]].map(([d,p])=>({x:r+d*l-p*c,y:a+d*c+p*l}))}function Gi(t){if(!t||!t.startsWith("data:image/svg+xml"))return null;let e=t.slice(t.indexOf(",")+1);if(/;base64/i.test(t.slice(0,t.indexOf(","))))try{e=atob(e)}catch{return null}else try{e=decodeURIComponent(e)}catch{}let n=e.match(/<(?:rect|path)\b[^>]*\bfill="([^"]+)"/i);if(!n)return null;let i=n[1].trim();if(i==="none"||i==="transparent")return null;let o=i.match(/^url\(#([^)]+)\)$/);if(!o)return K(i);let r=e.match(new RegExp(`<(?:linear|radial)Gradient\\b[^>]*\\bid="${o[1]}"[^>]*>([\\s\\S]*?)</(?:linear|radial)Gradient>`,"i"));if(!r)return null;let a=[];for(let s of r[1].matchAll(/stop-color="([^"]+)"/gi)){let l=K(s[1].trim());l&&a.push(l)}return a.length?a.reduce((s,l,c)=>he(s,l,1/(c+1)),a[0]):null}function Oo(t,e,n,i){if(e.layer==="foreground")return;let o=dn(e);if(!o)return;let r=n+zi,a=Ie(Gi(e.href),i.decorTop),s=Math.max(0,Math.min(1,e.opacity??1));s<1&&(a=he(i.ground,a,s)),ie(t,o,void 0,()=>r,n,a,he(a,i.decorWall,.5),re)}function Bo(t,e,n,i,o){if(!e.points||e.points.length<3)return;let r=Ie(i,o.gaTop);ie(t,e.points,e.holes,()=>n+.15,n,r,o.gaWall,re)}var Hi=.25,Ui=1.2,Xi=.6,Yi=.45,Wi=2.3,ji=Math.PI/180;function Ye(t,e,n){let i=n*ji;return{x:t.x+e*Math.sin(i),y:t.y+e*Math.cos(i)}}function qi(t,e){let n=e.rings[e.rings.length-1];if(!n)return!1;let i=n.outerRMedian*.85;for(let o of t){if(o.role!=="wall")continue;let r=o.points&&o.points.length>=2?o.points:o.x!==void 0&&o.y!==void 0&&o.width!==void 0&&o.height!==void 0?[{x:o.x,y:o.y},{x:o.x+o.width,y:o.y},{x:o.x+o.width,y:o.y+o.height},{x:o.x,y:o.y+o.height}]:[];if(r.length<2)continue;let a=0;for(let s of r)Math.hypot(s.x-e.centre.x,s.y-e.centre.y)>=i&&a++;if(a>=r.length/2)return!0}return!1}var Zi=24;function Ki(t,e,n,i,o,r,a,s){let l=n.binCount,c=Zi,h=ke,m=r+.02,d=[];for(let g=0;g<l;g++){let w=(n.startBin+g+.5)*e.binStepDeg,E=new Float64Array(c+1);for(let C=0;C<=c;C++){let N=i[g]+(o[g]-i[g])*C/c;E[C]=Math.max(m,Vn(e,n,w,N)-Hi)}d.push(E)}let p=[a.bandTop[0]*s.top,a.bandTop[1]*s.top,a.bandTop[2]*s.top],f=[a.bandTop[0]*s.bottomCap,a.bandTop[1]*s.bottomCap,a.bandTop[2]*s.bottomCap],u=[a.bandWall[0]*s.top,a.bandWall[1]*s.top,a.bandWall[2]*s.top],b=[a.bandWall[0]*s.wallBottom,a.bandWall[1]*s.wallBottom,a.bandWall[2]*s.wallBottom],y=(g,w)=>{let E=(n.startBin+g+.5)*e.binStepDeg,C=i[g]+(o[g]-i[g])*w/c,N=Ye(e.centre,C,E);return[N.x*h,d[g][w],N.y*h]};{let g=Math.tan(12*Math.PI/180);for(let w=0;w<6;w++){let E=!1;for(let N=0;N<l;N++)for(let S=c-1;S>=0;S--)d[N][S]>d[N][S+1]&&(d[N][S]=d[N][S+1],E=!0);let C=n.closed?l:l-1;for(let N=0;N<C;N++){let S=(N+1)%l;for(let I=0;I<=c;I++){let T=d[S][I]-d[N][I];if(Math.abs(T)>1)continue;let B=i[N]+(o[N]-i[N])*I/c,A=i[S]+(o[S]-i[S])*I/c,D=Ye(e.centre,B,(n.startBin+N+.5)*e.binStepDeg),V=Ye(e.centre,A,(n.startBin+S+.5)*e.binStepDeg),U=g*Math.hypot(V.x-D.x,V.y-D.y)*h;T>U?(d[S][I]=d[N][I]+U,E=!0):-T>U&&(d[N][I]=d[S][I]+U,E=!0)}}if(!E)break}}let x=1,v=(g,w)=>{for(let E=0;E<=c;E+=4)if(Math.abs(d[g][E]-d[w][E])>x)return!0;return Math.abs(d[g][c]-d[w][c])>x},k=Math.tan(38*Math.PI/180),P=g=>(o[g]-i[g])/c*h,M=(g,w)=>d[g][w+1]-d[g][w]>k*Math.max(1e-6,P(g)),F=(g,w)=>{let E=n.closed?(g-1+l)%l:Math.max(0,g-1),C=n.closed?(g+1)%l:Math.min(l-1,g+1);Math.abs(d[E][w]-d[g][w])>x&&(E=g),Math.abs(d[C][w]-d[g][w])>x&&(C=g);let N=Math.max(0,w-1),S=Math.min(c,w+1);N<w&&M(g,N)&&(N=w),S>w&&M(g,w)&&(S=w);let I=y(E,w),T=y(C,w),B=y(g,N),A=y(g,S),D=T[0]-I[0],V=T[1]-I[1],U=T[2]-I[2],Y=A[0]-B[0],X=A[1]-B[1],j=A[2]-B[2],Z=V*j-U*X,te=U*Y-D*j,ne=D*X-V*Y,Q=Math.hypot(Z,te,ne);return Q>1e-12?(Z/=Q,te/=Q,ne/=Q,te<0&&(Z=-Z,te=-te,ne=-ne),[Z,te,ne]):[0,1,0]},O=(g,w)=>{let E=[g[0],r,g[2]],C=[w[0],r,w[2]],N=w[0]-g[0],S=w[2]-g[2],I=Math.hypot(N,S);if(!(I>1e-12))return;let T=[S/I,0,-N/I];t.tri(g,w,C,T,u,u,b),t.tri(g,C,E,T,u,b,b)},L=.05*Le,H=g=>o[g]-i[g]<L,_=n.closed?l:l-1;for(let g=0;g<_;g++){let w=(g+1)%l;if(H(g)||H(w))continue;if(v(g,w)){let T=(n.startBin+g+1)*e.binStepDeg,B=(X,j)=>{let Z=(i[g]+i[w])/2,te=(o[g]+o[w])/2,ne=Z+(te-Z)*j/c,Q=Ye(e.centre,ne,T);return[Q.x*h,d[X][j],Q.y*h]};for(let X=0;X<c;X++){let j=y(g,X),Z=y(g,X+1),te=B(g,X),ne=B(g,X+1),Q=F(g,X),ae=F(g,X+1);t.triN(j,te,ne,Q,Q,ae,p),t.triN(j,ne,Z,Q,ae,ae,p);let Be=y(w,X),Ve=y(w,X+1),Se=B(w,X),we=B(w,X+1),Pe=F(w,X),ye=F(w,X+1);t.triN(Se,Be,Ve,Pe,Pe,ye,p),t.triN(Se,Ve,we,Pe,ye,ye,p);let xe=B(g,X),oe=B(g,X+1),qe=B(w,X+1),Fe=B(w,X),Ae=oe[0]-xe[0],Ne=oe[2]-xe[2],nt=Math.hypot(Ae,Ne);if(nt>1e-12){let me=[Ne/nt,0,-Ae/nt];t.tri(xe,oe,qe,me,u),t.tri(xe,qe,Fe,me,u)}}let A=y(g,0),D=y(w,0),V=y(w,c),U=y(g,c),Y=X=>[X[0],r,X[2]];t.tri(Y(A),Y(V),Y(D),[0,-1,0],f),t.tri(Y(A),Y(U),Y(V),[0,-1,0],f),O(A,D),O(U,V);continue}for(let T=0;T<c;T++){let B=F(g,T),A=F(w,T),D=F(w,T+1),V=F(g,T+1);if(M(g,T)||M(w,T)){let Z=(oe,qe)=>{let Fe=(n.startBin+oe+.5)*e.binStepDeg,Ae=i[oe]+(o[oe]-i[oe])*(T+.5)/c,Ne=Ye(e.centre,Ae,Fe);return[Ne.x*h,qe,Ne.y*h]},te=y(g,T),ne=y(w,T),Q=Z(g,d[g][T]),ae=Z(w,d[w][T]);t.triN(te,ne,ae,B,A,A,p),t.triN(te,ae,Q,B,A,B,p);let Be=y(w,T+1),Ve=y(g,T+1),Se=Z(g,d[g][T+1]),we=Z(w,d[w][T+1]);t.triN(Se,we,Be,V,D,D,p),t.triN(Se,Be,Ve,V,D,V,p);let Pe=ae[0]-Q[0],ye=ae[2]-Q[2],xe=Math.hypot(Pe,ye);if(xe>1e-12){let oe=[-ye/xe,0,Pe/xe];t.tri(Q,ae,we,oe,u),t.tri(Q,we,Se,oe,u)}continue}let U=y(g,T),Y=y(w,T),X=y(w,T+1),j=y(g,T+1);t.triN(U,Y,X,B,A,D,p),t.triN(U,X,j,B,D,V,p)}let E=y(g,0),C=y(w,0),N=y(w,c),S=y(g,c),I=T=>[T[0],r,T[2]];t.tri(I(E),I(N),I(C),[0,-1,0],f),t.tri(I(E),I(S),I(N),[0,-1,0],f),O(E,C),O(S,N)}if(!n.closed)for(let g of[0,l-1])for(let w=0;w<c;w++)O(y(g,w),y(g,w+1))}function Vo(t,e,n){let{bottomY:i,colors:o,ao:r}=n,a=new Float64Array(e.binCount).fill(-1/0);for(let h of e.rings)for(let m of h.arcs){let d=new Float64Array(m.binCount),p=new Float64Array(m.binCount);for(let u=0;u<m.binCount;u++){let b=(m.startBin+u)%e.binCount,y=Math.max(0,m.innerR[u]-fe);d[u]=Math.max(y,a[b]+.001),p[u]=Math.max(d[u]+.001,m.outerR[u]+fe)}let f=0;for(let u=0;u<m.binCount;u++){let b=m.topLevelM[u]-i;b>f&&(f=b)}f>=Ui&&Ki(t,e,m,d,p,i,o,r);for(let u=0;u<m.binCount;u++){let b=(m.startBin+u)%e.binCount;p[u]>a[b]&&(a[b]=p[u])}}if(qi(n.shapes,e))return;let s=e.rings[e.rings.length-1],l=Xi*Le,c=Yi*Le;for(let h of s.arcs){let m=[],d=[];for(let u=0;u<h.binCount;u++){let b=(h.startBin+u+.5)*e.binStepDeg,y=h.outerR[u]+fe+l;m.push(Ye(e.centre,y,b)),d.push(Ye(e.centre,y+c,b))}let p=-1/0;for(let u=0;u<h.binCount;u++)h.topLevelM[u]>p&&(p=h.topLevelM[u]);let f=()=>p+Wi;h.closed?ie(t,d,[m.slice().reverse()],f,i,o.shellTop,o.shellWall,r):ie(t,[...d,...m.slice().reverse()],void 0,f,i,o.shellTop,o.shellWall,r)}}function No(t,e,n,i,o,r,a,s){if(!e.outline||e.outline.length<3)return;let l=n.baseHeightM,c=Ie(i,s.tierTop);if(!o)return;let h=b=>o.deckAt(b.x,b.y),m=Po(e,a),d=m[0]??e.outline;if(o.rowLevels.length>=2){let b=_t(o.rowLevels),y=Ao(xo(o.rowLevels,n.focal,b),m),x=()=>[0,1,0];for(let k of y){let P=Math.max(l,k.topY-.02);for(let M of r.subtract(k.outline,P))ie(t,M,k.holes,()=>P,l,c,s.tierWall,re,void 0,x)}y.length||ie(t,d,e.holes,()=>o.landingY,l,c,s.tierWall,re);let v={tread:[c[0]*re.top,c[1]*re.top,c[2]*re.top],riser:[c[0]*.72,c[1]*.72,c[2]*.72]};for(let k of m.length?m:[d])vo(t,o.rowLevels,n.focal,o.landingY,v,k,b);return}let p=o.flat?1/0:Co,f=b=>o.normalAt(b.x,b.y),u=o.flat?o.landingY:void 0;for(let b of r.subtract(d,u))ie(t,b,e.holes,h,l,c,s.tierWall,re,p,f)}function Qi(t,e,n){let i=new Set;for(let a of t.objects)a.type==="section"&&i.add(a.id);let o=new Map;for(let a=0;a<e.length;a++){let s=n.seatOwner[a];if(!s||!i.has(s))continue;let l=n.bySection.get(s);if(l&&l.rowLevels.length>=2)continue;let c=e[a],h=o.get(s);h||(h=new Map,o.set(s,h));let m=c.rowId||`__seat-${a}`,d=h.get(m);d||(d={pts:[],levelM:0,n:0},h.set(m,d)),d.pts.push({x:c.x,y:c.y}),d.levelM+=n.seatDeckY(a),d.n++}let r=[];for(let a of t.objects){if(a.type!=="section")continue;let s=n.bySection.get(a.id);if(s&&s.rowLevels.length>=2){let c=s.rowLevels.filter(h=>!h.patch).map(h=>({pts:h.pts,levelM:h.y}));c.length>=2&&r.push({sectionId:a.id,rows:c});continue}let l=o.get(a.id);l&&r.push({sectionId:a.id,rows:[...l.values()].map(c=>({pts:c.pts,levelM:c.levelM/c.n}))})}return r}function zo(t,e,n,i,o){let r=Qi(e,n,i);if(!r.length)return;let a=Bn(r,e.focal);a&&(t.setMaterial(0),Vo(t,a,{bottomY:e.baseHeightM,colors:{bandTop:pe(o.tierTop,.8),bandWall:o.tierWall,shellTop:pe(o.tierWall,1.15),shellWall:o.tierWall},ao:re,shapes:e.objects.filter(s=>s.type==="shape")}))}function Go(t,e,n){return n<0?e>1?t.filter(i=>i.kind==="floor"):[...t]:t.filter(i=>i.floorIndex===void 0||i.floorIndex===n)}function Ho(t,e){let n=[...t].sort((o,r)=>o.screen.y-r.screen.y),i=[];for(let o of n){let r=i.find(a=>a.some(s=>Math.abs(s.screen.x-o.screen.x)<104&&Math.abs(s.screen.y-o.screen.y)<34));r?r.push(o):i.push([o])}return i.flatMap(o=>o.length<2?o:o.map((r,a)=>({...r,screen:{...r.screen,x:Math.max(54,Math.min(e-54,r.screen.x+(a-(o.length-1)/2)*104))}})))}var $i=1.15,Ji=3.25,ea=4.5,ta=.85,na=.5,oa=.26;function Uo(t,e,n){let i=Math.max(1e-6,e),o=t/i,r=n?.hasZoneLabels??!0,a=new Set;return o>=.75&&a.add("floor"),o>=$i&&a.add("zone"),o<=(r?Ji:ea)&&(a.add("section"),a.add("ga")),o<=ta&&(a.add("annotation"),a.add("booth")),o<=na&&a.add("row"),o<=oa&&a.add("seat"),a}function Oe(t,e,n,i){let o=t,r=e[0],a=e[1],s=e[2],l=o[0]*r+o[4]*a+o[8]*s+o[12],c=o[1]*r+o[5]*a+o[9]*s+o[13],h=o[2]*r+o[6]*a+o[10]*s+o[14],m=o[3]*r+o[7]*a+o[11]*s+o[15];if(!(m>1e-6))return{x:0,y:0,depth:1/0,visible:!1};let d=l/m,p=c/m,f=h/m,u=d>=-1.05&&d<=1.05&&p>=-1.05&&p<=1.05&&f<=1;return{x:(d*.5+.5)*n,y:(1-(p*.5+.5))*i,depth:f,visible:u}}function Xo(t,e,n=e){let i=[],o=[...t].sort((r,a)=>r.screen.depth-a.screen.depth);for(let r of o){let a=!1;for(let s of i){let l=Math.abs(r.screen.x-s.screen.x),c=Math.abs(r.screen.y-s.screen.y);if(l<e&&c<n){a=!0;break}}a||i.push(r)}return i}var Yo={row:8,seat:14};function Wo(t,e,n,i){let o=Math.max(1,Math.min(n,i)*.5),r=Math.min(2,Math.hypot(t.x-n/2,t.y-i/2)/o);return e*(1+1.5*r)}function jo(t,e,n,i){let o=[...t].sort((a,s)=>(s.priority??0)-(a.priority??0)||a.focus-s.focus),r=[];for(let a of o){if(r.length>=i)break;let s=!1;for(let l of r)if(Math.abs(a.screen.x-l.screen.x)<e&&Math.abs(a.screen.y-l.screen.y)<n){s=!0;break}s||r.push(a)}return r}var ra=6,ia=2.2,qo=.1,aa=.3,sa=1.8,ca=.9,la=.55,ua=6e3;function Zo(t){let{doc:e,units:n,seats:i,surfaces:o,focal:r}=t,a=e.zones??[],s=[];if(a.length){let l=new Map;for(let h of n)for(let m of h.objects)m.type==="section"&&m.zone&&l.set(m.id,m.zone);let c=new Map;for(let h=0;h<i.length;h++){let m=i[h],d=o.seatOwner[h],p=m.zoneId??(d?l.get(d):void 0);if(!p)continue;let f=c.get(p);f||(f={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},c.set(p,f)),f.n++,m.x<f.minX&&(f.minX=m.x),m.y<f.minY&&(f.minY=m.y),m.x>f.maxX&&(f.maxX=m.x),m.y>f.maxY&&(f.maxY=m.y),f.sumY+=o.seatDeckY(h)}for(let h of a){let m=c.get(h.id),d=[];for(let[p,f]of l)f===h.id&&d.push(p);if(!m||m.n===0){s.push({id:h.id,label:h.label,color:K(h.color),sectionIds:d,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(h.focalPoint??r).x*R,1.5,(h.focalPoint??r).y*R]});continue}s.push({id:h.id,label:h.label,color:K(h.color),sectionIds:d,seatCount:m.n,center:[(m.minX+m.maxX)/2*R,m.sumY/m.n,(m.minY+m.maxY)/2*R],radius:.5*Math.hypot((m.maxX-m.minX)*R,(m.maxY-m.minY)*R)||1,focalWorld:[(h.focalPoint??r).x*R,1.5,(h.focalPoint??r).y*R]})}}return s}function Ko(t){let{doc:e,units:n,seats:i,surfaces:o,seatData:r,hintedSeatFloor:a,zones:s,focal:l}=t,c=[],h=[],m=[];for(let d of s)d.seatCount!==0&&c.push({id:`zone:${d.id}`,kind:"zone",text:d.label,anchor:[d.center[0],d.center[1]+ra,d.center[2]],color:e.zones?.find(p=>p.id===d.id)?.color});{let d=new Map,p=new Map;for(let f=0;f<i.length;f++){let u=o.seatOwner[f];if(!u)continue;let b=d.get(u);b||(b={n:0,x:0,y:0,deck:0},d.set(u,b)),b.n++,b.x+=i[f].x,b.y+=i[f].y,b.deck+=o.seatDeckY(f);let y=p.get(u);y||(y={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0},p.set(u,y)),i[f].x<y.minX&&(y.minX=i[f].x),i[f].x>y.maxX&&(y.maxX=i[f].x),i[f].y<y.minY&&(y.minY=i[f].y),i[f].y>y.maxY&&(y.maxY=i[f].y)}for(let f of n)for(let u of f.objects){if(u.type!=="section")continue;let b=d.get(u.id);if(!b||b.n===0)continue;let y=p.get(u.id),x=[b.x/b.n*R,b.deck/b.n,b.y/b.n*R],v=u.displayLabel||u.label||u.id;h.push({id:u.id,floorIndex:f.index,label:v,seatCount:b.n,center:x,radius:Math.max(1,Math.hypot(y.maxX-y.minX,y.maxY-y.minY)*.5*R),focalWorld:[f.focal.x*R,f.baseHeightM+1.5,f.focal.y*R]});let k=e.floors?.[f.index]?.name?.trim().toLocaleLowerCase();n.length>1&&k===v.trim().toLocaleLowerCase()||c.push({id:`section:${u.id}`,kind:"section",text:v,anchor:[x[0],x[1]+ia,x[2]],floorIndex:f.index})}}{for(let f of n)for(let u of f.objects){if(u.type!=="gaArea")continue;let b=it(u.points);if(!b)continue;let y=u.displayLabel||u.label||u.id;c.push({id:`ga:${u.id}`,kind:"ga",text:u.capacity>0?`${y} \xB7 ${u.capacity.toLocaleString()}`:y,anchor:[b.x*R,f.baseHeightM+sa,b.y*R],floorIndex:f.index})}let d=new Map;for(let f=0;f<i.length;f++){let u=i[f],b=Math.hypot(u.x-l.x,u.y-l.y),y=d.get(u.rowId);(!y||b>y.far)&&d.set(u.rowId,{seat:u,index:f,far:b})}for(let[f,u]of d){let b=u.seat.label?u.seat.label.lastIndexOf("-"):-1,y=b>0?u.seat.label.slice(0,b):f;y&&c.push({id:`row:${f}`,kind:"row",text:y,anchor:[u.seat.x*R,o.seatDeckY(u.index)+ca,u.seat.y*R],floorIndex:a[u.index]})}let p=new Map;for(let f=0;f<i.length;f++){let u=i[f],b=u.label?u.label.lastIndexOf("-"):-1,y=p.get(u.rowId);y||(y={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:b>0?u.label.slice(0,b):u.rowId,sectionId:u.sectionId},p.set(u.rowId,y));let x=f*3,v=r.iPosition[x],k=r.iPosition[x+1],P=r.iPosition[x+2];y.n++,y.x+=v,y.y+=k,y.z+=P,y.minX=Math.min(y.minX,v),y.maxX=Math.max(y.maxX,v),y.minZ=Math.min(y.minZ,P),y.maxZ=Math.max(y.maxZ,P)}for(let[f,u]of p)m.push({id:f,label:u.label,sectionId:u.sectionId,seatCount:u.n,center:[u.x/u.n,u.y/u.n,u.z/u.n],radius:Math.max(.8,Math.hypot(u.maxX-u.minX,u.maxZ-u.minZ)*.5)});if(i.length<=ua)for(let f=0;f<i.length;f++){let u=i[f],b=u.displayLabel||u.label;b&&c.push({id:`seat:${u.id}`,kind:"seat",text:b,anchor:[u.x*R,o.seatDeckY(f)+la,u.y*R],floorIndex:a[f]})}}for(let d of n)for(let p of d.objects)if(p.type==="shape"&&p.role&&["entrance","exit","screen","suite","obstruction"].includes(p.role)){let f=ht(p),u=f?it(f):null;if(!u||!p.label)continue;c.push({id:`architecture:${p.id}`,kind:"annotation",text:p.label,anchor:[u.x*R,d.baseHeightM+pt(p).heightM+qo,u.y*R],color:p.fill,floorIndex:d.index})}else if(p.type==="text"){if(!p.text)continue;c.push({id:`text:${p.id}`,kind:"annotation",text:p.text,anchor:[p.position.x*R,d.baseHeightM+qo,p.position.y*R],color:p.color,rotation:p.rotation,floorIndex:d.index})}else if(p.type==="booth"){let f=bt(p);if(!f)continue;let u=it(f);if(!u)continue;c.push({id:`booth:${p.id}`,kind:"booth",text:p.displayLabel||p.label||p.id,anchor:[u.x*R,d.baseHeightM+un+aa,u.y*R],floorIndex:d.index})}return{labels:c,sections:h,rows:m}}function Qo(t,e){if(e.length>1)for(let n of e)t.push({id:`floor:${n.id}`,kind:"floor",text:n.label,anchor:[n.center[0],n.box.max[1]+1.2,n.center[2]],floorIndex:n.index})}function $o(t){let{doc:e,units:n,seats:i,surfaces:o,solids:r,hintedSeatFloor:a,seatFloor:s}=t,l=[];{let c=n.map(()=>({minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}));for(let d=0;d<r.floor.length;d+=1){let p=Math.max(0,Math.min(n.length-1,Math.round(r.floor[d]))),f=d*3,u=c[p];u.minX=Math.min(u.minX,r.position[f]),u.minY=Math.min(u.minY,r.position[f+1]),u.minZ=Math.min(u.minZ,r.position[f+2]),u.maxX=Math.max(u.maxX,r.position[f]),u.maxY=Math.max(u.maxY,r.position[f+1]),u.maxZ=Math.max(u.maxZ,r.position[f+2])}let h=new Map;for(let d=0;d<n.length;d++)for(let p of n[d].objects)p.type==="section"&&h.set(p.id,d);let m=n.map(()=>({n:0,minX:1/0,minY:1/0,minDeck:1/0,maxX:-1/0,maxY:-1/0,maxDeck:-1/0,sumX:0,sumDeck:0,sumZ:0}));for(let d=0;d<i.length;d++){let p=o.seatOwner[d],f=(p!==null?h.get(p):void 0)??a[d];if(f===void 0)continue;let u=m[f],b=i[d];u.n++,b.x<u.minX&&(u.minX=b.x),b.y<u.minY&&(u.minY=b.y),b.x>u.maxX&&(u.maxX=b.x),b.y>u.maxY&&(u.maxY=b.y);let y=o.seatDeckY(d);u.sumX+=b.x*R,u.sumDeck+=y,u.sumZ+=b.y*R,u.minDeck=Math.min(u.minDeck,y),u.maxDeck=Math.max(u.maxDeck,y+1.6),s[d]=f}for(let d=0;d<n.length;d++){let p=m[d],f=e.floors?.[d],u=c[d],b=Math.min(p.n?p.minX*R:n[d].focal.x*R-1,Number.isFinite(u.minX)?u.minX:1/0),y=Math.max(p.n?p.maxX*R:n[d].focal.x*R+1,Number.isFinite(u.maxX)?u.maxX:-1/0),x=Math.min(p.n?p.minY*R:n[d].focal.y*R-1,Number.isFinite(u.minZ)?u.minZ:1/0),v=Math.max(p.n?p.maxY*R:n[d].focal.y*R+1,Number.isFinite(u.maxZ)?u.maxZ:-1/0),k=Math.min(p.n?Math.min(n[d].baseHeightM,p.minDeck):n[d].baseHeightM,Number.isFinite(u.minY)?u.minY:1/0),P=Math.max(p.n?Math.max(p.maxDeck,k+.5):k+.5,Number.isFinite(u.maxY)?u.maxY:-1/0),M=[p.n?p.sumX/p.n:(b+y)/2,p.n?p.sumDeck/p.n:(k+P)/2,p.n?p.sumZ/p.n:(x+v)/2],F=Math.max(1,.5*Math.hypot(y-b,P-k,v-x));l.push({index:d,id:f?.id??`floor-${d}`,label:f?.name??(n.length>1?`Floor ${d+1}`:"Venue"),seatCount:p.n,center:M,radius:F,box:{min:[b,k,x],max:[y,P,v]},focalWorld:[n[d].focal.x*R,n[d].baseHeightM+1.5,n[d].focal.y*R]})}}return l}function hn(t,e){let n=1/0,i=1/0,o=-1/0,r=-1/0,a=(s,l)=>{s<n&&(n=s),l<i&&(i=l),s>o&&(o=s),l>r&&(r=l)};for(let s of e)a(s.x,s.y);for(let s of t)for(let l of s.objects)if(l.type==="section")for(let c of l.outline)a(c.x,c.y);else if(l.type==="shape"&&l.points)for(let c of l.points)a(c.x,c.y);else if(l.type==="gaArea")for(let c of l.points)a(c.x,c.y);else if(l.type==="booth"){let c=bt(l);if(c)for(let h of c)a(h.x,h.y)}else if(l.type==="table"){let c=mn(l);if(c)for(let h of c)a(h.x,h.y)}else if(l.type==="decorImage"){let c=dn(l);if(c)for(let h of c)a(h.x,h.y)}return Number.isFinite(n)||(n=-100,i=-100,o=100,r=100),{minX:n,minY:i,maxX:o,maxY:r}}function Jo(t,e,n,i,o,r){if(e.length===1){let a=Math.max(60,(o.maxX-o.minX+o.maxY-o.minY)*.06),s=dt(o.minX-a,o.minY-a,o.maxX-o.minX+a*2,o.maxY-o.minY+a*2);ie(t,s,void 0,()=>0,-.4,r.ground,r.ground,re)}else{let a=e.reduce((p,f)=>f.baseHeightM<p.baseHeightM?f:p);t.setFloor(a.index);let s=n.filter((p,f)=>i[f]===a.index),l=hn([a],s),c=Math.hypot(l.maxX-l.minX,l.maxY-l.minY),h=Math.max(28,Math.min(80,c*.04)),m=dt(l.minX-h,l.minY-h,l.maxX-l.minX+h*2,l.maxY-l.minY+h*2),d=a.baseHeightM-.03;ie(t,m,void 0,()=>d,d-.22,r.ground,r.ground,re)}}function er(t,e,n){let{cx:i,cz:o,radius:r}=n,a=1/0,s=1/0,l=1/0,c=-1/0,h=-1/0,m=-1/0,d=(u,b,y)=>{a=Math.min(a,u),c=Math.max(c,u),s=Math.min(s,b),h=Math.max(h,b),l=Math.min(l,y),m=Math.max(m,y)};for(let u=0;u<t.position.length;u+=3)d(t.position[u],t.position[u+1],t.position[u+2]);for(let u=0;u<e.count;u++){let b=u*3,y=e.iPosition[b],x=e.iPosition[b+1],v=e.iPosition[b+2],k=Math.max(.35,e.iMaxRadius[u]??.35);d(y-k,x,v-k),d(y+k,x+1.6,v+k)}Number.isFinite(a)||(a=i-r,c=i+r,s=0,h=r*.16,l=o-r,m=o+r);let p=[(a+c)/2,(s+h)/2,(l+m)/2],f=Math.max(1,.5*Math.hypot(c-a,h-s,m-l));return{center:p,radius:f,minY:s,maxY:h}}function tr(t,e,n,i,o,r){let a=1/0,s=1/0,l=-1/0,c=-1/0;for(let k=0;k<t.count;k++){let P=k*3,M=t.iPosition[P],F=t.iPosition[P+2];M<a&&(a=M),M>l&&(l=M),F<s&&(s=F),F>c&&(c=F)}for(let k of e)a=Math.min(a,k.cx-k.halfX),l=Math.max(l,k.cx+k.halfX),s=Math.min(s,k.cz-k.halfZ),c=Math.max(c,k.cz+k.halfZ);let h=n.minX*R,m=n.maxX*R,d=n.minY*R,p=n.maxY*R,f=h,u=m,b=d,y=p;if(Number.isFinite(a)){let k=Math.max(2,.06*Math.hypot(l-a,c-s));f=Math.max(h,a-k),u=Math.min(m,l+k),b=Math.max(d,s-k),y=Math.min(p,c+k)}let x=Math.min(0,i),v=Math.max(o,r*.05);return{min:[f,x,b],max:[u,v,y]}}function yt(t){let{doc:e}=t,n=so(e.theme),i=n.structure,o=wo(e,t.eventConfigurationId??e.eventConfigurationId),r=t.seats,a=new Et,s=new Map;for(let g of o)for(let w of g.objects)s.set(w.id,g.index),w.type==="section"&&s.set(w.logicalSectionId??w.id,g.index);let l=r.map(g=>s.get(g.sectionId??"")??s.get(g.rowId??"")??0),c=hn(o,r);Jo(a,o,r,l,c,i);let h=Io(e,r),m=new Map;for(let g of e.categories??[])m.set(g.key,g.color);let d=[],p=Ro(o,r,l),f=new Float32Array(r.length);for(let g=0;g<o.length;g++){let w=o[g];a.setFloor(g);let E=new Ot,C=[],N=w.objects.filter(S=>S.type==="section"&&!!S.outline&&S.outline.length>=3);for(let S of w.objects)S.type==="section"?No(a,S,w,To(S,h),p.bySection.get(S.id),E,N,i):S.type==="shape"?(a.setMaterial(S.role==="screen"?1:0),_o(a,S,w.baseHeightM,Fo(S,C),i,w.focal,d),a.setMaterial(0)):S.type==="gaArea"?Bo(a,S,w.baseHeightM,K(m.get(S.categoryKey)),i):S.type==="booth"?ko(a,S,w.baseHeightM,K(m.get(S.categoryKey)),i):S.type==="table"?Lo(a,S,w.baseHeightM,K(m.get(S.categoryKey)),i):S.type==="decorImage"&&Oo(a,S,w.baseHeightM,i);zo(a,w,r,p,i)}let u=o.length>1?{x:o.reduce((g,w)=>g+w.focal.x,0)/o.length,y:o.reduce((g,w)=>g+w.focal.y,0)/o.length}:e.focalPoint??{x:(c.minX+c.maxX)/2,y:(c.minY+c.maxY)/2},b=to([a.build()]),y=ao(r,t.initialState,p,f,m),x=Zo({doc:e,units:o,seats:r,surfaces:p,focal:u}),{labels:v,sections:k,rows:P}=Ko({doc:e,units:o,seats:r,surfaces:p,seatData:y,hintedSeatFloor:l,zones:x,focal:u}),M=$o({doc:e,units:o,seats:r,surfaces:p,solids:b,hintedSeatFloor:l,seatFloor:f});Qo(v,M),y.iYaw=ro(y.iPosition,r.length,g=>r[g].rowId,g=>{let w=o[f[g]]?.focal??u;return[w.x*R,w.y*R]});let F=(c.minX+c.maxX)/2*R,O=(c.minY+c.maxY)/2*R,L=.5*Math.hypot((c.maxX-c.minX)*R,(c.maxY-c.minY)*R)||10,H=er(b,y,{cx:F,cz:O,radius:L}),_=tr(y,d,c,H.minY,H.maxY,L);return{solids:b,seats:y,bounds:{center:[(_.min[0]+_.max[0])/2,(_.min[1]+_.max[1])/2,(_.min[2]+_.max[2])/2],radius:L,groundY:0,box:_},renderBounds:{center:H.center,radius:H.radius},stateColorLUT:co(n,be),theme:n,seatCount:r.length,focalWorld:[u.x*R,1.5,u.y*R],zones:x,stages:d,sections:k,rows:P,labels:v,floors:M}}var ma=88,da=20,ha={floor:{size:14,weight:"700",opacity:.98},zone:{size:15,weight:"600",opacity:.95},section:{size:12,weight:"500",opacity:.88},ga:{size:12,weight:"500",opacity:.88},booth:{size:11,weight:"500",opacity:.85},annotation:{size:11,weight:"400",opacity:.75},row:{size:10.5,weight:"600",opacity:.8},seat:{size:9.5,weight:"500",opacity:.72}},pn=new Set(["row","seat"]),nr={floor:5,zone:4,section:3,ga:3,booth:2,annotation:1},or={row:{x:62,y:16},seat:{x:46,y:18}},ir=K,fn=t=>En(t);function ar(t,e){let n=fn(t),i=fn(e);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function rr(t,e){let n=/rgba\((\d+),(\d+),(\d+),([\d.]+)\)/.exec(t.replace(/\s/g,""));if(!n)return e;let i=Math.max(0,Math.min(1,Number(n[4])));return[1,2,3].map(o=>Number(n[o])/255*i+e[o-1]*(1-i))}function pa(t,e=[.04,.06,.1]){let n=fn(e)<.42,i=n?"#f4f7fb":"#0b1220",o=ir(t),r=o&&ar(o,e)>=4.5?t:i;return n?{ink:r,backing:"rgba(8,12,22,.78)",border:"rgba(210,222,245,.24)"}:{ink:r,backing:"rgba(255,255,255,.84)",border:"rgba(11,18,32,.22)"}}var Bt=class{constructor(e,n={}){this.nodes=new Map;this.labels=[];this.forcedDense=!1;this.selectedSeatLabelIds=new Set;this.opts=n,this.root=document.createElement("div"),this.root.setAttribute("data-view3d-labels","");let i=this.root.style;i.position="absolute",i.inset="0",i.pointerEvents="none",i.overflow="hidden",n.fontFamily&&(i.fontFamily=n.fontFamily),e.appendChild(this.root)}setVisible(e){this.root.style.visibility=e?"":"hidden"}setLabels(e){this.labels=e;for(let[n,i]of this.nodes)e.some(o=>o.id===n)||(i.remove(),this.nodes.delete(n))}setForcedDense(e){this.forcedDense=e}setSelectedSeatIds(e){this.selectedSeatLabelIds=new Set(Array.from(e,n=>`seat:${n}`))}qualityEvidence(){let e=this.root.getBoundingClientRect(),n=this.root.style.visibility!=="hidden";return this.labels.map(i=>{let o=this.nodes.get(i.id),r=o?.getBoundingClientRect(),a=!!(n&&o&&o.style.display!=="none"&&r&&r.width>0&&r.height>0);return{id:i.id,kind:i.kind,text:i.text,visible:a,renderedFontPx:o&&Number.parseFloat(o.style.fontSize)||0,contrast:o?Number(o.dataset.qualityContrast??0):0,...a&&r?{screenBox:{x:r.x-e.x,y:r.y-e.y,width:r.width,height:r.height}}:{}}})}update(e,n,i,o,r,a){if(!this.labels.length)return;let s=Uo(o,r,{hasZoneLabels:this.labels.some(u=>u.kind==="zone")});this.forcedDense&&(s.add("row"),s.add("seat"));let l=[];for(let u of this.labels){if(!s.has(u.kind))continue;let b=Oe(e,u.anchor,n,i);if(!b.visible)continue;let y=a?Math.hypot(u.anchor[0]-a[0],u.anchor[1]-a[1],u.anchor[2]-a[2]):1;l.push({label:u,screen:b,focus:Wo(b,y,n,i),...this.selectedSeatLabelIds.has(u.id)?{priority:1}:{}})}let c=Ho(l.filter(u=>u.label.kind==="floor"),n),h=[...l.filter(u=>!pn.has(u.label.kind)&&u.label.kind!=="floor"),...c],m=[...Xo(h,ma,da),...["row","seat"].flatMap(u=>jo(l.filter(b=>b.label.kind===u),or[u].x,or[u].y,Yo[u]))],d=new Set(m.map(u=>u.label.id));for(let{label:u,screen:b}of m){let x=this.nodeFor(u).style;x.display="",x.transform=`translate(-50%, -50%) translate(${b.x.toFixed(1)}px, ${b.y.toFixed(1)}px)`}let p=m.filter(({label:u})=>!pn.has(u.kind)).sort((u,b)=>nr[b.label.kind]-nr[u.label.kind]||u.screen.depth-b.screen.depth||u.focus-b.focus),f=[];for(let{label:u}of p){let b=this.nodes.get(u.id);if(!b||b.style.display==="none")continue;let y=b.getBoundingClientRect();f.some(v=>y.left<v.right+3&&y.right+3>v.left&&y.top<v.bottom+3&&y.bottom+3>v.top)?b.style.display="none":f.push(y)}for(let[u,b]of this.nodes)d.has(u)||(b.style.display="none")}nodeFor(e){let n=this.nodes.get(e.id);if(!n){n=document.createElement("div");let m=n.style;m.position="absolute",m.left="0",m.top="0",m.whiteSpace="nowrap",m.textShadow="0 1px 3px rgba(0,0,0,0.85), 0 0 8px rgba(0,0,0,0.55)",m.display="none",this.root.appendChild(n),this.nodes.set(e.id,n)}n.textContent=e.text,n.setAttribute("data-label-kind",e.kind);let i=this.selectedSeatLabelIds.has(e.id);n.toggleAttribute("data-selected-seat",i);let o=ha[e.kind],r=n.style;r.fontSize=`${o.size}px`,r.fontWeight=i?"800":o.weight,r.opacity=i?"1":String(o.opacity);let a=pa(e.color??this.opts.ink,this.opts.backgroundRgb),s=!pn.has(e.kind);r.color=i?"#ecf8ff":a.ink,r.background=i?"rgba(10,28,45,.9)":s?a.backing:"",r.border=i?"1px solid rgba(89,199,255,.92)":s?`1px solid ${a.border}`:"",r.borderRadius=i||s?"999px":"",r.padding=i||s?"3px 7px":"",r.boxShadow=i?"0 0 0 2px rgba(41,176,255,.18), 0 5px 14px rgba(0,0,0,.35)":s?"0 3px 10px rgba(0,0,0,.24)":"",r.letterSpacing=e.kind==="zone"||e.kind==="floor"?"0.08em":"0.02em";let l=this.opts.backgroundRgb??[.04,.06,.1],c=ir(i?"#ecf8ff":a.ink)??[1,1,1],h=i?rr("rgba(10,28,45,.9)",l):s?rr(a.backing,l):l;return n.dataset.qualityContrast=ar(c,h).toFixed(3),(e.kind==="zone"||e.kind==="floor")&&(r.textTransform="uppercase"),n}dispose(){this.root.remove(),this.nodes.clear()}};var fa=1;var ba=new Set(["floor","zone","section","ga","booth","annotation"]);function ya(t){return t.every(e=>Number.isFinite(e))}function xa(t,e){return t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y}function sr(t){return t.length?Math.round(Math.min(...t)*100)/100:null}function We(t){return Math.round(t*1e4)/1e4}function ga(t){if(t)return{box:{x:We(t.box.x),y:We(t.box.y),width:We(t.box.width),height:We(t.box.height)},horizontalFillRatio:We(t.horizontalFillRatio),verticalFillRatio:We(t.verticalFillRatio),visibleAreaRatio:We(t.visibleAreaRatio),clippedEdges:[...t.clippedEdges]}}function Me(t,e,n){return n.length?{code:t,message:e,count:n.length,samples:n.slice(0,20)}:null}function bn(t){let e=t.labels.filter(s=>s.visible&&s.screenBox),n=e.filter(s=>ba.has(s.kind)),i=t.scene.floorCount>1?t.scene.floorCount:t.scene.zoneCount||t.scene.sectionCount,o=[];for(let s=0;s<n.length;s+=1)for(let l=0;l<s;l+=1)xa(n[s].screenBox,n[l].screenBox)&&o.push({primaryId:n[s].id,primaryLabel:n[s].text,secondaryId:n[l].id});let r=[...t.camera.position,t.camera.distance,t.camera.verticalFovDeg],a=[Me("webgl2-unavailable","The venue scene must render through WebGL2",t.context.webgl2?[]:[{primaryId:"renderer",primaryLabel:"WebGL2"}]),Me("context-lost","The WebGL context must be live at capture",t.context.lost?[{primaryId:"renderer",primaryLabel:"context lost"}]:[]),Me("frame-not-stable","The captured 3D frame must be rendered and parked",t.frame.rendered>0&&t.frame.idle?[]:[{primaryId:"renderer",primaryLabel:"unstable frame"}]),Me("viewport-empty","The 3D viewport must have visible dimensions",t.viewport.width>1&&t.viewport.height>1?[]:[{primaryId:"viewport",primaryLabel:`${t.viewport.width}\xD7${t.viewport.height}`}]),Me("camera-invalid","The capture camera must have a finite physical pose",ya(r)&&t.camera.distance>0&&t.camera.verticalFovDeg>0&&t.camera.verticalFovDeg<180?[]:[{primaryId:"camera",primaryLabel:"invalid pose"}]),Me("authored-relief-not-visible","Authored 3D height or rake must produce visible screen-space relief",!t.scene.authoredRelief||t.scene.renderedVerticalSpanM>.05&&t.scene.projectedReliefPx>=2?[]:[{primaryId:"scene",primaryLabel:"authored relief",measured:t.scene.projectedReliefPx,minimum:2}]),Me("hierarchy-label-missing","A venue with authored hierarchy must show at least one structural label",i===0||n.length>0?[]:[{primaryId:"labels",primaryLabel:`${i} expected hierarchy labels`}]),Me("hierarchy-label-undersized","Visible 3D hierarchy labels must remain readable",n.filter(s=>s.renderedFontPx<11).map(s=>({primaryId:s.id,primaryLabel:s.text,measured:s.renderedFontPx,minimum:11}))),Me("hierarchy-label-contrast-low","Visible 3D hierarchy labels must meet text contrast",n.filter(s=>s.contrast<4.5).map(s=>({primaryId:s.id,primaryLabel:s.text,measured:s.contrast,minimum:4.5}))),Me("hierarchy-label-collision","Visible 3D hierarchy labels must not overlap",o)].filter(s=>!!s);return{version:1,state:"venue3d",passed:a.length===0,resolvedRules:["rendered-3d-webgl-context","rendered-3d-stable-frame","rendered-3d-camera-pose","rendered-3d-relief-projection","rendered-3d-label-size","rendered-3d-label-contrast","rendered-3d-label-collision"],viewport:t.viewport,context:t.context,frame:t.frame,camera:t.camera,scene:t.scene,composition:{visibleLabels:e.map(({id:s,kind:l,text:c})=>({id:s,kind:l,text:c})).sort((s,l)=>s.kind.localeCompare(l.kind)||s.id.localeCompare(l.id)),framing:ga(t.framing)},metrics:{minimumHierarchyFontPx:sr(n.map(s=>s.renderedFontPx)),minimumHierarchyContrast:sr(n.map(s=>s.contrast)),projectedReliefPx:Math.round(t.scene.projectedReliefPx*100)/100},findings:a}}import{Geometry as Nt,Mesh as zt,Transform as br}from"ogl";import{Program as je}from"ogl";var Vt=`
1
+ import{a as On,c as Bn,d as Vn}from"../chunk-IRFG5DVH.js";import{a as Nn,c as zn,d as Gn,e as Ce,j as Hn}from"../chunk-XPPT3OGQ.js";import{c as kn,d as Ln,e as Zt,f as _n}from"../chunk-IJI4WU57.js";import{e as Cn,l as He,n as st,o as Dn,q as Pt}from"../chunk-6XJN4REG.js";import{d as K,k as En,x as he,z as at}from"../chunk-CXF32VPG.js";import{V as ke,W as Le,da as St,fa as In,ga as wt,ia as Tn,l as Rn,m as it,ta as Fn}from"../chunk-GHJUDU3U.js";import{Renderer as Yr}from"ogl";var be=["available","held","sold","selected","dimmed"];function ct(t){let e=be.indexOf(t);return e<0?0:e}var Un={available:[.24,.82,.52],held:[.95,.66,.22],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};function Xn(t){let e=.2126*t[0]+.7152*t[1]+.0722*t[2],n=.42,i=.62;return[(e+(t[0]-e)*n)*i,(e+(t[1]-e)*n)*i,(e+(t[2]-e)*n)*i]}var Kt={ground:[.07,.085,.11],tierTop:[.24,.28,.34],tierWall:[.17,.2,.25],stageTop:[.94,.7,.38],stageWall:[.48,.33,.18],decorTop:[.22,.25,.29],decorWall:[.15,.17,.2],gaTop:[.24,.28,.33],gaWall:[.16,.19,.23],boothTop:[.3,.33,.38],boothWall:[.2,.23,.27],tableTop:[.38,.34,.29],tableWall:[.24,.21,.18]},Ue={top:[.05,.06,.08],bottom:[.1,.12,.15]};function pe(t,e){return[Math.min(1,t[0]*e),Math.min(1,t[1]*e),Math.min(1,t[2]*e)]}function Wr(){let t=typeof window<"u"&&window.devicePixelRatio||1,e=navigator.deviceMemory,n=typeof e=="number"&&e<=4?1.5:2;return Math.min(t,n)}var At=class{constructor(e,n){this.clearRgb=[0,0,0];this.container=e,this.canvas=document.createElement("canvas"),this.canvas.style.display="block",this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.touchAction="none",this.canvas.tabIndex=0,this.canvas.setAttribute("role","application"),this.canvas.setAttribute("aria-label","Interactive 3D venue. Drag or use arrow keys to look around; pinch, scroll, plus or minus to zoom."),this.renderer=new Yr({canvas:this.canvas,dpr:Wr(),alpha:!1,antialias:!1,depth:!0,stencil:!1,powerPreference:"high-performance",webgl:2}),this.gl=this.renderer.gl,this.clearRgb=[Ue.top[0],Ue.top[1],Ue.top[2]],this.gl.clearColor(this.clearRgb[0],this.clearRgb[1],this.clearRgb[2],1),e.appendChild(this.canvas),this.lostHandler=i=>{i.preventDefault(),n.onContextLost()},this.restoredHandler=()=>n.onContextRestored(),this.canvas.addEventListener("webglcontextlost",this.lostHandler,!1),this.canvas.addEventListener("webglcontextrestored",this.restoredHandler,!1),this.resize()}setClearColor(e){this.clearRgb=[e[0],e[1],e[2]],this.gl.clearColor(e[0],e[1],e[2],1)}get clearColor(){return this.clearRgb}resize(){let e=Math.max(1,this.container.clientWidth||this.canvas.clientWidth||1),n=Math.max(1,this.container.clientHeight||this.canvas.clientHeight||1);return this.renderer.setSize(e,n),{width:e,height:n}}get pixelHeight(){return this.renderer.height*this.renderer.dpr}get aspect(){return this.renderer.width/Math.max(1,this.renderer.height)}dispose(){this.canvas.removeEventListener("webglcontextlost",this.lostHandler,!1),this.canvas.removeEventListener("webglcontextrestored",this.restoredHandler,!1);let e=this.gl.getExtension("WEBGL_lose_context");e&&e.loseContext(),this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}simulateContextLossCycle(){let e=this.gl.getExtension("WEBGL_lose_context");e&&(e.loseContext(),setTimeout(()=>{e.restoreContext&&e.restoreContext()},300))}};import{Camera as jr,Vec3 as Qt}from"ogl";var ue=Math.PI/180,$t=15*ue,Jt=80*ue,Ze=.12,Yn=35,Wn=1.25,Ct=class{constructor(e,n,i,o){this.fovY=Yn;this.target=new Qt;this.azimuth=-30*ue;this.polar=55*ue;this.distance=10;this.azT=-30*ue;this.polT=55*ue;this.distT=10;this.minDist=1;this.maxDist=100;this.gestureFired=!1;this.interactionEnabled=!0;this.dragging=!1;this.panning=!1;this.lastX=0;this.lastY=0;this.activePointers=new Map;this.pinchDist=0;this.pinchCx=0;this.pinchCy=0;this.targetT=new Qt;this.panAnchor=new Qt;this.panLimit=0;this.primaryDragMode="orbit";this.camera=new jr(e,{fov:Yn,near:.1,far:5e3,aspect:1}),this.canvas=n,this.requestRender=i,this.onGesture=o,this.onPointerDown=r=>{if(this.interactionEnabled){try{this.canvas.setPointerCapture?.(r.pointerId)}catch{}if(this.activePointers.set(r.pointerId,{x:r.clientX,y:r.clientY}),this.activePointers.size===1){let a=r.button===2||r.button===1,s=r.button===0&&(r.shiftKey?this.primaryDragMode==="orbit":this.primaryDragMode==="pan");this.panning=a||s,this.dragging=!this.panning,this.lastX=r.clientX,this.lastY=r.clientY}else if(this.activePointers.size===2){this.dragging=!1,this.panning=!1,this.pinchDist=this.currentPinchDistance();let a=this.pinchCentroid();this.pinchCx=a.x,this.pinchCy=a.y}}},this.onPointerMove=r=>{if(!this.interactionEnabled||!this.activePointers.has(r.pointerId))return;if(this.activePointers.set(r.pointerId,{x:r.clientX,y:r.clientY}),this.activePointers.size>=2){let l=this.currentPinchDistance();this.pinchDist>0&&(this.dollyBy(Math.exp((this.pinchDist-l)*.005)),this.fireGesture()),this.pinchDist=l;let c=this.pinchCentroid();this.panBy(c.x-this.pinchCx,c.y-this.pinchCy),this.pinchCx=c.x,this.pinchCy=c.y;return}let a=r.clientX-this.lastX,s=r.clientY-this.lastY;if(this.panning){this.lastX=r.clientX,this.lastY=r.clientY,(a!==0||s!==0)&&(this.panBy(a,s),this.fireGesture());return}this.dragging&&(this.lastX=r.clientX,this.lastY=r.clientY,(a!==0||s!==0)&&this.fireGesture(),this.azT-=a*.006,this.polT=Math.max($t,Math.min(Jt,this.polT-s*.006)),this.requestRender())},this.onPointerUp=r=>{this.activePointers.delete(r.pointerId);try{this.canvas.releasePointerCapture?.(r.pointerId)}catch{}this.activePointers.size<2&&(this.pinchDist=0),this.activePointers.size===0&&(this.dragging=!1,this.panning=!1)},this.onContextMenu=r=>{r.preventDefault()},this.onWheel=r=>{if(r.preventDefault(),!this.interactionEnabled)return;let a=r.deltaMode===1?16:r.deltaMode===2?100:1,s=Math.max(-2,Math.min(2,r.deltaY*a/100));this.dollyBy(Math.exp(s*.22)),this.fireGesture()},this.onKeyDown=r=>{if(!this.interactionEnabled)return;let a=7*ue;if(r.shiftKey&&(r.key==="ArrowLeft"||r.key==="ArrowRight"||r.key==="ArrowUp"||r.key==="ArrowDown"))this.panBy(r.key==="ArrowLeft"?-32:r.key==="ArrowRight"?32:0,r.key==="ArrowUp"?-32:r.key==="ArrowDown"?32:0);else if(r.key==="ArrowLeft"||r.key==="ArrowRight")this.azT+=r.key==="ArrowLeft"?-a:a;else if(r.key==="ArrowUp"||r.key==="ArrowDown")this.polT=Math.max($t,Math.min(Jt,this.polT+(r.key==="ArrowUp"?-a:a)));else if(r.key==="+"||r.key==="=")this.dollyBy(.82);else if(r.key==="-"||r.key==="_")this.dollyBy(1.22);else return;r.preventDefault(),this.fireGesture(),this.requestRender()},n.addEventListener("pointerdown",this.onPointerDown),n.addEventListener("pointermove",this.onPointerMove),n.addEventListener("pointerup",this.onPointerUp),n.addEventListener("pointercancel",this.onPointerUp),n.addEventListener("wheel",this.onWheel,{passive:!1}),n.addEventListener("keydown",this.onKeyDown),n.addEventListener("contextmenu",this.onContextMenu)}pinchCentroid(){let e=[...this.activePointers.values()];if(!e.length)return{x:0,y:0};let n=0,i=0;for(let o of e)n+=o.x,i+=o.y;return{x:n/e.length,y:i/e.length}}panBy(e,n){let i=this.canvas.clientHeight||1,o=2*this.distance*Math.tan(this.fovY*ue/2)/i,r=Math.sin(this.azimuth),a=Math.cos(this.azimuth),s=a,l=-r,c=Math.cos(this.polar),h=Math.sin(this.polar),m=-r*c,d=-a*c;this.targetT.x+=(-e*s+n*m)*o,this.targetT.z+=(-e*l+n*d)*o,this.targetT.y+=n*h*o,this.clampPan(),this.requestRender()}clampPan(){if(this.panLimit<=0)return;let e=this.panLimit,n=this.panAnchor.x,i=this.panAnchor.y,o=this.panAnchor.z;this.targetT.x=Math.max(n-e,Math.min(n+e,this.targetT.x)),this.targetT.z=Math.max(o-e,Math.min(o+e,this.targetT.z)),this.targetT.y=Math.max(i-e*.5,Math.min(i+e,this.targetT.y))}fireGesture(){this.gestureFired||(this.gestureFired=!0,this.onGesture?.())}currentPinchDistance(){let e=[...this.activePointers.values()];return e.length<2?0:Math.hypot(e[0].x-e[1].x,e[0].y-e[1].y)}dollyBy(e){this.distT=Math.max(this.minDist,Math.min(this.maxDist,this.distT*e)),this.requestRender()}zoomBy(e){this.interactionEnabled&&(this.dollyBy(e),this.fireGesture())}setPrimaryDragMode(e){this.primaryDragMode=e}setInteractionEnabled(e){this.interactionEnabled=e,!e&&(this.activePointers.clear(),this.dragging=!1,this.panning=!1,this.pinchDist=0)}frame(e,n=!1,i,o=!1,r){this.target.set(e.center[0],e.center[1],e.center[2]),this.targetT.copy(this.target),this.panAnchor.copy(this.target),this.panLimit=Math.max(1,e.radius)*1.5;let a=Math.max(1,e.radius),s=this.fovY*ue/2,l=o?Math.max(.82,this.camera.aspect||1):this.camera.aspect||1,c=Math.atan(Math.tan(s)*l);this.azT=i??-30*ue,this.polT=Math.max(15,Math.min(80,r?.polarDeg??55))*ue;let h=this.fitDistance(e,s,c,this.azT,this.polT);this.distT=h*Math.max(1.05,Math.min(2,r?.margin??Wn)),this.minDist=Math.max(2,a*.12),this.maxDist=h*4,n?(this.azimuth=this.azT,this.polar=12*ue,this.distance=this.distT*1.7):(this.azimuth=this.azT,this.polar=this.polT,this.distance=this.distT),this.applyPosition()}setAspect(e){this.camera.perspective({aspect:e})}frameSoft(e,n,i=!1,o){this.target.set(e.center[0],e.center[1],e.center[2]),this.targetT.copy(this.target),this.panAnchor.copy(this.target),this.panLimit=Math.max(1,e.radius)*1.5,this.syncFromCamera(),this.camera.perspective({fov:this.fovY,aspect:this.camera.aspect});let r=this.fovY*ue/2,a=i?Math.max(.82,this.camera.aspect||1):this.camera.aspect||1,s=Math.atan(Math.tan(r)*a);this.azT=n??this.azimuth,this.polT=Math.max(15,Math.min(80,o?.polarDeg??55))*ue;let l=this.fitDistance(e,r,s,this.azT,this.polT);this.distT=l*Math.max(1.05,Math.min(2,o?.margin??Wn))}fitDistance(e,n,i,o,r){let a=Math.max(1,e.radius),s=Math.max(a/Math.tan(n),a/Math.tan(i)),l=e.box;if(!l)return s;let c=Math.sin(r),h=-c*Math.sin(o),m=-Math.cos(r),d=-c*Math.cos(o);if(Math.abs(m)>.999)return s;let p=-d,f=h,u=Math.hypot(p,f);p/=u,f/=u;let b=-f*m,y=f*h-p*d,x=p*m,v=Math.tan(i),k=Math.tan(n),P=1;for(let M=0;M<8;M++){let F=(M&1?l.max[0]:l.min[0])-e.center[0],O=(M&2?l.max[1]:l.min[1])-e.center[1],L=(M&4?l.max[2]:l.min[2])-e.center[2],H=F*h+O*m+L*d,_=Math.abs(F*p+L*f),g=Math.abs(F*b+O*y+L*x);P=Math.max(P,_/v-H,g/k-H)}return Math.min(s,Math.max(P,a*.35))}updateClipping(e){let n=this.camera.position.x-e.center[0],i=this.camera.position.y-e.center[1],o=this.camera.position.z-e.center[2],r=Math.hypot(n,i,o),a=Math.max(1,e.radius)*1.18,s=Math.max(.05,r-a),l=Math.max(s+10,r+a);this.camera.perspective({near:s,far:l,aspect:this.camera.aspect})}update(){let e=this.azT-this.azimuth,n=this.polT-this.polar,i=this.distT-this.distance,o=this.targetT.x-this.target.x,r=this.targetT.y-this.target.y,a=this.targetT.z-this.target.z,s=Math.max(1e-4,this.distance*1e-4),l=Math.abs(e)>1e-4||Math.abs(n)>1e-4||Math.abs(i)>1e-4||Math.abs(o)>s||Math.abs(r)>s||Math.abs(a)>s;return this.azimuth+=e*Ze,this.polar+=n*Ze,this.distance+=i*Ze,this.target.x+=o*Ze,this.target.y+=r*Ze,this.target.z+=a*Ze,l&&this.applyPosition(),l}get currentDistance(){return this.distance}syncFromCamera(){let e=this.camera.position.x-this.target.x,n=this.camera.position.y-this.target.y,i=this.camera.position.z-this.target.z,o=Math.hypot(e,n,i)||1,r=Math.max($t,Math.min(Jt,Math.acos(Math.max(-1,Math.min(1,n/o)))));this.distance=this.distT=o,this.polar=this.polT=r,this.azimuth=this.azT=Math.atan2(e,i)}setTarget(e){this.target.set(e[0],e[1],e[2]),this.targetT.copy(this.target)}resumeAfterFlight(e){this.camera.perspective({fov:this.fovY,aspect:this.camera.aspect}),e&&this.target.set(e[0],e[1],e[2]),this.targetT.copy(this.target),this.syncFromCamera()}applyPosition(){let e=Math.sin(this.polar),n=this.target.x+this.distance*e*Math.sin(this.azimuth),i=this.target.y+this.distance*Math.cos(this.polar),o=this.target.z+this.distance*e*Math.cos(this.azimuth);this.camera.position.set(n,i,o),this.camera.lookAt(this.target)}dispose(){this.canvas.removeEventListener("pointerdown",this.onPointerDown),this.canvas.removeEventListener("pointermove",this.onPointerMove),this.canvas.removeEventListener("pointerup",this.onPointerUp),this.canvas.removeEventListener("pointercancel",this.onPointerUp),this.canvas.removeEventListener("wheel",this.onWheel),this.canvas.removeEventListener("keydown",this.onKeyDown),this.canvas.removeEventListener("contextmenu",this.onContextMenu),this.activePointers.clear()}};var Rt=class{constructor(e){this.rafId=0;this.running=!1;this.lastTime=0;this.fpsEma=0;this.rendered=0;this.tick=e=>{let n=this.lastTime?(e-this.lastTime)/1e3:.016666666666666666;if(this.lastTime=e,n>0){let o=1/n;this.fpsEma=this.fpsEma?this.fpsEma*.9+o*.1:o}this.rendered++,this.frame(n)?this.rafId=requestAnimationFrame(this.tick):(this.running=!1,this.rafId=0)};this.frame=e}requestRender(){this.running||(this.running=!0,this.lastTime=0,this.rafId=requestAnimationFrame(this.tick))}stats(){return{fps:this.running?Math.round(this.fpsEma):0,rendered:this.rendered,idle:!this.running}}stop(){this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=0,this.running=!1}};var Ke=2.5,qr=1.15,lt=6,Qe=10,jn=6,qn=9.5,Zn=.9,Kn=2.2,en=30,tn=4,It=8192;var ps=Qe+tn;function Qn(t,e){let n=e*1.4,i=e*3.2;if(t<=n)return{scale:1,fade:0,minPixels:Ke};let o=Math.min(1,(t-n)/Math.max(.001,i-n));return{scale:1-o*.4,fade:o*.55,minPixels:Ke+o*(qr-Ke)}}function $n(t,e,n){return!(t>0)||!(e>0)||!(n>0)?!1:e*n/t>=64}function Jn(t,e,n,i,o){if(!(t>0)||!(e>0)||!(n>0)||!(i>0)||!(o>0))return!1;let r=Math.tan(i/2*Math.PI/180);if(!(r>0))return!1;let a=e/(n*r)*(o/2);return Math.PI*a*a/t>=64}import Zr from"earcut";import Kr from"polygon-clipping";var R=ke,Qr=.002;function $r(t,e,n){let i=Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2]),o=Math.hypot(n[0]-e[0],n[1]-e[1],n[2]-e[2]),r=Math.hypot(t[0]-n[0],t[1]-n[1],t[2]-n[2]),a=Math.max(i,o,r);if(a<1e-9)return!0;let s=(i+o+r)/2;return 2*Math.sqrt(Math.max(0,s*(s-i)*(s-o)*(s-r)))/a<Qr}var Xe=class{constructor(e=16384){this.len=0;this.buf=new Float32Array(e)}push3(e,n,i){this.len+3>this.buf.length&&this.grow(this.len+3),this.buf[this.len++]=e,this.buf[this.len++]=n,this.buf[this.len++]=i}push1(e){this.len+1>this.buf.length&&this.grow(this.len+1),this.buf[this.len++]=e}grow(e){let n=this.buf.length*2;for(;n<e;)n*=2;let i=new Float32Array(n);i.set(this.buf.subarray(0,this.len)),this.buf=i}get length(){return this.len}toArray(){return this.buf.slice(0,this.len)}},Et=class{constructor(){this.pos=new Xe;this.nor=new Xe;this.col=new Xe;this.flr=new Xe;this.mat=new Xe;this.currentFloor=0;this.currentMaterial=0}setFloor(e){this.currentFloor=e}setMaterial(e){this.currentMaterial=e}tri(e,n,i,o,r,a=r,s=r){$r(e,n,i)||(this.pos.push3(e[0],e[1],e[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(i[0],i[1],i[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.col.push3(r[0],r[1],r[2]),this.col.push3(a[0],a[1],a[2]),this.col.push3(s[0],s[1],s[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}triN(e,n,i,o,r,a,s,l=s,c=s){[...e,...n,...i].every(Number.isFinite)&&(this.pos.push3(e[0],e[1],e[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(i[0],i[1],i[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(a[0],a[1],a[2]),this.col.push3(s[0],s[1],s[2]),this.col.push3(l[0],l[1],l[2]),this.col.push3(c[0],c[1],c[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}get vertexCount(){return this.pos.length/3}build(){return{position:this.pos.toArray(),normal:this.nor.toArray(),color:this.col.toArray(),floor:this.flr.toArray(),material:this.mat.toArray(),count:this.pos.length/3}}};function Jr(t,e,n){let i=e[0]-t[0],o=e[1]-t[1],r=e[2]-t[2],a=n[0]-t[0],s=n[1]-t[1],l=n[2]-t[2],c=o*l-r*s,h=r*a-i*l,m=i*s-o*a,d=Math.hypot(c,h,m)||1;return c/=d,h/=d,m/=d,[c,h,m]}function ei(t,e){let n=[...t],i=[];for(let a of t)i.push(a.x,a.y);let o=[];if(e){for(let a of e)if(!(a.length<3)){o.push(n.length);for(let s of a)n.push(s),i.push(s.x,s.y)}}let r=Zr(i,o.length?o:void 0,2);return{pts:n,tris:r}}function nn(t){return He(t)<0?[...t].reverse():t}var ti=3;function ni(t,e,n,i){let o=i(t),r=i(e),a=i(n),s=(p,f,u,b)=>Math.abs(i({x:(p.x+f.x)/2,y:(p.y+f.y)/2})-(u+b)/2),l=(t.x+e.x+n.x)/3,c=(t.y+e.y+n.y)/3,h=(o+r+a)/3,m=Math.max(s(t,e,o,r),s(e,n,r,a),s(n,t,a,o),Math.abs(i({x:l,y:c})-h)),d=(p,f,u)=>{let b=Math.abs(i({x:(p+l)/2,y:(f+c)/2})-(u+h)/2);b>m&&(m=b)};return d((t.x+e.x)/2,(t.y+e.y)/2,(o+r)/2),d((e.x+n.x)/2,(e.y+n.y)/2,(r+a)/2),d((n.x+t.x)/2,(n.y+t.y)/2,(a+o)/2),m}function ut(t,e,n,i,o){if(o<=0)return ni(t,e,n,i);let r={x:(t.x+e.x)/2,y:(t.y+e.y)/2},a={x:(e.x+n.x)/2,y:(e.y+n.y)/2},s={x:(n.x+t.x)/2,y:(n.y+t.y)/2};return Math.max(ut(t,r,s,i,o-1),ut(r,e,a,i,o-1),ut(s,a,n,i,o-1),ut(r,a,s,i,o-1))}function mt(t,e,n,i,o,r,a,s){if(a>0){let d={x:(e.x+n.x)/2,y:(e.y+n.y)/2},p={x:(n.x+i.x)/2,y:(n.y+i.y)/2},f={x:(i.x+e.x)/2,y:(i.y+e.y)/2};mt(t,e,d,f,o,r,a-1,s),mt(t,d,n,p,o,r,a-1,s),mt(t,f,p,i,o,r,a-1,s),mt(t,d,p,f,o,r,a-1,s);return}let l=[e.x*R,o(e),e.y*R],c=[n.x*R,o(n),n.y*R],h=[i.x*R,o(i),i.y*R];if(s){t.triN(l,c,h,s(e),s(n),s(i),r);return}let m=Jr(l,c,h);m[1]<0&&(m=[-m[0],-m[1],-m[2]]),t.tri(l,c,h,m,r)}var oi=8;function eo(t,e,n){if(!Number.isFinite(n))return t;let i=[],o=(r,a,s,l,c)=>{if(c>0){let h={x:(r.x+a.x)/2,y:(r.y+a.y)/2},m=e(h);if(Math.abs(m-(s+l)/2)>n){o(r,h,s,m,c-1),o(h,a,m,l,c-1);return}}i.push(r)};for(let r=0;r<t.length;r++){let a=t[r],s=t[(r+1)%t.length];o(a,s,e(a),e(s),oi)}return i}function Tt(t,e){if(t.length<3)return t;let n=[];for(let o of t){let r=n[n.length-1];r&&Math.hypot(o.x-r.x,o.y-r.y)<e||n.push(o)}for(;n.length>2&&Math.hypot(n[0].x-n[n.length-1].x,n[0].y-n[n.length-1].y)<e;)n.pop();if(n.length<3)return t;let i=[];for(let o=0;o<n.length;o++){let r=i.length?i[i.length-1]:n[(o-1+n.length)%n.length],a=n[o],s=n[(o+1)%n.length],l=s.x-r.x,c=s.y-r.y,h=Math.hypot(l,c);h>e&&Math.abs((a.x-r.x)*c-(a.y-r.y)*l)/h<e||i.push(a)}return i.length>=3?i:n}var Ft=.001*Le*.1;function ie(t,e,n,i,o,r,a,s,l=1/0,c){if(!e||e.length<3||(l===void 0&&(l=1/0),Math.abs(He(e))<1e-4))return;let h=Tt(eo(Tt(nn(e),Ft),i,l),Ft),m=n?.map(M=>Tt(eo(Tt(nn(M),Ft),i,l),Ft)).filter(M=>M.length>=3&&Math.abs(He(M))>=1e-4),{pts:d,tris:p}=ei(h,m),f=[r[0]*s.top,r[1]*s.top,r[2]*s.top],u=[r[0]*s.bottomCap,r[1]*s.bottomCap,r[2]*s.bottomCap],b=[a[0]*s.top,a[1]*s.top,a[2]*s.top],y=[a[0]*s.wallBottom,a[1]*s.wallBottom,a[2]*s.wallBottom],x=0;if(Number.isFinite(l))for(;x<ti;x++){let M=0;for(let F=0;F<p.length;F+=3){let O=ut(d[p[F]],d[p[F+1]],d[p[F+2]],i,x);O>M&&(M=O)}if(M<=l)break}for(let M=0;M<p.length;M+=3){let F=d[p[M]],O=d[p[M+1]],L=d[p[M+2]];mt(t,F,O,L,i,f,x,c);let H=[F.x*R,o,F.y*R],_=[O.x*R,o,O.y*R],g=[L.x*R,o,L.y*R];t.tri(H,g,_,[0,-1,0],u)}let v=M=>{if(x<=0)return M;let F=1<<x,O=[];for(let L=0;L<M.length;L++){let H=M[L],_=M[(L+1)%M.length];for(let g=0;g<F;g++){let w=g/F;O.push({x:H.x+(_.x-H.x)*w,y:H.y+(_.y-H.y)*w})}}return O},k=Rn(h),P=[{ring:v(h),flip:!1}];if(m)for(let M of m)M.length>=3&&P.push({ring:v(M),flip:!0});for(let{ring:M,flip:F}of P)for(let O=0;O<M.length;O++){let L=M[O],H=M[(O+1)%M.length],_=(H.x-L.x)*R,w=(H.y-L.y)*R,E=-_,C=Math.hypot(w,E)||1;w/=C,E/=C;let N=(L.x+H.x)/2-k.x,S=(L.y+H.y)/2-k.y,I=w*N+E*S;F&&(I=-I),I<0&&(w=-w,E=-E);let T=[w,0,E],B=[L.x*R,i(L),L.y*R],A=[H.x*R,i(H),H.y*R],D=[L.x*R,o,L.y*R],V=[H.x*R,o,H.y*R];t.tri(B,A,V,T,b,b,y),t.tri(B,V,D,T,b,y,y)}}function to(t){let e=0;for(let l of t)e+=l.count;let n=new Float32Array(e*3),i=new Float32Array(e*3),o=new Float32Array(e*3),r=new Float32Array(e),a=new Float32Array(e),s=0;for(let l of t)n.set(l.position,s*3),i.set(l.normal,s*3),o.set(l.color,s*3),r.set(l.floor,s),a.set(l.material,s),s+=l.count;return{position:n,normal:i,color:o,floor:r,material:a,count:e}}function Dt(t,e,n=2.5){if(e<=0||t.length<3)return t;let i=nn(t),o=i.length,r=[];for(let s=0;s<o;s++){let l=i[s],c=i[(s+1)%o],h=c.x-l.x,m=c.y-l.y,d=Math.hypot(h,m)||1;r.push({x:m/d,y:-h/d})}let a=[];for(let s=0;s<o;s++){let l=i[s],c=r[(s-1+o)%o],h=r[s],m=c.x+h.x,d=c.y+h.y,p=Math.hypot(m,d),f=()=>{a.push([l.x+c.x*e,l.y+c.y*e]),a.push([l.x+h.x*e,l.y+h.y*e])};if(p<1e-9){f();continue}m/=p,d/=p;let u=m*c.x+d*c.y,b=1/Math.max(u,1e-6);if(!Number.isFinite(b)||b>n){f();continue}a.push([l.x+m*e*b,l.y+d*e*b])}if(a.length<3)return t;try{let s=Kr.union([[...a,a[0]]]),l=null,c=-1/0;for(let m of s){let d=Math.abs(He(m[0].map(([p,f])=>({x:p,y:f}))));d>c&&(c=d,l=m[0])}if(!l)return t;let h=l.map(([m,d])=>({x:m,y:d}));if(h.length>1){let m=h[0],d=h[h.length-1];Math.abs(m.x-d.x)<1e-9&&Math.abs(m.y-d.y)<1e-9&&h.pop()}return h.length>=3?h:t}catch{return t}}function kt(t,e,n,i,o=28){let r=[];for(let a=0;a<o;a++){let s=a/o*Math.PI*2;r.push({x:t+n*Math.cos(s),y:e+i*Math.sin(s)})}return r}function dt(t,e,n,i){return[{x:t,y:e},{x:t+n,y:e},{x:t+n,y:e+i},{x:t,y:e+i}]}var ce={pedestal:0,pad:1,back:2,body:3,head:4},ri=.44,ii=.15,ai=.3,si=.24;function no(t){return t===void 0||!Number.isFinite(t)||t<=0?si:Math.min(ai,Math.max(ii,t*ri))}var on=.21,ci=.05,rn=.45,Lt=rn+ci,li=[{part:ce.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:ce.pad,min:[-1,.36,-.95],max:[1,rn,1]},{part:ce.back,min:[-1,Lt,-1],max:[1,.92,-.72]}],ui=[{part:ce.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:ce.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:ce.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:ce.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:ce.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}],mi=[{n:[1,0,0],c:[[1,0,0],[1,1,0],[1,1,1],[1,0,1]]},{n:[-1,0,0],c:[[0,0,1],[0,1,1],[0,1,0],[0,0,0]]},{n:[0,1,0],c:[[0,1,0],[0,1,1],[1,1,1],[1,1,0]]},{n:[0,-1,0],c:[[0,0,1],[0,0,0],[1,0,0],[1,0,1]]},{n:[0,0,1],c:[[0,0,1],[1,0,1],[1,1,1],[0,1,1]]},{n:[0,0,-1],c:[[1,0,0],[0,0,0],[0,1,0],[1,1,0]]}];function oo(){let t=[],e=[],n=[],i=[],o=(C,N,S)=>{let I=n.length,[T,B,A]=C,D=[B[0]-T[0],B[1]-T[1],B[2]-T[2]],V=[A[0]-T[0],A[1]-T[1],A[2]-T[2]],U=D[1]*V[2]-D[2]*V[1],Y=D[2]*V[0]-D[0]*V[2],X=D[0]*V[1]-D[1]*V[0],j=Math.hypot(U,Y,X);j>1e-9?(U/=j,Y/=j,X/=j):[U,Y,X]=N,U*N[0]+Y*N[1]+X*N[2]<0&&(U=-U,Y=-Y,X=-X);for(let Z of C)t.push(...Z),e.push(U,Y,X),n.push(S);i.push(I,I+1,I+2,I,I+2,I+3)},r=C=>{for(let N of mi){let S=N.c.map(I=>I.map((T,B)=>T?C.max[B]:C.min[B]));o(S,N.n,C.part)}};for(let C of li)r(C);for(let C of ui)r(C);let a=rn,s=1.08,l=.47,c=.69,h=-.55,m=.08,d=-.48,p=.01,f=[-l,a,h],u=[l,a,h],b=[-l,a,m],y=[l,a,m],x=[-c,s,d],v=[c,s,d],k=[-c,s,p],P=[c,s,p];o([u,v,P,y],[1,0,0],ce.body),o([b,k,x,f],[-1,0,0],ce.body),o([k,P,v,x],[0,1,0],ce.body),o([f,u,y,b],[0,-1,0],ce.body),o([y,P,k,b],[0,0,1],ce.body),o([f,x,v,u],[0,0,-1],ce.body);let M=10,F=8,O=[0,1.205,-.23],L=[.42,.115,.38],H=n.length;for(let C=0;C<=F;C++){let N=Math.PI*C/F,S=Math.cos(N),I=Math.sin(N);for(let T=0;T<=M;T++){let B=Math.PI*2*T/M,A=I*Math.cos(B),D=I*Math.sin(B);t.push(O[0]+L[0]*A,O[1]+L[1]*S,O[2]+L[2]*D);let V=A/L[0],U=S/L[1],Y=D/L[2],X=Math.hypot(V,U,Y)||1;V/=X,U/=X,Y/=X,e.push(V,U,Y),n.push(ce.head)}}for(let C=0;C<F;C++)for(let N=0;N<M;N++){let S=H+C*(M+1)+N,I=S+M+1;i.push(S,I,S+1,S+1,I,I+1)}let _=new Float32Array(t),g=new Float32Array(e),w=new Float32Array(n),E=new Uint16Array(i);return{position:_,normal:g,part:w,index:E,vertexCount:n.length,indexCount:i.length}}function ro(t,e,n,i){let o=new Float32Array(e),r=c=>t[c*3],a=c=>t[c*3+2],s=0,l=(c,h)=>{let m=h-c;for(let d=c;d<h;d++){let[p,f]=i(d),u=p-r(d),b=f-a(d);if(m>=2){let y=Math.max(c,d-1),x=Math.min(h-1,d+1),v=r(x)-r(y),k=a(x)-a(y),P=Math.hypot(v,k);if(P>1e-6){let M=-k/P,F=v/P;M*u+F*b<0&&(M=-M,F=-F),u=M,b=F}}o[d]=u===0&&b===0?0:Math.atan2(u,b)}};for(let c=1;c<=e;c++)(c===e||n(c)!==n(s))&&(l(s,c),s=c);return o}var Re=.22;function io(t,e){let n=be[t];if(n!=="sold"&&n!=="held")return-1;let i=(e+1)*2654435761;return i^=i>>>15,i=Math.imul(i,2246822519),i^=i>>>13,(i>>>0)%1e5/1e5}var di=.42;function hi(t){let e=t.length,n=new Float64Array(e);if(e<2)return n.fill(1/0),n;let i=1/0,o=1/0,r=-1/0,a=-1/0;for(let f of t)f.x<i&&(i=f.x),f.y<o&&(o=f.y),f.x>r&&(r=f.x),f.y>a&&(a=f.y);let s=Math.max(r-i,1e-6),l=Math.max(a-o,1e-6),c=Math.max(Math.sqrt(s*l/e),1e-6),h=Math.max(1,Math.ceil(s/c)+1),m=Math.max(1,Math.ceil(l/c)+1),d=new Map,p=(f,u)=>{let b=Math.min(h-1,Math.max(0,Math.floor((f-i)/c)));return Math.min(m-1,Math.max(0,Math.floor((u-o)/c)))*h+b};for(let f=0;f<e;f++){let u=p(t[f].x,t[f].y),b=d.get(u);b?b.push(f):d.set(u,[f])}for(let f=0;f<e;f++){let u=t[f],b=Math.min(h-1,Math.max(0,Math.floor((u.x-i)/c))),y=Math.min(m-1,Math.max(0,Math.floor((u.y-o)/c))),x=1/0;for(let v=1;v<=4;v++){for(let k=y-v;k<=y+v;k++)if(!(k<0||k>=m))for(let P=b-v;P<=b+v;P++){if(P<0||P>=h||v>1&&Math.abs(k-y)<v&&Math.abs(P-b)<v)continue;let M=d.get(k*h+P);if(M)for(let F of M){if(F===f)continue;let O=Math.hypot(t[F].x-u.x,t[F].y-u.y);O<x&&(x=O)}}if(Number.isFinite(x)&&x<=v*c)break}n[f]=x}return n}function pi(t){let e=t.eyeHeightM;return Number.isFinite(e)?Math.max(0,e-St):0}function ao(t,e,n,i,o){let r=t.length,a=new Float32Array(r*3),s=new Float32Array(r),l=new Float32Array(r*3),c=new Float32Array(r),h=new Float32Array(r),m=new Float32Array(r),d=new Float32Array(r*3),p=new Map,f=hi(t);for(let u=0;u<r;u++){let b=t[u],x=(n?.seatPitchU(u)??f[u])*R;c[u]=Number.isFinite(x)?Math.max(.06,Math.min(Re,x*di)):Re,h[u]=no(Number.isFinite(x)?x:void 0),m[u]=b.wheelchairSpaceType==="no-seat"?0:1,a[u*3]=b.x*R,a[u*3+1]=n?n.seatDeckY(u):pi(b),a[u*3+2]=b.y*R,s[u]=ct(e?e(b):"available");let v=K(o?.get(b.categoryKey)??"#6e7bff")??[.43,.48,1];if(l[u*3]=v[0],l[u*3+1]=v[1],l[u*3+2]=v[2],b.accessibility?.length){let k=K(Cn(b.accessibility));k&&(d[u*3]=k[0],d[u*3+1]=k[1],d[u*3+2]=k[2])}p.set(b.id,u)}return{count:r,iPosition:a,iState:s,iCategory:l,iMaxRadius:c,iRing:d,idToIndex:p,iChairWidth:h,iPhysicalSeat:m,iFloor:i??new Float32Array(r),iYaw:new Float32Array(r)}}var fi=64;function an(t,e){let n=[];for(let a of e){let s=t.idToIndex.get(a.seatId);if(s===void 0)continue;let l=ct(a.state);t.iState[s]!==l&&(t.iState[s]=l,n.push(s))}if(!n.length)return[];n.sort((a,s)=>a-s);let i=[],o=n[0],r=n[0];for(let a=1;a<n.length;a++){let s=n[a];if(s!==r){if(s<=r+fi){r=s;continue}i.push({start:o,length:r-o+1}),o=s,r=s}}return i.push({start:o,length:r-o+1}),i}var bi=.15,yi=.9,xi=1.76,gi=.7,vi=1.6;function Mi(){return{background:{top:[...Ue.top],bottom:[...Ue.bottom]},structure:Kt,seatStates:{...Un},seatScale:1}}function so(t){let e=Mi();if(!t)return e;let n=K(t.background);if(n){e.background={top:pe(n,yi),bottom:pe(n,xi)};let r={};for(let[a,s]of Object.entries(Kt))r[a]=he(s,n,bi);e.structure=r}let i=K(t.selectionColor)??K(t.accent);i&&(e.seatStates={...e.seatStates,selected:i});let o=t.seatScale;return typeof o=="number"&&Number.isFinite(o)&&(e.seatScale=Math.min(vi,Math.max(gi,o))),e}function co(t,e){let n=[];for(let i of e)n.push(...t.seatStates[i]);return n}import ho from"polygon-clipping";import Si from"earcut";var wi=.58,lo=.01,fe=Re*1.5*Le,Pi=.5,Ai=.6;function Ci(t,e){let n=t.length,i=[];for(let a=0;a<n;a++){let s=t[Math.max(0,a-1)],l=t[Math.min(n-1,a+1)],c=l.x-s.x,h=l.y-s.y,m=Math.hypot(c,h);if(m<1e-9){i.push([0,0]);continue}c/=m,h/=m,i.push([-h,c])}let o=0;for(let a=0;a<n;a++)o+=(t[a].x-e.x)*i[a][0]+(t[a].y-e.y)*i[a][1];return o<0?i.map(([a,s])=>[-a,-s]):i}function Ri(t,e){if(t.length<2||e<=0)return[...t];let n=[...t],i=(a,s)=>{let l=s.x-a.x,c=s.y-a.y,h=Math.hypot(l,c)||1;return{x:l/h,y:c/h}},o=i(n[1],n[0]),r=i(n[n.length-2],n[n.length-1]);return n.unshift({x:n[0].x+o.x*e,y:n[0].y+o.y*e}),n.push({x:n[n.length-1].x+r.x*e,y:n[n.length-1].y+r.y*e}),n}var uo=Math.PI/12;function Ii(t){if(t.length<3)return[...t];let e=[...t].sort((r,a)=>r.x-a.x||r.y-a.y),n=(r,a,s)=>(a.x-r.x)*(s.y-r.y)-(a.y-r.y)*(s.x-r.x),i=r=>{let a=[];for(let s of r){for(;a.length>=2&&n(a[a.length-2],a[a.length-1],s)<=0;)a.pop();a.push(s)}return a.pop(),a},o=[...i(e),...i([...e].reverse())];return o.length>=3?o:[...t]}function po(t,e){if(!t.length||!(e>0))return[];let n=Ii(t),i=(s,l,c,h)=>{let m=c-l;for(;m<0;)m+=Math.PI*2;for(;m>Math.PI*2;)m-=Math.PI*2;let d=Math.max(1,Math.ceil(m/uo)),p=e/Math.cos(m/d/2);for(let f=0;f<=d;f++){let u=l+m*f/d;h.push({x:s.x+Math.cos(u)*p,y:s.y+Math.sin(u)*p})}};if(n.length<3){let s=0,l=0;for(let p of n)s+=p.x,l+=p.y;s/=n.length||1,l/=n.length||1;let c=0;for(let p of n)c=Math.max(c,Math.hypot(p.x-s,p.y-l));let h=[],m=Math.max(3,Math.ceil(Math.PI*2/uo)),d=(c+e)/Math.cos(Math.PI/m);for(let p=0;p<m;p++){let f=p/m*Math.PI*2;h.push({x:s+Math.cos(f)*d,y:l+Math.sin(f)*d})}return h}let o=n.length,r=[];for(let s=0;s<o;s++){let l=n[s],c=n[(s+1)%o];r.push(Math.atan2(-(c.x-l.x),c.y-l.y))}let a=[];for(let s=0;s<o;s++)i(n[s],r[(s+o-1)%o],r[s],a);return go(a)}function Ti(t,e,n){if(t.length===1)return Math.hypot(e-t[0].x,n-t[0].y);let i=1/0;for(let o=0;o+1<t.length;o++){let r=t[o],a=t[o+1],s=a.x-r.x,l=a.y-r.y,c=s*s+l*l,h=c>1e-12?((e-r.x)*s+(n-r.y)*l)/c:0;h<0?h=0:h>1&&(h=1);let m=Math.hypot(e-(r.x+h*s),n-(r.y+h*l));m<i&&(i=m)}return i}function _t(t){let e=t.map(o=>{let r=0,a=0;for(let c of o.pts)r+=c.x,a+=c.y;let s=o.pts.length||1;r/=s,a/=s;let l=0;for(let c of o.pts){let h=Math.hypot(c.x-r,c.y-a);h>l&&(l=h)}return{cx:r,cy:a,rad:l}}),n=o=>{let r=o.length;return r<=2?[...o]:[o[Math.floor(r*.25)],o[Math.floor(r*.5)],o[Math.floor(r*.75)]]},i=[];for(let o=0;o<t.length;o++){let r=n(t[o].pts),a=[],s=1/0,l=null;for(let h of r){let m=1/0;for(let d=0;d<t.length;d++){if(d===o||Math.abs(t[d].y-t[o].y)<.001)continue;let p=e[d],f=Math.hypot(h.x-p.cx,h.y-p.cy)-p.rad;if(f>=m&&f>=s)continue;let u=Ti(t[d].pts,h.x,h.y);u<m&&(m=u),t[d].depth<t[o].depth&&u<s&&(s=u,l=t[d].y)}Number.isFinite(m)&&m>0&&a.push(m)}a.sort((h,m)=>h-m);let c=a.length?a[Math.floor(a.length/2)]:1;i.push({pitch:c,belowY:l})}return i}function fo(t,e,n,i){let o=t[e],r=o.pts.length>=2?[...o.pts]:o.pts.length===1?(()=>{let h=o.pts[0],m=h.x-i.x,d=h.y-i.y,p=Math.hypot(m,d)||1;m/=p,d/=p;let f=Math.max(n[e].pitch,.001)*.5;return[{x:h.x+d*f,y:h.y-m*f},{x:h.x-d*f,y:h.y+m*f}]})():[];if(r.length<2)return null;let a=0,s=0;for(let h=1;h<r.length;h++){let m=Math.hypot(r[h].x-r[h-1].x,r[h].y-r[h-1].y);m>1e-6&&(a+=m,s++)}let l=s>0?a/s:0,c=Ri(r,Math.max(l*Ai,fe));return{pts:c,nrm:Ci(c,i),front:Math.max(n[e].pitch*wi,fe),back:Math.max(n[e].pitch*Pi,fe)}}var $e=1.5,bo=.3;function sn(t,e){if(t.length<3)return t;let n=t[0],i=t[t.length-1],o=i.x-n.x,r=i.y-n.y,a=Math.hypot(o,r),s=-1,l=-1;for(let m=1;m<t.length-1;m++){let d=t[m],p=a>1e-12?Math.abs((d.x-n.x)*r-(d.y-n.y)*o)/a:Math.hypot(d.x-n.x,d.y-n.y);p>s&&(s=p,l=m)}if(s<=e||l<0)return[n,i];let c=sn(t.slice(0,l+1),e),h=sn(t.slice(l),e);return[...c.slice(0,-1),...h]}function yo(t,e){if(t.length<4)return t;let n=sn([...t,t[0]],e);return n.pop(),n.length>=3?n:t}function xo(t,e,n){if(t.length<2)return[];let i=n??_t(t),o=new Map;for(let a=0;a<t.length;a++){let s=o.get(t[a].blockId);s?s.push(a):o.set(t[a].blockId,[a])}let r=[];for(let[,a]of o){let s=[];for(let x of a){let v=t[x].patch;v&&v.length>=3?r.push({outline:[...v],holes:[],topY:t[x].y}):s.push(x)}if(!s.length)continue;s.sort((x,v)=>t[x].depth-t[v].depth);let c=s.map(x=>fo(t,x,i,e)).filter(x=>x!==null);if(!c.length)continue;let h=(x,v)=>({x:x.pts[v].x-x.nrm[v][0]*(x.front+$e),y:x.pts[v].y-x.nrm[v][1]*(x.front+$e)}),m=(x,v)=>({x:x.pts[v].x+x.nrm[v][0]*(x.back+$e),y:x.pts[v].y+x.nrm[v][1]*(x.back+$e)}),d=c[0],p=c[c.length-1],f=[];for(let x=0;x<d.pts.length;x++)f.push(h(d,x));for(let x of c)f.push(m(x,x.pts.length-1));for(let x=p.pts.length-1;x>=0;x--)f.push(m(p,x));for(let x=c.length-1;x>=0;x--)f.push(h(c[x],0));let u=go(f),b=1/0;for(let x of s)t[x].y<b&&(b=t[x].y);if(!Number.isFinite(b))continue;if(u.length>=3&&Math.abs(He(u))>1e-6&&c.every(x=>{let v=x.pts[Math.floor(x.pts.length/2)];return st(u,v.x,v.y)})){r.push({outline:yo(u,bo),holes:[],topY:b});continue}for(let x of Fi(c))r.push({outline:x,holes:[],topY:b})}return r}function Fi(t){let e=[];for(let n of t){let i=[],o=[],r=n.front+$e,a=n.back+$e;for(let l=0;l<n.pts.length;l++){let c=n.pts[l],h=n.nrm[l];i.push([c.x-h[0]*r,c.y-h[1]*r]),o.push([c.x+h[0]*a,c.y+h[1]*a])}let s=[...i,...o.reverse()];s.length<3||(s.push(s[0]),e.push([s]))}if(!e.length)return[];try{let n=ho.union(e[0],...e.slice(1)),i=[];for(let o of n){if(!o.length||o[0].length<4)continue;let r=o[0].map(([l,c])=>({x:l,y:c})),a=r[0],s=r[r.length-1];r.length>1&&Math.abs(a.x-s.x)<1e-9&&Math.abs(a.y-s.y)<1e-9&&r.pop(),r.length>=3&&i.push(yo(r,bo))}return i}catch{return[]}}function go(t){let e=[];for(let n of t){let i=e[e.length-1];i&&Math.hypot(n.x-i.x,n.y-i.y)<1e-9||e.push(n)}for(;e.length>2&&Math.hypot(e[0].x-e[e.length-1].x,e[0].y-e[e.length-1].y)<1e-9;)e.pop();return e}var cn=class{constructor(e){this.minX=1/0;this.minY=1/0;this.maxX=-1/0;this.maxY=-1/0;this.rings=e;for(let n of e)for(let i of n)i.x<this.minX&&(this.minX=i.x),i.y<this.minY&&(this.minY=i.y),i.x>this.maxX&&(this.maxX=i.x),i.y>this.maxY&&(this.maxY=i.y)}containsAll(e){for(let n of e)if(n.x<this.minX||n.x>this.maxX||n.y<this.minY||n.y>this.maxY)return!1;for(let n of this.rings){let i=!0;for(let o of e)if(!st(n,o.x,o.y)){i=!1;break}if(i)return!0}return!1}};function mo(t,e,n,i,o,r){if(i.length<3)return;if(n.containsAll(i)){let c=[0,1,0],h=i[0];for(let m=1;m+1<i.length;m++){let d=i[m],p=i[m+1];t.tri([h.x*R,o,h.y*R],[d.x*R,o,d.y*R],[p.x*R,o,p.y*R],c,r)}return}let a=i.map(c=>[c.x,c.y]);a.push(a[0]);let s;try{s=ho.intersection([a],e)}catch{return}let l=[0,1,0];for(let c of s){if(!c.length||c[0].length<4)continue;let h=c[0],m=[],d=[];for(let f=0;f<h.length-1;f++)m.push(h[f][0],h[f][1]),d.push([h[f][0],h[f][1]]);if(d.length<3)continue;let p=Si(m,void 0,2);for(let f=0;f<p.length;f+=3){let u=d[p[f]],b=d[p[f+1]],y=d[p[f+2]];t.tri([u[0]*R,o,u[1]*R],[b[0]*R,o,b[1]*R],[y[0]*R,o,y[1]*R],l,r)}}}function vo(t,e,n,i,o,r,a){if(e.length<2)return;let s=a??_t(e),l=[0,1,0],c=r&&r.length>=3?[[...r.map(p=>[p.x,p.y]),[r[0].x,r[0].y]]]:null,h=r&&r.length>=3?new cn([[...r]]):null,m=p=>{t.setMaterial(2),p(),t.setMaterial(0)},d=p=>{t.setMaterial(3),p(),t.setMaterial(0)};for(let p=0;p<e.length;p++){let f=e[p];if(f.patch&&f.patch.length>=3){let P=[...f.patch],M=s[p].belowY??i;if(d(()=>{if(c&&h)mo(t,c,h,P,f.y,o.tread);else{let F=P[0];for(let O=1;O+1<P.length;O++){let L=P[O],H=P[O+1];t.tri([F.x*R,f.y,F.y*R],[L.x*R,f.y,L.y*R],[H.x*R,f.y,H.y*R],l,o.tread)}}}),f.y>M+lo){let F=0,O=0;for(let L of P)F+=L.x,O+=L.y;F/=P.length,O/=P.length,m(()=>{for(let L=0;L<P.length;L++){let H=P[L],_=P[(L+1)%P.length],g=_.x-H.x,w=_.y-H.y,E=Math.hypot(g,w);if(E<1e-6)continue;let C=w/E,N=-g/E;(H.x-F)*C+(H.y-O)*N<0&&(C=-C,N=-N);let S=[C,0,N],I=[H.x*R,f.y,H.y*R],T=[_.x*R,f.y,_.y*R],B=[H.x*R,M,H.y*R],A=[_.x*R,M,_.y*R];t.tri(I,T,A,S,o.riser),t.tri(I,A,B,S,o.riser)}})}continue}let u=fo(e,p,s,n);if(!u)continue;let{pts:b,nrm:y,front:x,back:v}=u,k=s[p].belowY??i;for(let P=0;P+1<b.length;P++){let M=b[P],F=b[P+1],O=y[P],L=y[P+1];if(Math.hypot(F.x-M.x,F.y-M.y)<1e-6||O[0]===0&&O[1]===0||L[0]===0&&L[1]===0)continue;let H=[(M.x-O[0]*x)*R,f.y,(M.y-O[1]*x)*R],_=[(F.x-L[0]*x)*R,f.y,(F.y-L[1]*x)*R],g=[(M.x+O[0]*v)*R,f.y,(M.y+O[1]*v)*R],w=[(F.x+L[0]*v)*R,f.y,(F.y+L[1]*v)*R];if(d(()=>{c&&h?mo(t,c,h,[{x:M.x-O[0]*x,y:M.y-O[1]*x},{x:F.x-L[0]*x,y:F.y-L[1]*x},{x:F.x+L[0]*v,y:F.y+L[1]*v},{x:M.x+O[0]*v,y:M.y+O[1]*v}],f.y,o.tread):(t.tri(H,_,w,l,o.tread),t.tri(H,w,g,l,o.tread))}),f.y>k+lo){let E=[H[0],k,H[2]],C=[_[0],k,_[2]],N=[-O[0],0,-O[1]];m(()=>{t.tri(H,_,C,N,o.riser),t.tri(H,C,E,N,o.riser)})}}}}import So from"polygon-clipping";function Ei(t,e){let n=t.eventConfigurationIds;return!n?.length||!!e&&n.includes(e)}function Mo(t,e){return t.filter(n=>n.type!=="shape"||Ei(n,e))}function wo(t,e){let n=t.focalPoint??{x:0,y:0};return t.floors?.length?t.floors.map((i,o)=>({objects:Mo(i.objects,e),focal:{x:(i.focalPoint??n).x,y:(i.focalPoint??n).y},baseHeightM:i.baseHeightM??0,index:o})):[{objects:Mo(t.objects,e),focal:n,baseHeightM:0,index:0}]}var Di={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Je(t){return Dn(t)??Di}function Po(t,e){let n=Dt(t.outline,fe),i=Je(n),o=e.filter(a=>a!==t&&a.outline&&a.outline.length>=3&&Pt(i,Je(a.outline)));if(!o.length)return[n];let r=a=>{let s=a.map(l=>[l.x,l.y]);return s.push(s[0]),s};try{let a=So.difference([r(n)],...o.map(l=>[r(l.outline)])),s=[];for(let l of a){if(!l.length)continue;let c=l[0].map(([h,m])=>({x:h,y:m}));if(c.length>1){let h=c[0],m=c[c.length-1];Math.abs(h.x-m.x)<1e-9&&Math.abs(h.y-m.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s.length?s:[n]}catch{return[n]}}function Ao(t,e){if(!e.length)return t;let n=r=>{let a=r.map(s=>[s.x,s.y]);return a.push(a[0]),a},i=e.map(r=>[n(r)]),o=[];for(let r of t){let a;try{a=So.intersection([n(r.outline)],i.flat())}catch{o.push(r);continue}for(let s of a){if(!s.length)continue;let l=s[0].map(([c,h])=>({x:c,y:h}));if(l.length>1){let c=l[0],h=l[l.length-1];Math.abs(c.x-h.x)<1e-9&&Math.abs(c.y-h.y)<1e-9&&l.pop()}l.length>=3&&o.push({outline:l,holes:[],topY:r.topY})}}return o.length?o:t}var ki=.05,Co=.05,Li=.15,ln=25;function Ro(t,e,n){let i=new Map,o=new Array(e.length).fill(null),r=new Float64Array(e.length),a=new Array(e.length).fill(void 0),s=new Array(e.length).fill(void 0),l=new Map,c=[],h=new Set;for(let m=0;m<t.length;m+=1){let d=t[m];for(let p of d.objects){if(p.type==="table"&&h.add(p.id),p.type!=="section"||!p.outline||p.outline.length<3)continue;let f=Dt(p.outline,fe);l.set(p.id,{section:p,unit:d,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),c.push({id:p.id,floorIndex:m,box:Je(f),section:p,unit:d,outline:f})}}for(let m=0;m<e.length;m++){let d=e[m];for(let p of c){if(n&&p.floorIndex!==n[m]||d.x<p.box.minX||d.x>p.box.maxX||d.y<p.box.minY||d.y>p.box.maxY||!Fn({x:d.x,y:d.y},p.outline,p.section.holes))continue;o[m]=p.id;let f=l.get(p.id);f.hasSeats=!0;let u=d.focalPoint??p.unit.focal,b=Math.hypot(d.x-u.x,d.y-u.y);b<f.frontU&&(f.frontU=b),f.seatIndices.push(m);let y=d.rowId||`__seat-${m}`,x=f.rows.get(y);x?x.push({x:d.x,y:d.y}):f.rows.set(y,[{x:d.x,y:d.y}]);break}}for(let[m,d]of l){let p=In(d.section,{floorBaseHeightM:d.unit.baseHeightM}),f=d.unit.baseHeightM,u=p.rake>0?Math.tan(p.rake*Math.PI/180):0,b=p.rake<=.01&&p.height<=f+.001,y=d.section.surfaceKind,x=y==="flat"?!0:y==="rakedRows"&&p.rake>.01?!1:b,v=d.hasSeats?Tn(m,e,d.seatIndices,d.unit.focal):{sectionId:m,rows:[],blockCount:0},P=v.rows.length<2?On([...d.rows.values()].map(S=>({points:S})),d.unit.focal):null,M=1/0;if(P){if(d.hasSeats)for(let S of d.rows.values())for(let I of S){let T=P.depthAt(I.x,I.y);T<M&&(M=T)}if(!d.hasSeats||!Number.isFinite(M)){M=1/0;for(let S of d.section.outline){let I=P.depthAt(S.x,S.y);I<M&&(M=I)}}}let F=f+ki,O=Math.max(F,p.height),L=S=>{let I=Math.max(0,S-M)*ke,T=Math.min(I*u,ln);return Math.max(F,p.height+T)},H=S=>{let I=Math.max(0,S)*ke,T=Math.min(I*u,ln);return Math.max(F,p.height+T)},_=x?[]:v.rows.map(S=>({pts:S.pts,y:H(S.blockDepth),depth:S.blockDepth,blockId:S.blockId,...h.has(S.id)?{patch:po(S.pts,fe)}:{}})),g=_.length?_[0].y:O,w=_.map(S=>{let I=S.patch&&S.patch.length>=3?S.patch:S.pts,T=0,B=0;for(let V of I)T+=V.x,B+=V.y;let A=I.length||1;T/=A,B/=A;let D=0;for(let V of I){let U=Math.hypot(V.x-T,V.y-B);U>D&&(D=U)}return{cx:T,cy:B,rad:D}}),E=x?()=>O:_.length>=2?(S,I)=>{let T=1/0,B=g;for(let A=0;A<_.length;A++){let D=w[A];if(Math.hypot(S-D.cx,I-D.cy)-D.rad>=T)continue;let V=_[A].patch,U=V&&V.length>=3?st(V,S,I)?0:wt(V,S,I):wt(_[A].pts,S,I);U<T&&(T=U,B=_[A].y)}return B}:(S,I)=>P?L(P.depthAt(S,I)):O,C=[0,1,0],N=_.length>=2||x?()=>C:(S,I)=>{if(!P)return C;let T=P.depthAt(S,I);if(T<=M)return C;let B=(T-M)*ke;if(B*u>=ln||p.height+B*u<=F)return C;let[A,D]=P.gradientAt(S,I);if(A===0&&D===0)return C;let V=1/Math.hypot(u,1);return[-A*u*V,V,-D*u*V]};if(!x)for(let S of v.rows){let I=H(S.blockDepth);for(let T of S.seatIndices)a[T]=I}for(let S of v.rows){let I=[];for(let V=1;V<S.pts.length;V++){let U=Math.hypot(S.pts[V].x-S.pts[V-1].x,S.pts[V].y-S.pts[V-1].y);U>1e-6&&I.push(U)}I.sort((V,U)=>V-U);let T=I.length?I[Math.floor(I.length/2)]:1/0,B=1/0,A=S.pts[Math.floor(S.pts.length/2)];if(A)for(let V of v.rows){if(V===S||V.blockId!==S.blockId)continue;let U=wt(V.pts,A.x,A.y);U>1e-6&&U<B&&(B=U)}let D=Math.min(T,Math.max(B,T*.5));if(Number.isFinite(D)&&D>0)for(let V of S.seatIndices)s[V]=D}i.set(m,{sectionId:m,deckAt:E,normalAt:N,flat:x,bottomY:f,rowLevels:_,landingY:g})}for(let m=0;m<e.length;m++){let d=o[m],p=e[m];if(d){let u=a[m];r[m]=(u??i.get(d).deckAt(p.x,p.y))+Li;continue}let f=p.eyeHeightM;r[m]=Number.isFinite(f)?Math.max(0,f-St):0}return{bySection:i,seatOwner:o,seatDeckY:m=>r[m],seatPitchU:m=>s[m]}}var re={top:1,wallBottom:.5,bottomCap:.4};function Ie(t,e){if(!t)return e;let n=pe(at(t,.4),.62);return he(e,n,.72)}function Io(t,e){let n=new Map;for(let r of t.categories??[])n.set(r.key,r.color);let i=new Map;for(let r of e){if(!r.sectionId)continue;let a=i.get(r.sectionId);a||(a=new Map,i.set(r.sectionId,a)),a.set(r.categoryKey,(a.get(r.categoryKey)??0)+1)}let o=new Map;for(let[r,a]of i){let s=0,l=0,c=0,h=0;for(let[m,d]of a){let p=K(n.get(m));p&&(s+=p[0]*d,l+=p[1]*d,c+=p[2]*d,h+=d)}h>0&&o.set(r,[s/h,l/h,c/h])}return o}function To(t,e){return K(t.color)??e.get(t.logicalSectionId??t.id)??null}import _i from"polygon-clipping";function Oi(t,e){return t===void 0||e===void 0?!0:Math.abs(t-e)<.001}var Ot=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(e,n){let i=e.map(l=>[l.x,l.y]);if(i.length<3)return[];i.push(i[0]);let o=Je(e),r=this.rings.filter((l,c)=>Pt(o,this.boxes[c])&&Oi(n,this.levels[c])),a=[[i]];if(r.length)try{a=_i.difference([i],...r).map(c=>c.map(h=>h.map(([m,d])=>[m,d])))}catch{a=[[i]]}this.rings.push([i]),this.boxes.push(o),this.levels.push(n);let s=[];for(let l of a){if(!l.length)continue;let c=l[0].map(([h,m])=>({x:h,y:m}));if(c.length>1){let h=c[0],m=c[c.length-1];Math.abs(h.x-m.x)<1e-9&&Math.abs(h.y-m.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s}};function Bi(t,e){if(!e)return t;let n=1/0,i=-1/0,o=1/0,r=-1/0;for(let m of t)n=Math.min(n,m.x),i=Math.max(i,m.x),o=Math.min(o,m.y),r=Math.max(r,m.y);let a=(n+i)/2,s=(o+r)/2,l=e*Math.PI/180,c=Math.cos(l),h=Math.sin(l);return t.map(m=>{let d=m.x-a,p=m.y-s;return{x:a+d*c-p*h,y:s+d*h+p*c}})}function ht(t){let e=null;if(t.kind==="polygon"&&t.points&&t.points.length>=3&&(e=t.points),t.kind==="rect"&&t.width&&t.height&&(e=dt(t.x??0,t.y??0,t.width,t.height)),t.kind==="ellipse"&&t.width&&t.height){let n=(t.x??0)+t.width/2,i=(t.y??0)+t.height/2;e=kt(n,i,t.width/2,t.height/2)}return e?Bi(e,t.rotation):null}function pt(t){let e=t.role??"",i={stage:{kind:"stage",heightM:1},entrance:{kind:"portal",heightM:2.7},exit:{kind:"portal",heightM:2.7},screen:{kind:"solid",heightM:6},wall:{kind:"solid",heightM:2.8},rail:{kind:"solid",heightM:1.1},suite:{kind:"suite",heightM:3},obstruction:{kind:"solid",heightM:4.5},sound:{kind:"solid",heightM:1.45},restroom:{kind:"solid",heightM:2.4},bar:{kind:"solid",heightM:1.1},concession:{kind:"solid",heightM:1.1},coat:{kind:"solid",heightM:1.1},goal:{kind:"portal",heightM:1.8}}[e]??{kind:"plate",heightM:.25};return{...i,heightM:t.heightM??i.heightM}}var Vi=.08;function Fo(t,e){let n=ht(t),i=pt(t),o=i.heightM;if(!n||i.kind!=="plate"&&i.kind!=="stage")return o;let r=1/0,a=1/0,s=-1/0,l=-1/0;for(let h of n)r=Math.min(r,h.x),a=Math.min(a,h.y),s=Math.max(s,h.x),l=Math.max(l,h.y);let c=o;for(let h of e)s>h.minX&&r<h.maxX&&l>h.minY&&a<h.maxY&&c<=h.topOffsetM+1e-6&&(c=h.topOffsetM+Vi);return e.push({minX:r,minY:a,maxX:s,maxY:l,topOffsetM:c}),c}function _e(t,e,n){return{x:t.x+(e.x-t.x)*n,y:t.y+(e.y-t.y)*n}}function Eo(t){if(t.length!==4)return t;let e=Math.hypot(t[1].x-t[0].x,t[1].y-t[0].y),n=Math.hypot(t[2].x-t[1].x,t[2].y-t[1].y);return e>=n?t:[t[1],t[2],t[3],t[0]]}function ft(t,e,n){return[_e(t[0],t[1],e),_e(t[0],t[1],n),_e(t[3],t[2],n),_e(t[3],t[2],e)]}function Do(t,e,n){return[_e(t[0],t[3],e),_e(t[1],t[2],e),_e(t[1],t[2],n),_e(t[0],t[3],n)]}function Te(t,e,n,i,o,r){ie(t,e,void 0,()=>n,i,o,r,re)}var un=2.4,Ni=.75,zi=.15;function bt(t){if(t.points&&t.points.length>=3)return t.points;let{center:e,width:n,height:i,rotation:o}=t;if(!n||!i)return null;let r=(o??0)*Math.PI/180,a=Math.cos(r),s=Math.sin(r),l=n/2,c=i/2;return[[-l,-c],[l,-c],[l,c],[-l,c]].map(([h,m])=>({x:e.x+h*a-m*s,y:e.y+h*s+m*a}))}function ko(t,e,n,i,o){let r=bt(e);r&&ie(t,r,void 0,()=>n+un,n,Ie(i,o.boothTop),o.boothWall,re)}function mn(t){if(t.shape==="round"){let h=t.radius;return h?kt(t.center.x,t.center.y,h,h,24):null}let{width:e,height:n,rotation:i,center:o}=t;if(!e||!n)return null;let r=(i??0)*Math.PI/180,a=Math.cos(r),s=Math.sin(r),l=e/2,c=n/2;return[[-l,-c],[l,-c],[l,c],[-l,c]].map(([h,m])=>({x:o.x+h*a-m*s,y:o.y+h*s+m*a}))}function Lo(t,e,n,i,o){let r=mn(e);r&&ie(t,r,void 0,()=>n+Ni,n,Ie(i,o.tableTop),o.tableWall,re)}function _o(t,e,n,i,o,r,a){let s=ht(e);if(!s)return;let l=e.role==="stage",c=pt(e),h=n+i;if(l&&a){let u=1/0,b=-1/0,y=1/0,x=-1/0;for(let v of s)v.x<u&&(u=v.x),v.x>b&&(b=v.x),v.y<y&&(y=v.y),v.y>x&&(x=v.y);a.push({cx:(u+b)/2*R,cz:(y+x)/2*R,y:h,halfX:Math.max((b-u)/2*R,.5),halfZ:Math.max((x-y)/2*R,.5)})}let m=K(e.fill),d=l&&m?he(o.stageTop,pe(at(m,.18),.9),.9):Ie(m,l?o.stageTop:o.decorTop),p=e.role==="screen"?m:null,f=l?m?he(o.stageWall,pe(m,.58),.82):o.stageWall:e.role==="screen"?p?he(pe(p,1.42),[.24,.46,.82],.08):[.24,.46,.82]:Ie(K(e.fill),o.decorWall);if(c.kind==="portal"&&s.length===4){let u=Eo(s);Te(t,ft(u,0,.16),h,n,d,f),Te(t,ft(u,.84,1),h,n,d,f),Te(t,u,h,Math.max(n,h-.35),d,f);return}if(c.kind==="suite"&&s.length===4){let u=s.map((x,v)=>{let k=s[(v+1)%4],P=(x.x+k.x)/2,M=(x.y+k.y)/2;return Math.hypot(P-r.x,M-r.y)}),b=u.indexOf(Math.min(...u)),y=[0,1,2,3].map(x=>s[(b+x)%4]);Te(t,ft(y,0,.08),h,n,d,f),Te(t,ft(y,.92,1),h,n,d,f),Te(t,Do(y,.88,1),h,n,d,f),Te(t,y,h,Math.max(n,h-.18),d,f);return}Te(t,s,h,n,d,f)}function dn(t){let{x:e,y:n,width:i,height:o}=t;if(!i||!o)return null;let r=e+i/2,a=n+o/2,s=(t.rotation??0)*Math.PI/180,l=Math.cos(s),c=Math.sin(s),h=i/2,m=o/2;return[[-h,-m],[h,-m],[h,m],[-h,m]].map(([d,p])=>({x:r+d*l-p*c,y:a+d*c+p*l}))}function Gi(t){if(!t||!t.startsWith("data:image/svg+xml"))return null;let e=t.slice(t.indexOf(",")+1);if(/;base64/i.test(t.slice(0,t.indexOf(","))))try{e=atob(e)}catch{return null}else try{e=decodeURIComponent(e)}catch{}let n=e.match(/<(?:rect|path)\b[^>]*\bfill="([^"]+)"/i);if(!n)return null;let i=n[1].trim();if(i==="none"||i==="transparent")return null;let o=i.match(/^url\(#([^)]+)\)$/);if(!o)return K(i);let r=e.match(new RegExp(`<(?:linear|radial)Gradient\\b[^>]*\\bid="${o[1]}"[^>]*>([\\s\\S]*?)</(?:linear|radial)Gradient>`,"i"));if(!r)return null;let a=[];for(let s of r[1].matchAll(/stop-color="([^"]+)"/gi)){let l=K(s[1].trim());l&&a.push(l)}return a.length?a.reduce((s,l,c)=>he(s,l,1/(c+1)),a[0]):null}function Oo(t,e,n,i){if(e.layer==="foreground")return;let o=dn(e);if(!o)return;let r=n+zi,a=Ie(Gi(e.href),i.decorTop),s=Math.max(0,Math.min(1,e.opacity??1));s<1&&(a=he(i.ground,a,s)),ie(t,o,void 0,()=>r,n,a,he(a,i.decorWall,.5),re)}function Bo(t,e,n,i,o){if(!e.points||e.points.length<3)return;let r=Ie(i,o.gaTop);ie(t,e.points,e.holes,()=>n+.15,n,r,o.gaWall,re)}var Hi=.25,Ui=1.2,Xi=.6,Yi=.45,Wi=2.3,ji=Math.PI/180;function Ye(t,e,n){let i=n*ji;return{x:t.x+e*Math.sin(i),y:t.y+e*Math.cos(i)}}function qi(t,e){let n=e.rings[e.rings.length-1];if(!n)return!1;let i=n.outerRMedian*.85;for(let o of t){if(o.role!=="wall")continue;let r=o.points&&o.points.length>=2?o.points:o.x!==void 0&&o.y!==void 0&&o.width!==void 0&&o.height!==void 0?[{x:o.x,y:o.y},{x:o.x+o.width,y:o.y},{x:o.x+o.width,y:o.y+o.height},{x:o.x,y:o.y+o.height}]:[];if(r.length<2)continue;let a=0;for(let s of r)Math.hypot(s.x-e.centre.x,s.y-e.centre.y)>=i&&a++;if(a>=r.length/2)return!0}return!1}var Zi=24;function Ki(t,e,n,i,o,r,a,s){let l=n.binCount,c=Zi,h=ke,m=r+.02,d=[];for(let g=0;g<l;g++){let w=(n.startBin+g+.5)*e.binStepDeg,E=new Float64Array(c+1);for(let C=0;C<=c;C++){let N=i[g]+(o[g]-i[g])*C/c;E[C]=Math.max(m,Vn(e,n,w,N)-Hi)}d.push(E)}let p=[a.bandTop[0]*s.top,a.bandTop[1]*s.top,a.bandTop[2]*s.top],f=[a.bandTop[0]*s.bottomCap,a.bandTop[1]*s.bottomCap,a.bandTop[2]*s.bottomCap],u=[a.bandWall[0]*s.top,a.bandWall[1]*s.top,a.bandWall[2]*s.top],b=[a.bandWall[0]*s.wallBottom,a.bandWall[1]*s.wallBottom,a.bandWall[2]*s.wallBottom],y=(g,w)=>{let E=(n.startBin+g+.5)*e.binStepDeg,C=i[g]+(o[g]-i[g])*w/c,N=Ye(e.centre,C,E);return[N.x*h,d[g][w],N.y*h]};{let g=Math.tan(12*Math.PI/180);for(let w=0;w<6;w++){let E=!1;for(let N=0;N<l;N++)for(let S=c-1;S>=0;S--)d[N][S]>d[N][S+1]&&(d[N][S]=d[N][S+1],E=!0);let C=n.closed?l:l-1;for(let N=0;N<C;N++){let S=(N+1)%l;for(let I=0;I<=c;I++){let T=d[S][I]-d[N][I];if(Math.abs(T)>1)continue;let B=i[N]+(o[N]-i[N])*I/c,A=i[S]+(o[S]-i[S])*I/c,D=Ye(e.centre,B,(n.startBin+N+.5)*e.binStepDeg),V=Ye(e.centre,A,(n.startBin+S+.5)*e.binStepDeg),U=g*Math.hypot(V.x-D.x,V.y-D.y)*h;T>U?(d[S][I]=d[N][I]+U,E=!0):-T>U&&(d[N][I]=d[S][I]+U,E=!0)}}if(!E)break}}let x=1,v=(g,w)=>{for(let E=0;E<=c;E+=4)if(Math.abs(d[g][E]-d[w][E])>x)return!0;return Math.abs(d[g][c]-d[w][c])>x},k=Math.tan(38*Math.PI/180),P=g=>(o[g]-i[g])/c*h,M=(g,w)=>d[g][w+1]-d[g][w]>k*Math.max(1e-6,P(g)),F=(g,w)=>{let E=n.closed?(g-1+l)%l:Math.max(0,g-1),C=n.closed?(g+1)%l:Math.min(l-1,g+1);Math.abs(d[E][w]-d[g][w])>x&&(E=g),Math.abs(d[C][w]-d[g][w])>x&&(C=g);let N=Math.max(0,w-1),S=Math.min(c,w+1);N<w&&M(g,N)&&(N=w),S>w&&M(g,w)&&(S=w);let I=y(E,w),T=y(C,w),B=y(g,N),A=y(g,S),D=T[0]-I[0],V=T[1]-I[1],U=T[2]-I[2],Y=A[0]-B[0],X=A[1]-B[1],j=A[2]-B[2],Z=V*j-U*X,te=U*Y-D*j,ne=D*X-V*Y,Q=Math.hypot(Z,te,ne);return Q>1e-12?(Z/=Q,te/=Q,ne/=Q,te<0&&(Z=-Z,te=-te,ne=-ne),[Z,te,ne]):[0,1,0]},O=(g,w)=>{let E=[g[0],r,g[2]],C=[w[0],r,w[2]],N=w[0]-g[0],S=w[2]-g[2],I=Math.hypot(N,S);if(!(I>1e-12))return;let T=[S/I,0,-N/I];t.tri(g,w,C,T,u,u,b),t.tri(g,C,E,T,u,b,b)},L=.05*Le,H=g=>o[g]-i[g]<L,_=n.closed?l:l-1;for(let g=0;g<_;g++){let w=(g+1)%l;if(H(g)||H(w))continue;if(v(g,w)){let T=(n.startBin+g+1)*e.binStepDeg,B=(X,j)=>{let Z=(i[g]+i[w])/2,te=(o[g]+o[w])/2,ne=Z+(te-Z)*j/c,Q=Ye(e.centre,ne,T);return[Q.x*h,d[X][j],Q.y*h]};for(let X=0;X<c;X++){let j=y(g,X),Z=y(g,X+1),te=B(g,X),ne=B(g,X+1),Q=F(g,X),ae=F(g,X+1);t.triN(j,te,ne,Q,Q,ae,p),t.triN(j,ne,Z,Q,ae,ae,p);let Be=y(w,X),Ve=y(w,X+1),Se=B(w,X),we=B(w,X+1),Pe=F(w,X),ye=F(w,X+1);t.triN(Se,Be,Ve,Pe,Pe,ye,p),t.triN(Se,Ve,we,Pe,ye,ye,p);let xe=B(g,X),oe=B(g,X+1),qe=B(w,X+1),Fe=B(w,X),Ae=oe[0]-xe[0],Ne=oe[2]-xe[2],nt=Math.hypot(Ae,Ne);if(nt>1e-12){let me=[Ne/nt,0,-Ae/nt];t.tri(xe,oe,qe,me,u),t.tri(xe,qe,Fe,me,u)}}let A=y(g,0),D=y(w,0),V=y(w,c),U=y(g,c),Y=X=>[X[0],r,X[2]];t.tri(Y(A),Y(V),Y(D),[0,-1,0],f),t.tri(Y(A),Y(U),Y(V),[0,-1,0],f),O(A,D),O(U,V);continue}for(let T=0;T<c;T++){let B=F(g,T),A=F(w,T),D=F(w,T+1),V=F(g,T+1);if(M(g,T)||M(w,T)){let Z=(oe,qe)=>{let Fe=(n.startBin+oe+.5)*e.binStepDeg,Ae=i[oe]+(o[oe]-i[oe])*(T+.5)/c,Ne=Ye(e.centre,Ae,Fe);return[Ne.x*h,qe,Ne.y*h]},te=y(g,T),ne=y(w,T),Q=Z(g,d[g][T]),ae=Z(w,d[w][T]);t.triN(te,ne,ae,B,A,A,p),t.triN(te,ae,Q,B,A,B,p);let Be=y(w,T+1),Ve=y(g,T+1),Se=Z(g,d[g][T+1]),we=Z(w,d[w][T+1]);t.triN(Se,we,Be,V,D,D,p),t.triN(Se,Be,Ve,V,D,V,p);let Pe=ae[0]-Q[0],ye=ae[2]-Q[2],xe=Math.hypot(Pe,ye);if(xe>1e-12){let oe=[-ye/xe,0,Pe/xe];t.tri(Q,ae,we,oe,u),t.tri(Q,we,Se,oe,u)}continue}let U=y(g,T),Y=y(w,T),X=y(w,T+1),j=y(g,T+1);t.triN(U,Y,X,B,A,D,p),t.triN(U,X,j,B,D,V,p)}let E=y(g,0),C=y(w,0),N=y(w,c),S=y(g,c),I=T=>[T[0],r,T[2]];t.tri(I(E),I(N),I(C),[0,-1,0],f),t.tri(I(E),I(S),I(N),[0,-1,0],f),O(E,C),O(S,N)}if(!n.closed)for(let g of[0,l-1])for(let w=0;w<c;w++)O(y(g,w),y(g,w+1))}function Vo(t,e,n){let{bottomY:i,colors:o,ao:r}=n,a=new Float64Array(e.binCount).fill(-1/0);for(let h of e.rings)for(let m of h.arcs){let d=new Float64Array(m.binCount),p=new Float64Array(m.binCount);for(let u=0;u<m.binCount;u++){let b=(m.startBin+u)%e.binCount,y=Math.max(0,m.innerR[u]-fe);d[u]=Math.max(y,a[b]+.001),p[u]=Math.max(d[u]+.001,m.outerR[u]+fe)}let f=0;for(let u=0;u<m.binCount;u++){let b=m.topLevelM[u]-i;b>f&&(f=b)}f>=Ui&&Ki(t,e,m,d,p,i,o,r);for(let u=0;u<m.binCount;u++){let b=(m.startBin+u)%e.binCount;p[u]>a[b]&&(a[b]=p[u])}}if(qi(n.shapes,e))return;let s=e.rings[e.rings.length-1],l=Xi*Le,c=Yi*Le;for(let h of s.arcs){let m=[],d=[];for(let u=0;u<h.binCount;u++){let b=(h.startBin+u+.5)*e.binStepDeg,y=h.outerR[u]+fe+l;m.push(Ye(e.centre,y,b)),d.push(Ye(e.centre,y+c,b))}let p=-1/0;for(let u=0;u<h.binCount;u++)h.topLevelM[u]>p&&(p=h.topLevelM[u]);let f=()=>p+Wi;h.closed?ie(t,d,[m.slice().reverse()],f,i,o.shellTop,o.shellWall,r):ie(t,[...d,...m.slice().reverse()],void 0,f,i,o.shellTop,o.shellWall,r)}}function No(t,e,n,i,o,r,a,s){if(!e.outline||e.outline.length<3)return;let l=n.baseHeightM,c=Ie(i,s.tierTop);if(!o)return;let h=b=>o.deckAt(b.x,b.y),m=Po(e,a),d=m[0]??e.outline;if(o.rowLevels.length>=2){let b=_t(o.rowLevels),y=Ao(xo(o.rowLevels,n.focal,b),m),x=()=>[0,1,0];for(let k of y){let P=Math.max(l,k.topY-.02);for(let M of r.subtract(k.outline,P))ie(t,M,k.holes,()=>P,l,c,s.tierWall,re,void 0,x)}y.length||ie(t,d,e.holes,()=>o.landingY,l,c,s.tierWall,re);let v={tread:[c[0]*re.top,c[1]*re.top,c[2]*re.top],riser:[c[0]*.72,c[1]*.72,c[2]*.72]};for(let k of m.length?m:[d])vo(t,o.rowLevels,n.focal,o.landingY,v,k,b);return}let p=o.flat?1/0:Co,f=b=>o.normalAt(b.x,b.y),u=o.flat?o.landingY:void 0;for(let b of r.subtract(d,u))ie(t,b,e.holes,h,l,c,s.tierWall,re,p,f)}function Qi(t,e,n){let i=new Set;for(let a of t.objects)a.type==="section"&&i.add(a.id);let o=new Map;for(let a=0;a<e.length;a++){let s=n.seatOwner[a];if(!s||!i.has(s))continue;let l=n.bySection.get(s);if(l&&l.rowLevels.length>=2)continue;let c=e[a],h=o.get(s);h||(h=new Map,o.set(s,h));let m=c.rowId||`__seat-${a}`,d=h.get(m);d||(d={pts:[],levelM:0,n:0},h.set(m,d)),d.pts.push({x:c.x,y:c.y}),d.levelM+=n.seatDeckY(a),d.n++}let r=[];for(let a of t.objects){if(a.type!=="section")continue;let s=n.bySection.get(a.id);if(s&&s.rowLevels.length>=2){let c=s.rowLevels.filter(h=>!h.patch).map(h=>({pts:h.pts,levelM:h.y}));c.length>=2&&r.push({sectionId:a.id,rows:c});continue}let l=o.get(a.id);l&&r.push({sectionId:a.id,rows:[...l.values()].map(c=>({pts:c.pts,levelM:c.levelM/c.n}))})}return r}function zo(t,e,n,i,o){let r=Qi(e,n,i);if(!r.length)return;let a=Bn(r,e.focal);a&&(t.setMaterial(0),Vo(t,a,{bottomY:e.baseHeightM,colors:{bandTop:pe(o.tierTop,.8),bandWall:o.tierWall,shellTop:pe(o.tierWall,1.15),shellWall:o.tierWall},ao:re,shapes:e.objects.filter(s=>s.type==="shape")}))}function Go(t,e,n){return n<0?e>1?t.filter(i=>i.kind==="floor"):[...t]:t.filter(i=>i.floorIndex===void 0||i.floorIndex===n)}function Ho(t,e){let n=[...t].sort((o,r)=>o.screen.y-r.screen.y),i=[];for(let o of n){let r=i.find(a=>a.some(s=>Math.abs(s.screen.x-o.screen.x)<104&&Math.abs(s.screen.y-o.screen.y)<34));r?r.push(o):i.push([o])}return i.flatMap(o=>o.length<2?o:o.map((r,a)=>({...r,screen:{...r.screen,x:Math.max(54,Math.min(e-54,r.screen.x+(a-(o.length-1)/2)*104))}})))}var $i=1.15,Ji=3.25,ea=4.5,ta=.85,na=.5,oa=.26;function Uo(t,e,n){let i=Math.max(1e-6,e),o=t/i,r=n?.hasZoneLabels??!0,a=new Set;return o>=.75&&a.add("floor"),o>=$i&&a.add("zone"),o<=(r?Ji:ea)&&(a.add("section"),a.add("ga")),o<=ta&&(a.add("annotation"),a.add("booth")),o<=na&&a.add("row"),o<=oa&&a.add("seat"),a}function Oe(t,e,n,i){let o=t,r=e[0],a=e[1],s=e[2],l=o[0]*r+o[4]*a+o[8]*s+o[12],c=o[1]*r+o[5]*a+o[9]*s+o[13],h=o[2]*r+o[6]*a+o[10]*s+o[14],m=o[3]*r+o[7]*a+o[11]*s+o[15];if(!(m>1e-6))return{x:0,y:0,depth:1/0,visible:!1};let d=l/m,p=c/m,f=h/m,u=d>=-1.05&&d<=1.05&&p>=-1.05&&p<=1.05&&f<=1;return{x:(d*.5+.5)*n,y:(1-(p*.5+.5))*i,depth:f,visible:u}}function Xo(t,e,n=e){let i=[],o=[...t].sort((r,a)=>r.screen.depth-a.screen.depth);for(let r of o){let a=!1;for(let s of i){let l=Math.abs(r.screen.x-s.screen.x),c=Math.abs(r.screen.y-s.screen.y);if(l<e&&c<n){a=!0;break}}a||i.push(r)}return i}var Yo={row:8,seat:14};function Wo(t,e,n,i){let o=Math.max(1,Math.min(n,i)*.5),r=Math.min(2,Math.hypot(t.x-n/2,t.y-i/2)/o);return e*(1+1.5*r)}function jo(t,e,n,i){let o=[...t].sort((a,s)=>(s.priority??0)-(a.priority??0)||a.focus-s.focus),r=[];for(let a of o){if(r.length>=i)break;let s=!1;for(let l of r)if(Math.abs(a.screen.x-l.screen.x)<e&&Math.abs(a.screen.y-l.screen.y)<n){s=!0;break}s||r.push(a)}return r}var ra=6,ia=2.2,qo=.1,aa=.3,sa=1.8,ca=.9,la=.55,ua=6e3;function Zo(t){let{doc:e,units:n,seats:i,surfaces:o,focal:r}=t,a=e.zones??[],s=[];if(a.length){let l=new Map;for(let h of n)for(let m of h.objects)m.type==="section"&&m.zone&&l.set(m.id,m.zone);let c=new Map;for(let h=0;h<i.length;h++){let m=i[h],d=o.seatOwner[h],p=m.zoneId??(d?l.get(d):void 0);if(!p)continue;let f=c.get(p);f||(f={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},c.set(p,f)),f.n++,m.x<f.minX&&(f.minX=m.x),m.y<f.minY&&(f.minY=m.y),m.x>f.maxX&&(f.maxX=m.x),m.y>f.maxY&&(f.maxY=m.y),f.sumY+=o.seatDeckY(h)}for(let h of a){let m=c.get(h.id),d=[];for(let[p,f]of l)f===h.id&&d.push(p);if(!m||m.n===0){s.push({id:h.id,label:h.label,color:K(h.color),sectionIds:d,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(h.focalPoint??r).x*R,1.5,(h.focalPoint??r).y*R]});continue}s.push({id:h.id,label:h.label,color:K(h.color),sectionIds:d,seatCount:m.n,center:[(m.minX+m.maxX)/2*R,m.sumY/m.n,(m.minY+m.maxY)/2*R],radius:.5*Math.hypot((m.maxX-m.minX)*R,(m.maxY-m.minY)*R)||1,focalWorld:[(h.focalPoint??r).x*R,1.5,(h.focalPoint??r).y*R]})}}return s}function Ko(t){let{doc:e,units:n,seats:i,surfaces:o,seatData:r,hintedSeatFloor:a,zones:s,focal:l}=t,c=[],h=[],m=[];for(let d of s)d.seatCount!==0&&c.push({id:`zone:${d.id}`,kind:"zone",text:d.label,anchor:[d.center[0],d.center[1]+ra,d.center[2]],color:e.zones?.find(p=>p.id===d.id)?.color});{let d=new Map,p=new Map;for(let f=0;f<i.length;f++){let u=o.seatOwner[f];if(!u)continue;let b=d.get(u);b||(b={n:0,x:0,y:0,deck:0},d.set(u,b)),b.n++,b.x+=i[f].x,b.y+=i[f].y,b.deck+=o.seatDeckY(f);let y=p.get(u);y||(y={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0},p.set(u,y)),i[f].x<y.minX&&(y.minX=i[f].x),i[f].x>y.maxX&&(y.maxX=i[f].x),i[f].y<y.minY&&(y.minY=i[f].y),i[f].y>y.maxY&&(y.maxY=i[f].y)}for(let f of n)for(let u of f.objects){if(u.type!=="section")continue;let b=d.get(u.id);if(!b||b.n===0)continue;let y=p.get(u.id),x=[b.x/b.n*R,b.deck/b.n,b.y/b.n*R],v=u.displayLabel||u.label||u.id;h.push({id:u.id,floorIndex:f.index,label:v,seatCount:b.n,center:x,radius:Math.max(1,Math.hypot(y.maxX-y.minX,y.maxY-y.minY)*.5*R),focalWorld:[f.focal.x*R,f.baseHeightM+1.5,f.focal.y*R]});let k=e.floors?.[f.index]?.name?.trim().toLocaleLowerCase();n.length>1&&k===v.trim().toLocaleLowerCase()||c.push({id:`section:${u.id}`,kind:"section",text:v,anchor:[x[0],x[1]+ia,x[2]],floorIndex:f.index})}}{for(let f of n)for(let u of f.objects){if(u.type!=="gaArea")continue;let b=it(u.points);if(!b)continue;let y=u.displayLabel||u.label||u.id;c.push({id:`ga:${u.id}`,kind:"ga",text:u.capacity>0?`${y} \xB7 ${u.capacity.toLocaleString()}`:y,anchor:[b.x*R,f.baseHeightM+sa,b.y*R],floorIndex:f.index})}let d=new Map;for(let f=0;f<i.length;f++){let u=i[f],b=Math.hypot(u.x-l.x,u.y-l.y),y=d.get(u.rowId);(!y||b>y.far)&&d.set(u.rowId,{seat:u,index:f,far:b})}for(let[f,u]of d){let b=u.seat.label?u.seat.label.lastIndexOf("-"):-1,y=b>0?u.seat.label.slice(0,b):f;y&&c.push({id:`row:${f}`,kind:"row",text:y,anchor:[u.seat.x*R,o.seatDeckY(u.index)+ca,u.seat.y*R],floorIndex:a[u.index]})}let p=new Map;for(let f=0;f<i.length;f++){let u=i[f],b=u.label?u.label.lastIndexOf("-"):-1,y=p.get(u.rowId);y||(y={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:b>0?u.label.slice(0,b):u.rowId,sectionId:u.sectionId},p.set(u.rowId,y));let x=f*3,v=r.iPosition[x],k=r.iPosition[x+1],P=r.iPosition[x+2];y.n++,y.x+=v,y.y+=k,y.z+=P,y.minX=Math.min(y.minX,v),y.maxX=Math.max(y.maxX,v),y.minZ=Math.min(y.minZ,P),y.maxZ=Math.max(y.maxZ,P)}for(let[f,u]of p)m.push({id:f,label:u.label,sectionId:u.sectionId,seatCount:u.n,center:[u.x/u.n,u.y/u.n,u.z/u.n],radius:Math.max(.8,Math.hypot(u.maxX-u.minX,u.maxZ-u.minZ)*.5)});if(i.length<=ua)for(let f=0;f<i.length;f++){let u=i[f],b=u.displayLabel||u.label;b&&c.push({id:`seat:${u.id}`,kind:"seat",text:b,anchor:[u.x*R,o.seatDeckY(f)+la,u.y*R],floorIndex:a[f]})}}for(let d of n)for(let p of d.objects)if(p.type==="shape"&&p.role&&["entrance","exit","screen","suite","obstruction"].includes(p.role)){let f=ht(p),u=f?it(f):null;if(!u||!p.label)continue;c.push({id:`architecture:${p.id}`,kind:"annotation",text:p.label,anchor:[u.x*R,d.baseHeightM+pt(p).heightM+qo,u.y*R],color:p.fill,floorIndex:d.index})}else if(p.type==="text"){if(!p.text)continue;c.push({id:`text:${p.id}`,kind:"annotation",text:p.text,anchor:[p.position.x*R,d.baseHeightM+qo,p.position.y*R],color:p.color,rotation:p.rotation,floorIndex:d.index})}else if(p.type==="booth"){let f=bt(p);if(!f)continue;let u=it(f);if(!u)continue;c.push({id:`booth:${p.id}`,kind:"booth",text:p.displayLabel||p.label||p.id,anchor:[u.x*R,d.baseHeightM+un+aa,u.y*R],floorIndex:d.index})}return{labels:c,sections:h,rows:m}}function Qo(t,e){if(e.length>1)for(let n of e)t.push({id:`floor:${n.id}`,kind:"floor",text:n.label,anchor:[n.center[0],n.box.max[1]+1.2,n.center[2]],floorIndex:n.index})}function $o(t){let{doc:e,units:n,seats:i,surfaces:o,solids:r,hintedSeatFloor:a,seatFloor:s}=t,l=[];{let c=n.map(()=>({minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}));for(let d=0;d<r.floor.length;d+=1){let p=Math.max(0,Math.min(n.length-1,Math.round(r.floor[d]))),f=d*3,u=c[p];u.minX=Math.min(u.minX,r.position[f]),u.minY=Math.min(u.minY,r.position[f+1]),u.minZ=Math.min(u.minZ,r.position[f+2]),u.maxX=Math.max(u.maxX,r.position[f]),u.maxY=Math.max(u.maxY,r.position[f+1]),u.maxZ=Math.max(u.maxZ,r.position[f+2])}let h=new Map;for(let d=0;d<n.length;d++)for(let p of n[d].objects)p.type==="section"&&h.set(p.id,d);let m=n.map(()=>({n:0,minX:1/0,minY:1/0,minDeck:1/0,maxX:-1/0,maxY:-1/0,maxDeck:-1/0,sumX:0,sumDeck:0,sumZ:0}));for(let d=0;d<i.length;d++){let p=o.seatOwner[d],f=(p!==null?h.get(p):void 0)??a[d];if(f===void 0)continue;let u=m[f],b=i[d];u.n++,b.x<u.minX&&(u.minX=b.x),b.y<u.minY&&(u.minY=b.y),b.x>u.maxX&&(u.maxX=b.x),b.y>u.maxY&&(u.maxY=b.y);let y=o.seatDeckY(d);u.sumX+=b.x*R,u.sumDeck+=y,u.sumZ+=b.y*R,u.minDeck=Math.min(u.minDeck,y),u.maxDeck=Math.max(u.maxDeck,y+1.6),s[d]=f}for(let d=0;d<n.length;d++){let p=m[d],f=e.floors?.[d],u=c[d],b=Math.min(p.n?p.minX*R:n[d].focal.x*R-1,Number.isFinite(u.minX)?u.minX:1/0),y=Math.max(p.n?p.maxX*R:n[d].focal.x*R+1,Number.isFinite(u.maxX)?u.maxX:-1/0),x=Math.min(p.n?p.minY*R:n[d].focal.y*R-1,Number.isFinite(u.minZ)?u.minZ:1/0),v=Math.max(p.n?p.maxY*R:n[d].focal.y*R+1,Number.isFinite(u.maxZ)?u.maxZ:-1/0),k=Math.min(p.n?Math.min(n[d].baseHeightM,p.minDeck):n[d].baseHeightM,Number.isFinite(u.minY)?u.minY:1/0),P=Math.max(p.n?Math.max(p.maxDeck,k+.5):k+.5,Number.isFinite(u.maxY)?u.maxY:-1/0),M=[p.n?p.sumX/p.n:(b+y)/2,p.n?p.sumDeck/p.n:(k+P)/2,p.n?p.sumZ/p.n:(x+v)/2],F=Math.max(1,.5*Math.hypot(y-b,P-k,v-x));l.push({index:d,id:f?.id??`floor-${d}`,label:f?.name??(n.length>1?`Floor ${d+1}`:"Venue"),seatCount:p.n,center:M,radius:F,box:{min:[b,k,x],max:[y,P,v]},focalWorld:[n[d].focal.x*R,n[d].baseHeightM+1.5,n[d].focal.y*R]})}}return l}function hn(t,e){let n=1/0,i=1/0,o=-1/0,r=-1/0,a=(s,l)=>{s<n&&(n=s),l<i&&(i=l),s>o&&(o=s),l>r&&(r=l)};for(let s of e)a(s.x,s.y);for(let s of t)for(let l of s.objects)if(l.type==="section")for(let c of l.outline)a(c.x,c.y);else if(l.type==="shape"&&l.points)for(let c of l.points)a(c.x,c.y);else if(l.type==="gaArea")for(let c of l.points)a(c.x,c.y);else if(l.type==="booth"){let c=bt(l);if(c)for(let h of c)a(h.x,h.y)}else if(l.type==="table"){let c=mn(l);if(c)for(let h of c)a(h.x,h.y)}else if(l.type==="decorImage"){let c=dn(l);if(c)for(let h of c)a(h.x,h.y)}return Number.isFinite(n)||(n=-100,i=-100,o=100,r=100),{minX:n,minY:i,maxX:o,maxY:r}}function Jo(t,e,n,i,o,r){if(e.length===1){let a=Math.max(60,(o.maxX-o.minX+o.maxY-o.minY)*.06),s=dt(o.minX-a,o.minY-a,o.maxX-o.minX+a*2,o.maxY-o.minY+a*2);ie(t,s,void 0,()=>0,-.4,r.ground,r.ground,re)}else{let a=e.reduce((p,f)=>f.baseHeightM<p.baseHeightM?f:p);t.setFloor(a.index);let s=n.filter((p,f)=>i[f]===a.index),l=hn([a],s),c=Math.hypot(l.maxX-l.minX,l.maxY-l.minY),h=Math.max(28,Math.min(80,c*.04)),m=dt(l.minX-h,l.minY-h,l.maxX-l.minX+h*2,l.maxY-l.minY+h*2),d=a.baseHeightM-.03;ie(t,m,void 0,()=>d,d-.22,r.ground,r.ground,re)}}function er(t,e,n){let{cx:i,cz:o,radius:r}=n,a=1/0,s=1/0,l=1/0,c=-1/0,h=-1/0,m=-1/0,d=(u,b,y)=>{a=Math.min(a,u),c=Math.max(c,u),s=Math.min(s,b),h=Math.max(h,b),l=Math.min(l,y),m=Math.max(m,y)};for(let u=0;u<t.position.length;u+=3)d(t.position[u],t.position[u+1],t.position[u+2]);for(let u=0;u<e.count;u++){let b=u*3,y=e.iPosition[b],x=e.iPosition[b+1],v=e.iPosition[b+2],k=Math.max(.35,e.iMaxRadius[u]??.35);d(y-k,x,v-k),d(y+k,x+1.6,v+k)}Number.isFinite(a)||(a=i-r,c=i+r,s=0,h=r*.16,l=o-r,m=o+r);let p=[(a+c)/2,(s+h)/2,(l+m)/2],f=Math.max(1,.5*Math.hypot(c-a,h-s,m-l));return{center:p,radius:f,minY:s,maxY:h}}function tr(t,e,n,i,o,r){let a=1/0,s=1/0,l=-1/0,c=-1/0;for(let k=0;k<t.count;k++){let P=k*3,M=t.iPosition[P],F=t.iPosition[P+2];M<a&&(a=M),M>l&&(l=M),F<s&&(s=F),F>c&&(c=F)}for(let k of e)a=Math.min(a,k.cx-k.halfX),l=Math.max(l,k.cx+k.halfX),s=Math.min(s,k.cz-k.halfZ),c=Math.max(c,k.cz+k.halfZ);let h=n.minX*R,m=n.maxX*R,d=n.minY*R,p=n.maxY*R,f=h,u=m,b=d,y=p;if(Number.isFinite(a)){let k=Math.max(2,.06*Math.hypot(l-a,c-s));f=Math.max(h,a-k),u=Math.min(m,l+k),b=Math.max(d,s-k),y=Math.min(p,c+k)}let x=Math.min(0,i),v=Math.max(o,r*.05);return{min:[f,x,b],max:[u,v,y]}}function yt(t){let{doc:e}=t,n=so(e.theme),i=n.structure,o=wo(e,t.eventConfigurationId??e.eventConfigurationId),r=t.seats,a=new Et,s=new Map;for(let g of o)for(let w of g.objects)s.set(w.id,g.index),w.type==="section"&&s.set(w.logicalSectionId??w.id,g.index);let l=r.map(g=>s.get(g.sectionId??"")??s.get(g.rowId??"")??0),c=hn(o,r);Jo(a,o,r,l,c,i);let h=Io(e,r),m=new Map;for(let g of e.categories??[])m.set(g.key,g.color);let d=[],p=Ro(o,r,l),f=new Float32Array(r.length);for(let g=0;g<o.length;g++){let w=o[g];a.setFloor(g);let E=new Ot,C=[],N=w.objects.filter(S=>S.type==="section"&&!!S.outline&&S.outline.length>=3);for(let S of w.objects)S.type==="section"?No(a,S,w,To(S,h),p.bySection.get(S.id),E,N,i):S.type==="shape"?(a.setMaterial(S.role==="screen"?1:0),_o(a,S,w.baseHeightM,Fo(S,C),i,w.focal,d),a.setMaterial(0)):S.type==="gaArea"?Bo(a,S,w.baseHeightM,K(m.get(S.categoryKey)),i):S.type==="booth"?ko(a,S,w.baseHeightM,K(m.get(S.categoryKey)),i):S.type==="table"?Lo(a,S,w.baseHeightM,K(m.get(S.categoryKey)),i):S.type==="decorImage"&&Oo(a,S,w.baseHeightM,i);zo(a,w,r,p,i)}let u=o.length>1?{x:o.reduce((g,w)=>g+w.focal.x,0)/o.length,y:o.reduce((g,w)=>g+w.focal.y,0)/o.length}:e.focalPoint??{x:(c.minX+c.maxX)/2,y:(c.minY+c.maxY)/2},b=to([a.build()]),y=ao(r,t.initialState,p,f,m),x=Zo({doc:e,units:o,seats:r,surfaces:p,focal:u}),{labels:v,sections:k,rows:P}=Ko({doc:e,units:o,seats:r,surfaces:p,seatData:y,hintedSeatFloor:l,zones:x,focal:u}),M=$o({doc:e,units:o,seats:r,surfaces:p,solids:b,hintedSeatFloor:l,seatFloor:f});Qo(v,M),y.iYaw=ro(y.iPosition,r.length,g=>r[g].rowId,g=>{let w=o[f[g]]?.focal??u;return[w.x*R,w.y*R]});let F=(c.minX+c.maxX)/2*R,O=(c.minY+c.maxY)/2*R,L=.5*Math.hypot((c.maxX-c.minX)*R,(c.maxY-c.minY)*R)||10,H=er(b,y,{cx:F,cz:O,radius:L}),_=tr(y,d,c,H.minY,H.maxY,L);return{solids:b,seats:y,bounds:{center:[(_.min[0]+_.max[0])/2,(_.min[1]+_.max[1])/2,(_.min[2]+_.max[2])/2],radius:L,groundY:0,box:_},renderBounds:{center:H.center,radius:H.radius},stateColorLUT:co(n,be),theme:n,seatCount:r.length,focalWorld:[u.x*R,1.5,u.y*R],zones:x,stages:d,sections:k,rows:P,labels:v,floors:M}}var ma=88,da=20,ha={floor:{size:14,weight:"700",opacity:.98},zone:{size:15,weight:"600",opacity:.95},section:{size:12,weight:"500",opacity:.88},ga:{size:12,weight:"500",opacity:.88},booth:{size:11,weight:"500",opacity:.85},annotation:{size:11,weight:"400",opacity:.75},row:{size:10.5,weight:"600",opacity:.8},seat:{size:9.5,weight:"500",opacity:.72}},pn=new Set(["row","seat"]),nr={floor:5,zone:4,section:3,ga:3,booth:2,annotation:1},or={row:{x:62,y:16},seat:{x:46,y:18}},ir=K,fn=t=>En(t);function ar(t,e){let n=fn(t),i=fn(e);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function rr(t,e){let n=/rgba\((\d+),(\d+),(\d+),([\d.]+)\)/.exec(t.replace(/\s/g,""));if(!n)return e;let i=Math.max(0,Math.min(1,Number(n[4])));return[1,2,3].map(o=>Number(n[o])/255*i+e[o-1]*(1-i))}function pa(t,e=[.04,.06,.1]){let n=fn(e)<.42,i=n?"#f4f7fb":"#0b1220",o=ir(t),r=o&&ar(o,e)>=4.5?t:i;return n?{ink:r,backing:"rgba(8,12,22,.78)",border:"rgba(210,222,245,.24)"}:{ink:r,backing:"rgba(255,255,255,.84)",border:"rgba(11,18,32,.22)"}}var Bt=class{constructor(e,n={}){this.nodes=new Map;this.labels=[];this.forcedDense=!1;this.selectedSeatLabelIds=new Set;this.opts=n,this.root=document.createElement("div"),this.root.setAttribute("data-view3d-labels","");let i=this.root.style;i.position="absolute",i.inset="0",i.pointerEvents="none",i.overflow="hidden",n.fontFamily&&(i.fontFamily=n.fontFamily),e.appendChild(this.root)}setVisible(e){this.root.style.visibility=e?"":"hidden"}setLabels(e){this.labels=e;for(let[n,i]of this.nodes)e.some(o=>o.id===n)||(i.remove(),this.nodes.delete(n))}setForcedDense(e){this.forcedDense=e}setSelectedSeatIds(e){this.selectedSeatLabelIds=new Set(Array.from(e,n=>`seat:${n}`))}qualityEvidence(){let e=this.root.getBoundingClientRect(),n=this.root.style.visibility!=="hidden";return this.labels.map(i=>{let o=this.nodes.get(i.id),r=o?.getBoundingClientRect(),a=!!(n&&o&&o.style.display!=="none"&&r&&r.width>0&&r.height>0);return{id:i.id,kind:i.kind,text:i.text,visible:a,renderedFontPx:o&&Number.parseFloat(o.style.fontSize)||0,contrast:o?Number(o.dataset.qualityContrast??0):0,...a&&r?{screenBox:{x:r.x-e.x,y:r.y-e.y,width:r.width,height:r.height}}:{}}})}update(e,n,i,o,r,a){if(!this.labels.length)return;let s=Uo(o,r,{hasZoneLabels:this.labels.some(u=>u.kind==="zone")});this.forcedDense&&(s.add("row"),s.add("seat"));let l=[];for(let u of this.labels){if(!s.has(u.kind))continue;let b=Oe(e,u.anchor,n,i);if(!b.visible)continue;let y=a?Math.hypot(u.anchor[0]-a[0],u.anchor[1]-a[1],u.anchor[2]-a[2]):1;l.push({label:u,screen:b,focus:Wo(b,y,n,i),...this.selectedSeatLabelIds.has(u.id)?{priority:1}:{}})}let c=Ho(l.filter(u=>u.label.kind==="floor"),n),h=[...l.filter(u=>!pn.has(u.label.kind)&&u.label.kind!=="floor"),...c],m=[...Xo(h,ma,da),...["row","seat"].flatMap(u=>jo(l.filter(b=>b.label.kind===u),or[u].x,or[u].y,Yo[u]))],d=new Set(m.map(u=>u.label.id));for(let{label:u,screen:b}of m){let x=this.nodeFor(u).style;x.display="",x.transform=`translate(-50%, -50%) translate(${b.x.toFixed(1)}px, ${b.y.toFixed(1)}px)`}let p=m.filter(({label:u})=>!pn.has(u.kind)).sort((u,b)=>nr[b.label.kind]-nr[u.label.kind]||u.screen.depth-b.screen.depth||u.focus-b.focus),f=[];for(let{label:u}of p){let b=this.nodes.get(u.id);if(!b||b.style.display==="none")continue;let y=b.getBoundingClientRect();f.some(v=>y.left<v.right+3&&y.right+3>v.left&&y.top<v.bottom+3&&y.bottom+3>v.top)?b.style.display="none":f.push(y)}for(let[u,b]of this.nodes)d.has(u)||(b.style.display="none")}nodeFor(e){let n=this.nodes.get(e.id);if(!n){n=document.createElement("div");let m=n.style;m.position="absolute",m.left="0",m.top="0",m.whiteSpace="nowrap",m.textShadow="0 1px 3px rgba(0,0,0,0.85), 0 0 8px rgba(0,0,0,0.55)",m.display="none",this.root.appendChild(n),this.nodes.set(e.id,n)}n.textContent=e.text,n.setAttribute("data-label-kind",e.kind);let i=this.selectedSeatLabelIds.has(e.id);n.toggleAttribute("data-selected-seat",i);let o=ha[e.kind],r=n.style;r.fontSize=`${o.size}px`,r.fontWeight=i?"800":o.weight,r.opacity=i?"1":String(o.opacity);let a=pa(e.color??this.opts.ink,this.opts.backgroundRgb),s=!pn.has(e.kind);r.color=i?"#ecf8ff":a.ink,r.background=i?"rgba(10,28,45,.9)":s?a.backing:"",r.border=i?"1px solid rgba(89,199,255,.92)":s?`1px solid ${a.border}`:"",r.borderRadius=i||s?"999px":"",r.padding=i||s?"3px 7px":"",r.boxShadow=i?"0 0 0 2px rgba(41,176,255,.18), 0 5px 14px rgba(0,0,0,.35)":s?"0 3px 10px rgba(0,0,0,.24)":"",r.letterSpacing=e.kind==="zone"||e.kind==="floor"?"0.08em":"0.02em";let l=this.opts.backgroundRgb??[.04,.06,.1],c=ir(i?"#ecf8ff":a.ink)??[1,1,1],h=i?rr("rgba(10,28,45,.9)",l):s?rr(a.backing,l):l;return n.dataset.qualityContrast=ar(c,h).toFixed(3),(e.kind==="zone"||e.kind==="floor")&&(r.textTransform="uppercase"),n}dispose(){this.root.remove(),this.nodes.clear()}};var fa=1;var ba=new Set(["floor","zone","section","ga","booth","annotation"]);function ya(t){return t.every(e=>Number.isFinite(e))}function xa(t,e){return t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y}function sr(t){return t.length?Math.round(Math.min(...t)*100)/100:null}function We(t){return Math.round(t*1e4)/1e4}function ga(t){if(t)return{box:{x:We(t.box.x),y:We(t.box.y),width:We(t.box.width),height:We(t.box.height)},horizontalFillRatio:We(t.horizontalFillRatio),verticalFillRatio:We(t.verticalFillRatio),visibleAreaRatio:We(t.visibleAreaRatio),clippedEdges:[...t.clippedEdges]}}function Me(t,e,n){return n.length?{code:t,message:e,count:n.length,samples:n.slice(0,20)}:null}function bn(t){let e=t.labels.filter(s=>s.visible&&s.screenBox),n=e.filter(s=>ba.has(s.kind)),i=t.scene.floorCount>1?t.scene.floorCount:t.scene.zoneCount||t.scene.sectionCount,o=[];for(let s=0;s<n.length;s+=1)for(let l=0;l<s;l+=1)xa(n[s].screenBox,n[l].screenBox)&&o.push({primaryId:n[s].id,primaryLabel:n[s].text,secondaryId:n[l].id});let r=[...t.camera.position,t.camera.distance,t.camera.verticalFovDeg],a=[Me("webgl2-unavailable","The venue scene must render through WebGL2",t.context.webgl2?[]:[{primaryId:"renderer",primaryLabel:"WebGL2"}]),Me("context-lost","The WebGL context must be live at capture",t.context.lost?[{primaryId:"renderer",primaryLabel:"context lost"}]:[]),Me("frame-not-stable","The captured 3D frame must be rendered and parked",t.frame.rendered>0&&t.frame.idle?[]:[{primaryId:"renderer",primaryLabel:"unstable frame"}]),Me("viewport-empty","The 3D viewport must have visible dimensions",t.viewport.width>1&&t.viewport.height>1?[]:[{primaryId:"viewport",primaryLabel:`${t.viewport.width}\xD7${t.viewport.height}`}]),Me("camera-invalid","The capture camera must have a finite physical pose",ya(r)&&t.camera.distance>0&&t.camera.verticalFovDeg>0&&t.camera.verticalFovDeg<180?[]:[{primaryId:"camera",primaryLabel:"invalid pose"}]),Me("authored-relief-not-visible","Authored 3D height or rake must produce visible screen-space relief",!t.scene.authoredRelief||t.scene.renderedVerticalSpanM>.05&&t.scene.projectedReliefPx>=2?[]:[{primaryId:"scene",primaryLabel:"authored relief",measured:t.scene.projectedReliefPx,minimum:2}]),Me("hierarchy-label-missing","A venue with authored hierarchy must show at least one structural label",i===0||n.length>0?[]:[{primaryId:"labels",primaryLabel:`${i} expected hierarchy labels`}]),Me("hierarchy-label-undersized","Visible 3D hierarchy labels must remain readable",n.filter(s=>s.renderedFontPx<11).map(s=>({primaryId:s.id,primaryLabel:s.text,measured:s.renderedFontPx,minimum:11}))),Me("hierarchy-label-contrast-low","Visible 3D hierarchy labels must meet text contrast",n.filter(s=>s.contrast<4.5).map(s=>({primaryId:s.id,primaryLabel:s.text,measured:s.contrast,minimum:4.5}))),Me("hierarchy-label-collision","Visible 3D hierarchy labels must not overlap",o)].filter(s=>!!s);return{version:1,state:"venue3d",passed:a.length===0,resolvedRules:["rendered-3d-webgl-context","rendered-3d-stable-frame","rendered-3d-camera-pose","rendered-3d-relief-projection","rendered-3d-label-size","rendered-3d-label-contrast","rendered-3d-label-collision"],viewport:t.viewport,context:t.context,frame:t.frame,camera:t.camera,scene:t.scene,composition:{visibleLabels:e.map(({id:s,kind:l,text:c})=>({id:s,kind:l,text:c})).sort((s,l)=>s.kind.localeCompare(l.kind)||s.id.localeCompare(l.id)),framing:ga(t.framing)},metrics:{minimumHierarchyFontPx:sr(n.map(s=>s.renderedFontPx)),minimumHierarchyContrast:sr(n.map(s=>s.contrast)),projectedReliefPx:Math.round(t.scene.projectedReliefPx*100)/100},findings:a}}import{Geometry as Nt,Mesh as zt,Transform as br}from"ogl";import{Program as je}from"ogl";var Vt=`
2
2
  float chairWeight(float depth) {
3
3
  return 1.0 - smoothstep(uChairFull, uChairNone, depth);
4
4
  }`,cr=`
@@ -56,18 +56,23 @@ uniform float uStructureDetail;
56
56
  out vec4 fragColor;
57
57
  void main() {
58
58
  if (vDim > 0.5) discard;
59
- // Row treads/risers are honest and useful when the buyer is inside a stand.
60
- // At whole-venue scale their overlapping centimetre-scale surfaces quantise
61
- // and alias into camera-dependent radial combs. The clean structural block
62
- // cap remains, so overview keeps every stand without pretending to show row
63
- // detail below a useful pixel size.
64
- float rowDetail = step(1.5, vMaterial);
59
+ // Row treads (material 3) and risers (material 2) are chart truth: the
60
+ // stepped deck IS the stand, at every distance. What must not survive at
61
+ // whole-venue scale is the risers' darker shade \u2014 hundreds of sub-pixel dark
62
+ // faces quantise into a radial comb \u2014 and what must not replace them is an
63
+ // invented flat plate, which the derived bowl band climbs above on any
64
+ // correctly raked stand and shows through as a torn grey surface. So the
65
+ // geometry stays and only the riser SHADING is the close-range detail rung:
66
+ // at overview a riser takes its tread's colour, so the stand reads as one
67
+ // continuous coloured surface with no seams to alias.
68
+ //
65
69
  // The rung DISSOLVES rather than popping: uStructureDetail eases 0..1 over a
66
- // few frames (see the render loop) and each pixel holds a stable screen-door
67
- // threshold against it, so free-zooming across the handover reads as detail
68
- // developing instead of the venue changing in a single frame.
69
- float stipple = fract(sin(dot(gl_FragCoord.xy, vec2(12.9898, 78.233))) * 43758.5453);
70
- if (rowDetail > 0.5 && stipple >= uStructureDetail) discard;
70
+ // few frames (see the render loop), so free-zooming across the handover reads
71
+ // as the step shading developing instead of the venue changing in one frame.
72
+ float riser = 1.0 - step(0.5, abs(vMaterial - 2.0));
73
+ // Risers are baked at 0.72 of their tread (see tiers.ts bandColors); lift
74
+ // them back to the tread colour as detail fades out.
75
+ vec3 vColorRung = vColor * mix(mix(1.0 / 0.72, 1.0, uStructureDetail), 1.0, 1.0 - riser);
71
76
  vec3 N = normalize(vNormalWorld);
72
77
  vec3 V = normalize(-vPosView);
73
78
  float hemi = 0.5 + 0.5 * N.y; // sky/ground gradient about WORLD up
@@ -76,7 +81,7 @@ void main() {
76
81
  // of crushing to a single flat value.
77
82
  vec3 fillDir = normalize(vec3(-uKeyDir.x, 0.25, -uKeyDir.z));
78
83
  float fill = max(dot(N, fillDir), 0.0);
79
- vec3 base = vColor * (0.52 + 0.34 * hemi) + vColor * key * 0.34 + vColor * fill * 0.10;
84
+ vec3 base = vColorRung * (0.52 + 0.34 * hemi) + vColorRung * key * 0.34 + vColorRung * fill * 0.10;
80
85
  float fres = pow(1.0 - max(dot(normalize(vNormalView), V), 0.0), 3.0);
81
86
  base += vec3(0.26, 0.31, 0.38) * fres * 0.35; // cool rim, restrained (view-dependent by design)
82
87
  // Bright, saturated authored screen faces should read as powered displays,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seatlayer/core",
3
- "version": "0.57.0",
3
+ "version": "0.59.0",
4
4
  "description": "Framework-agnostic seat-rendering runtime shared by the SeatLayer SDKs.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "homepage": "https://docs.seatlayer.io/buyer-sdk/install/",
@@ -1 +0,0 @@
1
- var jt=40,Nt=1200,Ft=.8,Dt=3,Ht=-2,Ut=20,Bt=.1,Gt=40,Xt=40,ne=e=>Math.max(1,e.fontSize*.6+(e.letterSpacing??0));function He(e,t){let n=e.text.split(/\r?\n/);if(!e.width)return Math.max(1,n.length);let o=Math.max(1,Math.floor(t/ne(e))),r=0;for(let i of n){if(!i.length){r+=1;continue}let s=0;for(let c of i.split(/\s+/)){let u=c.length;s&&s+1+u<=o?s+=1+u:(r+=Math.max(1,Math.ceil(u/o)),s=u%o)}}return Math.max(1,r)}function oe(e){let t=e.background?.padding??0,n=e.text.split(/\r?\n/),o=Math.max(1,...n.map(c=>c.length))*ne(e),r=e.width??o+t*2,i=Math.max(1,r-t*2),s=He(e,i);return{width:r,height:s*e.fontSize*(e.lineHeight??1.2)+t*2,lineCount:s,padding:t}}var Ue=Math.PI/180;function v(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function Be(e,t,n){let o=Math.cos(n),r=Math.sin(n),i=e.x-t.x,s=e.y-t.y;return{x:t.x+i*o-s*r,y:t.y+i*r+s*o}}function Kt(e,t){return Be(e,{x:0,y:0},t*Ue)}function C(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function Ge(e){let t=0,n=0;for(let r of e)t+=r.x,n+=r.y;let o=e.length||1;return{x:t/o,y:n/o}}function $t(e){return e.length?Ge(e):null}function K(e,t){let n=1-t,o=n*n*n,r=3*n*n*t,i=3*n*t*t,s=t*t*t;return{x:o*e.start.x+r*e.control1.x+i*e.control2.x+s*e.end.x,y:o*e.start.y+r*e.control1.y+i*e.control2.y+s*e.end.y}}function Yt(e,t,n){let o={x:(e.x+t.x)/2,y:(e.y+t.y)/2},r={x:(n.x-o.x)*4/3,y:(n.y-o.y)*4/3};return{start:{...e},control1:{x:e.x+(t.x-e.x)/3+r.x,y:e.y+(t.y-e.y)/3+r.y},control2:{x:e.x+(t.x-e.x)*2/3+r.x,y:e.y+(t.y-e.y)*2/3+r.y},end:{...t}}}function se(e,t,n=192){if(!Number.isInteger(t)||t<1)throw new Error("Path point count must be a positive integer");if(t===1)return[K(e,.5)];let o=Array.from({length:n+1},(u,b)=>K(e,b/n)),r=new Float64Array(o.length);for(let u=1;u<o.length;u+=1){let b=o[u].x-o[u-1].x,a=o[u].y-o[u-1].y;r[u]=r[u-1]+Math.hypot(b,a)}let i=r[r.length-1];if(i<=1e-9)return Array.from({length:t},()=>({...e.start}));let s=[],c=1;for(let u=0;u<t;u+=1){let b=i*u/(t-1);for(;c<r.length-1&&r[c]<b;)c+=1;let a=r[c-1],f=r[c],l=f===a?0:(b-a)/(f-a);s.push({x:o[c-1].x+(o[c].x-o[c-1].x)*l,y:o[c-1].y+(o[c].y-o[c-1].y)*l})}return s}function R(e,t){return{x:e.x+t.x,y:e.y+t.y}}function D(e,t){return{x:e.x-t.x,y:e.y-t.y}}function T(e,t){return{x:e.x*t,y:e.y*t}}function H(e,t=13){return Array.from({length:t},(n,o)=>K(e,o/(t-1)))}function re(e,t){let n=Math.max(0,Math.min(1,t))*(e.length-1),o=Math.min(e.length-2,Math.floor(n));return C(e[o],e[o+1],n-o)}function ie(e,t,n){let o=Math.max(0,Math.min(1,t)),r=Math.max(o,Math.min(1,n)),i=[re(e,o)];for(let s=1;s<e.length-1;s+=1){let c=s/(e.length-1);c>o+1e-9&&c<r-1e-9&&i.push(e[s])}return i.push(re(e,r)),i}function ce(e,t){let n=[[0,1],[1,2],[2,3],[3,0]],o=0,r=Number.POSITIVE_INFINITY;n.forEach(([l,p],x)=>{let g=v(C(e[l],e[p],.5),t);g<r&&(r=g,o=x)});let i=e[o],s=e[(o+1)%4],c=e[(o+2)%4],u=e[(o+3)%4],b=C(i,s,.5),a=D(t,b),f=Math.max(1e-9,Math.hypot(a.x,a.y));return{p0:i,p1:s,p2:c,p3:u,normal:T(a,1/f),depth:(v(i,u)+v(s,c))/2}}function ae(e){let{p0:t,p1:n,p2:o,p3:r,normal:i,depth:s}=e,c=D(n,t),u=D(o,r),b=s*.22,a=s*.12;return{nearPath:{start:t,control1:R(R(t,T(c,1/3)),T(i,b)),control2:R(R(t,T(c,2/3)),T(i,b)),end:n},farPath:{start:o,control1:R(R(r,T(u,2/3)),T(i,a)),control2:R(R(r,T(u,1/3)),T(i,a)),end:r}}}function qt(e,t,n){if(e.length!==4)throw new Error("A section shell requires four mapped bounds corners");let o=e.reduce((x,g)=>R(x,g),{x:0,y:0});o.x/=4,o.y/=4;let r=v(e[0],e[1]),i=v(e[0],e[3]),s=n==="auto"?r>i*1.25&&v(o,t)>i?"bezier":"tapered":n;if(s==="rectangle")return{mode:s,outline:e.map(x=>({...x}))};let c=ce(e,t),{p0:u,p1:b,p2:a,p3:f}=c;if(s==="tapered")return{mode:s,outline:[R(u,T(D(b,u),.14)),R(u,T(D(b,u),1-.14)),a,f]};let{nearPath:l,farPath:p}=ae(c);return{mode:s,outline:[...H(l),...H(p).slice(1)]}}function Jt(e,t,n,o){if(e.length!==4)throw new Error("Aisle generation requires four mapped bounds corners");if(!Number.isInteger(n)||n<0||n>3)throw new Error("Aisle count must be an integer from 0 to 3");if(n===0)return[];let r=ce(e,t),{p0:i,p1:s,p2:c,p3:u}=r,b=o==="bezier"?ae(r):null,a=b?H(b.nearPath):null,f=b?H(b.farPath).reverse():null,l=Math.min(.055,.18/(n+1));return Array.from({length:n},(p,x)=>{let g=(x+1)/(n+1),m=g-l/2,h=g+l/2;return a&&f?[...ie(a,m,h),...ie(f,m,h).reverse()]:[C(i,s,m),C(i,s,h),C(u,c,h),C(u,c,m)]})}function Xe(e,t,n){let o=n.x-t.x,r=n.y-t.y,i=o*o+r*r,s=i?Math.max(0,Math.min(1,((e.x-t.x)*o+(e.y-t.y)*r)/i)):0;return Math.hypot(e.x-(t.x+s*o),e.y-(t.y+s*r))}function ze(e,t){let n=1/0;for(let o of t)if(!(o.length<2))for(let r=0,i=o.length-1;r<o.length;i=r++){let s=Xe(e,o[i],o[r]);s<n&&(n=s)}return n}function le(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[o].x,s=t[o].y,c=t[r].x,u=t[r].y;s>e.y!=u>e.y&&e.x<(c-i)*(e.y-s)/(u-s)+i&&(n=!n)}return n}function Ke(e,t,n){let o=le(e,t)&&!n.some(i=>le(e,i)),r=ze(e,[t,...n]);return o?r:-r}function L(e,t,n,o,r){let i=Ke({x:e,y:t},o,r);return{x:e,y:t,h:n,d:i,max:i+n*Math.SQRT2}}var $=class{constructor(){this.items=[]}get size(){return this.items.length}push(t){let n=this.items;n.push(t);let o=n.length-1;for(;o>0;){let r=o-1>>1;if(n[r].max>=n[o].max)break;[n[r],n[o]]=[n[o],n[r]],o=r}}pop(){let t=this.items,n=t[0],o=t.pop();if(t.length&&o){t[0]=o;let r=0;for(;;){let i=r*2+1,s=i+1,c=r;if(i<t.length&&t[i].max>t[c].max&&(c=i),s<t.length&&t[s].max>t[c].max&&(c=s),c===r)break;[t[c],t[r]]=[t[r],t[c]],r=c}}return n}};function ue(e){if(e.length<3)return 0;let t=0;for(let n=0,o=e.length-1;n<e.length;o=n++)t+=(e[o].x+e[n].x)*(e[o].y-e[n].y);return Math.abs(t)/2}function Zt(e,t){return Math.max(0,ue(e)-(t??[]).reduce((n,o)=>n+ue(o),0))}function fe(e,t){let n=t??[];if(!e.length)return{point:{x:0,y:0},radius:0};if(e.length<3){let g=e.reduce((h,S)=>h+S.x,0)/e.length,m=e.reduce((h,S)=>h+S.y,0)/e.length;return{point:{x:g,y:m},radius:0}}let o=1/0,r=1/0,i=-1/0,s=-1/0;for(let g of e)g.x<o&&(o=g.x),g.y<r&&(r=g.y),g.x>i&&(i=g.x),g.y>s&&(s=g.y);let c=i-o,u=s-r,b=Math.min(c,u);if(!(b>0))return{point:{x:(o+i)/2,y:(r+s)/2},radius:0};let a=Math.max(c,u)/150,f=new $,l=b/2;for(let g=o;g<i;g+=b)for(let m=r;m<s;m+=b)f.push(L(g+l,m+l,l,e,n));let p=L(o+c/2,r+u/2,0,e,n),x=0;for(;f.size;){let g=f.pop();if(!g)break;g.d>p.d&&(p=g),!(g.max-p.d<=a)&&(x>=4e3||(x+=1,l=g.h/2,f.push(L(g.x-l,g.y-l,l,e,n)),f.push(L(g.x+l,g.y-l,l,e,n)),f.push(L(g.x-l,g.y+l,l,e,n)),f.push(L(g.x+l,g.y+l,l,e,n))))}return{point:{x:p.x,y:p.y},radius:Math.max(0,p.d)}}function $e(e,t,n){return Math.max(t,Math.min(n,e))}function tn(e,t,n){return e<t?t:e>n?n:e}function We(e){return $e(e,0,1)}function de(e){let t=We(e);return t*t*(3-2*t)}var j=Math.PI*2;function N(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}function Ve(e,t,n){let o=t-e;if(n){for(;o<0;)o+=j;for(;o>=j;)o-=j}else{for(;o>0;)o-=j;for(;o<=-j;)o+=j}return o}function sn(e){return e.end}function pe(e){if(e.version!==1||e.closed!==!0||!N(e.start)||!Array.isArray(e.segments)||e.segments.length<2||e.segments.length>512)return!1;let t=e.start;for(let n of e.segments){if(!n||!N(n.end))return!1;if(n.kind==="line"){if(v(t,n.end)<=1e-9)return!1}else if(n.kind==="bezier"){if(!N(n.control1)||!N(n.control2)||v(t,n.end)<=1e-9)return!1}else if(n.kind==="arc"){if(!N(n.center)||!Number.isFinite(n.radius)||n.radius<=1e-6||Math.abs(v(t,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||Math.abs(v(n.end,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||v(t,n.end)<=1e-9)return!1}else return!1;t=n.end}return v(t,e.start)<=1e-4}function Ye(e,t,n){let o=1-n;return{x:o**3*e.x+3*o**2*n*t.control1.x+3*o*n**2*t.control2.x+n**3*t.end.x,y:o**3*e.y+3*o**2*n*t.control1.y+3*o*n**2*t.control2.y+n**3*t.end.y}}function cn(e,t=2){if(!pe(e))throw new Error("Section outline path is invalid");let n=Math.max(.25,t),o=[{...e.start}],r=e.start;for(let i of e.segments){if(i.kind==="line")o.push({...i.end});else if(i.kind==="arc"){let s=Math.atan2(r.y-i.center.y,r.x-i.center.x),c=Math.atan2(i.end.y-i.center.y,i.end.x-i.center.x),u=Ve(s,c,i.clockwise),b=Math.max(2,Math.ceil(Math.abs(u)*i.radius/n));for(let a=1;a<=b;a+=1){let f=s+u*a/b;o.push({x:i.center.x+Math.cos(f)*i.radius,y:i.center.y+Math.sin(f)*i.radius})}}else{let s=v(r,i.control1)+v(i.control1,i.control2)+v(i.control2,i.end),c=Math.max(2,Math.ceil(s/n));for(let u=1;u<=c;u+=1)o.push(Ye(r,i,u/c))}r=i.end}return v(o[o.length-1],o[0])<=1e-4&&o.pop(),o}function ye(e,t,n){return qe(e,r=>({x:r.x+t,y:r.y+n}))}function qe(e,t,n=1,o=!1){return{...e,start:t(e.start),segments:e.segments.map(r=>r.kind==="line"?{...r,end:t(r.end)}:r.kind==="arc"?{...r,center:t(r.center),radius:r.radius*Math.abs(n),clockwise:o?!r.clockwise:r.clockwise,end:t(r.end)}:{...r,control1:t(r.control1),control2:t(r.control2),end:t(r.end)})}}var an=45,Je=150,he=.5523;function me(e,t){return Math.abs(e.x-t.x)<=1e-6&&Math.abs(e.y-t.y)<=1e-6}function Qe(e){let t=[],n=[];for(e.forEach((o,r)=>{N(o)&&(t.length&&me(t[t.length-1],o)||(t.push({x:o.x,y:o.y}),n.push(r)))});t.length>1&&me(t[0],t[t.length-1]);)t.pop(),n.pop();return{points:t,sourceIndex:n}}function ln(e,t,n){return nt(e,{cornerSmoothing:t,...n})}var Ze=.5,et=4/3;function tt(e,t,n){let o=t.x-e.x,r=t.y-e.y,i=Math.hypot(o,r);if(i<=1e-9)return{kind:"line",end:{...t}};let s=-r/i,c=o/i,u=n*et;return{kind:"bezier",control1:{x:e.x+o/3+s*u,y:e.y+r/3+c*u},control2:{x:e.x+o*2/3+s*u,y:e.y+r*2/3+c*u},end:{...t}}}function nt(e,t){let{points:n,sourceIndex:o}=Qe(e),r=n.length;if(r<3)return null;let i=Math.min(100,Math.max(0,t.cornerSmoothing??0))/100,s=t.edgeCurvature,c=new Array(r).fill(0);if(s?.length)for(let d=0;d<r;d+=1){let P=s[o[d]];c[d]=Number.isFinite(P)?Math.min(100,Math.max(-100,P))/100:0}let u=c.some(d=>Math.abs(d)>1e-6);if(i<=0&&!u)return null;let b=t.wideAngleThresholdDeg??Je,a=[];for(let d=0;d<r;d+=1)a[d]=v(n[d],n[(d+1)%r]);let f=new Array(r).fill(0);for(let d=0;d<r;d+=1){let P=n[(d-1+r)%r],w=n[d],M=n[(d+1)%r],E={x:P.x-w.x,y:P.y-w.y},O={x:M.x-w.x,y:M.y-w.y},A=Math.hypot(E.x,E.y),k=Math.hypot(O.x,O.y);if(A<=1e-9||k<=1e-9)continue;let I=Math.min(1,Math.max(-1,(E.x*O.x+E.y*O.y)/(A*k))),_=Math.acos(I)*180/Math.PI;if(_<b)continue;let z=de((_-b)/(180-b));f[d]=i*z*.5*Math.min(A,k)}for(let d=0;d<r;d+=1){let P=(d+1)%r,w=f[d]+f[P];if(w>a[d]&&w>1e-9){let M=a[d]/w;f[d]*=M,f[P]*=M}}let l=new Array(r),p=new Array(r);for(let d=0;d<r;d+=1){let P=n[(d-1+r)%r],w=n[d],M=n[(d+1)%r];if(f[d]<=1e-6){l[d]={...w},p[d]={...w};continue}let E=v(w,P)||1,O=v(w,M)||1;l[d]={x:w.x+(P.x-w.x)/E*f[d],y:w.y+(P.y-w.y)/E*f[d]},p[d]={x:w.x+(M.x-w.x)/O*f[d],y:w.y+(M.y-w.y)/O*f[d]}}if(f.every(d=>d<=1e-6)&&!u)return null;let x=[],g={...p[0]},m=g,h=(d,P)=>{if(v(m,d)<=1e-9)return;let w=c[P];Math.abs(w)>1e-6?x.push(tt(m,d,w*Ze*a[P])):x.push({kind:"line",end:{...d}}),m=d};for(let d=1;d<=r;d+=1){let P=d%r,w=n[P];h(l[P],(d-1)%r),f[P]>1e-6&&v(l[P],p[P])>1e-9&&(x.push({kind:"bezier",control1:C(l[P],w,he),control2:C(p[P],w,he),end:{...p[P]}}),m=p[P])}if(!x.length)return null;let S=x[x.length-1];v(S.end,g)>1e-9&&(S.kind==="line"?S.end={...g}:x.push({kind:"line",end:{...g}}));let y={version:1,closed:!0,start:g,segments:x};return pe(y)?y:null}function un(e){let t=[],n=e.start;for(let r of e.segments)t.push(n),n=r.end;let o=[];for(let r=e.segments.length-1;r>=0;r-=1){let i=e.segments[r],s=t[r];i.kind==="line"?o.push({kind:"line",end:{...s}}):i.kind==="arc"?o.push({kind:"arc",center:{...i.center},radius:i.radius,clockwise:!i.clockwise,end:{...s}}):o.push({kind:"bezier",control1:{...i.control2},control2:{...i.control1},end:{...s}})}return{version:1,closed:!0,start:{...e.start},segments:o}}function dn(e,t,n){let o=[];for(let r=0;r<e.length-1;r+=1){let i=e[r],s=e[r+1],c=Math.hypot(s.x-i.x,s.y-i.y);if(c<=0)continue;let u=Math.max(1,Math.round(c/n)),b=c/u,a=Math.atan2(s.y-i.y,s.x-i.x),f=r===0,p=(r>0?t[r-1]:void 0)==="break"?2:1,x=f?{...i}:{x:i.x+Math.cos(a)*b*p,y:i.y+Math.sin(a)*b*p},g=f?u+1:Math.max(1,u-(p-1));o.push({origin:x,rotation:a*180/Math.PI,seatCount:g,seatSpacing:b})}return o}function hn(e){let t=e.rotation*Math.PI/180,n={x:Math.cos(t),y:Math.sin(t)};return Array.from({length:e.seatCount},(o,r)=>({x:e.origin.x+n.x*r*e.seatSpacing,y:e.origin.y+n.y*r*e.seatSpacing}))}function mn(e){return e.reduce((t,n)=>t+n.seatCount,0)}function be(e){let t=new Map,n=new Map;for(let o of e){if(o.type!=="row"||!o.segmentedRow)continue;let r=n.get(o.segmentedRow.groupId)??[];r.push(o),n.set(o.segmentedRow.groupId,r)}for(let[o,r]of n){let i=r.slice().sort((l,p)=>l.segmentedRow.componentIndex-p.segmentedRow.componentIndex),s=i[0]?.segmentedRow?.componentCount??0,c=i[0]?.segmentedRow;if(!c||!(s>=2&&i.length===s&&c?.boundaryBefore==="start"&&i.every((l,p)=>l.segmentedRow?.kind==="segmented-row-v1"&&l.segmentedRow.groupId===o&&l.segmentedRow.componentCount===s&&l.segmentedRow.componentIndex===p&&l.segmentedRow.repeatLabelOnComponents===c.repeatLabelOnComponents&&(p===0?l.segmentedRow.boundaryBefore==="start":l.segmentedRow.boundaryBefore!=="start")&&l.segmentedRow.displayLabel===c.displayLabel)))continue;let b=i.reduce((l,p)=>l+p.seatCount,0),a=0,f=0;for(let l of i)l.segmentedRow.boundaryBefore==="break"&&(a+=1),t.set(l.id,{groupId:o,adjacencyOffset:a,displayOffset:f,displayLabel:c.displayLabel,totalSeats:b,canonical:i[0],viewFromSeatUrl:c.viewFromSeatUrl,viewFromSeatMeta:c.viewFromSeatMeta,confidenceEvidence:c.confidenceEvidence}),a+=l.seatCount,f+=l.seatCount}return t}var xe="ABCDEFGHIJKLMNOPQRSTUVWXYZ",ot="ABCDEFGHJKLMNPQRSTUVWXYZ",rt="abcdefghijklmnopqrstuvwxyz";function ge(e,t){let n=t.length,o=e+1,r="";for(;o>0;){o-=1;let i=o%n;r=t[i]+r,o=Math.floor(o/n)}return r}function it(e,t){let n=t.startAt-1,o=e+n;if(t.scheme==="numbers")return String(o+1);let r=t.skipAmbiguous?ot:xe;return ge(o,r)}function W(e,t=!1){let n=t?rt:xe;return ge(Math.max(0,Math.floor(e)-1),n)}var st=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];function Se(e){if(!Number.isFinite(e)||e<=0)return String(e);let t=Math.floor(e),n="";for(let[o,r]of st)for(;t>=o;)n+=r,t-=o;return n}function yn(e,t){let n=e.length;return e.map((o,r)=>{let i=t.reverse?n-1-r:r;return{...o,label:it(i,t)}})}function ct(e){let t=new Array(e);return Array.from({length:e},(n,o)=>o).sort((n,o)=>Math.abs(2*n-(e-1))-Math.abs(2*o-(e-1))||n-o).forEach((n,o)=>t[n]=o),t}function V(e,t){let n=e.seatLabelStart??1,o=e.seatNumbering?.direction??"ltr",r=e.seatNumbering?.step??1,i=e.seatNumbering?.scheme??"decimal",s=e.seatNumbering?.prefix??"",c=e.seatNumbering?.endAt,u=e.seatCount;if(i==="updown"||i==="updown-descending"){let p=Math.ceil(u/2),x=i==="updown"?t<p?n+2*t:n-1+2*(u-t):t<p?n+2*(p-1-t):n+1+2*(t-p);return`${s}${x}`}let b=i==="odd"||i==="even"?2:r,a=c!=null&&Number.isFinite(c)?c-(u-1)*b:n,f=o==="center"?ct(u)[t]:o==="rtl"?u-1-t:t,l;switch(i){case"odd":{let p=a%2===1?a:a+1;l=String(p+f*2);break}case"even":{let p=a%2===0?a:a+1;l=String(p+f*2);break}case"roman":l=Se(a+f*r);break;case"letters-upper":l=W(a+f*r,!1);break;case"letters-lower":l=W(a+f*r,!0);break;default:l=String(a+f*r);break}return`${s}${l}`}function at(e){return{...e.canonical,seatCount:e.totalSeats,label:e.displayLabel,displayLabel:e.displayLabel}}function we(e,t,n){return n?.label??`${e.label}-${V(e,t)}`}function Y(e,t,n,o){if(o?.displayLabel)return o.displayLabel;if(!n)return`${e.displayLabel??e.label}-${V(e,t)}`;let r=at(n),i=n.displayOffset+t;return`${n.displayLabel}-${V(r,i)}`}var U=.02291666666666667,Sn=1/U,lt=58,ut=lt*U,Pe=0,ve=3,Me=0,q=120,ft=0,dt=45,ht=7,B=1.2;function J(e,t,n,o){return Number.isFinite(e)?Math.max(t,Math.min(n,e)):o}function wn(e){return Number.isFinite(e)?Math.max(Pe,Math.min(ve,Math.round(e))):Pe}function mt(e){return!Number.isFinite(e)||!Number.isInteger(e)||e<0?0:e<=ht?e:ve}function Ie(e,t={}){let n=J(t.floorBaseHeightM,Me,q,0),o=Math.min(q,n+mt(e.elevation)*ut),r=e.height===void 0?o:J(e.height,Me,q,o),i=J(e.rake,ft,dt,0);return{height:r,rake:i}}function Ee(e){let t=e.length;return t<=3?[...e]:[e[Math.floor(t*.25)],e[Math.floor(t*.5)],e[Math.floor(t*.75)]]}function Oe(e,t,n){if(!e.length)return 1/0;if(e.length===1)return Math.hypot(t-e[0].x,n-e[0].y);let o=1/0;for(let r=0;r+1<e.length;r++){let i=e[r],s=e[r+1],c=s.x-i.x,u=s.y-i.y,b=c*c+u*u,a=b>1e-12?((t-i.x)*c+(n-i.y)*u)/b:0;a<0?a=0:a>1&&(a=1);let f=Math.hypot(t-(i.x+a*c),n-(i.y+a*u));f<o&&(o=f)}return o}function pt(e){let t=0,n=0;for(let i of e)t+=i.x,n+=i.y;let o=e.length||1;t/=o,n/=o;let r=0;for(let i of e){let s=Math.hypot(i.x-t,i.y-n);s>r&&(r=s)}return{cx:t,cy:n,r}}function Ce(e,t){return Math.hypot(e.cx-t.cx,e.cy-t.cy)-e.r-t.r}function Q(e,t){let n=1/0;for(let o of Ee(e)){let r=Oe(t,o.x,o.y);r<n&&(n=r)}for(let o of Ee(t)){let r=Oe(e,o.x,o.y);r<n&&(n=r)}return n}function yt(e,t){if(e.length<3)return{pts:e,seatIndices:t};let n=0,o=0;for(let a of e)n+=a.x,o+=a.y;n/=e.length,o/=e.length;let r=-1,i=e[0];for(let a of e){let f=Math.hypot(a.x-n,a.y-o);f>r&&(r=f,i=a)}let s=i.x-n,c=i.y-o,u=Math.hypot(s,c);u>1e-9?(s/=u,c/=u):(s=1,c=0);let b=e.map((a,f)=>({p:a,i:f,t:(a.x-n)*s+(a.y-o)*c})).sort((a,f)=>a.t-f.t);return{pts:b.map(a=>a.p),seatIndices:b.map(a=>t[a.i])}}function bt(e){let t=e.length;if(t<3)return null;let n=0,o=0;for(let S of e)n+=S.x,o+=S.y;n/=t,o/=t;let r=0,i=0,s=0,c=0,u=0,b=0,a=0;for(let S of e){let y=S.x-n,d=S.y-o;r+=y*y,s+=d*d,i+=y*d,c+=y*y*y,u+=d*d*d,b+=y*d*d,a+=d*y*y}let f=r*s-i*i;if(Math.abs(f)<1e-9)return null;let l=(c+b)/2,p=(u+a)/2,x=(l*s-p*i)/f,g=(p*r-l*i)/f,m=x+n,h=g+o;return!Number.isFinite(m)||!Number.isFinite(h)?null:{cx:m,cy:h}}var xt=.15;function gt(e){if(e.length<2)return null;let t=e.map(S=>{let y=0,d=0;for(let P of S.pts)y+=P.x,d+=P.y;return{x:y/S.pts.length,y:d/S.pts.length}}),n=0,o=0;for(let S of t)n+=S.x,o+=S.y;n/=t.length,o/=t.length;let r=0,i=0,s=0;for(let S of t){let y=S.x-n,d=S.y-o;r+=y*y,i+=y*d,s+=d*d}let c=r+s,u=r*s-i*i,b=c/2+Math.sqrt(Math.max(0,c*c/4-u)),a,f;Math.abs(i)>1e-12?(a=b-s,f=i):r>=s?(a=1,f=0):(a=0,f=1);let l=Math.hypot(a,f);if(!(l>1e-12))return null;a/=l,f/=l;let p=1/0,x=-1/0,g=[];for(let S of e){let y=1/0,d=-1/0;for(let P of S.pts){let w=P.x*a+P.y*f;w<y&&(y=w),w>d&&(d=w),w<p&&(p=w),w>x&&(x=w)}g.push(d-y)}let m=x-p;return m>1e-9?(g.sort((S,y)=>S-y),g[Math.min(g.length-1,Math.floor(g.length*.9))]/m<=St?{x:a,y:f}:null):null}var St=.35;function Re(e,t,n,o){let r=new Map;for(let m of n){let h=t[m],S=h.rowId||`__seat-${m}`,y=r.get(S);y||(y={pts:[],idx:[]},r.set(S,y)),y.pts.push({x:h.x,y:h.y}),y.idx.push(m)}if(!r.size)return{sectionId:e,rows:[],blockCount:0};let i=[];for(let[m,h]of r){let S=yt(h.pts,h.idx),y=0;for(let d of S.pts)y+=Math.hypot(d.x-o.x,d.y-o.y);i.push({id:m,pts:S.pts,seatIndices:S.seatIndices,blockId:-1,ordinal:0,blockDepth:0,focalDistance:y/S.pts.length})}let s=i.map(m=>pt(m.pts)),c=[];for(let m=0;m<i.length;m++){let h=1/0;for(let S=0;S<i.length;S++){if(m===S||Ce(s[m],s[S])>=h)continue;let y=Q(i[m].pts,i[S].pts);y<h&&(h=y)}Number.isFinite(h)&&c.push(h)}c.sort((m,h)=>m-h);let u=c.length?c[Math.floor(c.length/2)]:1,b=Math.max(u*1.8,1e-6),a=i.map(()=>[]);for(let m=0;m<i.length;m++)for(let h=m+1;h<i.length;h++)Ce(s[m],s[h])>b||Q(i[m].pts,i[h].pts)<=b&&(a[m].push(h),a[h].push(m));let f=0;for(let m=0;m<i.length;m++){if(i[m].blockId!==-1)continue;let h=f++,S=[m];for(i[m].blockId=h;S.length;){let y=S.pop();for(let d of a[y])i[d].blockId===-1&&(i[d].blockId=h,S.push(d))}}let l=new Map;for(let m of i){let h=l.get(m.blockId)??[];h.push(m),l.set(m.blockId,h)}let p=[];for(let m of i){if(m.pts.length<4)continue;let h=bt(m.pts);h&&(!Number.isFinite(h.cx)||!Number.isFinite(h.cy)||p.push({x:h.cx,y:h.cy}))}let x=p.length>=2?(()=>{let m=p.map(y=>y.x).sort((y,d)=>y-d),h=p.map(y=>y.y).sort((y,d)=>y-d),S=Math.floor(p.length/2);return{cx:m[S],cy:h[S]}})():null;if(x){let m=w=>Math.hypot(w.x-x.cx,w.y-x.cy),h=1/0,S=-1/0,y=[];for(let w of i){let M=1/0,E=-1/0;for(let O of w.pts){let A=m(O);A<M&&(M=A),A>E&&(E=A)}y.push(E-M),M<h&&(h=M),E>S&&(S=E)}let d=S-h;y.sort((w,M)=>w-M);let P=y[Math.min(y.length-1,Math.floor(y.length*.9))];if(d>1e-9&&P/d<=xt){let w=i.map(I=>{let _=0;for(let z of I.pts)_+=m(z);return{row:I,radius:_/I.pts.length}}),M=1/0;for(let I of w)I.radius<M&&(M=I.radius);w.sort((I,_)=>I.radius-_.radius);let E=-1,O=-1/0,A=d/Math.max(1,w.length)*.5,k=[];for(let I of w)I.radius-O>A&&(E++,O=I.radius),I.row.ordinal=E,I.row.blockDepth=I.radius-M,k.push(I.row);return{sectionId:e,rows:k,blockCount:f}}}let g=[];for(let[,m]of l){let h=gt(m);if(h){let S=d=>{let P=0;for(let w of d.pts)P+=w.x*h.x+w.y*h.y;return P/d.pts.length};m.sort((d,P)=>S(d)-S(P));let y=0;for(let d=0;d<m.length;d++)d>0&&(y+=Q(m[d-1].pts,m[d].pts)),m[d].ordinal=d,m[d].blockDepth=y,g.push(m[d])}else{let S=1/0;for(let y of m)y.focalDistance<S&&(S=y.focalDistance);m.sort((y,d)=>y.focalDistance-d.focalDistance);for(let y=0;y<m.length;y++)m[y].ordinal=y,m[y].blockDepth=Math.max(0,m[y].focalDistance-S),g.push(m[y])}}return{sectionId:e,rows:g,blockCount:f}}function Le(e){return e?e.accessibility&&e.accessibility.length?e.wheelchairSpaceType&&!e.accessibility.includes("wheelchair")?["wheelchair",...e.accessibility]:e.accessibility:e.wheelchairSpaceType?["wheelchair"]:e.accessible?["wheelchair"]:[]:[]}var X=Math.PI/180,wt=9,F=16;function ee(e,t,n,o){let r=n*X,i=Math.cos(r),s=Math.sin(r);return{x:o.x+e*i-t*s,y:o.y+e*s+t*i}}function je(e){let{seatCount:t,seatSpacing:n,curve:o,rotation:r,origin:i}=e,s=[];if(e.path)return se(e.path,t);if(t<=1)return t===1&&s.push({x:i.x,y:i.y}),s;if(o===0){for(let b=0;b<t;b++)s.push(ee(b*n,0,r,i));return s}let c=o/(t-1)*X,u=n/(2*Math.sin(Math.abs(c)/2));for(let b=0;b<t;b++){let a=b*c,f=u*Math.sin(a),l=-u+u*Math.cos(a);s.push(ee(f,l,r,i))}return s}function Pt(e){let t=new Map;if(e.overrides)for(let n of e.overrides)t.set(n.index,n);return t}function _n(e){let t=new Set((e.overrides??[]).filter(n=>n.skip&&Number.isInteger(n.index)&&n.index>=0&&n.index<e.seatCount).map(n=>n.index));return Math.max(0,e.seatCount-t.size)}function Mt(e,t){let n=Pt(e);return je(e).map((o,r)=>{let i=n.get(r),s=Le(i),c=we(e,r,i),u={...e.commercial,...i?.commercial};return{index:r,x:o.x+(i?.dx??0),y:o.y+(i?.dy??0),label:c,displayLabel:Y(e,r,t,i),categoryKey:i?.categoryKey??e.categoryKey,skipped:!!i?.skip,accessible:s.length>0,accessibility:s,wheelchairSpaceType:i?.wheelchairSpaceType,commercial:Object.values(u).some(b=>b!==void 0&&b!==!1&&b!=="")?u:void 0,viewUrl:i?.viewFromSeatUrl??e.viewFromSeatUrl,viewMeta:i?.viewFromSeatUrl?i.viewFromSeatMeta:e.viewFromSeatMeta,labelStyle:i?.labelStyle}})}function Ne(e){let t=[];for(let n of Mt(e))n.skipped||t.push({id:`${e.id}:${n.index}`,label:n.label,displayLabel:n.displayLabel===n.label?void 0:n.displayLabel,x:n.x,y:n.y,rowId:e.id,categoryKey:n.categoryKey,accessible:n.accessible||void 0,accessibility:n.accessibility.length?n.accessibility:void 0,wheelchairSpaceType:n.wheelchairSpaceType,commercial:n.commercial,viewUrl:n.viewUrl,viewMeta:n.viewMeta,labelStyle:n.labelStyle});return t}function vt(e){if(e.seatCountsBySide)return{...e.seatCountsBySide};let t=e.sides&&e.sides.length?e.sides:["top","bottom"],n=["top","bottom","left","right"].filter(i=>t.includes(i)),o={top:0,bottom:0,left:0,right:0};if(!n.length)return o;let r=Math.max(0,Math.round(e.seatCount));for(let i=0;i<r;i++)o[n[i%n.length]]+=1;return o}function Fe(e){let t=[],n=Math.max(0,Math.round(e.seatCount));if(n===0)return t;let o=new Map((e.overrides??[]).map(a=>[a.index,a])),r=(a,f,l,p)=>{let x=o.get(a),g=Le(x),m=x?.label??`${e.label}-${a+1}`,h=e.displayLabel??e.label;return{index:a,label:m,displayLabel:x?.displayLabel??`${h}-${a+1}`,x:f+(x?.dx??0),y:l+(x?.dy??0),categoryKey:x?.categoryKey??e.categoryKey,skipped:!!x?.skip,accessible:g.length>0,accessibility:g,wheelchairSpaceType:x?.wheelchairSpaceType,commercial:x?.commercial,viewUrl:x?.viewFromSeatUrl,viewMeta:x?.viewFromSeatUrl?x.viewFromSeatMeta:void 0,labelStyle:x?.labelStyle,...p?{side:p}:{}}};if(e.shape==="round"){let a=(e.radius??40)+F,f=e.rotation*X,l=Math.max(0,Math.min(360,e.seatArc??360));if(l>=360||n===1){for(let m=0;m<n;m++){let h=f+m/n*2*Math.PI;t.push(r(m,e.center.x+a*Math.cos(h),e.center.y+a*Math.sin(h)))}return t}let p=l*X,x=(2*Math.PI-p)/2,g=f+x;for(let m=0;m<n;m++){let h=g+m/(n-1)*p;t.push(r(m,e.center.x+a*Math.cos(h),e.center.y+a*Math.sin(h)))}return t}let i=e.width??80,s=e.height??50,c=vt(e),u=["top","bottom","left","right"],b=0;for(let a of u){let f=c[a];for(let l=0;l<f;l++){let p,x;a==="top"?(p=-i/2+(l+.5)*i/f,x=-s/2-F):a==="bottom"?(p=-i/2+(l+.5)*i/f,x=s/2+F):a==="left"?(p=-i/2-F,x=-s/2+(l+.5)*s/f):(p=i/2+F,x=-s/2+(l+.5)*s/f);let g=ee(p,x,e.rotation,e.center);t.push(r(b++,g.x,g.y,a))}}return t}function kn(e){return e.bookAsWhole||e.variableOccupancy?Math.max(0,Math.round(e.seatCount)):Fe(e).filter(t=>!t.skipped).length}function It(e){return Fe(e).filter(t=>!t.skipped).map(t=>({id:`${e.id}:${t.index}`,label:t.label,...t.displayLabel!==t.label?{displayLabel:t.displayLabel}:{},x:t.x,y:t.y,rowId:e.id,categoryKey:t.categoryKey,...t.accessible?{accessible:!0}:{},...t.accessibility.length?{accessibility:t.accessibility}:{},...t.wheelchairSpaceType?{wheelchairSpaceType:t.wheelchairSpaceType}:{},...t.commercial?{commercial:t.commercial}:{},...t.viewUrl?{viewUrl:t.viewUrl}:{},...t.viewUrl&&t.viewMeta?{viewMeta:t.viewMeta}:{},...t.labelStyle?{labelStyle:t.labelStyle}:{}}))}function Et(e){return[{id:`${e.id}:0`,label:e.label,...e.displayLabel&&e.displayLabel!==e.label?{displayLabel:e.displayLabel}:{},x:e.center.x,y:e.center.y,rowId:e.id,categoryKey:e.categoryKey,kind:"booth"}]}function Te(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[o].x,s=t[o].y,c=t[r].x,u=t[r].y;s>e.y!=u>e.y&&e.x<(c-i)*(e.y-s)/(u-s)+i&&(n=!n)}return n}function Ot(e,t){return t.some((n,o)=>{let r=t[(o+1)%t.length],i=(e.y-n.y)*(r.x-n.x)-(e.x-n.x)*(r.y-n.y);if(Math.abs(i)>1e-7)return!1;let s=(e.x-n.x)*(r.x-n.x)+(e.y-n.y)*(r.y-n.y),c=(r.x-n.x)**2+(r.y-n.y)**2;return s>=-1e-7&&s<=c+1e-7})}function te(e,t,n){return Te(e,t)&&!(n??[]).some(o=>Te(e,o)||Ot(e,o))}function Ln(e,t){return fe(e,t).point}function Z(e){if(!e.length)return{x:0,y:0};let t=0,n=0;for(let o of e)t+=o.x,n+=o.y;return{x:t/e.length,y:n/e.length}}function Ct(e){switch(e.type){case"row":{let t=Ne(e);if(!t.length)return{x:e.origin.x,y:e.origin.y};let n=0,o=0;for(let r of t)n+=r.x,o+=r.y;return{x:n/t.length,y:o/t.length}}case"table":case"booth":return{x:e.center.x,y:e.center.y};case"gaArea":return Z(e.points);case"section":return Z(e.outline);case"text":return{x:e.position.x,y:e.position.y};case"shape":return e.points&&e.points.length?Z(e.points):e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null?{x:e.x+e.width/2,y:e.y+e.height/2}:{x:e.x??0,y:e.y??0};case"decorImage":return{x:e.x+e.width/2,y:e.y+e.height/2}}}function Ae(e,t){return e.length===t.length&&e.every((n,o)=>n.x===t[o].x&&n.y===t[o].y)}function Rt(e,t){if(e.type!=="gaArea"||!Ae(e.points,t.outline))return!1;let n=e.holes??[],o=t.holes??[];return n.length===o.length&&n.every((r,i)=>Ae(r,o[i]))}function Tt(e,t){let n=e.filter(s=>s.type==="section"),o="referenceInventorySource"in t?t.referenceInventorySource?.logicalSectionId:void 0,r=Ct(t);return(o?n.find(s=>(s.logicalSectionId??s.id)===o&&(Rt(t,s)||te(r,s.outline,s.holes))):void 0)??n.find(s=>te(r,s.outline,s.holes))}function At(e){return e.floors&&e.floors.length?e.floors:[{id:"floor-0",name:"Main",objects:e.objects,focalPoint:e.focalPoint,referenceImage:e.referenceImage,backgroundImage:e.backgroundImage}]}function jn(e,t){let n=At(e);return(t?n.find(o=>o.id===t):n[0])?.objects??[]}function _t(e){return e.floors&&e.floors.length?e.floors.flatMap(t=>t.objects):e.objects}function De(e,t,n){let o=i=>({x:i.x+t,y:i.y+n}),r=i=>i.map(o);switch(e.type){case"row":return{...e,origin:o(e.origin)};case"table":case"booth":return{...e,center:o(e.center)};case"gaArea":return{...e,points:r(e.points),...e.holes?{holes:e.holes.map(r)}:{}};case"section":return{...e,outline:r(e.outline),...e.outlinePath?{outlinePath:ye(e.outlinePath,t,n)}:{},...e.holes?{holes:e.holes.map(r)}:{}};case"text":return{...e,position:o(e.position)};case"shape":return{...e,...e.points?{points:r(e.points)}:{},...e.x!=null?{x:e.x+t}:{},...e.y!=null?{y:e.y+n}:{}};case"decorImage":return{...e,x:e.x+t,y:e.y+n}}}function Nn(e,t=900){if(!e.floors||e.floors.length<2)return e;let n=[];return e.floors.forEach((o,r)=>{let i=-r*t;for(let s of o.objects)n.push(i===0?s:De(s,0,i))}),{...e,objects:n,floors:void 0}}function Fn(e){let t=e.floors;if(!t||t.length<2)return e;let n=kt(e),o=[];return t.forEach((r,i)=>{let{x:s,y:c}=n[i];for(let u of r.objects)o.push(De(u,s,c))}),{...e,objects:o,floors:void 0,referenceImage:void 0,backgroundImage:void 0}}function kt(e){let t=e.floors;if(!t?.length)return[{x:0,y:0}];if(t.length<2)return t.map(()=>({x:0,y:0}));let n=t.map(l=>Lt({...e,objects:l.objects,floors:void 0,focalPoint:l.focalPoint,referenceImage:void 0,backgroundImage:void 0})),o=Math.max(1,...n.map(l=>Math.max(l.width,l.height))),r=Math.max(64,Math.min(240,o*.08)),i=16/10,s=null;for(let l=1;l<=t.length;l+=1){let p=Math.ceil(t.length/l),x=new Array(l).fill(0),g=new Array(p).fill(0);n.forEach((d,P)=>{let w=P%l,M=Math.floor(P/l);x[w]=Math.max(x[w],d.width),g[M]=Math.max(g[M],d.height)});let m=x.reduce((d,P)=>d+P,0)+r*(l-1),h=g.reduce((d,P)=>d+P,0)+r*(p-1),S=l*p-t.length,y=Math.abs(Math.log(m/Math.max(1,h)/i))+S*.04;(!s||y<s.score)&&(s={columns:l,columnWidths:x,rowHeights:g,score:y})}let{columns:c,columnWidths:u,rowHeights:b}=s,a=[],f=[];return u.reduce((l,p,x)=>(a[x]=l,l+p+r),0),b.reduce((l,p,x)=>(f[x]=l,l+p+r),0),t.map((l,p)=>{let x=n[p],g=p%c,m=Math.floor(p/c),h=a[g]+(u[g]-x.width)/2,S=f[m]+(b[m]-x.height)/2;return{x:h-x.x,y:S-x.y}})}function _e(e,t,n,o,r,i){let s=[],c=be(e),u=f=>!f?.eventConfigurationId||f.eventConfigurationId===o,b=f=>!!f&&(!f.eventConfigurationId||f.eventConfigurationId===o),a=(f,l)=>b(f)?{...f,coverage:l}:void 0;for(let f of e){let l=[];if(f.type==="row"?l=Ne(f):f.type==="table"?l=It(f):f.type==="booth"&&(l=Et(f)),!l.length)continue;for(let h of l)h.viewUrl&&!u(h.viewMeta)&&(h.viewUrl=void 0,h.viewMeta=void 0);if(f.type==="row"){let h=c.get(f.id);if(h){let S=new Map((f.overrides??[]).map(y=>[y.index,y]));for(let y of l){let d=Number(y.id.slice(y.id.lastIndexOf(":")+1));if(!Number.isInteger(d))continue;y.logicalRowId=h.groupId,y.logicalSeatIndex=h.adjacencyOffset+d,S.get(d)?.displayLabel||(y.displayLabel=Y(f,d,h)),!y.viewUrl&&h.viewFromSeatUrl&&u(h.viewFromSeatMeta)&&(y.viewUrl=h.viewFromSeatUrl,y.viewMeta=h.viewFromSeatMeta);let P=S.get(d)?.confidenceEvidence;y.confidenceEvidence=a(P,"exact-seat")??a(f.confidenceEvidence,"row-representative")??a(h.confidenceEvidence,"row-representative")}}}let p=Tt(e,f),x=p?.viewFromSeatUrl,m=(p?.zone?t?.find(h=>h.id===p.zone):void 0)?.focalPoint??n;for(let h of l){if(!h.confidenceEvidence){let S=Number(h.id.slice(h.id.lastIndexOf(":")+1)),y=(f.type==="row"||f.type==="table")&&Number.isInteger(S)?f.overrides?.find(d=>d.index===S)?.confidenceEvidence:void 0;h.confidenceEvidence=a(y,"exact-seat")??(f.type==="row"?a(f.confidenceEvidence,"row-representative"):void 0)}h.confidenceEvidence??=a(p?.confidenceEvidence,"section-representative")??(i?a(i.evidence,i.coverage):void 0),!h.viewUrl&&x&&u(p?.viewFromSeatMeta)&&(h.viewUrl=x,h.viewMeta=p?.viewFromSeatMeta),!h.viewUrl&&r&&u(r.meta)&&(h.viewUrl=r.url,h.viewMeta=r.meta),p&&(h.sectionId=p.logicalSectionId??p.id),p?.zone&&(h.zoneId=p.zone),m&&(h.focalPoint={...m})}s.push(...l)}return s}function Dn(e,t={}){if(e.floors?.length){let o=[];for(let r of e.floors){let i=r.focalPoint??e.focalPoint,s=r.viewFromSeatUrl?{url:r.viewFromSeatUrl,meta:r.viewFromSeatMeta}:e.viewFromSeatUrl?{url:e.viewFromSeatUrl,meta:e.viewFromSeatMeta}:void 0,c=r.confidenceEvidence?{evidence:r.confidenceEvidence,coverage:"floor-representative"}:e.confidenceEvidence?{evidence:e.confidenceEvidence,coverage:"venue-representative"}:void 0,u=_e(r.objects,e.zones,i,e.eventConfigurationId,s,c);t.resolveEyeHeights!==!1&&ke(r.objects,r.focalPoint??e.focalPoint,r.baseHeightM??0,u),o.push(...u)}return o}let n=_e(e.objects,e.zones,e.focalPoint,e.eventConfigurationId,e.viewFromSeatUrl?{url:e.viewFromSeatUrl,meta:e.viewFromSeatMeta}:void 0,e.confidenceEvidence?{evidence:e.confidenceEvidence,coverage:"venue-representative"}:void 0);return t.resolveEyeHeights!==!1&&ke(e.objects,e.focalPoint,t.floorBaseHeightM??0,n),n}function ke(e,t,n,o){let r=e.filter(a=>a.type==="section"),i=n>0||r.some(a=>a.height!==void 0||a.rake!==void 0||(a.elevation??0)>0);if(!r.length||!i||!t){for(let a of o)a.eyeHeightM=n+B;return}let s=new Array(o.length),c=new Map,u=new Map;for(let a=0;a<o.length;a++){let f=o[a],l=r.find(x=>te({x:f.x,y:f.y},x.outline,x.holes))??null;if(s[a]=l,!l)continue;c.has(l.id)||c.set(l.id,Ie(l,{floorBaseHeightM:n}));let p=u.get(l.id);p?p.push(a):u.set(l.id,[a])}let b=new Array(o.length).fill(void 0);for(let[a,f]of u){let l=c.get(a);if(!l)continue;let p=l.rake>0?Math.tan(l.rake*Math.PI/180):0,x=Re(a,o,f,t);for(let g of x.rows){let m=g.blockDepth*U*p,h=l.height+m;for(let S of g.seatIndices)b[S]=h}}for(let a=0;a<o.length;a++){let f=o[a],l=s[a];if(!l){f.eyeHeightM=n+B;continue}let p=c.get(l.id);f.eyeHeightM=(b[a]??p.height)+B}}var G=40;function Lt(e){let t=1/0,n=1/0,o=-1/0,r=-1/0,i=(s,c)=>{s<t&&(t=s),c<n&&(n=c),s>o&&(o=s),c>r&&(r=c)};for(let s of _t(e))if(s.type==="row"){let c=new Map((s.overrides??[]).map(u=>[u.index,u]));je(s).forEach((u,b)=>{let a=c.get(b);a?.skip||i(u.x+(a?.dx??0),u.y+(a?.dy??0))})}else if(s.type==="gaArea")for(let c of s.points)i(c.x,c.y);else if(s.type==="section")for(let c of s.outline)i(c.x,c.y);else if(s.type==="decorImage")i(s.x,s.y),i(s.x+s.width,s.y+s.height);else if(s.type==="shape")if(s.points&&s.points.length)for(let c of s.points)i(c.x,c.y);else s.x!=null&&s.y!=null&&s.width!=null&&s.height!=null&&(i(s.x,s.y),i(s.x+s.width,s.y+s.height));else if(s.type==="table"){let c=F+wt,u=s.shape==="round"?(s.radius??40)+c:Math.max((s.width??80)/2,(s.height??50)/2)+c;i(s.center.x-u,s.center.y-u),i(s.center.x+u,s.center.y+u)}else if(s.type==="booth"){let c=Math.max(s.width,s.height)/2;i(s.center.x-c,s.center.y-c),i(s.center.x+c,s.center.y+c)}else if(s.type==="text"){let c=oe(s);i(s.position.x,s.position.y),i(s.position.x+c.width,s.position.y+c.height)}for(let s of[e.referenceImage,e.backgroundImage]){if(!s)continue;let{center:c,width:u}=s,b=u*3/4;i(c.x-u/2,c.y-b/2),i(c.x+u/2,c.y+b/2)}if(!isFinite(t)){let s=e.focalPoint??{x:0,y:0};return{x:s.x-200,y:s.y-200,width:400,height:400}}return{x:t-G,y:n-G,width:o-t+G*2,height:r-n+G*2}}export{jt as a,Nt as b,Ft as c,Dt as d,Ht as e,Ut as f,Bt as g,Gt as h,Xt as i,oe as j,Kt as k,Ge as l,$t as m,K as n,Yt as o,se as p,qt as q,Jt as r,ze as s,ue as t,Zt as u,fe as v,$e as w,tn as x,sn as y,pe as z,cn as A,ye as B,qe as C,an as D,ln as E,Ze as F,nt as G,un as H,dn as I,hn as J,mn as K,be as L,ge as M,it as N,W as O,Se as P,yn as Q,V as R,at as S,we as T,Y as U,U as V,Sn as W,ut as X,Pe as Y,ve as Z,Me as _,q as $,ft as aa,dt as ba,ht as ca,B as da,wn as ea,Ie as fa,Oe as ga,bt as ha,Re as ia,je as ja,_n as ka,Mt as la,Ne as ma,vt as na,Fe as oa,kn as pa,It as qa,Et as ra,Te as sa,te as ta,Ln as ua,Ct as va,Tt as wa,At as xa,jn as ya,_t as za,De as Aa,Nn as Ba,Fn as Ca,kt as Da,Dn as Ea,Lt as Fa};