@seatlayer/core 0.102.0 → 0.103.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.
- package/dist/ar-D6ASWQBI.js +1 -0
- package/dist/be-T23MSCFC.js +1 -0
- package/dist/bg-2MMSY43I.js +1 -0
- package/dist/ca-EXRTYE33.js +1 -0
- package/dist/{categoryInventory-7gSFTu0l.d.cts → categoryInventory-D_gpkfsq.d.cts} +1 -1
- package/dist/{categoryInventory-hJxuFF9L.d.ts → categoryInventory-i-mGCBD3.d.ts} +1 -1
- package/dist/{chunk-ZS5YFXSE.js → chunk-2STEWCI2.js} +1 -1
- package/dist/chunk-33SRM2CP.js +1 -0
- package/dist/chunk-3W4ZMU4G.js +1 -0
- package/dist/chunk-76AUT55N.js +1 -0
- package/dist/chunk-B75VUM6L.js +1 -0
- package/dist/{chunk-GTRYL7YV.js → chunk-FAY7ARLB.js} +1 -1
- package/dist/chunk-NWRHKTMV.js +1 -0
- package/dist/{chunk-4DYJCT62.js → chunk-QG7ZFUNX.js} +1 -1
- package/dist/{chunk-AFJWTB7L.js → chunk-R2TRYVOY.js} +1 -1
- package/dist/{chunk-PHV2U54Y.js → chunk-RF4QU72N.js} +1 -1
- package/dist/{chunk-FOIYJ5NT.js → chunk-TFYAMLCK.js} +1 -1
- package/dist/chunk-TZBJCAXH.js +1 -0
- package/dist/{chunk-254ABRJF.js → chunk-UEYHH7Y5.js} +1 -1
- package/dist/{chunk-COECA63Q.js → chunk-WH2EVBIG.js} +1 -1
- package/dist/chunk-WKWXU5QM.js +1 -0
- package/dist/core/chart-ops/index.cjs +1 -1
- package/dist/core/chart-ops/index.d.cts +466 -14
- package/dist/core/chart-ops/index.d.ts +466 -14
- package/dist/core/chart-ops/index.js +1 -1
- package/dist/core/color.d.cts +1 -1
- package/dist/core/color.d.ts +1 -1
- package/dist/core/inventory/index.cjs +1 -1
- package/dist/core/inventory/index.d.cts +4 -4
- package/dist/core/inventory/index.d.ts +4 -4
- package/dist/core/inventory/index.js +1 -1
- package/dist/core/layout/index.cjs +1 -1
- package/dist/core/layout/index.d.cts +5 -5
- package/dist/core/layout/index.d.ts +5 -5
- package/dist/core/layout/index.js +1 -1
- package/dist/core/quality/index.d.cts +3 -3
- package/dist/core/quality/index.d.ts +3 -3
- package/dist/core/render-assets/index.cjs +1 -1
- package/dist/core/render-assets/index.d.cts +45 -5
- package/dist/core/render-assets/index.d.ts +45 -5
- package/dist/core/render-assets/index.js +1 -1
- package/dist/core/seatConfidence.d.cts +1 -1
- package/dist/core/seatConfidence.d.ts +1 -1
- package/dist/core/sections/index.cjs +1 -1
- package/dist/core/sections/index.d.cts +5 -5
- package/dist/core/sections/index.d.ts +5 -5
- package/dist/core/sections/index.js +1 -1
- package/dist/cs-L5EG7LLR.js +1 -0
- package/dist/cy-AB2Q6XHI.js +1 -0
- package/dist/da-EGJO7W4Q.js +1 -0
- package/dist/de-Q56NNVPD.js +1 -0
- package/dist/el-JW2YADAL.js +1 -0
- package/dist/es-N35HVHMD.js +1 -0
- package/dist/et-53UYPQR7.js +1 -0
- package/dist/{eventConfigurations-BHIfPJJJ.d.cts → eventConfigurations-C0x_OtjQ.d.cts} +1 -1
- package/dist/{eventConfigurations-I5UBS6r9.d.ts → eventConfigurations-CDPqKz_8.d.ts} +1 -1
- package/dist/{fa-5MS3C6YX.js → fa-JL3HW42Q.js} +1 -1
- package/dist/fi-ZFWROLPU.js +1 -0
- package/dist/fr-6EKBGKIT.js +1 -0
- package/dist/he-KSOTIRJW.js +1 -0
- package/dist/hi-RWHSYCVV.js +1 -0
- package/dist/hr-ECH5LYKR.js +1 -0
- package/dist/hu-BAXHRRWC.js +1 -0
- package/dist/id-ECFNLK3G.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +22 -15
- package/dist/index.d.ts +22 -15
- package/dist/index.js +1 -1
- package/dist/{it-KG53QPQF.js → it-HT57FDFI.js} +1 -1
- package/dist/ja-LHVHSM5J.js +1 -0
- package/dist/ko-G2HVHBKT.js +1 -0
- package/dist/ku-MNPV6BJJ.js +1 -0
- package/dist/{labeling-CDKZ9TO1.d.ts → labeling-20iLar-Q.d.ts} +1 -1
- package/dist/{labeling-2A31f781.d.cts → labeling-DW_pEMgl.d.cts} +1 -1
- package/dist/localeLoaders-L36RHPNS.js +1 -0
- package/dist/lt-GB2GJDNS.js +1 -0
- package/dist/lv-3ZE6IM47.js +1 -0
- package/dist/ms-YH2PYOHG.js +1 -0
- package/dist/nl-D4FX7T7U.js +1 -0
- package/dist/no-5YNLYHN4.js +1 -0
- package/dist/pl-RUXCR6JV.js +1 -0
- package/dist/pt-TKFGIUL6.js +1 -0
- package/dist/{renderedQuality-CwZ8hY-5.d.cts → renderedQuality-BIWwSRMS.d.cts} +1 -1
- package/dist/{renderedQuality-wDIiUId3.d.ts → renderedQuality-CdpKQidA.d.ts} +1 -1
- package/dist/{renderer-D6ggv3bV.d.cts → renderer-BSjyHBDK.d.cts} +1 -1
- package/dist/{renderer-CdJx5l3B.d.ts → renderer-BurPZ2Io.d.ts} +1 -1
- package/dist/ro-UFIOIOVH.js +1 -0
- package/dist/ru-VMRD53B7.js +1 -0
- package/dist/{seatTypeIcons-DMJX4rVN.d.cts → seatTypeIcons-BlEzPXFf.d.cts} +1 -1
- package/dist/{seatTypeIcons-UpUTD8Xf.d.ts → seatTypeIcons-D_T5HfJs.d.ts} +1 -1
- package/dist/{sections-lpdfwSdO.d.ts → sections-BySKMsFE.d.ts} +1 -1
- package/dist/{sections-CempT5a0.d.cts → sections-DXUcW0ZT.d.cts} +1 -1
- package/dist/{segmentedRowModel-HwY4XuYa.d.ts → segmentedRowModel-C5qFY6jJ.d.ts} +1 -1
- package/dist/{segmentedRowModel-Ddx5ol8T.d.cts → segmentedRowModel-CyW-LFuI.d.cts} +1 -1
- package/dist/sk-XIK2KO3F.js +1 -0
- package/dist/sl-CDZGH6C6.js +1 -0
- package/dist/sr-A3TESNV3.js +1 -0
- package/dist/sv-HKGKDGSG.js +1 -0
- package/dist/{tableSizing-C0zx97eg.d.ts → tableSizing-Bos5ueqg.d.cts} +5 -4
- package/dist/{tableSizing-BJqAuJDg.d.cts → tableSizing-CAiE_oii.d.ts} +5 -4
- package/dist/th-ZPGRIY7D.js +1 -0
- package/dist/{ticketRestrictions-DDQHiKF-.d.cts → ticketRestrictions-DKdJWh9u.d.cts} +2 -2
- package/dist/{ticketRestrictions-AU8UUmdL.d.ts → ticketRestrictions-DRDtAVKw.d.ts} +2 -2
- package/dist/tr-IUB54G3R.js +1 -0
- package/dist/{types-DL7qIUrD.d.cts → types-ZviQR7ch.d.cts} +127 -8
- package/dist/{types-DL7qIUrD.d.ts → types-ZviQR7ch.d.ts} +127 -8
- package/dist/uk-JQKEV42K.js +1 -0
- package/dist/vi-KRM5S2Q7.js +1 -0
- package/dist/view3d/crossfade/panorama.d.cts +1 -1
- package/dist/view3d/crossfade/panorama.d.ts +1 -1
- package/dist/view3d/index.cjs +54 -54
- package/dist/view3d/index.d.cts +7 -3
- package/dist/view3d/index.d.ts +7 -3
- package/dist/view3d/index.js +44 -44
- package/dist/view3d/scene/scene.worker.cjs +1 -1
- package/dist/view3d/scene/scene.worker.js +1 -1
- package/dist/zh-Hans-FEUYIOYS.js +1 -0
- package/dist/zh-Hant-PK2XOE2G.js +1 -0
- package/package.json +1 -1
- package/dist/ar-TGXEBJUB.js +0 -1
- package/dist/be-JIDOHWF6.js +0 -1
- package/dist/bg-ODVJNCC2.js +0 -1
- package/dist/ca-3I7TMWYU.js +0 -1
- package/dist/chunk-4R6TXHY2.js +0 -1
- package/dist/chunk-5N4H3KMR.js +0 -1
- package/dist/chunk-66T4EAUA.js +0 -1
- package/dist/chunk-EIV3CAGV.js +0 -1
- package/dist/chunk-FUFRWRPM.js +0 -1
- package/dist/chunk-TAMY7HTV.js +0 -1
- package/dist/chunk-TQN2VWQO.js +0 -1
- package/dist/cs-XXB624Z3.js +0 -1
- package/dist/cy-W2QNU2GO.js +0 -1
- package/dist/da-Q47YPK2E.js +0 -1
- package/dist/de-TS3DPLM5.js +0 -1
- package/dist/el-3JQUH6DB.js +0 -1
- package/dist/es-GP7VOX7S.js +0 -1
- package/dist/et-A22OMZ6V.js +0 -1
- package/dist/fi-OJLAOJO2.js +0 -1
- package/dist/fr-7ATOYJCF.js +0 -1
- package/dist/he-37LKRY5W.js +0 -1
- package/dist/hi-YXZ5EWK7.js +0 -1
- package/dist/hr-QFOPGLMR.js +0 -1
- package/dist/hu-RHRBK46E.js +0 -1
- package/dist/id-A5Q3MLSX.js +0 -1
- package/dist/ja-CC6EPUSN.js +0 -1
- package/dist/ko-7H4RGYFK.js +0 -1
- package/dist/ku-HFYWPSS4.js +0 -1
- package/dist/localeLoaders-4YMC7FIZ.js +0 -1
- package/dist/lt-HQXE7W47.js +0 -1
- package/dist/lv-AN25XXPB.js +0 -1
- package/dist/ms-CWAYSF6E.js +0 -1
- package/dist/nl-63QBRZSZ.js +0 -1
- package/dist/no-RAPQMKWU.js +0 -1
- package/dist/pl-ILSTD4ZV.js +0 -1
- package/dist/pt-WF3US5D7.js +0 -1
- package/dist/ro-XR3HT6DE.js +0 -1
- package/dist/ru-TLJEWDPA.js +0 -1
- package/dist/sk-OJC2EL3Z.js +0 -1
- package/dist/sl-7RGTVXCV.js +0 -1
- package/dist/sr-NHDJ54BS.js +0 -1
- package/dist/sv-ZODCCBCU.js +0 -1
- package/dist/th-VCZA4MP5.js +0 -1
- package/dist/tr-ROKZO3HC.js +0 -1
- package/dist/uk-LP2DPUHC.js +0 -1
- package/dist/vi-JDK3JRJR.js +0 -1
- package/dist/zh-Hans-P3GB3FAZ.js +0 -1
- package/dist/zh-Hant-YU4OKSFZ.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var ms=Object.create;var so=Object.defineProperty;var hs=Object.getOwnPropertyDescriptor;var ds=Object.getOwnPropertyNames;var ps=Object.getPrototypeOf,bs=Object.prototype.hasOwnProperty;var ys=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ds(t))!bs.call(e,r)&&r!==n&&so(e,r,{get:()=>t[r],enumerable:!(o=hs(t,r))||o.enumerable});return e};var Ce=(e,t,n)=>(n=e!=null?ms(ps(e)):{},ys(t||!e||!e.__esModule?so(n,"default",{value:e,enumerable:!0}):n,e));var pm=Math.PI/180;function fn(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 Je(e){return e.length?fn(e):null}function ao(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 co(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[ao(e,.5)];let o=Array.from({length:n+1},(c,f)=>ao(e,f/n)),r=new Float64Array(o.length);for(let c=1;c<o.length;c+=1){let f=o[c].x-o[c-1].x,l=o[c].y-o[c-1].y;r[c]=r[c-1]+Math.hypot(f,l)}let i=r[r.length-1];if(i<=1e-9)return Array.from({length:t},()=>({...e.start}));let s=[],a=1;for(let c=0;c<t;c+=1){let f=i*c/(t-1);for(;a<r.length-1&&r[a]<f;)a+=1;let l=r[a-1],u=r[a],h=u===l?0:(f-l)/(u-l);s.push({x:o[a-1].x+(o[a].x-o[a-1].x)*h,y:o[a-1].y+(o[a].y-o[a-1].y)*h})}return s}function lo(e,t,n){return Math.max(t,Math.min(n,e))}function uo(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((h,m)=>h.segmentedRow.componentIndex-m.segmentedRow.componentIndex),s=i[0]?.segmentedRow?.componentCount??0,a=i[0]?.segmentedRow;if(!a||!(s>=2&&i.length===s&&a?.boundaryBefore==="start"&&i.every((h,m)=>h.segmentedRow?.kind==="segmented-row-v1"&&h.segmentedRow.groupId===o&&h.segmentedRow.componentCount===s&&h.segmentedRow.componentIndex===m&&h.segmentedRow.repeatLabelOnComponents===a.repeatLabelOnComponents&&(m===0?h.segmentedRow.boundaryBefore==="start":h.segmentedRow.boundaryBefore!=="start")&&h.segmentedRow.displayLabel===a.displayLabel)))continue;let f=i.reduce((h,m)=>h+m.seatCount,0),l=0,u=0;for(let h of i)h.segmentedRow.boundaryBefore==="break"&&(l+=1),t.set(h.id,{groupId:o,adjacencyOffset:l,displayOffset:u,displayLabel:a.displayLabel,totalSeats:f,canonical:i[0],viewFromSeatUrl:a.viewFromSeatUrl,viewFromSeatMeta:a.viewFromSeatMeta,confidenceEvidence:a.confidenceEvidence}),l+=h.seatCount,u+=h.seatCount}return t}var xs="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var gs="abcdefghijklmnopqrstuvwxyz";function Ms(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 mt(e,t=!1){let n=t?gs:xs;return Ms(Math.max(0,Math.floor(e)-1),n)}var Ss=[[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 fo(e){if(!Number.isFinite(e)||e<=0)return String(e);let t=Math.floor(e),n="";for(let[o,r]of Ss)for(;t>=o;)n+=r,t-=o;return n}function Is(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 vt(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,c=e.seatCount;if(i==="updown"||i==="updown-descending"){let m=Math.ceil(c/2),d=i==="updown"?t<m?n+2*t:n-1+2*(c-t):t<m?n+2*(m-1-t):n+1+2*(t-m);return`${s}${d}`}let f=i==="odd"||i==="even"?2:r,l=a!=null&&Number.isFinite(a)?a-(c-1)*f:n,u=o==="center"?Is(c)[t]:o==="rtl"?c-1-t:t,h;switch(i){case"odd":{let m=l%2===1?l:l+1;h=String(m+u*2);break}case"even":{let m=l%2===0?l:l+1;h=String(m+u*2);break}case"roman":h=fo(l+u*r);break;case"letters-upper":h=mt(l+u*r,!1);break;case"letters-lower":h=mt(l+u*r,!0);break;default:h=String(l+u*r);break}return`${s}${h}`}function Rs(e){return{...e.canonical,seatCount:e.totalSeats,label:e.displayLabel,displayLabel:e.displayLabel}}function mo(e,t,n){return n?.label??`${e.seatLabelBase??e.label}-${vt(e,t)}`}function mn(e,t,n,o){if(o?.displayLabel)return o.displayLabel;if(e.seatDisplayLabelMode==="number")return vt(e,t);if(!n)return`${e.displayLabel||e.label}-${vt(e,t)}`;let r=Rs(n),i=n.displayOffset+t;return`${n.displayLabel}-${vt(r,i)}`}function ho(e,t){return`${e.label}-${t+1}`}function ws(e,t,n){return e?.direction==="anticlockwise"?Math.max(0,t-1-n):n}function Ps(e,t){let n=e.chairNumbering,o=n?.start??1,r=ws(n,Math.max(0,Math.round(e.seatCount)),t);return n?.format==="letter"?mt(Math.max(1,o)+r):String(o+r)}function po(e,t){let n=Ps(e,t);return(e.chairNumbering?.format??"table-number")==="table-number"?`${e.displayLabel??e.label}-${n}`:n}var $=.02291666666666667,Ie=1/$,As=58,Es=As*$;var _s=3,bo=0,hn=120,Cs=0,vs=45,ks=7,ve=1.2;function dn(e,t,n,o){return Number.isFinite(e)?Math.max(t,Math.min(n,e)):o}function Ts(e){return!Number.isFinite(e)||!Number.isInteger(e)||e<0?0:e<=ks?e:_s}function Ge(e,t={}){let n=dn(t.floorBaseHeightM,bo,hn,0),o=Math.min(hn,n+Ts(e.elevation)*Es),r=e.height===void 0?o:dn(e.height,bo,hn,o),i=dn(e.rake,Cs,vs,0);return{height:r,rake:i}}function yo(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 et(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,c=s.y-i.y,f=a*a+c*c,l=f>1e-12?((t-i.x)*a+(n-i.y)*c)/f:0;l<0?l=0:l>1&&(l=1);let u=t-(i.x+l*a),h=n-(i.y+l*c);if(Math.abs(u)>=o||Math.abs(h)>=o)continue;let m=Math.hypot(u,h);m<o&&(o=m)}return o}function Os(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 xo(e,t){return Math.hypot(e.cx-t.cx,e.cy-t.cy)-e.r-t.r}function pn(e,t){let n=1/0;for(let o of yo(e)){let r=et(t,o.x,o.y);r<n&&(n=r)}for(let o of yo(t)){let r=et(e,o.x,o.y);r<n&&(n=r)}return n}function Ls(e,t){if(e.length<3)return{pts:e,seatIndices:t};let n=0,o=0;for(let l of e)n+=l.x,o+=l.y;n/=e.length,o/=e.length;let r=-1,i=e[0];for(let l of e){let u=Math.hypot(l.x-n,l.y-o);u>r&&(r=u,i=l)}let s=i.x-n,a=i.y-o,c=Math.hypot(s,a);c>1e-9?(s/=c,a/=c):(s=1,a=0);let f=e.map((l,u)=>({p:l,i:u,t:(l.x-n)*s+(l.y-o)*a})).sort((l,u)=>l.t-u.t);return{pts:f.map(l=>l.p),seatIndices:f.map(l=>t[l.i])}}function bn(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,c=0,f=0,l=0;for(let g of e){let R=g.x-n,A=g.y-o;r+=R*R,s+=A*A,i+=R*A,a+=R*R*R,c+=A*A*A,f+=R*A*A,l+=A*R*R}let u=r*s-i*i;if(Math.abs(u)<1e-9)return null;let h=(a+f)/2,m=(c+l)/2,d=(h*s-m*i)/u,p=(m*r-h*i)/u,y=d+n,x=p+o;return!Number.isFinite(y)||!Number.isFinite(x)?null:{cx:y,cy:x}}var Bs=.15;function Fs(e){if(e.length<2)return null;let t=e.map(M=>{let b=0,I=0;for(let S of M.pts)b+=S.x,I+=S.y;return{x:b/M.pts.length,y:I/M.pts.length}}),n=0,o=0;for(let M of t)n+=M.x,o+=M.y;n/=t.length,o/=t.length;let r=0,i=0,s=0;for(let M of t){let b=M.x-n,I=M.y-o;r+=b*b,i+=b*I,s+=I*I}let a=r+s,c=r*s-i*i,f=a/2+Math.sqrt(Math.max(0,a*a/4-c)),l,u;Math.abs(i)>1e-12?(l=f-s,u=i):r>=s?(l=1,u=0):(l=0,u=1);let h=Math.hypot(l,u);if(!(h>1e-12))return null;l/=h,u/=h;let m=0,d=0,p=0;for(let M of e){if(M.pts.length<2)continue;let b=M.pts[0],I=M.pts[M.pts.length-1],S=I.x-b.x,w=I.y-b.y,_=Math.hypot(S,w);if(!(_>1e-9))continue;let k=S/_,L=w/_;m+=(k*k-L*L)*_,d+=2*k*L*_,p+=_}if(p>0&&Math.hypot(m,d)>=Ds*p){let M=Math.atan2(d,m)/2,b=Math.cos(M),I=Math.sin(M);Math.abs(l*b+u*I)>Gs&&(l=-I,u=b)}let y=1/0,x=-1/0,g=[];for(let M of e){let b=1/0,I=-1/0;for(let S of M.pts){let w=S.x*l+S.y*u;w<b&&(b=w),w>I&&(I=w),w<y&&(y=w),w>x&&(x=w)}g.push(I-b)}let R=x-y;return R>1e-9?(g.sort((M,b)=>M-b),g[Math.min(g.length-1,Math.floor(g.length*.9))]/R<=Ns?{x:l,y:u}:null):null}var Ns=.35,Ds=.8,Gs=.7;function kt(e,t,n,o){let r=new Map;for(let b of n){let I=t[b],S=I.rowId||`__seat-${b}`,w=r.get(S);w||(w={pts:[],idx:[]},r.set(S,w)),w.pts.push({x:I.x,y:I.y}),w.idx.push(b)}if(!r.size)return{sectionId:e,rows:[],blockCount:0};let i=[];for(let[b,I]of r){let S=Ls(I.pts,I.idx),w=0;for(let _ of S.pts)w+=Math.hypot(_.x-o.x,_.y-o.y);i.push({id:b,pts:S.pts,seatIndices:S.seatIndices,blockId:-1,ordinal:0,blockDepth:0,focalDistance:w/S.pts.length})}let s=i.map(b=>Os(b.pts)),a=i.length<=256?i.length*(i.length-1)/2:0,c=a?new Float64Array(a):null;c?.fill(Number.NaN);let f=c?new Map(i.map((b,I)=>[b,I])):null,l=(b,I)=>(b>I&&([b,I]=[I,b]),b*(2*i.length-b-1)/2+(I-b-1)),u=(b,I)=>{if(!c)return pn(i[b].pts,i[I].pts);let S=l(b,I),w=c[S];if(!Number.isNaN(w))return w;let _=pn(i[b].pts,i[I].pts);return c[S]=_,_},h=(b,I)=>f?u(f.get(b),f.get(I)):pn(b.pts,I.pts),m=[];for(let b=0;b<i.length;b++){let I=1/0;for(let S=0;S<i.length;S++){if(b===S||xo(s[b],s[S])>=I)continue;let w=u(b,S);w<I&&(I=w)}Number.isFinite(I)&&m.push(I)}m.sort((b,I)=>b-I);let d=m.length?m[Math.floor(m.length/2)]:1,p=Math.max(d*1.8,1e-6),y=i.map(()=>[]);for(let b=0;b<i.length;b++)for(let I=b+1;I<i.length;I++)xo(s[b],s[I])>p||u(b,I)<=p&&(y[b].push(I),y[I].push(b));let x=0;for(let b=0;b<i.length;b++){if(i[b].blockId!==-1)continue;let I=x++,S=[b];for(i[b].blockId=I;S.length;){let w=S.pop();for(let _ of y[w])i[_].blockId===-1&&(i[_].blockId=I,S.push(_))}}let g=new Map;for(let b of i){let I=g.get(b.blockId)??[];I.push(b),g.set(b.blockId,I)}let R=[];for(let b of i){if(b.pts.length<4)continue;let I=bn(b.pts);I&&(!Number.isFinite(I.cx)||!Number.isFinite(I.cy)||R.push({x:I.cx,y:I.cy}))}let A=R.length>=2?(()=>{let b=R.map(w=>w.x).sort((w,_)=>w-_),I=R.map(w=>w.y).sort((w,_)=>w-_),S=Math.floor(R.length/2);return{cx:b[S],cy:I[S]}})():null;if(A){let b=L=>Math.hypot(L.x-A.cx,L.y-A.cy),I=1/0,S=-1/0,w=[];for(let L of i){let C=1/0,E=-1/0;for(let v of L.pts){let T=b(v);T<C&&(C=T),T>E&&(E=T)}w.push(E-C),C<I&&(I=C),E>S&&(S=E)}let _=S-I;w.sort((L,C)=>L-C);let k=w[Math.min(w.length-1,Math.floor(w.length*.9))];if(_>1e-9&&k/_<=Bs){let L=i.map(N=>{let V=0;for(let X of N.pts)V+=b(X);return{row:N,radius:V/N.pts.length}}),C=0,E=0;for(let N of L)C+=N.radius,E+=N.row.focalDistance;C/=L.length,E/=L.length;let v=0;for(let N of L)v+=(N.radius-C)*(N.row.focalDistance-E);if(v<0)for(let N of L)N.radius=-N.radius;let F=1/0;for(let N of L)N.radius<F&&(F=N.radius);L.sort((N,V)=>N.radius-V.radius);let O=-1,B=-1/0,D=_/Math.max(1,L.length)*.5,H=[];for(let N of L)N.radius-B>D&&(O++,B=N.radius),N.row.ordinal=O,N.row.blockDepth=N.radius-F,H.push(N.row);return{sectionId:e,rows:H,blockCount:x}}}let M=[];for(let[,b]of g){let I=Fs(b);if(I){let S=L=>{let C=0;for(let E of L.pts)C+=E.x*I.x+E.y*I.y;return C/L.pts.length};b.sort((L,C)=>S(L)-S(C)),b.length>=2&&b[0].focalDistance>b[b.length-1].focalDistance&&b.reverse();let w=[],_=d*.5;for(let L of b){let C=w[w.length-1];C&&Math.abs(S(L)-S(C[0]))<_?C.push(L):w.push([L])}let k=0;for(let L=0;L<w.length;L++){if(L>0){let C=1/0;for(let E of w[L-1])for(let v of w[L])C=Math.min(C,h(E,v));k+=C}for(let C of w[L])C.ordinal=L,C.blockDepth=k,M.push(C)}}else{let S=1/0;for(let w of b)w.focalDistance<S&&(S=w.focalDistance);b.sort((w,_)=>w.focalDistance-_.focalDistance);for(let w=0;w<b.length;w++)b[w].ordinal=w,b[w].blockDepth=Math.max(0,b[w].focalDistance-S),M.push(b[w])}}return{sectionId:e,rows:M,blockCount:x}}var js=/^\d{4}-\d{2}-\d{2}$/;function Hs(e){let t=Date.parse(e);return Number.isFinite(t)?js.test(e)?t+864e5:t:null}function Xs(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=Hs(e.validUntil);return n===null?!1:(t instanceof Date?t.getTime():t)<n}function Us(e,t,n){return!(e.eventConfigurationId&&e.eventConfigurationId!==t||e.eventConfigurationVersion!==void 0&&e.eventConfigurationVersion!==n)}function Vs(e){return e.status!=="draft"&&e.status!=="retracted"}function Ks(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 go(e,t={}){return!!e&&Vs(e)&&Us(e,t.activeConfigurationId,t.activeConfigurationVersion)&&Ks(e,t.activeBasisSha256)&&Xs(e,t.now)}var Ys=new Set(["pitch-football","rink-hockey","track-athletics","oval-cricket","pitch-rugby","diamond-baseball","court-basketball","court-tennis","ring-boxing"]),Ws=new Set(["pitch-football","track-athletics","oval-cricket","pitch-rugby","diamond-baseball"]);function ze(e){return!!e&&Ys.has(e)}function Tt(e){return!!e&&Ws.has(e)}var Ot=1.1,zs={"pitch-football":{width:105,height:68},"rink-hockey":{width:60,height:30},"track-athletics":{width:176.9,height:92.5},"oval-cricket":{width:150,height:140},"pitch-rugby":{width:120,height:70},"diamond-baseball":{width:140,height:140},"court-basketball":{width:32,height:19},"court-tennis":{width:36.57,height:18.29},"ring-boxing":{width:7.8,height:7.8}},Zs={"pitch-football":"#2f7d4f","rink-hockey":"#e8f1f8","track-athletics":"#a4472f","oval-cricket":"#3d8a53","pitch-rugby":"#2f7d4f","diamond-baseball":"#2f7d4f","court-basketball":"#c8894f","court-tennis":"#3f7a5a","ring-boxing":"#2a4d8f"};var $s=Math.PI*2;function Qs(e,t,n,o,r,i){return{x:r+e*n-t*o,y:i+e*o+t*n}}function Mo(e,t){let n=Math.max(0,e-t),o=[],r=20;for(let i=0;i<=r;i++){let s=-Math.PI/2+i/r*Math.PI;o.push({x:n+t*Math.cos(s),y:t*Math.sin(s)})}for(let i=0;i<=r;i++){let s=Math.PI/2+i/r*Math.PI;o.push({x:-n+t*Math.cos(s),y:t*Math.sin(s)})}return o}var So=(()=>{let t={x:0,y:52},n=25,o={x:70,y:t.y-70},r=(o.x*o.x+o.y*o.y-4900)/(2*(o.y+70)),i=r+70,s=[],a=Math.atan2(o.y-r,o.x),c=Math.atan2(o.y-r,-o.x);for(let f=0;f<=24;f++){let l=a+(c-a)*f/24;s.push({x:i*Math.cos(l),y:r+i*Math.sin(l)})}return{half:70,home:t,backstop:n,fence:s}})();var Lt="#f1f5f9";function ht(e){return ze(e)}function je(e,t,n,o,r=32){let i=[];for(let s=0;s<r;s++){let a=s/r*$s;i.push({x:e+n*Math.cos(a),y:t+o*Math.sin(a)})}return i}function Oe(e,t,n,o){return[{x:e-n,y:t-o},{x:e+n,y:t-o},{x:e+n,y:t+o},{x:e-n,y:t+o}]}function qs(e){let{kind:t,cx:n,cy:o,width:r,height:i}=e,s=(e.rotation??0)*Math.PI/180,a=Math.cos(s),c=Math.sin(s),f=r/2,l=i/2,u=[],h=zs[t],m=p=>h?p/h.width*r:0,d=p=>h?p/h.height*i:0;switch(t){case"pitch-football":{u.push({points:[{x:0,y:-l},{x:0,y:l}],closed:!1}),u.push({points:je(0,0,m(9.15),d(9.15)),closed:!0});for(let p of[-1,1])u.push({points:Oe(p*(f-m(16.5)/2),0,m(16.5)/2,d(40.32)/2),closed:!0}),u.push({points:Oe(p*(f-m(5.5)/2),0,m(5.5)/2,d(18.32)/2),closed:!0});break}case"rink-hockey":{u.push({points:[{x:0,y:-l},{x:0,y:l}],closed:!1,ink:"#d63b3b"});for(let p of[-1,1]){u.push({points:[{x:p*m(7.5),y:-l},{x:p*m(7.5),y:l}],closed:!1,ink:"#2f6ecb"}),u.push({points:[{x:p*(f-m(4)),y:-d(11)},{x:p*(f-m(4)),y:d(11)}],closed:!1,ink:"#d63b3b"});for(let y of[-1,1])u.push({points:je(p*m(20.5),y*d(7),m(4.5),d(4.5)),closed:!0,ink:"#2f6ecb"})}u.push({points:je(0,0,m(4.5),d(4.5)),closed:!0,ink:"#2f6ecb"});break}case"track-athletics":{let y=l-d(1.22)*8;y>0&&u.push({points:Mo(f-m(1.22)*8,y),closed:!0,fill:"#2f7d4f"});for(let x=1;x<8;x++){let g=d(1.22)*x,R=l-g;if(R<=0)break;u.push({points:Mo(f-m(1.22)*x,R),closed:!0})}break}case"oval-cricket":{u.push({points:je(0,0,m(27.4),d(27.4+20.12/2),40),closed:!0}),u.push({points:Oe(0,0,m(3.05)/2,d(20.12)/2),closed:!0,ink:"#d8cfae"});break}case"pitch-rugby":{let p=y=>({points:[{x:m(y),y:-l},{x:m(y),y:l}],closed:!1});u.push(p(0));for(let y of[-1,1]){u.push(p(y*50),p(y*28));for(let x=-35;x<35;x+=4)u.push({points:[{x:m(y*10),y:d(x)},{x:m(y*10),y:d(Math.min(35,x+2))}],closed:!1})}break}case"diamond-baseball":{let p=(T,F)=>({x:m(T),y:d(F)}),{home:y}=So,x=27.43,g=x/Math.SQRT2,R={x:y.x+g,y:y.y-g},A={x:y.x,y:y.y-2*g},M={x:y.x-g,y:y.y-g},b={x:y.x,y:y.y-18.44},I="#b98a59",S=Zs["diamond-baseball"],w=38.94,_=[p(y.x,y.y)],k=Math.atan2(y.y-w/Math.SQRT2-b.y,w/Math.SQRT2),L=Math.PI-k;for(let T=0;T<=16;T++){let F=k-(k+Math.PI*2-L)%(Math.PI*2)*(T/16);_.push(p(b.x+29*Math.cos(F),b.y+29*Math.sin(F)))}u.push({points:_,closed:!0,fill:I,ink:I});let C={x:y.x,y:y.y-g},E=[{x:y.x,y:y.y},R,A,M].map(T=>p(C.x+(T.x-C.x)*.84,C.y+(T.y-C.y)*.84));u.push({points:E,closed:!0,fill:S,ink:S}),u.push({points:je(m(b.x),d(b.y),m(2.74),d(2.74),20),closed:!0,fill:I,ink:I}),u.push({points:je(m(y.x),d(y.y),m(3.96),d(3.96),20),closed:!0,fill:I,ink:I});let v=So.fence;u.push({points:[p(y.x,y.y),p(v[0].x,v[0].y)],closed:!1}),u.push({points:[p(y.x,y.y),p(v[v.length-1].x,v[v.length-1].y)],closed:!1});for(let T of[R,A,M])u.push({points:Oe(m(T.x),d(T.y),m(.3),d(.3)),closed:!0,fill:Lt});break}case"court-basketball":{u.push({points:Oe(0,0,m(14),d(7.5)),closed:!0}),u.push({points:[{x:0,y:-d(7.5)},{x:0,y:d(7.5)}],closed:!1}),u.push({points:je(0,0,m(1.8),d(1.8),24),closed:!0});for(let p of[-1,1]){let y=p*14,x=p*(14-5.8),g=p*(14-1.575);u.push({points:Oe(m((y+x)/2),0,m(2.9),d(2.45)),closed:!0,fill:"#2f5d8a"}),u.push({points:je(m(x),0,m(1.8),d(1.8),24),closed:!0});let R=Math.sqrt(6.75*6.75-6.6*6.6),A=[{x:m(y),y:-d(6.6)}],M=Math.atan2(-6.6,-p*R),b=2*Math.atan2(6.6,R);for(let I=0;I<=16;I++){let S=M-p*b*(I/16);A.push({x:m(g+6.75*Math.cos(S)),y:d(6.75*Math.sin(S))})}A.push({x:m(y),y:d(6.6)}),u.push({points:A,closed:!1})}break}case"court-tennis":{u.push({points:Oe(0,0,m(11.885),d(5.485)),closed:!0,fill:"#2b5f99"});for(let p of[-1,1])u.push({points:[{x:-m(11.885),y:p*d(4.115)},{x:m(11.885),y:p*d(4.115)}],closed:!1}),u.push({points:[{x:p*m(6.4),y:-d(4.115)},{x:p*m(6.4),y:d(4.115)}],closed:!1});u.push({points:[{x:-m(6.4),y:0},{x:m(6.4),y:0}],closed:!1}),u.push({points:[{x:0,y:-d(6.4)},{x:0,y:d(6.4)}],closed:!1,ink:"#d1d5db"});break}case"ring-boxing":{u.push({points:Oe(0,0,m(3.05),d(3.05)),closed:!0});let x=[[-1,-1,"#c53030"],[1,1,"#2b6cb0"],[1,-1,"#e2e8f0"],[-1,1,"#e2e8f0"]];for(let[g,R,A]of x)u.push({points:Oe(g*m(3.05),R*d(3.05),m(.3),d(.3)),closed:!0,fill:A,ink:A});break}default:return[]}return u.map(p=>({...p,points:p.points.map(y=>Qs(y.x,y.y,a,c,n,o))}))}function Io(e){if(e.role!=="stage"||!ht(e.stageKind))return[];let t=null;if(e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null&&e.width>0&&e.height>0&&[e.x,e.y,e.width,e.height].every(Number.isFinite))t={cx:e.x+e.width/2,cy:e.y+e.height/2,width:e.width,height:e.height};else if(e.points&&e.points.length>=3&&e.points.every(n=>Number.isFinite(n.x)&&Number.isFinite(n.y))){let n=e.points.map(l=>l.x),o=e.points.map(l=>l.y),r=Math.min(...n),i=Math.max(...n),s=Math.min(...o),a=Math.max(...o),c=Math.max(1,i-r),f=Math.max(1,a-s);t={cx:r+c/2,cy:s+f/2,width:c,height:f}}return t?qs({kind:e.stageKind,...t}):[]}var Js=/^data:image\/(?:png|jpe?g|webp|gif|avif);base64,[a-z0-9+/]+={0,2}$/i,ea=/[\s"'<>`\\]/;function ta(e){if(typeof e!="string"||!e||e.length>2e6||e!==e.trim())return!1;if(e.startsWith("data:"))return Js.test(e);if(ea.test(e))return!1;try{let t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}}function Ro(e){let t=e.trim();return ta(t)?t:null}var yn="seatlayer.event-configuration/1";var tt=100,na=120,oa=2e5,ra=1e4,ia=/^[a-f0-9]{64}$/,sa=new Set(["stage","screen","barrier","camera_platform","sound_desk","rigging_truss"]);function dt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ze(e,t){return typeof e=="string"&&e.length>=1&&e.length<=t&&e.normalize("NFKC").trim()===e}function aa(e){return typeof e=="number"&&Number.isInteger(e)&&e>0}function wo(e){return!Array.isArray(e)||e.length>oa||!e.every(t=>Ze(t,tt))?null:[...new Set(e)].sort()}function ca(e){return!dt(e)||!Ze(e.chartId,tt)||!Ze(e.version,tt)||e.sha256!==void 0&&(typeof e.sha256!="string"||!ia.test(e.sha256))?null:{chartId:e.chartId,version:e.version,...typeof e.sha256=="string"?{sha256:e.sha256}:{}}}function xn(e,t,n){return typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=n}function la(e){return dt(e)?e.mode==="none"||e.mode==="opaque"?e.opacity===void 0?{mode:e.mode}:null:e.mode==="partial"&&xn(e.opacity,.01,.99)?{mode:"partial",opacity:e.opacity}:null:null}function ua(e,t){if(e===void 0)return;if(!Array.isArray(e)||e.length>ra)return null;let n=new Set(t),o=new Set,r=new Set,i=0,s=[];for(let a of e){if(!dt(a)||!Ze(a.id,tt)||!Ze(a.objectId,tt)||!n.has(a.objectId)||!sa.has(String(a.kind))||!xn(a.heightM,.05,50)||a.baseElevationM!==void 0&&!xn(a.baseElevationM,-10,100))return null;let c=la(a.occlusion);if(!c||o.has(a.id)||r.has(a.objectId))return null;let f=a.contentImageUrl===void 0?void 0:typeof a.contentImageUrl=="string"?Ro(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:c,...f?{contentImageUrl:f}:{}})}return s.sort((a,c)=>a.id.localeCompare(c.id))}function fa(e){let t=[];if(!dt(e))return{issues:[{code:"invalid_export",path:"configuration",message:"Configuration must be an object"}]};e.schema!==yn&&t.push({code:"unsupported_schema",path:"configuration.schema",message:`Configuration schema must be ${yn}`}),Ze(e.id,tt)||t.push({code:"invalid_id",path:"configuration.id",message:"Configuration id must contain 1 to 100 normalized characters"}),Ze(e.label,na)||t.push({code:"invalid_label",path:"configuration.label",message:"Configuration label must contain 1 to 120 normalized characters"}),aa(e.version)||t.push({code:"invalid_version",path:"configuration.version",message:"Configuration version must be a positive integer"});let n=ca(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=dt(e.overlay)?e.overlay:null,r=wo(o?.objectIds),i=wo(o?.productionKillSeatIds),s=r?ua(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:yn,id:e.id,label:e.label,version:e.version,baseVenue:n,overlay:{objectIds:r,productionKillSeatIds:i,...s!==void 0?{productionElements:s}:{}}}}}function Po(e){let t=fa(e);return t.value?{ok:!0,value:t.value}:{ok:!1,issues:t.issues}}function ma(e){if((e.kind==="polygon"||e.kind==="polyline"||e.kind==="line")&&e.points&&e.points.length>=2)return e.points;if(e.x==null||e.y==null||e.width==null||e.height==null)return null;let t=e.x,n=e.y,o=e.width,r=e.height;return[{x:t,y:n},{x:t+o,y:n},{x:t+o,y:n+r},{x:t,y:n+r}]}function ha(e,t,n){let o=n*Math.PI/180,r=Math.cos(o),i=Math.sin(o),s=e.x-t.x,a=e.y-t.y;return{x:t.x+s*r-a*i,y:t.y+s*i+a*r}}function Ao(e){let t=ma(e);if(!t||t.length<2)return null;let n=e.rotation??0,o=Math.abs(n)<1e-6?t:t.map(c=>ha(c,{x:t.reduce((f,l)=>f+l.x,0)/t.length,y:t.reduce((f,l)=>f+l.y,0)/t.length},n)),r=1/0,i=1/0,s=-1/0,a=-1/0;for(let c of o)r=Math.min(r,c.x),i=Math.min(i,c.y),s=Math.max(s,c.x),a=Math.max(a,c.y);return!Number.isFinite(r)||s-r<1e-6||a-i<1e-6?null:{minX:r,minY:i,maxX:s,maxY:a}}var da=5,pa=3,ba=.92,ya=1.9,xa=2,ga=.6,Ma=1,Sa=.06;function Ia(e){return e.heightM!==void 0?e.heightM:e.stageKind==="ring-boxing"?Ot:ht(e.stageKind)?Sa:Ma}function Eo(e){let t=1/0,n=1/0,o=-1/0,r=-1/0,i=-1/0;for(let s of vo(e)){let a=s.baseHeightM??0;for(let c of s.objects){if(c.type!=="shape"||c.role!=="stage")continue;let f=Ao(c);f&&(t=Math.min(t,f.minX),n=Math.min(n,f.minY),o=Math.max(o,f.maxX),r=Math.max(r,f.maxY),i=Math.max(i,a+Ia(c)))}}return!Number.isFinite(t)||!Number.isFinite(i)?null:{minX:t,minY:n,maxX:o,maxY:r,deckTopM:i}}function Ra(e,t,n,o){let r=1/0,i=1/0,s=-1/0,a=-1/0;for(let m of e)Number.isFinite(m.eyeHeightM)&&(r=Math.min(r,m.x),s=Math.max(s,m.x),i=Math.min(i,m.y),a=Math.max(a,m.y));if(!Number.isFinite(r))return null;let c=r*t,f=i*t,l=Math.max(1,Math.ceil((s-r)*t/n)+1),u=Math.max(1,Math.ceil((a-i)*t/n)+1),h=new Float64Array(l*u).fill(-1/0);for(let m of e){if(!Number.isFinite(m.eyeHeightM))continue;let d=m.eyeHeightM-ve,p=Math.min(l-1,Math.max(0,Math.floor((m.x*t-c)/n))),x=Math.min(u-1,Math.max(0,Math.floor((m.y*t-f)/n)))*l+p,g=d+o;g>h[x]&&(h[x]=g)}return{cellM:n,minX:c,minY:f,cols:l,rows:u,top:h}}function wa(e,t,n){let o=Math.floor((t-e.minX)/e.cellM),r=Math.floor((n-e.minY)/e.cellM);return o<0||r<0||o>=e.cols||r>=e.rows?-1/0:e.top[r*e.cols+o]}function _o(e,t,n={}){let o=new Map;if(!t||!e.length)return o;let r=n.metresPerChartUnit??$,i=n.cellM??ga,s=n.chairBackM??ba,a=n.selfRowSkipM??xa,c=n.clearThreshold??.9,f=n.partialThreshold??.25,l=Math.max(1,n.columns??da),u=Math.max(1,n.rows??pa),h=Ra(e,r,i,s);if(!h)return o;let m=(t.maxX-t.minX)*r,d=(t.maxY-t.minY)*r,p=m>=d,y=(t.minX+t.maxX)/2*r,x=(t.minY+t.maxY)/2*r,g=[];for(let A=0;A<l;A++){let M=(A+.5)/l-.5,b=p?y+M*m:y,I=p?x:x+M*d;for(let S=0;S<u;S++){let w=t.deckTopM+(u===1?0:S/(u-1)*ya);g.push({x:b,y:I,z:w})}}let R=i/2;for(let A of e){if(!Number.isFinite(A.eyeHeightM))continue;let M=A.x*r,b=A.y*r,I=A.eyeHeightM,S=0,w=1/0;for(let k of g){let L=k.x-M,C=k.y-b,E=Math.hypot(L,C);if(!(E>a)){S++;continue}let v=L/E,T=C/E,F=0;for(let O=a;O<E;O+=R){let B=wa(h,M+v*O,b+T*O);if(!(!Number.isFinite(B)||B>=I)&&B>I+(k.z-I)*O/E){F=O;break}}F?w=Math.min(w,F):S++}let _=S/g.length;_>=c||o.set(A.id,{seatId:A.id,mark:_<f?"obstructedView":"restrictedView",visibleFraction:_,totalRays:g.length,atDistanceM:Number.isFinite(w)?w:0})}return o}function Co(e,t){if(!t.size)return 0;let n=0;for(let o of e){let r=t.get(o.id);if(!r)continue;let i=o.commercial;i?.restrictedView!==void 0||i?.obstructedView!==void 0||(o.commercial={...i,[r.mark]:!0},n++)}return n}function gn(e){return e?e.accessibility?.length?e.wheelchairSpaceType&&!e.accessibility.includes("wheelchair")?["wheelchair",...e.accessibility]:e.accessibility:e.wheelchairSpaceType?["wheelchair"]:e.accessible?["wheelchair"]:[]:[]}var Ft=Math.PI/180;var pt=16;function Mn(e,t,n,o){let r=n*Ft,i=Math.cos(r),s=Math.sin(r);return{x:o.x+e*i-t*s,y:o.y+e*s+t*i}}function Bo(e){let{seatCount:t,seatSpacing:n,curve:o,rotation:r,origin:i}=e,s=[];if(e.path)return co(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(Mn(f*n,0,r,i));return s}let a=o/(t-1)*Ft,c=n/(2*Math.sin(Math.abs(a)/2));for(let f=0;f<t;f++){let l=f*a,u=c*Math.sin(l),h=-c+c*Math.cos(l);s.push(Mn(u,h,r,i))}return s}function Fo(e){let t=new Map;if(e.overrides)for(let n of e.overrides)t.set(n.index,n);return t}function Pa(e,t){let n=Fo(e);return Bo(e).map((o,r)=>{let i=n.get(r),s=gn(i),a=mo(e,r,i),c={...e.commercial,...i?.commercial};return{index:r,x:o.x+(i?.dx??0),y:o.y+(i?.dy??0),label:a,displayLabel:mn(e,r,t,i),categoryKey:i?.categoryKey??e.categoryKey,skipped:!!i?.skip,accessible:s.length>0,accessibility:s,wheelchairSpaceType:i?.wheelchairSpaceType,commercial:Object.values(c).some(f=>f!==void 0&&f!==!1&&f!=="")?c:void 0,glyph:i?.glyph,viewUrl:i?.viewFromSeatUrl??e.viewFromSeatUrl,viewMeta:i?.viewFromSeatUrl?i.viewFromSeatMeta:e.viewFromSeatMeta,labelStyle:i?.labelStyle??e.seatLabelStyle}})}function Aa(e){let t=[];for(let n of Pa(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 Ea(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 _a(e){let t=[],n=Math.max(0,Math.round(e.seatCount));if(n===0)return t;let o=new Map((e.overrides??[]).map(l=>[l.index,l])),r=(l,u,h,m)=>{let d=o.get(l),p=gn(d),y=d?.label??ho(e,l);return{index:l,label:y,displayLabel:d?.displayLabel??po(e,l),x:u+(d?.dx??0),y:h+(d?.dy??0),categoryKey:d?.categoryKey??e.categoryKey,skipped:!!d?.skip,accessible:p.length>0,accessibility:p,wheelchairSpaceType:d?.wheelchairSpaceType,commercial:d?.commercial,glyph:d?.glyph,viewUrl:d?.viewFromSeatUrl,viewMeta:d?.viewFromSeatUrl?d.viewFromSeatMeta:void 0,labelStyle:d?.labelStyle,...m?{side:m}:{}}};if(e.shape==="round"){let l=(e.radius??40)+pt,u=e.rotation*Ft,h=Math.max(0,Math.min(360,e.seatArc??360));if(h>=360||n===1){for(let y=0;y<n;y++){let x=u+y/n*2*Math.PI;t.push(r(y,e.center.x+l*Math.cos(x),e.center.y+l*Math.sin(x)))}return t}let m=h*Ft,d=(2*Math.PI-m)/2,p=u+d;for(let y=0;y<n;y++){let x=p+y/(n-1)*m;t.push(r(y,e.center.x+l*Math.cos(x),e.center.y+l*Math.sin(x)))}return t}let i=e.width??80,s=e.height??50,a=Ea(e),c=["top","bottom","left","right"],f=0;for(let l of c){let u=a[l];for(let h=0;h<u;h++){let m,d;l==="top"?(m=-i/2+(h+.5)*i/u,d=-s/2-pt):l==="bottom"?(m=-i/2+(h+.5)*i/u,d=s/2+pt):l==="left"?(m=-i/2-pt,d=-s/2+(h+.5)*s/u):(m=i/2+pt,d=-s/2+(h+.5)*s/u);let p=Mn(m,d,e.rotation,e.center);t.push(r(f++,p.x,p.y,l))}}return t}function Ca(e){return _a(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 va(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",...e.commercial?.note?{commercial:{note:e.commercial.note}}:{}}]}function ko(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,c=t[r].y;s>e.y!=c>e.y&&e.x<(a-i)*(e.y-s)/(c-s)+i&&(n=!n)}return n}function ka(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 Sn(e){return Array.isArray(e)?e.filter(t=>Array.isArray(t)&&t.length>=3):[]}function he(e,t,n){return ko(e,t)&&!Sn(n).some(o=>ko(e,o)||ka(e,o))}function Bt(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 No(e){switch(e.type){case"row":{let t=Bo(e),n=Fo(e),o=0,r=0,i=0;for(let s=0;s<t.length;s++){let a=n.get(s);a?.skip||(o+=t[s].x+(a?.dx??0),r+=t[s].y+(a?.dy??0),i++)}return i?{x:o/i,y:r/i}:{x:e.origin.x,y:e.origin.y}}case"table":case"booth":return{x:e.center.x,y:e.center.y};case"gaArea":return Bt(e.points);case"section":return Bt(e.outline);case"text":return{x:e.position.x,y:e.position.y};case"shape":return e.points&&e.points.length?Bt(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 To(e,t){return e.length===t.length&&e.every((n,o)=>n.x===t[o].x&&n.y===t[o].y)}function Ta(e,t){if(e.type!=="gaArea"||!To(e.points,t.outline))return!1;let n=Sn(e.holes),o=Sn(t.holes);return n.length===o.length&&n.every((r,i)=>To(r,o[i]))}function Oa(e,t,n=e.filter(r=>r.type==="section"),o=No(t)){let r="referenceInventorySource"in t?t.referenceInventorySource?.logicalSectionId:void 0;return(r?n.find(s=>(s.logicalSectionId??s.id)===r&&(Ta(t,s)||he(o,s.outline,s.holes))):void 0)??n.find(s=>he(o,s.outline,s.holes))}function vo(e){return e.floors&&e.floors.length?e.floors:[{id:"floor-0",name:"Main",objects:e.objects,focalPoint:e.focalPoint,referenceImage:e.referenceImage,backgroundImage:e.backgroundImage}]}function Oo(e,t,n,o,r,i,s,a,c){let f=[],l=e.filter(p=>p.type==="section"),u=uo(e),h=p=>!p?.eventConfigurationId||p.eventConfigurationId===o&&(p.eventConfigurationVersion===void 0||p.eventConfigurationVersion===c),m=p=>go(p,{activeConfigurationId:o,activeConfigurationVersion:c,activeBasisSha256:r,now:a}),d=(p,y)=>m(p)?{...p,coverage:y}:void 0;for(let p of e){let y=[];if(p.type==="row"?y=Aa(p):p.type==="table"?y=Ca(p):p.type==="booth"&&(y=va(p)),!y.length)continue;for(let M of y)M.viewUrl&&!h(M.viewMeta)&&(M.viewUrl=void 0,M.viewMeta=void 0);if(p.type==="row"){let M=u.get(p.id);if(M){let b=new Map((p.overrides??[]).map(I=>[I.index,I]));for(let I of y){let S=Number(I.id.slice(I.id.lastIndexOf(":")+1));if(!Number.isInteger(S))continue;I.logicalRowId=M.groupId,I.logicalSeatIndex=M.adjacencyOffset+S,b.get(S)?.displayLabel||(I.displayLabel=mn(p,S,M)),!I.viewUrl&&M.viewFromSeatUrl&&h(M.viewFromSeatMeta)&&(I.viewUrl=M.viewFromSeatUrl,I.viewMeta=M.viewFromSeatMeta);let w=b.get(S)?.confidenceEvidence;I.confidenceEvidence=d(w,"exact-seat")??d(p.confidenceEvidence,"row-representative")??d(M.confidenceEvidence,"row-representative")}}}let x=Oa(e,p,l,p.type==="row"?Bt(y):No(p)),g=x?.viewFromSeatUrl,A=(x?.zone?t?.find(M=>M.id===x.zone):void 0)?.focalPoint??n;for(let M of y){if(!M.confidenceEvidence){let b=Number(M.id.slice(M.id.lastIndexOf(":")+1)),I=(p.type==="row"||p.type==="table")&&Number.isInteger(b)?p.overrides?.find(S=>S.index===b)?.confidenceEvidence:void 0;M.confidenceEvidence=d(I,"exact-seat")??(p.type==="row"?d(p.confidenceEvidence,"row-representative"):void 0)}M.confidenceEvidence??=d(x?.confidenceEvidence,"section-representative")??(s?d(s.evidence,s.coverage):void 0),!M.viewUrl&&g&&h(x?.viewFromSeatMeta)&&(M.viewUrl=g,M.viewMeta=x?.viewFromSeatMeta),!M.viewUrl&&i&&h(i.meta)&&(M.viewUrl=i.url,M.viewMeta=i.meta),x&&(M.sectionId=x.logicalSectionId??x.id),x?.zone&&(M.zoneId=x.zone),A&&(M.focalPoint={...A})}f.push(...y)}return f}function nt(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,c=Oo(r.objects,e.zones,i,e.eventConfigurationId,e.confidenceBasisSha256,s,a,t.now,t.eventConfigurationVersion??e.eventConfigurationVersion);t.resolveEyeHeights!==!1&&Lo(r.objects,r.focalPoint??e.focalPoint,r.baseHeightM??0,c);for(let f of c)f.floorId=r.id;for(let f of c)o.push(f)}return o}let n=Oo(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&&Lo(e.objects,e.focalPoint,t.floorBaseHeightM??0,n),La(e,n,t)}function La(e,t,n){return!n.deriveRestrictedView||e.derivedRestrictedView===!1||n.resolveEyeHeights===!1||Co(t,_o(t,Eo(e))),t}function Lo(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+ve;return}let s=new Array(o.length),a=new Map;for(let u of r)a.has(u.id)||a.set(u.id,u);let c=new Map,f=new Map;for(let u=0;u<o.length;u++){let h=o[u],d=(h.sectionId?a.get(h.sectionId)??r.find(y=>y.logicalSectionId===h.sectionId&&he({x:h.x,y:h.y},y.outline,y.holes)):void 0)??r.find(y=>he({x:h.x,y:h.y},y.outline,y.holes))??null;if(s[u]=d,!d)continue;c.has(d.id)||c.set(d.id,Ge(d,{floorBaseHeightM:n}));let p=f.get(d.id);p?p.push(u):f.set(d.id,[u])}let l=new Array(o.length).fill(void 0);for(let[u,h]of f){let m=c.get(u);if(!m)continue;let d=m.rake>0?Math.tan(m.rake*Math.PI/180):0,p=kt(u,o,h,t);for(let y of p.rows){let x=y.blockDepth*$*d,g=m.height+x;for(let R of y.seatIndices)l[R]=g}}for(let u=0;u<o.length;u++){let h=o[u],m=s[u];if(!m){h.eyeHeightM=n+ve;continue}let d=c.get(m.id);h.eyeHeightM=(l[u]??d.height)+ve}}var Go=Ce(require("earcut"),1),In=Ce(require("polygon-clipping"),1);function ye(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 xe(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 P=$,Ba=.002;function Fa(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<Ba}var $e=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)}},Gt=class{constructor(){this.pos=new $e;this.nor=new $e;this.col=new $e;this.flr=new $e;this.mat=new $e;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){Fa(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,c=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(c[0],c[1],c[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 Na(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],c=n[2]-e[2],f=r*c-i*a,l=i*s-o*c,u=o*a-r*s,h=Math.hypot(f,l,u)||1;return f/=h,l/=h,u/=h,[f,l,u]}function Da(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,Go.default)(o,r.length?r:void 0,2);return{pts:n,tris:i}}function ke(e){return ye(e)<0?[...e].reverse():e}var Ga=3;function ja(e,t,n,o){let r=o(e),i=o(t),s=o(n),a=(m,d,p,y)=>Math.abs(o({x:(m.x+d.x)/2,y:(m.y+d.y)/2})-(p+y)/2),c=(e.x+t.x+n.x)/3,f=(e.y+t.y+n.y)/3,l=(r+i+s)/3,u=Math.max(a(e,t,r,i),a(t,n,i,s),a(n,e,s,r),Math.abs(o({x:c,y:f})-l)),h=(m,d,p)=>{let y=Math.abs(o({x:(m+c)/2,y:(d+f)/2})-(p+l)/2);y>u&&(u=y)};return h((e.x+t.x)/2,(e.y+t.y)/2,(r+i)/2),h((t.x+n.x)/2,(t.y+n.y)/2,(i+s)/2),h((n.x+e.x)/2,(n.y+e.y)/2,(s+r)/2),u}function bt(e,t,n,o,r){if(r<=0)return ja(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(bt(e,i,a,o,r-1),bt(i,t,s,o,r-1),bt(a,s,n,o,r-1),bt(i,s,a,o,r-1))}function yt(e,t,n,o,r,i,s,a){if(s>0){let h={x:(t.x+n.x)/2,y:(t.y+n.y)/2},m={x:(n.x+o.x)/2,y:(n.y+o.y)/2},d={x:(o.x+t.x)/2,y:(o.y+t.y)/2};yt(e,t,h,d,r,i,s-1,a),yt(e,h,n,m,r,i,s-1,a),yt(e,d,m,o,r,i,s-1,a),yt(e,h,m,d,r,i,s-1,a);return}let c=[t.x*P,r(t),t.y*P],f=[n.x*P,r(n),n.y*P],l=[o.x*P,r(o),o.y*P];if(a){e.triN(c,f,l,a(t),a(n),a(o),i);return}let u=Na(c,f,l);u[1]<0&&(u=[-u[0],-u[1],-u[2]]),e.tri(c,f,l,u,i)}var Ha=8;function Do(e,t,n){if(!Number.isFinite(n))return e;let o=[],r=(i,s,a,c,f)=>{if(f>0){let l={x:(i.x+s.x)/2,y:(i.y+s.y)/2},u=t(l);if(Math.abs(u-(a+c)/2)>n){r(i,l,a,u,f-1),r(l,s,u,c,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),Ha)}return o}function Nt(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],c=a.x-i.x,f=a.y-i.y,l=Math.hypot(c,f);l>t&&Math.abs((s.x-i.x)*f-(s.y-i.y)*c)/l<t||o.push(s)}return o.length>=3?o:n}var Dt=.001*Ie*.1;function z(e,t,n,o,r,i,s,a,c=1/0,f){if(!t||t.length<3||(c===void 0&&(c=1/0),Math.abs(ye(t))<1e-4))return;let l=Nt(Do(Nt(ke(t),Dt),o,c),Dt),u=n?.map(b=>Nt(Do(Nt(ke(b),Dt),o,c),Dt)).filter(b=>b.length>=3&&Math.abs(ye(b))>=1e-4),{pts:h,tris:m}=Da(l,u),d=[i[0]*a.top,i[1]*a.top,i[2]*a.top],p=[i[0]*a.bottomCap,i[1]*a.bottomCap,i[2]*a.bottomCap],y=[s[0]*a.top,s[1]*a.top,s[2]*a.top],x=[s[0]*a.wallBottom,s[1]*a.wallBottom,s[2]*a.wallBottom],g=0;if(Number.isFinite(c))for(;g<Ga;g++){let b=0;for(let I=0;I<m.length;I+=3){let S=bt(h[m[I]],h[m[I+1]],h[m[I+2]],o,g);S>b&&(b=S)}if(b<=c)break}for(let b=0;b<m.length;b+=3){let I=h[m[b]],S=h[m[b+1]],w=h[m[b+2]];yt(e,I,S,w,o,d,g,f);let _=[I.x*P,r,I.y*P],k=[S.x*P,r,S.y*P],L=[w.x*P,r,w.y*P];e.tri(_,L,k,[0,-1,0],p)}let R=b=>{if(g<=0)return b;let I=1<<g,S=[];for(let w=0;w<b.length;w++){let _=b[w],k=b[(w+1)%b.length];for(let L=0;L<I;L++){let C=L/I;S.push({x:_.x+(k.x-_.x)*C,y:_.y+(k.y-_.y)*C})}}return S},A=fn(l),M=[{ring:R(l),flip:!1}];if(u)for(let b of u)b.length>=3&&M.push({ring:R(b),flip:!0});for(let{ring:b,flip:I}of M)for(let S=0;S<b.length;S++){let w=b[S],_=b[(S+1)%b.length],k=(_.x-w.x)*P,C=(_.y-w.y)*P,E=-k,v=Math.hypot(C,E)||1;C/=v,E/=v;let T=(w.x+_.x)/2-A.x,F=(w.y+_.y)/2-A.y,O=C*T+E*F;I&&(O=-O),O<0&&(C=-C,E=-E);let B=[C,0,E],D=[w.x*P,o(w),w.y*P],H=[_.x*P,o(_),_.y*P],N=[w.x*P,r,w.y*P],V=[_.x*P,r,_.y*P];e.tri(D,H,V,B,y,y,x),e.tri(D,V,N,B,y,x,x)}}function jo(e){let t=0;for(let c of e)t+=c.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 c of e)n.set(c.position,a*3),o.set(c.normal,a*3),r.set(c.color,a*3),i.set(c.floor,a),s.set(c.material,a),a+=c.count;return{position:n,normal:o,color:r,floor:i,material:s,count:t}}function we(e,t,n=2.5){if(t<=0||e.length<3)return e;let o=ke(e),r=o.length,i=[];for(let a=0;a<r;a++){let c=o[a],f=o[(a+1)%r],l=f.x-c.x,u=f.y-c.y,h=Math.hypot(l,u)||1;i.push({x:u/h,y:-l/h})}let s=[];for(let a=0;a<r;a++){let c=o[a],f=i[(a-1+r)%r],l=i[a],u=f.x+l.x,h=f.y+l.y,m=Math.hypot(u,h),d=()=>{s.push([c.x+f.x*t,c.y+f.y*t]),s.push([c.x+l.x*t,c.y+l.y*t])};if(m<1e-9){d();continue}u/=m,h/=m;let p=u*f.x+h*f.y,y=1/Math.max(p,1e-6);if(!Number.isFinite(y)||y>n){d();continue}s.push([c.x+u*t*y,c.y+h*t*y])}if(s.length<3)return e;try{let a=In.default.union([[...s,s[0]]]),c=null,f=-1/0;for(let u of a){let h=Math.abs(ye(u[0].map(([m,d])=>({x:m,y:d}))));h>f&&(f=h,c=u[0])}if(!c)return e;let l=c.map(([u,h])=>({x:u,y:h}));if(l.length>1){let u=l[0],h=l[l.length-1];Math.abs(u.x-h.x)<1e-9&&Math.abs(u.y-h.y)<1e-9&&l.pop()}return l.length>=3?l:e}catch{return e}}function He(e,t,n=2.5){if(e.length<3)return[];if(t<=0)return e;let o=ke(e),r=o.length,i=[];for(let c=0;c<r;c++){let f=o[c],l=o[(c+1)%r],u=Math.hypot(l.x-f.x,l.y-f.y)||1;i.push({x:-(l.y-f.y)/u,y:(l.x-f.x)/u})}let s=[],a=[];for(let c=0;c<r;c++){let f=o[c],l=i[(c-1+r)%r],u=i[c],h=l.x+u.x,m=l.y+u.y,d=Math.hypot(h,m),p=d<1e-9?1/0:1/Math.max(h/d*l.x+m/d*l.y,1e-6);if(!Number.isFinite(p)||p>n){s.push({x:f.x+l.x*t,y:f.y+l.y*t},{x:f.x+u.x*t,y:f.y+u.y*t}),a.push(c,c);continue}h/=d,m/=d,s.push({x:f.x+h*t*p,y:f.y+m*t*p}),a.push(c)}for(let c=0;c<s.length;c++){let f=(c+1)%s.length,l=a[c],u=a[f];if(u!==(l+1)%r)continue;let h=o[l],m=o[u];if((s[f].x-s[c].x)*(m.x-h.x)+(s[f].y-s[c].y)*(m.y-h.y)<=0)return[]}try{let c=In.default.intersection([[...s.map(d=>[d.x,d.y]),[s[0].x,s[0].y]]],[[...o.map(d=>[d.x,d.y]),[o[0].x,o[0].y]]]),f=null,l=0;for(let d of c){let p=Math.abs(ye(d[0].map(([y,x])=>({x:y,y:x}))));p>l&&(l=p,f=d[0])}if(!f)return[];let u=f.map(([d,p])=>({x:d,y:p})),h=u[0],m=u[u.length-1];return u.length>1&&Math.abs(h.x-m.x)<1e-9&&Math.abs(h.y-m.y)<1e-9&&u.pop(),u.length>=3?ke(u):[]}catch{return[]}}function jt(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 xt(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 gt=3,Qe=.38,Mt=.24;function Xa(e){if(e.length<3)return null;let t=e[0],n=e[Math.floor(e.length/2)],o=e[e.length-1],r=(n.x-t.x)*P,i=(n.y-t.y)*P,s=(o.x-t.x)*P,a=(o.y-t.y)*P,c=2*(r*a-i*s);if(Math.abs(c)<1e-7)return null;let f=r*r+i*i,l=s*s+a*a,u=(f*a-l*i)/c+t.x*P,h=(r*l-s*f)/c+t.y*P,m=Math.hypot(t.x*P-u,t.y*P-h);return m<1||m>200||!Number.isFinite(m)||e.some(d=>Math.abs(Math.hypot(d.x*P-u,d.y*P-h)-m)>.03)?null:{x:u,z:h,radius:m}}function Ho(e){let t=[],n=new Map,o=(c,f)=>`${Math.floor(c/gt)},${Math.floor(f/gt)}`;for(let c of e)for(let f of c.rows){for(let u of f.pts){let h=u.x*P,m=u.y*P,d=o(h,m),p=n.get(d)??[];p.push({x:h,z:m,y:f.y,floor:c.floorIndex}),n.set(d,p)}if(f.patch||f.pts.length<2)continue;let l=Xa(f.pts);for(let u of[0,f.pts.length-1]){let h=f.pts[u],m=f.pts[u===0?1:u-1],d=h.x-m.x,p=h.y-m.y,y=Math.hypot(d,p);y<1e-6||t.push({sectionId:c.sectionId,floorIndex:c.floorIndex,curve:l,row:f,point:h,x:h.x*P,z:h.y*P,dx:d/y,dz:p/y})}}let r=new Map;t.forEach((c,f)=>{let l=o(c.x,c.z),u=r.get(l)??[];u.push(f),r.set(l,u)});let i=(c,f)=>{let l=Math.floor(c/gt),u=Math.floor(f/gt);return[-1,0,1].flatMap(h=>[-1,0,1].map(m=>`${l+h},${u+m}`))},s=new Map;t.forEach((c,f)=>{let l=-1,u=1/0,h=!1;for(let m of i(c.x,c.z))for(let d of r.get(m)??[]){let p=t[d];if(c.sectionId===p.sectionId&&c.row.blockId===p.row.blockId||c.floorIndex!==p.floorIndex||Math.abs(c.row.y-p.row.y)>.05)continue;let y=p.x-c.x,x=p.z-c.z,g=Math.hypot(y,x);if(g<Qe*2+.45||g>gt)continue;let R=c.curve&&p.curve&&Math.hypot(c.curve.x-p.curve.x,c.curve.z-p.curve.z)<=.05&&Math.abs(c.curve.radius-p.curve.radius)<=.05,A=Math.min((y*c.dx+x*c.dz)/g,(-y*p.dx-x*p.dz)/g);(R?A<.8:A<.98)||!R&&(Math.abs(y*c.dz-x*c.dx)>.15||Math.abs(y*p.dz-x*p.dx)>.15)||(g<u-.02?(l=d,u=g,h=!1):Math.abs(g-u)<=.02&&(h=!0))}l>=0&&!h&&s.set(f,l)});let a=[];for(let[c,f]of s){if(c>=f||s.get(f)!==c)continue;let l=t[c],u=t[f],h=Math.hypot(u.x-l.x,u.z-l.z),m=(u.x-l.x)/h,d=(u.z-l.z)/h,p=!1;for(let x of i((l.x+u.x)/2,(l.z+u.z)/2))for(let g of n.get(x)??[]){if(g.floor!==l.floorIndex||Math.abs(g.y-l.row.y)>.75)continue;let R=(g.x-l.x)*m+(g.z-l.z)*d,A=Math.abs((g.x-l.x)*d-(g.z-l.z)*m);R>.01&&R<h-.01&&A<Mt+Qe&&(p=!0)}if(p)continue;let y=(x,g)=>({x:(l.x+m*x-d*g)/P,y:(l.z+d*x+m*g)/P});a.push({sections:[l.sectionId,u.sectionId],blocks:[l.row.blockId,u.row.blockId],floorIndex:l.floorIndex,ends:[l.point,u.point],clearWidthM:h-2*Qe,heightM:(l.row.y+u.row.y)/2,outline:[y(Qe,-Mt),y(h-Qe,-Mt),y(h-Qe,Mt),y(Qe,Mt)]})}return a}var Ua=/^#?([\da-f]{3}|[\da-f]{6})$/i;function Xo(e){let t=e.replace("#","");return{r:parseInt(t.slice(0,2),16),g:parseInt(t.slice(2,4),16),b:parseInt(t.slice(4,6),16)}}function Va(e){let t=Ua.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 ne(e){let t=Va(e);return t?[t[0]/255,t[1]/255,t[2]/255]:null}function Ka(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 Pe(e,t){let n=Ka(e);return te(e,[n,n,n],t)}function Uo({r:e,g:t,b:n}){let o=e/255,r=t/255,i=n/255,s=Math.max(o,r,i),a=Math.min(o,r,i),c=(s+a)/2;if(s===a)return{h:0,s:0,l:c};let f=s-a,l=c>.5?f/(2-s-a):f/(s+a),u;return s===o?u=((r-i)/f+(r<i?6:0))/6:s===r?u=((i-o)/f+2)/6:u=((o-r)/f+4)/6,{h:u,s:l,l:c}}var Ht=["available","held","sold","selected","dimmed"];function Vo(e){let t=Ht.indexOf(e);return t<0?0:t}var Ko={available:[.24,.82,.52],held:[.34,.39,.45],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};var Rn={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]},wn={top:[.05,.06,.08],bottom:[.1,.12,.15]};function Y(e,t){return[Math.min(1,e[0]*t),Math.min(1,e[1]*t),Math.min(1,e[2]*t)]}var Ya=.15,Wa=1.6;function Yo(e){return lo(e??1,Ya,Wa)}var za=.15,Za=.9,$a=1.76;function Wo(e){return!!e&&e[0]*.2126+e[1]*.7152+e[2]*.0722>.55?{zenith:[.36,.58,.84],horizon:[.82,.88,.94]}:{zenith:[.05,.08,.15],horizon:[.3,.38,.5]}}function Qa(){return{background:{top:[...wn.top],bottom:[...wn.bottom]},sky:Wo(null),structure:Rn,seatStates:{...Ko},seatScale:1,materials:{seat:null,shell:null,roughness:.78}}}function qa(e){return!!e&&e[0]*.2126+e[1]*.7152+e[2]*.0722>.55?{deck:"#c9ccc8",fascia:"#b4bab8",shell:"#c3c9c8",roughness:.87}:{deck:"#69747b",fascia:"#3e4d58",shell:"#526572",roughness:.87}}function zo(e){let t=Qa();e??={};let n=ne(e.background);if(n){t.background={top:Y(n,Za),bottom:Y(n,$a)},t.sky=Wo(n);let a={};for(let[f,l]of Object.entries(Rn))a[f]=te(l,n,za);n[0]*.2126+n[1]*.7152+n[2]*.0722>.55&&(a.ground=Y(n,.86)),t.structure=a}let o=ne(e.selectionColor)??ne(e.accent);o&&(t.seatStates={...t.seatStates,selected:o});let r=e.seatScale;typeof r=="number"&&Number.isFinite(r)&&(t.seatScale=Yo(r));let i=Object.fromEntries(Object.entries(e.venue3d??{}).filter(([,a])=>a!=null)),s={...qa(n),...i};if(s){let a=ne(s.deck),c=ne(s.fascia);a&&(t.structure={...t.structure,tierTop:a,gaTop:a}),c&&(t.structure={...t.structure,tierWall:c,gaWall:c}),t.materials.seat=ne(s.seat),t.materials.shell=ne(s.shell),typeof s.roughness=="number"&&Number.isFinite(s.roughness)&&(t.materials.roughness=Math.min(1,Math.max(0,s.roughness)))}return t}function Zo(e,t){let n=[];for(let o of t)n.push(...e.seatStates[o]);return n}function $o(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 Pn=[{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"}],dh=new Map(Pn.map(e=>[e.key,e]));var Ja={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 Xt(e){let t=e?.[0];return t&&Ja[t]||"#3b82f6"}var ec=[{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"}],ph=new Map(ec.map(e=>[e.key,e]));var tc=["reference-focal","bar","entrance","exit","restroom","screen","sound","concession","coat","wall","rail","suite","obstruction"],bh=new Set(tc);function St(e){if(e.length<3)return e.map(i=>({...i}));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.map(i=>({...i})):t.map(i=>({...i}))}var wr=Ce(require("polygon-clipping"),1);var K={top:1,wallBottom:.58,bottomCap:.4};function qe(e,t){if(!e)return t;let n=Y(Pe(e,.4),.62);return te(t,n,.22)}function Qo(e,t){return e?te(t,Y(Pe(e,.25),.74),.62):t}function qo(e,t){return e?te(t,Y(Pe(e,.08),.9),.82):t}function Jo(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,c=0,f=0,l=0;for(let[u,h]of s){let m=ne(n.get(u));m&&(a+=m[0]*h,c+=m[1]*h,f+=m[2]*h,l+=h)}l>0&&r.set(i,[a/l,c/l,f/l])}return r}function er(e,t){return ne(e.color)??t.get(e.logicalSectionId??e.id)??null}var Cn=Ce(require("polygon-clipping"),1);var _n=Ce(require("polygon-clipping"),1);var nr=[{key:"circle",label:"Standard seat",shortLabel:"Standard",useCase:"General assigned seating",group:"general",path:null,bounds:null,mark: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},mark:{x:12,y:10,radius:6}},{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},mark:{x:12,y:10,radius:4.5}},{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},mark:{x:12,y:5,radius:3}},{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},mark:{x:12,y:7.5,radius:5.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},mark:{x:12,y:8,radius: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},mark:{x:12,y:9.25,radius:6.5}},{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},mark:{x:12,y:12.25,radius:4.75}}],or=nr.map(e=>e.key),nc=new Map(nr.map(e=>[e.key,e]));function tr(e){return typeof e=="string"&&nc.has(e)}function rr(e,t){return tr(e)?e:tr(t?.seatGlyph)?t.seatGlyph:"circle"}var pe={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,body:10,head:11},oc=.44,rc=.15,ic=.3,sc=.24;function ir(e){return e===void 0||!Number.isFinite(e)||e<=0?sc:Math.min(ic,Math.max(rc,e*oc))}var ac=.05,sr=.45,cc=sr+ac,lc=.92;var wh=[{part:pe.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:pe.pad,min:[-1,.36,-.95],max:[1,sr,1]},{part:pe.back,min:[-1,cc,-1],max:[1,lc,-.72]},{part:pe.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:pe.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:pe.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:pe.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:pe.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:pe.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:pe.leg,min:[.62,0,.48],max:[.82,.37,.7]}],Ph=[{part:pe.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:pe.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:pe.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:pe.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:pe.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}];function ar(e,t,n,o){let r=new Float32Array(t),i=f=>e[f*3],s=f=>e[f*3+2],a=0,c=(f,l)=>{let u=l-f;for(let h=f;h<l;h++){let[m,d]=o(h),p=m-i(h),y=d-s(h);if(u>=2){let x=Math.max(f,h-1),g=Math.min(l-1,h+1),R=i(g)-i(x),A=s(g)-s(x),M=Math.hypot(R,A);if(M>1e-6){let b=-A/M,I=R/M;b*p+I*y<0&&(b=-b,I=-I),p=b,y=I}}r[h]=p===0&&y===0?0:Math.atan2(p,y)}};for(let f=1;f<=t;f++)(f===t||n(f)!==n(a))&&(c(a,f),a=f);return r}var Ut=.22;var uc=.42;function fc(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 d of e)d.x<o&&(o=d.x),d.y<r&&(r=d.y),d.x>i&&(i=d.x),d.y>s&&(s=d.y);let a=Math.max(i-o,1e-6),c=Math.max(s-r,1e-6),f=Math.max(Math.sqrt(a*c/t),1e-6),l=Math.max(1,Math.ceil(a/f)+1),u=Math.max(1,Math.ceil(c/f)+1),h=new Map,m=(d,p)=>{let y=Math.min(l-1,Math.max(0,Math.floor((d-o)/f)));return Math.min(u-1,Math.max(0,Math.floor((p-r)/f)))*l+y};for(let d=0;d<t;d++){let p=m(e[d].x,e[d].y),y=h.get(p);y?y.push(d):h.set(p,[d])}for(let d=0;d<t;d++){let p=e[d],y=Math.min(l-1,Math.max(0,Math.floor((p.x-o)/f))),x=Math.min(u-1,Math.max(0,Math.floor((p.y-r)/f))),g=1/0;for(let R=1;R<=4;R++){for(let A=x-R;A<=x+R;A++)if(!(A<0||A>=u))for(let M=y-R;M<=y+R;M++){if(M<0||M>=l||R>1&&Math.abs(A-x)<R&&Math.abs(M-y)<R)continue;let b=h.get(A*l+M);if(b)for(let I of b){if(I===d)continue;let S=Math.hypot(e[I].x-p.x,e[I].y-p.y);S<g&&(g=S)}}if(Number.isFinite(g)&&g<=R*f)break}n[d]=g}return n}function mc(e){let t=e.eyeHeightM;return Number.isFinite(t)?Math.max(0,t-ve):0}function cr(e,t,n,o,r,i){let s=e.length,a=new Float32Array(s*3),c=new Float32Array(s),f=new Float32Array(s*3),l=new Float32Array(s),u=new Float32Array(s),h=new Float32Array(s),m=new Float32Array(s),d=new Float32Array(s*3),p=new Map,y=fc(e);for(let x=0;x<s;x++){let g=e[x],A=(n?.seatPitchU(x)??y[x])*P;l[x]=Number.isFinite(A)?Math.max(.06,Math.min(Ut,A*uc)):Ut,u[x]=ir(Number.isFinite(A)?A:void 0);let M=rr(g.glyph,{seatGlyph:i?.get(g.categoryKey)});h[x]=or.indexOf(M),m[x]=g.wheelchairSpaceType==="no-seat"?0:1,a[x*3]=g.x*P,a[x*3+1]=n?n.seatDeckY(x):mc(g),a[x*3+2]=g.y*P,c[x]=Vo(t?t(g):"available");let b=ne(r?.get(g.categoryKey)??"#6e7bff")??[.43,.48,1];if(f[x*3]=b[0],f[x*3+1]=b[1],f[x*3+2]=b[2],g.accessibility?.length){let I=ne(Xt(g.accessibility));I&&(d[x*3]=I[0],d[x*3+1]=I[1],d[x*3+2]=I[2])}p.set(g.id,x)}return{count:s,iPosition:a,iState:c,iCategory:f,iMaxRadius:l,iRing:d,idToIndex:p,iChairWidth:u,iGlyph:h,iPhysicalSeat:m,iFloor:o??new Float32Array(s),iSection:new Float32Array(s).fill(-1),iYaw:new Float32Array(s)}}var mr=Ce(require("earcut"),1);var hc=.58,lr=.01,Re=Ut*1.5*Ie,dc=.5,pc=.6;function bc(e,t){let n=e.length,o=[];for(let s=0;s<n;s++){let a=e[Math.max(0,s-1)],c=e[Math.min(n-1,s+1)],f=c.x-a.x,l=c.y-a.y,u=Math.hypot(f,l);if(u<1e-9){o.push([0,0]);continue}f/=u,l/=u,o.push([-l,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 yc(e,t){if(e.length<2||t<=0)return[...e];let n=[...e],o=(s,a)=>{let c=a.x-s.x,f=a.y-s.y,l=Math.hypot(c,f)||1;return{x:c/l,y:f/l}},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 ur=Math.PI/12;function xc(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 hr(e,t){if(!e.length||!(t>0))return[];let n=xc(e),o=(a,c,f,l)=>{let u=f-c;for(;u<0;)u+=Math.PI*2;for(;u>Math.PI*2;)u-=Math.PI*2;let h=Math.max(1,Math.ceil(u/ur)),m=t/Math.cos(u/h/2);for(let d=0;d<=h;d++){let p=c+u*d/h;l.push({x:a.x+Math.cos(p)*m,y:a.y+Math.sin(p)*m})}};if(n.length<3){let a=0,c=0;for(let m of n)a+=m.x,c+=m.y;a/=n.length||1,c/=n.length||1;let f=0;for(let m of n)f=Math.max(f,Math.hypot(m.x-a,m.y-c));let l=[],u=Math.max(3,Math.ceil(Math.PI*2/ur)),h=(f+t)/Math.cos(Math.PI/u);for(let m=0;m<u;m++){let d=m/u*Math.PI*2;l.push({x:a+Math.cos(d)*h,y:c+Math.sin(d)*h})}return l}let r=n.length,i=[];for(let a=0;a<r;a++){let c=n[a],f=n[(a+1)%r];i.push(Math.atan2(-(f.x-c.x),f.y-c.y))}let s=[];for(let a=0;a<r;a++)o(n[a],i[(a+r-1)%r],i[a],s);return xr(s)}function gc(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,c=s.y-i.y,f=a*a+c*c,l=f>1e-12?((t-i.x)*a+(n-i.y)*c)/f:0;l<0?l=0:l>1&&(l=1);let u=Math.hypot(t-(i.x+l*a),n-(i.y+l*c));u<o&&(o=u)}return o}function Vt(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 c=0;for(let f of r.pts){let l=Math.hypot(f.x-i,f.y-s);l>c&&(c=l)}return{cx:i,cy:s,rad:c}}),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,c=null;for(let l of i){let u=1/0;for(let h=0;h<e.length;h++){if(h===r||Math.abs(e[h].y-e[r].y)<.001)continue;let m=t[h],d=Math.hypot(l.x-m.cx,l.y-m.cy)-m.rad;if(d>=u&&d>=a)continue;let p=gc(e[h].pts,l.x,l.y);p<u&&(u=p),e[h].depth<e[r].depth&&p<a&&(a=p,c=e[h].y)}Number.isFinite(u)&&u>0&&s.push(u)}s.sort((l,u)=>l-u);let f=s.length?s[Math.floor(s.length/2)]:1;o.push({pitch:f,belowY:c})}return o}function dr(e,t,n,o){let r=e[t],i=r.pts.length>=2?[...r.pts]:r.pts.length===1?(()=>{let l=r.pts[0],u=l.x-o.x,h=l.y-o.y,m=Math.hypot(u,h)||1;u/=m,h/=m;let d=Math.max(n[t].pitch,.001)*.5;return[{x:l.x+h*d,y:l.y-u*d},{x:l.x-h*d,y:l.y+u*d}]})():[];if(i.length<2)return null;let s=0,a=0;for(let l=1;l<i.length;l++){let u=Math.hypot(i[l].x-i[l-1].x,i[l].y-i[l-1].y);u>1e-6&&(s+=u,a++)}let c=a>0?s/a:0,f=yc(i,Math.max(c*pc,Re));return{pts:f,nrm:bc(f,o),front:Math.max(n[t].pitch*hc,Re),back:Math.max(n[t].pitch*dc,Re)}}var rt=1.5,pr=.3;function An(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,c=-1;for(let u=1;u<e.length-1;u++){let h=e[u],m=s>1e-12?Math.abs((h.x-n.x)*i-(h.y-n.y)*r)/s:Math.hypot(h.x-n.x,h.y-n.y);m>a&&(a=m,c=u)}if(a<=t||c<0)return[n,o];let f=An(e.slice(0,c+1),t),l=An(e.slice(c),t);return[...f.slice(0,-1),...l]}function br(e,t){if(e.length<4)return e;let n=An([...e,e[0]],t);return n.pop(),n.length>=3?n:e}function Mc(e){let t=e.map((o,r)=>{let i=e[(r+1)%e.length];return{a:o,b:i,i:r,minX:Math.min(o.x,i.x),maxX:Math.max(o.x,i.x),minY:Math.min(o.y,i.y),maxY:Math.max(o.y,i.y)}}).sort((o,r)=>o.minX-r.minX),n=(o,r,i)=>(r.x-o.x)*(i.y-o.y)-(r.y-o.y)*(i.x-o.x);for(let o=0;o<t.length;o++){let r=t[o];for(let i=o+1;i<t.length&&t[i].minX<=r.maxX;i++){let s=t[i];if(!(Math.abs(r.i-s.i)===1||Math.abs(r.i-s.i)===e.length-1||r.maxY<s.minY||s.maxY<r.minY)&&n(r.a,r.b,s.a)*n(r.a,r.b,s.b)<=0&&n(s.a,s.b,r.a)*n(s.a,s.b,r.b)<=0)return!0}}return!1}function yr(e,t,n){if(e.length<2)return[];let o=n??Vt(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 R=e[g].patch;R&&R.length>=3?i.push({outline:[...R],holes:[],topY:e[g].y}):a.push(g)}if(!a.length)continue;a.sort((g,R)=>e[g].depth-e[R].depth);let f=a.map(g=>dr(e,g,o,t)).filter(g=>g!==null);if(!f.length)continue;let l=(g,R)=>({x:g.pts[R].x-g.nrm[R][0]*(g.front+rt),y:g.pts[R].y-g.nrm[R][1]*(g.front+rt)}),u=(g,R)=>({x:g.pts[R].x+g.nrm[R][0]*(g.back+rt),y:g.pts[R].y+g.nrm[R][1]*(g.back+rt)}),h=f[0],m=f[f.length-1],d=[];for(let g=0;g<h.pts.length;g++)d.push(l(h,g));for(let g of f)d.push(u(g,g.pts.length-1));for(let g=m.pts.length-1;g>=0;g--)d.push(u(m,g));for(let g=f.length-1;g>=0;g--)d.push(l(f[g],0));let p=xr(d),y=1/0;for(let g of a)e[g].y<y&&(y=e[g].y);if(!Number.isFinite(y))continue;if(p.length>=3&&Math.abs(ye(p))>1e-6&&f.every(g=>{let R=g.pts[Math.floor(g.pts.length/2)];return xe(p,R.x,R.y)})&&!Mc(p)){i.push({outline:br(p,pr),holes:[],topY:y});continue}for(let g of Sc(f))i.push({outline:g,holes:[],topY:y})}return i}function Sc(e){let t=[];for(let n of e){let o=[],r=[],i=n.front+rt,s=n.back+rt;for(let c=0;c<n.pts.length;c++){let f=n.pts[c],l=n.nrm[c];o.push([f.x-l[0]*i,f.y-l[1]*i]),r.push([f.x+l[0]*s,f.y+l[1]*s])}let a=[...o,...r.reverse()];a.length<3||(a.push(a[0]),t.push([a]))}if(!t.length)return[];try{let n=_n.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(([c,f])=>({x:c,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(br(i,pr))}return o}catch{return[]}}function xr(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 En=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(!xe(n,r.x,r.y)){o=!1;break}if(o)return!0}return!1}};function fr(e,t,n,o,r,i){if(o.length<3)return;if(n.containsAll(o)){let f=[0,1,0],l=o[0];for(let u=1;u+1<o.length;u++){let h=o[u],m=o[u+1];e.tri([l.x*P,r,l.y*P],[h.x*P,r,h.y*P],[m.x*P,r,m.y*P],f,i)}return}let s=o.map(f=>[f.x,f.y]);s.push(s[0]);let a;try{a=_n.default.intersection([s],t)}catch{return}let c=[0,1,0];for(let f of a){if(!f.length||f[0].length<4)continue;let l=f[0],u=[],h=[];for(let d=0;d<l.length-1;d++)u.push(l[d][0],l[d][1]),h.push([l[d][0],l[d][1]]);if(h.length<3)continue;let m=(0,mr.default)(u,void 0,2);for(let d=0;d<m.length;d+=3){let p=h[m[d]],y=h[m[d+1]],x=h[m[d+2]];e.tri([p[0]*P,r,p[1]*P],[y[0]*P,r,y[1]*P],[x[0]*P,r,x[1]*P],c,i)}}}function gr(e,t,n,o,r,i,s){if(t.length<2)return;let a=s??Vt(t),c=[0,1,0],f=i&&i.length>=3?[[...i.map(m=>[m.x,m.y]),[i[0].x,i[0].y]]]:null,l=i&&i.length>=3?new En([[...i]]):null,u=m=>{e.setMaterial(2),m(),e.setMaterial(0)},h=m=>{e.setMaterial(3),m(),e.setMaterial(0)};for(let m=0;m<t.length;m++){let d=t[m];if(d.patch&&d.patch.length>=3){let M=[...d.patch],b=a[m].belowY??o;if(h(()=>{if(f&&l)fr(e,f,l,M,d.y,r.tread);else{let I=M[0];for(let S=1;S+1<M.length;S++){let w=M[S],_=M[S+1];e.tri([I.x*P,d.y,I.y*P],[w.x*P,d.y,w.y*P],[_.x*P,d.y,_.y*P],c,r.tread)}}}),d.y>b+lr){let I=0,S=0;for(let w of M)I+=w.x,S+=w.y;I/=M.length,S/=M.length,u(()=>{for(let w=0;w<M.length;w++){let _=M[w],k=M[(w+1)%M.length],L=k.x-_.x,C=k.y-_.y,E=Math.hypot(L,C);if(E<1e-6)continue;let v=C/E,T=-L/E;(_.x-I)*v+(_.y-S)*T<0&&(v=-v,T=-T);let F=[v,0,T],O=[_.x*P,d.y,_.y*P],B=[k.x*P,d.y,k.y*P],D=[_.x*P,b,_.y*P],H=[k.x*P,b,k.y*P];e.tri(O,B,H,F,r.riser),e.tri(O,H,D,F,r.riser)}})}continue}let p=dr(t,m,a,n);if(!p)continue;let{pts:y,nrm:x,front:g,back:R}=p,A=a[m].belowY??o;for(let M=0;M+1<y.length;M++){let b=y[M],I=y[M+1],S=x[M],w=x[M+1];if(Math.hypot(I.x-b.x,I.y-b.y)<1e-6||S[0]===0&&S[1]===0||w[0]===0&&w[1]===0)continue;let _=[(b.x-S[0]*g)*P,d.y,(b.y-S[1]*g)*P],k=[(I.x-w[0]*g)*P,d.y,(I.y-w[1]*g)*P],L=[(b.x+S[0]*R)*P,d.y,(b.y+S[1]*R)*P],C=[(I.x+w[0]*R)*P,d.y,(I.y+w[1]*R)*P];if(h(()=>{f&&l?fr(e,f,l,[{x:b.x-S[0]*g,y:b.y-S[1]*g},{x:I.x-w[0]*g,y:I.y-w[1]*g},{x:I.x+w[0]*R,y:I.y+w[1]*R},{x:b.x+S[0]*R,y:b.y+S[1]*R}],d.y,r.tread):(e.tri(_,k,C,c,r.tread),e.tri(_,C,L,c,r.tread))}),d.y>A+lr){let E=[_[0],A,_[2]],v=[k[0],A,k[2]],T=[-S[0],0,-S[1]];u(()=>{e.tri(_,k,v,T,r.riser),e.tri(_,v,E,T,r.riser)})}}}}function Ic(e,t){let n=e.eventConfigurationIds;return!n?.length||!!t&&n.includes(t)}function Mr(e,t){return e.filter(n=>n.type!=="shape"||Ic(n,t))}function Sr(e,t){let n=e.focalPoint??{x:0,y:0};return e.floors?.length?e.floors.map((o,r)=>({objects:Mr(o.objects,t),focal:{x:(o.focalPoint??n).x,y:(o.focalPoint??n).y},baseHeightM:o.baseHeightM??0,index:r})):[{objects:Mr(e.objects,t),focal:n,baseHeightM:0,index:0}]}var Rc={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Le(e){return $o(e)??Rc}function Ir(e,t){let n=we(e.outline,Re),o=Le(n),r=t.filter(s=>s!==e&&s.outline&&s.outline.length>=3&&ot(o,Le(s.outline)));if(!r.length)return[n];let i=s=>{let a=s.map(c=>[c.x,c.y]);return a.push(a[0]),a};try{let s=Cn.default.difference([i(n)],...r.map(c=>[i(c.outline)])),a=[];for(let c of s){if(!c.length)continue;let f=c[0].map(([l,u])=>({x:l,y:u}));if(f.length>1){let l=f[0],u=f[f.length-1];Math.abs(l.x-u.x)<1e-9&&Math.abs(l.y-u.y)<1e-9&&f.pop()}f.length>=3&&a.push(f)}return a.length?a:[n]}catch{return[n]}}function Rr(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=Cn.default.intersection([n(i.outline)],o.flat())}catch{r.push(i);continue}for(let a of s){if(!a.length)continue;let c=a[0].map(([f,l])=>({x:f,y:l}));if(c.length>1){let f=c[0],l=c[c.length-1];Math.abs(f.x-l.x)<1e-9&&Math.abs(f.y-l.y)<1e-9&&c.pop()}c.length>=3&&r.push({outline:c,holes:[],topY:i.topY})}}return r.length?r:e}function wc(e,t){return e===void 0||t===void 0?!0:Math.abs(e-t)<.001}var Kt=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(t,n){let o=t.map(c=>[c.x,c.y]);if(o.length<3)return[];o.push(o[0]);let r=Le(t),i=this.rings.filter((c,f)=>ot(r,this.boxes[f])&&wc(n,this.levels[f])),s=[[o]];if(i.length)try{s=wr.default.difference([o],...i).map(f=>f.map(l=>l.map(([u,h])=>[u,h])))}catch{s=[[o]]}this.rings.push([o]),this.boxes.push(r),this.levels.push(n);let a=[];for(let c of s){if(!c.length)continue;let f=c[0].map(([l,u])=>({x:l,y:u}));if(f.length>1){let l=f[0],u=f[f.length-1];Math.abs(l.x-u.x)<1e-9&&Math.abs(l.y-u.y)<1e-9&&f.pop()}f.length>=3&&a.push(f)}return a}};function Yt(e,t){if(!t)return e;let n=1/0,o=-1/0,r=1/0,i=-1/0;for(let u of e)n=Math.min(n,u.x),o=Math.max(o,u.x),r=Math.min(r,u.y),i=Math.max(i,u.y);let s=(n+o)/2,a=(r+i)/2,c=t*Math.PI/180,f=Math.cos(c),l=Math.sin(c);return e.map(u=>{let h=u.x-s,m=u.y-a;return{x:s+h*f-m*l,y:a+h*l+m*f}})}function oe(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=xt(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=jt(n,o,e.width/2,e.height/2)}return t?Yt(t,e.rotation):null}function Ae(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"&&ht(e.stageKind)?{kind:"stage",heightM:e.stageKind==="ring-boxing"?Ot:.06}:n[t]??{kind:"plate",heightM:.25};return{...o,heightM:e.heightM??o.heightM}}var Pc=.08,Ac=30,Ec=.015;function _c(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[o],s=t[r];i.y>e.y!=s.y>e.y&&e.x<(s.x-i.x)*(e.y-i.y)/(s.y-i.y)+i.x&&(n=!n)}return n}function Pr(e,t){let n=oe(e)??(e.points?.length?Yt(e.points,e.rotation):null),o=Ae(e),i=!e.role&&o.kind==="plate"&&e.heightM===void 0&&!!n&&Math.abs(ye(n))*$**2>=Ac?Ec:o.heightM;if(!n)return{topOffsetM:i,supportOffsetM:0};if(o.kind!=="plate"&&o.kind!=="stage")return{topOffsetM:i,supportOffsetM:0};let s=1/0,a=1/0,c=-1/0,f=-1/0;for(let m of n)s=Math.min(s,m.x),a=Math.min(a,m.y),c=Math.max(c,m.x),f=Math.max(f,m.y);let l=i,u=0,h=1e-6*Math.max(1,c-s,f-a);for(let m of t)c>m.minX&&s<m.maxX&&f>m.minY&&a<m.maxY&&l<=m.topOffsetM+1e-6&&(l=m.topOffsetM+Pc),s>=m.minX-h&&c<=m.maxX+h&&a>=m.minY-h&&f<=m.maxY+h&&(!m.poly||n.every(y=>_c(y,m.poly)||Cc(y,m.poly,h)))&&(u=Math.max(u,m.topOffsetM));return e.fill&&e.fill!=="none"&&e.fill!=="transparent"&&t.push({minX:s,minY:a,maxX:c,maxY:f,topOffsetM:l,poly:n}),{topOffsetM:l,supportOffsetM:Math.min(u,l)}}function Cc(e,t,n){for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[r],s=t[o],a=s.x-i.x,c=s.y-i.y,f=a*a+c*c,l=f?Math.max(0,Math.min(1,((e.x-i.x)*a+(e.y-i.y)*c)/f)):0;if(Math.hypot(e.x-(i.x+l*a),e.y-(i.y+l*c))<=n)return!0}return!1}function Xe(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function ge(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 be(e,t,n){return[Xe(e[0],e[1],t),Xe(e[0],e[1],n),Xe(e[3],e[2],n),Xe(e[3],e[2],t)]}function It(e,t,n){return[Xe(e[0],e[3],t),Xe(e[1],e[2],t),Xe(e[1],e[2],n),Xe(e[0],e[3],n)]}function ee(e,t,n,o,r,i){z(e,t,void 0,()=>n,o,r,i,K)}var vc=.8,kc=.6,Tc=2;function Ue(e,t){if(!t.length)return null;let n=[],o=0;for(let s of e.objects){if(s.type!=="shape"||s.role!=="wall")continue;let a=oe(s)??[],c=Ar(a)/2;!(c>0)||Bc(a)/c*P>Tc||(n.push(...a),o+=c)}if(n.length<3)return null;let r=St(n);if(r.length<3||o<Ar(r)*kc)return null;let i=0;for(let s of t)Fc(s,r)&&(i+=1);return i>=t.length*vc?r:null}var Wt=6,Oc=5,Lc=8;function Er(e){return Math.max(Lc,(Number.isFinite(e)?e:0)+Oc)}function it(e){let t=0,n=0,o=0;for(let r=0;r<e.length;r++){let i=e[r],s=e[(r+1)%e.length],a=i.x*s.y-s.x*i.y;t+=a,n+=(i.x+s.x)*a,o+=(i.y+s.y)*a}if(Math.abs(t)<1e-9){let r=0,i=0;for(let s of e)r+=s.x,i+=s.y;return{x:r/Math.max(1,e.length),y:i/Math.max(1,e.length)}}return{x:n/(3*t),y:o/(3*t)}}function Bc(e){let t=0;for(let n=0;n<e.length;n++){let o=e[n],r=e[(n+1)%e.length];t+=o.x*r.y-r.x*o.y}return Math.abs(t)/2}function Ar(e){let t=0;for(let n=0;n<e.length;n++){let o=e[n],r=e[(n+1)%e.length];t+=Math.hypot(r.x-o.x,r.y-o.y)}return t}function Fc(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[o],s=t[r];i.y>e.y!=s.y>e.y&&e.x<(s.x-i.x)*(e.y-i.y)/(s.y-i.y)+i.x&&(n=!n)}return n}function Nc(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 Dc(e,t){if(!e.length)return null;let n=0,o=0,r=0;for(let m of e)n+=m.x,o+=m.y,r+=Math.hypot(m.x-t.x,m.y-t.y);let i=e.length;n/=i,o/=i,r/=i;let s=e[0],a=-1;for(let m of e){let d=Math.hypot(m.x-n,m.y-o);d>a&&(a=d,s=m)}let c=s.x-n,f=s.y-o,l=Math.hypot(c,f);l>1e-9?(c/=l,f/=l):(c=1,f=0);let u=[...e].sort((m,d)=>(m.x-n)*c+(m.y-o)*f-((d.x-n)*c+(d.y-o)*f)),h=0;for(let m of u){let d=Math.hypot(m.x-n,m.y-o);d>h&&(h=d)}return{pts:u,cx:n,cy:o,radius:h,depth:r}}function _r(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],c=a.x-s.x,f=a.y-s.y,l=c*c+f*f,u=l>1e-12?((t-s.x)*c+(n-s.y)*f)/l:0;u<0?u=0:u>1&&(u=1);let h=Math.hypot(t-(s.x+u*c),n-(s.y+u*f));h<r&&(r=h)}return r}var zt=8;function Gc(e,t,n){let o=new Array(zt).fill(1/0),r=new Array(zt).fill(-1);for(let l=0;l<e.length;l++){let u=e[l],h=Math.hypot(t-u.cx,n-u.cy)-u.radius;for(let m=0;m<zt;m++)if(h<o[m]){for(let d=zt-1;d>m;d--)o[d]=o[d-1],r[d]=r[d-1];o[m]=h,r[m]=l;break}}let i=new Array(3).fill(1/0),s=new Array(3).fill(-1);for(let l of r){if(l<0)continue;let u=_r(e[l],t,n);for(let h=0;h<3;h++)if(u<i[h]){for(let m=2;m>h;m--)i[m]=i[m-1],s[m]=s[m-1];i[h]=u,s[h]=l;break}}if(s[0]<0)return 0;if(i[0]<1e-6)return e[s[0]].depth;let a=i[0]*2.2,c=0,f=0;for(let l=0;l<3;l++){let u=s[l];if(u<0||i[l]>a)continue;let h=1/(i[l]*i[l]);c+=h*e[u].depth,f+=h}return f>0?c/f:e[s[0]].depth}function jc(e){let t=(o,r)=>Gc(e,o,r),n=(o,r)=>{let i=1/0,s=-1;for(let a=0;a<e.length;a++){let c=e[a];if(Math.hypot(o-c.cx,r-c.cy)-c.radius>=i)continue;let f=_r(c,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 Cr(e,t){let n=[];for(let o of e){let r=Dc(o.points,t);r&&n.push(r)}return n.length<2?Nc(t):(n.sort((o,r)=>o.depth-r.depth),jc(n))}var Ve=.06,Hc=.05,kr=.05,vr=.15,vn=25;function Tr(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),c=new Map,f=[],l=new Set;for(let h=0;h<e.length;h+=1){let m=e[h];for(let d of m.objects){if(d.type==="table"&&l.add(d.id),d.type!=="section"||!d.outline||d.outline.length<3)continue;let p=we(d.outline,Re);c.set(d.id,{section:d,unit:m,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),f.push({id:d.id,floorIndex:h,box:Le(p),section:d,unit:m,outline:p})}}let u=new Map;for(let h of f){let m=u.get(h.floorIndex);m?m.push(h):u.set(h.floorIndex,[h])}for(let h=0;h<t.length;h++){let m=t[h],d=n?u.get(n[h])??[]:f,p=m.sectionId?d.find(x=>x.id===m.sectionId)??d.find(x=>x.section.logicalSectionId===m.sectionId&&he({x:m.x,y:m.y},x.outline,x.section.holes)):void 0,y=p?[p]:d;for(let x of y){if(n&&x.floorIndex!==n[h]||!p&&(m.x<x.box.minX||m.x>x.box.maxX||m.y<x.box.minY||m.y>x.box.maxY||!he({x:m.x,y:m.y},x.outline,x.section.holes)))continue;r[h]=x.id;let g=c.get(x.id);g.hasSeats=!0;let R=m.focalPoint??x.unit.focal,A=Math.hypot(m.x-R.x,m.y-R.y);A<g.frontU&&(g.frontU=A),g.seatIndices.push(h);let M=m.rowId||`__seat-${h}`,b=g.rows.get(M);b?b.push({x:m.x,y:m.y}):g.rows.set(M,[{x:m.x,y:m.y}]);break}}for(let[h,m]of c){let d=Ge(m.section,{floorBaseHeightM:m.unit.baseHeightM}),p=m.unit.baseHeightM,y=d.rake>0?Math.tan(d.rake*Math.PI/180):0,x=d.rake<=.01&&d.height<=p+.001,g=m.section.surfaceKind,R=g==="flat"?!0:g==="rakedRows"&&d.rake>.01?!1:x,A=m.hasSeats?kt(h,t,m.seatIndices,m.unit.focal):{sectionId:h,rows:[],blockCount:0},b=A.rows.length<2?Cr([...m.rows.values()].map(O=>({points:O})),m.unit.focal):null,I=1/0;if(b){if(m.hasSeats)for(let O of m.rows.values())for(let B of O){let D=b.depthAt(B.x,B.y);D<I&&(I=D)}if(!m.hasSeats||!Number.isFinite(I)){I=1/0;for(let O of m.section.outline){let B=b.depthAt(O.x,O.y);B<I&&(I=B)}}}let S=p+Hc,w=Math.max(S,d.height),_=O=>{let B=Math.max(0,O-I)*$,D=Math.min(B*y,vn);return Math.max(S,d.height+D)},k=O=>{let B=Math.max(0,O)*$,D=Math.min(B*y,vn);return Math.max(S,d.height+D)},L=R?[]:A.rows.map(O=>({pts:O.pts,y:k(O.blockDepth),depth:O.blockDepth,blockId:O.blockId,...l.has(O.id)?{patch:hr(O.pts,Re)}:{}})),C=L.length?L[0].y:w,E=L.map(O=>{let B=O.patch&&O.patch.length>=3?O.patch:O.pts,D=0,H=0;for(let X of B)D+=X.x,H+=X.y;let N=B.length||1;D/=N,H/=N;let V=0;for(let X of B){let Z=Math.hypot(X.x-D,X.y-H);Z>V&&(V=Z)}return{cx:D,cy:H,rad:V}}),v=R?()=>w:L.length>=2?(O,B)=>{let D=1/0,H=C;for(let N=0;N<L.length;N++){let V=E[N];if(Math.hypot(O-V.cx,B-V.cy)-V.rad>=D)continue;let X=L[N].patch,Z=X&&X.length>=3?xe(X,O,B)?0:et(X,O,B):et(L[N].pts,O,B);Z<D&&(D=Z,H=L[N].y)}return H}:(O,B)=>b?_(b.depthAt(O,B)):w,T=[0,1,0],F=L.length>=2||R?()=>T:(O,B)=>{if(!b)return T;let D=b.depthAt(O,B);if(D<=I)return T;let H=(D-I)*$;if(H*y>=vn||d.height+H*y<=S)return T;let[N,V]=b.gradientAt(O,B);if(N===0&&V===0)return T;let X=1/Math.hypot(y,1);return[-N*y*X,X,-V*y*X]};if(!R)for(let O of A.rows){let B=k(O.blockDepth);for(let D of O.seatIndices)s[D]=B}for(let O of A.rows){let B=[];for(let X=1;X<O.pts.length;X++){let Z=Math.hypot(O.pts[X].x-O.pts[X-1].x,O.pts[X].y-O.pts[X-1].y);Z>1e-6&&B.push(Z)}B.sort((X,Z)=>X-Z);let D=B.length?B[Math.floor(B.length/2)]:1/0,H=1/0,N=O.pts[Math.floor(O.pts.length/2)];if(N)for(let X of A.rows){if(X===O||X.blockId!==O.blockId)continue;let Z=et(X.pts,N.x,N.y);Z>1e-6&&Z<H&&(H=Z)}let V=Math.min(D,Math.max(H,D*.5));if(Number.isFinite(V)&&V>0)for(let X of O.seatIndices)a[X]=V}o.set(h,{sectionId:h,deckAt:v,normalAt:F,flat:R,bottomY:p,rowLevels:L,landingY:C})}for(let h=0;h<t.length;h++){let m=r[h],d=t[h];if(m){let x=s[h];i[h]=(x??o.get(m).deckAt(d.x,d.y))+vr;continue}let p=d.eyeHeightM,y=Number.isFinite(p)?Math.max(0,p-ve):0;i[h]=d.kind==="booth"?y+Ve+vr:y}return{bySection:o,seatOwner:r,seatDeckY:h=>i[h],seatPitchU:h=>a[h]}}function st(e,t,n){if(e.length!==4||n<=t)return null;let o=ge(e),r=Math.hypot(o[1].x-o[0].x,o[1].y-o[0].y)*P,i=Math.hypot(o[3].x-o[0].x,o[3].y-o[0].y)*P;if(r<1e-6||i<1e-6)return null;let s=Math.min(.22/r,.16),a=Math.min(.28,(n-t)*.13),c=Math.min(.065/i,.2);return{quad:o,side:s,face:c,opening:be(o,s,1-s),openingTop:n-a}}function kn(e,t,n){if(e.length!==4||n-t<=.2)return null;let o=ge(e),r=Math.hypot(o[1].x-o[0].x,o[1].y-o[0].y)*P;if(r<=1e-6)return null;let i=Math.min(.14,(n-t)*.08,r*.08),s=i/r,a=be(o,s,1-s);return{quad:o,side:s,trim:i,inner:a,panel:It(a,.15,.85),bottom:t+i,top:n-i}}function Or(e,t,n,o){let r=kn(e,t,n);if(!r)return;let{panel:i}=r,s=(g,R)=>({x:(g.x+R.x)/2,y:(g.y+R.y)/2}),a=s(i[0],i[1]),c=s(i[3],i[2]),f=Math.hypot(a.x-o.x,a.y-o.y)<=Math.hypot(c.x-o.x,c.y-o.y),[l,u]=f?[i[0],i[1]]:[i[3],i[2]],h=f?{x:a.x-c.x,y:a.y-c.y}:{x:c.x-a.x,y:c.y-a.y},m=Math.hypot(h.x,h.y);if(m<1e-6)return;-(u.y-l.y)*h.x+(u.x-l.x)*h.y<0&&([l,u]=[u,l]);let d=Math.min(.006,m*P*.05),p=h.x/m*d,y=h.y/m*d,x=(g,R)=>[g.x*P+p,R,g.y*P+y];return[x(l,r.bottom),x(u,r.bottom),x(l,r.top),x(u,r.top)]}var Br=Ce(require("polygon-clipping"),1);var Lr=Ce(require("polygon-clipping"),1);function Be(e,t,n,o,r,i,s,a={}){let c=Le(t),f=a.ao??K,l=r.flatMap(p=>{if(p.role!=="entrance"&&p.role!=="exit")return[];let y=oe(p);if(!y||y.length!==4||!ot(c,Le(y)))return[];let x=a.portalBase??n,g=st(y,x,x+Ae(p).heightM);if(!g)return[];let R=Math.min(o,g.openingTop);return R<=n?[]:[{poly:g.opening,height:R}]});if(!l.length)return!1;let u=p=>p.map(y=>[y.x,y.y]),h=[u(t),...(a.holes??[]).map(u)],m=[n,...new Set(l.map(p=>p.height)),o].sort((p,y)=>p-y),d=[];try{for(let p=1;p<m.length;p++){let y=m[p-1],x=m[p];if(x-y<1e-6)continue;let g=l.filter(A=>A.height>y+1e-6).map(A=>[u(A.poly)]),R=g.length?Lr.default.difference(h,...g):[h];d.push({low:y,high:x,polys:R})}}catch{return!1}for(let p of d)for(let y of p.polys){let[x,...g]=y.map(A=>A.map(([M,b])=>({x:M,y:b}))),R=A=>f.wallBottom+(f.top-f.wallBottom)*(A-n)/(o-n);z(e,x,g,()=>p.high,p.low,i,s,{...f,top:R(p.high),wallBottom:R(p.low)})}return!0}var Tn={depthM:1.6,thicknessM:.35,minWallM:6};function Zt(e,t,n,o,r,i,s,a,c){let f=o-n;if(f<=0)return;let l=a&&(c??f)>=Tn.minWallM?Xc(t,a):null,u=l?o-Tn.thicknessM:o,h=u-n,m=h<1.5?[[n,u,1]]:l?[[n,n+Math.min(.9,h*.18),.82],[n+Math.min(.9,h*.18),u,1]]:[[n,n+Math.min(.9,h*.18),.82],[n+Math.min(.9,h*.18),u-.1,1],[u-.1,u,1.1]],d=p=>K.wallBottom+(K.top-K.wallBottom)*(p-n)/f;for(let[p,y,x]of m){let g={...K,top:d(y),wallBottom:d(p)},R=Y(i,x),A=Y(s,x);Be(e,t,p,y,r,R,A,{portalBase:n,ao:g})||z(e,t,void 0,()=>y,p,R,A,g)}for(let[p,...y]of l??[])z(e,p,y.length?y:void 0,()=>o,u,Y(i,1.12),Y(s,.78),K)}function Xc(e,t){let n=Tn.depthM/P,o=e.map(s=>{let a=t.x-s.x,c=t.y-s.y,f=Math.hypot(a,c)||1;return{x:s.x+a/f*n,y:s.y+c/f*n}}),r=s=>{let a=s.map(c=>[c.x,c.y]);return a.push(a[0]),a},i=[[r(e)],[r(o)]];for(let s=0;s<e.length;s++){let a=(s+1)%e.length;i.push([r([e[s],e[a],o[a],o[s]])])}try{let[s,...a]=i,c=Br.default.union(s,...a);return c.length?c.map(f=>f.map(l=>l.slice(0,-1).map(([u,h])=>({x:u,y:h})))):null}catch{return null}}function Rt(e,t,n){let o=ne(t.stroke?.color),r=t.stroke?.width??0;if(!o||!Number.isFinite(r)||r<=0)return;let i=t.kind==="line"||t.kind==="polyline",s=i?Yt(t.points??[],t.rotation):oe(t);if(!s||s.length<2)return;let a=i?s.length-1:s.length,c=r*.5;for(let f=0;f<a;f++){let l=s[f],u=s[(f+1)%s.length],h=Math.hypot(u.x-l.x,u.y-l.y);if(h<1e-6)continue;let m=-(u.y-l.y)/h*c,d=(u.x-l.x)/h*c,p=[(l.x+m)*P,n,(l.y+d)*P],y=[(u.x+m)*P,n,(u.y+d)*P],x=[(u.x-m)*P,n,(u.y-d)*P],g=[(l.x-m)*P,n,(l.y-d)*P];e.tri(p,y,x,[0,1,0],o),e.tri(p,x,g,[0,1,0],o)}}function Fr(e){return e==="bar"||e==="concession"||e==="coat"||e==="restroom"}var at=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n});function $t(e,t,n,o){let[r,i,s,a]=t?e:[e[3],e[2],e[1],e[0]];return[at(r,a,n),at(i,s,n),at(i,s,o),at(r,a,o)]}function Nr(e,t,n,o,r,i,s,a,c=!1){if(n.length!==4||r-o<.4)return!1;let f=S=>c?Math.min(S,r):S,l=ge(n),u=Math.hypot(l[3].x-l[0].x,l[3].y-l[0].y)*P;if(u<.4)return!1;let h=at(l[0],l[1],.5),m=at(l[3],l[2],.5),d=Math.hypot(h.x-a.x,h.y-a.y)<=Math.hypot(m.x-a.x,m.y-a.y),p=te(s,[.92,.9,.86],.35),y=Y(i,.72),x=r-o;if(t==="restroom"){let S=Math.min(.18,x*.08);return ee(e,l,r-S,o,s,i),ee(e,l,r,r-S,p,p),!0}let g=o+Math.min(1.1,x),R=t==="coat"?1:Math.min(.5,.75/u),A=$t(l,d,0,R);if(ee(e,A,g-.05,o,y,i),ee(e,A,g,g-.05,p,p),t==="coat"||u<1.2)return!0;if(t==="bar"){let S=$t(l,d,Math.max(R+.2,1-.45/u),1),w=f(o+Math.max(Math.min(2.2,x*2),g-o+.6));return ee(e,S,w,o,s,y),!0}let M=$t(l,d,Math.max(R+.25,.55),1),b=f(o+Math.max(2.6,g-o+1.4));if(b-.14<=g)return!0;ee(e,M,b-.14,o,s,i),ee(e,l,b,b-.14,p,y);let I=Math.min(.08,.1/Math.max(.1,Math.hypot(l[1].x-l[0].x,l[1].y-l[0].y)*P));for(let[S,w]of[[0,I],[1-I,1]])ee(e,$t(be(l,S,w),d,0,Math.min(.08,.1/u)),b-.14,g,y,y);return!0}var Uc=[.12,.38,.16],Vc=[.72,.62,.45],Kc=[.88,.93,.96],Dr=[.95,.95,.94],Yc=[.66,.29,.22],On={length:20.12,width:3.05},Wc=.14,zc=9.76,Fe=[.93,.94,.95],Qt=[.1,.11,.13],Zc=[.45,.85,1.25],$c=1.45,Gr=.012,jr=.004,Qc=1.07,qc=.15;function lt(e,t,n,o,r,i){e.setMaterial(i),z(e,t,n?[n.slice().reverse()]:void 0,()=>o,o-.004,r,r,K)}var Hr=(e,t)=>He(e,t/P);function Xr(e,t,n){let o=t.x-e.x,r=t.y-e.y,i=Math.hypot(o,r);if(i<1e-9)return null;let s=-r/i*n,a=o/i*n;return[{x:e.x+s,y:e.y+a},{x:t.x+s,y:t.y+a},{x:t.x-s,y:t.y-a},{x:e.x-s,y:e.y-a}]}function Jc(e,t,n,o){let r=t.map(i=>[i.x*P,n,i.y*P]);e.tri(r[0],r[1],r[2],[0,1,0],o),e.tri(r[0],r[2],r[3],[0,1,0],o)}function qt(e,t,n,o,r,i){let s=n/P,a=[{x:t.x-s,y:t.y-s},{x:t.x+s,y:t.y-s},{x:t.x+s,y:t.y+s},{x:t.x-s,y:t.y+s}];z(e,a,void 0,()=>r,o,i,Y(i,.85),K)}function ct(e,t,n,o,r,i,s){let a=Xr(t,n,o/P);a&&z(e,a,void 0,()=>i,r,s,Y(s,.85),K)}function Jt(e){let t=ge(e),n={x:(t[0].x+t[2].x)/2,y:(t[0].y+t[2].y)/2},o=Math.hypot(t[1].x-t[0].x,t[1].y-t[0].y)||1,r=Math.hypot(t[3].x-t[0].x,t[3].y-t[0].y)||1,i={x:(t[1].x-t[0].x)/o,y:(t[1].y-t[0].y)/o},s={x:(t[3].x-t[0].x)/r,y:(t[3].y-t[0].y)/r};return{at:(c,f)=>({x:n.x+(i.x*c+s.x*f)/P,y:n.y+(i.y*c+s.y*f)/P}),lengthM:o*P,widthM:r*P}}function Ur(e,t,n){let o=Io(t);if(!o.length)return;let r=1/0,i=-1/0,s=1/0,a=-1/0;for(let R of t.points??[])r=Math.min(r,R.x),i=Math.max(i,R.x),s=Math.min(s,R.y),a=Math.max(a,R.y);let c=(t.rotation??0)*Math.PI/180,f=Math.cos(c),l=Math.sin(c),u=(r+i)/2,h=(s+a)/2,m=R=>c?{x:u+(R.x-u)*f-(R.y-h)*l,y:h+(R.x-u)*l+(R.y-h)*f}:R,d=Math.min(i-r,a-s)*P,p=Math.max(.04,Math.min(.3,d*.004))/P,y=0;e.setMaterial(0);for(let R of o){if(!R.fill)continue;let A=R.points.map(m);lt(e,A,null,n+Gr+y*jr,ne(R.fill)??Fe,0),y++}let x=o.filter(R=>!(R.fill&&R.ink===R.fill)),g=[...new Set(x.map(R=>R.ink??Lt))];for(let R of g){let A=n+Gr+y++*jr,M=ne(R)??Fe;for(let b of x){if((b.ink??Lt)!==R)continue;let I=b.points.map(m),S=b.closed?I.length:I.length-1;for(let w=0;w<S;w++){let _=Xr(I[w],I[(w+1)%I.length],p);_&&Jc(e,_,A,M)}}}}function Vr(e,t,n,o,r){if(t.length<3)return!1;let i=o+.006,s=r??Uc;if(n==="oval-cricket"){let a=t.reduce((M,b)=>M+b.x,0)/t.length,c=t.reduce((M,b)=>M+b.y,0)/t.length,f=M=>t.map(b=>({x:a+(b.x-a)*M,y:c+(b.y-c)*M})),l=8;for(let M=0;M<l;M++){let b=f(1-M/l),I=M===l-1?null:f(1-(M+1)/l);lt(e,b,I,i,Y(s,M%2?1.04:.96),4)}let u=t[0];for(let M of t)Math.hypot(M.x-a,M.y-c)>Math.hypot(u.x-a,u.y-c)&&(u=M);let h=Math.hypot(u.x-a,u.y-c)||1,m=(u.x-a)/h,d=(u.y-c)/h,p=-d,y=m,x=Math.min(1,2*h*P*Wc/On.length),g=On.length*x/2/P,R=On.width*x/2/P,A=[[-g,-R],[g,-R],[g,R],[-g,R]].map(([M,b])=>({x:a+m*M+p*b,y:c+d*M+y*b}));return lt(e,A,null,i+.004,Vc,0),e.setMaterial(0),!0}if(n==="rink-hockey"){let a=Hr(t,qc);return lt(e,a,null,i,Kc,0),e.setMaterial(0),z(e,t,[a.slice().reverse()],()=>o+Qc,o,Dr,Y(Dr,.9),K),!0}if(n==="ring-boxing"&&t.length===4){let{at:a}=Jt(t),c=[a(-3.05,-3.05),a(3.05,-3.05),a(3.05,3.05),a(-3.05,3.05)],f=[[.77,.19,.19],Fe,[.17,.42,.69],Fe];e.setMaterial(0),c.forEach((l,u)=>qt(e,l,.07,o,o+$c,f[u]));for(let l of Zc)for(let u=0;u<4;u++)ct(e,c[u],c[(u+1)%4],.025,o+l-.025,o+l+.025,Fe);return!0}if(n==="court-tennis"&&t.length===4){let{at:a}=Jt(t);e.setMaterial(0),ct(e,a(0,-6.4),a(0,6.4),.015,o,o+.95,Qt),ct(e,a(0,-6.4),a(0,6.4),.03,o+.95,o+1,Fe);for(let c of[-1,1])qt(e,a(0,c*6.4),.05,o,o+1.07,Qt);return!0}if(n==="court-basketball"&&t.length===4){let{at:a,lengthM:c}=Jt(t),f=Math.min(14,c/2-.5);e.setMaterial(0);for(let l of[-1,1]){let u=a(l*(f+1.2),0),h=a(l*(f-1.2),0);qt(e,u,.12,o,o+3.4,Qt),ct(e,u,h,.06,o+3.25,o+3.4,Qt),ct(e,a(l*(f-1.2),-.9),a(l*(f-1.2),.9),.03,o+2.9,o+3.95,Fe)}return!0}if(n==="pitch-rugby"&&t.length===4){let{at:a,lengthM:c}=Jt(t),f=c*(50/120);e.setMaterial(0);for(let l of[-1,1]){for(let u of[-2.8,2.8])qt(e,a(l*f,u),.07,o,o+12,Fe);ct(e,a(l*f,-2.8),a(l*f,2.8),.06,o+2.94,o+3.06,Fe)}return!0}if(n==="track-athletics"){let a=Hr(t,zc);return a.length<3?!1:(lt(e,t,a,i,Yc,0),lt(e,a,null,i,s,4),e.setMaterial(0),!0)}return!1}var Kr=[.19,.4,.15],el=.012,on=2.4,tl=1,nl=.75,ol=.15;function Ee(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),c=n/2,f=o/2;return[[-c,-f],[c,-f],[c,f],[-c,f]].map(([l,u])=>({x:t.x+l*s-u*a,y:t.y+l*a+u*s}))}function Qr(e,t,n,o,r,i,s=!1){let a=Ee(t);if(a){if(s){let c=qe(o,r.boothTop),f=ke([...a]);z(e,we(f,rl/P),[f.slice().reverse()],()=>n+.03,n,c,Y(c,.8),K);return}if(!(!t.points&&i&&sl(e,a,n,o,i))){if(!t.points&&i&&a.length===4){il(e,a,n,o,i);return}z(e,a,void 0,()=>n+on,n,qe(o,r.boothTop),r.boothWall,K)}}}var Ln=1.1,Yr=[.9,.9,.88],rl=.1,en=[.87,.87,.85],Wr=.08;function qr(e,t){let n=c=>({x:(e[c].x+e[(c+1)%4].x)/2,y:(e[c].y+e[(c+1)%4].y)/2}),o=0,r=1/0;for(let c=0;c<4;c++){let f=n(c),l=Math.hypot(f.x-t.x,f.y-t.y);l<r&&(r=l,o=c)}let i=[0,1,2,3].map(c=>e[(o+c)%4]),s=(c,f,l)=>({x:c.x+(f.x-c.x)*l,y:c.y+(f.y-c.y)*l});return{q:i,part:(c,f,l,u)=>{let h=s(i[0],i[1],c),m=s(i[0],i[1],f),d=s(i[3],i[2],c),p=s(i[3],i[2],f);return[s(h,d,l),s(m,p,l),s(m,p,u),s(h,d,u)]},depthM:Math.hypot(i[3].x-i[0].x,i[3].y-i[0].y)*P,widthM:Math.hypot(i[1].x-i[0].x,i[1].y-i[0].y)*P}}function il(e,t,n,o,r){let{q:i,part:s}=qr(t,r),a=o??[.35,.42,.55],c=te(a,[.78,.78,.77],.62),f=te(a,[.95,.95,.94],.45);ee(e,i,n+Ve,n,c,Y(c,.8)),ee(e,s(.05,.95,.72,.98),n+Ln-.05,n+Ve,f,Y(f,.8)),ee(e,s(.03,.97,.7,1),n+Ln,n+Ln-.05,Yr,Y(Yr,.9))}function sl(e,t,n,o,r){if(t.length!==4)return!1;let{q:i,part:s,depthM:a,widthM:c}=qr(t,r);if(a<1||c<1)return!1;let f=o??[.35,.42,.55],l=te(f,[.78,.78,.77],.62),u=n+on,h=Wr/c,m=Wr/a;ee(e,i,n+Ve,n,l,Y(l,.8)),ee(e,s(0,1,1-m,1),u,n+Ve,en,Y(en,.9));for(let[y,x]of[[0,h],[1-h,1]])ee(e,s(y,x,0,1-m),u,n+Ve,en,Y(en,.9));ee(e,s(h,1-h,0,Math.min(.5,.06/a)),u,u-.3,f,Y(f,.85));let d=Math.min(.4,.6/c),p=Math.min(.12,.3/a);return ee(e,s(.5-d,.5+d,.72-p,.72+p),n+tl,n+Ve,te(f,[.95,.95,.94],.7),Y(f,.75)),!0}function rn(e){if(e.shape==="round"){let l=e.radius;return l?jt(e.center.x,e.center.y,l,l,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),c=t/2,f=n/2;return[[-c,-f],[c,-f],[c,f],[-c,f]].map(([l,u])=>({x:r.x+l*s-u*a,y:r.y+l*a+u*s}))}function Jr(e,t,n,o,r,i=!0){let s=rn(t);if(!s)return;let a=s.reduce((h,m)=>h+m.x,0)/s.length,c=s.reduce((h,m)=>h+m.y,0)/s.length,f=h=>s.map(m=>({x:a+(m.x-a)*h,y:c+(m.y-c)*h})),l=i&&o?qe(o,r.tableTop):al,u=n+nl;z(e,s,void 0,()=>u,n+cl,l,Y(l,.86),K),z(e,f(.12),void 0,()=>u+.12,u,zr,Y(zr,.8),K)}var al=[.93,.92,.89],zr=[.78,.66,.42],cl=.25,wt={armM:1.1,widthM:.28,insideM:1.4,low:.043,high:.048};function ll(e,t,n){let o=e.reduce((x,g)=>x+g.x,0)/4,r=e.reduce((x,g)=>x+g.y,0)/4,i=e[3].x-e[0].x,s=e[3].y-e[0].y,a=Math.hypot(i,s)||1;i/=a,s/=a,i*(t.x-o)+s*(t.y-r)<0&&(i=-i,s=-s);let c=-s,f=i,l=wt.armM/P,u=wt.widthM/P,h=a/2+wt.insideM/P,m=n?-1:1,d=o+i*(h+(n?0:l)),p=r+s*(h+(n?0:l)),y=(x,g)=>({x:d+i*x*m+c*g,y:p+s*x*m+f*g});return[y(0,0),y(-l,l),y(-l-u,l),y(-u,0),y(-l-u,-l),y(-l,-l)]}function ul(e,t,n,o,r){let i=[.94,.95,.96];z(e,ll(t,o,r),void 0,()=>n+wt.high,n+wt.low,i,i,K)}function nn(e,t){let n=ne(e);return n?{top:Y(Pe(n,.12),.95),wall:Y(Pe(n,.12),.85)}:{top:t.tierTop,wall:t.tierWall}}function ei(e,t,n,o,r,i,s,a,c=[]){let f=oe(t);if(!t.role&&(!t.fill||t.fill==="none"||t.fill==="transparent")||!f){Rt(e,t,n+o+el);return}let u=a?a.kind==="stage":t.role==="stage",h=a?a.kind==="screen":t.role==="screen",m=a?{kind:u?"stage":"solid",heightM:a.topY-a.baseY}:Ae(t),d=a?.baseY??n,p=a?.topY??n+o;if(u&&s){let S=1/0,w=-1/0,_=1/0,k=-1/0;for(let L of f)L.x<S&&(S=L.x),L.x>w&&(w=L.x),L.y<_&&(_=L.y),L.y>k&&(k=L.y);s.push({cx:(S+w)/2*P,cz:(_+k)/2*P,y:p,halfX:Math.max((w-S)/2*P,.5),halfZ:Math.max((k-_)/2*P,.5)})}let y=ne(t.fill),x=t.role==="wall"||t.role==="entrance"||t.role==="exit",g=x?nn(t.fill,r).top:u&&y?te(r.stageTop,Y(Pe(y,.18),.9),.9):!t.role&&y?y:qe(y,u?r.stageTop:r.decorTop),R=h?y:null,A=x?nn(t.fill,r).wall:u?y?te(r.stageWall,Y(y,.58),.82):r.stageWall:h?R?te(Y(R,1.42),[.24,.46,.82],.08):[.24,.46,.82]:qe(ne(t.fill),r.decorWall);if(t.role==="wall"&&!a){Zt(e,f,d,p,c,g,A,i),Rt(e,t,p+.012);return}if(h&&f.length===4&&p-d>.2){let S=kn(f,d,p);if(!S)return;let{quad:w,side:_,trim:k,inner:L,panel:C}=S,E=[.12,.15,.18];for(let[v,T]of[[0,_],[1-_,1]])ee(e,be(w,v,T),p,d,E,E);ee(e,L,d+k,d,E,E),ee(e,L,p,p-k,E,E),ee(e,C,p-k,d+k,A,A),Rt(e,t,p+.012);return}let M=y?Y(Pe(y,.15),.82):A,b=y?Y(Pe(y,.1),1.02):g;if(Fr(t.role)&&!a&&Nr(e,t.role,f,d,p,M,b,i,t.heightM!==void 0))return;if((t.role==="sound"||a?.kind==="sound_desk")&&f.length===4&&p-d>.3){let S=ge(f),w=Math.hypot(S[1].x-S[0].x,S[1].y-S[0].y)*P,_=Math.min(.12,.09/Math.max(w,.001)),k=[.18,.21,.24],L=p-Math.min(.12,(p-d)*.15);for(let[C,E]of[[0,_],[1-_,1]])ee(e,be(S,C,E),L,d,k,k);ee(e,S,p,L,g,k);return}if(t.role==="rail"&&f.length===4&&p>d){let S=ge(f),w=Math.hypot(S[1].x-S[0].x,S[1].y-S[0].y)*P,_=Math.max(1,Math.min(128,Math.ceil(w/1.4))),k=Math.min(.08,.055/Math.max(.055,w)),L=[.58,.64,.66];for(let C=0;C<=_;C++){let E=C/_,v=Math.min(1-k,Math.max(0,E-k/2));ee(e,be(S,v,v+k),p,d,L,Y(L,.8))}for(let C of[.52,1]){let E=d+(p-d)*C;ee(e,S,E,Math.max(d,E-.055),L,Y(L,.8))}return}if(t.role==="goal"&&f.length===4){let S=ge(f),w=Math.hypot(S[1].x-S[0].x,S[1].y-S[0].y)*P,_=Math.min(.12,.1/Math.max(.1,w)),k=[.9,.94,.94];for(let[L,C]of[[0,_],[1-_,1]])ee(e,be(S,L,C),Math.max(d,p-.1),d,k,k);ee(e,S,p,Math.max(d,p-.1),k,k);return}if(m.kind==="portal"&&f.length===4){let S=st(f,d,p);if(!S)return;let{quad:w,side:_,face:k,openingTop:L}=S;for(let[C,E,v]of[[0,k,1],[k,1-k,.67],[1-k,1,1]]){let T=It(w,C,E),F=Y(g,v),O=Y(A,v);for(let[B,D]of[[0,_],[1-_,1]])ee(e,be(T,B,D),L,d,F,O);ee(e,T,p,L,F,O)}(t.role==="entrance"||t.role==="exit")&&ul(e,w,d,i,t.role==="exit");return}if(m.kind==="suite"&&f.length===4){let S=f.map((k,L)=>{let C=f[(L+1)%4],E=(k.x+C.x)/2,v=(k.y+C.y)/2;return Math.hypot(E-i.x,v-i.y)}),w=S.indexOf(Math.min(...S)),_=[0,1,2,3].map(k=>f[(w+k)%4]);ee(e,be(_,0,.08),p,d,g,A),ee(e,be(_,.92,1),p,d,g,A),ee(e,It(_,.88,1),p,d,g,A),ee(e,_,p,Math.max(d,p-.18),g,A);return}if(u&&!t.stageKind?.startsWith("pitch-")&&p-d>.12){let S=p-Math.min(.06,(p-d)*.15);ee(e,f,S,d,g,A),ee(e,f,p,S,g,te(g,A,.2))}else ee(e,f,p,d,g,A);if((t.stageKind==="pitch-football"||t.stageKind==="pitch-rugby")&&f.length===4){e.setMaterial(4);let S=ge(f),w=te(y??Kr,Kr,y?.45:0);for(let _=0;_<12;_++){let k=be(S,_/12,(_+1)/12),L=Y(w,_%2?1.09:.91),C=k.map(E=>[E.x*P,p+.006,E.y*P]);e.tri(C[0],C[1],C[2],[0,1,0],L),e.tri(C[0],C[2],C[3],[0,1,0],L)}}t.stageKind&&t.stageKind!=="pitch-football"&&Vr(e,f,t.stageKind,p,y),u&&ze(t.stageKind)&&Ur(e,t,p),e.setMaterial(h?1:0),Rt(e,t,p+.012)}function sn(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,c=Math.cos(a),f=Math.sin(a),l=o/2,u=r/2;return[[-l,-u],[l,-u],[l,u],[-l,u]].map(([h,m])=>({x:i+h*c-m*f,y:s+h*f+m*c}))}function fl(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 ne(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 c=ne(a[1].trim());c&&s.push(c)}return s.length?s.reduce((a,c,f)=>te(a,c,1/(f+1)),s[0]):null}function ti(e,t,n,o){if(t.layer==="foreground")return;let r=sn(t);if(!r)return;let i=n+ol,s=qe(fl(t.href),o.decorTop),a=Math.max(0,Math.min(1,t.opacity??1));a<1&&(s=te(o.ground,s,a)),z(e,r,void 0,()=>i,n,s,te(s,o.decorWall,.5),K)}function ni(e,t,n,o,r){if(!t.points||t.points.length<3)return;let i=Qo(o,r.gaTop);z(e,t.points,t.holes,()=>n+Zr,n,i,r.gaWall,K),dl(e,t.points,n+Zr)}var Zr=.15,tn=[.72,.74,.76],Bn=1.1,$r=.12,Fn=.05,ml=.06,hl=2.4;function dl(e,t,n){let o=ke([...t]),r=He(o,$r/P),i=He(o,($r+Fn)/P);if(r.length<3||i.length<3)return;for(let a of[n+Bn,n+Bn*.5])z(e,r,[i.slice().reverse()],()=>a,a-Fn,tn,Y(tn,.85),K);let s=ml/2/P;for(let a=0;a<r.length;a++){let c=r[a],f=r[(a+1)%r.length],l=Math.hypot(f.x-c.x,f.y-c.y)*P,u=Math.max(1,Math.round(l/hl));for(let h=0;h<u;h++){let m=h/u,d=c.x+(f.x-c.x)*m,p=c.y+(f.y-c.y)*m,y=[{x:d-s,y:p-s},{x:d+s,y:p-s},{x:d+s,y:p+s},{x:d-s,y:p+s}];z(e,y,void 0,()=>n+Bn-Fn,n,tn,Y(tn,.8),K)}}}var Nn=.6,oi=3,pl=.25;function bl(e,t){if(xe(t,e.x,e.y))return 0;let n=1/0;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[r],s=t[o],a=s.x-i.x,c=s.y-i.y,f=a*a+c*c||1,l=Math.max(0,Math.min(1,((e.x-i.x)*a+(e.y-i.y)*c)/f));n=Math.min(n,Math.hypot(e.x-(i.x+l*a),e.y-(i.y+l*c)))}return n}function ri(e,t){let n=e.map(s=>({booth:s,ring:Ee(s)})).filter(s=>!!s.ring&&s.ring.length===4&&!s.booth.points),o=n.map(({ring:s})=>({minX:Math.min(...s.map(a=>a.x)),maxX:Math.max(...s.map(a=>a.x)),minY:Math.min(...s.map(a=>a.y)),maxY:Math.max(...s.map(a=>a.y))})),r=(oi+Nn)/P,i=new Map;return n.forEach(({booth:s,ring:a},c)=>{let f={x:a.reduce((m,d)=>m+d.x,0)/4,y:a.reduce((m,d)=>m+d.y,0)/4},l=[0,1,2,3].map(m=>{let d=a[m],p=a[(m+1)%4],y={x:(d.x+p.x)/2,y:(d.y+p.y)/2},x=y.x-f.x,g=y.y-f.y,R=Math.hypot(x,g)||1,A={x:y.x+x/R*Nn/P,y:y.y+g/R*Nn/P},M=oi/P;return o.forEach((b,I)=>{I===c||A.x<b.minX-r||A.x>b.maxX+r||A.y<b.minY-r||A.y>b.maxY+r||(M=Math.min(M,bl(A,n[I].ring)))}),{open:M*P,toward:{x:y.x+x/R*10/P,y:y.y+g/R*10/P},focal:Math.hypot(y.x-t.x,y.y-t.y)}}),u=Math.max(...l.map(m=>m.open)),h=l.filter(m=>m.open>=u-pl).sort((m,d)=>m.focal-d.focal)[0];i.set(s.id,h.toward)}),i}var ii=Ce(require("polygon-clipping"),1);var yl=.45,xl=1500,gl=200;function si(e,t){if(e.role!=="stage"||ze(e.stageKind))return e;let n=oe(e);if(!n||n.length<3||Math.abs(ye(n))*P*P>xl)return e;let o=t.filter(s=>xe(n,s.x,s.y));if(!o.length||o.length>gl)return e;let r=yl/P,i=o.map(s=>[[[s.x-r,s.y-r],[s.x+r,s.y-r],[s.x+r,s.y+r],[s.x-r,s.y+r],[s.x-r,s.y-r]]]);try{let s=ii.default.difference([[...n.map(f=>[f.x,f.y]),[n[0].x,n[0].y]]],...i),a=null,c=0;for(let f of s){let l=f[0].slice(0,-1).map(([h,m])=>({x:h,y:m})),u=Math.abs(ye(l));u>c&&(c=u,a=l)}return!a||a.length<3?e:{...e,kind:"polygon",points:a,rotation:0}}catch{return e}}var Ml=Math.PI/180,re=96,Sl=6,Il=60,Rl=150,ai=.2,wl=.35;function Pl(e,t){let n=Math.atan2(t.x-e.x,t.y-e.y)/Ml;return n<0?n+360:n}function an(e){if(!e.length)return NaN;let t=[...e].sort((n,o)=>n-o);return t[Math.floor(t.length/2)]}function cn(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 c=-n;c<=n;c++){let f=i+c;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 ci(e,t){let n=e.filter(h=>h.rows.length>=1);if(n.length<1)return null;let o=[],r=0,i=0,s=0;for(let h of n)for(let m of h.rows){for(let d of m.pts)r+=d.x,i+=d.y,s++;if(m.pts.length>=4){let d=bn(m.pts);d&&Number.isFinite(d.cx)&&Number.isFinite(d.cy)&&o.push({x:d.cx,y:d.cy})}}if(!s)return null;let a={x:r/s,y:i/s},c=a;if(o.length>=8){let h=an(o.map(x=>x.x)),m=an(o.map(x=>x.y)),d=0;for(let x of n)for(let g of x.rows)for(let R of g.pts){let A=Math.hypot(R.x-a.x,R.y-a.y);A>d&&(d=A)}let p=0,y=d*.2;for(let x of n)for(let g of x.rows)for(let R of g.pts)Math.hypot(R.x-h,R.y-m)<y&&p++;Math.hypot(h-a.x,m-a.y)<=d&&p/s<.01&&(c={x:h,y:m})}let f=[];for(let h of n){let m={sectionId:h.sectionId,rMin:1/0,rMax:-1/0,samples:[]};for(let d of h.rows)for(let p of d.pts){let y=Math.hypot(p.x-c.x,p.y-c.y),x=Math.min(re-1,Math.floor(Pl(c,p)/(360/re)));m.samples.push({r:y,bin:x,levelM:d.levelM}),y<m.rMin&&(m.rMin=y),y>m.rMax&&(m.rMax=y)}m.samples.length&&f.push(m)}if(!f.length)return null;f.sort((h,m)=>h.rMin+h.rMax-(m.rMin+m.rMax));let l=[];for(let h of f){let m=!1;for(let d of l){let p=Math.min(h.rMax,d.rMax)-Math.max(h.rMin,d.rMin),y=Math.min(h.rMax-h.rMin,d.rMax-d.rMin);if(y>1e-9&&p>=wl*y){d.members.push(h),d.rMin=Math.min(d.rMin,h.rMin),d.rMax=Math.max(d.rMax,h.rMax),m=!0;break}}m||l.push({members:[h],rMin:h.rMin,rMax:h.rMax})}let u=[];for(let h of l){let m=new Array(re).fill(null);for(let C of h.members)for(let E of C.samples){let v=m[E.bin];v||(v={samples:[]},m[E.bin]=v),v.samples.push({r:E.r,levelM:E.levelM})}let d=m.map(C=>!!C);if(!d.filter(Boolean).length)continue;let y=[],x=[];for(let C of m){if(!C)continue;let E=1/0,v=-1/0;for(let T of C.samples)T.r<E&&(E=T.r),T.r>v&&(v=T.r);y.push(E),x.push(v)}let g=an(y),R=an(x);if(!(g>=ai*R)||!(R>0))continue;let A=[...y].sort((C,E)=>C-E);if(!(A[Math.floor(A.length*.1)]>=ai*R))continue;let b=m.map(C=>{if(!C)return null;let E=[...C.samples].sort((N,V)=>N.r-V.r),v=E[0].r,T=E[E.length-1].r,F=E[0].levelM,O=-1/0;for(let N of E)N.levelM>O&&(O=N.levelM);let B=[];for(let N of E){let V={r:N.r,l:N.levelM};for(;B.length&&Math.abs(B[B.length-1].r-V.r)<1e-9;){if(B[B.length-1].l<=V.l){V.skip=!0;break}B.pop()}if(!V.skip){for(;B.length>=2;){let X=B[B.length-2],Z=B[B.length-1];if((Z.r-X.r)*(V.l-X.l)-(Z.l-X.l)*(V.r-X.r)<=0)B.pop();else break}B.push(V)}}let D=B.map(N=>N.r),H=B.map(N=>N.l);return{inner:v,outer:T,front:F,top:O,profile:{rs:D,ls:H}}}),I=d.slice();for(let C=0;C<re;C++){if(I[C])continue;let E=-1,v=-1,T=0;for(let U=1;U<=re;U++){let J=(C-U+re*2)%re;if(I[J]){E=J;break}}for(let U=1;U<=re;U++){let J=(C+U)%re;if(I[J]){v=J,T=U;break}}if(E<0||v<0)continue;let F=0;for(let U=1;U<=re;U++){let J=(C-U+re*2)%re;if(d[J]){F=U;break}}if(F-1+T>Sl)continue;let B=b[E],D=b[v],H=F/(F+T),N=B.inner+(D.inner-B.inner)*H,V=B.outer+(D.outer-B.outer)*H,X=B.front+(D.front-B.front)*H,Z=B.top+(D.top-B.top)*H;b[C]={inner:N,outer:V,front:X,top:Z,profile:{rs:[N,V],ls:[X,Z]}}}for(let C=0;C<re;C++)b[C]&&(I[C]=!0);let S=360/re,w=[],_=I.filter(Boolean).length,k=[];if(_===re)k.push({start:0,len:re});else{let C=0;for(;I[C];)C=(C+1)%re;let E=-1;for(let v=0;v<=re;v++){let T=(C+v)%re,F=v<re&&I[T];if(F&&E<0)E=T;else if(!F&&E>=0){let O=(T-E+re)%re||re;k.push({start:E,len:O}),E=-1}}}for(let C of k){if(C.len*S<Il&&C.len<re)continue;let E=C.len===re,v=new Float64Array(C.len),T=new Float64Array(C.len),F=new Float64Array(C.len),O=new Float64Array(C.len),B=[];for(let U=0;U<C.len;U++){let J=b[(C.start+U)%re];v[U]=J.inner,T[U]=J.outer,F[U]=J.front,O[U]=J.top,B.push(J.profile??{rs:[J.inner,J.outer],ls:[J.front,J.top]})}let D=cn(v,E),H=cn(T,E),N=cn(F,E),V=cn(O,E);for(let U=0;U<C.len;U++)D[U]>v[U]&&(D[U]=v[U]),H[U]<T[U]&&(H[U]=T[U]),D[U]>H[U]-1e-6&&(D[U]=Math.max(0,H[U]-1e-6)),V[U]<N[U]&&(V[U]=N[U]);let X={startBin:C.start,binCount:C.len,closed:E,innerR:D,outerR:H,frontLevelM:N,topLevelM:V,profiles:B},Z=(U,J,Q)=>{let ce=B[U],ae=ce.rs,G=ce.ls;if(J<=ae[0]){G[0]>Q&&(G[0]=Q);return}if(J>=ae[ae.length-1]){G[G.length-1]>Q&&(G[G.length-1]=Q);return}for(let j=0;j+1<ae.length;j++)if(J<=ae[j+1]){G[j]>Q&&(G[j]=Q),G[j+1]>Q&&(G[j+1]=Q);return}};for(let U=0;U<C.len;U++){let J=m[(C.start+U)%re];if(J)for(let Q of J.samples){Z(U,Q.r,Q.levelM);let ce=E?(U-1+C.len)%C.len:U-1,ae=E?(U+1)%C.len:U+1;ce>=0&&Z(ce,Q.r,Q.levelM),ae<C.len&&Z(ae,Q.r,Q.levelM)}}w.push(X)}w.reduce((C,E)=>C+E.binCount*S,0)<Rl||u.push({arcs:w,sectionIds:h.members.map(C=>C.sectionId),innerRMedian:g,outerRMedian:R})}if(!u.length)return null;if(u.sort((h,m)=>h.innerRMedian-m.innerRMedian),t){let h=u[u.length-1].outerRMedian;if(Math.hypot(t.x-c.x,t.y-c.y)>.9*h)return null}return{centre:c,binCount:re,binStepDeg:360/re,rings:u}}function li(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),c=i-s,f=l=>{let u=t.profiles[l],h=u.rs,m=u.ls;if(o<=h[0])return m[0];if(o>=h[h.length-1])return m[m.length-1];for(let d=0;d+1<h.length;d++)if(o<=h[d+1]){let p=h[d+1]-h[d],y=p>1e-9?(o-h[d])/p:0;return m[d]+(m[d+1]-m[d])*y}return m[m.length-1]};return f(s)*(1-c)+f(a)*c}function Dn(e,t,n,o,r,i,s,a,c,f=[],l=r){if(t.length!==n.length||t.length<2||i-r<1.5)return;let u=(p,y,x)=>{Be(e,p,y,x,f,s,a,{portalBase:l,ao:c})||z(e,p,void 0,()=>x,y,s,a,c)},h=(p,y,x)=>({x:p.x+(y.x-p.x)*x,y:p.y+(y.y-p.y)*x}),m=o?t.length:t.length-1,d=0;for(let p=0;p<m;p++){let y=(p+1)%t.length,x=Math.hypot(n[y].x-n[p].x,n[y].y-n[p].y)*$;if(x<1e-5)continue;let g=(b,I)=>[h(t[p],t[y],b),h(t[p],t[y],I),h(n[p],n[y],I),h(n[p],n[y],b)];u(g(0,1),r,r+.95),u(g(0,1),i-.22,i);let R=Math.ceil((d-.32)/6)*6,A=!1,M=!1;for(let b=R;b<d+x;b+=6){let I=Math.max(0,(b-d)/x),S=Math.min(1,(b+.32-d)/x);S<=I||(u(g(I,S),r+.95,i-.22),A||=I<1e-6,M||=S>1-1e-6)}if(!o&&(p===0&&!A||p===m-1&&!M)){let b=Math.min(1,.32/x);u(g(p===0?0:1-b,p===0?b:1),r+.95,i-.22)}d+=x}}var Ke=Ce(require("polygon-clipping"),1),At=.65;function Gn(e,t){let n=1/0;for(let o of t)for(let r=0;r<o.length;r++){let i=o[r],s=o[(r+1)%o.length],a=s.x-i.x,c=s.y-i.y,f=Math.max(0,Math.min(1,((e.x-i.x)*a+(e.y-i.y)*c)/(a*a+c*c||1)));n=Math.min(n,Math.hypot(e.x-i.x-f*a,e.y-i.y-f*c))}return n}var jn=.01;function ui(e,t,n,o,r,i,s,a=[],c=!0,f={bays:[],walls:[]}){if(o-r<=1e-5)return;let l=o-r>=3,u=l?o-At:r;e.setMaterial(5);let h=l?[]:a.filter(b=>{if(b.role!=="entrance"&&b.role!=="exit")return!1;let I=oe(b);if(!I)return!1;let S=st(I,r,r+Ae(b).heightM);return S!==null&&S.openingTop<=o-.12});if((!h.length||!Be(e,t,u,o,h,i,s,{holes:n,portalBase:r}))&&z(e,t,n,()=>o,u,i,s,K,void 0,()=>[0,1,0]),!l){e.setMaterial(0);return}let m=c&&f.bays.length?Al(t,n,He(t,Pt/P),f):null,d=6/P,p=.22/P,y=a.flatMap(b=>{if(b.role!=="entrance"&&b.role!=="exit")return[];let I=oe(b);return I?.length?[{minX:Math.min(...I.map(S=>S.x)),maxX:Math.max(...I.map(S=>S.x)),minY:Math.min(...I.map(S=>S.y)),maxY:Math.max(...I.map(S=>S.y))}]:[]}),x=Math.min(...t.map(b=>b.x)),g=Math.max(...t.map(b=>b.x)),R=Math.min(...t.map(b=>b.y)),A=Math.max(...t.map(b=>b.y));for(let b=x+d/2;b<g;b+=d)for(let I=R+d/2;I<A;I+=d){if(y.some(w=>b+p>=w.minX&&b-p<=w.maxX&&I+p>=w.minY&&I-p<=w.maxY))continue;let S=[{x:b-p,y:I-p},{x:b+p,y:I-p},{x:b+p,y:I+p},{x:b-p,y:I+p}];!he({x:b,y:I},t,n)||Gn({x:b,y:I},[t,...n??[]])<p*Math.SQRT2+(c?Pt/P:0)||m&&Gn({x:b,y:I},m.flat())<p*Math.SQRT2+Pt/P||z(e,S,void 0,()=>u,r,i,s,K)}if(m){for(let[b,...I]of m)z(e,b,I,()=>u,r-jn,i,s,K);e.setMaterial(0);return}let M=He(t,Pt/P);if(c&&M.length>=3){let b=a.filter(w=>{if(w.role!=="entrance"&&w.role!=="exit")return!1;let _=oe(w);return!!_&&_.some(k=>!he(k,t,void 0)||Gn(k,[t])<=Pt/P)}),I=[M.slice().reverse()],S=r-jn;(!b.length||!Be(e,t,S,u,b,i,s,{holes:I,portalBase:r+jn}))&&z(e,t,I,()=>u,S,i,s,K)}e.setMaterial(0)}var Hn=.25,Pt=Hn;function Al(e,t,n,o){if(n.length<3)return null;let r=s=>{let a=s.map(c=>[c.x,c.y]);return a.push(a[0]),a},i=s=>{let[a,...c]=s.map(f=>[r(f)]);return Ke.default.union(a,...c)};try{let s=[r(e),...(t??[]).map(r)],a=Ke.default.difference(s,[r(n)]),c=Ke.default.intersection(s,i(o.bays));if(!c.length)return null;let f=Ke.default.difference(Ke.default.intersection(s,i(o.walls)),c);return Ke.default.union(Ke.default.difference(a,c),f).map(u=>u.map(h=>h.slice(0,-1).map(([m,d])=>({x:m,y:d}))))}catch{return null}}var El=.02,_l=.25,Cl=1.2,vl=.6,kl=.45,Tl=2.3,Ol=Math.PI/180,fi=.005;function Te(e,t,n){let o=n*Ol;return{x:e.x+t*Math.sin(o),y:e.y+t*Math.cos(o)}}function Ll(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 Bl=24,Fl=.01;function Nl(e,t,n,o,r,i,s,a,c){let f=n.binCount,l=Bl,u=$,h=i+.02,m=i-Fl,d=[];for(let E=0;E<f;E++){let v=(n.startBin+E+.5)*t.binStepDeg,T=new Float64Array(l+1);for(let F=0;F<=l;F++){let O=o[E]+(r[E]-o[E])*F/l;T[F]=Math.max(h,li(t,n,v,O)-_l)}d.push(T)}if(c){let E=0;for(let v=0;v+1<f;v++)for(let T=0;T<l;T++){let F=Te(t.centre,o[v]+(r[v]-o[v])*T/l,(n.startBin+v+.5)*t.binStepDeg),O=Te(t.centre,o[v+1]+(r[v+1]-o[v+1])*(T+1)/l,(n.startBin+v+1.5)*t.binStepDeg);E=Math.max(E,Math.hypot(O.x-F.x,O.y-F.y))}for(let v=0;v<f;v++){let T=(n.startBin+v+.5)*t.binStepDeg;for(let F=0;F<=l;F++){let O=Te(t.centre,o[v]+(r[v]-o[v])*F/l,T),B=c(O.x,O.y,E*1.01);B!==null&&(d[v][F]=Math.min(d[v][F],Math.max(m+fi,B-fi)))}}}let p=[s.bandTop[0]*a.top,s.bandTop[1]*a.top,s.bandTop[2]*a.top],y=[s.bandTop[0]*a.bottomCap,s.bandTop[1]*a.bottomCap,s.bandTop[2]*a.bottomCap],x=[s.bandWall[0]*a.top,s.bandWall[1]*a.top,s.bandWall[2]*a.top],g=[s.bandWall[0]*a.wallBottom,s.bandWall[1]*a.wallBottom,s.bandWall[2]*a.wallBottom],R=(E,v)=>{let T=(n.startBin+E+.5)*t.binStepDeg,F=o[E]+(r[E]-o[E])*v/l,O=Te(t.centre,F,T);return[O.x*u,d[E][v],O.y*u]};{let E=Math.tan(12*Math.PI/180);for(let v=0;v<6;v++){let T=!1;for(let O=0;O<f;O++)for(let B=l-1;B>=0;B--)d[O][B]>d[O][B+1]&&(d[O][B]=d[O][B+1],T=!0);let F=n.closed?f:f-1;for(let O=0;O<F;O++){let B=(O+1)%f;for(let D=0;D<=l;D++){let H=d[B][D]-d[O][D];if(Math.abs(H)>1)continue;let N=o[O]+(r[O]-o[O])*D/l,V=o[B]+(r[B]-o[B])*D/l,X=Te(t.centre,N,(n.startBin+O+.5)*t.binStepDeg),Z=Te(t.centre,V,(n.startBin+B+.5)*t.binStepDeg),U=E*Math.hypot(Z.x-X.x,Z.y-X.y)*u;H>U?(d[B][D]=d[O][D]+U,T=!0):-H>U&&(d[O][D]=d[B][D]+U,T=!0)}}if(!T)break}}let A=1,M=(E,v)=>{for(let T=0;T<=l;T+=4)if(Math.abs(d[E][T]-d[v][T])>A)return!0;return Math.abs(d[E][l]-d[v][l])>A},b=Math.tan(38*Math.PI/180),I=E=>(r[E]-o[E])/l*u,S=(E,v)=>d[E][v+1]-d[E][v]>b*Math.max(1e-6,I(E)),w=(E,v)=>{let T=n.closed?(E-1+f)%f:Math.max(0,E-1),F=n.closed?(E+1)%f:Math.min(f-1,E+1);Math.abs(d[T][v]-d[E][v])>A&&(T=E),Math.abs(d[F][v]-d[E][v])>A&&(F=E);let O=Math.max(0,v-1),B=Math.min(l,v+1);O<v&&S(E,O)&&(O=v),B>v&&S(E,v)&&(B=v);let D=R(T,v),H=R(F,v),N=R(E,O),V=R(E,B),X=H[0]-D[0],Z=H[1]-D[1],U=H[2]-D[2],J=V[0]-N[0],Q=V[1]-N[1],ce=V[2]-N[2],ae=Z*ce-U*Q,G=U*J-X*ce,j=X*Q-Z*J,q=Math.hypot(ae,G,j);return q>1e-12?(ae/=q,G/=q,j/=q,G<0&&(ae=-ae,G=-G,j=-j),[ae,G,j]):[0,1,0]},_=(E,v,T=!1)=>{let F=T&&Math.min(E[1],v[1])-i>=3,O=[E[0],F?E[1]-At:m,E[2]],B=[v[0],F?v[1]-At:m,v[2]],D=v[0]-E[0],H=v[2]-E[2],N=Math.hypot(D,H);if(!(N>1e-12))return;let V=[H/N,0,-D/N];e.tri(E,v,B,V,x,x,g),e.tri(E,B,O,V,x,g,g)},k=.05*Ie,L=E=>r[E]-o[E]<k,C=n.closed?f:f-1;for(let E=0;E<C;E++){let v=(E+1)%f;if(L(E)||L(v))continue;if(M(E,v)){let H=(n.startBin+E+1)*t.binStepDeg,N=(Q,ce)=>{let ae=(o[E]+o[v])/2,G=(r[E]+r[v])/2,j=ae+(G-ae)*ce/l,q=Te(t.centre,j,H);return[q.x*u,d[Q][ce],q.y*u]};for(let Q=0;Q<l;Q++){let ce=R(E,Q),ae=R(E,Q+1),G=N(E,Q),j=N(E,Q+1),q=w(E,Q),le=w(E,Q+1);e.triN(ce,G,j,q,q,le,p),e.triN(ce,j,ae,q,le,le,p);let fe=R(v,Q),de=R(v,Q+1),ie=N(v,Q),se=N(v,Q+1),_e=w(v,Q),W=w(v,Q+1);e.triN(ie,fe,de,_e,_e,W,p),e.triN(ie,de,se,_e,W,W,p);let ue=N(E,Q),me=N(E,Q+1),Ye=N(v,Q+1),We=N(v,Q),Ne=me[0]-ue[0],De=me[2]-ue[2],ft=Math.hypot(Ne,De);if(ft>1e-12){let Ct=[De/ft,0,-Ne/ft];e.tri(ue,me,Ye,Ct,x),e.tri(ue,Ye,We,Ct,x)}}let V=R(E,0),X=R(v,0),Z=R(v,l),U=R(E,l),J=Q=>[Q[0],m,Q[2]];Math.min(V[1],X[1])-i<3&&(e.tri(J(V),J(Z),J(X),[0,-1,0],y),e.tri(J(V),J(U),J(Z),[0,-1,0],y)),_(V,X,!0),_(U,Z,!0);continue}for(let H=0;H<l;H++){let N=w(E,H),V=w(v,H),X=w(v,H+1),Z=w(E,H+1);if(S(E,H)||S(v,H)){let ae=(me,Ye)=>{let We=(n.startBin+me+.5)*t.binStepDeg,Ne=o[me]+(r[me]-o[me])*(H+.5)/l,De=Te(t.centre,Ne,We);return[De.x*u,Ye,De.y*u]},G=R(E,H),j=R(v,H),q=ae(E,d[E][H]),le=ae(v,d[v][H]);e.triN(G,j,le,N,V,V,p),e.triN(G,le,q,N,V,N,p);let fe=R(v,H+1),de=R(E,H+1),ie=ae(E,d[E][H+1]),se=ae(v,d[v][H+1]);e.triN(ie,se,fe,Z,X,X,p),e.triN(ie,fe,de,Z,X,Z,p);let _e=le[0]-q[0],W=le[2]-q[2],ue=Math.hypot(_e,W);if(ue>1e-12){let me=[-W/ue,0,_e/ue];e.tri(q,le,se,me,x),e.tri(q,se,ie,me,x)}continue}let U=R(E,H),J=R(v,H),Q=R(v,H+1),ce=R(E,H+1);e.triN(U,J,Q,N,V,X,p),e.triN(U,Q,ce,N,X,Z,p)}let T=R(E,0),F=R(v,0),O=R(v,l),B=R(E,l),D=H=>[H[0],m,H[2]];Math.min(T[1],F[1])-i<3&&(e.tri(D(T),D(O),D(F),[0,-1,0],y),e.tri(D(T),D(B),D(O),[0,-1,0],y)),_(T,F,!0),_(B,O,!0)}if(!n.closed)for(let E of[0,f-1])for(let v=0;v<l;v++)_(R(E,v),R(E,v+1))}function mi(e,t,n){let{bottomY:o,colors:r,ao:i}=n,s=new Float64Array(t.binCount).fill(-1/0);for(let l of t.rings)for(let u of l.arcs){let h=new Float64Array(u.binCount),m=new Float64Array(u.binCount);for(let p=0;p<u.binCount;p++){let y=(u.startBin+p)%t.binCount,x=Math.max(0,u.innerR[p]-Re);h[p]=Math.max(x,s[y]+.001),m[p]=Math.max(h[p]+.001,u.outerR[p]+Re)}let d=0;for(let p=0;p<u.binCount;p++){let y=u.topLevelM[p]-o;y>d&&(d=y)}d>=Cl&&Nl(e,t,u,h,m,o,r,i,n.standTopNear);for(let p=0;p<u.binCount;p++){let y=(u.startBin+p)%t.binCount;m[p]>s[y]&&(s[y]=m[p])}}if(n.deriveShell===!1||Ll(n.shapes,t))return;let a=t.rings[t.rings.length-1],c=vl*Ie,f=kl*Ie;for(let l of a.arcs){let u=[],h=[];for(let w=0;w<l.binCount;w++){let _=(l.startBin+w+.5)*t.binStepDeg,k=l.outerR[w]+Re+c;u.push(Te(t.centre,k,_)),h.push(Te(t.centre,k+f,_))}let m=-1/0;for(let w=0;w<l.binCount;w++)l.topLevelM[w]>m&&(m=l.topLevelM[w]);let d=m+Tl,p=l.closed?h:[...h,...u.slice().reverse()],y=l.closed?[u.slice().reverse()]:void 0,x=te(r.shellWall,[.66,.71,.72],.62),g=(w,_,k,L,C)=>{let E=Math.abs(L-m)<1e-6?L-El:L;Be(e,w,k,E,n.shapes,r.shellTop,C,{holes:_,portalBase:o,ao:i})||z(e,w,_,()=>E,k,r.shellTop,C,i)},R=Math.max(1,Math.ceil((m-o)/4.5)),A=(m-o)/R,M=new Set,b=n.tierFrontLevels??t.rings.map(w=>{let _=w.arcs.flatMap(k=>Array.from(k.frontLevelM)).filter(Number.isFinite).sort((k,L)=>k-L);return _[Math.floor(_.length/2)]});for(let w of b)Number.isFinite(w)&&w-o>=3&&w<m&&M.add(Math.max(0,Math.min(R-1,Math.floor((w-o)/A))));let I=Math.min(...b.filter(w=>Number.isFinite(w)&&w-o>=3&&w<m));for(let w=0;w<R;w++)o+(w+1)*A<=I-At&&Number.isFinite(I)&&M.add(w);for(let w=0;w<R;w++){let _=o+(m-o)*w/R,k=o+(m-o)*(w+1)/R;M.has(w)&&k-_>=3.2?(g(p,y,_,_+.45,x),Dn(e,u,h,l.closed,_+.45,k-.16,r.shellTop,x,i,n.shapes,o)):g(p,y,_,k-.16,x),g(p,y,k-.16,k,Y(x,.62))}Dn(e,u,h,l.closed,m,d,r.shellTop,x,i,n.shapes,o);let S=8;for(let w=1;w<h.length;w++){if(S+=Math.hypot(h[w].x-h[w-1].x,h[w].y-h[w-1].y)*$,S<8)continue;S=0;let _=h[w],k=h[w-1],L=_.x-k.x,C=_.y-k.y,E=Math.max(1,Math.hypot(L,C)),v=L/E*.16*Ie,T=C/E*.16*Ie,F=Math.max(1,Math.hypot(_.x-t.centre.x,_.y-t.centre.y)),O=(_.x-t.centre.x)/F*.24*Ie,B=(_.y-t.centre.y)/F*.24*Ie,D=[{x:_.x-v,y:_.y-T},{x:_.x+v,y:_.y+T},{x:_.x+v+O,y:_.y+T+B},{x:_.x-v+O,y:_.y-T+B}];g(D,void 0,o,m,Y(x,1.12))}}}var Dl=2.5,hi=.65,Gl=2,jl=.03;function Hl(e,t){let n=()=>{let o=t;for(;e.length>2;){let r=e[0],i=e[1],s=Math.hypot(i.x-r.x,i.y-r.y);if(s>o){e[0]={x:r.x+(i.x-r.x)/s*o,y:r.y+(i.y-r.y)/s*o};return}o-=s,e.shift()}};n(),e.reverse(),n(),e.reverse()}function Vn(e,t,n){let o=new Map;for(let i of e){let s=o.get(i.blockId);(!s||i.depth<s.depth)&&o.set(i.blockId,i)}let r=[];for(let[i,s]of o){if(s.y-n<Dl||s.pts.length<2)continue;let a=s.pts.map(l=>{let u=l.x-t.x,h=l.y-t.y,m=Math.max(1,Math.hypot(u,h));return{x:l.x-u/m*hi/P,y:l.y-h/m*hi/P}}),c=[],f=[a[0]];for(let l=1;l<a.length;l++){let u=a[l-1],h=a[l];Math.hypot(h.x-u.x,h.y-u.y)*P>Gl?(f.length>=2&&c.push(f),f=[h]):f.push(h)}f.length>=2&&c.push(f);for(let l of c)Hl(l,jl/P);c.length&&r.push({blockId:i,y:s.y,runs:c})}return r}var di=.1,Xl=1.1,Ul=.22,Xn=.95,Un=.05,pi=1.8;function bi(e,t,n,o){let r=[.72,.72,.69],i=[.48,.55,.57];for(let s of Vn(t,n,o)){let a=s.y;for(let c of s.runs){let f=pi;for(let l=1;l<c.length;l++){let u=c[l-1],h=c[l],m=h.x-u.x,d=h.y-u.y,p=Math.hypot(m,d);if(p<1e-5)continue;let y=x=>{let g=-d/p*x/P/2,R=m/p*x/P/2;return[{x:u.x+g,y:u.y+R},{x:h.x+g,y:h.y+R},{x:h.x-g,y:h.y-R},{x:u.x-g,y:u.y-R}]};if(z(e,y(Ul),void 0,()=>a+di,a-Xl,r,r,K),z(e,y(Un),void 0,()=>a+Xn,a+Xn-Un,i,i,K),f+=p*P,f>=pi||l===c.length-1){f=0;let x=.028/P,g=[{x:u.x-x,y:u.y-x},{x:u.x+x,y:u.y-x},{x:u.x+x,y:u.y+x},{x:u.x-x,y:u.y+x}];z(e,g,void 0,()=>a+Xn-Un,a+di,i,i,K)}}}}}var Vl=.9,Kl=1.5,Yl=.3;function yi(e,t,n){let o=[],r=[],i=Vl/P,s=Kl/P,a=Yl/P;for(let c of e)for(let f of c.runs){if(f.length<2)continue;let l=f.slice(),u=(y,x)=>{let g=l[y],R=l[x],A=Math.hypot(g.x-R.x,g.y-R.y)||1;l[y]={x:g.x+(g.x-R.x)/A*a,y:g.y+(g.y-R.y)/A*a}};u(0,1),u(l.length-1,l.length-2);let h=l.map((y,x)=>{let g=l[Math.max(0,x-1)],R=l[Math.min(l.length-1,x+1)],A=R.x-g.x,M=R.y-g.y,b=Math.hypot(A,M)||1,I=-M/b,S=A/b;return I*(y.x-t.x)+S*(y.y-t.y)<0&&(I=-I,S=-S),{nx:I,ny:S}}),m=l.map((y,x)=>({x:y.x-h[x].nx*s,y:y.y-h[x].ny*s})),d=l.map((y,x)=>({x:y.x+h[x].nx*i,y:y.y+h[x].ny*i})),p=l.map((y,x)=>({x:y.x+h[x].nx*(i+n/P),y:y.y+h[x].ny*(i+n/P)}));o.push([...m,...d.slice().reverse()]),r.push([...d,...p.reverse()])}return{bays:o,walls:r}}var Kn=.88,ln=.27,Wl=1.2,zl=.01;function xi(e,t,n,o,r){let i=[.67,.71,.68],s=[i[0]*Kn,i[1]*Kn,i[2]*Kn],a=c=>!!r&&r.some((f,l)=>l!==c&&f?.belowY!=null&&Math.abs(f.belowY-t[c].y)<1e-6&&t[l].blockId===t[c].blockId);for(let c=0;c<t.length;c++){let f=t[c];if(!(f.pts.length<2))for(let l of[0,f.pts.length-1]){let u=f.pts[l],h=f.pts[l===0?1:l-1],m=u.x-h.x,d=u.y-h.y,p=Math.hypot(m,d);if(p<1e-5)continue;m/=p,d/=p;let y=1/0;for(let v=0;v<n.length;v++){let T=n[v],F=n[(v+1)%n.length],O=F.x-T.x,B=F.y-T.y,D=m*B-d*O;if(Math.abs(D)<1e-8)continue;let H=T.x-u.x,N=T.y-u.y,V=(H*B-N*O)/D,X=(H*d-N*m)/D;V>0&&X>=0&&X<=1&&(y=Math.min(y,V))}let x=.3/P,g=y-.04/P;if(!Number.isFinite(y)||y*P>2||g-x<.12/P)continue;let R=!!o&&a(c),A=r?.[c]?.pitch,M=R&&A&&Number.isFinite(A)?Math.min(Wl/P,Math.max(ln/P,A-ln/P-zl/P)):ln/P,b=-d,I=m;o&&b*(o.x-u.x)+I*(o.y-u.y)<0&&(b=-b,I=-I);let S=ln/P,w=[{x:u.x+m*x+b*S,y:u.y+d*x+I*S},{x:u.x+m*g+b*S,y:u.y+d*g+I*S},{x:u.x+m*g-b*M,y:u.y+d*g-I*M},{x:u.x+m*x-b*M,y:u.y+d*x-I*M}];if(!w.every(v=>xe(n,v.x,v.y)))continue;let _=r?.[c]?.belowY,k=_==null?0:f.y-_,L=!!o&&k>.03&&k<=.65;if(L&&o){let v=(T,F)=>Math.hypot((T.x+F.x)/2-o.x,(T.y+F.y)/2-o.y);v(w[0],w[1])>v(w[3],w[2])&&(w=[w[3],w[2],w[1],w[0]])}let C=L?Math.ceil((k-1e-8)/.2):1,E=(v,T,F)=>({x:v.x+(T.x-v.x)*F,y:v.y+(T.y-v.y)*F});for(let v=0;v<C;v++){let T=v/C,F=(v+1)/C,O=[E(w[0],w[3],T),E(w[1],w[2],T),E(w[1],w[2],F),E(w[0],w[3],F)],B=f.y+.008-(L?k*(1-F):0);z(e,O,void 0,()=>B,B-(L?k/C+.1:.16),i,s,K)}}}}var Zl=.02,$l=.012,Ql=.01,ql=.3,Jl=.5;function eu(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,c=s.y-i.y,f=a*a+c*c,l=f>1e-12?((t-i.x)*a+(n-i.y)*c)/f:0;l=Math.max(0,Math.min(1,l)),o=Math.min(o,Math.hypot(t-(i.x+l*a),n-(i.y+l*c)))}return o}function tu(e,t,n,o){let r=1/0,i=Number.NaN;for(let s=0;s<e.length;s++){let a=t[s];if(Math.hypot(n-a.cx,o-a.cy)-a.rad>=r)continue;let c=eu(e[s].pts,n,o);c<r&&(r=c,i=e[s].y)}return i}function gi(e,t,n,o,r,i,s){let a=o.filter(h=>h.pts.length>0);if(a.length<2||t.length<3)return;let c=a.map(h=>{let m=0,d=0;for(let y of h.pts)m+=y.x,d+=y.y;m/=h.pts.length,d/=h.pts.length;let p=0;for(let y of h.pts)p=Math.max(p,Math.hypot(y.x-m,y.y-d));return{cx:m,cy:d,rad:p}}),f=[...t],l=n.map(h=>[...h]),u=Zl/P;for(let h of[f,...l])for(let m=0;m<h.length;m++){let d=h[m],p=h[(m+1)%h.length],y=p.x-d.x,x=p.y-d.y,g=Math.hypot(y,x);if(g*P<.05)continue;let R=(d.x+p.x)/2,A=(d.y+p.y)/2,M=x/g,b=-y/g;he({x:R+M*u,y:A+b*u},f,l)&&(M=-M,b=-b);let I=r.x-R,S=r.y-A,w=Math.hypot(I,S)||1;if((M*I+b*S)/w>Jl)continue;let _=1/0;for(let O of[.2,.5,.8]){let B=tu(a,c,d.x+y*O-M*u*2,d.y+x*O-b*u*2);Number.isFinite(B)&&(_=Math.min(_,B))}if(!Number.isFinite(_)||_-i<ql)continue;let k=i-Ql,L=_-$l,C={x:(d.x-M*u)*P,z:(d.y-b*u)*P},E={x:(p.x-M*u)*P,z:(p.y-b*u)*P},v=[M,0,b],T=Y(s,K.wallBottom),F=Y(s,K.top);e.tri([C.x,L,C.z],[E.x,L,E.z],[E.x,k,E.z],v,F,F,T),e.tri([C.x,L,C.z],[E.x,k,E.z],[C.x,k,C.z],v,F,T,T)}}function Mi(e,t,n,o,r,i,s,a,c=!1){if(!t.outline||t.outline.length<3)return;let f=n.baseHeightM,l=n.objects.filter(g=>g.type==="shape"&&(g.role==="entrance"||g.role==="exit")),u=qo(o,a.tierTop);if(!r)return;let h=g=>r.deckAt(g.x,g.y),m=Ir(t,s),d=m[0]??t.outline;if(r.rowLevels.length>=2){let g=Vt(r.rowLevels),R=Rr(yr(r.rowLevels,n.focal,g),m),A=yi(Vn(r.rowLevels,n.focal,f),n.focal,Hn);for(let b of R){let I=Math.max(f,b.topY-Si);for(let S of i.subtract(b.outline,I))ui(e,S,b.holes,I,f,a.tierTop,a.tierWall,l,!c,A);e.setMaterial(5),gi(e,b.outline,b.holes,r.rowLevels,n.focal,I,a.tierWall),e.setMaterial(0)}R.length||z(e,d,t.holes,()=>r.landingY,f,u,a.tierWall,K);let M={tread:[u[0]*K.top,u[1]*K.top,u[2]*K.top],riser:[u[0]*.72,u[1]*.72,u[2]*.72]};for(let b of m.length?m:[d])gr(e,r.rowLevels,n.focal,r.landingY,M,b,g);bi(e,r.rowLevels,n.focal,f),xi(e,r.rowLevels,t.outline,n.focal,g);return}let p=r.flat?1/0:kr,y=g=>r.normalAt(g.x,g.y),x=r.flat?r.landingY:void 0;for(let g of i.subtract(d,x))z(e,g,t.holes,h,f,u,a.tierWall,K,p,y)}function nu(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 c=n.bySection.get(a);if(c&&c.rowLevels.length>=2)continue;let f=t[s];if(f.kind==="booth")continue;let l=r.get(a);l||(l=new Map,r.set(a,l));let u=f.rowId||`__seat-${s}`,h=l.get(u);h||(h={pts:[],levelM:0,n:0},l.set(u,h)),h.pts.push({x:f.x,y:f.y}),h.levelM+=n.seatDeckY(s),h.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(l=>!l.patch).map(l=>({pts:l.pts,levelM:l.y}));f.length>=2&&i.push({sectionId:s.id,rows:f});continue}let c=r.get(s.id);c&&i.push({sectionId:s.id,rows:[...c.values()].map(f=>({pts:f.pts,levelM:f.levelM/f.n}))})}return i}function ou(e,t){let n=1/0;for(let o=0;o<t.length;o++){let r=t[o],i=t[(o+1)%t.length],s=i.x-r.x,a=i.y-r.y,c=Math.max(0,Math.min(1,((e.x-r.x)*s+(e.y-r.y)*a)/(s*s+a*a||1)));n=Math.min(n,Math.hypot(e.x-r.x-c*s,e.y-r.y-c*a))}return n}var Si=.02;function ru(e,t){let n=e.objects.filter(o=>o.type==="section"&&!!o.outline&&o.outline.length>=3).flatMap(o=>{let r=t.bySection.get(o.id);if(!r)return[];let i=1/0,s=-1/0,a=1/0,c=-1/0;for(let l of o.outline)l.x<i&&(i=l.x),l.x>s&&(s=l.x),l.y<a&&(a=l.y),l.y>c&&(c=l.y);let f=r.landingY;for(let l of r.rowLevels)f=Math.min(f,l.y-Si);return[{outline:o.outline,holes:o.holes,surface:r,floorTop:f,minX:i,maxX:s,minY:a,maxY:c}]});return(o,r,i)=>{let s=null;for(let a of n){if(o<a.minX-i||o>a.maxX+i||r<a.minY-i||r>a.maxY+i)continue;let c={x:o,y:r};if(!he(c,a.outline,a.holes)&&ou(c,a.outline)>i)continue;let f=Math.min(a.surface.deckAt(o,r),a.floorTop);(s===null||f<s)&&(s=f)}return s}}var iu=3,su=.4;function Ii(e,t,n,o,r,i,s=!0){let a=nu(t,n,o);if(a.length<iu)return;let c=ci(a,t.focal);if(!c)return;let f=Math.max(0,...c.rings.map(l=>l.arcs.reduce((u,h)=>u+h.binCount,0)))/c.binCount;e.setMaterial(5),mi(e,c,{bottomY:t.baseHeightM,tierFrontLevels:a.map(l=>Math.min(...l.rows.map(u=>u.levelM))),colors:{bandTop:Y(r.tierTop,.8),bandWall:r.tierWall,shellTop:i??Y(r.tierWall,1.15),shellWall:i??r.tierWall},ao:K,shapes:t.objects.filter(l=>l.type==="shape"),deriveShell:s&&f>=su,standTopNear:ru(t,o)}),e.setMaterial(0)}var Ri=4;var au=[[/\b(wc|toilets?|restrooms?|washrooms?|lavatory|loo)\b/i,"restroom"],[/\b(bar|drinks|pub|cocktails?)\b/i,"bar"],[/\b(food|concessions?|snacks?|kiosk|caf[eé]|kitchen|catering)\b/i,"concession"],[/\b(coat ?check|cloak ?room|cloakroom|coats)\b/i,"coat"],[/\b(screen|led wall|projection|video wall)\b/i,"screen"],[/\b(sound|foh|mixing desk|control booth)\b/i,"sound"],[/\b(entrance|entry|way in|gate)\b/i,"entrance"],[/\b(exit|way out)\b/i,"exit"],[/\b(pillar|column|obstruction)\b/i,"obstruction"],[/\b(walls?|outline|boundary|perimeter)\b/i,"wall"]],cu=1.2,lu=12;function wi(e){if(e.heightM!==void 0)return!1;let t=oe(e);if(!t||t.length<3)return!1;let n=0;for(let r=0;r<t.length;r++){let i=t[r],s=t[(r+1)%t.length];n+=Math.hypot(s.x-i.x,s.y-i.y)}return n*$<lu*2?!1:2*Et(t)/n*$<=cu}function Yn(e){if(!e)return null;for(let[t,n]of au)if(t.test(e))return n;return null}var Ai="auto-rows-";function Ei(e){return e.id.startsWith(Ai)&&!e.label}var uu=1.15,fu=.09,_i=6,mu=34,hu=.35,du=6,pu=.35,bu=.75,yu=12,xu=2.5,gu=40,Mu=[18,24],Su=[12,16],Pi=14,Iu=.8,Ru=.6,wu=5,Pu=.3,Ci=.4,vi=2,Au=400,Eu=2.6,_u=.8,Cu=4,vu=26,ku=.7,Tu=.5,Ou=.985,Lu=1.5,Bu=2.2,Fu=3,Nu=25,Du=.985,Gu=2,ju=6,Hu=3,Xu=.1,Uu=1.5,Vu=1.6,Ku=6e3,Yu=.6,Wu="#c3c7cd",Wn=300,zu=240;function Zu(e,t,n,o){if(!e.fill||!/^#[0-9a-f]{6}$/i.test(e.fill))return null;let r=Zn([...t]),i=new Set;for(let l of o)i.add(Math.floor(Math.atan2(l.y-r.y,l.x-r.x)*180/Math.PI/10));if(i.size*10<zu)return null;let{h:s,s:a,l:c}=Uo(Xo(e.fill));return s<70/360||s>170/360||a<.2||c<.08||c>.75||n.some(l=>l!==e&&l.type==="shape"&&oe(l)?.some(u=>qn(u,t)))?null:e.kind==="ellipse"?"oval-cricket":e.kind==="rect"?"pitch-football":null}var $u="Estimated from the drawing; confirm with the venue.",$n=e=>{if(!e.length)return null;let t=[...e].sort((o,r)=>o-r),n=Math.floor(t.length/2);return t.length%2?t[n]:(t[n-1]+t[n])/2},Zn=e=>({x:e.reduce((t,n)=>t+n.x,0)/e.length,y:e.reduce((t,n)=>t+n.y,0)/e.length}),Et=e=>{let t=0;for(let n=0;n<e.length;n++){let o=e[n],r=e[(n+1)%e.length];t+=o.x*r.y-r.x*o.y}return Math.abs(t)/2};function Qu(e){return e.height!==void 0||e.rake!==void 0||e.elevation!==void 0||e.surfaceKind!==void 0}function Qn(e){let t=new Map;for(let n of e){let o=t.get(n.rowId);o?o.push(n):t.set(n.rowId,[n])}return t}function qn(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[o],s=t[r];i.y>e.y!=s.y>e.y&&e.x<(s.x-i.x)*(e.y-i.y)/(s.y-i.y)+i.x&&(n=!n)}return n}function Jn(e,t){let n=t[0],o=1/0;for(let r=0;r<t.length;r++){let i=t[r],s=t[(r+1)%t.length],a=s.x-i.x,c=s.y-i.y,f=a*a+c*c,l=f>0?Math.max(0,Math.min(1,((e.x-i.x)*a+(e.y-i.y)*c)/f)):0,u={x:i.x+a*l,y:i.y+c*l},h=Math.hypot(e.x-u.x,e.y-u.y);h<o&&(o=h,n=u)}return n}function ki(e,t){let n=0,o=0;for(let r of e.values()){if(r.length<3)continue;let i=r[0],s=r[r.length-1],a=s.x-i.x,c=s.y-i.y,f=Math.hypot(a,c);if(f<1e-6)continue;let l={x:(i.x+s.x)/2,y:(i.y+s.y)/2},u=Jn(l,t),h=u.x-l.x,m=u.y-l.y,d=Math.hypot(h,m);d<1e-6||(o+=Math.abs((-c*h+a*m)/(f*d))*r.length,n+=r.length)}return n?o/n:0}function qu(e,t,n){let o=e.filter(p=>p.type==="shape"),r=o.find(p=>p.role==="stage");if(r){let p=oe(r);return p?{shape:r,centre:Zn(p),outline:p,inferred:!1}:null}if(!n.length)return null;let i=1/0,s=-1/0,a=1/0,c=-1/0;for(let p of n)i=Math.min(i,p.x),s=Math.max(s,p.x),a=Math.min(a,p.y),c=Math.max(c,p.y);let f=(s-i)*(c-a),l=[];for(let p of o){if(p.role)continue;let y=oe(p);if(!y)continue;let x=Et(y);if(x*$*$<6||x>f)continue;let g=Math.min(...y.map(w=>w.x)),R=Math.max(...y.map(w=>w.x)),A=Math.min(...y.map(w=>w.y)),M=Math.max(...y.map(w=>w.y)),b=0;for(let w of n)w.x>g&&w.x<R&&w.y>A&&w.y<M&&qn(w,y)&&b++;if(b>n.length*.05)continue;let I=Zn(y),S=ki(t,y);S>=Iu&&l.push({shape:p,centre:I,outline:y,score:S,area:x,box:[g,A,R,M]})}let u=(p,y)=>y!==p&&y.area>p.area&&p.box[0]>=y.box[0]-1e-6&&p.box[1]>=y.box[1]-1e-6&&p.box[2]<=y.box[2]+1e-6&&p.box[3]<=y.box[3]+1e-6,h=l.filter(p=>!l.some(y=>u(p,y))),m=Math.max(0,...h.map(p=>p.score)),d=h.filter(p=>p.score>=m-.03).sort((p,y)=>y.area-p.area)[0]??null;return d?{shape:d.shape,centre:d.centre,outline:d.outline,inferred:!0}:null}function Ju(e,t,n){if(!n||n.length<3)return Math.hypot(e.x-t.x,e.y-t.y);let o=Jn(e,n);return Math.hypot(e.x-o.x,e.y-o.y)}function Ti(e){let t=[...e].sort((i,s)=>i.x-s.x||i.y-s.y);if(t.length<3)return t;let n=(i,s,a)=>(s.x-i.x)*(a.y-i.y)-(s.y-i.y)*(a.x-i.x),o=[];for(let i of t){for(;o.length>=2&&n(o[o.length-2],o[o.length-1],i)<=0;)o.pop();o.push(i)}let r=[];for(let i=t.length-1;i>=0;i--){let s=t[i];for(;r.length>=2&&n(r[r.length-2],r[r.length-1],s)<=0;)r.pop();r.push(s)}return[...o.slice(0,-1),...r.slice(0,-1)]}function ef(e){if(!e.length||e.length>Ku)return[];let t=[...Qn(e).values()],n=t.map((a,c)=>c),o=a=>n[a]===a?a:n[a]=o(n[a]),r=Vu/$,i=t.map(a=>({minX:Math.min(...a.map(c=>c.x))-r,maxX:Math.max(...a.map(c=>c.x))+r,minY:Math.min(...a.map(c=>c.y))-r,maxY:Math.max(...a.map(c=>c.y))+r}));for(let a=0;a<t.length;a++)for(let c=a+1;c<t.length;c++){let f=i[a],l=i[c];if(f.maxX<l.minX||l.maxX<f.minX||f.maxY<l.minY||l.maxY<f.minY)continue;t[a].some(h=>t[c].some(m=>Math.hypot(h.x-m.x,h.y-m.y)<=r))&&(n[o(a)]=o(c))}let s=new Map;return t.forEach((a,c)=>{let f=o(c),l=s.get(f);l?l.push(...a):s.set(f,[...a])}),[...s.values()].filter(a=>new Set(a.map(c=>c.rowId)).size>=2)}function tf(e,t,n){if(!t.length)return null;let o=t.filter(S=>n.tableIds.has(S.rowId)||S.kind==="booth").length>t.length/2,r=Qn(t),i=!n.outline||ki(r,n.outline)>=Ru,s=0,a=0;for(let S of r.values()){if(S.length<2)continue;let w=S[0],_=S[S.length-1],k=_.x-w.x,L=_.y-w.y,C=Math.hypot(k,L);if(C<1e-6)continue;let E={x:(w.x+_.x)/2,y:(w.y+_.y)/2},v=i?n.outline?Jn(E,n.outline):n.focal:n.middle,T=-L/C,F=k/C;T*(v.x-E.x)+F*(v.y-E.y)<0&&(T=-T,F=-F),s+=T*S.length,a+=F*S.length}let c={x:t.reduce((S,w)=>S+w.x,0)/t.length,y:t.reduce((S,w)=>S+w.y,0)/t.length};if(Math.hypot(s,a)<1e-9){let S=i?n.focal:n.middle;s=S.x-c.x,a=S.y-c.y}let f=Math.hypot(s,a)||1,l={x:s/f,y:a/f},u=S=>-(S.x*l.x+S.y*l.y),h=S=>-S.x*l.y+S.y*l.x,m=1/0,d=-1/0,p=1/0,y=-1/0,x=1/0,g=new Map;for(let S of t){let w=u(S),_=h(S);m=Math.min(m,w),d=Math.max(d,w),p=Math.min(p,_),y=Math.max(y,_),i&&(x=Math.min(x,Ju(S,n.focal,n.outline)));let k=S.logicalRowId??S.rowId,L=g.get(k);L?L.push(w):g.set(k,[w])}i||(x=Math.max(0,m-u(n.middle)));let R=[...g.values()].map(S=>$n(S)).sort((S,w)=>S-w),A=[];if(!o)for(let S of R)A.length&&S-A[A.length-1]<pu/$||A.push(S);let M=Qu(e),b=Ge(e,{floorBaseHeightM:n.baseHeightM}),I={id:e.id,section:e,authored:M,plane:n,facing:l,facesAction:i,hull:Ti(t),sample:t.filter((S,w)=>w%Math.ceil(t.length/Au)===0),frontD:m,backD:d,latMin:p,latMax:y,frontDistance:x,rowDepths:A,rowCount:A.length,level:0,height:b.height,rake:M?b.rake:0,backHeight:0};return I.backHeight=I.height+(d-m)*$*Math.tan(I.rake*Math.PI/180),I}function nf(e,t,n,o){if(e.length<2)return 0;let r=Math.max(1,t*$),i=n+uu-o,s=0,a=0;for(let f=1;f<e.length;f++){let l=Math.max(bu,(e[f]-e[f-1])*$),u=(i+fu)*(r+l)/r;s+=u-i,a+=l,i=u,r+=l}let c=Math.atan(s/a)*180/Math.PI;return Math.round(Math.max(_i,Math.min(mu,c))*10)/10}function of(e,t,n=!1){if(!n&&e.facing.x*t.facing.x+e.facing.y*t.facing.y<Pu)return null;let o=-1/0,r=1/0,i=-1/0;for(let h of t.hull){o=Math.max(o,-(h.x*e.facing.x+h.y*e.facing.y));let m=-h.x*e.facing.y+h.y*e.facing.x;r=Math.min(r,m),i=Math.max(i,m)}if(Math.min(e.latMax,i)-Math.max(e.latMin,r)<(n?1e-6:Ci*(e.latMax-e.latMin)))return null;let a=vi/$,c=new Map,f=new Map;for(let h of e.sample){let m=Math.floor((-h.x*e.facing.y+h.y*e.facing.x)/a),d=-(h.x*e.facing.x+h.y*e.facing.y);c.set(m,Math.min(c.get(m)??1/0,d))}for(let h of t.sample){let m=Math.floor((-h.x*e.facing.y+h.y*e.facing.x)/a),d=-(h.x*e.facing.x+h.y*e.facing.y);f.set(m,Math.max(f.get(m)??-1/0,d))}let l=[];for(let[h,m]of c){let d=f.get(h);d!==void 0&&l.push(m-d)}let u=l.length?$n(l):e.frontD-o;return u<-1/$?null:u}function rf(e,t){if(t.plane.floorIndex>=e.plane.floorIndex)return!1;let n=-1/0,o=1/0,r=1/0,i=-1/0;for(let c of t.hull){let f=-(c.x*e.facing.x+c.y*e.facing.y);n=Math.max(n,f),o=Math.min(o,f);let l=-c.x*e.facing.y+c.y*e.facing.x;r=Math.min(r,l),i=Math.max(i,l)}let s=Math.min(e.latMax,i)-Math.max(e.latMin,r),a=Math.min(e.backD,n)-Math.max(e.frontD,o);return s>Ci*(e.latMax-e.latMin)&&a>1/$}function sf(e,t){let n=new Set;for(let o of e){let r=(Math.atan2(o.y-t.y,o.x-t.x)*180/Math.PI+360)%360;n.add(Math.floor(r/10))}return n.size/36}function af(e,t){let n=1/0,o=-1/0;for(let i of t.hull){let s=-(i.x*e.facing.x+i.y*e.facing.y);n=Math.min(n,s),o=Math.max(o,s)}let r=Math.max(0,Math.min(o-n,e.frontD-n));return t.height+r*$*Math.tan(t.rake*Math.PI/180)}function cf(e,t){if(!e.facesAction)return!1;let n={x:-e.facing.y,y:e.facing.x},o=vi/$,r=Math.max(1,Math.ceil((e.backD-e.frontD)/o)),i={left:new Map,right:new Map};for(let a of t)if(!(a===e||a.plane.floorIndex!==e.plane.floorIndex)&&!(a.facing.x*e.facing.x+a.facing.y*e.facing.y>=Ou))for(let c of a.sample){let f=-(c.x*e.facing.x+c.y*e.facing.y);if(f<e.frontD||f>e.backD)continue;let l=-c.x*e.facing.y+c.y*e.facing.x,u=l<e.latMin?"left":l>e.latMax?"right":null;if(!u)return!1;let h=Math.min(r-1,Math.floor((f-e.frontD)/o)),m=u==="left"?e.latMin-l:l-e.latMax;m<(i[u].get(h)?.gap??1/0)&&i[u].set(h,{gap:m,other:a})}let s=a=>{let c=a==="left"?e.latMin:e.latMax,f=0;for(let[l,{other:u}]of i[a]){if((u.facing.x*n.x+u.facing.y*n.y)*(a==="left"?1:-1)<ku)continue;let m=e.frontD+(l+.5)*o,d={x:-m*e.facing.x+c*n.x,y:-m*e.facing.y+c*n.y},p=-(d.x*u.facing.x+d.y*u.facing.y),y=-d.x*u.facing.y+d.y*u.facing.x;p<u.frontD&&y>=u.latMin&&y<=u.latMax&&f++}return f/r>=Tu};return s("left")&&s("right")}function lf(e,t){if(t.plane.floorIndex!==e.plane.floorIndex||t.facing.x*e.facing.x+t.facing.y*e.facing.y<Du)return!1;let n=1/0,o=-1/0,r=1/0;for(let a of t.hull){let c=-a.x*e.facing.y+a.y*e.facing.x;n=Math.min(n,c),o=Math.max(o,c),r=Math.min(r,-(a.x*e.facing.x+a.y*e.facing.y))}let i=(e.frontD-r)*$;if(i<-Gu||i>ju)return!1;let s=Math.max(n-e.latMax,e.latMin-o);return s*$<=Hu&&s*$>=-Xu}function uf(e,t=!1,n=!1,o){let r=t?Su:Mu,i=new Set(n?[]:e.filter(p=>!p.authored&&cf(p,e))),s=[...e].sort((p,y)=>p.plane.floorIndex-y.plane.floorIndex||Number(i.has(y))-Number(i.has(p))||p.frontDistance-y.frontDistance);for(let p of i)o?.add(p.id);let a=(p,y,x)=>{let g=new Map,R=[],A=new Map,M=b=>{if(b.plane.floorIndex===0||b.plane.baseHeightM>0)return b.plane.baseHeightM;let I=A.get(b.plane.floorIndex-1);return I===void 0?b.plane.baseHeightM:I+Ri};for(let b of s){if(i.has(b))b.height=M(b),b.level=0,b.rake=0,b.backHeight=b.height,g.set(b.id,void 0);else if(!b.authored){let S=M(b),w;for(let E of R){if(E.plane.floorIndex>b.plane.floorIndex)continue;if(rf(b,E)){let O=af(b,E)+Eu;O>S&&(S=O,w=E);continue}let v=of(b,E,i.has(E));if(v==null)continue;let T=n&&!!b.plane.stageDeck&&E.level===0&&E.plane.floorIndex===b.plane.floorIndex&&Math.max(0,v)*$<=Cu,F=i.has(E)?E.height+Lu:T?E.backHeight:E.backHeight+hu+Math.min(du,Math.max(0,v)*$)*Math.tan(E.rake*Math.PI/180);F>S&&(S=F,w=E)}let _=p.get(b);_&&_.height>S+.01?(S=_.height,w=void 0):_=void 0,b.height=Math.round(Math.min(S,b.plane.baseHeightM+gu)*100)/100;let k=!w&&!_&&b.height>b.plane.baseHeightM;if(b.level=w?w.level+1:_?_.level:k?1:0,b.rake=nf(b.rowDepths,b.frontDistance,b.height,b.plane.focalHeightM),!b.facesAction&&b.rowCount<wu)b.rake=0;else if(b.level===0){let E=Math.max(1e-6,(b.backD-b.frontD)*$);b.rake=Math.min(b.rake,yu,Math.round(Math.atan(xu/E)*1800/Math.PI)/10)}else b.rowCount>=2&&(b.rake=Math.max(b.rake,r[Math.min(b.level,r.length)-1]));let L=(b.backD-b.frontD)*$,C=w&&i.has(w)||_&&x?.has(_.id);if(y!==void 0&&C&&b.rowCount>=2&&(b.rake=y),t&&L>0&&b.height+L*Math.tan(b.rake*Math.PI/180)>b.plane.baseHeightM+Pi){let E=Math.max(0,b.plane.baseHeightM+Pi-b.height);b.rake=Math.max(_i,Math.round(Math.atan(E/L)*1800/Math.PI)/10)}n&&b.plane.stageDeck&&b.level>0&&(b.rake=Math.min(b.rake,vu)),b.backHeight=b.height+L*Math.tan(b.rake*Math.PI/180),g.set(b.id,w?.id??(_?g.get(_.id):void 0))}let I=b.plane.floorIndex;A.set(I,Math.min(A.get(I)??1/0,b.height)),R.push(b)}return g},c=a(new Map),f=new Map,l=p=>f.get(p)?.height??p.height;for(let p=!0,y=0;p&&y<e.length;y++){p=!1;for(let x of e)if(!(x.authored||i.has(x)))for(let g of e){let R=f.get(g)??g;g===x||R.height-R.plane.baseHeightM<Uu||R.height<=l(x)+.01||lf(x,g)&&(f.set(x,R),p=!0)}}let u=new Map(e.map(p=>[p.id,p])),h=e.filter(p=>!p.authored&&p.rowCount>=2&&i.has(u.get(c.get(p.id)??""))),m=h.length?$n(h.map(p=>p.rake)):void 0;if(!f.size&&m===void 0)return c;let d=new Map([...new Set(f.values())].map(p=>[p,{...p}]));return a(new Map([...f].map(([p,y])=>[p,d.get(y)])),m,new Set(h.map(p=>p.id)))}var zn=(e,t)=>!!e&&e.x===t.x&&e.y===t.y;function Oi(e,t={x:0,y:-40}){let n=nt(e),o=new Map;for(let x of n){if(!x.sectionId)continue;let g=o.get(x.sectionId);g?g.push(x):o.set(x.sectionId,[x])}let r={focalInferred:!1,confident:!1,sections:[]},i=e.floors?.length?e.floors.map((x,g)=>({objects:x.objects,floorIndex:g,floorId:x.id,baseHeightM:x.baseHeightM??0,focal:x.focalPoint??e.focalPoint})):[{objects:e.objects,floorIndex:0,floorId:void 0,baseHeightM:0,focal:e.focalPoint}],s=new Set(i.flatMap(x=>x.objects.filter(g=>g.type==="table").map(g=>g.id))),a=[],c,f=new Set,l=i.map(x=>{let g=C=>!e.floors?.length||C.floorId===x.floorId,R=ef(n.filter(C=>!C.sectionId&&C.kind!=="booth"&&!s.has(C.rowId)&&g(C))),A=[];for(let C of R){let E=we(ke(Ti(C)),Yu/$);if(n.some(T=>!g(T)&&qn(T,E)))continue;let v=`${Ai}${x.floorIndex}-${A.length}`;f.add(v),o.set(v,C),A.push({type:"section",id:v,label:"",color:Wu,outline:E})}let M=A.length?{...x,objects:[...x.objects,...A]}:x,b=new Set(M.objects.filter(C=>C.type==="section").map(C=>C.logicalSectionId??C.id)),I=[...o.entries()].filter(([C])=>b.has(C)).flatMap(([,C])=>C),S=qu(M.objects,Qn(I),I),w=M.focal;(S||M.focal&&!zn(M.focal,t))&&(r.confident=!0),S&&(r.stage??={id:S.shape.id,inferred:S.inferred,...M.floorId?{floorId:M.floorId}:{}},(S.inferred||zn(M.focal,t))&&(w=S.centre,r.focalInferred=!0));let _=S&&(!S.inferred||Et(S.outline)*$*$<=Wn),k=S?void 0:c,L={tableIds:s,floorIndex:M.floorIndex,floorId:M.floorId,baseHeightM:M.baseHeightM,focal:k?.focal??w,outline:S?.outline??k?.outline,focalHeightM:k?.focalHeightM??M.baseHeightM+(S&&_?Ae({...S.shape,role:"stage"}).heightM:0),stageDeck:k?.stageDeck??!!(S&&_&&Et(S.outline)*$*$<=Wn),middle:I.length?{x:I.reduce((C,E)=>C+E.x,0)/I.length,y:I.reduce((C,E)=>C+E.y,0)/I.length}:w};for(let C of M.objects){if(C.type!=="section")continue;let E=tf(C,o.get(C.logicalSectionId??C.id)??[],L);E&&a.push(E)}return L.outline&&(c=L),zn(M.focal,L.focal)||(r.focal??=[]).push({...M.floorId?{floorId:M.floorId}:{},point:{...L.focal}}),{unit:M,plane:L,stage:S,planeSeats:I}}),u=i.flatMap(x=>x.objects).map(x=>x.type==="shape"&&!x.role&&(Yn(x.label)==="wall"||!Yn(x.label)&&wi(x))?{...x,role:"wall"}:x),h=Ue({objects:u},n)!==null;h&&(r.indoor=!0);let m=new Set,d=uf(a,h,sf(n,l[0]?.plane.focal??t)<_u,m),p=new Map(a.filter(x=>!x.authored).map(x=>[x.id,x])),y=l.map(({unit:x,plane:g,stage:R,planeSeats:A})=>x.objects.map(M=>{let b=M.type==="shape"&&!M.role&&M.id!==R?.shape.id?Yn(M.label):null;if(M.type==="shape"&&!M.role&&M.id!==R?.shape.id&&(b==="wall"||!b&&wi(M))&&M.type==="shape"){(r.roles??=[]).push({id:M.id,...g.floorId?{floorId:g.floorId}:{},role:"wall"});let{fill:E,...v}=M;return{...v,role:"wall"}}if(b&&M.type==="shape")return(r.roles??=[]).push({id:M.id,...g.floorId?{floorId:g.floorId}:{},role:b}),{...M,role:b};let S=R?.inferred&&M.id===R.shape.id&&M.type==="shape"?Zu(M,R.outline,x.objects,A):null;if(S&&M.type==="shape")return r.stage?.id===M.id&&(r.stage.field=S),{...M,role:"stage",stageKind:S};let w=M.type==="shape"&&M.id===R?.shape.id&&M.heightM===void 0&&!M.stageKind&&a.some(E=>E.plane===g&&(m.has(E.id)||E.level===0&&E.facesAction&&E.rake<=Fu&&(E.frontDistance+E.backD-E.frontD)*$>=Nu)),_=w?{heightM:Bu}:{};if(R?.inferred&&M.id===R.shape.id&&M.type==="shape"&&Et(R.outline)*$*$<=Wn)return r.stage?.id===M.id&&(r.stage.deck=!0),{...M,role:"stage",..._};if(w&&M.type==="shape"&&M.role==="stage")return{...M,..._};let k=M.type==="section"?p.get(M.id):void 0;if(!k||M.type!=="section")return M;let L=k.rowCount>=2&&k.rake>0;f.has(k.id)?r.looseRowBlocks=(r.looseRowBlocks??0)+1:r.sections.push({id:k.id,floorId:g.floorId,surfaceKind:L?"rakedRows":"flat",height:k.height,rake:k.rake,stackedOn:d.get(k.id)});let C={status:"inferred",source:"public-2d-topology",note:$u};return{...M,height:k.height,rake:k.rake,surfaceKind:L?"rakedRows":"flat",physical3dProvenance:{height:C,rake:C,surfaceKind:C}}}));if(e.floors?.length){let x=e.floors.map((g,R)=>({...g,objects:y[R],focalPoint:l[R].plane.focal}));return{doc:{...e,floors:x,objects:x[0].objects,focalPoint:x[0].focalPoint},report:r}}return{doc:{...e,objects:y[0],focalPoint:l[0].plane.focal},report:r}}var Li=/^[\p{L}\p{N}]{1,4}$/u,ff=/^([\p{L}\p{N}]{2,})[\s\-\u2013\u2014\u00b7_./]+(.+)$/u;function Bi(e,t){let n=t?.trim();if(!n)return e;let o=e.toLocaleLowerCase("en-US"),r=n.toLocaleLowerCase("en-US");if(o.startsWith(`${r} `)){let s=e.slice(n.length).trim();if(Li.test(s))return s}let i=ff.exec(e);if(i){let s=i[1].toLocaleLowerCase("en-US"),a=i[2].trim();if((r.startsWith(s)||s.startsWith(r))&&Li.test(a))return a}return e}var Fi={inline:"Inline booth \xB7 1 open side",corner:"Corner booth \xB7 2 open sides",peninsula:"Peninsula booth \xB7 3 open sides",island:"Island booth \xB7 4 open sides"},mf=new Map(Pn.map(e=>[e.key,e.label]));function hf(e){return`picker.access.${e}`}function Ni(e){let t=[],n=e.boothType;n&&Object.prototype.hasOwnProperty.call(Fi,n)&&t.push({key:`booth:${n}`,icon:"booth",titleKey:`picker.boothType.${n}`,titleFallback:Fi[n],tone:"place"});let o=e.wheelchairSpaceType;for(let a of e.accessibility??[]){if(a==="wheelchair"&&o)continue;let c=mf.get(a);c&&t.push({key:`access:${a}`,icon:a,titleKey:hf(a),titleFallback:c,tone:"access"})}o==="no-seat"?t.push({key:"wheelchair:no-seat",icon:"wheelchair",titleKey:"picker.emptyWheelchairSpace",titleFallback:"Empty wheelchair space",tone:"access"}):o==="seat-present"&&t.push({key:"wheelchair:seat-present",icon:"wheelchair",titleKey:"picker.accessiblePhysicalSeat",titleFallback:"Accessible physical seat",tone:"access"}),e.aisle===!0&&t.push({key:"place:aisle",icon:"aisle",titleKey:"picker.aisleSeat",titleFallback:"Aisle seat",tone:"place"});let r=e.commercial;r?.restrictedView&&t.push({key:"mark:restrictedView",icon:"restrictedView",titleKey:"picker.restrictedView",titleFallback:"Restricted view",tone:"warn"}),r?.obstructedView&&t.push({key:"mark:obstructedView",icon:"obstructedView",titleKey:"picker.obstructedView",titleFallback:"Obstructed view",tone:"warn"}),r?.premium&&t.push({key:"mark:premium",icon:"premium",titleKey:"picker.premiumSeat",titleFallback:"Premium seat",tone:"premium"});let i=r?.note?.trim();if(i){let a=t.find(c=>c.tone==="warn"||c.tone==="premium");a?a.note=i:t.push({key:"note",icon:"note",titleKey:"picker.organizerNote",titleFallback:"Organizer note",tone:"note",note:i})}let s=typeof e.entrance=="string"?e.entrance.trim():"";return s&&t.push({key:"place:entrance",icon:"entrance",titleKey:"picker.entrance",titleFallback:"Entrance",tone:"place",note:s}),t}var df=1.5,pf=30,bf=4,yf=3.6,xf=6,eo=15,gf=3,Mf=1;function Sf(e){return Math.max(yf,Math.min(xf,2.4+.15*e))}var _t=Math.PI*2;function If(e,t){let n=0,o=0;for(let u of e)n+=u.x,o+=u.y;let r=Math.atan2(o/e.length-t.y,n/e.length-t.x),i=e.map(u=>{let h=Math.atan2(u.y-t.y,u.x-t.x)-r;for(;h>Math.PI;)h-=_t;for(;h<-Math.PI;)h+=_t;return h+r}),s=i.map((u,h)=>h).sort((u,h)=>i[u]-i[h]),a=i[s[0]],c=i[s[s.length-1]];if(c-a>Math.PI)return null;let f=u=>Math.hypot(u.x-t.x,u.y-t.y),l=u=>{let h=e[u],m=(u+e.length-1)%e.length,d=(u+1)%e.length,p=Math.abs(i[m]-i[u])<=Math.abs(i[d]-i[u])?m:d,y=e[p];return f(h)<=f(y)?[h,y]:[y,h]};return{start:a,end:c,startEdge:l(s[0]),endEdge:l(s[s.length-1])}}function Di(e){return e.type==="shape"&&e.role==="wall"&&e.heightM===void 0}function to(e,t,n=()=>!0){let o=[];for(let c of e){if(!Di(c)||!n(c))continue;let f=oe(c);if(!f||f.length<3)continue;let l=If(f,t);if(!l)return[];o.push(l)}if(o.length<2)return[];let r=e.flatMap(c=>{if(c.type!=="shape"||c.role!=="entrance"&&c.role!=="exit")return[];let f=oe(c);if(!f?.length)return[];let l=0,u=0;for(let h of f)l+=h.x,u+=h.y;return[{x:l/f.length,y:u/f.length}]}),i=c=>(c%_t+_t)%_t;o.sort((c,f)=>i(c.start)-i(f.start));let s=c=>Math.hypot(c.x-t.x,c.y-t.y),a=[];for(let c=0;c<o.length;c++){let f=o[c],l=o[(c+1)%o.length],u=i(l.start-f.end);if(u<=0||u>=Math.PI/2)continue;let h=b=>i(b-f.end)<u;if(o.some(b=>b!==f&&b!==l&&(h(b.start)||h(b.end)||i(f.end-b.start)<b.end-b.start)))continue;let[d,p]=f.endEdge,[y,x]=l.startEdge,g={x:(d.x+p.x)/2,y:(d.y+p.y)/2},R={x:(y.x+x.x)/2,y:(y.y+x.y)/2},A=Math.hypot(R.x-g.x,R.y-g.y)*P;if(A<df||A>pf||Math.abs(s(g)-s(R))*P>bf+.2*A)continue;let M={x:(g.x+R.x)/2,y:(g.y+R.y)/2};r.some(b=>h(Math.atan2(b.y-t.y,b.x-t.x))&&Math.abs(s(b)-s(M))*P<=gf)||a.push({quad:[d,p,x,y],mid:M,widthM:A,openingM:Sf(A)})}return a}function Gi(e,t){let n=[];for(let i of t)if(i.text?.trim())for(let s of e){let a=Math.hypot(i.position.x-s.mid.x,i.position.y-s.mid.y)*P;a<=eo&&n.push({text:i,gate:s,d:a})}n.sort((i,s)=>i.d-s.d);let o=new Map,r=new Set;for(let{text:i,gate:s}of n)o.has(i.id)||r.has(s)||(o.set(i.id,s),r.add(s));return o}function ji(e,t,n,o,r,i,s,a=()=>!0){let c=to(t,it(n),a);if(!c.length)return;let f=t.find(u=>Di(u)&&a(u)),l=nn(f?.fill,s);e.setMaterial(Wt);for(let u of c)r-u.openingM<Mf||Zt(e,u.quad,o+u.openingM,o+r,[],l.top,l.wall,i,r);e.setMaterial(0)}var Rf=6,wf=2.2,no=.1,Pf=/^(gate|entrance|entry|exit|way in|way out|door)s?$/i,Af=new Set(["stage","entrance","exit","screen","suite","obstruction","sound","bar","concession","restroom","coat"]),Ef=.3,_f=1.8,Cf=.9,vf=.55,kf=1,Hi=4e3,Tf=6,Xi="#d8a425",Of="#e8c15a",oo="#1c1608";function Ui(e){let t=Lf(e);if(!t)return null;let n=Ni(e).find(o=>o.icon===t.icon);return{...t,name:n?.titleFallback??t.icon}}function Lf(e){let t=e.accessibility;if(t?.length)return{icon:t.includes("wheelchair")?"wheelchair":t[0],color:Xt(t)};let n=e.commercial;return n?.obstructedView?{icon:"obstructedView",color:Xi,ink:oo}:n?.restrictedView?{icon:"restrictedView",color:Xi,ink:oo}:n?.premium?{icon:"premium",color:Of,ink:oo}:null}function Bf(e,t){if(!e)return;let n,o=0;for(let[i,s]of e)s>o&&(o=s,n=i);let r=t.categories?.find(i=>i.key===n)?.color;return r&&/^#[0-9a-f]{6}$/i.test(r)?r:void 0}var Ff=6e3,Nf=.25,Vi=[-90,90,-135,135,-45,45];function Df(e,t,n,o){let r=e.flatMap(({id:s,a,members:c})=>{let f=(a.minX+a.maxX)/2,l=(a.minY+a.maxY)/2,u=.5*Math.hypot(a.maxX-a.minX,a.maxY-a.minY),h=1/0;for(let m of c)h=Math.min(h,Math.hypot(t[m].x-f,t[m].y-l));return c.length&&h>=u*Nf?[{id:s,cx:f,cy:l,half:u,members:c}]:[]}).sort((s,a)=>s.half-a.half),i=new Map;return r.forEach(({id:s,cx:a,cy:c,members:f},l)=>{let u=o.x-a,h=o.y-c,p=(Math.hypot(u,h)>1e-6?Math.atan2(h,u):0)+Vi[l%Vi.length]*Math.PI/180,y=Math.cos(p),x=Math.sin(p),g=-1,R=-1/0;for(let A of f){let M=(t[A].x-a)*y+(t[A].y-c)*x;M>R&&(R=M,g=A)}i.set(s,[t[g].x*P,n.seatDeckY(g),t[g].y*P])}),i}function Yi(e){let{doc:t,units:n,seats:o,surfaces:r,focal:i}=e,s=t.zones??[],a=[];if(s.length){let c=new Map;for(let h of n)for(let m of h.objects)m.type==="section"&&m.zone&&c.set(m.id,m.zone);let f=new Map,l=new Map;for(let h=0;h<o.length;h++){let m=o[h],d=r.seatOwner[h],p=m.zoneId??(d?c.get(d):void 0);if(!p)continue;let y=f.get(p);y||(y={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},f.set(p,y));let x=l.get(p);x||l.set(p,x=[]),x.push(h),y.n++,m.x<y.minX&&(y.minX=m.x),m.y<y.minY&&(y.minY=m.y),m.x>y.maxX&&(y.maxX=m.x),m.y>y.maxY&&(y.maxY=m.y),y.sumY+=r.seatDeckY(h)}let u=Df(s.flatMap(h=>{let m=f.get(h.id);return m?[{id:h.id,a:m,members:l.get(h.id)??[]}]:[]}),o,r,i);for(let h of s){let m=f.get(h.id),d=[];for(let[p,y]of c)y===h.id&&d.push(p);if(!m||m.n===0){a.push({id:h.id,label:h.label,color:ne(h.color),sectionIds:d,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(h.focalPoint??i).x*P,1.5,(h.focalPoint??i).y*P]});continue}a.push({id:h.id,label:h.label,color:ne(h.color),sectionIds:d,seatCount:m.n,...u.has(h.id)?{labelAt:u.get(h.id)}:{},center:[(m.minX+m.maxX)/2*P,m.sumY/m.n,(m.minY+m.maxY)/2*P],radius:.5*Math.hypot((m.maxX-m.minX)*P,(m.maxY-m.minY)*P)||1,focalWorld:[(h.focalPoint??i).x*P,1.5,(h.focalPoint??i).y*P]})}}return a}function Wi(e){let{doc:t,units:n,seats:o,surfaces:r,seatData:i,hintedSeatFloor:s,zones:a,focal:c}=e,f=[],l=[],u=[],h=new Map;for(let m of n)for(let d of m.objects){if(d.type!=="section"||!d.zone)continue;let p=(d.displayLabel||d.label||"").trim().toLocaleLowerCase();if(!p)continue;let y=t.floors?.[m.index]?.name?.trim().toLocaleLowerCase();if(n.length>1&&y===p)continue;let x=h.get(d.zone);x||h.set(d.zone,x=new Set),x.add(p)}for(let m of a)m.seatCount!==0&&(h.get(m.id)?.has(m.label.trim().toLocaleLowerCase())||f.push({id:`zone:${m.id}`,kind:"zone",text:m.label,anchor:[(m.labelAt??m.center)[0],(m.labelAt??m.center)[1]+Rf,(m.labelAt??m.center)[2]],color:t.zones?.find(d=>d.id===m.id)?.color}));{let m=new Map,d=new Map,p=new Map,y=new Map;for(let x=0;x<o.length;x++){let g=r.seatOwner[x];if(!g)continue;let R=m.get(g);R||(R={n:0,x:0,y:0,deck:0},m.set(g,R)),R.n++,R.x+=o[x].x,R.y+=o[x].y,R.deck+=r.seatDeckY(x);let A=o[x].categoryKey;if(A){let b=d.get(g);b||(b=new Map,d.set(g,b)),b.set(A,(b.get(A)??0)+1)}if(o[x].accessibility?.includes("wheelchair")){let b=p.get(g);b?b.push(x):p.set(g,[x])}let M=y.get(g);M||(M={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0,minDeck:1/0,maxDeck:-1/0},y.set(g,M)),M.minDeck=Math.min(M.minDeck,r.seatDeckY(x)),M.maxDeck=Math.max(M.maxDeck,r.seatDeckY(x)),o[x].x<M.minX&&(M.minX=o[x].x),o[x].x>M.maxX&&(M.maxX=o[x].x),o[x].y<M.minY&&(M.minY=o[x].y),o[x].y>M.maxY&&(M.maxY=o[x].y)}for(let x of n)for(let g of x.objects){if(g.type!=="section"||Ei(g))continue;let R=m.get(g.id);if(!R||R.n===0)continue;let A=y.get(g.id),M=[R.x/R.n*P,R.deck/R.n,R.y/R.n*P],b=g.displayLabel||g.label||g.id;l.push({id:g.id,floorIndex:x.index,label:b,seatCount:R.n,center:M,radius:Math.max(1,Math.hypot(A.maxX-A.minX,A.maxY-A.minY)*.5*P),box:{min:[A.minX*P-.4,A.minDeck,A.minY*P-.4],max:[A.maxX*P+.4,A.maxDeck+1,A.maxY*P+.4]},focalWorld:[x.focal.x*P,x.baseHeightM+1.5,x.focal.y*P]});let I=t.floors?.[x.index]?.name?.trim().toLocaleLowerCase();if(!(n.length>1&&I===b.trim().toLocaleLowerCase())){let S=Bf(d.get(g.id),t),w=p.get(g.id);f.push({id:`section:${g.id}`,kind:"section",text:b,anchor:[M[0],M[1]+wf,M[2]],floorIndex:x.index,...S?{tint:S}:{},...w?{wheelchairSeats:w}:{}})}}}{for(let M of n)for(let b of M.objects){if(b.type!=="gaArea")continue;let I=Je(b.points);if(!I)continue;let S=b.labelPresentation?.visible===!1?"":b.displayLabel||b.label||b.id,w=b.capacity>0?[S,b.capacity.toLocaleString()].filter(Boolean).join(" \xB7 "):S;w&&f.push({id:`ga:${b.id}`,kind:"ga",text:w,anchor:[I.x*P,M.baseHeightM+_f,I.y*P],floorIndex:M.index})}let m=new Map,d=new Map;for(let M of n)for(let b of M.objects)if(b.type==="section"&&m.set(b.id,b.displayLabel||b.label||b.id),b.type==="row"){let I=b.displayLabel?.trim()||b.segmentedRow?.displayLabel?.trim();I&&d.set(b.id,I)}let p=new Map;for(let M=0;M<o.length;M++){let b=o[M],I=Math.hypot(b.x-c.x,b.y-c.y),S=p.get(b.rowId);(!S||I>S.far)&&p.set(b.rowId,{seat:b,index:M,far:I})}for(let[M,b]of p){let I=r.seatOwner[b.index]??b.seat.sectionId,S=Ki(b.seat.label,M,m.get(I??""),d.get(M));S&&f.push({id:`row:${M}`,kind:"row",text:S,anchor:[b.seat.x*P,r.seatDeckY(b.index)+Cf,b.seat.y*P],floorIndex:s[b.index]})}let y=new Map;for(let M=0;M<o.length;M++){let b=o[M],I=y.get(b.rowId);I||(I={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:Ki(b.label,b.rowId,m.get(r.seatOwner[M]??b.sectionId??""),d.get(b.rowId)),sectionId:r.seatOwner[M]??b.sectionId},y.set(b.rowId,I));let S=M*3,w=i.iPosition[S],_=i.iPosition[S+1],k=i.iPosition[S+2];I.n++,I.x+=w,I.y+=_,I.z+=k,I.minX=Math.min(I.minX,w),I.maxX=Math.max(I.maxX,w),I.minZ=Math.min(I.minZ,k),I.maxZ=Math.max(I.maxZ,k)}for(let[M,b]of y)u.push({id:M,label:b.label,sectionId:b.sectionId,seatCount:b.n,center:[b.x/b.n,b.y/b.n,b.z/b.n],radius:Math.max(.8,Math.hypot(b.maxX-b.minX,b.maxZ-b.minZ)*.5)});let x=0,g=(M,b)=>{x++,f.push({id:`access:${o[M].id}`,kind:"access",text:b.name,icon:b.icon,color:b.color,...b.ink?{ink:b.ink}:{},seatWidthM:i.iChairWidth[M]*2,anchor:[o[M].x*P,r.seatDeckY(M)+kf,o[M].y*P],floorIndex:s[M],rowId:o[M].rowId})},R=null,A=()=>{if(R){let M=Ui(o[R.seats[0]]),b=R.seats.length,I=Math.max(1,Math.round(b/Tf));for(let S=0;S<I&&x<Hi;S++)g(R.seats[Math.min(b-1,Math.floor((S+.5)*b/I))],M)}R=null};for(let M=0;M<o.length&&x<Hi;M++){let b=Ui(o[M]);if(b&&o[M].accessibility?.length){A(),g(M,b);continue}if(!b){A();continue}R&&R.rowId===o[M].rowId&&R.icon===b.icon?R.seats.push(M):(A(),R={rowId:o[M].rowId,icon:b.icon,seats:[M]})}if(A(),o.length<=Ff)for(let M=0;M<o.length;M++){let b=o[M],I=Gf(b.displayLabel||b.label);I&&f.push({id:`seat:${b.id}`,kind:"seat",seatWidthM:i.iChairWidth[M]*2,text:I,anchor:[b.x*P,r.seatDeckY(M)+vf,b.y*P],floorIndex:s[M],rowId:b.rowId})}}for(let m of n){let d=Ue(m,n.length===1?o:o.filter((x,g)=>s[g]===m.index)),p=d?Gi(to(m.objects,it(d)),m.objects.filter(x=>x.type==="text")):new Map,y=[...p.values()];for(let x of m.objects){let g=x.type==="text"?p.get(x.id):void 0;if(x.type==="shape"&&(x.role==="entrance"||x.role==="exit")&&Pf.test(x.label?.trim()??"")){let R=oe(x),A=R?Je(R):null;if(A&&y.some(M=>Math.hypot(A.x-M.mid.x,A.y-M.mid.y)*P<=eo+M.widthM))continue}if(g&&x.type==="text")f.push({id:`text:${x.id}`,kind:"gate",text:x.text,icon:"entrance",anchor:[g.mid.x*P,m.baseHeightM+g.openingM+no,g.mid.y*P],color:x.color,floorIndex:m.index});else if(x.type==="shape"&&x.role&&Af.has(x.role)){let R=oe(x),A=R?Je(R):null;if(!A||!x.label)continue;f.push({id:`architecture:${x.id}`,kind:x.role==="stage"?"stage":x.role==="entrance"||x.role==="exit"?"gate":"annotation",text:x.label,...x.role==="entrance"||x.role==="exit"?{icon:x.role}:{},anchor:[A.x*P,m.baseHeightM+Ae(x).heightM+no,A.y*P],color:x.fill,floorIndex:m.index})}else if(x.type==="text"){if(!x.text)continue;f.push({id:`text:${x.id}`,kind:"annotation",text:x.text,anchor:[x.position.x*P,m.baseHeightM+no,x.position.y*P],color:x.color,rotation:x.rotation,floorIndex:m.index})}else if(x.type==="booth"){if(x.labelPresentation?.visible===!1)continue;let R=Ee(x);if(!R)continue;let A=Je(R);if(!A)continue;f.push({id:`booth:${x.id}`,kind:"booth",text:x.displayLabel||x.label||x.id,anchor:[A.x*P,m.baseHeightM+on+Ef,A.y*P],floorIndex:m.index})}}}return{labels:f,sections:l,rows:u}}function zi(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 Gf(e){let t=e.lastIndexOf("-");return t>=0&&t<e.length-1?e.slice(t+1):e}function Ki(e,t,n,o){if(o?.trim())return o.trim();let r=e?e.lastIndexOf("-"):-1,i=r>0?e.slice(0,r):t;return i&&Bi(i,n)}function Zi(e){let{doc:t,units:n,seats:o,surfaces:r,solids:i,hintedSeatFloor:s,seatFloor:a}=e,c=[];{let f=n.map(()=>({minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}));for(let h=0;h<i.floor.length;h+=1){let m=Math.max(0,Math.min(n.length-1,Math.round(i.floor[h]))),d=h*3,p=f[m];p.minX=Math.min(p.minX,i.position[d]),p.minY=Math.min(p.minY,i.position[d+1]),p.minZ=Math.min(p.minZ,i.position[d+2]),p.maxX=Math.max(p.maxX,i.position[d]),p.maxY=Math.max(p.maxY,i.position[d+1]),p.maxZ=Math.max(p.maxZ,i.position[d+2])}let l=new Map;for(let h=0;h<n.length;h++)for(let m of n[h].objects)m.type==="section"&&l.set(m.id,h);let u=n.map(()=>({n:0,minX:1/0,minY:1/0,minDeck:1/0,maxX:-1/0,maxY:-1/0,maxDeck:-1/0,sumX:0,sumDeck:0,sumZ:0}));for(let h=0;h<o.length;h++){let m=r.seatOwner[h],d=(m!==null?l.get(m):void 0)??s[h];if(d===void 0)continue;let p=u[d],y=o[h];p.n++,y.x<p.minX&&(p.minX=y.x),y.y<p.minY&&(p.minY=y.y),y.x>p.maxX&&(p.maxX=y.x),y.y>p.maxY&&(p.maxY=y.y);let x=r.seatDeckY(h);p.sumX+=y.x*P,p.sumDeck+=x,p.sumZ+=y.y*P,p.minDeck=Math.min(p.minDeck,x),p.maxDeck=Math.max(p.maxDeck,x+1.6),a[h]=d}for(let h=0;h<n.length;h++){let m=u[h],d=t.floors?.[h],p=f[h],y=Math.min(m.n?m.minX*P:n[h].focal.x*P-1,Number.isFinite(p.minX)?p.minX:1/0),x=Math.max(m.n?m.maxX*P:n[h].focal.x*P+1,Number.isFinite(p.maxX)?p.maxX:-1/0),g=Math.min(m.n?m.minY*P:n[h].focal.y*P-1,Number.isFinite(p.minZ)?p.minZ:1/0),R=Math.max(m.n?m.maxY*P:n[h].focal.y*P+1,Number.isFinite(p.maxZ)?p.maxZ:-1/0),A=Math.min(m.n?Math.min(n[h].baseHeightM,m.minDeck):n[h].baseHeightM,Number.isFinite(p.minY)?p.minY:1/0),M=Math.max(m.n?Math.max(m.maxDeck,A+.5):A+.5,Number.isFinite(p.maxY)?p.maxY:-1/0),b=[m.n?m.sumX/m.n:(y+x)/2,m.n?m.sumDeck/m.n:(A+M)/2,m.n?m.sumZ/m.n:(g+R)/2],I=Math.max(1,.5*Math.hypot(x-y,M-A,R-g));c.push({index:h,id:d?.id??`floor-${h}`,label:d?.name??(n.length>1?`Floor ${h+1}`:"Venue"),seatCount:m.n,center:b,radius:I,box:{min:[y,A,g],max:[x,M,R]},focalWorld:[n[h].focal.x*P,n[h].baseHeightM+1.5,n[h].focal.y*P]})}}return c}function ro(e,t){let n=1/0,o=1/0,r=-1/0,i=-1/0,s=(a,c)=>{a<n&&(n=a),c<o&&(o=c),a>r&&(r=a),c>i&&(i=c)};for(let a of t)s(a.x,a.y);for(let a of e)for(let c of a.objects)if(c.type==="section")for(let f of c.outline)s(f.x,f.y);else if(c.type==="shape"&&c.points)for(let f of c.points)s(f.x,f.y);else if(c.type==="gaArea")for(let f of c.points)s(f.x,f.y);else if(c.type==="booth"){let f=Ee(c);if(f)for(let l of f)s(l.x,l.y)}else if(c.type==="table"){let f=rn(c);if(f)for(let l of f)s(l.x,l.y)}else if(c.type==="decorImage"){let f=sn(c);if(f)for(let l of f)s(l.x,l.y)}return Number.isFinite(n)||(n=-100,o=-100,r=100,i=100),{minX:n,minY:o,maxX:r,maxY:i}}function ts(e,t,n,o,r,i,s){if(t.length===1){let a=n.map(h=>({x:h.x,y:h.y}));for(let h of t[0].objects)h.type==="section"?a.push(...h.outline):h.type==="shape"?a.push(...oe(h)??h.points??[]):h.type==="gaArea"?a.push(...h.points):h.type==="booth"?a.push(...Ee(h)??[]):h.type==="table"?a.push(...rn(h)??[]):h.type==="decorImage"&&a.push(...sn(h)??[]);if(qi(e,t[0],n,i)||es(e,t[0],n,a,i))return!1;if(s&&Qi(e,t[0].baseHeightM,a,i,s))return!0;let c=St(a),f=(r.minX+r.maxX)/2,l=(r.minY+r.maxY)/2,u=c.length>=3?c.map(h=>{let m=h.x-f,d=h.y-l,p=Math.max(1,Math.hypot(m,d));return{x:h.x+m/p*80,y:h.y+d/p*80}}):xt(r.minX-28,r.minY-28,r.maxX-r.minX+56,r.maxY-r.minY+56);return z(e,u,void 0,()=>-.04,-.22,i.ground,i.ground,K),!1}else{let a=t.reduce((y,x)=>x.baseHeightM<y.baseHeightM?x:y);e.setFloor(a.index);let c={...a,objects:t.flatMap(y=>y.objects)},f=n.map(y=>({x:y.x,y:y.y}));for(let y of c.objects)y.type==="section"&&f.push(...y.outline);if(qi(e,c,n,i)||es(e,c,n,f,i))return!1;if(s&&Qi(e,a.baseHeightM,f,i,s))return!0;let l=n.filter((y,x)=>o[x]===a.index),u=ro([a],l),h=Math.hypot(u.maxX-u.minX,u.maxY-u.minY),m=Math.max(28,Math.min(80,h*.04)),d=xt(u.minX-m,u.minY-m,u.maxX-u.minX+m*2,u.maxY-u.minY+m*2),p=a.baseHeightM-.03;return z(e,d,void 0,()=>p,p-.22,i.ground,i.ground,K),!1}}function io(e,t,n,o){let{cx:r,cz:i,radius:s}=n,a=1/0,c=1/0,f=1/0,l=-1/0,u=-1/0,h=-1/0,m=(y,x,g)=>{a=Math.min(a,y),l=Math.max(l,y),c=Math.min(c,x),u=Math.max(u,x),f=Math.min(f,g),h=Math.max(h,g)};for(let y=0;y<e.position.length;y+=3){let x=y/3;o&&x>=o[0]&&x<o[1]||m(e.position[y],e.position[y+1],e.position[y+2])}for(let y=0;y<t.count;y++){let x=y*3,g=t.iPosition[x],R=t.iPosition[x+1],A=t.iPosition[x+2],M=Math.max(.35,t.iMaxRadius[y]??.35);m(g-M,R,A-M),m(g+M,R+1.6,A+M)}Number.isFinite(a)||(a=r-s,l=r+s,c=0,u=s*.16,f=i-s,h=i+s);let d=[(a+l)/2,(c+u)/2,(f+h)/2],p=Math.max(1,.5*Math.hypot(l-a,u-c,h-f));return{center:d,radius:p,minY:c,maxY:u}}var jf=4096;function ns(e,t,n=[]){let o=Math.max(1,Math.ceil(e.count/jf)),r=Math.ceil(e.count/o),i=new Float32Array((r*2+t.length*4+n.length)*3),s=0;for(let a=0;a<e.count;a+=o){let c=e.iPosition[a*3],f=e.iPosition[a*3+1],l=e.iPosition[a*3+2];i[s++]=c,i[s++]=f,i[s++]=l,i[s++]=c,i[s++]=0,i[s++]=l}for(let[a,c,f]of n)i[s++]=a,i[s++]=c,i[s++]=f;for(let a of t)for(let[c,f]of[[-1,-1],[1,-1],[1,1],[-1,1]])i[s++]=a.cx+c*a.halfX,i[s++]=a.y,i[s++]=a.cz+f*a.halfZ;return i.subarray(0,s)}function os(e,t,n,o,r,i,s=[]){let a=1/0,c=1/0,f=-1/0,l=-1/0;for(let M=0;M<e.count;M++){let b=M*3,I=e.iPosition[b],S=e.iPosition[b+2];I<a&&(a=I),I>f&&(f=I),S<c&&(c=S),S>l&&(l=S)}for(let[M,,b]of s)M<a&&(a=M),M>f&&(f=M),b<c&&(c=b),b>l&&(l=b);for(let M of t)a=Math.min(a,M.cx-M.halfX),f=Math.max(f,M.cx+M.halfX),c=Math.min(c,M.cz-M.halfZ),l=Math.max(l,M.cz+M.halfZ);let u=n.minX*P,h=n.maxX*P,m=n.minY*P,d=n.maxY*P,p=u,y=h,x=m,g=d;if(Number.isFinite(a)){let M=Math.max(2,.06*Math.hypot(f-a,l-c));p=Math.max(u,a-M),y=Math.min(h,f+M),x=Math.max(m,c-M),g=Math.min(d,l+M)}let R=Math.min(0,o),A=Math.max(r,i*.05);return{min:[p,R,x],max:[y,A,g]}}var $i=12,Hf=.6,Xf=40;function Qi(e,t,n,o,r){let i=St([...n]);if(i.length<3)return!1;let s=1/0,a=1/0,c=-1/0,f=-1/0;for(let A of i)s=Math.min(s,A.x),c=Math.max(c,A.x),a=Math.min(a,A.y),f=Math.max(f,A.y);let l=Math.hypot(c-s,f-a)*P,u=we(i,$i/P,1.2),h=Math.max(Xf,l*Hf),m=we(i,($i+h)/P,1.2);if(u.length!==m.length)return!1;let d=te(o.ground,[.78,.76,.72],.35),p=te(o.ground,[.56,.62,.52],.3);z(e,u,void 0,()=>t-.04,t-.22,d,d,K);let y=t-.05,x=u.map(A=>[A.x*P,y,A.y*P]),g=m.map(A=>[A.x*P,y,A.y*P]),R=[0,1,0];for(let A=0;A<x.length;A++){let M=(A+1)%x.length;e.tri(x[A],g[M],g[A],R,p,r,r),e.tri(x[A],x[M],g[M],R,p,p,r)}return!0}function qi(e,t,n,o){let r=Ue(t,n);if(!r)return!1;let i=t.baseHeightM,s=te(o.ground,[.62,.55,.47],.4);return z(e,r,void 0,()=>i-.04,i-.22,s,s,K),!0}var Uf=3e3,Vf=20,Ji=1.5,Kf=1.2,Yf=.25;function es(e,t,n,o,r){if(!n.length||n.length>Uf||o.length<3)return!1;for(let w of t.objects){if(w.type==="shape"&&Tt(w.stageKind))return!1;if(w.type==="section"){let{height:_}=Ge(w,{floorBaseHeightM:t.baseHeightM});if(_-t.baseHeightM>Vf)return!1}}let i=0,s=0;for(let w of o)i+=w.x,s+=w.y;i/=o.length,s/=o.length;let a=0,c=0,f=0;for(let w of o){let _=w.x-i,k=w.y-s;a+=_*_,c+=k*k,f+=_*k}let l=.5*Math.atan2(2*f,a-c),u=Math.cos(l),h=Math.sin(l),m=-h,d=u,p=1/0,y=-1/0,x=1/0,g=-1/0;for(let w of o){let _=(w.x-i)*u+(w.y-s)*h,k=(w.x-i)*m+(w.y-s)*d;p=Math.min(p,_),y=Math.max(y,_),x=Math.min(x,k),g=Math.max(g,k)}let R=w=>[[p-w,x-w],[y+w,x-w],[y+w,g+w],[p-w,g+w]].map(([_,k])=>({x:i+u*_+m*k,y:s+h*_+d*k})),A=R(Ji/P),M=R((Ji+Yf)/P),b=t.baseHeightM,I=te(r.ground,[.62,.55,.47],.4),S=te(r.ground,[.86,.86,.84],.55);return z(e,M,void 0,()=>b-.04,b-.22,I,I,K),z(e,M,[A.slice().reverse()],()=>b+Kf,b-.04,te(S,[1,1,1],.2),S,K),!0}function rs(e,t,n){let o=()=>({byObjectId:new Map,elements:[]});if(!t||!e)return o();let r=Po(t);if(!r.ok||r.value.id!==e)return o();let i=new Map;for(let u of n)for(let h of u.objects)h.type==="shape"&&i.set(h.id,{shape:h,unit:u});let s=new Set,a=new Set,c=new Map((t.overlay.productionElements??[]).map(u=>{let h=u.runtimeContentImageUrl;return[u.id,typeof h=="string"&&/^(?:blob:|data:image\/|https:\/\/)/.test(h)?h:void 0]})),f=[];for(let u of r.value.overlay.productionElements??[]){let h=i.get(u.objectId),m=h?oe(h.shape):null,d=u.baseElevationM??0;if(!h||!m||m.length<3||!u.id||s.has(u.id)||a.has(u.objectId)||!Number.isFinite(u.heightM)||u.heightM<.05||u.heightM>50||!Number.isFinite(d)||d<-10||d>100)return o();s.add(u.id),a.add(u.objectId);let p=m.map(S=>S.x*P),y=m.map(S=>S.y*P),x=h.unit.baseHeightM+d,g=Math.min(...p),R=Math.max(...p),A=Math.min(...y),M=Math.max(...y),b,I=c.get(u.id)??u.contentImageUrl;if(u.kind==="screen"&&I&&(b=Or(m,x,x+u.heightM,h.unit.focal),!b))if(R-g>=M-A){let S=Math.abs(A-h.unit.focal.y*P)<=Math.abs(M-h.unit.focal.y*P)?A-.006:M+.006;b=[[g,x,S],[R,x,S],[g,x+u.heightM,S],[R,x+u.heightM,S]]}else{let S=Math.abs(g-h.unit.focal.x*P)<=Math.abs(R-h.unit.focal.x*P)?g-.006:R+.006;b=[[S,x,A],[S,x,M],[S,x+u.heightM,A],[S,x+u.heightM,M]]}f.push({id:u.id,objectId:u.objectId,kind:u.kind,floorIndex:h.unit.index,baseY:x,topY:x+u.heightM,bounds:{min:[g,x,A],max:[R,x+u.heightM,M]},occlusion:u.occlusion,...I?{contentImageUrl:I}:{},...b?{contentPlane:b}:{}})}let l=f.sort((u,h)=>u.id.localeCompare(h.id));return{byObjectId:new Map(l.map(u=>[u.objectId,u])),elements:l}}var is=[.13,.14,.17],ut=[.4,.43,.47],Wf=.18,zf=.02,Zf=2.4,$f=1500,Qf=240,qf=.25;function ss(e,t,n,o){let r=t.stageKind??"";if(ze(r)||r==="round"||!o.length)return;let i=oe(t);if(!i||i.length<3)return;let s={x:i.reduce((T,F)=>T+F.x,0)/i.length,y:i.reduce((T,F)=>T+F.y,0)/i.length},a=0,c=0,f=new Set;for(let T of o)a+=T.x,c+=T.y,f.add(Math.floor(Math.atan2(T.y-s.y,T.x-s.x)*180/Math.PI/10));let l=s.x-a/o.length,u=s.y-c/o.length,h=Math.hypot(l,u);if(h<1e-6)return;let m=o.reduce((T,F)=>T+Math.hypot(F.x-s.x,F.y-s.y),0)/o.length;if(f.size*10>Qf&&h<qf*m)return;let d=l/h,p=u/h,y=-p,x=d,g=-1/0,R=1/0,A=1/0,M=-1/0;for(let T of i){let F=(T.x-s.x)*d+(T.y-s.y)*p,O=(T.x-s.x)*y+(T.y-s.y)*x;g=Math.max(g,F),R=Math.min(R,F),A=Math.min(A,O),M=Math.max(M,O)}let b=(M-A)*P,I=(g-R)*P;if(b<3||I<1.5||b*I>$f)return;let S=Wf/P,w=(T,F)=>({x:s.x+d*T+y*F,y:s.y+p*T+x*F}),_=(T,F,O,B)=>[w(T,O),w(T,B),w(F,B),w(F,O)],k=n+Math.max(3.5,Math.min(8,b*.35)),L=n+Math.min(Zf,k-n-1),C=.2/P,E=R+Math.min(I*.25,1.5)/P,v=zf/P;z(e,_(g-2*S+v,g-S-v,A+S+C,M-S-C),void 0,()=>L,n,is,is,K);for(let[T,F]of[[A+S,A+S+C],[M-S-C,M-S]])z(e,_(g-2*S,g-S,T,F),void 0,()=>k+.3,n,ut,ut,K),z(e,_(E+C,g-2*S,T,F),void 0,()=>k+.3,k,ut,ut,K);z(e,_(E,E+C,A+S,M-S),void 0,()=>k+.3,k,ut,ut,K)}function Se(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Me(e){return Array.isArray(e)?e:[]}function Jf(e){let t=[e];for(;t.length;){let n=t.pop();if(Array.isArray(n)){t.push(...n);continue}if(!Se(n))continue;let o=Se(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 un(e,t){return!Array.isArray(e)||e.length!==t||!e.every(n=>typeof n=="number"&&Number.isFinite(n))?null:e}function em(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function tm(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 nm(e){let t=un(e.matrix,16);if(t)return t;if(e.matrix!==void 0)return null;let n=e.translation===void 0?[0,0,0]:un(e.translation,3),o=e.rotation===void 0?[0,0,0,1]:un(e.rotation,4),r=e.scale===void 0?[1,1,1]:un(e.scale,3);if(!n||!o||!r)return null;let[i,s,a,c]=o,f=Math.hypot(i,s,a,c);if(!(f>1e-8))return null;let l=i/f,u=s/f,h=a/f,m=c/f,d=l+l,p=u+u,y=h+h,x=l*d,g=l*p,R=l*y,A=u*p,M=u*y,b=h*y,I=m*d,S=m*p,w=m*y;return[(1-(A+b))*r[0],(g+w)*r[0],(R-S)*r[0],0,(g-w)*r[1],(1-(x+b))*r[1],(M+I)*r[1],0,(R+S)*r[2],(M-I)*r[2],(1-(x+A))*r[2],0,n[0],n[1],n[2],1]}function om(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 rm(e){let t=e[0],n=e[4],o=e[8],r=e[1],i=e[5],s=e[9],a=e[2],c=e[6],f=e[10],l=i*f-s*c,u=s*a-r*f,h=r*c-i*a,m=t*l+n*u+o*h;if(Math.abs(m)<1e-12)return null;let d=1/m;return[l*d,u*d,h*d,(o*c-n*f)*d,(t*f-o*a)*d,(n*a-t*c)*d,(n*s-o*i)*d,(o*r-t*s)*d,(t*i-n*r)*d]}function as(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 im(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 c=JSON.parse(new TextDecoder().decode(a).replace(/[\u0000 ]+$/g,""));if(!Se(c))return null;o=c}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 sm(e){return e===5120||e===5121?1:e===5122||e===5123?2:e===5125||e===5126?4:0}function am(e){return e==="SCALAR"?1:e==="VEC2"?2:e==="VEC3"?3:e==="VEC4"?4:0}function cm(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 lm(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=im(t);if(!n)return{ok:!1,issue:"invalid_glb"};let{json:o,bin:r}=n;if(!Se(o.asset)||o.asset.version!=="2.0")return{ok:!1,issue:"unsupported_glb"};let i=Me(o.extensionsUsed).filter(A=>typeof A=="string");if(i.includes("KHR_draco_mesh_compression")||Jf(o))return{ok:!1,issue:"draco_not_allowed"};if(i.length||Me(o.extensionsRequired).length)return{ok:!1,issue:"unsupported_glb"};if(Me(o.images).length||Me(o.textures).length)return{ok:!1,issue:"external_resource"};let s=Me(o.buffers);if(s.length!==1||!Se(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=Me(o.accessors),c=Me(o.bufferViews),f=Me(o.meshes),l=Me(o.nodes),u=Me(o.scenes),h=typeof o.scene=="number"?o.scene:0;if(!Se(u[h]))return{ok:!1,issue:"unsupported_glb"};let m=new DataView(r.buffer,r.byteOffset,r.byteLength),d=(A,M,b)=>{if(typeof A!="number"||!Number.isInteger(A)||!Se(a[A]))return null;let I=a[A];if(I.type!==M||I.sparse!==void 0||I.normalized===!0||typeof I.count!="number"||!Number.isInteger(I.count)||I.count<1||typeof I.componentType!="number"||!b.includes(I.componentType)||typeof I.bufferView!="number")return null;let S=c[I.bufferView];if(!Se(S)||S.buffer!==0||typeof S.byteLength!="number"||!Number.isInteger(S.byteLength)||S.byteLength<0)return null;let w=am(I.type),_=sm(I.componentType),k=typeof S.byteStride=="number"?S.byteStride:w*_,L=typeof S.byteOffset=="number"?S.byteOffset:0,C=typeof I.byteOffset=="number"?I.byteOffset:0,E=L+C,v=C+(I.count-1)*k+w*_;if(!Number.isInteger(k)||!Number.isInteger(L)||!Number.isInteger(C)||k<w*_||L<0||C<0||L+S.byteLength>r.byteLength||v>S.byteLength)return null;let T=[];for(let F=0;F<I.count;F++){let O=[];for(let B=0;B<w;B++){let D=cm(m,E+F*k+B*_,I.componentType);if(!Number.isFinite(D))return null;O.push(D)}T.push(O)}return T},p=[],y=[],x=0,g=new Set,R=(A,M)=>{if(typeof A!="number"||!Number.isInteger(A)||!Se(l[A])||g.has(A))return!1;g.add(A);let b=l[A],I=nm(b);if(!I)return!1;let S=tm(M,I),w=rm(S);if(!w)return!1;if(b.mesh!==void 0){if(typeof b.mesh!="number")return!1;let _=f[b.mesh];if(!Se(_))return!1;for(let k of Me(_.primitives)){if(!Se(k)||k.mode!==void 0&&k.mode!==4||!Se(k.attributes))return!1;let L=d(k.attributes.POSITION,"VEC3",[5126]),C=k.attributes.NORMAL===void 0?null:d(k.attributes.NORMAL,"VEC3",[5126]);if(!L||k.attributes.NORMAL!==void 0&&!C)return!1;let E=L.length;if(k.indices!==void 0){let T=typeof k.indices=="number"?a[k.indices]:null;E=Se(T)?T.count:void 0}if(typeof E!="number"||!Number.isInteger(E)||E%3!==0||(x+=E/3,x>1e5))return!1;let v=k.indices===void 0?L.map((T,F)=>[F]):d(k.indices,"SCALAR",[5121,5123,5125]);if(!v||v.length%3!==0||v.length!==E)return!1;for(let T=0;T<v.length;T+=3){let F=[v[T][0],v[T+1][0],v[T+2][0]];if(F.some(D=>!Number.isInteger(D)||D<0||D>=L.length))return!1;let O=F.map(D=>om(S,...L[D])),B=null;if(!C){let D=O[1][0]-O[0][0],H=O[1][1]-O[0][1],N=O[1][2]-O[0][2],V=O[2][0]-O[0][0],X=O[2][1]-O[0][1],Z=O[2][2]-O[0][2];B=as([1,0,0,0,1,0,0,0,1],H*Z-N*X,N*V-D*Z,D*X-H*V)}for(let D=0;D<3;D++)p.push(...O[D]),y.push(...C?as(w,...C[F[D]]):B)}}}for(let _ of Me(b.children))if(!R(_,S))return!1;return g.delete(A),!0};for(let A of Me(u[h].nodes))if(!R(A,em()))return{ok:!1,issue:x>1e5?"triangle_limit":"unsupported_glb"};return!x||p.length!==x*9||y.length!==p.length?{ok:!1,issue:"unsupported_glb"}:{ok:!0,triangleCount:x,position:new Float32Array(p),normal:new Float32Array(y)}}function cs(e){try{return lm(e)}catch{return{ok:!1,issue:"invalid_glb"}}}function ls(e){let{doc:t}=e,n=zo(t.theme),o=n.structure,r=Sr(t,e.eventConfigurationId??t.eventConfigurationId),i=rs(e.eventConfigurationId,e.eventConfiguration,r),s=e.seats,a=new Gt,c=null;if(e.registeredShellGlb){let G=cs(e.registeredShellGlb);if(G.ok){let j=G.position.length/3,q=new Float32Array(G.position.length),le=n.materials.shell??o.tierWall;for(let fe=0;fe<j;fe++){let de=G.normal[fe*3+1],ie=de<-.25?.4:.62+.38*Math.max(0,de);q[fe*3]=le[0]*ie,q[fe*3+1]=le[1]*ie,q[fe*3+2]=le[2]*ie}c={position:G.position,normal:G.normal,color:q,floor:new Float32Array(j).fill(-2),material:new Float32Array(j),count:j}}}let f=new Map;for(let G of r)for(let j of G.objects)f.set(j.id,G.index),j.type==="section"&&f.set(j.logicalSectionId??j.id,G.index);let l=s.map(G=>f.get(G.sectionId??"")??f.get(G.rowId??"")??0),u=ro(r,s),h=a.vertexCount,d=ts(a,r,s,l,u,o,te(n.background.top,n.background.bottom,.5))?a.vertexCount:h,p=Jo(t,s),y=new Map,x=new Map;for(let G of t.categories??[])y.set(G.key,G.color),G.seatGlyph&&x.set(G.key,G.seatGlyph);let g=[],R=Tr(r,s,l),A=new Map;s.forEach((G,j)=>{let q=R.seatDeckY(j);Number.isFinite(q)&&A.set(G.rowId,Math.min(A.get(G.rowId)??1/0,q))});let M=new Float32Array(s.length),b=[],I=new Map((t.floors??[]).map((G,j)=>[G.id,j])),S=r.map(()=>[]);for(let G of s){let j=G.floorId?I.get(G.floorId)??0:0;S[Math.min(j,S.length-1)]?.push(G)}let w=(G,j)=>{if(!j||j.length<3)return!1;let q=Math.min(...j.map(ie=>ie.x)),le=Math.max(...j.map(ie=>ie.x)),fe=Math.min(...j.map(ie=>ie.y)),de=Math.max(...j.map(ie=>ie.y));for(let ie=0;ie<G;ie++)for(let se of S[ie])if(!(se.x<q||se.x>le||se.y<fe||se.y>de)&&he(se,j,void 0))return!0;return!1},_=null,k=G=>r.length===1?s:s.filter((j,q)=>l[q]===G),L=(G,j)=>{let q=Ee(G);if(!q)return!1;let le=1/0,fe=1/0,de=-1/0,ie=-1/0;for(let se of q)le=Math.min(le,se.x),de=Math.max(de,se.x),fe=Math.min(fe,se.y),ie=Math.max(ie,se.y);return s.some((se,_e)=>se.kind!=="booth"&&(r.length===1||l[_e]===j)&&se.x>le&&se.x<de&&se.y>fe&&se.y<ie&&xe(q,se.x,se.y))},C;for(let G=0;G<r.length;G++){let j=r[G];a.setFloor(G);let q=Ue(j,k(G)),le=0;if(q){let W=0;for(let ue of j.objects)if(ue.type==="section")for(let me of R.bySection.get(ue.id)?.rowLevels??[])W=Math.max(W,me.y-j.baseHeightM);if(le=Er(W),!C){let ue=it(q);C={centre:[ue.x*P,ue.y*P]}}}let fe=new Kt,de=[],ie=j.objects.filter(W=>W.type==="shape"&&(W.role==="entrance"||W.role==="exit")),se=j.objects.filter(W=>W.type==="section"&&!!W.outline&&W.outline.length>=3),_e=ri(j.objects.filter(W=>W.type==="booth"),j.focal);for(let W of j.objects)if(W.type==="section"){let ue=a.vertexCount;Mi(a,W,j,er(W,p),R.bySection.get(W.id),fe,se,o,G>0&&w(G,W.outline));let me=a.vertexCount-ue;me>0&&b.push({sectionId:W.id,start:ue,count:me})}else if(W.type==="shape"){let ue=i.byObjectId.get(W.id),me=g.length,Ye=q!==null&&W.role==="wall"&&!ue;a.setMaterial(Ye?Wt:(ue?.kind??W.role)==="screen"?1:0);let We=W.role==="stage"&&!ue?si(W,k(G)):Ye&&W.heightM===void 0?{...W,heightM:le}:W,Ne=Pr(We,de);if(ei(a,We,j.baseHeightM+Ne.supportOffsetM,Ne.topOffsetM-Ne.supportOffsetM,o,j.focal,g,ue,ie),a.setMaterial(0),W.role==="stage"&&!ue&&g.length>me&&(_??G)===G){_=G;let De=t.floors?.[G]?.id,ft=r.length>1&&De?s.filter(Ct=>Ct.floorId===De):s;ss(a,We,g[g.length-1].y,ft)}}else W.type==="gaArea"?ni(a,W,j.baseHeightM,ne(y.get(W.categoryKey)),o):W.type==="booth"?Qr(a,W,j.baseHeightM,ne(y.get(W.categoryKey)),o,_e.get(W.id)??j.focal,L(W,G)):W.type==="table"?Jr(a,W,Math.max(j.baseHeightM,A.get(W.id)??j.baseHeightM),ne(W.fill??t.theme?.decorFill??"#232c40"),o,!!(W.fill??t.theme?.decorFill)):W.type==="decorImage"&&ti(a,W,j.baseHeightM,o);q&&ji(a,j.objects,q,j.baseHeightM,le,j.focal,o,W=>!i.byObjectId.has(W.id)),Ii(a,j,s,R,o,n.materials.shell,!c)}let E=r.length>1?{x:r.reduce((G,j)=>G+j.focal.x,0)/r.length,y:r.reduce((G,j)=>G+j.focal.y,0)/r.length}:t.focalPoint??{x:(u.minX+u.maxX)/2,y:(u.minY+u.maxY)/2},v=jo(c?[a.build(),c]:[a.build()]),T=cr(s,e.initialState,R,M,y,x),F=Yi({doc:t,units:r,seats:s,surfaces:R,focal:E}),{labels:O,sections:B,rows:D}=Wi({doc:t,units:r,seats:s,surfaces:R,seatData:T,hintedSeatFloor:l,zones:F,focal:E}),H=new Map(B.map((G,j)=>[G.id,j]));R.seatOwner.forEach((G,j)=>{T.iSection[j]=G?H.get(G)??-1:-1});let N=Zi({doc:t,units:r,seats:s,surfaces:R,solids:v,hintedSeatFloor:l,seatFloor:M});zi(O,N),T.iYaw=ar(T.iPosition,s.length,G=>s[G].rowId,G=>{let j=r[M[G]]?.focal??E;return[j.x*P,j.y*P]});let V=(u.minX+u.maxX)/2*P,X=(u.minY+u.maxY)/2*P,Z=.5*Math.hypot((u.maxX-u.minX)*P,(u.maxY-u.minY)*P)||10,U=io(v,T,{cx:V,cz:X,radius:Z},[h,d]),J=io(v,T,{cx:V,cz:X,radius:Z}),Q=um(r),ce=os(T,g,u,U.minY,U.maxY,Z,Q);return{sharedAisles:Ho(r.flatMap(G=>G.objects.flatMap(j=>{if(j.type!=="section")return[];let q=R.bySection.get(j.id);return q?[{sectionId:j.id,floorIndex:G.index,rows:q.rowLevels}]:[]}))),solids:v,sectionSolidRanges:b,seats:T,seatSectionIds:R.seatOwner,bounds:{center:[(ce.min[0]+ce.max[0])/2,(ce.min[1]+ce.max[1])/2,(ce.min[2]+ce.max[2])/2],radius:Z,groundY:0,box:ce,fitPoints:ns(T,g,Q)},...C?{room:C}:{},...!C&&r.some(G=>G.objects.some(j=>j.type==="shape"&&Tt(j.stageKind)))?{outdoor:!0}:{},renderBounds:{center:U.center,radius:U.radius},clipBounds:{center:J.center,radius:J.radius},stateColorLUT:Zo(n,Ht),theme:n,seatCount:s.length,focalWorld:[E.x*P,1.5,E.y*P],zones:F,stages:g,productionElements:i.elements,sections:B,rows:D,labels:O,floors:N}}function um(e){let t=[];for(let n of e)for(let o of n.objects){let r=o.type==="gaArea"?o.points:o.type==="booth"?Ee(o):null;for(let i of r??[])t.push([i.x*P,n.baseHeightM,i.y*P])}return t}function fm(e,t){let{doc:n,report:o}=Oi(e),r=o.confident&&(o.sections.length>0||!!o.looseRowBlocks);if(!r&&!o.roles?.length)return null;if(!r){let c=new Map(o.roles.map(m=>[m.id,m.role])),f=m=>m.map(d=>d.type==="shape"&&c.has(d.id)?{...d,role:c.get(d.id)}:d),l=e.floors?.map(m=>({...m,objects:f(m.objects)})),u=new Float64Array(t.length).fill(Number.NaN),h=new Float64Array(t.length*2).fill(Number.NaN);return t.forEach((m,d)=>{m.eyeHeightM!==void 0&&(u[d]=m.eyeHeightM),m.focalPoint&&(h[d*2]=m.focalPoint.x,h[d*2+1]=m.focalPoint.y)}),{doc:{...e,objects:l?.[0]?.objects??f(e.objects),...l?{floors:l}:{}},report:o,eyeHeightM:u,focal:h}}let i=new Map(nt(n).map(c=>[c.id,c])),s=new Float64Array(t.length).fill(Number.NaN),a=new Float64Array(t.length*2).fill(Number.NaN);return t.forEach((c,f)=>{let l=i.get(c.id)??c;l.eyeHeightM!==void 0&&(s[f]=l.eyeHeightM),l.focalPoint&&(a[f*2]=l.focalPoint.x,a[f*2+1]=l.focalPoint.y)}),{doc:n,report:o,eyeHeightM:s,focal:a}}function mm(e,t){return e.map((n,o)=>{let r=t.eyeHeightM[o],i=t.focal[o*2],s=t.focal[o*2+1],a={...n};return Number.isNaN(r)?delete a.eyeHeightM:a.eyeHeightM=r,Number.isNaN(i)?delete a.focalPoint:a.focalPoint={x:i,y:s},a})}function us(e){let t=e.estimate===!1?null:fm(e.doc,e.seats);return t?{input:{...e,doc:t.doc,seats:mm(e.seats,t)},estimate:t}:{input:e}}function hm(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 fs=self;fs.onmessage=e=>{let t=performance.now(),n=!e.data.seats,o=e.data.seats??nt(e.data.doc),{input:r,estimate:i}=us({doc:e.data.doc,seats:o,eventConfigurationId:e.data.eventConfigurationId,eventConfiguration:e.data.eventConfiguration,registeredShellGlb:e.data.registeredShellGlb,estimate:e.data.estimate}),s=ls(r),a=hm(s);i&&a.push(i.eyeHeightM.buffer,i.focal.buffer),fs.postMessage({model:s,buildMs:performance.now()-t,...n?{seats:o}:{},...i?{estimate:i}:{}},a)};
|
|
1
|
+
"use strict";var da=Object.create;var No=Object.defineProperty;var pa=Object.getOwnPropertyDescriptor;var ba=Object.getOwnPropertyNames;var ya=Object.getPrototypeOf,ga=Object.prototype.hasOwnProperty;var xa=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ba(t))!ga.call(e,r)&&r!==n&&No(e,r,{get:()=>t[r],enumerable:!(o=pa(t,r))||o.enumerable});return e};var je=(e,t,n)=>(n=e!=null?da(ya(e)):{},xa(t||!e||!e.__esModule?No(n,"default",{value:e,enumerable:!0}):n,e));var Nh=Math.PI/180;function Se(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function Fn(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function Nn(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 mt(e){return e.length?Nn(e):null}function Do(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 Go(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[Do(e,.5)];let o=Array.from({length:n+1},(c,u)=>Do(e,u/n)),r=new Float64Array(o.length);for(let c=1;c<o.length;c+=1){let u=o[c].x-o[c-1].x,l=o[c].y-o[c-1].y;r[c]=r[c-1]+Math.hypot(u,l)}let i=r[r.length-1];if(i<=1e-9)return Array.from({length:t},()=>({...e.start}));let s=[],a=1;for(let c=0;c<t;c+=1){let u=i*c/(t-1);for(;a<r.length-1&&r[a]<u;)a+=1;let l=r[a-1],f=r[a],m=f===l?0:(u-l)/(f-l);s.push({x:o[a-1].x+(o[a].x-o[a-1].x)*m,y:o[a-1].y+(o[a].y-o[a-1].y)*m})}return s}function Dn(e,t,n){return Math.max(t,Math.min(n,e))}function Ma(e){return Dn(e,0,1)}function jo(e){let t=Ma(e);return t*t*(3-2*t)}var ht=Math.PI*2;function dt(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}function Sa(e,t,n){let o=t-e;if(n){for(;o<0;)o+=ht;for(;o>=ht;)o-=ht}else{for(;o>0;)o-=ht;for(;o<=-ht;)o+=ht}return o}function Xo(e){if(e.version!==1||e.closed!==!0||!dt(e.start)||!Array.isArray(e.segments)||e.segments.length<2||e.segments.length>512)return!1;let t=e.start;for(let n of e.segments){if(!n||!dt(n.end))return!1;if(n.kind==="line"){if(Se(t,n.end)<=1e-9)return!1}else if(n.kind==="bezier"){if(!dt(n.control1)||!dt(n.control2)||Se(t,n.end)<=1e-9)return!1}else if(n.kind==="arc"){if(!dt(n.center)||!Number.isFinite(n.radius)||n.radius<=1e-6||Math.abs(Se(t,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||Math.abs(Se(n.end,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||Se(t,n.end)<=1e-9)return!1}else return!1;t=n.end}return Se(t,e.start)<=1e-4}function Pa(e,t,n){let o=1-n;return{x:o**3*e.x+3*o**2*n*t.control1.x+3*o*n**2*t.control2.x+n**3*t.end.x,y:o**3*e.y+3*o**2*n*t.control1.y+3*o*n**2*t.control2.y+n**3*t.end.y}}function Uo(e,t=2){if(!Xo(e))throw new Error("Section outline path is invalid");let n=Math.max(.25,t),o=[{...e.start}],r=e.start;for(let i of e.segments){if(i.kind==="line")o.push({...i.end});else if(i.kind==="arc"){let s=Math.atan2(r.y-i.center.y,r.x-i.center.x),a=Math.atan2(i.end.y-i.center.y,i.end.x-i.center.x),c=Sa(s,a,i.clockwise),u=Math.max(2,Math.ceil(Math.abs(c)*i.radius/n));for(let l=1;l<=u;l+=1){let f=s+c*l/u;o.push({x:i.center.x+Math.cos(f)*i.radius,y:i.center.y+Math.sin(f)*i.radius})}}else{let s=Se(r,i.control1)+Se(i.control1,i.control2)+Se(i.control2,i.end),a=Math.max(2,Math.ceil(s/n));for(let c=1;c<=a;c+=1)o.push(Pa(r,i,c/a))}r=i.end}return Se(o[o.length-1],o[0])<=1e-4&&o.pop(),o}var Ia=45,Gn=150,Ra=60;function wa(e){let t=Ia/100;if(e<=t)return Gn;let n=Math.min(1,(e-t)/(1-t));return Gn-n*(Gn-Ra)}var Ho=.5523;function Vo(e,t){return Math.abs(e.x-t.x)<=1e-6&&Math.abs(e.y-t.y)<=1e-6}function Ea(e){let t=[],n=[];for(e.forEach((o,r)=>{dt(o)&&(t.length&&Vo(t[t.length-1],o)||(t.push({x:o.x,y:o.y}),n.push(r)))});t.length>1&&Vo(t[0],t[t.length-1]);)t.pop(),n.pop();return{points:t,sourceIndex:n}}var Aa=.5,_a=4/3;function va(e,t,n){let o=t.x-e.x,r=t.y-e.y,i=Math.hypot(o,r);if(i<=1e-9)return{kind:"line",end:{...t}};let s=-r/i,a=o/i,c=n*_a;return{kind:"bezier",control1:{x:e.x+o/3+s*c,y:e.y+r/3+a*c},control2:{x:e.x+o*2/3+s*c,y:e.y+r*2/3+a*c},end:{...t}}}function Ko(e,t){let{points:n,sourceIndex:o}=Ea(e),r=n.length;if(r<3)return null;let i=Math.min(100,Math.max(0,t.cornerSmoothing??0))/100,s=t.edgeCurvature,a=new Array(r).fill(0);if(s?.length)for(let R=0;R<r;R+=1){let x=s[o[R]];a[R]=Number.isFinite(x)?Math.min(100,Math.max(-100,x))/100:0}let c=a.some(R=>Math.abs(R)>1e-6);if(i<=0&&!c)return null;let u=t.wideAngleThresholdDeg??wa(i),l=[];for(let R=0;R<r;R+=1)l[R]=Se(n[R],n[(R+1)%r]);let f=new Array(r).fill(0);for(let R=0;R<r;R+=1){let x=n[(R-1+r)%r],b=n[R],I=n[(R+1)%r],w={x:x.x-b.x,y:x.y-b.y},S={x:I.x-b.x,y:I.y-b.y},C=Math.hypot(w.x,w.y),O=Math.hypot(S.x,S.y);if(C<=1e-9||O<=1e-9)continue;let L=Math.min(1,Math.max(-1,(w.x*S.x+w.y*S.y)/(C*O))),v=Math.acos(L)*180/Math.PI;if(v<u)continue;let A=jo((v-u)/(180-u));f[R]=i*A*.5*Math.min(C,O)}for(let R=0;R<r;R+=1){let x=(R+1)%r,b=f[R]+f[x];if(b>l[R]&&b>1e-9){let I=l[R]/b;f[R]*=I,f[x]*=I}}let m=new Array(r),h=new Array(r);for(let R=0;R<r;R+=1){let x=n[(R-1+r)%r],b=n[R],I=n[(R+1)%r];if(f[R]<=1e-6){m[R]={...b},h[R]={...b};continue}let w=Se(b,x)||1,S=Se(b,I)||1;m[R]={x:b.x+(x.x-b.x)/w*f[R],y:b.y+(x.y-b.y)/w*f[R]},h[R]={x:b.x+(I.x-b.x)/S*f[R],y:b.y+(I.y-b.y)/S*f[R]}}if(f.every(R=>R<=1e-6)&&!c)return null;let d=[],p={...h[0]},y=p,g=(R,x)=>{if(Se(y,R)<=1e-9)return;let b=a[x];Math.abs(b)>1e-6?d.push(va(y,R,b*Aa*l[x])):d.push({kind:"line",end:{...R}}),y=R};for(let R=1;R<=r;R+=1){let x=R%r,b=n[x];g(m[x],(R-1)%r),f[x]>1e-6&&Se(m[x],h[x])>1e-9&&(d.push({kind:"bezier",control1:Fn(m[x],b,Ho),control2:Fn(h[x],b,Ho),end:{...h[x]}}),y=h[x])}if(!d.length)return null;let M=d[d.length-1];Se(M.end,p)>1e-9&&(M.kind==="line"?M.end={...p}:d.push({kind:"line",end:{...p}}));let P={version:1,closed:!0,start:p,segments:d};return Xo(P)?P:null}function Ca(e){let t=e.points??[];if(e.kind!=="polygon"||t.length<3||!Array.isArray(e.edgeCurvature))return[];let n=t.map((o,r)=>{let i=e.edgeCurvature[r];return Number.isFinite(i)?Math.min(100,Math.max(-100,i)):0});return n.some(o=>Math.abs(o)>.5)?n:[]}function ka(e){let t=Ca(e);return t.length?Ko(e.points,{edgeCurvature:t}):null}function Qt(e,t=2){let n=ka(e);return n?Uo(n,t):e.points??[]}function Yo(e){return e.kind==="polygon"?Ot(e.holes):[]}function zo(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((m,h)=>m.segmentedRow.componentIndex-h.segmentedRow.componentIndex),s=i[0]?.segmentedRow?.componentCount??0,a=i[0]?.segmentedRow;if(!a||!(s>=2&&i.length===s&&a?.boundaryBefore==="start"&&i.every((m,h)=>m.segmentedRow?.kind==="segmented-row-v1"&&m.segmentedRow.groupId===o&&m.segmentedRow.componentCount===s&&m.segmentedRow.componentIndex===h&&m.segmentedRow.repeatLabelOnComponents===a.repeatLabelOnComponents&&(h===0?m.segmentedRow.boundaryBefore==="start":m.segmentedRow.boundaryBefore!=="start")&&m.segmentedRow.displayLabel===a.displayLabel)))continue;let u=i.reduce((m,h)=>m+h.seatCount,0),l=0,f=0;for(let m of i)m.segmentedRow.boundaryBefore==="break"&&(l+=1),t.set(m.id,{groupId:o,adjacencyOffset:l,displayOffset:f,displayLabel:a.displayLabel,totalSeats:u,canonical:i[0],viewFromSeatUrl:a.viewFromSeatUrl,viewFromSeatMeta:a.viewFromSeatMeta,confidenceEvidence:a.confidenceEvidence}),l+=m.seatCount,f+=m.seatCount}return t}var Oa="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var Ta="abcdefghijklmnopqrstuvwxyz";function La(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 Tt(e,t=!1){let n=t?Ta:Oa;return La(Math.max(0,Math.floor(e)-1),n)}var Ba=[[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 Zo(e){if(!Number.isFinite(e)||e<=0)return String(e);let t=Math.floor(e),n="";for(let[o,r]of Ba)for(;t>=o;)n+=r,t-=o;return n}function Fa(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 qt(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,c=e.seatCount;if(i==="updown"||i==="updown-descending"){let h=Math.ceil(c/2),d=i==="updown"?t<h?n+2*t:n-1+2*(c-t):t<h?n+2*(h-1-t):n+1+2*(t-h);return`${s}${d}`}let u=i==="odd"||i==="even"?2:r,l=a!=null&&Number.isFinite(a)?a-(c-1)*u:n,f=o==="center"?Fa(c)[t]:o==="rtl"?c-1-t:t,m;switch(i){case"odd":{let h=l%2===1?l:l+1;m=String(h+f*2);break}case"even":{let h=l%2===0?l:l+1;m=String(h+f*2);break}case"roman":m=Zo(l+f*r);break;case"letters-upper":m=Tt(l+f*r,!1);break;case"letters-lower":m=Tt(l+f*r,!0);break;default:m=String(l+f*r);break}return`${s}${m}`}function Na(e){return{...e.canonical,seatCount:e.totalSeats,label:e.displayLabel,displayLabel:e.displayLabel}}function $o(e,t,n){return n?.label??`${e.seatLabelBase??e.label}-${qt(e,t)}`}function Hn(e,t,n,o){if(o?.displayLabel)return o.displayLabel;if(e.seatDisplayLabelMode==="number")return qt(e,t);if(!n)return`${e.displayLabel||e.label}-${qt(e,t)}`;let r=Na(n),i=n.displayOffset+t;return`${n.displayLabel}-${qt(r,i)}`}function Qo(e,t){return`${e.label}-${t+1}`}function Da(e,t,n){return e?.direction==="anticlockwise"?Math.max(0,t-1-n):n}function Ga(e,t){let n=e.chairNumbering,o=n?.start??1,r=Da(n,Math.max(0,Math.round(e.seatCount)),t);return n?.format==="letter"?Tt(Math.max(1,o)+r):String(o+r)}function qo(e,t){let n=Ga(e,t);return(e.chairNumbering?.format??"table-number")==="table-number"?`${e.displayLabel??e.label}-${n}`:n}var $=.02291666666666667,Oe=1/$,ja=58,Ha=ja*$;var Va=3,Jo=0,Vn=120,Xa=0,Ua=45,Ka=7,He=1.2;function Xn(e,t,n,o){return Number.isFinite(e)?Math.max(t,Math.min(n,e)):o}function Ya(e){return!Number.isFinite(e)||!Number.isInteger(e)||e<0?0:e<=Ka?e:Va}function Qe(e,t={}){let n=Xn(t.floorBaseHeightM,Jo,Vn,0),o=Math.min(Vn,n+Ya(e.elevation)*Ha),r=e.height===void 0?o:Xn(e.height,Jo,Vn,o),i=Xn(e.rake,Xa,Ua,0);return{height:r,rake:i}}function er(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 pt(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,c=s.y-i.y,u=a*a+c*c,l=u>1e-12?((t-i.x)*a+(n-i.y)*c)/u:0;l<0?l=0:l>1&&(l=1);let f=t-(i.x+l*a),m=n-(i.y+l*c);if(Math.abs(f)>=o||Math.abs(m)>=o)continue;let h=Math.hypot(f,m);h<o&&(o=h)}return o}function Wa(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 tr(e,t){return Math.hypot(e.cx-t.cx,e.cy-t.cy)-e.r-t.r}function Un(e,t){let n=1/0;for(let o of er(e)){let r=pt(t,o.x,o.y);r<n&&(n=r)}for(let o of er(t)){let r=pt(e,o.x,o.y);r<n&&(n=r)}return n}function za(e,t){if(e.length<3)return{pts:e,seatIndices:t};let n=0,o=0;for(let l of e)n+=l.x,o+=l.y;n/=e.length,o/=e.length;let r=-1,i=e[0];for(let l of e){let f=Math.hypot(l.x-n,l.y-o);f>r&&(r=f,i=l)}let s=i.x-n,a=i.y-o,c=Math.hypot(s,a);c>1e-9?(s/=c,a/=c):(s=1,a=0);let u=e.map((l,f)=>({p:l,i:f,t:(l.x-n)*s+(l.y-o)*a})).sort((l,f)=>l.t-f.t);return{pts:u.map(l=>l.p),seatIndices:u.map(l=>t[l.i])}}function Kn(e){let t=e.length;if(t<3)return null;let n=0,o=0;for(let M of e)n+=M.x,o+=M.y;n/=t,o/=t;let r=0,i=0,s=0,a=0,c=0,u=0,l=0;for(let M of e){let P=M.x-n,R=M.y-o;r+=P*P,s+=R*R,i+=P*R,a+=P*P*P,c+=R*R*R,u+=P*R*R,l+=R*P*P}let f=r*s-i*i;if(Math.abs(f)<1e-9)return null;let m=(a+u)/2,h=(c+l)/2,d=(m*s-h*i)/f,p=(h*r-m*i)/f,y=d+n,g=p+o;return!Number.isFinite(y)||!Number.isFinite(g)?null:{cx:y,cy:g}}var Za=.15;function $a(e){if(e.length<2)return null;let t=e.map(x=>{let b=0,I=0;for(let w of x.pts)b+=w.x,I+=w.y;return{x:b/x.pts.length,y:I/x.pts.length}}),n=0,o=0;for(let x of t)n+=x.x,o+=x.y;n/=t.length,o/=t.length;let r=0,i=0,s=0;for(let x of t){let b=x.x-n,I=x.y-o;r+=b*b,i+=b*I,s+=I*I}let a=r+s,c=r*s-i*i,u=a/2+Math.sqrt(Math.max(0,a*a/4-c)),l,f;Math.abs(i)>1e-12?(l=u-s,f=i):r>=s?(l=1,f=0):(l=0,f=1);let m=Math.hypot(l,f);if(!(m>1e-12))return null;l/=m,f/=m;let h=0,d=0,p=0;for(let x of e){if(x.pts.length<2)continue;let b=x.pts[0],I=x.pts[x.pts.length-1],w=I.x-b.x,S=I.y-b.y,C=Math.hypot(w,S);if(!(C>1e-9))continue;let O=w/C,L=S/C;h+=(O*O-L*L)*C,d+=2*O*L*C,p+=C}if(p>0&&Math.hypot(h,d)>=qa*p){let x=Math.atan2(d,h)/2,b=Math.cos(x),I=Math.sin(x);Math.abs(l*b+f*I)>Ja&&(l=-I,f=b)}let y=1/0,g=-1/0,M=[];for(let x of e){let b=1/0,I=-1/0;for(let w of x.pts){let S=w.x*l+w.y*f;S<b&&(b=S),S>I&&(I=S),S<y&&(y=S),S>g&&(g=S)}M.push(I-b)}let P=g-y;return P>1e-9?(M.sort((x,b)=>x-b),M[Math.min(M.length-1,Math.floor(M.length*.9))]/P<=Qa?{x:l,y:f}:null):null}var Qa=.35,qa=.8,Ja=.7;function Jt(e,t,n,o){let r=new Map;for(let b of n){let I=t[b],w=I.rowId||`__seat-${b}`,S=r.get(w);S||(S={pts:[],idx:[]},r.set(w,S)),S.pts.push({x:I.x,y:I.y}),S.idx.push(b)}if(!r.size)return{sectionId:e,rows:[],blockCount:0};let i=[];for(let[b,I]of r){let w=za(I.pts,I.idx),S=0;for(let C of w.pts)S+=Math.hypot(C.x-o.x,C.y-o.y);i.push({id:b,pts:w.pts,seatIndices:w.seatIndices,blockId:-1,ordinal:0,blockDepth:0,focalDistance:S/w.pts.length})}let s=i.map(b=>Wa(b.pts)),a=i.length<=256?i.length*(i.length-1)/2:0,c=a?new Float64Array(a):null;c?.fill(Number.NaN);let u=c?new Map(i.map((b,I)=>[b,I])):null,l=(b,I)=>(b>I&&([b,I]=[I,b]),b*(2*i.length-b-1)/2+(I-b-1)),f=(b,I)=>{if(!c)return Un(i[b].pts,i[I].pts);let w=l(b,I),S=c[w];if(!Number.isNaN(S))return S;let C=Un(i[b].pts,i[I].pts);return c[w]=C,C},m=(b,I)=>u?f(u.get(b),u.get(I)):Un(b.pts,I.pts),h=[];for(let b=0;b<i.length;b++){let I=1/0;for(let w=0;w<i.length;w++){if(b===w||tr(s[b],s[w])>=I)continue;let S=f(b,w);S<I&&(I=S)}Number.isFinite(I)&&h.push(I)}h.sort((b,I)=>b-I);let d=h.length?h[Math.floor(h.length/2)]:1,p=Math.max(d*1.8,1e-6),y=i.map(()=>[]);for(let b=0;b<i.length;b++)for(let I=b+1;I<i.length;I++)tr(s[b],s[I])>p||f(b,I)<=p&&(y[b].push(I),y[I].push(b));let g=0;for(let b=0;b<i.length;b++){if(i[b].blockId!==-1)continue;let I=g++,w=[b];for(i[b].blockId=I;w.length;){let S=w.pop();for(let C of y[S])i[C].blockId===-1&&(i[C].blockId=I,w.push(C))}}let M=new Map;for(let b of i){let I=M.get(b.blockId)??[];I.push(b),M.set(b.blockId,I)}let P=[];for(let b of i){if(b.pts.length<4)continue;let I=Kn(b.pts);I&&(!Number.isFinite(I.cx)||!Number.isFinite(I.cy)||P.push({x:I.cx,y:I.cy}))}let R=P.length>=2?(()=>{let b=P.map(S=>S.x).sort((S,C)=>S-C),I=P.map(S=>S.y).sort((S,C)=>S-C),w=Math.floor(P.length/2);return{cx:b[w],cy:I[w]}})():null;if(R){let b=L=>Math.hypot(L.x-R.cx,L.y-R.cy),I=1/0,w=-1/0,S=[];for(let L of i){let v=1/0,A=-1/0;for(let _ of L.pts){let k=b(_);k<v&&(v=k),k>A&&(A=k)}S.push(A-v),v<I&&(I=v),A>w&&(w=A)}let C=w-I;S.sort((L,v)=>L-v);let O=S[Math.min(S.length-1,Math.floor(S.length*.9))];if(C>1e-9&&O/C<=Za){let L=i.map(N=>{let U=0;for(let V of N.pts)U+=b(V);return{row:N,radius:U/N.pts.length}}),v=0,A=0;for(let N of L)v+=N.radius,A+=N.row.focalDistance;v/=L.length,A/=L.length;let _=0;for(let N of L)_+=(N.radius-v)*(N.row.focalDistance-A);if(_<0)for(let N of L)N.radius=-N.radius;let F=1/0;for(let N of L)N.radius<F&&(F=N.radius);L.sort((N,U)=>N.radius-U.radius);let T=-1,B=-1/0,D=C/Math.max(1,L.length)*.5,H=[];for(let N of L)N.radius-B>D&&(T++,B=N.radius),N.row.ordinal=T,N.row.blockDepth=N.radius-F,H.push(N.row);return{sectionId:e,rows:H,blockCount:g}}}let x=[];for(let[,b]of M){let I=$a(b);if(I){let w=L=>{let v=0;for(let A of L.pts)v+=A.x*I.x+A.y*I.y;return v/L.pts.length};b.sort((L,v)=>w(L)-w(v)),b.length>=2&&b[0].focalDistance>b[b.length-1].focalDistance&&b.reverse();let S=[],C=d*.5;for(let L of b){let v=S[S.length-1];v&&Math.abs(w(L)-w(v[0]))<C?v.push(L):S.push([L])}let O=0;for(let L=0;L<S.length;L++){if(L>0){let v=1/0;for(let A of S[L-1])for(let _ of S[L])v=Math.min(v,m(A,_));O+=v}for(let v of S[L])v.ordinal=L,v.blockDepth=O,x.push(v)}}else{let w=1/0;for(let S of b)S.focalDistance<w&&(w=S.focalDistance);b.sort((S,C)=>S.focalDistance-C.focalDistance);for(let S=0;S<b.length;S++)b[S].ordinal=S,b[S].blockDepth=Math.max(0,b[S].focalDistance-w),x.push(b[S])}}return{sectionId:e,rows:x,blockCount:g}}var ec=/^\d{4}-\d{2}-\d{2}$/;function tc(e){let t=Date.parse(e);return Number.isFinite(t)?ec.test(e)?t+864e5:t:null}function nc(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=tc(e.validUntil);return n===null?!1:(t instanceof Date?t.getTime():t)<n}function oc(e,t,n){return!(e.eventConfigurationId&&e.eventConfigurationId!==t||e.eventConfigurationVersion!==void 0&&e.eventConfigurationVersion!==n)}function rc(e){return e.status!=="draft"&&e.status!=="retracted"}function ic(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 nr(e,t={}){return!!e&&rc(e)&&oc(e,t.activeConfigurationId,t.activeConfigurationVersion)&&ic(e,t.activeBasisSha256)&&nc(e,t.now)}var sc=new Set(["pitch-football","rink-hockey","track-athletics","oval-cricket","pitch-rugby","diamond-baseball","court-basketball","court-tennis","ring-boxing"]),ac=new Set(["pitch-football","track-athletics","oval-cricket","pitch-rugby","diamond-baseball"]);function st(e){return!!e&&sc.has(e)}function en(e){return!!e&&ac.has(e)}var Yn=1.1;function ir(e){return nn(e)?e==="ring-boxing"?Yn:.06:1}var cc={"pitch-football":{width:105,height:68},"rink-hockey":{width:60,height:30},"track-athletics":{width:176.9,height:92.5},"oval-cricket":{width:150,height:140},"pitch-rugby":{width:120,height:70},"diamond-baseball":{width:140,height:140},"court-basketball":{width:32,height:19},"court-tennis":{width:36.57,height:18.29},"ring-boxing":{width:7.8,height:7.8}},lc={"pitch-football":"#2f7d4f","rink-hockey":"#e8f1f8","track-athletics":"#a4472f","oval-cricket":"#3d8a53","pitch-rugby":"#2f7d4f","diamond-baseball":"#2f7d4f","court-basketball":"#c8894f","court-tennis":"#3f7a5a","ring-boxing":"#2a4d8f"};var uc=Math.PI*2;function fc(e,t,n,o,r,i){return{x:r+e*n-t*o,y:i+e*o+t*n}}function or(e,t){let n=Math.max(0,e-t),o=[],r=20;for(let i=0;i<=r;i++){let s=-Math.PI/2+i/r*Math.PI;o.push({x:n+t*Math.cos(s),y:t*Math.sin(s)})}for(let i=0;i<=r;i++){let s=Math.PI/2+i/r*Math.PI;o.push({x:-n+t*Math.cos(s),y:t*Math.sin(s)})}return o}var rr=(()=>{let t={x:0,y:52},n=25,o={x:70,y:t.y-70},r=(o.x*o.x+o.y*o.y-4900)/(2*(o.y+70)),i=r+70,s=[],a=Math.atan2(o.y-r,o.x),c=Math.atan2(o.y-r,-o.x);for(let u=0;u<=24;u++){let l=a+(c-a)*u/24;s.push({x:i*Math.cos(l),y:r+i*Math.sin(l)})}return{half:70,home:t,backstop:n,fence:s}})();var tn="#f1f5f9";function nn(e){return st(e)}function qe(e,t,n,o,r=32){let i=[];for(let s=0;s<r;s++){let a=s/r*uc;i.push({x:e+n*Math.cos(a),y:t+o*Math.sin(a)})}return i}function Ke(e,t,n,o){return[{x:e-n,y:t-o},{x:e+n,y:t-o},{x:e+n,y:t+o},{x:e-n,y:t+o}]}function mc(e){let{kind:t,cx:n,cy:o,width:r,height:i}=e,s=(e.rotation??0)*Math.PI/180,a=Math.cos(s),c=Math.sin(s),u=r/2,l=i/2,f=[],m=cc[t],h=p=>m?p/m.width*r:0,d=p=>m?p/m.height*i:0;switch(t){case"pitch-football":{f.push({points:[{x:0,y:-l},{x:0,y:l}],closed:!1}),f.push({points:qe(0,0,h(9.15),d(9.15)),closed:!0});for(let p of[-1,1])f.push({points:Ke(p*(u-h(16.5)/2),0,h(16.5)/2,d(40.32)/2),closed:!0}),f.push({points:Ke(p*(u-h(5.5)/2),0,h(5.5)/2,d(18.32)/2),closed:!0});break}case"rink-hockey":{f.push({points:[{x:0,y:-l},{x:0,y:l}],closed:!1,ink:"#d63b3b"});for(let p of[-1,1]){f.push({points:[{x:p*h(7.5),y:-l},{x:p*h(7.5),y:l}],closed:!1,ink:"#2f6ecb"}),f.push({points:[{x:p*(u-h(4)),y:-d(11)},{x:p*(u-h(4)),y:d(11)}],closed:!1,ink:"#d63b3b"});for(let y of[-1,1])f.push({points:qe(p*h(20.5),y*d(7),h(4.5),d(4.5)),closed:!0,ink:"#2f6ecb"})}f.push({points:qe(0,0,h(4.5),d(4.5)),closed:!0,ink:"#2f6ecb"});break}case"track-athletics":{let y=l-d(1.22)*8;y>0&&f.push({points:or(u-h(1.22)*8,y),closed:!0,fill:"#2f7d4f"});for(let g=1;g<8;g++){let M=d(1.22)*g,P=l-M;if(P<=0)break;f.push({points:or(u-h(1.22)*g,P),closed:!0})}break}case"oval-cricket":{f.push({points:qe(0,0,h(27.4),d(27.4+20.12/2),40),closed:!0}),f.push({points:Ke(0,0,h(3.05)/2,d(20.12)/2),closed:!0,ink:"#d8cfae"});break}case"pitch-rugby":{let p=y=>({points:[{x:h(y),y:-l},{x:h(y),y:l}],closed:!1});f.push(p(0));for(let y of[-1,1]){f.push(p(y*50),p(y*28));for(let g=-35;g<35;g+=4)f.push({points:[{x:h(y*10),y:d(g)},{x:h(y*10),y:d(Math.min(35,g+2))}],closed:!1})}break}case"diamond-baseball":{let p=(k,F)=>({x:h(k),y:d(F)}),{home:y}=rr,g=27.43,M=g/Math.SQRT2,P={x:y.x+M,y:y.y-M},R={x:y.x,y:y.y-2*M},x={x:y.x-M,y:y.y-M},b={x:y.x,y:y.y-18.44},I="#b98a59",w=lc["diamond-baseball"],S=38.94,C=[p(y.x,y.y)],O=Math.atan2(y.y-S/Math.SQRT2-b.y,S/Math.SQRT2),L=Math.PI-O;for(let k=0;k<=16;k++){let F=O-(O+Math.PI*2-L)%(Math.PI*2)*(k/16);C.push(p(b.x+29*Math.cos(F),b.y+29*Math.sin(F)))}f.push({points:C,closed:!0,fill:I,ink:I});let v={x:y.x,y:y.y-M},A=[{x:y.x,y:y.y},P,R,x].map(k=>p(v.x+(k.x-v.x)*.84,v.y+(k.y-v.y)*.84));f.push({points:A,closed:!0,fill:w,ink:w}),f.push({points:qe(h(b.x),d(b.y),h(2.74),d(2.74),20),closed:!0,fill:I,ink:I}),f.push({points:qe(h(y.x),d(y.y),h(3.96),d(3.96),20),closed:!0,fill:I,ink:I});let _=rr.fence;f.push({points:[p(y.x,y.y),p(_[0].x,_[0].y)],closed:!1}),f.push({points:[p(y.x,y.y),p(_[_.length-1].x,_[_.length-1].y)],closed:!1});for(let k of[P,R,x])f.push({points:Ke(h(k.x),d(k.y),h(.3),d(.3)),closed:!0,fill:tn});break}case"court-basketball":{f.push({points:Ke(0,0,h(14),d(7.5)),closed:!0}),f.push({points:[{x:0,y:-d(7.5)},{x:0,y:d(7.5)}],closed:!1}),f.push({points:qe(0,0,h(1.8),d(1.8),24),closed:!0});for(let p of[-1,1]){let y=p*14,g=p*(14-5.8),M=p*(14-1.575);f.push({points:Ke(h((y+g)/2),0,h(2.9),d(2.45)),closed:!0,fill:"#2f5d8a"}),f.push({points:qe(h(g),0,h(1.8),d(1.8),24),closed:!0});let P=Math.sqrt(6.75*6.75-6.6*6.6),R=[{x:h(y),y:-d(6.6)}],x=Math.atan2(-6.6,-p*P),b=2*Math.atan2(6.6,P);for(let I=0;I<=16;I++){let w=x-p*b*(I/16);R.push({x:h(M+6.75*Math.cos(w)),y:d(6.75*Math.sin(w))})}R.push({x:h(y),y:d(6.6)}),f.push({points:R,closed:!1})}break}case"court-tennis":{f.push({points:Ke(0,0,h(11.885),d(5.485)),closed:!0,fill:"#2b5f99"});for(let p of[-1,1])f.push({points:[{x:-h(11.885),y:p*d(4.115)},{x:h(11.885),y:p*d(4.115)}],closed:!1}),f.push({points:[{x:p*h(6.4),y:-d(4.115)},{x:p*h(6.4),y:d(4.115)}],closed:!1});f.push({points:[{x:-h(6.4),y:0},{x:h(6.4),y:0}],closed:!1}),f.push({points:[{x:0,y:-d(6.4)},{x:0,y:d(6.4)}],closed:!1,ink:"#d1d5db"});break}case"ring-boxing":{f.push({points:Ke(0,0,h(3.05),d(3.05)),closed:!0});let g=[[-1,-1,"#c53030"],[1,1,"#2b6cb0"],[1,-1,"#e2e8f0"],[-1,1,"#e2e8f0"]];for(let[M,P,R]of g)f.push({points:Ke(M*h(3.05),P*d(3.05),h(.3),d(.3)),closed:!0,fill:R,ink:R});break}default:return[]}return f.map(p=>({...p,points:p.points.map(y=>fc(y.x,y.y,a,c,n,o))}))}function sr(e){if(e.role!=="stage"||!nn(e.stageKind))return[];let t=null;if(e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null&&e.width>0&&e.height>0&&[e.x,e.y,e.width,e.height].every(Number.isFinite))t={cx:e.x+e.width/2,cy:e.y+e.height/2,width:e.width,height:e.height};else if(e.points&&e.points.length>=3&&e.points.every(n=>Number.isFinite(n.x)&&Number.isFinite(n.y))){let n=e.points.map(l=>l.x),o=e.points.map(l=>l.y),r=Math.min(...n),i=Math.max(...n),s=Math.min(...o),a=Math.max(...o),c=Math.max(1,i-r),u=Math.max(1,a-s);t={cx:r+c/2,cy:s+u/2,width:c,height:u}}return t?mc({kind:e.stageKind,...t}):[]}var hc=/^data:image\/(?:png|jpe?g|webp|gif|avif);base64,[a-z0-9+/]+={0,2}$/i,dc=/[\s"'<>`\\]/;function pc(e){if(typeof e!="string"||!e||e.length>2e6||e!==e.trim())return!1;if(e.startsWith("data:"))return hc.test(e);if(dc.test(e))return!1;try{let t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}}function ar(e){let t=e.trim();return pc(t)?t:null}var Wn="seatlayer.event-configuration/1";var bt=100,bc=120,yc=2e5,gc=1e4,xc=/^[a-f0-9]{64}$/,Mc=new Set(["stage","screen","barrier","camera_platform","sound_desk","rigging_truss"]);function Lt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function at(e,t){return typeof e=="string"&&e.length>=1&&e.length<=t&&e.normalize("NFKC").trim()===e}function Sc(e){return typeof e=="number"&&Number.isInteger(e)&&e>0}function cr(e){return!Array.isArray(e)||e.length>yc||!e.every(t=>at(t,bt))?null:[...new Set(e)].sort()}function Pc(e){return!Lt(e)||!at(e.chartId,bt)||!at(e.version,bt)||e.sha256!==void 0&&(typeof e.sha256!="string"||!xc.test(e.sha256))?null:{chartId:e.chartId,version:e.version,...typeof e.sha256=="string"?{sha256:e.sha256}:{}}}function zn(e,t,n){return typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=n}function Ic(e){return Lt(e)?e.mode==="none"||e.mode==="opaque"?e.opacity===void 0?{mode:e.mode}:null:e.mode==="partial"&&zn(e.opacity,.01,.99)?{mode:"partial",opacity:e.opacity}:null:null}function Rc(e,t){if(e===void 0)return;if(!Array.isArray(e)||e.length>gc)return null;let n=new Set(t),o=new Set,r=new Set,i=0,s=[];for(let a of e){if(!Lt(a)||!at(a.id,bt)||!at(a.objectId,bt)||!n.has(a.objectId)||!Mc.has(String(a.kind))||!zn(a.heightM,.05,50)||a.baseElevationM!==void 0&&!zn(a.baseElevationM,-10,100))return null;let c=Ic(a.occlusion);if(!c||o.has(a.id)||r.has(a.objectId))return null;let u=a.contentImageUrl===void 0?void 0:typeof a.contentImageUrl=="string"?ar(a.contentImageUrl):null;if(a.contentImageUrl!==void 0&&(!u||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:c,...u?{contentImageUrl:u}:{}})}return s.sort((a,c)=>a.id.localeCompare(c.id))}function wc(e){let t=[];if(!Lt(e))return{issues:[{code:"invalid_export",path:"configuration",message:"Configuration must be an object"}]};e.schema!==Wn&&t.push({code:"unsupported_schema",path:"configuration.schema",message:`Configuration schema must be ${Wn}`}),at(e.id,bt)||t.push({code:"invalid_id",path:"configuration.id",message:"Configuration id must contain 1 to 100 normalized characters"}),at(e.label,bc)||t.push({code:"invalid_label",path:"configuration.label",message:"Configuration label must contain 1 to 120 normalized characters"}),Sc(e.version)||t.push({code:"invalid_version",path:"configuration.version",message:"Configuration version must be a positive integer"});let n=Pc(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=Lt(e.overlay)?e.overlay:null,r=cr(o?.objectIds),i=cr(o?.productionKillSeatIds),s=r?Rc(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:Wn,id:e.id,label:e.label,version:e.version,baseVenue:n,overlay:{objectIds:r,productionKillSeatIds:i,...s!==void 0?{productionElements:s}:{}}}}}function lr(e){let t=wc(e);return t.value?{ok:!0,value:t.value}:{ok:!1,issues:t.issues}}function Ec(e){if((e.kind==="polygon"||e.kind==="polyline"||e.kind==="line")&&e.points&&e.points.length>=2)return e.kind==="polygon"?Qt(e,6):e.points;if(e.x==null||e.y==null||e.width==null||e.height==null)return null;let t=e.x,n=e.y,o=e.width,r=e.height;return[{x:t,y:n},{x:t+o,y:n},{x:t+o,y:n+r},{x:t,y:n+r}]}function Ac(e,t,n){let o=n*Math.PI/180,r=Math.cos(o),i=Math.sin(o),s=e.x-t.x,a=e.y-t.y;return{x:t.x+s*r-a*i,y:t.y+s*i+a*r}}function ur(e){let t=Ec(e);if(!t||t.length<2)return null;let n=e.rotation??0,o=Math.abs(n)<1e-6?t:t.map(c=>Ac(c,{x:t.reduce((u,l)=>u+l.x,0)/t.length,y:t.reduce((u,l)=>u+l.y,0)/t.length},n)),r=1/0,i=1/0,s=-1/0,a=-1/0;for(let c of o)r=Math.min(r,c.x),i=Math.min(i,c.y),s=Math.max(s,c.x),a=Math.max(a,c.y);return!Number.isFinite(r)||s-r<1e-6||a-i<1e-6?null:{minX:r,minY:i,maxX:s,maxY:a}}var _c=5,vc=3,Cc=.92,kc=1.9,Oc=2,Tc=.6,Lc=1,Bc=.06;function Fc(e){return e.heightM!==void 0?e.heightM:e.stageKind==="ring-boxing"?Yn:nn(e.stageKind)?Bc:Lc}function fr(e){let t=1/0,n=1/0,o=-1/0,r=-1/0,i=-1/0;for(let s of dr(e)){let a=s.baseHeightM??0;for(let c of s.objects){if(c.type!=="shape"||c.role!=="stage")continue;let u=ur(c);u&&(t=Math.min(t,u.minX),n=Math.min(n,u.minY),o=Math.max(o,u.maxX),r=Math.max(r,u.maxY),i=Math.max(i,a+Fc(c)))}}return!Number.isFinite(t)||!Number.isFinite(i)?null:{minX:t,minY:n,maxX:o,maxY:r,deckTopM:i}}function Nc(e,t,n,o){let r=1/0,i=1/0,s=-1/0,a=-1/0;for(let h of e)Number.isFinite(h.eyeHeightM)&&(r=Math.min(r,h.x),s=Math.max(s,h.x),i=Math.min(i,h.y),a=Math.max(a,h.y));if(!Number.isFinite(r))return null;let c=r*t,u=i*t,l=Math.max(1,Math.ceil((s-r)*t/n)+1),f=Math.max(1,Math.ceil((a-i)*t/n)+1),m=new Float64Array(l*f).fill(-1/0);for(let h of e){if(!Number.isFinite(h.eyeHeightM))continue;let d=h.eyeHeightM-He,p=Math.min(l-1,Math.max(0,Math.floor((h.x*t-c)/n))),g=Math.min(f-1,Math.max(0,Math.floor((h.y*t-u)/n)))*l+p,M=d+o;M>m[g]&&(m[g]=M)}return{cellM:n,minX:c,minY:u,cols:l,rows:f,top:m}}function Dc(e,t,n){let o=Math.floor((t-e.minX)/e.cellM),r=Math.floor((n-e.minY)/e.cellM);return o<0||r<0||o>=e.cols||r>=e.rows?-1/0:e.top[r*e.cols+o]}function mr(e,t,n={}){let o=new Map;if(!t||!e.length)return o;let r=n.metresPerChartUnit??$,i=n.cellM??Tc,s=n.chairBackM??Cc,a=n.selfRowSkipM??Oc,c=n.clearThreshold??.9,u=n.partialThreshold??.25,l=Math.max(1,n.columns??_c),f=Math.max(1,n.rows??vc),m=Nc(e,r,i,s);if(!m)return o;let h=(t.maxX-t.minX)*r,d=(t.maxY-t.minY)*r,p=h>=d,y=(t.minX+t.maxX)/2*r,g=(t.minY+t.maxY)/2*r,M=[];for(let R=0;R<l;R++){let x=(R+.5)/l-.5,b=p?y+x*h:y,I=p?g:g+x*d;for(let w=0;w<f;w++){let S=t.deckTopM+(f===1?0:w/(f-1)*kc);M.push({x:b,y:I,z:S})}}let P=i/2;for(let R of e){if(!Number.isFinite(R.eyeHeightM))continue;let x=R.x*r,b=R.y*r,I=R.eyeHeightM,w=0,S=1/0;for(let O of M){let L=O.x-x,v=O.y-b,A=Math.hypot(L,v);if(!(A>a)){w++;continue}let _=L/A,k=v/A,F=0;for(let T=a;T<A;T+=P){let B=Dc(m,x+_*T,b+k*T);if(!(!Number.isFinite(B)||B>=I)&&B>I+(O.z-I)*T/A){F=T;break}}F?S=Math.min(S,F):w++}let C=w/M.length;C>=c||o.set(R.id,{seatId:R.id,mark:C<u?"obstructedView":"restrictedView",visibleFraction:C,totalRays:M.length,atDistanceM:Number.isFinite(S)?S:0})}return o}function hr(e,t){if(!t.size)return 0;let n=0;for(let o of e){let r=t.get(o.id);if(!r)continue;let i=o.commercial;i?.restrictedView!==void 0||i?.obstructedView!==void 0||(o.commercial={...i,[r.mark]:!0},n++)}return n}function Zn(e){return e?e.accessibility?.length?e.wheelchairSpaceType&&!e.accessibility.includes("wheelchair")?["wheelchair",...e.accessibility]:e.accessibility:e.wheelchairSpaceType?["wheelchair"]:e.accessible?["wheelchair"]:[]:[]}var rn=Math.PI/180;var Bt=16;function $n(e,t,n,o){let r=n*rn,i=Math.cos(r),s=Math.sin(r);return{x:o.x+e*i-t*s,y:o.y+e*s+t*i}}function gr(e){let{seatCount:t,seatSpacing:n,curve:o,rotation:r,origin:i}=e,s=[];if(e.path)return Go(e.path,t);if(t<=1)return t===1&&s.push({x:i.x,y:i.y}),s;if(o===0){for(let u=0;u<t;u++)s.push($n(u*n,0,r,i));return s}let a=o/(t-1)*rn,c=n/(2*Math.sin(Math.abs(a)/2));for(let u=0;u<t;u++){let l=u*a,f=c*Math.sin(l),m=-c+c*Math.cos(l);s.push($n(f,m,r,i))}return s}function xr(e){let t=new Map;if(e.overrides)for(let n of e.overrides)t.set(n.index,n);return t}function Gc(e,t){let n=xr(e);return gr(e).map((o,r)=>{let i=n.get(r),s=Zn(i),a=$o(e,r,i),c={...e.commercial,...i?.commercial};return{index:r,x:o.x+(i?.dx??0),y:o.y+(i?.dy??0),label:a,displayLabel:Hn(e,r,t,i),categoryKey:i?.categoryKey??e.categoryKey,skipped:!!i?.skip,accessible:s.length>0,accessibility:s,wheelchairSpaceType:i?.wheelchairSpaceType,commercial:Object.values(c).some(u=>u!==void 0&&u!==!1&&u!=="")?c:void 0,glyph:i?.glyph,viewUrl:i?.viewFromSeatUrl??e.viewFromSeatUrl,viewMeta:i?.viewFromSeatUrl?i.viewFromSeatMeta:e.viewFromSeatMeta,labelStyle:i?.labelStyle??e.seatLabelStyle}})}function jc(e){let t=[];for(let n of Gc(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 Hc(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 Vc(e){let t=[],n=Math.max(0,Math.round(e.seatCount));if(n===0)return t;let o=new Map((e.overrides??[]).map(l=>[l.index,l])),r=(l,f,m,h)=>{let d=o.get(l),p=Zn(d),y=d?.label??Qo(e,l);return{index:l,label:y,displayLabel:d?.displayLabel??qo(e,l),x:f+(d?.dx??0),y:m+(d?.dy??0),categoryKey:d?.categoryKey??e.categoryKey,skipped:!!d?.skip,accessible:p.length>0,accessibility:p,wheelchairSpaceType:d?.wheelchairSpaceType,commercial:d?.commercial,glyph:d?.glyph,viewUrl:d?.viewFromSeatUrl,viewMeta:d?.viewFromSeatUrl?d.viewFromSeatMeta:void 0,labelStyle:d?.labelStyle,...h?{side:h}:{}}};if(e.shape==="round"){let l=(e.radius??40)+Bt,f=e.rotation*rn,m=Math.max(0,Math.min(360,e.seatArc??360));if(m>=360||n===1){for(let y=0;y<n;y++){let g=f+y/n*2*Math.PI;t.push(r(y,e.center.x+l*Math.cos(g),e.center.y+l*Math.sin(g)))}return t}let h=m*rn,d=(2*Math.PI-h)/2,p=f+d;for(let y=0;y<n;y++){let g=p+y/(n-1)*h;t.push(r(y,e.center.x+l*Math.cos(g),e.center.y+l*Math.sin(g)))}return t}let i=e.width??80,s=e.height??50,a=Hc(e),c=["top","bottom","left","right"],u=0;for(let l of c){let f=a[l];for(let m=0;m<f;m++){let h,d;l==="top"?(h=-i/2+(m+.5)*i/f,d=-s/2-Bt):l==="bottom"?(h=-i/2+(m+.5)*i/f,d=s/2+Bt):l==="left"?(h=-i/2-Bt,d=-s/2+(m+.5)*s/f):(h=i/2+Bt,d=-s/2+(m+.5)*s/f);let p=$n(h,d,e.rotation,e.center);t.push(r(u++,p.x,p.y,l))}}return t}function Xc(e){return Vc(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 Uc(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",...e.commercial?.note?{commercial:{note:e.commercial.note}}:{}}]}function jn(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,c=t[r].y;s>e.y!=c>e.y&&e.x<(a-i)*(e.y-s)/(c-s)+i&&(n=!n)}return n}function Wo(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 Ot(e){return Array.isArray(e)?e.filter(t=>Array.isArray(t)&&t.length>=3):[]}function Pe(e,t,n){return jn(e,t)&&!Ot(n).some(o=>jn(e,o)||Wo(e,o))}function on(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 Mr(e){switch(e.type){case"row":{let t=gr(e),n=xr(e),o=0,r=0,i=0;for(let s=0;s<t.length;s++){let a=n.get(s);a?.skip||(o+=t[s].x+(a?.dx??0),r+=t[s].y+(a?.dy??0),i++)}return i?{x:o/i,y:r/i}:{x:e.origin.x,y:e.origin.y}}case"table":case"booth":return{x:e.center.x,y:e.center.y};case"gaArea":return on(e.points);case"section":return on(e.outline);case"text":return{x:e.position.x,y:e.position.y};case"shape":return e.points&&e.points.length?on(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 pr(e,t){return e.length===t.length&&e.every((n,o)=>n.x===t[o].x&&n.y===t[o].y)}function Kc(e,t){if(e.type!=="gaArea"||!pr(e.points,t.outline))return!1;let n=Ot(e.holes),o=Ot(t.holes);return n.length===o.length&&n.every((r,i)=>pr(r,o[i]))}function Yc(e,t,n=e.filter(r=>r.type==="section"),o=Mr(t)){let r="referenceInventorySource"in t?t.referenceInventorySource?.logicalSectionId:void 0;return(r?n.find(s=>(s.logicalSectionId??s.id)===r&&(Kc(t,s)||Pe(o,s.outline,s.holes))):void 0)??n.find(s=>Pe(o,s.outline,s.holes))}function dr(e){return e.floors&&e.floors.length?e.floors:[{id:"floor-0",name:"Main",objects:e.objects,focalPoint:e.focalPoint,referenceImage:e.referenceImage,backgroundImage:e.backgroundImage}]}function br(e,t,n,o,r,i,s,a,c){let u=[],l=e.filter(p=>p.type==="section"),f=zo(e),m=p=>!p?.eventConfigurationId||p.eventConfigurationId===o&&(p.eventConfigurationVersion===void 0||p.eventConfigurationVersion===c),h=p=>nr(p,{activeConfigurationId:o,activeConfigurationVersion:c,activeBasisSha256:r,now:a}),d=(p,y)=>h(p)?{...p,coverage:y}:void 0;for(let p of e){let y=[];if(p.type==="row"?y=jc(p):p.type==="table"?y=Xc(p):p.type==="booth"&&(y=Uc(p)),!y.length)continue;for(let x of y)x.viewUrl&&!m(x.viewMeta)&&(x.viewUrl=void 0,x.viewMeta=void 0);if(p.type==="row"){let x=f.get(p.id);if(x){let b=new Map((p.overrides??[]).map(I=>[I.index,I]));for(let I of y){let w=Number(I.id.slice(I.id.lastIndexOf(":")+1));if(!Number.isInteger(w))continue;I.logicalRowId=x.groupId,I.logicalSeatIndex=x.adjacencyOffset+w,b.get(w)?.displayLabel||(I.displayLabel=Hn(p,w,x)),!I.viewUrl&&x.viewFromSeatUrl&&m(x.viewFromSeatMeta)&&(I.viewUrl=x.viewFromSeatUrl,I.viewMeta=x.viewFromSeatMeta);let S=b.get(w)?.confidenceEvidence;I.confidenceEvidence=d(S,"exact-seat")??d(p.confidenceEvidence,"row-representative")??d(x.confidenceEvidence,"row-representative")}}}let g=Yc(e,p,l,p.type==="row"?on(y):Mr(p)),M=g?.viewFromSeatUrl,R=(g?.zone?t?.find(x=>x.id===g.zone):void 0)?.focalPoint??n;for(let x of y){if(!x.confidenceEvidence){let b=Number(x.id.slice(x.id.lastIndexOf(":")+1)),I=(p.type==="row"||p.type==="table")&&Number.isInteger(b)?p.overrides?.find(w=>w.index===b)?.confidenceEvidence:void 0;x.confidenceEvidence=d(I,"exact-seat")??(p.type==="row"?d(p.confidenceEvidence,"row-representative"):void 0)}x.confidenceEvidence??=d(g?.confidenceEvidence,"section-representative")??(s?d(s.evidence,s.coverage):void 0),!x.viewUrl&&M&&m(g?.viewFromSeatMeta)&&(x.viewUrl=M,x.viewMeta=g?.viewFromSeatMeta),!x.viewUrl&&i&&m(i.meta)&&(x.viewUrl=i.url,x.viewMeta=i.meta),g&&(x.sectionId=g.logicalSectionId??g.id),g?.zone&&(x.zoneId=g.zone),R&&(x.focalPoint={...R})}u.push(...y)}return u}function yt(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,c=br(r.objects,e.zones,i,e.eventConfigurationId,e.confidenceBasisSha256,s,a,t.now,t.eventConfigurationVersion??e.eventConfigurationVersion);t.resolveEyeHeights!==!1&&yr(r.objects,r.focalPoint??e.focalPoint,r.baseHeightM??0,c);for(let u of c)u.floorId=r.id;for(let u of c)o.push(u)}return o}let n=br(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&&yr(e.objects,e.focalPoint,t.floorBaseHeightM??0,n),Wc(e,n,t)}function Wc(e,t,n){return!n.deriveRestrictedView||e.derivedRestrictedView===!1||n.resolveEyeHeights===!1||hr(t,mr(t,fr(e))),t}function yr(e,t,n,o){let r=e.filter(f=>f.type==="section"),i=n>0||r.some(f=>f.height!==void 0||f.rake!==void 0||(f.elevation??0)>0);if(!r.length||!i||!t){for(let f of o)f.eyeHeightM=n+He;return}let s=new Array(o.length),a=new Map;for(let f of r)a.has(f.id)||a.set(f.id,f);let c=new Map,u=new Map;for(let f=0;f<o.length;f++){let m=o[f],d=(m.sectionId?a.get(m.sectionId)??r.find(y=>y.logicalSectionId===m.sectionId&&Pe({x:m.x,y:m.y},y.outline,y.holes)):void 0)??r.find(y=>Pe({x:m.x,y:m.y},y.outline,y.holes))??null;if(s[f]=d,!d)continue;c.has(d.id)||c.set(d.id,Qe(d,{floorBaseHeightM:n}));let p=u.get(d.id);p?p.push(f):u.set(d.id,[f])}let l=new Array(o.length).fill(void 0);for(let[f,m]of u){let h=c.get(f);if(!h)continue;let d=h.rake>0?Math.tan(h.rake*Math.PI/180):0,p=Jt(f,o,m,t);for(let y of p.rows){let g=y.blockDepth*$*d,M=h.height+g;for(let P of y.seatIndices)l[P]=M}}for(let f=0;f<o.length;f++){let m=o[f],h=s[f];if(!h){m.eyeHeightM=n+He;continue}let d=c.get(h.id);m.eyeHeightM=(l[f]??d.height)+He}}var Pr=je(require("earcut"),1),Qn=je(require("polygon-clipping"),1);function Ae(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 _e(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 E=$,zc=.002;function Zc(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<zc}var ct=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)}},cn=class{constructor(){this.pos=new ct;this.nor=new ct;this.col=new ct;this.flr=new ct;this.mat=new ct;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){Zc(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,c=a,u=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(c[0],c[1],c[2]),this.col.push3(u[0],u[1],u[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 $c(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],c=n[2]-e[2],u=r*c-i*a,l=i*s-o*c,f=o*a-r*s,m=Math.hypot(u,l,f)||1;return u/=m,l/=m,f/=m,[u,l,f]}function Qc(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,Pr.default)(o,r.length?r:void 0,2);return{pts:n,tris:i}}function Ve(e){return Ae(e)<0?[...e].reverse():e}var qc=3;function Jc(e,t,n,o){let r=o(e),i=o(t),s=o(n),a=(h,d,p,y)=>Math.abs(o({x:(h.x+d.x)/2,y:(h.y+d.y)/2})-(p+y)/2),c=(e.x+t.x+n.x)/3,u=(e.y+t.y+n.y)/3,l=(r+i+s)/3,f=Math.max(a(e,t,r,i),a(t,n,i,s),a(n,e,s,r),Math.abs(o({x:c,y:u})-l)),m=(h,d,p)=>{let y=Math.abs(o({x:(h+c)/2,y:(d+u)/2})-(p+l)/2);y>f&&(f=y)};return m((e.x+t.x)/2,(e.y+t.y)/2,(r+i)/2),m((t.x+n.x)/2,(t.y+n.y)/2,(i+s)/2),m((n.x+e.x)/2,(n.y+e.y)/2,(s+r)/2),f}function Ft(e,t,n,o,r){if(r<=0)return Jc(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(Ft(e,i,a,o,r-1),Ft(i,t,s,o,r-1),Ft(a,s,n,o,r-1),Ft(i,s,a,o,r-1))}function Nt(e,t,n,o,r,i,s,a){if(s>0){let m={x:(t.x+n.x)/2,y:(t.y+n.y)/2},h={x:(n.x+o.x)/2,y:(n.y+o.y)/2},d={x:(o.x+t.x)/2,y:(o.y+t.y)/2};Nt(e,t,m,d,r,i,s-1,a),Nt(e,m,n,h,r,i,s-1,a),Nt(e,d,h,o,r,i,s-1,a),Nt(e,m,h,d,r,i,s-1,a);return}let c=[t.x*E,r(t),t.y*E],u=[n.x*E,r(n),n.y*E],l=[o.x*E,r(o),o.y*E];if(a){e.triN(c,u,l,a(t),a(n),a(o),i);return}let f=$c(c,u,l);f[1]<0&&(f=[-f[0],-f[1],-f[2]]),e.tri(c,u,l,f,i)}var el=8;function Sr(e,t,n){if(!Number.isFinite(n))return e;let o=[],r=(i,s,a,c,u)=>{if(u>0){let l={x:(i.x+s.x)/2,y:(i.y+s.y)/2},f=t(l);if(Math.abs(f-(a+c)/2)>n){r(i,l,a,f,u-1),r(l,s,f,c,u-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),el)}return o}function sn(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],c=a.x-i.x,u=a.y-i.y,l=Math.hypot(c,u);l>t&&Math.abs((s.x-i.x)*u-(s.y-i.y)*c)/l<t||o.push(s)}return o.length>=3?o:n}var an=.001*Oe*.1;function z(e,t,n,o,r,i,s,a,c=1/0,u){if(!t||t.length<3||(c===void 0&&(c=1/0),Math.abs(Ae(t))<1e-4))return;let l=sn(Sr(sn(Ve(t),an),o,c),an),f=n?.map(b=>sn(Sr(sn(Ve(b),an),o,c),an)).filter(b=>b.length>=3&&Math.abs(Ae(b))>=1e-4),{pts:m,tris:h}=Qc(l,f),d=[i[0]*a.top,i[1]*a.top,i[2]*a.top],p=[i[0]*a.bottomCap,i[1]*a.bottomCap,i[2]*a.bottomCap],y=[s[0]*a.top,s[1]*a.top,s[2]*a.top],g=[s[0]*a.wallBottom,s[1]*a.wallBottom,s[2]*a.wallBottom],M=0;if(Number.isFinite(c))for(;M<qc;M++){let b=0;for(let I=0;I<h.length;I+=3){let w=Ft(m[h[I]],m[h[I+1]],m[h[I+2]],o,M);w>b&&(b=w)}if(b<=c)break}for(let b=0;b<h.length;b+=3){let I=m[h[b]],w=m[h[b+1]],S=m[h[b+2]];Nt(e,I,w,S,o,d,M,u);let C=[I.x*E,r,I.y*E],O=[w.x*E,r,w.y*E],L=[S.x*E,r,S.y*E];e.tri(C,L,O,[0,-1,0],p)}let P=b=>{if(M<=0)return b;let I=1<<M,w=[];for(let S=0;S<b.length;S++){let C=b[S],O=b[(S+1)%b.length];for(let L=0;L<I;L++){let v=L/I;w.push({x:C.x+(O.x-C.x)*v,y:C.y+(O.y-C.y)*v})}}return w},R=Nn(l),x=[{ring:P(l),flip:!1}];if(f)for(let b of f)b.length>=3&&x.push({ring:P(b),flip:!0});for(let{ring:b,flip:I}of x)for(let w=0;w<b.length;w++){let S=b[w],C=b[(w+1)%b.length],O=(C.x-S.x)*E,v=(C.y-S.y)*E,A=-O,_=Math.hypot(v,A)||1;v/=_,A/=_;let k=(S.x+C.x)/2-R.x,F=(S.y+C.y)/2-R.y,T=v*k+A*F;I&&(T=-T),T<0&&(v=-v,A=-A);let B=[v,0,A],D=[S.x*E,o(S),S.y*E],H=[C.x*E,o(C),C.y*E],N=[S.x*E,r,S.y*E],U=[C.x*E,r,C.y*E];e.tri(D,H,U,B,y,y,g),e.tri(D,U,N,B,y,g,g)}}function Ir(e){let t=0;for(let c of e)t+=c.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 c of e)n.set(c.position,a*3),o.set(c.normal,a*3),r.set(c.color,a*3),i.set(c.floor,a),s.set(c.material,a),a+=c.count;return{position:n,normal:o,color:r,floor:i,material:s,count:t}}function Le(e,t,n=2.5){if(t<=0||e.length<3)return e;let o=Ve(e),r=o.length,i=[];for(let a=0;a<r;a++){let c=o[a],u=o[(a+1)%r],l=u.x-c.x,f=u.y-c.y,m=Math.hypot(l,f)||1;i.push({x:f/m,y:-l/m})}let s=[];for(let a=0;a<r;a++){let c=o[a],u=i[(a-1+r)%r],l=i[a],f=u.x+l.x,m=u.y+l.y,h=Math.hypot(f,m),d=()=>{s.push([c.x+u.x*t,c.y+u.y*t]),s.push([c.x+l.x*t,c.y+l.y*t])};if(h<1e-9){d();continue}f/=h,m/=h;let p=f*u.x+m*u.y,y=1/Math.max(p,1e-6);if(!Number.isFinite(y)||y>n){d();continue}s.push([c.x+f*t*y,c.y+m*t*y])}if(s.length<3)return e;try{let a=Qn.default.union([[...s,s[0]]]),c=null,u=-1/0;for(let f of a){let m=Math.abs(Ae(f[0].map(([h,d])=>({x:h,y:d}))));m>u&&(u=m,c=f[0])}if(!c)return e;let l=c.map(([f,m])=>({x:f,y:m}));if(l.length>1){let f=l[0],m=l[l.length-1];Math.abs(f.x-m.x)<1e-9&&Math.abs(f.y-m.y)<1e-9&&l.pop()}return l.length>=3?l:e}catch{return e}}function Je(e,t,n=2.5){if(e.length<3)return[];if(t<=0)return e;let o=Ve(e),r=o.length,i=[];for(let c=0;c<r;c++){let u=o[c],l=o[(c+1)%r],f=Math.hypot(l.x-u.x,l.y-u.y)||1;i.push({x:-(l.y-u.y)/f,y:(l.x-u.x)/f})}let s=[],a=[];for(let c=0;c<r;c++){let u=o[c],l=i[(c-1+r)%r],f=i[c],m=l.x+f.x,h=l.y+f.y,d=Math.hypot(m,h),p=d<1e-9?1/0:1/Math.max(m/d*l.x+h/d*l.y,1e-6);if(!Number.isFinite(p)||p>n){s.push({x:u.x+l.x*t,y:u.y+l.y*t},{x:u.x+f.x*t,y:u.y+f.y*t}),a.push(c,c);continue}m/=d,h/=d,s.push({x:u.x+m*t*p,y:u.y+h*t*p}),a.push(c)}for(let c=0;c<s.length;c++){let u=(c+1)%s.length,l=a[c],f=a[u];if(f!==(l+1)%r)continue;let m=o[l],h=o[f];if((s[u].x-s[c].x)*(h.x-m.x)+(s[u].y-s[c].y)*(h.y-m.y)<=0)return[]}try{let c=Qn.default.intersection([[...s.map(d=>[d.x,d.y]),[s[0].x,s[0].y]]],[[...o.map(d=>[d.x,d.y]),[o[0].x,o[0].y]]]),u=null,l=0;for(let d of c){let p=Math.abs(Ae(d[0].map(([y,g])=>({x:y,y:g}))));p>l&&(l=p,u=d[0])}if(!u)return[];let f=u.map(([d,p])=>({x:d,y:p})),m=f[0],h=f[f.length-1];return f.length>1&&Math.abs(m.x-h.x)<1e-9&&Math.abs(m.y-h.y)<1e-9&&f.pop(),f.length>=3?Ve(f):[]}catch{return[]}}function ln(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 Dt(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 Gt=3,lt=.38,jt=.24;function tl(e){if(e.length<3)return null;let t=e[0],n=e[Math.floor(e.length/2)],o=e[e.length-1],r=(n.x-t.x)*E,i=(n.y-t.y)*E,s=(o.x-t.x)*E,a=(o.y-t.y)*E,c=2*(r*a-i*s);if(Math.abs(c)<1e-7)return null;let u=r*r+i*i,l=s*s+a*a,f=(u*a-l*i)/c+t.x*E,m=(r*l-s*u)/c+t.y*E,h=Math.hypot(t.x*E-f,t.y*E-m);return h<1||h>200||!Number.isFinite(h)||e.some(d=>Math.abs(Math.hypot(d.x*E-f,d.y*E-m)-h)>.03)?null:{x:f,z:m,radius:h}}function Rr(e){let t=[],n=new Map,o=(c,u)=>`${Math.floor(c/Gt)},${Math.floor(u/Gt)}`;for(let c of e)for(let u of c.rows){for(let f of u.pts){let m=f.x*E,h=f.y*E,d=o(m,h),p=n.get(d)??[];p.push({x:m,z:h,y:u.y,floor:c.floorIndex}),n.set(d,p)}if(u.patch||u.pts.length<2)continue;let l=tl(u.pts);for(let f of[0,u.pts.length-1]){let m=u.pts[f],h=u.pts[f===0?1:f-1],d=m.x-h.x,p=m.y-h.y,y=Math.hypot(d,p);y<1e-6||t.push({sectionId:c.sectionId,floorIndex:c.floorIndex,curve:l,row:u,point:m,x:m.x*E,z:m.y*E,dx:d/y,dz:p/y})}}let r=new Map;t.forEach((c,u)=>{let l=o(c.x,c.z),f=r.get(l)??[];f.push(u),r.set(l,f)});let i=(c,u)=>{let l=Math.floor(c/Gt),f=Math.floor(u/Gt);return[-1,0,1].flatMap(m=>[-1,0,1].map(h=>`${l+m},${f+h}`))},s=new Map;t.forEach((c,u)=>{let l=-1,f=1/0,m=!1;for(let h of i(c.x,c.z))for(let d of r.get(h)??[]){let p=t[d];if(c.sectionId===p.sectionId&&c.row.blockId===p.row.blockId||c.floorIndex!==p.floorIndex||Math.abs(c.row.y-p.row.y)>.05)continue;let y=p.x-c.x,g=p.z-c.z,M=Math.hypot(y,g);if(M<lt*2+.45||M>Gt)continue;let P=c.curve&&p.curve&&Math.hypot(c.curve.x-p.curve.x,c.curve.z-p.curve.z)<=.05&&Math.abs(c.curve.radius-p.curve.radius)<=.05,R=Math.min((y*c.dx+g*c.dz)/M,(-y*p.dx-g*p.dz)/M);(P?R<.8:R<.98)||!P&&(Math.abs(y*c.dz-g*c.dx)>.15||Math.abs(y*p.dz-g*p.dx)>.15)||(M<f-.02?(l=d,f=M,m=!1):Math.abs(M-f)<=.02&&(m=!0))}l>=0&&!m&&s.set(u,l)});let a=[];for(let[c,u]of s){if(c>=u||s.get(u)!==c)continue;let l=t[c],f=t[u],m=Math.hypot(f.x-l.x,f.z-l.z),h=(f.x-l.x)/m,d=(f.z-l.z)/m,p=!1;for(let g of i((l.x+f.x)/2,(l.z+f.z)/2))for(let M of n.get(g)??[]){if(M.floor!==l.floorIndex||Math.abs(M.y-l.row.y)>.75)continue;let P=(M.x-l.x)*h+(M.z-l.z)*d,R=Math.abs((M.x-l.x)*d-(M.z-l.z)*h);P>.01&&P<m-.01&&R<jt+lt&&(p=!0)}if(p)continue;let y=(g,M)=>({x:(l.x+h*g-d*M)/E,y:(l.z+d*g+h*M)/E});a.push({sections:[l.sectionId,f.sectionId],blocks:[l.row.blockId,f.row.blockId],floorIndex:l.floorIndex,ends:[l.point,f.point],clearWidthM:m-2*lt,heightM:(l.row.y+f.row.y)/2,outline:[y(lt,-jt),y(m-lt,-jt),y(m-lt,jt),y(lt,jt)]})}return a}var nl=/^#?([\da-f]{3}|[\da-f]{6})$/i;function wr(e){let t=e.replace("#","");return{r:parseInt(t.slice(0,2),16),g:parseInt(t.slice(2,4),16),b:parseInt(t.slice(4,6),16)}}function ol(e){let t=nl.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 re(e){let t=ol(e);return t?[t[0]/255,t[1]/255,t[2]/255]:null}function rl(e){return .2126*e[0]+.7152*e[1]+.0722*e[2]}function oe(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 Be(e,t){let n=rl(e);return oe(e,[n,n,n],t)}function Er({r:e,g:t,b:n}){let o=e/255,r=t/255,i=n/255,s=Math.max(o,r,i),a=Math.min(o,r,i),c=(s+a)/2;if(s===a)return{h:0,s:0,l:c};let u=s-a,l=c>.5?u/(2-s-a):u/(s+a),f;return s===o?f=((r-i)/u+(r<i?6:0))/6:s===r?f=((i-o)/u+2)/6:f=((o-r)/u+4)/6,{h:f,s:l,l:c}}var un=["available","held","sold","selected","dimmed"];function Ar(e){let t=un.indexOf(e);return t<0?0:t}var _r={available:[.24,.82,.52],held:[.34,.39,.45],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};var qn={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]},Jn={top:[.05,.06,.08],bottom:[.1,.12,.15]};function Y(e,t){return[Math.min(1,e[0]*t),Math.min(1,e[1]*t),Math.min(1,e[2]*t)]}var il=.15,sl=1.6;function vr(e){return Dn(e??1,il,sl)}var al=.15,cl=.9,ll=1.76;function Cr(e){return!!e&&e[0]*.2126+e[1]*.7152+e[2]*.0722>.55?{zenith:[.36,.58,.84],horizon:[.82,.88,.94]}:{zenith:[.05,.08,.15],horizon:[.3,.38,.5]}}function ul(){return{background:{top:[...Jn.top],bottom:[...Jn.bottom]},sky:Cr(null),structure:qn,seatStates:{..._r},seatScale:1,materials:{seat:null,shell:null,roughness:.78}}}function fl(e){return!!e&&e[0]*.2126+e[1]*.7152+e[2]*.0722>.55?{deck:"#c9ccc8",fascia:"#b4bab8",shell:"#c3c9c8",roughness:.87}:{deck:"#69747b",fascia:"#3e4d58",shell:"#526572",roughness:.87}}function kr(e){let t=ul();e??={};let n=re(e.background);if(n){t.background={top:Y(n,cl),bottom:Y(n,ll)},t.sky=Cr(n);let a={};for(let[u,l]of Object.entries(qn))a[u]=oe(l,n,al);n[0]*.2126+n[1]*.7152+n[2]*.0722>.55&&(a.ground=Y(n,.86)),t.structure=a}let o=re(e.selectionColor)??re(e.accent);o&&(t.seatStates={...t.seatStates,selected:o});let r=e.seatScale;typeof r=="number"&&Number.isFinite(r)&&(t.seatScale=vr(r));let i=Object.fromEntries(Object.entries(e.venue3d??{}).filter(([,a])=>a!=null)),s={...fl(n),...i};if(s){let a=re(s.deck),c=re(s.fascia);a&&(t.structure={...t.structure,tierTop:a,gaTop:a}),c&&(t.structure={...t.structure,tierWall:c,gaWall:c}),t.materials.seat=re(s.seat),t.materials.shell=re(s.shell),typeof s.roughness=="number"&&Number.isFinite(s.roughness)&&(t.materials.roughness=Math.min(1,Math.max(0,s.roughness)))}return t}function Or(e,t){let n=[];for(let o of t)n.push(...e.seatStates[o]);return n}function Tr(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 gt(e,t){return e.minX<=t.maxX&&t.minX<=e.maxX&&e.minY<=t.maxY&&t.minY<=e.maxY}var eo=[{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"}],Xd=new Map(eo.map(e=>[e.key,e]));var ml={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 fn(e){let t=e?.[0];return t&&ml[t]||"#3b82f6"}var hl=[{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"}],Ud=new Map(hl.map(e=>[e.key,e]));var dl=["reference-focal","bar","entrance","exit","restroom","screen","sound","concession","coat","wall","rail","suite","obstruction"],Kd=new Set(dl);var mn=["#e69f00","#56b4e9","#009e73","#f0e442","#0072b2","#d55e00","#cc79a7"],Lr="#a4508b";var Qd={facilities:Lr,"food-drink":mn[5],navigation:mn[2],accessibility:mn[4]};var qd={minDiameterPx:12,glyphScale:.66,ringRatio:1/14,largeFromPx:24};var de=e=>{let t=Math.round(e*100)/100;return Object.is(t,-0)?"0":String(t)},Pt=e=>`${de(e[0])} ${de(e[1])}`,St=(e,t,n,o)=>[e+n*Math.cos(o*Math.PI/180),t+n*Math.sin(o*Math.PI/180)];function Wr(e){let t=`M${Pt(e.from)}`;for(let n of e.segs)t+=n.arc?`A${de(n.arc.r)} ${de(n.arc.r)} 0 ${n.arc.large} ${n.arc.sweep} ${Pt(n.to)}`:`L${Pt(n.to)}`;return`${t}Z`}function pe(e){let t=[e.from,...e.segs.map(o=>o.to)],n=[];for(let o=e.segs.length-1;o>=0;o--){let r=e.segs[o].arc;n.push({to:t[o],arc:r&&{...r,sweep:r.sweep?0:1}})}return{from:t[t.length-1],segs:n}}function be(e,t,n){let o={r:n,large:0,sweep:1};return{from:[e-n,t],segs:[{to:[e+n,t],arc:o},{to:[e-n,t],arc:o}]}}function q(e,t,n,o,r){let i=Math.min(r,n/2,o/2),s={r:i,large:0,sweep:1};return i<=0?ge([[e,t],[e+n,t],[e+n,t+o],[e,t+o]]):{from:[e+i,t],segs:[{to:[e+n-i,t]},{to:[e+n,t+i],arc:s},{to:[e+n,t+o-i]},{to:[e+n-i,t+o],arc:s},{to:[e+i,t+o]},{to:[e,t+o-i],arc:s},{to:[e,t+i]},{to:[e+i,t],arc:s}]}}function ge(e){let t=0;for(let o=0;o<e.length;o++){let[r,i]=e[o],[s,a]=e[(o+1)%e.length];t+=r*a-s*i}let n=t>0?e:[...e].reverse();return{from:n[0],segs:[...n.slice(1).map(o=>({to:o})),{to:n[0]}]}}function le(e,t,n){let o=n/2,r=t[0]-e[0],i=t[1]-e[1],s=Math.hypot(r,i);if(s<1e-6)return be(e[0],e[1],o);let a=[i/s*o,-r/s*o],c={r:o,large:0,sweep:1},u=[e[0]+a[0],e[1]+a[1]];return{from:u,segs:[{to:[t[0]+a[0],t[1]+a[1]]},{to:[t[0]-a[0],t[1]-a[1]],arc:c},{to:[e[0]-a[0],e[1]-a[1]]},{to:u,arc:c}]}}function ye(e,t,n=!1){let o=[],r=n?e.length:e.length-1;for(let i=0;i<r;i++)o.push(le(e[i],e[(i+1)%e.length],t));return o}function Fe(e,t,n,o,r,i){let s=i/2,a=r-o>180?1:0,c={r:s,large:0,sweep:1},u=St(e,t,n+s,o);return{from:u,segs:[{to:St(e,t,n+s,r),arc:{r:n+s,large:a,sweep:1}},{to:St(e,t,n-s,r),arc:c},{to:St(e,t,n-s,o),arc:{r:n-s,large:a,sweep:0}},{to:u,arc:c}]}}var ee=(...e)=>e.flat().map(Wr).join(" "),Ee=(e,t,n)=>`M${de(e-n)} ${de(t)}a${de(n)} ${de(n)} 0 1 0 ${de(2*n)} 0a${de(n)} ${de(n)} 0 1 0 ${de(-2*n)} 0`,Xe=(e,t,n,o,r)=>Wr(q(e,t,n,o,r)),dn=e=>`M${e.map(Pt).join("L")}`,hn=(e,t,n,o,r)=>`M${Pt(St(e,t,n,o))}A${de(n)} ${de(n)} 0 ${r-o>180?1:0} 1 ${Pt(St(e,t,n,r))}`;function xt(e,t,n,o=1){let r=i=>[i[0]*o+t,i[1]*o+n];return{head:[e.head[0]*o+t,e.head[1]*o+n,e.head[2]*o],limbs:e.limbs.map(i=>i.map(r)),arcs:e.arcs?.map(([i,s,a,c,u])=>[i*o+t,s*o+n,a*o,c,u])}}function Ht(e){return[Ee(e.head[0],e.head[1],e.head[2]),...e.limbs.map(dn),...(e.arcs??[]).map(([t,n,o,r,i])=>hn(t,n,o,r,i))].join(" ")}function Mt(e,t=2.6){return[be(e.head[0],e.head[1],e.head[2]+1),...e.limbs.flatMap(n=>ye(n,t)),...(e.arcs??[]).map(([n,o,r,i,s])=>Fe(n,o,r,i,s,t-.2))]}var ut={head:[10,4,2],limbs:[[[10,8.2],[10,14],[15.5,14],[18,19.5],[20.5,19.5]],[[10,10.6],[14.5,10.6]]],arcs:[[9.5,16,5.5,35,235]]},Br={head:[10.6,3.9,1.9],limbs:[[[9.6,7.8],[7.6,12]],[[5.4,8.2],[9.4,8.4],[12.8,10]],[[4,15.6],[7.6,12],[11,13.6],[10.6,16.4]]]},Fr={cx:12,hr:1.9,arm:5,leg:3,r:2},Nr={cx:12,hr:1.9,sh:2.2,hem:6,leg:3},Dr={cx:6.2,hr:1.8,arm:3.6,leg:2.2,r:1.4},Gr={cx:17.8,hr:1.8,sh:1.4,hem:4.1,leg:2.2};function jr({cx:e,hr:t,arm:n,leg:o,r}){return[Ee(e,2+t,t),`M${de(e-n+r)} 8.5H${de(e+n-r)}a${r} ${r} 0 0 1 ${r} ${r}V15H${de(e+o)}V22H${de(e-o)}V15H${de(e-n)}V${de(8.5+r)}a${r} ${r} 0 0 1 ${r} ${-r}Z`,`M${de(e)} 15V22`].join(" ")}function Hr({cx:e,hr:t,arm:n,leg:o,r}){return[be(e,2+t,t+1),q(e-n-.5,7.8,2*n+1,7.7,r+.5),q(e-o-.5,13,o,9.5,1),q(e+.5,13,o,9.5,1)]}function Vr({cx:e,hr:t,sh:n,hem:o,leg:r}){return[Ee(e,2+t,t),dn([[e-n,8.5],[e+n,8.5],[e+o,16],[e+r,16],[e+r,22],[e-r,22],[e-r,16],[e-o,16]])+"Z",`M${de(e)} 16V22`].join(" ")}function Xr({cx:e,hr:t,sh:n,hem:o,leg:r}){return[be(e,2+t,t+1),ge([[e-n-.6,7.8],[e+n+.6,7.8],[e+o+.9,16.8],[e-o-.9,16.8]]),q(e-r-.1,15,r-.4,7.5,.9),q(e+.5,15,r-.4,7.5,.9)]}var pl=[[14.6,1.5],[5.2,13.6],[11,13.6],[9.4,22.5],[18.8,10.4],[13,10.4]],bl="M8.5 3.5 4 5.5l-1.5 5 3 1 1-2v11h11v-11l1 2 3-1-1.5-5-4.5-2c-.5 1.5-1.8 2.5-3.5 2.5s-3-1-3.5-2.5Z",yl="M12 2.5S5 9.5 5 14.5a7 7 0 0 0 14 0c0-5-7-12-7-12Z",gl="M2.5 21.5h19V3h-6v6.2H9.2v6.2H2.5Z",Ur=[[9,3],[15,3],[15,9],[21,9],[21,15],[15,15],[15,21],[9,21],[9,15],[3,15],[3,9],[9,9]],xl={from:[3.8,5.2],segs:[{to:[20.2,5.2]},{to:[22,7],arc:{r:1.8,large:0,sweep:1}},{to:[22,9.7]},{to:[22,14.3],arc:{r:2.3,large:0,sweep:0}},{to:[22,17]},{to:[20.2,18.8],arc:{r:1.8,large:0,sweep:1}},{to:[3.8,18.8]},{to:[2,17],arc:{r:1.8,large:0,sweep:1}},{to:[2,14.3]},{to:[2,9.7],arc:{r:2.3,large:0,sweep:0}},{to:[2,7]},{to:[3.8,5.2],arc:{r:1.8,large:0,sweep:1}}]},Ml={from:[12,1.6],segs:[{to:[20.4,4.9]},{to:[20.4,11.2]},{to:[12,22.4],arc:{r:13,large:0,sweep:1}},{to:[3.6,11.2],arc:{r:13,large:0,sweep:1}},{to:[3.6,4.9]},{to:[12,1.6]}]};function Kr(e,t,n){return{from:[e-n,t],segs:[{to:[e+n,t],arc:{r:n,large:0,sweep:1}},{to:[e-n,t]}]}}var Yr={head:[13.2,4.3,2.2],limbs:[[[12.6,8.6],[11.2,15],[17.8,18.4],[9.4,18.4]],[[12.4,9.8],[16,14.4]]]},Sl=[[6,10.5],[15,10.5],[16.5,7],[18.5,5.5],[20,6.5],[21.5,8.5],[19.5,10],[18,12],[18,19],[16.5,19],[15.5,14],[9.5,14],[8.5,19],[7,19],[6.5,13]],Pl=[[5.4,9.8],[14.6,9.8],[16.1,6.4],[18.4,4.6],[20.5,5.9],[22.4,8.6],[19.9,10.6],[18.8,12.3],[18.8,19.8],[15.8,19.8],[15,14.8],[10.1,14.8],[9.2,19.8],[6.2,19.8],[5.6,13.2]],to=[{key:"restroom-men",label:"Men's restroom",group:"facilities",path:jr(Fr),solid:ee(Hr(Fr))},{key:"restroom-women",label:"Women's restroom",group:"facilities",path:Vr(Nr),solid:ee(Xr(Nr))},{key:"restroom-accessible",label:"Accessible restroom",group:"facilities",path:[Xe(2.5,2.5,19,19,3.5),Ht(xt(ut,4.6,4.3,.66))].join(" "),solid:ee(Mt(ut)),solidLarge:ee(q(1.5,1.5,21,21,4.5),pe(q(3.9,3.9,16.2,16.2,2.6)),Mt(xt(ut,4.9,4.7,.62),2.2))},{key:"first-aid",label:"First aid",group:"facilities",path:dn(Ur)+"Z",solid:ee(ge(Ur.map(([e,t])=>[e+(e-12)*.08,t+(t-12)*.08])))},{key:"coat-check",label:"Coat check",group:"facilities",path:"M10 6.5a2 2 0 1 1 2 2V10 M12 10 3.4 16.9a1.4 1.4 0 0 0 .9 2.6h15.4a1.4 1.4 0 0 0 .9-2.6Z",solid:ee(Fe(12,6.2,2.2,180,450,2.3),le([12,8.4],[12,10.5],2.3),ye([[12,10.2],[3.2,18.8],[20.8,18.8]],2.8,!0))},{key:"atm",label:"ATM / cash",group:"facilities",path:[Xe(2,6,20,12,2),Ee(12,12,2.75),"M6 12h.01 M18 12h.01"].join(" "),solid:ee(q(1.5,5.5,21,13,2.4),pe(be(12,12,3.2)))},{key:"info",label:"Info point",group:"facilities",path:[Ee(12,12,9.5),"M10.8 11H12v5.8 M12 7.6h.01"].join(" "),solid:ee(be(12,4.9,2.4),q(10.3,9.2,3.4,12.3,1),q(8.2,9.2,4,3,1),q(8.2,18.5,7.6,3,1))},{key:"lost-found",label:"Lost & found",group:"facilities",path:[Ee(10.5,10.5,7.5),"M16 16l5.5 5.5","M8.4 8.4a2.1 2.1 0 1 1 3 1.9c-.6.4-.9.8-.9 1.6 M10.5 14.6h.01"].join(" "),solid:ee(Fe(12,7.6,4.2,180,405,3.4),ye([[14.97,10.57],[12,13],[12,15]],3.4),be(12,20,2.1))},{key:"restrooms",label:"Toilets",group:"facilities",path:[jr(Dr),Vr(Gr)].join(" "),solid:ee(Hr(Dr),Xr(Gr))},{key:"charging",label:"Charging point",group:"facilities",path:[Xe(6,2,12,20,2.5),"M13.2 6.2 9.6 12h4.8l-3.6 5.8"].join(" "),solid:ee(ge(pl))},{key:"smoking",label:"Smoking area",group:"facilities",path:[Xe(2,14.5,14.5,4,1),"M6.5 14.5v4","M15.5 11.5c0-1.4 1.5-1.9 1.5-3.4s-1.5-2-1.5-3.4 M19 11.5c0-1.4 1.5-1.9 1.5-3.4s-1.5-2-1.5-3.4"].join(" "),solid:ee(q(1.5,14,4.2,5,1.2),q(6.8,14,10.4,5,1.2),ye([[15.9,11.4],[17.3,8.9],[15.9,6.4],[17.1,3.9]],2.2),ye([[19.6,11.4],[21,8.9],[19.6,6.4],[20.8,3.9]],2.2))},{key:"no-smoking",label:"No smoking",group:"facilities",path:[Ee(12,12,9.5),"M5.3 5.3l13.4 13.4","M5.5 10.5h13v3h-13Z"].join(" "),solid:ee(be(12,12,10.6),pe(be(12,12,8)),le([6,6],[18,18],2.8),q(5,10.4,3,3.2,.6),q(16,10.4,3,3.2,.6))},{key:"food",label:"Food",group:"food-drink",path:"M5 2.5V8a2.5 2.5 0 0 0 5 0V2.5 M7.5 2.5v19 M18.5 13.5h-2c-1.3 0-2-1-2-2.5 0-4 1.5-7 4-8.5v19",solid:ee(ye([[4.9,2.6],[4.9,8]],2.2),ye([[10.1,2.6],[10.1,8]],2.2),ye([[7.5,2.6],[7.5,8]],2.2),Fe(7.5,8,2.6,0,180,2.2),le([7.5,10],[7.5,21.4],3),ge([[19.4,2.2],[19.4,14.2],[16.2,14.2],[14.1,12],[14.1,9.4],[15.2,5.8],[17.3,3.3]]),le([18,13],[18,21.4],3))},{key:"bar",label:"Bar",group:"food-drink",path:"M3.5 3.5h17L12 13Z M6.2 6.5h11.6 M12 13v7.5 M8 20.5h8",solid:ee(ge([[2.8,3],[21.2,3],[12,13.6]]),le([12,12],[12,20.6],2.8),le([7.4,21],[16.6,21],2.8))},{key:"coffee",label:"Caf\xE9 / coffee",group:"food-drink",path:"M4 9h12v4.5a5.5 5.5 0 0 1-5.5 5.5h-1A5.5 5.5 0 0 1 4 13.5Z M16 10.5h1.2a2.75 2.75 0 0 1 0 5.5H16 M8 3v3 M12 3v3 M3 21.5h14",solid:ee({from:[3.4,8.4],segs:[{to:[16.6,8.4]},{to:[16.6,13.4]},{to:[11,19.4],arc:{r:5.8,large:0,sweep:1}},{to:[9,19.4]},{to:[3.4,13.4],arc:{r:5.8,large:0,sweep:1}},{to:[3.4,8.4]}]},Fe(17.2,13.25,2.5,270,450,2.4),le([7.8,2.6],[7.8,5.6],2.4),le([12.2,2.6],[12.2,5.6],2.4),le([2.6,21.6],[17.4,21.6],2.6))},{key:"water",label:"Water / drinks",group:"food-drink",path:yl,solid:"M12 1.2S4 8.9 4 14.5a8 8 0 0 0 16 0c0-5.6-8-13.3-8-13.3Z"},{key:"merch",label:"Merch / shop",group:"food-drink",path:bl,solid:"M8.4 2.8 3.5 5l-1.9 6 4.2 1.4.4-.8v9.4h11.6v-9.4l.4.8 4.2-1.4-1.9-6-4.9-2.2c-.4 1.5-1.8 2.6-3.6 2.6s-3.2-1.1-3.6-2.6Z"},{key:"screen",label:"Screen",group:"facilities",path:[Xe(2,3.5,20,13.5,2),"M12 17v3.5 M8 20.5h8","M10 7.8v5.9l5-2.95Z"].join(" "),solid:ee(q(1.5,3,21,14.4,2.4),pe(ge([[9.6,6.7],[16,10.2],[9.6,13.7]])),q(10.6,16.5,2.8,4,0),le([7.4,21],[16.6,21],2.8))},{key:"sound-booth",label:"Sound booth",group:"facilities",path:["M6 3v9 M6 16v5 M12 3v3 M12 10v11 M18 3v10 M18 17v4",Ee(6,14,2),Ee(12,8,2),Ee(18,15,2)].join(" "),solid:ee(le([6,2.8],[6,21.2],1.8),le([12,2.8],[12,21.2],1.8),le([18,2.8],[18,21.2],1.8),q(3.2,11.6,5.6,4.8,1.4),q(9.2,5.6,5.6,4.8,1.4),q(15.2,12.6,5.6,4.8,1.4))},{key:"entrance",label:"Entrance",group:"navigation",path:"M11 7V3.5a1 1 0 0 1 1-1h8a1 1 0 0 1 1 1v17a1 1 0 0 1-1 1h-8a1 1 0 0 1-1-1V17 M2.5 12h13.5 M12.5 8.5 16 12l-3.5 3.5",solid:ee(ye([[11,6.5],[11,2.6],[21,2.6],[21,21.4],[11,21.4],[11,17.5]],2.6),le([2.8,12],[13.5,12],3.2),ge([[12.6,7.8],[18,12],[12.6,16.2]]))},{key:"exit",label:"Exit",group:"navigation",path:"M13 7V3.5a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v17a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V17 M8 12h13.5 M18 8.5l3.5 3.5-3.5 3.5",solid:ee(ye([[13,6.5],[13,2.6],[3,2.6],[3,21.4],[13,21.4],[13,17.5]],2.6),le([7.2,12],[17,12],3.2),ge([[16.2,7.8],[21.6,12],[16.2,16.2]]))},{key:"emergency-exit",label:"Emergency exit",group:"navigation",path:[Ht(xt(Br,-2,1.4,1.15)),"M15.5 13h6 M19 10.5l2.5 2.5-2.5 2.5"].join(" "),solid:ee(Mt(xt(Br,-2,1.4,1.15),2.7),le([15.6,13],[19.5,13],2.8),ge([[18.4,9.4],[22.4,13],[18.4,16.6]]))},{key:"stairs",label:"Stairs",group:"navigation",path:gl,solid:"M1.5 22.5h21V2h-7.8v6.4H8.4v6.4H1.5Z"},{key:"elevator",label:"Elevator",group:"navigation",path:[Xe(3.5,2.5,17,19,2.5),"M8.5 9.5 12 5.5l3.5 4Z M8.5 14.5l3.5 4 3.5-4Z"].join(" "),solid:ee(ge([[12,1.6],[19.6,10.2],[4.4,10.2]]),ge([[4.4,13.8],[19.6,13.8],[12,22.4]]))},{key:"parking",label:"Parking",group:"navigation",path:[Xe(3,3,18,18,3),"M9.5 17V7h3.75a3 3 0 0 1 0 6H9.5"].join(" "),solid:"M6.5 21V3H12a5.5 5.5 0 0 1 0 11h-1.9v7Z M10.1 6.6v3.8H12a1.9 1.9 0 0 0 0-3.8Z"},{key:"wheelchair",label:"Wheelchair access",group:"accessibility",path:Ht(ut),solid:ee(Mt(ut))},{key:"hearing",label:"Hearing assistance",group:"accessibility",path:["M4 9a6 6 0 1 1 12 0c0 3-1.8 4.3-3 5.2-1.1.8-1.6 1.7-1.6 3.1a3.6 3.6 0 0 1-6.2 2.1","M7.5 9a2.5 2.5 0 0 1 5 0c0 1.2-.7 1.9-1.6 2.5","M18.5 5.5a6.5 6.5 0 0 1 0 8"].join(" "),solid:ee(Fe(10,9,6,180,380,3),ye([[15.64,11.05],[12.8,14.3],[11.5,17.2]],3),Fe(8.2,17.2,3.3,0,150,3),Fe(10,9,2.2,180,400,2.4),Fe(13.38,9.5,6.5,322,398,2.6))},{key:"box-office",label:"Box office / tickets",group:"navigation",path:"M3 7.5A1.5 1.5 0 0 1 4.5 6h15A1.5 1.5 0 0 1 21 7.5V10a2 2 0 0 0 0 4v2.5a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 3 16.5V14a2 2 0 0 0 0-4Z M15 6v2 M15 11v2 M15 16v2",solid:ee(xl,pe(q(14.1,7,1.8,2.2,.9)),pe(q(14.1,10.9,1.8,2.2,.9)),pe(q(14.1,14.8,1.8,2.2,.9)))},{key:"escalator",label:"Escalator",group:"navigation",path:"M2.5 17H7l9-9h5.5v4h-4l-9 9h-6Z M11 4.5h.01 M11 8.2v3.3",solid:ee(ge([[2,16.4],[6.8,16.4],[15.8,7.4],[22,7.4],[22,12.6],[17.8,12.6],[8.8,21.6],[2,21.6]]),be(11,4.3,2.3),le([11,8],[11,11],2.6))},{key:"ramp",label:"Ramp",group:"navigation",path:"M2.5 19.5h19v-10Z M4.5 13.2 14 8.2 M10.53 7.76 14 8.2l-1.6 3.11",solid:ee(ge([[1.6,20.4],[22.4,20.4],[22.4,8.6]]),le([4.2,13.4],[13.2,8.6],2.6),ge([[15.4,7.5],[13.16,11.84],[10.56,6.88]]))},{key:"taxi",label:"Taxi / rideshare",group:"navigation",path:["M9.5 2.5h5V5h-5Z M6.5 11 8 7h8l1.5 4",Xe(3.5,11,17,6,2),"M6.5 17v2.5 M17.5 17v2.5 M7 14h.01 M17 14h.01"].join(" "),solid:ee(q(9,1.8,6,3.4,.8),ge([[6,11.4],[7.6,6.4],[16.4,6.4],[18,11.4]]),q(2.8,10.6,18.4,7,2.2),pe(be(6.8,14,1.3)),pe(be(17.2,14,1.3)),q(4.8,16,3.6,5.2,1.2),q(15.6,16,3.6,5.2,1.2))},{key:"transit",label:"Bus / transit",group:"navigation",path:[Xe(4.5,2.5,15,16,3),"M4.5 10.5h15 M9 5.5h6 M7.5 18.5V21 M16.5 18.5V21 M8 14.5h.01 M16 14.5h.01"].join(" "),solid:ee(q(4,2,16,17,3.2),pe(q(6.2,5.8,11.6,5,1)),pe(be(8,14.5,1.3)),pe(be(16,14.5,1.3)),q(6,17,3.4,5,1.2),q(14.6,17,3.4,5,1.2))},{key:"bike-parking",label:"Bike parking",group:"navigation",path:[Ee(6,14.5,4),Ee(18,14.5,4),"M6 14.5 9 7.5h6.5L18 14.5 M9 7.5l2.5 7H6 M11.5 14.5l4-7 M7.5 6h3 M15.5 7.5 15 5.5h2"].join(" "),solid:ee(be(6,14.5,4.9),pe(be(6,14.5,2.7)),be(18,14.5,4.9),pe(be(18,14.5,2.7)),ye([[6,14.5],[9,7.5],[15.5,7.5],[18,14.5]],2.2),ye([[9,7.5],[11.5,14.5],[15.5,7.5]],2.2),le([6,14.5],[11.5,14.5],2.2),le([7.2,5.8],[10.6,5.8],2.2),ye([[15.4,7.3],[15,5.4],[17.2,5.4]],2.2))},{key:"meeting-point",label:"Meeting point",group:"navigation",path:["M9.5 2.5 12 5l2.5-2.5 M9.5 21.5 12 19l2.5 2.5 M2.5 9.5 5 12l-2.5 2.5 M21.5 9.5 19 12l2.5 2.5",Ee(10,9.6,1.5),Ee(14,9.6,1.5),"M7.5 15.5a2.5 2.5 0 0 1 5 0 M11.5 15.5a2.5 2.5 0 0 1 5 0"].join(" "),solid:ee(ye([[9.4,2.4],[12,5],[14.6,2.4]],2.6),ye([[9.4,21.6],[12,19],[14.6,21.6]],2.6),ye([[2.4,9.4],[5,12],[2.4,14.6]],2.6),ye([[21.6,9.4],[19,12],[21.6,14.6]],2.6),be(9.7,9.3,2.2),be(14.3,9.3,2.2),Kr(9.7,16,3),Kr(14.3,16,3))},{key:"security",label:"Security / bag check",group:"facilities",path:"M12 2.5 19.5 5.5v6c0 4.6-3.2 8.4-7.5 10-4.3-1.6-7.5-5.4-7.5-10v-6Z M8.5 12l2.5 2.5 4.5-5",solid:ee(Ml,pe(ge([[7.4,12.2],[9,10.6],[10.9,12.5],[15,8.4],[16.6,10],[10.9,15.7]])))},{key:"lockers",label:"Lockers",group:"facilities",path:[Xe(3.5,2.5,17,19,1.5),"M12 2.5v19 M6 6h3 M15 6h3 M9.5 11.5v2.5 M14.5 11.5v2.5"].join(" "),solid:ee(q(3,2,8.4,20,1.4),pe(q(5,5,4.4,1.7,.8)),pe(q(8.6,10.8,1.5,3.8,.7)),q(12.6,2,8.4,20,1.4),pe(q(14.6,5,4.4,1.7,.8)),pe(q(13.9,10.8,1.5,3.8,.7)))},{key:"baby-change",label:"Baby change",group:"facilities",path:"M10 6.5l.8-3.3a1.2 1.2 0 0 1 2.4 0l.8 3.3 M8.5 6.5h7 M9.5 6.5l-.9 2.2a3 3 0 0 0-.1.9V19a2.5 2.5 0 0 0 2.5 2.5h2a2.5 2.5 0 0 0 2.5-2.5V9.6a3 3 0 0 0-.1-.9l-.9-2.2 M8.5 12.5h3 M8.5 16h3",solid:ee(ge([[9.6,6.2],[10.6,1.8],[13.4,1.8],[14.4,6.2]]),q(7.6,5.4,8.8,2.6,1),q(7.8,7.4,8.4,15,2.6),pe(q(7.8,11.8,3.4,1.5,0)),pe(q(7.8,15.4,3.4,1.5,0)))},{key:"prayer-room",label:"Prayer room",group:"facilities",path:[Ht(Yr),"M3 21.5h18"].join(" "),solid:ee(Mt(Yr),q(2.4,20.2,19.2,2.6,1.3))},{key:"quiet-room",label:"Quiet room",group:"facilities",path:"M4 9h3.5l5-4v14l-5-4H4Z M15.5 9.5l5 5 M20.5 9.5l-5 5",solid:ee(ge([[2.6,8.4],[7.2,8.4],[13,3.6],[13,20.4],[7.2,15.6],[2.6,15.6]]),le([15.4,9.2],[20.8,14.8],2.8),le([20.8,9.2],[15.4,14.8],2.8))},{key:"wifi",label:"Wi-Fi",group:"facilities",path:[hn(12,19,11.5,218,322),hn(12,19,7.5,218,322),hn(12,19,3.5,218,322),"M12 19h.01"].join(" "),solid:ee(Fe(12,19.2,11,218,322,2.8),Fe(12,19.2,6.9,218,322,2.8),be(12,19.2,2.2))},{key:"vip-lounge",label:"VIP lounge",group:"facilities",path:["M6.5 11V7a2 2 0 0 1 2-2h7a2 2 0 0 1 2 2v4","M3.5 11.5a1.5 1.5 0 0 1 3 0V14h11v-2.5a1.5 1.5 0 0 1 3 0v6h-17Z","M5.5 17.5V20 M18.5 17.5V20"].join(" "),solid:ee(q(6,4,12,8.5,2.2),q(2.4,9.6,4.6,9,2.2),q(17,9.6,4.6,9,2.2),q(6,13.2,12,5.4,.6),le([5,18],[5,20.6],2.4),le([19,18],[19,20.6],2.4))},{key:"accessible-entrance",label:"Accessible entrance",group:"accessibility",path:[Ht(xt(ut,.3,5,.62)),"M12.5 3.5H20a1 1 0 0 1 1 1v15a1 1 0 0 1-1 1h-7.5"].join(" "),solid:ee(Mt(xt(ut,.3,5,.62),2.2),ye([[13,2.8],[21.2,2.8],[21.2,21.2],[13,21.2]],2.6))},{key:"assistance-dog",label:"Assistance-dog area",group:"accessibility",path:[dn(Sl)+"Z","M6 10.8 3.5 7.5","M10.5 10.5V6h4.5l1 2.5"].join(" "),solid:ee(ge(Pl),le([6.2,11],[3.2,7.2],2.4),ye([[10.5,11],[10.5,5.6],[15.2,5.6],[16.2,8.2]],2.2))}],Jd=new Map(to.map(e=>[e.key,e]));var zr=to;var Il=new Map(zr.map(e=>[e.key,e]));function no(e){return e?Il.get(e):void 0}var np=zr.map(e=>e.key);function Vt(e){if(e.length<3)return e.map(i=>({...i}));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.map(i=>({...i})):t.map(i=>({...i}))}var Pi=je(require("polygon-clipping"),1);var K={top:1,wallBottom:.58,bottomCap:.4};function ft(e,t){if(!e)return t;let n=Y(Be(e,.4),.62);return oe(t,n,.22)}function Zr(e,t){return e?oe(t,Y(Be(e,.25),.74),.62):t}function $r(e,t){return e?oe(t,Y(Be(e,.08),.9),.82):t}function Qr(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,c=0,u=0,l=0;for(let[f,m]of s){let h=re(n.get(f));h&&(a+=h[0]*m,c+=h[1]*m,u+=h[2]*m,l+=m)}l>0&&r.set(i,[a/l,c/l,u/l])}return r}function qr(e,t){return re(e.color)??t.get(e.logicalSectionId??e.id)??null}var so=je(require("polygon-clipping"),1);var io=je(require("polygon-clipping"),1);var ei=[{key:"circle",label:"Standard seat",shortLabel:"Standard",useCase:"General assigned seating",group:"general",path:null,bounds:null,mark: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},mark:{x:12,y:10,radius:6}},{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},mark:{x:12,y:10,radius:4.5}},{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},mark:{x:12,y:5,radius:3}},{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},mark:{x:12,y:7.5,radius:5.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},mark:{x:12,y:8,radius: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},mark:{x:12,y:9.25,radius:6.5}},{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},mark:{x:12,y:12.25,radius:4.75}}],ti=ei.map(e=>e.key),Rl=new Map(ei.map(e=>[e.key,e]));function Jr(e){return typeof e=="string"&&Rl.has(e)}function ni(e,t){return Jr(e)?e:Jr(t?.seatGlyph)?t.seatGlyph:"circle"}var Re={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,body:10,head:11},wl=.44,El=.15,Al=.3,_l=.24;function oi(e){return e===void 0||!Number.isFinite(e)||e<=0?_l:Math.min(Al,Math.max(El,e*wl))}var vl=.05,ri=.45,Cl=ri+vl,kl=.92;var cp=[{part:Re.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:Re.pad,min:[-1,.36,-.95],max:[1,ri,1]},{part:Re.back,min:[-1,Cl,-1],max:[1,kl,-.72]},{part:Re.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:Re.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:Re.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:Re.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:Re.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:Re.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:Re.leg,min:[.62,0,.48],max:[.82,.37,.7]}],lp=[{part:Re.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:Re.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:Re.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:Re.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:Re.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}];function ii(e,t,n,o){let r=new Float32Array(t),i=u=>e[u*3],s=u=>e[u*3+2],a=0,c=(u,l)=>{let f=l-u;for(let m=u;m<l;m++){let[h,d]=o(m),p=h-i(m),y=d-s(m);if(f>=2){let g=Math.max(u,m-1),M=Math.min(l-1,m+1),P=i(M)-i(g),R=s(M)-s(g),x=Math.hypot(P,R);if(x>1e-6){let b=-R/x,I=P/x;b*p+I*y<0&&(b=-b,I=-I),p=b,y=I}}r[m]=p===0&&y===0?0:Math.atan2(p,y)}};for(let u=1;u<=t;u++)(u===t||n(u)!==n(a))&&(c(a,u),a=u);return r}var pn=.22;var Ol=.42;function Tl(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 d of e)d.x<o&&(o=d.x),d.y<r&&(r=d.y),d.x>i&&(i=d.x),d.y>s&&(s=d.y);let a=Math.max(i-o,1e-6),c=Math.max(s-r,1e-6),u=Math.max(Math.sqrt(a*c/t),1e-6),l=Math.max(1,Math.ceil(a/u)+1),f=Math.max(1,Math.ceil(c/u)+1),m=new Map,h=(d,p)=>{let y=Math.min(l-1,Math.max(0,Math.floor((d-o)/u)));return Math.min(f-1,Math.max(0,Math.floor((p-r)/u)))*l+y};for(let d=0;d<t;d++){let p=h(e[d].x,e[d].y),y=m.get(p);y?y.push(d):m.set(p,[d])}for(let d=0;d<t;d++){let p=e[d],y=Math.min(l-1,Math.max(0,Math.floor((p.x-o)/u))),g=Math.min(f-1,Math.max(0,Math.floor((p.y-r)/u))),M=1/0;for(let P=1;P<=4;P++){for(let R=g-P;R<=g+P;R++)if(!(R<0||R>=f))for(let x=y-P;x<=y+P;x++){if(x<0||x>=l||P>1&&Math.abs(R-g)<P&&Math.abs(x-y)<P)continue;let b=m.get(R*l+x);if(b)for(let I of b){if(I===d)continue;let w=Math.hypot(e[I].x-p.x,e[I].y-p.y);w<M&&(M=w)}}if(Number.isFinite(M)&&M<=P*u)break}n[d]=M}return n}function Ll(e){let t=e.eyeHeightM;return Number.isFinite(t)?Math.max(0,t-He):0}function si(e,t,n,o,r,i){let s=e.length,a=new Float32Array(s*3),c=new Float32Array(s),u=new Float32Array(s*3),l=new Float32Array(s),f=new Float32Array(s),m=new Float32Array(s),h=new Float32Array(s),d=new Float32Array(s*3),p=new Map,y=Tl(e);for(let g=0;g<s;g++){let M=e[g],R=(n?.seatPitchU(g)??y[g])*E;l[g]=Number.isFinite(R)?Math.max(.06,Math.min(pn,R*Ol)):pn,f[g]=oi(Number.isFinite(R)?R:void 0);let x=ni(M.glyph,{seatGlyph:i?.get(M.categoryKey)});m[g]=ti.indexOf(x),h[g]=M.wheelchairSpaceType==="no-seat"?0:1,a[g*3]=M.x*E,a[g*3+1]=n?n.seatDeckY(g):Ll(M),a[g*3+2]=M.y*E,c[g]=Ar(t?t(M):"available");let b=re(r?.get(M.categoryKey)??"#6e7bff")??[.43,.48,1];if(u[g*3]=b[0],u[g*3+1]=b[1],u[g*3+2]=b[2],M.accessibility?.length){let I=re(fn(M.accessibility));I&&(d[g*3]=I[0],d[g*3+1]=I[1],d[g*3+2]=I[2])}p.set(M.id,g)}return{count:s,iPosition:a,iState:c,iCategory:u,iMaxRadius:l,iRing:d,idToIndex:p,iChairWidth:f,iGlyph:m,iPhysicalSeat:h,iFloor:o??new Float32Array(s),iSection:new Float32Array(s).fill(-1),iYaw:new Float32Array(s)}}var ui=je(require("earcut"),1);var Bl=.58,ai=.01,Te=pn*1.5*Oe,Fl=.5,Nl=.6;function Dl(e,t){let n=e.length,o=[];for(let s=0;s<n;s++){let a=e[Math.max(0,s-1)],c=e[Math.min(n-1,s+1)],u=c.x-a.x,l=c.y-a.y,f=Math.hypot(u,l);if(f<1e-9){o.push([0,0]);continue}u/=f,l/=f,o.push([-l,u])}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 Gl(e,t){if(e.length<2||t<=0)return[...e];let n=[...e],o=(s,a)=>{let c=a.x-s.x,u=a.y-s.y,l=Math.hypot(c,u)||1;return{x:c/l,y:u/l}},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 ci=Math.PI/12;function jl(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 fi(e,t){if(!e.length||!(t>0))return[];let n=jl(e),o=(a,c,u,l)=>{let f=u-c;for(;f<0;)f+=Math.PI*2;for(;f>Math.PI*2;)f-=Math.PI*2;let m=Math.max(1,Math.ceil(f/ci)),h=t/Math.cos(f/m/2);for(let d=0;d<=m;d++){let p=c+f*d/m;l.push({x:a.x+Math.cos(p)*h,y:a.y+Math.sin(p)*h})}};if(n.length<3){let a=0,c=0;for(let h of n)a+=h.x,c+=h.y;a/=n.length||1,c/=n.length||1;let u=0;for(let h of n)u=Math.max(u,Math.hypot(h.x-a,h.y-c));let l=[],f=Math.max(3,Math.ceil(Math.PI*2/ci)),m=(u+t)/Math.cos(Math.PI/f);for(let h=0;h<f;h++){let d=h/f*Math.PI*2;l.push({x:a+Math.cos(d)*m,y:c+Math.sin(d)*m})}return l}let r=n.length,i=[];for(let a=0;a<r;a++){let c=n[a],u=n[(a+1)%r];i.push(Math.atan2(-(u.x-c.x),u.y-c.y))}let s=[];for(let a=0;a<r;a++)o(n[a],i[(a+r-1)%r],i[a],s);return bi(s)}function Hl(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,c=s.y-i.y,u=a*a+c*c,l=u>1e-12?((t-i.x)*a+(n-i.y)*c)/u:0;l<0?l=0:l>1&&(l=1);let f=Math.hypot(t-(i.x+l*a),n-(i.y+l*c));f<o&&(o=f)}return o}function bn(e){let t=e.map(r=>{let i=0,s=0;for(let u of r.pts)i+=u.x,s+=u.y;let a=r.pts.length||1;i/=a,s/=a;let c=0;for(let u of r.pts){let l=Math.hypot(u.x-i,u.y-s);l>c&&(c=l)}return{cx:i,cy:s,rad:c}}),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,c=null;for(let l of i){let f=1/0;for(let m=0;m<e.length;m++){if(m===r||Math.abs(e[m].y-e[r].y)<.001)continue;let h=t[m],d=Math.hypot(l.x-h.cx,l.y-h.cy)-h.rad;if(d>=f&&d>=a)continue;let p=Hl(e[m].pts,l.x,l.y);p<f&&(f=p),e[m].depth<e[r].depth&&p<a&&(a=p,c=e[m].y)}Number.isFinite(f)&&f>0&&s.push(f)}s.sort((l,f)=>l-f);let u=s.length?s[Math.floor(s.length/2)]:1;o.push({pitch:u,belowY:c})}return o}function mi(e,t,n,o){let r=e[t],i=r.pts.length>=2?[...r.pts]:r.pts.length===1?(()=>{let l=r.pts[0],f=l.x-o.x,m=l.y-o.y,h=Math.hypot(f,m)||1;f/=h,m/=h;let d=Math.max(n[t].pitch,.001)*.5;return[{x:l.x+m*d,y:l.y-f*d},{x:l.x-m*d,y:l.y+f*d}]})():[];if(i.length<2)return null;let s=0,a=0;for(let l=1;l<i.length;l++){let f=Math.hypot(i[l].x-i[l-1].x,i[l].y-i[l-1].y);f>1e-6&&(s+=f,a++)}let c=a>0?s/a:0,u=Gl(i,Math.max(c*Nl,Te));return{pts:u,nrm:Dl(u,o),front:Math.max(n[t].pitch*Bl,Te),back:Math.max(n[t].pitch*Fl,Te)}}var It=1.5,hi=.3;function oo(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,c=-1;for(let f=1;f<e.length-1;f++){let m=e[f],h=s>1e-12?Math.abs((m.x-n.x)*i-(m.y-n.y)*r)/s:Math.hypot(m.x-n.x,m.y-n.y);h>a&&(a=h,c=f)}if(a<=t||c<0)return[n,o];let u=oo(e.slice(0,c+1),t),l=oo(e.slice(c),t);return[...u.slice(0,-1),...l]}function di(e,t){if(e.length<4)return e;let n=oo([...e,e[0]],t);return n.pop(),n.length>=3?n:e}function Vl(e){let t=e.map((o,r)=>{let i=e[(r+1)%e.length];return{a:o,b:i,i:r,minX:Math.min(o.x,i.x),maxX:Math.max(o.x,i.x),minY:Math.min(o.y,i.y),maxY:Math.max(o.y,i.y)}}).sort((o,r)=>o.minX-r.minX),n=(o,r,i)=>(r.x-o.x)*(i.y-o.y)-(r.y-o.y)*(i.x-o.x);for(let o=0;o<t.length;o++){let r=t[o];for(let i=o+1;i<t.length&&t[i].minX<=r.maxX;i++){let s=t[i];if(!(Math.abs(r.i-s.i)===1||Math.abs(r.i-s.i)===e.length-1||r.maxY<s.minY||s.maxY<r.minY)&&n(r.a,r.b,s.a)*n(r.a,r.b,s.b)<=0&&n(s.a,s.b,r.a)*n(s.a,s.b,r.b)<=0)return!0}}return!1}function pi(e,t,n){if(e.length<2)return[];let o=n??bn(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 M of s){let P=e[M].patch;P&&P.length>=3?i.push({outline:[...P],holes:[],topY:e[M].y}):a.push(M)}if(!a.length)continue;a.sort((M,P)=>e[M].depth-e[P].depth);let u=a.map(M=>mi(e,M,o,t)).filter(M=>M!==null);if(!u.length)continue;let l=(M,P)=>({x:M.pts[P].x-M.nrm[P][0]*(M.front+It),y:M.pts[P].y-M.nrm[P][1]*(M.front+It)}),f=(M,P)=>({x:M.pts[P].x+M.nrm[P][0]*(M.back+It),y:M.pts[P].y+M.nrm[P][1]*(M.back+It)}),m=u[0],h=u[u.length-1],d=[];for(let M=0;M<m.pts.length;M++)d.push(l(m,M));for(let M of u)d.push(f(M,M.pts.length-1));for(let M=h.pts.length-1;M>=0;M--)d.push(f(h,M));for(let M=u.length-1;M>=0;M--)d.push(l(u[M],0));let p=bi(d),y=1/0;for(let M of a)e[M].y<y&&(y=e[M].y);if(!Number.isFinite(y))continue;if(p.length>=3&&Math.abs(Ae(p))>1e-6&&u.every(M=>{let P=M.pts[Math.floor(M.pts.length/2)];return _e(p,P.x,P.y)})&&!Vl(p)){i.push({outline:di(p,hi),holes:[],topY:y});continue}for(let M of Xl(u))i.push({outline:M,holes:[],topY:y})}return i}function Xl(e){let t=[];for(let n of e){let o=[],r=[],i=n.front+It,s=n.back+It;for(let c=0;c<n.pts.length;c++){let u=n.pts[c],l=n.nrm[c];o.push([u.x-l[0]*i,u.y-l[1]*i]),r.push([u.x+l[0]*s,u.y+l[1]*s])}let a=[...o,...r.reverse()];a.length<3||(a.push(a[0]),t.push([a]))}if(!t.length)return[];try{let n=io.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(([c,u])=>({x:c,y:u})),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(di(i,hi))}return o}catch{return[]}}function bi(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 ro=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(!_e(n,r.x,r.y)){o=!1;break}if(o)return!0}return!1}};function li(e,t,n,o,r,i){if(o.length<3)return;if(n.containsAll(o)){let u=[0,1,0],l=o[0];for(let f=1;f+1<o.length;f++){let m=o[f],h=o[f+1];e.tri([l.x*E,r,l.y*E],[m.x*E,r,m.y*E],[h.x*E,r,h.y*E],u,i)}return}let s=o.map(u=>[u.x,u.y]);s.push(s[0]);let a;try{a=io.default.intersection([s],t)}catch{return}let c=[0,1,0];for(let u of a){if(!u.length||u[0].length<4)continue;let l=u[0],f=[],m=[];for(let d=0;d<l.length-1;d++)f.push(l[d][0],l[d][1]),m.push([l[d][0],l[d][1]]);if(m.length<3)continue;let h=(0,ui.default)(f,void 0,2);for(let d=0;d<h.length;d+=3){let p=m[h[d]],y=m[h[d+1]],g=m[h[d+2]];e.tri([p[0]*E,r,p[1]*E],[y[0]*E,r,y[1]*E],[g[0]*E,r,g[1]*E],c,i)}}}function yi(e,t,n,o,r,i,s){if(t.length<2)return;let a=s??bn(t),c=[0,1,0],u=i&&i.length>=3?[[...i.map(h=>[h.x,h.y]),[i[0].x,i[0].y]]]:null,l=i&&i.length>=3?new ro([[...i]]):null,f=h=>{e.setMaterial(2),h(),e.setMaterial(0)},m=h=>{e.setMaterial(3),h(),e.setMaterial(0)};for(let h=0;h<t.length;h++){let d=t[h];if(d.patch&&d.patch.length>=3){let x=[...d.patch],b=a[h].belowY??o;if(m(()=>{if(u&&l)li(e,u,l,x,d.y,r.tread);else{let I=x[0];for(let w=1;w+1<x.length;w++){let S=x[w],C=x[w+1];e.tri([I.x*E,d.y,I.y*E],[S.x*E,d.y,S.y*E],[C.x*E,d.y,C.y*E],c,r.tread)}}}),d.y>b+ai){let I=0,w=0;for(let S of x)I+=S.x,w+=S.y;I/=x.length,w/=x.length,f(()=>{for(let S=0;S<x.length;S++){let C=x[S],O=x[(S+1)%x.length],L=O.x-C.x,v=O.y-C.y,A=Math.hypot(L,v);if(A<1e-6)continue;let _=v/A,k=-L/A;(C.x-I)*_+(C.y-w)*k<0&&(_=-_,k=-k);let F=[_,0,k],T=[C.x*E,d.y,C.y*E],B=[O.x*E,d.y,O.y*E],D=[C.x*E,b,C.y*E],H=[O.x*E,b,O.y*E];e.tri(T,B,H,F,r.riser),e.tri(T,H,D,F,r.riser)}})}continue}let p=mi(t,h,a,n);if(!p)continue;let{pts:y,nrm:g,front:M,back:P}=p,R=a[h].belowY??o;for(let x=0;x+1<y.length;x++){let b=y[x],I=y[x+1],w=g[x],S=g[x+1];if(Math.hypot(I.x-b.x,I.y-b.y)<1e-6||w[0]===0&&w[1]===0||S[0]===0&&S[1]===0)continue;let C=[(b.x-w[0]*M)*E,d.y,(b.y-w[1]*M)*E],O=[(I.x-S[0]*M)*E,d.y,(I.y-S[1]*M)*E],L=[(b.x+w[0]*P)*E,d.y,(b.y+w[1]*P)*E],v=[(I.x+S[0]*P)*E,d.y,(I.y+S[1]*P)*E];if(m(()=>{u&&l?li(e,u,l,[{x:b.x-w[0]*M,y:b.y-w[1]*M},{x:I.x-S[0]*M,y:I.y-S[1]*M},{x:I.x+S[0]*P,y:I.y+S[1]*P},{x:b.x+w[0]*P,y:b.y+w[1]*P}],d.y,r.tread):(e.tri(C,O,v,c,r.tread),e.tri(C,v,L,c,r.tread))}),d.y>R+ai){let A=[C[0],R,C[2]],_=[O[0],R,O[2]],k=[-w[0],0,-w[1]];f(()=>{e.tri(C,O,_,k,r.riser),e.tri(C,_,A,k,r.riser)})}}}}function Ul(e,t){let n=e.eventConfigurationIds;return!n?.length||!!t&&n.includes(t)}function gi(e,t){return e.filter(n=>n.type!=="shape"||Ul(n,t))}function xi(e,t){let n=e.focalPoint??{x:0,y:0};return e.floors?.length?e.floors.map((o,r)=>({objects:gi(o.objects,t),focal:{x:(o.focalPoint??n).x,y:(o.focalPoint??n).y},baseHeightM:o.baseHeightM??0,index:r})):[{objects:gi(e.objects,t),focal:n,baseHeightM:0,index:0}]}var Kl={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Ye(e){return Tr(e)??Kl}function Mi(e,t){let n=Le(e.outline,Te),o=Ye(n),r=t.filter(s=>s!==e&&s.outline&&s.outline.length>=3&>(o,Ye(s.outline)));if(!r.length)return[n];let i=s=>{let a=s.map(c=>[c.x,c.y]);return a.push(a[0]),a};try{let s=so.default.difference([i(n)],...r.map(c=>[i(c.outline)])),a=[];for(let c of s){if(!c.length)continue;let u=c[0].map(([l,f])=>({x:l,y:f}));if(u.length>1){let l=u[0],f=u[u.length-1];Math.abs(l.x-f.x)<1e-9&&Math.abs(l.y-f.y)<1e-9&&u.pop()}u.length>=3&&a.push(u)}return a.length?a:[n]}catch{return[n]}}function Si(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=so.default.intersection([n(i.outline)],o.flat())}catch{r.push(i);continue}for(let a of s){if(!a.length)continue;let c=a[0].map(([u,l])=>({x:u,y:l}));if(c.length>1){let u=c[0],l=c[c.length-1];Math.abs(u.x-l.x)<1e-9&&Math.abs(u.y-l.y)<1e-9&&c.pop()}c.length>=3&&r.push({outline:c,holes:[],topY:i.topY})}}return r.length?r:e}function Yl(e,t){return e===void 0||t===void 0?!0:Math.abs(e-t)<.001}var yn=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(t,n){let o=t.map(c=>[c.x,c.y]);if(o.length<3)return[];o.push(o[0]);let r=Ye(t),i=this.rings.filter((c,u)=>gt(r,this.boxes[u])&&Yl(n,this.levels[u])),s=[[o]];if(i.length)try{s=Pi.default.difference([o],...i).map(u=>u.map(l=>l.map(([f,m])=>[f,m])))}catch{s=[[o]]}this.rings.push([o]),this.boxes.push(r),this.levels.push(n);let a=[];for(let c of s){if(!c.length)continue;let u=c[0].map(([l,f])=>({x:l,y:f}));if(u.length>1){let l=u[0],f=u[u.length-1];Math.abs(l.x-f.x)<1e-9&&Math.abs(l.y-f.y)<1e-9&&u.pop()}u.length>=3&&a.push(u)}return a}};function Rt(e,t,n=e){if(!t)return e;let o=1/0,r=-1/0,i=1/0,s=-1/0;for(let m of n)o=Math.min(o,m.x),r=Math.max(r,m.x),i=Math.min(i,m.y),s=Math.max(s,m.y);let a=(o+r)/2,c=(i+s)/2,u=t*Math.PI/180,l=Math.cos(u),f=Math.sin(u);return e.map(m=>{let h=m.x-a,d=m.y-c;return{x:a+h*l-d*f,y:c+h*f+d*l}})}function Ii(e){let t=Yo(e);return!t.length||!e.points?.length?[]:t.map(n=>Rt(n,e.rotation,e.points))}function ie(e){let t=null;if(e.kind==="polygon"&&e.points&&e.points.length>=3)return Rt(Qt(e,4),e.rotation,e.points);if(e.kind==="rect"&&e.width&&e.height&&(t=Dt(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=ln(n,o,e.width/2,e.height/2)}return t?Rt(t,e.rotation):null}function Ne(e){let t=e.role??"",o=t==="stage"?{kind:"stage",heightM:ir(e.stageKind)}:{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}}[t]??{kind:"plate",heightM:.25};return{...o,heightM:e.heightM??o.heightM}}var Wl=.08,zl=30,Zl=.015;function $l(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[o],s=t[r];i.y>e.y!=s.y>e.y&&e.x<(s.x-i.x)*(e.y-i.y)/(s.y-i.y)+i.x&&(n=!n)}return n}function Ri(e,t){let n=ie(e)??(e.points?.length?Rt(e.points,e.rotation):null),o=Ne(e),i=!e.role&&o.kind==="plate"&&e.heightM===void 0&&!!n&&Math.abs(Ae(n))*$**2>=zl?Zl:o.heightM;if(!n)return{topOffsetM:i,supportOffsetM:0};if(o.kind!=="plate"&&o.kind!=="stage")return{topOffsetM:i,supportOffsetM:0};let s=1/0,a=1/0,c=-1/0,u=-1/0;for(let h of n)s=Math.min(s,h.x),a=Math.min(a,h.y),c=Math.max(c,h.x),u=Math.max(u,h.y);let l=i,f=0,m=1e-6*Math.max(1,c-s,u-a);for(let h of t)c>h.minX&&s<h.maxX&&u>h.minY&&a<h.maxY&&l<=h.topOffsetM+1e-6&&(l=h.topOffsetM+Wl),s>=h.minX-m&&c<=h.maxX+m&&a>=h.minY-m&&u<=h.maxY+m&&(!h.poly||n.every(y=>$l(y,h.poly)||Ql(y,h.poly,m)))&&(f=Math.max(f,h.topOffsetM));return e.fill&&e.fill!=="none"&&e.fill!=="transparent"&&t.push({minX:s,minY:a,maxX:c,maxY:u,topOffsetM:l,poly:n}),{topOffsetM:l,supportOffsetM:Math.min(f,l)}}function Ql(e,t,n){for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[r],s=t[o],a=s.x-i.x,c=s.y-i.y,u=a*a+c*c,l=u?Math.max(0,Math.min(1,((e.x-i.x)*a+(e.y-i.y)*c)/u)):0;if(Math.hypot(e.x-(i.x+l*a),e.y-(i.y+l*c))<=n)return!0}return!1}function et(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function ve(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 we(e,t,n){return[et(e[0],e[1],t),et(e[0],e[1],n),et(e[3],e[2],n),et(e[3],e[2],t)]}function Xt(e,t,n){return[et(e[0],e[3],t),et(e[1],e[2],t),et(e[1],e[2],n),et(e[0],e[3],n)]}function ne(e,t,n,o,r,i,s){z(e,t,s?.length?s:void 0,()=>n,o,r,i,K)}var ql=.8,Jl=.6,eu=2;function tt(e,t){if(!t.length)return null;let n=[],o=0;for(let s of e.objects){if(s.type!=="shape"||s.role!=="wall")continue;let a=ie(s)??[],c=wi(a)/2;!(c>0)||ou(a)/c*E>eu||(n.push(...a),o+=c)}if(n.length<3)return null;let r=Vt(n);if(r.length<3||o<wi(r)*Jl)return null;let i=0;for(let s of t)ru(s,r)&&(i+=1);return i>=t.length*ql?r:null}var gn=6,tu=5,nu=8;function Ei(e){return Math.max(nu,(Number.isFinite(e)?e:0)+tu)}function wt(e){let t=0,n=0,o=0;for(let r=0;r<e.length;r++){let i=e[r],s=e[(r+1)%e.length],a=i.x*s.y-s.x*i.y;t+=a,n+=(i.x+s.x)*a,o+=(i.y+s.y)*a}if(Math.abs(t)<1e-9){let r=0,i=0;for(let s of e)r+=s.x,i+=s.y;return{x:r/Math.max(1,e.length),y:i/Math.max(1,e.length)}}return{x:n/(3*t),y:o/(3*t)}}function ou(e){let t=0;for(let n=0;n<e.length;n++){let o=e[n],r=e[(n+1)%e.length];t+=o.x*r.y-r.x*o.y}return Math.abs(t)/2}function wi(e){let t=0;for(let n=0;n<e.length;n++){let o=e[n],r=e[(n+1)%e.length];t+=Math.hypot(r.x-o.x,r.y-o.y)}return t}function ru(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[o],s=t[r];i.y>e.y!=s.y>e.y&&e.x<(s.x-i.x)*(e.y-i.y)/(s.y-i.y)+i.x&&(n=!n)}return n}function iu(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 su(e,t){if(!e.length)return null;let n=0,o=0,r=0;for(let h of e)n+=h.x,o+=h.y,r+=Math.hypot(h.x-t.x,h.y-t.y);let i=e.length;n/=i,o/=i,r/=i;let s=e[0],a=-1;for(let h of e){let d=Math.hypot(h.x-n,h.y-o);d>a&&(a=d,s=h)}let c=s.x-n,u=s.y-o,l=Math.hypot(c,u);l>1e-9?(c/=l,u/=l):(c=1,u=0);let f=[...e].sort((h,d)=>(h.x-n)*c+(h.y-o)*u-((d.x-n)*c+(d.y-o)*u)),m=0;for(let h of f){let d=Math.hypot(h.x-n,h.y-o);d>m&&(m=d)}return{pts:f,cx:n,cy:o,radius:m,depth:r}}function Ai(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],c=a.x-s.x,u=a.y-s.y,l=c*c+u*u,f=l>1e-12?((t-s.x)*c+(n-s.y)*u)/l:0;f<0?f=0:f>1&&(f=1);let m=Math.hypot(t-(s.x+f*c),n-(s.y+f*u));m<r&&(r=m)}return r}var xn=8;function au(e,t,n){let o=new Array(xn).fill(1/0),r=new Array(xn).fill(-1);for(let l=0;l<e.length;l++){let f=e[l],m=Math.hypot(t-f.cx,n-f.cy)-f.radius;for(let h=0;h<xn;h++)if(m<o[h]){for(let d=xn-1;d>h;d--)o[d]=o[d-1],r[d]=r[d-1];o[h]=m,r[h]=l;break}}let i=new Array(3).fill(1/0),s=new Array(3).fill(-1);for(let l of r){if(l<0)continue;let f=Ai(e[l],t,n);for(let m=0;m<3;m++)if(f<i[m]){for(let h=2;h>m;h--)i[h]=i[h-1],s[h]=s[h-1];i[m]=f,s[m]=l;break}}if(s[0]<0)return 0;if(i[0]<1e-6)return e[s[0]].depth;let a=i[0]*2.2,c=0,u=0;for(let l=0;l<3;l++){let f=s[l];if(f<0||i[l]>a)continue;let m=1/(i[l]*i[l]);c+=m*e[f].depth,u+=m}return u>0?c/u:e[s[0]].depth}function cu(e){let t=(o,r)=>au(e,o,r),n=(o,r)=>{let i=1/0,s=-1;for(let a=0;a<e.length;a++){let c=e[a];if(Math.hypot(o-c.cx,r-c.cy)-c.radius>=i)continue;let u=Ai(c,o,r);u<i&&(i=u,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 _i(e,t){let n=[];for(let o of e){let r=su(o.points,t);r&&n.push(r)}return n.length<2?iu(t):(n.sort((o,r)=>o.depth-r.depth),cu(n))}var nt=.06,lu=.05,Ci=.05,vi=.15,ao=25;function ki(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),c=new Map,u=[],l=new Set;for(let m=0;m<e.length;m+=1){let h=e[m];for(let d of h.objects){if(d.type==="table"&&l.add(d.id),d.type!=="section"||!d.outline||d.outline.length<3)continue;let p=Le(d.outline,Te);c.set(d.id,{section:d,unit:h,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),u.push({id:d.id,floorIndex:m,box:Ye(p),section:d,unit:h,outline:p})}}let f=new Map;for(let m of u){let h=f.get(m.floorIndex);h?h.push(m):f.set(m.floorIndex,[m])}for(let m=0;m<t.length;m++){let h=t[m],d=n?f.get(n[m])??[]:u,p=h.sectionId?d.find(g=>g.id===h.sectionId)??d.find(g=>g.section.logicalSectionId===h.sectionId&&Pe({x:h.x,y:h.y},g.outline,g.section.holes)):void 0,y=p?[p]:d;for(let g of y){if(n&&g.floorIndex!==n[m]||!p&&(h.x<g.box.minX||h.x>g.box.maxX||h.y<g.box.minY||h.y>g.box.maxY||!Pe({x:h.x,y:h.y},g.outline,g.section.holes)))continue;r[m]=g.id;let M=c.get(g.id);M.hasSeats=!0;let P=h.focalPoint??g.unit.focal,R=Math.hypot(h.x-P.x,h.y-P.y);R<M.frontU&&(M.frontU=R),M.seatIndices.push(m);let x=h.rowId||`__seat-${m}`,b=M.rows.get(x);b?b.push({x:h.x,y:h.y}):M.rows.set(x,[{x:h.x,y:h.y}]);break}}for(let[m,h]of c){let d=Qe(h.section,{floorBaseHeightM:h.unit.baseHeightM}),p=h.unit.baseHeightM,y=d.rake>0?Math.tan(d.rake*Math.PI/180):0,g=d.rake<=.01&&d.height<=p+.001,M=h.section.surfaceKind,P=M==="flat"?!0:M==="rakedRows"&&d.rake>.01?!1:g,R=h.hasSeats?Jt(m,t,h.seatIndices,h.unit.focal):{sectionId:m,rows:[],blockCount:0},b=R.rows.length<2?_i([...h.rows.values()].map(T=>({points:T})),h.unit.focal):null,I=1/0;if(b){if(h.hasSeats)for(let T of h.rows.values())for(let B of T){let D=b.depthAt(B.x,B.y);D<I&&(I=D)}if(!h.hasSeats||!Number.isFinite(I)){I=1/0;for(let T of h.section.outline){let B=b.depthAt(T.x,T.y);B<I&&(I=B)}}}let w=p+lu,S=Math.max(w,d.height),C=T=>{let B=Math.max(0,T-I)*$,D=Math.min(B*y,ao);return Math.max(w,d.height+D)},O=T=>{let B=Math.max(0,T)*$,D=Math.min(B*y,ao);return Math.max(w,d.height+D)},L=P?[]:R.rows.map(T=>({pts:T.pts,y:O(T.blockDepth),depth:T.blockDepth,blockId:T.blockId,...l.has(T.id)?{patch:fi(T.pts,Te)}:{}})),v=L.length?L[0].y:S,A=L.map(T=>{let B=T.patch&&T.patch.length>=3?T.patch:T.pts,D=0,H=0;for(let V of B)D+=V.x,H+=V.y;let N=B.length||1;D/=N,H/=N;let U=0;for(let V of B){let Z=Math.hypot(V.x-D,V.y-H);Z>U&&(U=Z)}return{cx:D,cy:H,rad:U}}),_=P?()=>S:L.length>=2?(T,B)=>{let D=1/0,H=v;for(let N=0;N<L.length;N++){let U=A[N];if(Math.hypot(T-U.cx,B-U.cy)-U.rad>=D)continue;let V=L[N].patch,Z=V&&V.length>=3?_e(V,T,B)?0:pt(V,T,B):pt(L[N].pts,T,B);Z<D&&(D=Z,H=L[N].y)}return H}:(T,B)=>b?C(b.depthAt(T,B)):S,k=[0,1,0],F=L.length>=2||P?()=>k:(T,B)=>{if(!b)return k;let D=b.depthAt(T,B);if(D<=I)return k;let H=(D-I)*$;if(H*y>=ao||d.height+H*y<=w)return k;let[N,U]=b.gradientAt(T,B);if(N===0&&U===0)return k;let V=1/Math.hypot(y,1);return[-N*y*V,V,-U*y*V]};if(!P)for(let T of R.rows){let B=O(T.blockDepth);for(let D of T.seatIndices)s[D]=B}for(let T of R.rows){let B=[];for(let V=1;V<T.pts.length;V++){let Z=Math.hypot(T.pts[V].x-T.pts[V-1].x,T.pts[V].y-T.pts[V-1].y);Z>1e-6&&B.push(Z)}B.sort((V,Z)=>V-Z);let D=B.length?B[Math.floor(B.length/2)]:1/0,H=1/0,N=T.pts[Math.floor(T.pts.length/2)];if(N)for(let V of R.rows){if(V===T||V.blockId!==T.blockId)continue;let Z=pt(V.pts,N.x,N.y);Z>1e-6&&Z<H&&(H=Z)}let U=Math.min(D,Math.max(H,D*.5));if(Number.isFinite(U)&&U>0)for(let V of T.seatIndices)a[V]=U}o.set(m,{sectionId:m,deckAt:_,normalAt:F,flat:P,bottomY:p,rowLevels:L,landingY:v})}for(let m=0;m<t.length;m++){let h=r[m],d=t[m];if(h){let g=s[m];i[m]=(g??o.get(h).deckAt(d.x,d.y))+vi;continue}let p=d.eyeHeightM,y=Number.isFinite(p)?Math.max(0,p-He):0;i[m]=d.kind==="booth"?y+nt+vi:y}return{bySection:o,seatOwner:r,seatDeckY:m=>i[m],seatPitchU:m=>a[m]}}function Et(e,t,n){if(e.length!==4||n<=t)return null;let o=ve(e),r=Math.hypot(o[1].x-o[0].x,o[1].y-o[0].y)*E,i=Math.hypot(o[3].x-o[0].x,o[3].y-o[0].y)*E;if(r<1e-6||i<1e-6)return null;let s=Math.min(.22/r,.16),a=Math.min(.28,(n-t)*.13),c=Math.min(.065/i,.2);return{quad:o,side:s,face:c,opening:we(o,s,1-s),openingTop:n-a}}function co(e,t,n){if(e.length!==4||n-t<=.2)return null;let o=ve(e),r=Math.hypot(o[1].x-o[0].x,o[1].y-o[0].y)*E;if(r<=1e-6)return null;let i=Math.min(.14,(n-t)*.08,r*.08),s=i/r,a=we(o,s,1-s);return{quad:o,side:s,trim:i,inner:a,panel:Xt(a,.15,.85),bottom:t+i,top:n-i}}function Oi(e,t,n,o){let r=co(e,t,n);if(!r)return;let{panel:i}=r,s=(M,P)=>({x:(M.x+P.x)/2,y:(M.y+P.y)/2}),a=s(i[0],i[1]),c=s(i[3],i[2]),u=Math.hypot(a.x-o.x,a.y-o.y)<=Math.hypot(c.x-o.x,c.y-o.y),[l,f]=u?[i[0],i[1]]:[i[3],i[2]],m=u?{x:a.x-c.x,y:a.y-c.y}:{x:c.x-a.x,y:c.y-a.y},h=Math.hypot(m.x,m.y);if(h<1e-6)return;-(f.y-l.y)*m.x+(f.x-l.x)*m.y<0&&([l,f]=[f,l]);let d=Math.min(.006,h*E*.05),p=m.x/h*d,y=m.y/h*d,g=(M,P)=>[M.x*E+p,P,M.y*E+y];return[g(l,r.bottom),g(f,r.bottom),g(l,r.top),g(f,r.top)]}var Li=je(require("polygon-clipping"),1);var Ti=je(require("polygon-clipping"),1);function We(e,t,n,o,r,i,s,a={}){let c=Ye(t),u=a.ao??K,l=r.flatMap(p=>{if(p.role!=="entrance"&&p.role!=="exit")return[];let y=ie(p);if(!y||y.length!==4||!gt(c,Ye(y)))return[];let g=a.portalBase??n,M=Et(y,g,g+Ne(p).heightM);if(!M)return[];let P=Math.min(o,M.openingTop);return P<=n?[]:[{poly:M.opening,height:P}]});if(!l.length)return!1;let f=p=>p.map(y=>[y.x,y.y]),m=[f(t),...(a.holes??[]).map(f)],h=[n,...new Set(l.map(p=>p.height)),o].sort((p,y)=>p-y),d=[];try{for(let p=1;p<h.length;p++){let y=h[p-1],g=h[p];if(g-y<1e-6)continue;let M=l.filter(R=>R.height>y+1e-6).map(R=>[f(R.poly)]),P=M.length?Ti.default.difference(m,...M):[m];d.push({low:y,high:g,polys:P})}}catch{return!1}for(let p of d)for(let y of p.polys){let[g,...M]=y.map(R=>R.map(([x,b])=>({x,y:b}))),P=R=>u.wallBottom+(u.top-u.wallBottom)*(R-n)/(o-n);z(e,g,M,()=>p.high,p.low,i,s,{...u,top:P(p.high),wallBottom:P(p.low)})}return!0}var lo={depthM:1.6,thicknessM:.35,minWallM:6};function Mn(e,t,n,o,r,i,s,a,c){let u=o-n;if(u<=0)return;let l=a&&(c??u)>=lo.minWallM?uu(t,a):null,f=l?o-lo.thicknessM:o,m=f-n,h=m<1.5?[[n,f,1]]:l?[[n,n+Math.min(.9,m*.18),.82],[n+Math.min(.9,m*.18),f,1]]:[[n,n+Math.min(.9,m*.18),.82],[n+Math.min(.9,m*.18),f-.1,1],[f-.1,f,1.1]],d=p=>K.wallBottom+(K.top-K.wallBottom)*(p-n)/u;for(let[p,y,g]of h){let M={...K,top:d(y),wallBottom:d(p)},P=Y(i,g),R=Y(s,g);We(e,t,p,y,r,P,R,{portalBase:n,ao:M})||z(e,t,void 0,()=>y,p,P,R,M)}for(let[p,...y]of l??[])z(e,p,y.length?y:void 0,()=>o,f,Y(i,1.12),Y(s,.78),K)}function uu(e,t){let n=lo.depthM/E,o=e.map(s=>{let a=t.x-s.x,c=t.y-s.y,u=Math.hypot(a,c)||1;return{x:s.x+a/u*n,y:s.y+c/u*n}}),r=s=>{let a=s.map(c=>[c.x,c.y]);return a.push(a[0]),a},i=[[r(e)],[r(o)]];for(let s=0;s<e.length;s++){let a=(s+1)%e.length;i.push([r([e[s],e[a],o[a],o[s]])])}try{let[s,...a]=i,c=Li.default.union(s,...a);return c.length?c.map(u=>u.map(l=>l.slice(0,-1).map(([f,m])=>({x:f,y:m})))):null}catch{return null}}function Bi(e){return e.route?.stepFree===!0&&(e.kind==="line"||e.kind==="polyline")}function Fi(e){let t=Number.isFinite(e)&&e>0?e:4;return[Math.max(6,t*2.6),Math.max(4,t*1.7)]}function Ni(e,t,n){let o=[];if(e.length<2||!(t>0)||!(n>=0))return o;let r=!0,i=t;for(let s=0;s<e.length-1;s+=1){let a=e[s],c=e[s+1],u=Math.hypot(c.x-a.x,c.y-a.y);if(u<1e-9)continue;let l=(c.x-a.x)/u,f=(c.y-a.y)/u,m=0;for(;m<u-1e-9;){let h=Math.min(i,u-m);r&&o.push([{x:a.x+l*m,y:a.y+f*m},{x:a.x+l*(m+h),y:a.y+f*(m+h)}]),m+=h,i-=h,i<=1e-9&&(r=!r,i=r?t:n)}}return o}function Ut(e,t,n){let o=re(t.stroke?.color),r=t.stroke?.width??0;if(!o||!Number.isFinite(r)||r<=0)return;let i=t.kind==="line"||t.kind==="polyline",s=i?Rt(t.points??[],t.rotation):ie(t);if(!s||s.length<2)return;let a=r*.5,c=Bi(t)?Ni(s,...Fi(r)):Array.from({length:i?s.length-1:s.length},(u,l)=>[s[l],s[(l+1)%s.length]]);for(let[u,l]of c){let f=Math.hypot(l.x-u.x,l.y-u.y);if(f<1e-6)continue;let m=-(l.y-u.y)/f*a,h=(l.x-u.x)/f*a,d=[(u.x+m)*E,n,(u.y+h)*E],p=[(l.x+m)*E,n,(l.y+h)*E],y=[(l.x-m)*E,n,(l.y-h)*E],g=[(u.x-m)*E,n,(u.y-h)*E];e.tri(d,p,y,[0,1,0],o),e.tri(d,y,g,[0,1,0],o)}}function Di(e){return e==="bar"||e==="concession"||e==="coat"||e==="restroom"}var At=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n});function Sn(e,t,n,o){let[r,i,s,a]=t?e:[e[3],e[2],e[1],e[0]];return[At(r,a,n),At(i,s,n),At(i,s,o),At(r,a,o)]}function Gi(e,t,n,o,r,i,s,a,c=!1){if(n.length!==4||r-o<.4)return!1;let u=w=>c?Math.min(w,r):w,l=ve(n),f=Math.hypot(l[3].x-l[0].x,l[3].y-l[0].y)*E;if(f<.4)return!1;let m=At(l[0],l[1],.5),h=At(l[3],l[2],.5),d=Math.hypot(m.x-a.x,m.y-a.y)<=Math.hypot(h.x-a.x,h.y-a.y),p=oe(s,[.92,.9,.86],.35),y=Y(i,.72),g=r-o;if(t==="restroom"){let w=Math.min(.18,g*.08);return ne(e,l,r-w,o,s,i),ne(e,l,r,r-w,p,p),!0}let M=o+Math.min(1.1,g),P=t==="coat"?1:Math.min(.5,.75/f),R=Sn(l,d,0,P);if(ne(e,R,M-.05,o,y,i),ne(e,R,M,M-.05,p,p),t==="coat"||f<1.2)return!0;if(t==="bar"){let w=Sn(l,d,Math.max(P+.2,1-.45/f),1),S=u(o+Math.max(Math.min(2.2,g*2),M-o+.6));return ne(e,w,S,o,s,y),!0}let x=Sn(l,d,Math.max(P+.25,.55),1),b=u(o+Math.max(2.6,M-o+1.4));if(b-.14<=M)return!0;ne(e,x,b-.14,o,s,i),ne(e,l,b,b-.14,p,y);let I=Math.min(.08,.1/Math.max(.1,Math.hypot(l[1].x-l[0].x,l[1].y-l[0].y)*E));for(let[w,S]of[[0,I],[1-I,1]])ne(e,Sn(we(l,w,S),d,0,Math.min(.08,.1/f)),b-.14,M,y,y);return!0}var fu=[.12,.38,.16],mu=[.72,.62,.45],hu=[.88,.93,.96],ji=[.95,.95,.94],du=[.66,.29,.22],uo={length:20.12,width:3.05},pu=.14,bu=9.76,ze=[.93,.94,.95],Pn=[.1,.11,.13],yu=[.45,.85,1.25],gu=1.45,Hi=.012,Vi=.004,xu=1.07,Mu=.15;function vt(e,t,n,o,r,i){e.setMaterial(i),z(e,t,n?[n.slice().reverse()]:void 0,()=>o,o-.004,r,r,K)}var Xi=(e,t)=>Je(e,t/E);function Ui(e,t,n){let o=t.x-e.x,r=t.y-e.y,i=Math.hypot(o,r);if(i<1e-9)return null;let s=-r/i*n,a=o/i*n;return[{x:e.x+s,y:e.y+a},{x:t.x+s,y:t.y+a},{x:t.x-s,y:t.y-a},{x:e.x-s,y:e.y-a}]}function Su(e,t,n,o){let r=t.map(i=>[i.x*E,n,i.y*E]);e.tri(r[0],r[1],r[2],[0,1,0],o),e.tri(r[0],r[2],r[3],[0,1,0],o)}function In(e,t,n,o,r,i){let s=n/E,a=[{x:t.x-s,y:t.y-s},{x:t.x+s,y:t.y-s},{x:t.x+s,y:t.y+s},{x:t.x-s,y:t.y+s}];z(e,a,void 0,()=>r,o,i,Y(i,.85),K)}function _t(e,t,n,o,r,i,s){let a=Ui(t,n,o/E);a&&z(e,a,void 0,()=>i,r,s,Y(s,.85),K)}function Rn(e){let t=ve(e),n={x:(t[0].x+t[2].x)/2,y:(t[0].y+t[2].y)/2},o=Math.hypot(t[1].x-t[0].x,t[1].y-t[0].y)||1,r=Math.hypot(t[3].x-t[0].x,t[3].y-t[0].y)||1,i={x:(t[1].x-t[0].x)/o,y:(t[1].y-t[0].y)/o},s={x:(t[3].x-t[0].x)/r,y:(t[3].y-t[0].y)/r};return{at:(c,u)=>({x:n.x+(i.x*c+s.x*u)/E,y:n.y+(i.y*c+s.y*u)/E}),lengthM:o*E,widthM:r*E}}function Ki(e,t,n){let o=sr(t);if(!o.length)return;let r=1/0,i=-1/0,s=1/0,a=-1/0;for(let P of t.points??[])r=Math.min(r,P.x),i=Math.max(i,P.x),s=Math.min(s,P.y),a=Math.max(a,P.y);let c=(t.rotation??0)*Math.PI/180,u=Math.cos(c),l=Math.sin(c),f=(r+i)/2,m=(s+a)/2,h=P=>c?{x:f+(P.x-f)*u-(P.y-m)*l,y:m+(P.x-f)*l+(P.y-m)*u}:P,d=Math.min(i-r,a-s)*E,p=Math.max(.04,Math.min(.3,d*.004))/E,y=0;e.setMaterial(0);for(let P of o){if(!P.fill)continue;let R=P.points.map(h);vt(e,R,null,n+Hi+y*Vi,re(P.fill)??ze,0),y++}let g=o.filter(P=>!(P.fill&&P.ink===P.fill)),M=[...new Set(g.map(P=>P.ink??tn))];for(let P of M){let R=n+Hi+y++*Vi,x=re(P)??ze;for(let b of g){if((b.ink??tn)!==P)continue;let I=b.points.map(h),w=b.closed?I.length:I.length-1;for(let S=0;S<w;S++){let C=Ui(I[S],I[(S+1)%I.length],p);C&&Su(e,C,R,x)}}}}function Yi(e,t,n,o,r){if(t.length<3)return!1;let i=o+.006,s=r??fu;if(n==="oval-cricket"){let a=t.reduce((x,b)=>x+b.x,0)/t.length,c=t.reduce((x,b)=>x+b.y,0)/t.length,u=x=>t.map(b=>({x:a+(b.x-a)*x,y:c+(b.y-c)*x})),l=8;for(let x=0;x<l;x++){let b=u(1-x/l),I=x===l-1?null:u(1-(x+1)/l);vt(e,b,I,i,Y(s,x%2?1.04:.96),4)}let f=t[0];for(let x of t)Math.hypot(x.x-a,x.y-c)>Math.hypot(f.x-a,f.y-c)&&(f=x);let m=Math.hypot(f.x-a,f.y-c)||1,h=(f.x-a)/m,d=(f.y-c)/m,p=-d,y=h,g=Math.min(1,2*m*E*pu/uo.length),M=uo.length*g/2/E,P=uo.width*g/2/E,R=[[-M,-P],[M,-P],[M,P],[-M,P]].map(([x,b])=>({x:a+h*x+p*b,y:c+d*x+y*b}));return vt(e,R,null,i+.004,mu,0),e.setMaterial(0),!0}if(n==="rink-hockey"){let a=Xi(t,Mu);return vt(e,a,null,i,hu,0),e.setMaterial(0),z(e,t,[a.slice().reverse()],()=>o+xu,o,ji,Y(ji,.9),K),!0}if(n==="ring-boxing"&&t.length===4){let{at:a}=Rn(t),c=[a(-3.05,-3.05),a(3.05,-3.05),a(3.05,3.05),a(-3.05,3.05)],u=[[.77,.19,.19],ze,[.17,.42,.69],ze];e.setMaterial(0),c.forEach((l,f)=>In(e,l,.07,o,o+gu,u[f]));for(let l of yu)for(let f=0;f<4;f++)_t(e,c[f],c[(f+1)%4],.025,o+l-.025,o+l+.025,ze);return!0}if(n==="court-tennis"&&t.length===4){let{at:a}=Rn(t);e.setMaterial(0),_t(e,a(0,-6.4),a(0,6.4),.015,o,o+.95,Pn),_t(e,a(0,-6.4),a(0,6.4),.03,o+.95,o+1,ze);for(let c of[-1,1])In(e,a(0,c*6.4),.05,o,o+1.07,Pn);return!0}if(n==="court-basketball"&&t.length===4){let{at:a,lengthM:c}=Rn(t),u=Math.min(14,c/2-.5);e.setMaterial(0);for(let l of[-1,1]){let f=a(l*(u+1.2),0),m=a(l*(u-1.2),0);In(e,f,.12,o,o+3.4,Pn),_t(e,f,m,.06,o+3.25,o+3.4,Pn),_t(e,a(l*(u-1.2),-.9),a(l*(u-1.2),.9),.03,o+2.9,o+3.95,ze)}return!0}if(n==="pitch-rugby"&&t.length===4){let{at:a,lengthM:c}=Rn(t),u=c*(50/120);e.setMaterial(0);for(let l of[-1,1]){for(let f of[-2.8,2.8])In(e,a(l*u,f),.07,o,o+12,ze);_t(e,a(l*u,-2.8),a(l*u,2.8),.06,o+2.94,o+3.06,ze)}return!0}if(n==="track-athletics"){let a=Xi(t,bu);return a.length<3?!1:(vt(e,t,a,i,du,0),vt(e,a,null,i,s,4),e.setMaterial(0),!0)}return!1}var Wi=[.19,.4,.15],Pu=.012,_n=2.4,Iu=1,Ru=.75,wu=.15;function De(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),c=n/2,u=o/2;return[[-c,-u],[c,-u],[c,u],[-c,u]].map(([l,f])=>({x:t.x+l*s-f*a,y:t.y+l*a+f*s}))}function Ji(e,t,n,o,r,i,s=!1){let a=De(t);if(a){if(s){let c=ft(o,r.boothTop),u=Ve([...a]);z(e,Le(u,Eu/E),[u.slice().reverse()],()=>n+.03,n,c,Y(c,.8),K);return}if(!(!t.points&&i&&_u(e,a,n,o,i))){if(!t.points&&i&&a.length===4){Au(e,a,n,o,i);return}z(e,a,void 0,()=>n+_n,n,ft(o,r.boothTop),r.boothWall,K)}}}var fo=1.1,zi=[.9,.9,.88],Eu=.1,wn=[.87,.87,.85],Zi=.08;function es(e,t){let n=c=>({x:(e[c].x+e[(c+1)%4].x)/2,y:(e[c].y+e[(c+1)%4].y)/2}),o=0,r=1/0;for(let c=0;c<4;c++){let u=n(c),l=Math.hypot(u.x-t.x,u.y-t.y);l<r&&(r=l,o=c)}let i=[0,1,2,3].map(c=>e[(o+c)%4]),s=(c,u,l)=>({x:c.x+(u.x-c.x)*l,y:c.y+(u.y-c.y)*l});return{q:i,part:(c,u,l,f)=>{let m=s(i[0],i[1],c),h=s(i[0],i[1],u),d=s(i[3],i[2],c),p=s(i[3],i[2],u);return[s(m,d,l),s(h,p,l),s(h,p,f),s(m,d,f)]},depthM:Math.hypot(i[3].x-i[0].x,i[3].y-i[0].y)*E,widthM:Math.hypot(i[1].x-i[0].x,i[1].y-i[0].y)*E}}function Au(e,t,n,o,r){let{q:i,part:s}=es(t,r),a=o??[.35,.42,.55],c=oe(a,[.78,.78,.77],.62),u=oe(a,[.95,.95,.94],.45);ne(e,i,n+nt,n,c,Y(c,.8)),ne(e,s(.05,.95,.72,.98),n+fo-.05,n+nt,u,Y(u,.8)),ne(e,s(.03,.97,.7,1),n+fo,n+fo-.05,zi,Y(zi,.9))}function _u(e,t,n,o,r){if(t.length!==4)return!1;let{q:i,part:s,depthM:a,widthM:c}=es(t,r);if(a<1||c<1)return!1;let u=o??[.35,.42,.55],l=oe(u,[.78,.78,.77],.62),f=n+_n,m=Zi/c,h=Zi/a;ne(e,i,n+nt,n,l,Y(l,.8)),ne(e,s(0,1,1-h,1),f,n+nt,wn,Y(wn,.9));for(let[y,g]of[[0,m],[1-m,1]])ne(e,s(y,g,0,1-h),f,n+nt,wn,Y(wn,.9));ne(e,s(m,1-m,0,Math.min(.5,.06/a)),f,f-.3,u,Y(u,.85));let d=Math.min(.4,.6/c),p=Math.min(.12,.3/a);return ne(e,s(.5-d,.5+d,.72-p,.72+p),n+Iu,n+nt,oe(u,[.95,.95,.94],.7),Y(u,.75)),!0}function vn(e){if(e.shape==="round"){let l=e.radius;return l?ln(e.center.x,e.center.y,l,l,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),c=t/2,u=n/2;return[[-c,-u],[c,-u],[c,u],[-c,u]].map(([l,f])=>({x:r.x+l*s-f*a,y:r.y+l*a+f*s}))}function ts(e,t,n,o,r,i=!0){let s=vn(t);if(!s)return;let a=s.reduce((m,h)=>m+h.x,0)/s.length,c=s.reduce((m,h)=>m+h.y,0)/s.length,u=m=>s.map(h=>({x:a+(h.x-a)*m,y:c+(h.y-c)*m})),l=i&&o?ft(o,r.tableTop):vu,f=n+Ru;z(e,s,void 0,()=>f,n+Cu,l,Y(l,.86),K),z(e,u(.12),void 0,()=>f+.12,f,$i,Y($i,.8),K)}var vu=[.93,.92,.89],$i=[.78,.66,.42],Cu=.25,Kt={armM:1.1,widthM:.28,insideM:1.4,low:.043,high:.048};function ku(e,t,n){let o=e.reduce((g,M)=>g+M.x,0)/4,r=e.reduce((g,M)=>g+M.y,0)/4,i=e[3].x-e[0].x,s=e[3].y-e[0].y,a=Math.hypot(i,s)||1;i/=a,s/=a,i*(t.x-o)+s*(t.y-r)<0&&(i=-i,s=-s);let c=-s,u=i,l=Kt.armM/E,f=Kt.widthM/E,m=a/2+Kt.insideM/E,h=n?-1:1,d=o+i*(m+(n?0:l)),p=r+s*(m+(n?0:l)),y=(g,M)=>({x:d+i*g*h+c*M,y:p+s*g*h+u*M});return[y(0,0),y(-l,l),y(-l-f,l),y(-f,0),y(-l-f,-l),y(-l,-l)]}function Ou(e,t,n,o,r){let i=[.94,.95,.96];z(e,ku(t,o,r),void 0,()=>n+Kt.high,n+Kt.low,i,i,K)}function An(e,t){let n=re(e);return n?{top:Y(Be(n,.12),.95),wall:Y(Be(n,.12),.85)}:{top:t.tierTop,wall:t.tierWall}}function ns(e,t,n,o,r,i,s,a,c=[]){let u=ie(t),l=Ii(t);if(!t.role&&(!t.fill||t.fill==="none"||t.fill==="transparent")||!u){Ut(e,t,n+o+Pu);return}let m=a?a.kind==="stage":t.role==="stage",h=a?a.kind==="screen":t.role==="screen",d=a?{kind:m?"stage":"solid",heightM:a.topY-a.baseY}:Ne(t),p=a?.baseY??n,y=a?.topY??n+o;if(m&&s){let S=1/0,C=-1/0,O=1/0,L=-1/0;for(let v of u)v.x<S&&(S=v.x),v.x>C&&(C=v.x),v.y<O&&(O=v.y),v.y>L&&(L=v.y);s.push({cx:(S+C)/2*E,cz:(O+L)/2*E,y,halfX:Math.max((C-S)/2*E,.5),halfZ:Math.max((L-O)/2*E,.5)})}let g=re(t.fill),M=t.role==="wall"||t.role==="entrance"||t.role==="exit",P=M?An(t.fill,r).top:m&&g?oe(r.stageTop,Y(Be(g,.18),.9),.9):!t.role&&g?g:ft(g,m?r.stageTop:r.decorTop),R=h?g:null,x=M?An(t.fill,r).wall:m?g?oe(r.stageWall,Y(g,.58),.82):r.stageWall:h?R?oe(Y(R,1.42),[.24,.46,.82],.08):[.24,.46,.82]:ft(re(t.fill),r.decorWall);if(t.role==="wall"&&!a){Mn(e,u,p,y,c,P,x,i),Ut(e,t,y+.012);return}if(h&&u.length===4&&y-p>.2){let S=co(u,p,y);if(!S)return;let{quad:C,side:O,trim:L,inner:v,panel:A}=S,_=[.12,.15,.18];for(let[k,F]of[[0,O],[1-O,1]])ne(e,we(C,k,F),y,p,_,_);ne(e,v,p+L,p,_,_),ne(e,v,y,y-L,_,_),ne(e,A,y-L,p+L,x,x),Ut(e,t,y+.012);return}let b=g?Y(Be(g,.15),.82):x,I=g?Y(Be(g,.1),1.02):P;if(Di(t.role)&&!a&&Gi(e,t.role,u,p,y,b,I,i,t.heightM!==void 0))return;if((t.role==="sound"||a?.kind==="sound_desk")&&u.length===4&&y-p>.3){let S=ve(u),C=Math.hypot(S[1].x-S[0].x,S[1].y-S[0].y)*E,O=Math.min(.12,.09/Math.max(C,.001)),L=[.18,.21,.24],v=y-Math.min(.12,(y-p)*.15);for(let[A,_]of[[0,O],[1-O,1]])ne(e,we(S,A,_),v,p,L,L);ne(e,S,y,v,P,L);return}if(t.role==="rail"&&u.length===4&&y>p){let S=ve(u),C=Math.hypot(S[1].x-S[0].x,S[1].y-S[0].y)*E,O=Math.max(1,Math.min(128,Math.ceil(C/1.4))),L=Math.min(.08,.055/Math.max(.055,C)),v=[.58,.64,.66];for(let A=0;A<=O;A++){let _=A/O,k=Math.min(1-L,Math.max(0,_-L/2));ne(e,we(S,k,k+L),y,p,v,Y(v,.8))}for(let A of[.52,1]){let _=p+(y-p)*A;ne(e,S,_,Math.max(p,_-.055),v,Y(v,.8))}return}if(t.role==="goal"&&u.length===4){let S=ve(u),C=Math.hypot(S[1].x-S[0].x,S[1].y-S[0].y)*E,O=Math.min(.12,.1/Math.max(.1,C)),L=[.9,.94,.94];for(let[v,A]of[[0,O],[1-O,1]])ne(e,we(S,v,A),Math.max(p,y-.1),p,L,L);ne(e,S,y,Math.max(p,y-.1),L,L);return}if(d.kind==="portal"&&u.length===4){let S=Et(u,p,y);if(!S)return;let{quad:C,side:O,face:L,openingTop:v}=S;for(let[A,_,k]of[[0,L,1],[L,1-L,.67],[1-L,1,1]]){let F=Xt(C,A,_),T=Y(P,k),B=Y(x,k);for(let[D,H]of[[0,O],[1-O,1]])ne(e,we(F,D,H),v,p,T,B);ne(e,F,y,v,T,B)}(t.role==="entrance"||t.role==="exit")&&Ou(e,C,p,i,t.role==="exit");return}if(d.kind==="suite"&&u.length===4){let S=u.map((L,v)=>{let A=u[(v+1)%4],_=(L.x+A.x)/2,k=(L.y+A.y)/2;return Math.hypot(_-i.x,k-i.y)}),C=S.indexOf(Math.min(...S)),O=[0,1,2,3].map(L=>u[(C+L)%4]);ne(e,we(O,0,.08),y,p,P,x),ne(e,we(O,.92,1),y,p,P,x),ne(e,Xt(O,.88,1),y,p,P,x),ne(e,O,y,Math.max(p,y-.18),P,x);return}if(m&&!t.stageKind?.startsWith("pitch-")&&y-p>.12){let S=y-Math.min(.06,(y-p)*.15);ne(e,u,S,p,P,x,l),ne(e,u,y,S,P,oe(P,x,.2),l)}else ne(e,u,y,p,P,x,l);if((t.stageKind==="pitch-football"||t.stageKind==="pitch-rugby")&&u.length===4){e.setMaterial(4);let S=ve(u),C=oe(g??Wi,Wi,g?.45:0);for(let O=0;O<12;O++){let L=we(S,O/12,(O+1)/12),v=Y(C,O%2?1.09:.91),A=L.map(_=>[_.x*E,y+.006,_.y*E]);e.tri(A[0],A[1],A[2],[0,1,0],v),e.tri(A[0],A[2],A[3],[0,1,0],v)}}t.stageKind&&t.stageKind!=="pitch-football"&&Yi(e,u,t.stageKind,y,g),m&&st(t.stageKind)&&Ki(e,t,y),e.setMaterial(h?1:0),Ut(e,t,y+.012)}function Cn(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,c=Math.cos(a),u=Math.sin(a),l=o/2,f=r/2;return[[-l,-f],[l,-f],[l,f],[-l,f]].map(([m,h])=>({x:i+m*c-h*u,y:s+m*u+h*c}))}function Tu(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 re(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 c=re(a[1].trim());c&&s.push(c)}return s.length?s.reduce((a,c,u)=>oe(a,c,1/(u+1)),s[0]):null}function os(e,t,n,o){if(t.layer==="foreground")return;let r=Cn(t);if(!r)return;let i=n+wu,s=ft(Tu(t.href),o.decorTop),a=Math.max(0,Math.min(1,t.opacity??1));a<1&&(s=oe(o.ground,s,a)),z(e,r,void 0,()=>i,n,s,oe(s,o.decorWall,.5),K)}function rs(e,t,n,o,r){if(!t.points||t.points.length<3)return;let i=Zr(o,r.gaTop);z(e,t.points,t.holes,()=>n+Qi,n,i,r.gaWall,K),Fu(e,t.points,n+Qi)}var Qi=.15,En=[.72,.74,.76],mo=1.1,qi=.12,ho=.05,Lu=.06,Bu=2.4;function Fu(e,t,n){let o=Ve([...t]),r=Je(o,qi/E),i=Je(o,(qi+ho)/E);if(r.length<3||i.length<3)return;for(let a of[n+mo,n+mo*.5])z(e,r,[i.slice().reverse()],()=>a,a-ho,En,Y(En,.85),K);let s=Lu/2/E;for(let a=0;a<r.length;a++){let c=r[a],u=r[(a+1)%r.length],l=Math.hypot(u.x-c.x,u.y-c.y)*E,f=Math.max(1,Math.round(l/Bu));for(let m=0;m<f;m++){let h=m/f,d=c.x+(u.x-c.x)*h,p=c.y+(u.y-c.y)*h,y=[{x:d-s,y:p-s},{x:d+s,y:p-s},{x:d+s,y:p+s},{x:d-s,y:p+s}];z(e,y,void 0,()=>n+mo-ho,n,En,Y(En,.8),K)}}}var po=.6,is=3,Nu=.25;function Du(e,t){if(_e(t,e.x,e.y))return 0;let n=1/0;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[r],s=t[o],a=s.x-i.x,c=s.y-i.y,u=a*a+c*c||1,l=Math.max(0,Math.min(1,((e.x-i.x)*a+(e.y-i.y)*c)/u));n=Math.min(n,Math.hypot(e.x-(i.x+l*a),e.y-(i.y+l*c)))}return n}function ss(e,t){let n=e.map(s=>({booth:s,ring:De(s)})).filter(s=>!!s.ring&&s.ring.length===4&&!s.booth.points),o=n.map(({ring:s})=>({minX:Math.min(...s.map(a=>a.x)),maxX:Math.max(...s.map(a=>a.x)),minY:Math.min(...s.map(a=>a.y)),maxY:Math.max(...s.map(a=>a.y))})),r=(is+po)/E,i=new Map;return n.forEach(({booth:s,ring:a},c)=>{let u={x:a.reduce((h,d)=>h+d.x,0)/4,y:a.reduce((h,d)=>h+d.y,0)/4},l=[0,1,2,3].map(h=>{let d=a[h],p=a[(h+1)%4],y={x:(d.x+p.x)/2,y:(d.y+p.y)/2},g=y.x-u.x,M=y.y-u.y,P=Math.hypot(g,M)||1,R={x:y.x+g/P*po/E,y:y.y+M/P*po/E},x=is/E;return o.forEach((b,I)=>{I===c||R.x<b.minX-r||R.x>b.maxX+r||R.y<b.minY-r||R.y>b.maxY+r||(x=Math.min(x,Du(R,n[I].ring)))}),{open:x*E,toward:{x:y.x+g/P*10/E,y:y.y+M/P*10/E},focal:Math.hypot(y.x-t.x,y.y-t.y)}}),f=Math.max(...l.map(h=>h.open)),m=l.filter(h=>h.open>=f-Nu).sort((h,d)=>h.focal-d.focal)[0];i.set(s.id,m.toward)}),i}var as=je(require("polygon-clipping"),1);var Gu=.45,ju=1500,Hu=200;function cs(e,t){if(e.role!=="stage"||st(e.stageKind))return e;let n=ie(e);if(!n||n.length<3||Math.abs(Ae(n))*E*E>ju)return e;let o=t.filter(s=>_e(n,s.x,s.y));if(!o.length||o.length>Hu)return e;let r=Gu/E,i=o.map(s=>[[[s.x-r,s.y-r],[s.x+r,s.y-r],[s.x+r,s.y+r],[s.x-r,s.y+r],[s.x-r,s.y-r]]]);try{let s=as.default.difference([[...n.map(u=>[u.x,u.y]),[n[0].x,n[0].y]]],...i),a=null,c=0;for(let u of s){let l=u[0].slice(0,-1).map(([m,h])=>({x:m,y:h})),f=Math.abs(Ae(l));f>c&&(c=f,a=l)}return!a||a.length<3?e:{...e,kind:"polygon",points:a,rotation:0}}catch{return e}}var Vu=Math.PI/180,se=96,Xu=6,Uu=60,Ku=150,ls=.2,Yu=.35;function Wu(e,t){let n=Math.atan2(t.x-e.x,t.y-e.y)/Vu;return n<0?n+360:n}function kn(e){if(!e.length)return NaN;let t=[...e].sort((n,o)=>n-o);return t[Math.floor(t.length/2)]}function On(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 c=-n;c<=n;c++){let u=i+c;if(t)u=(u%o+o)%o;else if(u<0||u>=o)continue;s+=e[u],a++}r[i]=s/a}return r}function us(e,t){let n=e.filter(m=>m.rows.length>=1);if(n.length<1)return null;let o=[],r=0,i=0,s=0;for(let m of n)for(let h of m.rows){for(let d of h.pts)r+=d.x,i+=d.y,s++;if(h.pts.length>=4){let d=Kn(h.pts);d&&Number.isFinite(d.cx)&&Number.isFinite(d.cy)&&o.push({x:d.cx,y:d.cy})}}if(!s)return null;let a={x:r/s,y:i/s},c=a;if(o.length>=8){let m=kn(o.map(g=>g.x)),h=kn(o.map(g=>g.y)),d=0;for(let g of n)for(let M of g.rows)for(let P of M.pts){let R=Math.hypot(P.x-a.x,P.y-a.y);R>d&&(d=R)}let p=0,y=d*.2;for(let g of n)for(let M of g.rows)for(let P of M.pts)Math.hypot(P.x-m,P.y-h)<y&&p++;Math.hypot(m-a.x,h-a.y)<=d&&p/s<.01&&(c={x:m,y:h})}let u=[];for(let m of n){let h={sectionId:m.sectionId,rMin:1/0,rMax:-1/0,samples:[]};for(let d of m.rows)for(let p of d.pts){let y=Math.hypot(p.x-c.x,p.y-c.y),g=Math.min(se-1,Math.floor(Wu(c,p)/(360/se)));h.samples.push({r:y,bin:g,levelM:d.levelM}),y<h.rMin&&(h.rMin=y),y>h.rMax&&(h.rMax=y)}h.samples.length&&u.push(h)}if(!u.length)return null;u.sort((m,h)=>m.rMin+m.rMax-(h.rMin+h.rMax));let l=[];for(let m of u){let h=!1;for(let d of l){let p=Math.min(m.rMax,d.rMax)-Math.max(m.rMin,d.rMin),y=Math.min(m.rMax-m.rMin,d.rMax-d.rMin);if(y>1e-9&&p>=Yu*y){d.members.push(m),d.rMin=Math.min(d.rMin,m.rMin),d.rMax=Math.max(d.rMax,m.rMax),h=!0;break}}h||l.push({members:[m],rMin:m.rMin,rMax:m.rMax})}let f=[];for(let m of l){let h=new Array(se).fill(null);for(let v of m.members)for(let A of v.samples){let _=h[A.bin];_||(_={samples:[]},h[A.bin]=_),_.samples.push({r:A.r,levelM:A.levelM})}let d=h.map(v=>!!v);if(!d.filter(Boolean).length)continue;let y=[],g=[];for(let v of h){if(!v)continue;let A=1/0,_=-1/0;for(let k of v.samples)k.r<A&&(A=k.r),k.r>_&&(_=k.r);y.push(A),g.push(_)}let M=kn(y),P=kn(g);if(!(M>=ls*P)||!(P>0))continue;let R=[...y].sort((v,A)=>v-A);if(!(R[Math.floor(R.length*.1)]>=ls*P))continue;let b=h.map(v=>{if(!v)return null;let A=[...v.samples].sort((N,U)=>N.r-U.r),_=A[0].r,k=A[A.length-1].r,F=A[0].levelM,T=-1/0;for(let N of A)N.levelM>T&&(T=N.levelM);let B=[];for(let N of A){let U={r:N.r,l:N.levelM};for(;B.length&&Math.abs(B[B.length-1].r-U.r)<1e-9;){if(B[B.length-1].l<=U.l){U.skip=!0;break}B.pop()}if(!U.skip){for(;B.length>=2;){let V=B[B.length-2],Z=B[B.length-1];if((Z.r-V.r)*(U.l-V.l)-(Z.l-V.l)*(U.r-V.r)<=0)B.pop();else break}B.push(U)}}let D=B.map(N=>N.r),H=B.map(N=>N.l);return{inner:_,outer:k,front:F,top:T,profile:{rs:D,ls:H}}}),I=d.slice();for(let v=0;v<se;v++){if(I[v])continue;let A=-1,_=-1,k=0;for(let X=1;X<=se;X++){let te=(v-X+se*2)%se;if(I[te]){A=te;break}}for(let X=1;X<=se;X++){let te=(v+X)%se;if(I[te]){_=te,k=X;break}}if(A<0||_<0)continue;let F=0;for(let X=1;X<=se;X++){let te=(v-X+se*2)%se;if(d[te]){F=X;break}}if(F-1+k>Xu)continue;let B=b[A],D=b[_],H=F/(F+k),N=B.inner+(D.inner-B.inner)*H,U=B.outer+(D.outer-B.outer)*H,V=B.front+(D.front-B.front)*H,Z=B.top+(D.top-B.top)*H;b[v]={inner:N,outer:U,front:V,top:Z,profile:{rs:[N,U],ls:[V,Z]}}}for(let v=0;v<se;v++)b[v]&&(I[v]=!0);let w=360/se,S=[],C=I.filter(Boolean).length,O=[];if(C===se)O.push({start:0,len:se});else{let v=0;for(;I[v];)v=(v+1)%se;let A=-1;for(let _=0;_<=se;_++){let k=(v+_)%se,F=_<se&&I[k];if(F&&A<0)A=k;else if(!F&&A>=0){let T=(k-A+se)%se||se;O.push({start:A,len:T}),A=-1}}}for(let v of O){if(v.len*w<Uu&&v.len<se)continue;let A=v.len===se,_=new Float64Array(v.len),k=new Float64Array(v.len),F=new Float64Array(v.len),T=new Float64Array(v.len),B=[];for(let X=0;X<v.len;X++){let te=b[(v.start+X)%se];_[X]=te.inner,k[X]=te.outer,F[X]=te.front,T[X]=te.top,B.push(te.profile??{rs:[te.inner,te.outer],ls:[te.front,te.top]})}let D=On(_,A),H=On(k,A),N=On(F,A),U=On(T,A);for(let X=0;X<v.len;X++)D[X]>_[X]&&(D[X]=_[X]),H[X]<k[X]&&(H[X]=k[X]),D[X]>H[X]-1e-6&&(D[X]=Math.max(0,H[X]-1e-6)),U[X]<N[X]&&(U[X]=N[X]);let V={startBin:v.start,binCount:v.len,closed:A,innerR:D,outerR:H,frontLevelM:N,topLevelM:U,profiles:B},Z=(X,te,Q)=>{let fe=B[X],ue=fe.rs,G=fe.ls;if(te<=ue[0]){G[0]>Q&&(G[0]=Q);return}if(te>=ue[ue.length-1]){G[G.length-1]>Q&&(G[G.length-1]=Q);return}for(let j=0;j+1<ue.length;j++)if(te<=ue[j+1]){G[j]>Q&&(G[j]=Q),G[j+1]>Q&&(G[j+1]=Q);return}};for(let X=0;X<v.len;X++){let te=h[(v.start+X)%se];if(te)for(let Q of te.samples){Z(X,Q.r,Q.levelM);let fe=A?(X-1+v.len)%v.len:X-1,ue=A?(X+1)%v.len:X+1;fe>=0&&Z(fe,Q.r,Q.levelM),ue<v.len&&Z(ue,Q.r,Q.levelM)}}S.push(V)}S.reduce((v,A)=>v+A.binCount*w,0)<Ku||f.push({arcs:S,sectionIds:m.members.map(v=>v.sectionId),innerRMedian:M,outerRMedian:P})}if(!f.length)return null;if(f.sort((m,h)=>m.innerRMedian-h.innerRMedian),t){let m=f[f.length-1].outerRMedian;if(Math.hypot(t.x-c.x,t.y-c.y)>.9*m)return null}return{centre:c,binCount:se,binStepDeg:360/se,rings:f}}function fs(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),c=i-s,u=l=>{let f=t.profiles[l],m=f.rs,h=f.ls;if(o<=m[0])return h[0];if(o>=m[m.length-1])return h[h.length-1];for(let d=0;d+1<m.length;d++)if(o<=m[d+1]){let p=m[d+1]-m[d],y=p>1e-9?(o-m[d])/p:0;return h[d]+(h[d+1]-h[d])*y}return h[h.length-1]};return u(s)*(1-c)+u(a)*c}function bo(e,t,n,o,r,i,s,a,c,u=[],l=r){if(t.length!==n.length||t.length<2||i-r<1.5)return;let f=(p,y,g)=>{We(e,p,y,g,u,s,a,{portalBase:l,ao:c})||z(e,p,void 0,()=>g,y,s,a,c)},m=(p,y,g)=>({x:p.x+(y.x-p.x)*g,y:p.y+(y.y-p.y)*g}),h=o?t.length:t.length-1,d=0;for(let p=0;p<h;p++){let y=(p+1)%t.length,g=Math.hypot(n[y].x-n[p].x,n[y].y-n[p].y)*$;if(g<1e-5)continue;let M=(b,I)=>[m(t[p],t[y],b),m(t[p],t[y],I),m(n[p],n[y],I),m(n[p],n[y],b)];f(M(0,1),r,r+.95),f(M(0,1),i-.22,i);let P=Math.ceil((d-.32)/6)*6,R=!1,x=!1;for(let b=P;b<d+g;b+=6){let I=Math.max(0,(b-d)/g),w=Math.min(1,(b+.32-d)/g);w<=I||(f(M(I,w),r+.95,i-.22),R||=I<1e-6,x||=w>1-1e-6)}if(!o&&(p===0&&!R||p===h-1&&!x)){let b=Math.min(1,.32/g);f(M(p===0?0:1-b,p===0?b:1),r+.95,i-.22)}d+=g}}var ot=je(require("polygon-clipping"),1),Wt=.65;function yo(e,t){let n=1/0;for(let o of t)for(let r=0;r<o.length;r++){let i=o[r],s=o[(r+1)%o.length],a=s.x-i.x,c=s.y-i.y,u=Math.max(0,Math.min(1,((e.x-i.x)*a+(e.y-i.y)*c)/(a*a+c*c||1)));n=Math.min(n,Math.hypot(e.x-i.x-u*a,e.y-i.y-u*c))}return n}var go=.01;function ms(e,t,n,o,r,i,s,a=[],c=!0,u={bays:[],walls:[]}){if(o-r<=1e-5)return;let l=o-r>=3,f=l?o-Wt:r;e.setMaterial(5);let m=l?[]:a.filter(b=>{if(b.role!=="entrance"&&b.role!=="exit")return!1;let I=ie(b);if(!I)return!1;let w=Et(I,r,r+Ne(b).heightM);return w!==null&&w.openingTop<=o-.12});if((!m.length||!We(e,t,f,o,m,i,s,{holes:n,portalBase:r}))&&z(e,t,n,()=>o,f,i,s,K,void 0,()=>[0,1,0]),!l){e.setMaterial(0);return}let h=c&&u.bays.length?zu(t,n,Je(t,Yt/E),u):null,d=6/E,p=.22/E,y=a.flatMap(b=>{if(b.role!=="entrance"&&b.role!=="exit")return[];let I=ie(b);return I?.length?[{minX:Math.min(...I.map(w=>w.x)),maxX:Math.max(...I.map(w=>w.x)),minY:Math.min(...I.map(w=>w.y)),maxY:Math.max(...I.map(w=>w.y))}]:[]}),g=Math.min(...t.map(b=>b.x)),M=Math.max(...t.map(b=>b.x)),P=Math.min(...t.map(b=>b.y)),R=Math.max(...t.map(b=>b.y));for(let b=g+d/2;b<M;b+=d)for(let I=P+d/2;I<R;I+=d){if(y.some(S=>b+p>=S.minX&&b-p<=S.maxX&&I+p>=S.minY&&I-p<=S.maxY))continue;let w=[{x:b-p,y:I-p},{x:b+p,y:I-p},{x:b+p,y:I+p},{x:b-p,y:I+p}];!Pe({x:b,y:I},t,n)||yo({x:b,y:I},[t,...n??[]])<p*Math.SQRT2+(c?Yt/E:0)||h&&yo({x:b,y:I},h.flat())<p*Math.SQRT2+Yt/E||z(e,w,void 0,()=>f,r,i,s,K)}if(h){for(let[b,...I]of h)z(e,b,I,()=>f,r-go,i,s,K);e.setMaterial(0);return}let x=Je(t,Yt/E);if(c&&x.length>=3){let b=a.filter(S=>{if(S.role!=="entrance"&&S.role!=="exit")return!1;let C=ie(S);return!!C&&C.some(O=>!Pe(O,t,void 0)||yo(O,[t])<=Yt/E)}),I=[x.slice().reverse()],w=r-go;(!b.length||!We(e,t,w,f,b,i,s,{holes:I,portalBase:r+go}))&&z(e,t,I,()=>f,w,i,s,K)}e.setMaterial(0)}var xo=.25,Yt=xo;function zu(e,t,n,o){if(n.length<3)return null;let r=s=>{let a=s.map(c=>[c.x,c.y]);return a.push(a[0]),a},i=s=>{let[a,...c]=s.map(u=>[r(u)]);return ot.default.union(a,...c)};try{let s=[r(e),...(t??[]).map(r)],a=ot.default.difference(s,[r(n)]),c=ot.default.intersection(s,i(o.bays));if(!c.length)return null;let u=ot.default.difference(ot.default.intersection(s,i(o.walls)),c);return ot.default.union(ot.default.difference(a,c),u).map(f=>f.map(m=>m.slice(0,-1).map(([h,d])=>({x:h,y:d}))))}catch{return null}}var Zu=.02,$u=.25,Qu=1.2,qu=.6,Ju=.45,ef=2.3,tf=Math.PI/180,hs=.005;function Ue(e,t,n){let o=n*tf;return{x:e.x+t*Math.sin(o),y:e.y+t*Math.cos(o)}}function nf(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 of=24,rf=.01;function sf(e,t,n,o,r,i,s,a,c){let u=n.binCount,l=of,f=$,m=i+.02,h=i-rf,d=[];for(let A=0;A<u;A++){let _=(n.startBin+A+.5)*t.binStepDeg,k=new Float64Array(l+1);for(let F=0;F<=l;F++){let T=o[A]+(r[A]-o[A])*F/l;k[F]=Math.max(m,fs(t,n,_,T)-$u)}d.push(k)}if(c){let A=0;for(let _=0;_+1<u;_++)for(let k=0;k<l;k++){let F=Ue(t.centre,o[_]+(r[_]-o[_])*k/l,(n.startBin+_+.5)*t.binStepDeg),T=Ue(t.centre,o[_+1]+(r[_+1]-o[_+1])*(k+1)/l,(n.startBin+_+1.5)*t.binStepDeg);A=Math.max(A,Math.hypot(T.x-F.x,T.y-F.y))}for(let _=0;_<u;_++){let k=(n.startBin+_+.5)*t.binStepDeg;for(let F=0;F<=l;F++){let T=Ue(t.centre,o[_]+(r[_]-o[_])*F/l,k),B=c(T.x,T.y,A*1.01);B!==null&&(d[_][F]=Math.min(d[_][F],Math.max(h+hs,B-hs)))}}}let p=[s.bandTop[0]*a.top,s.bandTop[1]*a.top,s.bandTop[2]*a.top],y=[s.bandTop[0]*a.bottomCap,s.bandTop[1]*a.bottomCap,s.bandTop[2]*a.bottomCap],g=[s.bandWall[0]*a.top,s.bandWall[1]*a.top,s.bandWall[2]*a.top],M=[s.bandWall[0]*a.wallBottom,s.bandWall[1]*a.wallBottom,s.bandWall[2]*a.wallBottom],P=(A,_)=>{let k=(n.startBin+A+.5)*t.binStepDeg,F=o[A]+(r[A]-o[A])*_/l,T=Ue(t.centre,F,k);return[T.x*f,d[A][_],T.y*f]};{let A=Math.tan(12*Math.PI/180);for(let _=0;_<6;_++){let k=!1;for(let T=0;T<u;T++)for(let B=l-1;B>=0;B--)d[T][B]>d[T][B+1]&&(d[T][B]=d[T][B+1],k=!0);let F=n.closed?u:u-1;for(let T=0;T<F;T++){let B=(T+1)%u;for(let D=0;D<=l;D++){let H=d[B][D]-d[T][D];if(Math.abs(H)>1)continue;let N=o[T]+(r[T]-o[T])*D/l,U=o[B]+(r[B]-o[B])*D/l,V=Ue(t.centre,N,(n.startBin+T+.5)*t.binStepDeg),Z=Ue(t.centre,U,(n.startBin+B+.5)*t.binStepDeg),X=A*Math.hypot(Z.x-V.x,Z.y-V.y)*f;H>X?(d[B][D]=d[T][D]+X,k=!0):-H>X&&(d[T][D]=d[B][D]+X,k=!0)}}if(!k)break}}let R=1,x=(A,_)=>{for(let k=0;k<=l;k+=4)if(Math.abs(d[A][k]-d[_][k])>R)return!0;return Math.abs(d[A][l]-d[_][l])>R},b=Math.tan(38*Math.PI/180),I=A=>(r[A]-o[A])/l*f,w=(A,_)=>d[A][_+1]-d[A][_]>b*Math.max(1e-6,I(A)),S=(A,_)=>{let k=n.closed?(A-1+u)%u:Math.max(0,A-1),F=n.closed?(A+1)%u:Math.min(u-1,A+1);Math.abs(d[k][_]-d[A][_])>R&&(k=A),Math.abs(d[F][_]-d[A][_])>R&&(F=A);let T=Math.max(0,_-1),B=Math.min(l,_+1);T<_&&w(A,T)&&(T=_),B>_&&w(A,_)&&(B=_);let D=P(k,_),H=P(F,_),N=P(A,T),U=P(A,B),V=H[0]-D[0],Z=H[1]-D[1],X=H[2]-D[2],te=U[0]-N[0],Q=U[1]-N[1],fe=U[2]-N[2],ue=Z*fe-X*Q,G=X*te-V*fe,j=V*Q-Z*te,J=Math.hypot(ue,G,j);return J>1e-12?(ue/=J,G/=J,j/=J,G<0&&(ue=-ue,G=-G,j=-j),[ue,G,j]):[0,1,0]},C=(A,_,k=!1)=>{let F=k&&Math.min(A[1],_[1])-i>=3,T=[A[0],F?A[1]-Wt:h,A[2]],B=[_[0],F?_[1]-Wt:h,_[2]],D=_[0]-A[0],H=_[2]-A[2],N=Math.hypot(D,H);if(!(N>1e-12))return;let U=[H/N,0,-D/N];e.tri(A,_,B,U,g,g,M),e.tri(A,B,T,U,g,M,M)},O=.05*Oe,L=A=>r[A]-o[A]<O,v=n.closed?u:u-1;for(let A=0;A<v;A++){let _=(A+1)%u;if(L(A)||L(_))continue;if(x(A,_)){let H=(n.startBin+A+1)*t.binStepDeg,N=(Q,fe)=>{let ue=(o[A]+o[_])/2,G=(r[A]+r[_])/2,j=ue+(G-ue)*fe/l,J=Ue(t.centre,j,H);return[J.x*f,d[Q][fe],J.y*f]};for(let Q=0;Q<l;Q++){let fe=P(A,Q),ue=P(A,Q+1),G=N(A,Q),j=N(A,Q+1),J=S(A,Q),me=S(A,Q+1);e.triN(fe,G,j,J,J,me,p),e.triN(fe,j,ue,J,me,me,p);let xe=P(_,Q),Ie=P(_,Q+1),ae=N(_,Q),ce=N(_,Q+1),Ge=S(_,Q),W=S(_,Q+1);e.triN(ae,xe,Ie,Ge,Ge,W,p),e.triN(ae,Ie,ce,Ge,W,W,p);let he=N(A,Q),Me=N(A,Q+1),rt=N(_,Q+1),it=N(_,Q),Ze=Me[0]-he[0],$e=Me[2]-he[2],kt=Math.hypot(Ze,$e);if(kt>1e-12){let $t=[$e/kt,0,-Ze/kt];e.tri(he,Me,rt,$t,g),e.tri(he,rt,it,$t,g)}}let U=P(A,0),V=P(_,0),Z=P(_,l),X=P(A,l),te=Q=>[Q[0],h,Q[2]];Math.min(U[1],V[1])-i<3&&(e.tri(te(U),te(Z),te(V),[0,-1,0],y),e.tri(te(U),te(X),te(Z),[0,-1,0],y)),C(U,V,!0),C(X,Z,!0);continue}for(let H=0;H<l;H++){let N=S(A,H),U=S(_,H),V=S(_,H+1),Z=S(A,H+1);if(w(A,H)||w(_,H)){let ue=(Me,rt)=>{let it=(n.startBin+Me+.5)*t.binStepDeg,Ze=o[Me]+(r[Me]-o[Me])*(H+.5)/l,$e=Ue(t.centre,Ze,it);return[$e.x*f,rt,$e.y*f]},G=P(A,H),j=P(_,H),J=ue(A,d[A][H]),me=ue(_,d[_][H]);e.triN(G,j,me,N,U,U,p),e.triN(G,me,J,N,U,N,p);let xe=P(_,H+1),Ie=P(A,H+1),ae=ue(A,d[A][H+1]),ce=ue(_,d[_][H+1]);e.triN(ae,ce,xe,Z,V,V,p),e.triN(ae,xe,Ie,Z,V,Z,p);let Ge=me[0]-J[0],W=me[2]-J[2],he=Math.hypot(Ge,W);if(he>1e-12){let Me=[-W/he,0,Ge/he];e.tri(J,me,ce,Me,g),e.tri(J,ce,ae,Me,g)}continue}let X=P(A,H),te=P(_,H),Q=P(_,H+1),fe=P(A,H+1);e.triN(X,te,Q,N,U,V,p),e.triN(X,Q,fe,N,V,Z,p)}let k=P(A,0),F=P(_,0),T=P(_,l),B=P(A,l),D=H=>[H[0],h,H[2]];Math.min(k[1],F[1])-i<3&&(e.tri(D(k),D(T),D(F),[0,-1,0],y),e.tri(D(k),D(B),D(T),[0,-1,0],y)),C(k,F,!0),C(B,T,!0)}if(!n.closed)for(let A of[0,u-1])for(let _=0;_<l;_++)C(P(A,_),P(A,_+1))}function ds(e,t,n){let{bottomY:o,colors:r,ao:i}=n,s=new Float64Array(t.binCount).fill(-1/0);for(let l of t.rings)for(let f of l.arcs){let m=new Float64Array(f.binCount),h=new Float64Array(f.binCount);for(let p=0;p<f.binCount;p++){let y=(f.startBin+p)%t.binCount,g=Math.max(0,f.innerR[p]-Te);m[p]=Math.max(g,s[y]+.001),h[p]=Math.max(m[p]+.001,f.outerR[p]+Te)}let d=0;for(let p=0;p<f.binCount;p++){let y=f.topLevelM[p]-o;y>d&&(d=y)}d>=Qu&&sf(e,t,f,m,h,o,r,i,n.standTopNear);for(let p=0;p<f.binCount;p++){let y=(f.startBin+p)%t.binCount;h[p]>s[y]&&(s[y]=h[p])}}if(n.deriveShell===!1||nf(n.shapes,t))return;let a=t.rings[t.rings.length-1],c=qu*Oe,u=Ju*Oe;for(let l of a.arcs){let f=[],m=[];for(let S=0;S<l.binCount;S++){let C=(l.startBin+S+.5)*t.binStepDeg,O=l.outerR[S]+Te+c;f.push(Ue(t.centre,O,C)),m.push(Ue(t.centre,O+u,C))}let h=-1/0;for(let S=0;S<l.binCount;S++)l.topLevelM[S]>h&&(h=l.topLevelM[S]);let d=h+ef,p=l.closed?m:[...m,...f.slice().reverse()],y=l.closed?[f.slice().reverse()]:void 0,g=oe(r.shellWall,[.66,.71,.72],.62),M=(S,C,O,L,v)=>{let A=Math.abs(L-h)<1e-6?L-Zu:L;We(e,S,O,A,n.shapes,r.shellTop,v,{holes:C,portalBase:o,ao:i})||z(e,S,C,()=>A,O,r.shellTop,v,i)},P=Math.max(1,Math.ceil((h-o)/4.5)),R=(h-o)/P,x=new Set,b=n.tierFrontLevels??t.rings.map(S=>{let C=S.arcs.flatMap(O=>Array.from(O.frontLevelM)).filter(Number.isFinite).sort((O,L)=>O-L);return C[Math.floor(C.length/2)]});for(let S of b)Number.isFinite(S)&&S-o>=3&&S<h&&x.add(Math.max(0,Math.min(P-1,Math.floor((S-o)/R))));let I=Math.min(...b.filter(S=>Number.isFinite(S)&&S-o>=3&&S<h));for(let S=0;S<P;S++)o+(S+1)*R<=I-Wt&&Number.isFinite(I)&&x.add(S);for(let S=0;S<P;S++){let C=o+(h-o)*S/P,O=o+(h-o)*(S+1)/P;x.has(S)&&O-C>=3.2?(M(p,y,C,C+.45,g),bo(e,f,m,l.closed,C+.45,O-.16,r.shellTop,g,i,n.shapes,o)):M(p,y,C,O-.16,g),M(p,y,O-.16,O,Y(g,.62))}bo(e,f,m,l.closed,h,d,r.shellTop,g,i,n.shapes,o);let w=8;for(let S=1;S<m.length;S++){if(w+=Math.hypot(m[S].x-m[S-1].x,m[S].y-m[S-1].y)*$,w<8)continue;w=0;let C=m[S],O=m[S-1],L=C.x-O.x,v=C.y-O.y,A=Math.max(1,Math.hypot(L,v)),_=L/A*.16*Oe,k=v/A*.16*Oe,F=Math.max(1,Math.hypot(C.x-t.centre.x,C.y-t.centre.y)),T=(C.x-t.centre.x)/F*.24*Oe,B=(C.y-t.centre.y)/F*.24*Oe,D=[{x:C.x-_,y:C.y-k},{x:C.x+_,y:C.y+k},{x:C.x+_+T,y:C.y+k+B},{x:C.x-_+T,y:C.y-k+B}];M(D,void 0,o,h,Y(g,1.12))}}}var af=2.5,ps=.65,cf=2,lf=.03;function uf(e,t){let n=()=>{let o=t;for(;e.length>2;){let r=e[0],i=e[1],s=Math.hypot(i.x-r.x,i.y-r.y);if(s>o){e[0]={x:r.x+(i.x-r.x)/s*o,y:r.y+(i.y-r.y)/s*o};return}o-=s,e.shift()}};n(),e.reverse(),n(),e.reverse()}function Po(e,t,n){let o=new Map;for(let i of e){let s=o.get(i.blockId);(!s||i.depth<s.depth)&&o.set(i.blockId,i)}let r=[];for(let[i,s]of o){if(s.y-n<af||s.pts.length<2)continue;let a=s.pts.map(l=>{let f=l.x-t.x,m=l.y-t.y,h=Math.max(1,Math.hypot(f,m));return{x:l.x-f/h*ps/E,y:l.y-m/h*ps/E}}),c=[],u=[a[0]];for(let l=1;l<a.length;l++){let f=a[l-1],m=a[l];Math.hypot(m.x-f.x,m.y-f.y)*E>cf?(u.length>=2&&c.push(u),u=[m]):u.push(m)}u.length>=2&&c.push(u);for(let l of c)uf(l,lf/E);c.length&&r.push({blockId:i,y:s.y,runs:c})}return r}var bs=.1,ff=1.1,mf=.22,Mo=.95,So=.05,ys=1.8;function gs(e,t,n,o){let r=[.72,.72,.69],i=[.48,.55,.57];for(let s of Po(t,n,o)){let a=s.y;for(let c of s.runs){let u=ys;for(let l=1;l<c.length;l++){let f=c[l-1],m=c[l],h=m.x-f.x,d=m.y-f.y,p=Math.hypot(h,d);if(p<1e-5)continue;let y=g=>{let M=-d/p*g/E/2,P=h/p*g/E/2;return[{x:f.x+M,y:f.y+P},{x:m.x+M,y:m.y+P},{x:m.x-M,y:m.y-P},{x:f.x-M,y:f.y-P}]};if(z(e,y(mf),void 0,()=>a+bs,a-ff,r,r,K),z(e,y(So),void 0,()=>a+Mo,a+Mo-So,i,i,K),u+=p*E,u>=ys||l===c.length-1){u=0;let g=.028/E,M=[{x:f.x-g,y:f.y-g},{x:f.x+g,y:f.y-g},{x:f.x+g,y:f.y+g},{x:f.x-g,y:f.y+g}];z(e,M,void 0,()=>a+Mo-So,a+bs,i,i,K)}}}}}var hf=.9,df=1.5,pf=.3;function xs(e,t,n){let o=[],r=[],i=hf/E,s=df/E,a=pf/E;for(let c of e)for(let u of c.runs){if(u.length<2)continue;let l=u.slice(),f=(y,g)=>{let M=l[y],P=l[g],R=Math.hypot(M.x-P.x,M.y-P.y)||1;l[y]={x:M.x+(M.x-P.x)/R*a,y:M.y+(M.y-P.y)/R*a}};f(0,1),f(l.length-1,l.length-2);let m=l.map((y,g)=>{let M=l[Math.max(0,g-1)],P=l[Math.min(l.length-1,g+1)],R=P.x-M.x,x=P.y-M.y,b=Math.hypot(R,x)||1,I=-x/b,w=R/b;return I*(y.x-t.x)+w*(y.y-t.y)<0&&(I=-I,w=-w),{nx:I,ny:w}}),h=l.map((y,g)=>({x:y.x-m[g].nx*s,y:y.y-m[g].ny*s})),d=l.map((y,g)=>({x:y.x+m[g].nx*i,y:y.y+m[g].ny*i})),p=l.map((y,g)=>({x:y.x+m[g].nx*(i+n/E),y:y.y+m[g].ny*(i+n/E)}));o.push([...h,...d.slice().reverse()]),r.push([...d,...p.reverse()])}return{bays:o,walls:r}}var Io=.88,Tn=.27,bf=1.2,yf=.01;function Ms(e,t,n,o,r){let i=[.67,.71,.68],s=[i[0]*Io,i[1]*Io,i[2]*Io],a=c=>!!r&&r.some((u,l)=>l!==c&&u?.belowY!=null&&Math.abs(u.belowY-t[c].y)<1e-6&&t[l].blockId===t[c].blockId);for(let c=0;c<t.length;c++){let u=t[c];if(!(u.pts.length<2))for(let l of[0,u.pts.length-1]){let f=u.pts[l],m=u.pts[l===0?1:l-1],h=f.x-m.x,d=f.y-m.y,p=Math.hypot(h,d);if(p<1e-5)continue;h/=p,d/=p;let y=1/0;for(let _=0;_<n.length;_++){let k=n[_],F=n[(_+1)%n.length],T=F.x-k.x,B=F.y-k.y,D=h*B-d*T;if(Math.abs(D)<1e-8)continue;let H=k.x-f.x,N=k.y-f.y,U=(H*B-N*T)/D,V=(H*d-N*h)/D;U>0&&V>=0&&V<=1&&(y=Math.min(y,U))}let g=.3/E,M=y-.04/E;if(!Number.isFinite(y)||y*E>2||M-g<.12/E)continue;let P=!!o&&a(c),R=r?.[c]?.pitch,x=P&&R&&Number.isFinite(R)?Math.min(bf/E,Math.max(Tn/E,R-Tn/E-yf/E)):Tn/E,b=-d,I=h;o&&b*(o.x-f.x)+I*(o.y-f.y)<0&&(b=-b,I=-I);let w=Tn/E,S=[{x:f.x+h*g+b*w,y:f.y+d*g+I*w},{x:f.x+h*M+b*w,y:f.y+d*M+I*w},{x:f.x+h*M-b*x,y:f.y+d*M-I*x},{x:f.x+h*g-b*x,y:f.y+d*g-I*x}];if(!S.every(_=>_e(n,_.x,_.y)))continue;let C=r?.[c]?.belowY,O=C==null?0:u.y-C,L=!!o&&O>.03&&O<=.65;if(L&&o){let _=(k,F)=>Math.hypot((k.x+F.x)/2-o.x,(k.y+F.y)/2-o.y);_(S[0],S[1])>_(S[3],S[2])&&(S=[S[3],S[2],S[1],S[0]])}let v=L?Math.ceil((O-1e-8)/.2):1,A=(_,k,F)=>({x:_.x+(k.x-_.x)*F,y:_.y+(k.y-_.y)*F});for(let _=0;_<v;_++){let k=_/v,F=(_+1)/v,T=[A(S[0],S[3],k),A(S[1],S[2],k),A(S[1],S[2],F),A(S[0],S[3],F)],B=u.y+.008-(L?O*(1-F):0);z(e,T,void 0,()=>B,B-(L?O/v+.1:.16),i,s,K)}}}}var gf=.02,xf=.012,Mf=.01,Sf=.3,Pf=.5;function If(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,c=s.y-i.y,u=a*a+c*c,l=u>1e-12?((t-i.x)*a+(n-i.y)*c)/u:0;l=Math.max(0,Math.min(1,l)),o=Math.min(o,Math.hypot(t-(i.x+l*a),n-(i.y+l*c)))}return o}function Rf(e,t,n,o){let r=1/0,i=Number.NaN;for(let s=0;s<e.length;s++){let a=t[s];if(Math.hypot(n-a.cx,o-a.cy)-a.rad>=r)continue;let c=If(e[s].pts,n,o);c<r&&(r=c,i=e[s].y)}return i}function Ss(e,t,n,o,r,i,s){let a=o.filter(m=>m.pts.length>0);if(a.length<2||t.length<3)return;let c=a.map(m=>{let h=0,d=0;for(let y of m.pts)h+=y.x,d+=y.y;h/=m.pts.length,d/=m.pts.length;let p=0;for(let y of m.pts)p=Math.max(p,Math.hypot(y.x-h,y.y-d));return{cx:h,cy:d,rad:p}}),u=[...t],l=n.map(m=>[...m]),f=gf/E;for(let m of[u,...l])for(let h=0;h<m.length;h++){let d=m[h],p=m[(h+1)%m.length],y=p.x-d.x,g=p.y-d.y,M=Math.hypot(y,g);if(M*E<.05)continue;let P=(d.x+p.x)/2,R=(d.y+p.y)/2,x=g/M,b=-y/M;Pe({x:P+x*f,y:R+b*f},u,l)&&(x=-x,b=-b);let I=r.x-P,w=r.y-R,S=Math.hypot(I,w)||1;if((x*I+b*w)/S>Pf)continue;let C=1/0;for(let T of[.2,.5,.8]){let B=Rf(a,c,d.x+y*T-x*f*2,d.y+g*T-b*f*2);Number.isFinite(B)&&(C=Math.min(C,B))}if(!Number.isFinite(C)||C-i<Sf)continue;let O=i-Mf,L=C-xf,v={x:(d.x-x*f)*E,z:(d.y-b*f)*E},A={x:(p.x-x*f)*E,z:(p.y-b*f)*E},_=[x,0,b],k=Y(s,K.wallBottom),F=Y(s,K.top);e.tri([v.x,L,v.z],[A.x,L,A.z],[A.x,O,A.z],_,F,F,k),e.tri([v.x,L,v.z],[A.x,O,A.z],[v.x,O,v.z],_,F,k,k)}}function Ps(e,t,n,o,r,i,s,a,c=!1){if(!t.outline||t.outline.length<3)return;let u=n.baseHeightM,l=n.objects.filter(M=>M.type==="shape"&&(M.role==="entrance"||M.role==="exit")),f=$r(o,a.tierTop);if(!r)return;let m=M=>r.deckAt(M.x,M.y),h=Mi(t,s),d=h[0]??t.outline;if(r.rowLevels.length>=2){let M=bn(r.rowLevels),P=Si(pi(r.rowLevels,n.focal,M),h),R=xs(Po(r.rowLevels,n.focal,u),n.focal,xo);for(let b of P){let I=Math.max(u,b.topY-Is);for(let w of i.subtract(b.outline,I))ms(e,w,b.holes,I,u,a.tierTop,a.tierWall,l,!c,R);e.setMaterial(5),Ss(e,b.outline,b.holes,r.rowLevels,n.focal,I,a.tierWall),e.setMaterial(0)}P.length||z(e,d,t.holes,()=>r.landingY,u,f,a.tierWall,K);let x={tread:[f[0]*K.top,f[1]*K.top,f[2]*K.top],riser:[f[0]*.72,f[1]*.72,f[2]*.72]};for(let b of h.length?h:[d])yi(e,r.rowLevels,n.focal,r.landingY,x,b,M);gs(e,r.rowLevels,n.focal,u),Ms(e,r.rowLevels,t.outline,n.focal,M);return}let p=r.flat?1/0:Ci,y=M=>r.normalAt(M.x,M.y),g=r.flat?r.landingY:void 0;for(let M of i.subtract(d,g))z(e,M,t.holes,m,u,f,a.tierWall,K,p,y)}function wf(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 c=n.bySection.get(a);if(c&&c.rowLevels.length>=2)continue;let u=t[s];if(u.kind==="booth")continue;let l=r.get(a);l||(l=new Map,r.set(a,l));let f=u.rowId||`__seat-${s}`,m=l.get(f);m||(m={pts:[],levelM:0,n:0},l.set(f,m)),m.pts.push({x:u.x,y:u.y}),m.levelM+=n.seatDeckY(s),m.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 u=a.rowLevels.filter(l=>!l.patch).map(l=>({pts:l.pts,levelM:l.y}));u.length>=2&&i.push({sectionId:s.id,rows:u});continue}let c=r.get(s.id);c&&i.push({sectionId:s.id,rows:[...c.values()].map(u=>({pts:u.pts,levelM:u.levelM/u.n}))})}return i}function Ef(e,t){let n=1/0;for(let o=0;o<t.length;o++){let r=t[o],i=t[(o+1)%t.length],s=i.x-r.x,a=i.y-r.y,c=Math.max(0,Math.min(1,((e.x-r.x)*s+(e.y-r.y)*a)/(s*s+a*a||1)));n=Math.min(n,Math.hypot(e.x-r.x-c*s,e.y-r.y-c*a))}return n}var Is=.02;function Af(e,t){let n=e.objects.filter(o=>o.type==="section"&&!!o.outline&&o.outline.length>=3).flatMap(o=>{let r=t.bySection.get(o.id);if(!r)return[];let i=1/0,s=-1/0,a=1/0,c=-1/0;for(let l of o.outline)l.x<i&&(i=l.x),l.x>s&&(s=l.x),l.y<a&&(a=l.y),l.y>c&&(c=l.y);let u=r.landingY;for(let l of r.rowLevels)u=Math.min(u,l.y-Is);return[{outline:o.outline,holes:o.holes,surface:r,floorTop:u,minX:i,maxX:s,minY:a,maxY:c}]});return(o,r,i)=>{let s=null;for(let a of n){if(o<a.minX-i||o>a.maxX+i||r<a.minY-i||r>a.maxY+i)continue;let c={x:o,y:r};if(!Pe(c,a.outline,a.holes)&&Ef(c,a.outline)>i)continue;let u=Math.min(a.surface.deckAt(o,r),a.floorTop);(s===null||u<s)&&(s=u)}return s}}var _f=3,vf=.4;function Rs(e,t,n,o,r,i,s=!0){let a=wf(t,n,o);if(a.length<_f)return;let c=us(a,t.focal);if(!c)return;let u=Math.max(0,...c.rings.map(l=>l.arcs.reduce((f,m)=>f+m.binCount,0)))/c.binCount;e.setMaterial(5),ds(e,c,{bottomY:t.baseHeightM,tierFrontLevels:a.map(l=>Math.min(...l.rows.map(f=>f.levelM))),colors:{bandTop:Y(r.tierTop,.8),bandWall:r.tierWall,shellTop:i??Y(r.tierWall,1.15),shellWall:i??r.tierWall},ao:K,shapes:t.objects.filter(l=>l.type==="shape"),deriveShell:s&&u>=vf,standTopNear:Af(t,o)}),e.setMaterial(0)}var ws=4;var Cf=[[/\b(wc|toilets?|restrooms?|washrooms?|lavatory|loo)\b/i,"restroom"],[/\b(bar|drinks|pub|cocktails?)\b/i,"bar"],[/\b(food|concessions?|snacks?|kiosk|caf[eé]|kitchen|catering)\b/i,"concession"],[/\b(coat ?check|cloak ?room|cloakroom|coats)\b/i,"coat"],[/\b(screen|led wall|projection|video wall)\b/i,"screen"],[/\b(sound|foh|mixing desk|control booth)\b/i,"sound"],[/\b(entrance|entry|way in|gate)\b/i,"entrance"],[/\b(exit|way out)\b/i,"exit"],[/\b(pillar|column|obstruction)\b/i,"obstruction"],[/\b(walls?|outline|boundary|perimeter)\b/i,"wall"]],kf=1.2,Of=12;function Es(e){if(e.heightM!==void 0)return!1;let t=ie(e);if(!t||t.length<3)return!1;let n=0;for(let r=0;r<t.length;r++){let i=t[r],s=t[(r+1)%t.length];n+=Math.hypot(s.x-i.x,s.y-i.y)}return n*$<Of*2?!1:2*zt(t)/n*$<=kf}function Ro(e){if(!e)return null;for(let[t,n]of Cf)if(t.test(e))return n;return null}var _s="auto-rows-";function vs(e){return e.id.startsWith(_s)&&!e.label}var Tf=1.15,Lf=.09,Cs=6,Bf=34,Ff=.35,Nf=6,Df=.35,Gf=.75,jf=12,Hf=2.5,Vf=40,Xf=[18,24],Uf=[12,16],As=14,Kf=.8,Yf=.6,Wf=5,zf=.3,ks=.4,Os=2,Zf=400,$f=2.6,Qf=.8,qf=4,Jf=26,em=.7,tm=.5,nm=.985,om=1.5,rm=2.2,im=3,sm=25,am=.985,cm=2,lm=6,um=3,fm=.1,mm=1.5,hm=1.6,dm=6e3,pm=.6,bm="#c3c7cd",wo=300,ym=240;function gm(e,t,n,o){if(!e.fill||!/^#[0-9a-f]{6}$/i.test(e.fill))return null;let r=Ao([...t]),i=new Set;for(let l of o)i.add(Math.floor(Math.atan2(l.y-r.y,l.x-r.x)*180/Math.PI/10));if(i.size*10<ym)return null;let{h:s,s:a,l:c}=Er(wr(e.fill));return s<70/360||s>170/360||a<.2||c<.08||c>.75||n.some(l=>l!==e&&l.type==="shape"&&ie(l)?.some(f=>Co(f,t)))?null:e.kind==="ellipse"?"oval-cricket":e.kind==="rect"?"pitch-football":null}var xm="Estimated from the drawing; confirm with the venue.",_o=e=>{if(!e.length)return null;let t=[...e].sort((o,r)=>o-r),n=Math.floor(t.length/2);return t.length%2?t[n]:(t[n-1]+t[n])/2},Ao=e=>({x:e.reduce((t,n)=>t+n.x,0)/e.length,y:e.reduce((t,n)=>t+n.y,0)/e.length}),zt=e=>{let t=0;for(let n=0;n<e.length;n++){let o=e[n],r=e[(n+1)%e.length];t+=o.x*r.y-r.x*o.y}return Math.abs(t)/2};function Mm(e){return e.height!==void 0||e.rake!==void 0||e.elevation!==void 0||e.surfaceKind!==void 0}function vo(e){let t=new Map;for(let n of e){let o=t.get(n.rowId);o?o.push(n):t.set(n.rowId,[n])}return t}function Co(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[o],s=t[r];i.y>e.y!=s.y>e.y&&e.x<(s.x-i.x)*(e.y-i.y)/(s.y-i.y)+i.x&&(n=!n)}return n}function ko(e,t){let n=t[0],o=1/0;for(let r=0;r<t.length;r++){let i=t[r],s=t[(r+1)%t.length],a=s.x-i.x,c=s.y-i.y,u=a*a+c*c,l=u>0?Math.max(0,Math.min(1,((e.x-i.x)*a+(e.y-i.y)*c)/u)):0,f={x:i.x+a*l,y:i.y+c*l},m=Math.hypot(e.x-f.x,e.y-f.y);m<o&&(o=m,n=f)}return n}function Ts(e,t){let n=0,o=0;for(let r of e.values()){if(r.length<3)continue;let i=r[0],s=r[r.length-1],a=s.x-i.x,c=s.y-i.y,u=Math.hypot(a,c);if(u<1e-6)continue;let l={x:(i.x+s.x)/2,y:(i.y+s.y)/2},f=ko(l,t),m=f.x-l.x,h=f.y-l.y,d=Math.hypot(m,h);d<1e-6||(o+=Math.abs((-c*m+a*h)/(u*d))*r.length,n+=r.length)}return n?o/n:0}function Sm(e,t,n){let o=e.filter(p=>p.type==="shape"),r=o.find(p=>p.role==="stage");if(r){let p=ie(r);return p?{shape:r,centre:Ao(p),outline:p,inferred:!1}:null}if(!n.length)return null;let i=1/0,s=-1/0,a=1/0,c=-1/0;for(let p of n)i=Math.min(i,p.x),s=Math.max(s,p.x),a=Math.min(a,p.y),c=Math.max(c,p.y);let u=(s-i)*(c-a),l=[];for(let p of o){if(p.role)continue;let y=ie(p);if(!y)continue;let g=zt(y);if(g*$*$<6||g>u)continue;let M=Math.min(...y.map(S=>S.x)),P=Math.max(...y.map(S=>S.x)),R=Math.min(...y.map(S=>S.y)),x=Math.max(...y.map(S=>S.y)),b=0;for(let S of n)S.x>M&&S.x<P&&S.y>R&&S.y<x&&Co(S,y)&&b++;if(b>n.length*.05)continue;let I=Ao(y),w=Ts(t,y);w>=Kf&&l.push({shape:p,centre:I,outline:y,score:w,area:g,box:[M,R,P,x]})}let f=(p,y)=>y!==p&&y.area>p.area&&p.box[0]>=y.box[0]-1e-6&&p.box[1]>=y.box[1]-1e-6&&p.box[2]<=y.box[2]+1e-6&&p.box[3]<=y.box[3]+1e-6,m=l.filter(p=>!l.some(y=>f(p,y))),h=Math.max(0,...m.map(p=>p.score)),d=m.filter(p=>p.score>=h-.03).sort((p,y)=>y.area-p.area)[0]??null;return d?{shape:d.shape,centre:d.centre,outline:d.outline,inferred:!0}:null}function Pm(e,t,n){if(!n||n.length<3)return Math.hypot(e.x-t.x,e.y-t.y);let o=ko(e,n);return Math.hypot(e.x-o.x,e.y-o.y)}function Ls(e){let t=[...e].sort((i,s)=>i.x-s.x||i.y-s.y);if(t.length<3)return t;let n=(i,s,a)=>(s.x-i.x)*(a.y-i.y)-(s.y-i.y)*(a.x-i.x),o=[];for(let i of t){for(;o.length>=2&&n(o[o.length-2],o[o.length-1],i)<=0;)o.pop();o.push(i)}let r=[];for(let i=t.length-1;i>=0;i--){let s=t[i];for(;r.length>=2&&n(r[r.length-2],r[r.length-1],s)<=0;)r.pop();r.push(s)}return[...o.slice(0,-1),...r.slice(0,-1)]}function Im(e){if(!e.length||e.length>dm)return[];let t=[...vo(e).values()],n=t.map((a,c)=>c),o=a=>n[a]===a?a:n[a]=o(n[a]),r=hm/$,i=t.map(a=>({minX:Math.min(...a.map(c=>c.x))-r,maxX:Math.max(...a.map(c=>c.x))+r,minY:Math.min(...a.map(c=>c.y))-r,maxY:Math.max(...a.map(c=>c.y))+r}));for(let a=0;a<t.length;a++)for(let c=a+1;c<t.length;c++){let u=i[a],l=i[c];if(u.maxX<l.minX||l.maxX<u.minX||u.maxY<l.minY||l.maxY<u.minY)continue;t[a].some(m=>t[c].some(h=>Math.hypot(m.x-h.x,m.y-h.y)<=r))&&(n[o(a)]=o(c))}let s=new Map;return t.forEach((a,c)=>{let u=o(c),l=s.get(u);l?l.push(...a):s.set(u,[...a])}),[...s.values()].filter(a=>new Set(a.map(c=>c.rowId)).size>=2)}function Rm(e,t,n){if(!t.length)return null;let o=t.filter(w=>n.tableIds.has(w.rowId)||w.kind==="booth").length>t.length/2,r=vo(t),i=!n.outline||Ts(r,n.outline)>=Yf,s=0,a=0;for(let w of r.values()){if(w.length<2)continue;let S=w[0],C=w[w.length-1],O=C.x-S.x,L=C.y-S.y,v=Math.hypot(O,L);if(v<1e-6)continue;let A={x:(S.x+C.x)/2,y:(S.y+C.y)/2},_=i?n.outline?ko(A,n.outline):n.focal:n.middle,k=-L/v,F=O/v;k*(_.x-A.x)+F*(_.y-A.y)<0&&(k=-k,F=-F),s+=k*w.length,a+=F*w.length}let c={x:t.reduce((w,S)=>w+S.x,0)/t.length,y:t.reduce((w,S)=>w+S.y,0)/t.length};if(Math.hypot(s,a)<1e-9){let w=i?n.focal:n.middle;s=w.x-c.x,a=w.y-c.y}let u=Math.hypot(s,a)||1,l={x:s/u,y:a/u},f=w=>-(w.x*l.x+w.y*l.y),m=w=>-w.x*l.y+w.y*l.x,h=1/0,d=-1/0,p=1/0,y=-1/0,g=1/0,M=new Map;for(let w of t){let S=f(w),C=m(w);h=Math.min(h,S),d=Math.max(d,S),p=Math.min(p,C),y=Math.max(y,C),i&&(g=Math.min(g,Pm(w,n.focal,n.outline)));let O=w.logicalRowId??w.rowId,L=M.get(O);L?L.push(S):M.set(O,[S])}i||(g=Math.max(0,h-f(n.middle)));let P=[...M.values()].map(w=>_o(w)).sort((w,S)=>w-S),R=[];if(!o)for(let w of P)R.length&&w-R[R.length-1]<Df/$||R.push(w);let x=Mm(e),b=Qe(e,{floorBaseHeightM:n.baseHeightM}),I={id:e.id,section:e,authored:x,plane:n,facing:l,facesAction:i,hull:Ls(t),sample:t.filter((w,S)=>S%Math.ceil(t.length/Zf)===0),frontD:h,backD:d,latMin:p,latMax:y,frontDistance:g,rowDepths:R,rowCount:R.length,level:0,height:b.height,rake:x?b.rake:0,backHeight:0};return I.backHeight=I.height+(d-h)*$*Math.tan(I.rake*Math.PI/180),I}function wm(e,t,n,o){if(e.length<2)return 0;let r=Math.max(1,t*$),i=n+Tf-o,s=0,a=0;for(let u=1;u<e.length;u++){let l=Math.max(Gf,(e[u]-e[u-1])*$),f=(i+Lf)*(r+l)/r;s+=f-i,a+=l,i=f,r+=l}let c=Math.atan(s/a)*180/Math.PI;return Math.round(Math.max(Cs,Math.min(Bf,c))*10)/10}function Em(e,t,n=!1){if(!n&&e.facing.x*t.facing.x+e.facing.y*t.facing.y<zf)return null;let o=-1/0,r=1/0,i=-1/0;for(let m of t.hull){o=Math.max(o,-(m.x*e.facing.x+m.y*e.facing.y));let h=-m.x*e.facing.y+m.y*e.facing.x;r=Math.min(r,h),i=Math.max(i,h)}if(Math.min(e.latMax,i)-Math.max(e.latMin,r)<(n?1e-6:ks*(e.latMax-e.latMin)))return null;let a=Os/$,c=new Map,u=new Map;for(let m of e.sample){let h=Math.floor((-m.x*e.facing.y+m.y*e.facing.x)/a),d=-(m.x*e.facing.x+m.y*e.facing.y);c.set(h,Math.min(c.get(h)??1/0,d))}for(let m of t.sample){let h=Math.floor((-m.x*e.facing.y+m.y*e.facing.x)/a),d=-(m.x*e.facing.x+m.y*e.facing.y);u.set(h,Math.max(u.get(h)??-1/0,d))}let l=[];for(let[m,h]of c){let d=u.get(m);d!==void 0&&l.push(h-d)}let f=l.length?_o(l):e.frontD-o;return f<-1/$?null:f}function Am(e,t){if(t.plane.floorIndex>=e.plane.floorIndex)return!1;let n=-1/0,o=1/0,r=1/0,i=-1/0;for(let c of t.hull){let u=-(c.x*e.facing.x+c.y*e.facing.y);n=Math.max(n,u),o=Math.min(o,u);let l=-c.x*e.facing.y+c.y*e.facing.x;r=Math.min(r,l),i=Math.max(i,l)}let s=Math.min(e.latMax,i)-Math.max(e.latMin,r),a=Math.min(e.backD,n)-Math.max(e.frontD,o);return s>ks*(e.latMax-e.latMin)&&a>1/$}function _m(e,t){let n=new Set;for(let o of e){let r=(Math.atan2(o.y-t.y,o.x-t.x)*180/Math.PI+360)%360;n.add(Math.floor(r/10))}return n.size/36}function vm(e,t){let n=1/0,o=-1/0;for(let i of t.hull){let s=-(i.x*e.facing.x+i.y*e.facing.y);n=Math.min(n,s),o=Math.max(o,s)}let r=Math.max(0,Math.min(o-n,e.frontD-n));return t.height+r*$*Math.tan(t.rake*Math.PI/180)}function Cm(e,t){if(!e.facesAction)return!1;let n={x:-e.facing.y,y:e.facing.x},o=Os/$,r=Math.max(1,Math.ceil((e.backD-e.frontD)/o)),i={left:new Map,right:new Map};for(let a of t)if(!(a===e||a.plane.floorIndex!==e.plane.floorIndex)&&!(a.facing.x*e.facing.x+a.facing.y*e.facing.y>=nm))for(let c of a.sample){let u=-(c.x*e.facing.x+c.y*e.facing.y);if(u<e.frontD||u>e.backD)continue;let l=-c.x*e.facing.y+c.y*e.facing.x,f=l<e.latMin?"left":l>e.latMax?"right":null;if(!f)return!1;let m=Math.min(r-1,Math.floor((u-e.frontD)/o)),h=f==="left"?e.latMin-l:l-e.latMax;h<(i[f].get(m)?.gap??1/0)&&i[f].set(m,{gap:h,other:a})}let s=a=>{let c=a==="left"?e.latMin:e.latMax,u=0;for(let[l,{other:f}]of i[a]){if((f.facing.x*n.x+f.facing.y*n.y)*(a==="left"?1:-1)<em)continue;let h=e.frontD+(l+.5)*o,d={x:-h*e.facing.x+c*n.x,y:-h*e.facing.y+c*n.y},p=-(d.x*f.facing.x+d.y*f.facing.y),y=-d.x*f.facing.y+d.y*f.facing.x;p<f.frontD&&y>=f.latMin&&y<=f.latMax&&u++}return u/r>=tm};return s("left")&&s("right")}function km(e,t){if(t.plane.floorIndex!==e.plane.floorIndex||t.facing.x*e.facing.x+t.facing.y*e.facing.y<am)return!1;let n=1/0,o=-1/0,r=1/0;for(let a of t.hull){let c=-a.x*e.facing.y+a.y*e.facing.x;n=Math.min(n,c),o=Math.max(o,c),r=Math.min(r,-(a.x*e.facing.x+a.y*e.facing.y))}let i=(e.frontD-r)*$;if(i<-cm||i>lm)return!1;let s=Math.max(n-e.latMax,e.latMin-o);return s*$<=um&&s*$>=-fm}function Om(e,t=!1,n=!1,o){let r=t?Uf:Xf,i=new Set(n?[]:e.filter(p=>!p.authored&&Cm(p,e))),s=[...e].sort((p,y)=>p.plane.floorIndex-y.plane.floorIndex||Number(i.has(y))-Number(i.has(p))||p.frontDistance-y.frontDistance);for(let p of i)o?.add(p.id);let a=(p,y,g)=>{let M=new Map,P=[],R=new Map,x=b=>{if(b.plane.floorIndex===0||b.plane.baseHeightM>0)return b.plane.baseHeightM;let I=R.get(b.plane.floorIndex-1);return I===void 0?b.plane.baseHeightM:I+ws};for(let b of s){if(i.has(b))b.height=x(b),b.level=0,b.rake=0,b.backHeight=b.height,M.set(b.id,void 0);else if(!b.authored){let w=x(b),S;for(let A of P){if(A.plane.floorIndex>b.plane.floorIndex)continue;if(Am(b,A)){let T=vm(b,A)+$f;T>w&&(w=T,S=A);continue}let _=Em(b,A,i.has(A));if(_==null)continue;let k=n&&!!b.plane.stageDeck&&A.level===0&&A.plane.floorIndex===b.plane.floorIndex&&Math.max(0,_)*$<=qf,F=i.has(A)?A.height+om:k?A.backHeight:A.backHeight+Ff+Math.min(Nf,Math.max(0,_)*$)*Math.tan(A.rake*Math.PI/180);F>w&&(w=F,S=A)}let C=p.get(b);C&&C.height>w+.01?(w=C.height,S=void 0):C=void 0,b.height=Math.round(Math.min(w,b.plane.baseHeightM+Vf)*100)/100;let O=!S&&!C&&b.height>b.plane.baseHeightM;if(b.level=S?S.level+1:C?C.level:O?1:0,b.rake=wm(b.rowDepths,b.frontDistance,b.height,b.plane.focalHeightM),!b.facesAction&&b.rowCount<Wf)b.rake=0;else if(b.level===0){let A=Math.max(1e-6,(b.backD-b.frontD)*$);b.rake=Math.min(b.rake,jf,Math.round(Math.atan(Hf/A)*1800/Math.PI)/10)}else b.rowCount>=2&&(b.rake=Math.max(b.rake,r[Math.min(b.level,r.length)-1]));let L=(b.backD-b.frontD)*$,v=S&&i.has(S)||C&&g?.has(C.id);if(y!==void 0&&v&&b.rowCount>=2&&(b.rake=y),t&&L>0&&b.height+L*Math.tan(b.rake*Math.PI/180)>b.plane.baseHeightM+As){let A=Math.max(0,b.plane.baseHeightM+As-b.height);b.rake=Math.max(Cs,Math.round(Math.atan(A/L)*1800/Math.PI)/10)}n&&b.plane.stageDeck&&b.level>0&&(b.rake=Math.min(b.rake,Jf)),b.backHeight=b.height+L*Math.tan(b.rake*Math.PI/180),M.set(b.id,S?.id??(C?M.get(C.id):void 0))}let I=b.plane.floorIndex;R.set(I,Math.min(R.get(I)??1/0,b.height)),P.push(b)}return M},c=a(new Map),u=new Map,l=p=>u.get(p)?.height??p.height;for(let p=!0,y=0;p&&y<e.length;y++){p=!1;for(let g of e)if(!(g.authored||i.has(g)))for(let M of e){let P=u.get(M)??M;M===g||P.height-P.plane.baseHeightM<mm||P.height<=l(g)+.01||km(g,M)&&(u.set(g,P),p=!0)}}let f=new Map(e.map(p=>[p.id,p])),m=e.filter(p=>!p.authored&&p.rowCount>=2&&i.has(f.get(c.get(p.id)??""))),h=m.length?_o(m.map(p=>p.rake)):void 0;if(!u.size&&h===void 0)return c;let d=new Map([...new Set(u.values())].map(p=>[p,{...p}]));return a(new Map([...u].map(([p,y])=>[p,d.get(y)])),h,new Set(m.map(p=>p.id)))}var Eo=(e,t)=>!!e&&e.x===t.x&&e.y===t.y;function Bs(e,t={x:0,y:-40}){let n=yt(e),o=new Map;for(let g of n){if(!g.sectionId)continue;let M=o.get(g.sectionId);M?M.push(g):o.set(g.sectionId,[g])}let r={focalInferred:!1,confident:!1,sections:[]},i=e.floors?.length?e.floors.map((g,M)=>({objects:g.objects,floorIndex:M,floorId:g.id,baseHeightM:g.baseHeightM??0,focal:g.focalPoint??e.focalPoint})):[{objects:e.objects,floorIndex:0,floorId:void 0,baseHeightM:0,focal:e.focalPoint}],s=new Set(i.flatMap(g=>g.objects.filter(M=>M.type==="table").map(M=>M.id))),a=[],c,u=new Set,l=i.map(g=>{let M=v=>!e.floors?.length||v.floorId===g.floorId,P=Im(n.filter(v=>!v.sectionId&&v.kind!=="booth"&&!s.has(v.rowId)&&M(v))),R=[];for(let v of P){let A=Le(Ve(Ls(v)),pm/$);if(n.some(k=>!M(k)&&Co(k,A)))continue;let _=`${_s}${g.floorIndex}-${R.length}`;u.add(_),o.set(_,v),R.push({type:"section",id:_,label:"",color:bm,outline:A})}let x=R.length?{...g,objects:[...g.objects,...R]}:g,b=new Set(x.objects.filter(v=>v.type==="section").map(v=>v.logicalSectionId??v.id)),I=[...o.entries()].filter(([v])=>b.has(v)).flatMap(([,v])=>v),w=Sm(x.objects,vo(I),I),S=x.focal;(w||x.focal&&!Eo(x.focal,t))&&(r.confident=!0),w&&(r.stage??={id:w.shape.id,inferred:w.inferred,...x.floorId?{floorId:x.floorId}:{}},(w.inferred||Eo(x.focal,t))&&(S=w.centre,r.focalInferred=!0));let C=w&&(!w.inferred||zt(w.outline)*$*$<=wo),O=w?void 0:c,L={tableIds:s,floorIndex:x.floorIndex,floorId:x.floorId,baseHeightM:x.baseHeightM,focal:O?.focal??S,outline:w?.outline??O?.outline,focalHeightM:O?.focalHeightM??x.baseHeightM+(w&&C?Ne({...w.shape,role:"stage"}).heightM:0),stageDeck:O?.stageDeck??!!(w&&C&&zt(w.outline)*$*$<=wo),middle:I.length?{x:I.reduce((v,A)=>v+A.x,0)/I.length,y:I.reduce((v,A)=>v+A.y,0)/I.length}:S};for(let v of x.objects){if(v.type!=="section")continue;let A=Rm(v,o.get(v.logicalSectionId??v.id)??[],L);A&&a.push(A)}return L.outline&&(c=L),Eo(x.focal,L.focal)||(r.focal??=[]).push({...x.floorId?{floorId:x.floorId}:{},point:{...L.focal}}),{unit:x,plane:L,stage:w,planeSeats:I}}),f=i.flatMap(g=>g.objects).map(g=>g.type==="shape"&&!g.role&&(Ro(g.label)==="wall"||!Ro(g.label)&&Es(g))?{...g,role:"wall"}:g),m=tt({objects:f},n)!==null;m&&(r.indoor=!0);let h=new Set,d=Om(a,m,_m(n,l[0]?.plane.focal??t)<Qf,h),p=new Map(a.filter(g=>!g.authored).map(g=>[g.id,g])),y=l.map(({unit:g,plane:M,stage:P,planeSeats:R})=>g.objects.map(x=>{let b=x.type==="shape"&&!x.role&&x.id!==P?.shape.id?Ro(x.label):null;if(x.type==="shape"&&!x.role&&x.id!==P?.shape.id&&(b==="wall"||!b&&Es(x))&&x.type==="shape"){(r.roles??=[]).push({id:x.id,...M.floorId?{floorId:M.floorId}:{},role:"wall"});let{fill:A,..._}=x;return{..._,role:"wall"}}if(b&&x.type==="shape")return(r.roles??=[]).push({id:x.id,...M.floorId?{floorId:M.floorId}:{},role:b}),{...x,role:b};let w=P?.inferred&&x.id===P.shape.id&&x.type==="shape"?gm(x,P.outline,g.objects,R):null;if(w&&x.type==="shape")return r.stage?.id===x.id&&(r.stage.field=w),{...x,role:"stage",stageKind:w};let S=x.type==="shape"&&x.id===P?.shape.id&&x.heightM===void 0&&!x.stageKind&&a.some(A=>A.plane===M&&(h.has(A.id)||A.level===0&&A.facesAction&&A.rake<=im&&(A.frontDistance+A.backD-A.frontD)*$>=sm)),C=S?{heightM:rm}:{};if(P?.inferred&&x.id===P.shape.id&&x.type==="shape"&&zt(P.outline)*$*$<=wo)return r.stage?.id===x.id&&(r.stage.deck=!0),{...x,role:"stage",...C};if(S&&x.type==="shape"&&x.role==="stage")return{...x,...C};let O=x.type==="section"?p.get(x.id):void 0;if(!O||x.type!=="section")return x;let L=O.rowCount>=2&&O.rake>0;u.has(O.id)?r.looseRowBlocks=(r.looseRowBlocks??0)+1:r.sections.push({id:O.id,floorId:M.floorId,surfaceKind:L?"rakedRows":"flat",height:O.height,rake:O.rake,stackedOn:d.get(O.id)});let v={status:"inferred",source:"public-2d-topology",note:xm};return{...x,height:O.height,rake:O.rake,surfaceKind:L?"rakedRows":"flat",physical3dProvenance:{height:v,rake:v,surfaceKind:v}}}));if(e.floors?.length){let g=e.floors.map((M,P)=>({...M,objects:y[P],focalPoint:l[P].plane.focal}));return{doc:{...e,floors:g,objects:g[0].objects,focalPoint:g[0].focalPoint},report:r}}return{doc:{...e,objects:y[0],focalPoint:l[0].plane.focal},report:r}}var Fs=/^[\p{L}\p{N}]{1,4}$/u,Tm=/^([\p{L}\p{N}]{2,})[\s\-\u2013\u2014\u00b7_./]+(.+)$/u;function Ns(e,t){let n=t?.trim();if(!n)return e;let o=e.toLocaleLowerCase("en-US"),r=n.toLocaleLowerCase("en-US");if(o.startsWith(`${r} `)){let s=e.slice(n.length).trim();if(Fs.test(s))return s}let i=Tm.exec(e);if(i){let s=i[1].toLocaleLowerCase("en-US"),a=i[2].trim();if((r.startsWith(s)||s.startsWith(r))&&Fs.test(a))return a}return e}var Ds={inline:"Inline booth \xB7 1 open side",corner:"Corner booth \xB7 2 open sides",peninsula:"Peninsula booth \xB7 3 open sides",island:"Island booth \xB7 4 open sides"},Lm=new Map(eo.map(e=>[e.key,e.label]));function Bm(e){return`picker.access.${e}`}function Gs(e){let t=[],n=e.boothType;n&&Object.prototype.hasOwnProperty.call(Ds,n)&&t.push({key:`booth:${n}`,icon:"booth",titleKey:`picker.boothType.${n}`,titleFallback:Ds[n],tone:"place"});let o=e.wheelchairSpaceType;for(let a of e.accessibility??[]){if(a==="wheelchair"&&o)continue;let c=Lm.get(a);c&&t.push({key:`access:${a}`,icon:a,titleKey:Bm(a),titleFallback:c,tone:"access"})}o==="no-seat"?t.push({key:"wheelchair:no-seat",icon:"wheelchair",titleKey:"picker.emptyWheelchairSpace",titleFallback:"Empty wheelchair space",tone:"access"}):o==="seat-present"&&t.push({key:"wheelchair:seat-present",icon:"wheelchair",titleKey:"picker.accessiblePhysicalSeat",titleFallback:"Accessible physical seat",tone:"access"}),e.aisle===!0&&t.push({key:"place:aisle",icon:"aisle",titleKey:"picker.aisleSeat",titleFallback:"Aisle seat",tone:"place"});let r=e.commercial;r?.restrictedView&&t.push({key:"mark:restrictedView",icon:"restrictedView",titleKey:"picker.restrictedView",titleFallback:"Restricted view",tone:"warn"}),r?.obstructedView&&t.push({key:"mark:obstructedView",icon:"obstructedView",titleKey:"picker.obstructedView",titleFallback:"Obstructed view",tone:"warn"}),r?.premium&&t.push({key:"mark:premium",icon:"premium",titleKey:"picker.premiumSeat",titleFallback:"Premium seat",tone:"premium"});let i=r?.note?.trim();if(i){let a=t.find(c=>c.tone==="warn"||c.tone==="premium");a?a.note=i:t.push({key:"note",icon:"note",titleKey:"picker.organizerNote",titleFallback:"Organizer note",tone:"note",note:i})}let s=typeof e.entrance=="string"?e.entrance.trim():"";return s&&t.push({key:"place:entrance",icon:"entrance",titleKey:"picker.entrance",titleFallback:"Entrance",tone:"place",note:s}),t}var Fm=1.5,Nm=30,Dm=4,Gm=3.6,jm=6,Oo=15,Hm=3,Vm=1;function Xm(e){return Math.max(Gm,Math.min(jm,2.4+.15*e))}var Zt=Math.PI*2;function Um(e,t){let n=0,o=0;for(let f of e)n+=f.x,o+=f.y;let r=Math.atan2(o/e.length-t.y,n/e.length-t.x),i=e.map(f=>{let m=Math.atan2(f.y-t.y,f.x-t.x)-r;for(;m>Math.PI;)m-=Zt;for(;m<-Math.PI;)m+=Zt;return m+r}),s=i.map((f,m)=>m).sort((f,m)=>i[f]-i[m]),a=i[s[0]],c=i[s[s.length-1]];if(c-a>Math.PI)return null;let u=f=>Math.hypot(f.x-t.x,f.y-t.y),l=f=>{let m=e[f],h=(f+e.length-1)%e.length,d=(f+1)%e.length,p=Math.abs(i[h]-i[f])<=Math.abs(i[d]-i[f])?h:d,y=e[p];return u(m)<=u(y)?[m,y]:[y,m]};return{start:a,end:c,startEdge:l(s[0]),endEdge:l(s[s.length-1])}}function js(e){return e.type==="shape"&&e.role==="wall"&&e.heightM===void 0}function To(e,t,n=()=>!0){let o=[];for(let c of e){if(!js(c)||!n(c))continue;let u=ie(c);if(!u||u.length<3)continue;let l=Um(u,t);if(!l)return[];o.push(l)}if(o.length<2)return[];let r=e.flatMap(c=>{if(c.type!=="shape"||c.role!=="entrance"&&c.role!=="exit")return[];let u=ie(c);if(!u?.length)return[];let l=0,f=0;for(let m of u)l+=m.x,f+=m.y;return[{x:l/u.length,y:f/u.length}]}),i=c=>(c%Zt+Zt)%Zt;o.sort((c,u)=>i(c.start)-i(u.start));let s=c=>Math.hypot(c.x-t.x,c.y-t.y),a=[];for(let c=0;c<o.length;c++){let u=o[c],l=o[(c+1)%o.length],f=i(l.start-u.end);if(f<=0||f>=Math.PI/2)continue;let m=b=>i(b-u.end)<f;if(o.some(b=>b!==u&&b!==l&&(m(b.start)||m(b.end)||i(u.end-b.start)<b.end-b.start)))continue;let[d,p]=u.endEdge,[y,g]=l.startEdge,M={x:(d.x+p.x)/2,y:(d.y+p.y)/2},P={x:(y.x+g.x)/2,y:(y.y+g.y)/2},R=Math.hypot(P.x-M.x,P.y-M.y)*E;if(R<Fm||R>Nm||Math.abs(s(M)-s(P))*E>Dm+.2*R)continue;let x={x:(M.x+P.x)/2,y:(M.y+P.y)/2};r.some(b=>m(Math.atan2(b.y-t.y,b.x-t.x))&&Math.abs(s(b)-s(x))*E<=Hm)||a.push({quad:[d,p,g,y],mid:x,widthM:R,openingM:Xm(R)})}return a}function Hs(e,t){let n=[];for(let i of t)if(i.text?.trim())for(let s of e){let a=Math.hypot(i.position.x-s.mid.x,i.position.y-s.mid.y)*E;a<=Oo&&n.push({text:i,gate:s,d:a})}n.sort((i,s)=>i.d-s.d);let o=new Map,r=new Set;for(let{text:i,gate:s}of n)o.has(i.id)||r.has(s)||(o.set(i.id,s),r.add(s));return o}function Vs(e,t,n,o,r,i,s,a=()=>!0){let c=To(t,wt(n),a);if(!c.length)return;let u=t.find(f=>js(f)&&a(f)),l=An(u?.fill,s);e.setMaterial(gn);for(let f of c)r-f.openingM<Vm||Mn(e,f.quad,o+f.openingM,o+r,[],l.top,l.wall,i,r);e.setMaterial(0)}var Km=6,Ym=2.2,Ln=.1,Wm=/^(gate|entrance|entry|exit|way in|way out|door)s?$/i,zm=new Set(["stage","entrance","exit","screen","suite","obstruction","sound","bar","concession","restroom","coat"]),Zm=.3,$m=1.8,Qm=.9,qm=.55,Jm=1,Xs=4e3,eh=6,Us="#d8a425",th="#e8c15a",Lo="#1c1608";function Ks(e){let t=nh(e);if(!t)return null;let n=Gs(e).find(o=>o.icon===t.icon);return{...t,name:n?.titleFallback??t.icon}}function nh(e){let t=e.accessibility;if(t?.length)return{icon:t.includes("wheelchair")?"wheelchair":t[0],color:fn(t)};let n=e.commercial;return n?.obstructedView?{icon:"obstructedView",color:Us,ink:Lo}:n?.restrictedView?{icon:"restrictedView",color:Us,ink:Lo}:n?.premium?{icon:"premium",color:th,ink:Lo}:null}function oh(e,t){if(!e)return;let n,o=0;for(let[i,s]of e)s>o&&(o=s,n=i);let r=t.categories?.find(i=>i.key===n)?.color;return r&&/^#[0-9a-f]{6}$/i.test(r)?r:void 0}var rh=6e3,ih=.25,Ys=[-90,90,-135,135,-45,45];function sh(e,t,n,o){let r=e.flatMap(({id:s,a,members:c})=>{let u=(a.minX+a.maxX)/2,l=(a.minY+a.maxY)/2,f=.5*Math.hypot(a.maxX-a.minX,a.maxY-a.minY),m=1/0;for(let h of c)m=Math.min(m,Math.hypot(t[h].x-u,t[h].y-l));return c.length&&m>=f*ih?[{id:s,cx:u,cy:l,half:f,members:c}]:[]}).sort((s,a)=>s.half-a.half),i=new Map;return r.forEach(({id:s,cx:a,cy:c,members:u},l)=>{let f=o.x-a,m=o.y-c,p=(Math.hypot(f,m)>1e-6?Math.atan2(m,f):0)+Ys[l%Ys.length]*Math.PI/180,y=Math.cos(p),g=Math.sin(p),M=-1,P=-1/0;for(let R of u){let x=(t[R].x-a)*y+(t[R].y-c)*g;x>P&&(P=x,M=R)}i.set(s,[t[M].x*E,n.seatDeckY(M),t[M].y*E])}),i}function zs(e){let{doc:t,units:n,seats:o,surfaces:r,focal:i}=e,s=t.zones??[],a=[];if(s.length){let c=new Map;for(let m of n)for(let h of m.objects)h.type==="section"&&h.zone&&c.set(h.id,h.zone);let u=new Map,l=new Map;for(let m=0;m<o.length;m++){let h=o[m],d=r.seatOwner[m],p=h.zoneId??(d?c.get(d):void 0);if(!p)continue;let y=u.get(p);y||(y={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},u.set(p,y));let g=l.get(p);g||l.set(p,g=[]),g.push(m),y.n++,h.x<y.minX&&(y.minX=h.x),h.y<y.minY&&(y.minY=h.y),h.x>y.maxX&&(y.maxX=h.x),h.y>y.maxY&&(y.maxY=h.y),y.sumY+=r.seatDeckY(m)}let f=sh(s.flatMap(m=>{let h=u.get(m.id);return h?[{id:m.id,a:h,members:l.get(m.id)??[]}]:[]}),o,r,i);for(let m of s){let h=u.get(m.id),d=[];for(let[p,y]of c)y===m.id&&d.push(p);if(!h||h.n===0){a.push({id:m.id,label:m.label,color:re(m.color),sectionIds:d,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(m.focalPoint??i).x*E,1.5,(m.focalPoint??i).y*E]});continue}a.push({id:m.id,label:m.label,color:re(m.color),sectionIds:d,seatCount:h.n,...f.has(m.id)?{labelAt:f.get(m.id)}:{},center:[(h.minX+h.maxX)/2*E,h.sumY/h.n,(h.minY+h.maxY)/2*E],radius:.5*Math.hypot((h.maxX-h.minX)*E,(h.maxY-h.minY)*E)||1,focalWorld:[(m.focalPoint??i).x*E,1.5,(m.focalPoint??i).y*E]})}}return a}function Zs(e){let{doc:t,units:n,seats:o,surfaces:r,seatData:i,hintedSeatFloor:s,zones:a,focal:c}=e,u=[],l=[],f=[],m=new Map;for(let h of n)for(let d of h.objects){if(d.type!=="section"||!d.zone)continue;let p=(d.displayLabel||d.label||"").trim().toLocaleLowerCase();if(!p)continue;let y=t.floors?.[h.index]?.name?.trim().toLocaleLowerCase();if(n.length>1&&y===p)continue;let g=m.get(d.zone);g||m.set(d.zone,g=new Set),g.add(p)}for(let h of a)h.seatCount!==0&&(m.get(h.id)?.has(h.label.trim().toLocaleLowerCase())||u.push({id:`zone:${h.id}`,kind:"zone",text:h.label,anchor:[(h.labelAt??h.center)[0],(h.labelAt??h.center)[1]+Km,(h.labelAt??h.center)[2]],color:t.zones?.find(d=>d.id===h.id)?.color}));{let h=new Map,d=new Map,p=new Map,y=new Map;for(let g=0;g<o.length;g++){let M=r.seatOwner[g];if(!M)continue;let P=h.get(M);P||(P={n:0,x:0,y:0,deck:0},h.set(M,P)),P.n++,P.x+=o[g].x,P.y+=o[g].y,P.deck+=r.seatDeckY(g);let R=o[g].categoryKey;if(R){let b=d.get(M);b||(b=new Map,d.set(M,b)),b.set(R,(b.get(R)??0)+1)}if(o[g].accessibility?.includes("wheelchair")){let b=p.get(M);b?b.push(g):p.set(M,[g])}let x=y.get(M);x||(x={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0,minDeck:1/0,maxDeck:-1/0},y.set(M,x)),x.minDeck=Math.min(x.minDeck,r.seatDeckY(g)),x.maxDeck=Math.max(x.maxDeck,r.seatDeckY(g)),o[g].x<x.minX&&(x.minX=o[g].x),o[g].x>x.maxX&&(x.maxX=o[g].x),o[g].y<x.minY&&(x.minY=o[g].y),o[g].y>x.maxY&&(x.maxY=o[g].y)}for(let g of n)for(let M of g.objects){if(M.type!=="section"||vs(M))continue;let P=h.get(M.id);if(!P||P.n===0)continue;let R=y.get(M.id),x=[P.x/P.n*E,P.deck/P.n,P.y/P.n*E],b=M.displayLabel||M.label||M.id;l.push({id:M.id,floorIndex:g.index,label:b,seatCount:P.n,center:x,radius:Math.max(1,Math.hypot(R.maxX-R.minX,R.maxY-R.minY)*.5*E),box:{min:[R.minX*E-.4,R.minDeck,R.minY*E-.4],max:[R.maxX*E+.4,R.maxDeck+1,R.maxY*E+.4]},focalWorld:[g.focal.x*E,g.baseHeightM+1.5,g.focal.y*E]});let I=t.floors?.[g.index]?.name?.trim().toLocaleLowerCase();if(!(n.length>1&&I===b.trim().toLocaleLowerCase())){let w=oh(d.get(M.id),t),S=p.get(M.id);u.push({id:`section:${M.id}`,kind:"section",text:b,anchor:[x[0],x[1]+Ym,x[2]],floorIndex:g.index,...w?{tint:w}:{},...S?{wheelchairSeats:S}:{}})}}}{for(let x of n)for(let b of x.objects){if(b.type!=="gaArea")continue;let I=mt(b.points);if(!I)continue;let w=b.labelPresentation?.visible===!1?"":b.displayLabel||b.label||b.id,S=b.capacity>0?[w,b.capacity.toLocaleString()].filter(Boolean).join(" \xB7 "):w;S&&u.push({id:`ga:${b.id}`,kind:"ga",text:S,anchor:[I.x*E,x.baseHeightM+$m,I.y*E],floorIndex:x.index})}let h=new Map,d=new Map;for(let x of n)for(let b of x.objects)if(b.type==="section"&&h.set(b.id,b.displayLabel||b.label||b.id),b.type==="row"){let I=b.displayLabel?.trim()||b.segmentedRow?.displayLabel?.trim();I&&d.set(b.id,I)}let p=new Map;for(let x=0;x<o.length;x++){let b=o[x],I=Math.hypot(b.x-c.x,b.y-c.y),w=p.get(b.rowId);(!w||I>w.far)&&p.set(b.rowId,{seat:b,index:x,far:I})}for(let[x,b]of p){let I=r.seatOwner[b.index]??b.seat.sectionId,w=Ws(b.seat.label,x,h.get(I??""),d.get(x));w&&u.push({id:`row:${x}`,kind:"row",text:w,anchor:[b.seat.x*E,r.seatDeckY(b.index)+Qm,b.seat.y*E],floorIndex:s[b.index]})}let y=new Map;for(let x=0;x<o.length;x++){let b=o[x],I=y.get(b.rowId);I||(I={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:Ws(b.label,b.rowId,h.get(r.seatOwner[x]??b.sectionId??""),d.get(b.rowId)),sectionId:r.seatOwner[x]??b.sectionId},y.set(b.rowId,I));let w=x*3,S=i.iPosition[w],C=i.iPosition[w+1],O=i.iPosition[w+2];I.n++,I.x+=S,I.y+=C,I.z+=O,I.minX=Math.min(I.minX,S),I.maxX=Math.max(I.maxX,S),I.minZ=Math.min(I.minZ,O),I.maxZ=Math.max(I.maxZ,O)}for(let[x,b]of y)f.push({id:x,label:b.label,sectionId:b.sectionId,seatCount:b.n,center:[b.x/b.n,b.y/b.n,b.z/b.n],radius:Math.max(.8,Math.hypot(b.maxX-b.minX,b.maxZ-b.minZ)*.5)});let g=0,M=(x,b)=>{g++,u.push({id:`access:${o[x].id}`,kind:"access",text:b.name,icon:b.icon,color:b.color,...b.ink?{ink:b.ink}:{},seatWidthM:i.iChairWidth[x]*2,anchor:[o[x].x*E,r.seatDeckY(x)+Jm,o[x].y*E],floorIndex:s[x],rowId:o[x].rowId})},P=null,R=()=>{if(P){let x=Ks(o[P.seats[0]]),b=P.seats.length,I=Math.max(1,Math.round(b/eh));for(let w=0;w<I&&g<Xs;w++)M(P.seats[Math.min(b-1,Math.floor((w+.5)*b/I))],x)}P=null};for(let x=0;x<o.length&&g<Xs;x++){let b=Ks(o[x]);if(b&&o[x].accessibility?.length){R(),M(x,b);continue}if(!b){R();continue}P&&P.rowId===o[x].rowId&&P.icon===b.icon?P.seats.push(x):(R(),P={rowId:o[x].rowId,icon:b.icon,seats:[x]})}if(R(),o.length<=rh)for(let x=0;x<o.length;x++){let b=o[x],I=ah(b.displayLabel||b.label);I&&u.push({id:`seat:${b.id}`,kind:"seat",seatWidthM:i.iChairWidth[x]*2,text:I,anchor:[b.x*E,r.seatDeckY(x)+qm,b.y*E],floorIndex:s[x],rowId:b.rowId})}}for(let h of n){let d=tt(h,n.length===1?o:o.filter((g,M)=>s[M]===h.index)),p=d?Hs(To(h.objects,wt(d)),h.objects.filter(g=>g.type==="text")):new Map,y=[...p.values()];for(let g of h.objects){let M=g.type==="text"?p.get(g.id):void 0;if(g.type==="shape"&&(g.role==="entrance"||g.role==="exit")&&Wm.test(g.label?.trim()??"")){let P=ie(g),R=P?mt(P):null;if(R&&y.some(x=>Math.hypot(R.x-x.mid.x,R.y-x.mid.y)*E<=Oo+x.widthM))continue}if(M&&g.type==="text")u.push({id:`text:${g.id}`,kind:"gate",text:g.text,icon:"entrance",anchor:[M.mid.x*E,h.baseHeightM+M.openingM+Ln,M.mid.y*E],color:g.color,floorIndex:h.index});else if(g.type==="shape"&&g.role&&zm.has(g.role)){let P=ie(g),R=P?mt(P):null;if(!R||!g.label||g.gate?.hideFromBuyers)continue;u.push({id:`architecture:${g.id}`,kind:g.role==="stage"?"stage":g.role==="entrance"||g.role==="exit"?"gate":"annotation",text:g.label,...g.role==="entrance"||g.role==="exit"?{icon:g.role}:{},...g.gate?.stepFree?{stepFree:!0}:{},anchor:[R.x*E,h.baseHeightM+Ne(g).heightM+Ln,R.y*E],color:g.fill,floorIndex:h.index})}else if(g.type==="text"){let P=g.semanticKind==="icon"?no(g.iconKey)?.key:void 0,R=g.text||(P?no(P).label:"");if(!R)continue;u.push({id:`text:${g.id}`,kind:"annotation",text:R,...P?{venueIcon:P}:{},anchor:P?[(g.position.x+g.fontSize/2)*E,h.baseHeightM+Ln,(g.position.y+g.fontSize/2)*E]:[g.position.x*E,h.baseHeightM+Ln,g.position.y*E],color:g.color,rotation:g.rotation,floorIndex:h.index})}else if(g.type==="booth"){if(g.labelPresentation?.visible===!1)continue;let P=De(g);if(!P)continue;let R=mt(P);if(!R)continue;u.push({id:`booth:${g.id}`,kind:"booth",text:g.displayLabel||g.label||g.id,anchor:[R.x*E,h.baseHeightM+_n+Zm,R.y*E],floorIndex:h.index})}}}return{labels:u,sections:l,rows:f}}function $s(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 ah(e){let t=e.lastIndexOf("-");return t>=0&&t<e.length-1?e.slice(t+1):e}function Ws(e,t,n,o){if(o?.trim())return o.trim();let r=e?e.lastIndexOf("-"):-1,i=r>0?e.slice(0,r):t;return i&&Ns(i,n)}function Qs(e){let{doc:t,units:n,seats:o,surfaces:r,solids:i,hintedSeatFloor:s,seatFloor:a}=e,c=[];{let u=n.map(()=>({minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}));for(let m=0;m<i.floor.length;m+=1){let h=Math.max(0,Math.min(n.length-1,Math.round(i.floor[m]))),d=m*3,p=u[h];p.minX=Math.min(p.minX,i.position[d]),p.minY=Math.min(p.minY,i.position[d+1]),p.minZ=Math.min(p.minZ,i.position[d+2]),p.maxX=Math.max(p.maxX,i.position[d]),p.maxY=Math.max(p.maxY,i.position[d+1]),p.maxZ=Math.max(p.maxZ,i.position[d+2])}let l=new Map;for(let m=0;m<n.length;m++)for(let h of n[m].objects)h.type==="section"&&l.set(h.id,m);let f=n.map(()=>({n:0,minX:1/0,minY:1/0,minDeck:1/0,maxX:-1/0,maxY:-1/0,maxDeck:-1/0,sumX:0,sumDeck:0,sumZ:0}));for(let m=0;m<o.length;m++){let h=r.seatOwner[m],d=(h!==null?l.get(h):void 0)??s[m];if(d===void 0)continue;let p=f[d],y=o[m];p.n++,y.x<p.minX&&(p.minX=y.x),y.y<p.minY&&(p.minY=y.y),y.x>p.maxX&&(p.maxX=y.x),y.y>p.maxY&&(p.maxY=y.y);let g=r.seatDeckY(m);p.sumX+=y.x*E,p.sumDeck+=g,p.sumZ+=y.y*E,p.minDeck=Math.min(p.minDeck,g),p.maxDeck=Math.max(p.maxDeck,g+1.6),a[m]=d}for(let m=0;m<n.length;m++){let h=f[m],d=t.floors?.[m],p=u[m],y=Math.min(h.n?h.minX*E:n[m].focal.x*E-1,Number.isFinite(p.minX)?p.minX:1/0),g=Math.max(h.n?h.maxX*E:n[m].focal.x*E+1,Number.isFinite(p.maxX)?p.maxX:-1/0),M=Math.min(h.n?h.minY*E:n[m].focal.y*E-1,Number.isFinite(p.minZ)?p.minZ:1/0),P=Math.max(h.n?h.maxY*E:n[m].focal.y*E+1,Number.isFinite(p.maxZ)?p.maxZ:-1/0),R=Math.min(h.n?Math.min(n[m].baseHeightM,h.minDeck):n[m].baseHeightM,Number.isFinite(p.minY)?p.minY:1/0),x=Math.max(h.n?Math.max(h.maxDeck,R+.5):R+.5,Number.isFinite(p.maxY)?p.maxY:-1/0),b=[h.n?h.sumX/h.n:(y+g)/2,h.n?h.sumDeck/h.n:(R+x)/2,h.n?h.sumZ/h.n:(M+P)/2],I=Math.max(1,.5*Math.hypot(g-y,x-R,P-M));c.push({index:m,id:d?.id??`floor-${m}`,label:d?.name??(n.length>1?`Floor ${m+1}`:"Venue"),seatCount:h.n,center:b,radius:I,box:{min:[y,R,M],max:[g,x,P]},focalWorld:[n[m].focal.x*E,n[m].baseHeightM+1.5,n[m].focal.y*E]})}}return c}function Bo(e,t){let n=1/0,o=1/0,r=-1/0,i=-1/0,s=(a,c)=>{a<n&&(n=a),c<o&&(o=c),a>r&&(r=a),c>i&&(i=c)};for(let a of t)s(a.x,a.y);for(let a of e)for(let c of a.objects)if(c.type==="section")for(let u of c.outline)s(u.x,u.y);else if(c.type==="shape"&&c.points)for(let u of c.points)s(u.x,u.y);else if(c.type==="gaArea")for(let u of c.points)s(u.x,u.y);else if(c.type==="booth"){let u=De(c);if(u)for(let l of u)s(l.x,l.y)}else if(c.type==="table"){let u=vn(c);if(u)for(let l of u)s(l.x,l.y)}else if(c.type==="decorImage"){let u=Cn(c);if(u)for(let l of u)s(l.x,l.y)}return Number.isFinite(n)||(n=-100,o=-100,r=100,i=100),{minX:n,minY:o,maxX:r,maxY:i}}function oa(e,t,n,o,r,i,s){if(t.length===1){let a=n.map(m=>({x:m.x,y:m.y}));for(let m of t[0].objects)m.type==="section"?a.push(...m.outline):m.type==="shape"?a.push(...ie(m)??m.points??[]):m.type==="gaArea"?a.push(...m.points):m.type==="booth"?a.push(...De(m)??[]):m.type==="table"?a.push(...vn(m)??[]):m.type==="decorImage"&&a.push(...Cn(m)??[]);if(ea(e,t[0],n,i)||na(e,t[0],n,a,i))return!1;if(s&&Js(e,t[0].baseHeightM,a,i,s))return!0;let c=Vt(a),u=(r.minX+r.maxX)/2,l=(r.minY+r.maxY)/2,f=c.length>=3?c.map(m=>{let h=m.x-u,d=m.y-l,p=Math.max(1,Math.hypot(h,d));return{x:m.x+h/p*80,y:m.y+d/p*80}}):Dt(r.minX-28,r.minY-28,r.maxX-r.minX+56,r.maxY-r.minY+56);return z(e,f,void 0,()=>-.04,-.22,i.ground,i.ground,K),!1}else{let a=t.reduce((y,g)=>g.baseHeightM<y.baseHeightM?g:y);e.setFloor(a.index);let c={...a,objects:t.flatMap(y=>y.objects)},u=n.map(y=>({x:y.x,y:y.y}));for(let y of c.objects)y.type==="section"&&u.push(...y.outline);if(ea(e,c,n,i)||na(e,c,n,u,i))return!1;if(s&&Js(e,a.baseHeightM,u,i,s))return!0;let l=n.filter((y,g)=>o[g]===a.index),f=Bo([a],l),m=Math.hypot(f.maxX-f.minX,f.maxY-f.minY),h=Math.max(28,Math.min(80,m*.04)),d=Dt(f.minX-h,f.minY-h,f.maxX-f.minX+h*2,f.maxY-f.minY+h*2),p=a.baseHeightM-.03;return z(e,d,void 0,()=>p,p-.22,i.ground,i.ground,K),!1}}function Fo(e,t,n,o){let{cx:r,cz:i,radius:s}=n,a=1/0,c=1/0,u=1/0,l=-1/0,f=-1/0,m=-1/0,h=(y,g,M)=>{a=Math.min(a,y),l=Math.max(l,y),c=Math.min(c,g),f=Math.max(f,g),u=Math.min(u,M),m=Math.max(m,M)};for(let y=0;y<e.position.length;y+=3){let g=y/3;o&&g>=o[0]&&g<o[1]||h(e.position[y],e.position[y+1],e.position[y+2])}for(let y=0;y<t.count;y++){let g=y*3,M=t.iPosition[g],P=t.iPosition[g+1],R=t.iPosition[g+2],x=Math.max(.35,t.iMaxRadius[y]??.35);h(M-x,P,R-x),h(M+x,P+1.6,R+x)}Number.isFinite(a)||(a=r-s,l=r+s,c=0,f=s*.16,u=i-s,m=i+s);let d=[(a+l)/2,(c+f)/2,(u+m)/2],p=Math.max(1,.5*Math.hypot(l-a,f-c,m-u));return{center:d,radius:p,minY:c,maxY:f}}var ch=4096;function ra(e,t,n=[]){let o=Math.max(1,Math.ceil(e.count/ch)),r=Math.ceil(e.count/o),i=new Float32Array((r*2+t.length*4+n.length)*3),s=0;for(let a=0;a<e.count;a+=o){let c=e.iPosition[a*3],u=e.iPosition[a*3+1],l=e.iPosition[a*3+2];i[s++]=c,i[s++]=u,i[s++]=l,i[s++]=c,i[s++]=0,i[s++]=l}for(let[a,c,u]of n)i[s++]=a,i[s++]=c,i[s++]=u;for(let a of t)for(let[c,u]of[[-1,-1],[1,-1],[1,1],[-1,1]])i[s++]=a.cx+c*a.halfX,i[s++]=a.y,i[s++]=a.cz+u*a.halfZ;return i.subarray(0,s)}function ia(e,t,n,o,r,i,s=[]){let a=1/0,c=1/0,u=-1/0,l=-1/0;for(let x=0;x<e.count;x++){let b=x*3,I=e.iPosition[b],w=e.iPosition[b+2];I<a&&(a=I),I>u&&(u=I),w<c&&(c=w),w>l&&(l=w)}for(let[x,,b]of s)x<a&&(a=x),x>u&&(u=x),b<c&&(c=b),b>l&&(l=b);for(let x of t)a=Math.min(a,x.cx-x.halfX),u=Math.max(u,x.cx+x.halfX),c=Math.min(c,x.cz-x.halfZ),l=Math.max(l,x.cz+x.halfZ);let f=n.minX*E,m=n.maxX*E,h=n.minY*E,d=n.maxY*E,p=f,y=m,g=h,M=d;if(Number.isFinite(a)){let x=Math.max(2,.06*Math.hypot(u-a,l-c));p=Math.max(f,a-x),y=Math.min(m,u+x),g=Math.max(h,c-x),M=Math.min(d,l+x)}let P=Math.min(0,o),R=Math.max(r,i*.05);return{min:[p,P,g],max:[y,R,M]}}var qs=12,lh=.6,uh=40;function Js(e,t,n,o,r){let i=Vt([...n]);if(i.length<3)return!1;let s=1/0,a=1/0,c=-1/0,u=-1/0;for(let R of i)s=Math.min(s,R.x),c=Math.max(c,R.x),a=Math.min(a,R.y),u=Math.max(u,R.y);let l=Math.hypot(c-s,u-a)*E,f=Le(i,qs/E,1.2),m=Math.max(uh,l*lh),h=Le(i,(qs+m)/E,1.2);if(f.length!==h.length)return!1;let d=oe(o.ground,[.78,.76,.72],.35),p=oe(o.ground,[.56,.62,.52],.3);z(e,f,void 0,()=>t-.04,t-.22,d,d,K);let y=t-.05,g=f.map(R=>[R.x*E,y,R.y*E]),M=h.map(R=>[R.x*E,y,R.y*E]),P=[0,1,0];for(let R=0;R<g.length;R++){let x=(R+1)%g.length;e.tri(g[R],M[x],M[R],P,p,r,r),e.tri(g[R],g[x],M[x],P,p,p,r)}return!0}function ea(e,t,n,o){let r=tt(t,n);if(!r)return!1;let i=t.baseHeightM,s=oe(o.ground,[.62,.55,.47],.4);return z(e,r,void 0,()=>i-.04,i-.22,s,s,K),!0}var fh=3e3,mh=20,ta=1.5,hh=1.2,dh=.25;function na(e,t,n,o,r){if(!n.length||n.length>fh||o.length<3)return!1;for(let S of t.objects){if(S.type==="shape"&&en(S.stageKind))return!1;if(S.type==="section"){let{height:C}=Qe(S,{floorBaseHeightM:t.baseHeightM});if(C-t.baseHeightM>mh)return!1}}let i=0,s=0;for(let S of o)i+=S.x,s+=S.y;i/=o.length,s/=o.length;let a=0,c=0,u=0;for(let S of o){let C=S.x-i,O=S.y-s;a+=C*C,c+=O*O,u+=C*O}let l=.5*Math.atan2(2*u,a-c),f=Math.cos(l),m=Math.sin(l),h=-m,d=f,p=1/0,y=-1/0,g=1/0,M=-1/0;for(let S of o){let C=(S.x-i)*f+(S.y-s)*m,O=(S.x-i)*h+(S.y-s)*d;p=Math.min(p,C),y=Math.max(y,C),g=Math.min(g,O),M=Math.max(M,O)}let P=S=>[[p-S,g-S],[y+S,g-S],[y+S,M+S],[p-S,M+S]].map(([C,O])=>({x:i+f*C+h*O,y:s+m*C+d*O})),R=P(ta/E),x=P((ta+dh)/E),b=t.baseHeightM,I=oe(r.ground,[.62,.55,.47],.4),w=oe(r.ground,[.86,.86,.84],.55);return z(e,x,void 0,()=>b-.04,b-.22,I,I,K),z(e,x,[R.slice().reverse()],()=>b+hh,b-.04,oe(w,[1,1,1],.2),w,K),!0}function sa(e,t,n){let o=()=>({byObjectId:new Map,elements:[]});if(!t||!e)return o();let r=lr(t);if(!r.ok||r.value.id!==e)return o();let i=new Map;for(let f of n)for(let m of f.objects)m.type==="shape"&&i.set(m.id,{shape:m,unit:f});let s=new Set,a=new Set,c=new Map((t.overlay.productionElements??[]).map(f=>{let m=f.runtimeContentImageUrl;return[f.id,typeof m=="string"&&/^(?:blob:|data:image\/|https:\/\/)/.test(m)?m:void 0]})),u=[];for(let f of r.value.overlay.productionElements??[]){let m=i.get(f.objectId),h=m?ie(m.shape):null,d=f.baseElevationM??0;if(!m||!h||h.length<3||!f.id||s.has(f.id)||a.has(f.objectId)||!Number.isFinite(f.heightM)||f.heightM<.05||f.heightM>50||!Number.isFinite(d)||d<-10||d>100)return o();s.add(f.id),a.add(f.objectId);let p=h.map(w=>w.x*E),y=h.map(w=>w.y*E),g=m.unit.baseHeightM+d,M=Math.min(...p),P=Math.max(...p),R=Math.min(...y),x=Math.max(...y),b,I=c.get(f.id)??f.contentImageUrl;if(f.kind==="screen"&&I&&(b=Oi(h,g,g+f.heightM,m.unit.focal),!b))if(P-M>=x-R){let w=Math.abs(R-m.unit.focal.y*E)<=Math.abs(x-m.unit.focal.y*E)?R-.006:x+.006;b=[[M,g,w],[P,g,w],[M,g+f.heightM,w],[P,g+f.heightM,w]]}else{let w=Math.abs(M-m.unit.focal.x*E)<=Math.abs(P-m.unit.focal.x*E)?M-.006:P+.006;b=[[w,g,R],[w,g,x],[w,g+f.heightM,R],[w,g+f.heightM,x]]}u.push({id:f.id,objectId:f.objectId,kind:f.kind,floorIndex:m.unit.index,baseY:g,topY:g+f.heightM,bounds:{min:[M,g,R],max:[P,g+f.heightM,x]},occlusion:f.occlusion,...I?{contentImageUrl:I}:{},...b?{contentPlane:b}:{}})}let l=u.sort((f,m)=>f.id.localeCompare(m.id));return{byObjectId:new Map(l.map(f=>[f.objectId,f])),elements:l}}var aa=[.13,.14,.17],Ct=[.4,.43,.47],ph=.18,bh=.02,yh=2.4,gh=1500,xh=240,Mh=.25;function ca(e,t,n,o){let r=t.stageKind??"";if(st(r)||r==="round"||!o.length)return;let i=ie(t);if(!i||i.length<3)return;let s={x:i.reduce((k,F)=>k+F.x,0)/i.length,y:i.reduce((k,F)=>k+F.y,0)/i.length},a=0,c=0,u=new Set;for(let k of o)a+=k.x,c+=k.y,u.add(Math.floor(Math.atan2(k.y-s.y,k.x-s.x)*180/Math.PI/10));let l=s.x-a/o.length,f=s.y-c/o.length,m=Math.hypot(l,f);if(m<1e-6)return;let h=o.reduce((k,F)=>k+Math.hypot(F.x-s.x,F.y-s.y),0)/o.length;if(u.size*10>xh&&m<Mh*h)return;let d=l/m,p=f/m,y=-p,g=d,M=-1/0,P=1/0,R=1/0,x=-1/0;for(let k of i){let F=(k.x-s.x)*d+(k.y-s.y)*p,T=(k.x-s.x)*y+(k.y-s.y)*g;M=Math.max(M,F),P=Math.min(P,F),R=Math.min(R,T),x=Math.max(x,T)}let b=(x-R)*E,I=(M-P)*E;if(b<3||I<1.5||b*I>gh)return;let w=ph/E,S=(k,F)=>({x:s.x+d*k+y*F,y:s.y+p*k+g*F}),C=(k,F,T,B)=>[S(k,T),S(k,B),S(F,B),S(F,T)],O=n+Math.max(3.5,Math.min(8,b*.35)),L=n+Math.min(yh,O-n-1),v=.2/E,A=P+Math.min(I*.25,1.5)/E,_=bh/E;z(e,C(M-2*w+_,M-w-_,R+w+v,x-w-v),void 0,()=>L,n,aa,aa,K);for(let[k,F]of[[R+w,R+w+v],[x-w-v,x-w]])z(e,C(M-2*w,M-w,k,F),void 0,()=>O+.3,n,Ct,Ct,K),z(e,C(A+v,M-2*w,k,F),void 0,()=>O+.3,O,Ct,Ct,K);z(e,C(A,A+v,R+w,x-w),void 0,()=>O+.3,O,Ct,Ct,K)}function ke(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ce(e){return Array.isArray(e)?e:[]}function Sh(e){let t=[e];for(;t.length;){let n=t.pop();if(Array.isArray(n)){t.push(...n);continue}if(!ke(n))continue;let o=ke(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 Bn(e,t){return!Array.isArray(e)||e.length!==t||!e.every(n=>typeof n=="number"&&Number.isFinite(n))?null:e}function Ph(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Ih(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 Rh(e){let t=Bn(e.matrix,16);if(t)return t;if(e.matrix!==void 0)return null;let n=e.translation===void 0?[0,0,0]:Bn(e.translation,3),o=e.rotation===void 0?[0,0,0,1]:Bn(e.rotation,4),r=e.scale===void 0?[1,1,1]:Bn(e.scale,3);if(!n||!o||!r)return null;let[i,s,a,c]=o,u=Math.hypot(i,s,a,c);if(!(u>1e-8))return null;let l=i/u,f=s/u,m=a/u,h=c/u,d=l+l,p=f+f,y=m+m,g=l*d,M=l*p,P=l*y,R=f*p,x=f*y,b=m*y,I=h*d,w=h*p,S=h*y;return[(1-(R+b))*r[0],(M+S)*r[0],(P-w)*r[0],0,(M-S)*r[1],(1-(g+b))*r[1],(x+I)*r[1],0,(P+w)*r[2],(x-I)*r[2],(1-(g+R))*r[2],0,n[0],n[1],n[2],1]}function wh(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 Eh(e){let t=e[0],n=e[4],o=e[8],r=e[1],i=e[5],s=e[9],a=e[2],c=e[6],u=e[10],l=i*u-s*c,f=s*a-r*u,m=r*c-i*a,h=t*l+n*f+o*m;if(Math.abs(h)<1e-12)return null;let d=1/h;return[l*d,f*d,m*d,(o*c-n*u)*d,(t*u-o*a)*d,(n*a-t*c)*d,(n*s-o*i)*d,(o*r-t*s)*d,(t*i-n*r)*d]}function la(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 Ah(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 c=JSON.parse(new TextDecoder().decode(a).replace(/[\u0000 ]+$/g,""));if(!ke(c))return null;o=c}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 _h(e){return e===5120||e===5121?1:e===5122||e===5123?2:e===5125||e===5126?4:0}function vh(e){return e==="SCALAR"?1:e==="VEC2"?2:e==="VEC3"?3:e==="VEC4"?4:0}function Ch(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 kh(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=Ah(t);if(!n)return{ok:!1,issue:"invalid_glb"};let{json:o,bin:r}=n;if(!ke(o.asset)||o.asset.version!=="2.0")return{ok:!1,issue:"unsupported_glb"};let i=Ce(o.extensionsUsed).filter(R=>typeof R=="string");if(i.includes("KHR_draco_mesh_compression")||Sh(o))return{ok:!1,issue:"draco_not_allowed"};if(i.length||Ce(o.extensionsRequired).length)return{ok:!1,issue:"unsupported_glb"};if(Ce(o.images).length||Ce(o.textures).length)return{ok:!1,issue:"external_resource"};let s=Ce(o.buffers);if(s.length!==1||!ke(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=Ce(o.accessors),c=Ce(o.bufferViews),u=Ce(o.meshes),l=Ce(o.nodes),f=Ce(o.scenes),m=typeof o.scene=="number"?o.scene:0;if(!ke(f[m]))return{ok:!1,issue:"unsupported_glb"};let h=new DataView(r.buffer,r.byteOffset,r.byteLength),d=(R,x,b)=>{if(typeof R!="number"||!Number.isInteger(R)||!ke(a[R]))return null;let I=a[R];if(I.type!==x||I.sparse!==void 0||I.normalized===!0||typeof I.count!="number"||!Number.isInteger(I.count)||I.count<1||typeof I.componentType!="number"||!b.includes(I.componentType)||typeof I.bufferView!="number")return null;let w=c[I.bufferView];if(!ke(w)||w.buffer!==0||typeof w.byteLength!="number"||!Number.isInteger(w.byteLength)||w.byteLength<0)return null;let S=vh(I.type),C=_h(I.componentType),O=typeof w.byteStride=="number"?w.byteStride:S*C,L=typeof w.byteOffset=="number"?w.byteOffset:0,v=typeof I.byteOffset=="number"?I.byteOffset:0,A=L+v,_=v+(I.count-1)*O+S*C;if(!Number.isInteger(O)||!Number.isInteger(L)||!Number.isInteger(v)||O<S*C||L<0||v<0||L+w.byteLength>r.byteLength||_>w.byteLength)return null;let k=[];for(let F=0;F<I.count;F++){let T=[];for(let B=0;B<S;B++){let D=Ch(h,A+F*O+B*C,I.componentType);if(!Number.isFinite(D))return null;T.push(D)}k.push(T)}return k},p=[],y=[],g=0,M=new Set,P=(R,x)=>{if(typeof R!="number"||!Number.isInteger(R)||!ke(l[R])||M.has(R))return!1;M.add(R);let b=l[R],I=Rh(b);if(!I)return!1;let w=Ih(x,I),S=Eh(w);if(!S)return!1;if(b.mesh!==void 0){if(typeof b.mesh!="number")return!1;let C=u[b.mesh];if(!ke(C))return!1;for(let O of Ce(C.primitives)){if(!ke(O)||O.mode!==void 0&&O.mode!==4||!ke(O.attributes))return!1;let L=d(O.attributes.POSITION,"VEC3",[5126]),v=O.attributes.NORMAL===void 0?null:d(O.attributes.NORMAL,"VEC3",[5126]);if(!L||O.attributes.NORMAL!==void 0&&!v)return!1;let A=L.length;if(O.indices!==void 0){let k=typeof O.indices=="number"?a[O.indices]:null;A=ke(k)?k.count:void 0}if(typeof A!="number"||!Number.isInteger(A)||A%3!==0||(g+=A/3,g>1e5))return!1;let _=O.indices===void 0?L.map((k,F)=>[F]):d(O.indices,"SCALAR",[5121,5123,5125]);if(!_||_.length%3!==0||_.length!==A)return!1;for(let k=0;k<_.length;k+=3){let F=[_[k][0],_[k+1][0],_[k+2][0]];if(F.some(D=>!Number.isInteger(D)||D<0||D>=L.length))return!1;let T=F.map(D=>wh(w,...L[D])),B=null;if(!v){let D=T[1][0]-T[0][0],H=T[1][1]-T[0][1],N=T[1][2]-T[0][2],U=T[2][0]-T[0][0],V=T[2][1]-T[0][1],Z=T[2][2]-T[0][2];B=la([1,0,0,0,1,0,0,0,1],H*Z-N*V,N*U-D*Z,D*V-H*U)}for(let D=0;D<3;D++)p.push(...T[D]),y.push(...v?la(S,...v[F[D]]):B)}}}for(let C of Ce(b.children))if(!P(C,w))return!1;return M.delete(R),!0};for(let R of Ce(f[m].nodes))if(!P(R,Ph()))return{ok:!1,issue:g>1e5?"triangle_limit":"unsupported_glb"};return!g||p.length!==g*9||y.length!==p.length?{ok:!1,issue:"unsupported_glb"}:{ok:!0,triangleCount:g,position:new Float32Array(p),normal:new Float32Array(y)}}function ua(e){try{return kh(e)}catch{return{ok:!1,issue:"invalid_glb"}}}function fa(e){let{doc:t}=e,n=kr(t.theme),o=n.structure,r=xi(t,e.eventConfigurationId??t.eventConfigurationId),i=sa(e.eventConfigurationId,e.eventConfiguration,r),s=e.seats,a=new cn,c=null;if(e.registeredShellGlb){let G=ua(e.registeredShellGlb);if(G.ok){let j=G.position.length/3,J=new Float32Array(G.position.length),me=n.materials.shell??o.tierWall;for(let xe=0;xe<j;xe++){let Ie=G.normal[xe*3+1],ae=Ie<-.25?.4:.62+.38*Math.max(0,Ie);J[xe*3]=me[0]*ae,J[xe*3+1]=me[1]*ae,J[xe*3+2]=me[2]*ae}c={position:G.position,normal:G.normal,color:J,floor:new Float32Array(j).fill(-2),material:new Float32Array(j),count:j}}}let u=new Map;for(let G of r)for(let j of G.objects)u.set(j.id,G.index),j.type==="section"&&u.set(j.logicalSectionId??j.id,G.index);let l=s.map(G=>u.get(G.sectionId??"")??u.get(G.rowId??"")??0),f=Bo(r,s),m=a.vertexCount,d=oa(a,r,s,l,f,o,oe(n.background.top,n.background.bottom,.5))?a.vertexCount:m,p=Qr(t,s),y=new Map,g=new Map;for(let G of t.categories??[])y.set(G.key,G.color),G.seatGlyph&&g.set(G.key,G.seatGlyph);let M=[],P=ki(r,s,l),R=new Map;s.forEach((G,j)=>{let J=P.seatDeckY(j);Number.isFinite(J)&&R.set(G.rowId,Math.min(R.get(G.rowId)??1/0,J))});let x=new Float32Array(s.length),b=[],I=new Map((t.floors??[]).map((G,j)=>[G.id,j])),w=r.map(()=>[]);for(let G of s){let j=G.floorId?I.get(G.floorId)??0:0;w[Math.min(j,w.length-1)]?.push(G)}let S=(G,j)=>{if(!j||j.length<3)return!1;let J=Math.min(...j.map(ae=>ae.x)),me=Math.max(...j.map(ae=>ae.x)),xe=Math.min(...j.map(ae=>ae.y)),Ie=Math.max(...j.map(ae=>ae.y));for(let ae=0;ae<G;ae++)for(let ce of w[ae])if(!(ce.x<J||ce.x>me||ce.y<xe||ce.y>Ie)&&Pe(ce,j,void 0))return!0;return!1},C=null,O=G=>r.length===1?s:s.filter((j,J)=>l[J]===G),L=(G,j)=>{let J=De(G);if(!J)return!1;let me=1/0,xe=1/0,Ie=-1/0,ae=-1/0;for(let ce of J)me=Math.min(me,ce.x),Ie=Math.max(Ie,ce.x),xe=Math.min(xe,ce.y),ae=Math.max(ae,ce.y);return s.some((ce,Ge)=>ce.kind!=="booth"&&(r.length===1||l[Ge]===j)&&ce.x>me&&ce.x<Ie&&ce.y>xe&&ce.y<ae&&_e(J,ce.x,ce.y))},v;for(let G=0;G<r.length;G++){let j=r[G];a.setFloor(G);let J=tt(j,O(G)),me=0;if(J){let W=0;for(let he of j.objects)if(he.type==="section")for(let Me of P.bySection.get(he.id)?.rowLevels??[])W=Math.max(W,Me.y-j.baseHeightM);if(me=Ei(W),!v){let he=wt(J);v={centre:[he.x*E,he.y*E]}}}let xe=new yn,Ie=[],ae=j.objects.filter(W=>W.type==="shape"&&(W.role==="entrance"||W.role==="exit")),ce=j.objects.filter(W=>W.type==="section"&&!!W.outline&&W.outline.length>=3),Ge=ss(j.objects.filter(W=>W.type==="booth"),j.focal);for(let W of j.objects)if(W.type==="section"){let he=a.vertexCount;Ps(a,W,j,qr(W,p),P.bySection.get(W.id),xe,ce,o,G>0&&S(G,W.outline));let Me=a.vertexCount-he;Me>0&&b.push({sectionId:W.id,start:he,count:Me})}else if(W.type==="shape"){let he=i.byObjectId.get(W.id),Me=M.length,rt=J!==null&&W.role==="wall"&&!he;a.setMaterial(rt?gn:(he?.kind??W.role)==="screen"?1:0);let it=W.role==="stage"&&!he?cs(W,O(G)):rt&&W.heightM===void 0?{...W,heightM:me}:W,Ze=Ri(it,Ie);if(ns(a,it,j.baseHeightM+Ze.supportOffsetM,Ze.topOffsetM-Ze.supportOffsetM,o,j.focal,M,he,ae),a.setMaterial(0),W.role==="stage"&&!he&&M.length>Me&&(C??G)===G){C=G;let $e=t.floors?.[G]?.id,kt=r.length>1&&$e?s.filter($t=>$t.floorId===$e):s;ca(a,it,M[M.length-1].y,kt)}}else W.type==="gaArea"?rs(a,W,j.baseHeightM,re(y.get(W.categoryKey)),o):W.type==="booth"?Ji(a,W,j.baseHeightM,re(y.get(W.categoryKey)),o,Ge.get(W.id)??j.focal,L(W,G)):W.type==="table"?ts(a,W,Math.max(j.baseHeightM,R.get(W.id)??j.baseHeightM),re(W.fill??t.theme?.decorFill??"#232c40"),o,!!(W.fill??t.theme?.decorFill)):W.type==="decorImage"&&os(a,W,j.baseHeightM,o);J&&Vs(a,j.objects,J,j.baseHeightM,me,j.focal,o,W=>!i.byObjectId.has(W.id)),Rs(a,j,s,P,o,n.materials.shell,!c)}let A=r.length>1?{x:r.reduce((G,j)=>G+j.focal.x,0)/r.length,y:r.reduce((G,j)=>G+j.focal.y,0)/r.length}:t.focalPoint??{x:(f.minX+f.maxX)/2,y:(f.minY+f.maxY)/2},_=Ir(c?[a.build(),c]:[a.build()]),k=si(s,e.initialState,P,x,y,g),F=zs({doc:t,units:r,seats:s,surfaces:P,focal:A}),{labels:T,sections:B,rows:D}=Zs({doc:t,units:r,seats:s,surfaces:P,seatData:k,hintedSeatFloor:l,zones:F,focal:A}),H=new Map(B.map((G,j)=>[G.id,j]));P.seatOwner.forEach((G,j)=>{k.iSection[j]=G?H.get(G)??-1:-1});let N=Qs({doc:t,units:r,seats:s,surfaces:P,solids:_,hintedSeatFloor:l,seatFloor:x});$s(T,N),k.iYaw=ii(k.iPosition,s.length,G=>s[G].rowId,G=>{let j=r[x[G]]?.focal??A;return[j.x*E,j.y*E]});let U=(f.minX+f.maxX)/2*E,V=(f.minY+f.maxY)/2*E,Z=.5*Math.hypot((f.maxX-f.minX)*E,(f.maxY-f.minY)*E)||10,X=Fo(_,k,{cx:U,cz:V,radius:Z},[m,d]),te=Fo(_,k,{cx:U,cz:V,radius:Z}),Q=Oh(r),fe=ia(k,M,f,X.minY,X.maxY,Z,Q);return{sharedAisles:Rr(r.flatMap(G=>G.objects.flatMap(j=>{if(j.type!=="section")return[];let J=P.bySection.get(j.id);return J?[{sectionId:j.id,floorIndex:G.index,rows:J.rowLevels}]:[]}))),solids:_,sectionSolidRanges:b,seats:k,seatSectionIds:P.seatOwner,bounds:{center:[(fe.min[0]+fe.max[0])/2,(fe.min[1]+fe.max[1])/2,(fe.min[2]+fe.max[2])/2],radius:Z,groundY:0,box:fe,fitPoints:ra(k,M,Q)},...v?{room:v}:{},...!v&&r.some(G=>G.objects.some(j=>j.type==="shape"&&en(j.stageKind)))?{outdoor:!0}:{},renderBounds:{center:X.center,radius:X.radius},clipBounds:{center:te.center,radius:te.radius},stateColorLUT:Or(n,un),theme:n,seatCount:s.length,focalWorld:[A.x*E,1.5,A.y*E],zones:F,stages:M,productionElements:i.elements,sections:B,rows:D,labels:T,floors:N}}function Oh(e){let t=[];for(let n of e)for(let o of n.objects){let r=o.type==="gaArea"?o.points:o.type==="booth"?De(o):null;for(let i of r??[])t.push([i.x*E,n.baseHeightM,i.y*E])}return t}function Th(e,t){let{doc:n,report:o}=Bs(e),r=o.confident&&(o.sections.length>0||!!o.looseRowBlocks);if(!r&&!o.roles?.length)return null;if(!r){let c=new Map(o.roles.map(h=>[h.id,h.role])),u=h=>h.map(d=>d.type==="shape"&&c.has(d.id)?{...d,role:c.get(d.id)}:d),l=e.floors?.map(h=>({...h,objects:u(h.objects)})),f=new Float64Array(t.length).fill(Number.NaN),m=new Float64Array(t.length*2).fill(Number.NaN);return t.forEach((h,d)=>{h.eyeHeightM!==void 0&&(f[d]=h.eyeHeightM),h.focalPoint&&(m[d*2]=h.focalPoint.x,m[d*2+1]=h.focalPoint.y)}),{doc:{...e,objects:l?.[0]?.objects??u(e.objects),...l?{floors:l}:{}},report:o,eyeHeightM:f,focal:m}}let i=new Map(yt(n).map(c=>[c.id,c])),s=new Float64Array(t.length).fill(Number.NaN),a=new Float64Array(t.length*2).fill(Number.NaN);return t.forEach((c,u)=>{let l=i.get(c.id)??c;l.eyeHeightM!==void 0&&(s[u]=l.eyeHeightM),l.focalPoint&&(a[u*2]=l.focalPoint.x,a[u*2+1]=l.focalPoint.y)}),{doc:n,report:o,eyeHeightM:s,focal:a}}function Lh(e,t){return e.map((n,o)=>{let r=t.eyeHeightM[o],i=t.focal[o*2],s=t.focal[o*2+1],a={...n};return Number.isNaN(r)?delete a.eyeHeightM:a.eyeHeightM=r,Number.isNaN(i)?delete a.focalPoint:a.focalPoint={x:i,y:s},a})}function ma(e){let t=e.estimate===!1?null:Th(e.doc,e.seats);return t?{input:{...e,doc:t.doc,seats:Lh(e.seats,t)},estimate:t}:{input:e}}function Bh(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 ha=self;ha.onmessage=e=>{let t=performance.now(),n=!e.data.seats,o=e.data.seats??yt(e.data.doc),{input:r,estimate:i}=ma({doc:e.data.doc,seats:o,eventConfigurationId:e.data.eventConfigurationId,eventConfiguration:e.data.eventConfiguration,registeredShellGlb:e.data.registeredShellGlb,estimate:e.data.estimate}),s=fa(r),a=Bh(s);i&&a.push(i.eyeHeightM.buffer,i.focal.buffer),ha.postMessage({model:s,buildMs:performance.now()-t,...n?{seats:o}:{},...i?{estimate:i}:{}},a)};
|