@seatlayer/core 0.84.1 → 0.85.1

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 (55) hide show
  1. package/dist/{categoryInventory-CXB_6cKR.d.cts → categoryInventory-B7amHjdA.d.cts} +1 -1
  2. package/dist/{categoryInventory-CJAUVm-9.d.ts → categoryInventory-CthzF9K9.d.ts} +1 -1
  3. package/dist/{chunk-3BSYPGF3.js → chunk-4ABXX5PL.js} +1 -1
  4. package/dist/chunk-HEYENCES.js +1 -0
  5. package/dist/core/chart-ops/index.d.cts +4 -4
  6. package/dist/core/chart-ops/index.d.ts +4 -4
  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 +4 -4
  10. package/dist/core/inventory/index.d.ts +4 -4
  11. package/dist/core/inventory/index.js +1 -1
  12. package/dist/core/layout/index.d.cts +5 -5
  13. package/dist/core/layout/index.d.ts +5 -5
  14. package/dist/core/quality/index.cjs +1 -1
  15. package/dist/core/quality/index.d.cts +3 -3
  16. package/dist/core/quality/index.d.ts +3 -3
  17. package/dist/core/render-assets/index.d.cts +2 -2
  18. package/dist/core/render-assets/index.d.ts +2 -2
  19. package/dist/core/render-assets/index.js +1 -1
  20. package/dist/core/seatConfidence.d.cts +1 -1
  21. package/dist/core/seatConfidence.d.ts +1 -1
  22. package/dist/core/sections/index.d.cts +5 -5
  23. package/dist/core/sections/index.d.ts +5 -5
  24. package/dist/{eventConfigurations-CwfetQY5.d.cts → eventConfigurations-C-LVnEGg.d.cts} +1 -1
  25. package/dist/{eventConfigurations-mKY39sfQ.d.ts → eventConfigurations-CSuSanij.d.ts} +1 -1
  26. package/dist/index.cjs +1 -1
  27. package/dist/index.d.cts +24 -13
  28. package/dist/index.d.ts +24 -13
  29. package/dist/index.js +1 -1
  30. package/dist/{labeling-BXgKZTmM.d.cts → labeling-BFDnb10o.d.cts} +1 -1
  31. package/dist/{labeling-DA9cTa22.d.ts → labeling-BwC8Bksi.d.ts} +1 -1
  32. package/dist/{renderedQuality-D32EPlWq.d.ts → renderedQuality-CkrbA7iV.d.ts} +1 -1
  33. package/dist/{renderedQuality-BzTliRbk.d.cts → renderedQuality-DL9Nfka1.d.cts} +1 -1
  34. package/dist/{renderer-Kxpv-Iv6.d.ts → renderer-D9kIJYmd.d.cts} +3 -1
  35. package/dist/{renderer-C9TqalQD.d.cts → renderer-DUko-vky.d.ts} +3 -1
  36. package/dist/{seatTypeIcons-CKPTA_-Q.d.cts → seatTypeIcons-Bv2xK0xp.d.cts} +1 -1
  37. package/dist/{seatTypeIcons-DlGnOWfb.d.ts → seatTypeIcons-DUEZapsF.d.ts} +1 -1
  38. package/dist/{sections-CMh0XgP2.d.cts → sections-B1DzCiqs.d.cts} +1 -1
  39. package/dist/{sections-DImaB4fK.d.ts → sections-DcD6uNuO.d.ts} +1 -1
  40. package/dist/{segmentedRowModel-B0bIfSCS.d.ts → segmentedRowModel-NH_qhgic.d.ts} +1 -1
  41. package/dist/{segmentedRowModel-Cu6ojvdO.d.cts → segmentedRowModel-uu0WfRIz.d.cts} +1 -1
  42. package/dist/{tableSizing-CGzjNFm4.d.ts → tableSizing-BGl1e6Bi.d.ts} +3 -3
  43. package/dist/{tableSizing-Dp_GGrlh.d.cts → tableSizing-CJbozzMS.d.cts} +3 -3
  44. package/dist/{ticketRestrictions-LP9gbybN.d.ts → ticketRestrictions-BD5hvqtL.d.ts} +2 -2
  45. package/dist/{ticketRestrictions-CgpE7mdU.d.cts → ticketRestrictions-BEkiPPYg.d.cts} +2 -2
  46. package/dist/{types-CF7_htTi.d.cts → types-B97dNRwl.d.cts} +2 -0
  47. package/dist/{types-CF7_htTi.d.ts → types-B97dNRwl.d.ts} +2 -0
  48. package/dist/view3d/crossfade/panorama.d.cts +1 -1
  49. package/dist/view3d/crossfade/panorama.d.ts +1 -1
  50. package/dist/view3d/index.d.cts +3 -3
  51. package/dist/view3d/index.d.ts +3 -3
  52. package/dist/view3d/index.js +1 -1
  53. package/dist/view3d/scene/scene.worker.js +1 -1
  54. package/package.json +1 -1
  55. package/dist/chunk-WP5XGIE6.js +0 -1
@@ -1,4 +1,4 @@
1
- import { C as ChartDoc, R as RowObject, T as TableObject } from './types-CF7_htTi.cjs';
1
+ import { C as ChartDoc, R as RowObject, T as TableObject } from './types-B97dNRwl.cjs';
2
2
 
3
3
  /**
4
4
  * A category is a commercial definition for exactly one kind of inventory.
@@ -1,4 +1,4 @@
1
- import { C as ChartDoc, R as RowObject, T as TableObject } from './types-CF7_htTi.js';
1
+ import { C as ChartDoc, R as RowObject, T as TableObject } from './types-B97dNRwl.js';
2
2
 
3
3
  /**
4
4
  * A category is a commercial definition for exactly one kind of inventory.
@@ -1 +1 @@
1
- import{a as Pn,c as In,d as wn}from"./chunk-PRED5KHO.js";import{a as gn}from"./chunk-QJXSZT3H.js";import{e as Sn,k as Rn}from"./chunk-UL5OIGIF.js";import{a as Mn,c as Nt,d as ft,f as It,i as An}from"./chunk-BS37TGPX.js";import{f as hn}from"./chunk-4I2VWFJY.js";import{Na as qt,f as bn,ga as ut,ha as lt,qa as Gt,sa as dn,ta as Dt,va as yn,x as pn,y as At,za as xn}from"./chunk-24O23MNB.js";import{A as Pt,d as H,y as nt}from"./chunk-JBOTRSMY.js";import Ae from"earcut";import Pe from"polygon-clipping";var g=ut,Ie=.002;function we(t,n,e){let r=Math.hypot(n[0]-t[0],n[1]-t[1],n[2]-t[2]),o=Math.hypot(e[0]-n[0],e[1]-n[1],e[2]-n[2]),a=Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2]),i=Math.max(r,o,a);if(i<1e-9)return!0;let s=(r+o+a)/2;return 2*Math.sqrt(Math.max(0,s*(s-r)*(s-o)*(s-a)))/i<Ie}var ht=class{constructor(n=16384){this.len=0;this.buf=new Float32Array(n)}push3(n,e,r){this.len+3>this.buf.length&&this.grow(this.len+3),this.buf[this.len++]=n,this.buf[this.len++]=e,this.buf[this.len++]=r}push1(n){this.len+1>this.buf.length&&this.grow(this.len+1),this.buf[this.len++]=n}grow(n){let e=this.buf.length*2;for(;e<n;)e*=2;let r=new Float32Array(e);r.set(this.buf.subarray(0,this.len)),this.buf=r}get length(){return this.len}toArray(){return this.buf.slice(0,this.len)}},Yt=class{constructor(){this.pos=new ht;this.nor=new ht;this.col=new ht;this.flr=new ht;this.mat=new ht;this.currentFloor=0;this.currentMaterial=0}setFloor(n){this.currentFloor=n}setMaterial(n){this.currentMaterial=n}tri(n,e,r,o,a,i=a,s=a){we(n,e,r)||(this.pos.push3(n[0],n[1],n[2]),this.pos.push3(e[0],e[1],e[2]),this.pos.push3(r[0],r[1],r[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.col.push3(a[0],a[1],a[2]),this.col.push3(i[0],i[1],i[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(n,e,r,o,a,i,s,l=s,c=s){[...n,...e,...r].every(Number.isFinite)&&(this.pos.push3(n[0],n[1],n[2]),this.pos.push3(e[0],e[1],e[2]),this.pos.push3(r[0],r[1],r[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(a[0],a[1],a[2]),this.nor.push3(i[0],i[1],i[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 _e(t,n,e){let r=n[0]-t[0],o=n[1]-t[1],a=n[2]-t[2],i=e[0]-t[0],s=e[1]-t[1],l=e[2]-t[2],c=o*l-a*s,f=a*i-r*l,m=r*s-o*i,u=Math.hypot(c,f,m)||1;return c/=u,f/=u,m/=u,[c,f,m]}function Te(t,n){let e=[...t],r=[];for(let i of t)r.push(i.x,i.y);let o=[];if(n){for(let i of n)if(!(i.length<3)){o.push(e.length);for(let s of i)e.push(s),r.push(s.x,s.y)}}let a=Ae(r,o.length?o:void 0,2);return{pts:e,tris:a}}function Jt(t){return ft(t)<0?[...t].reverse():t}var Be=3;function Ee(t,n,e,r){let o=r(t),a=r(n),i=r(e),s=(h,b,p,d)=>Math.abs(r({x:(h.x+b.x)/2,y:(h.y+b.y)/2})-(p+d)/2),l=(t.x+n.x+e.x)/3,c=(t.y+n.y+e.y)/3,f=(o+a+i)/3,m=Math.max(s(t,n,o,a),s(n,e,a,i),s(e,t,i,o),Math.abs(r({x:l,y:c})-f)),u=(h,b,p)=>{let d=Math.abs(r({x:(h+l)/2,y:(b+c)/2})-(p+f)/2);d>m&&(m=d)};return u((t.x+n.x)/2,(t.y+n.y)/2,(o+a)/2),u((n.x+e.x)/2,(n.y+e.y)/2,(a+i)/2),u((e.x+t.x)/2,(e.y+t.y)/2,(i+o)/2),m}function wt(t,n,e,r,o){if(o<=0)return Ee(t,n,e,r);let a={x:(t.x+n.x)/2,y:(t.y+n.y)/2},i={x:(n.x+e.x)/2,y:(n.y+e.y)/2},s={x:(e.x+t.x)/2,y:(e.y+t.y)/2};return Math.max(wt(t,a,s,r,o-1),wt(a,n,i,r,o-1),wt(s,i,e,r,o-1),wt(a,i,s,r,o-1))}function _t(t,n,e,r,o,a,i,s){if(i>0){let u={x:(n.x+e.x)/2,y:(n.y+e.y)/2},h={x:(e.x+r.x)/2,y:(e.y+r.y)/2},b={x:(r.x+n.x)/2,y:(r.y+n.y)/2};_t(t,n,u,b,o,a,i-1,s),_t(t,u,e,h,o,a,i-1,s),_t(t,b,h,r,o,a,i-1,s),_t(t,u,h,b,o,a,i-1,s);return}let l=[n.x*g,o(n),n.y*g],c=[e.x*g,o(e),e.y*g],f=[r.x*g,o(r),r.y*g];if(s){t.triN(l,c,f,s(n),s(e),s(r),a);return}let m=_e(l,c,f);m[1]<0&&(m=[-m[0],-m[1],-m[2]]),t.tri(l,c,f,m,a)}var Ce=8;function _n(t,n,e){if(!Number.isFinite(e))return t;let r=[],o=(a,i,s,l,c)=>{if(c>0){let f={x:(a.x+i.x)/2,y:(a.y+i.y)/2},m=n(f);if(Math.abs(m-(s+l)/2)>e){o(a,f,s,m,c-1),o(f,i,m,l,c-1);return}}r.push(a)};for(let a=0;a<t.length;a++){let i=t[a],s=t[(a+1)%t.length];o(i,s,n(i),n(s),Ce)}return r}function Xt(t,n){if(t.length<3)return t;let e=[];for(let o of t){let a=e[e.length-1];a&&Math.hypot(o.x-a.x,o.y-a.y)<n||e.push(o)}for(;e.length>2&&Math.hypot(e[0].x-e[e.length-1].x,e[0].y-e[e.length-1].y)<n;)e.pop();if(e.length<3)return t;let r=[];for(let o=0;o<e.length;o++){let a=r.length?r[r.length-1]:e[(o-1+e.length)%e.length],i=e[o],s=e[(o+1)%e.length],l=s.x-a.x,c=s.y-a.y,f=Math.hypot(l,c);f>n&&Math.abs((i.x-a.x)*c-(i.y-a.y)*l)/f<n||r.push(i)}return r.length>=3?r:e}var Ut=.001*lt*.1;function K(t,n,e,r,o,a,i,s,l=1/0,c){if(!n||n.length<3||(l===void 0&&(l=1/0),Math.abs(ft(n))<1e-4))return;let f=Xt(_n(Xt(Jt(n),Ut),r,l),Ut),m=e?.map(M=>Xt(_n(Xt(Jt(M),Ut),r,l),Ut)).filter(M=>M.length>=3&&Math.abs(ft(M))>=1e-4),{pts:u,tris:h}=Te(f,m),b=[a[0]*s.top,a[1]*s.top,a[2]*s.top],p=[a[0]*s.bottomCap,a[1]*s.bottomCap,a[2]*s.bottomCap],d=[i[0]*s.top,i[1]*s.top,i[2]*s.top],y=[i[0]*s.wallBottom,i[1]*s.wallBottom,i[2]*s.wallBottom],x=0;if(Number.isFinite(l))for(;x<Be;x++){let M=0;for(let I=0;I<h.length;I+=3){let B=wt(u[h[I]],u[h[I+1]],u[h[I+2]],r,x);B>M&&(M=B)}if(M<=l)break}for(let M=0;M<h.length;M+=3){let I=u[h[M]],B=u[h[M+1]],k=u[h[M+2]];_t(t,I,B,k,r,b,x,c);let D=[I.x*g,o,I.y*g],U=[B.x*g,o,B.y*g],S=[k.x*g,o,k.y*g];t.tri(D,S,U,[0,-1,0],p)}let w=M=>{if(x<=0)return M;let I=1<<x,B=[];for(let k=0;k<M.length;k++){let D=M[k],U=M[(k+1)%M.length];for(let S=0;S<I;S++){let _=S/I;B.push({x:D.x+(U.x-D.x)*_,y:D.y+(U.y-D.y)*_})}}return B},A=pn(f),E=[{ring:w(f),flip:!1}];if(m)for(let M of m)M.length>=3&&E.push({ring:w(M),flip:!0});for(let{ring:M,flip:I}of E)for(let B=0;B<M.length;B++){let k=M[B],D=M[(B+1)%M.length],U=(D.x-k.x)*g,_=(D.y-k.y)*g,N=-U,O=Math.hypot(_,N)||1;_/=O,N/=O;let P=(k.x+D.x)/2-A.x,F=(k.y+D.y)/2-A.y,R=_*P+N*F;I&&(R=-R),R<0&&(_=-_,N=-N);let T=[_,0,N],C=[k.x*g,r(k),k.y*g],v=[D.x*g,r(D),D.y*g],G=[k.x*g,o,k.y*g],X=[D.x*g,o,D.y*g];t.tri(C,v,X,T,d,d,y),t.tri(C,X,G,T,d,y,y)}}function Tn(t){let n=0;for(let l of t)n+=l.count;let e=new Float32Array(n*3),r=new Float32Array(n*3),o=new Float32Array(n*3),a=new Float32Array(n),i=new Float32Array(n),s=0;for(let l of t)e.set(l.position,s*3),r.set(l.normal,s*3),o.set(l.color,s*3),a.set(l.floor,s),i.set(l.material,s),s+=l.count;return{position:e,normal:r,color:o,floor:a,material:i,count:n}}function jt(t,n,e=2.5){if(n<=0||t.length<3)return t;let r=Jt(t),o=r.length,a=[];for(let s=0;s<o;s++){let l=r[s],c=r[(s+1)%o],f=c.x-l.x,m=c.y-l.y,u=Math.hypot(f,m)||1;a.push({x:m/u,y:-f/u})}let i=[];for(let s=0;s<o;s++){let l=r[s],c=a[(s-1+o)%o],f=a[s],m=c.x+f.x,u=c.y+f.y,h=Math.hypot(m,u),b=()=>{i.push([l.x+c.x*n,l.y+c.y*n]),i.push([l.x+f.x*n,l.y+f.y*n])};if(h<1e-9){b();continue}m/=h,u/=h;let p=m*c.x+u*c.y,d=1/Math.max(p,1e-6);if(!Number.isFinite(d)||d>e){b();continue}i.push([l.x+m*n*d,l.y+u*n*d])}if(i.length<3)return t;try{let s=Pe.union([[...i,i[0]]]),l=null,c=-1/0;for(let m of s){let u=Math.abs(ft(m[0].map(([h,b])=>({x:h,y:b}))));u>c&&(c=u,l=m[0])}if(!l)return t;let f=l.map(([m,u])=>({x:m,y:u}));if(f.length>1){let m=f[0],u=f[f.length-1];Math.abs(m.x-u.x)<1e-9&&Math.abs(m.y-u.y)<1e-9&&f.pop()}return f.length>=3?f:t}catch{return t}}function Ht(t,n,e,r,o=28){let a=[];for(let i=0;i<o;i++){let s=i/o*Math.PI*2;a.push({x:t+e*Math.cos(s),y:n+r*Math.sin(s)})}return a}function Tt(t,n,e,r){return[{x:t,y:n},{x:t+e,y:n},{x:t+e,y:n+r},{x:t,y:n+r}]}var Bt=["available","held","sold","selected","dimmed"];function Qt(t){let n=Bt.indexOf(t);return n<0?0:n}var Bn={available:[.24,.82,.52],held:[.95,.66,.22],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};function mr(t){let n=.2126*t[0]+.7152*t[1]+.0722*t[2],e=.42,r=.62;return[(n+(t[0]-n)*e)*r,(n+(t[1]-n)*e)*r,(n+(t[2]-n)*e)*r]}var tn={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]},nn={top:[.05,.06,.08],bottom:[.1,.12,.15]};function et(t,n){return[Math.min(1,t[0]*n),Math.min(1,t[1]*n),Math.min(1,t[2]*n)]}var V={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,body:10,head:11},Fe=.44,ve=.15,ke=.3,Oe=.24;function En(t){return t===void 0||!Number.isFinite(t)||t<=0?Oe:Math.min(ke,Math.max(ve,t*Fe))}var hr=.21,Le=.05,en=.45,Ge=en+Le,De=.92,Ne=1.205,Xe=-.23,Ue=.38,Ye=[{part:V.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:V.pad,min:[-1,.36,-.95],max:[1,en,1]},{part:V.back,min:[-1,Ge,-1],max:[1,De,-.72]},{part:V.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:V.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:V.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:V.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:V.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:V.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:V.leg,min:[.62,0,.48],max:[.82,.37,.7]}],je=[{part:V.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:V.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:V.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:V.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:V.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}],He=[{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 br(){let t=[],n=[],e=[],r=[],o=(O,P,F)=>{let R=e.length,[T,C,v]=O,G=[C[0]-T[0],C[1]-T[1],C[2]-T[2]],X=[v[0]-T[0],v[1]-T[1],v[2]-T[2]],L=G[1]*X[2]-G[2]*X[1],Y=G[2]*X[0]-G[0]*X[2],j=G[0]*X[1]-G[1]*X[0],$=Math.hypot(L,Y,j);$>1e-9?(L/=$,Y/=$,j/=$):[L,Y,j]=P,L*P[0]+Y*P[1]+j*P[2]<0&&(L=-L,Y=-Y,j=-j);for(let z of O)t.push(...z),n.push(L,Y,j),e.push(F);r.push(R,R+1,R+2,R,R+2,R+3)},a=O=>{for(let P of He){let F=P.c.map(R=>R.map((T,C)=>T?O.max[C]:O.min[C]));o(F,P.n,O.part)}};for(let O of Ye)a(O);for(let O of je)a(O);let i=en,s=1.08,l=.47,c=.69,f=-.55,m=.08,u=-.48,h=.01,b=[-l,i,f],p=[l,i,f],d=[-l,i,m],y=[l,i,m],x=[-c,s,u],w=[c,s,u],A=[-c,s,h],E=[c,s,h];o([p,w,E,y],[1,0,0],V.body),o([d,A,x,b],[-1,0,0],V.body),o([A,E,w,x],[0,1,0],V.body),o([b,p,y,d],[0,-1,0],V.body),o([y,E,A,d],[0,0,1],V.body),o([b,x,w,p],[0,0,-1],V.body);let M=10,I=8,B=[0,Ne,Xe],k=[.42,.115,Ue],D=e.length;for(let O=0;O<=I;O++){let P=Math.PI*O/I,F=Math.cos(P),R=Math.sin(P);for(let T=0;T<=M;T++){let C=Math.PI*2*T/M,v=R*Math.cos(C),G=R*Math.sin(C);t.push(B[0]+k[0]*v,B[1]+k[1]*F,B[2]+k[2]*G);let X=v/k[0],L=F/k[1],Y=G/k[2],j=Math.hypot(X,L,Y)||1;X/=j,L/=j,Y/=j,n.push(X,L,Y),e.push(V.head)}}for(let O=0;O<I;O++)for(let P=0;P<M;P++){let F=D+O*(M+1)+P,R=F+M+1;r.push(F,R,F+1,F+1,R,R+1)}let U=new Float32Array(t),S=new Float32Array(n),_=new Float32Array(e),N=new Uint16Array(r);return{position:U,normal:S,part:_,index:N,vertexCount:e.length,indexCount:r.length}}function Cn(t,n,e,r){let o=new Float32Array(n),a=c=>t[c*3],i=c=>t[c*3+2],s=0,l=(c,f)=>{let m=f-c;for(let u=c;u<f;u++){let[h,b]=r(u),p=h-a(u),d=b-i(u);if(m>=2){let y=Math.max(c,u-1),x=Math.min(f-1,u+1),w=a(x)-a(y),A=i(x)-i(y),E=Math.hypot(w,A);if(E>1e-6){let M=-A/E,I=w/E;M*p+I*d<0&&(M=-M,I=-I),p=M,d=I}}o[u]=p===0&&d===0?0:Math.atan2(p,d)}};for(let c=1;c<=n;c++)(c===n||e(c)!==e(s))&&(l(s,c),s=c);return o}var Vt=.22;function Ar(t,n){let e=Bt[t];if(e!=="sold"&&e!=="held")return-1;let r=(n+1)*2654435761;return r^=r>>>15,r=Math.imul(r,2246822519),r^=r>>>13,(r>>>0)%1e5/1e5}var Ve=.42;function We(t){let n=t.length,e=new Float64Array(n);if(n<2)return e.fill(1/0),e;let r=1/0,o=1/0,a=-1/0,i=-1/0;for(let b of t)b.x<r&&(r=b.x),b.y<o&&(o=b.y),b.x>a&&(a=b.x),b.y>i&&(i=b.y);let s=Math.max(a-r,1e-6),l=Math.max(i-o,1e-6),c=Math.max(Math.sqrt(s*l/n),1e-6),f=Math.max(1,Math.ceil(s/c)+1),m=Math.max(1,Math.ceil(l/c)+1),u=new Map,h=(b,p)=>{let d=Math.min(f-1,Math.max(0,Math.floor((b-r)/c)));return Math.min(m-1,Math.max(0,Math.floor((p-o)/c)))*f+d};for(let b=0;b<n;b++){let p=h(t[b].x,t[b].y),d=u.get(p);d?d.push(b):u.set(p,[b])}for(let b=0;b<n;b++){let p=t[b],d=Math.min(f-1,Math.max(0,Math.floor((p.x-r)/c))),y=Math.min(m-1,Math.max(0,Math.floor((p.y-o)/c))),x=1/0;for(let w=1;w<=4;w++){for(let A=y-w;A<=y+w;A++)if(!(A<0||A>=m))for(let E=d-w;E<=d+w;E++){if(E<0||E>=f||w>1&&Math.abs(A-y)<w&&Math.abs(E-d)<w)continue;let M=u.get(A*f+E);if(M)for(let I of M){if(I===b)continue;let B=Math.hypot(t[I].x-p.x,t[I].y-p.y);B<x&&(x=B)}}if(Number.isFinite(x)&&x<=w*c)break}e[b]=x}return e}function ze(t){let n=t.eyeHeightM;return Number.isFinite(n)?Math.max(0,n-Gt):0}function Fn(t,n,e,r,o,a){let i=t.length,s=new Float32Array(i*3),l=new Float32Array(i),c=new Float32Array(i*3),f=new Float32Array(i),m=new Float32Array(i),u=new Float32Array(i),h=new Float32Array(i),b=new Float32Array(i*3),p=new Map,d=We(t);for(let y=0;y<i;y++){let x=t[y],A=(e?.seatPitchU(y)??d[y])*g;f[y]=Number.isFinite(A)?Math.max(.06,Math.min(Vt,A*Ve)):Vt,m[y]=En(Number.isFinite(A)?A:void 0);let E=Rn(x.glyph,{seatGlyph:a?.get(x.categoryKey)});u[y]=Sn.indexOf(E),h[y]=x.wheelchairSpaceType==="no-seat"?0:1,s[y*3]=x.x*g,s[y*3+1]=e?e.seatDeckY(y):ze(x),s[y*3+2]=x.y*g,l[y]=Qt(n?n(x):"available");let M=H(o?.get(x.categoryKey)??"#6e7bff")??[.43,.48,1];if(c[y*3]=M[0],c[y*3+1]=M[1],c[y*3+2]=M[2],x.accessibility?.length){let I=H(hn(x.accessibility));I&&(b[y*3]=I[0],b[y*3+1]=I[1],b[y*3+2]=I[2])}p.set(x.id,y)}return{count:i,iPosition:s,iState:l,iCategory:c,iMaxRadius:f,iRing:b,idToIndex:p,iChairWidth:m,iGlyph:u,iPhysicalSeat:h,iFloor:r??new Float32Array(i),iYaw:new Float32Array(i)}}var Ze=64;function Pr(t,n){let e=[];for(let i of n){let s=t.idToIndex.get(i.seatId);if(s===void 0)continue;let l=Qt(i.state);t.iState[s]!==l&&(t.iState[s]=l,e.push(s))}if(!e.length)return[];e.sort((i,s)=>i-s);let r=[],o=e[0],a=e[0];for(let i=1;i<e.length;i++){let s=e[i];if(s!==a){if(s<=a+Ze){a=s;continue}r.push({start:o,length:a-o+1}),o=s,a=s}}return r.push({start:o,length:a-o+1}),r}function _r(t,n,e){return e<0?n>1?t.filter(r=>r.kind==="floor"):[...t]:t.filter(r=>r.floorIndex===void 0||r.floorIndex===e)}function Tr(t,n){let e=[...t].sort((o,a)=>o.screen.y-a.screen.y),r=[];for(let o of e){let a=r.find(i=>i.some(s=>Math.abs(s.screen.x-o.screen.x)<104&&Math.abs(s.screen.y-o.screen.y)<34));a?a.push(o):r.push([o])}return r.flatMap(o=>o.length<2?o:o.map((a,i)=>({...a,screen:{...a.screen,x:Math.max(54,Math.min(n-54,a.screen.x+(i-(o.length-1)/2)*104))}})))}var Ke=1.15,$e=2.75,qe=4.5,Je=.85,Qe=.5,to=.26;function Br(t,n,e){let r=Math.max(1e-6,n),o=t/r,a=e?.hasZoneLabels??!0,i=new Set;return o>=.75&&i.add("floor"),o>=Ke&&i.add("zone"),o<=(a?$e:qe)&&(i.add("section"),i.add("ga")),o<=Je&&(i.add("annotation"),i.add("booth")),o<=Qe&&i.add("row"),o<=to&&i.add("seat"),i}function Er(t,n,e,r,o,a=6){let i=a+n,s=r-a-n,l=a+e,c=o-a-e;return{...t,x:i>s?r/2:Math.max(i,Math.min(s,t.x)),y:l>c?o/2:Math.max(l,Math.min(c,t.y))}}function Cr(t,n,e,r){let o=t,a=n[0],i=n[1],s=n[2],l=o[0]*a+o[4]*i+o[8]*s+o[12],c=o[1]*a+o[5]*i+o[9]*s+o[13],f=o[2]*a+o[6]*i+o[10]*s+o[14],m=o[3]*a+o[7]*i+o[11]*s+o[15];if(!(m>1e-6))return{x:0,y:0,depth:1/0,visible:!1};let u=l/m,h=c/m,b=f/m,p=u>=-1.05&&u<=1.05&&h>=-1.05&&h<=1.05&&b<=1;return{x:(u*.5+.5)*e,y:(1-(h*.5+.5))*r,depth:b,visible:p}}function Fr(t,n,e=n){let r=[],o=[...t].sort((a,i)=>a.screen.depth-i.screen.depth);for(let a of o){let i=!1;for(let s of r)if(on(a,s,n,e)){i=!0;break}i||r.push(a)}return r}var no=6;function on(t,n,e,r){let o=Math.abs(t.screen.x-n.screen.x),a=Math.abs(t.screen.y-n.screen.y),i=t.halfWidth!=null&&n.halfWidth!=null?Math.max(e,t.halfWidth+n.halfWidth+no):e;return o<i&&a<r}function vr(t,n,e){return t.length*n*.58+(e?14:0)}var eo={row:8,seat:14};function kr(t){return t<480?{row:5,seat:8}:t<768?{row:6,seat:10}:eo}function Or(t,n,e,r){let o=Math.max(1,Math.min(e,r)*.5),a=Math.min(2,Math.hypot(t.x-e/2,t.y-r/2)/o);return n*(1+1.5*a)}function Lr(t,n,e,r,o=[]){let a=[...t].sort((s,l)=>(l.priority??0)-(s.priority??0)||s.focus-l.focus),i=[];for(let s of a){if(i.length>=r)break;let l=!1;for(let c of o)if(on(s,c,n,e)){l=!0;break}if(!l){for(let c of i)if(on(s,c,n,e)){l=!0;break}}l||i.push(s)}return i}import bo from"polygon-clipping";var W={top:1,wallBottom:.5,bottomCap:.4};function st(t,n){if(!t)return n;let e=et(Pt(t,.4),.62);return nt(n,e,.72)}function vn(t,n){let e=new Map;for(let a of t.categories??[])e.set(a.key,a.color);let r=new Map;for(let a of n){if(!a.sectionId)continue;let i=r.get(a.sectionId);i||(i=new Map,r.set(a.sectionId,i)),i.set(a.categoryKey,(i.get(a.categoryKey)??0)+1)}let o=new Map;for(let[a,i]of r){let s=0,l=0,c=0,f=0;for(let[m,u]of i){let h=H(e.get(m));h&&(s+=h[0]*u,l+=h[1]*u,c+=h[2]*u,f+=u)}f>0&&o.set(a,[s/f,l/f,c/f])}return o}function kn(t,n){return H(t.color)??n.get(t.logicalSectionId??t.id)??null}import zn from"polygon-clipping";import Dn from"polygon-clipping";import oo from"earcut";var ro=.58,On=.01,ot=Vt*1.5*lt,io=.5,so=.6;function ao(t,n){let e=t.length,r=[];for(let i=0;i<e;i++){let s=t[Math.max(0,i-1)],l=t[Math.min(e-1,i+1)],c=l.x-s.x,f=l.y-s.y,m=Math.hypot(c,f);if(m<1e-9){r.push([0,0]);continue}c/=m,f/=m,r.push([-f,c])}let o=0;for(let i=0;i<e;i++)o+=(t[i].x-n.x)*r[i][0]+(t[i].y-n.y)*r[i][1];return o<0?r.map(([i,s])=>[-i,-s]):r}function co(t,n){if(t.length<2||n<=0)return[...t];let e=[...t],r=(i,s)=>{let l=s.x-i.x,c=s.y-i.y,f=Math.hypot(l,c)||1;return{x:l/f,y:c/f}},o=r(e[1],e[0]),a=r(e[e.length-2],e[e.length-1]);return e.unshift({x:e[0].x+o.x*n,y:e[0].y+o.y*n}),e.push({x:e[e.length-1].x+a.x*n,y:e[e.length-1].y+a.y*n}),e}var Ln=Math.PI/12;function uo(t){if(t.length<3)return[...t];let n=[...t].sort((a,i)=>a.x-i.x||a.y-i.y),e=(a,i,s)=>(i.x-a.x)*(s.y-a.y)-(i.y-a.y)*(s.x-a.x),r=a=>{let i=[];for(let s of a){for(;i.length>=2&&e(i[i.length-2],i[i.length-1],s)<=0;)i.pop();i.push(s)}return i.pop(),i},o=[...r(n),...r([...n].reverse())];return o.length>=3?o:[...t]}function Nn(t,n){if(!t.length||!(n>0))return[];let e=uo(t),r=(s,l,c,f)=>{let m=c-l;for(;m<0;)m+=Math.PI*2;for(;m>Math.PI*2;)m-=Math.PI*2;let u=Math.max(1,Math.ceil(m/Ln)),h=n/Math.cos(m/u/2);for(let b=0;b<=u;b++){let p=l+m*b/u;f.push({x:s.x+Math.cos(p)*h,y:s.y+Math.sin(p)*h})}};if(e.length<3){let s=0,l=0;for(let h of e)s+=h.x,l+=h.y;s/=e.length||1,l/=e.length||1;let c=0;for(let h of e)c=Math.max(c,Math.hypot(h.x-s,h.y-l));let f=[],m=Math.max(3,Math.ceil(Math.PI*2/Ln)),u=(c+n)/Math.cos(Math.PI/m);for(let h=0;h<m;h++){let b=h/m*Math.PI*2;f.push({x:s+Math.cos(b)*u,y:l+Math.sin(b)*u})}return f}let o=e.length,a=[];for(let s=0;s<o;s++){let l=e[s],c=e[(s+1)%o];a.push(Math.atan2(-(c.x-l.x),c.y-l.y))}let i=[];for(let s=0;s<o;s++)r(e[s],a[(s+o-1)%o],a[s],i);return Hn(i)}function lo(t,n,e){if(t.length===1)return Math.hypot(n-t[0].x,e-t[0].y);let r=1/0;for(let o=0;o+1<t.length;o++){let a=t[o],i=t[o+1],s=i.x-a.x,l=i.y-a.y,c=s*s+l*l,f=c>1e-12?((n-a.x)*s+(e-a.y)*l)/c:0;f<0?f=0:f>1&&(f=1);let m=Math.hypot(n-(a.x+f*s),e-(a.y+f*l));m<r&&(r=m)}return r}function Wt(t){let n=t.map(o=>{let a=0,i=0;for(let c of o.pts)a+=c.x,i+=c.y;let s=o.pts.length||1;a/=s,i/=s;let l=0;for(let c of o.pts){let f=Math.hypot(c.x-a,c.y-i);f>l&&(l=f)}return{cx:a,cy:i,rad:l}}),e=o=>{let a=o.length;return a<=2?[...o]:[o[Math.floor(a*.25)],o[Math.floor(a*.5)],o[Math.floor(a*.75)]]},r=[];for(let o=0;o<t.length;o++){let a=e(t[o].pts),i=[],s=1/0,l=null;for(let f of a){let m=1/0;for(let u=0;u<t.length;u++){if(u===o||Math.abs(t[u].y-t[o].y)<.001)continue;let h=n[u],b=Math.hypot(f.x-h.cx,f.y-h.cy)-h.rad;if(b>=m&&b>=s)continue;let p=lo(t[u].pts,f.x,f.y);p<m&&(m=p),t[u].depth<t[o].depth&&p<s&&(s=p,l=t[u].y)}Number.isFinite(m)&&m>0&&i.push(m)}i.sort((f,m)=>f-m);let c=i.length?i[Math.floor(i.length/2)]:1;r.push({pitch:c,belowY:l})}return r}function Xn(t,n,e,r){let o=t[n],a=o.pts.length>=2?[...o.pts]:o.pts.length===1?(()=>{let f=o.pts[0],m=f.x-r.x,u=f.y-r.y,h=Math.hypot(m,u)||1;m/=h,u/=h;let b=Math.max(e[n].pitch,.001)*.5;return[{x:f.x+u*b,y:f.y-m*b},{x:f.x-u*b,y:f.y+m*b}]})():[];if(a.length<2)return null;let i=0,s=0;for(let f=1;f<a.length;f++){let m=Math.hypot(a[f].x-a[f-1].x,a[f].y-a[f-1].y);m>1e-6&&(i+=m,s++)}let l=s>0?i/s:0,c=co(a,Math.max(l*so,ot));return{pts:c,nrm:ao(c,r),front:Math.max(e[n].pitch*ro,ot),back:Math.max(e[n].pitch*io,ot)}}var gt=1.5,Un=.3;function rn(t,n){if(t.length<3)return t;let e=t[0],r=t[t.length-1],o=r.x-e.x,a=r.y-e.y,i=Math.hypot(o,a),s=-1,l=-1;for(let m=1;m<t.length-1;m++){let u=t[m],h=i>1e-12?Math.abs((u.x-e.x)*a-(u.y-e.y)*o)/i:Math.hypot(u.x-e.x,u.y-e.y);h>s&&(s=h,l=m)}if(s<=n||l<0)return[e,r];let c=rn(t.slice(0,l+1),n),f=rn(t.slice(l),n);return[...c.slice(0,-1),...f]}function Yn(t,n){if(t.length<4)return t;let e=rn([...t,t[0]],n);return e.pop(),e.length>=3?e:t}function jn(t,n,e){if(t.length<2)return[];let r=e??Wt(t),o=new Map;for(let i=0;i<t.length;i++){let s=o.get(t[i].blockId);s?s.push(i):o.set(t[i].blockId,[i])}let a=[];for(let[,i]of o){let s=[];for(let x of i){let w=t[x].patch;w&&w.length>=3?a.push({outline:[...w],holes:[],topY:t[x].y}):s.push(x)}if(!s.length)continue;s.sort((x,w)=>t[x].depth-t[w].depth);let c=s.map(x=>Xn(t,x,r,n)).filter(x=>x!==null);if(!c.length)continue;let f=(x,w)=>({x:x.pts[w].x-x.nrm[w][0]*(x.front+gt),y:x.pts[w].y-x.nrm[w][1]*(x.front+gt)}),m=(x,w)=>({x:x.pts[w].x+x.nrm[w][0]*(x.back+gt),y:x.pts[w].y+x.nrm[w][1]*(x.back+gt)}),u=c[0],h=c[c.length-1],b=[];for(let x=0;x<u.pts.length;x++)b.push(f(u,x));for(let x of c)b.push(m(x,x.pts.length-1));for(let x=h.pts.length-1;x>=0;x--)b.push(m(h,x));for(let x=c.length-1;x>=0;x--)b.push(f(c[x],0));let p=Hn(b),d=1/0;for(let x of s)t[x].y<d&&(d=t[x].y);if(!Number.isFinite(d))continue;if(p.length>=3&&Math.abs(ft(p))>1e-6&&c.every(x=>{let w=x.pts[Math.floor(x.pts.length/2)];return It(p,w.x,w.y)})){a.push({outline:Yn(p,Un),holes:[],topY:d});continue}for(let x of mo(c))a.push({outline:x,holes:[],topY:d})}return a}function mo(t){let n=[];for(let e of t){let r=[],o=[],a=e.front+gt,i=e.back+gt;for(let l=0;l<e.pts.length;l++){let c=e.pts[l],f=e.nrm[l];r.push([c.x-f[0]*a,c.y-f[1]*a]),o.push([c.x+f[0]*i,c.y+f[1]*i])}let s=[...r,...o.reverse()];s.length<3||(s.push(s[0]),n.push([s]))}if(!n.length)return[];try{let e=Dn.union(n[0],...n.slice(1)),r=[];for(let o of e){if(!o.length||o[0].length<4)continue;let a=o[0].map(([l,c])=>({x:l,y:c})),i=a[0],s=a[a.length-1];a.length>1&&Math.abs(i.x-s.x)<1e-9&&Math.abs(i.y-s.y)<1e-9&&a.pop(),a.length>=3&&r.push(Yn(a,Un))}return r}catch{return[]}}function Hn(t){let n=[];for(let e of t){let r=n[n.length-1];r&&Math.hypot(e.x-r.x,e.y-r.y)<1e-9||n.push(e)}for(;n.length>2&&Math.hypot(n[0].x-n[n.length-1].x,n[0].y-n[n.length-1].y)<1e-9;)n.pop();return n}var sn=class{constructor(n){this.minX=1/0;this.minY=1/0;this.maxX=-1/0;this.maxY=-1/0;this.rings=n;for(let e of n)for(let r of e)r.x<this.minX&&(this.minX=r.x),r.y<this.minY&&(this.minY=r.y),r.x>this.maxX&&(this.maxX=r.x),r.y>this.maxY&&(this.maxY=r.y)}containsAll(n){for(let e of n)if(e.x<this.minX||e.x>this.maxX||e.y<this.minY||e.y>this.maxY)return!1;for(let e of this.rings){let r=!0;for(let o of n)if(!It(e,o.x,o.y)){r=!1;break}if(r)return!0}return!1}};function Gn(t,n,e,r,o,a){if(r.length<3)return;if(e.containsAll(r)){let c=[0,1,0],f=r[0];for(let m=1;m+1<r.length;m++){let u=r[m],h=r[m+1];t.tri([f.x*g,o,f.y*g],[u.x*g,o,u.y*g],[h.x*g,o,h.y*g],c,a)}return}let i=r.map(c=>[c.x,c.y]);i.push(i[0]);let s;try{s=Dn.intersection([i],n)}catch{return}let l=[0,1,0];for(let c of s){if(!c.length||c[0].length<4)continue;let f=c[0],m=[],u=[];for(let b=0;b<f.length-1;b++)m.push(f[b][0],f[b][1]),u.push([f[b][0],f[b][1]]);if(u.length<3)continue;let h=oo(m,void 0,2);for(let b=0;b<h.length;b+=3){let p=u[h[b]],d=u[h[b+1]],y=u[h[b+2]];t.tri([p[0]*g,o,p[1]*g],[d[0]*g,o,d[1]*g],[y[0]*g,o,y[1]*g],l,a)}}}function Vn(t,n,e,r,o,a,i){if(n.length<2)return;let s=i??Wt(n),l=[0,1,0],c=a&&a.length>=3?[[...a.map(h=>[h.x,h.y]),[a[0].x,a[0].y]]]:null,f=a&&a.length>=3?new sn([[...a]]):null,m=h=>{t.setMaterial(2),h(),t.setMaterial(0)},u=h=>{t.setMaterial(3),h(),t.setMaterial(0)};for(let h=0;h<n.length;h++){let b=n[h];if(b.patch&&b.patch.length>=3){let E=[...b.patch],M=s[h].belowY??r;if(u(()=>{if(c&&f)Gn(t,c,f,E,b.y,o.tread);else{let I=E[0];for(let B=1;B+1<E.length;B++){let k=E[B],D=E[B+1];t.tri([I.x*g,b.y,I.y*g],[k.x*g,b.y,k.y*g],[D.x*g,b.y,D.y*g],l,o.tread)}}}),b.y>M+On){let I=0,B=0;for(let k of E)I+=k.x,B+=k.y;I/=E.length,B/=E.length,m(()=>{for(let k=0;k<E.length;k++){let D=E[k],U=E[(k+1)%E.length],S=U.x-D.x,_=U.y-D.y,N=Math.hypot(S,_);if(N<1e-6)continue;let O=_/N,P=-S/N;(D.x-I)*O+(D.y-B)*P<0&&(O=-O,P=-P);let F=[O,0,P],R=[D.x*g,b.y,D.y*g],T=[U.x*g,b.y,U.y*g],C=[D.x*g,M,D.y*g],v=[U.x*g,M,U.y*g];t.tri(R,T,v,F,o.riser),t.tri(R,v,C,F,o.riser)}})}continue}let p=Xn(n,h,s,e);if(!p)continue;let{pts:d,nrm:y,front:x,back:w}=p,A=s[h].belowY??r;for(let E=0;E+1<d.length;E++){let M=d[E],I=d[E+1],B=y[E],k=y[E+1];if(Math.hypot(I.x-M.x,I.y-M.y)<1e-6||B[0]===0&&B[1]===0||k[0]===0&&k[1]===0)continue;let D=[(M.x-B[0]*x)*g,b.y,(M.y-B[1]*x)*g],U=[(I.x-k[0]*x)*g,b.y,(I.y-k[1]*x)*g],S=[(M.x+B[0]*w)*g,b.y,(M.y+B[1]*w)*g],_=[(I.x+k[0]*w)*g,b.y,(I.y+k[1]*w)*g];if(u(()=>{c&&f?Gn(t,c,f,[{x:M.x-B[0]*x,y:M.y-B[1]*x},{x:I.x-k[0]*x,y:I.y-k[1]*x},{x:I.x+k[0]*w,y:I.y+k[1]*w},{x:M.x+B[0]*w,y:M.y+B[1]*w}],b.y,o.tread):(t.tri(D,U,_,l,o.tread),t.tri(D,_,S,l,o.tread))}),b.y>A+On){let N=[D[0],A,D[2]],O=[U[0],A,U[2]],P=[-B[0],0,-B[1]];m(()=>{t.tri(D,U,O,P,o.riser),t.tri(D,O,N,P,o.riser)})}}}}function fo(t,n){let e=t.eventConfigurationIds;return!e?.length||!!n&&e.includes(n)}function Wn(t,n){return t.filter(e=>e.type!=="shape"||fo(e,n))}function Zn(t,n){let e=t.focalPoint??{x:0,y:0};return t.floors?.length?t.floors.map((r,o)=>({objects:Wn(r.objects,n),focal:{x:(r.focalPoint??e).x,y:(r.focalPoint??e).y},baseHeightM:r.baseHeightM??0,index:o})):[{objects:Wn(t.objects,n),focal:e,baseHeightM:0,index:0}]}var ho={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Mt(t){return Mn(t)??ho}function Kn(t,n){let e=jt(t.outline,ot),r=Mt(e),o=n.filter(i=>i!==t&&i.outline&&i.outline.length>=3&&Nt(r,Mt(i.outline)));if(!o.length)return[e];let a=i=>{let s=i.map(l=>[l.x,l.y]);return s.push(s[0]),s};try{let i=zn.difference([a(e)],...o.map(l=>[a(l.outline)])),s=[];for(let l of i){if(!l.length)continue;let c=l[0].map(([f,m])=>({x:f,y:m}));if(c.length>1){let f=c[0],m=c[c.length-1];Math.abs(f.x-m.x)<1e-9&&Math.abs(f.y-m.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s.length?s:[e]}catch{return[e]}}function $n(t,n){if(!n.length)return t;let e=a=>{let i=a.map(s=>[s.x,s.y]);return i.push(i[0]),i},r=n.map(a=>[e(a)]),o=[];for(let a of t){let i;try{i=zn.intersection([e(a.outline)],r.flat())}catch{o.push(a);continue}for(let s of i){if(!s.length)continue;let l=s[0].map(([c,f])=>({x:c,y:f}));if(l.length>1){let c=l[0],f=l[l.length-1];Math.abs(c.x-f.x)<1e-9&&Math.abs(c.y-f.y)<1e-9&&l.pop()}l.length>=3&&o.push({outline:l,holes:[],topY:a.topY})}}return o.length?o:t}function po(t,n){return t===void 0||n===void 0?!0:Math.abs(t-n)<.001}var zt=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(n,e){let r=n.map(l=>[l.x,l.y]);if(r.length<3)return[];r.push(r[0]);let o=Mt(n),a=this.rings.filter((l,c)=>Nt(o,this.boxes[c])&&po(e,this.levels[c])),i=[[r]];if(a.length)try{i=bo.difference([r],...a).map(c=>c.map(f=>f.map(([m,u])=>[m,u])))}catch{i=[[r]]}this.rings.push([r]),this.boxes.push(o),this.levels.push(e);let s=[];for(let l of i){if(!l.length)continue;let c=l[0].map(([f,m])=>({x:f,y:m}));if(c.length>1){let f=c[0],m=c[c.length-1];Math.abs(f.x-m.x)<1e-9&&Math.abs(f.y-m.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s}};function yo(t,n){if(!n)return t;let e=1/0,r=-1/0,o=1/0,a=-1/0;for(let m of t)e=Math.min(e,m.x),r=Math.max(r,m.x),o=Math.min(o,m.y),a=Math.max(a,m.y);let i=(e+r)/2,s=(o+a)/2,l=n*Math.PI/180,c=Math.cos(l),f=Math.sin(l);return t.map(m=>{let u=m.x-i,h=m.y-s;return{x:i+u*c-h*f,y:s+u*f+h*c}})}function bt(t){let n=null;if(t.kind==="polygon"&&t.points&&t.points.length>=3&&(n=t.points),t.kind==="rect"&&t.width&&t.height&&(n=Tt(t.x??0,t.y??0,t.width,t.height)),t.kind==="ellipse"&&t.width&&t.height){let e=(t.x??0)+t.width/2,r=(t.y??0)+t.height/2;n=Ht(e,r,t.width/2,t.height/2)}return n?yo(n,t.rotation):null}function Et(t){let n=t.role??"",e={stage:{kind:"stage",heightM:1},entrance:{kind:"portal",heightM:2.7},exit:{kind:"portal",heightM:2.7},screen:{kind:"solid",heightM:6},wall:{kind:"solid",heightM:2.8},rail:{kind:"solid",heightM:1.1},suite:{kind:"suite",heightM:3},obstruction:{kind:"solid",heightM:4.5},sound:{kind:"solid",heightM:1.45},restroom:{kind:"solid",heightM:2.4},bar:{kind:"solid",heightM:1.1},concession:{kind:"solid",heightM:1.1},coat:{kind:"solid",heightM:1.1},goal:{kind:"portal",heightM:1.8}},r=n==="stage"&&xn(t.stageKind)?{kind:"stage",heightM:.06}:e[n]??{kind:"plate",heightM:.25};return{...r,heightM:t.heightM??r.heightM}}var xo=.08;function qn(t,n){let e=bt(t),r=Et(t),o=r.heightM;if(!e||r.kind!=="plate"&&r.kind!=="stage")return o;let a=1/0,i=1/0,s=-1/0,l=-1/0;for(let f of e)a=Math.min(a,f.x),i=Math.min(i,f.y),s=Math.max(s,f.x),l=Math.max(l,f.y);let c=o;for(let f of n)s>f.minX&&a<f.maxX&&l>f.minY&&i<f.maxY&&c<=f.topOffsetM+1e-6&&(c=f.topOffsetM+xo);return n.push({minX:a,minY:i,maxX:s,maxY:l,topOffsetM:c}),c}function mt(t,n,e){return{x:t.x+(n.x-t.x)*e,y:t.y+(n.y-t.y)*e}}function Jn(t){if(t.length!==4)return t;let n=Math.hypot(t[1].x-t[0].x,t[1].y-t[0].y),e=Math.hypot(t[2].x-t[1].x,t[2].y-t[1].y);return n>=e?t:[t[1],t[2],t[3],t[0]]}function Ct(t,n,e){return[mt(t[0],t[1],n),mt(t[0],t[1],e),mt(t[3],t[2],e),mt(t[3],t[2],n)]}function Qn(t,n,e){return[mt(t[0],t[3],n),mt(t[1],t[2],n),mt(t[1],t[2],e),mt(t[0],t[3],e)]}function at(t,n,e,r,o,a){K(t,n,void 0,()=>e,r,o,a,W)}var an=2.4,go=.75,Mo=.15;function Ft(t){if(t.points&&t.points.length>=3)return t.points;let{center:n,width:e,height:r,rotation:o}=t;if(!e||!r)return null;let a=(o??0)*Math.PI/180,i=Math.cos(a),s=Math.sin(a),l=e/2,c=r/2;return[[-l,-c],[l,-c],[l,c],[-l,c]].map(([f,m])=>({x:n.x+f*i-m*s,y:n.y+f*s+m*i}))}function te(t,n,e,r,o){let a=Ft(n);a&&K(t,a,void 0,()=>e+an,e,st(r,o.boothTop),o.boothWall,W)}function cn(t){if(t.shape==="round"){let f=t.radius;return f?Ht(t.center.x,t.center.y,f,f,24):null}let{width:n,height:e,rotation:r,center:o}=t;if(!n||!e)return null;let a=(r??0)*Math.PI/180,i=Math.cos(a),s=Math.sin(a),l=n/2,c=e/2;return[[-l,-c],[l,-c],[l,c],[-l,c]].map(([f,m])=>({x:o.x+f*i-m*s,y:o.y+f*s+m*i}))}function ne(t,n,e,r,o){let a=cn(n);a&&K(t,a,void 0,()=>e+go,e,st(r,o.tableTop),o.tableWall,W)}function ee(t,n,e,r,o,a,i,s){let l=bt(n);if(!l)return;let c=s?s.kind==="stage":n.role==="stage",f=s?s.kind==="screen":n.role==="screen",m=s?{kind:c?"stage":"solid",heightM:s.topY-s.baseY}:Et(n),u=s?.baseY??e,h=s?.topY??e+r;if(c&&i){let x=1/0,w=-1/0,A=1/0,E=-1/0;for(let M of l)M.x<x&&(x=M.x),M.x>w&&(w=M.x),M.y<A&&(A=M.y),M.y>E&&(E=M.y);i.push({cx:(x+w)/2*g,cz:(A+E)/2*g,y:h,halfX:Math.max((w-x)/2*g,.5),halfZ:Math.max((E-A)/2*g,.5)})}let b=H(n.fill),p=c&&b?nt(o.stageTop,et(Pt(b,.18),.9),.9):st(b,c?o.stageTop:o.decorTop),d=f?b:null,y=c?b?nt(o.stageWall,et(b,.58),.82):o.stageWall:f?d?nt(et(d,1.42),[.24,.46,.82],.08):[.24,.46,.82]:st(H(n.fill),o.decorWall);if(m.kind==="portal"&&l.length===4){let x=Jn(l);at(t,Ct(x,0,.16),h,u,p,y),at(t,Ct(x,.84,1),h,u,p,y),at(t,x,h,Math.max(u,h-.35),p,y);return}if(m.kind==="suite"&&l.length===4){let x=l.map((E,M)=>{let I=l[(M+1)%4],B=(E.x+I.x)/2,k=(E.y+I.y)/2;return Math.hypot(B-a.x,k-a.y)}),w=x.indexOf(Math.min(...x)),A=[0,1,2,3].map(E=>l[(w+E)%4]);at(t,Ct(A,0,.08),h,u,p,y),at(t,Ct(A,.92,1),h,u,p,y),at(t,Qn(A,.88,1),h,u,p,y),at(t,A,h,Math.max(u,h-.18),p,y);return}at(t,l,h,u,p,y)}function un(t){let{x:n,y:e,width:r,height:o}=t;if(!r||!o)return null;let a=n+r/2,i=e+o/2,s=(t.rotation??0)*Math.PI/180,l=Math.cos(s),c=Math.sin(s),f=r/2,m=o/2;return[[-f,-m],[f,-m],[f,m],[-f,m]].map(([u,h])=>({x:a+u*l-h*c,y:i+u*c+h*l}))}function So(t){if(!t||!t.startsWith("data:image/svg+xml"))return null;let n=t.slice(t.indexOf(",")+1);if(/;base64/i.test(t.slice(0,t.indexOf(","))))try{n=atob(n)}catch{return null}else try{n=decodeURIComponent(n)}catch{}let e=n.match(/<(?:rect|path)\b[^>]*\bfill="([^"]+)"/i);if(!e)return null;let r=e[1].trim();if(r==="none"||r==="transparent")return null;let o=r.match(/^url\(#([^)]+)\)$/);if(!o)return H(r);let a=n.match(new RegExp(`<(?:linear|radial)Gradient\\b[^>]*\\bid="${o[1]}"[^>]*>([\\s\\S]*?)</(?:linear|radial)Gradient>`,"i"));if(!a)return null;let i=[];for(let s of a[1].matchAll(/stop-color="([^"]+)"/gi)){let l=H(s[1].trim());l&&i.push(l)}return i.length?i.reduce((s,l,c)=>nt(s,l,1/(c+1)),i[0]):null}function oe(t,n,e,r){if(n.layer==="foreground")return;let o=un(n);if(!o)return;let a=e+Mo,i=st(So(n.href),r.decorTop),s=Math.max(0,Math.min(1,n.opacity??1));s<1&&(i=nt(r.ground,i,s)),K(t,o,void 0,()=>a,e,i,nt(i,r.decorWall,.5),W)}function re(t,n,e,r,o){if(!n.points||n.points.length<3)return;let a=st(r,o.gaTop);K(t,n.points,n.holes,()=>e+.15,e,a,o.gaWall,W)}var Ro=6,Ao=2.2,ie=.1,Po=.3,Io=1.8,wo=.9,_o=.55,To=6e3;function se(t){let{doc:n,units:e,seats:r,surfaces:o,focal:a}=t,i=n.zones??[],s=[];if(i.length){let l=new Map;for(let f of e)for(let m of f.objects)m.type==="section"&&m.zone&&l.set(m.id,m.zone);let c=new Map;for(let f=0;f<r.length;f++){let m=r[f],u=o.seatOwner[f],h=m.zoneId??(u?l.get(u):void 0);if(!h)continue;let b=c.get(h);b||(b={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},c.set(h,b)),b.n++,m.x<b.minX&&(b.minX=m.x),m.y<b.minY&&(b.minY=m.y),m.x>b.maxX&&(b.maxX=m.x),m.y>b.maxY&&(b.maxY=m.y),b.sumY+=o.seatDeckY(f)}for(let f of i){let m=c.get(f.id),u=[];for(let[h,b]of l)b===f.id&&u.push(h);if(!m||m.n===0){s.push({id:f.id,label:f.label,color:H(f.color),sectionIds:u,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(f.focalPoint??a).x*g,1.5,(f.focalPoint??a).y*g]});continue}s.push({id:f.id,label:f.label,color:H(f.color),sectionIds:u,seatCount:m.n,center:[(m.minX+m.maxX)/2*g,m.sumY/m.n,(m.minY+m.maxY)/2*g],radius:.5*Math.hypot((m.maxX-m.minX)*g,(m.maxY-m.minY)*g)||1,focalWorld:[(f.focalPoint??a).x*g,1.5,(f.focalPoint??a).y*g]})}}return s}function ae(t){let{doc:n,units:e,seats:r,surfaces:o,seatData:a,hintedSeatFloor:i,zones:s,focal:l}=t,c=[],f=[],m=[];for(let u of s)u.seatCount!==0&&c.push({id:`zone:${u.id}`,kind:"zone",text:u.label,anchor:[u.center[0],u.center[1]+Ro,u.center[2]],color:n.zones?.find(h=>h.id===u.id)?.color});{let u=new Map,h=new Map;for(let b=0;b<r.length;b++){let p=o.seatOwner[b];if(!p)continue;let d=u.get(p);d||(d={n:0,x:0,y:0,deck:0},u.set(p,d)),d.n++,d.x+=r[b].x,d.y+=r[b].y,d.deck+=o.seatDeckY(b);let y=h.get(p);y||(y={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0},h.set(p,y)),r[b].x<y.minX&&(y.minX=r[b].x),r[b].x>y.maxX&&(y.maxX=r[b].x),r[b].y<y.minY&&(y.minY=r[b].y),r[b].y>y.maxY&&(y.maxY=r[b].y)}for(let b of e)for(let p of b.objects){if(p.type!=="section")continue;let d=u.get(p.id);if(!d||d.n===0)continue;let y=h.get(p.id),x=[d.x/d.n*g,d.deck/d.n,d.y/d.n*g],w=p.displayLabel||p.label||p.id;f.push({id:p.id,floorIndex:b.index,label:w,seatCount:d.n,center:x,radius:Math.max(1,Math.hypot(y.maxX-y.minX,y.maxY-y.minY)*.5*g),focalWorld:[b.focal.x*g,b.baseHeightM+1.5,b.focal.y*g]});let A=n.floors?.[b.index]?.name?.trim().toLocaleLowerCase();e.length>1&&A===w.trim().toLocaleLowerCase()||c.push({id:`section:${p.id}`,kind:"section",text:w,anchor:[x[0],x[1]+Ao,x[2]],floorIndex:b.index})}}{for(let p of e)for(let d of p.objects){if(d.type!=="gaArea")continue;let y=At(d.points);if(!y)continue;let x=d.displayLabel||d.label||d.id;c.push({id:`ga:${d.id}`,kind:"ga",text:d.capacity>0?`${x} \xB7 ${d.capacity.toLocaleString()}`:x,anchor:[y.x*g,p.baseHeightM+Io,y.y*g],floorIndex:p.index})}let u=new Map;for(let p of e)for(let d of p.objects)d.type==="section"&&u.set(d.id,d.displayLabel||d.label||d.id);let h=new Map;for(let p=0;p<r.length;p++){let d=r[p],y=Math.hypot(d.x-l.x,d.y-l.y),x=h.get(d.rowId);(!x||y>x.far)&&h.set(d.rowId,{seat:d,index:p,far:y})}for(let[p,d]of h){let y=Eo(d.seat.label,p,u.get(d.seat.sectionId??""));y&&c.push({id:`row:${p}`,kind:"row",text:y,anchor:[d.seat.x*g,o.seatDeckY(d.index)+wo,d.seat.y*g],floorIndex:i[d.index]})}let b=new Map;for(let p=0;p<r.length;p++){let d=r[p],y=d.label?d.label.lastIndexOf("-"):-1,x=b.get(d.rowId);x||(x={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:y>0?d.label.slice(0,y):d.rowId,sectionId:d.sectionId},b.set(d.rowId,x));let w=p*3,A=a.iPosition[w],E=a.iPosition[w+1],M=a.iPosition[w+2];x.n++,x.x+=A,x.y+=E,x.z+=M,x.minX=Math.min(x.minX,A),x.maxX=Math.max(x.maxX,A),x.minZ=Math.min(x.minZ,M),x.maxZ=Math.max(x.maxZ,M)}for(let[p,d]of b)m.push({id:p,label:d.label,sectionId:d.sectionId,seatCount:d.n,center:[d.x/d.n,d.y/d.n,d.z/d.n],radius:Math.max(.8,Math.hypot(d.maxX-d.minX,d.maxZ-d.minZ)*.5)});if(r.length<=To)for(let p=0;p<r.length;p++){let d=r[p],y=Bo(d.displayLabel||d.label);y&&c.push({id:`seat:${d.id}`,kind:"seat",text:y,anchor:[d.x*g,o.seatDeckY(p)+_o,d.y*g],floorIndex:i[p]})}}for(let u of e)for(let h of u.objects)if(h.type==="shape"&&h.role&&["entrance","exit","screen","suite","obstruction"].includes(h.role)){let b=bt(h),p=b?At(b):null;if(!p||!h.label)continue;c.push({id:`architecture:${h.id}`,kind:"annotation",text:h.label,anchor:[p.x*g,u.baseHeightM+Et(h).heightM+ie,p.y*g],color:h.fill,floorIndex:u.index})}else if(h.type==="text"){if(!h.text)continue;c.push({id:`text:${h.id}`,kind:"annotation",text:h.text,anchor:[h.position.x*g,u.baseHeightM+ie,h.position.y*g],color:h.color,rotation:h.rotation,floorIndex:u.index})}else if(h.type==="booth"){let b=Ft(h);if(!b)continue;let p=At(b);if(!p)continue;c.push({id:`booth:${h.id}`,kind:"booth",text:h.displayLabel||h.label||h.id,anchor:[p.x*g,u.baseHeightM+an+Po,p.y*g],floorIndex:u.index})}return{labels:c,sections:f,rows:m}}function ce(t,n){if(n.length>1)for(let e of n)t.push({id:`floor:${e.id}`,kind:"floor",text:e.label,anchor:[e.center[0],e.box.max[1]+1.2,e.center[2]],floorIndex:e.index})}function Bo(t){let n=t.lastIndexOf("-");return n>=0&&n<t.length-1?t.slice(n+1):t}function Eo(t,n,e){let r=t?t.lastIndexOf("-"):-1,o=r>0?t.slice(0,r):n;return o&&gn(o,e)}var Co=.15,Fo=.9,vo=1.76;function ko(){return{background:{top:[...nn.top],bottom:[...nn.bottom]},structure:tn,seatStates:{...Bn},seatScale:1,materials:{seat:null,shell:null,roughness:.78}}}function ue(t){let n=ko();if(!t)return n;let e=H(t.background);if(e){n.background={top:et(e,Fo),bottom:et(e,vo)};let i={};for(let[s,l]of Object.entries(tn))i[s]=nt(l,e,Co);n.structure=i}let r=H(t.selectionColor)??H(t.accent);r&&(n.seatStates={...n.seatStates,selected:r});let o=t.seatScale;typeof o=="number"&&Number.isFinite(o)&&(n.seatScale=An(o));let a=t.venue3d;if(a){let i=H(a.deck),s=H(a.fascia);i&&(n.structure={...n.structure,tierTop:i,gaTop:i}),s&&(n.structure={...n.structure,tierWall:s,gaWall:s}),n.materials.seat=H(a.seat),n.materials.shell=H(a.shell),typeof a.roughness=="number"&&Number.isFinite(a.roughness)&&(n.materials.roughness=Math.min(1,Math.max(0,a.roughness)))}return n}function le(t,n){let e=[];for(let r of n)e.push(...t.seatStates[r]);return e}var Oo=.05,me=.05,Lo=.15,ln=25;function fe(t,n,e){let r=new Map,o=new Array(n.length).fill(null),a=new Float64Array(n.length),i=new Array(n.length).fill(void 0),s=new Array(n.length).fill(void 0),l=new Map,c=[],f=new Set;for(let u=0;u<t.length;u+=1){let h=t[u];for(let b of h.objects){if(b.type==="table"&&f.add(b.id),b.type!=="section"||!b.outline||b.outline.length<3)continue;let p=jt(b.outline,ot);l.set(b.id,{section:b,unit:h,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),c.push({id:b.id,floorIndex:u,box:Mt(p),section:b,unit:h,outline:p})}}let m=new Map;for(let u of c){let h=m.get(u.floorIndex);h?h.push(u):m.set(u.floorIndex,[u])}for(let u=0;u<n.length;u++){let h=n[u],b=e?m.get(e[u])??[]:c,p=h.sectionId?b.find(y=>y.id===h.sectionId)??b.find(y=>y.section.logicalSectionId===h.sectionId&&qt({x:h.x,y:h.y},y.outline,y.section.holes)):void 0,d=p?[p]:b;for(let y of d){if(e&&y.floorIndex!==e[u]||!p&&(h.x<y.box.minX||h.x>y.box.maxX||h.y<y.box.minY||h.y>y.box.maxY||!qt({x:h.x,y:h.y},y.outline,y.section.holes)))continue;o[u]=y.id;let x=l.get(y.id);x.hasSeats=!0;let w=h.focalPoint??y.unit.focal,A=Math.hypot(h.x-w.x,h.y-w.y);A<x.frontU&&(x.frontU=A),x.seatIndices.push(u);let E=h.rowId||`__seat-${u}`,M=x.rows.get(E);M?M.push({x:h.x,y:h.y}):x.rows.set(E,[{x:h.x,y:h.y}]);break}}for(let[u,h]of l){let b=dn(h.section,{floorBaseHeightM:h.unit.baseHeightM}),p=h.unit.baseHeightM,d=b.rake>0?Math.tan(b.rake*Math.PI/180):0,y=b.rake<=.01&&b.height<=p+.001,x=h.section.surfaceKind,w=x==="flat"?!0:x==="rakedRows"&&b.rake>.01?!1:y,A=h.hasSeats?yn(u,n,h.seatIndices,h.unit.focal):{sectionId:u,rows:[],blockCount:0},M=A.rows.length<2?Pn([...h.rows.values()].map(R=>({points:R})),h.unit.focal):null,I=1/0;if(M){if(h.hasSeats)for(let R of h.rows.values())for(let T of R){let C=M.depthAt(T.x,T.y);C<I&&(I=C)}if(!h.hasSeats||!Number.isFinite(I)){I=1/0;for(let R of h.section.outline){let T=M.depthAt(R.x,R.y);T<I&&(I=T)}}}let B=p+Oo,k=Math.max(B,b.height),D=R=>{let T=Math.max(0,R-I)*ut,C=Math.min(T*d,ln);return Math.max(B,b.height+C)},U=R=>{let T=Math.max(0,R)*ut,C=Math.min(T*d,ln);return Math.max(B,b.height+C)},S=w?[]:A.rows.map(R=>({pts:R.pts,y:U(R.blockDepth),depth:R.blockDepth,blockId:R.blockId,...f.has(R.id)?{patch:Nn(R.pts,ot)}:{}})),_=S.length?S[0].y:k,N=S.map(R=>{let T=R.patch&&R.patch.length>=3?R.patch:R.pts,C=0,v=0;for(let L of T)C+=L.x,v+=L.y;let G=T.length||1;C/=G,v/=G;let X=0;for(let L of T){let Y=Math.hypot(L.x-C,L.y-v);Y>X&&(X=Y)}return{cx:C,cy:v,rad:X}}),O=w?()=>k:S.length>=2?(R,T)=>{let C=1/0,v=_;for(let G=0;G<S.length;G++){let X=N[G];if(Math.hypot(R-X.cx,T-X.cy)-X.rad>=C)continue;let L=S[G].patch,Y=L&&L.length>=3?It(L,R,T)?0:Dt(L,R,T):Dt(S[G].pts,R,T);Y<C&&(C=Y,v=S[G].y)}return v}:(R,T)=>M?D(M.depthAt(R,T)):k,P=[0,1,0],F=S.length>=2||w?()=>P:(R,T)=>{if(!M)return P;let C=M.depthAt(R,T);if(C<=I)return P;let v=(C-I)*ut;if(v*d>=ln||b.height+v*d<=B)return P;let[G,X]=M.gradientAt(R,T);if(G===0&&X===0)return P;let L=1/Math.hypot(d,1);return[-G*d*L,L,-X*d*L]};if(!w)for(let R of A.rows){let T=U(R.blockDepth);for(let C of R.seatIndices)i[C]=T}for(let R of A.rows){let T=[];for(let L=1;L<R.pts.length;L++){let Y=Math.hypot(R.pts[L].x-R.pts[L-1].x,R.pts[L].y-R.pts[L-1].y);Y>1e-6&&T.push(Y)}T.sort((L,Y)=>L-Y);let C=T.length?T[Math.floor(T.length/2)]:1/0,v=1/0,G=R.pts[Math.floor(R.pts.length/2)];if(G)for(let L of A.rows){if(L===R||L.blockId!==R.blockId)continue;let Y=Dt(L.pts,G.x,G.y);Y>1e-6&&Y<v&&(v=Y)}let X=Math.min(C,Math.max(v,C*.5));if(Number.isFinite(X)&&X>0)for(let L of R.seatIndices)s[L]=X}r.set(u,{sectionId:u,deckAt:O,normalAt:F,flat:w,bottomY:p,rowLevels:S,landingY:_})}for(let u=0;u<n.length;u++){let h=o[u],b=n[u];if(h){let d=i[u];a[u]=(d??r.get(h).deckAt(b.x,b.y))+Lo;continue}let p=b.eyeHeightM;a[u]=Number.isFinite(p)?Math.max(0,p-Gt):0}return{bySection:r,seatOwner:o,seatDeckY:u=>a[u],seatPitchU:u=>s[u]}}var Go=.25,Do=1.2,No=.6,Xo=.45,Uo=2.3,Yo=Math.PI/180;function pt(t,n,e){let r=e*Yo;return{x:t.x+n*Math.sin(r),y:t.y+n*Math.cos(r)}}function jo(t,n){let e=n.rings[n.rings.length-1];if(!e)return!1;let r=e.outerRMedian*.85;for(let o of t){if(o.role!=="wall")continue;let a=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(a.length<2)continue;let i=0;for(let s of a)Math.hypot(s.x-n.centre.x,s.y-n.centre.y)>=r&&i++;if(i>=a.length/2)return!0}return!1}var Ho=24;function Vo(t,n,e,r,o,a,i,s){let l=e.binCount,c=Ho,f=ut,m=a+.02,u=[];for(let S=0;S<l;S++){let _=(e.startBin+S+.5)*n.binStepDeg,N=new Float64Array(c+1);for(let O=0;O<=c;O++){let P=r[S]+(o[S]-r[S])*O/c;N[O]=Math.max(m,wn(n,e,_,P)-Go)}u.push(N)}let h=[i.bandTop[0]*s.top,i.bandTop[1]*s.top,i.bandTop[2]*s.top],b=[i.bandTop[0]*s.bottomCap,i.bandTop[1]*s.bottomCap,i.bandTop[2]*s.bottomCap],p=[i.bandWall[0]*s.top,i.bandWall[1]*s.top,i.bandWall[2]*s.top],d=[i.bandWall[0]*s.wallBottom,i.bandWall[1]*s.wallBottom,i.bandWall[2]*s.wallBottom],y=(S,_)=>{let N=(e.startBin+S+.5)*n.binStepDeg,O=r[S]+(o[S]-r[S])*_/c,P=pt(n.centre,O,N);return[P.x*f,u[S][_],P.y*f]};{let S=Math.tan(12*Math.PI/180);for(let _=0;_<6;_++){let N=!1;for(let P=0;P<l;P++)for(let F=c-1;F>=0;F--)u[P][F]>u[P][F+1]&&(u[P][F]=u[P][F+1],N=!0);let O=e.closed?l:l-1;for(let P=0;P<O;P++){let F=(P+1)%l;for(let R=0;R<=c;R++){let T=u[F][R]-u[P][R];if(Math.abs(T)>1)continue;let C=r[P]+(o[P]-r[P])*R/c,v=r[F]+(o[F]-r[F])*R/c,G=pt(n.centre,C,(e.startBin+P+.5)*n.binStepDeg),X=pt(n.centre,v,(e.startBin+F+.5)*n.binStepDeg),L=S*Math.hypot(X.x-G.x,X.y-G.y)*f;T>L?(u[F][R]=u[P][R]+L,N=!0):-T>L&&(u[P][R]=u[F][R]+L,N=!0)}}if(!N)break}}let x=1,w=(S,_)=>{for(let N=0;N<=c;N+=4)if(Math.abs(u[S][N]-u[_][N])>x)return!0;return Math.abs(u[S][c]-u[_][c])>x},A=Math.tan(38*Math.PI/180),E=S=>(o[S]-r[S])/c*f,M=(S,_)=>u[S][_+1]-u[S][_]>A*Math.max(1e-6,E(S)),I=(S,_)=>{let N=e.closed?(S-1+l)%l:Math.max(0,S-1),O=e.closed?(S+1)%l:Math.min(l-1,S+1);Math.abs(u[N][_]-u[S][_])>x&&(N=S),Math.abs(u[O][_]-u[S][_])>x&&(O=S);let P=Math.max(0,_-1),F=Math.min(c,_+1);P<_&&M(S,P)&&(P=_),F>_&&M(S,_)&&(F=_);let R=y(N,_),T=y(O,_),C=y(S,P),v=y(S,F),G=T[0]-R[0],X=T[1]-R[1],L=T[2]-R[2],Y=v[0]-C[0],j=v[1]-C[1],$=v[2]-C[2],z=X*$-L*j,q=L*Y-G*$,tt=G*j-X*Y,Z=Math.hypot(z,q,tt);return Z>1e-12?(z/=Z,q/=Z,tt/=Z,q<0&&(z=-z,q=-q,tt=-tt),[z,q,tt]):[0,1,0]},B=(S,_)=>{let N=[S[0],a,S[2]],O=[_[0],a,_[2]],P=_[0]-S[0],F=_[2]-S[2],R=Math.hypot(P,F);if(!(R>1e-12))return;let T=[F/R,0,-P/R];t.tri(S,_,O,T,p,p,d),t.tri(S,O,N,T,p,d,d)},k=.05*lt,D=S=>o[S]-r[S]<k,U=e.closed?l:l-1;for(let S=0;S<U;S++){let _=(S+1)%l;if(D(S)||D(_))continue;if(w(S,_)){let T=(e.startBin+S+1)*n.binStepDeg,C=(j,$)=>{let z=(r[S]+r[_])/2,q=(o[S]+o[_])/2,tt=z+(q-z)*$/c,Z=pt(n.centre,tt,T);return[Z.x*f,u[j][$],Z.y*f]};for(let j=0;j<c;j++){let $=y(S,j),z=y(S,j+1),q=C(S,j),tt=C(S,j+1),Z=I(S,j),it=I(S,j+1);t.triN($,q,tt,Z,Z,it,h),t.triN($,tt,z,Z,it,it,h);let vt=y(_,j),kt=y(_,j+1),dt=C(_,j),St=C(_,j+1),yt=I(_,j),xt=I(_,j+1);t.triN(dt,vt,kt,yt,yt,xt,h),t.triN(dt,kt,St,yt,xt,xt,h);let ct=C(S,j),rt=C(S,j+1),Ot=C(_,j+1),Kt=C(_,j),Lt=rt[0]-ct[0],Rt=rt[2]-ct[2],$t=Math.hypot(Lt,Rt);if($t>1e-12){let fn=[Rt/$t,0,-Lt/$t];t.tri(ct,rt,Ot,fn,p),t.tri(ct,Ot,Kt,fn,p)}}let v=y(S,0),G=y(_,0),X=y(_,c),L=y(S,c),Y=j=>[j[0],a,j[2]];t.tri(Y(v),Y(X),Y(G),[0,-1,0],b),t.tri(Y(v),Y(L),Y(X),[0,-1,0],b),B(v,G),B(L,X);continue}for(let T=0;T<c;T++){let C=I(S,T),v=I(_,T),G=I(_,T+1),X=I(S,T+1);if(M(S,T)||M(_,T)){let z=(rt,Ot)=>{let Kt=(e.startBin+rt+.5)*n.binStepDeg,Lt=r[rt]+(o[rt]-r[rt])*(T+.5)/c,Rt=pt(n.centre,Lt,Kt);return[Rt.x*f,Ot,Rt.y*f]},q=y(S,T),tt=y(_,T),Z=z(S,u[S][T]),it=z(_,u[_][T]);t.triN(q,tt,it,C,v,v,h),t.triN(q,it,Z,C,v,C,h);let vt=y(_,T+1),kt=y(S,T+1),dt=z(S,u[S][T+1]),St=z(_,u[_][T+1]);t.triN(dt,St,vt,X,G,G,h),t.triN(dt,vt,kt,X,G,X,h);let yt=it[0]-Z[0],xt=it[2]-Z[2],ct=Math.hypot(yt,xt);if(ct>1e-12){let rt=[-xt/ct,0,yt/ct];t.tri(Z,it,St,rt,p),t.tri(Z,St,dt,rt,p)}continue}let L=y(S,T),Y=y(_,T),j=y(_,T+1),$=y(S,T+1);t.triN(L,Y,j,C,v,G,h),t.triN(L,j,$,C,G,X,h)}let N=y(S,0),O=y(_,0),P=y(_,c),F=y(S,c),R=T=>[T[0],a,T[2]];t.tri(R(N),R(P),R(O),[0,-1,0],b),t.tri(R(N),R(F),R(P),[0,-1,0],b),B(N,O),B(F,P)}if(!e.closed)for(let S of[0,l-1])for(let _=0;_<c;_++)B(y(S,_),y(S,_+1))}function he(t,n,e){let{bottomY:r,colors:o,ao:a}=e,i=new Float64Array(n.binCount).fill(-1/0);for(let f of n.rings)for(let m of f.arcs){let u=new Float64Array(m.binCount),h=new Float64Array(m.binCount);for(let p=0;p<m.binCount;p++){let d=(m.startBin+p)%n.binCount,y=Math.max(0,m.innerR[p]-ot);u[p]=Math.max(y,i[d]+.001),h[p]=Math.max(u[p]+.001,m.outerR[p]+ot)}let b=0;for(let p=0;p<m.binCount;p++){let d=m.topLevelM[p]-r;d>b&&(b=d)}b>=Do&&Vo(t,n,m,u,h,r,o,a);for(let p=0;p<m.binCount;p++){let d=(m.startBin+p)%n.binCount;h[p]>i[d]&&(i[d]=h[p])}}if(e.deriveShell===!1||jo(e.shapes,n))return;let s=n.rings[n.rings.length-1],l=No*lt,c=Xo*lt;for(let f of s.arcs){let m=[],u=[];for(let p=0;p<f.binCount;p++){let d=(f.startBin+p+.5)*n.binStepDeg,y=f.outerR[p]+ot+l;m.push(pt(n.centre,y,d)),u.push(pt(n.centre,y+c,d))}let h=-1/0;for(let p=0;p<f.binCount;p++)f.topLevelM[p]>h&&(h=f.topLevelM[p]);let b=()=>h+Uo;f.closed?K(t,u,[m.slice().reverse()],b,r,o.shellTop,o.shellWall,a):K(t,[...u,...m.slice().reverse()],void 0,b,r,o.shellTop,o.shellWall,a)}}function be(t,n,e,r,o,a,i,s){if(!n.outline||n.outline.length<3)return;let l=e.baseHeightM,c=st(r,s.tierTop);if(!o)return;let f=d=>o.deckAt(d.x,d.y),m=Kn(n,i),u=m[0]??n.outline;if(o.rowLevels.length>=2){let d=Wt(o.rowLevels),y=$n(jn(o.rowLevels,e.focal,d),m),x=()=>[0,1,0];for(let A of y){let E=Math.max(l,A.topY-.02);for(let M of a.subtract(A.outline,E))K(t,M,A.holes,()=>E,l,c,s.tierWall,W,void 0,x)}y.length||K(t,u,n.holes,()=>o.landingY,l,c,s.tierWall,W);let w={tread:[c[0]*W.top,c[1]*W.top,c[2]*W.top],riser:[c[0]*.72,c[1]*.72,c[2]*.72]};for(let A of m.length?m:[u])Vn(t,o.rowLevels,e.focal,o.landingY,w,A,d);return}let h=o.flat?1/0:me,b=d=>o.normalAt(d.x,d.y),p=o.flat?o.landingY:void 0;for(let d of a.subtract(u,p))K(t,d,n.holes,f,l,c,s.tierWall,W,h,b)}function Wo(t,n,e){let r=new Set;for(let i of t.objects)i.type==="section"&&r.add(i.id);let o=new Map;for(let i=0;i<n.length;i++){let s=e.seatOwner[i];if(!s||!r.has(s))continue;let l=e.bySection.get(s);if(l&&l.rowLevels.length>=2)continue;let c=n[i],f=o.get(s);f||(f=new Map,o.set(s,f));let m=c.rowId||`__seat-${i}`,u=f.get(m);u||(u={pts:[],levelM:0,n:0},f.set(m,u)),u.pts.push({x:c.x,y:c.y}),u.levelM+=e.seatDeckY(i),u.n++}let a=[];for(let i of t.objects){if(i.type!=="section")continue;let s=e.bySection.get(i.id);if(s&&s.rowLevels.length>=2){let c=s.rowLevels.filter(f=>!f.patch).map(f=>({pts:f.pts,levelM:f.y}));c.length>=2&&a.push({sectionId:i.id,rows:c});continue}let l=o.get(i.id);l&&a.push({sectionId:i.id,rows:[...l.values()].map(c=>({pts:c.pts,levelM:c.levelM/c.n}))})}return a}function pe(t,n,e,r,o,a,i=!0){let s=Wo(n,e,r);if(!s.length)return;let l=In(s,n.focal);l&&(t.setMaterial(0),he(t,l,{bottomY:n.baseHeightM,colors:{bandTop:et(o.tierTop,.8),bandWall:o.tierWall,shellTop:a??et(o.tierWall,1.15),shellWall:a??o.tierWall},ao:W,shapes:n.objects.filter(c=>c.type==="shape"),deriveShell:i}))}function de(t){let{doc:n,units:e,seats:r,surfaces:o,solids:a,hintedSeatFloor:i,seatFloor:s}=t,l=[];{let c=e.map(()=>({minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}));for(let u=0;u<a.floor.length;u+=1){let h=Math.max(0,Math.min(e.length-1,Math.round(a.floor[u]))),b=u*3,p=c[h];p.minX=Math.min(p.minX,a.position[b]),p.minY=Math.min(p.minY,a.position[b+1]),p.minZ=Math.min(p.minZ,a.position[b+2]),p.maxX=Math.max(p.maxX,a.position[b]),p.maxY=Math.max(p.maxY,a.position[b+1]),p.maxZ=Math.max(p.maxZ,a.position[b+2])}let f=new Map;for(let u=0;u<e.length;u++)for(let h of e[u].objects)h.type==="section"&&f.set(h.id,u);let m=e.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 u=0;u<r.length;u++){let h=o.seatOwner[u],b=(h!==null?f.get(h):void 0)??i[u];if(b===void 0)continue;let p=m[b],d=r[u];p.n++,d.x<p.minX&&(p.minX=d.x),d.y<p.minY&&(p.minY=d.y),d.x>p.maxX&&(p.maxX=d.x),d.y>p.maxY&&(p.maxY=d.y);let y=o.seatDeckY(u);p.sumX+=d.x*g,p.sumDeck+=y,p.sumZ+=d.y*g,p.minDeck=Math.min(p.minDeck,y),p.maxDeck=Math.max(p.maxDeck,y+1.6),s[u]=b}for(let u=0;u<e.length;u++){let h=m[u],b=n.floors?.[u],p=c[u],d=Math.min(h.n?h.minX*g:e[u].focal.x*g-1,Number.isFinite(p.minX)?p.minX:1/0),y=Math.max(h.n?h.maxX*g:e[u].focal.x*g+1,Number.isFinite(p.maxX)?p.maxX:-1/0),x=Math.min(h.n?h.minY*g:e[u].focal.y*g-1,Number.isFinite(p.minZ)?p.minZ:1/0),w=Math.max(h.n?h.maxY*g:e[u].focal.y*g+1,Number.isFinite(p.maxZ)?p.maxZ:-1/0),A=Math.min(h.n?Math.min(e[u].baseHeightM,h.minDeck):e[u].baseHeightM,Number.isFinite(p.minY)?p.minY:1/0),E=Math.max(h.n?Math.max(h.maxDeck,A+.5):A+.5,Number.isFinite(p.maxY)?p.maxY:-1/0),M=[h.n?h.sumX/h.n:(d+y)/2,h.n?h.sumDeck/h.n:(A+E)/2,h.n?h.sumZ/h.n:(x+w)/2],I=Math.max(1,.5*Math.hypot(y-d,E-A,w-x));l.push({index:u,id:b?.id??`floor-${u}`,label:b?.name??(e.length>1?`Floor ${u+1}`:"Venue"),seatCount:h.n,center:M,radius:I,box:{min:[d,A,x],max:[y,E,w]},focalWorld:[e[u].focal.x*g,e[u].baseHeightM+1.5,e[u].focal.y*g]})}}return l}function mn(t,n){let e=1/0,r=1/0,o=-1/0,a=-1/0,i=(s,l)=>{s<e&&(e=s),l<r&&(r=l),s>o&&(o=s),l>a&&(a=l)};for(let s of n)i(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)i(c.x,c.y);else if(l.type==="shape"&&l.points)for(let c of l.points)i(c.x,c.y);else if(l.type==="gaArea")for(let c of l.points)i(c.x,c.y);else if(l.type==="booth"){let c=Ft(l);if(c)for(let f of c)i(f.x,f.y)}else if(l.type==="table"){let c=cn(l);if(c)for(let f of c)i(f.x,f.y)}else if(l.type==="decorImage"){let c=un(l);if(c)for(let f of c)i(f.x,f.y)}return Number.isFinite(e)||(e=-100,r=-100,o=100,a=100),{minX:e,minY:r,maxX:o,maxY:a}}function ye(t,n,e,r,o,a){if(n.length===1){let i=Math.max(60,(o.maxX-o.minX+o.maxY-o.minY)*.06),s=Tt(o.minX-i,o.minY-i,o.maxX-o.minX+i*2,o.maxY-o.minY+i*2);K(t,s,void 0,()=>0,-.4,a.ground,a.ground,W)}else{let i=n.reduce((h,b)=>b.baseHeightM<h.baseHeightM?b:h);t.setFloor(i.index);let s=e.filter((h,b)=>r[b]===i.index),l=mn([i],s),c=Math.hypot(l.maxX-l.minX,l.maxY-l.minY),f=Math.max(28,Math.min(80,c*.04)),m=Tt(l.minX-f,l.minY-f,l.maxX-l.minX+f*2,l.maxY-l.minY+f*2),u=i.baseHeightM-.03;K(t,m,void 0,()=>u,u-.22,a.ground,a.ground,W)}}function xe(t,n,e){let{cx:r,cz:o,radius:a}=e,i=1/0,s=1/0,l=1/0,c=-1/0,f=-1/0,m=-1/0,u=(p,d,y)=>{i=Math.min(i,p),c=Math.max(c,p),s=Math.min(s,d),f=Math.max(f,d),l=Math.min(l,y),m=Math.max(m,y)};for(let p=0;p<t.position.length;p+=3)u(t.position[p],t.position[p+1],t.position[p+2]);for(let p=0;p<n.count;p++){let d=p*3,y=n.iPosition[d],x=n.iPosition[d+1],w=n.iPosition[d+2],A=Math.max(.35,n.iMaxRadius[p]??.35);u(y-A,x,w-A),u(y+A,x+1.6,w+A)}Number.isFinite(i)||(i=r-a,c=r+a,s=0,f=a*.16,l=o-a,m=o+a);let h=[(i+c)/2,(s+f)/2,(l+m)/2],b=Math.max(1,.5*Math.hypot(c-i,f-s,m-l));return{center:h,radius:b,minY:s,maxY:f}}function ge(t,n,e,r,o,a){let i=1/0,s=1/0,l=-1/0,c=-1/0;for(let A=0;A<t.count;A++){let E=A*3,M=t.iPosition[E],I=t.iPosition[E+2];M<i&&(i=M),M>l&&(l=M),I<s&&(s=I),I>c&&(c=I)}for(let A of n)i=Math.min(i,A.cx-A.halfX),l=Math.max(l,A.cx+A.halfX),s=Math.min(s,A.cz-A.halfZ),c=Math.max(c,A.cz+A.halfZ);let f=e.minX*g,m=e.maxX*g,u=e.minY*g,h=e.maxY*g,b=f,p=m,d=u,y=h;if(Number.isFinite(i)){let A=Math.max(2,.06*Math.hypot(l-i,c-s));b=Math.max(f,i-A),p=Math.min(m,l+A),d=Math.max(u,s-A),y=Math.min(h,c+A)}let x=Math.min(0,r),w=Math.max(o,a*.05);return{min:[b,x,d],max:[p,w,y]}}function Me(t,n,e){let r=()=>({byObjectId:new Map,elements:[]});if(!n||!t)return r();let o=bn(n);if(!o.ok||o.value.id!==t)return r();let a=new Map;for(let m of e)for(let u of m.objects)u.type==="shape"&&a.set(u.id,{shape:u,unit:m});let i=new Set,s=new Set,l=new Map((n.overlay.productionElements??[]).map(m=>{let u=m.runtimeContentImageUrl;return[m.id,typeof u=="string"&&/^(?:blob:|data:image\/|https:\/\/)/.test(u)?u:void 0]})),c=[];for(let m of o.value.overlay.productionElements??[]){let u=a.get(m.objectId),h=u?bt(u.shape):null,b=m.baseElevationM??0;if(!u||!h||h.length<3||!m.id||i.has(m.id)||s.has(m.objectId)||!Number.isFinite(m.heightM)||m.heightM<.05||m.heightM>50||!Number.isFinite(b)||b<-10||b>100)return r();i.add(m.id),s.add(m.objectId);let p=h.map(B=>B.x*g),d=h.map(B=>B.y*g),y=u.unit.baseHeightM+b,x=Math.min(...p),w=Math.max(...p),A=Math.min(...d),E=Math.max(...d),M,I=l.get(m.id)??m.contentImageUrl;if(m.kind==="screen"&&I)if(w-x>=E-A){let B=Math.abs(A-u.unit.focal.y*g)<=Math.abs(E-u.unit.focal.y*g)?A-.006:E+.006;M=[[x,y,B],[w,y,B],[x,y+m.heightM,B],[w,y+m.heightM,B]]}else{let B=Math.abs(x-u.unit.focal.x*g)<=Math.abs(w-u.unit.focal.x*g)?x-.006:w+.006;M=[[B,y,A],[B,y,E],[B,y+m.heightM,A],[B,y+m.heightM,E]]}c.push({id:m.id,objectId:m.objectId,kind:m.kind,floorIndex:u.unit.index,baseY:y,topY:y+m.heightM,bounds:{min:[x,y,A],max:[w,y+m.heightM,E]},occlusion:m.occlusion,...I?{contentImageUrl:I}:{},...M?{contentPlane:M}:{}})}let f=c.sort((m,u)=>m.id.localeCompare(u.id));return{byObjectId:new Map(f.map(m=>[m.objectId,m])),elements:f}}function Q(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function J(t){return Array.isArray(t)?t:[]}function zo(t){let n=[t];for(;n.length;){let e=n.pop();if(Array.isArray(e)){n.push(...e);continue}if(!Q(e))continue;let r=Q(e.extensions)?e.extensions:null;if(r&&Object.prototype.hasOwnProperty.call(r,"KHR_draco_mesh_compression"))return!0;n.push(...Object.values(e))}return!1}function Zt(t,n){return!Array.isArray(t)||t.length!==n||!t.every(e=>typeof e=="number"&&Number.isFinite(e))?null:t}function Zo(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Ko(t,n){let e=new Array(16).fill(0);for(let r=0;r<4;r++)for(let o=0;o<4;o++)for(let a=0;a<4;a++)e[r*4+o]+=t[a*4+o]*n[r*4+a];return e}function $o(t){let n=Zt(t.matrix,16);if(n)return n;if(t.matrix!==void 0)return null;let e=t.translation===void 0?[0,0,0]:Zt(t.translation,3),r=t.rotation===void 0?[0,0,0,1]:Zt(t.rotation,4),o=t.scale===void 0?[1,1,1]:Zt(t.scale,3);if(!e||!r||!o)return null;let[a,i,s,l]=r,c=Math.hypot(a,i,s,l);if(!(c>1e-8))return null;let f=a/c,m=i/c,u=s/c,h=l/c,b=f+f,p=m+m,d=u+u,y=f*b,x=f*p,w=f*d,A=m*p,E=m*d,M=u*d,I=h*b,B=h*p,k=h*d;return[(1-(A+M))*o[0],(x+k)*o[0],(w-B)*o[0],0,(x-k)*o[1],(1-(y+M))*o[1],(E+I)*o[1],0,(w+B)*o[2],(E-I)*o[2],(1-(y+A))*o[2],0,e[0],e[1],e[2],1]}function qo(t,n,e,r){return[t[0]*n+t[4]*e+t[8]*r+t[12],t[1]*n+t[5]*e+t[9]*r+t[13],t[2]*n+t[6]*e+t[10]*r+t[14]]}function Jo(t){let n=t[0],e=t[4],r=t[8],o=t[1],a=t[5],i=t[9],s=t[2],l=t[6],c=t[10],f=a*c-i*l,m=i*s-o*c,u=o*l-a*s,h=n*f+e*m+r*u;if(Math.abs(h)<1e-12)return null;let b=1/h;return[f*b,m*b,u*b,(r*l-e*c)*b,(n*c-r*s)*b,(e*s-n*l)*b,(e*i-r*a)*b,(r*o-n*i)*b,(n*a-e*o)*b]}function Se(t,n,e,r){let o=t[0]*n+t[1]*e+t[2]*r,a=t[3]*n+t[4]*e+t[5]*r,i=t[6]*n+t[7]*e+t[8]*r,s=Math.hypot(o,a,i)||1;return o/=s,a/=s,i/=s,[o,a,i]}function Qo(t){if(t.byteLength<20||t.byteLength>8388608)return null;let n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0,!0)!==1179937895||n.getUint32(4,!0)!==2||n.getUint32(8,!0)!==t.byteLength)return null;let e=12,r=null,o=null;for(;e+8<=t.byteLength;){let a=n.getUint32(e,!0),i=n.getUint32(e+4,!0);if(e+=8,a%4!==0||e+a>t.byteLength)return null;let s=t.subarray(e,e+a);if(i===1313821514&&!r)try{let l=JSON.parse(new TextDecoder().decode(s).replace(/[\u0000 ]+$/g,""));if(!Q(l))return null;r=l}catch{return null}else if(i===5130562&&!o)o=s;else return null;e+=a}return e===t.byteLength&&r&&o?{json:r,bin:o}:null}function tr(t){return t===5120||t===5121?1:t===5122||t===5123?2:t===5125||t===5126?4:0}function nr(t){return t==="SCALAR"?1:t==="VEC2"?2:t==="VEC3"?3:t==="VEC4"?4:0}function er(t,n,e){return e===5120?t.getInt8(n):e===5121?t.getUint8(n):e===5122?t.getInt16(n,!0):e===5123?t.getUint16(n,!0):e===5125?t.getUint32(n,!0):t.getFloat32(n,!0)}function or(t){let n=t instanceof Uint8Array?t:new Uint8Array(t),e=Qo(n);if(!e)return{ok:!1,issue:"invalid_glb"};let{json:r,bin:o}=e;if(!Q(r.asset)||r.asset.version!=="2.0")return{ok:!1,issue:"unsupported_glb"};let a=J(r.extensionsUsed).filter(A=>typeof A=="string");if(a.includes("KHR_draco_mesh_compression")||zo(r))return{ok:!1,issue:"draco_not_allowed"};if(a.length||J(r.extensionsRequired).length)return{ok:!1,issue:"unsupported_glb"};if(J(r.images).length||J(r.textures).length)return{ok:!1,issue:"external_resource"};let i=J(r.buffers);if(i.length!==1||!Q(i[0])||i[0].uri!==void 0||typeof i[0].byteLength!="number"||!Number.isInteger(i[0].byteLength)||i[0].byteLength<0||i[0].byteLength>o.byteLength)return{ok:!1,issue:"external_resource"};let s=J(r.accessors),l=J(r.bufferViews),c=J(r.meshes),f=J(r.nodes),m=J(r.scenes),u=typeof r.scene=="number"?r.scene:0;if(!Q(m[u]))return{ok:!1,issue:"unsupported_glb"};let h=new DataView(o.buffer,o.byteOffset,o.byteLength),b=(A,E,M)=>{if(typeof A!="number"||!Number.isInteger(A)||!Q(s[A]))return null;let I=s[A];if(I.type!==E||I.sparse!==void 0||I.normalized===!0||typeof I.count!="number"||!Number.isInteger(I.count)||I.count<1||typeof I.componentType!="number"||!M.includes(I.componentType)||typeof I.bufferView!="number")return null;let B=l[I.bufferView];if(!Q(B)||B.buffer!==0||typeof B.byteLength!="number"||!Number.isInteger(B.byteLength)||B.byteLength<0)return null;let k=nr(I.type),D=tr(I.componentType),U=typeof B.byteStride=="number"?B.byteStride:k*D,S=typeof B.byteOffset=="number"?B.byteOffset:0,_=typeof I.byteOffset=="number"?I.byteOffset:0,N=S+_,O=_+(I.count-1)*U+k*D;if(!Number.isInteger(U)||!Number.isInteger(S)||!Number.isInteger(_)||U<k*D||S<0||_<0||S+B.byteLength>o.byteLength||O>B.byteLength)return null;let P=[];for(let F=0;F<I.count;F++){let R=[];for(let T=0;T<k;T++){let C=er(h,N+F*U+T*D,I.componentType);if(!Number.isFinite(C))return null;R.push(C)}P.push(R)}return P},p=[],d=[],y=0,x=new Set,w=(A,E)=>{if(typeof A!="number"||!Number.isInteger(A)||!Q(f[A])||x.has(A))return!1;x.add(A);let M=f[A],I=$o(M);if(!I)return!1;let B=Ko(E,I),k=Jo(B);if(!k)return!1;if(M.mesh!==void 0){if(typeof M.mesh!="number")return!1;let D=c[M.mesh];if(!Q(D))return!1;for(let U of J(D.primitives)){if(!Q(U)||U.mode!==void 0&&U.mode!==4||!Q(U.attributes))return!1;let S=b(U.attributes.POSITION,"VEC3",[5126]),_=U.attributes.NORMAL===void 0?null:b(U.attributes.NORMAL,"VEC3",[5126]);if(!S||U.attributes.NORMAL!==void 0&&!_)return!1;let N=S.length;if(U.indices!==void 0){let P=typeof U.indices=="number"?s[U.indices]:null;N=Q(P)?P.count:void 0}if(typeof N!="number"||!Number.isInteger(N)||N%3!==0||(y+=N/3,y>1e5))return!1;let O=U.indices===void 0?S.map((P,F)=>[F]):b(U.indices,"SCALAR",[5121,5123,5125]);if(!O||O.length%3!==0||O.length!==N)return!1;for(let P=0;P<O.length;P+=3){let F=[O[P][0],O[P+1][0],O[P+2][0]];if(F.some(C=>!Number.isInteger(C)||C<0||C>=S.length))return!1;let R=F.map(C=>qo(B,...S[C])),T=null;if(!_){let C=R[1][0]-R[0][0],v=R[1][1]-R[0][1],G=R[1][2]-R[0][2],X=R[2][0]-R[0][0],L=R[2][1]-R[0][1],Y=R[2][2]-R[0][2];T=Se([1,0,0,0,1,0,0,0,1],v*Y-G*L,G*X-C*Y,C*L-v*X)}for(let C=0;C<3;C++)p.push(...R[C]),d.push(..._?Se(k,..._[F[C]]):T)}}}for(let D of J(M.children))if(!w(D,B))return!1;return x.delete(A),!0};for(let A of J(m[u].nodes))if(!w(A,Zo()))return{ok:!1,issue:y>1e5?"triangle_limit":"unsupported_glb"};return!y||p.length!==y*9||d.length!==p.length?{ok:!1,issue:"unsupported_glb"}:{ok:!0,triangleCount:y,position:new Float32Array(p),normal:new Float32Array(d)}}function Re(t){try{return or(t)}catch{return{ok:!1,issue:"invalid_glb"}}}function As(t){let{doc:n}=t,e=ue(n.theme),r=e.structure,o=Zn(n,t.eventConfigurationId??n.eventConfigurationId),a=Me(t.eventConfigurationId,t.eventConfiguration,o),i=t.seats,s=new Yt,l=null;if(t.registeredShellGlb){let P=Re(t.registeredShellGlb);if(P.ok){let F=P.position.length/3,R=new Float32Array(P.position.length),T=e.materials.shell??r.tierWall;for(let C=0;C<F;C++){let v=P.normal[C*3+1],G=v<-.25?.4:.62+.38*Math.max(0,v);R[C*3]=T[0]*G,R[C*3+1]=T[1]*G,R[C*3+2]=T[2]*G}l={position:P.position,normal:P.normal,color:R,floor:new Float32Array(F).fill(-2),material:new Float32Array(F),count:F}}}let c=new Map;for(let P of o)for(let F of P.objects)c.set(F.id,P.index),F.type==="section"&&c.set(F.logicalSectionId??F.id,P.index);let f=i.map(P=>c.get(P.sectionId??"")??c.get(P.rowId??"")??0),m=mn(o,i);ye(s,o,i,f,m,r);let u=vn(n,i),h=new Map,b=new Map;for(let P of n.categories??[])h.set(P.key,P.color),P.seatGlyph&&b.set(P.key,P.seatGlyph);let p=[],d=fe(o,i,f),y=new Float32Array(i.length),x=[];for(let P=0;P<o.length;P++){let F=o[P];s.setFloor(P);let R=new zt,T=[],C=F.objects.filter(v=>v.type==="section"&&!!v.outline&&v.outline.length>=3);for(let v of F.objects)if(v.type==="section"){let G=s.vertexCount;be(s,v,F,kn(v,u),d.bySection.get(v.id),R,C,r);let X=s.vertexCount-G;X>0&&x.push({sectionId:v.id,start:G,count:X})}else if(v.type==="shape"){let G=a.byObjectId.get(v.id);s.setMaterial((G?.kind??v.role)==="screen"?1:0),ee(s,v,F.baseHeightM,qn(v,T),r,F.focal,p,G),s.setMaterial(0)}else v.type==="gaArea"?re(s,v,F.baseHeightM,H(h.get(v.categoryKey)),r):v.type==="booth"?te(s,v,F.baseHeightM,H(h.get(v.categoryKey)),r):v.type==="table"?ne(s,v,F.baseHeightM,H(v.fill??n.theme?.decorFill??"#232c40"),r):v.type==="decorImage"&&oe(s,v,F.baseHeightM,r);pe(s,F,i,d,r,e.materials.shell,!l)}let w=o.length>1?{x:o.reduce((P,F)=>P+F.focal.x,0)/o.length,y:o.reduce((P,F)=>P+F.focal.y,0)/o.length}:n.focalPoint??{x:(m.minX+m.maxX)/2,y:(m.minY+m.maxY)/2},A=Tn(l?[s.build(),l]:[s.build()]),E=Fn(i,t.initialState,d,y,h,b),M=se({doc:n,units:o,seats:i,surfaces:d,focal:w}),{labels:I,sections:B,rows:k}=ae({doc:n,units:o,seats:i,surfaces:d,seatData:E,hintedSeatFloor:f,zones:M,focal:w}),D=de({doc:n,units:o,seats:i,surfaces:d,solids:A,hintedSeatFloor:f,seatFloor:y});ce(I,D),E.iYaw=Cn(E.iPosition,i.length,P=>i[P].rowId,P=>{let F=o[y[P]]?.focal??w;return[F.x*g,F.y*g]});let U=(m.minX+m.maxX)/2*g,S=(m.minY+m.maxY)/2*g,_=.5*Math.hypot((m.maxX-m.minX)*g,(m.maxY-m.minY)*g)||10,N=xe(A,E,{cx:U,cz:S,radius:_}),O=ge(E,p,m,N.minY,N.maxY,_);return{solids:A,sectionSolidRanges:x,seats:E,bounds:{center:[(O.min[0]+O.max[0])/2,(O.min[1]+O.max[1])/2,(O.min[2]+O.max[2])/2],radius:_,groundY:0,box:O},renderBounds:{center:N.center,radius:N.radius},stateColorLUT:le(e,Bt),theme:e,seatCount:i.length,focalWorld:[w.x*g,1.5,w.y*g],zones:M,stages:p,productionElements:a.elements,sections:B,rows:k,labels:I,floors:D}}export{Bt as a,Qt as b,mr as c,nn as d,g as e,hr as f,Ge as g,Ne as h,br as i,Vt as j,Ar as k,Pr as l,_r as m,Tr as n,Br as o,Er as p,Cr as q,Fr as r,vr as s,kr as t,Or as u,Lr as v,Bo as w,As as x};
1
+ import{a as Pn,c as In,d as wn}from"./chunk-PRED5KHO.js";import{a as gn}from"./chunk-QJXSZT3H.js";import{a as Mn,c as Nt,d as ft,f as It,i as An}from"./chunk-BS37TGPX.js";import{f as hn}from"./chunk-4I2VWFJY.js";import{e as Sn,k as Rn}from"./chunk-UL5OIGIF.js";import{Na as qt,f as bn,ga as ut,ha as lt,qa as Gt,sa as dn,ta as Dt,va as yn,x as pn,y as At,za as xn}from"./chunk-24O23MNB.js";import{A as Pt,d as H,y as nt}from"./chunk-JBOTRSMY.js";import Ae from"earcut";import Pe from"polygon-clipping";var g=ut,Ie=.002;function we(t,n,e){let r=Math.hypot(n[0]-t[0],n[1]-t[1],n[2]-t[2]),o=Math.hypot(e[0]-n[0],e[1]-n[1],e[2]-n[2]),a=Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2]),i=Math.max(r,o,a);if(i<1e-9)return!0;let s=(r+o+a)/2;return 2*Math.sqrt(Math.max(0,s*(s-r)*(s-o)*(s-a)))/i<Ie}var ht=class{constructor(n=16384){this.len=0;this.buf=new Float32Array(n)}push3(n,e,r){this.len+3>this.buf.length&&this.grow(this.len+3),this.buf[this.len++]=n,this.buf[this.len++]=e,this.buf[this.len++]=r}push1(n){this.len+1>this.buf.length&&this.grow(this.len+1),this.buf[this.len++]=n}grow(n){let e=this.buf.length*2;for(;e<n;)e*=2;let r=new Float32Array(e);r.set(this.buf.subarray(0,this.len)),this.buf=r}get length(){return this.len}toArray(){return this.buf.slice(0,this.len)}},Yt=class{constructor(){this.pos=new ht;this.nor=new ht;this.col=new ht;this.flr=new ht;this.mat=new ht;this.currentFloor=0;this.currentMaterial=0}setFloor(n){this.currentFloor=n}setMaterial(n){this.currentMaterial=n}tri(n,e,r,o,a,i=a,s=a){we(n,e,r)||(this.pos.push3(n[0],n[1],n[2]),this.pos.push3(e[0],e[1],e[2]),this.pos.push3(r[0],r[1],r[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.col.push3(a[0],a[1],a[2]),this.col.push3(i[0],i[1],i[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(n,e,r,o,a,i,s,l=s,c=s){[...n,...e,...r].every(Number.isFinite)&&(this.pos.push3(n[0],n[1],n[2]),this.pos.push3(e[0],e[1],e[2]),this.pos.push3(r[0],r[1],r[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(a[0],a[1],a[2]),this.nor.push3(i[0],i[1],i[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 _e(t,n,e){let r=n[0]-t[0],o=n[1]-t[1],a=n[2]-t[2],i=e[0]-t[0],s=e[1]-t[1],l=e[2]-t[2],c=o*l-a*s,f=a*i-r*l,m=r*s-o*i,u=Math.hypot(c,f,m)||1;return c/=u,f/=u,m/=u,[c,f,m]}function Te(t,n){let e=[...t],r=[];for(let i of t)r.push(i.x,i.y);let o=[];if(n){for(let i of n)if(!(i.length<3)){o.push(e.length);for(let s of i)e.push(s),r.push(s.x,s.y)}}let a=Ae(r,o.length?o:void 0,2);return{pts:e,tris:a}}function Jt(t){return ft(t)<0?[...t].reverse():t}var Be=3;function Ee(t,n,e,r){let o=r(t),a=r(n),i=r(e),s=(h,b,p,d)=>Math.abs(r({x:(h.x+b.x)/2,y:(h.y+b.y)/2})-(p+d)/2),l=(t.x+n.x+e.x)/3,c=(t.y+n.y+e.y)/3,f=(o+a+i)/3,m=Math.max(s(t,n,o,a),s(n,e,a,i),s(e,t,i,o),Math.abs(r({x:l,y:c})-f)),u=(h,b,p)=>{let d=Math.abs(r({x:(h+l)/2,y:(b+c)/2})-(p+f)/2);d>m&&(m=d)};return u((t.x+n.x)/2,(t.y+n.y)/2,(o+a)/2),u((n.x+e.x)/2,(n.y+e.y)/2,(a+i)/2),u((e.x+t.x)/2,(e.y+t.y)/2,(i+o)/2),m}function wt(t,n,e,r,o){if(o<=0)return Ee(t,n,e,r);let a={x:(t.x+n.x)/2,y:(t.y+n.y)/2},i={x:(n.x+e.x)/2,y:(n.y+e.y)/2},s={x:(e.x+t.x)/2,y:(e.y+t.y)/2};return Math.max(wt(t,a,s,r,o-1),wt(a,n,i,r,o-1),wt(s,i,e,r,o-1),wt(a,i,s,r,o-1))}function _t(t,n,e,r,o,a,i,s){if(i>0){let u={x:(n.x+e.x)/2,y:(n.y+e.y)/2},h={x:(e.x+r.x)/2,y:(e.y+r.y)/2},b={x:(r.x+n.x)/2,y:(r.y+n.y)/2};_t(t,n,u,b,o,a,i-1,s),_t(t,u,e,h,o,a,i-1,s),_t(t,b,h,r,o,a,i-1,s),_t(t,u,h,b,o,a,i-1,s);return}let l=[n.x*g,o(n),n.y*g],c=[e.x*g,o(e),e.y*g],f=[r.x*g,o(r),r.y*g];if(s){t.triN(l,c,f,s(n),s(e),s(r),a);return}let m=_e(l,c,f);m[1]<0&&(m=[-m[0],-m[1],-m[2]]),t.tri(l,c,f,m,a)}var Ce=8;function _n(t,n,e){if(!Number.isFinite(e))return t;let r=[],o=(a,i,s,l,c)=>{if(c>0){let f={x:(a.x+i.x)/2,y:(a.y+i.y)/2},m=n(f);if(Math.abs(m-(s+l)/2)>e){o(a,f,s,m,c-1),o(f,i,m,l,c-1);return}}r.push(a)};for(let a=0;a<t.length;a++){let i=t[a],s=t[(a+1)%t.length];o(i,s,n(i),n(s),Ce)}return r}function Xt(t,n){if(t.length<3)return t;let e=[];for(let o of t){let a=e[e.length-1];a&&Math.hypot(o.x-a.x,o.y-a.y)<n||e.push(o)}for(;e.length>2&&Math.hypot(e[0].x-e[e.length-1].x,e[0].y-e[e.length-1].y)<n;)e.pop();if(e.length<3)return t;let r=[];for(let o=0;o<e.length;o++){let a=r.length?r[r.length-1]:e[(o-1+e.length)%e.length],i=e[o],s=e[(o+1)%e.length],l=s.x-a.x,c=s.y-a.y,f=Math.hypot(l,c);f>n&&Math.abs((i.x-a.x)*c-(i.y-a.y)*l)/f<n||r.push(i)}return r.length>=3?r:e}var Ut=.001*lt*.1;function K(t,n,e,r,o,a,i,s,l=1/0,c){if(!n||n.length<3||(l===void 0&&(l=1/0),Math.abs(ft(n))<1e-4))return;let f=Xt(_n(Xt(Jt(n),Ut),r,l),Ut),m=e?.map(M=>Xt(_n(Xt(Jt(M),Ut),r,l),Ut)).filter(M=>M.length>=3&&Math.abs(ft(M))>=1e-4),{pts:u,tris:h}=Te(f,m),b=[a[0]*s.top,a[1]*s.top,a[2]*s.top],p=[a[0]*s.bottomCap,a[1]*s.bottomCap,a[2]*s.bottomCap],d=[i[0]*s.top,i[1]*s.top,i[2]*s.top],y=[i[0]*s.wallBottom,i[1]*s.wallBottom,i[2]*s.wallBottom],x=0;if(Number.isFinite(l))for(;x<Be;x++){let M=0;for(let I=0;I<h.length;I+=3){let B=wt(u[h[I]],u[h[I+1]],u[h[I+2]],r,x);B>M&&(M=B)}if(M<=l)break}for(let M=0;M<h.length;M+=3){let I=u[h[M]],B=u[h[M+1]],k=u[h[M+2]];_t(t,I,B,k,r,b,x,c);let D=[I.x*g,o,I.y*g],U=[B.x*g,o,B.y*g],S=[k.x*g,o,k.y*g];t.tri(D,S,U,[0,-1,0],p)}let w=M=>{if(x<=0)return M;let I=1<<x,B=[];for(let k=0;k<M.length;k++){let D=M[k],U=M[(k+1)%M.length];for(let S=0;S<I;S++){let _=S/I;B.push({x:D.x+(U.x-D.x)*_,y:D.y+(U.y-D.y)*_})}}return B},A=pn(f),E=[{ring:w(f),flip:!1}];if(m)for(let M of m)M.length>=3&&E.push({ring:w(M),flip:!0});for(let{ring:M,flip:I}of E)for(let B=0;B<M.length;B++){let k=M[B],D=M[(B+1)%M.length],U=(D.x-k.x)*g,_=(D.y-k.y)*g,N=-U,O=Math.hypot(_,N)||1;_/=O,N/=O;let P=(k.x+D.x)/2-A.x,F=(k.y+D.y)/2-A.y,R=_*P+N*F;I&&(R=-R),R<0&&(_=-_,N=-N);let T=[_,0,N],C=[k.x*g,r(k),k.y*g],v=[D.x*g,r(D),D.y*g],G=[k.x*g,o,k.y*g],X=[D.x*g,o,D.y*g];t.tri(C,v,X,T,d,d,y),t.tri(C,X,G,T,d,y,y)}}function Tn(t){let n=0;for(let l of t)n+=l.count;let e=new Float32Array(n*3),r=new Float32Array(n*3),o=new Float32Array(n*3),a=new Float32Array(n),i=new Float32Array(n),s=0;for(let l of t)e.set(l.position,s*3),r.set(l.normal,s*3),o.set(l.color,s*3),a.set(l.floor,s),i.set(l.material,s),s+=l.count;return{position:e,normal:r,color:o,floor:a,material:i,count:n}}function jt(t,n,e=2.5){if(n<=0||t.length<3)return t;let r=Jt(t),o=r.length,a=[];for(let s=0;s<o;s++){let l=r[s],c=r[(s+1)%o],f=c.x-l.x,m=c.y-l.y,u=Math.hypot(f,m)||1;a.push({x:m/u,y:-f/u})}let i=[];for(let s=0;s<o;s++){let l=r[s],c=a[(s-1+o)%o],f=a[s],m=c.x+f.x,u=c.y+f.y,h=Math.hypot(m,u),b=()=>{i.push([l.x+c.x*n,l.y+c.y*n]),i.push([l.x+f.x*n,l.y+f.y*n])};if(h<1e-9){b();continue}m/=h,u/=h;let p=m*c.x+u*c.y,d=1/Math.max(p,1e-6);if(!Number.isFinite(d)||d>e){b();continue}i.push([l.x+m*n*d,l.y+u*n*d])}if(i.length<3)return t;try{let s=Pe.union([[...i,i[0]]]),l=null,c=-1/0;for(let m of s){let u=Math.abs(ft(m[0].map(([h,b])=>({x:h,y:b}))));u>c&&(c=u,l=m[0])}if(!l)return t;let f=l.map(([m,u])=>({x:m,y:u}));if(f.length>1){let m=f[0],u=f[f.length-1];Math.abs(m.x-u.x)<1e-9&&Math.abs(m.y-u.y)<1e-9&&f.pop()}return f.length>=3?f:t}catch{return t}}function Ht(t,n,e,r,o=28){let a=[];for(let i=0;i<o;i++){let s=i/o*Math.PI*2;a.push({x:t+e*Math.cos(s),y:n+r*Math.sin(s)})}return a}function Tt(t,n,e,r){return[{x:t,y:n},{x:t+e,y:n},{x:t+e,y:n+r},{x:t,y:n+r}]}var Bt=["available","held","sold","selected","dimmed"];function Qt(t){let n=Bt.indexOf(t);return n<0?0:n}var Bn={available:[.24,.82,.52],held:[.95,.66,.22],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};function mr(t){let n=.2126*t[0]+.7152*t[1]+.0722*t[2],e=.42,r=.62;return[(n+(t[0]-n)*e)*r,(n+(t[1]-n)*e)*r,(n+(t[2]-n)*e)*r]}var tn={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]},nn={top:[.05,.06,.08],bottom:[.1,.12,.15]};function et(t,n){return[Math.min(1,t[0]*n),Math.min(1,t[1]*n),Math.min(1,t[2]*n)]}var V={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,body:10,head:11},Fe=.44,ve=.15,ke=.3,Oe=.24;function En(t){return t===void 0||!Number.isFinite(t)||t<=0?Oe:Math.min(ke,Math.max(ve,t*Fe))}var hr=.21,Le=.05,en=.45,Ge=en+Le,De=.92,Ne=1.205,Xe=-.23,Ue=.38,Ye=[{part:V.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:V.pad,min:[-1,.36,-.95],max:[1,en,1]},{part:V.back,min:[-1,Ge,-1],max:[1,De,-.72]},{part:V.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:V.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:V.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:V.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:V.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:V.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:V.leg,min:[.62,0,.48],max:[.82,.37,.7]}],je=[{part:V.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:V.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:V.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:V.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:V.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}],He=[{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 br(){let t=[],n=[],e=[],r=[],o=(O,P,F)=>{let R=e.length,[T,C,v]=O,G=[C[0]-T[0],C[1]-T[1],C[2]-T[2]],X=[v[0]-T[0],v[1]-T[1],v[2]-T[2]],L=G[1]*X[2]-G[2]*X[1],Y=G[2]*X[0]-G[0]*X[2],j=G[0]*X[1]-G[1]*X[0],$=Math.hypot(L,Y,j);$>1e-9?(L/=$,Y/=$,j/=$):[L,Y,j]=P,L*P[0]+Y*P[1]+j*P[2]<0&&(L=-L,Y=-Y,j=-j);for(let z of O)t.push(...z),n.push(L,Y,j),e.push(F);r.push(R,R+1,R+2,R,R+2,R+3)},a=O=>{for(let P of He){let F=P.c.map(R=>R.map((T,C)=>T?O.max[C]:O.min[C]));o(F,P.n,O.part)}};for(let O of Ye)a(O);for(let O of je)a(O);let i=en,s=1.08,l=.47,c=.69,f=-.55,m=.08,u=-.48,h=.01,b=[-l,i,f],p=[l,i,f],d=[-l,i,m],y=[l,i,m],x=[-c,s,u],w=[c,s,u],A=[-c,s,h],E=[c,s,h];o([p,w,E,y],[1,0,0],V.body),o([d,A,x,b],[-1,0,0],V.body),o([A,E,w,x],[0,1,0],V.body),o([b,p,y,d],[0,-1,0],V.body),o([y,E,A,d],[0,0,1],V.body),o([b,x,w,p],[0,0,-1],V.body);let M=10,I=8,B=[0,Ne,Xe],k=[.42,.115,Ue],D=e.length;for(let O=0;O<=I;O++){let P=Math.PI*O/I,F=Math.cos(P),R=Math.sin(P);for(let T=0;T<=M;T++){let C=Math.PI*2*T/M,v=R*Math.cos(C),G=R*Math.sin(C);t.push(B[0]+k[0]*v,B[1]+k[1]*F,B[2]+k[2]*G);let X=v/k[0],L=F/k[1],Y=G/k[2],j=Math.hypot(X,L,Y)||1;X/=j,L/=j,Y/=j,n.push(X,L,Y),e.push(V.head)}}for(let O=0;O<I;O++)for(let P=0;P<M;P++){let F=D+O*(M+1)+P,R=F+M+1;r.push(F,R,F+1,F+1,R,R+1)}let U=new Float32Array(t),S=new Float32Array(n),_=new Float32Array(e),N=new Uint16Array(r);return{position:U,normal:S,part:_,index:N,vertexCount:e.length,indexCount:r.length}}function Cn(t,n,e,r){let o=new Float32Array(n),a=c=>t[c*3],i=c=>t[c*3+2],s=0,l=(c,f)=>{let m=f-c;for(let u=c;u<f;u++){let[h,b]=r(u),p=h-a(u),d=b-i(u);if(m>=2){let y=Math.max(c,u-1),x=Math.min(f-1,u+1),w=a(x)-a(y),A=i(x)-i(y),E=Math.hypot(w,A);if(E>1e-6){let M=-A/E,I=w/E;M*p+I*d<0&&(M=-M,I=-I),p=M,d=I}}o[u]=p===0&&d===0?0:Math.atan2(p,d)}};for(let c=1;c<=n;c++)(c===n||e(c)!==e(s))&&(l(s,c),s=c);return o}var Vt=.22;function Ar(t,n){let e=Bt[t];if(e!=="sold"&&e!=="held")return-1;let r=(n+1)*2654435761;return r^=r>>>15,r=Math.imul(r,2246822519),r^=r>>>13,(r>>>0)%1e5/1e5}var Ve=.42;function We(t){let n=t.length,e=new Float64Array(n);if(n<2)return e.fill(1/0),e;let r=1/0,o=1/0,a=-1/0,i=-1/0;for(let b of t)b.x<r&&(r=b.x),b.y<o&&(o=b.y),b.x>a&&(a=b.x),b.y>i&&(i=b.y);let s=Math.max(a-r,1e-6),l=Math.max(i-o,1e-6),c=Math.max(Math.sqrt(s*l/n),1e-6),f=Math.max(1,Math.ceil(s/c)+1),m=Math.max(1,Math.ceil(l/c)+1),u=new Map,h=(b,p)=>{let d=Math.min(f-1,Math.max(0,Math.floor((b-r)/c)));return Math.min(m-1,Math.max(0,Math.floor((p-o)/c)))*f+d};for(let b=0;b<n;b++){let p=h(t[b].x,t[b].y),d=u.get(p);d?d.push(b):u.set(p,[b])}for(let b=0;b<n;b++){let p=t[b],d=Math.min(f-1,Math.max(0,Math.floor((p.x-r)/c))),y=Math.min(m-1,Math.max(0,Math.floor((p.y-o)/c))),x=1/0;for(let w=1;w<=4;w++){for(let A=y-w;A<=y+w;A++)if(!(A<0||A>=m))for(let E=d-w;E<=d+w;E++){if(E<0||E>=f||w>1&&Math.abs(A-y)<w&&Math.abs(E-d)<w)continue;let M=u.get(A*f+E);if(M)for(let I of M){if(I===b)continue;let B=Math.hypot(t[I].x-p.x,t[I].y-p.y);B<x&&(x=B)}}if(Number.isFinite(x)&&x<=w*c)break}e[b]=x}return e}function ze(t){let n=t.eyeHeightM;return Number.isFinite(n)?Math.max(0,n-Gt):0}function Fn(t,n,e,r,o,a){let i=t.length,s=new Float32Array(i*3),l=new Float32Array(i),c=new Float32Array(i*3),f=new Float32Array(i),m=new Float32Array(i),u=new Float32Array(i),h=new Float32Array(i),b=new Float32Array(i*3),p=new Map,d=We(t);for(let y=0;y<i;y++){let x=t[y],A=(e?.seatPitchU(y)??d[y])*g;f[y]=Number.isFinite(A)?Math.max(.06,Math.min(Vt,A*Ve)):Vt,m[y]=En(Number.isFinite(A)?A:void 0);let E=Rn(x.glyph,{seatGlyph:a?.get(x.categoryKey)});u[y]=Sn.indexOf(E),h[y]=x.wheelchairSpaceType==="no-seat"?0:1,s[y*3]=x.x*g,s[y*3+1]=e?e.seatDeckY(y):ze(x),s[y*3+2]=x.y*g,l[y]=Qt(n?n(x):"available");let M=H(o?.get(x.categoryKey)??"#6e7bff")??[.43,.48,1];if(c[y*3]=M[0],c[y*3+1]=M[1],c[y*3+2]=M[2],x.accessibility?.length){let I=H(hn(x.accessibility));I&&(b[y*3]=I[0],b[y*3+1]=I[1],b[y*3+2]=I[2])}p.set(x.id,y)}return{count:i,iPosition:s,iState:l,iCategory:c,iMaxRadius:f,iRing:b,idToIndex:p,iChairWidth:m,iGlyph:u,iPhysicalSeat:h,iFloor:r??new Float32Array(i),iYaw:new Float32Array(i)}}var Ze=64;function Pr(t,n){let e=[];for(let i of n){let s=t.idToIndex.get(i.seatId);if(s===void 0)continue;let l=Qt(i.state);t.iState[s]!==l&&(t.iState[s]=l,e.push(s))}if(!e.length)return[];e.sort((i,s)=>i-s);let r=[],o=e[0],a=e[0];for(let i=1;i<e.length;i++){let s=e[i];if(s!==a){if(s<=a+Ze){a=s;continue}r.push({start:o,length:a-o+1}),o=s,a=s}}return r.push({start:o,length:a-o+1}),r}function _r(t,n,e){return e<0?n>1?t.filter(r=>r.kind==="floor"):[...t]:t.filter(r=>r.floorIndex===void 0||r.floorIndex===e)}function Tr(t,n){let e=[...t].sort((o,a)=>o.screen.y-a.screen.y),r=[];for(let o of e){let a=r.find(i=>i.some(s=>Math.abs(s.screen.x-o.screen.x)<104&&Math.abs(s.screen.y-o.screen.y)<34));a?a.push(o):r.push([o])}return r.flatMap(o=>o.length<2?o:o.map((a,i)=>({...a,screen:{...a.screen,x:Math.max(54,Math.min(n-54,a.screen.x+(i-(o.length-1)/2)*104))}})))}var Ke=1.15,$e=2.75,qe=4.5,Je=.85,Qe=.5,to=.26;function Br(t,n,e){let r=Math.max(1e-6,n),o=t/r,a=e?.hasZoneLabels??!0,i=new Set;return o>=.75&&i.add("floor"),o>=Ke&&i.add("zone"),o<=(a?$e:qe)&&(i.add("section"),i.add("ga")),o<=Je&&(i.add("annotation"),i.add("booth")),o<=Qe&&i.add("row"),o<=to&&i.add("seat"),i}function Er(t,n,e,r,o,a=6){let i=a+n,s=r-a-n,l=a+e,c=o-a-e;return{...t,x:i>s?r/2:Math.max(i,Math.min(s,t.x)),y:l>c?o/2:Math.max(l,Math.min(c,t.y))}}function Cr(t,n,e,r){let o=t,a=n[0],i=n[1],s=n[2],l=o[0]*a+o[4]*i+o[8]*s+o[12],c=o[1]*a+o[5]*i+o[9]*s+o[13],f=o[2]*a+o[6]*i+o[10]*s+o[14],m=o[3]*a+o[7]*i+o[11]*s+o[15];if(!(m>1e-6))return{x:0,y:0,depth:1/0,visible:!1};let u=l/m,h=c/m,b=f/m,p=u>=-1.05&&u<=1.05&&h>=-1.05&&h<=1.05&&b<=1;return{x:(u*.5+.5)*e,y:(1-(h*.5+.5))*r,depth:b,visible:p}}function Fr(t,n,e=n){let r=[],o=[...t].sort((a,i)=>a.screen.depth-i.screen.depth);for(let a of o){let i=!1;for(let s of r)if(on(a,s,n,e)){i=!0;break}i||r.push(a)}return r}var no=6;function on(t,n,e,r){let o=Math.abs(t.screen.x-n.screen.x),a=Math.abs(t.screen.y-n.screen.y),i=t.halfWidth!=null&&n.halfWidth!=null?Math.max(e,t.halfWidth+n.halfWidth+no):e;return o<i&&a<r}function vr(t,n,e){return t.length*n*.58+(e?14:0)}var eo={row:8,seat:14};function kr(t){return t<480?{row:5,seat:8}:t<768?{row:6,seat:10}:eo}function Or(t,n,e,r){let o=Math.max(1,Math.min(e,r)*.5),a=Math.min(2,Math.hypot(t.x-e/2,t.y-r/2)/o);return n*(1+1.5*a)}function Lr(t,n,e,r,o=[]){let a=[...t].sort((s,l)=>(l.priority??0)-(s.priority??0)||s.focus-l.focus),i=[];for(let s of a){if(i.length>=r)break;let l=!1;for(let c of o)if(on(s,c,n,e)){l=!0;break}if(!l){for(let c of i)if(on(s,c,n,e)){l=!0;break}}l||i.push(s)}return i}import bo from"polygon-clipping";var W={top:1,wallBottom:.5,bottomCap:.4};function st(t,n){if(!t)return n;let e=et(Pt(t,.4),.62);return nt(n,e,.72)}function vn(t,n){let e=new Map;for(let a of t.categories??[])e.set(a.key,a.color);let r=new Map;for(let a of n){if(!a.sectionId)continue;let i=r.get(a.sectionId);i||(i=new Map,r.set(a.sectionId,i)),i.set(a.categoryKey,(i.get(a.categoryKey)??0)+1)}let o=new Map;for(let[a,i]of r){let s=0,l=0,c=0,f=0;for(let[m,u]of i){let h=H(e.get(m));h&&(s+=h[0]*u,l+=h[1]*u,c+=h[2]*u,f+=u)}f>0&&o.set(a,[s/f,l/f,c/f])}return o}function kn(t,n){return H(t.color)??n.get(t.logicalSectionId??t.id)??null}import zn from"polygon-clipping";import Dn from"polygon-clipping";import oo from"earcut";var ro=.58,On=.01,ot=Vt*1.5*lt,io=.5,so=.6;function ao(t,n){let e=t.length,r=[];for(let i=0;i<e;i++){let s=t[Math.max(0,i-1)],l=t[Math.min(e-1,i+1)],c=l.x-s.x,f=l.y-s.y,m=Math.hypot(c,f);if(m<1e-9){r.push([0,0]);continue}c/=m,f/=m,r.push([-f,c])}let o=0;for(let i=0;i<e;i++)o+=(t[i].x-n.x)*r[i][0]+(t[i].y-n.y)*r[i][1];return o<0?r.map(([i,s])=>[-i,-s]):r}function co(t,n){if(t.length<2||n<=0)return[...t];let e=[...t],r=(i,s)=>{let l=s.x-i.x,c=s.y-i.y,f=Math.hypot(l,c)||1;return{x:l/f,y:c/f}},o=r(e[1],e[0]),a=r(e[e.length-2],e[e.length-1]);return e.unshift({x:e[0].x+o.x*n,y:e[0].y+o.y*n}),e.push({x:e[e.length-1].x+a.x*n,y:e[e.length-1].y+a.y*n}),e}var Ln=Math.PI/12;function uo(t){if(t.length<3)return[...t];let n=[...t].sort((a,i)=>a.x-i.x||a.y-i.y),e=(a,i,s)=>(i.x-a.x)*(s.y-a.y)-(i.y-a.y)*(s.x-a.x),r=a=>{let i=[];for(let s of a){for(;i.length>=2&&e(i[i.length-2],i[i.length-1],s)<=0;)i.pop();i.push(s)}return i.pop(),i},o=[...r(n),...r([...n].reverse())];return o.length>=3?o:[...t]}function Nn(t,n){if(!t.length||!(n>0))return[];let e=uo(t),r=(s,l,c,f)=>{let m=c-l;for(;m<0;)m+=Math.PI*2;for(;m>Math.PI*2;)m-=Math.PI*2;let u=Math.max(1,Math.ceil(m/Ln)),h=n/Math.cos(m/u/2);for(let b=0;b<=u;b++){let p=l+m*b/u;f.push({x:s.x+Math.cos(p)*h,y:s.y+Math.sin(p)*h})}};if(e.length<3){let s=0,l=0;for(let h of e)s+=h.x,l+=h.y;s/=e.length||1,l/=e.length||1;let c=0;for(let h of e)c=Math.max(c,Math.hypot(h.x-s,h.y-l));let f=[],m=Math.max(3,Math.ceil(Math.PI*2/Ln)),u=(c+n)/Math.cos(Math.PI/m);for(let h=0;h<m;h++){let b=h/m*Math.PI*2;f.push({x:s+Math.cos(b)*u,y:l+Math.sin(b)*u})}return f}let o=e.length,a=[];for(let s=0;s<o;s++){let l=e[s],c=e[(s+1)%o];a.push(Math.atan2(-(c.x-l.x),c.y-l.y))}let i=[];for(let s=0;s<o;s++)r(e[s],a[(s+o-1)%o],a[s],i);return Hn(i)}function lo(t,n,e){if(t.length===1)return Math.hypot(n-t[0].x,e-t[0].y);let r=1/0;for(let o=0;o+1<t.length;o++){let a=t[o],i=t[o+1],s=i.x-a.x,l=i.y-a.y,c=s*s+l*l,f=c>1e-12?((n-a.x)*s+(e-a.y)*l)/c:0;f<0?f=0:f>1&&(f=1);let m=Math.hypot(n-(a.x+f*s),e-(a.y+f*l));m<r&&(r=m)}return r}function Wt(t){let n=t.map(o=>{let a=0,i=0;for(let c of o.pts)a+=c.x,i+=c.y;let s=o.pts.length||1;a/=s,i/=s;let l=0;for(let c of o.pts){let f=Math.hypot(c.x-a,c.y-i);f>l&&(l=f)}return{cx:a,cy:i,rad:l}}),e=o=>{let a=o.length;return a<=2?[...o]:[o[Math.floor(a*.25)],o[Math.floor(a*.5)],o[Math.floor(a*.75)]]},r=[];for(let o=0;o<t.length;o++){let a=e(t[o].pts),i=[],s=1/0,l=null;for(let f of a){let m=1/0;for(let u=0;u<t.length;u++){if(u===o||Math.abs(t[u].y-t[o].y)<.001)continue;let h=n[u],b=Math.hypot(f.x-h.cx,f.y-h.cy)-h.rad;if(b>=m&&b>=s)continue;let p=lo(t[u].pts,f.x,f.y);p<m&&(m=p),t[u].depth<t[o].depth&&p<s&&(s=p,l=t[u].y)}Number.isFinite(m)&&m>0&&i.push(m)}i.sort((f,m)=>f-m);let c=i.length?i[Math.floor(i.length/2)]:1;r.push({pitch:c,belowY:l})}return r}function Xn(t,n,e,r){let o=t[n],a=o.pts.length>=2?[...o.pts]:o.pts.length===1?(()=>{let f=o.pts[0],m=f.x-r.x,u=f.y-r.y,h=Math.hypot(m,u)||1;m/=h,u/=h;let b=Math.max(e[n].pitch,.001)*.5;return[{x:f.x+u*b,y:f.y-m*b},{x:f.x-u*b,y:f.y+m*b}]})():[];if(a.length<2)return null;let i=0,s=0;for(let f=1;f<a.length;f++){let m=Math.hypot(a[f].x-a[f-1].x,a[f].y-a[f-1].y);m>1e-6&&(i+=m,s++)}let l=s>0?i/s:0,c=co(a,Math.max(l*so,ot));return{pts:c,nrm:ao(c,r),front:Math.max(e[n].pitch*ro,ot),back:Math.max(e[n].pitch*io,ot)}}var gt=1.5,Un=.3;function rn(t,n){if(t.length<3)return t;let e=t[0],r=t[t.length-1],o=r.x-e.x,a=r.y-e.y,i=Math.hypot(o,a),s=-1,l=-1;for(let m=1;m<t.length-1;m++){let u=t[m],h=i>1e-12?Math.abs((u.x-e.x)*a-(u.y-e.y)*o)/i:Math.hypot(u.x-e.x,u.y-e.y);h>s&&(s=h,l=m)}if(s<=n||l<0)return[e,r];let c=rn(t.slice(0,l+1),n),f=rn(t.slice(l),n);return[...c.slice(0,-1),...f]}function Yn(t,n){if(t.length<4)return t;let e=rn([...t,t[0]],n);return e.pop(),e.length>=3?e:t}function jn(t,n,e){if(t.length<2)return[];let r=e??Wt(t),o=new Map;for(let i=0;i<t.length;i++){let s=o.get(t[i].blockId);s?s.push(i):o.set(t[i].blockId,[i])}let a=[];for(let[,i]of o){let s=[];for(let x of i){let w=t[x].patch;w&&w.length>=3?a.push({outline:[...w],holes:[],topY:t[x].y}):s.push(x)}if(!s.length)continue;s.sort((x,w)=>t[x].depth-t[w].depth);let c=s.map(x=>Xn(t,x,r,n)).filter(x=>x!==null);if(!c.length)continue;let f=(x,w)=>({x:x.pts[w].x-x.nrm[w][0]*(x.front+gt),y:x.pts[w].y-x.nrm[w][1]*(x.front+gt)}),m=(x,w)=>({x:x.pts[w].x+x.nrm[w][0]*(x.back+gt),y:x.pts[w].y+x.nrm[w][1]*(x.back+gt)}),u=c[0],h=c[c.length-1],b=[];for(let x=0;x<u.pts.length;x++)b.push(f(u,x));for(let x of c)b.push(m(x,x.pts.length-1));for(let x=h.pts.length-1;x>=0;x--)b.push(m(h,x));for(let x=c.length-1;x>=0;x--)b.push(f(c[x],0));let p=Hn(b),d=1/0;for(let x of s)t[x].y<d&&(d=t[x].y);if(!Number.isFinite(d))continue;if(p.length>=3&&Math.abs(ft(p))>1e-6&&c.every(x=>{let w=x.pts[Math.floor(x.pts.length/2)];return It(p,w.x,w.y)})){a.push({outline:Yn(p,Un),holes:[],topY:d});continue}for(let x of mo(c))a.push({outline:x,holes:[],topY:d})}return a}function mo(t){let n=[];for(let e of t){let r=[],o=[],a=e.front+gt,i=e.back+gt;for(let l=0;l<e.pts.length;l++){let c=e.pts[l],f=e.nrm[l];r.push([c.x-f[0]*a,c.y-f[1]*a]),o.push([c.x+f[0]*i,c.y+f[1]*i])}let s=[...r,...o.reverse()];s.length<3||(s.push(s[0]),n.push([s]))}if(!n.length)return[];try{let e=Dn.union(n[0],...n.slice(1)),r=[];for(let o of e){if(!o.length||o[0].length<4)continue;let a=o[0].map(([l,c])=>({x:l,y:c})),i=a[0],s=a[a.length-1];a.length>1&&Math.abs(i.x-s.x)<1e-9&&Math.abs(i.y-s.y)<1e-9&&a.pop(),a.length>=3&&r.push(Yn(a,Un))}return r}catch{return[]}}function Hn(t){let n=[];for(let e of t){let r=n[n.length-1];r&&Math.hypot(e.x-r.x,e.y-r.y)<1e-9||n.push(e)}for(;n.length>2&&Math.hypot(n[0].x-n[n.length-1].x,n[0].y-n[n.length-1].y)<1e-9;)n.pop();return n}var sn=class{constructor(n){this.minX=1/0;this.minY=1/0;this.maxX=-1/0;this.maxY=-1/0;this.rings=n;for(let e of n)for(let r of e)r.x<this.minX&&(this.minX=r.x),r.y<this.minY&&(this.minY=r.y),r.x>this.maxX&&(this.maxX=r.x),r.y>this.maxY&&(this.maxY=r.y)}containsAll(n){for(let e of n)if(e.x<this.minX||e.x>this.maxX||e.y<this.minY||e.y>this.maxY)return!1;for(let e of this.rings){let r=!0;for(let o of n)if(!It(e,o.x,o.y)){r=!1;break}if(r)return!0}return!1}};function Gn(t,n,e,r,o,a){if(r.length<3)return;if(e.containsAll(r)){let c=[0,1,0],f=r[0];for(let m=1;m+1<r.length;m++){let u=r[m],h=r[m+1];t.tri([f.x*g,o,f.y*g],[u.x*g,o,u.y*g],[h.x*g,o,h.y*g],c,a)}return}let i=r.map(c=>[c.x,c.y]);i.push(i[0]);let s;try{s=Dn.intersection([i],n)}catch{return}let l=[0,1,0];for(let c of s){if(!c.length||c[0].length<4)continue;let f=c[0],m=[],u=[];for(let b=0;b<f.length-1;b++)m.push(f[b][0],f[b][1]),u.push([f[b][0],f[b][1]]);if(u.length<3)continue;let h=oo(m,void 0,2);for(let b=0;b<h.length;b+=3){let p=u[h[b]],d=u[h[b+1]],y=u[h[b+2]];t.tri([p[0]*g,o,p[1]*g],[d[0]*g,o,d[1]*g],[y[0]*g,o,y[1]*g],l,a)}}}function Vn(t,n,e,r,o,a,i){if(n.length<2)return;let s=i??Wt(n),l=[0,1,0],c=a&&a.length>=3?[[...a.map(h=>[h.x,h.y]),[a[0].x,a[0].y]]]:null,f=a&&a.length>=3?new sn([[...a]]):null,m=h=>{t.setMaterial(2),h(),t.setMaterial(0)},u=h=>{t.setMaterial(3),h(),t.setMaterial(0)};for(let h=0;h<n.length;h++){let b=n[h];if(b.patch&&b.patch.length>=3){let E=[...b.patch],M=s[h].belowY??r;if(u(()=>{if(c&&f)Gn(t,c,f,E,b.y,o.tread);else{let I=E[0];for(let B=1;B+1<E.length;B++){let k=E[B],D=E[B+1];t.tri([I.x*g,b.y,I.y*g],[k.x*g,b.y,k.y*g],[D.x*g,b.y,D.y*g],l,o.tread)}}}),b.y>M+On){let I=0,B=0;for(let k of E)I+=k.x,B+=k.y;I/=E.length,B/=E.length,m(()=>{for(let k=0;k<E.length;k++){let D=E[k],U=E[(k+1)%E.length],S=U.x-D.x,_=U.y-D.y,N=Math.hypot(S,_);if(N<1e-6)continue;let O=_/N,P=-S/N;(D.x-I)*O+(D.y-B)*P<0&&(O=-O,P=-P);let F=[O,0,P],R=[D.x*g,b.y,D.y*g],T=[U.x*g,b.y,U.y*g],C=[D.x*g,M,D.y*g],v=[U.x*g,M,U.y*g];t.tri(R,T,v,F,o.riser),t.tri(R,v,C,F,o.riser)}})}continue}let p=Xn(n,h,s,e);if(!p)continue;let{pts:d,nrm:y,front:x,back:w}=p,A=s[h].belowY??r;for(let E=0;E+1<d.length;E++){let M=d[E],I=d[E+1],B=y[E],k=y[E+1];if(Math.hypot(I.x-M.x,I.y-M.y)<1e-6||B[0]===0&&B[1]===0||k[0]===0&&k[1]===0)continue;let D=[(M.x-B[0]*x)*g,b.y,(M.y-B[1]*x)*g],U=[(I.x-k[0]*x)*g,b.y,(I.y-k[1]*x)*g],S=[(M.x+B[0]*w)*g,b.y,(M.y+B[1]*w)*g],_=[(I.x+k[0]*w)*g,b.y,(I.y+k[1]*w)*g];if(u(()=>{c&&f?Gn(t,c,f,[{x:M.x-B[0]*x,y:M.y-B[1]*x},{x:I.x-k[0]*x,y:I.y-k[1]*x},{x:I.x+k[0]*w,y:I.y+k[1]*w},{x:M.x+B[0]*w,y:M.y+B[1]*w}],b.y,o.tread):(t.tri(D,U,_,l,o.tread),t.tri(D,_,S,l,o.tread))}),b.y>A+On){let N=[D[0],A,D[2]],O=[U[0],A,U[2]],P=[-B[0],0,-B[1]];m(()=>{t.tri(D,U,O,P,o.riser),t.tri(D,O,N,P,o.riser)})}}}}function fo(t,n){let e=t.eventConfigurationIds;return!e?.length||!!n&&e.includes(n)}function Wn(t,n){return t.filter(e=>e.type!=="shape"||fo(e,n))}function Zn(t,n){let e=t.focalPoint??{x:0,y:0};return t.floors?.length?t.floors.map((r,o)=>({objects:Wn(r.objects,n),focal:{x:(r.focalPoint??e).x,y:(r.focalPoint??e).y},baseHeightM:r.baseHeightM??0,index:o})):[{objects:Wn(t.objects,n),focal:e,baseHeightM:0,index:0}]}var ho={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Mt(t){return Mn(t)??ho}function Kn(t,n){let e=jt(t.outline,ot),r=Mt(e),o=n.filter(i=>i!==t&&i.outline&&i.outline.length>=3&&Nt(r,Mt(i.outline)));if(!o.length)return[e];let a=i=>{let s=i.map(l=>[l.x,l.y]);return s.push(s[0]),s};try{let i=zn.difference([a(e)],...o.map(l=>[a(l.outline)])),s=[];for(let l of i){if(!l.length)continue;let c=l[0].map(([f,m])=>({x:f,y:m}));if(c.length>1){let f=c[0],m=c[c.length-1];Math.abs(f.x-m.x)<1e-9&&Math.abs(f.y-m.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s.length?s:[e]}catch{return[e]}}function $n(t,n){if(!n.length)return t;let e=a=>{let i=a.map(s=>[s.x,s.y]);return i.push(i[0]),i},r=n.map(a=>[e(a)]),o=[];for(let a of t){let i;try{i=zn.intersection([e(a.outline)],r.flat())}catch{o.push(a);continue}for(let s of i){if(!s.length)continue;let l=s[0].map(([c,f])=>({x:c,y:f}));if(l.length>1){let c=l[0],f=l[l.length-1];Math.abs(c.x-f.x)<1e-9&&Math.abs(c.y-f.y)<1e-9&&l.pop()}l.length>=3&&o.push({outline:l,holes:[],topY:a.topY})}}return o.length?o:t}function po(t,n){return t===void 0||n===void 0?!0:Math.abs(t-n)<.001}var zt=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(n,e){let r=n.map(l=>[l.x,l.y]);if(r.length<3)return[];r.push(r[0]);let o=Mt(n),a=this.rings.filter((l,c)=>Nt(o,this.boxes[c])&&po(e,this.levels[c])),i=[[r]];if(a.length)try{i=bo.difference([r],...a).map(c=>c.map(f=>f.map(([m,u])=>[m,u])))}catch{i=[[r]]}this.rings.push([r]),this.boxes.push(o),this.levels.push(e);let s=[];for(let l of i){if(!l.length)continue;let c=l[0].map(([f,m])=>({x:f,y:m}));if(c.length>1){let f=c[0],m=c[c.length-1];Math.abs(f.x-m.x)<1e-9&&Math.abs(f.y-m.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s}};function yo(t,n){if(!n)return t;let e=1/0,r=-1/0,o=1/0,a=-1/0;for(let m of t)e=Math.min(e,m.x),r=Math.max(r,m.x),o=Math.min(o,m.y),a=Math.max(a,m.y);let i=(e+r)/2,s=(o+a)/2,l=n*Math.PI/180,c=Math.cos(l),f=Math.sin(l);return t.map(m=>{let u=m.x-i,h=m.y-s;return{x:i+u*c-h*f,y:s+u*f+h*c}})}function bt(t){let n=null;if(t.kind==="polygon"&&t.points&&t.points.length>=3&&(n=t.points),t.kind==="rect"&&t.width&&t.height&&(n=Tt(t.x??0,t.y??0,t.width,t.height)),t.kind==="ellipse"&&t.width&&t.height){let e=(t.x??0)+t.width/2,r=(t.y??0)+t.height/2;n=Ht(e,r,t.width/2,t.height/2)}return n?yo(n,t.rotation):null}function Et(t){let n=t.role??"",e={stage:{kind:"stage",heightM:1},entrance:{kind:"portal",heightM:2.7},exit:{kind:"portal",heightM:2.7},screen:{kind:"solid",heightM:6},wall:{kind:"solid",heightM:2.8},rail:{kind:"solid",heightM:1.1},suite:{kind:"suite",heightM:3},obstruction:{kind:"solid",heightM:4.5},sound:{kind:"solid",heightM:1.45},restroom:{kind:"solid",heightM:2.4},bar:{kind:"solid",heightM:1.1},concession:{kind:"solid",heightM:1.1},coat:{kind:"solid",heightM:1.1},goal:{kind:"portal",heightM:1.8}},r=n==="stage"&&xn(t.stageKind)?{kind:"stage",heightM:.06}:e[n]??{kind:"plate",heightM:.25};return{...r,heightM:t.heightM??r.heightM}}var xo=.08;function qn(t,n){let e=bt(t),r=Et(t),o=r.heightM;if(!e||r.kind!=="plate"&&r.kind!=="stage")return o;let a=1/0,i=1/0,s=-1/0,l=-1/0;for(let f of e)a=Math.min(a,f.x),i=Math.min(i,f.y),s=Math.max(s,f.x),l=Math.max(l,f.y);let c=o;for(let f of n)s>f.minX&&a<f.maxX&&l>f.minY&&i<f.maxY&&c<=f.topOffsetM+1e-6&&(c=f.topOffsetM+xo);return n.push({minX:a,minY:i,maxX:s,maxY:l,topOffsetM:c}),c}function mt(t,n,e){return{x:t.x+(n.x-t.x)*e,y:t.y+(n.y-t.y)*e}}function Jn(t){if(t.length!==4)return t;let n=Math.hypot(t[1].x-t[0].x,t[1].y-t[0].y),e=Math.hypot(t[2].x-t[1].x,t[2].y-t[1].y);return n>=e?t:[t[1],t[2],t[3],t[0]]}function Ct(t,n,e){return[mt(t[0],t[1],n),mt(t[0],t[1],e),mt(t[3],t[2],e),mt(t[3],t[2],n)]}function Qn(t,n,e){return[mt(t[0],t[3],n),mt(t[1],t[2],n),mt(t[1],t[2],e),mt(t[0],t[3],e)]}function at(t,n,e,r,o,a){K(t,n,void 0,()=>e,r,o,a,W)}var an=2.4,go=.75,Mo=.15;function Ft(t){if(t.points&&t.points.length>=3)return t.points;let{center:n,width:e,height:r,rotation:o}=t;if(!e||!r)return null;let a=(o??0)*Math.PI/180,i=Math.cos(a),s=Math.sin(a),l=e/2,c=r/2;return[[-l,-c],[l,-c],[l,c],[-l,c]].map(([f,m])=>({x:n.x+f*i-m*s,y:n.y+f*s+m*i}))}function te(t,n,e,r,o){let a=Ft(n);a&&K(t,a,void 0,()=>e+an,e,st(r,o.boothTop),o.boothWall,W)}function cn(t){if(t.shape==="round"){let f=t.radius;return f?Ht(t.center.x,t.center.y,f,f,24):null}let{width:n,height:e,rotation:r,center:o}=t;if(!n||!e)return null;let a=(r??0)*Math.PI/180,i=Math.cos(a),s=Math.sin(a),l=n/2,c=e/2;return[[-l,-c],[l,-c],[l,c],[-l,c]].map(([f,m])=>({x:o.x+f*i-m*s,y:o.y+f*s+m*i}))}function ne(t,n,e,r,o){let a=cn(n);a&&K(t,a,void 0,()=>e+go,e,st(r,o.tableTop),o.tableWall,W)}function ee(t,n,e,r,o,a,i,s){let l=bt(n);if(!l)return;let c=s?s.kind==="stage":n.role==="stage",f=s?s.kind==="screen":n.role==="screen",m=s?{kind:c?"stage":"solid",heightM:s.topY-s.baseY}:Et(n),u=s?.baseY??e,h=s?.topY??e+r;if(c&&i){let x=1/0,w=-1/0,A=1/0,E=-1/0;for(let M of l)M.x<x&&(x=M.x),M.x>w&&(w=M.x),M.y<A&&(A=M.y),M.y>E&&(E=M.y);i.push({cx:(x+w)/2*g,cz:(A+E)/2*g,y:h,halfX:Math.max((w-x)/2*g,.5),halfZ:Math.max((E-A)/2*g,.5)})}let b=H(n.fill),p=c&&b?nt(o.stageTop,et(Pt(b,.18),.9),.9):st(b,c?o.stageTop:o.decorTop),d=f?b:null,y=c?b?nt(o.stageWall,et(b,.58),.82):o.stageWall:f?d?nt(et(d,1.42),[.24,.46,.82],.08):[.24,.46,.82]:st(H(n.fill),o.decorWall);if(m.kind==="portal"&&l.length===4){let x=Jn(l);at(t,Ct(x,0,.16),h,u,p,y),at(t,Ct(x,.84,1),h,u,p,y),at(t,x,h,Math.max(u,h-.35),p,y);return}if(m.kind==="suite"&&l.length===4){let x=l.map((E,M)=>{let I=l[(M+1)%4],B=(E.x+I.x)/2,k=(E.y+I.y)/2;return Math.hypot(B-a.x,k-a.y)}),w=x.indexOf(Math.min(...x)),A=[0,1,2,3].map(E=>l[(w+E)%4]);at(t,Ct(A,0,.08),h,u,p,y),at(t,Ct(A,.92,1),h,u,p,y),at(t,Qn(A,.88,1),h,u,p,y),at(t,A,h,Math.max(u,h-.18),p,y);return}at(t,l,h,u,p,y)}function un(t){let{x:n,y:e,width:r,height:o}=t;if(!r||!o)return null;let a=n+r/2,i=e+o/2,s=(t.rotation??0)*Math.PI/180,l=Math.cos(s),c=Math.sin(s),f=r/2,m=o/2;return[[-f,-m],[f,-m],[f,m],[-f,m]].map(([u,h])=>({x:a+u*l-h*c,y:i+u*c+h*l}))}function So(t){if(!t||!t.startsWith("data:image/svg+xml"))return null;let n=t.slice(t.indexOf(",")+1);if(/;base64/i.test(t.slice(0,t.indexOf(","))))try{n=atob(n)}catch{return null}else try{n=decodeURIComponent(n)}catch{}let e=n.match(/<(?:rect|path)\b[^>]*\bfill="([^"]+)"/i);if(!e)return null;let r=e[1].trim();if(r==="none"||r==="transparent")return null;let o=r.match(/^url\(#([^)]+)\)$/);if(!o)return H(r);let a=n.match(new RegExp(`<(?:linear|radial)Gradient\\b[^>]*\\bid="${o[1]}"[^>]*>([\\s\\S]*?)</(?:linear|radial)Gradient>`,"i"));if(!a)return null;let i=[];for(let s of a[1].matchAll(/stop-color="([^"]+)"/gi)){let l=H(s[1].trim());l&&i.push(l)}return i.length?i.reduce((s,l,c)=>nt(s,l,1/(c+1)),i[0]):null}function oe(t,n,e,r){if(n.layer==="foreground")return;let o=un(n);if(!o)return;let a=e+Mo,i=st(So(n.href),r.decorTop),s=Math.max(0,Math.min(1,n.opacity??1));s<1&&(i=nt(r.ground,i,s)),K(t,o,void 0,()=>a,e,i,nt(i,r.decorWall,.5),W)}function re(t,n,e,r,o){if(!n.points||n.points.length<3)return;let a=st(r,o.gaTop);K(t,n.points,n.holes,()=>e+.15,e,a,o.gaWall,W)}var Ro=6,Ao=2.2,ie=.1,Po=.3,Io=1.8,wo=.9,_o=.55,To=6e3;function se(t){let{doc:n,units:e,seats:r,surfaces:o,focal:a}=t,i=n.zones??[],s=[];if(i.length){let l=new Map;for(let f of e)for(let m of f.objects)m.type==="section"&&m.zone&&l.set(m.id,m.zone);let c=new Map;for(let f=0;f<r.length;f++){let m=r[f],u=o.seatOwner[f],h=m.zoneId??(u?l.get(u):void 0);if(!h)continue;let b=c.get(h);b||(b={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},c.set(h,b)),b.n++,m.x<b.minX&&(b.minX=m.x),m.y<b.minY&&(b.minY=m.y),m.x>b.maxX&&(b.maxX=m.x),m.y>b.maxY&&(b.maxY=m.y),b.sumY+=o.seatDeckY(f)}for(let f of i){let m=c.get(f.id),u=[];for(let[h,b]of l)b===f.id&&u.push(h);if(!m||m.n===0){s.push({id:f.id,label:f.label,color:H(f.color),sectionIds:u,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(f.focalPoint??a).x*g,1.5,(f.focalPoint??a).y*g]});continue}s.push({id:f.id,label:f.label,color:H(f.color),sectionIds:u,seatCount:m.n,center:[(m.minX+m.maxX)/2*g,m.sumY/m.n,(m.minY+m.maxY)/2*g],radius:.5*Math.hypot((m.maxX-m.minX)*g,(m.maxY-m.minY)*g)||1,focalWorld:[(f.focalPoint??a).x*g,1.5,(f.focalPoint??a).y*g]})}}return s}function ae(t){let{doc:n,units:e,seats:r,surfaces:o,seatData:a,hintedSeatFloor:i,zones:s,focal:l}=t,c=[],f=[],m=[];for(let u of s)u.seatCount!==0&&c.push({id:`zone:${u.id}`,kind:"zone",text:u.label,anchor:[u.center[0],u.center[1]+Ro,u.center[2]],color:n.zones?.find(h=>h.id===u.id)?.color});{let u=new Map,h=new Map;for(let b=0;b<r.length;b++){let p=o.seatOwner[b];if(!p)continue;let d=u.get(p);d||(d={n:0,x:0,y:0,deck:0},u.set(p,d)),d.n++,d.x+=r[b].x,d.y+=r[b].y,d.deck+=o.seatDeckY(b);let y=h.get(p);y||(y={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0},h.set(p,y)),r[b].x<y.minX&&(y.minX=r[b].x),r[b].x>y.maxX&&(y.maxX=r[b].x),r[b].y<y.minY&&(y.minY=r[b].y),r[b].y>y.maxY&&(y.maxY=r[b].y)}for(let b of e)for(let p of b.objects){if(p.type!=="section")continue;let d=u.get(p.id);if(!d||d.n===0)continue;let y=h.get(p.id),x=[d.x/d.n*g,d.deck/d.n,d.y/d.n*g],w=p.displayLabel||p.label||p.id;f.push({id:p.id,floorIndex:b.index,label:w,seatCount:d.n,center:x,radius:Math.max(1,Math.hypot(y.maxX-y.minX,y.maxY-y.minY)*.5*g),focalWorld:[b.focal.x*g,b.baseHeightM+1.5,b.focal.y*g]});let A=n.floors?.[b.index]?.name?.trim().toLocaleLowerCase();e.length>1&&A===w.trim().toLocaleLowerCase()||c.push({id:`section:${p.id}`,kind:"section",text:w,anchor:[x[0],x[1]+Ao,x[2]],floorIndex:b.index})}}{for(let p of e)for(let d of p.objects){if(d.type!=="gaArea")continue;let y=At(d.points);if(!y)continue;let x=d.displayLabel||d.label||d.id;c.push({id:`ga:${d.id}`,kind:"ga",text:d.capacity>0?`${x} \xB7 ${d.capacity.toLocaleString()}`:x,anchor:[y.x*g,p.baseHeightM+Io,y.y*g],floorIndex:p.index})}let u=new Map;for(let p of e)for(let d of p.objects)d.type==="section"&&u.set(d.id,d.displayLabel||d.label||d.id);let h=new Map;for(let p=0;p<r.length;p++){let d=r[p],y=Math.hypot(d.x-l.x,d.y-l.y),x=h.get(d.rowId);(!x||y>x.far)&&h.set(d.rowId,{seat:d,index:p,far:y})}for(let[p,d]of h){let y=Eo(d.seat.label,p,u.get(d.seat.sectionId??""));y&&c.push({id:`row:${p}`,kind:"row",text:y,anchor:[d.seat.x*g,o.seatDeckY(d.index)+wo,d.seat.y*g],floorIndex:i[d.index]})}let b=new Map;for(let p=0;p<r.length;p++){let d=r[p],y=d.label?d.label.lastIndexOf("-"):-1,x=b.get(d.rowId);x||(x={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:y>0?d.label.slice(0,y):d.rowId,sectionId:d.sectionId},b.set(d.rowId,x));let w=p*3,A=a.iPosition[w],E=a.iPosition[w+1],M=a.iPosition[w+2];x.n++,x.x+=A,x.y+=E,x.z+=M,x.minX=Math.min(x.minX,A),x.maxX=Math.max(x.maxX,A),x.minZ=Math.min(x.minZ,M),x.maxZ=Math.max(x.maxZ,M)}for(let[p,d]of b)m.push({id:p,label:d.label,sectionId:d.sectionId,seatCount:d.n,center:[d.x/d.n,d.y/d.n,d.z/d.n],radius:Math.max(.8,Math.hypot(d.maxX-d.minX,d.maxZ-d.minZ)*.5)});if(r.length<=To)for(let p=0;p<r.length;p++){let d=r[p],y=Bo(d.displayLabel||d.label);y&&c.push({id:`seat:${d.id}`,kind:"seat",text:y,anchor:[d.x*g,o.seatDeckY(p)+_o,d.y*g],floorIndex:i[p]})}}for(let u of e)for(let h of u.objects)if(h.type==="shape"&&h.role&&["entrance","exit","screen","suite","obstruction"].includes(h.role)){let b=bt(h),p=b?At(b):null;if(!p||!h.label)continue;c.push({id:`architecture:${h.id}`,kind:"annotation",text:h.label,anchor:[p.x*g,u.baseHeightM+Et(h).heightM+ie,p.y*g],color:h.fill,floorIndex:u.index})}else if(h.type==="text"){if(!h.text)continue;c.push({id:`text:${h.id}`,kind:"annotation",text:h.text,anchor:[h.position.x*g,u.baseHeightM+ie,h.position.y*g],color:h.color,rotation:h.rotation,floorIndex:u.index})}else if(h.type==="booth"){let b=Ft(h);if(!b)continue;let p=At(b);if(!p)continue;c.push({id:`booth:${h.id}`,kind:"booth",text:h.displayLabel||h.label||h.id,anchor:[p.x*g,u.baseHeightM+an+Po,p.y*g],floorIndex:u.index})}return{labels:c,sections:f,rows:m}}function ce(t,n){if(n.length>1)for(let e of n)t.push({id:`floor:${e.id}`,kind:"floor",text:e.label,anchor:[e.center[0],e.box.max[1]+1.2,e.center[2]],floorIndex:e.index})}function Bo(t){let n=t.lastIndexOf("-");return n>=0&&n<t.length-1?t.slice(n+1):t}function Eo(t,n,e){let r=t?t.lastIndexOf("-"):-1,o=r>0?t.slice(0,r):n;return o&&gn(o,e)}var Co=.15,Fo=.9,vo=1.76;function ko(){return{background:{top:[...nn.top],bottom:[...nn.bottom]},structure:tn,seatStates:{...Bn},seatScale:1,materials:{seat:null,shell:null,roughness:.78}}}function ue(t){let n=ko();if(!t)return n;let e=H(t.background);if(e){n.background={top:et(e,Fo),bottom:et(e,vo)};let i={};for(let[s,l]of Object.entries(tn))i[s]=nt(l,e,Co);n.structure=i}let r=H(t.selectionColor)??H(t.accent);r&&(n.seatStates={...n.seatStates,selected:r});let o=t.seatScale;typeof o=="number"&&Number.isFinite(o)&&(n.seatScale=An(o));let a=t.venue3d;if(a){let i=H(a.deck),s=H(a.fascia);i&&(n.structure={...n.structure,tierTop:i,gaTop:i}),s&&(n.structure={...n.structure,tierWall:s,gaWall:s}),n.materials.seat=H(a.seat),n.materials.shell=H(a.shell),typeof a.roughness=="number"&&Number.isFinite(a.roughness)&&(n.materials.roughness=Math.min(1,Math.max(0,a.roughness)))}return n}function le(t,n){let e=[];for(let r of n)e.push(...t.seatStates[r]);return e}var Oo=.05,me=.05,Lo=.15,ln=25;function fe(t,n,e){let r=new Map,o=new Array(n.length).fill(null),a=new Float64Array(n.length),i=new Array(n.length).fill(void 0),s=new Array(n.length).fill(void 0),l=new Map,c=[],f=new Set;for(let u=0;u<t.length;u+=1){let h=t[u];for(let b of h.objects){if(b.type==="table"&&f.add(b.id),b.type!=="section"||!b.outline||b.outline.length<3)continue;let p=jt(b.outline,ot);l.set(b.id,{section:b,unit:h,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),c.push({id:b.id,floorIndex:u,box:Mt(p),section:b,unit:h,outline:p})}}let m=new Map;for(let u of c){let h=m.get(u.floorIndex);h?h.push(u):m.set(u.floorIndex,[u])}for(let u=0;u<n.length;u++){let h=n[u],b=e?m.get(e[u])??[]:c,p=h.sectionId?b.find(y=>y.id===h.sectionId)??b.find(y=>y.section.logicalSectionId===h.sectionId&&qt({x:h.x,y:h.y},y.outline,y.section.holes)):void 0,d=p?[p]:b;for(let y of d){if(e&&y.floorIndex!==e[u]||!p&&(h.x<y.box.minX||h.x>y.box.maxX||h.y<y.box.minY||h.y>y.box.maxY||!qt({x:h.x,y:h.y},y.outline,y.section.holes)))continue;o[u]=y.id;let x=l.get(y.id);x.hasSeats=!0;let w=h.focalPoint??y.unit.focal,A=Math.hypot(h.x-w.x,h.y-w.y);A<x.frontU&&(x.frontU=A),x.seatIndices.push(u);let E=h.rowId||`__seat-${u}`,M=x.rows.get(E);M?M.push({x:h.x,y:h.y}):x.rows.set(E,[{x:h.x,y:h.y}]);break}}for(let[u,h]of l){let b=dn(h.section,{floorBaseHeightM:h.unit.baseHeightM}),p=h.unit.baseHeightM,d=b.rake>0?Math.tan(b.rake*Math.PI/180):0,y=b.rake<=.01&&b.height<=p+.001,x=h.section.surfaceKind,w=x==="flat"?!0:x==="rakedRows"&&b.rake>.01?!1:y,A=h.hasSeats?yn(u,n,h.seatIndices,h.unit.focal):{sectionId:u,rows:[],blockCount:0},M=A.rows.length<2?Pn([...h.rows.values()].map(R=>({points:R})),h.unit.focal):null,I=1/0;if(M){if(h.hasSeats)for(let R of h.rows.values())for(let T of R){let C=M.depthAt(T.x,T.y);C<I&&(I=C)}if(!h.hasSeats||!Number.isFinite(I)){I=1/0;for(let R of h.section.outline){let T=M.depthAt(R.x,R.y);T<I&&(I=T)}}}let B=p+Oo,k=Math.max(B,b.height),D=R=>{let T=Math.max(0,R-I)*ut,C=Math.min(T*d,ln);return Math.max(B,b.height+C)},U=R=>{let T=Math.max(0,R)*ut,C=Math.min(T*d,ln);return Math.max(B,b.height+C)},S=w?[]:A.rows.map(R=>({pts:R.pts,y:U(R.blockDepth),depth:R.blockDepth,blockId:R.blockId,...f.has(R.id)?{patch:Nn(R.pts,ot)}:{}})),_=S.length?S[0].y:k,N=S.map(R=>{let T=R.patch&&R.patch.length>=3?R.patch:R.pts,C=0,v=0;for(let L of T)C+=L.x,v+=L.y;let G=T.length||1;C/=G,v/=G;let X=0;for(let L of T){let Y=Math.hypot(L.x-C,L.y-v);Y>X&&(X=Y)}return{cx:C,cy:v,rad:X}}),O=w?()=>k:S.length>=2?(R,T)=>{let C=1/0,v=_;for(let G=0;G<S.length;G++){let X=N[G];if(Math.hypot(R-X.cx,T-X.cy)-X.rad>=C)continue;let L=S[G].patch,Y=L&&L.length>=3?It(L,R,T)?0:Dt(L,R,T):Dt(S[G].pts,R,T);Y<C&&(C=Y,v=S[G].y)}return v}:(R,T)=>M?D(M.depthAt(R,T)):k,P=[0,1,0],F=S.length>=2||w?()=>P:(R,T)=>{if(!M)return P;let C=M.depthAt(R,T);if(C<=I)return P;let v=(C-I)*ut;if(v*d>=ln||b.height+v*d<=B)return P;let[G,X]=M.gradientAt(R,T);if(G===0&&X===0)return P;let L=1/Math.hypot(d,1);return[-G*d*L,L,-X*d*L]};if(!w)for(let R of A.rows){let T=U(R.blockDepth);for(let C of R.seatIndices)i[C]=T}for(let R of A.rows){let T=[];for(let L=1;L<R.pts.length;L++){let Y=Math.hypot(R.pts[L].x-R.pts[L-1].x,R.pts[L].y-R.pts[L-1].y);Y>1e-6&&T.push(Y)}T.sort((L,Y)=>L-Y);let C=T.length?T[Math.floor(T.length/2)]:1/0,v=1/0,G=R.pts[Math.floor(R.pts.length/2)];if(G)for(let L of A.rows){if(L===R||L.blockId!==R.blockId)continue;let Y=Dt(L.pts,G.x,G.y);Y>1e-6&&Y<v&&(v=Y)}let X=Math.min(C,Math.max(v,C*.5));if(Number.isFinite(X)&&X>0)for(let L of R.seatIndices)s[L]=X}r.set(u,{sectionId:u,deckAt:O,normalAt:F,flat:w,bottomY:p,rowLevels:S,landingY:_})}for(let u=0;u<n.length;u++){let h=o[u],b=n[u];if(h){let d=i[u];a[u]=(d??r.get(h).deckAt(b.x,b.y))+Lo;continue}let p=b.eyeHeightM;a[u]=Number.isFinite(p)?Math.max(0,p-Gt):0}return{bySection:r,seatOwner:o,seatDeckY:u=>a[u],seatPitchU:u=>s[u]}}var Go=.25,Do=1.2,No=.6,Xo=.45,Uo=2.3,Yo=Math.PI/180;function pt(t,n,e){let r=e*Yo;return{x:t.x+n*Math.sin(r),y:t.y+n*Math.cos(r)}}function jo(t,n){let e=n.rings[n.rings.length-1];if(!e)return!1;let r=e.outerRMedian*.85;for(let o of t){if(o.role!=="wall")continue;let a=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(a.length<2)continue;let i=0;for(let s of a)Math.hypot(s.x-n.centre.x,s.y-n.centre.y)>=r&&i++;if(i>=a.length/2)return!0}return!1}var Ho=24;function Vo(t,n,e,r,o,a,i,s){let l=e.binCount,c=Ho,f=ut,m=a+.02,u=[];for(let S=0;S<l;S++){let _=(e.startBin+S+.5)*n.binStepDeg,N=new Float64Array(c+1);for(let O=0;O<=c;O++){let P=r[S]+(o[S]-r[S])*O/c;N[O]=Math.max(m,wn(n,e,_,P)-Go)}u.push(N)}let h=[i.bandTop[0]*s.top,i.bandTop[1]*s.top,i.bandTop[2]*s.top],b=[i.bandTop[0]*s.bottomCap,i.bandTop[1]*s.bottomCap,i.bandTop[2]*s.bottomCap],p=[i.bandWall[0]*s.top,i.bandWall[1]*s.top,i.bandWall[2]*s.top],d=[i.bandWall[0]*s.wallBottom,i.bandWall[1]*s.wallBottom,i.bandWall[2]*s.wallBottom],y=(S,_)=>{let N=(e.startBin+S+.5)*n.binStepDeg,O=r[S]+(o[S]-r[S])*_/c,P=pt(n.centre,O,N);return[P.x*f,u[S][_],P.y*f]};{let S=Math.tan(12*Math.PI/180);for(let _=0;_<6;_++){let N=!1;for(let P=0;P<l;P++)for(let F=c-1;F>=0;F--)u[P][F]>u[P][F+1]&&(u[P][F]=u[P][F+1],N=!0);let O=e.closed?l:l-1;for(let P=0;P<O;P++){let F=(P+1)%l;for(let R=0;R<=c;R++){let T=u[F][R]-u[P][R];if(Math.abs(T)>1)continue;let C=r[P]+(o[P]-r[P])*R/c,v=r[F]+(o[F]-r[F])*R/c,G=pt(n.centre,C,(e.startBin+P+.5)*n.binStepDeg),X=pt(n.centre,v,(e.startBin+F+.5)*n.binStepDeg),L=S*Math.hypot(X.x-G.x,X.y-G.y)*f;T>L?(u[F][R]=u[P][R]+L,N=!0):-T>L&&(u[P][R]=u[F][R]+L,N=!0)}}if(!N)break}}let x=1,w=(S,_)=>{for(let N=0;N<=c;N+=4)if(Math.abs(u[S][N]-u[_][N])>x)return!0;return Math.abs(u[S][c]-u[_][c])>x},A=Math.tan(38*Math.PI/180),E=S=>(o[S]-r[S])/c*f,M=(S,_)=>u[S][_+1]-u[S][_]>A*Math.max(1e-6,E(S)),I=(S,_)=>{let N=e.closed?(S-1+l)%l:Math.max(0,S-1),O=e.closed?(S+1)%l:Math.min(l-1,S+1);Math.abs(u[N][_]-u[S][_])>x&&(N=S),Math.abs(u[O][_]-u[S][_])>x&&(O=S);let P=Math.max(0,_-1),F=Math.min(c,_+1);P<_&&M(S,P)&&(P=_),F>_&&M(S,_)&&(F=_);let R=y(N,_),T=y(O,_),C=y(S,P),v=y(S,F),G=T[0]-R[0],X=T[1]-R[1],L=T[2]-R[2],Y=v[0]-C[0],j=v[1]-C[1],$=v[2]-C[2],z=X*$-L*j,q=L*Y-G*$,tt=G*j-X*Y,Z=Math.hypot(z,q,tt);return Z>1e-12?(z/=Z,q/=Z,tt/=Z,q<0&&(z=-z,q=-q,tt=-tt),[z,q,tt]):[0,1,0]},B=(S,_)=>{let N=[S[0],a,S[2]],O=[_[0],a,_[2]],P=_[0]-S[0],F=_[2]-S[2],R=Math.hypot(P,F);if(!(R>1e-12))return;let T=[F/R,0,-P/R];t.tri(S,_,O,T,p,p,d),t.tri(S,O,N,T,p,d,d)},k=.05*lt,D=S=>o[S]-r[S]<k,U=e.closed?l:l-1;for(let S=0;S<U;S++){let _=(S+1)%l;if(D(S)||D(_))continue;if(w(S,_)){let T=(e.startBin+S+1)*n.binStepDeg,C=(j,$)=>{let z=(r[S]+r[_])/2,q=(o[S]+o[_])/2,tt=z+(q-z)*$/c,Z=pt(n.centre,tt,T);return[Z.x*f,u[j][$],Z.y*f]};for(let j=0;j<c;j++){let $=y(S,j),z=y(S,j+1),q=C(S,j),tt=C(S,j+1),Z=I(S,j),it=I(S,j+1);t.triN($,q,tt,Z,Z,it,h),t.triN($,tt,z,Z,it,it,h);let vt=y(_,j),kt=y(_,j+1),dt=C(_,j),St=C(_,j+1),yt=I(_,j),xt=I(_,j+1);t.triN(dt,vt,kt,yt,yt,xt,h),t.triN(dt,kt,St,yt,xt,xt,h);let ct=C(S,j),rt=C(S,j+1),Ot=C(_,j+1),Kt=C(_,j),Lt=rt[0]-ct[0],Rt=rt[2]-ct[2],$t=Math.hypot(Lt,Rt);if($t>1e-12){let fn=[Rt/$t,0,-Lt/$t];t.tri(ct,rt,Ot,fn,p),t.tri(ct,Ot,Kt,fn,p)}}let v=y(S,0),G=y(_,0),X=y(_,c),L=y(S,c),Y=j=>[j[0],a,j[2]];t.tri(Y(v),Y(X),Y(G),[0,-1,0],b),t.tri(Y(v),Y(L),Y(X),[0,-1,0],b),B(v,G),B(L,X);continue}for(let T=0;T<c;T++){let C=I(S,T),v=I(_,T),G=I(_,T+1),X=I(S,T+1);if(M(S,T)||M(_,T)){let z=(rt,Ot)=>{let Kt=(e.startBin+rt+.5)*n.binStepDeg,Lt=r[rt]+(o[rt]-r[rt])*(T+.5)/c,Rt=pt(n.centre,Lt,Kt);return[Rt.x*f,Ot,Rt.y*f]},q=y(S,T),tt=y(_,T),Z=z(S,u[S][T]),it=z(_,u[_][T]);t.triN(q,tt,it,C,v,v,h),t.triN(q,it,Z,C,v,C,h);let vt=y(_,T+1),kt=y(S,T+1),dt=z(S,u[S][T+1]),St=z(_,u[_][T+1]);t.triN(dt,St,vt,X,G,G,h),t.triN(dt,vt,kt,X,G,X,h);let yt=it[0]-Z[0],xt=it[2]-Z[2],ct=Math.hypot(yt,xt);if(ct>1e-12){let rt=[-xt/ct,0,yt/ct];t.tri(Z,it,St,rt,p),t.tri(Z,St,dt,rt,p)}continue}let L=y(S,T),Y=y(_,T),j=y(_,T+1),$=y(S,T+1);t.triN(L,Y,j,C,v,G,h),t.triN(L,j,$,C,G,X,h)}let N=y(S,0),O=y(_,0),P=y(_,c),F=y(S,c),R=T=>[T[0],a,T[2]];t.tri(R(N),R(P),R(O),[0,-1,0],b),t.tri(R(N),R(F),R(P),[0,-1,0],b),B(N,O),B(F,P)}if(!e.closed)for(let S of[0,l-1])for(let _=0;_<c;_++)B(y(S,_),y(S,_+1))}function he(t,n,e){let{bottomY:r,colors:o,ao:a}=e,i=new Float64Array(n.binCount).fill(-1/0);for(let f of n.rings)for(let m of f.arcs){let u=new Float64Array(m.binCount),h=new Float64Array(m.binCount);for(let p=0;p<m.binCount;p++){let d=(m.startBin+p)%n.binCount,y=Math.max(0,m.innerR[p]-ot);u[p]=Math.max(y,i[d]+.001),h[p]=Math.max(u[p]+.001,m.outerR[p]+ot)}let b=0;for(let p=0;p<m.binCount;p++){let d=m.topLevelM[p]-r;d>b&&(b=d)}b>=Do&&Vo(t,n,m,u,h,r,o,a);for(let p=0;p<m.binCount;p++){let d=(m.startBin+p)%n.binCount;h[p]>i[d]&&(i[d]=h[p])}}if(e.deriveShell===!1||jo(e.shapes,n))return;let s=n.rings[n.rings.length-1],l=No*lt,c=Xo*lt;for(let f of s.arcs){let m=[],u=[];for(let p=0;p<f.binCount;p++){let d=(f.startBin+p+.5)*n.binStepDeg,y=f.outerR[p]+ot+l;m.push(pt(n.centre,y,d)),u.push(pt(n.centre,y+c,d))}let h=-1/0;for(let p=0;p<f.binCount;p++)f.topLevelM[p]>h&&(h=f.topLevelM[p]);let b=()=>h+Uo;f.closed?K(t,u,[m.slice().reverse()],b,r,o.shellTop,o.shellWall,a):K(t,[...u,...m.slice().reverse()],void 0,b,r,o.shellTop,o.shellWall,a)}}function be(t,n,e,r,o,a,i,s){if(!n.outline||n.outline.length<3)return;let l=e.baseHeightM,c=st(r,s.tierTop);if(!o)return;let f=d=>o.deckAt(d.x,d.y),m=Kn(n,i),u=m[0]??n.outline;if(o.rowLevels.length>=2){let d=Wt(o.rowLevels),y=$n(jn(o.rowLevels,e.focal,d),m),x=()=>[0,1,0];for(let A of y){let E=Math.max(l,A.topY-.02);for(let M of a.subtract(A.outline,E))K(t,M,A.holes,()=>E,l,c,s.tierWall,W,void 0,x)}y.length||K(t,u,n.holes,()=>o.landingY,l,c,s.tierWall,W);let w={tread:[c[0]*W.top,c[1]*W.top,c[2]*W.top],riser:[c[0]*.72,c[1]*.72,c[2]*.72]};for(let A of m.length?m:[u])Vn(t,o.rowLevels,e.focal,o.landingY,w,A,d);return}let h=o.flat?1/0:me,b=d=>o.normalAt(d.x,d.y),p=o.flat?o.landingY:void 0;for(let d of a.subtract(u,p))K(t,d,n.holes,f,l,c,s.tierWall,W,h,b)}function Wo(t,n,e){let r=new Set;for(let i of t.objects)i.type==="section"&&r.add(i.id);let o=new Map;for(let i=0;i<n.length;i++){let s=e.seatOwner[i];if(!s||!r.has(s))continue;let l=e.bySection.get(s);if(l&&l.rowLevels.length>=2)continue;let c=n[i],f=o.get(s);f||(f=new Map,o.set(s,f));let m=c.rowId||`__seat-${i}`,u=f.get(m);u||(u={pts:[],levelM:0,n:0},f.set(m,u)),u.pts.push({x:c.x,y:c.y}),u.levelM+=e.seatDeckY(i),u.n++}let a=[];for(let i of t.objects){if(i.type!=="section")continue;let s=e.bySection.get(i.id);if(s&&s.rowLevels.length>=2){let c=s.rowLevels.filter(f=>!f.patch).map(f=>({pts:f.pts,levelM:f.y}));c.length>=2&&a.push({sectionId:i.id,rows:c});continue}let l=o.get(i.id);l&&a.push({sectionId:i.id,rows:[...l.values()].map(c=>({pts:c.pts,levelM:c.levelM/c.n}))})}return a}function pe(t,n,e,r,o,a,i=!0){let s=Wo(n,e,r);if(!s.length)return;let l=In(s,n.focal);l&&(t.setMaterial(0),he(t,l,{bottomY:n.baseHeightM,colors:{bandTop:et(o.tierTop,.8),bandWall:o.tierWall,shellTop:a??et(o.tierWall,1.15),shellWall:a??o.tierWall},ao:W,shapes:n.objects.filter(c=>c.type==="shape"),deriveShell:i}))}function de(t){let{doc:n,units:e,seats:r,surfaces:o,solids:a,hintedSeatFloor:i,seatFloor:s}=t,l=[];{let c=e.map(()=>({minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}));for(let u=0;u<a.floor.length;u+=1){let h=Math.max(0,Math.min(e.length-1,Math.round(a.floor[u]))),b=u*3,p=c[h];p.minX=Math.min(p.minX,a.position[b]),p.minY=Math.min(p.minY,a.position[b+1]),p.minZ=Math.min(p.minZ,a.position[b+2]),p.maxX=Math.max(p.maxX,a.position[b]),p.maxY=Math.max(p.maxY,a.position[b+1]),p.maxZ=Math.max(p.maxZ,a.position[b+2])}let f=new Map;for(let u=0;u<e.length;u++)for(let h of e[u].objects)h.type==="section"&&f.set(h.id,u);let m=e.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 u=0;u<r.length;u++){let h=o.seatOwner[u],b=(h!==null?f.get(h):void 0)??i[u];if(b===void 0)continue;let p=m[b],d=r[u];p.n++,d.x<p.minX&&(p.minX=d.x),d.y<p.minY&&(p.minY=d.y),d.x>p.maxX&&(p.maxX=d.x),d.y>p.maxY&&(p.maxY=d.y);let y=o.seatDeckY(u);p.sumX+=d.x*g,p.sumDeck+=y,p.sumZ+=d.y*g,p.minDeck=Math.min(p.minDeck,y),p.maxDeck=Math.max(p.maxDeck,y+1.6),s[u]=b}for(let u=0;u<e.length;u++){let h=m[u],b=n.floors?.[u],p=c[u],d=Math.min(h.n?h.minX*g:e[u].focal.x*g-1,Number.isFinite(p.minX)?p.minX:1/0),y=Math.max(h.n?h.maxX*g:e[u].focal.x*g+1,Number.isFinite(p.maxX)?p.maxX:-1/0),x=Math.min(h.n?h.minY*g:e[u].focal.y*g-1,Number.isFinite(p.minZ)?p.minZ:1/0),w=Math.max(h.n?h.maxY*g:e[u].focal.y*g+1,Number.isFinite(p.maxZ)?p.maxZ:-1/0),A=Math.min(h.n?Math.min(e[u].baseHeightM,h.minDeck):e[u].baseHeightM,Number.isFinite(p.minY)?p.minY:1/0),E=Math.max(h.n?Math.max(h.maxDeck,A+.5):A+.5,Number.isFinite(p.maxY)?p.maxY:-1/0),M=[h.n?h.sumX/h.n:(d+y)/2,h.n?h.sumDeck/h.n:(A+E)/2,h.n?h.sumZ/h.n:(x+w)/2],I=Math.max(1,.5*Math.hypot(y-d,E-A,w-x));l.push({index:u,id:b?.id??`floor-${u}`,label:b?.name??(e.length>1?`Floor ${u+1}`:"Venue"),seatCount:h.n,center:M,radius:I,box:{min:[d,A,x],max:[y,E,w]},focalWorld:[e[u].focal.x*g,e[u].baseHeightM+1.5,e[u].focal.y*g]})}}return l}function mn(t,n){let e=1/0,r=1/0,o=-1/0,a=-1/0,i=(s,l)=>{s<e&&(e=s),l<r&&(r=l),s>o&&(o=s),l>a&&(a=l)};for(let s of n)i(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)i(c.x,c.y);else if(l.type==="shape"&&l.points)for(let c of l.points)i(c.x,c.y);else if(l.type==="gaArea")for(let c of l.points)i(c.x,c.y);else if(l.type==="booth"){let c=Ft(l);if(c)for(let f of c)i(f.x,f.y)}else if(l.type==="table"){let c=cn(l);if(c)for(let f of c)i(f.x,f.y)}else if(l.type==="decorImage"){let c=un(l);if(c)for(let f of c)i(f.x,f.y)}return Number.isFinite(e)||(e=-100,r=-100,o=100,a=100),{minX:e,minY:r,maxX:o,maxY:a}}function ye(t,n,e,r,o,a){if(n.length===1){let i=Math.max(60,(o.maxX-o.minX+o.maxY-o.minY)*.06),s=Tt(o.minX-i,o.minY-i,o.maxX-o.minX+i*2,o.maxY-o.minY+i*2);K(t,s,void 0,()=>0,-.4,a.ground,a.ground,W)}else{let i=n.reduce((h,b)=>b.baseHeightM<h.baseHeightM?b:h);t.setFloor(i.index);let s=e.filter((h,b)=>r[b]===i.index),l=mn([i],s),c=Math.hypot(l.maxX-l.minX,l.maxY-l.minY),f=Math.max(28,Math.min(80,c*.04)),m=Tt(l.minX-f,l.minY-f,l.maxX-l.minX+f*2,l.maxY-l.minY+f*2),u=i.baseHeightM-.03;K(t,m,void 0,()=>u,u-.22,a.ground,a.ground,W)}}function xe(t,n,e){let{cx:r,cz:o,radius:a}=e,i=1/0,s=1/0,l=1/0,c=-1/0,f=-1/0,m=-1/0,u=(p,d,y)=>{i=Math.min(i,p),c=Math.max(c,p),s=Math.min(s,d),f=Math.max(f,d),l=Math.min(l,y),m=Math.max(m,y)};for(let p=0;p<t.position.length;p+=3)u(t.position[p],t.position[p+1],t.position[p+2]);for(let p=0;p<n.count;p++){let d=p*3,y=n.iPosition[d],x=n.iPosition[d+1],w=n.iPosition[d+2],A=Math.max(.35,n.iMaxRadius[p]??.35);u(y-A,x,w-A),u(y+A,x+1.6,w+A)}Number.isFinite(i)||(i=r-a,c=r+a,s=0,f=a*.16,l=o-a,m=o+a);let h=[(i+c)/2,(s+f)/2,(l+m)/2],b=Math.max(1,.5*Math.hypot(c-i,f-s,m-l));return{center:h,radius:b,minY:s,maxY:f}}function ge(t,n,e,r,o,a){let i=1/0,s=1/0,l=-1/0,c=-1/0;for(let A=0;A<t.count;A++){let E=A*3,M=t.iPosition[E],I=t.iPosition[E+2];M<i&&(i=M),M>l&&(l=M),I<s&&(s=I),I>c&&(c=I)}for(let A of n)i=Math.min(i,A.cx-A.halfX),l=Math.max(l,A.cx+A.halfX),s=Math.min(s,A.cz-A.halfZ),c=Math.max(c,A.cz+A.halfZ);let f=e.minX*g,m=e.maxX*g,u=e.minY*g,h=e.maxY*g,b=f,p=m,d=u,y=h;if(Number.isFinite(i)){let A=Math.max(2,.06*Math.hypot(l-i,c-s));b=Math.max(f,i-A),p=Math.min(m,l+A),d=Math.max(u,s-A),y=Math.min(h,c+A)}let x=Math.min(0,r),w=Math.max(o,a*.05);return{min:[b,x,d],max:[p,w,y]}}function Me(t,n,e){let r=()=>({byObjectId:new Map,elements:[]});if(!n||!t)return r();let o=bn(n);if(!o.ok||o.value.id!==t)return r();let a=new Map;for(let m of e)for(let u of m.objects)u.type==="shape"&&a.set(u.id,{shape:u,unit:m});let i=new Set,s=new Set,l=new Map((n.overlay.productionElements??[]).map(m=>{let u=m.runtimeContentImageUrl;return[m.id,typeof u=="string"&&/^(?:blob:|data:image\/|https:\/\/)/.test(u)?u:void 0]})),c=[];for(let m of o.value.overlay.productionElements??[]){let u=a.get(m.objectId),h=u?bt(u.shape):null,b=m.baseElevationM??0;if(!u||!h||h.length<3||!m.id||i.has(m.id)||s.has(m.objectId)||!Number.isFinite(m.heightM)||m.heightM<.05||m.heightM>50||!Number.isFinite(b)||b<-10||b>100)return r();i.add(m.id),s.add(m.objectId);let p=h.map(B=>B.x*g),d=h.map(B=>B.y*g),y=u.unit.baseHeightM+b,x=Math.min(...p),w=Math.max(...p),A=Math.min(...d),E=Math.max(...d),M,I=l.get(m.id)??m.contentImageUrl;if(m.kind==="screen"&&I)if(w-x>=E-A){let B=Math.abs(A-u.unit.focal.y*g)<=Math.abs(E-u.unit.focal.y*g)?A-.006:E+.006;M=[[x,y,B],[w,y,B],[x,y+m.heightM,B],[w,y+m.heightM,B]]}else{let B=Math.abs(x-u.unit.focal.x*g)<=Math.abs(w-u.unit.focal.x*g)?x-.006:w+.006;M=[[B,y,A],[B,y,E],[B,y+m.heightM,A],[B,y+m.heightM,E]]}c.push({id:m.id,objectId:m.objectId,kind:m.kind,floorIndex:u.unit.index,baseY:y,topY:y+m.heightM,bounds:{min:[x,y,A],max:[w,y+m.heightM,E]},occlusion:m.occlusion,...I?{contentImageUrl:I}:{},...M?{contentPlane:M}:{}})}let f=c.sort((m,u)=>m.id.localeCompare(u.id));return{byObjectId:new Map(f.map(m=>[m.objectId,m])),elements:f}}function Q(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function J(t){return Array.isArray(t)?t:[]}function zo(t){let n=[t];for(;n.length;){let e=n.pop();if(Array.isArray(e)){n.push(...e);continue}if(!Q(e))continue;let r=Q(e.extensions)?e.extensions:null;if(r&&Object.prototype.hasOwnProperty.call(r,"KHR_draco_mesh_compression"))return!0;n.push(...Object.values(e))}return!1}function Zt(t,n){return!Array.isArray(t)||t.length!==n||!t.every(e=>typeof e=="number"&&Number.isFinite(e))?null:t}function Zo(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Ko(t,n){let e=new Array(16).fill(0);for(let r=0;r<4;r++)for(let o=0;o<4;o++)for(let a=0;a<4;a++)e[r*4+o]+=t[a*4+o]*n[r*4+a];return e}function $o(t){let n=Zt(t.matrix,16);if(n)return n;if(t.matrix!==void 0)return null;let e=t.translation===void 0?[0,0,0]:Zt(t.translation,3),r=t.rotation===void 0?[0,0,0,1]:Zt(t.rotation,4),o=t.scale===void 0?[1,1,1]:Zt(t.scale,3);if(!e||!r||!o)return null;let[a,i,s,l]=r,c=Math.hypot(a,i,s,l);if(!(c>1e-8))return null;let f=a/c,m=i/c,u=s/c,h=l/c,b=f+f,p=m+m,d=u+u,y=f*b,x=f*p,w=f*d,A=m*p,E=m*d,M=u*d,I=h*b,B=h*p,k=h*d;return[(1-(A+M))*o[0],(x+k)*o[0],(w-B)*o[0],0,(x-k)*o[1],(1-(y+M))*o[1],(E+I)*o[1],0,(w+B)*o[2],(E-I)*o[2],(1-(y+A))*o[2],0,e[0],e[1],e[2],1]}function qo(t,n,e,r){return[t[0]*n+t[4]*e+t[8]*r+t[12],t[1]*n+t[5]*e+t[9]*r+t[13],t[2]*n+t[6]*e+t[10]*r+t[14]]}function Jo(t){let n=t[0],e=t[4],r=t[8],o=t[1],a=t[5],i=t[9],s=t[2],l=t[6],c=t[10],f=a*c-i*l,m=i*s-o*c,u=o*l-a*s,h=n*f+e*m+r*u;if(Math.abs(h)<1e-12)return null;let b=1/h;return[f*b,m*b,u*b,(r*l-e*c)*b,(n*c-r*s)*b,(e*s-n*l)*b,(e*i-r*a)*b,(r*o-n*i)*b,(n*a-e*o)*b]}function Se(t,n,e,r){let o=t[0]*n+t[1]*e+t[2]*r,a=t[3]*n+t[4]*e+t[5]*r,i=t[6]*n+t[7]*e+t[8]*r,s=Math.hypot(o,a,i)||1;return o/=s,a/=s,i/=s,[o,a,i]}function Qo(t){if(t.byteLength<20||t.byteLength>8388608)return null;let n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0,!0)!==1179937895||n.getUint32(4,!0)!==2||n.getUint32(8,!0)!==t.byteLength)return null;let e=12,r=null,o=null;for(;e+8<=t.byteLength;){let a=n.getUint32(e,!0),i=n.getUint32(e+4,!0);if(e+=8,a%4!==0||e+a>t.byteLength)return null;let s=t.subarray(e,e+a);if(i===1313821514&&!r)try{let l=JSON.parse(new TextDecoder().decode(s).replace(/[\u0000 ]+$/g,""));if(!Q(l))return null;r=l}catch{return null}else if(i===5130562&&!o)o=s;else return null;e+=a}return e===t.byteLength&&r&&o?{json:r,bin:o}:null}function tr(t){return t===5120||t===5121?1:t===5122||t===5123?2:t===5125||t===5126?4:0}function nr(t){return t==="SCALAR"?1:t==="VEC2"?2:t==="VEC3"?3:t==="VEC4"?4:0}function er(t,n,e){return e===5120?t.getInt8(n):e===5121?t.getUint8(n):e===5122?t.getInt16(n,!0):e===5123?t.getUint16(n,!0):e===5125?t.getUint32(n,!0):t.getFloat32(n,!0)}function or(t){let n=t instanceof Uint8Array?t:new Uint8Array(t),e=Qo(n);if(!e)return{ok:!1,issue:"invalid_glb"};let{json:r,bin:o}=e;if(!Q(r.asset)||r.asset.version!=="2.0")return{ok:!1,issue:"unsupported_glb"};let a=J(r.extensionsUsed).filter(A=>typeof A=="string");if(a.includes("KHR_draco_mesh_compression")||zo(r))return{ok:!1,issue:"draco_not_allowed"};if(a.length||J(r.extensionsRequired).length)return{ok:!1,issue:"unsupported_glb"};if(J(r.images).length||J(r.textures).length)return{ok:!1,issue:"external_resource"};let i=J(r.buffers);if(i.length!==1||!Q(i[0])||i[0].uri!==void 0||typeof i[0].byteLength!="number"||!Number.isInteger(i[0].byteLength)||i[0].byteLength<0||i[0].byteLength>o.byteLength)return{ok:!1,issue:"external_resource"};let s=J(r.accessors),l=J(r.bufferViews),c=J(r.meshes),f=J(r.nodes),m=J(r.scenes),u=typeof r.scene=="number"?r.scene:0;if(!Q(m[u]))return{ok:!1,issue:"unsupported_glb"};let h=new DataView(o.buffer,o.byteOffset,o.byteLength),b=(A,E,M)=>{if(typeof A!="number"||!Number.isInteger(A)||!Q(s[A]))return null;let I=s[A];if(I.type!==E||I.sparse!==void 0||I.normalized===!0||typeof I.count!="number"||!Number.isInteger(I.count)||I.count<1||typeof I.componentType!="number"||!M.includes(I.componentType)||typeof I.bufferView!="number")return null;let B=l[I.bufferView];if(!Q(B)||B.buffer!==0||typeof B.byteLength!="number"||!Number.isInteger(B.byteLength)||B.byteLength<0)return null;let k=nr(I.type),D=tr(I.componentType),U=typeof B.byteStride=="number"?B.byteStride:k*D,S=typeof B.byteOffset=="number"?B.byteOffset:0,_=typeof I.byteOffset=="number"?I.byteOffset:0,N=S+_,O=_+(I.count-1)*U+k*D;if(!Number.isInteger(U)||!Number.isInteger(S)||!Number.isInteger(_)||U<k*D||S<0||_<0||S+B.byteLength>o.byteLength||O>B.byteLength)return null;let P=[];for(let F=0;F<I.count;F++){let R=[];for(let T=0;T<k;T++){let C=er(h,N+F*U+T*D,I.componentType);if(!Number.isFinite(C))return null;R.push(C)}P.push(R)}return P},p=[],d=[],y=0,x=new Set,w=(A,E)=>{if(typeof A!="number"||!Number.isInteger(A)||!Q(f[A])||x.has(A))return!1;x.add(A);let M=f[A],I=$o(M);if(!I)return!1;let B=Ko(E,I),k=Jo(B);if(!k)return!1;if(M.mesh!==void 0){if(typeof M.mesh!="number")return!1;let D=c[M.mesh];if(!Q(D))return!1;for(let U of J(D.primitives)){if(!Q(U)||U.mode!==void 0&&U.mode!==4||!Q(U.attributes))return!1;let S=b(U.attributes.POSITION,"VEC3",[5126]),_=U.attributes.NORMAL===void 0?null:b(U.attributes.NORMAL,"VEC3",[5126]);if(!S||U.attributes.NORMAL!==void 0&&!_)return!1;let N=S.length;if(U.indices!==void 0){let P=typeof U.indices=="number"?s[U.indices]:null;N=Q(P)?P.count:void 0}if(typeof N!="number"||!Number.isInteger(N)||N%3!==0||(y+=N/3,y>1e5))return!1;let O=U.indices===void 0?S.map((P,F)=>[F]):b(U.indices,"SCALAR",[5121,5123,5125]);if(!O||O.length%3!==0||O.length!==N)return!1;for(let P=0;P<O.length;P+=3){let F=[O[P][0],O[P+1][0],O[P+2][0]];if(F.some(C=>!Number.isInteger(C)||C<0||C>=S.length))return!1;let R=F.map(C=>qo(B,...S[C])),T=null;if(!_){let C=R[1][0]-R[0][0],v=R[1][1]-R[0][1],G=R[1][2]-R[0][2],X=R[2][0]-R[0][0],L=R[2][1]-R[0][1],Y=R[2][2]-R[0][2];T=Se([1,0,0,0,1,0,0,0,1],v*Y-G*L,G*X-C*Y,C*L-v*X)}for(let C=0;C<3;C++)p.push(...R[C]),d.push(..._?Se(k,..._[F[C]]):T)}}}for(let D of J(M.children))if(!w(D,B))return!1;return x.delete(A),!0};for(let A of J(m[u].nodes))if(!w(A,Zo()))return{ok:!1,issue:y>1e5?"triangle_limit":"unsupported_glb"};return!y||p.length!==y*9||d.length!==p.length?{ok:!1,issue:"unsupported_glb"}:{ok:!0,triangleCount:y,position:new Float32Array(p),normal:new Float32Array(d)}}function Re(t){try{return or(t)}catch{return{ok:!1,issue:"invalid_glb"}}}function As(t){let{doc:n}=t,e=ue(n.theme),r=e.structure,o=Zn(n,t.eventConfigurationId??n.eventConfigurationId),a=Me(t.eventConfigurationId,t.eventConfiguration,o),i=t.seats,s=new Yt,l=null;if(t.registeredShellGlb){let P=Re(t.registeredShellGlb);if(P.ok){let F=P.position.length/3,R=new Float32Array(P.position.length),T=e.materials.shell??r.tierWall;for(let C=0;C<F;C++){let v=P.normal[C*3+1],G=v<-.25?.4:.62+.38*Math.max(0,v);R[C*3]=T[0]*G,R[C*3+1]=T[1]*G,R[C*3+2]=T[2]*G}l={position:P.position,normal:P.normal,color:R,floor:new Float32Array(F).fill(-2),material:new Float32Array(F),count:F}}}let c=new Map;for(let P of o)for(let F of P.objects)c.set(F.id,P.index),F.type==="section"&&c.set(F.logicalSectionId??F.id,P.index);let f=i.map(P=>c.get(P.sectionId??"")??c.get(P.rowId??"")??0),m=mn(o,i);ye(s,o,i,f,m,r);let u=vn(n,i),h=new Map,b=new Map;for(let P of n.categories??[])h.set(P.key,P.color),P.seatGlyph&&b.set(P.key,P.seatGlyph);let p=[],d=fe(o,i,f),y=new Float32Array(i.length),x=[];for(let P=0;P<o.length;P++){let F=o[P];s.setFloor(P);let R=new zt,T=[],C=F.objects.filter(v=>v.type==="section"&&!!v.outline&&v.outline.length>=3);for(let v of F.objects)if(v.type==="section"){let G=s.vertexCount;be(s,v,F,kn(v,u),d.bySection.get(v.id),R,C,r);let X=s.vertexCount-G;X>0&&x.push({sectionId:v.id,start:G,count:X})}else if(v.type==="shape"){let G=a.byObjectId.get(v.id);s.setMaterial((G?.kind??v.role)==="screen"?1:0),ee(s,v,F.baseHeightM,qn(v,T),r,F.focal,p,G),s.setMaterial(0)}else v.type==="gaArea"?re(s,v,F.baseHeightM,H(h.get(v.categoryKey)),r):v.type==="booth"?te(s,v,F.baseHeightM,H(h.get(v.categoryKey)),r):v.type==="table"?ne(s,v,F.baseHeightM,H(v.fill??n.theme?.decorFill??"#232c40"),r):v.type==="decorImage"&&oe(s,v,F.baseHeightM,r);pe(s,F,i,d,r,e.materials.shell,!l)}let w=o.length>1?{x:o.reduce((P,F)=>P+F.focal.x,0)/o.length,y:o.reduce((P,F)=>P+F.focal.y,0)/o.length}:n.focalPoint??{x:(m.minX+m.maxX)/2,y:(m.minY+m.maxY)/2},A=Tn(l?[s.build(),l]:[s.build()]),E=Fn(i,t.initialState,d,y,h,b),M=se({doc:n,units:o,seats:i,surfaces:d,focal:w}),{labels:I,sections:B,rows:k}=ae({doc:n,units:o,seats:i,surfaces:d,seatData:E,hintedSeatFloor:f,zones:M,focal:w}),D=de({doc:n,units:o,seats:i,surfaces:d,solids:A,hintedSeatFloor:f,seatFloor:y});ce(I,D),E.iYaw=Cn(E.iPosition,i.length,P=>i[P].rowId,P=>{let F=o[y[P]]?.focal??w;return[F.x*g,F.y*g]});let U=(m.minX+m.maxX)/2*g,S=(m.minY+m.maxY)/2*g,_=.5*Math.hypot((m.maxX-m.minX)*g,(m.maxY-m.minY)*g)||10,N=xe(A,E,{cx:U,cz:S,radius:_}),O=ge(E,p,m,N.minY,N.maxY,_);return{solids:A,sectionSolidRanges:x,seats:E,bounds:{center:[(O.min[0]+O.max[0])/2,(O.min[1]+O.max[1])/2,(O.min[2]+O.max[2])/2],radius:_,groundY:0,box:O},renderBounds:{center:N.center,radius:N.radius},stateColorLUT:le(e,Bt),theme:e,seatCount:i.length,focalWorld:[w.x*g,1.5,w.y*g],zones:M,stages:p,productionElements:a.elements,sections:B,rows:k,labels:I,floors:D}}export{Bt as a,Qt as b,mr as c,nn as d,g as e,hr as f,Ge as g,Ne as h,br as i,Vt as j,Ar as k,Pr as l,_r as m,Tr as n,Br as o,Er as p,Cr as q,Fr as r,vr as s,kr as t,Or as u,Lr as v,Bo as w,As as x};
@@ -0,0 +1 @@
1
+ import{c as Pe}from"./chunk-BT2KJXQC.js";import{a as Be,c as ze,f as be,g as Ue,l as Ge,u as pe,y as Ve}from"./chunk-FQ2MMJMH.js";import{i as He,k as Xe,l as Ye,m as he,q as ve}from"./chunk-TQN2VWQO.js";import{h as Fe}from"./chunk-NJTU4QK7.js";import{a as ge,b as me,d as Ne,f as _e,i as ne}from"./chunk-Q3U3F4YJ.js";import{b as Qe,e as z,i as qe}from"./chunk-BS37TGPX.js";import{c as Q}from"./chunk-4I2VWFJY.js";import{Ea as Le,Ga as D,Ha as Me,I as te,Ka as Y,L as Oe,M as Ae,Na as W,Pa as oe,Ra as ye,b as ce,ea as Ee,ja as de,ka as q,la as H,m as jt,ma as X,n as $t,na as ue,o as kt,oa as fe,p as Ot,pa as Te,q as At,r as Et,s as je,sa as Re,t as Tt,u as Rt,v as $e,w as ke,x as le}from"./chunk-24O23MNB.js";import{a as De,i as Ke,n as F}from"./chunk-JBOTRSMY.js";var Ie=[{key:"row-seats",label:"row seats",suffix:"rows",labelSuffix:"Rows",creationWord:"Seats",objectType:"row"},{key:"table-chairs",label:"table chairs",suffix:"tables",labelSuffix:"Tables",creationWord:"Tables",objectType:"table"},{key:"booth-units",label:"booth units",suffix:"booths",labelSuffix:"Booths",creationWord:"Booths",objectType:"booth"},{key:"ga-capacity",label:"GA capacity",suffix:"ga",labelSuffix:"GA",creationWord:"Standing",objectType:"gaArea"}];function We(t){return t.floors?.length?t.floors:[{id:"floor-0",objects:t.objects}]}function Lt(t){return Ie.find(e=>e.key===t)}function re(t){let e=new Map,n=Math.max(0,Math.floor(t.seatCount)),i=new Map((t.overrides??[]).filter(s=>Number.isInteger(s.index)&&s.index>=0&&s.index<t.seatCount).map(s=>[s.index,s])),r=(s,y=1)=>{s&&y>0&&e.set(s,(e.get(s)??0)+y)};r(t.categoryKey,n-i.size);for(let s of i.values())s.skip||r(s.categoryKey??t.categoryKey);return e}function Mt(t){return t.type==="row"||t.type==="table"?[...re(t).keys()]:t.type==="booth"?t.categoryKey?[t.categoryKey]:[]:t.type==="gaArea"?t.capacity>0&&t.categoryKey?[t.categoryKey]:[]:[]}function Ze(t){return Ie.find(e=>e.objectType===t.type)??null}function Je(t){return t.type==="row"||t.type==="table"||t.type==="booth"||t.type==="gaArea"}function ie(t){let e=new Map;for(let r of We(t))for(let s of r.objects){if(!Je(s))continue;let y=Ze(s);for(let f of Mt(s)){let m=e.get(f)??new Map,a=m.get(y.key)??[];if(!a.some(u=>u.id===s.id)){let u=s.displayLabel||s.label||s.id;a.push({id:s.id,label:u,type:y.objectType,floorId:r.id})}m.set(y.key,a),e.set(f,m)}}let n=new Map(t.categories.map(r=>[r.key,r.label]));return[...t.categories.map(r=>r.key),...[...e.keys()].filter(r=>!n.has(r)).sort()].flatMap(r=>{let s=e.get(r);if(!s||s.size<2)return[];let y=Ie.flatMap(f=>{let m=s.get(f.key);return m?.length?[{family:f.key,label:f.label,objectType:f.objectType,targets:m}]:[]});return[{categoryKey:r,categoryLabel:n.get(r)??r,families:y,objectIds:[...new Set(y.flatMap(f=>f.targets.map(m=>m.id)))]}]})}function et(t){let e=t.families.map(n=>`${n.label} (${n.targets.map(i=>i.label).join(", ")})`).join(" and ");return`Category \u201C${t.categoryLabel}\u201D is used by more than one kind of inventory \u2014 ${e}. Each category can belong to only one kind \u2014 use the safe split to separate them (prices, ticket tiers, accessibility, and provenance are preserved).`}function tt(t){return t.normalize("NFKC").trim().toLocaleLowerCase("en")}function Ft(t,e,n){for(let i=1;i<=1e4;i+=1){let r=i===1?`--${e}`:`--${e}-${i}`,y=`${t.slice(0,Math.max(1,160-r.length))}${r}`;if(!n.has(y))return n.add(y),y}throw new Error(`Unable to allocate a category key for ${t} (${e})`)}function Pt(t,e,n){for(let i=1;i<=1e4;i+=1){let r=i===1?` (${e})`:` (${e} ${i})`,y=`${t.normalize("NFKC").trim().slice(0,Math.max(1,80-r.length)).trimEnd()}${r}`,f=tt(y);if(!n.has(f))return n.add(f),y}throw new Error(`Unable to allocate a category label for ${t} (${e})`)}function Nt(t,e,n,i){let r=Lt(e);return{...structuredClone(t),key:Ft(t.key,r.suffix,n),label:Pt(t.label,r.labelSuffix,i)}}function _t(t,e,n){let i=[];for(let r of We(t))for(let s of r.objects){if(!Je(s))continue;let y=Ze(s),f=n.get(y.key);if(!(!f||f===e))if(s.type==="row"||s.type==="table"){let m=[];s.categoryKey===e&&(s.categoryKey=f);for(let a of s.overrides??[])a.categoryKey===e&&(a.categoryKey=f,m.push(a.index));(s.categoryKey===f||m.length)&&i.push({family:y.key,floorId:r.id,objectId:s.id,objectType:y.objectType,fromCategoryKey:e,toCategoryKey:f,...m.length?{seatOverrideIndices:m.sort((a,u)=>a-u)}:{}})}else s.categoryKey===e&&(s.categoryKey=f,i.push({family:y.key,floorId:r.id,objectId:s.id,objectType:y.objectType,fromCategoryKey:e,toCategoryKey:f}))}return i}function ot(t){let e=structuredClone(t),n=ie(e);if(!n.length)return{doc:e,changed:!1,changes:[],before:n,after:n};let i=new Set(e.categories.map(f=>f.key)),r=new Set(e.categories.map(f=>tt(f.label))),s=[];for(let f of n){let m=e.categories.findIndex(I=>I.key===f.categoryKey);if(m<0)continue;let a=e.categories[m],u=f.families[0].family,g=new Map([[u,a.key]]),p=f.families.slice(1).map(I=>{let k=Nt(a,I.family,i,r);return g.set(I.family,k.key),{family:I.family,key:k.key,label:k.label,category:k}});e.categories.splice(m+1,0,...p.map(I=>I.category));let b=_t(e,a.key,g);s.push({categoryKey:a.key,categoryLabel:a.label,retainedFamily:u,clones:p.map(({family:I,key:k,label:w})=>({family:I,key:k,label:w})),reassignments:b})}e.floors?.length&&(e.objects=e.floors[0].objects);let y=ie(e);return{doc:e,changed:s.length>0,changes:s,before:n,after:y}}function vo(t){let e=(t%360+360)%360,n=e>=180?e-360:e;return Object.is(n,-0)||Math.abs(n)<1e-9?0:n}function Dt(t,e){return Math.abs(t.x-e.x)<=1e-7&&Math.abs(t.y-e.y)<=1e-7}function Z(t,e,n){return(e.x-t.x)*(n.y-t.y)-(e.y-t.y)*(n.x-t.x)}function ae(t,e,n){let i=Z(e,n,t);return Math.abs(i)>1e-7?!1:t.x>=Math.min(e.x,n.x)-1e-7&&t.x<=Math.max(e.x,n.x)+1e-7&&t.y>=Math.min(e.y,n.y)-1e-7&&t.y<=Math.max(e.y,n.y)+1e-7}function Kt(t,e,n,i){let r=Z(t,e,n),s=Z(t,e,i),y=Z(n,i,t),f=Z(n,i,e);return(r>1e-7&&s<-1e-7||r<-1e-7&&s>1e-7)&&(y>1e-7&&f<-1e-7||y<-1e-7&&f>1e-7)?!0:Math.abs(r)<=1e-7&&ae(n,t,e)||Math.abs(s)<=1e-7&&ae(i,t,e)||Math.abs(y)<=1e-7&&ae(t,n,i)||Math.abs(f)<=1e-7&&ae(e,n,i)}function Bt(t){return t.reduce((e,n,i)=>{let r=t[(i+1)%t.length];return e+n.x*r.y-r.x*n.y},0)}function zt(t){for(let e=0;e<t.length;e+=1){let n=(e+1)%t.length;for(let i=e+1;i<t.length;i+=1){let r=(i+1)%t.length;if(!(e===i||n===i||r===e)&&Kt(t[e],t[n],t[i],t[r]))return!0}}return!1}function nt(t){return t.length<3?{ok:!1,code:"too_few_vertices",message:"Add at least three vertices to create a polygon."}:t.length>256?{ok:!1,code:"too_many_vertices",message:"A polygon can contain at most 256 vertices."}:t.some(e=>!Number.isFinite(e.x)||!Number.isFinite(e.y)||Math.abs(e.x)>1e7||Math.abs(e.y)>1e7)?{ok:!1,code:"invalid_coordinate",message:"Every polygon vertex must use a finite coordinate inside the safe chart range."}:t.some((e,n)=>Dt(e,t[(n+1)%t.length]))?{ok:!1,code:"duplicate_vertex",message:"Move or remove duplicate neighbouring vertices."}:Math.abs(Bt(t))<2?{ok:!1,code:"degenerate_polygon",message:"The polygon needs a visible enclosed area."}:zt(t)?{ok:!1,code:"self_intersection",message:"Polygon edges cannot cross or touch each other."}:{ok:!0}}function B(t){return t.length>=3&&t.every(e=>Number.isFinite(e.x)&&Number.isFinite(e.y))}function U(t,e,n){let i=(t.y-e.y)*(n.x-e.x)-(t.x-e.x)*(n.y-e.y);if(Math.abs(i)>1e-7)return!1;let r=(t.x-e.x)*(n.x-e.x)+(t.y-e.y)*(n.y-e.y);if(r<-1e-7)return!1;let s=(n.x-e.x)**2+(n.y-e.y)**2;return r<=s+1e-7}function G(t,e){let n=!1;for(let i=0,r=e.length-1;i<e.length;r=i++){let s=e[r],y=e[i];if(U(t,s,y))return!0;s.y>t.y!=y.y>t.y&&t.x<(y.x-s.x)*(t.y-s.y)/(y.y-s.y)+s.x&&(n=!n)}return n}function K(t,e,n){return(e.x-t.x)*(n.y-t.y)-(e.y-t.y)*(n.x-t.x)}function rt(t,e,n,i){let r=K(t,e,n),s=K(t,e,i),y=K(n,i,t),f=K(n,i,e);return(r>1e-7&&s<-1e-7||r<-1e-7&&s>1e-7)&&(y>1e-7&&f<-1e-7||y<-1e-7&&f>1e-7)?!0:Math.abs(r)<=1e-7&&U(n,t,e)||Math.abs(s)<=1e-7&&U(i,t,e)||Math.abs(y)<=1e-7&&U(t,n,i)||Math.abs(f)<=1e-7&&U(e,n,i)}function V(t){for(let e=0;e<t.length;e+=1){let n=(e+1)%t.length;for(let i=e+1;i<t.length;i+=1){let r=(i+1)%t.length;if(!(e===i||n===i||r===e)&&rt(t[e],t[n],t[i],t[r]))return!0}}return!1}function J(t,e){for(let n=0;n<t.length;n+=1)for(let i=0;i<e.length;i+=1)if(rt(t[n],t[(n+1)%t.length],e[i],e[(i+1)%e.length]))return!0;return G(t[0],e)||G(e[0],t)}function it(t,e){return!e.some((n,i)=>U(t,n,e[(i+1)%e.length]))&&G(t,e)}function at(t){let e=t.outlinePath;if(!e?.segments.length)return;let n=s=>Number.isFinite(s.x)&&Number.isFinite(s.y),i=(s,y)=>Math.hypot(s.x-y.x,s.y-y.y);if(!n(e.start))return 0;let r=e.start;for(let s=0;s<e.segments.length;s++){let y=e.segments[s];if(!y||!n(y.end)||i(r,y.end)<=1e-9||y.kind==="bezier"&&(!n(y.control1)||!n(y.control2)))return s;if(y.kind==="arc"){if(!n(y.center)||!Number.isFinite(y.radius)||y.radius<=1e-6)return s;let f=Math.max(1e-4,y.radius*1e-4);if(Math.abs(i(r,y.center)-y.radius)>f||Math.abs(i(y.end,y.center)-y.radius)>f)return s}r=y.end}return i(r,e.start)>1e-4,e.segments.length-1}function Ut(t,e,n,i){let r=K(t,e,n),s=K(t,e,i),y=K(n,i,t),f=K(n,i,e);return(r>1e-7&&s<-1e-7||r<-1e-7&&s>1e-7)&&(y>1e-7&&f<-1e-7||y<-1e-7&&f>1e-7)}function st(t,e){for(let n=0;n<t.length;n+=1)for(let i=0;i<e.length;i+=1)if(Ut(t[n],t[(n+1)%t.length],e[i],e[(i+1)%e.length]))return!0;return t.some(n=>it(n,e))||e.some(n=>it(n,t))}function ct(t){return t.role!=="reference-focal"||!t.points||!B(t.points)?null:t.points}function dt(t,e){if(t.displayLabel!==void 0){let n=t.displayLabel.normalize("NFKC").trim();!(t.type==="row"&&t.displayLabel==="")&&(!n||n!==t.displayLabel||n.length>80)&&e.push({severity:"error",code:"invalid-display-label",message:`${t.type==="gaArea"?"GA area":t.type} "${t.label}" must use a normalized buyer label of 1 to 80 characters`,objectId:t.id})}if(t.displayType!==void 0){let n=t.displayType.normalize("NFKC").trim();(!n||n!==t.displayType||n.length>24)&&e.push({severity:"error",code:"invalid-display-type",message:`${t.type==="gaArea"?"GA area":t.type} "${t.label}" must use a normalized buyer type of 1 to 24 characters`,objectId:t.id})}}function lt(t,e,n,i){let r=t.crop,s=r&&(!Number.isFinite(r.x)||!Number.isFinite(r.y)||!Number.isFinite(r.width)||!Number.isFinite(r.height)||r.x<0||r.y<0||r.width<=0||r.height<=0||r.x+r.width>1.000001||r.y+r.height>1.000001);(!Number.isFinite(t.center?.x)||!Number.isFinite(t.center?.y)||!Number.isFinite(t.width)||t.width<=0||!Number.isFinite(t.opacity)||t.opacity<0||t.opacity>1||t.rotation!==void 0&&!Number.isFinite(t.rotation)||s)&&n.push({severity:"error",code:"invalid-background-placement",message:`The ${e} image has an invalid position, size, opacity, rotation, or crop`,...i?{floorId:i}:{}})}function we(t,e,n,i){let r=t.referenceImage,s=t.backgroundImage;r&&(lt(r,"reference",e,i),!r.assetId&&!r.url&&e.push({severity:"error",code:"invalid-reference-image",message:"A trace reference must identify a private asset or self-contained image",...i?{floorId:i}:{}})),s&&(lt(s,s.assetId?"legacy reference":"buyer background",e,i),!s.assetId&&!s.url&&e.push({severity:"error",code:"invalid-buyer-background",message:"A buyer background must contain a renderable image URL",...i?{floorId:i}:{}}),s.assetId&&n.push({severity:"warning",code:"legacy-reference-background",message:"This legacy asset-backed background is trace-only and will migrate to the private reference layer when edited",...i?{floorId:i}:{}})),Fe(t)&&e.push({severity:"error",code:"conflicting-reference-images",message:"The canonical reference and legacy asset-backed background identify different private sources",...i?{floorId:i}:{}})}function ee(t){let e=new Set(Q.map(n=>n.key));return!t||/^ref_[0-9a-f-]{36}$/.test(t.assetId)&&!!t.logicalSectionId.trim()&&["user-confirmed","authoritative-source"].includes(t.evidence)&&!!t.sourceDescription.trim()&&(t.derivation===void 0||["explicit-inventory","server-synthesized-from-aggregate"].includes(t.derivation))&&(t.aggregateEvidence===void 0||["user-confirmed","authoritative-source"].includes(t.aggregateEvidence))&&(t.derivation!=="server-synthesized-from-aggregate"||t.evidence==="user-confirmed")&&(t.sectionAssignmentEvidence===void 0||["user-confirmed","authoritative-source"].includes(t.sectionAssignmentEvidence))&&t.sectionAssignmentEvidence===void 0==!t.sectionAssignmentSourceDescription?.trim()&&(t.sectionAssignmentSourceDescription?.trim().length??0)<=240&&(t.numberingEvidence===void 0||t.numberingEvidence==="user-confirmed")&&t.numberingEvidence===void 0==!t.numberingSourceDescription?.trim()&&(t.numberingSourceDescription?.trim().length??0)<=240&&(!t.accessibility||t.accessibility.placementDerivation==="server-synthesized-row-edges"&&t.accessibility.groupLogicalSectionIds.length>0&&t.accessibility.groupLogicalSectionIds.length<=100&&new Set(t.accessibility.groupLogicalSectionIds).size===t.accessibility.groupLogicalSectionIds.length&&t.accessibility.groupLogicalSectionIds.includes(t.logicalSectionId)&&t.accessibility.groupLogicalSectionIds.every(n=>!!n.trim()&&n.length<=160)&&["user-confirmed","authoritative-source"].includes(t.accessibility.assignmentEvidence)&&!!t.accessibility.assignmentSourceDescription.trim()&&t.accessibility.assignmentSourceDescription.trim().length<=240&&t.accessibility.counts.length>0&&t.accessibility.counts.length<=Q.length&&new Set(t.accessibility.counts.map(n=>n.type)).size===t.accessibility.counts.length&&t.accessibility.counts.every(n=>e.has(n.type)&&Number.isInteger(n.count)&&n.count>0&&["user-confirmed","authoritative-source"].includes(n.evidence)&&!!n.sourceDescription.trim()&&n.sourceDescription.trim().length<=240))}function ut(t){let e=t.referenceInventoryExclusion;return!e||typeof e.assetId=="string"&&/^ref_[0-9a-f-]{36}$/.test(e.assetId)&&e.assetId===t.referenceSource?.assetId&&typeof e.logicalSectionId=="string"&&e.logicalSectionId===(t.logicalSectionId??t.id)&&typeof e.reason=="string"&&!!e.reason.trim()&&e.reason.trim().length<=80&&["user-confirmed","authoritative-source"].includes(e.evidence)&&typeof e.sourceDescription=="string"&&!!e.sourceDescription.trim()&&e.sourceDescription.trim().length<=240}function ft(t){let e=t.referenceCategorySource;return!e||/^ref_[0-9a-f-]{36}$/.test(e.assetId)&&/^#[0-9a-f]{6}$/i.test(e.sourceColor)&&(e.sourceColors===void 0||e.sourceColors.length>0&&e.sourceColors.includes(e.sourceColor)&&new Set(e.sourceColors).size===e.sourceColors.length&&e.sourceColors.every(n=>/^#[0-9a-f]{6}$/i.test(n)&&`${n[1]}${n[3]}${n[5]}`.toLowerCase()===`${e.sourceColor[1]}${e.sourceColor[3]}${e.sourceColor[5]}`.toLowerCase()))&&(e.logicalSectionIds===void 0||e.logicalSectionIds.length>0&&new Set(e.logicalSectionIds).size===e.logicalSectionIds.length&&e.logicalSectionIds.every(n=>!!n.trim()&&n.length<=160))&&(e.assignmentDerivation===void 0||["source-color-class","confirmed-logical-sections"].includes(e.assignmentDerivation))&&e.assignmentEvidence===void 0==!e.assignmentSourceDescription?.trim()&&(e.assignmentEvidence===void 0||["user-confirmed","authoritative-source"].includes(e.assignmentEvidence))&&(e.assignmentSourceDescription?.trim().length??0)<=240&&(e.assignmentDerivation!=="confirmed-logical-sections"||e.assignmentEvidence!==void 0&&!!e.assignmentSourceDescription?.trim())&&e.sourcePaletteColor===void 0==(e.sourcePaletteColorEvidence===void 0)&&e.sourcePaletteColorEvidence===void 0==!e.sourcePaletteColorSourceDescription?.trim()&&(e.sourcePaletteColor===void 0||/^#[0-9a-f]{6}$/i.test(e.sourcePaletteColor))&&(e.sourcePaletteColorEvidence===void 0||["user-confirmed","authoritative-source"].includes(e.sourcePaletteColorEvidence))&&(e.sourcePaletteColorSourceDescription?.trim().length??0)<=240&&["user-confirmed","authoritative-source"].includes(e.labelEvidence)&&!!e.labelSourceDescription.trim()&&e.labelSourceDescription.trim().length<=240&&t.price!==void 0&&["user-confirmed","authoritative-source"].includes(e.priceEvidence)&&!!e.priceSourceDescription.trim()&&e.priceSourceDescription.trim().length<=240&&e.outputColorEvidence===void 0==!e.outputColorSourceDescription?.trim()&&(e.outputColorEvidence===void 0||["user-confirmed","authoritative-source"].includes(e.outputColorEvidence))&&(e.outputColorSourceDescription?.trim().length??0)<=240&&(t.color.toLowerCase()===(e.sourcePaletteColor??e.sourceColor).toLowerCase()&&new Set((e.sourceColors??[e.sourceColor]).map(n=>`${n[1]}${n[3]}${n[5]}`.toLowerCase())).size===1||e.outputColorEvidence!==void 0&&["user-confirmed","authoritative-source"].includes(e.outputColorEvidence))}function yt(t){let e=t.referenceDirectSeatImport;return!e||/^ref_[0-9a-f-]{36}$/.test(e.assetId)&&/^source-color:(?:#[0-9a-f]{6}(?:\+#[0-9a-f]{6})*|unclassified)$/i.test(e.familyId)}function gt(t,e){let n=t.floors?.length?t.floors.map(s=>({id:s.id,objects:s.objects})):[{id:"floor-0",objects:t.objects}],i=new Map,r=new Map;for(let s of n){let y=s.objects.filter(a=>a.type==="row"),f=new Map,m=new Map;for(let a of y){if(a.segmentedRow){let u=f.get(a.segmentedRow.groupId)??[];u.push(a),f.set(a.segmentedRow.groupId,u)}if(a.rowBlockGeneration){let u=m.get(a.rowBlockGeneration.groupId)??[];u.push(a),m.set(a.rowBlockGeneration.groupId,u)}a.segmentedRow&&a.rowBlockGeneration&&e.push({severity:"error",code:"invalid-row-group-membership",message:`Row "${a.label}" cannot be both a segmented-row component and a generated row-block member`,objectId:a.id,floorId:s.id})}for(let[a,u]of f){let g=i.get(a);g&&g!==s.id&&e.push({severity:"error",code:"invalid-segmented-row",message:`Segmented row "${a}" cannot span multiple floors`,objectId:u[0].id,floorId:s.id}),i.set(a,s.id);let p=u.slice().sort((C,O)=>C.segmentedRow.componentIndex-O.segmentedRow.componentIndex),b=p[0]?.segmentedRow,I=b?.componentCount??0,k=b?JSON.stringify({displayLabel:b.displayLabel,repeatLabelOnComponents:b.repeatLabelOnComponents,displayType:b.displayType,labelPresentation:b.labelPresentation,viewFromSeatUrl:b.viewFromSeatUrl,viewFromSeatMeta:b.viewFromSeatMeta,confidenceEvidence:b.confidenceEvidence,smoothing:b.smoothing}):"";b&&I>=2&&I<=64&&p.length===I&&b.boundaryBefore==="start"&&p.every((C,O)=>{let j=C.segmentedRow;return j.kind==="segmented-row-v1"&&j.groupId===a&&j.componentCount===I&&j.componentIndex===O&&(O===0?j.boundaryBefore==="start":j.boundaryBefore!=="start")&&j.displayLabel.normalize("NFKC").trim()===j.displayLabel&&j.displayLabel.length>0&&j.displayLabel.length<=80&&JSON.stringify({displayLabel:j.displayLabel,repeatLabelOnComponents:j.repeatLabelOnComponents,displayType:j.displayType,labelPresentation:j.labelPresentation,viewFromSeatUrl:j.viewFromSeatUrl,viewFromSeatMeta:j.viewFromSeatMeta,confidenceEvidence:j.confidenceEvidence,smoothing:j.smoothing})===k})||e.push({severity:"error",code:"invalid-segmented-row",message:`Segmented row "${a}" has missing, duplicated, cyclic, or inconsistent component metadata`,objectId:u[0]?.id,floorId:s.id})}for(let[a,u]of m){let g=r.get(a);g&&g!==s.id&&e.push({severity:"error",code:"invalid-row-block-generation",message:"A generated row block cannot span multiple floors",objectId:u[0].id,floorId:s.id}),r.set(a,s.id)}}}function Gt(t){return t.type==="row"||t.type==="table"||t.type==="booth"}function Vt(t){let e=[],n=new Map((t.overrides??[]).map(i=>[i.index,i]));for(let i=0;i<t.seatCount;i++){let r=n.get(i);r?.skip||e.push({label:Ee(t,i,r),index:i})}return e}function mt(t){let e=[],n=new Map((t.overrides??[]).map(i=>[i.index,i]));for(let i=0;i<t.seatCount;i++){let r=n.get(i);r?.skip||e.push({label:r?.label??`${t.label}-${i+1}`,index:i})}return e}function bt(t){let e=[];t.floorOverview!==void 0&&t.floorOverview!=="combined"&&t.floorOverview!=="separated"&&e.push({severity:"error",code:"invalid-floor-overview",message:"Whole venue view must be Combined plan or Separate levels"}),t.eventConfigurationId!==void 0&&(typeof t.eventConfigurationId!="string"||t.eventConfigurationId.normalize("NFKC").trim()!==t.eventConfigurationId||t.eventConfigurationId.length<1||t.eventConfigurationId.length>100)&&e.push({severity:"error",code:"invalid-event-configuration",message:"Active event configuration must contain 1 to 100 normalized characters"});let n=[],i=new Set(t.categories.map(o=>o.key)),r=new Set(Q.map(o=>o.key)),s=new Map(t.categories.map(o=>[o.key,o.price!=null||o.notForSale===!0])),y=new Set;we(t,e,n),t.theme?.sectionDetail!==void 0&&!["rows","seats"].includes(t.theme.sectionDetail)&&e.push({severity:"error",code:"invalid-section-detail",message:"Section detail must be rows or seats"}),t.theme?.logoUrl!==void 0&&!ce(t.theme.logoUrl)&&e.push({severity:"error",code:"invalid-theme-logo-url",message:"The buyer-facing theme logo URL is invalid"});let f=ce,m=(o,S,c,d={})=>{if(S===void 0)return;if(!S||typeof S!="object"||Array.isArray(S)){e.push({severity:"error",code:"invalid-seat-view-metadata",message:`${c} view metadata is invalid`,...d});return}let l=S;o||n.push({severity:"warning",code:"orphaned-seat-view-metadata",message:`${c} view metadata has no image`,...d});let v=new Set(["exact-seat","row-representative","section-representative","floor-representative","venue-representative"]);l.projection!==void 0&&l.projection!=="equirectangular"&&e.push({severity:"error",code:"invalid-seat-view-projection",message:`${c} view projection must be equirectangular`,...d}),l.coverage!==void 0&&!v.has(l.coverage)&&e.push({severity:"error",code:"invalid-seat-view-coverage",message:`${c} view coverage is invalid`,...d});let h=(x,$,A)=>typeof x=="number"&&Number.isFinite(x)&&x>=$&&x<=A;if(l.initialBearingDeg!==void 0&&!h(l.initialBearingDeg,-360,360)&&e.push({severity:"error",code:"invalid-seat-view-bearing",message:`${c} view bearing must be between -360\xB0 and 360\xB0`,...d}),l.initialPitchDeg!==void 0&&!h(l.initialPitchDeg,-90,90)&&e.push({severity:"error",code:"invalid-seat-view-pitch",message:`${c} view pitch must be between -90\xB0 and 90\xB0`,...d}),l.capturedAt!==void 0&&(typeof l.capturedAt!="string"||l.capturedAt.length>40||!Number.isFinite(Date.parse(l.capturedAt)))&&e.push({severity:"error",code:"invalid-seat-view-capture-date",message:`${c} view capture date is invalid`,...d}),l.sourceLabel!==void 0&&(typeof l.sourceLabel!="string"||l.sourceLabel.trim().length>100)&&e.push({severity:"error",code:"invalid-seat-view-source",message:`${c} view source label is invalid`,...d}),l.previewUrl!==void 0&&!f(l.previewUrl)&&e.push({severity:"error",code:"invalid-seat-view-preview-url",message:`${c} view preview URL is invalid`,...d}),l.variants!==void 0){let x=Array.isArray(l.variants)?l.variants:[];if(!Array.isArray(l.variants)||x.length<1||x.length>4)e.push({severity:"error",code:"invalid-seat-view-variants",message:`${c} view variants must contain between 1 and 4 tiers`,...d});else{let $=new Set;for(let A of x){if(!A||typeof A!="object"||!f(A.url)||!Number.isInteger(A.width)||A.width<1||A.width>12e3||!Number.isInteger(A.height)||A.height<1||A.height>12e3||A.width!==A.height*2||typeof A.sha256!="string"||!/^[a-f0-9]{64}$/.test(A.sha256)||$.has(A.width)){e.push({severity:"error",code:"invalid-seat-view-variant",message:`${c} view variant is not a unique immutable 2:1 equirectangular tier`,...d});break}$.add(A.width)}}}for(let[x,$]of[["width",l.sourceWidth],["height",l.sourceHeight],["preview width",l.previewWidth],["preview height",l.previewHeight]])$!==void 0&&(!Number.isInteger($)||$<1||$>32768)&&e.push({severity:"error",code:"invalid-seat-view-dimensions",message:`${c} view source ${x} is invalid`,...d});l.captureEyeHeightM!==void 0&&!h(l.captureEyeHeightM,.5,3)&&e.push({severity:"error",code:"invalid-seat-view-eye-height",message:`${c} capture eye height must be between 0.5 m and 3 m`,...d}),l.eventConfigurationId!==void 0&&(typeof l.eventConfigurationId!="string"||!l.eventConfigurationId.trim()||l.eventConfigurationId.length>100)&&e.push({severity:"error",code:"invalid-seat-view-configuration",message:`${c} event configuration id is invalid`,...d}),l.eventConfigurationVersion!==void 0&&(!Number.isInteger(l.eventConfigurationVersion)||l.eventConfigurationVersion<1)&&e.push({severity:"error",code:"invalid-seat-view-configuration-version",message:`${c} event configuration version is invalid`,...d}),l.eventConfigurationVersion!==void 0&&!l.eventConfigurationId&&e.push({severity:"error",code:"invalid-seat-view-configuration-pin",message:`${c} event configuration version requires an id`,...d})},a=(o,S,c={})=>{if(o===void 0)return;let d=$=>{e.push({severity:"error",code:"invalid-seat-confidence-evidence",message:`${S} confidence evidence ${$}`,...c})};if(!o||typeof o!="object"||Array.isArray(o)){d("is invalid");return}let l=o;l.schema!=="seatlayer.seat-confidence/1"&&d("has an unsupported schema");let v=($,A)=>typeof $=="string"&&$.normalize("NFKC").trim()===$&&$.length>0&&$.length<=A;v(l.evidenceId,120)||d("has an invalid evidence id"),v(l.modelVersion,120)||d("has an invalid model version"),new Set(["synthetic-model","organizer-approved","calibrated-provider"]).has(l.evidenceKind)||d("has an invalid evidence kind"),new Set(["generated","geometry-verified","configuration-verified"]).has(l.modelLevel)||d("has an invalid model level");let h=l.realityLevel??"none";new Set(["none","comparable-build-reference","actual-build-checked"]).has(h)||d("has an invalid reality level"),l.eventConfigurationId!==void 0&&!v(l.eventConfigurationId,100)&&d("has an invalid event configuration id"),l.eventConfigurationVersion!==void 0&&(!Number.isInteger(l.eventConfigurationVersion)||l.eventConfigurationVersion<1)&&d("has an invalid event configuration version"),l.status!==void 0&&!new Set(["draft","approved","retracted"]).has(l.status)&&d("has an invalid publication status"),l.basisSha256!==void 0&&!/^[a-f0-9]{64}$/.test(l.basisSha256)&&d("has an invalid venue basis SHA-256"),l.basisSha256!==void 0&&l.status!=="approved"&&d("can carry a venue basis SHA-256 only after approval");for(let[$,A]of[["assessment",l.assessedAt],["expiry",l.validUntil]])A!==void 0&&(!v(A,40)||!Number.isFinite(Date.parse(A)))&&d(`has an invalid ${$} date`);l.approvedByRole!==void 0&&!v(l.approvedByRole,100)&&d("has an invalid approving organization or role"),l.sourceLabel!==void 0&&!v(l.sourceLabel,120)&&d("has an invalid source label"),l.limitations!==void 0&&(!Array.isArray(l.limitations)||l.limitations.length>6||l.limitations.some($=>!v($,160)))&&d("has invalid limitations"),l.evidenceKind==="synthetic-model"&&(l.modelLevel!=="generated"||h!=="none")&&d("cannot describe synthetic data as verified or reality checked"),l.modelLevel!=="generated"&&(!l.assessedAt||!l.approvedByRole)&&d("requires an assessment date and approving organization or role for verified model levels"),l.modelLevel==="configuration-verified"&&!l.eventConfigurationId&&d("requires an event configuration id for configuration verification"),h!=="none"&&(!l.assessedAt||!l.sourceLabel)&&d("requires an assessment date and source for reality evidence"),h==="actual-build-checked"&&(l.modelLevel!=="configuration-verified"||!l.eventConfigurationId)&&d("requires a configuration-verified model and event configuration for an actual-build check");let x=l.modeledTarget;x!==void 0&&(!x||typeof x!="object"||Array.isArray(x)?d("has an invalid modeled target"):((!v(x.label,80)||!v(x.methodLabel,100))&&d("has invalid modeled-target labels"),(!Number.isInteger(x.totalRayCount)||x.totalRayCount<1||x.totalRayCount>1e3||!Number.isInteger(x.clearRayCount)||x.clearRayCount<0||x.clearRayCount>x.totalRayCount)&&d("has invalid modeled-target ray counts"),new Set(["clear","partial","obstructed"]).has(x.classification)||d("has an invalid modeled-target classification"),x.occluderLabels!==void 0&&(!Array.isArray(x.occluderLabels)||x.occluderLabels.length>10||x.occluderLabels.some($=>!v($,100)))&&d("has invalid modeled-target occluders")))};m(t.viewFromSeatUrl,t.viewFromSeatMeta,"Venue"),a(t.confidenceEvidence,"Venue"),t.viewFromSeatUrl!==void 0&&!f(t.viewFromSeatUrl)&&e.push({severity:"error",code:"invalid-venue-view-url",message:"The whole-venue view-from-seat image URL is invalid"});for(let o of t.floors??[])o.viewFromSeatUrl!==void 0&&!f(o.viewFromSeatUrl)&&e.push({severity:"error",code:"invalid-floor-view-url",message:`Floor "${o.name}" has an invalid view-from-seat image URL`}),m(o.viewFromSeatUrl,o.viewFromSeatMeta,`Floor "${o.name}"`,{floorId:o.id}),a(o.confidenceEvidence,`Floor "${o.name}"`,{floorId:o.id});let u=t.floors?.length?t.floors.flatMap(o=>o.objects):t.objects;for(let o of u)if((o.type==="row"||o.type==="section")&&(o.viewFromSeatUrl!==void 0&&!f(o.viewFromSeatUrl)&&e.push({severity:"error",code:o.type==="row"?"invalid-row-view-url":"invalid-section-view-url",message:`${o.type==="row"?"Row":"Section"} "${o.label}" has an invalid view-from-seat image URL`,objectId:o.id}),m(o.viewFromSeatUrl,o.viewFromSeatMeta,`${o.type==="row"?"Row":"Section"} "${o.label}"`,{objectId:o.id}),a(o.confidenceEvidence,`${o.type==="row"?"Row":"Section"} "${o.label}"`,{objectId:o.id})),o.type==="row"&&o.segmentedRow&&(o.segmentedRow.viewFromSeatUrl!==void 0&&!f(o.segmentedRow.viewFromSeatUrl)&&e.push({severity:"error",code:"invalid-segmented-row-view-url",message:`Segmented row "${o.segmentedRow.displayLabel}" has an invalid view-from-seat image URL`,objectId:o.id}),m(o.segmentedRow.viewFromSeatUrl,o.segmentedRow.viewFromSeatMeta,`Segmented row "${o.segmentedRow.displayLabel}"`,{objectId:o.id}),a(o.segmentedRow.confidenceEvidence,`Segmented row "${o.segmentedRow.displayLabel}"`,{objectId:o.id})),o.type==="row"||o.type==="table")for(let S of o.overrides??[])S.viewFromSeatUrl!==void 0&&!f(S.viewFromSeatUrl)&&e.push({severity:"error",code:"invalid-seat-view-url",message:`Seat ${S.index+1} has an invalid view-from-seat image URL`,objectId:o.id,seatIndices:[S.index]}),m(S.viewFromSeatUrl,S.viewFromSeatMeta,`Seat ${S.index+1}`,{objectId:o.id,seatIndices:[S.index]}),a(S.confidenceEvidence,`Seat ${S.index+1}`,{objectId:o.id,seatIndices:[S.index]});let g=new Set;for(let o of t.categories){g.has(o.key)&&e.push({severity:"error",code:"duplicate-category-key",message:`Category key "${o.key}" is used more than once`,categoryKey:o.key}),g.add(o.key);let S=new Set;for(let c of o.tiers??[]){if(S.has(c.id)&&e.push({severity:"error",code:"duplicate-category-tier-id",message:`Ticket tier id "${c.id}" is used more than once in category "${o.key}"`,categoryKey:o.key}),c.restriction!=null&&!["companion","child","senior","student","membership","custom"].includes(c.restriction)&&e.push({severity:"error",code:"invalid-category-tier-restriction",message:`Ticket tier "${c.name}" has an unknown restriction`,categoryKey:o.key}),c.buyerMessage!=null&&(!c.buyerMessage.trim()||c.buyerMessage.length>240)&&e.push({severity:"error",code:"invalid-category-tier-buyer-message",message:`Ticket tier "${c.name}" buyer guidance must contain 1 to 240 characters`,categoryKey:o.key}),c.currency!=null&&!/^[A-Z]{3}$/.test(c.currency)&&e.push({severity:"error",code:"invalid-category-tier-currency",message:`Ticket tier "${c.name}" must use a three-letter ISO currency`,categoryKey:o.key}),c.applicability!=null){let d=c.applicability.seatLabels,l=c.applicability.accessibility;(d!==void 0&&(!Array.isArray(d)||!d.length||d.length>1e4||d.some(v=>typeof v!="string"||!v.trim()||v.length>160)||new Set(d).size!==d.length)||l!==void 0&&(!Array.isArray(l)||!l.length||l.some(v=>!r.has(v))||new Set(l).size!==l.length))&&e.push({severity:"error",code:"invalid-category-tier-applicability",message:`Ticket tier "${c.name}" has invalid seat applicability`,categoryKey:o.key})}c.evidence!=null&&(!["public-host","public-event","user-confirmed"].includes(c.evidence.provenance)||!c.evidence.sourceDescription.trim()||c.evidence.sourceDescription.length>240||c.evidence.capturedAt!==void 0&&(c.evidence.capturedAt.length>40||!Number.isFinite(Date.parse(c.evidence.capturedAt))))&&e.push({severity:"error",code:"invalid-category-tier-evidence",message:`Ticket tier "${c.name}" has invalid evidence provenance`,categoryKey:o.key}),S.add(c.id)}ft(o)||e.push({severity:"error",code:"invalid-reference-category-source",message:`Category ${o.label||o.key} has incomplete or invalid reference evidence`,categoryKey:o.key}),yt(o)||e.push({severity:"error",code:"invalid-reference-direct-seat-import",message:`Category ${o.label||o.key} has invalid direct-seat import provenance`,categoryKey:o.key})}let p=new Map,b=new Map,I=[],k=new Map,w=0,C=0,O=new Set;for(let o of t.floors??[])we(o,e,n,o.id),O.has(o.id)&&e.push({severity:"error",code:"duplicate-floor-id",message:`Floor id "${o.id}" is used more than once`,floorId:o.id}),O.add(o.id),o.baseHeightM!==void 0&&(!Number.isFinite(o.baseHeightM)||o.baseHeightM<H||o.baseHeightM>X)&&e.push({severity:"error",code:"invalid-floor-base-height",message:`Floor "${o.name}" base height must be between ${H} and ${X} metres`,floorId:o.id});let j=t.floors&&t.floors.length?t.floors.flatMap(o=>o.objects):t.objects;gt(t,e);let P=new Set;for(let o of j)P.has(o.id)&&e.push({severity:"error",code:"duplicate-object-id",message:`Object id "${o.id}" is used more than once`,objectId:o.id}),P.add(o.id);let M=new Set;for(let o of t.zones??[])M.has(o.id)&&e.push({severity:"error",code:"duplicate-zone-id",message:`Zone id "${o.id}" is used more than once`}),M.add(o.id),o.focalPoint!==void 0&&(!Number.isFinite(o.focalPoint.x)||!Number.isFinite(o.focalPoint.y))&&e.push({severity:"error",code:"invalid-zone-focal-point",message:`Zone "${o.label}" must use a finite focal point`});let T=new Map;for(let o of j)if(!(o.type!=="section"||!o.zone)){if(t.zones?.length&&!M.has(o.zone)){e.push({severity:"error",code:"unknown-section-zone",message:`Section "${o.displayLabel??o.label}" references unknown zone "${o.zone}"`,objectId:o.id});continue}T.has(o.zone)||T.set(o.zone,o)}for(let[o,S]of T){let c=t.zones?.find(d=>d.id===o);c&&(c?.focalPoint||n.push({severity:"warning",code:"missing-zone-focal-point",message:`Zone "${c?.label??o}" uses the legacy floor focal; set its own focal point before publishing`,objectId:S.id}))}for(let o of j)if((o.type==="row"||o.type==="table"||o.type==="booth"||o.type==="gaArea")&&dt(o,e),Gt(o)){if(w++,C+=o.type==="booth"?1:o.type==="row"?Le(o):o.bookAsWhole||o.variableOccupancy?o.seatCount:mt(o).length,p.get(o.label)!==void 0?o.type!=="row"&&e.push({severity:"error",code:"duplicate-object-label",message:`Label "${o.label}" is used by more than one object`,objectId:o.id}):p.set(o.label,o.id),i.has(o.categoryKey)?y.add(o.categoryKey):e.push({severity:"error",code:"unknown-category",message:`"${o.label}" references unknown category "${o.categoryKey}"`,objectId:o.id,categoryKey:o.categoryKey}),o.type==="row"){ee(o.referenceInventorySource)||e.push({severity:"error",code:"invalid-reference-inventory-source",message:`Row "${o.label}" has invalid reference-inventory provenance`,objectId:o.id}),o.seatCount<1&&e.push({severity:"error",code:"empty-row",message:`Row "${o.label}" has no seats`,objectId:o.id});let c=new Set;for(let d of o.overrides??[]){(d.accessibility??[]).filter(x=>!r.has(x)).length&&e.push({severity:"error",code:"invalid-accessibility-type",message:`Row "${o.label}" seat ${d.index+1} uses an unknown accessibility type`,objectId:o.id,seatIndices:[d.index]}),(!Number.isInteger(d.index)||d.index<0||d.index>=o.seatCount||c.has(d.index))&&e.push({severity:"error",code:"invalid-seat-override",message:`Row "${o.label}" has a duplicated or out-of-range seat override`,objectId:o.id,...Number.isInteger(d.index)?{seatIndices:[d.index]}:{}}),c.add(d.index);let v=d.wheelchairSpaceType,h=d.accessible===!0||d.accessibility?.includes("wheelchair");v!==void 0&&v!=="seat-present"&&v!=="no-seat"?e.push({severity:"error",code:"invalid-wheelchair-space",message:`Row "${o.label}" seat ${d.index+1} has an invalid wheelchair-space type`,objectId:o.id,seatIndices:[d.index]}):v&&(!h||d.skip)&&e.push({severity:"error",code:"invalid-wheelchair-space",message:d.skip?`Row "${o.label}" seat ${d.index+1} cannot have a wheelchair-space physical type while skipped from inventory`:`Row "${o.label}" seat ${d.index+1} must include wheelchair accessibility for its physical-space type`,objectId:o.id,seatIndices:[d.index]})}for(let d of Vt(o))ne(d.label)&&e.push({severity:"error",code:"reserved-seat-label",message:`Seat label "${d.label}" uses SeatLayer's reserved GA namespace`,objectId:o.id,seatIndices:[d.index]}),b.get(d.label)!==void 0?I.push({severity:"error",code:"duplicate-seat-label",message:`Seat label "${d.label}" is used more than once`,objectId:o.id,seatIndices:[d.index]}):b.set(d.label,o.id)}else if(o.type==="table"){let c=o.bookAsWhole===!0||o.variableOccupancy===!0;if(o.fill!==void 0&&!De(o.fill)&&e.push({severity:"error",code:"invalid-table-fill",message:`Table "${o.label}" has an invalid surface color`,objectId:o.id}),o.automaticRadius!==void 0&&typeof o.automaticRadius!="boolean"?e.push({severity:"error",code:"invalid-table-automatic-radius",message:`Table "${o.label}" has an invalid automatic-radius setting`,objectId:o.id}):o.automaticRadius===!0&&(o.shape!=="round"||o.radius!==Pe(o.seatCount,o.seatArc))&&e.push({severity:"error",code:"invalid-table-automatic-radius",message:`Table "${o.label}" needs a radius that matches its automatic chair spacing`,objectId:o.id}),o.seatCountsBySide){let h=["top","bottom","left","right"],x=Object.keys(o.seatCountsBySide),$=h.every(_=>Number.isInteger(o.seatCountsBySide[_])&&o.seatCountsBySide[_]>=0&&o.seatCountsBySide[_]<=40),A=$?h.reduce((_,Ct)=>_+o.seatCountsBySide[Ct],0):Number.NaN;(o.shape!=="rect"||x.length!==h.length||x.some(_=>!h.includes(_))||!$||A!==o.seatCount||A<1||A>40)&&e.push({severity:"error",code:"invalid-table-side-counts",message:`Table "${o.label}" needs top, bottom, left, and right whole-number chair counts totaling its ${o.seatCount}-chair capacity`,objectId:o.id})}c&&o.overrides?.length&&e.push({severity:"error",code:"grouped-table-chair-overrides",message:`Grouped table "${o.label}" cannot carry individual-chair overrides`,objectId:o.id,seatIndices:o.overrides.map(h=>h.index)});let d=new Set;for(let h of o.overrides??[]){(h.accessibility??[]).filter(_=>!r.has(_)).length&&e.push({severity:"error",code:"invalid-accessibility-type",message:`Table "${o.label}" chair ${h.index+1} uses an unknown accessibility type`,objectId:o.id,seatIndices:[h.index]}),(!Number.isInteger(h.index)||h.index<0||h.index>=o.seatCount||d.has(h.index))&&e.push({severity:"error",code:"invalid-seat-override",message:`Table "${o.label}" has a duplicated or out-of-range chair override`,objectId:o.id,...Number.isInteger(h.index)?{seatIndices:[h.index]}:{}}),d.add(h.index),h.categoryKey&&!i.has(h.categoryKey)?e.push({severity:"error",code:"unknown-category",message:`Table "${o.label}" chair ${h.index+1} references unknown category "${h.categoryKey}"`,objectId:o.id,seatIndices:[h.index],categoryKey:h.categoryKey}):h.categoryKey&&y.add(h.categoryKey);let $=h.wheelchairSpaceType,A=h.accessible===!0||h.accessibility?.includes("wheelchair");$!==void 0&&$!=="seat-present"&&$!=="no-seat"?e.push({severity:"error",code:"invalid-wheelchair-space",message:`Table "${o.label}" chair ${h.index+1} has an invalid wheelchair-space type`,objectId:o.id,seatIndices:[h.index]}):$&&(!A||h.skip)&&e.push({severity:"error",code:"invalid-wheelchair-space",message:h.skip?`Table "${o.label}" chair ${h.index+1} cannot have a wheelchair-space physical type while skipped from inventory`:`Table "${o.label}" chair ${h.index+1} must include wheelchair accessibility for its physical-space type`,objectId:o.id,seatIndices:[h.index]})}o.bookAsWhole&&o.variableOccupancy?e.push({severity:"error",code:"invalid-table-booking-mode",message:`Table "${o.label}" cannot be sold both as a whole table and with variable occupancy`,objectId:o.id}):o.variableOccupancy?(!Number.isInteger(o.minOccupancy)||!Number.isInteger(o.maxOccupancy)||o.minOccupancy<1||o.maxOccupancy<o.minOccupancy||o.maxOccupancy>o.seatCount)&&e.push({severity:"error",code:"invalid-table-occupancy",message:`Table "${o.label}" needs whole-number minimum and maximum guests from 1 to its ${o.seatCount}-chair capacity`,objectId:o.id}):(o.minOccupancy!=null||o.maxOccupancy!=null)&&e.push({severity:"error",code:"invalid-table-occupancy",message:`Table "${o.label}" has guest bounds without variable-occupancy selling`,objectId:o.id}),ee(o.referenceInventorySource)||e.push({severity:"error",code:"invalid-reference-inventory-source",message:`Table "${o.label}" has invalid reference-inventory provenance`,objectId:o.id}),(o.shape==="round"&&o.radius==null||o.shape==="rect"&&(o.width==null||o.height==null)||o.seatCount<1)&&e.push({severity:"error",code:"bad-table",message:`Table "${o.label}" is missing required dimensions or seats`,objectId:o.id});let v=c?[{label:o.label,index:void 0}]:mt(o);for(let h of v)ne(h.label)&&e.push({severity:"error",code:"reserved-seat-label",message:`Inventory label "${h.label}" uses SeatLayer's reserved GA namespace`,objectId:o.id}),b.get(h.label)!==void 0?I.push({severity:"error",code:"duplicate-seat-label",message:`Inventory label "${h.label}" is used more than once; grouped table labels must be unique`,objectId:o.id,...h.index===void 0?{}:{seatIndices:[h.index]}}):b.set(h.label,o.id)}else if(o.type==="booth"){ee(o.referenceInventorySource)||e.push({severity:"error",code:"invalid-reference-inventory-source",message:`Booth "${o.label}" has invalid reference-inventory provenance`,objectId:o.id});let c=o.label;ne(c)&&e.push({severity:"error",code:"reserved-seat-label",message:`Seat label "${c}" uses SeatLayer's reserved GA namespace`,objectId:o.id}),b.get(c)!==void 0?I.push({severity:"error",code:"duplicate-seat-label",message:`Seat label "${c}" is used more than once`,objectId:o.id}):b.set(c,o.id)}}else if(o.type==="gaArea"){if(!Ne(o))e.push({severity:"error",code:"invalid-ga-inventory-segments",message:`GA area "${o.label}" has invalid joined-area inventory provenance`,objectId:o.id});else for(let l of _e(o))b.get(l)!==void 0?I.push({severity:"error",code:"duplicate-seat-label",message:`GA inventory label "${l}" is used more than once`,objectId:o.id}):b.set(l,o.id);ee(o.referenceInventorySource)||e.push({severity:"error",code:"invalid-reference-inventory-source",message:`GA area "${o.label}" has invalid reference-inventory provenance`,objectId:o.id}),(!B(o.points)||Math.abs(z(o.points))<=1e-7||V(o.points))&&e.push({severity:"error",code:"invalid-ga-outline",message:`GA area "${o.label}" must have a finite, non-self-intersecting polygon outline`,objectId:o.id});let c=o.holes??[],d=Array.isArray(c)&&c.length<=64?c.findIndex(l=>!Array.isArray(l)||l.length>512||!B(l)||Math.abs(z(l))<=1e-7||V(l)?!0:!l.flatMap((h,x)=>{let $=l[(x+1)%l.length];return[h,{x:(h.x+$.x)/2,y:(h.y+$.y)/2}]}).every(h=>G(h,o.points))):0;if(d>=0)e.push({severity:"error",code:"invalid-ga-hole",message:`GA area "${o.label}" has a cutout outside its outline or with invalid geometry`,objectId:o.id,holeIndex:d});else if(c.some((l,v)=>c.slice(v+1).some(h=>J(l,h)))){let l=c.findIndex((v,h)=>c.slice(h+1).some(x=>J(v,x)));e.push({severity:"error",code:"overlapping-ga-holes",message:`GA area "${o.label}" has overlapping cutout polygons`,objectId:o.id,holeIndex:l})}i.has(o.categoryKey)?y.add(o.categoryKey):e.push({severity:"error",code:"unknown-category",message:`"${o.label}" references unknown category "${o.categoryKey}"`,objectId:o.id,categoryKey:o.categoryKey}),o.capacity<1&&e.push({severity:"error",code:"empty-ga",message:`GA area "${o.label}" has zero capacity`,objectId:o.id}),(!Number.isInteger(o.capacity)||o.capacity>ge)&&e.push({severity:"error",code:"invalid-ga-capacity",message:`GA area "${o.label}" capacity must be a whole number from 1 to ${ge}`,objectId:o.id}),w++,C+=Math.max(0,Math.floor(o.capacity))}else if(o.type==="section"){if(o.displayLabel!==void 0){let d=o.displayLabel.normalize("NFKC").trim();d?(d!==o.displayLabel||d.length>80)&&e.push({severity:"error",code:"invalid-display-label",message:`Section "${o.label}" must use a normalized buyer label of 1 to 80 characters`,objectId:o.id}):e.push({severity:"error",code:"unnamed-section",message:`Section "${o.label}" needs a buyer-facing name before seats are added`,objectId:o.id})}if(o.editor?.defaultCategoryKey&&!i.has(o.editor.defaultCategoryKey)&&e.push({severity:"error",code:"unknown-category",message:`Section "${o.label}" references unknown future-seat category "${o.editor.defaultCategoryKey}"`,objectId:o.id}),o.elevation!==void 0&&(!Number.isInteger(o.elevation)||o.elevation<de||o.elevation>q)){let d=Number.isInteger(o.elevation)&&o.elevation>q&&o.elevation<=Te;n.push({severity:"warning",code:d?"legacy-section-elevation":"invalid-section-elevation",message:d?`Section "${o.label}" uses legacy tier ${o.elevation}; set an exact height before normalizing it to tier ${q}`:`Section "${o.label}" elevation must be a whole-number tier from ${de} to ${q}`,objectId:o.id})}if(o.height!==void 0&&(!Number.isFinite(o.height)||o.height<H||o.height>X)&&e.push({severity:"error",code:"invalid-section-height",message:`Section "${o.label}" exact height must be between ${H} and ${X} metres`,objectId:o.id}),o.rake!==void 0&&(!Number.isFinite(o.rake)||o.rake<ue||o.rake>fe)&&e.push({severity:"error",code:"invalid-section-rake",message:`Section "${o.label}" rake must be between ${ue}\xB0 and ${fe}\xB0`,objectId:o.id}),o.surfaceKind!==void 0&&o.surfaceKind!=="flat"&&o.surfaceKind!=="rakedRows"&&e.push({severity:"error",code:"invalid-section-surface-kind",message:`Section "${o.label}" surfaceKind must be 'flat' or 'rakedRows'`,objectId:o.id}),!B(o.outline)||Math.abs(z(o.outline))<=1e-7||V(o.outline)){e.push({severity:"error",code:"invalid-section-outline",message:`Section "${o.label}" must have a finite, non-self-intersecting polygon outline`,objectId:o.id});continue}if(o.outlinePath){let d=[];try{d=Ae(o.outlinePath)}catch{}(!Oe(o.outlinePath)||!d.length||Math.hypot(o.outlinePath.start.x-o.outline[0].x,o.outlinePath.start.y-o.outline[0].y)>1e-4||!B(d)||Math.abs(z(d))<=1e-7||V(d))&&e.push({severity:"error",code:"invalid-section-outline-path",message:`Section "${o.label}" has an invalid or inconsistent curved outline path`,objectId:o.id,edgeIndex:at(o)})}if(o.referenceSource&&(!/^ref_[0-9a-f-]{36}$/.test(o.referenceSource.assetId)||!/^(?:reg|ai)_[0-9a-f]{16}$/.test(o.referenceSource.regionId))&&e.push({severity:"error",code:"invalid-section-reference-source",message:`Section "${o.label}" has invalid opaque reference provenance`,objectId:o.id}),ut(o)||e.push({severity:"error",code:"invalid-section-inventory-exclusion",message:`Section "${o.label}" has incomplete or mismatched non-sellable evidence`,objectId:o.id}),o.logicalSectionId!==void 0&&!o.logicalSectionId.trim())e.push({severity:"error",code:"invalid-logical-section-id",message:`Section "${o.label}" has an empty logical section id`,objectId:o.id});else if(o.logicalSectionId){let d=JSON.stringify({displayLabel:o.displayLabel??null,entrance:o.entrance??null,viewFromSeatUrl:o.viewFromSeatUrl??null,viewFromSeatMeta:o.viewFromSeatMeta??null,confidenceEvidence:o.confidenceEvidence??null,zone:o.zone??null,labelStyle:o.labelPresentation?.labelStyle??null,labelVisible:o.labelPresentation?.visible!==!1}),l=k.get(o.logicalSectionId);l&&(l.label!==o.label||l.semanticSignature!==d)?e.push({severity:"error",code:"inconsistent-logical-section",message:`Logical section "${o.logicalSectionId}" must use one technical label and buyer-facing presentation across every component`,objectId:o.id}):l||k.set(o.logicalSectionId,{label:o.label,semanticSignature:d})}let S=o.holes??[];if(!Array.isArray(S)||S.length>64){e.push({severity:"error",code:"invalid-section-hole",message:`Section "${o.label}" has an invalid opening collection`,objectId:o.id});continue}let c=-1;for(let d=0;d<S.length;d++){let l=S[d];if(!Array.isArray(l)||l.length>512||!B(l)||Math.abs(z(l))<=1e-7||V(l)){c=d;break}if(!l.flatMap((h,x)=>{let $=l[(x+1)%l.length];return[h,{x:(h.x+$.x)/2,y:(h.y+$.y)/2}]}).every(h=>G(h,o.outline))){c=d;break}}if(c>=0)e.push({severity:"error",code:"invalid-section-hole",message:`Section "${o.label}" has an opening outside its outline or with an invalid shape`,objectId:o.id,holeIndex:c});else if(S.some((d,l)=>S.slice(l+1).some(v=>J(d,v)))){let d=S.findIndex((l,v)=>S.slice(v+1).some(h=>J(l,h)));e.push({severity:"error",code:"overlapping-section-holes",message:`Section "${o.label}" has overlapping openings`,objectId:o.id,holeIndex:d})}}let N=t.floors?.length?t.floors.map(o=>o.objects):[t.objects];for(let o of N){let S=o.filter(c=>c.type==="section");for(let c of o.filter(d=>d.type==="text")){let d=c.iconKey;d!==void 0&&!He(d)&&e.push({severity:"error",code:"invalid-icon-key",message:`Venue icon "${c.text||c.id}" references an unknown symbol`,objectId:c.id});let l=c.fontFamily;l!==void 0&&(typeof l!="string"||l.normalize("NFKC").trim()!==l||l.length<1||l.length>120)&&e.push({severity:"error",code:"invalid-text-font-family",message:`Text "${c.text||c.id}" font family must contain 1 to 120 normalized characters`,objectId:c.id});let v=c.background;(c.width!==void 0&&(!Number.isFinite(c.width)||c.width<40||c.width>1200)||c.align!==void 0&&!["left","center","right"].includes(c.align)||c.lineHeight!==void 0&&(!Number.isFinite(c.lineHeight)||c.lineHeight<.8||c.lineHeight>3)||c.letterSpacing!==void 0&&(!Number.isFinite(c.letterSpacing)||c.letterSpacing<-2||c.letterSpacing>20)||c.opacity!==void 0&&(!Number.isFinite(c.opacity)||c.opacity<.1||c.opacity>1)||v!==void 0&&(!/^#[0-9a-f]{6}$/i.test(v.color)||v.padding!==void 0&&(!Number.isFinite(v.padding)||v.padding<0||v.padding>40)||v.cornerRadius!==void 0&&(!Number.isFinite(v.cornerRadius)||v.cornerRadius<0||v.cornerRadius>40)||v.opacity!==void 0&&(!Number.isFinite(v.opacity)||v.opacity<.1||v.opacity>1)))&&e.push({severity:"error",code:"invalid-text-layout",message:`Text "${c.text||c.id}" has invalid width, spacing, opacity, alignment, or background layout`,objectId:c.id})}for(let c of o.filter(d=>d.type==="shape")){if(c.eventConfigurationIds!==void 0){let v=c.eventConfigurationIds;Array.isArray(v)&&v.length>0&&v.length<=20&&v.every(x=>typeof x=="string"&&x.normalize("NFKC").trim()===x&&x.length>=1&&x.length<=100)&&new Set(v).size===v.length||e.push({severity:"error",code:"invalid-shape-configurations",message:`Shape "${c.label||c.id}" must reference 1 to 20 unique event configuration ids`,objectId:c.id})}if(c.heightM!==void 0&&(!Number.isFinite(c.heightM)||c.heightM<.05||c.heightM>50)&&e.push({severity:"error",code:"invalid-shape-height",message:`Shape "${c.label||c.id}" height must be between 0.05 m and 50 m`,objectId:c.id}),c.stroke!==void 0&&(!c.stroke||typeof c.stroke.color!="string"||!/^#[0-9a-f]{6}$/i.test(c.stroke.color)||!Number.isFinite(c.stroke.width)||c.stroke.width<.5||c.stroke.width>40)&&e.push({severity:"error",code:"invalid-shape-stroke",message:`Shape "${c.label||c.id}" stroke must use a six-digit color and width from 0.5 to 40 chart units`,objectId:c.id}),(c.lineCap!==void 0||c.lineJoin!==void 0||c.startEnding!==void 0||c.endEnding!==void 0)&&!ve(c.kind)?e.push({severity:"error",code:"invalid-shape-line-style-applicability",message:`Shape "${c.label||c.id}" may use line caps, joins, and end decorations only when it is an open line or polyline`,objectId:c.id}):ve(c.kind)&&(c.lineCap!==void 0&&!Xe.includes(c.lineCap)||c.lineJoin!==void 0&&!Ye.includes(c.lineJoin)||c.startEnding!==void 0&&!he.includes(c.startEnding)||c.endEnding!==void 0&&!he.includes(c.endEnding))&&e.push({severity:"error",code:"invalid-shape-line-style",message:`Shape "${c.label||c.id}" has an unsupported line cap, join, or ending`,objectId:c.id}),c.kind==="polygon"){let v=nt(c.points??[]);v.ok||e.push({severity:"error",code:"invalid-shape-polygon",message:`Shape "${c.label||c.id}" has invalid polygon geometry: ${v.message}`,objectId:c.id})}let l=ct(c);if(l){for(let v of S)if(st(l,v.outline)){e.push({severity:"error",code:"reference-focal-overlaps-section",message:`Reference focal area "${c.label??c.id}" overlaps section "${v.label}"`,objectId:c.id});break}}}}C>me&&e.push({severity:"error",code:"inventory-capacity-exceeded",message:`Chart has ${C} bookable units; the maximum is ${me}`}),e.push(...I.slice(0,5)),I.length>5&&e.push({severity:"error",code:"duplicate-seat-label",message:`${I.length} seats share a label with another seat; the first 5 are listed above. Seat labels must be unique across the whole chart.`});for(let o of ie(t)){let S=o.families[0]?.targets[0];n.push({severity:"warning",code:"category-inventory-family-conflict",message:et(o),categoryKey:o.categoryKey,...S?{objectId:S.id,floorId:S.floorId}:{},relatedObjectIds:o.objectIds,categoryInventoryFamilies:o.families})}t.focalPoint||n.push({severity:"warning",code:"missing-focal-point",message:"Chart has no focal point set"}),w===0&&n.push({severity:"warning",code:"no-bookables",message:"Chart has no rows, tables, booths, or GA areas"});for(let o of y)if(s.get(o)===!1){let S=t.categories.find(c=>c.key===o);n.push({severity:"warning",code:"unpriced-category",message:`Category "${S?.label??o}" is used but has no price`,categoryKey:o})}return[...e,...n]}var Qt=9,It="#f7f8fb",qt="#f5f6f8",wt="#8b93a7",Ht="#0b1220",Xt="#0b1220",Yt="#ffffff",Wt=100;function E(t,e=2){let n=10**e;return Math.round(t*n)/n}function R(t){return{source:"quality",...t}}function Zt(t){return t.code==="missing-focal-point"||t.code==="missing-zone-focal-point"?"navigation":"structure"}function Ce(t){return Qt*qe(t.theme?.seatScale)}function St(t){let e=[];for(let n of t.objects)n.type==="row"?e.push(...D(n)):n.type==="table"&&e.push(...Y(n));return e}function Jt(t){let e={rowSeats:0,tableSeats:0,booths:0,gaCapacity:0};for(let n of t)for(let i of n.objects)i.type==="row"?e.rowSeats+=D(i).length:i.type==="table"?e.tableSeats+=Y(i).length:i.type==="booth"?e.booths+=1:i.type==="gaArea"&&(e.gaCapacity+=Math.max(0,Math.floor(i.capacity)));return{inventoryByKind:e,bookableUnits:e.rowSeats+e.tableSeats+e.booths+e.gaCapacity}}function L(t,e){t.filter(n=>n.code===e.code).length<Wt&&t.push(e)}function eo(t,e,n){let i=Ce(t),r=2*i,s=2.3*i,y=0,f=0,m=1/0;for(let a of e){let u=new Map(a.objects.filter(w=>w.type==="row").map(w=>[w.id,w])),g=w=>{let C=a.objects.find(T=>T.id===w);if(!C||C.type!=="row"&&C.type!=="table")return"another seating object";let O=C.type==="row"?D(C):Y(C),j=O.length?{x:O.reduce((T,N)=>T+N.x,0)/O.length,y:O.reduce((T,N)=>T+N.y,0)/O.length}:C.type==="row"?C.origin:C.center,P=a.objects.find(T=>T.type==="section"&&W(j,T.outline,T.holes)),M=C.type==="row"?`Row \u201C${C.label}\u201D`:`Table \u201C${C.label}\u201D`;return P?.type==="section"?`${M} in \u201C${P.label}\u201D`:M},p=St(a);y+=p.length;let b=s,I=new Map,k=new Map;for(let w of p){let C=Math.floor(w.x/b),O=Math.floor(w.y/b);for(let M=-1;M<=1;M++)for(let T=-1;T<=1;T++){let N=I.get(`${C+M}:${O+T}`)??[];for(let o of N){f++;let S=Math.hypot(w.x-o.x,w.y-o.y);if(m=Math.min(m,S),S>=s)continue;let d=(w.rowId<o.rowId?[w.rowId,o.rowId]:[o.rowId,w.rowId]).join("|"),l=k.get(d);(!l||S<l.distance)&&k.set(d,{a:w,b:o,distance:S})}}let j=`${C}:${O}`,P=I.get(j)??[];P.push(w),I.set(j,P)}for(let w of k.values()){let C=w.a.rowId===w.b.rowId,O=u.get(w.a.rowId),j=u.get(w.b.rowId),P=!C&&O?.segmentedRow?.repeatLabelOnComponents===!0&&j?.segmentedRow?.repeatLabelOnComponents===!0&&O.segmentedRow.groupId===j.segmentedRow.groupId,M=!!O?.referenceScan&&!!j?.referenceScan&&O.referenceScan.assetId===j.referenceScan.assetId&&O.referenceScan.sectionId===j.referenceScan.sectionId,T=w.distance<r?"error":"warning";if((P||M)&&T==="warning")continue;let N=T==="error"?"seat-overlap":"seat-cramped",o=g(w.a.rowId),S=g(w.b.rowId),c=E(T==="error"?r:s);L(n,R({severity:T,code:N,dimension:"geometry",title:C?`${o} has seats too close together`:`${o} and ${S} are too close together`,message:`The closest seats are ${E(w.distance)} chart units apart; at least ${c} are required.`,action:C?`Increase the seat spacing for ${o}, or use Review safe fixes.`:`Move ${o} or ${S} until they no longer overlap.`,objectId:w.a.rowId,relatedObjectIds:C?[w.a.rowId]:[w.a.rowId,w.b.rowId],floorId:a.id,measured:E(w.distance),minimum:E(T==="error"?r:s),autoFixable:C}))}}return{seats:y,checkedSeatPairs:f,minimumSeatDistance:Number.isFinite(m)?E(m):null}}function se(t){let{width:e,height:n}=$e(t);if(!t.rotation)return{x:t.position.x,y:t.position.y,width:e,height:n};let i=[{x:0,y:0},{x:e,y:0},{x:e,y:n},{x:0,y:n}].map(r=>{let s=ke(r,t.rotation);return{x:t.position.x+s.x,y:t.position.y+s.y}});return Qe(i)}function xt(t,e,n=0){return t.x<e.x+e.width+n&&t.x+t.width+n>e.x&&t.y<e.y+e.height+n&&t.y+t.height+n>e.y}function xe(t,e,n){let i=te(e.x,t.x,t.x+t.width),r=te(e.y,t.y,t.y+t.height);return(e.x-i)**2+(e.y-r)**2<n**2}function to(t,e,n){let i=Ce(t),r=0;for(let s of e){let y=s.objects.filter(m=>m.type==="text"),f=St(s);r+=y.length;for(let m=0;m<y.length;m++){let a=y[m],u=se(a),g=f.find(p=>xe(u,p,i));g&&L(n,R({severity:"warning",code:"label-collision",dimension:"labels",message:`Text \u201C${a.text}\u201D overlaps seat ${g.label}`,objectId:a.id,relatedObjectIds:[a.id,g.rowId],floorId:s.id,autoFixable:!0}));for(let p=0;p<m;p++){let b=y[p];xt(u,se(b),2)&&L(n,R({severity:"warning",code:"label-collision",dimension:"labels",message:`Text \u201C${a.text}\u201D overlaps text \u201C${b.text}\u201D`,objectId:a.id,relatedObjectIds:[a.id,b.id],floorId:s.id,autoFixable:!0}))}}}return r}function Se(t){return t.normalize("NFKC").trim().toLowerCase().replace(/\s+/g," ")}function oo(t,e,n){let i=new Map;for(let f of e)for(let m of f.objects){let a=m.type,u=a==="row"||a==="table"||a==="booth"||a==="gaArea",g=u||a==="section";if(u&&!m.categoryKey.trim()){let p=a==="gaArea"?"GA area":a==="row"?"Row":a==="table"?"Table":"Booth";L(n,R({severity:"warning",code:"object-uncategorized",dimension:"structure",title:`${p} \u201C${m.label||m.id}\u201D has no category`,message:`${p} \u201C${m.label||m.id}\u201D is not assigned to any category, so buyers see no price or colour for it.`,action:"Assign a category to this object in the inspector, or create one in the Categories tab first.",objectId:m.id,floorId:f.id,autoFixable:!1}))}if(g){let p=(m.type==="section"?m.displayLabel??m.label:m.label)??"";if(p.trim()){if(a==="table"||a==="booth"||a==="gaArea"){let b=Se(p),I=i.get(b);I&&I.raw!==p?L(n,R({severity:"warning",code:"duplicate-object-label-normalized",dimension:"labels",title:`\u201C${p}\u201D and \u201C${I.raw}\u201D read as the same label`,message:`Labels \u201C${p}\u201D and \u201C${I.raw}\u201D differ only by case, spacing, or accents, so buyers cannot tell them apart.`,action:"Make the two labels visibly distinct.",objectId:m.id,relatedObjectIds:[m.id,I.id],floorId:f.id,autoFixable:!1})):I||i.set(b,{id:m.id,raw:p})}}else{let b=a==="gaArea"?"A GA area":a==="section"?"A section":a==="row"?"A row":a==="table"?"A table":"A booth";L(n,R({severity:"warning",code:"object-unlabeled",dimension:"labels",title:`${b} has no label`,message:`${b} has an empty label; buyers rely on labels to identify what they are booking.`,action:"Give this object a short, unique label in the inspector.",objectId:m.id,floorId:f.id,autoFixable:!1}))}}}let r=[];for(let f of e){let m=f.objects.filter(a=>a.type==="row"||a.type==="table"||a.type==="booth"||a.type==="gaArea");for(let a of f.objects)if(!(a.type!=="section"||a.referenceInventoryExclusion||m.some(g=>W(oe(g),a.outline,a.holes)))){if(a.referenceSource){r.push({id:a.id,floorId:f.id});continue}L(n,R({severity:"warning",code:"empty-section",dimension:"structure",title:`Section \u201C${a.displayLabel??a.label}\u201D is empty`,message:`Section \u201C${a.displayLabel??a.label}\u201D contains no rows, tables, booths, or GA areas.`,action:"Add seating inside this section (Fill with rows), or remove the empty section.",objectId:a.id,floorId:f.id,autoFixable:!1}))}}r.length&&L(n,R({severity:"warning",code:"empty-section",dimension:"structure",title:r.length===1?"1 traced section has no seating yet":`${r.length} traced sections have no seating yet`,message:`${r.length} section${r.length===1?"":"s"} traced from the reference image contain${r.length===1?"s":""} no rows, tables, booths, or GA areas.`,action:"Fill them with rows, or remove the ones the venue does not sell.",objectId:r[0].id,relatedObjectIds:r.map(f=>f.id),floorId:r[0].floorId,autoFixable:!1}));let s=new Map,y=new Map;for(let f of e){let m=[];for(let a of f.objects)a.type!=="section"||a.outline.length<3||m.push({id:a.logicalSectionId??a.id,outline:a.outline,...a.holes?{holes:a.holes}:{},bounds:so(a.outline)});for(let a of f.objects){if(a.type!=="row")continue;let u=(a.segmentedRow?.displayLabel??a.displayLabel??a.label??"").trim(),g=(a.displayType??"").trim(),p=u&&g&&Se(g)!=="row"?`${g} ${u}`:u,b="";if(m.length){let C=oe(a),O=m.find(j=>C.x>=j.bounds.minX&&C.x<=j.bounds.maxX&&C.y>=j.bounds.minY&&C.y<=j.bounds.maxY&&W(C,j.outline,j.holes));O&&(b=O.id)}let I=`${f.id}\0${b}\0${Se(p)}`,k=a.segmentedRow?.groupId??a.id;if(!p){let C=`${f.id}\0${b}`,O=y.get(C);O?(O.ids.push(a.id),O.logical.set(k,[...O.logical.get(k)??[],a])):y.set(C,{ids:[a.id],logical:new Map([[k,[a]]]),floorId:f.id});continue}let w=s.get(I);w?(w.ids.push(a.id),w.logical.set(k,[...w.logical.get(k)??[],a])):s.set(I,{ids:[a.id],logical:new Map([[k,[a]]]),floorId:f.id,raw:p})}}for(let{ids:f,logical:m,floorId:a,raw:u}of s.values()){let g=m.size;g<2||pt([...m.values()])&&L(n,R({severity:"warning",code:"duplicate-row-label",dimension:"labels",title:`${g} rows share the name \u201C${u}\u201D`,message:`${g} rows share the label \u201C${u}\u201D, so buyers cannot tell which row a seat belongs to.`,action:"Rename them so each row reads differently \u2014 for example the section or box each belongs to.",objectId:f[0],relatedObjectIds:f,floorId:a,autoFixable:!1}))}for(let{ids:f,logical:m,floorId:a}of y.values()){let u=m.size;u<2||pt([...m.values()])&&L(n,R({severity:"warning",code:"unnamed-row-collision",dimension:"labels",title:`${u} rows have no name`,message:`${u} rows in the same area have no name and repeat each other\u2019s seat numbers, so buyers cannot tell which row a seat belongs to.`,action:"Give each of these rows a name \u2014 for example the box each belongs to \u2014 so a ticket can say which row a seat is in.",objectId:f[0],relatedObjectIds:f,floorId:a,autoFixable:!1}))}if(t.floors&&t.floors.length>1)for(let f of t.floors)f.objects.length===0&&L(n,R({severity:"warning",code:"unused-floor",dimension:"structure",title:`Floor \u201C${f.name}\u201D is empty`,message:`Floor \u201C${f.name}\u201D has no objects on it.`,action:"Add seating to this floor, or delete it from the floor list below the canvas.",floorId:f.id,autoFixable:!1}))}var no=5,io=16;function ro(t,e,n){for(let i of e){let r=i.focalPoint??t.focalPoint;if(r)for(let s of i.objects){if(s.type!=="section"||s.outline.length<3)continue;let{rake:y}=Re(s);if(y<no)continue;let f=s.outline.map(p=>Math.hypot(p.x-r.x,p.y-r.y)),m=Math.max(...f);if(m<=0)continue;let a=(m-Math.min(...f))/m;if(y*a<=io)continue;let g=s.displayLabel??s.label;L(n,R({severity:"warning",code:"section-rake-inconsistent",dimension:"geometry",title:`Section \u201C${g}\u201D is too deep for a single rake`,message:`Section \u201C${g}\u201D spans ${Math.round(a*100)}% of its distance to the stage at a ${Math.round(y)}\xB0 rake, so one rake can't represent its sightlines faithfully \u2014 a real tier this deep changes slope at a cross-aisle.`,action:"Split this section at the cross-aisle into two sections, each with its own rake.",objectId:s.id,floorId:i.id,autoFixable:!1}))}}}function ao(t,e,n){let i=t.theme?.background??It,r=qt,s=new Map;for(let a of e)for(let u of a.objects){if(u.type!=="gaArea")continue;let g=s.get(u.categoryKey)??[];g.push({id:u.id,floorId:a.id}),s.set(u.categoryKey,g)}for(let a of t.categories){let u=F(a.color,i),g=F(a.color,r);if(u==null||g==null){L(n,R({severity:"error",code:"invalid-category-color",dimension:"contrast",message:`Category \u201C${a.label}\u201D does not use a supported hex color`,categoryKey:a.key}));continue}let p=Math.min(u,g);p<3&&L(n,R({severity:"warning",code:"category-contrast-low",dimension:"contrast",title:`Category \u201C${a.label}\u201D is hard to see`,message:`Category \u201C${a.label}\u201D reaches only ${E(p)}:1 across dark and light chart backgrounds; 3:1 is required`,action:`Choose a lighter or darker color for \u201C${a.label}\u201D until this warning clears.`,categoryKey:a.key,measured:E(p),minimum:3,autoFixable:!1}));let b=s.get(a.key)??[];if(b.length){let I=pe(a.color,i,be),k=pe(a.color,r,be),w=Math.min(F(I,i)??0,F(k,r)??0);w<3&&L(n,R({severity:"warning",code:"ga-contrast-low",dimension:"contrast",message:`GA category \u201C${a.label}\u201D reaches only ${E(w)}:1 after its rendered opacity is composited; 3:1 is required`,objectId:b[0].id,categoryKey:a.key,floorId:b[0].floorId,relatedObjectIds:b.map(C=>C.id),measured:E(w),minimum:3,autoFixable:!1}))}}for(let a=0;a<t.categories.length;a++)for(let u=0;u<a;u++){let g=t.categories[a],p=t.categories[u],b=Ke(g.color,p.color);b!=null&&b<25&&L(n,R({severity:"warning",code:"category-colors-too-similar",dimension:"contrast",title:`\u201C${g.label}\u201D and \u201C${p.label}\u201D look too similar`,message:`Categories \u201C${g.label}\u201D and \u201C${p.label}\u201D are only \u0394E ${E(b)} apart; 25 is required`,action:"Pick a visibly different color for either category so buyers can tell them apart.",categoryKey:g.key,measured:E(b),minimum:25,autoFixable:!1}))}for(let a of e){let u=a.objects.filter(g=>g.type==="text");for(let g of u){let p=g.color??t.theme?.textColor??wt,b=F(p,i),I=g.fontSize>=18?3:4.5;(b==null||b<I)&&L(n,R({severity:"warning",code:"text-contrast-low",dimension:"contrast",message:`Text \u201C${g.text}\u201D has ${E(b??0)}:1 contrast against the chart background; ${I}:1 is required`,objectId:g.id,floorId:a.id,measured:E(b??0),minimum:I,autoFixable:!0}))}}if(t.theme?.selectionColor){let a=F(t.theme.selectionColor,i);(a==null||a<3)&&L(n,R({severity:"warning",code:"selection-contrast-low",dimension:"contrast",title:"The selection color is hard to see",message:`Selection rings have ${E(a??0)}:1 contrast against the chart background; 3:1 is required.`,action:"In Theme, choose a Selection color that stands out clearly from the Background color.",measured:E(a??0),minimum:3,autoFixable:!1}))}if(t.theme?.textColor){let a=F(t.theme.textColor,i);(a==null||a<3)&&L(n,R({severity:"warning",code:"theme-text-contrast-low",dimension:"contrast",title:"The theme text color is hard to read",message:`Theme text has ${E(a??0)}:1 contrast against the chart background; 3:1 is required.`,action:"In Theme, choose a Text color with stronger contrast against the Background color.",measured:E(a??0),minimum:3,autoFixable:!1}))}let y=t.theme?.seatLabelColor??Ht,f=new Map,m=(a,u,g)=>{let p=f.get(a)??new Map,b=p.get(u)??[];b.push(g),p.set(u,b),f.set(a,p)};for(let a of e)for(let u of a.objects)if(u.type==="row")for(let g of re(u).keys())m(g,"seat",u.id);else if(u.type==="table")for(let g of re(u).keys())m(g,"table seat",u.id);else u.type==="booth"&&m(u.categoryKey,"booth",u.id);for(let a of t.categories){let u=f.get(a.key);if(u)for(let[g,p]of u){let b=g==="booth"?ze:Be,I=Ge(Ue,600),k=Ve(a.color,y),w=F(k,a.color);(w==null||w<I)&&L(n,R({severity:"warning",code:"bookable-label-contrast-low",dimension:"contrast",message:`${g==="booth"?"Booth":g==="seat"?"Seat":"Table-seat"} labels use ${b}u type and have ${E(w??0)}:1 contrast on category \u201C${a.label}\u201D; ${I}:1 is required for small text`,objectId:p[0],relatedObjectIds:p,measured:E(w??0),minimum:I,autoFixable:!0}))}}}function pt(t){if(t.length>24)return!0;let e=new Set;for(let n of t){let i=new Set;for(let r of n)for(let s of D(r)){let y=s.label,f=y.lastIndexOf("-");i.add(f>=0?y.slice(f+1):y)}if(!i.size)return!0;for(let r of i)if(e.has(r))return!0;for(let r of i)e.add(r)}return!1}function so(t){let e=1/0,n=1/0,i=-1/0,r=-1/0;for(let s of t)s.x<e&&(e=s.x),s.y<n&&(n=s.y),s.x>i&&(i=s.x),s.y>r&&(r=s.y);return{minX:e,minY:n,maxX:i,maxY:r}}function co(t,e){for(let n of t){let i=n.objects.filter(r=>r.type==="section");if(!(i.length<2))for(let r of n.objects){if(!(r.type==="row"||r.type==="table"||r.type==="booth"||r.type==="gaArea"))continue;let y=oe(r),f=i.filter(b=>W(y,b.outline,b.holes)),m=new Map;for(let b of f){let I=b.logicalSectionId??b.id,k=m.get(I)??[];k.push(b),m.set(I,k)}if(m.size<2)continue;let a=[...m.values()],u=a.map(b=>`Section \u201C${b[0].displayLabel??b[0].label}\u201D`),g=u.length===2?u.join(" and "):`${u.slice(0,-1).join(", ")}, and ${u[u.length-1]}`,p=r.type==="gaArea"?"GA area":r.type==="row"?"Row":r.type==="table"?"Table":"Booth";L(e,R({severity:"warning",code:"ambiguous-section-ownership",dimension:"structure",title:`${p} \u201C${r.label}\u201D belongs to more than one section`,message:`${p} \u201C${r.label}\u201D has its center inside ${g}, so its buyer section is unclear.`,action:"Adjust the boundaries until this object sits in one Section. If the overlapping shapes are meant to form one Section, combine them first.",objectId:r.id,relatedObjectIds:[r.id,...a.flatMap(b=>b.map(I=>I.id))],floorId:n.id,autoFixable:!1}))}}}var lo={structure:20,geometry:30,contrast:25,labels:15,navigation:10},uo={"seat-overlap":15,"seat-cramped":4,"label-collision":4,"category-contrast-low":3,"ga-contrast-low":3,"category-colors-too-similar":3,"invalid-category-color":10,"text-contrast-low":4,"bookable-label-contrast-low":3,"selection-contrast-low":3,"theme-text-contrast-low":3,"missing-focal-point":10,"object-uncategorized":3,"object-unlabeled":3,"duplicate-object-label-normalized":2,"empty-section":2,"unused-floor":2,"ambiguous-section-ownership":4,"category-inventory-family-conflict":10};function fo(t){let e={...lo};for(let r of t){let s=r.severity==="error"?10:2;e[r.dimension]=Math.max(0,e[r.dimension]-(uo[r.code]??s))}let n=Object.values(e).reduce((r,s)=>r+s,0),i=n>=95?"A":n>=85?"B":n>=70?"C":n>=55?"D":"F";return{overall:n,dimensions:e,errorFree:t.every(r=>r.severity!=="error"),grade:i}}var yo=new Set(["unpriced-category","object-uncategorized"]);function ht(t,e={}){let n=ye(t),i=bt(t).filter(u=>u.code!=="missing-zone-focal-point"||e.requireExplicitZoneFocals).map(u=>{let g=u.objectId?n.find(I=>I.objects.some(k=>k.id===u.objectId))?.id:void 0,p=u.code==="category-inventory-family-conflict",b=p?t.categories.find(I=>I.key===u.categoryKey):void 0;return R({...u,...p?{severity:"error",title:`Category \u201C${b?.label??u.categoryKey??"Unknown"}\u201D spans incompatible inventory types`,action:"Show the affected objects, then review the safe category split. The repair preserves price, ticket tiers, accessibility assignments, and source provenance."}:{},...e.requireExplicitZoneFocals&&u.code==="missing-zone-focal-point"?{severity:"error"}:{},...g?{floorId:g}:{},source:"structural",dimension:Zt(u),autoFixable:p})}),r=eo(t,n,i),s=Jt(n),y=to(t,n,i);if(oo(t,n,i),co(n,i),ro(t,n,i),ao(t,n,i),n.reduce((u,g)=>u+g.objects.filter(p=>p.type==="row"||p.type==="table"||p.type==="booth"||p.type==="gaArea").length,0)===0){let u=new Set(["missing-focal-point","no-bookables"]);for(let g=i.length-1;g>=0;g--)u.has(i[g].code)&&i.splice(g,1)}if(e.requirePricedInventory)for(let u=0;u<i.length;u++)yo.has(i[u].code)&&(i[u]={...i[u],severity:"error"});let m=i.filter(u=>u.severity==="error"),a=i.filter(u=>u.severity==="warning");return{issues:i,errors:m,warnings:a,metrics:{floors:n.length,objects:n.reduce((u,g)=>u+g.objects.length,0),seats:r.seats,bookableUnits:s.bookableUnits,inventoryByKind:s.inventoryByKind,categories:t.categories.length,freeTextLabels:y,checkedSeatPairs:r.checkedSeatPairs,minimumSeatDistance:r.minimumSeatDistance},score:fo(i),deferredRules:["rendered-row-label-decollision","rendered-bookable-state-contrast","section-focus-opacity-and-backdrop","24px-pointer-hit-target","reference-image-diff","sightline-blocked","ga-density-high"]}}function go(t,e){if(t.seatCount<2||t.seatSpacing>=e)return!1;let n=le(D(t));t.seatSpacing=E(e,3);let i=le(D(t));return t.origin.x=E(t.origin.x+n.x-i.x,3),t.origin.y=E(t.origin.y+n.y-i.y,3),!0}function mo(t,e){if(t.seatCount<2)return!1;let n=!1;if(t.shape==="round"){let i=te(t.seatArc??360,0,360),r=(i>=360?360/t.seatCount:i/(t.seatCount-1))*Math.PI/180;if(r>0){let s=e/(2*Math.sin(r/2)),y=Math.max(1,s-16);(t.radius??40)<y&&(t.radius=E(y,3),n=!0)}}else{let i=Me(t),r=Math.max(i.top,i.bottom),s=Math.max(i.left,i.right);r>1&&(t.width??80)/r<e&&(t.width=E(r*e,3),n=!0),s>1&&(t.height??50)/s<e&&(t.height=E(s*e,3),n=!0)}return n}function bo(t){return[Xt,Yt].map(n=>({color:n,minimum:Math.min(...t.map(i=>F(n,i)??0))})).sort((n,i)=>i.minimum-n.minimum)[0].color}function vt(t,e,n){let i=se(t),r=0;for(let s of e)s.type==="row"?r+=D(s).filter(y=>xe(i,y,n)).length:s.type==="table"?r+=Y(s).filter(y=>xe(i,y,n)).length:s.type==="text"&&s.id!==t.id&&xt(i,se(s),2)&&r++;return r}function po(t,e,n){if(vt(t,e,n)===0)return!1;let r={...t.position},s=Math.max(12,t.fontSize*1.25),y=[[0,-1],[1,0],[0,1],[-1,0],[1,-1],[1,1],[-1,1],[-1,-1]];for(let f=1;f<=12;f++)for(let[m,a]of y)if(t.position={x:E(r.x+m*s*f,3),y:E(r.y+a*s*f,3)},vt(t,e,n)===0)return!0;return t.position=r,!1}function on(t){let e=JSON.parse(JSON.stringify(t)),n=ht(e),i=[],r=ot(e);if(r.changed){e=r.doc;for(let u of r.changes){let g=r.before.find(b=>b.categoryKey===u.categoryKey),p=g?.families.map(b=>b.label).join(", ")??"inventory families";i.push({code:"category-inventory-family-conflict",objectId:g?.objectIds[0],message:`Split category \u201C${u.categoryLabel}\u201D across ${p}; preserved its commercial metadata and reassigned ${u.reassignments.length} affected object${u.reassignments.length===1?"":"s"}`})}}let s=Ce(e),y=2.5*s,f=ye(e);for(let u of f)for(let g of u.objects)if(g.type==="row"){let p=g.seatSpacing;go(g,y)&&i.push({code:p<2*s?"seat-overlap":"seat-cramped",objectId:g.id,message:`Expanded ${g.id} to the ${E(y)}u target pitch while preserving its centre`})}else g.type==="table"&&mo(g,y)&&i.push({code:"seat-cramped",objectId:g.id,message:`Expanded ${g.id} so its perimeter seats meet the ${E(y)}u target pitch`});let m=e.theme?.background??It;for(let u of f)for(let g of u.objects){if(g.type!=="text")continue;let p=g.color??e.theme?.textColor??wt,b=g.fontSize>=18?3:4.5;(F(p,m)??0)<b&&(g.color=bo([m]),i.push({code:"text-contrast-low",objectId:g.id,message:`Changed ${g.id} to the highest-contrast black/white ink`}))}for(let u of f){let g=u.objects.filter(p=>p.type==="text");for(let p of g)po(p,u.objects,s)&&i.push({code:"label-collision",objectId:p.id,message:`Moved ${p.id} to the nearest collision-free deterministic label position`})}e.floors?.length&&(e.objects=e.floors[0].objects);let a=ht(e);return{doc:e,changed:i.length>0,fixes:i,before:n,after:a}}export{Ie as a,re as b,ie as c,et as d,ot as e,vo as f,nt as g,on as h};
@@ -1,7 +1,7 @@
1
- import { c as SeatViewMetadata, i as SectionObject, aH as ZoneDef, C as ChartDoc, P as Point, v as CubicPath, q as Category, k as CategoryTier, a4 as ReferenceDirectSeatImportSource, I as ChartTheme, R as RowObject, ai as ReferenceScanSectionProposal, ag as ReferenceScanProposal, B as BoothObject, G as GAAreaObject, u as ShapeObject, T as TableObject, w as TextObject, aB as TextBackground, e as SeatGlyphKind, A as AccessibilityType, l as SeatOverride, at as SeatConfidenceEvidence, a as ChartObject, J as ConfidenceEvidenceScope } from '../../types-CF7_htTi.cjs';
2
- import { e as CategoryInventoryObjectType } from '../../categoryInventory-CXB_6cKR.cjs';
3
- import { R as RelabelOptions } from '../../labeling-BXgKZTmM.cjs';
4
- export { D as DEFAULT_SECTION_CORNER_SMOOTHING } from '../../labeling-BXgKZTmM.cjs';
1
+ import { c as SeatViewMetadata, i as SectionObject, aH as ZoneDef, C as ChartDoc, P as Point, v as CubicPath, q as Category, k as CategoryTier, a4 as ReferenceDirectSeatImportSource, I as ChartTheme, R as RowObject, ai as ReferenceScanSectionProposal, ag as ReferenceScanProposal, B as BoothObject, G as GAAreaObject, u as ShapeObject, T as TableObject, w as TextObject, aB as TextBackground, e as SeatGlyphKind, A as AccessibilityType, l as SeatOverride, at as SeatConfidenceEvidence, a as ChartObject, J as ConfidenceEvidenceScope } from '../../types-B97dNRwl.cjs';
2
+ import { e as CategoryInventoryObjectType } from '../../categoryInventory-B7amHjdA.cjs';
3
+ import { R as RelabelOptions } from '../../labeling-BFDnb10o.cjs';
4
+ export { D as DEFAULT_SECTION_CORNER_SMOOTHING } from '../../labeling-BFDnb10o.cjs';
5
5
 
6
6
  type ChartObjectIdFactory = (prefix: string) => string;
7
7
  type AutomaticPlacement = 'auto' | 'front' | 'rear' | 'left' | 'right';
@@ -1,7 +1,7 @@
1
- import { c as SeatViewMetadata, i as SectionObject, aH as ZoneDef, C as ChartDoc, P as Point, v as CubicPath, q as Category, k as CategoryTier, a4 as ReferenceDirectSeatImportSource, I as ChartTheme, R as RowObject, ai as ReferenceScanSectionProposal, ag as ReferenceScanProposal, B as BoothObject, G as GAAreaObject, u as ShapeObject, T as TableObject, w as TextObject, aB as TextBackground, e as SeatGlyphKind, A as AccessibilityType, l as SeatOverride, at as SeatConfidenceEvidence, a as ChartObject, J as ConfidenceEvidenceScope } from '../../types-CF7_htTi.js';
2
- import { e as CategoryInventoryObjectType } from '../../categoryInventory-CJAUVm-9.js';
3
- import { R as RelabelOptions } from '../../labeling-DA9cTa22.js';
4
- export { D as DEFAULT_SECTION_CORNER_SMOOTHING } from '../../labeling-DA9cTa22.js';
1
+ import { c as SeatViewMetadata, i as SectionObject, aH as ZoneDef, C as ChartDoc, P as Point, v as CubicPath, q as Category, k as CategoryTier, a4 as ReferenceDirectSeatImportSource, I as ChartTheme, R as RowObject, ai as ReferenceScanSectionProposal, ag as ReferenceScanProposal, B as BoothObject, G as GAAreaObject, u as ShapeObject, T as TableObject, w as TextObject, aB as TextBackground, e as SeatGlyphKind, A as AccessibilityType, l as SeatOverride, at as SeatConfidenceEvidence, a as ChartObject, J as ConfidenceEvidenceScope } from '../../types-B97dNRwl.js';
2
+ import { e as CategoryInventoryObjectType } from '../../categoryInventory-CthzF9K9.js';
3
+ import { R as RelabelOptions } from '../../labeling-BwC8Bksi.js';
4
+ export { D as DEFAULT_SECTION_CORNER_SMOOTHING } from '../../labeling-BwC8Bksi.js';
5
5
 
6
6
  type ChartObjectIdFactory = (prefix: string) => string;
7
7
  type AutomaticPlacement = 'auto' | 'front' | 'rear' | 'left' | 'right';