@seatlayer/core 0.72.1 → 0.74.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/{categoryInventory-Bt-0psga.d.ts → categoryInventory-Bcmnr6ZH.d.ts} +1 -1
  2. package/dist/{categoryInventory-BU1j8Q70.d.cts → categoryInventory-DueSAIBX.d.cts} +1 -1
  3. package/dist/{chunk-O5UWBFUT.js → chunk-3L4M7L5I.js} +1 -1
  4. package/dist/chunk-5JB4VW6B.js +1 -0
  5. package/dist/{chunk-5U25QLSS.js → chunk-6TIKEDC4.js} +1 -1
  6. package/dist/{chunk-YW2WGLRM.js → chunk-BAWUBGWY.js} +1 -1
  7. package/dist/chunk-JLYR66MT.js +1 -0
  8. package/dist/{chunk-KCFEFP6H.js → chunk-KN7GLEAI.js} +1 -1
  9. package/dist/{chunk-KPSJDH3N.js → chunk-N5NRM4NW.js} +1 -1
  10. package/dist/chunk-QLDV5ZGA.js +1 -0
  11. package/dist/{chunk-AM2LRFAY.js → chunk-UX67GDLV.js} +1 -1
  12. package/dist/{chunk-ALE2T36W.js → chunk-YFV4DSSX.js} +1 -1
  13. package/dist/{chunk-NKYPEBW3.js → chunk-ZMYRXJOA.js} +1 -1
  14. package/dist/core/chart-ops/index.cjs +1 -1
  15. package/dist/core/chart-ops/index.d.cts +11 -4
  16. package/dist/core/chart-ops/index.d.ts +11 -4
  17. package/dist/core/chart-ops/index.js +1 -1
  18. package/dist/core/inventory/index.cjs +1 -1
  19. package/dist/core/inventory/index.d.cts +11 -4
  20. package/dist/core/inventory/index.d.ts +11 -4
  21. package/dist/core/inventory/index.js +1 -1
  22. package/dist/core/layout/index.cjs +1 -1
  23. package/dist/core/layout/index.d.cts +5 -5
  24. package/dist/core/layout/index.d.ts +5 -5
  25. package/dist/core/layout/index.js +1 -1
  26. package/dist/core/quality/index.cjs +1 -1
  27. package/dist/core/quality/index.d.cts +3 -3
  28. package/dist/core/quality/index.d.ts +3 -3
  29. package/dist/core/quality/index.js +1 -1
  30. package/dist/core/render-assets/index.cjs +1 -1
  31. package/dist/core/render-assets/index.d.cts +1 -1
  32. package/dist/core/render-assets/index.d.ts +1 -1
  33. package/dist/core/render-assets/index.js +1 -1
  34. package/dist/core/seatConfidence.d.cts +1 -1
  35. package/dist/core/seatConfidence.d.ts +1 -1
  36. package/dist/core/sections/index.cjs +1 -1
  37. package/dist/core/sections/index.d.cts +5 -5
  38. package/dist/core/sections/index.d.ts +5 -5
  39. package/dist/core/sections/index.js +1 -1
  40. package/dist/{eventConfigurations-DfVUGyCg.d.ts → eventConfigurations-C7YAqkFR.d.ts} +1 -1
  41. package/dist/{eventConfigurations-3uSorYVC.d.cts → eventConfigurations-DwXdrjqj.d.cts} +1 -1
  42. package/dist/index.cjs +1 -1
  43. package/dist/index.d.cts +102 -13
  44. package/dist/index.d.ts +102 -13
  45. package/dist/index.js +1 -1
  46. package/dist/{labeling-BiWB-8aq.d.ts → labeling-BUCj-kHU.d.ts} +1 -1
  47. package/dist/{labeling-9RWWmJhZ.d.cts → labeling-iugoy25P.d.cts} +1 -1
  48. package/dist/{layout-B6iOoPOv.d.cts → layout-DPJX6D9k.d.cts} +3 -3
  49. package/dist/{layout-B7URbtDR.d.ts → layout-Dv3R0Mpw.d.ts} +3 -3
  50. package/dist/{renderedQuality-C5dQiq97.d.ts → renderedQuality-CSHrmnHf.d.cts} +10 -2
  51. package/dist/{renderedQuality-BZsq3wDe.d.cts → renderedQuality-CfonzUpl.d.ts} +10 -2
  52. package/dist/{renderer-6sFRupj0.d.ts → renderer-C5avrVLy.d.ts} +11 -2
  53. package/dist/{renderer-CBOo1OZk.d.cts → renderer-Dn4Plcv9.d.cts} +11 -2
  54. package/dist/{sections-DU6YDYoZ.d.cts → sections-DhJ7TukF.d.cts} +1 -1
  55. package/dist/{sections-Cn_sk1Sx.d.ts → sections-uV7vqDHj.d.ts} +1 -1
  56. package/dist/{segmentedRowModel-CKmyHvKv.d.cts → segmentedRowModel-DWOjcPrU.d.cts} +1 -1
  57. package/dist/{segmentedRowModel-DbP7pWUk.d.ts → segmentedRowModel-DgSEzAYd.d.ts} +1 -1
  58. package/dist/{ticketRestrictions-CvS2oQ8v.d.ts → ticketRestrictions-DIh61MqE.d.ts} +2 -2
  59. package/dist/{ticketRestrictions-DkenahW2.d.cts → ticketRestrictions-JT87K45q.d.cts} +2 -2
  60. package/dist/{types-D6-wLa-m.d.cts → types-Dx4jA8aI.d.cts} +22 -4
  61. package/dist/{types-D6-wLa-m.d.ts → types-Dx4jA8aI.d.ts} +22 -4
  62. package/dist/view3d/crossfade/panorama.d.cts +1 -1
  63. package/dist/view3d/crossfade/panorama.d.ts +1 -1
  64. package/dist/view3d/index.cjs +1 -1
  65. package/dist/view3d/index.d.cts +3 -3
  66. package/dist/view3d/index.d.ts +3 -3
  67. package/dist/view3d/index.js +1 -1
  68. package/dist/view3d/scene/scene.worker.cjs +1 -1
  69. package/dist/view3d/scene/scene.worker.js +1 -1
  70. package/package.json +1 -1
  71. package/dist/chunk-4F7VBQCF.js +0 -1
  72. package/dist/chunk-HXYWP6NX.js +0 -1
  73. package/dist/chunk-XLGYWT5G.js +0 -1
@@ -1 +1 @@
1
- "use strict";var xo=Object.create;var Bt=Object.defineProperty;var So=Object.getOwnPropertyDescriptor;var Mo=Object.getOwnPropertyNames;var wo=Object.getPrototypeOf,Io=Object.prototype.hasOwnProperty;var vo=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Mo(t))!Io.call(e,r)&&r!==n&&Bt(e,r,{get:()=>t[r],enumerable:!(o=So(t,r))||o.enumerable});return e};var Ie=(e,t,n)=>(n=e!=null?xo(wo(e)):{},vo(t||!e||!e.__esModule?Bt(n,"default",{value:e,enumerable:!0}):n,e));var Ji=Math.PI/180;function lt(e){let t=0,n=0;for(let r of e)t+=r.x,n+=r.y;let o=e.length||1;return{x:t/o,y:n/o}}function _e(e){return e.length?lt(e):null}function Ft(e,t){let n=1-t,o=n*n*n,r=3*n*n*t,i=3*n*t*t,s=t*t*t;return{x:o*e.start.x+r*e.control1.x+i*e.control2.x+s*e.end.x,y:o*e.start.y+r*e.control1.y+i*e.control2.y+s*e.end.y}}function Dt(e,t,n=192){if(!Number.isInteger(t)||t<1)throw new Error("Path point count must be a positive integer");if(t===1)return[Ft(e,.5)];let o=Array.from({length:n+1},(d,f)=>Ft(e,f/n)),r=new Float64Array(o.length);for(let d=1;d<o.length;d+=1){let f=o[d].x-o[d-1].x,u=o[d].y-o[d-1].y;r[d]=r[d-1]+Math.hypot(f,u)}let i=r[r.length-1];if(i<=1e-9)return Array.from({length:t},()=>({...e.start}));let s=[],a=1;for(let d=0;d<t;d+=1){let f=i*d/(t-1);for(;a<r.length-1&&r[a]<f;)a+=1;let u=r[a-1],b=r[a],c=b===u?0:(f-u)/(b-u);s.push({x:o[a-1].x+(o[a].x-o[a-1].x)*c,y:o[a-1].y+(o[a].y-o[a-1].y)*c})}return s}function Nt(e,t,n){return Math.max(t,Math.min(n,e))}function Gt(e){let t=new Map,n=new Map;for(let o of e){if(o.type!=="row"||!o.segmentedRow)continue;let r=n.get(o.segmentedRow.groupId)??[];r.push(o),n.set(o.segmentedRow.groupId,r)}for(let[o,r]of n){let i=r.slice().sort((c,l)=>c.segmentedRow.componentIndex-l.segmentedRow.componentIndex),s=i[0]?.segmentedRow?.componentCount??0,a=i[0]?.segmentedRow;if(!a||!(s>=2&&i.length===s&&a?.boundaryBefore==="start"&&i.every((c,l)=>c.segmentedRow?.kind==="segmented-row-v1"&&c.segmentedRow.groupId===o&&c.segmentedRow.componentCount===s&&c.segmentedRow.componentIndex===l&&c.segmentedRow.repeatLabelOnComponents===a.repeatLabelOnComponents&&(l===0?c.segmentedRow.boundaryBefore==="start":c.segmentedRow.boundaryBefore!=="start")&&c.segmentedRow.displayLabel===a.displayLabel)))continue;let f=i.reduce((c,l)=>c+l.seatCount,0),u=0,b=0;for(let c of i)c.segmentedRow.boundaryBefore==="break"&&(u+=1),t.set(c.id,{groupId:o,adjacencyOffset:u,displayOffset:b,displayLabel:a.displayLabel,totalSeats:f,canonical:i[0],viewFromSeatUrl:a.viewFromSeatUrl,viewFromSeatMeta:a.viewFromSeatMeta,confidenceEvidence:a.confidenceEvidence}),u+=c.seatCount,b+=c.seatCount}return t}var Ro="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var Po="abcdefghijklmnopqrstuvwxyz";function Co(e,t){let n=t.length,o=e+1,r="";for(;o>0;){o-=1;let i=o%n;r=t[i]+r,o=Math.floor(o/n)}return r}function ft(e,t=!1){let n=t?Po:Ro;return Co(Math.max(0,Math.floor(e)-1),n)}var Ao=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];function jt(e){if(!Number.isFinite(e)||e<=0)return String(e);let t=Math.floor(e),n="";for(let[o,r]of Ao)for(;t>=o;)n+=r,t-=o;return n}function Eo(e){let t=new Array(e);return Array.from({length:e},(n,o)=>o).sort((n,o)=>Math.abs(2*n-(e-1))-Math.abs(2*o-(e-1))||n-o).forEach((n,o)=>t[n]=o),t}function mt(e,t){let n=e.seatLabelStart??1,o=e.seatNumbering?.direction??"ltr",r=e.seatNumbering?.step??1,i=e.seatNumbering?.scheme??"decimal",s=e.seatNumbering?.prefix??"",a=e.seatNumbering?.endAt,d=e.seatCount;if(i==="updown"||i==="updown-descending"){let l=Math.ceil(d/2),m=i==="updown"?t<l?n+2*t:n-1+2*(d-t):t<l?n+2*(l-1-t):n+1+2*(t-l);return`${s}${m}`}let f=i==="odd"||i==="even"?2:r,u=a!=null&&Number.isFinite(a)?a-(d-1)*f:n,b=o==="center"?Eo(d)[t]:o==="rtl"?d-1-t:t,c;switch(i){case"odd":{let l=u%2===1?u:u+1;c=String(l+b*2);break}case"even":{let l=u%2===0?u:u+1;c=String(l+b*2);break}case"roman":c=jt(u+b*r);break;case"letters-upper":c=ft(u+b*r,!1);break;case"letters-lower":c=ft(u+b*r,!0);break;default:c=String(u+b*r);break}return`${s}${c}`}function _o(e){return{...e.canonical,seatCount:e.totalSeats,label:e.displayLabel,displayLabel:e.displayLabel}}function Ut(e,t,n){return n?.label??`${e.label}-${mt(e,t)}`}function dt(e,t,n,o){if(o?.displayLabel)return o.displayLabel;if(!n)return`${e.displayLabel??e.label}-${mt(e,t)}`;let r=_o(n),i=n.displayOffset+t;return`${n.displayLabel}-${mt(r,i)}`}var re=.02291666666666667,fe=1/re,ko=58,To=ko*re;var Lo=3,Xt=0,bt=120,Oo=0,Bo=45,Fo=7,me=1.2;function ht(e,t,n,o){return Number.isFinite(e)?Math.max(t,Math.min(n,e)):o}function Do(e){return!Number.isFinite(e)||!Number.isInteger(e)||e<0?0:e<=Fo?e:Lo}function He(e,t={}){let n=ht(t.floorBaseHeightM,Xt,bt,0),o=Math.min(bt,n+Do(e.elevation)*To),r=e.height===void 0?o:ht(e.height,Xt,bt,o),i=ht(e.rake,Oo,Bo,0);return{height:r,rake:i}}function Yt(e){let t=e.length;return t<=3?[...e]:[e[Math.floor(t*.25)],e[Math.floor(t*.5)],e[Math.floor(t*.75)]]}function ve(e,t,n){if(!e.length)return 1/0;if(e.length===1)return Math.hypot(t-e[0].x,n-e[0].y);let o=1/0;for(let r=0;r+1<e.length;r++){let i=e[r],s=e[r+1],a=s.x-i.x,d=s.y-i.y,f=a*a+d*d,u=f>1e-12?((t-i.x)*a+(n-i.y)*d)/f:0;u<0?u=0:u>1&&(u=1);let b=Math.hypot(t-(i.x+u*a),n-(i.y+u*d));b<o&&(o=b)}return o}function No(e){let t=0,n=0;for(let i of e)t+=i.x,n+=i.y;let o=e.length||1;t/=o,n/=o;let r=0;for(let i of e){let s=Math.hypot(i.x-t,i.y-n);s>r&&(r=s)}return{cx:t,cy:n,r}}function Vt(e,t){return Math.hypot(e.cx-t.cx,e.cy-t.cy)-e.r-t.r}function pt(e,t){let n=1/0;for(let o of Yt(e)){let r=ve(t,o.x,o.y);r<n&&(n=r)}for(let o of Yt(t)){let r=ve(e,o.x,o.y);r<n&&(n=r)}return n}function Go(e,t){if(e.length<3)return{pts:e,seatIndices:t};let n=0,o=0;for(let u of e)n+=u.x,o+=u.y;n/=e.length,o/=e.length;let r=-1,i=e[0];for(let u of e){let b=Math.hypot(u.x-n,u.y-o);b>r&&(r=b,i=u)}let s=i.x-n,a=i.y-o,d=Math.hypot(s,a);d>1e-9?(s/=d,a/=d):(s=1,a=0);let f=e.map((u,b)=>({p:u,i:b,t:(u.x-n)*s+(u.y-o)*a})).sort((u,b)=>u.t-b.t);return{pts:f.map(u=>u.p),seatIndices:f.map(u=>t[u.i])}}function yt(e){let t=e.length;if(t<3)return null;let n=0,o=0;for(let g of e)n+=g.x,o+=g.y;n/=t,o/=t;let r=0,i=0,s=0,a=0,d=0,f=0,u=0;for(let g of e){let S=g.x-n,x=g.y-o;r+=S*S,s+=x*x,i+=S*x,a+=S*S*S,d+=x*x*x,f+=S*x*x,u+=x*S*S}let b=r*s-i*i;if(Math.abs(b)<1e-9)return null;let c=(a+f)/2,l=(d+u)/2,m=(c*s-l*i)/b,h=(l*r-c*i)/b,p=m+n,y=h+o;return!Number.isFinite(p)||!Number.isFinite(y)?null:{cx:p,cy:y}}var jo=.15;function Uo(e){if(e.length<2)return null;let t=e.map(g=>{let S=0,x=0;for(let _ of g.pts)S+=_.x,x+=_.y;return{x:S/g.pts.length,y:x/g.pts.length}}),n=0,o=0;for(let g of t)n+=g.x,o+=g.y;n/=t.length,o/=t.length;let r=0,i=0,s=0;for(let g of t){let S=g.x-n,x=g.y-o;r+=S*S,i+=S*x,s+=x*x}let a=r+s,d=r*s-i*i,f=a/2+Math.sqrt(Math.max(0,a*a/4-d)),u,b;Math.abs(i)>1e-12?(u=f-s,b=i):r>=s?(u=1,b=0):(u=0,b=1);let c=Math.hypot(u,b);if(!(c>1e-12))return null;u/=c,b/=c;let l=1/0,m=-1/0,h=[];for(let g of e){let S=1/0,x=-1/0;for(let _ of g.pts){let M=_.x*u+_.y*b;M<S&&(S=M),M>x&&(x=M),M<l&&(l=M),M>m&&(m=M)}h.push(x-S)}let p=m-l;return p>1e-9?(h.sort((g,S)=>g-S),h[Math.min(h.length-1,Math.floor(h.length*.9))]/p<=Xo?{x:u,y:b}:null):null}var Xo=.35;function Ke(e,t,n,o){let r=new Map;for(let p of n){let y=t[p],g=y.rowId||`__seat-${p}`,S=r.get(g);S||(S={pts:[],idx:[]},r.set(g,S)),S.pts.push({x:y.x,y:y.y}),S.idx.push(p)}if(!r.size)return{sectionId:e,rows:[],blockCount:0};let i=[];for(let[p,y]of r){let g=Go(y.pts,y.idx),S=0;for(let x of g.pts)S+=Math.hypot(x.x-o.x,x.y-o.y);i.push({id:p,pts:g.pts,seatIndices:g.seatIndices,blockId:-1,ordinal:0,blockDepth:0,focalDistance:S/g.pts.length})}let s=i.map(p=>No(p.pts)),a=[];for(let p=0;p<i.length;p++){let y=1/0;for(let g=0;g<i.length;g++){if(p===g||Vt(s[p],s[g])>=y)continue;let S=pt(i[p].pts,i[g].pts);S<y&&(y=S)}Number.isFinite(y)&&a.push(y)}a.sort((p,y)=>p-y);let d=a.length?a[Math.floor(a.length/2)]:1,f=Math.max(d*1.8,1e-6),u=i.map(()=>[]);for(let p=0;p<i.length;p++)for(let y=p+1;y<i.length;y++)Vt(s[p],s[y])>f||pt(i[p].pts,i[y].pts)<=f&&(u[p].push(y),u[y].push(p));let b=0;for(let p=0;p<i.length;p++){if(i[p].blockId!==-1)continue;let y=b++,g=[p];for(i[p].blockId=y;g.length;){let S=g.pop();for(let x of u[S])i[x].blockId===-1&&(i[x].blockId=y,g.push(x))}}let c=new Map;for(let p of i){let y=c.get(p.blockId)??[];y.push(p),c.set(p.blockId,y)}let l=[];for(let p of i){if(p.pts.length<4)continue;let y=yt(p.pts);y&&(!Number.isFinite(y.cx)||!Number.isFinite(y.cy)||l.push({x:y.cx,y:y.cy}))}let m=l.length>=2?(()=>{let p=l.map(S=>S.x).sort((S,x)=>S-x),y=l.map(S=>S.y).sort((S,x)=>S-x),g=Math.floor(l.length/2);return{cx:p[g],cy:y[g]}})():null;if(m){let p=M=>Math.hypot(M.x-m.cx,M.y-m.cy),y=1/0,g=-1/0,S=[];for(let M of i){let v=1/0,k=-1/0;for(let B of M.pts){let D=p(B);D<v&&(v=D),D>k&&(k=D)}S.push(k-v),v<y&&(y=v),k>g&&(g=k)}let x=g-y;S.sort((M,v)=>M-v);let _=S[Math.min(S.length-1,Math.floor(S.length*.9))];if(x>1e-9&&_/x<=jo){let M=i.map(I=>{let F=0;for(let A of I.pts)F+=p(A);return{row:I,radius:F/I.pts.length}}),v=0,k=0;for(let I of M)v+=I.radius,k+=I.row.focalDistance;v/=M.length,k/=M.length;let B=0;for(let I of M)B+=(I.radius-v)*(I.row.focalDistance-k);if(B<0)for(let I of M)I.radius=-I.radius;let U=1/0;for(let I of M)I.radius<U&&(U=I.radius);M.sort((I,F)=>I.radius-F.radius);let P=-1,w=-1/0,L=x/Math.max(1,M.length)*.5,T=[];for(let I of M)I.radius-w>L&&(P++,w=I.radius),I.row.ordinal=P,I.row.blockDepth=I.radius-U,T.push(I.row);return{sectionId:e,rows:T,blockCount:b}}}let h=[];for(let[,p]of c){let y=Uo(p);if(y){let g=x=>{let _=0;for(let M of x.pts)_+=M.x*y.x+M.y*y.y;return _/x.pts.length};p.sort((x,_)=>g(x)-g(_)),p.length>=2&&p[0].focalDistance>p[p.length-1].focalDistance&&p.reverse();let S=0;for(let x=0;x<p.length;x++)x>0&&(S+=pt(p[x-1].pts,p[x].pts)),p[x].ordinal=x,p[x].blockDepth=S,h.push(p[x])}else{let g=1/0;for(let S of p)S.focalDistance<g&&(g=S.focalDistance);p.sort((S,x)=>S.focalDistance-x.focalDistance);for(let S=0;S<p.length;S++)p[S].ordinal=S,p[S].blockDepth=Math.max(0,p[S].focalDistance-g),h.push(p[S])}}return{sectionId:e,rows:h,blockCount:b}}var Yo=/^\d{4}-\d{2}-\d{2}$/;function Vo(e){let t=Date.parse(e);return Number.isFinite(t)?Yo.test(e)?t+864e5:t:null}function Ho(e,t=Date.now()){if(e.validUntil===void 0){if(e.status!=="approved")return!0;let o=e.assessedAt?Date.parse(e.assessedAt):Number.NaN;return Number.isFinite(o)&&(t instanceof Date?t.getTime():t)<=o+366*864e5}let n=Vo(e.validUntil);return n===null?!1:(t instanceof Date?t.getTime():t)<n}function Ko(e,t,n){return!(e.eventConfigurationId&&e.eventConfigurationId!==t||e.eventConfigurationVersion!==void 0&&e.eventConfigurationVersion!==n)}function zo(e){return e.status!=="draft"&&e.status!=="retracted"}function Wo(e,t){return e.status===void 0?t===void 0:e.status!=="approved"?!0:typeof t=="string"&&typeof e.basisSha256=="string"&&e.basisSha256===t}function Ht(e,t={}){return!!e&&zo(e)&&Ko(e,t.activeConfigurationId,t.activeConfigurationVersion)&&Wo(e,t.activeBasisSha256)&&Ho(e,t.now)}function Qt(e){return e?e.accessibility&&e.accessibility.length?e.wheelchairSpaceType&&!e.accessibility.includes("wheelchair")?["wheelchair",...e.accessibility]:e.accessibility:e.wheelchairSpaceType?["wheelchair"]:e.accessible?["wheelchair"]:[]:[]}var ze=Math.PI/180;var ke=16;function xt(e,t,n,o){let r=n*ze,i=Math.cos(r),s=Math.sin(r);return{x:o.x+e*i-t*s,y:o.y+e*s+t*i}}function Zo(e){let{seatCount:t,seatSpacing:n,curve:o,rotation:r,origin:i}=e,s=[];if(e.path)return Dt(e.path,t);if(t<=1)return t===1&&s.push({x:i.x,y:i.y}),s;if(o===0){for(let f=0;f<t;f++)s.push(xt(f*n,0,r,i));return s}let a=o/(t-1)*ze,d=n/(2*Math.sin(Math.abs(a)/2));for(let f=0;f<t;f++){let u=f*a,b=d*Math.sin(u),c=-d+d*Math.cos(u);s.push(xt(b,c,r,i))}return s}function Qo(e){let t=new Map;if(e.overrides)for(let n of e.overrides)t.set(n.index,n);return t}function $o(e,t){let n=Qo(e);return Zo(e).map((o,r)=>{let i=n.get(r),s=Qt(i),a=Ut(e,r,i),d={...e.commercial,...i?.commercial};return{index:r,x:o.x+(i?.dx??0),y:o.y+(i?.dy??0),label:a,displayLabel:dt(e,r,t,i),categoryKey:i?.categoryKey??e.categoryKey,skipped:!!i?.skip,accessible:s.length>0,accessibility:s,wheelchairSpaceType:i?.wheelchairSpaceType,commercial:Object.values(d).some(f=>f!==void 0&&f!==!1&&f!=="")?d:void 0,glyph:i?.glyph,viewUrl:i?.viewFromSeatUrl??e.viewFromSeatUrl,viewMeta:i?.viewFromSeatUrl?i.viewFromSeatMeta:e.viewFromSeatMeta,labelStyle:i?.labelStyle}})}function $t(e){let t=[];for(let n of $o(e))n.skipped||t.push({id:`${e.id}:${n.index}`,label:n.label,displayLabel:n.displayLabel===n.label?void 0:n.displayLabel,x:n.x,y:n.y,rowId:e.id,categoryKey:n.categoryKey,accessible:n.accessible||void 0,accessibility:n.accessibility.length?n.accessibility:void 0,wheelchairSpaceType:n.wheelchairSpaceType,commercial:n.commercial,glyph:n.glyph,viewUrl:n.viewUrl,viewMeta:n.viewMeta,labelStyle:n.labelStyle});return t}function qo(e){if(e.seatCountsBySide)return{...e.seatCountsBySide};let t=e.sides&&e.sides.length?e.sides:["top","bottom"],n=["top","bottom","left","right"].filter(i=>t.includes(i)),o={top:0,bottom:0,left:0,right:0};if(!n.length)return o;let r=Math.max(0,Math.round(e.seatCount));for(let i=0;i<r;i++)o[n[i%n.length]]+=1;return o}function Jo(e){let t=[],n=Math.max(0,Math.round(e.seatCount));if(n===0)return t;let o=new Map((e.overrides??[]).map(u=>[u.index,u])),r=(u,b,c,l)=>{let m=o.get(u),h=Qt(m),p=m?.label??`${e.label}-${u+1}`,y=e.displayLabel??e.label;return{index:u,label:p,displayLabel:m?.displayLabel??`${y}-${u+1}`,x:b+(m?.dx??0),y:c+(m?.dy??0),categoryKey:m?.categoryKey??e.categoryKey,skipped:!!m?.skip,accessible:h.length>0,accessibility:h,wheelchairSpaceType:m?.wheelchairSpaceType,commercial:m?.commercial,glyph:m?.glyph,viewUrl:m?.viewFromSeatUrl,viewMeta:m?.viewFromSeatUrl?m.viewFromSeatMeta:void 0,labelStyle:m?.labelStyle,...l?{side:l}:{}}};if(e.shape==="round"){let u=(e.radius??40)+ke,b=e.rotation*ze,c=Math.max(0,Math.min(360,e.seatArc??360));if(c>=360||n===1){for(let p=0;p<n;p++){let y=b+p/n*2*Math.PI;t.push(r(p,e.center.x+u*Math.cos(y),e.center.y+u*Math.sin(y)))}return t}let l=c*ze,m=(2*Math.PI-l)/2,h=b+m;for(let p=0;p<n;p++){let y=h+p/(n-1)*l;t.push(r(p,e.center.x+u*Math.cos(y),e.center.y+u*Math.sin(y)))}return t}let i=e.width??80,s=e.height??50,a=qo(e),d=["top","bottom","left","right"],f=0;for(let u of d){let b=a[u];for(let c=0;c<b;c++){let l,m;u==="top"?(l=-i/2+(c+.5)*i/b,m=-s/2-ke):u==="bottom"?(l=-i/2+(c+.5)*i/b,m=s/2+ke):u==="left"?(l=-i/2-ke,m=-s/2+(c+.5)*s/b):(l=i/2+ke,m=-s/2+(c+.5)*s/b);let h=xt(l,m,e.rotation,e.center);t.push(r(f++,h.x,h.y,u))}}return t}function er(e){return Jo(e).filter(t=>!t.skipped).map(t=>({id:`${e.id}:${t.index}`,label:t.label,...t.displayLabel!==t.label?{displayLabel:t.displayLabel}:{},x:t.x,y:t.y,rowId:e.id,categoryKey:t.categoryKey,...t.accessible?{accessible:!0}:{},...t.accessibility.length?{accessibility:t.accessibility}:{},...t.wheelchairSpaceType?{wheelchairSpaceType:t.wheelchairSpaceType}:{},...t.commercial?{commercial:t.commercial}:{},...t.glyph?{glyph:t.glyph}:{},...t.viewUrl?{viewUrl:t.viewUrl}:{},...t.viewUrl&&t.viewMeta?{viewMeta:t.viewMeta}:{},...t.labelStyle?{labelStyle:t.labelStyle}:{}}))}function tr(e){return[{id:`${e.id}:0`,label:e.label,...e.displayLabel&&e.displayLabel!==e.label?{displayLabel:e.displayLabel}:{},x:e.center.x,y:e.center.y,rowId:e.id,categoryKey:e.categoryKey,kind:"booth"}]}function Kt(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[o].x,s=t[o].y,a=t[r].x,d=t[r].y;s>e.y!=d>e.y&&e.x<(a-i)*(e.y-s)/(d-s)+i&&(n=!n)}return n}function nr(e,t){return t.some((n,o)=>{let r=t[(o+1)%t.length],i=(e.y-n.y)*(r.x-n.x)-(e.x-n.x)*(r.y-n.y);if(Math.abs(i)>1e-7)return!1;let s=(e.x-n.x)*(r.x-n.x)+(e.y-n.y)*(r.y-n.y),a=(r.x-n.x)**2+(r.y-n.y)**2;return s>=-1e-7&&s<=a+1e-7})}function be(e,t,n){return Kt(e,t)&&!(n??[]).some(o=>Kt(e,o)||nr(e,o))}function gt(e){if(!e.length)return{x:0,y:0};let t=0,n=0;for(let o of e)t+=o.x,n+=o.y;return{x:t/e.length,y:n/e.length}}function or(e){switch(e.type){case"row":{let t=$t(e);if(!t.length)return{x:e.origin.x,y:e.origin.y};let n=0,o=0;for(let r of t)n+=r.x,o+=r.y;return{x:n/t.length,y:o/t.length}}case"table":case"booth":return{x:e.center.x,y:e.center.y};case"gaArea":return gt(e.points);case"section":return gt(e.outline);case"text":return{x:e.position.x,y:e.position.y};case"shape":return e.points&&e.points.length?gt(e.points):e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null?{x:e.x+e.width/2,y:e.y+e.height/2}:{x:e.x??0,y:e.y??0};case"decorImage":return{x:e.x+e.width/2,y:e.y+e.height/2}}}function zt(e,t){return e.length===t.length&&e.every((n,o)=>n.x===t[o].x&&n.y===t[o].y)}function rr(e,t){if(e.type!=="gaArea"||!zt(e.points,t.outline))return!1;let n=e.holes??[],o=t.holes??[];return n.length===o.length&&n.every((r,i)=>zt(r,o[i]))}function ir(e,t){let n=e.filter(s=>s.type==="section"),o="referenceInventorySource"in t?t.referenceInventorySource?.logicalSectionId:void 0,r=or(t);return(o?n.find(s=>(s.logicalSectionId??s.id)===o&&(rr(t,s)||be(r,s.outline,s.holes))):void 0)??n.find(s=>be(r,s.outline,s.holes))}function Wt(e,t,n,o,r,i,s,a,d){let f=[],u=Gt(e),b=m=>!m?.eventConfigurationId||m.eventConfigurationId===o&&(m.eventConfigurationVersion===void 0||m.eventConfigurationVersion===d),c=m=>Ht(m,{activeConfigurationId:o,activeConfigurationVersion:d,activeBasisSha256:r,now:a}),l=(m,h)=>c(m)?{...m,coverage:h}:void 0;for(let m of e){let h=[];if(m.type==="row"?h=$t(m):m.type==="table"?h=er(m):m.type==="booth"&&(h=tr(m)),!h.length)continue;for(let x of h)x.viewUrl&&!b(x.viewMeta)&&(x.viewUrl=void 0,x.viewMeta=void 0);if(m.type==="row"){let x=u.get(m.id);if(x){let _=new Map((m.overrides??[]).map(M=>[M.index,M]));for(let M of h){let v=Number(M.id.slice(M.id.lastIndexOf(":")+1));if(!Number.isInteger(v))continue;M.logicalRowId=x.groupId,M.logicalSeatIndex=x.adjacencyOffset+v,_.get(v)?.displayLabel||(M.displayLabel=dt(m,v,x)),!M.viewUrl&&x.viewFromSeatUrl&&b(x.viewFromSeatMeta)&&(M.viewUrl=x.viewFromSeatUrl,M.viewMeta=x.viewFromSeatMeta);let k=_.get(v)?.confidenceEvidence;M.confidenceEvidence=l(k,"exact-seat")??l(m.confidenceEvidence,"row-representative")??l(x.confidenceEvidence,"row-representative")}}}let p=ir(e,m),y=p?.viewFromSeatUrl,S=(p?.zone?t?.find(x=>x.id===p.zone):void 0)?.focalPoint??n;for(let x of h){if(!x.confidenceEvidence){let _=Number(x.id.slice(x.id.lastIndexOf(":")+1)),M=(m.type==="row"||m.type==="table")&&Number.isInteger(_)?m.overrides?.find(v=>v.index===_)?.confidenceEvidence:void 0;x.confidenceEvidence=l(M,"exact-seat")??(m.type==="row"?l(m.confidenceEvidence,"row-representative"):void 0)}x.confidenceEvidence??=l(p?.confidenceEvidence,"section-representative")??(s?l(s.evidence,s.coverage):void 0),!x.viewUrl&&y&&b(p?.viewFromSeatMeta)&&(x.viewUrl=y,x.viewMeta=p?.viewFromSeatMeta),!x.viewUrl&&i&&b(i.meta)&&(x.viewUrl=i.url,x.viewMeta=i.meta),p&&(x.sectionId=p.logicalSectionId??p.id),p?.zone&&(x.zoneId=p.zone),S&&(x.focalPoint={...S})}f.push(...h)}return f}function qt(e,t={}){if(e.floors?.length){let o=[];for(let r of e.floors){let i=r.focalPoint??e.focalPoint,s=r.viewFromSeatUrl?{url:r.viewFromSeatUrl,meta:r.viewFromSeatMeta}:e.viewFromSeatUrl?{url:e.viewFromSeatUrl,meta:e.viewFromSeatMeta}:void 0,a=r.confidenceEvidence?{evidence:r.confidenceEvidence,coverage:"floor-representative"}:e.confidenceEvidence?{evidence:e.confidenceEvidence,coverage:"venue-representative"}:void 0,d=Wt(r.objects,e.zones,i,e.eventConfigurationId,e.confidenceBasisSha256,s,a,t.now,t.eventConfigurationVersion??e.eventConfigurationVersion);t.resolveEyeHeights!==!1&&Zt(r.objects,r.focalPoint??e.focalPoint,r.baseHeightM??0,d);for(let f of d)f.floorId=r.id;o.push(...d)}return o}let n=Wt(e.objects,e.zones,e.focalPoint,e.eventConfigurationId,e.confidenceBasisSha256,e.viewFromSeatUrl?{url:e.viewFromSeatUrl,meta:e.viewFromSeatMeta}:void 0,e.confidenceEvidence?{evidence:e.confidenceEvidence,coverage:"venue-representative"}:void 0,t.now,t.eventConfigurationVersion??e.eventConfigurationVersion);return t.resolveEyeHeights!==!1&&Zt(e.objects,e.focalPoint,t.floorBaseHeightM??0,n),n}function Zt(e,t,n,o){let r=e.filter(u=>u.type==="section"),i=n>0||r.some(u=>u.height!==void 0||u.rake!==void 0||(u.elevation??0)>0);if(!r.length||!i||!t){for(let u of o)u.eyeHeightM=n+me;return}let s=new Array(o.length),a=new Map,d=new Map;for(let u=0;u<o.length;u++){let b=o[u],l=(b.sectionId?r.find(h=>h.id===b.sectionId)??r.find(h=>h.logicalSectionId===b.sectionId&&be({x:b.x,y:b.y},h.outline,h.holes)):void 0)??r.find(h=>be({x:b.x,y:b.y},h.outline,h.holes))??null;if(s[u]=l,!l)continue;a.has(l.id)||a.set(l.id,He(l,{floorBaseHeightM:n}));let m=d.get(l.id);m?m.push(u):d.set(l.id,[u])}let f=new Array(o.length).fill(void 0);for(let[u,b]of d){let c=a.get(u);if(!c)continue;let l=c.rake>0?Math.tan(c.rake*Math.PI/180):0,m=Ke(u,o,b,t);for(let h of m.rows){let p=h.blockDepth*re*l,y=c.height+p;for(let g of h.seatIndices)f[g]=y}}for(let u=0;u<o.length;u++){let b=o[u],c=s[u];if(!c){b.eyeHeightM=n+me;continue}let l=a.get(c.id);b.eyeHeightM=(f[u]??l.height)+me}}var sr=/^#?([\da-f]{3}|[\da-f]{6})$/i;function ar(e){let t=sr.exec((e??"").trim());if(!t)return null;let n=t[1].length===3?t[1].split("").map(r=>r+r).join(""):t[1],o=parseInt(n,16);return[o>>16&255,o>>8&255,o&255]}function W(e){let t=ar(e);return t?[t[0]/255,t[1]/255,t[2]/255]:null}function cr(e){return .2126*e[0]+.7152*e[1]+.0722*e[2]}function te(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}function Te(e,t){let n=cr(e);return te(e,[n,n,n],t)}var We=["available","held","sold","selected","dimmed"];function Jt(e){let t=We.indexOf(e);return t<0?0:t}var en={available:[.24,.82,.52],held:[.95,.66,.22],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};var St={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]},Mt={top:[.05,.06,.08],bottom:[.1,.12,.15]};function ie(e,t){return[Math.min(1,e[0]*t),Math.min(1,e[1]*t),Math.min(1,e[2]*t)]}var ur=.15,lr=1.6;function tn(e){return Nt(e??1,ur,lr)}var fr=.15,mr=.9,dr=1.76;function br(){return{background:{top:[...Mt.top],bottom:[...Mt.bottom]},structure:St,seatStates:{...en},seatScale:1,materials:{seat:null,shell:null,roughness:.78}}}function nn(e){let t=br();if(!e)return t;let n=W(e.background);if(n){t.background={top:ie(n,mr),bottom:ie(n,dr)};let s={};for(let[a,d]of Object.entries(St))s[a]=te(d,n,fr);t.structure=s}let o=W(e.selectionColor)??W(e.accent);o&&(t.seatStates={...t.seatStates,selected:o});let r=e.seatScale;typeof r=="number"&&Number.isFinite(r)&&(t.seatScale=tn(r));let i=e.venue3d;if(i){let s=W(i.deck),a=W(i.fascia);s&&(t.structure={...t.structure,tierTop:s,gaTop:s}),a&&(t.structure={...t.structure,tierWall:a,gaWall:a}),t.materials.seat=W(i.seat),t.materials.shell=W(i.shell),typeof i.roughness=="number"&&Number.isFinite(i.roughness)&&(t.materials.roughness=Math.min(1,Math.max(0,i.roughness)))}return t}function on(e,t){let n=[];for(let o of t)n.push(...e.seatStates[o]);return n}var sn=Ie(require("earcut"),1),an=Ie(require("polygon-clipping"),1);function he(e){let t=0;for(let n=0,o=e.length;n<o;n+=1){let r=e[n],i=e[(n+1)%o];t+=r.x*i.y-i.x*r.y}return t/2}function Le(e,t,n){let o=!1;for(let r=0,i=e.length-1;r<e.length;i=r++){let s=e[r],a=e[i];s.y>n!=a.y>n&&t<(a.x-s.x)*(n-s.y)/(a.y-s.y)+s.x&&(o=!o)}return o}var R=re,hr=.002;function pr(e,t,n){let o=Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2]),r=Math.hypot(n[0]-t[0],n[1]-t[1],n[2]-t[2]),i=Math.hypot(e[0]-n[0],e[1]-n[1],e[2]-n[2]),s=Math.max(o,r,i);if(s<1e-9)return!0;let a=(o+r+i)/2;return 2*Math.sqrt(Math.max(0,a*(a-o)*(a-r)*(a-i)))/s<hr}var pe=class{constructor(t=16384){this.len=0;this.buf=new Float32Array(t)}push3(t,n,o){this.len+3>this.buf.length&&this.grow(this.len+3),this.buf[this.len++]=t,this.buf[this.len++]=n,this.buf[this.len++]=o}push1(t){this.len+1>this.buf.length&&this.grow(this.len+1),this.buf[this.len++]=t}grow(t){let n=this.buf.length*2;for(;n<t;)n*=2;let o=new Float32Array(n);o.set(this.buf.subarray(0,this.len)),this.buf=o}get length(){return this.len}toArray(){return this.buf.slice(0,this.len)}},$e=class{constructor(){this.pos=new pe;this.nor=new pe;this.col=new pe;this.flr=new pe;this.mat=new pe;this.currentFloor=0;this.currentMaterial=0}setFloor(t){this.currentFloor=t}setMaterial(t){this.currentMaterial=t}tri(t,n,o,r,i,s=i,a=i){pr(t,n,o)||(this.pos.push3(t[0],t[1],t[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(o[0],o[1],o[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(r[0],r[1],r[2]),this.col.push3(i[0],i[1],i[2]),this.col.push3(s[0],s[1],s[2]),this.col.push3(a[0],a[1],a[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}triN(t,n,o,r,i,s,a,d=a,f=a){[...t,...n,...o].every(Number.isFinite)&&(this.pos.push3(t[0],t[1],t[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(o[0],o[1],o[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(i[0],i[1],i[2]),this.nor.push3(s[0],s[1],s[2]),this.col.push3(a[0],a[1],a[2]),this.col.push3(d[0],d[1],d[2]),this.col.push3(f[0],f[1],f[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}get vertexCount(){return this.pos.length/3}build(){return{position:this.pos.toArray(),normal:this.nor.toArray(),color:this.col.toArray(),floor:this.flr.toArray(),material:this.mat.toArray(),count:this.pos.length/3}}};function yr(e,t,n){let o=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2],s=n[0]-e[0],a=n[1]-e[1],d=n[2]-e[2],f=r*d-i*a,u=i*s-o*d,b=o*a-r*s,c=Math.hypot(f,u,b)||1;return f/=c,u/=c,b/=c,[f,u,b]}function gr(e,t){let n=[...e],o=[];for(let s of e)o.push(s.x,s.y);let r=[];if(t){for(let s of t)if(!(s.length<3)){r.push(n.length);for(let a of s)n.push(a),o.push(a.x,a.y)}}let i=(0,sn.default)(o,r.length?r:void 0,2);return{pts:n,tris:i}}function wt(e){return he(e)<0?[...e].reverse():e}var xr=3;function Sr(e,t,n,o){let r=o(e),i=o(t),s=o(n),a=(l,m,h,p)=>Math.abs(o({x:(l.x+m.x)/2,y:(l.y+m.y)/2})-(h+p)/2),d=(e.x+t.x+n.x)/3,f=(e.y+t.y+n.y)/3,u=(r+i+s)/3,b=Math.max(a(e,t,r,i),a(t,n,i,s),a(n,e,s,r),Math.abs(o({x:d,y:f})-u)),c=(l,m,h)=>{let p=Math.abs(o({x:(l+d)/2,y:(m+f)/2})-(h+u)/2);p>b&&(b=p)};return c((e.x+t.x)/2,(e.y+t.y)/2,(r+i)/2),c((t.x+n.x)/2,(t.y+n.y)/2,(i+s)/2),c((n.x+e.x)/2,(n.y+e.y)/2,(s+r)/2),b}function Oe(e,t,n,o,r){if(r<=0)return Sr(e,t,n,o);let i={x:(e.x+t.x)/2,y:(e.y+t.y)/2},s={x:(t.x+n.x)/2,y:(t.y+n.y)/2},a={x:(n.x+e.x)/2,y:(n.y+e.y)/2};return Math.max(Oe(e,i,a,o,r-1),Oe(i,t,s,o,r-1),Oe(a,s,n,o,r-1),Oe(i,s,a,o,r-1))}function Be(e,t,n,o,r,i,s,a){if(s>0){let c={x:(t.x+n.x)/2,y:(t.y+n.y)/2},l={x:(n.x+o.x)/2,y:(n.y+o.y)/2},m={x:(o.x+t.x)/2,y:(o.y+t.y)/2};Be(e,t,c,m,r,i,s-1,a),Be(e,c,n,l,r,i,s-1,a),Be(e,m,l,o,r,i,s-1,a),Be(e,c,l,m,r,i,s-1,a);return}let d=[t.x*R,r(t),t.y*R],f=[n.x*R,r(n),n.y*R],u=[o.x*R,r(o),o.y*R];if(a){e.triN(d,f,u,a(t),a(n),a(o),i);return}let b=yr(d,f,u);b[1]<0&&(b=[-b[0],-b[1],-b[2]]),e.tri(d,f,u,b,i)}var Mr=8;function rn(e,t,n){if(!Number.isFinite(n))return e;let o=[],r=(i,s,a,d,f)=>{if(f>0){let u={x:(i.x+s.x)/2,y:(i.y+s.y)/2},b=t(u);if(Math.abs(b-(a+d)/2)>n){r(i,u,a,b,f-1),r(u,s,b,d,f-1);return}}o.push(i)};for(let i=0;i<e.length;i++){let s=e[i],a=e[(i+1)%e.length];r(s,a,t(s),t(a),Mr)}return o}function Ze(e,t){if(e.length<3)return e;let n=[];for(let r of e){let i=n[n.length-1];i&&Math.hypot(r.x-i.x,r.y-i.y)<t||n.push(r)}for(;n.length>2&&Math.hypot(n[0].x-n[n.length-1].x,n[0].y-n[n.length-1].y)<t;)n.pop();if(n.length<3)return e;let o=[];for(let r=0;r<n.length;r++){let i=o.length?o[o.length-1]:n[(r-1+n.length)%n.length],s=n[r],a=n[(r+1)%n.length],d=a.x-i.x,f=a.y-i.y,u=Math.hypot(d,f);u>t&&Math.abs((s.x-i.x)*f-(s.y-i.y)*d)/u<t||o.push(s)}return o.length>=3?o:n}var Qe=.001*fe*.1;function J(e,t,n,o,r,i,s,a,d=1/0,f){if(!t||t.length<3||(d===void 0&&(d=1/0),Math.abs(he(t))<1e-4))return;let u=Ze(rn(Ze(wt(t),Qe),o,d),Qe),b=n?.map(M=>Ze(rn(Ze(wt(M),Qe),o,d),Qe)).filter(M=>M.length>=3&&Math.abs(he(M))>=1e-4),{pts:c,tris:l}=gr(u,b),m=[i[0]*a.top,i[1]*a.top,i[2]*a.top],h=[i[0]*a.bottomCap,i[1]*a.bottomCap,i[2]*a.bottomCap],p=[s[0]*a.top,s[1]*a.top,s[2]*a.top],y=[s[0]*a.wallBottom,s[1]*a.wallBottom,s[2]*a.wallBottom],g=0;if(Number.isFinite(d))for(;g<xr;g++){let M=0;for(let v=0;v<l.length;v+=3){let k=Oe(c[l[v]],c[l[v+1]],c[l[v+2]],o,g);k>M&&(M=k)}if(M<=d)break}for(let M=0;M<l.length;M+=3){let v=c[l[M]],k=c[l[M+1]],B=c[l[M+2]];Be(e,v,k,B,o,m,g,f);let D=[v.x*R,r,v.y*R],U=[k.x*R,r,k.y*R],P=[B.x*R,r,B.y*R];e.tri(D,P,U,[0,-1,0],h)}let S=M=>{if(g<=0)return M;let v=1<<g,k=[];for(let B=0;B<M.length;B++){let D=M[B],U=M[(B+1)%M.length];for(let P=0;P<v;P++){let w=P/v;k.push({x:D.x+(U.x-D.x)*w,y:D.y+(U.y-D.y)*w})}}return k},x=lt(u),_=[{ring:S(u),flip:!1}];if(b)for(let M of b)M.length>=3&&_.push({ring:S(M),flip:!0});for(let{ring:M,flip:v}of _)for(let k=0;k<M.length;k++){let B=M[k],D=M[(k+1)%M.length],U=(D.x-B.x)*R,w=(D.y-B.y)*R,L=-U,T=Math.hypot(w,L)||1;w/=T,L/=T;let I=(B.x+D.x)/2-x.x,F=(B.y+D.y)/2-x.y,A=w*I+L*F;v&&(A=-A),A<0&&(w=-w,L=-L);let C=[w,0,L],E=[B.x*R,o(B),B.y*R],N=[D.x*R,o(D),D.y*R],j=[B.x*R,r,B.y*R],X=[D.x*R,r,D.y*R];e.tri(E,N,X,C,p,p,y),e.tri(E,X,j,C,p,y,y)}}function cn(e){let t=0;for(let d of e)t+=d.count;let n=new Float32Array(t*3),o=new Float32Array(t*3),r=new Float32Array(t*3),i=new Float32Array(t),s=new Float32Array(t),a=0;for(let d of e)n.set(d.position,a*3),o.set(d.normal,a*3),r.set(d.color,a*3),i.set(d.floor,a),s.set(d.material,a),a+=d.count;return{position:n,normal:o,color:r,floor:i,material:s,count:t}}function qe(e,t,n=2.5){if(t<=0||e.length<3)return e;let o=wt(e),r=o.length,i=[];for(let a=0;a<r;a++){let d=o[a],f=o[(a+1)%r],u=f.x-d.x,b=f.y-d.y,c=Math.hypot(u,b)||1;i.push({x:b/c,y:-u/c})}let s=[];for(let a=0;a<r;a++){let d=o[a],f=i[(a-1+r)%r],u=i[a],b=f.x+u.x,c=f.y+u.y,l=Math.hypot(b,c),m=()=>{s.push([d.x+f.x*t,d.y+f.y*t]),s.push([d.x+u.x*t,d.y+u.y*t])};if(l<1e-9){m();continue}b/=l,c/=l;let h=b*f.x+c*f.y,p=1/Math.max(h,1e-6);if(!Number.isFinite(p)||p>n){m();continue}s.push([d.x+b*t*p,d.y+c*t*p])}if(s.length<3)return e;try{let a=an.default.union([[...s,s[0]]]),d=null,f=-1/0;for(let b of a){let c=Math.abs(he(b[0].map(([l,m])=>({x:l,y:m}))));c>f&&(f=c,d=b[0])}if(!d)return e;let u=d.map(([b,c])=>({x:b,y:c}));if(u.length>1){let b=u[0],c=u[u.length-1];Math.abs(b.x-c.x)<1e-9&&Math.abs(b.y-c.y)<1e-9&&u.pop()}return u.length>=3?u:e}catch{return e}}function Je(e,t,n,o,r=28){let i=[];for(let s=0;s<r;s++){let a=s/r*Math.PI*2;i.push({x:e+n*Math.cos(a),y:t+o*Math.sin(a)})}return i}function Fe(e,t,n,o){return[{x:e,y:t},{x:e+n,y:t},{x:e+n,y:t+o},{x:e,y:t+o}]}var wr=[{key:"wheelchair",label:"Wheelchair space",short:"Wheelchair",icon:"\u267F"},{key:"companion",label:"Companion seat",short:"Companion",icon:"\u{1F9D1}\u200D\u{1F91D}\u200D\u{1F9D1}"},{key:"semi-ambulatory",label:"Semi-ambulatory (limited mobility)",short:"Limited mobility",icon:"\u{1F9AF}"},{key:"designated-aisle",label:"Designated aisle / transfer seat",short:"Aisle transfer",icon:"AS"},{key:"step-free",label:"Step-free accessible seat",short:"Step-free",icon:"SF"},{key:"hearing",label:"Assistive listening",short:"Hearing",icon:"\u{1F9BB}"},{key:"cart",label:"CART live-caption view",short:"CART captions",icon:"CC"},{key:"sign-language",label:"Sign-language view",short:"Sign language",icon:"\u{1F91F}"},{key:"low-vision",label:"Blind / low-vision viewing",short:"Low vision",icon:"LV"},{key:"sensory-friendly",label:"Quiet / sensory-friendly seating",short:"Sensory-friendly",icon:"QS"},{key:"plus-size",label:"Plus-size seat",short:"Plus-size",icon:"\u{1F4BA}"},{key:"lift-armrest",label:"Lift-up armrest",short:"Lift armrest",icon:"\u2195\uFE0F"}],_s=new Map(wr.map(e=>[e.key,e]));var Ir={wheelchair:"#3b82f6",companion:"#8b5cf6","semi-ambulatory":"#0ea5e9","designated-aisle":"#0284c7","step-free":"#16a34a",hearing:"#14b8a6",cart:"#7c3aed","sign-language":"#f59e0b","low-vision":"#d97706","sensory-friendly":"#6366f1","plus-size":"#ec4899","lift-armrest":"#22c55e"};function un(e){let t=e?.[0];return t&&Ir[t]||"#3b82f6"}var vr=[{key:"obstructedView",label:"Obstructed view",short:"Obstructed",icon:"\u26D4"},{key:"restrictedView",label:"Restricted view",short:"Restricted",icon:"\u{1F441}"},{key:"premium",label:"Premium seat",short:"Premium",icon:"\u2605"}],ks=new Map(vr.map(e=>[e.key,e]));var Rr=["reference-focal","bar","entrance","exit","restroom","screen","sound","concession","coat","wall","rail","suite","obstruction"],Ts=new Set(Rr);var fn=[{key:"circle",label:"Standard seat",shortLabel:"Standard",useCase:"General assigned seating",group:"general",path:null,bounds:null},{key:"theatre",label:"Theatre chair",shortLabel:"Theatre",useCase:"Auditoriums, arenas and stadium stands",group:"fixed",path:"M4.5 3.5 Q4.5 1.5 6.5 1.5 L17.5 1.5 Q19.5 1.5 19.5 3.5 L19.5 13 L4.5 13 Z M3.5 12 L20.5 12 Q22.5 12 22.5 14 L22.5 21 Q22.5 22.5 21 22.5 Q19.5 22.5 19.5 21 L19.5 17.5 L4.5 17.5 L4.5 21 Q4.5 22.5 3 22.5 Q1.5 22.5 1.5 21 L1.5 14 Q1.5 12 3.5 12 Z",bounds:{x:1.5,y:1.5,width:21,height:21}},{key:"dining",label:"Dining chair",shortLabel:"Dining",useCase:"Banquets, restaurants and table seating",group:"flexible",path:"M7 1 Q6 1 6 2.5 L6.75 10.5 L5 10.5 Q4 10.5 4 12 L4 14 Q4 15 5.25 15 L6 15 L4 23 L7 23 L9.5 15 L14.5 15 L17 23 L20 23 L18 15 L18.75 15 Q20 15 20 14 L20 12 Q20 10.5 19 10.5 L17.25 10.5 L18 2.5 Q18 1 17 1 Z",bounds:{x:4,y:1,width:16,height:22}},{key:"folding",label:"Folding chair",shortLabel:"Folding",useCase:"Concert floors, ceremonies and conferences",group:"flexible",path:"M6 2 Q5 2 5 3 L6 8 L18 8 L19 3 Q19 2 18 2 Z M5 9 L19 9 Q20 9 20 10.5 L19 13 L5 13 L4 10.5 Q4 9 5 9 Z M6 12 L9 12 L12 17 L15 12 L18 12 L14 19 L17 23 L14 23 L12 21 L10 23 L7 23 L10 19 Z",bounds:{x:4,y:2,width:16,height:21}},{key:"armchair",label:"Premium armchair",shortLabel:"Armchair",useCase:"Boxes, lounges and club seating",group:"premium",path:"M3.5 4 Q3.5 1.5 6 1.5 L18 1.5 Q20.5 1.5 20.5 4 L20.5 13 L3.5 13 Z M1.5 12.5 Q1.5 10 3.25 10 Q5 10 5 12.5 L5 13.5 L19 13.5 L19 12.5 Q19 10 20.75 10 Q22.5 10 22.5 12.5 L22.5 19.5 Q22.5 22 20 22 L4 22 Q1.5 22 1.5 19.5 Z",bounds:{x:1.5,y:1.5,width:21,height:20.5}},{key:"recliner",label:"Recliner",shortLabel:"Recliner",useCase:"Luxury cinemas and premium clubs",group:"premium",path:"M7 2 Q7 1 8.5 1 L15.5 1 Q17 1 17 2 L19 13 L5 13 Z M4 9 Q2 9 2 11.5 L2 16 Q2 18 4 18 L6 18 L6 15 L18 15 L18 18 L20 18 Q22 18 22 16 L22 11.5 Q22 9 20 9 Q18 9 18 11 L18 13 L6 13 L6 11 Q6 9 4 9 Z M7 17 L17 17 Q18 17 18.5 18.5 L19.5 22.5 L4.5 22.5 L5.5 18.5 Q6 17 7 17 Z",bounds:{x:2,y:1,width:20,height:21.5}},{key:"stool",label:"Stool",shortLabel:"Stool",useCase:"Bars, high-tops and seating rails",group:"flexible",path:"M6 2.5 L18 2.5 Q22 2.5 22 6.5 L22 12 Q22 16 18 16 L6 16 Q2 16 2 12 L2 6.5 Q2 2.5 6 2.5 Z M6 15.5 L9.5 15.5 L7.5 22.5 L3 22.5 Z M14.5 15.5 L18 15.5 L20.5 22.5 L16 22.5 Z",bounds:{x:2,y:2.5,width:20,height:20}},{key:"bench",label:"Bench place",shortLabel:"Bench",useCase:"Pews, bleachers and terraces",group:"fixed",path:"M2.5 0.5 L21.5 0.5 Q23 0.5 23 2 L23 5 Q23 6.5 21.5 6.5 L2.5 6.5 Q1 6.5 1 5 L1 2 Q1 0.5 2.5 0.5 Z M2 7.5 L22 7.5 Q23.5 7.5 23.5 9 L23.5 15.5 Q23.5 17 22 17 L18 17 L18 21.5 Q18 22.5 16.75 22.5 Q15.5 22.5 15.5 21.5 L15.5 17 L8.5 17 L8.5 21.5 Q8.5 22.5 7.25 22.5 Q6 22.5 6 21.5 L6 17 L2 17 Q0.5 17 0.5 15.5 L0.5 9 Q0.5 7.5 2 7.5 Z",bounds:{x:.5,y:.5,width:23,height:22}}],mn=fn.map(e=>e.key),Pr=new Map(fn.map(e=>[e.key,e]));function ln(e){return typeof e=="string"&&Pr.has(e)}function dn(e,t){return ln(e)?e:ln(t?.seatGlyph)?t.seatGlyph:"circle"}var ee={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,body:10,head:11},Cr=.44,Ar=.15,Er=.3,_r=.24;function bn(e){return e===void 0||!Number.isFinite(e)||e<=0?_r:Math.min(Er,Math.max(Ar,e*Cr))}var kr=.05,hn=.45,Tr=hn+kr,Ds=[{part:ee.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:ee.pad,min:[-1,.36,-.95],max:[1,hn,1]},{part:ee.back,min:[-1,Tr,-1],max:[1,.92,-.72]},{part:ee.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:ee.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:ee.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:ee.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:ee.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:ee.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:ee.leg,min:[.62,0,.48],max:[.82,.37,.7]}],Ns=[{part:ee.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:ee.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:ee.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:ee.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:ee.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}];function pn(e,t,n,o){let r=new Float32Array(t),i=f=>e[f*3],s=f=>e[f*3+2],a=0,d=(f,u)=>{let b=u-f;for(let c=f;c<u;c++){let[l,m]=o(c),h=l-i(c),p=m-s(c);if(b>=2){let y=Math.max(f,c-1),g=Math.min(u-1,c+1),S=i(g)-i(y),x=s(g)-s(y),_=Math.hypot(S,x);if(_>1e-6){let M=-x/_,v=S/_;M*h+v*p<0&&(M=-M,v=-v),h=M,p=v}}r[c]=h===0&&p===0?0:Math.atan2(h,p)}};for(let f=1;f<=t;f++)(f===t||n(f)!==n(a))&&(d(a,f),a=f);return r}var et=.22;var Lr=.42;function Or(e){let t=e.length,n=new Float64Array(t);if(t<2)return n.fill(1/0),n;let o=1/0,r=1/0,i=-1/0,s=-1/0;for(let m of e)m.x<o&&(o=m.x),m.y<r&&(r=m.y),m.x>i&&(i=m.x),m.y>s&&(s=m.y);let a=Math.max(i-o,1e-6),d=Math.max(s-r,1e-6),f=Math.max(Math.sqrt(a*d/t),1e-6),u=Math.max(1,Math.ceil(a/f)+1),b=Math.max(1,Math.ceil(d/f)+1),c=new Map,l=(m,h)=>{let p=Math.min(u-1,Math.max(0,Math.floor((m-o)/f)));return Math.min(b-1,Math.max(0,Math.floor((h-r)/f)))*u+p};for(let m=0;m<t;m++){let h=l(e[m].x,e[m].y),p=c.get(h);p?p.push(m):c.set(h,[m])}for(let m=0;m<t;m++){let h=e[m],p=Math.min(u-1,Math.max(0,Math.floor((h.x-o)/f))),y=Math.min(b-1,Math.max(0,Math.floor((h.y-r)/f))),g=1/0;for(let S=1;S<=4;S++){for(let x=y-S;x<=y+S;x++)if(!(x<0||x>=b))for(let _=p-S;_<=p+S;_++){if(_<0||_>=u||S>1&&Math.abs(x-y)<S&&Math.abs(_-p)<S)continue;let M=c.get(x*u+_);if(M)for(let v of M){if(v===m)continue;let k=Math.hypot(e[v].x-h.x,e[v].y-h.y);k<g&&(g=k)}}if(Number.isFinite(g)&&g<=S*f)break}n[m]=g}return n}function Br(e){let t=e.eyeHeightM;return Number.isFinite(t)?Math.max(0,t-me):0}function yn(e,t,n,o,r,i){let s=e.length,a=new Float32Array(s*3),d=new Float32Array(s),f=new Float32Array(s*3),u=new Float32Array(s),b=new Float32Array(s),c=new Float32Array(s),l=new Float32Array(s),m=new Float32Array(s*3),h=new Map,p=Or(e);for(let y=0;y<s;y++){let g=e[y],x=(n?.seatPitchU(y)??p[y])*R;u[y]=Number.isFinite(x)?Math.max(.06,Math.min(et,x*Lr)):et,b[y]=bn(Number.isFinite(x)?x:void 0);let _=dn(g.glyph,{seatGlyph:i?.get(g.categoryKey)});c[y]=mn.indexOf(_),l[y]=g.wheelchairSpaceType==="no-seat"?0:1,a[y*3]=g.x*R,a[y*3+1]=n?n.seatDeckY(y):Br(g),a[y*3+2]=g.y*R,d[y]=Jt(t?t(g):"available");let M=W(r?.get(g.categoryKey)??"#6e7bff")??[.43,.48,1];if(f[y*3]=M[0],f[y*3+1]=M[1],f[y*3+2]=M[2],g.accessibility?.length){let v=W(un(g.accessibility));v&&(m[y*3]=v[0],m[y*3+1]=v[1],m[y*3+2]=v[2])}h.set(g.id,y)}return{count:s,iPosition:a,iState:d,iCategory:f,iMaxRadius:u,iRing:m,idToIndex:h,iChairWidth:b,iGlyph:c,iPhysicalSeat:l,iFloor:o??new Float32Array(s),iYaw:new Float32Array(s)}}function Fr(e){return{kind:"radial",rowCount:0,rows:[],nearestRow:()=>-1,depthAt:(t,n)=>Math.hypot(t-e.x,n-e.y),gradientAt:(t,n)=>{let o=t-e.x,r=n-e.y,i=Math.hypot(o,r);return i<1e-9?[0,0]:[o/i,r/i]}}}function Dr(e,t){if(!e.length)return null;let n=0,o=0,r=0;for(let l of e)n+=l.x,o+=l.y,r+=Math.hypot(l.x-t.x,l.y-t.y);let i=e.length;n/=i,o/=i,r/=i;let s=e[0],a=-1;for(let l of e){let m=Math.hypot(l.x-n,l.y-o);m>a&&(a=m,s=l)}let d=s.x-n,f=s.y-o,u=Math.hypot(d,f);u>1e-9?(d/=u,f/=u):(d=1,f=0);let b=[...e].sort((l,m)=>(l.x-n)*d+(l.y-o)*f-((m.x-n)*d+(m.y-o)*f)),c=0;for(let l of b){let m=Math.hypot(l.x-n,l.y-o);m>c&&(c=m)}return{pts:b,cx:n,cy:o,radius:c,depth:r}}function gn(e,t,n){let o=e.pts;if(o.length===1)return Math.hypot(t-o[0].x,n-o[0].y);let r=1/0;for(let i=0;i+1<o.length;i++){let s=o[i],a=o[i+1],d=a.x-s.x,f=a.y-s.y,u=d*d+f*f,b=u>1e-12?((t-s.x)*d+(n-s.y)*f)/u:0;b<0?b=0:b>1&&(b=1);let c=Math.hypot(t-(s.x+b*d),n-(s.y+b*f));c<r&&(r=c)}return r}var tt=8;function Nr(e,t,n){let o=new Array(tt).fill(1/0),r=new Array(tt).fill(-1);for(let u=0;u<e.length;u++){let b=e[u],c=Math.hypot(t-b.cx,n-b.cy)-b.radius;for(let l=0;l<tt;l++)if(c<o[l]){for(let m=tt-1;m>l;m--)o[m]=o[m-1],r[m]=r[m-1];o[l]=c,r[l]=u;break}}let i=new Array(3).fill(1/0),s=new Array(3).fill(-1);for(let u of r){if(u<0)continue;let b=gn(e[u],t,n);for(let c=0;c<3;c++)if(b<i[c]){for(let l=2;l>c;l--)i[l]=i[l-1],s[l]=s[l-1];i[c]=b,s[c]=u;break}}if(s[0]<0)return 0;if(i[0]<1e-6)return e[s[0]].depth;let a=i[0]*2.2,d=0,f=0;for(let u=0;u<3;u++){let b=s[u];if(b<0||i[u]>a)continue;let c=1/(i[u]*i[u]);d+=c*e[b].depth,f+=c}return f>0?d/f:e[s[0]].depth}function Gr(e){let t=(o,r)=>Nr(e,o,r),n=(o,r)=>{let i=1/0,s=-1;for(let a=0;a<e.length;a++){let d=e[a];if(Math.hypot(o-d.cx,r-d.cy)-d.radius>=i)continue;let f=gn(d,o,r);f<i&&(i=f,s=a)}return s};return{kind:"rows",rowCount:e.length,rows:e,nearestRow:n,depthAt:t,gradientAt:(o,r)=>{let i=(t(o+.5,r)-t(o-.5,r))/1,s=(t(o,r+.5)-t(o,r-.5))/(2*.5),a=Math.hypot(i,s);return a<1e-9?[0,0]:[i/a,s/a]}}}function xn(e,t){let n=[];for(let o of e){let r=Dr(o.points,t);r&&n.push(r)}return n.length<2?Fr(t):(n.sort((o,r)=>o.depth-r.depth),Gr(n))}var Rt=Ie(require("polygon-clipping"),1);var In=Ie(require("earcut"),1);var jr=.58,Sn=.01,se=et*1.5*fe,Ur=.5,Xr=.6;function Yr(e,t){let n=e.length,o=[];for(let s=0;s<n;s++){let a=e[Math.max(0,s-1)],d=e[Math.min(n-1,s+1)],f=d.x-a.x,u=d.y-a.y,b=Math.hypot(f,u);if(b<1e-9){o.push([0,0]);continue}f/=b,u/=b,o.push([-u,f])}let r=0;for(let s=0;s<n;s++)r+=(e[s].x-t.x)*o[s][0]+(e[s].y-t.y)*o[s][1];return r<0?o.map(([s,a])=>[-s,-a]):o}function Vr(e,t){if(e.length<2||t<=0)return[...e];let n=[...e],o=(s,a)=>{let d=a.x-s.x,f=a.y-s.y,u=Math.hypot(d,f)||1;return{x:d/u,y:f/u}},r=o(n[1],n[0]),i=o(n[n.length-2],n[n.length-1]);return n.unshift({x:n[0].x+r.x*t,y:n[0].y+r.y*t}),n.push({x:n[n.length-1].x+i.x*t,y:n[n.length-1].y+i.y*t}),n}var Mn=Math.PI/12;function Hr(e){if(e.length<3)return[...e];let t=[...e].sort((i,s)=>i.x-s.x||i.y-s.y),n=(i,s,a)=>(s.x-i.x)*(a.y-i.y)-(s.y-i.y)*(a.x-i.x),o=i=>{let s=[];for(let a of i){for(;s.length>=2&&n(s[s.length-2],s[s.length-1],a)<=0;)s.pop();s.push(a)}return s.pop(),s},r=[...o(t),...o([...t].reverse())];return r.length>=3?r:[...e]}function vn(e,t){if(!e.length||!(t>0))return[];let n=Hr(e),o=(a,d,f,u)=>{let b=f-d;for(;b<0;)b+=Math.PI*2;for(;b>Math.PI*2;)b-=Math.PI*2;let c=Math.max(1,Math.ceil(b/Mn)),l=t/Math.cos(b/c/2);for(let m=0;m<=c;m++){let h=d+b*m/c;u.push({x:a.x+Math.cos(h)*l,y:a.y+Math.sin(h)*l})}};if(n.length<3){let a=0,d=0;for(let l of n)a+=l.x,d+=l.y;a/=n.length||1,d/=n.length||1;let f=0;for(let l of n)f=Math.max(f,Math.hypot(l.x-a,l.y-d));let u=[],b=Math.max(3,Math.ceil(Math.PI*2/Mn)),c=(f+t)/Math.cos(Math.PI/b);for(let l=0;l<b;l++){let m=l/b*Math.PI*2;u.push({x:a+Math.cos(m)*c,y:d+Math.sin(m)*c})}return u}let r=n.length,i=[];for(let a=0;a<r;a++){let d=n[a],f=n[(a+1)%r];i.push(Math.atan2(-(f.x-d.x),f.y-d.y))}let s=[];for(let a=0;a<r;a++)o(n[a],i[(a+r-1)%r],i[a],s);return En(s)}function Kr(e,t,n){if(e.length===1)return Math.hypot(t-e[0].x,n-e[0].y);let o=1/0;for(let r=0;r+1<e.length;r++){let i=e[r],s=e[r+1],a=s.x-i.x,d=s.y-i.y,f=a*a+d*d,u=f>1e-12?((t-i.x)*a+(n-i.y)*d)/f:0;u<0?u=0:u>1&&(u=1);let b=Math.hypot(t-(i.x+u*a),n-(i.y+u*d));b<o&&(o=b)}return o}function nt(e){let t=e.map(r=>{let i=0,s=0;for(let f of r.pts)i+=f.x,s+=f.y;let a=r.pts.length||1;i/=a,s/=a;let d=0;for(let f of r.pts){let u=Math.hypot(f.x-i,f.y-s);u>d&&(d=u)}return{cx:i,cy:s,rad:d}}),n=r=>{let i=r.length;return i<=2?[...r]:[r[Math.floor(i*.25)],r[Math.floor(i*.5)],r[Math.floor(i*.75)]]},o=[];for(let r=0;r<e.length;r++){let i=n(e[r].pts),s=[],a=1/0,d=null;for(let u of i){let b=1/0;for(let c=0;c<e.length;c++){if(c===r||Math.abs(e[c].y-e[r].y)<.001)continue;let l=t[c],m=Math.hypot(u.x-l.cx,u.y-l.cy)-l.rad;if(m>=b&&m>=a)continue;let h=Kr(e[c].pts,u.x,u.y);h<b&&(b=h),e[c].depth<e[r].depth&&h<a&&(a=h,d=e[c].y)}Number.isFinite(b)&&b>0&&s.push(b)}s.sort((u,b)=>u-b);let f=s.length?s[Math.floor(s.length/2)]:1;o.push({pitch:f,belowY:d})}return o}function Rn(e,t,n,o){let r=e[t],i=r.pts.length>=2?[...r.pts]:r.pts.length===1?(()=>{let u=r.pts[0],b=u.x-o.x,c=u.y-o.y,l=Math.hypot(b,c)||1;b/=l,c/=l;let m=Math.max(n[t].pitch,.001)*.5;return[{x:u.x+c*m,y:u.y-b*m},{x:u.x-c*m,y:u.y+b*m}]})():[];if(i.length<2)return null;let s=0,a=0;for(let u=1;u<i.length;u++){let b=Math.hypot(i[u].x-i[u-1].x,i[u].y-i[u-1].y);b>1e-6&&(s+=b,a++)}let d=a>0?s/a:0,f=Vr(i,Math.max(d*Xr,se));return{pts:f,nrm:Yr(f,o),front:Math.max(n[t].pitch*jr,se),back:Math.max(n[t].pitch*Ur,se)}}var Re=1.5,Pn=.3;function It(e,t){if(e.length<3)return e;let n=e[0],o=e[e.length-1],r=o.x-n.x,i=o.y-n.y,s=Math.hypot(r,i),a=-1,d=-1;for(let b=1;b<e.length-1;b++){let c=e[b],l=s>1e-12?Math.abs((c.x-n.x)*i-(c.y-n.y)*r)/s:Math.hypot(c.x-n.x,c.y-n.y);l>a&&(a=l,d=b)}if(a<=t||d<0)return[n,o];let f=It(e.slice(0,d+1),t),u=It(e.slice(d),t);return[...f.slice(0,-1),...u]}function Cn(e,t){if(e.length<4)return e;let n=It([...e,e[0]],t);return n.pop(),n.length>=3?n:e}function An(e,t,n){if(e.length<2)return[];let o=n??nt(e),r=new Map;for(let s=0;s<e.length;s++){let a=r.get(e[s].blockId);a?a.push(s):r.set(e[s].blockId,[s])}let i=[];for(let[,s]of r){let a=[];for(let g of s){let S=e[g].patch;S&&S.length>=3?i.push({outline:[...S],holes:[],topY:e[g].y}):a.push(g)}if(!a.length)continue;a.sort((g,S)=>e[g].depth-e[S].depth);let f=a.map(g=>Rn(e,g,o,t)).filter(g=>g!==null);if(!f.length)continue;let u=(g,S)=>({x:g.pts[S].x-g.nrm[S][0]*(g.front+Re),y:g.pts[S].y-g.nrm[S][1]*(g.front+Re)}),b=(g,S)=>({x:g.pts[S].x+g.nrm[S][0]*(g.back+Re),y:g.pts[S].y+g.nrm[S][1]*(g.back+Re)}),c=f[0],l=f[f.length-1],m=[];for(let g=0;g<c.pts.length;g++)m.push(u(c,g));for(let g of f)m.push(b(g,g.pts.length-1));for(let g=l.pts.length-1;g>=0;g--)m.push(b(l,g));for(let g=f.length-1;g>=0;g--)m.push(u(f[g],0));let h=En(m),p=1/0;for(let g of a)e[g].y<p&&(p=e[g].y);if(!Number.isFinite(p))continue;if(h.length>=3&&Math.abs(he(h))>1e-6&&f.every(g=>{let S=g.pts[Math.floor(g.pts.length/2)];return Le(h,S.x,S.y)})){i.push({outline:Cn(h,Pn),holes:[],topY:p});continue}for(let g of zr(f))i.push({outline:g,holes:[],topY:p})}return i}function zr(e){let t=[];for(let n of e){let o=[],r=[],i=n.front+Re,s=n.back+Re;for(let d=0;d<n.pts.length;d++){let f=n.pts[d],u=n.nrm[d];o.push([f.x-u[0]*i,f.y-u[1]*i]),r.push([f.x+u[0]*s,f.y+u[1]*s])}let a=[...o,...r.reverse()];a.length<3||(a.push(a[0]),t.push([a]))}if(!t.length)return[];try{let n=Rt.default.union(t[0],...t.slice(1)),o=[];for(let r of n){if(!r.length||r[0].length<4)continue;let i=r[0].map(([d,f])=>({x:d,y:f})),s=i[0],a=i[i.length-1];i.length>1&&Math.abs(s.x-a.x)<1e-9&&Math.abs(s.y-a.y)<1e-9&&i.pop(),i.length>=3&&o.push(Cn(i,Pn))}return o}catch{return[]}}function En(e){let t=[];for(let n of e){let o=t[t.length-1];o&&Math.hypot(n.x-o.x,n.y-o.y)<1e-9||t.push(n)}for(;t.length>2&&Math.hypot(t[0].x-t[t.length-1].x,t[0].y-t[t.length-1].y)<1e-9;)t.pop();return t}var vt=class{constructor(t){this.minX=1/0;this.minY=1/0;this.maxX=-1/0;this.maxY=-1/0;this.rings=t;for(let n of t)for(let o of n)o.x<this.minX&&(this.minX=o.x),o.y<this.minY&&(this.minY=o.y),o.x>this.maxX&&(this.maxX=o.x),o.y>this.maxY&&(this.maxY=o.y)}containsAll(t){for(let n of t)if(n.x<this.minX||n.x>this.maxX||n.y<this.minY||n.y>this.maxY)return!1;for(let n of this.rings){let o=!0;for(let r of t)if(!Le(n,r.x,r.y)){o=!1;break}if(o)return!0}return!1}};function wn(e,t,n,o,r,i){if(o.length<3)return;if(n.containsAll(o)){let f=[0,1,0],u=o[0];for(let b=1;b+1<o.length;b++){let c=o[b],l=o[b+1];e.tri([u.x*R,r,u.y*R],[c.x*R,r,c.y*R],[l.x*R,r,l.y*R],f,i)}return}let s=o.map(f=>[f.x,f.y]);s.push(s[0]);let a;try{a=Rt.default.intersection([s],t)}catch{return}let d=[0,1,0];for(let f of a){if(!f.length||f[0].length<4)continue;let u=f[0],b=[],c=[];for(let m=0;m<u.length-1;m++)b.push(u[m][0],u[m][1]),c.push([u[m][0],u[m][1]]);if(c.length<3)continue;let l=(0,In.default)(b,void 0,2);for(let m=0;m<l.length;m+=3){let h=c[l[m]],p=c[l[m+1]],y=c[l[m+2]];e.tri([h[0]*R,r,h[1]*R],[p[0]*R,r,p[1]*R],[y[0]*R,r,y[1]*R],d,i)}}}function _n(e,t,n,o,r,i,s){if(t.length<2)return;let a=s??nt(t),d=[0,1,0],f=i&&i.length>=3?[[...i.map(l=>[l.x,l.y]),[i[0].x,i[0].y]]]:null,u=i&&i.length>=3?new vt([[...i]]):null,b=l=>{e.setMaterial(2),l(),e.setMaterial(0)},c=l=>{e.setMaterial(3),l(),e.setMaterial(0)};for(let l=0;l<t.length;l++){let m=t[l];if(m.patch&&m.patch.length>=3){let _=[...m.patch],M=a[l].belowY??o;if(c(()=>{if(f&&u)wn(e,f,u,_,m.y,r.tread);else{let v=_[0];for(let k=1;k+1<_.length;k++){let B=_[k],D=_[k+1];e.tri([v.x*R,m.y,v.y*R],[B.x*R,m.y,B.y*R],[D.x*R,m.y,D.y*R],d,r.tread)}}}),m.y>M+Sn){let v=0,k=0;for(let B of _)v+=B.x,k+=B.y;v/=_.length,k/=_.length,b(()=>{for(let B=0;B<_.length;B++){let D=_[B],U=_[(B+1)%_.length],P=U.x-D.x,w=U.y-D.y,L=Math.hypot(P,w);if(L<1e-6)continue;let T=w/L,I=-P/L;(D.x-v)*T+(D.y-k)*I<0&&(T=-T,I=-I);let F=[T,0,I],A=[D.x*R,m.y,D.y*R],C=[U.x*R,m.y,U.y*R],E=[D.x*R,M,D.y*R],N=[U.x*R,M,U.y*R];e.tri(A,C,N,F,r.riser),e.tri(A,N,E,F,r.riser)}})}continue}let h=Rn(t,l,a,n);if(!h)continue;let{pts:p,nrm:y,front:g,back:S}=h,x=a[l].belowY??o;for(let _=0;_+1<p.length;_++){let M=p[_],v=p[_+1],k=y[_],B=y[_+1];if(Math.hypot(v.x-M.x,v.y-M.y)<1e-6||k[0]===0&&k[1]===0||B[0]===0&&B[1]===0)continue;let D=[(M.x-k[0]*g)*R,m.y,(M.y-k[1]*g)*R],U=[(v.x-B[0]*g)*R,m.y,(v.y-B[1]*g)*R],P=[(M.x+k[0]*S)*R,m.y,(M.y+k[1]*S)*R],w=[(v.x+B[0]*S)*R,m.y,(v.y+B[1]*S)*R];if(c(()=>{f&&u?wn(e,f,u,[{x:M.x-k[0]*g,y:M.y-k[1]*g},{x:v.x-B[0]*g,y:v.y-B[1]*g},{x:v.x+B[0]*S,y:v.y+B[1]*S},{x:M.x+k[0]*S,y:M.y+k[1]*S}],m.y,r.tread):(e.tri(D,U,w,d,r.tread),e.tri(D,w,P,d,r.tread))}),m.y>x+Sn){let L=[D[0],x,D[2]],T=[U[0],x,U[2]],I=[-k[0],0,-k[1]];b(()=>{e.tri(D,U,T,I,r.riser),e.tri(D,T,L,I,r.riser)})}}}}function kn(e){let t=1/0,n=1/0,o=-1/0,r=-1/0,i=!1;for(let s of e)!Number.isFinite(s.x)||!Number.isFinite(s.y)||(i=!0,s.x<t&&(t=s.x),s.y<n&&(n=s.y),s.x>o&&(o=s.x),s.y>r&&(r=s.y));return i?{minX:t,minY:n,maxX:o,maxY:r}:null}function ot(e,t){return e.minX<=t.maxX&&t.minX<=e.maxX&&e.minY<=t.maxY&&t.minY<=e.maxY}var Pt=Ie(require("polygon-clipping"),1);function Wr(e,t){let n=e.eventConfigurationIds;return!n?.length||!!t&&n.includes(t)}function Tn(e,t){return e.filter(n=>n.type!=="shape"||Wr(n,t))}function Ln(e,t){let n=e.focalPoint??{x:0,y:0};return e.floors?.length?e.floors.map((o,r)=>({objects:Tn(o.objects,t),focal:{x:(o.focalPoint??n).x,y:(o.focalPoint??n).y},baseHeightM:o.baseHeightM??0,index:r})):[{objects:Tn(e.objects,t),focal:n,baseHeightM:0,index:0}]}var Zr={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Pe(e){return kn(e)??Zr}function On(e,t){let n=qe(e.outline,se),o=Pe(n),r=t.filter(s=>s!==e&&s.outline&&s.outline.length>=3&&ot(o,Pe(s.outline)));if(!r.length)return[n];let i=s=>{let a=s.map(d=>[d.x,d.y]);return a.push(a[0]),a};try{let s=Pt.default.difference([i(n)],...r.map(d=>[i(d.outline)])),a=[];for(let d of s){if(!d.length)continue;let f=d[0].map(([u,b])=>({x:u,y:b}));if(f.length>1){let u=f[0],b=f[f.length-1];Math.abs(u.x-b.x)<1e-9&&Math.abs(u.y-b.y)<1e-9&&f.pop()}f.length>=3&&a.push(f)}return a.length?a:[n]}catch{return[n]}}function Bn(e,t){if(!t.length)return e;let n=i=>{let s=i.map(a=>[a.x,a.y]);return s.push(s[0]),s},o=t.map(i=>[n(i)]),r=[];for(let i of e){let s;try{s=Pt.default.intersection([n(i.outline)],o.flat())}catch{r.push(i);continue}for(let a of s){if(!a.length)continue;let d=a[0].map(([f,u])=>({x:f,y:u}));if(d.length>1){let f=d[0],u=d[d.length-1];Math.abs(f.x-u.x)<1e-9&&Math.abs(f.y-u.y)<1e-9&&d.pop()}d.length>=3&&r.push({outline:d,holes:[],topY:i.topY})}}return r.length?r:e}var Qr=.05,Fn=.05,$r=.15,Ct=25;function Dn(e,t,n){let o=new Map,r=new Array(t.length).fill(null),i=new Float64Array(t.length),s=new Array(t.length).fill(void 0),a=new Array(t.length).fill(void 0),d=new Map,f=[],u=new Set;for(let c=0;c<e.length;c+=1){let l=e[c];for(let m of l.objects){if(m.type==="table"&&u.add(m.id),m.type!=="section"||!m.outline||m.outline.length<3)continue;let h=qe(m.outline,se);d.set(m.id,{section:m,unit:l,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),f.push({id:m.id,floorIndex:c,box:Pe(h),section:m,unit:l,outline:h})}}let b=new Map;for(let c of f){let l=b.get(c.floorIndex);l?l.push(c):b.set(c.floorIndex,[c])}for(let c=0;c<t.length;c++){let l=t[c],m=n?b.get(n[c])??[]:f,h=l.sectionId?m.find(y=>y.id===l.sectionId)??m.find(y=>y.section.logicalSectionId===l.sectionId&&be({x:l.x,y:l.y},y.outline,y.section.holes)):void 0,p=h?[h]:m;for(let y of p){if(n&&y.floorIndex!==n[c]||!h&&(l.x<y.box.minX||l.x>y.box.maxX||l.y<y.box.minY||l.y>y.box.maxY||!be({x:l.x,y:l.y},y.outline,y.section.holes)))continue;r[c]=y.id;let g=d.get(y.id);g.hasSeats=!0;let S=l.focalPoint??y.unit.focal,x=Math.hypot(l.x-S.x,l.y-S.y);x<g.frontU&&(g.frontU=x),g.seatIndices.push(c);let _=l.rowId||`__seat-${c}`,M=g.rows.get(_);M?M.push({x:l.x,y:l.y}):g.rows.set(_,[{x:l.x,y:l.y}]);break}}for(let[c,l]of d){let m=He(l.section,{floorBaseHeightM:l.unit.baseHeightM}),h=l.unit.baseHeightM,p=m.rake>0?Math.tan(m.rake*Math.PI/180):0,y=m.rake<=.01&&m.height<=h+.001,g=l.section.surfaceKind,S=g==="flat"?!0:g==="rakedRows"&&m.rake>.01?!1:y,x=l.hasSeats?Ke(c,t,l.seatIndices,l.unit.focal):{sectionId:c,rows:[],blockCount:0},M=x.rows.length<2?xn([...l.rows.values()].map(A=>({points:A})),l.unit.focal):null,v=1/0;if(M){if(l.hasSeats)for(let A of l.rows.values())for(let C of A){let E=M.depthAt(C.x,C.y);E<v&&(v=E)}if(!l.hasSeats||!Number.isFinite(v)){v=1/0;for(let A of l.section.outline){let C=M.depthAt(A.x,A.y);C<v&&(v=C)}}}let k=h+Qr,B=Math.max(k,m.height),D=A=>{let C=Math.max(0,A-v)*re,E=Math.min(C*p,Ct);return Math.max(k,m.height+E)},U=A=>{let C=Math.max(0,A)*re,E=Math.min(C*p,Ct);return Math.max(k,m.height+E)},P=S?[]:x.rows.map(A=>({pts:A.pts,y:U(A.blockDepth),depth:A.blockDepth,blockId:A.blockId,...u.has(A.id)?{patch:vn(A.pts,se)}:{}})),w=P.length?P[0].y:B,L=P.map(A=>{let C=A.patch&&A.patch.length>=3?A.patch:A.pts,E=0,N=0;for(let G of C)E+=G.x,N+=G.y;let j=C.length||1;E/=j,N/=j;let X=0;for(let G of C){let Y=Math.hypot(G.x-E,G.y-N);Y>X&&(X=Y)}return{cx:E,cy:N,rad:X}}),T=S?()=>B:P.length>=2?(A,C)=>{let E=1/0,N=w;for(let j=0;j<P.length;j++){let X=L[j];if(Math.hypot(A-X.cx,C-X.cy)-X.rad>=E)continue;let G=P[j].patch,Y=G&&G.length>=3?Le(G,A,C)?0:ve(G,A,C):ve(P[j].pts,A,C);Y<E&&(E=Y,N=P[j].y)}return N}:(A,C)=>M?D(M.depthAt(A,C)):B,I=[0,1,0],F=P.length>=2||S?()=>I:(A,C)=>{if(!M)return I;let E=M.depthAt(A,C);if(E<=v)return I;let N=(E-v)*re;if(N*p>=Ct||m.height+N*p<=k)return I;let[j,X]=M.gradientAt(A,C);if(j===0&&X===0)return I;let G=1/Math.hypot(p,1);return[-j*p*G,G,-X*p*G]};if(!S)for(let A of x.rows){let C=U(A.blockDepth);for(let E of A.seatIndices)s[E]=C}for(let A of x.rows){let C=[];for(let G=1;G<A.pts.length;G++){let Y=Math.hypot(A.pts[G].x-A.pts[G-1].x,A.pts[G].y-A.pts[G-1].y);Y>1e-6&&C.push(Y)}C.sort((G,Y)=>G-Y);let E=C.length?C[Math.floor(C.length/2)]:1/0,N=1/0,j=A.pts[Math.floor(A.pts.length/2)];if(j)for(let G of x.rows){if(G===A||G.blockId!==A.blockId)continue;let Y=ve(G.pts,j.x,j.y);Y>1e-6&&Y<N&&(N=Y)}let X=Math.min(E,Math.max(N,E*.5));if(Number.isFinite(X)&&X>0)for(let G of A.seatIndices)a[G]=X}o.set(c,{sectionId:c,deckAt:T,normalAt:F,flat:S,bottomY:h,rowLevels:P,landingY:w})}for(let c=0;c<t.length;c++){let l=r[c],m=t[c];if(l){let p=s[c];i[c]=(p??o.get(l).deckAt(m.x,m.y))+$r;continue}let h=m.eyeHeightM;i[c]=Number.isFinite(h)?Math.max(0,h-me):0}return{bySection:o,seatOwner:r,seatDeckY:c=>i[c],seatPitchU:c=>a[c]}}var $={top:1,wallBottom:.5,bottomCap:.4};function ce(e,t){if(!e)return t;let n=ie(Te(e,.4),.62);return te(t,n,.72)}function Nn(e,t){let n=new Map;for(let i of e.categories??[])n.set(i.key,i.color);let o=new Map;for(let i of t){if(!i.sectionId)continue;let s=o.get(i.sectionId);s||(s=new Map,o.set(i.sectionId,s)),s.set(i.categoryKey,(s.get(i.categoryKey)??0)+1)}let r=new Map;for(let[i,s]of o){let a=0,d=0,f=0,u=0;for(let[b,c]of s){let l=W(n.get(b));l&&(a+=l[0]*c,d+=l[1]*c,f+=l[2]*c,u+=c)}u>0&&r.set(i,[a/u,d/u,f/u])}return r}function Gn(e,t){return W(e.color)??t.get(e.logicalSectionId??e.id)??null}var ya=Math.PI*2;function jn(e){return e==="pitch-football"||e==="rink-hockey"||e==="track-athletics"||e==="oval-cricket"}var Un=Ie(require("polygon-clipping"),1);function qr(e,t){return e===void 0||t===void 0?!0:Math.abs(e-t)<.001}var rt=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(t,n){let o=t.map(d=>[d.x,d.y]);if(o.length<3)return[];o.push(o[0]);let r=Pe(t),i=this.rings.filter((d,f)=>ot(r,this.boxes[f])&&qr(n,this.levels[f])),s=[[o]];if(i.length)try{s=Un.default.difference([o],...i).map(f=>f.map(u=>u.map(([b,c])=>[b,c])))}catch{s=[[o]]}this.rings.push([o]),this.boxes.push(r),this.levels.push(n);let a=[];for(let d of s){if(!d.length)continue;let f=d[0].map(([u,b])=>({x:u,y:b}));if(f.length>1){let u=f[0],b=f[f.length-1];Math.abs(u.x-b.x)<1e-9&&Math.abs(u.y-b.y)<1e-9&&f.pop()}f.length>=3&&a.push(f)}return a}};function Jr(e,t){if(!t)return e;let n=1/0,o=-1/0,r=1/0,i=-1/0;for(let b of e)n=Math.min(n,b.x),o=Math.max(o,b.x),r=Math.min(r,b.y),i=Math.max(i,b.y);let s=(n+o)/2,a=(r+i)/2,d=t*Math.PI/180,f=Math.cos(d),u=Math.sin(d);return e.map(b=>{let c=b.x-s,l=b.y-a;return{x:s+c*f-l*u,y:a+c*u+l*f}})}function ye(e){let t=null;if(e.kind==="polygon"&&e.points&&e.points.length>=3&&(t=e.points),e.kind==="rect"&&e.width&&e.height&&(t=Fe(e.x??0,e.y??0,e.width,e.height)),e.kind==="ellipse"&&e.width&&e.height){let n=(e.x??0)+e.width/2,o=(e.y??0)+e.height/2;t=Je(n,o,e.width/2,e.height/2)}return t?Jr(t,e.rotation):null}function De(e){let t=e.role??"",n={stage:{kind:"stage",heightM:1},entrance:{kind:"portal",heightM:2.7},exit:{kind:"portal",heightM:2.7},screen:{kind:"solid",heightM:6},wall:{kind:"solid",heightM:2.8},rail:{kind:"solid",heightM:1.1},suite:{kind:"suite",heightM:3},obstruction:{kind:"solid",heightM:4.5},sound:{kind:"solid",heightM:1.45},restroom:{kind:"solid",heightM:2.4},bar:{kind:"solid",heightM:1.1},concession:{kind:"solid",heightM:1.1},coat:{kind:"solid",heightM:1.1},goal:{kind:"portal",heightM:1.8}},o=t==="stage"&&jn(e.stageKind)?{kind:"stage",heightM:.06}:n[t]??{kind:"plate",heightM:.25};return{...o,heightM:e.heightM??o.heightM}}var ei=.08;function Xn(e,t){let n=ye(e),o=De(e),r=o.heightM;if(!n||o.kind!=="plate"&&o.kind!=="stage")return r;let i=1/0,s=1/0,a=-1/0,d=-1/0;for(let u of n)i=Math.min(i,u.x),s=Math.min(s,u.y),a=Math.max(a,u.x),d=Math.max(d,u.y);let f=r;for(let u of t)a>u.minX&&i<u.maxX&&d>u.minY&&s<u.maxY&&f<=u.topOffsetM+1e-6&&(f=u.topOffsetM+ei);return t.push({minX:i,minY:s,maxX:a,maxY:d,topOffsetM:f}),f}function de(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function Yn(e){if(e.length!==4)return e;let t=Math.hypot(e[1].x-e[0].x,e[1].y-e[0].y),n=Math.hypot(e[2].x-e[1].x,e[2].y-e[1].y);return t>=n?e:[e[1],e[2],e[3],e[0]]}function Ne(e,t,n){return[de(e[0],e[1],t),de(e[0],e[1],n),de(e[3],e[2],n),de(e[3],e[2],t)]}function Vn(e,t,n){return[de(e[0],e[3],t),de(e[1],e[2],t),de(e[1],e[2],n),de(e[0],e[3],n)]}function ue(e,t,n,o,r,i){J(e,t,void 0,()=>n,o,r,i,$)}var At=2.4,ti=.75,ni=.15;function Ge(e){if(e.points&&e.points.length>=3)return e.points;let{center:t,width:n,height:o,rotation:r}=e;if(!n||!o)return null;let i=(r??0)*Math.PI/180,s=Math.cos(i),a=Math.sin(i),d=n/2,f=o/2;return[[-d,-f],[d,-f],[d,f],[-d,f]].map(([u,b])=>({x:t.x+u*s-b*a,y:t.y+u*a+b*s}))}function Hn(e,t,n,o,r){let i=Ge(t);i&&J(e,i,void 0,()=>n+At,n,ce(o,r.boothTop),r.boothWall,$)}function Et(e){if(e.shape==="round"){let u=e.radius;return u?Je(e.center.x,e.center.y,u,u,24):null}let{width:t,height:n,rotation:o,center:r}=e;if(!t||!n)return null;let i=(o??0)*Math.PI/180,s=Math.cos(i),a=Math.sin(i),d=t/2,f=n/2;return[[-d,-f],[d,-f],[d,f],[-d,f]].map(([u,b])=>({x:r.x+u*s-b*a,y:r.y+u*a+b*s}))}function Kn(e,t,n,o,r){let i=Et(t);i&&J(e,i,void 0,()=>n+ti,n,ce(o,r.tableTop),r.tableWall,$)}function zn(e,t,n,o,r,i,s,a){let d=ye(t);if(!d)return;let f=a?a.kind==="stage":t.role==="stage",u=a?a.kind==="screen":t.role==="screen",b=a?{kind:f?"stage":"solid",heightM:a.topY-a.baseY}:De(t),c=a?.baseY??n,l=a?.topY??n+o;if(f&&s){let g=1/0,S=-1/0,x=1/0,_=-1/0;for(let M of d)M.x<g&&(g=M.x),M.x>S&&(S=M.x),M.y<x&&(x=M.y),M.y>_&&(_=M.y);s.push({cx:(g+S)/2*R,cz:(x+_)/2*R,y:l,halfX:Math.max((S-g)/2*R,.5),halfZ:Math.max((_-x)/2*R,.5)})}let m=W(t.fill),h=f&&m?te(r.stageTop,ie(Te(m,.18),.9),.9):ce(m,f?r.stageTop:r.decorTop),p=u?m:null,y=f?m?te(r.stageWall,ie(m,.58),.82):r.stageWall:u?p?te(ie(p,1.42),[.24,.46,.82],.08):[.24,.46,.82]:ce(W(t.fill),r.decorWall);if(b.kind==="portal"&&d.length===4){let g=Yn(d);ue(e,Ne(g,0,.16),l,c,h,y),ue(e,Ne(g,.84,1),l,c,h,y),ue(e,g,l,Math.max(c,l-.35),h,y);return}if(b.kind==="suite"&&d.length===4){let g=d.map((_,M)=>{let v=d[(M+1)%4],k=(_.x+v.x)/2,B=(_.y+v.y)/2;return Math.hypot(k-i.x,B-i.y)}),S=g.indexOf(Math.min(...g)),x=[0,1,2,3].map(_=>d[(S+_)%4]);ue(e,Ne(x,0,.08),l,c,h,y),ue(e,Ne(x,.92,1),l,c,h,y),ue(e,Vn(x,.88,1),l,c,h,y),ue(e,x,l,Math.max(c,l-.18),h,y);return}ue(e,d,l,c,h,y)}function _t(e){let{x:t,y:n,width:o,height:r}=e;if(!o||!r)return null;let i=t+o/2,s=n+r/2,a=(e.rotation??0)*Math.PI/180,d=Math.cos(a),f=Math.sin(a),u=o/2,b=r/2;return[[-u,-b],[u,-b],[u,b],[-u,b]].map(([c,l])=>({x:i+c*d-l*f,y:s+c*f+l*d}))}function oi(e){if(!e||!e.startsWith("data:image/svg+xml"))return null;let t=e.slice(e.indexOf(",")+1);if(/;base64/i.test(e.slice(0,e.indexOf(","))))try{t=atob(t)}catch{return null}else try{t=decodeURIComponent(t)}catch{}let n=t.match(/<(?:rect|path)\b[^>]*\bfill="([^"]+)"/i);if(!n)return null;let o=n[1].trim();if(o==="none"||o==="transparent")return null;let r=o.match(/^url\(#([^)]+)\)$/);if(!r)return W(o);let i=t.match(new RegExp(`<(?:linear|radial)Gradient\\b[^>]*\\bid="${r[1]}"[^>]*>([\\s\\S]*?)</(?:linear|radial)Gradient>`,"i"));if(!i)return null;let s=[];for(let a of i[1].matchAll(/stop-color="([^"]+)"/gi)){let d=W(a[1].trim());d&&s.push(d)}return s.length?s.reduce((a,d,f)=>te(a,d,1/(f+1)),s[0]):null}function Wn(e,t,n,o){if(t.layer==="foreground")return;let r=_t(t);if(!r)return;let i=n+ni,s=ce(oi(t.href),o.decorTop),a=Math.max(0,Math.min(1,t.opacity??1));a<1&&(s=te(o.ground,s,a)),J(e,r,void 0,()=>i,n,s,te(s,o.decorWall,.5),$)}function Zn(e,t,n,o,r){if(!t.points||t.points.length<3)return;let i=ce(o,r.gaTop);J(e,t.points,t.holes,()=>n+.15,n,i,r.gaWall,$)}var ri=Math.PI/180,K=96,ii=6,si=60,ai=150,Qn=.2,ci=.35;function ui(e,t){let n=Math.atan2(t.x-e.x,t.y-e.y)/ri;return n<0?n+360:n}function it(e){if(!e.length)return NaN;let t=[...e].sort((n,o)=>n-o);return t[Math.floor(t.length/2)]}function st(e,t,n=2){let o=e.length,r=new Float64Array(o);for(let i=0;i<o;i++){let s=0,a=0;for(let d=-n;d<=n;d++){let f=i+d;if(t)f=(f%o+o)%o;else if(f<0||f>=o)continue;s+=e[f],a++}r[i]=s/a}return r}function $n(e,t){let n=e.filter(c=>c.rows.length>=1);if(n.length<1)return null;let o=[],r=0,i=0,s=0;for(let c of n)for(let l of c.rows){for(let m of l.pts)r+=m.x,i+=m.y,s++;if(l.pts.length>=4){let m=yt(l.pts);m&&Number.isFinite(m.cx)&&Number.isFinite(m.cy)&&o.push({x:m.cx,y:m.cy})}}if(!s)return null;let a={x:r/s,y:i/s},d=a;if(o.length>=8){let c=it(o.map(y=>y.x)),l=it(o.map(y=>y.y)),m=0;for(let y of n)for(let g of y.rows)for(let S of g.pts){let x=Math.hypot(S.x-a.x,S.y-a.y);x>m&&(m=x)}let h=0,p=m*.2;for(let y of n)for(let g of y.rows)for(let S of g.pts)Math.hypot(S.x-c,S.y-l)<p&&h++;Math.hypot(c-a.x,l-a.y)<=m&&h/s<.01&&(d={x:c,y:l})}let f=[];for(let c of n){let l={sectionId:c.sectionId,rMin:1/0,rMax:-1/0,samples:[]};for(let m of c.rows)for(let h of m.pts){let p=Math.hypot(h.x-d.x,h.y-d.y),y=Math.min(K-1,Math.floor(ui(d,h)/(360/K)));l.samples.push({r:p,bin:y,levelM:m.levelM}),p<l.rMin&&(l.rMin=p),p>l.rMax&&(l.rMax=p)}l.samples.length&&f.push(l)}if(!f.length)return null;f.sort((c,l)=>c.rMin+c.rMax-(l.rMin+l.rMax));let u=[];for(let c of f){let l=!1;for(let m of u){let h=Math.min(c.rMax,m.rMax)-Math.max(c.rMin,m.rMin),p=Math.min(c.rMax-c.rMin,m.rMax-m.rMin);if(p>1e-9&&h>=ci*p){m.members.push(c),m.rMin=Math.min(m.rMin,c.rMin),m.rMax=Math.max(m.rMax,c.rMax),l=!0;break}}l||u.push({members:[c],rMin:c.rMin,rMax:c.rMax})}let b=[];for(let c of u){let l=new Array(K).fill(null);for(let w of c.members)for(let L of w.samples){let T=l[L.bin];T||(T={samples:[]},l[L.bin]=T),T.samples.push({r:L.r,levelM:L.levelM})}let m=l.map(w=>!!w);if(!m.filter(Boolean).length)continue;let p=[],y=[];for(let w of l){if(!w)continue;let L=1/0,T=-1/0;for(let I of w.samples)I.r<L&&(L=I.r),I.r>T&&(T=I.r);p.push(L),y.push(T)}let g=it(p),S=it(y);if(!(g>=Qn*S)||!(S>0))continue;let x=[...p].sort((w,L)=>w-L);if(!(x[Math.floor(x.length*.1)]>=Qn*S))continue;let M=l.map(w=>{if(!w)return null;let L=[...w.samples].sort((j,X)=>j.r-X.r),T=L[0].r,I=L[L.length-1].r,F=L[0].levelM,A=-1/0;for(let j of L)j.levelM>A&&(A=j.levelM);let C=[];for(let j of L){let X={r:j.r,l:j.levelM};for(;C.length&&Math.abs(C[C.length-1].r-X.r)<1e-9;){if(C[C.length-1].l<=X.l){X.skip=!0;break}C.pop()}if(!X.skip){for(;C.length>=2;){let G=C[C.length-2],Y=C[C.length-1];if((Y.r-G.r)*(X.l-G.l)-(Y.l-G.l)*(X.r-G.r)<=0)C.pop();else break}C.push(X)}}let E=C.map(j=>j.r),N=C.map(j=>j.l);return{inner:T,outer:I,front:F,top:A,profile:{rs:E,ls:N}}}),v=m.slice();for(let w=0;w<K;w++){if(v[w])continue;let L=-1,T=-1,I=0;for(let O=1;O<=K;O++){let V=(w-O+K*2)%K;if(v[V]){L=V;break}}for(let O=1;O<=K;O++){let V=(w+O)%K;if(v[V]){T=V,I=O;break}}if(L<0||T<0)continue;let F=0;for(let O=1;O<=K;O++){let V=(w-O+K*2)%K;if(m[V]){F=O;break}}if(F-1+I>ii)continue;let C=M[L],E=M[T],N=F/(F+I),j=C.inner+(E.inner-C.inner)*N,X=C.outer+(E.outer-C.outer)*N,G=C.front+(E.front-C.front)*N,Y=C.top+(E.top-C.top)*N;M[w]={inner:j,outer:X,front:G,top:Y,profile:{rs:[j,X],ls:[G,Y]}}}for(let w=0;w<K;w++)M[w]&&(v[w]=!0);let k=360/K,B=[],D=v.filter(Boolean).length,U=[];if(D===K)U.push({start:0,len:K});else{let w=0;for(;v[w];)w=(w+1)%K;let L=-1;for(let T=0;T<=K;T++){let I=(w+T)%K,F=T<K&&v[I];if(F&&L<0)L=I;else if(!F&&L>=0){let A=(I-L+K)%K||K;U.push({start:L,len:A}),L=-1}}}for(let w of U){if(w.len*k<si&&w.len<K)continue;let L=w.len===K,T=new Float64Array(w.len),I=new Float64Array(w.len),F=new Float64Array(w.len),A=new Float64Array(w.len),C=[];for(let O=0;O<w.len;O++){let V=M[(w.start+O)%K];T[O]=V.inner,I[O]=V.outer,F[O]=V.front,A[O]=V.top,C.push(V.profile??{rs:[V.inner,V.outer],ls:[V.front,V.top]})}let E=st(T,L),N=st(I,L),j=st(F,L),X=st(A,L);for(let O=0;O<w.len;O++)E[O]>T[O]&&(E[O]=T[O]),N[O]<I[O]&&(N[O]=I[O]),E[O]>N[O]-1e-6&&(E[O]=Math.max(0,N[O]-1e-6)),X[O]<j[O]&&(X[O]=j[O]);let G={startBin:w.start,binCount:w.len,closed:L,innerR:E,outerR:N,frontLevelM:j,topLevelM:X,profiles:C},Y=(O,V,H)=>{let Q=C[O],Z=Q.rs,z=Q.ls;if(V<=Z[0]){z[0]>H&&(z[0]=H);return}if(V>=Z[Z.length-1]){z[z.length-1]>H&&(z[z.length-1]=H);return}for(let q=0;q+1<Z.length;q++)if(V<=Z[q+1]){z[q]>H&&(z[q]=H),z[q+1]>H&&(z[q+1]=H);return}};for(let O=0;O<w.len;O++){let V=l[(w.start+O)%K];if(V)for(let H of V.samples){Y(O,H.r,H.levelM);let Q=L?(O-1+w.len)%w.len:O-1,Z=L?(O+1)%w.len:O+1;Q>=0&&Y(Q,H.r,H.levelM),Z<w.len&&Y(Z,H.r,H.levelM)}}B.push(G)}B.reduce((w,L)=>w+L.binCount*k,0)<ai||b.push({arcs:B,sectionIds:c.members.map(w=>w.sectionId),innerRMedian:g,outerRMedian:S})}if(!b.length)return null;if(b.sort((c,l)=>c.innerRMedian-l.innerRMedian),t){let c=b[b.length-1].outerRMedian;if(Math.hypot(t.x-d.x,t.y-d.y)>.9*c)return null}return{centre:d,binCount:K,binStepDeg:360/K,rings:b}}function qn(e,t,n,o){let r=e.binStepDeg,i=n/r-.5-t.startBin;i=(i%e.binCount+e.binCount)%e.binCount,i>t.binCount-1&&(t.closed?i=i-t.binCount<t.binCount-i?0:t.binCount-1:i=i-(t.binCount-1)<e.binCount-i?t.binCount-1:0);let s=Math.floor(i),a=t.closed?(s+1)%t.binCount:Math.min(t.binCount-1,s+1),d=i-s,f=u=>{let b=t.profiles[u],c=b.rs,l=b.ls;if(o<=c[0])return l[0];if(o>=c[c.length-1])return l[l.length-1];for(let m=0;m+1<c.length;m++)if(o<=c[m+1]){let h=c[m+1]-c[m],p=h>1e-9?(o-c[m])/h:0;return l[m]+(l[m+1]-l[m])*p}return l[l.length-1]};return f(s)*(1-d)+f(a)*d}var li=.25,fi=1.2,mi=.6,di=.45,bi=2.3,hi=Math.PI/180;function ge(e,t,n){let o=n*hi;return{x:e.x+t*Math.sin(o),y:e.y+t*Math.cos(o)}}function pi(e,t){let n=t.rings[t.rings.length-1];if(!n)return!1;let o=n.outerRMedian*.85;for(let r of e){if(r.role!=="wall")continue;let i=r.points&&r.points.length>=2?r.points:r.x!==void 0&&r.y!==void 0&&r.width!==void 0&&r.height!==void 0?[{x:r.x,y:r.y},{x:r.x+r.width,y:r.y},{x:r.x+r.width,y:r.y+r.height},{x:r.x,y:r.y+r.height}]:[];if(i.length<2)continue;let s=0;for(let a of i)Math.hypot(a.x-t.centre.x,a.y-t.centre.y)>=o&&s++;if(s>=i.length/2)return!0}return!1}var yi=24;function gi(e,t,n,o,r,i,s,a){let d=n.binCount,f=yi,u=re,b=i+.02,c=[];for(let P=0;P<d;P++){let w=(n.startBin+P+.5)*t.binStepDeg,L=new Float64Array(f+1);for(let T=0;T<=f;T++){let I=o[P]+(r[P]-o[P])*T/f;L[T]=Math.max(b,qn(t,n,w,I)-li)}c.push(L)}let l=[s.bandTop[0]*a.top,s.bandTop[1]*a.top,s.bandTop[2]*a.top],m=[s.bandTop[0]*a.bottomCap,s.bandTop[1]*a.bottomCap,s.bandTop[2]*a.bottomCap],h=[s.bandWall[0]*a.top,s.bandWall[1]*a.top,s.bandWall[2]*a.top],p=[s.bandWall[0]*a.wallBottom,s.bandWall[1]*a.wallBottom,s.bandWall[2]*a.wallBottom],y=(P,w)=>{let L=(n.startBin+P+.5)*t.binStepDeg,T=o[P]+(r[P]-o[P])*w/f,I=ge(t.centre,T,L);return[I.x*u,c[P][w],I.y*u]};{let P=Math.tan(12*Math.PI/180);for(let w=0;w<6;w++){let L=!1;for(let I=0;I<d;I++)for(let F=f-1;F>=0;F--)c[I][F]>c[I][F+1]&&(c[I][F]=c[I][F+1],L=!0);let T=n.closed?d:d-1;for(let I=0;I<T;I++){let F=(I+1)%d;for(let A=0;A<=f;A++){let C=c[F][A]-c[I][A];if(Math.abs(C)>1)continue;let E=o[I]+(r[I]-o[I])*A/f,N=o[F]+(r[F]-o[F])*A/f,j=ge(t.centre,E,(n.startBin+I+.5)*t.binStepDeg),X=ge(t.centre,N,(n.startBin+F+.5)*t.binStepDeg),G=P*Math.hypot(X.x-j.x,X.y-j.y)*u;C>G?(c[F][A]=c[I][A]+G,L=!0):-C>G&&(c[I][A]=c[F][A]+G,L=!0)}}if(!L)break}}let g=1,S=(P,w)=>{for(let L=0;L<=f;L+=4)if(Math.abs(c[P][L]-c[w][L])>g)return!0;return Math.abs(c[P][f]-c[w][f])>g},x=Math.tan(38*Math.PI/180),_=P=>(r[P]-o[P])/f*u,M=(P,w)=>c[P][w+1]-c[P][w]>x*Math.max(1e-6,_(P)),v=(P,w)=>{let L=n.closed?(P-1+d)%d:Math.max(0,P-1),T=n.closed?(P+1)%d:Math.min(d-1,P+1);Math.abs(c[L][w]-c[P][w])>g&&(L=P),Math.abs(c[T][w]-c[P][w])>g&&(T=P);let I=Math.max(0,w-1),F=Math.min(f,w+1);I<w&&M(P,I)&&(I=w),F>w&&M(P,w)&&(F=w);let A=y(L,w),C=y(T,w),E=y(P,I),N=y(P,F),j=C[0]-A[0],X=C[1]-A[1],G=C[2]-A[2],Y=N[0]-E[0],O=N[1]-E[1],V=N[2]-E[2],H=X*V-G*O,Q=G*Y-j*V,Z=j*O-X*Y,z=Math.hypot(H,Q,Z);return z>1e-12?(H/=z,Q/=z,Z/=z,Q<0&&(H=-H,Q=-Q,Z=-Z),[H,Q,Z]):[0,1,0]},k=(P,w)=>{let L=[P[0],i,P[2]],T=[w[0],i,w[2]],I=w[0]-P[0],F=w[2]-P[2],A=Math.hypot(I,F);if(!(A>1e-12))return;let C=[F/A,0,-I/A];e.tri(P,w,T,C,h,h,p),e.tri(P,T,L,C,h,p,p)},B=.05*fe,D=P=>r[P]-o[P]<B,U=n.closed?d:d-1;for(let P=0;P<U;P++){let w=(P+1)%d;if(D(P)||D(w))continue;if(S(P,w)){let C=(n.startBin+P+1)*t.binStepDeg,E=(O,V)=>{let H=(o[P]+o[w])/2,Q=(r[P]+r[w])/2,Z=H+(Q-H)*V/f,z=ge(t.centre,Z,C);return[z.x*u,c[O][V],z.y*u]};for(let O=0;O<f;O++){let V=y(P,O),H=y(P,O+1),Q=E(P,O),Z=E(P,O+1),z=v(P,O),q=v(P,O+1);e.triN(V,Q,Z,z,z,q,l),e.triN(V,Z,H,z,q,q,l);let Ue=y(w,O),Xe=y(w,O+1),Se=E(w,O),Ae=E(w,O+1),Me=v(w,O),we=v(w,O+1);e.triN(Se,Ue,Xe,Me,Me,we,l),e.triN(Se,Xe,Ae,Me,we,we,l);let le=E(P,O),ae=E(P,O+1),Ye=E(w,O+1),ct=E(w,O),Ve=ae[0]-le[0],Ee=ae[2]-le[2],ut=Math.hypot(Ve,Ee);if(ut>1e-12){let Ot=[Ee/ut,0,-Ve/ut];e.tri(le,ae,Ye,Ot,h),e.tri(le,Ye,ct,Ot,h)}}let N=y(P,0),j=y(w,0),X=y(w,f),G=y(P,f),Y=O=>[O[0],i,O[2]];e.tri(Y(N),Y(X),Y(j),[0,-1,0],m),e.tri(Y(N),Y(G),Y(X),[0,-1,0],m),k(N,j),k(G,X);continue}for(let C=0;C<f;C++){let E=v(P,C),N=v(w,C),j=v(w,C+1),X=v(P,C+1);if(M(P,C)||M(w,C)){let H=(ae,Ye)=>{let ct=(n.startBin+ae+.5)*t.binStepDeg,Ve=o[ae]+(r[ae]-o[ae])*(C+.5)/f,Ee=ge(t.centre,Ve,ct);return[Ee.x*u,Ye,Ee.y*u]},Q=y(P,C),Z=y(w,C),z=H(P,c[P][C]),q=H(w,c[w][C]);e.triN(Q,Z,q,E,N,N,l),e.triN(Q,q,z,E,N,E,l);let Ue=y(w,C+1),Xe=y(P,C+1),Se=H(P,c[P][C+1]),Ae=H(w,c[w][C+1]);e.triN(Se,Ae,Ue,X,j,j,l),e.triN(Se,Ue,Xe,X,j,X,l);let Me=q[0]-z[0],we=q[2]-z[2],le=Math.hypot(Me,we);if(le>1e-12){let ae=[-we/le,0,Me/le];e.tri(z,q,Ae,ae,h),e.tri(z,Ae,Se,ae,h)}continue}let G=y(P,C),Y=y(w,C),O=y(w,C+1),V=y(P,C+1);e.triN(G,Y,O,E,N,j,l),e.triN(G,O,V,E,j,X,l)}let L=y(P,0),T=y(w,0),I=y(w,f),F=y(P,f),A=C=>[C[0],i,C[2]];e.tri(A(L),A(I),A(T),[0,-1,0],m),e.tri(A(L),A(F),A(I),[0,-1,0],m),k(L,T),k(F,I)}if(!n.closed)for(let P of[0,d-1])for(let w=0;w<f;w++)k(y(P,w),y(P,w+1))}function Jn(e,t,n){let{bottomY:o,colors:r,ao:i}=n,s=new Float64Array(t.binCount).fill(-1/0);for(let u of t.rings)for(let b of u.arcs){let c=new Float64Array(b.binCount),l=new Float64Array(b.binCount);for(let h=0;h<b.binCount;h++){let p=(b.startBin+h)%t.binCount,y=Math.max(0,b.innerR[h]-se);c[h]=Math.max(y,s[p]+.001),l[h]=Math.max(c[h]+.001,b.outerR[h]+se)}let m=0;for(let h=0;h<b.binCount;h++){let p=b.topLevelM[h]-o;p>m&&(m=p)}m>=fi&&gi(e,t,b,c,l,o,r,i);for(let h=0;h<b.binCount;h++){let p=(b.startBin+h)%t.binCount;l[h]>s[p]&&(s[p]=l[h])}}if(n.deriveShell===!1||pi(n.shapes,t))return;let a=t.rings[t.rings.length-1],d=mi*fe,f=di*fe;for(let u of a.arcs){let b=[],c=[];for(let h=0;h<u.binCount;h++){let p=(u.startBin+h+.5)*t.binStepDeg,y=u.outerR[h]+se+d;b.push(ge(t.centre,y,p)),c.push(ge(t.centre,y+f,p))}let l=-1/0;for(let h=0;h<u.binCount;h++)u.topLevelM[h]>l&&(l=u.topLevelM[h]);let m=()=>l+bi;u.closed?J(e,c,[b.slice().reverse()],m,o,r.shellTop,r.shellWall,i):J(e,[...c,...b.slice().reverse()],void 0,m,o,r.shellTop,r.shellWall,i)}}function eo(e,t,n,o,r,i,s,a){if(!t.outline||t.outline.length<3)return;let d=n.baseHeightM,f=ce(o,a.tierTop);if(!r)return;let u=p=>r.deckAt(p.x,p.y),b=On(t,s),c=b[0]??t.outline;if(r.rowLevels.length>=2){let p=nt(r.rowLevels),y=Bn(An(r.rowLevels,n.focal,p),b),g=()=>[0,1,0];for(let x of y){let _=Math.max(d,x.topY-.02);for(let M of i.subtract(x.outline,_))J(e,M,x.holes,()=>_,d,f,a.tierWall,$,void 0,g)}y.length||J(e,c,t.holes,()=>r.landingY,d,f,a.tierWall,$);let S={tread:[f[0]*$.top,f[1]*$.top,f[2]*$.top],riser:[f[0]*.72,f[1]*.72,f[2]*.72]};for(let x of b.length?b:[c])_n(e,r.rowLevels,n.focal,r.landingY,S,x,p);return}let l=r.flat?1/0:Fn,m=p=>r.normalAt(p.x,p.y),h=r.flat?r.landingY:void 0;for(let p of i.subtract(c,h))J(e,p,t.holes,u,d,f,a.tierWall,$,l,m)}function xi(e,t,n){let o=new Set;for(let s of e.objects)s.type==="section"&&o.add(s.id);let r=new Map;for(let s=0;s<t.length;s++){let a=n.seatOwner[s];if(!a||!o.has(a))continue;let d=n.bySection.get(a);if(d&&d.rowLevels.length>=2)continue;let f=t[s],u=r.get(a);u||(u=new Map,r.set(a,u));let b=f.rowId||`__seat-${s}`,c=u.get(b);c||(c={pts:[],levelM:0,n:0},u.set(b,c)),c.pts.push({x:f.x,y:f.y}),c.levelM+=n.seatDeckY(s),c.n++}let i=[];for(let s of e.objects){if(s.type!=="section")continue;let a=n.bySection.get(s.id);if(a&&a.rowLevels.length>=2){let f=a.rowLevels.filter(u=>!u.patch).map(u=>({pts:u.pts,levelM:u.y}));f.length>=2&&i.push({sectionId:s.id,rows:f});continue}let d=r.get(s.id);d&&i.push({sectionId:s.id,rows:[...d.values()].map(f=>({pts:f.pts,levelM:f.levelM/f.n}))})}return i}function to(e,t,n,o,r,i,s=!0){let a=xi(t,n,o);if(!a.length)return;let d=$n(a,t.focal);d&&(e.setMaterial(0),Jn(e,d,{bottomY:t.baseHeightM,colors:{bandTop:ie(r.tierTop,.8),bandWall:r.tierWall,shellTop:i??ie(r.tierWall,1.15),shellWall:i??r.tierWall},ao:$,shapes:t.objects.filter(f=>f.type==="shape"),deriveShell:s}))}var Si=6,Mi=2.2,no=.1,wi=.3,Ii=1.8,vi=.9,Ri=.55,Pi=6e3;function oo(e){let{doc:t,units:n,seats:o,surfaces:r,focal:i}=e,s=t.zones??[],a=[];if(s.length){let d=new Map;for(let u of n)for(let b of u.objects)b.type==="section"&&b.zone&&d.set(b.id,b.zone);let f=new Map;for(let u=0;u<o.length;u++){let b=o[u],c=r.seatOwner[u],l=b.zoneId??(c?d.get(c):void 0);if(!l)continue;let m=f.get(l);m||(m={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},f.set(l,m)),m.n++,b.x<m.minX&&(m.minX=b.x),b.y<m.minY&&(m.minY=b.y),b.x>m.maxX&&(m.maxX=b.x),b.y>m.maxY&&(m.maxY=b.y),m.sumY+=r.seatDeckY(u)}for(let u of s){let b=f.get(u.id),c=[];for(let[l,m]of d)m===u.id&&c.push(l);if(!b||b.n===0){a.push({id:u.id,label:u.label,color:W(u.color),sectionIds:c,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(u.focalPoint??i).x*R,1.5,(u.focalPoint??i).y*R]});continue}a.push({id:u.id,label:u.label,color:W(u.color),sectionIds:c,seatCount:b.n,center:[(b.minX+b.maxX)/2*R,b.sumY/b.n,(b.minY+b.maxY)/2*R],radius:.5*Math.hypot((b.maxX-b.minX)*R,(b.maxY-b.minY)*R)||1,focalWorld:[(u.focalPoint??i).x*R,1.5,(u.focalPoint??i).y*R]})}}return a}function ro(e){let{doc:t,units:n,seats:o,surfaces:r,seatData:i,hintedSeatFloor:s,zones:a,focal:d}=e,f=[],u=[],b=[];for(let c of a)c.seatCount!==0&&f.push({id:`zone:${c.id}`,kind:"zone",text:c.label,anchor:[c.center[0],c.center[1]+Si,c.center[2]],color:t.zones?.find(l=>l.id===c.id)?.color});{let c=new Map,l=new Map;for(let m=0;m<o.length;m++){let h=r.seatOwner[m];if(!h)continue;let p=c.get(h);p||(p={n:0,x:0,y:0,deck:0},c.set(h,p)),p.n++,p.x+=o[m].x,p.y+=o[m].y,p.deck+=r.seatDeckY(m);let y=l.get(h);y||(y={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0},l.set(h,y)),o[m].x<y.minX&&(y.minX=o[m].x),o[m].x>y.maxX&&(y.maxX=o[m].x),o[m].y<y.minY&&(y.minY=o[m].y),o[m].y>y.maxY&&(y.maxY=o[m].y)}for(let m of n)for(let h of m.objects){if(h.type!=="section")continue;let p=c.get(h.id);if(!p||p.n===0)continue;let y=l.get(h.id),g=[p.x/p.n*R,p.deck/p.n,p.y/p.n*R],S=h.displayLabel||h.label||h.id;u.push({id:h.id,floorIndex:m.index,label:S,seatCount:p.n,center:g,radius:Math.max(1,Math.hypot(y.maxX-y.minX,y.maxY-y.minY)*.5*R),focalWorld:[m.focal.x*R,m.baseHeightM+1.5,m.focal.y*R]});let x=t.floors?.[m.index]?.name?.trim().toLocaleLowerCase();n.length>1&&x===S.trim().toLocaleLowerCase()||f.push({id:`section:${h.id}`,kind:"section",text:S,anchor:[g[0],g[1]+Mi,g[2]],floorIndex:m.index})}}{for(let m of n)for(let h of m.objects){if(h.type!=="gaArea")continue;let p=_e(h.points);if(!p)continue;let y=h.displayLabel||h.label||h.id;f.push({id:`ga:${h.id}`,kind:"ga",text:h.capacity>0?`${y} \xB7 ${h.capacity.toLocaleString()}`:y,anchor:[p.x*R,m.baseHeightM+Ii,p.y*R],floorIndex:m.index})}let c=new Map;for(let m=0;m<o.length;m++){let h=o[m],p=Math.hypot(h.x-d.x,h.y-d.y),y=c.get(h.rowId);(!y||p>y.far)&&c.set(h.rowId,{seat:h,index:m,far:p})}for(let[m,h]of c){let p=h.seat.label?h.seat.label.lastIndexOf("-"):-1,y=p>0?h.seat.label.slice(0,p):m;y&&f.push({id:`row:${m}`,kind:"row",text:y,anchor:[h.seat.x*R,r.seatDeckY(h.index)+vi,h.seat.y*R],floorIndex:s[h.index]})}let l=new Map;for(let m=0;m<o.length;m++){let h=o[m],p=h.label?h.label.lastIndexOf("-"):-1,y=l.get(h.rowId);y||(y={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:p>0?h.label.slice(0,p):h.rowId,sectionId:h.sectionId},l.set(h.rowId,y));let g=m*3,S=i.iPosition[g],x=i.iPosition[g+1],_=i.iPosition[g+2];y.n++,y.x+=S,y.y+=x,y.z+=_,y.minX=Math.min(y.minX,S),y.maxX=Math.max(y.maxX,S),y.minZ=Math.min(y.minZ,_),y.maxZ=Math.max(y.maxZ,_)}for(let[m,h]of l)b.push({id:m,label:h.label,sectionId:h.sectionId,seatCount:h.n,center:[h.x/h.n,h.y/h.n,h.z/h.n],radius:Math.max(.8,Math.hypot(h.maxX-h.minX,h.maxZ-h.minZ)*.5)});if(o.length<=Pi)for(let m=0;m<o.length;m++){let h=o[m],p=h.displayLabel||h.label;p&&f.push({id:`seat:${h.id}`,kind:"seat",text:p,anchor:[h.x*R,r.seatDeckY(m)+Ri,h.y*R],floorIndex:s[m]})}}for(let c of n)for(let l of c.objects)if(l.type==="shape"&&l.role&&["entrance","exit","screen","suite","obstruction"].includes(l.role)){let m=ye(l),h=m?_e(m):null;if(!h||!l.label)continue;f.push({id:`architecture:${l.id}`,kind:"annotation",text:l.label,anchor:[h.x*R,c.baseHeightM+De(l).heightM+no,h.y*R],color:l.fill,floorIndex:c.index})}else if(l.type==="text"){if(!l.text)continue;f.push({id:`text:${l.id}`,kind:"annotation",text:l.text,anchor:[l.position.x*R,c.baseHeightM+no,l.position.y*R],color:l.color,rotation:l.rotation,floorIndex:c.index})}else if(l.type==="booth"){let m=Ge(l);if(!m)continue;let h=_e(m);if(!h)continue;f.push({id:`booth:${l.id}`,kind:"booth",text:l.displayLabel||l.label||l.id,anchor:[h.x*R,c.baseHeightM+At+wi,h.y*R],floorIndex:c.index})}return{labels:f,sections:u,rows:b}}function io(e,t){if(t.length>1)for(let n of t)e.push({id:`floor:${n.id}`,kind:"floor",text:n.label,anchor:[n.center[0],n.box.max[1]+1.2,n.center[2]],floorIndex:n.index})}function so(e){let{doc:t,units:n,seats:o,surfaces:r,solids:i,hintedSeatFloor:s,seatFloor:a}=e,d=[];{let f=n.map(()=>({minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}));for(let c=0;c<i.floor.length;c+=1){let l=Math.max(0,Math.min(n.length-1,Math.round(i.floor[c]))),m=c*3,h=f[l];h.minX=Math.min(h.minX,i.position[m]),h.minY=Math.min(h.minY,i.position[m+1]),h.minZ=Math.min(h.minZ,i.position[m+2]),h.maxX=Math.max(h.maxX,i.position[m]),h.maxY=Math.max(h.maxY,i.position[m+1]),h.maxZ=Math.max(h.maxZ,i.position[m+2])}let u=new Map;for(let c=0;c<n.length;c++)for(let l of n[c].objects)l.type==="section"&&u.set(l.id,c);let b=n.map(()=>({n:0,minX:1/0,minY:1/0,minDeck:1/0,maxX:-1/0,maxY:-1/0,maxDeck:-1/0,sumX:0,sumDeck:0,sumZ:0}));for(let c=0;c<o.length;c++){let l=r.seatOwner[c],m=(l!==null?u.get(l):void 0)??s[c];if(m===void 0)continue;let h=b[m],p=o[c];h.n++,p.x<h.minX&&(h.minX=p.x),p.y<h.minY&&(h.minY=p.y),p.x>h.maxX&&(h.maxX=p.x),p.y>h.maxY&&(h.maxY=p.y);let y=r.seatDeckY(c);h.sumX+=p.x*R,h.sumDeck+=y,h.sumZ+=p.y*R,h.minDeck=Math.min(h.minDeck,y),h.maxDeck=Math.max(h.maxDeck,y+1.6),a[c]=m}for(let c=0;c<n.length;c++){let l=b[c],m=t.floors?.[c],h=f[c],p=Math.min(l.n?l.minX*R:n[c].focal.x*R-1,Number.isFinite(h.minX)?h.minX:1/0),y=Math.max(l.n?l.maxX*R:n[c].focal.x*R+1,Number.isFinite(h.maxX)?h.maxX:-1/0),g=Math.min(l.n?l.minY*R:n[c].focal.y*R-1,Number.isFinite(h.minZ)?h.minZ:1/0),S=Math.max(l.n?l.maxY*R:n[c].focal.y*R+1,Number.isFinite(h.maxZ)?h.maxZ:-1/0),x=Math.min(l.n?Math.min(n[c].baseHeightM,l.minDeck):n[c].baseHeightM,Number.isFinite(h.minY)?h.minY:1/0),_=Math.max(l.n?Math.max(l.maxDeck,x+.5):x+.5,Number.isFinite(h.maxY)?h.maxY:-1/0),M=[l.n?l.sumX/l.n:(p+y)/2,l.n?l.sumDeck/l.n:(x+_)/2,l.n?l.sumZ/l.n:(g+S)/2],v=Math.max(1,.5*Math.hypot(y-p,_-x,S-g));d.push({index:c,id:m?.id??`floor-${c}`,label:m?.name??(n.length>1?`Floor ${c+1}`:"Venue"),seatCount:l.n,center:M,radius:v,box:{min:[p,x,g],max:[y,_,S]},focalWorld:[n[c].focal.x*R,n[c].baseHeightM+1.5,n[c].focal.y*R]})}}return d}function kt(e,t){let n=1/0,o=1/0,r=-1/0,i=-1/0,s=(a,d)=>{a<n&&(n=a),d<o&&(o=d),a>r&&(r=a),d>i&&(i=d)};for(let a of t)s(a.x,a.y);for(let a of e)for(let d of a.objects)if(d.type==="section")for(let f of d.outline)s(f.x,f.y);else if(d.type==="shape"&&d.points)for(let f of d.points)s(f.x,f.y);else if(d.type==="gaArea")for(let f of d.points)s(f.x,f.y);else if(d.type==="booth"){let f=Ge(d);if(f)for(let u of f)s(u.x,u.y)}else if(d.type==="table"){let f=Et(d);if(f)for(let u of f)s(u.x,u.y)}else if(d.type==="decorImage"){let f=_t(d);if(f)for(let u of f)s(u.x,u.y)}return Number.isFinite(n)||(n=-100,o=-100,r=100,i=100),{minX:n,minY:o,maxX:r,maxY:i}}function ao(e,t,n,o,r,i){if(t.length===1){let s=Math.max(60,(r.maxX-r.minX+r.maxY-r.minY)*.06),a=Fe(r.minX-s,r.minY-s,r.maxX-r.minX+s*2,r.maxY-r.minY+s*2);J(e,a,void 0,()=>0,-.4,i.ground,i.ground,$)}else{let s=t.reduce((l,m)=>m.baseHeightM<l.baseHeightM?m:l);e.setFloor(s.index);let a=n.filter((l,m)=>o[m]===s.index),d=kt([s],a),f=Math.hypot(d.maxX-d.minX,d.maxY-d.minY),u=Math.max(28,Math.min(80,f*.04)),b=Fe(d.minX-u,d.minY-u,d.maxX-d.minX+u*2,d.maxY-d.minY+u*2),c=s.baseHeightM-.03;J(e,b,void 0,()=>c,c-.22,i.ground,i.ground,$)}}function co(e,t,n){let{cx:o,cz:r,radius:i}=n,s=1/0,a=1/0,d=1/0,f=-1/0,u=-1/0,b=-1/0,c=(h,p,y)=>{s=Math.min(s,h),f=Math.max(f,h),a=Math.min(a,p),u=Math.max(u,p),d=Math.min(d,y),b=Math.max(b,y)};for(let h=0;h<e.position.length;h+=3)c(e.position[h],e.position[h+1],e.position[h+2]);for(let h=0;h<t.count;h++){let p=h*3,y=t.iPosition[p],g=t.iPosition[p+1],S=t.iPosition[p+2],x=Math.max(.35,t.iMaxRadius[h]??.35);c(y-x,g,S-x),c(y+x,g+1.6,S+x)}Number.isFinite(s)||(s=o-i,f=o+i,a=0,u=i*.16,d=r-i,b=r+i);let l=[(s+f)/2,(a+u)/2,(d+b)/2],m=Math.max(1,.5*Math.hypot(f-s,u-a,b-d));return{center:l,radius:m,minY:a,maxY:u}}function uo(e,t,n,o,r,i){let s=1/0,a=1/0,d=-1/0,f=-1/0;for(let x=0;x<e.count;x++){let _=x*3,M=e.iPosition[_],v=e.iPosition[_+2];M<s&&(s=M),M>d&&(d=M),v<a&&(a=v),v>f&&(f=v)}for(let x of t)s=Math.min(s,x.cx-x.halfX),d=Math.max(d,x.cx+x.halfX),a=Math.min(a,x.cz-x.halfZ),f=Math.max(f,x.cz+x.halfZ);let u=n.minX*R,b=n.maxX*R,c=n.minY*R,l=n.maxY*R,m=u,h=b,p=c,y=l;if(Number.isFinite(s)){let x=Math.max(2,.06*Math.hypot(d-s,f-a));m=Math.max(u,s-x),h=Math.min(b,d+x),p=Math.max(c,a-x),y=Math.min(l,f+x)}let g=Math.min(0,o),S=Math.max(r,i*.05);return{min:[m,g,p],max:[h,S,y]}}var Ci=/^data:image\/(?:png|jpe?g|webp|gif|avif);base64,[a-z0-9+/]+={0,2}$/i,Ai=/[\s"'<>`\\]/;function Ei(e){if(typeof e!="string"||!e||e.length>2e6||e!==e.trim())return!1;if(e.startsWith("data:"))return Ci.test(e);if(Ai.test(e))return!1;try{let t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}}function lo(e){let t=e.trim();return Ei(t)?t:null}var Tt="seatlayer.event-configuration/1";var Ce=100,_i=120,ki=1e5,Ti=1e4,Li=/^[a-f0-9]{64}$/,Oi=new Set(["stage","screen","barrier","camera_platform","sound_desk","rigging_truss"]);function je(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function xe(e,t){return typeof e=="string"&&e.length>=1&&e.length<=t&&e.normalize("NFKC").trim()===e}function Bi(e){return typeof e=="number"&&Number.isInteger(e)&&e>0}function fo(e){return!Array.isArray(e)||e.length>ki||!e.every(t=>xe(t,Ce))?null:[...new Set(e)].sort()}function Fi(e){return!je(e)||!xe(e.chartId,Ce)||!xe(e.version,Ce)||e.sha256!==void 0&&(typeof e.sha256!="string"||!Li.test(e.sha256))?null:{chartId:e.chartId,version:e.version,...typeof e.sha256=="string"?{sha256:e.sha256}:{}}}function Lt(e,t,n){return typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=n}function Di(e){return je(e)?e.mode==="none"||e.mode==="opaque"?e.opacity===void 0?{mode:e.mode}:null:e.mode==="partial"&&Lt(e.opacity,.01,.99)?{mode:"partial",opacity:e.opacity}:null:null}function Ni(e,t){if(e===void 0)return;if(!Array.isArray(e)||e.length>Ti)return null;let n=new Set(t),o=new Set,r=new Set,i=0,s=[];for(let a of e){if(!je(a)||!xe(a.id,Ce)||!xe(a.objectId,Ce)||!n.has(a.objectId)||!Oi.has(String(a.kind))||!Lt(a.heightM,.05,50)||a.baseElevationM!==void 0&&!Lt(a.baseElevationM,-10,100))return null;let d=Di(a.occlusion);if(!d||o.has(a.id)||r.has(a.objectId))return null;let f=a.contentImageUrl===void 0?void 0:typeof a.contentImageUrl=="string"?lo(a.contentImageUrl):null;if(a.contentImageUrl!==void 0&&(!f||a.kind!=="screen"||++i>1))return null;o.add(a.id),r.add(a.objectId),s.push({id:a.id,objectId:a.objectId,kind:a.kind,heightM:a.heightM,...a.baseElevationM!==void 0?{baseElevationM:a.baseElevationM}:{},occlusion:d,...f?{contentImageUrl:f}:{}})}return s.sort((a,d)=>a.id.localeCompare(d.id))}function Gi(e){let t=[];if(!je(e))return{issues:[{code:"invalid_export",path:"configuration",message:"Configuration must be an object"}]};e.schema!==Tt&&t.push({code:"unsupported_schema",path:"configuration.schema",message:`Configuration schema must be ${Tt}`}),xe(e.id,Ce)||t.push({code:"invalid_id",path:"configuration.id",message:"Configuration id must contain 1 to 100 normalized characters"}),xe(e.label,_i)||t.push({code:"invalid_label",path:"configuration.label",message:"Configuration label must contain 1 to 120 normalized characters"}),Bi(e.version)||t.push({code:"invalid_version",path:"configuration.version",message:"Configuration version must be a positive integer"});let n=Fi(e.baseVenue);n||t.push({code:"invalid_base_venue",path:"configuration.baseVenue",message:"Base venue must identify one normalized chart id and exact version"});let o=je(e.overlay)?e.overlay:null,r=fo(o?.objectIds),i=fo(o?.productionKillSeatIds),s=r?Ni(o?.productionElements,r):null;return(!o||!r||!i)&&t.push({code:"invalid_overlay",path:"configuration.overlay",message:"Overlay ids must be bounded arrays of normalized stable ids"}),s===null&&t.push({code:"invalid_production_element",path:"configuration.overlay.productionElements",message:"Production elements must be unique, bounded semantics over referenced base-venue objects"}),t.length||!n||!r||!i||s===null?{issues:t}:{issues:t,value:{schema:Tt,id:e.id,label:e.label,version:e.version,baseVenue:n,overlay:{objectIds:r,productionKillSeatIds:i,...s!==void 0?{productionElements:s}:{}}}}}function mo(e){let t=Gi(e);return t.value?{ok:!0,value:t.value}:{ok:!1,issues:t.issues}}function bo(e,t,n){let o=()=>({byObjectId:new Map,elements:[]});if(!t||!e)return o();let r=mo(t);if(!r.ok||r.value.id!==e)return o();let i=new Map;for(let b of n)for(let c of b.objects)c.type==="shape"&&i.set(c.id,{shape:c,unit:b});let s=new Set,a=new Set,d=new Map((t.overlay.productionElements??[]).map(b=>{let c=b.runtimeContentImageUrl;return[b.id,typeof c=="string"&&/^(?:blob:|data:image\/|https:\/\/)/.test(c)?c:void 0]})),f=[];for(let b of r.value.overlay.productionElements??[]){let c=i.get(b.objectId),l=c?ye(c.shape):null,m=b.baseElevationM??0;if(!c||!l||l.length<3||!b.id||s.has(b.id)||a.has(b.objectId)||!Number.isFinite(b.heightM)||b.heightM<.05||b.heightM>50||!Number.isFinite(m)||m<-10||m>100)return o();s.add(b.id),a.add(b.objectId);let h=l.map(k=>k.x*R),p=l.map(k=>k.y*R),y=c.unit.baseHeightM+m,g=Math.min(...h),S=Math.max(...h),x=Math.min(...p),_=Math.max(...p),M,v=d.get(b.id)??b.contentImageUrl;if(b.kind==="screen"&&v)if(S-g>=_-x){let k=Math.abs(x-c.unit.focal.y*R)<=Math.abs(_-c.unit.focal.y*R)?x-.006:_+.006;M=[[g,y,k],[S,y,k],[g,y+b.heightM,k],[S,y+b.heightM,k]]}else{let k=Math.abs(g-c.unit.focal.x*R)<=Math.abs(S-c.unit.focal.x*R)?g-.006:S+.006;M=[[k,y,x],[k,y,_],[k,y+b.heightM,x],[k,y+b.heightM,_]]}f.push({id:b.id,objectId:b.objectId,kind:b.kind,floorIndex:c.unit.index,baseY:y,topY:y+b.heightM,bounds:{min:[g,y,x],max:[S,y+b.heightM,_]},occlusion:b.occlusion,...v?{contentImageUrl:v}:{},...M?{contentPlane:M}:{}})}let u=f.sort((b,c)=>b.id.localeCompare(c.id));return{byObjectId:new Map(u.map(b=>[b.objectId,b])),elements:u}}function oe(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ne(e){return Array.isArray(e)?e:[]}function ji(e){let t=[e];for(;t.length;){let n=t.pop();if(Array.isArray(n)){t.push(...n);continue}if(!oe(n))continue;let o=oe(n.extensions)?n.extensions:null;if(o&&Object.prototype.hasOwnProperty.call(o,"KHR_draco_mesh_compression"))return!0;t.push(...Object.values(n))}return!1}function at(e,t){return!Array.isArray(e)||e.length!==t||!e.every(n=>typeof n=="number"&&Number.isFinite(n))?null:e}function Ui(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Xi(e,t){let n=new Array(16).fill(0);for(let o=0;o<4;o++)for(let r=0;r<4;r++)for(let i=0;i<4;i++)n[o*4+r]+=e[i*4+r]*t[o*4+i];return n}function Yi(e){let t=at(e.matrix,16);if(t)return t;if(e.matrix!==void 0)return null;let n=e.translation===void 0?[0,0,0]:at(e.translation,3),o=e.rotation===void 0?[0,0,0,1]:at(e.rotation,4),r=e.scale===void 0?[1,1,1]:at(e.scale,3);if(!n||!o||!r)return null;let[i,s,a,d]=o,f=Math.hypot(i,s,a,d);if(!(f>1e-8))return null;let u=i/f,b=s/f,c=a/f,l=d/f,m=u+u,h=b+b,p=c+c,y=u*m,g=u*h,S=u*p,x=b*h,_=b*p,M=c*p,v=l*m,k=l*h,B=l*p;return[(1-(x+M))*r[0],(g+B)*r[0],(S-k)*r[0],0,(g-B)*r[1],(1-(y+M))*r[1],(_+v)*r[1],0,(S+k)*r[2],(_-v)*r[2],(1-(y+x))*r[2],0,n[0],n[1],n[2],1]}function Vi(e,t,n,o){return[e[0]*t+e[4]*n+e[8]*o+e[12],e[1]*t+e[5]*n+e[9]*o+e[13],e[2]*t+e[6]*n+e[10]*o+e[14]]}function Hi(e){let t=e[0],n=e[4],o=e[8],r=e[1],i=e[5],s=e[9],a=e[2],d=e[6],f=e[10],u=i*f-s*d,b=s*a-r*f,c=r*d-i*a,l=t*u+n*b+o*c;if(Math.abs(l)<1e-12)return null;let m=1/l;return[u*m,b*m,c*m,(o*d-n*f)*m,(t*f-o*a)*m,(n*a-t*d)*m,(n*s-o*i)*m,(o*r-t*s)*m,(t*i-n*r)*m]}function ho(e,t,n,o){let r=e[0]*t+e[1]*n+e[2]*o,i=e[3]*t+e[4]*n+e[5]*o,s=e[6]*t+e[7]*n+e[8]*o,a=Math.hypot(r,i,s)||1;return r/=a,i/=a,s/=a,[r,i,s]}function Ki(e){if(e.byteLength<20||e.byteLength>8388608)return null;let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getUint32(0,!0)!==1179937895||t.getUint32(4,!0)!==2||t.getUint32(8,!0)!==e.byteLength)return null;let n=12,o=null,r=null;for(;n+8<=e.byteLength;){let i=t.getUint32(n,!0),s=t.getUint32(n+4,!0);if(n+=8,i%4!==0||n+i>e.byteLength)return null;let a=e.subarray(n,n+i);if(s===1313821514&&!o)try{let d=JSON.parse(new TextDecoder().decode(a).replace(/[\u0000 ]+$/g,""));if(!oe(d))return null;o=d}catch{return null}else if(s===5130562&&!r)r=a;else return null;n+=i}return n===e.byteLength&&o&&r?{json:o,bin:r}:null}function zi(e){return e===5120||e===5121?1:e===5122||e===5123?2:e===5125||e===5126?4:0}function Wi(e){return e==="SCALAR"?1:e==="VEC2"?2:e==="VEC3"?3:e==="VEC4"?4:0}function Zi(e,t,n){return n===5120?e.getInt8(t):n===5121?e.getUint8(t):n===5122?e.getInt16(t,!0):n===5123?e.getUint16(t,!0):n===5125?e.getUint32(t,!0):e.getFloat32(t,!0)}function Qi(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=Ki(t);if(!n)return{ok:!1,issue:"invalid_glb"};let{json:o,bin:r}=n;if(!oe(o.asset)||o.asset.version!=="2.0")return{ok:!1,issue:"unsupported_glb"};let i=ne(o.extensionsUsed).filter(x=>typeof x=="string");if(i.includes("KHR_draco_mesh_compression")||ji(o))return{ok:!1,issue:"draco_not_allowed"};if(i.length||ne(o.extensionsRequired).length)return{ok:!1,issue:"unsupported_glb"};if(ne(o.images).length||ne(o.textures).length)return{ok:!1,issue:"external_resource"};let s=ne(o.buffers);if(s.length!==1||!oe(s[0])||s[0].uri!==void 0||typeof s[0].byteLength!="number"||!Number.isInteger(s[0].byteLength)||s[0].byteLength<0||s[0].byteLength>r.byteLength)return{ok:!1,issue:"external_resource"};let a=ne(o.accessors),d=ne(o.bufferViews),f=ne(o.meshes),u=ne(o.nodes),b=ne(o.scenes),c=typeof o.scene=="number"?o.scene:0;if(!oe(b[c]))return{ok:!1,issue:"unsupported_glb"};let l=new DataView(r.buffer,r.byteOffset,r.byteLength),m=(x,_,M)=>{if(typeof x!="number"||!Number.isInteger(x)||!oe(a[x]))return null;let v=a[x];if(v.type!==_||v.sparse!==void 0||v.normalized===!0||typeof v.count!="number"||!Number.isInteger(v.count)||v.count<1||typeof v.componentType!="number"||!M.includes(v.componentType)||typeof v.bufferView!="number")return null;let k=d[v.bufferView];if(!oe(k)||k.buffer!==0||typeof k.byteLength!="number"||!Number.isInteger(k.byteLength)||k.byteLength<0)return null;let B=Wi(v.type),D=zi(v.componentType),U=typeof k.byteStride=="number"?k.byteStride:B*D,P=typeof k.byteOffset=="number"?k.byteOffset:0,w=typeof v.byteOffset=="number"?v.byteOffset:0,L=P+w,T=w+(v.count-1)*U+B*D;if(!Number.isInteger(U)||!Number.isInteger(P)||!Number.isInteger(w)||U<B*D||P<0||w<0||P+k.byteLength>r.byteLength||T>k.byteLength)return null;let I=[];for(let F=0;F<v.count;F++){let A=[];for(let C=0;C<B;C++){let E=Zi(l,L+F*U+C*D,v.componentType);if(!Number.isFinite(E))return null;A.push(E)}I.push(A)}return I},h=[],p=[],y=0,g=new Set,S=(x,_)=>{if(typeof x!="number"||!Number.isInteger(x)||!oe(u[x])||g.has(x))return!1;g.add(x);let M=u[x],v=Yi(M);if(!v)return!1;let k=Xi(_,v),B=Hi(k);if(!B)return!1;if(M.mesh!==void 0){if(typeof M.mesh!="number")return!1;let D=f[M.mesh];if(!oe(D))return!1;for(let U of ne(D.primitives)){if(!oe(U)||U.mode!==void 0&&U.mode!==4||!oe(U.attributes))return!1;let P=m(U.attributes.POSITION,"VEC3",[5126]),w=U.attributes.NORMAL===void 0?null:m(U.attributes.NORMAL,"VEC3",[5126]);if(!P||U.attributes.NORMAL!==void 0&&!w)return!1;let L=P.length;if(U.indices!==void 0){let I=typeof U.indices=="number"?a[U.indices]:null;L=oe(I)?I.count:void 0}if(typeof L!="number"||!Number.isInteger(L)||L%3!==0||(y+=L/3,y>1e5))return!1;let T=U.indices===void 0?P.map((I,F)=>[F]):m(U.indices,"SCALAR",[5121,5123,5125]);if(!T||T.length%3!==0||T.length!==L)return!1;for(let I=0;I<T.length;I+=3){let F=[T[I][0],T[I+1][0],T[I+2][0]];if(F.some(E=>!Number.isInteger(E)||E<0||E>=P.length))return!1;let A=F.map(E=>Vi(k,...P[E])),C=null;if(!w){let E=A[1][0]-A[0][0],N=A[1][1]-A[0][1],j=A[1][2]-A[0][2],X=A[2][0]-A[0][0],G=A[2][1]-A[0][1],Y=A[2][2]-A[0][2];C=ho([1,0,0,0,1,0,0,0,1],N*Y-j*G,j*X-E*Y,E*G-N*X)}for(let E=0;E<3;E++)h.push(...A[E]),p.push(...w?ho(B,...w[F[E]]):C)}}}for(let D of ne(M.children))if(!S(D,k))return!1;return g.delete(x),!0};for(let x of ne(b[c].nodes))if(!S(x,Ui()))return{ok:!1,issue:y>1e5?"triangle_limit":"unsupported_glb"};return!y||h.length!==y*9||p.length!==h.length?{ok:!1,issue:"unsupported_glb"}:{ok:!0,triangleCount:y,position:new Float32Array(h),normal:new Float32Array(p)}}function po(e){try{return Qi(e)}catch{return{ok:!1,issue:"invalid_glb"}}}function yo(e){let{doc:t}=e,n=nn(t.theme),o=n.structure,r=Ln(t,e.eventConfigurationId??t.eventConfigurationId),i=bo(e.eventConfigurationId,e.eventConfiguration,r),s=e.seats,a=new $e,d=null;if(e.registeredShellGlb){let T=po(e.registeredShellGlb);if(T.ok){let I=T.position.length/3,F=new Float32Array(T.position.length),A=n.materials.shell??o.tierWall;for(let C=0;C<I;C++){let E=T.normal[C*3+1],N=E<-.25?.4:.62+.38*Math.max(0,E);F[C*3]=A[0]*N,F[C*3+1]=A[1]*N,F[C*3+2]=A[2]*N}d={position:T.position,normal:T.normal,color:F,floor:new Float32Array(I).fill(-2),material:new Float32Array(I),count:I}}}let f=new Map;for(let T of r)for(let I of T.objects)f.set(I.id,T.index),I.type==="section"&&f.set(I.logicalSectionId??I.id,T.index);let u=s.map(T=>f.get(T.sectionId??"")??f.get(T.rowId??"")??0),b=kt(r,s);ao(a,r,s,u,b,o);let c=Nn(t,s),l=new Map,m=new Map;for(let T of t.categories??[])l.set(T.key,T.color),T.seatGlyph&&m.set(T.key,T.seatGlyph);let h=[],p=Dn(r,s,u),y=new Float32Array(s.length);for(let T=0;T<r.length;T++){let I=r[T];a.setFloor(T);let F=new rt,A=[],C=I.objects.filter(E=>E.type==="section"&&!!E.outline&&E.outline.length>=3);for(let E of I.objects)if(E.type==="section")eo(a,E,I,Gn(E,c),p.bySection.get(E.id),F,C,o);else if(E.type==="shape"){let N=i.byObjectId.get(E.id);a.setMaterial((N?.kind??E.role)==="screen"?1:0),zn(a,E,I.baseHeightM,Xn(E,A),o,I.focal,h,N),a.setMaterial(0)}else E.type==="gaArea"?Zn(a,E,I.baseHeightM,W(l.get(E.categoryKey)),o):E.type==="booth"?Hn(a,E,I.baseHeightM,W(l.get(E.categoryKey)),o):E.type==="table"?Kn(a,E,I.baseHeightM,W(l.get(E.categoryKey)),o):E.type==="decorImage"&&Wn(a,E,I.baseHeightM,o);to(a,I,s,p,o,n.materials.shell,!d)}let g=r.length>1?{x:r.reduce((T,I)=>T+I.focal.x,0)/r.length,y:r.reduce((T,I)=>T+I.focal.y,0)/r.length}:t.focalPoint??{x:(b.minX+b.maxX)/2,y:(b.minY+b.maxY)/2},S=cn(d?[a.build(),d]:[a.build()]),x=yn(s,e.initialState,p,y,l,m),_=oo({doc:t,units:r,seats:s,surfaces:p,focal:g}),{labels:M,sections:v,rows:k}=ro({doc:t,units:r,seats:s,surfaces:p,seatData:x,hintedSeatFloor:u,zones:_,focal:g}),B=so({doc:t,units:r,seats:s,surfaces:p,solids:S,hintedSeatFloor:u,seatFloor:y});io(M,B),x.iYaw=pn(x.iPosition,s.length,T=>s[T].rowId,T=>{let I=r[y[T]]?.focal??g;return[I.x*R,I.y*R]});let D=(b.minX+b.maxX)/2*R,U=(b.minY+b.maxY)/2*R,P=.5*Math.hypot((b.maxX-b.minX)*R,(b.maxY-b.minY)*R)||10,w=co(S,x,{cx:D,cz:U,radius:P}),L=uo(x,h,b,w.minY,w.maxY,P);return{solids:S,seats:x,bounds:{center:[(L.min[0]+L.max[0])/2,(L.min[1]+L.max[1])/2,(L.min[2]+L.max[2])/2],radius:P,groundY:0,box:L},renderBounds:{center:w.center,radius:w.radius},stateColorLUT:on(n,We),theme:n,seatCount:s.length,focalWorld:[g.x*R,1.5,g.y*R],zones:_,stages:h,productionElements:i.elements,sections:v,rows:k,labels:M,floors:B}}function $i(e){return[e.solids.position,e.solids.normal,e.solids.color,e.solids.floor,e.solids.material,e.seats.iPosition,e.seats.iState,e.seats.iCategory,e.seats.iMaxRadius,e.seats.iRing,e.seats.iFloor,e.seats.iYaw,e.seats.iChairWidth,e.seats.iGlyph,e.seats.iPhysicalSeat].map(n=>n.buffer)}var go=self;go.onmessage=e=>{let t=performance.now(),n=!e.data.seats,o=e.data.seats??qt(e.data.doc),r=yo({doc:e.data.doc,seats:o,eventConfigurationId:e.data.eventConfigurationId,eventConfiguration:e.data.eventConfiguration,registeredShellGlb:e.data.registeredShellGlb});go.postMessage({model:r,buildMs:performance.now()-t,...n?{seats:o}:{}},$i(r))};
1
+ "use strict";var xo=Object.create;var Bt=Object.defineProperty;var So=Object.getOwnPropertyDescriptor;var Mo=Object.getOwnPropertyNames;var wo=Object.getPrototypeOf,Io=Object.prototype.hasOwnProperty;var vo=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Mo(t))!Io.call(e,r)&&r!==n&&Bt(e,r,{get:()=>t[r],enumerable:!(o=So(t,r))||o.enumerable});return e};var Ie=(e,t,n)=>(n=e!=null?xo(wo(e)):{},vo(t||!e||!e.__esModule?Bt(n,"default",{value:e,enumerable:!0}):n,e));var Ji=Math.PI/180;function lt(e){let t=0,n=0;for(let r of e)t+=r.x,n+=r.y;let o=e.length||1;return{x:t/o,y:n/o}}function _e(e){return e.length?lt(e):null}function Ft(e,t){let n=1-t,o=n*n*n,r=3*n*n*t,i=3*n*t*t,s=t*t*t;return{x:o*e.start.x+r*e.control1.x+i*e.control2.x+s*e.end.x,y:o*e.start.y+r*e.control1.y+i*e.control2.y+s*e.end.y}}function Dt(e,t,n=192){if(!Number.isInteger(t)||t<1)throw new Error("Path point count must be a positive integer");if(t===1)return[Ft(e,.5)];let o=Array.from({length:n+1},(d,f)=>Ft(e,f/n)),r=new Float64Array(o.length);for(let d=1;d<o.length;d+=1){let f=o[d].x-o[d-1].x,u=o[d].y-o[d-1].y;r[d]=r[d-1]+Math.hypot(f,u)}let i=r[r.length-1];if(i<=1e-9)return Array.from({length:t},()=>({...e.start}));let s=[],a=1;for(let d=0;d<t;d+=1){let f=i*d/(t-1);for(;a<r.length-1&&r[a]<f;)a+=1;let u=r[a-1],b=r[a],c=b===u?0:(f-u)/(b-u);s.push({x:o[a-1].x+(o[a].x-o[a-1].x)*c,y:o[a-1].y+(o[a].y-o[a-1].y)*c})}return s}function Nt(e,t,n){return Math.max(t,Math.min(n,e))}function Gt(e){let t=new Map,n=new Map;for(let o of e){if(o.type!=="row"||!o.segmentedRow)continue;let r=n.get(o.segmentedRow.groupId)??[];r.push(o),n.set(o.segmentedRow.groupId,r)}for(let[o,r]of n){let i=r.slice().sort((c,l)=>c.segmentedRow.componentIndex-l.segmentedRow.componentIndex),s=i[0]?.segmentedRow?.componentCount??0,a=i[0]?.segmentedRow;if(!a||!(s>=2&&i.length===s&&a?.boundaryBefore==="start"&&i.every((c,l)=>c.segmentedRow?.kind==="segmented-row-v1"&&c.segmentedRow.groupId===o&&c.segmentedRow.componentCount===s&&c.segmentedRow.componentIndex===l&&c.segmentedRow.repeatLabelOnComponents===a.repeatLabelOnComponents&&(l===0?c.segmentedRow.boundaryBefore==="start":c.segmentedRow.boundaryBefore!=="start")&&c.segmentedRow.displayLabel===a.displayLabel)))continue;let f=i.reduce((c,l)=>c+l.seatCount,0),u=0,b=0;for(let c of i)c.segmentedRow.boundaryBefore==="break"&&(u+=1),t.set(c.id,{groupId:o,adjacencyOffset:u,displayOffset:b,displayLabel:a.displayLabel,totalSeats:f,canonical:i[0],viewFromSeatUrl:a.viewFromSeatUrl,viewFromSeatMeta:a.viewFromSeatMeta,confidenceEvidence:a.confidenceEvidence}),u+=c.seatCount,b+=c.seatCount}return t}var Ro="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var Po="abcdefghijklmnopqrstuvwxyz";function Co(e,t){let n=t.length,o=e+1,r="";for(;o>0;){o-=1;let i=o%n;r=t[i]+r,o=Math.floor(o/n)}return r}function ft(e,t=!1){let n=t?Po:Ro;return Co(Math.max(0,Math.floor(e)-1),n)}var Ao=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];function jt(e){if(!Number.isFinite(e)||e<=0)return String(e);let t=Math.floor(e),n="";for(let[o,r]of Ao)for(;t>=o;)n+=r,t-=o;return n}function Eo(e){let t=new Array(e);return Array.from({length:e},(n,o)=>o).sort((n,o)=>Math.abs(2*n-(e-1))-Math.abs(2*o-(e-1))||n-o).forEach((n,o)=>t[n]=o),t}function mt(e,t){let n=e.seatLabelStart??1,o=e.seatNumbering?.direction??"ltr",r=e.seatNumbering?.step??1,i=e.seatNumbering?.scheme??"decimal",s=e.seatNumbering?.prefix??"",a=e.seatNumbering?.endAt,d=e.seatCount;if(i==="updown"||i==="updown-descending"){let l=Math.ceil(d/2),m=i==="updown"?t<l?n+2*t:n-1+2*(d-t):t<l?n+2*(l-1-t):n+1+2*(t-l);return`${s}${m}`}let f=i==="odd"||i==="even"?2:r,u=a!=null&&Number.isFinite(a)?a-(d-1)*f:n,b=o==="center"?Eo(d)[t]:o==="rtl"?d-1-t:t,c;switch(i){case"odd":{let l=u%2===1?u:u+1;c=String(l+b*2);break}case"even":{let l=u%2===0?u:u+1;c=String(l+b*2);break}case"roman":c=jt(u+b*r);break;case"letters-upper":c=ft(u+b*r,!1);break;case"letters-lower":c=ft(u+b*r,!0);break;default:c=String(u+b*r);break}return`${s}${c}`}function _o(e){return{...e.canonical,seatCount:e.totalSeats,label:e.displayLabel,displayLabel:e.displayLabel}}function Ut(e,t,n){return n?.label??`${e.label}-${mt(e,t)}`}function dt(e,t,n,o){if(o?.displayLabel)return o.displayLabel;if(!n)return`${e.displayLabel||e.label}-${mt(e,t)}`;let r=_o(n),i=n.displayOffset+t;return`${n.displayLabel}-${mt(r,i)}`}var re=.02291666666666667,fe=1/re,ko=58,To=ko*re;var Lo=3,Xt=0,bt=120,Oo=0,Bo=45,Fo=7,me=1.2;function ht(e,t,n,o){return Number.isFinite(e)?Math.max(t,Math.min(n,e)):o}function Do(e){return!Number.isFinite(e)||!Number.isInteger(e)||e<0?0:e<=Fo?e:Lo}function He(e,t={}){let n=ht(t.floorBaseHeightM,Xt,bt,0),o=Math.min(bt,n+Do(e.elevation)*To),r=e.height===void 0?o:ht(e.height,Xt,bt,o),i=ht(e.rake,Oo,Bo,0);return{height:r,rake:i}}function Yt(e){let t=e.length;return t<=3?[...e]:[e[Math.floor(t*.25)],e[Math.floor(t*.5)],e[Math.floor(t*.75)]]}function ve(e,t,n){if(!e.length)return 1/0;if(e.length===1)return Math.hypot(t-e[0].x,n-e[0].y);let o=1/0;for(let r=0;r+1<e.length;r++){let i=e[r],s=e[r+1],a=s.x-i.x,d=s.y-i.y,f=a*a+d*d,u=f>1e-12?((t-i.x)*a+(n-i.y)*d)/f:0;u<0?u=0:u>1&&(u=1);let b=Math.hypot(t-(i.x+u*a),n-(i.y+u*d));b<o&&(o=b)}return o}function No(e){let t=0,n=0;for(let i of e)t+=i.x,n+=i.y;let o=e.length||1;t/=o,n/=o;let r=0;for(let i of e){let s=Math.hypot(i.x-t,i.y-n);s>r&&(r=s)}return{cx:t,cy:n,r}}function Vt(e,t){return Math.hypot(e.cx-t.cx,e.cy-t.cy)-e.r-t.r}function pt(e,t){let n=1/0;for(let o of Yt(e)){let r=ve(t,o.x,o.y);r<n&&(n=r)}for(let o of Yt(t)){let r=ve(e,o.x,o.y);r<n&&(n=r)}return n}function Go(e,t){if(e.length<3)return{pts:e,seatIndices:t};let n=0,o=0;for(let u of e)n+=u.x,o+=u.y;n/=e.length,o/=e.length;let r=-1,i=e[0];for(let u of e){let b=Math.hypot(u.x-n,u.y-o);b>r&&(r=b,i=u)}let s=i.x-n,a=i.y-o,d=Math.hypot(s,a);d>1e-9?(s/=d,a/=d):(s=1,a=0);let f=e.map((u,b)=>({p:u,i:b,t:(u.x-n)*s+(u.y-o)*a})).sort((u,b)=>u.t-b.t);return{pts:f.map(u=>u.p),seatIndices:f.map(u=>t[u.i])}}function yt(e){let t=e.length;if(t<3)return null;let n=0,o=0;for(let g of e)n+=g.x,o+=g.y;n/=t,o/=t;let r=0,i=0,s=0,a=0,d=0,f=0,u=0;for(let g of e){let S=g.x-n,x=g.y-o;r+=S*S,s+=x*x,i+=S*x,a+=S*S*S,d+=x*x*x,f+=S*x*x,u+=x*S*S}let b=r*s-i*i;if(Math.abs(b)<1e-9)return null;let c=(a+f)/2,l=(d+u)/2,m=(c*s-l*i)/b,h=(l*r-c*i)/b,p=m+n,y=h+o;return!Number.isFinite(p)||!Number.isFinite(y)?null:{cx:p,cy:y}}var jo=.15;function Uo(e){if(e.length<2)return null;let t=e.map(g=>{let S=0,x=0;for(let _ of g.pts)S+=_.x,x+=_.y;return{x:S/g.pts.length,y:x/g.pts.length}}),n=0,o=0;for(let g of t)n+=g.x,o+=g.y;n/=t.length,o/=t.length;let r=0,i=0,s=0;for(let g of t){let S=g.x-n,x=g.y-o;r+=S*S,i+=S*x,s+=x*x}let a=r+s,d=r*s-i*i,f=a/2+Math.sqrt(Math.max(0,a*a/4-d)),u,b;Math.abs(i)>1e-12?(u=f-s,b=i):r>=s?(u=1,b=0):(u=0,b=1);let c=Math.hypot(u,b);if(!(c>1e-12))return null;u/=c,b/=c;let l=1/0,m=-1/0,h=[];for(let g of e){let S=1/0,x=-1/0;for(let _ of g.pts){let M=_.x*u+_.y*b;M<S&&(S=M),M>x&&(x=M),M<l&&(l=M),M>m&&(m=M)}h.push(x-S)}let p=m-l;return p>1e-9?(h.sort((g,S)=>g-S),h[Math.min(h.length-1,Math.floor(h.length*.9))]/p<=Xo?{x:u,y:b}:null):null}var Xo=.35;function Ke(e,t,n,o){let r=new Map;for(let p of n){let y=t[p],g=y.rowId||`__seat-${p}`,S=r.get(g);S||(S={pts:[],idx:[]},r.set(g,S)),S.pts.push({x:y.x,y:y.y}),S.idx.push(p)}if(!r.size)return{sectionId:e,rows:[],blockCount:0};let i=[];for(let[p,y]of r){let g=Go(y.pts,y.idx),S=0;for(let x of g.pts)S+=Math.hypot(x.x-o.x,x.y-o.y);i.push({id:p,pts:g.pts,seatIndices:g.seatIndices,blockId:-1,ordinal:0,blockDepth:0,focalDistance:S/g.pts.length})}let s=i.map(p=>No(p.pts)),a=[];for(let p=0;p<i.length;p++){let y=1/0;for(let g=0;g<i.length;g++){if(p===g||Vt(s[p],s[g])>=y)continue;let S=pt(i[p].pts,i[g].pts);S<y&&(y=S)}Number.isFinite(y)&&a.push(y)}a.sort((p,y)=>p-y);let d=a.length?a[Math.floor(a.length/2)]:1,f=Math.max(d*1.8,1e-6),u=i.map(()=>[]);for(let p=0;p<i.length;p++)for(let y=p+1;y<i.length;y++)Vt(s[p],s[y])>f||pt(i[p].pts,i[y].pts)<=f&&(u[p].push(y),u[y].push(p));let b=0;for(let p=0;p<i.length;p++){if(i[p].blockId!==-1)continue;let y=b++,g=[p];for(i[p].blockId=y;g.length;){let S=g.pop();for(let x of u[S])i[x].blockId===-1&&(i[x].blockId=y,g.push(x))}}let c=new Map;for(let p of i){let y=c.get(p.blockId)??[];y.push(p),c.set(p.blockId,y)}let l=[];for(let p of i){if(p.pts.length<4)continue;let y=yt(p.pts);y&&(!Number.isFinite(y.cx)||!Number.isFinite(y.cy)||l.push({x:y.cx,y:y.cy}))}let m=l.length>=2?(()=>{let p=l.map(S=>S.x).sort((S,x)=>S-x),y=l.map(S=>S.y).sort((S,x)=>S-x),g=Math.floor(l.length/2);return{cx:p[g],cy:y[g]}})():null;if(m){let p=M=>Math.hypot(M.x-m.cx,M.y-m.cy),y=1/0,g=-1/0,S=[];for(let M of i){let v=1/0,k=-1/0;for(let B of M.pts){let D=p(B);D<v&&(v=D),D>k&&(k=D)}S.push(k-v),v<y&&(y=v),k>g&&(g=k)}let x=g-y;S.sort((M,v)=>M-v);let _=S[Math.min(S.length-1,Math.floor(S.length*.9))];if(x>1e-9&&_/x<=jo){let M=i.map(I=>{let F=0;for(let A of I.pts)F+=p(A);return{row:I,radius:F/I.pts.length}}),v=0,k=0;for(let I of M)v+=I.radius,k+=I.row.focalDistance;v/=M.length,k/=M.length;let B=0;for(let I of M)B+=(I.radius-v)*(I.row.focalDistance-k);if(B<0)for(let I of M)I.radius=-I.radius;let U=1/0;for(let I of M)I.radius<U&&(U=I.radius);M.sort((I,F)=>I.radius-F.radius);let P=-1,w=-1/0,L=x/Math.max(1,M.length)*.5,T=[];for(let I of M)I.radius-w>L&&(P++,w=I.radius),I.row.ordinal=P,I.row.blockDepth=I.radius-U,T.push(I.row);return{sectionId:e,rows:T,blockCount:b}}}let h=[];for(let[,p]of c){let y=Uo(p);if(y){let g=x=>{let _=0;for(let M of x.pts)_+=M.x*y.x+M.y*y.y;return _/x.pts.length};p.sort((x,_)=>g(x)-g(_)),p.length>=2&&p[0].focalDistance>p[p.length-1].focalDistance&&p.reverse();let S=0;for(let x=0;x<p.length;x++)x>0&&(S+=pt(p[x-1].pts,p[x].pts)),p[x].ordinal=x,p[x].blockDepth=S,h.push(p[x])}else{let g=1/0;for(let S of p)S.focalDistance<g&&(g=S.focalDistance);p.sort((S,x)=>S.focalDistance-x.focalDistance);for(let S=0;S<p.length;S++)p[S].ordinal=S,p[S].blockDepth=Math.max(0,p[S].focalDistance-g),h.push(p[S])}}return{sectionId:e,rows:h,blockCount:b}}var Yo=/^\d{4}-\d{2}-\d{2}$/;function Vo(e){let t=Date.parse(e);return Number.isFinite(t)?Yo.test(e)?t+864e5:t:null}function Ho(e,t=Date.now()){if(e.validUntil===void 0){if(e.status!=="approved")return!0;let o=e.assessedAt?Date.parse(e.assessedAt):Number.NaN;return Number.isFinite(o)&&(t instanceof Date?t.getTime():t)<=o+366*864e5}let n=Vo(e.validUntil);return n===null?!1:(t instanceof Date?t.getTime():t)<n}function Ko(e,t,n){return!(e.eventConfigurationId&&e.eventConfigurationId!==t||e.eventConfigurationVersion!==void 0&&e.eventConfigurationVersion!==n)}function zo(e){return e.status!=="draft"&&e.status!=="retracted"}function Wo(e,t){return e.status===void 0?t===void 0:e.status!=="approved"?!0:typeof t=="string"&&typeof e.basisSha256=="string"&&e.basisSha256===t}function Ht(e,t={}){return!!e&&zo(e)&&Ko(e,t.activeConfigurationId,t.activeConfigurationVersion)&&Wo(e,t.activeBasisSha256)&&Ho(e,t.now)}function Qt(e){return e?e.accessibility&&e.accessibility.length?e.wheelchairSpaceType&&!e.accessibility.includes("wheelchair")?["wheelchair",...e.accessibility]:e.accessibility:e.wheelchairSpaceType?["wheelchair"]:e.accessible?["wheelchair"]:[]:[]}var ze=Math.PI/180;var ke=16;function xt(e,t,n,o){let r=n*ze,i=Math.cos(r),s=Math.sin(r);return{x:o.x+e*i-t*s,y:o.y+e*s+t*i}}function Zo(e){let{seatCount:t,seatSpacing:n,curve:o,rotation:r,origin:i}=e,s=[];if(e.path)return Dt(e.path,t);if(t<=1)return t===1&&s.push({x:i.x,y:i.y}),s;if(o===0){for(let f=0;f<t;f++)s.push(xt(f*n,0,r,i));return s}let a=o/(t-1)*ze,d=n/(2*Math.sin(Math.abs(a)/2));for(let f=0;f<t;f++){let u=f*a,b=d*Math.sin(u),c=-d+d*Math.cos(u);s.push(xt(b,c,r,i))}return s}function Qo(e){let t=new Map;if(e.overrides)for(let n of e.overrides)t.set(n.index,n);return t}function $o(e,t){let n=Qo(e);return Zo(e).map((o,r)=>{let i=n.get(r),s=Qt(i),a=Ut(e,r,i),d={...e.commercial,...i?.commercial};return{index:r,x:o.x+(i?.dx??0),y:o.y+(i?.dy??0),label:a,displayLabel:dt(e,r,t,i),categoryKey:i?.categoryKey??e.categoryKey,skipped:!!i?.skip,accessible:s.length>0,accessibility:s,wheelchairSpaceType:i?.wheelchairSpaceType,commercial:Object.values(d).some(f=>f!==void 0&&f!==!1&&f!=="")?d:void 0,glyph:i?.glyph,viewUrl:i?.viewFromSeatUrl??e.viewFromSeatUrl,viewMeta:i?.viewFromSeatUrl?i.viewFromSeatMeta:e.viewFromSeatMeta,labelStyle:i?.labelStyle}})}function $t(e){let t=[];for(let n of $o(e))n.skipped||t.push({id:`${e.id}:${n.index}`,label:n.label,displayLabel:n.displayLabel===n.label?void 0:n.displayLabel,x:n.x,y:n.y,rowId:e.id,categoryKey:n.categoryKey,accessible:n.accessible||void 0,accessibility:n.accessibility.length?n.accessibility:void 0,wheelchairSpaceType:n.wheelchairSpaceType,commercial:n.commercial,glyph:n.glyph,viewUrl:n.viewUrl,viewMeta:n.viewMeta,labelStyle:n.labelStyle});return t}function qo(e){if(e.seatCountsBySide)return{...e.seatCountsBySide};let t=e.sides&&e.sides.length?e.sides:["top","bottom"],n=["top","bottom","left","right"].filter(i=>t.includes(i)),o={top:0,bottom:0,left:0,right:0};if(!n.length)return o;let r=Math.max(0,Math.round(e.seatCount));for(let i=0;i<r;i++)o[n[i%n.length]]+=1;return o}function Jo(e){let t=[],n=Math.max(0,Math.round(e.seatCount));if(n===0)return t;let o=new Map((e.overrides??[]).map(u=>[u.index,u])),r=(u,b,c,l)=>{let m=o.get(u),h=Qt(m),p=m?.label??`${e.label}-${u+1}`,y=e.displayLabel??e.label;return{index:u,label:p,displayLabel:m?.displayLabel??`${y}-${u+1}`,x:b+(m?.dx??0),y:c+(m?.dy??0),categoryKey:m?.categoryKey??e.categoryKey,skipped:!!m?.skip,accessible:h.length>0,accessibility:h,wheelchairSpaceType:m?.wheelchairSpaceType,commercial:m?.commercial,glyph:m?.glyph,viewUrl:m?.viewFromSeatUrl,viewMeta:m?.viewFromSeatUrl?m.viewFromSeatMeta:void 0,labelStyle:m?.labelStyle,...l?{side:l}:{}}};if(e.shape==="round"){let u=(e.radius??40)+ke,b=e.rotation*ze,c=Math.max(0,Math.min(360,e.seatArc??360));if(c>=360||n===1){for(let p=0;p<n;p++){let y=b+p/n*2*Math.PI;t.push(r(p,e.center.x+u*Math.cos(y),e.center.y+u*Math.sin(y)))}return t}let l=c*ze,m=(2*Math.PI-l)/2,h=b+m;for(let p=0;p<n;p++){let y=h+p/(n-1)*l;t.push(r(p,e.center.x+u*Math.cos(y),e.center.y+u*Math.sin(y)))}return t}let i=e.width??80,s=e.height??50,a=qo(e),d=["top","bottom","left","right"],f=0;for(let u of d){let b=a[u];for(let c=0;c<b;c++){let l,m;u==="top"?(l=-i/2+(c+.5)*i/b,m=-s/2-ke):u==="bottom"?(l=-i/2+(c+.5)*i/b,m=s/2+ke):u==="left"?(l=-i/2-ke,m=-s/2+(c+.5)*s/b):(l=i/2+ke,m=-s/2+(c+.5)*s/b);let h=xt(l,m,e.rotation,e.center);t.push(r(f++,h.x,h.y,u))}}return t}function er(e){return Jo(e).filter(t=>!t.skipped).map(t=>({id:`${e.id}:${t.index}`,label:t.label,...t.displayLabel!==t.label?{displayLabel:t.displayLabel}:{},x:t.x,y:t.y,rowId:e.id,categoryKey:t.categoryKey,...t.accessible?{accessible:!0}:{},...t.accessibility.length?{accessibility:t.accessibility}:{},...t.wheelchairSpaceType?{wheelchairSpaceType:t.wheelchairSpaceType}:{},...t.commercial?{commercial:t.commercial}:{},...t.glyph?{glyph:t.glyph}:{},...t.viewUrl?{viewUrl:t.viewUrl}:{},...t.viewUrl&&t.viewMeta?{viewMeta:t.viewMeta}:{},...t.labelStyle?{labelStyle:t.labelStyle}:{}}))}function tr(e){return[{id:`${e.id}:0`,label:e.label,...e.displayLabel&&e.displayLabel!==e.label?{displayLabel:e.displayLabel}:{},x:e.center.x,y:e.center.y,rowId:e.id,categoryKey:e.categoryKey,kind:"booth"}]}function Kt(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[o].x,s=t[o].y,a=t[r].x,d=t[r].y;s>e.y!=d>e.y&&e.x<(a-i)*(e.y-s)/(d-s)+i&&(n=!n)}return n}function nr(e,t){return t.some((n,o)=>{let r=t[(o+1)%t.length],i=(e.y-n.y)*(r.x-n.x)-(e.x-n.x)*(r.y-n.y);if(Math.abs(i)>1e-7)return!1;let s=(e.x-n.x)*(r.x-n.x)+(e.y-n.y)*(r.y-n.y),a=(r.x-n.x)**2+(r.y-n.y)**2;return s>=-1e-7&&s<=a+1e-7})}function be(e,t,n){return Kt(e,t)&&!(n??[]).some(o=>Kt(e,o)||nr(e,o))}function gt(e){if(!e.length)return{x:0,y:0};let t=0,n=0;for(let o of e)t+=o.x,n+=o.y;return{x:t/e.length,y:n/e.length}}function or(e){switch(e.type){case"row":{let t=$t(e);if(!t.length)return{x:e.origin.x,y:e.origin.y};let n=0,o=0;for(let r of t)n+=r.x,o+=r.y;return{x:n/t.length,y:o/t.length}}case"table":case"booth":return{x:e.center.x,y:e.center.y};case"gaArea":return gt(e.points);case"section":return gt(e.outline);case"text":return{x:e.position.x,y:e.position.y};case"shape":return e.points&&e.points.length?gt(e.points):e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null?{x:e.x+e.width/2,y:e.y+e.height/2}:{x:e.x??0,y:e.y??0};case"decorImage":return{x:e.x+e.width/2,y:e.y+e.height/2}}}function zt(e,t){return e.length===t.length&&e.every((n,o)=>n.x===t[o].x&&n.y===t[o].y)}function rr(e,t){if(e.type!=="gaArea"||!zt(e.points,t.outline))return!1;let n=e.holes??[],o=t.holes??[];return n.length===o.length&&n.every((r,i)=>zt(r,o[i]))}function ir(e,t){let n=e.filter(s=>s.type==="section"),o="referenceInventorySource"in t?t.referenceInventorySource?.logicalSectionId:void 0,r=or(t);return(o?n.find(s=>(s.logicalSectionId??s.id)===o&&(rr(t,s)||be(r,s.outline,s.holes))):void 0)??n.find(s=>be(r,s.outline,s.holes))}function Wt(e,t,n,o,r,i,s,a,d){let f=[],u=Gt(e),b=m=>!m?.eventConfigurationId||m.eventConfigurationId===o&&(m.eventConfigurationVersion===void 0||m.eventConfigurationVersion===d),c=m=>Ht(m,{activeConfigurationId:o,activeConfigurationVersion:d,activeBasisSha256:r,now:a}),l=(m,h)=>c(m)?{...m,coverage:h}:void 0;for(let m of e){let h=[];if(m.type==="row"?h=$t(m):m.type==="table"?h=er(m):m.type==="booth"&&(h=tr(m)),!h.length)continue;for(let x of h)x.viewUrl&&!b(x.viewMeta)&&(x.viewUrl=void 0,x.viewMeta=void 0);if(m.type==="row"){let x=u.get(m.id);if(x){let _=new Map((m.overrides??[]).map(M=>[M.index,M]));for(let M of h){let v=Number(M.id.slice(M.id.lastIndexOf(":")+1));if(!Number.isInteger(v))continue;M.logicalRowId=x.groupId,M.logicalSeatIndex=x.adjacencyOffset+v,_.get(v)?.displayLabel||(M.displayLabel=dt(m,v,x)),!M.viewUrl&&x.viewFromSeatUrl&&b(x.viewFromSeatMeta)&&(M.viewUrl=x.viewFromSeatUrl,M.viewMeta=x.viewFromSeatMeta);let k=_.get(v)?.confidenceEvidence;M.confidenceEvidence=l(k,"exact-seat")??l(m.confidenceEvidence,"row-representative")??l(x.confidenceEvidence,"row-representative")}}}let p=ir(e,m),y=p?.viewFromSeatUrl,S=(p?.zone?t?.find(x=>x.id===p.zone):void 0)?.focalPoint??n;for(let x of h){if(!x.confidenceEvidence){let _=Number(x.id.slice(x.id.lastIndexOf(":")+1)),M=(m.type==="row"||m.type==="table")&&Number.isInteger(_)?m.overrides?.find(v=>v.index===_)?.confidenceEvidence:void 0;x.confidenceEvidence=l(M,"exact-seat")??(m.type==="row"?l(m.confidenceEvidence,"row-representative"):void 0)}x.confidenceEvidence??=l(p?.confidenceEvidence,"section-representative")??(s?l(s.evidence,s.coverage):void 0),!x.viewUrl&&y&&b(p?.viewFromSeatMeta)&&(x.viewUrl=y,x.viewMeta=p?.viewFromSeatMeta),!x.viewUrl&&i&&b(i.meta)&&(x.viewUrl=i.url,x.viewMeta=i.meta),p&&(x.sectionId=p.logicalSectionId??p.id),p?.zone&&(x.zoneId=p.zone),S&&(x.focalPoint={...S})}f.push(...h)}return f}function qt(e,t={}){if(e.floors?.length){let o=[];for(let r of e.floors){let i=r.focalPoint??e.focalPoint,s=r.viewFromSeatUrl?{url:r.viewFromSeatUrl,meta:r.viewFromSeatMeta}:e.viewFromSeatUrl?{url:e.viewFromSeatUrl,meta:e.viewFromSeatMeta}:void 0,a=r.confidenceEvidence?{evidence:r.confidenceEvidence,coverage:"floor-representative"}:e.confidenceEvidence?{evidence:e.confidenceEvidence,coverage:"venue-representative"}:void 0,d=Wt(r.objects,e.zones,i,e.eventConfigurationId,e.confidenceBasisSha256,s,a,t.now,t.eventConfigurationVersion??e.eventConfigurationVersion);t.resolveEyeHeights!==!1&&Zt(r.objects,r.focalPoint??e.focalPoint,r.baseHeightM??0,d);for(let f of d)f.floorId=r.id;o.push(...d)}return o}let n=Wt(e.objects,e.zones,e.focalPoint,e.eventConfigurationId,e.confidenceBasisSha256,e.viewFromSeatUrl?{url:e.viewFromSeatUrl,meta:e.viewFromSeatMeta}:void 0,e.confidenceEvidence?{evidence:e.confidenceEvidence,coverage:"venue-representative"}:void 0,t.now,t.eventConfigurationVersion??e.eventConfigurationVersion);return t.resolveEyeHeights!==!1&&Zt(e.objects,e.focalPoint,t.floorBaseHeightM??0,n),n}function Zt(e,t,n,o){let r=e.filter(u=>u.type==="section"),i=n>0||r.some(u=>u.height!==void 0||u.rake!==void 0||(u.elevation??0)>0);if(!r.length||!i||!t){for(let u of o)u.eyeHeightM=n+me;return}let s=new Array(o.length),a=new Map,d=new Map;for(let u=0;u<o.length;u++){let b=o[u],l=(b.sectionId?r.find(h=>h.id===b.sectionId)??r.find(h=>h.logicalSectionId===b.sectionId&&be({x:b.x,y:b.y},h.outline,h.holes)):void 0)??r.find(h=>be({x:b.x,y:b.y},h.outline,h.holes))??null;if(s[u]=l,!l)continue;a.has(l.id)||a.set(l.id,He(l,{floorBaseHeightM:n}));let m=d.get(l.id);m?m.push(u):d.set(l.id,[u])}let f=new Array(o.length).fill(void 0);for(let[u,b]of d){let c=a.get(u);if(!c)continue;let l=c.rake>0?Math.tan(c.rake*Math.PI/180):0,m=Ke(u,o,b,t);for(let h of m.rows){let p=h.blockDepth*re*l,y=c.height+p;for(let g of h.seatIndices)f[g]=y}}for(let u=0;u<o.length;u++){let b=o[u],c=s[u];if(!c){b.eyeHeightM=n+me;continue}let l=a.get(c.id);b.eyeHeightM=(f[u]??l.height)+me}}var sr=/^#?([\da-f]{3}|[\da-f]{6})$/i;function ar(e){let t=sr.exec((e??"").trim());if(!t)return null;let n=t[1].length===3?t[1].split("").map(r=>r+r).join(""):t[1],o=parseInt(n,16);return[o>>16&255,o>>8&255,o&255]}function W(e){let t=ar(e);return t?[t[0]/255,t[1]/255,t[2]/255]:null}function cr(e){return .2126*e[0]+.7152*e[1]+.0722*e[2]}function te(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}function Te(e,t){let n=cr(e);return te(e,[n,n,n],t)}var We=["available","held","sold","selected","dimmed"];function Jt(e){let t=We.indexOf(e);return t<0?0:t}var en={available:[.24,.82,.52],held:[.95,.66,.22],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};var St={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]},Mt={top:[.05,.06,.08],bottom:[.1,.12,.15]};function ie(e,t){return[Math.min(1,e[0]*t),Math.min(1,e[1]*t),Math.min(1,e[2]*t)]}var ur=.15,lr=1.6;function tn(e){return Nt(e??1,ur,lr)}var fr=.15,mr=.9,dr=1.76;function br(){return{background:{top:[...Mt.top],bottom:[...Mt.bottom]},structure:St,seatStates:{...en},seatScale:1,materials:{seat:null,shell:null,roughness:.78}}}function nn(e){let t=br();if(!e)return t;let n=W(e.background);if(n){t.background={top:ie(n,mr),bottom:ie(n,dr)};let s={};for(let[a,d]of Object.entries(St))s[a]=te(d,n,fr);t.structure=s}let o=W(e.selectionColor)??W(e.accent);o&&(t.seatStates={...t.seatStates,selected:o});let r=e.seatScale;typeof r=="number"&&Number.isFinite(r)&&(t.seatScale=tn(r));let i=e.venue3d;if(i){let s=W(i.deck),a=W(i.fascia);s&&(t.structure={...t.structure,tierTop:s,gaTop:s}),a&&(t.structure={...t.structure,tierWall:a,gaWall:a}),t.materials.seat=W(i.seat),t.materials.shell=W(i.shell),typeof i.roughness=="number"&&Number.isFinite(i.roughness)&&(t.materials.roughness=Math.min(1,Math.max(0,i.roughness)))}return t}function on(e,t){let n=[];for(let o of t)n.push(...e.seatStates[o]);return n}var sn=Ie(require("earcut"),1),an=Ie(require("polygon-clipping"),1);function he(e){let t=0;for(let n=0,o=e.length;n<o;n+=1){let r=e[n],i=e[(n+1)%o];t+=r.x*i.y-i.x*r.y}return t/2}function Le(e,t,n){let o=!1;for(let r=0,i=e.length-1;r<e.length;i=r++){let s=e[r],a=e[i];s.y>n!=a.y>n&&t<(a.x-s.x)*(n-s.y)/(a.y-s.y)+s.x&&(o=!o)}return o}var R=re,hr=.002;function pr(e,t,n){let o=Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2]),r=Math.hypot(n[0]-t[0],n[1]-t[1],n[2]-t[2]),i=Math.hypot(e[0]-n[0],e[1]-n[1],e[2]-n[2]),s=Math.max(o,r,i);if(s<1e-9)return!0;let a=(o+r+i)/2;return 2*Math.sqrt(Math.max(0,a*(a-o)*(a-r)*(a-i)))/s<hr}var pe=class{constructor(t=16384){this.len=0;this.buf=new Float32Array(t)}push3(t,n,o){this.len+3>this.buf.length&&this.grow(this.len+3),this.buf[this.len++]=t,this.buf[this.len++]=n,this.buf[this.len++]=o}push1(t){this.len+1>this.buf.length&&this.grow(this.len+1),this.buf[this.len++]=t}grow(t){let n=this.buf.length*2;for(;n<t;)n*=2;let o=new Float32Array(n);o.set(this.buf.subarray(0,this.len)),this.buf=o}get length(){return this.len}toArray(){return this.buf.slice(0,this.len)}},$e=class{constructor(){this.pos=new pe;this.nor=new pe;this.col=new pe;this.flr=new pe;this.mat=new pe;this.currentFloor=0;this.currentMaterial=0}setFloor(t){this.currentFloor=t}setMaterial(t){this.currentMaterial=t}tri(t,n,o,r,i,s=i,a=i){pr(t,n,o)||(this.pos.push3(t[0],t[1],t[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(o[0],o[1],o[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(r[0],r[1],r[2]),this.col.push3(i[0],i[1],i[2]),this.col.push3(s[0],s[1],s[2]),this.col.push3(a[0],a[1],a[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}triN(t,n,o,r,i,s,a,d=a,f=a){[...t,...n,...o].every(Number.isFinite)&&(this.pos.push3(t[0],t[1],t[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(o[0],o[1],o[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(i[0],i[1],i[2]),this.nor.push3(s[0],s[1],s[2]),this.col.push3(a[0],a[1],a[2]),this.col.push3(d[0],d[1],d[2]),this.col.push3(f[0],f[1],f[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}get vertexCount(){return this.pos.length/3}build(){return{position:this.pos.toArray(),normal:this.nor.toArray(),color:this.col.toArray(),floor:this.flr.toArray(),material:this.mat.toArray(),count:this.pos.length/3}}};function yr(e,t,n){let o=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2],s=n[0]-e[0],a=n[1]-e[1],d=n[2]-e[2],f=r*d-i*a,u=i*s-o*d,b=o*a-r*s,c=Math.hypot(f,u,b)||1;return f/=c,u/=c,b/=c,[f,u,b]}function gr(e,t){let n=[...e],o=[];for(let s of e)o.push(s.x,s.y);let r=[];if(t){for(let s of t)if(!(s.length<3)){r.push(n.length);for(let a of s)n.push(a),o.push(a.x,a.y)}}let i=(0,sn.default)(o,r.length?r:void 0,2);return{pts:n,tris:i}}function wt(e){return he(e)<0?[...e].reverse():e}var xr=3;function Sr(e,t,n,o){let r=o(e),i=o(t),s=o(n),a=(l,m,h,p)=>Math.abs(o({x:(l.x+m.x)/2,y:(l.y+m.y)/2})-(h+p)/2),d=(e.x+t.x+n.x)/3,f=(e.y+t.y+n.y)/3,u=(r+i+s)/3,b=Math.max(a(e,t,r,i),a(t,n,i,s),a(n,e,s,r),Math.abs(o({x:d,y:f})-u)),c=(l,m,h)=>{let p=Math.abs(o({x:(l+d)/2,y:(m+f)/2})-(h+u)/2);p>b&&(b=p)};return c((e.x+t.x)/2,(e.y+t.y)/2,(r+i)/2),c((t.x+n.x)/2,(t.y+n.y)/2,(i+s)/2),c((n.x+e.x)/2,(n.y+e.y)/2,(s+r)/2),b}function Oe(e,t,n,o,r){if(r<=0)return Sr(e,t,n,o);let i={x:(e.x+t.x)/2,y:(e.y+t.y)/2},s={x:(t.x+n.x)/2,y:(t.y+n.y)/2},a={x:(n.x+e.x)/2,y:(n.y+e.y)/2};return Math.max(Oe(e,i,a,o,r-1),Oe(i,t,s,o,r-1),Oe(a,s,n,o,r-1),Oe(i,s,a,o,r-1))}function Be(e,t,n,o,r,i,s,a){if(s>0){let c={x:(t.x+n.x)/2,y:(t.y+n.y)/2},l={x:(n.x+o.x)/2,y:(n.y+o.y)/2},m={x:(o.x+t.x)/2,y:(o.y+t.y)/2};Be(e,t,c,m,r,i,s-1,a),Be(e,c,n,l,r,i,s-1,a),Be(e,m,l,o,r,i,s-1,a),Be(e,c,l,m,r,i,s-1,a);return}let d=[t.x*R,r(t),t.y*R],f=[n.x*R,r(n),n.y*R],u=[o.x*R,r(o),o.y*R];if(a){e.triN(d,f,u,a(t),a(n),a(o),i);return}let b=yr(d,f,u);b[1]<0&&(b=[-b[0],-b[1],-b[2]]),e.tri(d,f,u,b,i)}var Mr=8;function rn(e,t,n){if(!Number.isFinite(n))return e;let o=[],r=(i,s,a,d,f)=>{if(f>0){let u={x:(i.x+s.x)/2,y:(i.y+s.y)/2},b=t(u);if(Math.abs(b-(a+d)/2)>n){r(i,u,a,b,f-1),r(u,s,b,d,f-1);return}}o.push(i)};for(let i=0;i<e.length;i++){let s=e[i],a=e[(i+1)%e.length];r(s,a,t(s),t(a),Mr)}return o}function Ze(e,t){if(e.length<3)return e;let n=[];for(let r of e){let i=n[n.length-1];i&&Math.hypot(r.x-i.x,r.y-i.y)<t||n.push(r)}for(;n.length>2&&Math.hypot(n[0].x-n[n.length-1].x,n[0].y-n[n.length-1].y)<t;)n.pop();if(n.length<3)return e;let o=[];for(let r=0;r<n.length;r++){let i=o.length?o[o.length-1]:n[(r-1+n.length)%n.length],s=n[r],a=n[(r+1)%n.length],d=a.x-i.x,f=a.y-i.y,u=Math.hypot(d,f);u>t&&Math.abs((s.x-i.x)*f-(s.y-i.y)*d)/u<t||o.push(s)}return o.length>=3?o:n}var Qe=.001*fe*.1;function J(e,t,n,o,r,i,s,a,d=1/0,f){if(!t||t.length<3||(d===void 0&&(d=1/0),Math.abs(he(t))<1e-4))return;let u=Ze(rn(Ze(wt(t),Qe),o,d),Qe),b=n?.map(M=>Ze(rn(Ze(wt(M),Qe),o,d),Qe)).filter(M=>M.length>=3&&Math.abs(he(M))>=1e-4),{pts:c,tris:l}=gr(u,b),m=[i[0]*a.top,i[1]*a.top,i[2]*a.top],h=[i[0]*a.bottomCap,i[1]*a.bottomCap,i[2]*a.bottomCap],p=[s[0]*a.top,s[1]*a.top,s[2]*a.top],y=[s[0]*a.wallBottom,s[1]*a.wallBottom,s[2]*a.wallBottom],g=0;if(Number.isFinite(d))for(;g<xr;g++){let M=0;for(let v=0;v<l.length;v+=3){let k=Oe(c[l[v]],c[l[v+1]],c[l[v+2]],o,g);k>M&&(M=k)}if(M<=d)break}for(let M=0;M<l.length;M+=3){let v=c[l[M]],k=c[l[M+1]],B=c[l[M+2]];Be(e,v,k,B,o,m,g,f);let D=[v.x*R,r,v.y*R],U=[k.x*R,r,k.y*R],P=[B.x*R,r,B.y*R];e.tri(D,P,U,[0,-1,0],h)}let S=M=>{if(g<=0)return M;let v=1<<g,k=[];for(let B=0;B<M.length;B++){let D=M[B],U=M[(B+1)%M.length];for(let P=0;P<v;P++){let w=P/v;k.push({x:D.x+(U.x-D.x)*w,y:D.y+(U.y-D.y)*w})}}return k},x=lt(u),_=[{ring:S(u),flip:!1}];if(b)for(let M of b)M.length>=3&&_.push({ring:S(M),flip:!0});for(let{ring:M,flip:v}of _)for(let k=0;k<M.length;k++){let B=M[k],D=M[(k+1)%M.length],U=(D.x-B.x)*R,w=(D.y-B.y)*R,L=-U,T=Math.hypot(w,L)||1;w/=T,L/=T;let I=(B.x+D.x)/2-x.x,F=(B.y+D.y)/2-x.y,A=w*I+L*F;v&&(A=-A),A<0&&(w=-w,L=-L);let C=[w,0,L],E=[B.x*R,o(B),B.y*R],N=[D.x*R,o(D),D.y*R],j=[B.x*R,r,B.y*R],X=[D.x*R,r,D.y*R];e.tri(E,N,X,C,p,p,y),e.tri(E,X,j,C,p,y,y)}}function cn(e){let t=0;for(let d of e)t+=d.count;let n=new Float32Array(t*3),o=new Float32Array(t*3),r=new Float32Array(t*3),i=new Float32Array(t),s=new Float32Array(t),a=0;for(let d of e)n.set(d.position,a*3),o.set(d.normal,a*3),r.set(d.color,a*3),i.set(d.floor,a),s.set(d.material,a),a+=d.count;return{position:n,normal:o,color:r,floor:i,material:s,count:t}}function qe(e,t,n=2.5){if(t<=0||e.length<3)return e;let o=wt(e),r=o.length,i=[];for(let a=0;a<r;a++){let d=o[a],f=o[(a+1)%r],u=f.x-d.x,b=f.y-d.y,c=Math.hypot(u,b)||1;i.push({x:b/c,y:-u/c})}let s=[];for(let a=0;a<r;a++){let d=o[a],f=i[(a-1+r)%r],u=i[a],b=f.x+u.x,c=f.y+u.y,l=Math.hypot(b,c),m=()=>{s.push([d.x+f.x*t,d.y+f.y*t]),s.push([d.x+u.x*t,d.y+u.y*t])};if(l<1e-9){m();continue}b/=l,c/=l;let h=b*f.x+c*f.y,p=1/Math.max(h,1e-6);if(!Number.isFinite(p)||p>n){m();continue}s.push([d.x+b*t*p,d.y+c*t*p])}if(s.length<3)return e;try{let a=an.default.union([[...s,s[0]]]),d=null,f=-1/0;for(let b of a){let c=Math.abs(he(b[0].map(([l,m])=>({x:l,y:m}))));c>f&&(f=c,d=b[0])}if(!d)return e;let u=d.map(([b,c])=>({x:b,y:c}));if(u.length>1){let b=u[0],c=u[u.length-1];Math.abs(b.x-c.x)<1e-9&&Math.abs(b.y-c.y)<1e-9&&u.pop()}return u.length>=3?u:e}catch{return e}}function Je(e,t,n,o,r=28){let i=[];for(let s=0;s<r;s++){let a=s/r*Math.PI*2;i.push({x:e+n*Math.cos(a),y:t+o*Math.sin(a)})}return i}function Fe(e,t,n,o){return[{x:e,y:t},{x:e+n,y:t},{x:e+n,y:t+o},{x:e,y:t+o}]}var wr=[{key:"wheelchair",label:"Wheelchair space",short:"Wheelchair",icon:"\u267F"},{key:"companion",label:"Companion seat",short:"Companion",icon:"\u{1F9D1}\u200D\u{1F91D}\u200D\u{1F9D1}"},{key:"semi-ambulatory",label:"Semi-ambulatory (limited mobility)",short:"Limited mobility",icon:"\u{1F9AF}"},{key:"designated-aisle",label:"Designated aisle / transfer seat",short:"Aisle transfer",icon:"AS"},{key:"step-free",label:"Step-free accessible seat",short:"Step-free",icon:"SF"},{key:"hearing",label:"Assistive listening",short:"Hearing",icon:"\u{1F9BB}"},{key:"cart",label:"CART live-caption view",short:"CART captions",icon:"CC"},{key:"sign-language",label:"Sign-language view",short:"Sign language",icon:"\u{1F91F}"},{key:"low-vision",label:"Blind / low-vision viewing",short:"Low vision",icon:"LV"},{key:"sensory-friendly",label:"Quiet / sensory-friendly seating",short:"Sensory-friendly",icon:"QS"},{key:"plus-size",label:"Plus-size seat",short:"Plus-size",icon:"\u{1F4BA}"},{key:"lift-armrest",label:"Lift-up armrest",short:"Lift armrest",icon:"\u2195\uFE0F"}],_s=new Map(wr.map(e=>[e.key,e]));var Ir={wheelchair:"#3b82f6",companion:"#8b5cf6","semi-ambulatory":"#0ea5e9","designated-aisle":"#0284c7","step-free":"#16a34a",hearing:"#14b8a6",cart:"#7c3aed","sign-language":"#f59e0b","low-vision":"#d97706","sensory-friendly":"#6366f1","plus-size":"#ec4899","lift-armrest":"#22c55e"};function un(e){let t=e?.[0];return t&&Ir[t]||"#3b82f6"}var vr=[{key:"obstructedView",label:"Obstructed view",short:"Obstructed",icon:"\u26D4"},{key:"restrictedView",label:"Restricted view",short:"Restricted",icon:"\u{1F441}"},{key:"premium",label:"Premium seat",short:"Premium",icon:"\u2605"}],ks=new Map(vr.map(e=>[e.key,e]));var Rr=["reference-focal","bar","entrance","exit","restroom","screen","sound","concession","coat","wall","rail","suite","obstruction"],Ts=new Set(Rr);var fn=[{key:"circle",label:"Standard seat",shortLabel:"Standard",useCase:"General assigned seating",group:"general",path:null,bounds:null},{key:"theatre",label:"Theatre chair",shortLabel:"Theatre",useCase:"Auditoriums, arenas and stadium stands",group:"fixed",path:"M4.5 3.5 Q4.5 1.5 6.5 1.5 L17.5 1.5 Q19.5 1.5 19.5 3.5 L19.5 13 L4.5 13 Z M3.5 12 L20.5 12 Q22.5 12 22.5 14 L22.5 21 Q22.5 22.5 21 22.5 Q19.5 22.5 19.5 21 L19.5 17.5 L4.5 17.5 L4.5 21 Q4.5 22.5 3 22.5 Q1.5 22.5 1.5 21 L1.5 14 Q1.5 12 3.5 12 Z",bounds:{x:1.5,y:1.5,width:21,height:21}},{key:"dining",label:"Dining chair",shortLabel:"Dining",useCase:"Banquets, restaurants and table seating",group:"flexible",path:"M7 1 Q6 1 6 2.5 L6.75 10.5 L5 10.5 Q4 10.5 4 12 L4 14 Q4 15 5.25 15 L6 15 L4 23 L7 23 L9.5 15 L14.5 15 L17 23 L20 23 L18 15 L18.75 15 Q20 15 20 14 L20 12 Q20 10.5 19 10.5 L17.25 10.5 L18 2.5 Q18 1 17 1 Z",bounds:{x:4,y:1,width:16,height:22}},{key:"folding",label:"Folding chair",shortLabel:"Folding",useCase:"Concert floors, ceremonies and conferences",group:"flexible",path:"M6 2 Q5 2 5 3 L6 8 L18 8 L19 3 Q19 2 18 2 Z M5 9 L19 9 Q20 9 20 10.5 L19 13 L5 13 L4 10.5 Q4 9 5 9 Z M6 12 L9 12 L12 17 L15 12 L18 12 L14 19 L17 23 L14 23 L12 21 L10 23 L7 23 L10 19 Z",bounds:{x:4,y:2,width:16,height:21}},{key:"armchair",label:"Premium armchair",shortLabel:"Armchair",useCase:"Boxes, lounges and club seating",group:"premium",path:"M3.5 4 Q3.5 1.5 6 1.5 L18 1.5 Q20.5 1.5 20.5 4 L20.5 13 L3.5 13 Z M1.5 12.5 Q1.5 10 3.25 10 Q5 10 5 12.5 L5 13.5 L19 13.5 L19 12.5 Q19 10 20.75 10 Q22.5 10 22.5 12.5 L22.5 19.5 Q22.5 22 20 22 L4 22 Q1.5 22 1.5 19.5 Z",bounds:{x:1.5,y:1.5,width:21,height:20.5}},{key:"recliner",label:"Recliner",shortLabel:"Recliner",useCase:"Luxury cinemas and premium clubs",group:"premium",path:"M7 2 Q7 1 8.5 1 L15.5 1 Q17 1 17 2 L19 13 L5 13 Z M4 9 Q2 9 2 11.5 L2 16 Q2 18 4 18 L6 18 L6 15 L18 15 L18 18 L20 18 Q22 18 22 16 L22 11.5 Q22 9 20 9 Q18 9 18 11 L18 13 L6 13 L6 11 Q6 9 4 9 Z M7 17 L17 17 Q18 17 18.5 18.5 L19.5 22.5 L4.5 22.5 L5.5 18.5 Q6 17 7 17 Z",bounds:{x:2,y:1,width:20,height:21.5}},{key:"stool",label:"Stool",shortLabel:"Stool",useCase:"Bars, high-tops and seating rails",group:"flexible",path:"M6 2.5 L18 2.5 Q22 2.5 22 6.5 L22 12 Q22 16 18 16 L6 16 Q2 16 2 12 L2 6.5 Q2 2.5 6 2.5 Z M6 15.5 L9.5 15.5 L7.5 22.5 L3 22.5 Z M14.5 15.5 L18 15.5 L20.5 22.5 L16 22.5 Z",bounds:{x:2,y:2.5,width:20,height:20}},{key:"bench",label:"Bench place",shortLabel:"Bench",useCase:"Pews, bleachers and terraces",group:"fixed",path:"M2.5 0.5 L21.5 0.5 Q23 0.5 23 2 L23 5 Q23 6.5 21.5 6.5 L2.5 6.5 Q1 6.5 1 5 L1 2 Q1 0.5 2.5 0.5 Z M2 7.5 L22 7.5 Q23.5 7.5 23.5 9 L23.5 15.5 Q23.5 17 22 17 L18 17 L18 21.5 Q18 22.5 16.75 22.5 Q15.5 22.5 15.5 21.5 L15.5 17 L8.5 17 L8.5 21.5 Q8.5 22.5 7.25 22.5 Q6 22.5 6 21.5 L6 17 L2 17 Q0.5 17 0.5 15.5 L0.5 9 Q0.5 7.5 2 7.5 Z",bounds:{x:.5,y:.5,width:23,height:22}}],mn=fn.map(e=>e.key),Pr=new Map(fn.map(e=>[e.key,e]));function ln(e){return typeof e=="string"&&Pr.has(e)}function dn(e,t){return ln(e)?e:ln(t?.seatGlyph)?t.seatGlyph:"circle"}var ee={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,body:10,head:11},Cr=.44,Ar=.15,Er=.3,_r=.24;function bn(e){return e===void 0||!Number.isFinite(e)||e<=0?_r:Math.min(Er,Math.max(Ar,e*Cr))}var kr=.05,hn=.45,Tr=hn+kr,Ds=[{part:ee.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:ee.pad,min:[-1,.36,-.95],max:[1,hn,1]},{part:ee.back,min:[-1,Tr,-1],max:[1,.92,-.72]},{part:ee.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:ee.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:ee.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:ee.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:ee.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:ee.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:ee.leg,min:[.62,0,.48],max:[.82,.37,.7]}],Ns=[{part:ee.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:ee.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:ee.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:ee.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:ee.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}];function pn(e,t,n,o){let r=new Float32Array(t),i=f=>e[f*3],s=f=>e[f*3+2],a=0,d=(f,u)=>{let b=u-f;for(let c=f;c<u;c++){let[l,m]=o(c),h=l-i(c),p=m-s(c);if(b>=2){let y=Math.max(f,c-1),g=Math.min(u-1,c+1),S=i(g)-i(y),x=s(g)-s(y),_=Math.hypot(S,x);if(_>1e-6){let M=-x/_,v=S/_;M*h+v*p<0&&(M=-M,v=-v),h=M,p=v}}r[c]=h===0&&p===0?0:Math.atan2(h,p)}};for(let f=1;f<=t;f++)(f===t||n(f)!==n(a))&&(d(a,f),a=f);return r}var et=.22;var Lr=.42;function Or(e){let t=e.length,n=new Float64Array(t);if(t<2)return n.fill(1/0),n;let o=1/0,r=1/0,i=-1/0,s=-1/0;for(let m of e)m.x<o&&(o=m.x),m.y<r&&(r=m.y),m.x>i&&(i=m.x),m.y>s&&(s=m.y);let a=Math.max(i-o,1e-6),d=Math.max(s-r,1e-6),f=Math.max(Math.sqrt(a*d/t),1e-6),u=Math.max(1,Math.ceil(a/f)+1),b=Math.max(1,Math.ceil(d/f)+1),c=new Map,l=(m,h)=>{let p=Math.min(u-1,Math.max(0,Math.floor((m-o)/f)));return Math.min(b-1,Math.max(0,Math.floor((h-r)/f)))*u+p};for(let m=0;m<t;m++){let h=l(e[m].x,e[m].y),p=c.get(h);p?p.push(m):c.set(h,[m])}for(let m=0;m<t;m++){let h=e[m],p=Math.min(u-1,Math.max(0,Math.floor((h.x-o)/f))),y=Math.min(b-1,Math.max(0,Math.floor((h.y-r)/f))),g=1/0;for(let S=1;S<=4;S++){for(let x=y-S;x<=y+S;x++)if(!(x<0||x>=b))for(let _=p-S;_<=p+S;_++){if(_<0||_>=u||S>1&&Math.abs(x-y)<S&&Math.abs(_-p)<S)continue;let M=c.get(x*u+_);if(M)for(let v of M){if(v===m)continue;let k=Math.hypot(e[v].x-h.x,e[v].y-h.y);k<g&&(g=k)}}if(Number.isFinite(g)&&g<=S*f)break}n[m]=g}return n}function Br(e){let t=e.eyeHeightM;return Number.isFinite(t)?Math.max(0,t-me):0}function yn(e,t,n,o,r,i){let s=e.length,a=new Float32Array(s*3),d=new Float32Array(s),f=new Float32Array(s*3),u=new Float32Array(s),b=new Float32Array(s),c=new Float32Array(s),l=new Float32Array(s),m=new Float32Array(s*3),h=new Map,p=Or(e);for(let y=0;y<s;y++){let g=e[y],x=(n?.seatPitchU(y)??p[y])*R;u[y]=Number.isFinite(x)?Math.max(.06,Math.min(et,x*Lr)):et,b[y]=bn(Number.isFinite(x)?x:void 0);let _=dn(g.glyph,{seatGlyph:i?.get(g.categoryKey)});c[y]=mn.indexOf(_),l[y]=g.wheelchairSpaceType==="no-seat"?0:1,a[y*3]=g.x*R,a[y*3+1]=n?n.seatDeckY(y):Br(g),a[y*3+2]=g.y*R,d[y]=Jt(t?t(g):"available");let M=W(r?.get(g.categoryKey)??"#6e7bff")??[.43,.48,1];if(f[y*3]=M[0],f[y*3+1]=M[1],f[y*3+2]=M[2],g.accessibility?.length){let v=W(un(g.accessibility));v&&(m[y*3]=v[0],m[y*3+1]=v[1],m[y*3+2]=v[2])}h.set(g.id,y)}return{count:s,iPosition:a,iState:d,iCategory:f,iMaxRadius:u,iRing:m,idToIndex:h,iChairWidth:b,iGlyph:c,iPhysicalSeat:l,iFloor:o??new Float32Array(s),iYaw:new Float32Array(s)}}function Fr(e){return{kind:"radial",rowCount:0,rows:[],nearestRow:()=>-1,depthAt:(t,n)=>Math.hypot(t-e.x,n-e.y),gradientAt:(t,n)=>{let o=t-e.x,r=n-e.y,i=Math.hypot(o,r);return i<1e-9?[0,0]:[o/i,r/i]}}}function Dr(e,t){if(!e.length)return null;let n=0,o=0,r=0;for(let l of e)n+=l.x,o+=l.y,r+=Math.hypot(l.x-t.x,l.y-t.y);let i=e.length;n/=i,o/=i,r/=i;let s=e[0],a=-1;for(let l of e){let m=Math.hypot(l.x-n,l.y-o);m>a&&(a=m,s=l)}let d=s.x-n,f=s.y-o,u=Math.hypot(d,f);u>1e-9?(d/=u,f/=u):(d=1,f=0);let b=[...e].sort((l,m)=>(l.x-n)*d+(l.y-o)*f-((m.x-n)*d+(m.y-o)*f)),c=0;for(let l of b){let m=Math.hypot(l.x-n,l.y-o);m>c&&(c=m)}return{pts:b,cx:n,cy:o,radius:c,depth:r}}function gn(e,t,n){let o=e.pts;if(o.length===1)return Math.hypot(t-o[0].x,n-o[0].y);let r=1/0;for(let i=0;i+1<o.length;i++){let s=o[i],a=o[i+1],d=a.x-s.x,f=a.y-s.y,u=d*d+f*f,b=u>1e-12?((t-s.x)*d+(n-s.y)*f)/u:0;b<0?b=0:b>1&&(b=1);let c=Math.hypot(t-(s.x+b*d),n-(s.y+b*f));c<r&&(r=c)}return r}var tt=8;function Nr(e,t,n){let o=new Array(tt).fill(1/0),r=new Array(tt).fill(-1);for(let u=0;u<e.length;u++){let b=e[u],c=Math.hypot(t-b.cx,n-b.cy)-b.radius;for(let l=0;l<tt;l++)if(c<o[l]){for(let m=tt-1;m>l;m--)o[m]=o[m-1],r[m]=r[m-1];o[l]=c,r[l]=u;break}}let i=new Array(3).fill(1/0),s=new Array(3).fill(-1);for(let u of r){if(u<0)continue;let b=gn(e[u],t,n);for(let c=0;c<3;c++)if(b<i[c]){for(let l=2;l>c;l--)i[l]=i[l-1],s[l]=s[l-1];i[c]=b,s[c]=u;break}}if(s[0]<0)return 0;if(i[0]<1e-6)return e[s[0]].depth;let a=i[0]*2.2,d=0,f=0;for(let u=0;u<3;u++){let b=s[u];if(b<0||i[u]>a)continue;let c=1/(i[u]*i[u]);d+=c*e[b].depth,f+=c}return f>0?d/f:e[s[0]].depth}function Gr(e){let t=(o,r)=>Nr(e,o,r),n=(o,r)=>{let i=1/0,s=-1;for(let a=0;a<e.length;a++){let d=e[a];if(Math.hypot(o-d.cx,r-d.cy)-d.radius>=i)continue;let f=gn(d,o,r);f<i&&(i=f,s=a)}return s};return{kind:"rows",rowCount:e.length,rows:e,nearestRow:n,depthAt:t,gradientAt:(o,r)=>{let i=(t(o+.5,r)-t(o-.5,r))/1,s=(t(o,r+.5)-t(o,r-.5))/(2*.5),a=Math.hypot(i,s);return a<1e-9?[0,0]:[i/a,s/a]}}}function xn(e,t){let n=[];for(let o of e){let r=Dr(o.points,t);r&&n.push(r)}return n.length<2?Fr(t):(n.sort((o,r)=>o.depth-r.depth),Gr(n))}var Rt=Ie(require("polygon-clipping"),1);var In=Ie(require("earcut"),1);var jr=.58,Sn=.01,se=et*1.5*fe,Ur=.5,Xr=.6;function Yr(e,t){let n=e.length,o=[];for(let s=0;s<n;s++){let a=e[Math.max(0,s-1)],d=e[Math.min(n-1,s+1)],f=d.x-a.x,u=d.y-a.y,b=Math.hypot(f,u);if(b<1e-9){o.push([0,0]);continue}f/=b,u/=b,o.push([-u,f])}let r=0;for(let s=0;s<n;s++)r+=(e[s].x-t.x)*o[s][0]+(e[s].y-t.y)*o[s][1];return r<0?o.map(([s,a])=>[-s,-a]):o}function Vr(e,t){if(e.length<2||t<=0)return[...e];let n=[...e],o=(s,a)=>{let d=a.x-s.x,f=a.y-s.y,u=Math.hypot(d,f)||1;return{x:d/u,y:f/u}},r=o(n[1],n[0]),i=o(n[n.length-2],n[n.length-1]);return n.unshift({x:n[0].x+r.x*t,y:n[0].y+r.y*t}),n.push({x:n[n.length-1].x+i.x*t,y:n[n.length-1].y+i.y*t}),n}var Mn=Math.PI/12;function Hr(e){if(e.length<3)return[...e];let t=[...e].sort((i,s)=>i.x-s.x||i.y-s.y),n=(i,s,a)=>(s.x-i.x)*(a.y-i.y)-(s.y-i.y)*(a.x-i.x),o=i=>{let s=[];for(let a of i){for(;s.length>=2&&n(s[s.length-2],s[s.length-1],a)<=0;)s.pop();s.push(a)}return s.pop(),s},r=[...o(t),...o([...t].reverse())];return r.length>=3?r:[...e]}function vn(e,t){if(!e.length||!(t>0))return[];let n=Hr(e),o=(a,d,f,u)=>{let b=f-d;for(;b<0;)b+=Math.PI*2;for(;b>Math.PI*2;)b-=Math.PI*2;let c=Math.max(1,Math.ceil(b/Mn)),l=t/Math.cos(b/c/2);for(let m=0;m<=c;m++){let h=d+b*m/c;u.push({x:a.x+Math.cos(h)*l,y:a.y+Math.sin(h)*l})}};if(n.length<3){let a=0,d=0;for(let l of n)a+=l.x,d+=l.y;a/=n.length||1,d/=n.length||1;let f=0;for(let l of n)f=Math.max(f,Math.hypot(l.x-a,l.y-d));let u=[],b=Math.max(3,Math.ceil(Math.PI*2/Mn)),c=(f+t)/Math.cos(Math.PI/b);for(let l=0;l<b;l++){let m=l/b*Math.PI*2;u.push({x:a+Math.cos(m)*c,y:d+Math.sin(m)*c})}return u}let r=n.length,i=[];for(let a=0;a<r;a++){let d=n[a],f=n[(a+1)%r];i.push(Math.atan2(-(f.x-d.x),f.y-d.y))}let s=[];for(let a=0;a<r;a++)o(n[a],i[(a+r-1)%r],i[a],s);return En(s)}function Kr(e,t,n){if(e.length===1)return Math.hypot(t-e[0].x,n-e[0].y);let o=1/0;for(let r=0;r+1<e.length;r++){let i=e[r],s=e[r+1],a=s.x-i.x,d=s.y-i.y,f=a*a+d*d,u=f>1e-12?((t-i.x)*a+(n-i.y)*d)/f:0;u<0?u=0:u>1&&(u=1);let b=Math.hypot(t-(i.x+u*a),n-(i.y+u*d));b<o&&(o=b)}return o}function nt(e){let t=e.map(r=>{let i=0,s=0;for(let f of r.pts)i+=f.x,s+=f.y;let a=r.pts.length||1;i/=a,s/=a;let d=0;for(let f of r.pts){let u=Math.hypot(f.x-i,f.y-s);u>d&&(d=u)}return{cx:i,cy:s,rad:d}}),n=r=>{let i=r.length;return i<=2?[...r]:[r[Math.floor(i*.25)],r[Math.floor(i*.5)],r[Math.floor(i*.75)]]},o=[];for(let r=0;r<e.length;r++){let i=n(e[r].pts),s=[],a=1/0,d=null;for(let u of i){let b=1/0;for(let c=0;c<e.length;c++){if(c===r||Math.abs(e[c].y-e[r].y)<.001)continue;let l=t[c],m=Math.hypot(u.x-l.cx,u.y-l.cy)-l.rad;if(m>=b&&m>=a)continue;let h=Kr(e[c].pts,u.x,u.y);h<b&&(b=h),e[c].depth<e[r].depth&&h<a&&(a=h,d=e[c].y)}Number.isFinite(b)&&b>0&&s.push(b)}s.sort((u,b)=>u-b);let f=s.length?s[Math.floor(s.length/2)]:1;o.push({pitch:f,belowY:d})}return o}function Rn(e,t,n,o){let r=e[t],i=r.pts.length>=2?[...r.pts]:r.pts.length===1?(()=>{let u=r.pts[0],b=u.x-o.x,c=u.y-o.y,l=Math.hypot(b,c)||1;b/=l,c/=l;let m=Math.max(n[t].pitch,.001)*.5;return[{x:u.x+c*m,y:u.y-b*m},{x:u.x-c*m,y:u.y+b*m}]})():[];if(i.length<2)return null;let s=0,a=0;for(let u=1;u<i.length;u++){let b=Math.hypot(i[u].x-i[u-1].x,i[u].y-i[u-1].y);b>1e-6&&(s+=b,a++)}let d=a>0?s/a:0,f=Vr(i,Math.max(d*Xr,se));return{pts:f,nrm:Yr(f,o),front:Math.max(n[t].pitch*jr,se),back:Math.max(n[t].pitch*Ur,se)}}var Re=1.5,Pn=.3;function It(e,t){if(e.length<3)return e;let n=e[0],o=e[e.length-1],r=o.x-n.x,i=o.y-n.y,s=Math.hypot(r,i),a=-1,d=-1;for(let b=1;b<e.length-1;b++){let c=e[b],l=s>1e-12?Math.abs((c.x-n.x)*i-(c.y-n.y)*r)/s:Math.hypot(c.x-n.x,c.y-n.y);l>a&&(a=l,d=b)}if(a<=t||d<0)return[n,o];let f=It(e.slice(0,d+1),t),u=It(e.slice(d),t);return[...f.slice(0,-1),...u]}function Cn(e,t){if(e.length<4)return e;let n=It([...e,e[0]],t);return n.pop(),n.length>=3?n:e}function An(e,t,n){if(e.length<2)return[];let o=n??nt(e),r=new Map;for(let s=0;s<e.length;s++){let a=r.get(e[s].blockId);a?a.push(s):r.set(e[s].blockId,[s])}let i=[];for(let[,s]of r){let a=[];for(let g of s){let S=e[g].patch;S&&S.length>=3?i.push({outline:[...S],holes:[],topY:e[g].y}):a.push(g)}if(!a.length)continue;a.sort((g,S)=>e[g].depth-e[S].depth);let f=a.map(g=>Rn(e,g,o,t)).filter(g=>g!==null);if(!f.length)continue;let u=(g,S)=>({x:g.pts[S].x-g.nrm[S][0]*(g.front+Re),y:g.pts[S].y-g.nrm[S][1]*(g.front+Re)}),b=(g,S)=>({x:g.pts[S].x+g.nrm[S][0]*(g.back+Re),y:g.pts[S].y+g.nrm[S][1]*(g.back+Re)}),c=f[0],l=f[f.length-1],m=[];for(let g=0;g<c.pts.length;g++)m.push(u(c,g));for(let g of f)m.push(b(g,g.pts.length-1));for(let g=l.pts.length-1;g>=0;g--)m.push(b(l,g));for(let g=f.length-1;g>=0;g--)m.push(u(f[g],0));let h=En(m),p=1/0;for(let g of a)e[g].y<p&&(p=e[g].y);if(!Number.isFinite(p))continue;if(h.length>=3&&Math.abs(he(h))>1e-6&&f.every(g=>{let S=g.pts[Math.floor(g.pts.length/2)];return Le(h,S.x,S.y)})){i.push({outline:Cn(h,Pn),holes:[],topY:p});continue}for(let g of zr(f))i.push({outline:g,holes:[],topY:p})}return i}function zr(e){let t=[];for(let n of e){let o=[],r=[],i=n.front+Re,s=n.back+Re;for(let d=0;d<n.pts.length;d++){let f=n.pts[d],u=n.nrm[d];o.push([f.x-u[0]*i,f.y-u[1]*i]),r.push([f.x+u[0]*s,f.y+u[1]*s])}let a=[...o,...r.reverse()];a.length<3||(a.push(a[0]),t.push([a]))}if(!t.length)return[];try{let n=Rt.default.union(t[0],...t.slice(1)),o=[];for(let r of n){if(!r.length||r[0].length<4)continue;let i=r[0].map(([d,f])=>({x:d,y:f})),s=i[0],a=i[i.length-1];i.length>1&&Math.abs(s.x-a.x)<1e-9&&Math.abs(s.y-a.y)<1e-9&&i.pop(),i.length>=3&&o.push(Cn(i,Pn))}return o}catch{return[]}}function En(e){let t=[];for(let n of e){let o=t[t.length-1];o&&Math.hypot(n.x-o.x,n.y-o.y)<1e-9||t.push(n)}for(;t.length>2&&Math.hypot(t[0].x-t[t.length-1].x,t[0].y-t[t.length-1].y)<1e-9;)t.pop();return t}var vt=class{constructor(t){this.minX=1/0;this.minY=1/0;this.maxX=-1/0;this.maxY=-1/0;this.rings=t;for(let n of t)for(let o of n)o.x<this.minX&&(this.minX=o.x),o.y<this.minY&&(this.minY=o.y),o.x>this.maxX&&(this.maxX=o.x),o.y>this.maxY&&(this.maxY=o.y)}containsAll(t){for(let n of t)if(n.x<this.minX||n.x>this.maxX||n.y<this.minY||n.y>this.maxY)return!1;for(let n of this.rings){let o=!0;for(let r of t)if(!Le(n,r.x,r.y)){o=!1;break}if(o)return!0}return!1}};function wn(e,t,n,o,r,i){if(o.length<3)return;if(n.containsAll(o)){let f=[0,1,0],u=o[0];for(let b=1;b+1<o.length;b++){let c=o[b],l=o[b+1];e.tri([u.x*R,r,u.y*R],[c.x*R,r,c.y*R],[l.x*R,r,l.y*R],f,i)}return}let s=o.map(f=>[f.x,f.y]);s.push(s[0]);let a;try{a=Rt.default.intersection([s],t)}catch{return}let d=[0,1,0];for(let f of a){if(!f.length||f[0].length<4)continue;let u=f[0],b=[],c=[];for(let m=0;m<u.length-1;m++)b.push(u[m][0],u[m][1]),c.push([u[m][0],u[m][1]]);if(c.length<3)continue;let l=(0,In.default)(b,void 0,2);for(let m=0;m<l.length;m+=3){let h=c[l[m]],p=c[l[m+1]],y=c[l[m+2]];e.tri([h[0]*R,r,h[1]*R],[p[0]*R,r,p[1]*R],[y[0]*R,r,y[1]*R],d,i)}}}function _n(e,t,n,o,r,i,s){if(t.length<2)return;let a=s??nt(t),d=[0,1,0],f=i&&i.length>=3?[[...i.map(l=>[l.x,l.y]),[i[0].x,i[0].y]]]:null,u=i&&i.length>=3?new vt([[...i]]):null,b=l=>{e.setMaterial(2),l(),e.setMaterial(0)},c=l=>{e.setMaterial(3),l(),e.setMaterial(0)};for(let l=0;l<t.length;l++){let m=t[l];if(m.patch&&m.patch.length>=3){let _=[...m.patch],M=a[l].belowY??o;if(c(()=>{if(f&&u)wn(e,f,u,_,m.y,r.tread);else{let v=_[0];for(let k=1;k+1<_.length;k++){let B=_[k],D=_[k+1];e.tri([v.x*R,m.y,v.y*R],[B.x*R,m.y,B.y*R],[D.x*R,m.y,D.y*R],d,r.tread)}}}),m.y>M+Sn){let v=0,k=0;for(let B of _)v+=B.x,k+=B.y;v/=_.length,k/=_.length,b(()=>{for(let B=0;B<_.length;B++){let D=_[B],U=_[(B+1)%_.length],P=U.x-D.x,w=U.y-D.y,L=Math.hypot(P,w);if(L<1e-6)continue;let T=w/L,I=-P/L;(D.x-v)*T+(D.y-k)*I<0&&(T=-T,I=-I);let F=[T,0,I],A=[D.x*R,m.y,D.y*R],C=[U.x*R,m.y,U.y*R],E=[D.x*R,M,D.y*R],N=[U.x*R,M,U.y*R];e.tri(A,C,N,F,r.riser),e.tri(A,N,E,F,r.riser)}})}continue}let h=Rn(t,l,a,n);if(!h)continue;let{pts:p,nrm:y,front:g,back:S}=h,x=a[l].belowY??o;for(let _=0;_+1<p.length;_++){let M=p[_],v=p[_+1],k=y[_],B=y[_+1];if(Math.hypot(v.x-M.x,v.y-M.y)<1e-6||k[0]===0&&k[1]===0||B[0]===0&&B[1]===0)continue;let D=[(M.x-k[0]*g)*R,m.y,(M.y-k[1]*g)*R],U=[(v.x-B[0]*g)*R,m.y,(v.y-B[1]*g)*R],P=[(M.x+k[0]*S)*R,m.y,(M.y+k[1]*S)*R],w=[(v.x+B[0]*S)*R,m.y,(v.y+B[1]*S)*R];if(c(()=>{f&&u?wn(e,f,u,[{x:M.x-k[0]*g,y:M.y-k[1]*g},{x:v.x-B[0]*g,y:v.y-B[1]*g},{x:v.x+B[0]*S,y:v.y+B[1]*S},{x:M.x+k[0]*S,y:M.y+k[1]*S}],m.y,r.tread):(e.tri(D,U,w,d,r.tread),e.tri(D,w,P,d,r.tread))}),m.y>x+Sn){let L=[D[0],x,D[2]],T=[U[0],x,U[2]],I=[-k[0],0,-k[1]];b(()=>{e.tri(D,U,T,I,r.riser),e.tri(D,T,L,I,r.riser)})}}}}function kn(e){let t=1/0,n=1/0,o=-1/0,r=-1/0,i=!1;for(let s of e)!Number.isFinite(s.x)||!Number.isFinite(s.y)||(i=!0,s.x<t&&(t=s.x),s.y<n&&(n=s.y),s.x>o&&(o=s.x),s.y>r&&(r=s.y));return i?{minX:t,minY:n,maxX:o,maxY:r}:null}function ot(e,t){return e.minX<=t.maxX&&t.minX<=e.maxX&&e.minY<=t.maxY&&t.minY<=e.maxY}var Pt=Ie(require("polygon-clipping"),1);function Wr(e,t){let n=e.eventConfigurationIds;return!n?.length||!!t&&n.includes(t)}function Tn(e,t){return e.filter(n=>n.type!=="shape"||Wr(n,t))}function Ln(e,t){let n=e.focalPoint??{x:0,y:0};return e.floors?.length?e.floors.map((o,r)=>({objects:Tn(o.objects,t),focal:{x:(o.focalPoint??n).x,y:(o.focalPoint??n).y},baseHeightM:o.baseHeightM??0,index:r})):[{objects:Tn(e.objects,t),focal:n,baseHeightM:0,index:0}]}var Zr={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Pe(e){return kn(e)??Zr}function On(e,t){let n=qe(e.outline,se),o=Pe(n),r=t.filter(s=>s!==e&&s.outline&&s.outline.length>=3&&ot(o,Pe(s.outline)));if(!r.length)return[n];let i=s=>{let a=s.map(d=>[d.x,d.y]);return a.push(a[0]),a};try{let s=Pt.default.difference([i(n)],...r.map(d=>[i(d.outline)])),a=[];for(let d of s){if(!d.length)continue;let f=d[0].map(([u,b])=>({x:u,y:b}));if(f.length>1){let u=f[0],b=f[f.length-1];Math.abs(u.x-b.x)<1e-9&&Math.abs(u.y-b.y)<1e-9&&f.pop()}f.length>=3&&a.push(f)}return a.length?a:[n]}catch{return[n]}}function Bn(e,t){if(!t.length)return e;let n=i=>{let s=i.map(a=>[a.x,a.y]);return s.push(s[0]),s},o=t.map(i=>[n(i)]),r=[];for(let i of e){let s;try{s=Pt.default.intersection([n(i.outline)],o.flat())}catch{r.push(i);continue}for(let a of s){if(!a.length)continue;let d=a[0].map(([f,u])=>({x:f,y:u}));if(d.length>1){let f=d[0],u=d[d.length-1];Math.abs(f.x-u.x)<1e-9&&Math.abs(f.y-u.y)<1e-9&&d.pop()}d.length>=3&&r.push({outline:d,holes:[],topY:i.topY})}}return r.length?r:e}var Qr=.05,Fn=.05,$r=.15,Ct=25;function Dn(e,t,n){let o=new Map,r=new Array(t.length).fill(null),i=new Float64Array(t.length),s=new Array(t.length).fill(void 0),a=new Array(t.length).fill(void 0),d=new Map,f=[],u=new Set;for(let c=0;c<e.length;c+=1){let l=e[c];for(let m of l.objects){if(m.type==="table"&&u.add(m.id),m.type!=="section"||!m.outline||m.outline.length<3)continue;let h=qe(m.outline,se);d.set(m.id,{section:m,unit:l,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),f.push({id:m.id,floorIndex:c,box:Pe(h),section:m,unit:l,outline:h})}}let b=new Map;for(let c of f){let l=b.get(c.floorIndex);l?l.push(c):b.set(c.floorIndex,[c])}for(let c=0;c<t.length;c++){let l=t[c],m=n?b.get(n[c])??[]:f,h=l.sectionId?m.find(y=>y.id===l.sectionId)??m.find(y=>y.section.logicalSectionId===l.sectionId&&be({x:l.x,y:l.y},y.outline,y.section.holes)):void 0,p=h?[h]:m;for(let y of p){if(n&&y.floorIndex!==n[c]||!h&&(l.x<y.box.minX||l.x>y.box.maxX||l.y<y.box.minY||l.y>y.box.maxY||!be({x:l.x,y:l.y},y.outline,y.section.holes)))continue;r[c]=y.id;let g=d.get(y.id);g.hasSeats=!0;let S=l.focalPoint??y.unit.focal,x=Math.hypot(l.x-S.x,l.y-S.y);x<g.frontU&&(g.frontU=x),g.seatIndices.push(c);let _=l.rowId||`__seat-${c}`,M=g.rows.get(_);M?M.push({x:l.x,y:l.y}):g.rows.set(_,[{x:l.x,y:l.y}]);break}}for(let[c,l]of d){let m=He(l.section,{floorBaseHeightM:l.unit.baseHeightM}),h=l.unit.baseHeightM,p=m.rake>0?Math.tan(m.rake*Math.PI/180):0,y=m.rake<=.01&&m.height<=h+.001,g=l.section.surfaceKind,S=g==="flat"?!0:g==="rakedRows"&&m.rake>.01?!1:y,x=l.hasSeats?Ke(c,t,l.seatIndices,l.unit.focal):{sectionId:c,rows:[],blockCount:0},M=x.rows.length<2?xn([...l.rows.values()].map(A=>({points:A})),l.unit.focal):null,v=1/0;if(M){if(l.hasSeats)for(let A of l.rows.values())for(let C of A){let E=M.depthAt(C.x,C.y);E<v&&(v=E)}if(!l.hasSeats||!Number.isFinite(v)){v=1/0;for(let A of l.section.outline){let C=M.depthAt(A.x,A.y);C<v&&(v=C)}}}let k=h+Qr,B=Math.max(k,m.height),D=A=>{let C=Math.max(0,A-v)*re,E=Math.min(C*p,Ct);return Math.max(k,m.height+E)},U=A=>{let C=Math.max(0,A)*re,E=Math.min(C*p,Ct);return Math.max(k,m.height+E)},P=S?[]:x.rows.map(A=>({pts:A.pts,y:U(A.blockDepth),depth:A.blockDepth,blockId:A.blockId,...u.has(A.id)?{patch:vn(A.pts,se)}:{}})),w=P.length?P[0].y:B,L=P.map(A=>{let C=A.patch&&A.patch.length>=3?A.patch:A.pts,E=0,N=0;for(let G of C)E+=G.x,N+=G.y;let j=C.length||1;E/=j,N/=j;let X=0;for(let G of C){let Y=Math.hypot(G.x-E,G.y-N);Y>X&&(X=Y)}return{cx:E,cy:N,rad:X}}),T=S?()=>B:P.length>=2?(A,C)=>{let E=1/0,N=w;for(let j=0;j<P.length;j++){let X=L[j];if(Math.hypot(A-X.cx,C-X.cy)-X.rad>=E)continue;let G=P[j].patch,Y=G&&G.length>=3?Le(G,A,C)?0:ve(G,A,C):ve(P[j].pts,A,C);Y<E&&(E=Y,N=P[j].y)}return N}:(A,C)=>M?D(M.depthAt(A,C)):B,I=[0,1,0],F=P.length>=2||S?()=>I:(A,C)=>{if(!M)return I;let E=M.depthAt(A,C);if(E<=v)return I;let N=(E-v)*re;if(N*p>=Ct||m.height+N*p<=k)return I;let[j,X]=M.gradientAt(A,C);if(j===0&&X===0)return I;let G=1/Math.hypot(p,1);return[-j*p*G,G,-X*p*G]};if(!S)for(let A of x.rows){let C=U(A.blockDepth);for(let E of A.seatIndices)s[E]=C}for(let A of x.rows){let C=[];for(let G=1;G<A.pts.length;G++){let Y=Math.hypot(A.pts[G].x-A.pts[G-1].x,A.pts[G].y-A.pts[G-1].y);Y>1e-6&&C.push(Y)}C.sort((G,Y)=>G-Y);let E=C.length?C[Math.floor(C.length/2)]:1/0,N=1/0,j=A.pts[Math.floor(A.pts.length/2)];if(j)for(let G of x.rows){if(G===A||G.blockId!==A.blockId)continue;let Y=ve(G.pts,j.x,j.y);Y>1e-6&&Y<N&&(N=Y)}let X=Math.min(E,Math.max(N,E*.5));if(Number.isFinite(X)&&X>0)for(let G of A.seatIndices)a[G]=X}o.set(c,{sectionId:c,deckAt:T,normalAt:F,flat:S,bottomY:h,rowLevels:P,landingY:w})}for(let c=0;c<t.length;c++){let l=r[c],m=t[c];if(l){let p=s[c];i[c]=(p??o.get(l).deckAt(m.x,m.y))+$r;continue}let h=m.eyeHeightM;i[c]=Number.isFinite(h)?Math.max(0,h-me):0}return{bySection:o,seatOwner:r,seatDeckY:c=>i[c],seatPitchU:c=>a[c]}}var $={top:1,wallBottom:.5,bottomCap:.4};function ce(e,t){if(!e)return t;let n=ie(Te(e,.4),.62);return te(t,n,.72)}function Nn(e,t){let n=new Map;for(let i of e.categories??[])n.set(i.key,i.color);let o=new Map;for(let i of t){if(!i.sectionId)continue;let s=o.get(i.sectionId);s||(s=new Map,o.set(i.sectionId,s)),s.set(i.categoryKey,(s.get(i.categoryKey)??0)+1)}let r=new Map;for(let[i,s]of o){let a=0,d=0,f=0,u=0;for(let[b,c]of s){let l=W(n.get(b));l&&(a+=l[0]*c,d+=l[1]*c,f+=l[2]*c,u+=c)}u>0&&r.set(i,[a/u,d/u,f/u])}return r}function Gn(e,t){return W(e.color)??t.get(e.logicalSectionId??e.id)??null}var ya=Math.PI*2;function jn(e){return e==="pitch-football"||e==="rink-hockey"||e==="track-athletics"||e==="oval-cricket"}var Un=Ie(require("polygon-clipping"),1);function qr(e,t){return e===void 0||t===void 0?!0:Math.abs(e-t)<.001}var rt=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(t,n){let o=t.map(d=>[d.x,d.y]);if(o.length<3)return[];o.push(o[0]);let r=Pe(t),i=this.rings.filter((d,f)=>ot(r,this.boxes[f])&&qr(n,this.levels[f])),s=[[o]];if(i.length)try{s=Un.default.difference([o],...i).map(f=>f.map(u=>u.map(([b,c])=>[b,c])))}catch{s=[[o]]}this.rings.push([o]),this.boxes.push(r),this.levels.push(n);let a=[];for(let d of s){if(!d.length)continue;let f=d[0].map(([u,b])=>({x:u,y:b}));if(f.length>1){let u=f[0],b=f[f.length-1];Math.abs(u.x-b.x)<1e-9&&Math.abs(u.y-b.y)<1e-9&&f.pop()}f.length>=3&&a.push(f)}return a}};function Jr(e,t){if(!t)return e;let n=1/0,o=-1/0,r=1/0,i=-1/0;for(let b of e)n=Math.min(n,b.x),o=Math.max(o,b.x),r=Math.min(r,b.y),i=Math.max(i,b.y);let s=(n+o)/2,a=(r+i)/2,d=t*Math.PI/180,f=Math.cos(d),u=Math.sin(d);return e.map(b=>{let c=b.x-s,l=b.y-a;return{x:s+c*f-l*u,y:a+c*u+l*f}})}function ye(e){let t=null;if(e.kind==="polygon"&&e.points&&e.points.length>=3&&(t=e.points),e.kind==="rect"&&e.width&&e.height&&(t=Fe(e.x??0,e.y??0,e.width,e.height)),e.kind==="ellipse"&&e.width&&e.height){let n=(e.x??0)+e.width/2,o=(e.y??0)+e.height/2;t=Je(n,o,e.width/2,e.height/2)}return t?Jr(t,e.rotation):null}function De(e){let t=e.role??"",n={stage:{kind:"stage",heightM:1},entrance:{kind:"portal",heightM:2.7},exit:{kind:"portal",heightM:2.7},screen:{kind:"solid",heightM:6},wall:{kind:"solid",heightM:2.8},rail:{kind:"solid",heightM:1.1},suite:{kind:"suite",heightM:3},obstruction:{kind:"solid",heightM:4.5},sound:{kind:"solid",heightM:1.45},restroom:{kind:"solid",heightM:2.4},bar:{kind:"solid",heightM:1.1},concession:{kind:"solid",heightM:1.1},coat:{kind:"solid",heightM:1.1},goal:{kind:"portal",heightM:1.8}},o=t==="stage"&&jn(e.stageKind)?{kind:"stage",heightM:.06}:n[t]??{kind:"plate",heightM:.25};return{...o,heightM:e.heightM??o.heightM}}var ei=.08;function Xn(e,t){let n=ye(e),o=De(e),r=o.heightM;if(!n||o.kind!=="plate"&&o.kind!=="stage")return r;let i=1/0,s=1/0,a=-1/0,d=-1/0;for(let u of n)i=Math.min(i,u.x),s=Math.min(s,u.y),a=Math.max(a,u.x),d=Math.max(d,u.y);let f=r;for(let u of t)a>u.minX&&i<u.maxX&&d>u.minY&&s<u.maxY&&f<=u.topOffsetM+1e-6&&(f=u.topOffsetM+ei);return t.push({minX:i,minY:s,maxX:a,maxY:d,topOffsetM:f}),f}function de(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function Yn(e){if(e.length!==4)return e;let t=Math.hypot(e[1].x-e[0].x,e[1].y-e[0].y),n=Math.hypot(e[2].x-e[1].x,e[2].y-e[1].y);return t>=n?e:[e[1],e[2],e[3],e[0]]}function Ne(e,t,n){return[de(e[0],e[1],t),de(e[0],e[1],n),de(e[3],e[2],n),de(e[3],e[2],t)]}function Vn(e,t,n){return[de(e[0],e[3],t),de(e[1],e[2],t),de(e[1],e[2],n),de(e[0],e[3],n)]}function ue(e,t,n,o,r,i){J(e,t,void 0,()=>n,o,r,i,$)}var At=2.4,ti=.75,ni=.15;function Ge(e){if(e.points&&e.points.length>=3)return e.points;let{center:t,width:n,height:o,rotation:r}=e;if(!n||!o)return null;let i=(r??0)*Math.PI/180,s=Math.cos(i),a=Math.sin(i),d=n/2,f=o/2;return[[-d,-f],[d,-f],[d,f],[-d,f]].map(([u,b])=>({x:t.x+u*s-b*a,y:t.y+u*a+b*s}))}function Hn(e,t,n,o,r){let i=Ge(t);i&&J(e,i,void 0,()=>n+At,n,ce(o,r.boothTop),r.boothWall,$)}function Et(e){if(e.shape==="round"){let u=e.radius;return u?Je(e.center.x,e.center.y,u,u,24):null}let{width:t,height:n,rotation:o,center:r}=e;if(!t||!n)return null;let i=(o??0)*Math.PI/180,s=Math.cos(i),a=Math.sin(i),d=t/2,f=n/2;return[[-d,-f],[d,-f],[d,f],[-d,f]].map(([u,b])=>({x:r.x+u*s-b*a,y:r.y+u*a+b*s}))}function Kn(e,t,n,o,r){let i=Et(t);i&&J(e,i,void 0,()=>n+ti,n,ce(o,r.tableTop),r.tableWall,$)}function zn(e,t,n,o,r,i,s,a){let d=ye(t);if(!d)return;let f=a?a.kind==="stage":t.role==="stage",u=a?a.kind==="screen":t.role==="screen",b=a?{kind:f?"stage":"solid",heightM:a.topY-a.baseY}:De(t),c=a?.baseY??n,l=a?.topY??n+o;if(f&&s){let g=1/0,S=-1/0,x=1/0,_=-1/0;for(let M of d)M.x<g&&(g=M.x),M.x>S&&(S=M.x),M.y<x&&(x=M.y),M.y>_&&(_=M.y);s.push({cx:(g+S)/2*R,cz:(x+_)/2*R,y:l,halfX:Math.max((S-g)/2*R,.5),halfZ:Math.max((_-x)/2*R,.5)})}let m=W(t.fill),h=f&&m?te(r.stageTop,ie(Te(m,.18),.9),.9):ce(m,f?r.stageTop:r.decorTop),p=u?m:null,y=f?m?te(r.stageWall,ie(m,.58),.82):r.stageWall:u?p?te(ie(p,1.42),[.24,.46,.82],.08):[.24,.46,.82]:ce(W(t.fill),r.decorWall);if(b.kind==="portal"&&d.length===4){let g=Yn(d);ue(e,Ne(g,0,.16),l,c,h,y),ue(e,Ne(g,.84,1),l,c,h,y),ue(e,g,l,Math.max(c,l-.35),h,y);return}if(b.kind==="suite"&&d.length===4){let g=d.map((_,M)=>{let v=d[(M+1)%4],k=(_.x+v.x)/2,B=(_.y+v.y)/2;return Math.hypot(k-i.x,B-i.y)}),S=g.indexOf(Math.min(...g)),x=[0,1,2,3].map(_=>d[(S+_)%4]);ue(e,Ne(x,0,.08),l,c,h,y),ue(e,Ne(x,.92,1),l,c,h,y),ue(e,Vn(x,.88,1),l,c,h,y),ue(e,x,l,Math.max(c,l-.18),h,y);return}ue(e,d,l,c,h,y)}function _t(e){let{x:t,y:n,width:o,height:r}=e;if(!o||!r)return null;let i=t+o/2,s=n+r/2,a=(e.rotation??0)*Math.PI/180,d=Math.cos(a),f=Math.sin(a),u=o/2,b=r/2;return[[-u,-b],[u,-b],[u,b],[-u,b]].map(([c,l])=>({x:i+c*d-l*f,y:s+c*f+l*d}))}function oi(e){if(!e||!e.startsWith("data:image/svg+xml"))return null;let t=e.slice(e.indexOf(",")+1);if(/;base64/i.test(e.slice(0,e.indexOf(","))))try{t=atob(t)}catch{return null}else try{t=decodeURIComponent(t)}catch{}let n=t.match(/<(?:rect|path)\b[^>]*\bfill="([^"]+)"/i);if(!n)return null;let o=n[1].trim();if(o==="none"||o==="transparent")return null;let r=o.match(/^url\(#([^)]+)\)$/);if(!r)return W(o);let i=t.match(new RegExp(`<(?:linear|radial)Gradient\\b[^>]*\\bid="${r[1]}"[^>]*>([\\s\\S]*?)</(?:linear|radial)Gradient>`,"i"));if(!i)return null;let s=[];for(let a of i[1].matchAll(/stop-color="([^"]+)"/gi)){let d=W(a[1].trim());d&&s.push(d)}return s.length?s.reduce((a,d,f)=>te(a,d,1/(f+1)),s[0]):null}function Wn(e,t,n,o){if(t.layer==="foreground")return;let r=_t(t);if(!r)return;let i=n+ni,s=ce(oi(t.href),o.decorTop),a=Math.max(0,Math.min(1,t.opacity??1));a<1&&(s=te(o.ground,s,a)),J(e,r,void 0,()=>i,n,s,te(s,o.decorWall,.5),$)}function Zn(e,t,n,o,r){if(!t.points||t.points.length<3)return;let i=ce(o,r.gaTop);J(e,t.points,t.holes,()=>n+.15,n,i,r.gaWall,$)}var ri=Math.PI/180,K=96,ii=6,si=60,ai=150,Qn=.2,ci=.35;function ui(e,t){let n=Math.atan2(t.x-e.x,t.y-e.y)/ri;return n<0?n+360:n}function it(e){if(!e.length)return NaN;let t=[...e].sort((n,o)=>n-o);return t[Math.floor(t.length/2)]}function st(e,t,n=2){let o=e.length,r=new Float64Array(o);for(let i=0;i<o;i++){let s=0,a=0;for(let d=-n;d<=n;d++){let f=i+d;if(t)f=(f%o+o)%o;else if(f<0||f>=o)continue;s+=e[f],a++}r[i]=s/a}return r}function $n(e,t){let n=e.filter(c=>c.rows.length>=1);if(n.length<1)return null;let o=[],r=0,i=0,s=0;for(let c of n)for(let l of c.rows){for(let m of l.pts)r+=m.x,i+=m.y,s++;if(l.pts.length>=4){let m=yt(l.pts);m&&Number.isFinite(m.cx)&&Number.isFinite(m.cy)&&o.push({x:m.cx,y:m.cy})}}if(!s)return null;let a={x:r/s,y:i/s},d=a;if(o.length>=8){let c=it(o.map(y=>y.x)),l=it(o.map(y=>y.y)),m=0;for(let y of n)for(let g of y.rows)for(let S of g.pts){let x=Math.hypot(S.x-a.x,S.y-a.y);x>m&&(m=x)}let h=0,p=m*.2;for(let y of n)for(let g of y.rows)for(let S of g.pts)Math.hypot(S.x-c,S.y-l)<p&&h++;Math.hypot(c-a.x,l-a.y)<=m&&h/s<.01&&(d={x:c,y:l})}let f=[];for(let c of n){let l={sectionId:c.sectionId,rMin:1/0,rMax:-1/0,samples:[]};for(let m of c.rows)for(let h of m.pts){let p=Math.hypot(h.x-d.x,h.y-d.y),y=Math.min(K-1,Math.floor(ui(d,h)/(360/K)));l.samples.push({r:p,bin:y,levelM:m.levelM}),p<l.rMin&&(l.rMin=p),p>l.rMax&&(l.rMax=p)}l.samples.length&&f.push(l)}if(!f.length)return null;f.sort((c,l)=>c.rMin+c.rMax-(l.rMin+l.rMax));let u=[];for(let c of f){let l=!1;for(let m of u){let h=Math.min(c.rMax,m.rMax)-Math.max(c.rMin,m.rMin),p=Math.min(c.rMax-c.rMin,m.rMax-m.rMin);if(p>1e-9&&h>=ci*p){m.members.push(c),m.rMin=Math.min(m.rMin,c.rMin),m.rMax=Math.max(m.rMax,c.rMax),l=!0;break}}l||u.push({members:[c],rMin:c.rMin,rMax:c.rMax})}let b=[];for(let c of u){let l=new Array(K).fill(null);for(let w of c.members)for(let L of w.samples){let T=l[L.bin];T||(T={samples:[]},l[L.bin]=T),T.samples.push({r:L.r,levelM:L.levelM})}let m=l.map(w=>!!w);if(!m.filter(Boolean).length)continue;let p=[],y=[];for(let w of l){if(!w)continue;let L=1/0,T=-1/0;for(let I of w.samples)I.r<L&&(L=I.r),I.r>T&&(T=I.r);p.push(L),y.push(T)}let g=it(p),S=it(y);if(!(g>=Qn*S)||!(S>0))continue;let x=[...p].sort((w,L)=>w-L);if(!(x[Math.floor(x.length*.1)]>=Qn*S))continue;let M=l.map(w=>{if(!w)return null;let L=[...w.samples].sort((j,X)=>j.r-X.r),T=L[0].r,I=L[L.length-1].r,F=L[0].levelM,A=-1/0;for(let j of L)j.levelM>A&&(A=j.levelM);let C=[];for(let j of L){let X={r:j.r,l:j.levelM};for(;C.length&&Math.abs(C[C.length-1].r-X.r)<1e-9;){if(C[C.length-1].l<=X.l){X.skip=!0;break}C.pop()}if(!X.skip){for(;C.length>=2;){let G=C[C.length-2],Y=C[C.length-1];if((Y.r-G.r)*(X.l-G.l)-(Y.l-G.l)*(X.r-G.r)<=0)C.pop();else break}C.push(X)}}let E=C.map(j=>j.r),N=C.map(j=>j.l);return{inner:T,outer:I,front:F,top:A,profile:{rs:E,ls:N}}}),v=m.slice();for(let w=0;w<K;w++){if(v[w])continue;let L=-1,T=-1,I=0;for(let O=1;O<=K;O++){let V=(w-O+K*2)%K;if(v[V]){L=V;break}}for(let O=1;O<=K;O++){let V=(w+O)%K;if(v[V]){T=V,I=O;break}}if(L<0||T<0)continue;let F=0;for(let O=1;O<=K;O++){let V=(w-O+K*2)%K;if(m[V]){F=O;break}}if(F-1+I>ii)continue;let C=M[L],E=M[T],N=F/(F+I),j=C.inner+(E.inner-C.inner)*N,X=C.outer+(E.outer-C.outer)*N,G=C.front+(E.front-C.front)*N,Y=C.top+(E.top-C.top)*N;M[w]={inner:j,outer:X,front:G,top:Y,profile:{rs:[j,X],ls:[G,Y]}}}for(let w=0;w<K;w++)M[w]&&(v[w]=!0);let k=360/K,B=[],D=v.filter(Boolean).length,U=[];if(D===K)U.push({start:0,len:K});else{let w=0;for(;v[w];)w=(w+1)%K;let L=-1;for(let T=0;T<=K;T++){let I=(w+T)%K,F=T<K&&v[I];if(F&&L<0)L=I;else if(!F&&L>=0){let A=(I-L+K)%K||K;U.push({start:L,len:A}),L=-1}}}for(let w of U){if(w.len*k<si&&w.len<K)continue;let L=w.len===K,T=new Float64Array(w.len),I=new Float64Array(w.len),F=new Float64Array(w.len),A=new Float64Array(w.len),C=[];for(let O=0;O<w.len;O++){let V=M[(w.start+O)%K];T[O]=V.inner,I[O]=V.outer,F[O]=V.front,A[O]=V.top,C.push(V.profile??{rs:[V.inner,V.outer],ls:[V.front,V.top]})}let E=st(T,L),N=st(I,L),j=st(F,L),X=st(A,L);for(let O=0;O<w.len;O++)E[O]>T[O]&&(E[O]=T[O]),N[O]<I[O]&&(N[O]=I[O]),E[O]>N[O]-1e-6&&(E[O]=Math.max(0,N[O]-1e-6)),X[O]<j[O]&&(X[O]=j[O]);let G={startBin:w.start,binCount:w.len,closed:L,innerR:E,outerR:N,frontLevelM:j,topLevelM:X,profiles:C},Y=(O,V,H)=>{let Q=C[O],Z=Q.rs,z=Q.ls;if(V<=Z[0]){z[0]>H&&(z[0]=H);return}if(V>=Z[Z.length-1]){z[z.length-1]>H&&(z[z.length-1]=H);return}for(let q=0;q+1<Z.length;q++)if(V<=Z[q+1]){z[q]>H&&(z[q]=H),z[q+1]>H&&(z[q+1]=H);return}};for(let O=0;O<w.len;O++){let V=l[(w.start+O)%K];if(V)for(let H of V.samples){Y(O,H.r,H.levelM);let Q=L?(O-1+w.len)%w.len:O-1,Z=L?(O+1)%w.len:O+1;Q>=0&&Y(Q,H.r,H.levelM),Z<w.len&&Y(Z,H.r,H.levelM)}}B.push(G)}B.reduce((w,L)=>w+L.binCount*k,0)<ai||b.push({arcs:B,sectionIds:c.members.map(w=>w.sectionId),innerRMedian:g,outerRMedian:S})}if(!b.length)return null;if(b.sort((c,l)=>c.innerRMedian-l.innerRMedian),t){let c=b[b.length-1].outerRMedian;if(Math.hypot(t.x-d.x,t.y-d.y)>.9*c)return null}return{centre:d,binCount:K,binStepDeg:360/K,rings:b}}function qn(e,t,n,o){let r=e.binStepDeg,i=n/r-.5-t.startBin;i=(i%e.binCount+e.binCount)%e.binCount,i>t.binCount-1&&(t.closed?i=i-t.binCount<t.binCount-i?0:t.binCount-1:i=i-(t.binCount-1)<e.binCount-i?t.binCount-1:0);let s=Math.floor(i),a=t.closed?(s+1)%t.binCount:Math.min(t.binCount-1,s+1),d=i-s,f=u=>{let b=t.profiles[u],c=b.rs,l=b.ls;if(o<=c[0])return l[0];if(o>=c[c.length-1])return l[l.length-1];for(let m=0;m+1<c.length;m++)if(o<=c[m+1]){let h=c[m+1]-c[m],p=h>1e-9?(o-c[m])/h:0;return l[m]+(l[m+1]-l[m])*p}return l[l.length-1]};return f(s)*(1-d)+f(a)*d}var li=.25,fi=1.2,mi=.6,di=.45,bi=2.3,hi=Math.PI/180;function ge(e,t,n){let o=n*hi;return{x:e.x+t*Math.sin(o),y:e.y+t*Math.cos(o)}}function pi(e,t){let n=t.rings[t.rings.length-1];if(!n)return!1;let o=n.outerRMedian*.85;for(let r of e){if(r.role!=="wall")continue;let i=r.points&&r.points.length>=2?r.points:r.x!==void 0&&r.y!==void 0&&r.width!==void 0&&r.height!==void 0?[{x:r.x,y:r.y},{x:r.x+r.width,y:r.y},{x:r.x+r.width,y:r.y+r.height},{x:r.x,y:r.y+r.height}]:[];if(i.length<2)continue;let s=0;for(let a of i)Math.hypot(a.x-t.centre.x,a.y-t.centre.y)>=o&&s++;if(s>=i.length/2)return!0}return!1}var yi=24;function gi(e,t,n,o,r,i,s,a){let d=n.binCount,f=yi,u=re,b=i+.02,c=[];for(let P=0;P<d;P++){let w=(n.startBin+P+.5)*t.binStepDeg,L=new Float64Array(f+1);for(let T=0;T<=f;T++){let I=o[P]+(r[P]-o[P])*T/f;L[T]=Math.max(b,qn(t,n,w,I)-li)}c.push(L)}let l=[s.bandTop[0]*a.top,s.bandTop[1]*a.top,s.bandTop[2]*a.top],m=[s.bandTop[0]*a.bottomCap,s.bandTop[1]*a.bottomCap,s.bandTop[2]*a.bottomCap],h=[s.bandWall[0]*a.top,s.bandWall[1]*a.top,s.bandWall[2]*a.top],p=[s.bandWall[0]*a.wallBottom,s.bandWall[1]*a.wallBottom,s.bandWall[2]*a.wallBottom],y=(P,w)=>{let L=(n.startBin+P+.5)*t.binStepDeg,T=o[P]+(r[P]-o[P])*w/f,I=ge(t.centre,T,L);return[I.x*u,c[P][w],I.y*u]};{let P=Math.tan(12*Math.PI/180);for(let w=0;w<6;w++){let L=!1;for(let I=0;I<d;I++)for(let F=f-1;F>=0;F--)c[I][F]>c[I][F+1]&&(c[I][F]=c[I][F+1],L=!0);let T=n.closed?d:d-1;for(let I=0;I<T;I++){let F=(I+1)%d;for(let A=0;A<=f;A++){let C=c[F][A]-c[I][A];if(Math.abs(C)>1)continue;let E=o[I]+(r[I]-o[I])*A/f,N=o[F]+(r[F]-o[F])*A/f,j=ge(t.centre,E,(n.startBin+I+.5)*t.binStepDeg),X=ge(t.centre,N,(n.startBin+F+.5)*t.binStepDeg),G=P*Math.hypot(X.x-j.x,X.y-j.y)*u;C>G?(c[F][A]=c[I][A]+G,L=!0):-C>G&&(c[I][A]=c[F][A]+G,L=!0)}}if(!L)break}}let g=1,S=(P,w)=>{for(let L=0;L<=f;L+=4)if(Math.abs(c[P][L]-c[w][L])>g)return!0;return Math.abs(c[P][f]-c[w][f])>g},x=Math.tan(38*Math.PI/180),_=P=>(r[P]-o[P])/f*u,M=(P,w)=>c[P][w+1]-c[P][w]>x*Math.max(1e-6,_(P)),v=(P,w)=>{let L=n.closed?(P-1+d)%d:Math.max(0,P-1),T=n.closed?(P+1)%d:Math.min(d-1,P+1);Math.abs(c[L][w]-c[P][w])>g&&(L=P),Math.abs(c[T][w]-c[P][w])>g&&(T=P);let I=Math.max(0,w-1),F=Math.min(f,w+1);I<w&&M(P,I)&&(I=w),F>w&&M(P,w)&&(F=w);let A=y(L,w),C=y(T,w),E=y(P,I),N=y(P,F),j=C[0]-A[0],X=C[1]-A[1],G=C[2]-A[2],Y=N[0]-E[0],O=N[1]-E[1],V=N[2]-E[2],H=X*V-G*O,Q=G*Y-j*V,Z=j*O-X*Y,z=Math.hypot(H,Q,Z);return z>1e-12?(H/=z,Q/=z,Z/=z,Q<0&&(H=-H,Q=-Q,Z=-Z),[H,Q,Z]):[0,1,0]},k=(P,w)=>{let L=[P[0],i,P[2]],T=[w[0],i,w[2]],I=w[0]-P[0],F=w[2]-P[2],A=Math.hypot(I,F);if(!(A>1e-12))return;let C=[F/A,0,-I/A];e.tri(P,w,T,C,h,h,p),e.tri(P,T,L,C,h,p,p)},B=.05*fe,D=P=>r[P]-o[P]<B,U=n.closed?d:d-1;for(let P=0;P<U;P++){let w=(P+1)%d;if(D(P)||D(w))continue;if(S(P,w)){let C=(n.startBin+P+1)*t.binStepDeg,E=(O,V)=>{let H=(o[P]+o[w])/2,Q=(r[P]+r[w])/2,Z=H+(Q-H)*V/f,z=ge(t.centre,Z,C);return[z.x*u,c[O][V],z.y*u]};for(let O=0;O<f;O++){let V=y(P,O),H=y(P,O+1),Q=E(P,O),Z=E(P,O+1),z=v(P,O),q=v(P,O+1);e.triN(V,Q,Z,z,z,q,l),e.triN(V,Z,H,z,q,q,l);let Ue=y(w,O),Xe=y(w,O+1),Se=E(w,O),Ae=E(w,O+1),Me=v(w,O),we=v(w,O+1);e.triN(Se,Ue,Xe,Me,Me,we,l),e.triN(Se,Xe,Ae,Me,we,we,l);let le=E(P,O),ae=E(P,O+1),Ye=E(w,O+1),ct=E(w,O),Ve=ae[0]-le[0],Ee=ae[2]-le[2],ut=Math.hypot(Ve,Ee);if(ut>1e-12){let Ot=[Ee/ut,0,-Ve/ut];e.tri(le,ae,Ye,Ot,h),e.tri(le,Ye,ct,Ot,h)}}let N=y(P,0),j=y(w,0),X=y(w,f),G=y(P,f),Y=O=>[O[0],i,O[2]];e.tri(Y(N),Y(X),Y(j),[0,-1,0],m),e.tri(Y(N),Y(G),Y(X),[0,-1,0],m),k(N,j),k(G,X);continue}for(let C=0;C<f;C++){let E=v(P,C),N=v(w,C),j=v(w,C+1),X=v(P,C+1);if(M(P,C)||M(w,C)){let H=(ae,Ye)=>{let ct=(n.startBin+ae+.5)*t.binStepDeg,Ve=o[ae]+(r[ae]-o[ae])*(C+.5)/f,Ee=ge(t.centre,Ve,ct);return[Ee.x*u,Ye,Ee.y*u]},Q=y(P,C),Z=y(w,C),z=H(P,c[P][C]),q=H(w,c[w][C]);e.triN(Q,Z,q,E,N,N,l),e.triN(Q,q,z,E,N,E,l);let Ue=y(w,C+1),Xe=y(P,C+1),Se=H(P,c[P][C+1]),Ae=H(w,c[w][C+1]);e.triN(Se,Ae,Ue,X,j,j,l),e.triN(Se,Ue,Xe,X,j,X,l);let Me=q[0]-z[0],we=q[2]-z[2],le=Math.hypot(Me,we);if(le>1e-12){let ae=[-we/le,0,Me/le];e.tri(z,q,Ae,ae,h),e.tri(z,Ae,Se,ae,h)}continue}let G=y(P,C),Y=y(w,C),O=y(w,C+1),V=y(P,C+1);e.triN(G,Y,O,E,N,j,l),e.triN(G,O,V,E,j,X,l)}let L=y(P,0),T=y(w,0),I=y(w,f),F=y(P,f),A=C=>[C[0],i,C[2]];e.tri(A(L),A(I),A(T),[0,-1,0],m),e.tri(A(L),A(F),A(I),[0,-1,0],m),k(L,T),k(F,I)}if(!n.closed)for(let P of[0,d-1])for(let w=0;w<f;w++)k(y(P,w),y(P,w+1))}function Jn(e,t,n){let{bottomY:o,colors:r,ao:i}=n,s=new Float64Array(t.binCount).fill(-1/0);for(let u of t.rings)for(let b of u.arcs){let c=new Float64Array(b.binCount),l=new Float64Array(b.binCount);for(let h=0;h<b.binCount;h++){let p=(b.startBin+h)%t.binCount,y=Math.max(0,b.innerR[h]-se);c[h]=Math.max(y,s[p]+.001),l[h]=Math.max(c[h]+.001,b.outerR[h]+se)}let m=0;for(let h=0;h<b.binCount;h++){let p=b.topLevelM[h]-o;p>m&&(m=p)}m>=fi&&gi(e,t,b,c,l,o,r,i);for(let h=0;h<b.binCount;h++){let p=(b.startBin+h)%t.binCount;l[h]>s[p]&&(s[p]=l[h])}}if(n.deriveShell===!1||pi(n.shapes,t))return;let a=t.rings[t.rings.length-1],d=mi*fe,f=di*fe;for(let u of a.arcs){let b=[],c=[];for(let h=0;h<u.binCount;h++){let p=(u.startBin+h+.5)*t.binStepDeg,y=u.outerR[h]+se+d;b.push(ge(t.centre,y,p)),c.push(ge(t.centre,y+f,p))}let l=-1/0;for(let h=0;h<u.binCount;h++)u.topLevelM[h]>l&&(l=u.topLevelM[h]);let m=()=>l+bi;u.closed?J(e,c,[b.slice().reverse()],m,o,r.shellTop,r.shellWall,i):J(e,[...c,...b.slice().reverse()],void 0,m,o,r.shellTop,r.shellWall,i)}}function eo(e,t,n,o,r,i,s,a){if(!t.outline||t.outline.length<3)return;let d=n.baseHeightM,f=ce(o,a.tierTop);if(!r)return;let u=p=>r.deckAt(p.x,p.y),b=On(t,s),c=b[0]??t.outline;if(r.rowLevels.length>=2){let p=nt(r.rowLevels),y=Bn(An(r.rowLevels,n.focal,p),b),g=()=>[0,1,0];for(let x of y){let _=Math.max(d,x.topY-.02);for(let M of i.subtract(x.outline,_))J(e,M,x.holes,()=>_,d,f,a.tierWall,$,void 0,g)}y.length||J(e,c,t.holes,()=>r.landingY,d,f,a.tierWall,$);let S={tread:[f[0]*$.top,f[1]*$.top,f[2]*$.top],riser:[f[0]*.72,f[1]*.72,f[2]*.72]};for(let x of b.length?b:[c])_n(e,r.rowLevels,n.focal,r.landingY,S,x,p);return}let l=r.flat?1/0:Fn,m=p=>r.normalAt(p.x,p.y),h=r.flat?r.landingY:void 0;for(let p of i.subtract(c,h))J(e,p,t.holes,u,d,f,a.tierWall,$,l,m)}function xi(e,t,n){let o=new Set;for(let s of e.objects)s.type==="section"&&o.add(s.id);let r=new Map;for(let s=0;s<t.length;s++){let a=n.seatOwner[s];if(!a||!o.has(a))continue;let d=n.bySection.get(a);if(d&&d.rowLevels.length>=2)continue;let f=t[s],u=r.get(a);u||(u=new Map,r.set(a,u));let b=f.rowId||`__seat-${s}`,c=u.get(b);c||(c={pts:[],levelM:0,n:0},u.set(b,c)),c.pts.push({x:f.x,y:f.y}),c.levelM+=n.seatDeckY(s),c.n++}let i=[];for(let s of e.objects){if(s.type!=="section")continue;let a=n.bySection.get(s.id);if(a&&a.rowLevels.length>=2){let f=a.rowLevels.filter(u=>!u.patch).map(u=>({pts:u.pts,levelM:u.y}));f.length>=2&&i.push({sectionId:s.id,rows:f});continue}let d=r.get(s.id);d&&i.push({sectionId:s.id,rows:[...d.values()].map(f=>({pts:f.pts,levelM:f.levelM/f.n}))})}return i}function to(e,t,n,o,r,i,s=!0){let a=xi(t,n,o);if(!a.length)return;let d=$n(a,t.focal);d&&(e.setMaterial(0),Jn(e,d,{bottomY:t.baseHeightM,colors:{bandTop:ie(r.tierTop,.8),bandWall:r.tierWall,shellTop:i??ie(r.tierWall,1.15),shellWall:i??r.tierWall},ao:$,shapes:t.objects.filter(f=>f.type==="shape"),deriveShell:s}))}var Si=6,Mi=2.2,no=.1,wi=.3,Ii=1.8,vi=.9,Ri=.55,Pi=6e3;function oo(e){let{doc:t,units:n,seats:o,surfaces:r,focal:i}=e,s=t.zones??[],a=[];if(s.length){let d=new Map;for(let u of n)for(let b of u.objects)b.type==="section"&&b.zone&&d.set(b.id,b.zone);let f=new Map;for(let u=0;u<o.length;u++){let b=o[u],c=r.seatOwner[u],l=b.zoneId??(c?d.get(c):void 0);if(!l)continue;let m=f.get(l);m||(m={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},f.set(l,m)),m.n++,b.x<m.minX&&(m.minX=b.x),b.y<m.minY&&(m.minY=b.y),b.x>m.maxX&&(m.maxX=b.x),b.y>m.maxY&&(m.maxY=b.y),m.sumY+=r.seatDeckY(u)}for(let u of s){let b=f.get(u.id),c=[];for(let[l,m]of d)m===u.id&&c.push(l);if(!b||b.n===0){a.push({id:u.id,label:u.label,color:W(u.color),sectionIds:c,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(u.focalPoint??i).x*R,1.5,(u.focalPoint??i).y*R]});continue}a.push({id:u.id,label:u.label,color:W(u.color),sectionIds:c,seatCount:b.n,center:[(b.minX+b.maxX)/2*R,b.sumY/b.n,(b.minY+b.maxY)/2*R],radius:.5*Math.hypot((b.maxX-b.minX)*R,(b.maxY-b.minY)*R)||1,focalWorld:[(u.focalPoint??i).x*R,1.5,(u.focalPoint??i).y*R]})}}return a}function ro(e){let{doc:t,units:n,seats:o,surfaces:r,seatData:i,hintedSeatFloor:s,zones:a,focal:d}=e,f=[],u=[],b=[];for(let c of a)c.seatCount!==0&&f.push({id:`zone:${c.id}`,kind:"zone",text:c.label,anchor:[c.center[0],c.center[1]+Si,c.center[2]],color:t.zones?.find(l=>l.id===c.id)?.color});{let c=new Map,l=new Map;for(let m=0;m<o.length;m++){let h=r.seatOwner[m];if(!h)continue;let p=c.get(h);p||(p={n:0,x:0,y:0,deck:0},c.set(h,p)),p.n++,p.x+=o[m].x,p.y+=o[m].y,p.deck+=r.seatDeckY(m);let y=l.get(h);y||(y={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0},l.set(h,y)),o[m].x<y.minX&&(y.minX=o[m].x),o[m].x>y.maxX&&(y.maxX=o[m].x),o[m].y<y.minY&&(y.minY=o[m].y),o[m].y>y.maxY&&(y.maxY=o[m].y)}for(let m of n)for(let h of m.objects){if(h.type!=="section")continue;let p=c.get(h.id);if(!p||p.n===0)continue;let y=l.get(h.id),g=[p.x/p.n*R,p.deck/p.n,p.y/p.n*R],S=h.displayLabel||h.label||h.id;u.push({id:h.id,floorIndex:m.index,label:S,seatCount:p.n,center:g,radius:Math.max(1,Math.hypot(y.maxX-y.minX,y.maxY-y.minY)*.5*R),focalWorld:[m.focal.x*R,m.baseHeightM+1.5,m.focal.y*R]});let x=t.floors?.[m.index]?.name?.trim().toLocaleLowerCase();n.length>1&&x===S.trim().toLocaleLowerCase()||f.push({id:`section:${h.id}`,kind:"section",text:S,anchor:[g[0],g[1]+Mi,g[2]],floorIndex:m.index})}}{for(let m of n)for(let h of m.objects){if(h.type!=="gaArea")continue;let p=_e(h.points);if(!p)continue;let y=h.displayLabel||h.label||h.id;f.push({id:`ga:${h.id}`,kind:"ga",text:h.capacity>0?`${y} \xB7 ${h.capacity.toLocaleString()}`:y,anchor:[p.x*R,m.baseHeightM+Ii,p.y*R],floorIndex:m.index})}let c=new Map;for(let m=0;m<o.length;m++){let h=o[m],p=Math.hypot(h.x-d.x,h.y-d.y),y=c.get(h.rowId);(!y||p>y.far)&&c.set(h.rowId,{seat:h,index:m,far:p})}for(let[m,h]of c){let p=h.seat.label?h.seat.label.lastIndexOf("-"):-1,y=p>0?h.seat.label.slice(0,p):m;y&&f.push({id:`row:${m}`,kind:"row",text:y,anchor:[h.seat.x*R,r.seatDeckY(h.index)+vi,h.seat.y*R],floorIndex:s[h.index]})}let l=new Map;for(let m=0;m<o.length;m++){let h=o[m],p=h.label?h.label.lastIndexOf("-"):-1,y=l.get(h.rowId);y||(y={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:p>0?h.label.slice(0,p):h.rowId,sectionId:h.sectionId},l.set(h.rowId,y));let g=m*3,S=i.iPosition[g],x=i.iPosition[g+1],_=i.iPosition[g+2];y.n++,y.x+=S,y.y+=x,y.z+=_,y.minX=Math.min(y.minX,S),y.maxX=Math.max(y.maxX,S),y.minZ=Math.min(y.minZ,_),y.maxZ=Math.max(y.maxZ,_)}for(let[m,h]of l)b.push({id:m,label:h.label,sectionId:h.sectionId,seatCount:h.n,center:[h.x/h.n,h.y/h.n,h.z/h.n],radius:Math.max(.8,Math.hypot(h.maxX-h.minX,h.maxZ-h.minZ)*.5)});if(o.length<=Pi)for(let m=0;m<o.length;m++){let h=o[m],p=h.displayLabel||h.label;p&&f.push({id:`seat:${h.id}`,kind:"seat",text:p,anchor:[h.x*R,r.seatDeckY(m)+Ri,h.y*R],floorIndex:s[m]})}}for(let c of n)for(let l of c.objects)if(l.type==="shape"&&l.role&&["entrance","exit","screen","suite","obstruction"].includes(l.role)){let m=ye(l),h=m?_e(m):null;if(!h||!l.label)continue;f.push({id:`architecture:${l.id}`,kind:"annotation",text:l.label,anchor:[h.x*R,c.baseHeightM+De(l).heightM+no,h.y*R],color:l.fill,floorIndex:c.index})}else if(l.type==="text"){if(!l.text)continue;f.push({id:`text:${l.id}`,kind:"annotation",text:l.text,anchor:[l.position.x*R,c.baseHeightM+no,l.position.y*R],color:l.color,rotation:l.rotation,floorIndex:c.index})}else if(l.type==="booth"){let m=Ge(l);if(!m)continue;let h=_e(m);if(!h)continue;f.push({id:`booth:${l.id}`,kind:"booth",text:l.displayLabel||l.label||l.id,anchor:[h.x*R,c.baseHeightM+At+wi,h.y*R],floorIndex:c.index})}return{labels:f,sections:u,rows:b}}function io(e,t){if(t.length>1)for(let n of t)e.push({id:`floor:${n.id}`,kind:"floor",text:n.label,anchor:[n.center[0],n.box.max[1]+1.2,n.center[2]],floorIndex:n.index})}function so(e){let{doc:t,units:n,seats:o,surfaces:r,solids:i,hintedSeatFloor:s,seatFloor:a}=e,d=[];{let f=n.map(()=>({minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}));for(let c=0;c<i.floor.length;c+=1){let l=Math.max(0,Math.min(n.length-1,Math.round(i.floor[c]))),m=c*3,h=f[l];h.minX=Math.min(h.minX,i.position[m]),h.minY=Math.min(h.minY,i.position[m+1]),h.minZ=Math.min(h.minZ,i.position[m+2]),h.maxX=Math.max(h.maxX,i.position[m]),h.maxY=Math.max(h.maxY,i.position[m+1]),h.maxZ=Math.max(h.maxZ,i.position[m+2])}let u=new Map;for(let c=0;c<n.length;c++)for(let l of n[c].objects)l.type==="section"&&u.set(l.id,c);let b=n.map(()=>({n:0,minX:1/0,minY:1/0,minDeck:1/0,maxX:-1/0,maxY:-1/0,maxDeck:-1/0,sumX:0,sumDeck:0,sumZ:0}));for(let c=0;c<o.length;c++){let l=r.seatOwner[c],m=(l!==null?u.get(l):void 0)??s[c];if(m===void 0)continue;let h=b[m],p=o[c];h.n++,p.x<h.minX&&(h.minX=p.x),p.y<h.minY&&(h.minY=p.y),p.x>h.maxX&&(h.maxX=p.x),p.y>h.maxY&&(h.maxY=p.y);let y=r.seatDeckY(c);h.sumX+=p.x*R,h.sumDeck+=y,h.sumZ+=p.y*R,h.minDeck=Math.min(h.minDeck,y),h.maxDeck=Math.max(h.maxDeck,y+1.6),a[c]=m}for(let c=0;c<n.length;c++){let l=b[c],m=t.floors?.[c],h=f[c],p=Math.min(l.n?l.minX*R:n[c].focal.x*R-1,Number.isFinite(h.minX)?h.minX:1/0),y=Math.max(l.n?l.maxX*R:n[c].focal.x*R+1,Number.isFinite(h.maxX)?h.maxX:-1/0),g=Math.min(l.n?l.minY*R:n[c].focal.y*R-1,Number.isFinite(h.minZ)?h.minZ:1/0),S=Math.max(l.n?l.maxY*R:n[c].focal.y*R+1,Number.isFinite(h.maxZ)?h.maxZ:-1/0),x=Math.min(l.n?Math.min(n[c].baseHeightM,l.minDeck):n[c].baseHeightM,Number.isFinite(h.minY)?h.minY:1/0),_=Math.max(l.n?Math.max(l.maxDeck,x+.5):x+.5,Number.isFinite(h.maxY)?h.maxY:-1/0),M=[l.n?l.sumX/l.n:(p+y)/2,l.n?l.sumDeck/l.n:(x+_)/2,l.n?l.sumZ/l.n:(g+S)/2],v=Math.max(1,.5*Math.hypot(y-p,_-x,S-g));d.push({index:c,id:m?.id??`floor-${c}`,label:m?.name??(n.length>1?`Floor ${c+1}`:"Venue"),seatCount:l.n,center:M,radius:v,box:{min:[p,x,g],max:[y,_,S]},focalWorld:[n[c].focal.x*R,n[c].baseHeightM+1.5,n[c].focal.y*R]})}}return d}function kt(e,t){let n=1/0,o=1/0,r=-1/0,i=-1/0,s=(a,d)=>{a<n&&(n=a),d<o&&(o=d),a>r&&(r=a),d>i&&(i=d)};for(let a of t)s(a.x,a.y);for(let a of e)for(let d of a.objects)if(d.type==="section")for(let f of d.outline)s(f.x,f.y);else if(d.type==="shape"&&d.points)for(let f of d.points)s(f.x,f.y);else if(d.type==="gaArea")for(let f of d.points)s(f.x,f.y);else if(d.type==="booth"){let f=Ge(d);if(f)for(let u of f)s(u.x,u.y)}else if(d.type==="table"){let f=Et(d);if(f)for(let u of f)s(u.x,u.y)}else if(d.type==="decorImage"){let f=_t(d);if(f)for(let u of f)s(u.x,u.y)}return Number.isFinite(n)||(n=-100,o=-100,r=100,i=100),{minX:n,minY:o,maxX:r,maxY:i}}function ao(e,t,n,o,r,i){if(t.length===1){let s=Math.max(60,(r.maxX-r.minX+r.maxY-r.minY)*.06),a=Fe(r.minX-s,r.minY-s,r.maxX-r.minX+s*2,r.maxY-r.minY+s*2);J(e,a,void 0,()=>0,-.4,i.ground,i.ground,$)}else{let s=t.reduce((l,m)=>m.baseHeightM<l.baseHeightM?m:l);e.setFloor(s.index);let a=n.filter((l,m)=>o[m]===s.index),d=kt([s],a),f=Math.hypot(d.maxX-d.minX,d.maxY-d.minY),u=Math.max(28,Math.min(80,f*.04)),b=Fe(d.minX-u,d.minY-u,d.maxX-d.minX+u*2,d.maxY-d.minY+u*2),c=s.baseHeightM-.03;J(e,b,void 0,()=>c,c-.22,i.ground,i.ground,$)}}function co(e,t,n){let{cx:o,cz:r,radius:i}=n,s=1/0,a=1/0,d=1/0,f=-1/0,u=-1/0,b=-1/0,c=(h,p,y)=>{s=Math.min(s,h),f=Math.max(f,h),a=Math.min(a,p),u=Math.max(u,p),d=Math.min(d,y),b=Math.max(b,y)};for(let h=0;h<e.position.length;h+=3)c(e.position[h],e.position[h+1],e.position[h+2]);for(let h=0;h<t.count;h++){let p=h*3,y=t.iPosition[p],g=t.iPosition[p+1],S=t.iPosition[p+2],x=Math.max(.35,t.iMaxRadius[h]??.35);c(y-x,g,S-x),c(y+x,g+1.6,S+x)}Number.isFinite(s)||(s=o-i,f=o+i,a=0,u=i*.16,d=r-i,b=r+i);let l=[(s+f)/2,(a+u)/2,(d+b)/2],m=Math.max(1,.5*Math.hypot(f-s,u-a,b-d));return{center:l,radius:m,minY:a,maxY:u}}function uo(e,t,n,o,r,i){let s=1/0,a=1/0,d=-1/0,f=-1/0;for(let x=0;x<e.count;x++){let _=x*3,M=e.iPosition[_],v=e.iPosition[_+2];M<s&&(s=M),M>d&&(d=M),v<a&&(a=v),v>f&&(f=v)}for(let x of t)s=Math.min(s,x.cx-x.halfX),d=Math.max(d,x.cx+x.halfX),a=Math.min(a,x.cz-x.halfZ),f=Math.max(f,x.cz+x.halfZ);let u=n.minX*R,b=n.maxX*R,c=n.minY*R,l=n.maxY*R,m=u,h=b,p=c,y=l;if(Number.isFinite(s)){let x=Math.max(2,.06*Math.hypot(d-s,f-a));m=Math.max(u,s-x),h=Math.min(b,d+x),p=Math.max(c,a-x),y=Math.min(l,f+x)}let g=Math.min(0,o),S=Math.max(r,i*.05);return{min:[m,g,p],max:[h,S,y]}}var Ci=/^data:image\/(?:png|jpe?g|webp|gif|avif);base64,[a-z0-9+/]+={0,2}$/i,Ai=/[\s"'<>`\\]/;function Ei(e){if(typeof e!="string"||!e||e.length>2e6||e!==e.trim())return!1;if(e.startsWith("data:"))return Ci.test(e);if(Ai.test(e))return!1;try{let t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}}function lo(e){let t=e.trim();return Ei(t)?t:null}var Tt="seatlayer.event-configuration/1";var Ce=100,_i=120,ki=1e5,Ti=1e4,Li=/^[a-f0-9]{64}$/,Oi=new Set(["stage","screen","barrier","camera_platform","sound_desk","rigging_truss"]);function je(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function xe(e,t){return typeof e=="string"&&e.length>=1&&e.length<=t&&e.normalize("NFKC").trim()===e}function Bi(e){return typeof e=="number"&&Number.isInteger(e)&&e>0}function fo(e){return!Array.isArray(e)||e.length>ki||!e.every(t=>xe(t,Ce))?null:[...new Set(e)].sort()}function Fi(e){return!je(e)||!xe(e.chartId,Ce)||!xe(e.version,Ce)||e.sha256!==void 0&&(typeof e.sha256!="string"||!Li.test(e.sha256))?null:{chartId:e.chartId,version:e.version,...typeof e.sha256=="string"?{sha256:e.sha256}:{}}}function Lt(e,t,n){return typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=n}function Di(e){return je(e)?e.mode==="none"||e.mode==="opaque"?e.opacity===void 0?{mode:e.mode}:null:e.mode==="partial"&&Lt(e.opacity,.01,.99)?{mode:"partial",opacity:e.opacity}:null:null}function Ni(e,t){if(e===void 0)return;if(!Array.isArray(e)||e.length>Ti)return null;let n=new Set(t),o=new Set,r=new Set,i=0,s=[];for(let a of e){if(!je(a)||!xe(a.id,Ce)||!xe(a.objectId,Ce)||!n.has(a.objectId)||!Oi.has(String(a.kind))||!Lt(a.heightM,.05,50)||a.baseElevationM!==void 0&&!Lt(a.baseElevationM,-10,100))return null;let d=Di(a.occlusion);if(!d||o.has(a.id)||r.has(a.objectId))return null;let f=a.contentImageUrl===void 0?void 0:typeof a.contentImageUrl=="string"?lo(a.contentImageUrl):null;if(a.contentImageUrl!==void 0&&(!f||a.kind!=="screen"||++i>1))return null;o.add(a.id),r.add(a.objectId),s.push({id:a.id,objectId:a.objectId,kind:a.kind,heightM:a.heightM,...a.baseElevationM!==void 0?{baseElevationM:a.baseElevationM}:{},occlusion:d,...f?{contentImageUrl:f}:{}})}return s.sort((a,d)=>a.id.localeCompare(d.id))}function Gi(e){let t=[];if(!je(e))return{issues:[{code:"invalid_export",path:"configuration",message:"Configuration must be an object"}]};e.schema!==Tt&&t.push({code:"unsupported_schema",path:"configuration.schema",message:`Configuration schema must be ${Tt}`}),xe(e.id,Ce)||t.push({code:"invalid_id",path:"configuration.id",message:"Configuration id must contain 1 to 100 normalized characters"}),xe(e.label,_i)||t.push({code:"invalid_label",path:"configuration.label",message:"Configuration label must contain 1 to 120 normalized characters"}),Bi(e.version)||t.push({code:"invalid_version",path:"configuration.version",message:"Configuration version must be a positive integer"});let n=Fi(e.baseVenue);n||t.push({code:"invalid_base_venue",path:"configuration.baseVenue",message:"Base venue must identify one normalized chart id and exact version"});let o=je(e.overlay)?e.overlay:null,r=fo(o?.objectIds),i=fo(o?.productionKillSeatIds),s=r?Ni(o?.productionElements,r):null;return(!o||!r||!i)&&t.push({code:"invalid_overlay",path:"configuration.overlay",message:"Overlay ids must be bounded arrays of normalized stable ids"}),s===null&&t.push({code:"invalid_production_element",path:"configuration.overlay.productionElements",message:"Production elements must be unique, bounded semantics over referenced base-venue objects"}),t.length||!n||!r||!i||s===null?{issues:t}:{issues:t,value:{schema:Tt,id:e.id,label:e.label,version:e.version,baseVenue:n,overlay:{objectIds:r,productionKillSeatIds:i,...s!==void 0?{productionElements:s}:{}}}}}function mo(e){let t=Gi(e);return t.value?{ok:!0,value:t.value}:{ok:!1,issues:t.issues}}function bo(e,t,n){let o=()=>({byObjectId:new Map,elements:[]});if(!t||!e)return o();let r=mo(t);if(!r.ok||r.value.id!==e)return o();let i=new Map;for(let b of n)for(let c of b.objects)c.type==="shape"&&i.set(c.id,{shape:c,unit:b});let s=new Set,a=new Set,d=new Map((t.overlay.productionElements??[]).map(b=>{let c=b.runtimeContentImageUrl;return[b.id,typeof c=="string"&&/^(?:blob:|data:image\/|https:\/\/)/.test(c)?c:void 0]})),f=[];for(let b of r.value.overlay.productionElements??[]){let c=i.get(b.objectId),l=c?ye(c.shape):null,m=b.baseElevationM??0;if(!c||!l||l.length<3||!b.id||s.has(b.id)||a.has(b.objectId)||!Number.isFinite(b.heightM)||b.heightM<.05||b.heightM>50||!Number.isFinite(m)||m<-10||m>100)return o();s.add(b.id),a.add(b.objectId);let h=l.map(k=>k.x*R),p=l.map(k=>k.y*R),y=c.unit.baseHeightM+m,g=Math.min(...h),S=Math.max(...h),x=Math.min(...p),_=Math.max(...p),M,v=d.get(b.id)??b.contentImageUrl;if(b.kind==="screen"&&v)if(S-g>=_-x){let k=Math.abs(x-c.unit.focal.y*R)<=Math.abs(_-c.unit.focal.y*R)?x-.006:_+.006;M=[[g,y,k],[S,y,k],[g,y+b.heightM,k],[S,y+b.heightM,k]]}else{let k=Math.abs(g-c.unit.focal.x*R)<=Math.abs(S-c.unit.focal.x*R)?g-.006:S+.006;M=[[k,y,x],[k,y,_],[k,y+b.heightM,x],[k,y+b.heightM,_]]}f.push({id:b.id,objectId:b.objectId,kind:b.kind,floorIndex:c.unit.index,baseY:y,topY:y+b.heightM,bounds:{min:[g,y,x],max:[S,y+b.heightM,_]},occlusion:b.occlusion,...v?{contentImageUrl:v}:{},...M?{contentPlane:M}:{}})}let u=f.sort((b,c)=>b.id.localeCompare(c.id));return{byObjectId:new Map(u.map(b=>[b.objectId,b])),elements:u}}function oe(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ne(e){return Array.isArray(e)?e:[]}function ji(e){let t=[e];for(;t.length;){let n=t.pop();if(Array.isArray(n)){t.push(...n);continue}if(!oe(n))continue;let o=oe(n.extensions)?n.extensions:null;if(o&&Object.prototype.hasOwnProperty.call(o,"KHR_draco_mesh_compression"))return!0;t.push(...Object.values(n))}return!1}function at(e,t){return!Array.isArray(e)||e.length!==t||!e.every(n=>typeof n=="number"&&Number.isFinite(n))?null:e}function Ui(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Xi(e,t){let n=new Array(16).fill(0);for(let o=0;o<4;o++)for(let r=0;r<4;r++)for(let i=0;i<4;i++)n[o*4+r]+=e[i*4+r]*t[o*4+i];return n}function Yi(e){let t=at(e.matrix,16);if(t)return t;if(e.matrix!==void 0)return null;let n=e.translation===void 0?[0,0,0]:at(e.translation,3),o=e.rotation===void 0?[0,0,0,1]:at(e.rotation,4),r=e.scale===void 0?[1,1,1]:at(e.scale,3);if(!n||!o||!r)return null;let[i,s,a,d]=o,f=Math.hypot(i,s,a,d);if(!(f>1e-8))return null;let u=i/f,b=s/f,c=a/f,l=d/f,m=u+u,h=b+b,p=c+c,y=u*m,g=u*h,S=u*p,x=b*h,_=b*p,M=c*p,v=l*m,k=l*h,B=l*p;return[(1-(x+M))*r[0],(g+B)*r[0],(S-k)*r[0],0,(g-B)*r[1],(1-(y+M))*r[1],(_+v)*r[1],0,(S+k)*r[2],(_-v)*r[2],(1-(y+x))*r[2],0,n[0],n[1],n[2],1]}function Vi(e,t,n,o){return[e[0]*t+e[4]*n+e[8]*o+e[12],e[1]*t+e[5]*n+e[9]*o+e[13],e[2]*t+e[6]*n+e[10]*o+e[14]]}function Hi(e){let t=e[0],n=e[4],o=e[8],r=e[1],i=e[5],s=e[9],a=e[2],d=e[6],f=e[10],u=i*f-s*d,b=s*a-r*f,c=r*d-i*a,l=t*u+n*b+o*c;if(Math.abs(l)<1e-12)return null;let m=1/l;return[u*m,b*m,c*m,(o*d-n*f)*m,(t*f-o*a)*m,(n*a-t*d)*m,(n*s-o*i)*m,(o*r-t*s)*m,(t*i-n*r)*m]}function ho(e,t,n,o){let r=e[0]*t+e[1]*n+e[2]*o,i=e[3]*t+e[4]*n+e[5]*o,s=e[6]*t+e[7]*n+e[8]*o,a=Math.hypot(r,i,s)||1;return r/=a,i/=a,s/=a,[r,i,s]}function Ki(e){if(e.byteLength<20||e.byteLength>8388608)return null;let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getUint32(0,!0)!==1179937895||t.getUint32(4,!0)!==2||t.getUint32(8,!0)!==e.byteLength)return null;let n=12,o=null,r=null;for(;n+8<=e.byteLength;){let i=t.getUint32(n,!0),s=t.getUint32(n+4,!0);if(n+=8,i%4!==0||n+i>e.byteLength)return null;let a=e.subarray(n,n+i);if(s===1313821514&&!o)try{let d=JSON.parse(new TextDecoder().decode(a).replace(/[\u0000 ]+$/g,""));if(!oe(d))return null;o=d}catch{return null}else if(s===5130562&&!r)r=a;else return null;n+=i}return n===e.byteLength&&o&&r?{json:o,bin:r}:null}function zi(e){return e===5120||e===5121?1:e===5122||e===5123?2:e===5125||e===5126?4:0}function Wi(e){return e==="SCALAR"?1:e==="VEC2"?2:e==="VEC3"?3:e==="VEC4"?4:0}function Zi(e,t,n){return n===5120?e.getInt8(t):n===5121?e.getUint8(t):n===5122?e.getInt16(t,!0):n===5123?e.getUint16(t,!0):n===5125?e.getUint32(t,!0):e.getFloat32(t,!0)}function Qi(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=Ki(t);if(!n)return{ok:!1,issue:"invalid_glb"};let{json:o,bin:r}=n;if(!oe(o.asset)||o.asset.version!=="2.0")return{ok:!1,issue:"unsupported_glb"};let i=ne(o.extensionsUsed).filter(x=>typeof x=="string");if(i.includes("KHR_draco_mesh_compression")||ji(o))return{ok:!1,issue:"draco_not_allowed"};if(i.length||ne(o.extensionsRequired).length)return{ok:!1,issue:"unsupported_glb"};if(ne(o.images).length||ne(o.textures).length)return{ok:!1,issue:"external_resource"};let s=ne(o.buffers);if(s.length!==1||!oe(s[0])||s[0].uri!==void 0||typeof s[0].byteLength!="number"||!Number.isInteger(s[0].byteLength)||s[0].byteLength<0||s[0].byteLength>r.byteLength)return{ok:!1,issue:"external_resource"};let a=ne(o.accessors),d=ne(o.bufferViews),f=ne(o.meshes),u=ne(o.nodes),b=ne(o.scenes),c=typeof o.scene=="number"?o.scene:0;if(!oe(b[c]))return{ok:!1,issue:"unsupported_glb"};let l=new DataView(r.buffer,r.byteOffset,r.byteLength),m=(x,_,M)=>{if(typeof x!="number"||!Number.isInteger(x)||!oe(a[x]))return null;let v=a[x];if(v.type!==_||v.sparse!==void 0||v.normalized===!0||typeof v.count!="number"||!Number.isInteger(v.count)||v.count<1||typeof v.componentType!="number"||!M.includes(v.componentType)||typeof v.bufferView!="number")return null;let k=d[v.bufferView];if(!oe(k)||k.buffer!==0||typeof k.byteLength!="number"||!Number.isInteger(k.byteLength)||k.byteLength<0)return null;let B=Wi(v.type),D=zi(v.componentType),U=typeof k.byteStride=="number"?k.byteStride:B*D,P=typeof k.byteOffset=="number"?k.byteOffset:0,w=typeof v.byteOffset=="number"?v.byteOffset:0,L=P+w,T=w+(v.count-1)*U+B*D;if(!Number.isInteger(U)||!Number.isInteger(P)||!Number.isInteger(w)||U<B*D||P<0||w<0||P+k.byteLength>r.byteLength||T>k.byteLength)return null;let I=[];for(let F=0;F<v.count;F++){let A=[];for(let C=0;C<B;C++){let E=Zi(l,L+F*U+C*D,v.componentType);if(!Number.isFinite(E))return null;A.push(E)}I.push(A)}return I},h=[],p=[],y=0,g=new Set,S=(x,_)=>{if(typeof x!="number"||!Number.isInteger(x)||!oe(u[x])||g.has(x))return!1;g.add(x);let M=u[x],v=Yi(M);if(!v)return!1;let k=Xi(_,v),B=Hi(k);if(!B)return!1;if(M.mesh!==void 0){if(typeof M.mesh!="number")return!1;let D=f[M.mesh];if(!oe(D))return!1;for(let U of ne(D.primitives)){if(!oe(U)||U.mode!==void 0&&U.mode!==4||!oe(U.attributes))return!1;let P=m(U.attributes.POSITION,"VEC3",[5126]),w=U.attributes.NORMAL===void 0?null:m(U.attributes.NORMAL,"VEC3",[5126]);if(!P||U.attributes.NORMAL!==void 0&&!w)return!1;let L=P.length;if(U.indices!==void 0){let I=typeof U.indices=="number"?a[U.indices]:null;L=oe(I)?I.count:void 0}if(typeof L!="number"||!Number.isInteger(L)||L%3!==0||(y+=L/3,y>1e5))return!1;let T=U.indices===void 0?P.map((I,F)=>[F]):m(U.indices,"SCALAR",[5121,5123,5125]);if(!T||T.length%3!==0||T.length!==L)return!1;for(let I=0;I<T.length;I+=3){let F=[T[I][0],T[I+1][0],T[I+2][0]];if(F.some(E=>!Number.isInteger(E)||E<0||E>=P.length))return!1;let A=F.map(E=>Vi(k,...P[E])),C=null;if(!w){let E=A[1][0]-A[0][0],N=A[1][1]-A[0][1],j=A[1][2]-A[0][2],X=A[2][0]-A[0][0],G=A[2][1]-A[0][1],Y=A[2][2]-A[0][2];C=ho([1,0,0,0,1,0,0,0,1],N*Y-j*G,j*X-E*Y,E*G-N*X)}for(let E=0;E<3;E++)h.push(...A[E]),p.push(...w?ho(B,...w[F[E]]):C)}}}for(let D of ne(M.children))if(!S(D,k))return!1;return g.delete(x),!0};for(let x of ne(b[c].nodes))if(!S(x,Ui()))return{ok:!1,issue:y>1e5?"triangle_limit":"unsupported_glb"};return!y||h.length!==y*9||p.length!==h.length?{ok:!1,issue:"unsupported_glb"}:{ok:!0,triangleCount:y,position:new Float32Array(h),normal:new Float32Array(p)}}function po(e){try{return Qi(e)}catch{return{ok:!1,issue:"invalid_glb"}}}function yo(e){let{doc:t}=e,n=nn(t.theme),o=n.structure,r=Ln(t,e.eventConfigurationId??t.eventConfigurationId),i=bo(e.eventConfigurationId,e.eventConfiguration,r),s=e.seats,a=new $e,d=null;if(e.registeredShellGlb){let T=po(e.registeredShellGlb);if(T.ok){let I=T.position.length/3,F=new Float32Array(T.position.length),A=n.materials.shell??o.tierWall;for(let C=0;C<I;C++){let E=T.normal[C*3+1],N=E<-.25?.4:.62+.38*Math.max(0,E);F[C*3]=A[0]*N,F[C*3+1]=A[1]*N,F[C*3+2]=A[2]*N}d={position:T.position,normal:T.normal,color:F,floor:new Float32Array(I).fill(-2),material:new Float32Array(I),count:I}}}let f=new Map;for(let T of r)for(let I of T.objects)f.set(I.id,T.index),I.type==="section"&&f.set(I.logicalSectionId??I.id,T.index);let u=s.map(T=>f.get(T.sectionId??"")??f.get(T.rowId??"")??0),b=kt(r,s);ao(a,r,s,u,b,o);let c=Nn(t,s),l=new Map,m=new Map;for(let T of t.categories??[])l.set(T.key,T.color),T.seatGlyph&&m.set(T.key,T.seatGlyph);let h=[],p=Dn(r,s,u),y=new Float32Array(s.length);for(let T=0;T<r.length;T++){let I=r[T];a.setFloor(T);let F=new rt,A=[],C=I.objects.filter(E=>E.type==="section"&&!!E.outline&&E.outline.length>=3);for(let E of I.objects)if(E.type==="section")eo(a,E,I,Gn(E,c),p.bySection.get(E.id),F,C,o);else if(E.type==="shape"){let N=i.byObjectId.get(E.id);a.setMaterial((N?.kind??E.role)==="screen"?1:0),zn(a,E,I.baseHeightM,Xn(E,A),o,I.focal,h,N),a.setMaterial(0)}else E.type==="gaArea"?Zn(a,E,I.baseHeightM,W(l.get(E.categoryKey)),o):E.type==="booth"?Hn(a,E,I.baseHeightM,W(l.get(E.categoryKey)),o):E.type==="table"?Kn(a,E,I.baseHeightM,W(l.get(E.categoryKey)),o):E.type==="decorImage"&&Wn(a,E,I.baseHeightM,o);to(a,I,s,p,o,n.materials.shell,!d)}let g=r.length>1?{x:r.reduce((T,I)=>T+I.focal.x,0)/r.length,y:r.reduce((T,I)=>T+I.focal.y,0)/r.length}:t.focalPoint??{x:(b.minX+b.maxX)/2,y:(b.minY+b.maxY)/2},S=cn(d?[a.build(),d]:[a.build()]),x=yn(s,e.initialState,p,y,l,m),_=oo({doc:t,units:r,seats:s,surfaces:p,focal:g}),{labels:M,sections:v,rows:k}=ro({doc:t,units:r,seats:s,surfaces:p,seatData:x,hintedSeatFloor:u,zones:_,focal:g}),B=so({doc:t,units:r,seats:s,surfaces:p,solids:S,hintedSeatFloor:u,seatFloor:y});io(M,B),x.iYaw=pn(x.iPosition,s.length,T=>s[T].rowId,T=>{let I=r[y[T]]?.focal??g;return[I.x*R,I.y*R]});let D=(b.minX+b.maxX)/2*R,U=(b.minY+b.maxY)/2*R,P=.5*Math.hypot((b.maxX-b.minX)*R,(b.maxY-b.minY)*R)||10,w=co(S,x,{cx:D,cz:U,radius:P}),L=uo(x,h,b,w.minY,w.maxY,P);return{solids:S,seats:x,bounds:{center:[(L.min[0]+L.max[0])/2,(L.min[1]+L.max[1])/2,(L.min[2]+L.max[2])/2],radius:P,groundY:0,box:L},renderBounds:{center:w.center,radius:w.radius},stateColorLUT:on(n,We),theme:n,seatCount:s.length,focalWorld:[g.x*R,1.5,g.y*R],zones:_,stages:h,productionElements:i.elements,sections:v,rows:k,labels:M,floors:B}}function $i(e){return[e.solids.position,e.solids.normal,e.solids.color,e.solids.floor,e.solids.material,e.seats.iPosition,e.seats.iState,e.seats.iCategory,e.seats.iMaxRadius,e.seats.iRing,e.seats.iFloor,e.seats.iYaw,e.seats.iChairWidth,e.seats.iGlyph,e.seats.iPhysicalSeat].map(n=>n.buffer)}var go=self;go.onmessage=e=>{let t=performance.now(),n=!e.data.seats,o=e.data.seats??qt(e.data.doc),r=yo({doc:e.data.doc,seats:o,eventConfigurationId:e.data.eventConfigurationId,eventConfiguration:e.data.eventConfiguration,registeredShellGlb:e.data.registeredShellGlb});go.postMessage({model:r,buildMs:performance.now()-t,...n?{seats:o}:{}},$i(r))};
@@ -1 +1 @@
1
- import{v as n}from"../../chunk-5U25QLSS.js";import"../../chunk-KPSJDH3N.js";import"../../chunk-ALE2T36W.js";import"../../chunk-BLPBTW6I.js";import"../../chunk-UL5OIGIF.js";import"../../chunk-YW2WGLRM.js";import{Ea as o}from"../../chunk-KCFEFP6H.js";import"../../chunk-JBOTRSMY.js";import"../../chunk-CRCGO52K.js";function d(e){return[e.solids.position,e.solids.normal,e.solids.color,e.solids.floor,e.solids.material,e.seats.iPosition,e.seats.iState,e.seats.iCategory,e.seats.iMaxRadius,e.seats.iRing,e.seats.iFloor,e.seats.iYaw,e.seats.iChairWidth,e.seats.iGlyph,e.seats.iPhysicalSeat].map(s=>s.buffer)}var i=self;i.onmessage=e=>{let a=performance.now(),s=!e.data.seats,t=e.data.seats??o(e.data.doc),r=n({doc:e.data.doc,seats:t,eventConfigurationId:e.data.eventConfigurationId,eventConfiguration:e.data.eventConfiguration,registeredShellGlb:e.data.registeredShellGlb});i.postMessage({model:r,buildMs:performance.now()-a,...s?{seats:t}:{}},d(r))};
1
+ import{v as n}from"../../chunk-6TIKEDC4.js";import"../../chunk-N5NRM4NW.js";import"../../chunk-YFV4DSSX.js";import"../../chunk-BLPBTW6I.js";import"../../chunk-BAWUBGWY.js";import"../../chunk-UL5OIGIF.js";import{Ea as o}from"../../chunk-KN7GLEAI.js";import"../../chunk-JBOTRSMY.js";import"../../chunk-CRCGO52K.js";function d(e){return[e.solids.position,e.solids.normal,e.solids.color,e.solids.floor,e.solids.material,e.seats.iPosition,e.seats.iState,e.seats.iCategory,e.seats.iMaxRadius,e.seats.iRing,e.seats.iFloor,e.seats.iYaw,e.seats.iChairWidth,e.seats.iGlyph,e.seats.iPhysicalSeat].map(s=>s.buffer)}var i=self;i.onmessage=e=>{let a=performance.now(),s=!e.data.seats,t=e.data.seats??o(e.data.doc),r=n({doc:e.data.doc,seats:t,eventConfigurationId:e.data.eventConfigurationId,eventConfiguration:e.data.eventConfiguration,registeredShellGlb:e.data.registeredShellGlb});i.postMessage({model:r,buildMs:performance.now()-a,...s?{seats:t}:{}},d(r))};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seatlayer/core",
3
- "version": "0.72.1",
3
+ "version": "0.74.0",
4
4
  "description": "SeatLayer's seat map rendering engine — the seating chart runtime behind @seatlayer/js and the React, Vue, and Angular SDKs.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": {
@@ -1 +0,0 @@
1
- import{Ba as A,Ea as v,sa as _}from"./chunk-KCFEFP6H.js";function x(t){let n=Number(t.slice(t.lastIndexOf(":")+1));return Number.isFinite(n)?n:-1}function H(t,n,i){let e=new Map;for(let o of t){if(o.kind==="booth")continue;let a=e.get(o.rowId);a?a.push(o):e.set(o.rowId,[o])}let c=o=>i.has(o.id)||n(o.id)!=="free",l=[];for(let o of e.values())if(!(o.length<3)){o.sort((a,p)=>x(a.id)-x(p.id));for(let a=1;a<o.length-1;a++){let p=o[a];if(c(p))continue;let g=o[a-1],d=o[a+1];x(p.id)-x(g.id)!==1||x(d.id)-x(p.id)!==1||!c(g)||!c(d)||!i.has(g.id)&&!i.has(d.id)||l.push(p)}}return l}function q(t){return{code:"ticket_option_not_applicable",labels:t,message:"That ticket choice is not available for the selected seat."}}function C(t,n){let i=t.applicability;return i?!(i.seatLabels?.length&&!i.seatLabels.includes(n.label)||i.accessibility?.length&&!i.accessibility.some(e=>n.accessibility?.includes(e))):!0}function Y(t,n){return(t.categories.find(i=>i.key===n.categoryKey)?.tiers??[]).filter(i=>C(i,n))}function M(t,n,i){let e=t.categories.find(l=>l.key===n.categoryKey)?.tiers;if(!e?.length)return{kind:"none"};let c=i==null?e.find(l=>C(l,n)):e.find(l=>l.id===i&&C(l,n));return c?{kind:"resolved",tier:c}:{kind:"invalid"}}function D(t,n){return(t.logicalRowId??t.rowId)===(n.logicalRowId??n.rowId)}function N(t){if(Number.isInteger(t.logicalSeatIndex))return t.logicalSeatIndex;let n=t.id.slice(t.id.lastIndexOf(":")+1),i=Number(n);return Number.isInteger(i)?i:void 0}function z(t,n){if(!D(t,n))return!1;let i=N(t),e=N(n);return i!=null&&e!=null&&Math.abs(i-e)===1}function G(t,n){if(!n.length)return null;let i=new Map(v(t,{resolveEyeHeights:!1}).map(o=>[o.label,o])),e=n.flatMap(o=>{let a=i.get(o.label);return a?[{selection:o,seat:a}]:[]}),c=e.map(({seat:o})=>o).filter(o=>o.accessibility?.includes("wheelchair")),l=[];for(let{selection:o,seat:a}of e){let p=M(t,a,o.tierId),g=p.kind==="resolved"?p.tier:void 0;(a.accessibility?.includes("companion")||g?.restriction==="companion")&&!c.some(s=>s.id!==a.id&&z(a,s))&&l.push(a.label)}return l.length?{code:"companion_pair_required",labels:l,message:"Select the adjacent wheelchair place with each companion ticket."}:null}function J(t,n){if(!n.length)return null;let i=new Map(v(t,{resolveEyeHeights:!1}).map(o=>[o.label,o])),e=new Set(t.categories.filter(o=>o.notForSale).map(o=>o.key)),c=[],l=[];for(let o of n){let a=i.get(o.label);if(!a)continue;if(e.has(a.categoryKey)){c.push(a.label);continue}M(t,a,o.tierId).kind==="invalid"&&l.push(a.label)}return c.length?{code:"not_for_sale",labels:c,message:"These seats are not for sale."}:l.length?q(l):G(t,n)}function E(t,n){if(Number.isInteger(t.logicalSeatIndex))return t.logicalSeatIndex;let i=t.id.lastIndexOf(":");if(i<0)return n;let e=Number(t.id.slice(i+1));return Number.isFinite(e)?e:n}function T(t,n){let i=t.x-n.x,e=t.y-n.y;return i*i+e*e}function R(t){let n=0,i=0;for(let e of t)n+=e.x,i+=e.y;return{x:n/t.length,y:i/t.length}}function K(t,n){return t.find(i=>i.focalPoint)?.focalPoint??n}function P(t){return t.commercial?.premium===!0}function U(t,n,i){let e=Math.floor(i.qty);if(!Number.isFinite(e)||e<=0)return{labels:[],reason:"sold_out"};let{categoryKey:c,zoneId:l,focal:o,preferPremium:a}=i,p=new Map,g=[];if(t.forEach((r,b)=>{let m=n.has(r.label)&&(!c||r.categoryKey===c)&&(!l||r.zoneId===l),f=r.logicalRowId??r.rowId,u=p.get(f);u||(u=[],p.set(f,u)),u.push({seat:r,index:E(r,b),elig:m}),m&&g.push(r)}),g.length===0)return{labels:[],reason:"sold_out"};let d=null,s=r=>{if(!d)return!0;if(a&&r.nonPremium!==d.nonPremium)return r.nonPremium<d.nonPremium;if(r.orphan!==d.orphan)return r.orphan<d.orphan;if(r.d2!==d.d2)return r.d2<d.d2;let b=r.rowId.localeCompare(d.rowId);return b!==0?b<0:r.startIndex<d.startIndex};for(let[r,b]of p){let m=[...b].sort((u,k)=>u.index-k.index),f=0;for(;f<m.length;){if(!m[f].elig){f++;continue}let u=f;for(;u<m.length&&m[u].elig&&(u===f||m[u].index===m[u-1].index+1);)u++;let k=u-f;for(let y=0;y+e<=k;y++){let B=y,j=k-(y+e),F=B===1||j===1?1:0,h=m.slice(f+y,f+y+e).map(I=>I.seat),O={labels:h.map(I=>I.label),seats:h,rowId:r,startIndex:m[f+y].index,orphan:F,nonPremium:a?h.reduce((I,L)=>I+(P(L)?0:1),0):0,d2:T(R(h),K(h,o))};s(O)&&(d=O)}f=u}}return d?{labels:d.labels}:g.length<e?{labels:[],reason:"not_enough_together"}:{labels:g.map((r,b)=>({seat:r,i:b,d2:T(r,r.focalPoint??o)})).sort((r,b)=>{if(a){let f=P(r.seat)?0:1,u=P(b.seat)?0:1;if(f!==u)return f-u}if(r.d2!==b.d2)return r.d2-b.d2;let m=(r.seat.logicalRowId??r.seat.rowId).localeCompare(b.seat.logicalRowId??b.seat.rowId);return m!==0?m:E(r.seat,r.i)-E(b.seat,b.i)}).slice(0,e).map(r=>r.seat.label)}}function X(t,n,i,e){let c=Math.floor(e.qty),l=U(t,i,e),a=n.filter(s=>s.bookingMode==="whole"&&s.capacity===c&&i.has(s.label)&&(!e.categoryKey||s.categoryKey===e.categoryKey)&&(!e.zoneId||s.zoneId===e.zoneId)).map(s=>({table:s,d2:T(s.center,s.focalPoint??e.focal)})).sort((s,w)=>s.d2-w.d2||s.table.label.localeCompare(w.table.label))[0];if(!a)return l;if(!l.labels.length)return{labels:[a.table.label]};let p=new Map(t.map(s=>[s.label,s])),g=l.labels.map(s=>p.get(s)).filter(s=>!!s),d=g.length?T(R(g),K(g,e.focal)):Number.POSITIVE_INFINITY;return a.d2<d?{labels:[a.table.label]}:l}var S=class extends Error{constructor(i,e){super(e);this.objectId=i;this.name="GroupedTableProjectionError"}};function V(t){let n=t.minOccupancy,i=t.maxOccupancy;if(!Number.isInteger(n)||!Number.isInteger(i)||n<1||i<n||i>t.seatCount)throw new S(t.id,`Table "${t.label}" has invalid variable-occupancy bounds`);return{min:n,max:i}}function te(t,n){if(n!==2)return[];let i=[];for(let e of A(t)){if(e.type!=="table"||!e.bookAsWhole&&!e.variableOccupancy)continue;if(e.bookAsWhole&&e.variableOccupancy)throw new S(e.id,`Table "${e.label}" cannot be whole-table and variable-occupancy inventory`);if(!Number.isInteger(e.seatCount)||e.seatCount<1||!e.label.trim())throw new S(e.id,"Grouped tables require a label and at least one chair");let c=e.variableOccupancy?"variable":"whole",l=c==="variable"?V(e):{min:e.seatCount,max:e.seatCount};i.push({objectId:e.id,label:e.label,...e.displayLabel?{displayLabel:e.displayLabel}:{},...e.displayType?{displayType:e.displayType}:{},categoryKey:e.categoryKey,mode:c,capacity:e.seatCount,minOccupancy:l.min,maxOccupancy:l.max,chairs:_(e)})}return i}export{H as a,q as b,C as c,Y as d,M as e,G as f,J as g,U as h,X as i,S as j,te as k};
@@ -1 +0,0 @@
1
- function t(e){let n=e;return delete n.referenceScan,delete n.referenceInventorySource,delete n.referenceInventoryExclusion,delete n.referenceSource,delete n.referenceAnnotationSource,e}function y(e){return(e.type==="shape"||e.type==="text")&&e.referenceAnnotationSource?.kind==="direct-landmark-v1"&&(e.referenceAnnotationSource.ownership="organizer"),e}function m(e){return e.type==="shape"&&h(e)}function h(e){return(e.type==="shape"||e.type==="text")&&(e.labelImportance==="orientation"||e.referenceAnnotationSource?.kind==="direct-landmark-v1")}function S(e){return e.referenceImage??(e.backgroundImage?.assetId?e.backgroundImage:void 0)}function g(e){let n=e.backgroundImage;return n?.url&&!n.assetId?n:void 0}function o(e){let n=g(e);if(!n?.url)return;let{calibration:a,derivedScale:r,assetId:b,...u}=n;return u}function C(e){let n=a=>{let r=a.backgroundImage;r?.assetId&&(a.referenceImage||(a.referenceImage=r,a.backgroundImage=void 0))};n(e);for(let a of e.floors??[])n(a);return e}function i(e){let n={...e};return t(n),delete n.editor,n}function d(e){let n={...e};return delete n.referenceCategorySource,delete n.referenceDirectSeatImport,n}function x(e){let n=o(e),a=e.floors?.map(r=>({...r,objects:r.objects.map(i),referenceImage:void 0,backgroundImage:o(r)}));return{...e,categories:e.categories.map(d),objects:e.objects.map(i),referenceImage:void 0,venueSurveyRegistrations:void 0,backgroundImage:n,...a?{floors:a}:{}}}function O(e){return!!e.referenceImage?.assetId&&!!e.backgroundImage?.assetId&&e.referenceImage.assetId!==e.backgroundImage.assetId}var _=24,L=2,H={facilities:"Facilities","food-drink":"Food & drink",navigation:"Getting around",accessibility:"Accessibility"},N=["facilities","food-drink","navigation","accessibility"],c="M13 4.6a1.6 1.6 0 1 0-3.2 0 1.6 1.6 0 0 0 3.2 0 M11 6.5V13h5l2.4 6 M15 16.4A5 5 0 1 1 9 11.3",s=[{key:"restroom-men",label:"Men's restroom",group:"facilities",path:"M16 7a4 4 0 1 0-8 0 4 4 0 0 0 8 0 M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"},{key:"restroom-women",label:"Women's restroom",group:"facilities",path:"M15 5a3 3 0 1 0-6 0 3 3 0 0 0 6 0 M12 8l-4 10h8l-4-10 M10 18v4 M14 18v4"},{key:"restroom-accessible",label:"Accessible restroom",group:"facilities",path:c},{key:"first-aid",label:"First aid",group:"facilities",path:"M5 4h14a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1Z M12 8v8 M8 12h8"},{key:"coat-check",label:"Coat check",group:"facilities",path:"M12 6a2 2 0 0 1 0-4 2 2 0 0 1 1.6 3.2L21 13H3l8.4-7.8 M3 13h18"},{key:"atm",label:"ATM / cash",group:"facilities",path:"M2 6h20v12H2V6Z M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0 M6 9h.01 M18 15h.01"},{key:"info",label:"Info point",group:"facilities",path:"M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18 M12 11v5 M12 8h.01"},{key:"lost-found",label:"Lost & found",group:"facilities",path:"M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14 M16 16l5 5 M9 8.5a2 2 0 1 1 3 1.7c-.8.5-1 .8-1 1.8 M11 15h.01"},{key:"restrooms",label:"Restrooms",group:"facilities",path:"M6 3h12a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z M12 8a2 2 0 1 0 0 4 2 2 0 0 0 0-4 M9 18v-3.5a3 3 0 0 1 6 0V18"},{key:"charging",label:"Charging point",group:"facilities",path:"M3 8h13v8H3V8Z M16 10h3v4h-3 M9.6 9l-2 3.5h2.5l-1.5 3"},{key:"smoking",label:"Smoking area",group:"facilities",path:"M2 15h13v3H2v-3Z M18 16h2 M19 8c0 1 1 1.5 1 2.5S19 12 19 13"},{key:"no-smoking",label:"No smoking",group:"facilities",path:"M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18 M5.6 5.6l12.8 12.8 M7 13h6v2H7v-2Z"},{key:"food",label:"Food",group:"food-drink",path:"M7 3v6a2 2 0 0 0 4 0V3 M9 11v10 M17 3c-1.6 1-2.2 3-2.2 6 0 2 .9 3.2 2.2 3.6V21"},{key:"bar",label:"Bar",group:"food-drink",path:"M4 5h16l-8 8-8-8Z M12 13v6 M8 20h8"},{key:"coffee",label:"Caf\xE9 / coffee",group:"food-drink",path:"M4 8h13v4a5 5 0 0 1-5 5H9a5 5 0 0 1-5-5V8Z M17 9h2a2 2 0 0 1 0 4h-2 M8 2v2 M11 2v2 M4 21h14"},{key:"water",label:"Water / drinks",group:"food-drink",path:"M12 22a7 7 0 0 1-7-7c0-5 7-12 7-12s7 7 7 12a7 7 0 0 1-7 7Z"},{key:"merch",label:"Merch / shop",group:"food-drink",path:"M6 8h12l-1 12H7L6 8Z M9 8V6a3 3 0 0 1 6 0v2"},{key:"screen",label:"Screen",group:"facilities",path:"M3 4h18v12H3V4Z M9 20h6 M12 16v4 M10 8l4 2-4 2V8Z"},{key:"sound-booth",label:"Sound booth",group:"facilities",path:"M6 4v16 M6 14a2 2 0 1 0 0-4 2 2 0 0 0 0 4 M12 4v16 M12 8a2 2 0 1 0 0 4 2 2 0 0 0 0-4 M18 4v16 M18 12a2 2 0 1 0 0 4 2 2 0 0 0 0-4"},{key:"entrance",label:"Entrance",group:"navigation",path:"M14 3h5a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1h-5 M3 12h11 M10 8l4 4-4 4"},{key:"exit",label:"Exit",group:"navigation",path:"M10 3H5a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h5 M14 12h7 M17 8l4 4-4 4"},{key:"emergency-exit",label:"Emergency exit",group:"navigation",path:"M14 4.6a1.5 1.5 0 1 0-3 0 1.5 1.5 0 0 0 3 0 M12.5 8l-3.5 2 1.6 3.6-2 4.4 M12.5 10l3.5 1.5 M9 10.5l-3.5 1 M15 12h6 M18 9l3 3-3 3"},{key:"stairs",label:"Stairs",group:"navigation",path:"M3 20v-4h4v-4h4v-4h4V4h5"},{key:"elevator",label:"Elevator",group:"navigation",path:"M5 3h14a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z M8 11l1.5-2 1.5 2 M8 14l1.5 2 1.5-2 M15 8v8"},{key:"parking",label:"Parking",group:"navigation",path:"M5 3h14a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z M9 17V7h4a3 3 0 0 1 0 6H9"},{key:"wheelchair",label:"Wheelchair access",group:"accessibility",path:c},{key:"hearing",label:"Hearing assistance",group:"accessibility",path:"M8 20a4 4 0 0 1-2-3c0-1 .5-2 .5-3a4.5 4.5 0 1 1 9 0c0 1.4-1 2-2 2.4-1.2.5-1.5 1-1.5 2.2 M17 6a5 5 0 0 1 1 6 M19.5 4a8 8 0 0 1 1.2 9"}],P={wall:"M3 5h18v14H3V5Z M3 9.7h18 M3 14.3h18 M9 5v4.7 M15 5v4.7 M6 9.7v4.6 M12 9.7v4.6 M18 9.7v4.6 M9 14.3v4.7 M15 14.3v4.7",rail:"M3 7h18 M4 17h16 M6 7v10 M10 7v10 M14 7v10 M18 7v10",suite:"M3 4h18v16H3V4Z M6 17v-5h12v5 M8 12V9h8v3",obstruction:"M8 3h8l-1 4v10l1 4H8l1-4V7L8 3Z M9 7h6 M9 17h6"},l=new Map(s.map(e=>[e.key,e]));function f(e){return e?l.get(e):void 0}function A(e){return f(e)?.path}function R(e){return typeof e=="string"&&l.has(e)}var D=s.map(e=>e.key);var Z=["butt","round","square"],B=["miter","round","bevel"],j=["none","arrow"],M="round",k="round",p="none";function v(e){return e==="line"||e==="polyline"}function F(e){return e==="polygon"||v(e)}function U(e){return{lineCap:e.lineCap??M,lineJoin:e.lineJoin??k,startEnding:e.startEnding??p,endEnding:e.endEnding??p}}function w(e){return{pointerLength:Math.min(48,Math.max(8,e*3)),pointerWidth:Math.min(40,Math.max(8,e*2.25))}}export{y as a,m as b,h as c,S as d,g as e,C as f,x as g,O as h,_ as i,L as j,H as k,N as l,s as m,P as n,f as o,A as p,R as q,D as r,Z as s,B as t,j as u,M as v,k as w,p as x,v as y,F as z,U as A,w as B};