@seatlayer/core 0.101.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.
Files changed (183) hide show
  1. package/dist/ar-D6ASWQBI.js +1 -0
  2. package/dist/be-T23MSCFC.js +1 -0
  3. package/dist/bg-2MMSY43I.js +1 -0
  4. package/dist/ca-EXRTYE33.js +1 -0
  5. package/dist/{categoryInventory-H77A_8pF.d.cts → categoryInventory-D_gpkfsq.d.cts} +1 -1
  6. package/dist/{categoryInventory-DZ5IcDOy.d.ts → categoryInventory-i-mGCBD3.d.ts} +1 -1
  7. package/dist/chunk-2STEWCI2.js +1 -0
  8. package/dist/chunk-33SRM2CP.js +1 -0
  9. package/dist/chunk-3W4ZMU4G.js +1 -0
  10. package/dist/chunk-76AUT55N.js +1 -0
  11. package/dist/chunk-B75VUM6L.js +1 -0
  12. package/dist/{chunk-L34T3APU.js → chunk-FAY7ARLB.js} +1 -1
  13. package/dist/{chunk-2RNZOV5I.js → chunk-GPZFVQXV.js} +1 -1
  14. package/dist/chunk-JRZHC75P.js +1 -0
  15. package/dist/chunk-KTMZ3QAO.js +1 -0
  16. package/dist/chunk-NWRHKTMV.js +1 -0
  17. package/dist/{chunk-5HXTEMRE.js → chunk-QG7ZFUNX.js} +1 -1
  18. package/dist/{chunk-GLGXP5I7.js → chunk-R2TRYVOY.js} +1 -1
  19. package/dist/chunk-RF4QU72N.js +1 -0
  20. package/dist/chunk-TFYAMLCK.js +1 -0
  21. package/dist/chunk-TZBJCAXH.js +1 -0
  22. package/dist/chunk-UEDS3HJ3.js +1 -0
  23. package/dist/chunk-UEYHH7Y5.js +1 -0
  24. package/dist/chunk-WH2EVBIG.js +1 -0
  25. package/dist/chunk-WKWXU5QM.js +1 -0
  26. package/dist/{chunk-P4J57TK6.js → chunk-YPVYZYMH.js} +1 -1
  27. package/dist/core/chart-ops/index.cjs +1 -1
  28. package/dist/core/chart-ops/index.d.cts +491 -18
  29. package/dist/core/chart-ops/index.d.ts +491 -18
  30. package/dist/core/chart-ops/index.js +1 -1
  31. package/dist/core/color.d.cts +1 -1
  32. package/dist/core/color.d.ts +1 -1
  33. package/dist/core/inventory/index.cjs +1 -1
  34. package/dist/core/inventory/index.d.cts +72 -5
  35. package/dist/core/inventory/index.d.ts +72 -5
  36. package/dist/core/inventory/index.js +1 -1
  37. package/dist/core/layout/index.cjs +1 -1
  38. package/dist/core/layout/index.d.cts +63 -6
  39. package/dist/core/layout/index.d.ts +63 -6
  40. package/dist/core/layout/index.js +1 -1
  41. package/dist/core/quality/index.cjs +1 -1
  42. package/dist/core/quality/index.d.cts +18 -4
  43. package/dist/core/quality/index.d.ts +18 -4
  44. package/dist/core/quality/index.js +1 -1
  45. package/dist/core/render-assets/index.cjs +1 -1
  46. package/dist/core/render-assets/index.d.cts +45 -5
  47. package/dist/core/render-assets/index.d.ts +45 -5
  48. package/dist/core/render-assets/index.js +1 -1
  49. package/dist/core/seatConfidence.d.cts +1 -1
  50. package/dist/core/seatConfidence.d.ts +1 -1
  51. package/dist/core/sections/index.cjs +1 -1
  52. package/dist/core/sections/index.d.cts +5 -5
  53. package/dist/core/sections/index.d.ts +5 -5
  54. package/dist/core/sections/index.js +1 -1
  55. package/dist/cs-L5EG7LLR.js +1 -0
  56. package/dist/cy-AB2Q6XHI.js +1 -0
  57. package/dist/da-EGJO7W4Q.js +1 -0
  58. package/dist/de-Q56NNVPD.js +1 -0
  59. package/dist/el-JW2YADAL.js +1 -0
  60. package/dist/es-N35HVHMD.js +1 -0
  61. package/dist/et-53UYPQR7.js +1 -0
  62. package/dist/{eventConfigurations-ClFqXQi9.d.cts → eventConfigurations-C0x_OtjQ.d.cts} +1 -1
  63. package/dist/{eventConfigurations-B6aS6c-_.d.ts → eventConfigurations-CDPqKz_8.d.ts} +1 -1
  64. package/dist/fa-JL3HW42Q.js +1 -0
  65. package/dist/fi-ZFWROLPU.js +1 -0
  66. package/dist/fr-6EKBGKIT.js +1 -0
  67. package/dist/he-KSOTIRJW.js +1 -0
  68. package/dist/hi-RWHSYCVV.js +1 -0
  69. package/dist/hr-ECH5LYKR.js +1 -0
  70. package/dist/hu-BAXHRRWC.js +1 -0
  71. package/dist/id-ECFNLK3G.js +1 -0
  72. package/dist/index.cjs +1 -1
  73. package/dist/index.d.cts +65 -17
  74. package/dist/index.d.ts +65 -17
  75. package/dist/index.js +1 -1
  76. package/dist/it-HT57FDFI.js +1 -0
  77. package/dist/ja-LHVHSM5J.js +1 -0
  78. package/dist/ko-G2HVHBKT.js +1 -0
  79. package/dist/ku-MNPV6BJJ.js +1 -0
  80. package/dist/{labeling-ByEZkLee.d.cts → labeling-20iLar-Q.d.ts} +11 -3
  81. package/dist/{labeling-CP3GhUrf.d.ts → labeling-DW_pEMgl.d.cts} +11 -3
  82. package/dist/localeLoaders-L36RHPNS.js +1 -0
  83. package/dist/lt-GB2GJDNS.js +1 -0
  84. package/dist/lv-3ZE6IM47.js +1 -0
  85. package/dist/ms-YH2PYOHG.js +1 -0
  86. package/dist/nl-D4FX7T7U.js +1 -0
  87. package/dist/no-5YNLYHN4.js +1 -0
  88. package/dist/pl-RUXCR6JV.js +1 -0
  89. package/dist/pt-TKFGIUL6.js +1 -0
  90. package/dist/{renderedQuality--H0toc-2.d.cts → renderedQuality-BIWwSRMS.d.cts} +1 -1
  91. package/dist/{renderedQuality-Bo4k99GE.d.ts → renderedQuality-CdpKQidA.d.ts} +1 -1
  92. package/dist/{renderer-BPhSZUGh.d.cts → renderer-BSjyHBDK.d.cts} +8 -1
  93. package/dist/{renderer-CWbam_zr.d.ts → renderer-BurPZ2Io.d.ts} +8 -1
  94. package/dist/ro-UFIOIOVH.js +1 -0
  95. package/dist/ru-VMRD53B7.js +1 -0
  96. package/dist/{seatTypeIcons-CSt1isBY.d.ts → seatTypeIcons-BlEzPXFf.d.cts} +2 -2
  97. package/dist/{seatTypeIcons-B2tvcQ0H.d.cts → seatTypeIcons-D_T5HfJs.d.ts} +2 -2
  98. package/dist/{sections-C_AKwOIh.d.cts → sections-BySKMsFE.d.ts} +5 -2
  99. package/dist/{sections-JHox6Lsw.d.ts → sections-DXUcW0ZT.d.cts} +5 -2
  100. package/dist/{segmentedRowModel-DQO0vHR1.d.ts → segmentedRowModel-C5qFY6jJ.d.ts} +1 -1
  101. package/dist/{segmentedRowModel-CZ0Ciea-.d.cts → segmentedRowModel-CyW-LFuI.d.cts} +1 -1
  102. package/dist/sk-XIK2KO3F.js +1 -0
  103. package/dist/sl-CDZGH6C6.js +1 -0
  104. package/dist/sr-A3TESNV3.js +1 -0
  105. package/dist/sv-HKGKDGSG.js +1 -0
  106. package/dist/{tableSizing-ClgbhNks.d.ts → tableSizing-Bos5ueqg.d.cts} +5 -4
  107. package/dist/{tableSizing-Cp5T_6Lw.d.cts → tableSizing-CAiE_oii.d.ts} +5 -4
  108. package/dist/th-ZPGRIY7D.js +1 -0
  109. package/dist/{ticketRestrictions-DUdzkp4F.d.ts → ticketRestrictions-DKdJWh9u.d.cts} +39 -3
  110. package/dist/{ticketRestrictions-BHNbxzFT.d.cts → ticketRestrictions-DRDtAVKw.d.ts} +39 -3
  111. package/dist/tr-IUB54G3R.js +1 -0
  112. package/dist/{types-5AlKCD4j.d.ts → types-ZviQR7ch.d.cts} +194 -9
  113. package/dist/{types-5AlKCD4j.d.cts → types-ZviQR7ch.d.ts} +194 -9
  114. package/dist/uk-JQKEV42K.js +1 -0
  115. package/dist/vi-KRM5S2Q7.js +1 -0
  116. package/dist/view3d/crossfade/panorama.d.cts +1 -1
  117. package/dist/view3d/crossfade/panorama.d.ts +1 -1
  118. package/dist/view3d/index.cjs +54 -54
  119. package/dist/view3d/index.d.cts +13 -3
  120. package/dist/view3d/index.d.ts +13 -3
  121. package/dist/view3d/index.js +44 -44
  122. package/dist/view3d/scene/scene.worker.cjs +1 -1
  123. package/dist/view3d/scene/scene.worker.js +1 -1
  124. package/dist/zh-Hans-FEUYIOYS.js +1 -0
  125. package/dist/zh-Hant-PK2XOE2G.js +1 -0
  126. package/package.json +1 -1
  127. package/dist/ar-Q44JP5JY.js +0 -1
  128. package/dist/be-CGFFSIQL.js +0 -1
  129. package/dist/bg-WOYK6OLH.js +0 -1
  130. package/dist/ca-77ZVI3X5.js +0 -1
  131. package/dist/chunk-52XO3LA7.js +0 -1
  132. package/dist/chunk-5BMXWOE7.js +0 -1
  133. package/dist/chunk-5ITK5236.js +0 -1
  134. package/dist/chunk-5N4H3KMR.js +0 -1
  135. package/dist/chunk-5PFYIYM5.js +0 -1
  136. package/dist/chunk-CTIGUXXK.js +0 -1
  137. package/dist/chunk-D723OZEY.js +0 -1
  138. package/dist/chunk-FLZKBXHA.js +0 -1
  139. package/dist/chunk-HO4MFTVX.js +0 -1
  140. package/dist/chunk-JK3DUFRX.js +0 -1
  141. package/dist/chunk-N4J4CT6P.js +0 -1
  142. package/dist/chunk-NO6OLVTT.js +0 -1
  143. package/dist/chunk-TQN2VWQO.js +0 -1
  144. package/dist/chunk-UISTXRO5.js +0 -1
  145. package/dist/cs-OSBZYCSR.js +0 -1
  146. package/dist/cy-ZCOJW2WH.js +0 -1
  147. package/dist/da-2PDK6JTR.js +0 -1
  148. package/dist/de-R5LLVFUU.js +0 -1
  149. package/dist/el-ZPFVDCWA.js +0 -1
  150. package/dist/es-7YASJP32.js +0 -1
  151. package/dist/et-J4TV6KQL.js +0 -1
  152. package/dist/fa-4TEO7UGM.js +0 -1
  153. package/dist/fi-GIUDDKMH.js +0 -1
  154. package/dist/fr-J5J2XJLA.js +0 -1
  155. package/dist/he-OCEHSVUJ.js +0 -1
  156. package/dist/hi-EK5CTBW5.js +0 -1
  157. package/dist/hr-SLDTQOYC.js +0 -1
  158. package/dist/hu-2QNE77NO.js +0 -1
  159. package/dist/id-LGDAFQJK.js +0 -1
  160. package/dist/it-DT4Y3IYB.js +0 -1
  161. package/dist/ja-D5EY2XCQ.js +0 -1
  162. package/dist/ko-DD2NV45Q.js +0 -1
  163. package/dist/ku-KZCMVLBE.js +0 -1
  164. package/dist/localeLoaders-GGAKX22E.js +0 -1
  165. package/dist/lt-QWGTJ47Y.js +0 -1
  166. package/dist/lv-LYAIG3VK.js +0 -1
  167. package/dist/ms-XTF4KNGD.js +0 -1
  168. package/dist/nl-QEXY6XHS.js +0 -1
  169. package/dist/no-HCOXN2CN.js +0 -1
  170. package/dist/pl-BWY53TSD.js +0 -1
  171. package/dist/pt-2UJUBCPL.js +0 -1
  172. package/dist/ro-GGXOLTED.js +0 -1
  173. package/dist/ru-ZTFK3WCU.js +0 -1
  174. package/dist/sk-KU543Y2U.js +0 -1
  175. package/dist/sl-FT576R7A.js +0 -1
  176. package/dist/sr-WE3J46JE.js +0 -1
  177. package/dist/sv-YEAOPSEB.js +0 -1
  178. package/dist/th-BEBRDHJA.js +0 -1
  179. package/dist/tr-LOAHUPSH.js +0 -1
  180. package/dist/uk-2GMICSHN.js +0 -1
  181. package/dist/vi-TC5B6AUR.js +0 -1
  182. package/dist/zh-Hans-TSZWTZQY.js +0 -1
  183. package/dist/zh-Hant-TLB4FZYM.js +0 -1
@@ -1 +0,0 @@
1
- import{a as ve,c as De,d as Ne}from"./chunk-L34T3APU.js";import{b as Ee,c as ke}from"./chunk-FLZKBXHA.js";import{v as Ge}from"./chunk-5HXTEMRE.js";import{a as Fe,c as zt,d as pt,f as xt,i as Le}from"./chunk-D723OZEY.js";import{h as xn}from"./chunk-52XO3LA7.js";import{e as Oe,l as Ce}from"./chunk-4N5CHKHD.js";import{B as Re,C as nn,Ma as wt,Va as Pn,ba as $,ca as Pt,j as Se,la as bn,na as Wt,oa as gn,qa as Ie,sa as Yt,ta as Mn,ua as _e,wa as Xn,xa as Ae,ya as we}from"./chunk-UISTXRO5.js";import{A as Rt,D as Te,b as Be,d as at,y as it}from"./chunk-JBOTRSMY.js";var en=["available","held","sold","selected","dimmed"];function jn(t){let n=en.indexOf(t);return n<0?0:n}var He={available:[.24,.82,.52],held:[.34,.39,.45],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};function nl(t){let n=.2126*t[0]+.7152*t[1]+.0722*t[2],e=.78,r=.86;return[(n+(t[0]-n)*e)*r,(n+(t[1]-n)*e)*r,(n+(t[2]-n)*e)*r]}var Un={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 K(t,n){return[Math.min(1,t[0]*n),Math.min(1,t[1]*n),Math.min(1,t[2]*n)]}import Ur from"earcut";import je from"polygon-clipping";var R=$,Wr=.002;function Yr(t,n,e){let r=Math.hypot(n[0]-t[0],n[1]-t[1],n[2]-t[2]),o=Math.hypot(e[0]-n[0],e[1]-n[1],e[2]-n[2]),a=Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2]),i=Math.max(r,o,a);if(i<1e-9)return!0;let s=(r+o+a)/2;return 2*Math.sqrt(Math.max(0,s*(s-r)*(s-o)*(s-a)))/i<Wr}var Ht=class{constructor(n=16384){this.len=0;this.buf=new Float32Array(n)}push3(n,e,r){this.len+3>this.buf.length&&this.grow(this.len+3),this.buf[this.len++]=n,this.buf[this.len++]=e,this.buf[this.len++]=r}push1(n){this.len+1>this.buf.length&&this.grow(this.len+1),this.buf[this.len++]=n}grow(n){let e=this.buf.length*2;for(;e<n;)e*=2;let r=new Float32Array(e);r.set(this.buf.subarray(0,this.len)),this.buf=r}get length(){return this.len}toArray(){return this.buf.slice(0,this.len)}},In=class{constructor(){this.pos=new Ht;this.nor=new Ht;this.col=new Ht;this.flr=new Ht;this.mat=new Ht;this.currentFloor=0;this.currentMaterial=0}setFloor(n){this.currentFloor=n}setMaterial(n){this.currentMaterial=n}tri(n,e,r,o,a,i=a,s=a){Yr(n,e,r)||(this.pos.push3(n[0],n[1],n[2]),this.pos.push3(e[0],e[1],e[2]),this.pos.push3(r[0],r[1],r[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.col.push3(a[0],a[1],a[2]),this.col.push3(i[0],i[1],i[2]),this.col.push3(s[0],s[1],s[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}triN(n,e,r,o,a,i,s,l=s,u=s){[...n,...e,...r].every(Number.isFinite)&&(this.pos.push3(n[0],n[1],n[2]),this.pos.push3(e[0],e[1],e[2]),this.pos.push3(r[0],r[1],r[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(a[0],a[1],a[2]),this.nor.push3(i[0],i[1],i[2]),this.col.push3(s[0],s[1],s[2]),this.col.push3(l[0],l[1],l[2]),this.col.push3(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 zr(t,n,e){let r=n[0]-t[0],o=n[1]-t[1],a=n[2]-t[2],i=e[0]-t[0],s=e[1]-t[1],l=e[2]-t[2],u=o*l-a*s,c=a*i-r*l,f=r*s-o*i,m=Math.hypot(u,c,f)||1;return u/=m,c/=m,f/=m,[u,c,f]}function Vr(t,n){let e=[...t],r=[];for(let i of t)r.push(i.x,i.y);let o=[];if(n){for(let i of n)if(!(i.length<3)){o.push(e.length);for(let s of i)e.push(s),r.push(s.x,s.y)}}let a=Ur(r,o.length?o:void 0,2);return{pts:e,tris:a}}function Et(t){return pt(t)<0?[...t].reverse():t}var Kr=3;function Zr(t,n,e,r){let o=r(t),a=r(n),i=r(e),s=(y,h,d,b)=>Math.abs(r({x:(y.x+h.x)/2,y:(y.y+h.y)/2})-(d+b)/2),l=(t.x+n.x+e.x)/3,u=(t.y+n.y+e.y)/3,c=(o+a+i)/3,f=Math.max(s(t,n,o,a),s(n,e,a,i),s(e,t,i,o),Math.abs(r({x:l,y:u})-c)),m=(y,h,d)=>{let b=Math.abs(r({x:(y+l)/2,y:(h+u)/2})-(d+c)/2);b>f&&(f=b)};return m((t.x+n.x)/2,(t.y+n.y)/2,(o+a)/2),m((n.x+e.x)/2,(n.y+e.y)/2,(a+i)/2),m((e.x+t.x)/2,(e.y+t.y)/2,(i+o)/2),f}function on(t,n,e,r,o){if(o<=0)return Zr(t,n,e,r);let a={x:(t.x+n.x)/2,y:(t.y+n.y)/2},i={x:(n.x+e.x)/2,y:(n.y+e.y)/2},s={x:(e.x+t.x)/2,y:(e.y+t.y)/2};return Math.max(on(t,a,s,r,o-1),on(a,n,i,r,o-1),on(s,i,e,r,o-1),on(a,i,s,r,o-1))}function rn(t,n,e,r,o,a,i,s){if(i>0){let m={x:(n.x+e.x)/2,y:(n.y+e.y)/2},y={x:(e.x+r.x)/2,y:(e.y+r.y)/2},h={x:(r.x+n.x)/2,y:(r.y+n.y)/2};rn(t,n,m,h,o,a,i-1,s),rn(t,m,e,y,o,a,i-1,s),rn(t,h,y,r,o,a,i-1,s),rn(t,m,y,h,o,a,i-1,s);return}let l=[n.x*R,o(n),n.y*R],u=[e.x*R,o(e),e.y*R],c=[r.x*R,o(r),r.y*R];if(s){t.triN(l,u,c,s(n),s(e),s(r),a);return}let f=zr(l,u,c);f[1]<0&&(f=[-f[0],-f[1],-f[2]]),t.tri(l,u,c,f,a)}var qr=8;function Xe(t,n,e){if(!Number.isFinite(e))return t;let r=[],o=(a,i,s,l,u)=>{if(u>0){let c={x:(a.x+i.x)/2,y:(a.y+i.y)/2},f=n(c);if(Math.abs(f-(s+l)/2)>e){o(a,c,s,f,u-1),o(c,i,f,l,u-1);return}}r.push(a)};for(let a=0;a<t.length;a++){let i=t[a],s=t[(a+1)%t.length];o(i,s,n(i),n(s),qr)}return r}function Sn(t,n){if(t.length<3)return t;let e=[];for(let o of t){let a=e[e.length-1];a&&Math.hypot(o.x-a.x,o.y-a.y)<n||e.push(o)}for(;e.length>2&&Math.hypot(e[0].x-e[e.length-1].x,e[0].y-e[e.length-1].y)<n;)e.pop();if(e.length<3)return t;let r=[];for(let o=0;o<e.length;o++){let a=r.length?r[r.length-1]:e[(o-1+e.length)%e.length],i=e[o],s=e[(o+1)%e.length],l=s.x-a.x,u=s.y-a.y,c=Math.hypot(l,u);c>n&&Math.abs((i.x-a.x)*u-(i.y-a.y)*l)/c<n||r.push(i)}return r.length>=3?r:e}var Rn=.001*Pt*.1;function Z(t,n,e,r,o,a,i,s,l=1/0,u){if(!n||n.length<3||(l===void 0&&(l=1/0),Math.abs(pt(n))<1e-4))return;let c=Sn(Xe(Sn(Et(n),Rn),r,l),Rn),f=e?.map(p=>Sn(Xe(Sn(Et(p),Rn),r,l),Rn)).filter(p=>p.length>=3&&Math.abs(pt(p))>=1e-4),{pts:m,tris:y}=Vr(c,f),h=[a[0]*s.top,a[1]*s.top,a[2]*s.top],d=[a[0]*s.bottomCap,a[1]*s.bottomCap,a[2]*s.bottomCap],b=[i[0]*s.top,i[1]*s.top,i[2]*s.top],x=[i[0]*s.wallBottom,i[1]*s.wallBottom,i[2]*s.wallBottom],g=0;if(Number.isFinite(l))for(;g<Kr;g++){let p=0;for(let _=0;_<y.length;_+=3){let P=on(m[y[_]],m[y[_+1]],m[y[_+2]],r,g);P>p&&(p=P)}if(p<=l)break}for(let p=0;p<y.length;p+=3){let _=m[y[p]],P=m[y[p+1]],I=m[y[p+2]];rn(t,_,P,I,r,h,g,u);let E=[_.x*R,o,_.y*R],T=[P.x*R,o,P.y*R],F=[I.x*R,o,I.y*R];t.tri(E,F,T,[0,-1,0],d)}let S=p=>{if(g<=0)return p;let _=1<<g,P=[];for(let I=0;I<p.length;I++){let E=p[I],T=p[(I+1)%p.length];for(let F=0;F<_;F++){let k=F/_;P.push({x:E.x+(T.x-E.x)*k,y:E.y+(T.y-E.y)*k})}}return P},A=Re(c),M=[{ring:S(c),flip:!1}];if(f)for(let p of f)p.length>=3&&M.push({ring:S(p),flip:!0});for(let{ring:p,flip:_}of M)for(let P=0;P<p.length;P++){let I=p[P],E=p[(P+1)%p.length],T=(E.x-I.x)*R,k=(E.y-I.y)*R,w=-T,B=Math.hypot(k,w)||1;k/=B,w/=B;let C=(I.x+E.x)/2-A.x,v=(I.y+E.y)/2-A.y,O=k*C+w*v;_&&(O=-O),O<0&&(k=-k,w=-w);let N=[k,0,w],H=[I.x*R,r(I),I.y*R],j=[E.x*R,r(E),E.y*R],G=[I.x*R,o,I.y*R],U=[E.x*R,o,E.y*R];t.tri(H,j,U,N,b,b,x),t.tri(H,U,G,N,b,x,x)}}function Ue(t){let n=0;for(let l of t)n+=l.count;let e=new Float32Array(n*3),r=new Float32Array(n*3),o=new Float32Array(n*3),a=new Float32Array(n),i=new Float32Array(n),s=0;for(let l of t)e.set(l.position,s*3),r.set(l.normal,s*3),o.set(l.color,s*3),a.set(l.floor,s),i.set(l.material,s),s+=l.count;return{position:e,normal:r,color:o,floor:a,material:i,count:n}}function It(t,n,e=2.5){if(n<=0||t.length<3)return t;let r=Et(t),o=r.length,a=[];for(let s=0;s<o;s++){let l=r[s],u=r[(s+1)%o],c=u.x-l.x,f=u.y-l.y,m=Math.hypot(c,f)||1;a.push({x:f/m,y:-c/m})}let i=[];for(let s=0;s<o;s++){let l=r[s],u=a[(s-1+o)%o],c=a[s],f=u.x+c.x,m=u.y+c.y,y=Math.hypot(f,m),h=()=>{i.push([l.x+u.x*n,l.y+u.y*n]),i.push([l.x+c.x*n,l.y+c.y*n])};if(y<1e-9){h();continue}f/=y,m/=y;let d=f*u.x+m*u.y,b=1/Math.max(d,1e-6);if(!Number.isFinite(b)||b>e){h();continue}i.push([l.x+f*n*b,l.y+m*n*b])}if(i.length<3)return t;try{let s=je.union([[...i,i[0]]]),l=null,u=-1/0;for(let f of s){let m=Math.abs(pt(f[0].map(([y,h])=>({x:y,y:h}))));m>u&&(u=m,l=f[0])}if(!l)return t;let c=l.map(([f,m])=>({x:f,y:m}));if(c.length>1){let f=c[0],m=c[c.length-1];Math.abs(f.x-m.x)<1e-9&&Math.abs(f.y-m.y)<1e-9&&c.pop()}return c.length>=3?c:t}catch{return t}}function Lt(t,n,e=2.5){if(t.length<3)return[];if(n<=0)return t;let r=Et(t),o=r.length,a=[];for(let l=0;l<o;l++){let u=r[l],c=r[(l+1)%o],f=Math.hypot(c.x-u.x,c.y-u.y)||1;a.push({x:-(c.y-u.y)/f,y:(c.x-u.x)/f})}let i=[],s=[];for(let l=0;l<o;l++){let u=r[l],c=a[(l-1+o)%o],f=a[l],m=c.x+f.x,y=c.y+f.y,h=Math.hypot(m,y),d=h<1e-9?1/0:1/Math.max(m/h*c.x+y/h*c.y,1e-6);if(!Number.isFinite(d)||d>e){i.push({x:u.x+c.x*n,y:u.y+c.y*n},{x:u.x+f.x*n,y:u.y+f.y*n}),s.push(l,l);continue}m/=h,y/=h,i.push({x:u.x+m*n*d,y:u.y+y*n*d}),s.push(l)}for(let l=0;l<i.length;l++){let u=(l+1)%i.length,c=s[l],f=s[u];if(f!==(c+1)%o)continue;let m=r[c],y=r[f];if((i[u].x-i[l].x)*(y.x-m.x)+(i[u].y-i[l].y)*(y.y-m.y)<=0)return[]}try{let l=je.intersection([[...i.map(h=>[h.x,h.y]),[i[0].x,i[0].y]]],[[...r.map(h=>[h.x,h.y]),[r[0].x,r[0].y]]]),u=null,c=0;for(let h of l){let d=Math.abs(pt(h[0].map(([b,x])=>({x:b,y:x}))));d>c&&(c=d,u=h[0])}if(!u)return[];let f=u.map(([h,d])=>({x:h,y:d})),m=f[0],y=f[f.length-1];return f.length>1&&Math.abs(m.x-y.x)<1e-9&&Math.abs(m.y-y.y)<1e-9&&f.pop(),f.length>=3?Et(f):[]}catch{return[]}}function _n(t,n,e,r,o=28){let a=[];for(let i=0;i<o;i++){let s=i/o*Math.PI*2;a.push({x:t+e*Math.cos(s),y:n+r*Math.sin(s)})}return a}function sn(t,n,e,r){return[{x:t,y:n},{x:t+e,y:n},{x:t+e,y:n+r},{x:t,y:n+r}]}var lt={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,body:10,head:11},$r=.44,Qr=.15,Jr=.3,ti=.24;function Ye(t){return t===void 0||!Number.isFinite(t)||t<=0?ti:Math.min(Jr,Math.max(Qr,t*$r))}var ll=.21,ni=.05,Yn=.45,ei=Yn+ni,oi=.92,We=.66,ri=1.205,ii=-.23,si=.38,ai=[{part:lt.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:lt.pad,min:[-1,.36,-.95],max:[1,Yn,1]},{part:lt.back,min:[-1,ei,-1],max:[1,oi,-.72]},{part:lt.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:lt.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:lt.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:lt.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:lt.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:lt.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:lt.leg,min:[.62,0,.48],max:[.82,.37,.7]}],ci=[{part:lt.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:lt.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:lt.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:lt.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:lt.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}],li=[{n:[1,0,0],c:[[1,0,0],[1,1,0],[1,1,1],[1,0,1]]},{n:[-1,0,0],c:[[0,0,1],[0,1,1],[0,1,0],[0,0,0]]},{n:[0,1,0],c:[[0,1,0],[0,1,1],[1,1,1],[1,1,0]]},{n:[0,-1,0],c:[[0,0,1],[0,0,0],[1,0,0],[1,0,1]]},{n:[0,0,1],c:[[0,0,1],[1,0,1],[1,1,1],[0,1,1]]},{n:[0,0,-1],c:[[1,0,0],[0,0,0],[0,1,0],[1,1,0]]}];function ul(){let t=[],n=[],e=[],r=[],o=(G,U,X)=>{let W=e.length,[nt,rt,q]=G,Q=[rt[0]-nt[0],rt[1]-nt[1],rt[2]-nt[2]],J=[q[0]-nt[0],q[1]-nt[1],q[2]-nt[2]],L=Q[1]*J[2]-Q[2]*J[1],D=Q[2]*J[0]-Q[0]*J[2],Y=Q[0]*J[1]-Q[1]*J[0],ct=Math.hypot(L,D,Y);ct>1e-9?(L/=ct,D/=ct,Y/=ct):[L,D,Y]=U,L*U[0]+D*U[1]+Y*U[2]<0&&(L=-L,D=-D,Y=-Y);for(let ft of G)t.push(...ft),n.push(L,D,Y),e.push(X);r.push(W,W+1,W+2,W,W+2,W+3)},a=G=>{for(let U of li){let X=U.c.map(W=>W.map((nt,rt)=>nt?G.max[rt]:G.min[rt]));o(X,U.n,G.part)}},i=(G,U)=>{let[X,W,nt]=U?[0,1,2]:[0,2,1],rt=G.min[X],q=G.max[X],Q=G.min[W],J=G.max[W],L=(q-rt)*.1,D=(J-Q)*.1,Y=U?[[rt+L,Q],[q-L,Q],[q,Q+D],[q*.94,J-(J-Q)*.23],[q*We,J],[rt*We,J],[rt*.94,J-(J-Q)*.23],[rt,Q+D]]:[[rt+L,Q],[q-L,Q],[q,Q+D],[q,J-D],[q-L,J],[rt+L,J],[rt,J-D],[rt,Q+D]],ct=(st,tt,et)=>{let ht=[0,0,0];return ht[X]=st,ht[W]=tt,ht[nt]=et,ht},ft=[G.min[nt],G.max[nt]].map(st=>Y.map(([tt,et])=>ct(tt,et,st)));for(let st=0;st<Y.length;st++){let tt=(st+1)%Y.length,et=[0,0,0];et[X]=(Y[st][0]+Y[tt][0])/2-(rt+q)/2,et[W]=(Y[st][1]+Y[tt][1])/2-(Q+J)/2,o([ft[0][st],ft[0][tt],ft[1][tt],ft[1][st]],et,G.part)}for(let st=0;st<2;st++){let tt=[0,0,0];tt[nt]=st?1:-1;let et=ft[st];for(let ht=1;ht<et.length-1;ht++){let z=e.length;for(let mt of[et[0],et[ht],et[ht+1]])t.push(...mt),n.push(...tt),e.push(G.part);r.push(z,z+1,z+2)}}};for(let G of ai)G.part===lt.pad||G.part===lt.back?i(G,G.part===lt.back):a(G);for(let G of ci)a(G);let s=Yn,l=1.08,u=.47,c=.69,f=-.55,m=.08,y=-.48,h=.01,d=[-u,s,f],b=[u,s,f],x=[-u,s,m],g=[u,s,m],S=[-c,l,y],A=[c,l,y],M=[-c,l,h],p=[c,l,h];o([b,A,p,g],[1,0,0],lt.body),o([x,M,S,d],[-1,0,0],lt.body),o([d,b,g,x],[0,-1,0],lt.body);let _=l+.07,P=.24,I=[-P,_,y],E=[P,_,y],T=[-P,_,h],F=[P,_,h];o([M,T,I,S],[-.5,1,0],lt.body),o([T,F,E,I],[0,1,0],lt.body),o([F,p,A,E],[.5,1,0],lt.body),o([g,p,M,x],[0,0,1],lt.body),o([p,F,T,M],[0,0,1],lt.body),o([d,S,A,b],[0,0,-1],lt.body),o([S,I,E,A],[0,0,-1],lt.body);let k=10,w=8,B=[0,ri,ii],C=[.32,.115,si],v=e.length;for(let G=0;G<=w;G++){let U=Math.PI*G/w,X=Math.cos(U),W=Math.sin(U);for(let nt=0;nt<=k;nt++){let rt=Math.PI*2*nt/k,q=W*Math.cos(rt),Q=W*Math.sin(rt);t.push(B[0]+C[0]*q,B[1]+C[1]*X,B[2]+C[2]*Q);let J=q/C[0],L=X/C[1],D=Q/C[2],Y=Math.hypot(J,L,D)||1;J/=Y,L/=Y,D/=Y,n.push(J,L,D),e.push(lt.head)}}for(let G=0;G<w;G++)for(let U=0;U<k;U++){let X=v+G*(k+1)+U,W=X+k+1;r.push(X,W,X+1,X+1,W,W+1)}let O=new Float32Array(t),N=new Float32Array(n),H=new Float32Array(e),j=new Uint16Array(r);return{position:O,normal:N,part:H,index:j,vertexCount:e.length,indexCount:r.length}}function ze(t,n,e,r){let o=new Float32Array(n),a=u=>t[u*3],i=u=>t[u*3+2],s=0,l=(u,c)=>{let f=c-u;for(let m=u;m<c;m++){let[y,h]=r(m),d=y-a(m),b=h-i(m);if(f>=2){let x=Math.max(u,m-1),g=Math.min(c-1,m+1),S=a(g)-a(x),A=i(g)-i(x),M=Math.hypot(S,A);if(M>1e-6){let p=-A/M,_=S/M;p*d+_*b<0&&(p=-p,_=-_),d=p,b=_}}o[m]=d===0&&b===0?0:Math.atan2(d,b)}};for(let u=1;u<=n;u++)(u===n||e(u)!==e(s))&&(l(s,u),s=u);return o}var An=.22;function gl(t,n){let e=en[t];if(e!=="sold"&&e!=="held")return-1;let r=(n+1)*2654435761;return r^=r>>>15,r=Math.imul(r,2246822519),r^=r>>>13,(r>>>0)%1e5/1e5}var ui=.42;function fi(t){let n=t.length,e=new Float64Array(n);if(n<2)return e.fill(1/0),e;let r=1/0,o=1/0,a=-1/0,i=-1/0;for(let h of t)h.x<r&&(r=h.x),h.y<o&&(o=h.y),h.x>a&&(a=h.x),h.y>i&&(i=h.y);let s=Math.max(a-r,1e-6),l=Math.max(i-o,1e-6),u=Math.max(Math.sqrt(s*l/n),1e-6),c=Math.max(1,Math.ceil(s/u)+1),f=Math.max(1,Math.ceil(l/u)+1),m=new Map,y=(h,d)=>{let b=Math.min(c-1,Math.max(0,Math.floor((h-r)/u)));return Math.min(f-1,Math.max(0,Math.floor((d-o)/u)))*c+b};for(let h=0;h<n;h++){let d=y(t[h].x,t[h].y),b=m.get(d);b?b.push(h):m.set(d,[h])}for(let h=0;h<n;h++){let d=t[h],b=Math.min(c-1,Math.max(0,Math.floor((d.x-r)/u))),x=Math.min(f-1,Math.max(0,Math.floor((d.y-o)/u))),g=1/0;for(let S=1;S<=4;S++){for(let A=x-S;A<=x+S;A++)if(!(A<0||A>=f))for(let M=b-S;M<=b+S;M++){if(M<0||M>=c||S>1&&Math.abs(A-x)<S&&Math.abs(M-b)<S)continue;let p=m.get(A*c+M);if(p)for(let _ of p){if(_===h)continue;let P=Math.hypot(t[_].x-d.x,t[_].y-d.y);P<g&&(g=P)}}if(Number.isFinite(g)&&g<=S*u)break}e[h]=g}return e}function mi(t){let n=t.eyeHeightM;return Number.isFinite(n)?Math.max(0,n-bn):0}function Ve(t,n,e,r,o,a){let i=t.length,s=new Float32Array(i*3),l=new Float32Array(i),u=new Float32Array(i*3),c=new Float32Array(i),f=new Float32Array(i),m=new Float32Array(i),y=new Float32Array(i),h=new Float32Array(i*3),d=new Map,b=fi(t);for(let x=0;x<i;x++){let g=t[x],A=(e?.seatPitchU(x)??b[x])*R;c[x]=Number.isFinite(A)?Math.max(.06,Math.min(An,A*ui)):An,f[x]=Ye(Number.isFinite(A)?A:void 0);let M=Ce(g.glyph,{seatGlyph:a?.get(g.categoryKey)});m[x]=Oe.indexOf(M),y[x]=g.wheelchairSpaceType==="no-seat"?0:1,s[x*3]=g.x*R,s[x*3+1]=e?e.seatDeckY(x):mi(g),s[x*3+2]=g.y*R,l[x]=jn(n?n(g):"available");let p=at(o?.get(g.categoryKey)??"#6e7bff")??[.43,.48,1];if(u[x*3]=p[0],u[x*3+1]=p[1],u[x*3+2]=p[2],g.accessibility?.length){let _=at(xn(g.accessibility));_&&(h[x*3]=_[0],h[x*3+1]=_[1],h[x*3+2]=_[2])}d.set(g.id,x)}return{count:i,iPosition:s,iState:l,iCategory:u,iMaxRadius:c,iRing:h,idToIndex:d,iChairWidth:f,iGlyph:m,iPhysicalSeat:y,iFloor:r??new Float32Array(i),iSection:new Float32Array(i).fill(-1),iYaw:new Float32Array(i)}}var hi=64;function Ml(t,n){let e=[];for(let i of n){let s=t.idToIndex.get(i.seatId);if(s===void 0)continue;let l=jn(i.state);t.iState[s]!==l&&(t.iState[s]=l,e.push(s))}if(!e.length)return[];e.sort((i,s)=>i-s);let r=[],o=e[0],a=e[0];for(let i=1;i<e.length;i++){let s=e[i];if(s!==a){if(s<=a+hi){a=s;continue}r.push({start:o,length:a-o+1}),o=s,a=s}}return r.push({start:o,length:a-o+1}),r}import Ai from"polygon-clipping";var V={top:1,wallBottom:.58,bottomCap:.4};function Xt(t,n){if(!t)return n;let e=K(Rt(t,.4),.62);return it(n,e,.22)}function Ke(t,n){return t?it(n,K(Rt(t,.25),.74),.62):n}function Ze(t,n){return t?it(n,K(Rt(t,.08),.9),.82):n}function qe(t,n){let e=new Map;for(let a of t.categories??[])e.set(a.key,a.color);let r=new Map;for(let a of n){if(!a.sectionId)continue;let i=r.get(a.sectionId);i||(i=new Map,r.set(a.sectionId,i)),i.set(a.categoryKey,(i.get(a.categoryKey)??0)+1)}let o=new Map;for(let[a,i]of r){let s=0,l=0,u=0,c=0;for(let[f,m]of i){let y=at(e.get(f));y&&(s+=y[0]*m,l+=y[1]*m,u+=y[2]*m,c+=m)}c>0&&o.set(a,[s/c,l/c,u/c])}return o}function $e(t,n){return at(t.color)??n.get(t.logicalSectionId??t.id)??null}import uo from"polygon-clipping";import no from"polygon-clipping";import yi from"earcut";var di=.58,Qe=.01,St=An*1.5*Pt,pi=.5,xi=.6;function bi(t,n){let e=t.length,r=[];for(let i=0;i<e;i++){let s=t[Math.max(0,i-1)],l=t[Math.min(e-1,i+1)],u=l.x-s.x,c=l.y-s.y,f=Math.hypot(u,c);if(f<1e-9){r.push([0,0]);continue}u/=f,c/=f,r.push([-c,u])}let o=0;for(let i=0;i<e;i++)o+=(t[i].x-n.x)*r[i][0]+(t[i].y-n.y)*r[i][1];return o<0?r.map(([i,s])=>[-i,-s]):r}function gi(t,n){if(t.length<2||n<=0)return[...t];let e=[...t],r=(i,s)=>{let l=s.x-i.x,u=s.y-i.y,c=Math.hypot(l,u)||1;return{x:l/c,y:u/c}},o=r(e[1],e[0]),a=r(e[e.length-2],e[e.length-1]);return e.unshift({x:e[0].x+o.x*n,y:e[0].y+o.y*n}),e.push({x:e[e.length-1].x+a.x*n,y:e[e.length-1].y+a.y*n}),e}var Je=Math.PI/12;function Mi(t){if(t.length<3)return[...t];let n=[...t].sort((a,i)=>a.x-i.x||a.y-i.y),e=(a,i,s)=>(i.x-a.x)*(s.y-a.y)-(i.y-a.y)*(s.x-a.x),r=a=>{let i=[];for(let s of a){for(;i.length>=2&&e(i[i.length-2],i[i.length-1],s)<=0;)i.pop();i.push(s)}return i.pop(),i},o=[...r(n),...r([...n].reverse())];return o.length>=3?o:[...t]}function eo(t,n){if(!t.length||!(n>0))return[];let e=Mi(t),r=(s,l,u,c)=>{let f=u-l;for(;f<0;)f+=Math.PI*2;for(;f>Math.PI*2;)f-=Math.PI*2;let m=Math.max(1,Math.ceil(f/Je)),y=n/Math.cos(f/m/2);for(let h=0;h<=m;h++){let d=l+f*h/m;c.push({x:s.x+Math.cos(d)*y,y:s.y+Math.sin(d)*y})}};if(e.length<3){let s=0,l=0;for(let y of e)s+=y.x,l+=y.y;s/=e.length||1,l/=e.length||1;let u=0;for(let y of e)u=Math.max(u,Math.hypot(y.x-s,y.y-l));let c=[],f=Math.max(3,Math.ceil(Math.PI*2/Je)),m=(u+n)/Math.cos(Math.PI/f);for(let y=0;y<f;y++){let h=y/f*Math.PI*2;c.push({x:s+Math.cos(h)*m,y:l+Math.sin(h)*m})}return c}let o=e.length,a=[];for(let s=0;s<o;s++){let l=e[s],u=e[(s+1)%o];a.push(Math.atan2(-(u.x-l.x),u.y-l.y))}let i=[];for(let s=0;s<o;s++)r(e[s],a[(s+o-1)%o],a[s],i);return ao(i)}function Pi(t,n,e){if(t.length===1)return Math.hypot(n-t[0].x,e-t[0].y);let r=1/0;for(let o=0;o+1<t.length;o++){let a=t[o],i=t[o+1],s=i.x-a.x,l=i.y-a.y,u=s*s+l*l,c=u>1e-12?((n-a.x)*s+(e-a.y)*l)/u:0;c<0?c=0:c>1&&(c=1);let f=Math.hypot(n-(a.x+c*s),e-(a.y+c*l));f<r&&(r=f)}return r}function wn(t){let n=t.map(o=>{let a=0,i=0;for(let u of o.pts)a+=u.x,i+=u.y;let s=o.pts.length||1;a/=s,i/=s;let l=0;for(let u of o.pts){let c=Math.hypot(u.x-a,u.y-i);c>l&&(l=c)}return{cx:a,cy:i,rad:l}}),e=o=>{let a=o.length;return a<=2?[...o]:[o[Math.floor(a*.25)],o[Math.floor(a*.5)],o[Math.floor(a*.75)]]},r=[];for(let o=0;o<t.length;o++){let a=e(t[o].pts),i=[],s=1/0,l=null;for(let c of a){let f=1/0;for(let m=0;m<t.length;m++){if(m===o||Math.abs(t[m].y-t[o].y)<.001)continue;let y=n[m],h=Math.hypot(c.x-y.cx,c.y-y.cy)-y.rad;if(h>=f&&h>=s)continue;let d=Pi(t[m].pts,c.x,c.y);d<f&&(f=d),t[m].depth<t[o].depth&&d<s&&(s=d,l=t[m].y)}Number.isFinite(f)&&f>0&&i.push(f)}i.sort((c,f)=>c-f);let u=i.length?i[Math.floor(i.length/2)]:1;r.push({pitch:u,belowY:l})}return r}function oo(t,n,e,r){let o=t[n],a=o.pts.length>=2?[...o.pts]:o.pts.length===1?(()=>{let c=o.pts[0],f=c.x-r.x,m=c.y-r.y,y=Math.hypot(f,m)||1;f/=y,m/=y;let h=Math.max(e[n].pitch,.001)*.5;return[{x:c.x+m*h,y:c.y-f*h},{x:c.x-m*h,y:c.y+f*h}]})():[];if(a.length<2)return null;let i=0,s=0;for(let c=1;c<a.length;c++){let f=Math.hypot(a[c].x-a[c-1].x,a[c].y-a[c-1].y);f>1e-6&&(i+=f,s++)}let l=s>0?i/s:0,u=gi(a,Math.max(l*xi,St));return{pts:u,nrm:bi(u,r),front:Math.max(e[n].pitch*di,St),back:Math.max(e[n].pitch*pi,St)}}var Vt=1.5,ro=.3;function zn(t,n){if(t.length<3)return t;let e=t[0],r=t[t.length-1],o=r.x-e.x,a=r.y-e.y,i=Math.hypot(o,a),s=-1,l=-1;for(let f=1;f<t.length-1;f++){let m=t[f],y=i>1e-12?Math.abs((m.x-e.x)*a-(m.y-e.y)*o)/i:Math.hypot(m.x-e.x,m.y-e.y);y>s&&(s=y,l=f)}if(s<=n||l<0)return[e,r];let u=zn(t.slice(0,l+1),n),c=zn(t.slice(l),n);return[...u.slice(0,-1),...c]}function io(t,n){if(t.length<4)return t;let e=zn([...t,t[0]],n);return e.pop(),e.length>=3?e:t}function Si(t){let n=t.map((r,o)=>{let a=t[(o+1)%t.length];return{a:r,b:a,i:o,minX:Math.min(r.x,a.x),maxX:Math.max(r.x,a.x),minY:Math.min(r.y,a.y),maxY:Math.max(r.y,a.y)}}).sort((r,o)=>r.minX-o.minX),e=(r,o,a)=>(o.x-r.x)*(a.y-r.y)-(o.y-r.y)*(a.x-r.x);for(let r=0;r<n.length;r++){let o=n[r];for(let a=r+1;a<n.length&&n[a].minX<=o.maxX;a++){let i=n[a];if(!(Math.abs(o.i-i.i)===1||Math.abs(o.i-i.i)===t.length-1||o.maxY<i.minY||i.maxY<o.minY)&&e(o.a,o.b,i.a)*e(o.a,o.b,i.b)<=0&&e(i.a,i.b,o.a)*e(i.a,i.b,o.b)<=0)return!0}}return!1}function so(t,n,e){if(t.length<2)return[];let r=e??wn(t),o=new Map;for(let i=0;i<t.length;i++){let s=o.get(t[i].blockId);s?s.push(i):o.set(t[i].blockId,[i])}let a=[];for(let[,i]of o){let s=[];for(let g of i){let S=t[g].patch;S&&S.length>=3?a.push({outline:[...S],holes:[],topY:t[g].y}):s.push(g)}if(!s.length)continue;s.sort((g,S)=>t[g].depth-t[S].depth);let u=s.map(g=>oo(t,g,r,n)).filter(g=>g!==null);if(!u.length)continue;let c=(g,S)=>({x:g.pts[S].x-g.nrm[S][0]*(g.front+Vt),y:g.pts[S].y-g.nrm[S][1]*(g.front+Vt)}),f=(g,S)=>({x:g.pts[S].x+g.nrm[S][0]*(g.back+Vt),y:g.pts[S].y+g.nrm[S][1]*(g.back+Vt)}),m=u[0],y=u[u.length-1],h=[];for(let g=0;g<m.pts.length;g++)h.push(c(m,g));for(let g of u)h.push(f(g,g.pts.length-1));for(let g=y.pts.length-1;g>=0;g--)h.push(f(y,g));for(let g=u.length-1;g>=0;g--)h.push(c(u[g],0));let d=ao(h),b=1/0;for(let g of s)t[g].y<b&&(b=t[g].y);if(!Number.isFinite(b))continue;if(d.length>=3&&Math.abs(pt(d))>1e-6&&u.every(g=>{let S=g.pts[Math.floor(g.pts.length/2)];return xt(d,S.x,S.y)})&&!Si(d)){a.push({outline:io(d,ro),holes:[],topY:b});continue}for(let g of Ri(u))a.push({outline:g,holes:[],topY:b})}return a}function Ri(t){let n=[];for(let e of t){let r=[],o=[],a=e.front+Vt,i=e.back+Vt;for(let l=0;l<e.pts.length;l++){let u=e.pts[l],c=e.nrm[l];r.push([u.x-c[0]*a,u.y-c[1]*a]),o.push([u.x+c[0]*i,u.y+c[1]*i])}let s=[...r,...o.reverse()];s.length<3||(s.push(s[0]),n.push([s]))}if(!n.length)return[];try{let e=no.union(n[0],...n.slice(1)),r=[];for(let o of e){if(!o.length||o[0].length<4)continue;let a=o[0].map(([l,u])=>({x:l,y:u})),i=a[0],s=a[a.length-1];a.length>1&&Math.abs(i.x-s.x)<1e-9&&Math.abs(i.y-s.y)<1e-9&&a.pop(),a.length>=3&&r.push(io(a,ro))}return r}catch{return[]}}function ao(t){let n=[];for(let e of t){let r=n[n.length-1];r&&Math.hypot(e.x-r.x,e.y-r.y)<1e-9||n.push(e)}for(;n.length>2&&Math.hypot(n[0].x-n[n.length-1].x,n[0].y-n[n.length-1].y)<1e-9;)n.pop();return n}var Vn=class{constructor(n){this.minX=1/0;this.minY=1/0;this.maxX=-1/0;this.maxY=-1/0;this.rings=n;for(let e of n)for(let r of e)r.x<this.minX&&(this.minX=r.x),r.y<this.minY&&(this.minY=r.y),r.x>this.maxX&&(this.maxX=r.x),r.y>this.maxY&&(this.maxY=r.y)}containsAll(n){for(let e of n)if(e.x<this.minX||e.x>this.maxX||e.y<this.minY||e.y>this.maxY)return!1;for(let e of this.rings){let r=!0;for(let o of n)if(!xt(e,o.x,o.y)){r=!1;break}if(r)return!0}return!1}};function to(t,n,e,r,o,a){if(r.length<3)return;if(e.containsAll(r)){let u=[0,1,0],c=r[0];for(let f=1;f+1<r.length;f++){let m=r[f],y=r[f+1];t.tri([c.x*R,o,c.y*R],[m.x*R,o,m.y*R],[y.x*R,o,y.y*R],u,a)}return}let i=r.map(u=>[u.x,u.y]);i.push(i[0]);let s;try{s=no.intersection([i],n)}catch{return}let l=[0,1,0];for(let u of s){if(!u.length||u[0].length<4)continue;let c=u[0],f=[],m=[];for(let h=0;h<c.length-1;h++)f.push(c[h][0],c[h][1]),m.push([c[h][0],c[h][1]]);if(m.length<3)continue;let y=yi(f,void 0,2);for(let h=0;h<y.length;h+=3){let d=m[y[h]],b=m[y[h+1]],x=m[y[h+2]];t.tri([d[0]*R,o,d[1]*R],[b[0]*R,o,b[1]*R],[x[0]*R,o,x[1]*R],l,a)}}}function co(t,n,e,r,o,a,i){if(n.length<2)return;let s=i??wn(n),l=[0,1,0],u=a&&a.length>=3?[[...a.map(y=>[y.x,y.y]),[a[0].x,a[0].y]]]:null,c=a&&a.length>=3?new Vn([[...a]]):null,f=y=>{t.setMaterial(2),y(),t.setMaterial(0)},m=y=>{t.setMaterial(3),y(),t.setMaterial(0)};for(let y=0;y<n.length;y++){let h=n[y];if(h.patch&&h.patch.length>=3){let M=[...h.patch],p=s[y].belowY??r;if(m(()=>{if(u&&c)to(t,u,c,M,h.y,o.tread);else{let _=M[0];for(let P=1;P+1<M.length;P++){let I=M[P],E=M[P+1];t.tri([_.x*R,h.y,_.y*R],[I.x*R,h.y,I.y*R],[E.x*R,h.y,E.y*R],l,o.tread)}}}),h.y>p+Qe){let _=0,P=0;for(let I of M)_+=I.x,P+=I.y;_/=M.length,P/=M.length,f(()=>{for(let I=0;I<M.length;I++){let E=M[I],T=M[(I+1)%M.length],F=T.x-E.x,k=T.y-E.y,w=Math.hypot(F,k);if(w<1e-6)continue;let B=k/w,C=-F/w;(E.x-_)*B+(E.y-P)*C<0&&(B=-B,C=-C);let v=[B,0,C],O=[E.x*R,h.y,E.y*R],N=[T.x*R,h.y,T.y*R],H=[E.x*R,p,E.y*R],j=[T.x*R,p,T.y*R];t.tri(O,N,j,v,o.riser),t.tri(O,j,H,v,o.riser)}})}continue}let d=oo(n,y,s,e);if(!d)continue;let{pts:b,nrm:x,front:g,back:S}=d,A=s[y].belowY??r;for(let M=0;M+1<b.length;M++){let p=b[M],_=b[M+1],P=x[M],I=x[M+1];if(Math.hypot(_.x-p.x,_.y-p.y)<1e-6||P[0]===0&&P[1]===0||I[0]===0&&I[1]===0)continue;let E=[(p.x-P[0]*g)*R,h.y,(p.y-P[1]*g)*R],T=[(_.x-I[0]*g)*R,h.y,(_.y-I[1]*g)*R],F=[(p.x+P[0]*S)*R,h.y,(p.y+P[1]*S)*R],k=[(_.x+I[0]*S)*R,h.y,(_.y+I[1]*S)*R];if(m(()=>{u&&c?to(t,u,c,[{x:p.x-P[0]*g,y:p.y-P[1]*g},{x:_.x-I[0]*g,y:_.y-I[1]*g},{x:_.x+I[0]*S,y:_.y+I[1]*S},{x:p.x+P[0]*S,y:p.y+P[1]*S}],h.y,o.tread):(t.tri(E,T,k,l,o.tread),t.tri(E,k,F,l,o.tread))}),h.y>A+Qe){let w=[E[0],A,E[2]],B=[T[0],A,T[2]],C=[-P[0],0,-P[1]];f(()=>{t.tri(E,T,B,C,o.riser),t.tri(E,B,w,C,o.riser)})}}}}function Ii(t,n){let e=t.eventConfigurationIds;return!e?.length||!!n&&e.includes(n)}function lo(t,n){return t.filter(e=>e.type!=="shape"||Ii(e,n))}function fo(t,n){let e=t.focalPoint??{x:0,y:0};return t.floors?.length?t.floors.map((r,o)=>({objects:lo(r.objects,n),focal:{x:(r.focalPoint??e).x,y:(r.focalPoint??e).y},baseHeightM:r.baseHeightM??0,index:o})):[{objects:lo(t.objects,n),focal:e,baseHeightM:0,index:0}]}var _i={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Tt(t){return Fe(t)??_i}function mo(t,n){let e=It(t.outline,St),r=Tt(e),o=n.filter(i=>i!==t&&i.outline&&i.outline.length>=3&&zt(r,Tt(i.outline)));if(!o.length)return[e];let a=i=>{let s=i.map(l=>[l.x,l.y]);return s.push(s[0]),s};try{let i=uo.difference([a(e)],...o.map(l=>[a(l.outline)])),s=[];for(let l of i){if(!l.length)continue;let u=l[0].map(([c,f])=>({x:c,y:f}));if(u.length>1){let c=u[0],f=u[u.length-1];Math.abs(c.x-f.x)<1e-9&&Math.abs(c.y-f.y)<1e-9&&u.pop()}u.length>=3&&s.push(u)}return s.length?s:[e]}catch{return[e]}}function ho(t,n){if(!n.length)return t;let e=a=>{let i=a.map(s=>[s.x,s.y]);return i.push(i[0]),i},r=n.map(a=>[e(a)]),o=[];for(let a of t){let i;try{i=uo.intersection([e(a.outline)],r.flat())}catch{o.push(a);continue}for(let s of i){if(!s.length)continue;let l=s[0].map(([u,c])=>({x:u,y:c}));if(l.length>1){let u=l[0],c=l[l.length-1];Math.abs(u.x-c.x)<1e-9&&Math.abs(u.y-c.y)<1e-9&&l.pop()}l.length>=3&&o.push({outline:l,holes:[],topY:a.topY})}}return o.length?o:t}function wi(t,n){return t===void 0||n===void 0?!0:Math.abs(t-n)<.001}var En=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(n,e){let r=n.map(l=>[l.x,l.y]);if(r.length<3)return[];r.push(r[0]);let o=Tt(n),a=this.rings.filter((l,u)=>zt(o,this.boxes[u])&&wi(e,this.levels[u])),i=[[r]];if(a.length)try{i=Ai.difference([r],...a).map(u=>u.map(c=>c.map(([f,m])=>[f,m])))}catch{i=[[r]]}this.rings.push([r]),this.boxes.push(o),this.levels.push(e);let s=[];for(let l of i){if(!l.length)continue;let u=l[0].map(([c,f])=>({x:c,y:f}));if(u.length>1){let c=u[0],f=u[u.length-1];Math.abs(c.x-f.x)<1e-9&&Math.abs(c.y-f.y)<1e-9&&u.pop()}u.length>=3&&s.push(u)}return s}};function Bn(t,n){if(!n)return t;let e=1/0,r=-1/0,o=1/0,a=-1/0;for(let f of t)e=Math.min(e,f.x),r=Math.max(r,f.x),o=Math.min(o,f.y),a=Math.max(a,f.y);let i=(e+r)/2,s=(o+a)/2,l=n*Math.PI/180,u=Math.cos(l),c=Math.sin(l);return t.map(f=>{let m=f.x-i,y=f.y-s;return{x:i+m*u-y*c,y:s+m*c+y*u}})}function ut(t){let n=null;if(t.kind==="polygon"&&t.points&&t.points.length>=3&&(n=t.points),t.kind==="rect"&&t.width&&t.height&&(n=sn(t.x??0,t.y??0,t.width,t.height)),t.kind==="ellipse"&&t.width&&t.height){let e=(t.x??0)+t.width/2,r=(t.y??0)+t.height/2;n=_n(e,r,t.width/2,t.height/2)}return n?Bn(n,t.rotation):null}function _t(t){let n=t.role??"",e={stage:{kind:"stage",heightM:1},entrance:{kind:"portal",heightM:2.7},exit:{kind:"portal",heightM:2.7},screen:{kind:"solid",heightM:6},wall:{kind:"solid",heightM:2.8},rail:{kind:"solid",heightM:1.1},suite:{kind:"suite",heightM:3},obstruction:{kind:"solid",heightM:4.5},sound:{kind:"solid",heightM:1.45},restroom:{kind:"solid",heightM:2.4},bar:{kind:"solid",heightM:1.1},concession:{kind:"solid",heightM:1.1},coat:{kind:"solid",heightM:1.1},goal:{kind:"portal",heightM:1.8}},r=n==="stage"&&Ae(t.stageKind)?{kind:"stage",heightM:t.stageKind==="ring-boxing"?_e:.06}:e[n]??{kind:"plate",heightM:.25};return{...r,heightM:t.heightM??r.heightM}}var Ei=.08,Bi=30,Ti=.015;function Oi(t,n){let e=!1;for(let r=0,o=n.length-1;r<n.length;o=r++){let a=n[r],i=n[o];a.y>t.y!=i.y>t.y&&t.x<(i.x-a.x)*(t.y-a.y)/(i.y-a.y)+a.x&&(e=!e)}return e}function yo(t,n){let e=ut(t)??(t.points?.length?Bn(t.points,t.rotation):null),r=_t(t),a=!t.role&&r.kind==="plate"&&t.heightM===void 0&&!!e&&Math.abs(pt(e))*$**2>=Bi?Ti:r.heightM;if(!e)return{topOffsetM:a,supportOffsetM:0};if(r.kind!=="plate"&&r.kind!=="stage")return{topOffsetM:a,supportOffsetM:0};let i=1/0,s=1/0,l=-1/0,u=-1/0;for(let y of e)i=Math.min(i,y.x),s=Math.min(s,y.y),l=Math.max(l,y.x),u=Math.max(u,y.y);let c=a,f=0,m=1e-6*Math.max(1,l-i,u-s);for(let y of n)l>y.minX&&i<y.maxX&&u>y.minY&&s<y.maxY&&c<=y.topOffsetM+1e-6&&(c=y.topOffsetM+Ei),i>=y.minX-m&&l<=y.maxX+m&&s>=y.minY-m&&u<=y.maxY+m&&(!y.poly||e.every(b=>Oi(b,y.poly)||Ci(b,y.poly,m)))&&(f=Math.max(f,y.topOffsetM));return t.fill&&t.fill!=="none"&&t.fill!=="transparent"&&n.push({minX:i,minY:s,maxX:l,maxY:u,topOffsetM:c,poly:e}),{topOffsetM:c,supportOffsetM:Math.min(f,c)}}function Ci(t,n,e){for(let r=0,o=n.length-1;r<n.length;o=r++){let a=n[o],i=n[r],s=i.x-a.x,l=i.y-a.y,u=s*s+l*l,c=u?Math.max(0,Math.min(1,((t.x-a.x)*s+(t.y-a.y)*l)/u)):0;if(Math.hypot(t.x-(a.x+c*s),t.y-(a.y+c*l))<=e)return!0}return!1}function vt(t,n,e){return{x:t.x+(n.x-t.x)*e,y:t.y+(n.y-t.y)*e}}function bt(t){if(t.length!==4)return t;let n=Math.hypot(t[1].x-t[0].x,t[1].y-t[0].y),e=Math.hypot(t[2].x-t[1].x,t[2].y-t[1].y);return n>=e?t:[t[1],t[2],t[3],t[0]]}function dt(t,n,e){return[vt(t[0],t[1],n),vt(t[0],t[1],e),vt(t[3],t[2],e),vt(t[3],t[2],n)]}function an(t,n,e){return[vt(t[0],t[3],n),vt(t[1],t[2],n),vt(t[1],t[2],e),vt(t[0],t[3],e)]}function ot(t,n,e,r,o,a){Z(t,n,void 0,()=>e,r,o,a,V)}function cn(t){if(t.length<3)return t.map(a=>({...a}));let n=[...t].sort((a,i)=>a.x-i.x||a.y-i.y),e=(a,i,s)=>(i.x-a.x)*(s.y-a.y)-(i.y-a.y)*(s.x-a.x),r=a=>{let i=[];for(let s of a){for(;i.length>=2&&e(i[i.length-2],i[i.length-1],s)<=0;)i.pop();i.push(s)}return i.pop(),i},o=[...r(n),...r([...n].reverse())];return o.length>=3?o.map(a=>({...a})):n.map(a=>({...a}))}var ki=.8,Fi=.6,Li=2;function Kt(t,n){if(!n.length)return null;let e=[],r=0;for(let i of t.objects){if(i.type!=="shape"||i.role!=="wall")continue;let s=ut(i)??[],l=po(s)/2;!(l>0)||Ni(s)/l*R>Li||(e.push(...s),r+=l)}if(e.length<3)return null;let o=cn(e);if(o.length<3||r<po(o)*Fi)return null;let a=0;for(let i of n)Gi(i,o)&&(a+=1);return a>=n.length*ki?o:null}var xo=6,vi=5,Di=8;function bo(t){return Math.max(Di,(Number.isFinite(t)?t:0)+vi)}function go(t){let n=0,e=0,r=0;for(let o=0;o<t.length;o++){let a=t[o],i=t[(o+1)%t.length],s=a.x*i.y-i.x*a.y;n+=s,e+=(a.x+i.x)*s,r+=(a.y+i.y)*s}if(Math.abs(n)<1e-9){let o=0,a=0;for(let i of t)o+=i.x,a+=i.y;return{x:o/Math.max(1,t.length),y:a/Math.max(1,t.length)}}return{x:e/(3*n),y:r/(3*n)}}function Ni(t){let n=0;for(let e=0;e<t.length;e++){let r=t[e],o=t[(e+1)%t.length];n+=r.x*o.y-o.x*r.y}return Math.abs(n)/2}function po(t){let n=0;for(let e=0;e<t.length;e++){let r=t[e],o=t[(e+1)%t.length];n+=Math.hypot(o.x-r.x,o.y-r.y)}return n}function Gi(t,n){let e=!1;for(let r=0,o=n.length-1;r<n.length;o=r++){let a=n[r],i=n[o];a.y>t.y!=i.y>t.y&&t.x<(i.x-a.x)*(t.y-a.y)/(i.y-a.y)+a.x&&(e=!e)}return e}var Hi=[[/\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"]],Xi=1.2,ji=12;function Mo(t){if(t.heightM!==void 0)return!1;let n=ut(t);if(!n||n.length<3)return!1;let e=0;for(let o=0;o<n.length;o++){let a=n[o],i=n[(o+1)%n.length];e+=Math.hypot(i.x-a.x,i.y-a.y)}return e*$<ji*2?!1:2*ln(n)/e*$<=Xi}function Kn(t){if(!t)return null;for(let[n,e]of Hi)if(n.test(t))return e;return null}var So="auto-rows-";function Ro(t){return t.id.startsWith(So)&&!t.label}var Ui=1.15,Wi=.09,Io=6,Yi=34,zi=.35,Vi=6,Ki=.35,Zi=.75,qi=12,$i=2.5,Qi=40,Ji=[18,24],ts=[12,16],Po=14,ns=.8,es=.6,os=5,rs=.3,_o=.4,Ao=2,is=400,ss=2.6,as=.8,cs=4,ls=26,us=.7,fs=.5,ms=.985,hs=1.5,ys=2.2,ds=3,ps=25,xs=.985,bs=2,gs=6,Ms=3,Ps=.1,Ss=1.5,Rs=1.6,Is=6e3,_s=.6,As="#c3c7cd",Zn=300,ws=240;function Es(t,n,e,r){if(!t.fill||!/^#[0-9a-f]{6}$/i.test(t.fill))return null;let o=$n([...n]),a=new Set;for(let c of r)a.add(Math.floor(Math.atan2(c.y-o.y,c.x-o.x)*180/Math.PI/10));if(a.size*10<ws)return null;let{h:i,s,l}=Te(Be(t.fill));return i<70/360||i>170/360||s<.2||l<.08||l>.75||e.some(c=>c!==t&&c.type==="shape"&&ut(c)?.some(f=>te(f,n)))?null:t.kind==="ellipse"?"oval-cricket":t.kind==="rect"?"pitch-football":null}var Bs="Estimated from the drawing; confirm with the venue.",Qn=t=>{if(!t.length)return null;let n=[...t].sort((r,o)=>r-o),e=Math.floor(n.length/2);return n.length%2?n[e]:(n[e-1]+n[e])/2},$n=t=>({x:t.reduce((n,e)=>n+e.x,0)/t.length,y:t.reduce((n,e)=>n+e.y,0)/t.length}),ln=t=>{let n=0;for(let e=0;e<t.length;e++){let r=t[e],o=t[(e+1)%t.length];n+=r.x*o.y-o.x*r.y}return Math.abs(n)/2};function Ts(t){return t.height!==void 0||t.rake!==void 0||t.elevation!==void 0||t.surfaceKind!==void 0}function Jn(t){let n=new Map;for(let e of t){let r=n.get(e.rowId);r?r.push(e):n.set(e.rowId,[e])}return n}function te(t,n){let e=!1;for(let r=0,o=n.length-1;r<n.length;o=r++){let a=n[r],i=n[o];a.y>t.y!=i.y>t.y&&t.x<(i.x-a.x)*(t.y-a.y)/(i.y-a.y)+a.x&&(e=!e)}return e}function ne(t,n){let e=n[0],r=1/0;for(let o=0;o<n.length;o++){let a=n[o],i=n[(o+1)%n.length],s=i.x-a.x,l=i.y-a.y,u=s*s+l*l,c=u>0?Math.max(0,Math.min(1,((t.x-a.x)*s+(t.y-a.y)*l)/u)):0,f={x:a.x+s*c,y:a.y+l*c},m=Math.hypot(t.x-f.x,t.y-f.y);m<r&&(r=m,e=f)}return e}function wo(t,n){let e=0,r=0;for(let o of t.values()){if(o.length<3)continue;let a=o[0],i=o[o.length-1],s=i.x-a.x,l=i.y-a.y,u=Math.hypot(s,l);if(u<1e-6)continue;let c={x:(a.x+i.x)/2,y:(a.y+i.y)/2},f=ne(c,n),m=f.x-c.x,y=f.y-c.y,h=Math.hypot(m,y);h<1e-6||(r+=Math.abs((-l*m+s*y)/(u*h))*o.length,e+=o.length)}return e?r/e:0}function Os(t,n,e){let r=t.filter(d=>d.type==="shape"),o=r.find(d=>d.role==="stage");if(o){let d=ut(o);return d?{shape:o,centre:$n(d),outline:d,inferred:!1}:null}if(!e.length)return null;let a=1/0,i=-1/0,s=1/0,l=-1/0;for(let d of e)a=Math.min(a,d.x),i=Math.max(i,d.x),s=Math.min(s,d.y),l=Math.max(l,d.y);let u=(i-a)*(l-s),c=[];for(let d of r){if(d.role)continue;let b=ut(d);if(!b)continue;let x=ln(b);if(x*$*$<6||x>u)continue;let g=Math.min(...b.map(I=>I.x)),S=Math.max(...b.map(I=>I.x)),A=Math.min(...b.map(I=>I.y)),M=Math.max(...b.map(I=>I.y)),p=0;for(let I of e)I.x>g&&I.x<S&&I.y>A&&I.y<M&&te(I,b)&&p++;if(p>e.length*.05)continue;let _=$n(b),P=wo(n,b);P>=ns&&c.push({shape:d,centre:_,outline:b,score:P,area:x,box:[g,A,S,M]})}let f=(d,b)=>b!==d&&b.area>d.area&&d.box[0]>=b.box[0]-1e-6&&d.box[1]>=b.box[1]-1e-6&&d.box[2]<=b.box[2]+1e-6&&d.box[3]<=b.box[3]+1e-6,m=c.filter(d=>!c.some(b=>f(d,b))),y=Math.max(0,...m.map(d=>d.score)),h=m.filter(d=>d.score>=y-.03).sort((d,b)=>b.area-d.area)[0]??null;return h?{shape:h.shape,centre:h.centre,outline:h.outline,inferred:!0}:null}function Cs(t,n,e){if(!e||e.length<3)return Math.hypot(t.x-n.x,t.y-n.y);let r=ne(t,e);return Math.hypot(t.x-r.x,t.y-r.y)}function Eo(t){let n=[...t].sort((a,i)=>a.x-i.x||a.y-i.y);if(n.length<3)return n;let e=(a,i,s)=>(i.x-a.x)*(s.y-a.y)-(i.y-a.y)*(s.x-a.x),r=[];for(let a of n){for(;r.length>=2&&e(r[r.length-2],r[r.length-1],a)<=0;)r.pop();r.push(a)}let o=[];for(let a=n.length-1;a>=0;a--){let i=n[a];for(;o.length>=2&&e(o[o.length-2],o[o.length-1],i)<=0;)o.pop();o.push(i)}return[...r.slice(0,-1),...o.slice(0,-1)]}function ks(t){if(!t.length||t.length>Is)return[];let n=[...Jn(t).values()],e=n.map((s,l)=>l),r=s=>e[s]===s?s:e[s]=r(e[s]),o=Rs/$,a=n.map(s=>({minX:Math.min(...s.map(l=>l.x))-o,maxX:Math.max(...s.map(l=>l.x))+o,minY:Math.min(...s.map(l=>l.y))-o,maxY:Math.max(...s.map(l=>l.y))+o}));for(let s=0;s<n.length;s++)for(let l=s+1;l<n.length;l++){let u=a[s],c=a[l];if(u.maxX<c.minX||c.maxX<u.minX||u.maxY<c.minY||c.maxY<u.minY)continue;n[s].some(m=>n[l].some(y=>Math.hypot(m.x-y.x,m.y-y.y)<=o))&&(e[r(s)]=r(l))}let i=new Map;return n.forEach((s,l)=>{let u=r(l),c=i.get(u);c?c.push(...s):i.set(u,[...s])}),[...i.values()].filter(s=>new Set(s.map(l=>l.rowId)).size>=2)}function Fs(t,n,e){if(!n.length)return null;let r=n.filter(P=>e.tableIds.has(P.rowId)||P.kind==="booth").length>n.length/2,o=Jn(n),a=!e.outline||wo(o,e.outline)>=es,i=0,s=0;for(let P of o.values()){if(P.length<2)continue;let I=P[0],E=P[P.length-1],T=E.x-I.x,F=E.y-I.y,k=Math.hypot(T,F);if(k<1e-6)continue;let w={x:(I.x+E.x)/2,y:(I.y+E.y)/2},B=a?e.outline?ne(w,e.outline):e.focal:e.middle,C=-F/k,v=T/k;C*(B.x-w.x)+v*(B.y-w.y)<0&&(C=-C,v=-v),i+=C*P.length,s+=v*P.length}let l={x:n.reduce((P,I)=>P+I.x,0)/n.length,y:n.reduce((P,I)=>P+I.y,0)/n.length};if(Math.hypot(i,s)<1e-9){let P=a?e.focal:e.middle;i=P.x-l.x,s=P.y-l.y}let u=Math.hypot(i,s)||1,c={x:i/u,y:s/u},f=P=>-(P.x*c.x+P.y*c.y),m=P=>-P.x*c.y+P.y*c.x,y=1/0,h=-1/0,d=1/0,b=-1/0,x=1/0,g=new Map;for(let P of n){let I=f(P),E=m(P);y=Math.min(y,I),h=Math.max(h,I),d=Math.min(d,E),b=Math.max(b,E),a&&(x=Math.min(x,Cs(P,e.focal,e.outline)));let T=P.logicalRowId??P.rowId,F=g.get(T);F?F.push(I):g.set(T,[I])}a||(x=Math.max(0,y-f(e.middle)));let S=[...g.values()].map(P=>Qn(P)).sort((P,I)=>P-I),A=[];if(!r)for(let P of S)A.length&&P-A[A.length-1]<Ki/$||A.push(P);let M=Ts(t),p=Wt(t,{floorBaseHeightM:e.baseHeightM}),_={id:t.id,section:t,authored:M,plane:e,facing:c,facesAction:a,hull:Eo(n),sample:n.filter((P,I)=>I%Math.ceil(n.length/is)===0),frontD:y,backD:h,latMin:d,latMax:b,frontDistance:x,rowDepths:A,rowCount:A.length,level:0,height:p.height,rake:M?p.rake:0,backHeight:0};return _.backHeight=_.height+(h-y)*$*Math.tan(_.rake*Math.PI/180),_}function Ls(t,n,e,r){if(t.length<2)return 0;let o=Math.max(1,n*$),a=e+Ui-r,i=0,s=0;for(let u=1;u<t.length;u++){let c=Math.max(Zi,(t[u]-t[u-1])*$),f=(a+Wi)*(o+c)/o;i+=f-a,s+=c,a=f,o+=c}let l=Math.atan(i/s)*180/Math.PI;return Math.round(Math.max(Io,Math.min(Yi,l))*10)/10}function vs(t,n,e=!1){if(!e&&t.facing.x*n.facing.x+t.facing.y*n.facing.y<rs)return null;let r=-1/0,o=1/0,a=-1/0;for(let m of n.hull){r=Math.max(r,-(m.x*t.facing.x+m.y*t.facing.y));let y=-m.x*t.facing.y+m.y*t.facing.x;o=Math.min(o,y),a=Math.max(a,y)}if(Math.min(t.latMax,a)-Math.max(t.latMin,o)<(e?1e-6:_o*(t.latMax-t.latMin)))return null;let s=Ao/$,l=new Map,u=new Map;for(let m of t.sample){let y=Math.floor((-m.x*t.facing.y+m.y*t.facing.x)/s),h=-(m.x*t.facing.x+m.y*t.facing.y);l.set(y,Math.min(l.get(y)??1/0,h))}for(let m of n.sample){let y=Math.floor((-m.x*t.facing.y+m.y*t.facing.x)/s),h=-(m.x*t.facing.x+m.y*t.facing.y);u.set(y,Math.max(u.get(y)??-1/0,h))}let c=[];for(let[m,y]of l){let h=u.get(m);h!==void 0&&c.push(y-h)}let f=c.length?Qn(c):t.frontD-r;return f<-1/$?null:f}function Ds(t,n){if(n.plane.floorIndex>=t.plane.floorIndex)return!1;let e=-1/0,r=1/0,o=1/0,a=-1/0;for(let l of n.hull){let u=-(l.x*t.facing.x+l.y*t.facing.y);e=Math.max(e,u),r=Math.min(r,u);let c=-l.x*t.facing.y+l.y*t.facing.x;o=Math.min(o,c),a=Math.max(a,c)}let i=Math.min(t.latMax,a)-Math.max(t.latMin,o),s=Math.min(t.backD,e)-Math.max(t.frontD,r);return i>_o*(t.latMax-t.latMin)&&s>1/$}function Ns(t,n){let e=new Set;for(let r of t){let o=(Math.atan2(r.y-n.y,r.x-n.x)*180/Math.PI+360)%360;e.add(Math.floor(o/10))}return e.size/36}function Gs(t,n){let e=1/0,r=-1/0;for(let a of n.hull){let i=-(a.x*t.facing.x+a.y*t.facing.y);e=Math.min(e,i),r=Math.max(r,i)}let o=Math.max(0,Math.min(r-e,t.frontD-e));return n.height+o*$*Math.tan(n.rake*Math.PI/180)}function Hs(t,n){if(!t.facesAction)return!1;let e={x:-t.facing.y,y:t.facing.x},r=Ao/$,o=Math.max(1,Math.ceil((t.backD-t.frontD)/r)),a={left:new Map,right:new Map};for(let s of n)if(!(s===t||s.plane.floorIndex!==t.plane.floorIndex)&&!(s.facing.x*t.facing.x+s.facing.y*t.facing.y>=ms))for(let l of s.sample){let u=-(l.x*t.facing.x+l.y*t.facing.y);if(u<t.frontD||u>t.backD)continue;let c=-l.x*t.facing.y+l.y*t.facing.x,f=c<t.latMin?"left":c>t.latMax?"right":null;if(!f)return!1;let m=Math.min(o-1,Math.floor((u-t.frontD)/r)),y=f==="left"?t.latMin-c:c-t.latMax;y<(a[f].get(m)?.gap??1/0)&&a[f].set(m,{gap:y,other:s})}let i=s=>{let l=s==="left"?t.latMin:t.latMax,u=0;for(let[c,{other:f}]of a[s]){if((f.facing.x*e.x+f.facing.y*e.y)*(s==="left"?1:-1)<us)continue;let y=t.frontD+(c+.5)*r,h={x:-y*t.facing.x+l*e.x,y:-y*t.facing.y+l*e.y},d=-(h.x*f.facing.x+h.y*f.facing.y),b=-h.x*f.facing.y+h.y*f.facing.x;d<f.frontD&&b>=f.latMin&&b<=f.latMax&&u++}return u/o>=fs};return i("left")&&i("right")}function Xs(t,n){if(n.plane.floorIndex!==t.plane.floorIndex||n.facing.x*t.facing.x+n.facing.y*t.facing.y<xs)return!1;let e=1/0,r=-1/0,o=1/0;for(let s of n.hull){let l=-s.x*t.facing.y+s.y*t.facing.x;e=Math.min(e,l),r=Math.max(r,l),o=Math.min(o,-(s.x*t.facing.x+s.y*t.facing.y))}let a=(t.frontD-o)*$;if(a<-bs||a>gs)return!1;let i=Math.max(e-t.latMax,t.latMin-r);return i*$<=Ms&&i*$>=-Ps}function js(t,n=!1,e=!1,r){let o=n?ts:Ji,a=new Set(e?[]:t.filter(d=>!d.authored&&Hs(d,t))),i=[...t].sort((d,b)=>d.plane.floorIndex-b.plane.floorIndex||Number(a.has(b))-Number(a.has(d))||d.frontDistance-b.frontDistance);for(let d of a)r?.add(d.id);let s=(d,b,x)=>{let g=new Map,S=[],A=new Map,M=p=>{if(p.plane.floorIndex===0||p.plane.baseHeightM>0)return p.plane.baseHeightM;let _=A.get(p.plane.floorIndex-1);return _===void 0?p.plane.baseHeightM:_+Ge};for(let p of i){if(a.has(p))p.height=M(p),p.level=0,p.rake=0,p.backHeight=p.height,g.set(p.id,void 0);else if(!p.authored){let P=M(p),I;for(let w of S){if(w.plane.floorIndex>p.plane.floorIndex)continue;if(Ds(p,w)){let O=Gs(p,w)+ss;O>P&&(P=O,I=w);continue}let B=vs(p,w,a.has(w));if(B==null)continue;let C=e&&!!p.plane.stageDeck&&w.level===0&&w.plane.floorIndex===p.plane.floorIndex&&Math.max(0,B)*$<=cs,v=a.has(w)?w.height+hs:C?w.backHeight:w.backHeight+zi+Math.min(Vi,Math.max(0,B)*$)*Math.tan(w.rake*Math.PI/180);v>P&&(P=v,I=w)}let E=d.get(p);E&&E.height>P+.01?(P=E.height,I=void 0):E=void 0,p.height=Math.round(Math.min(P,p.plane.baseHeightM+Qi)*100)/100;let T=!I&&!E&&p.height>p.plane.baseHeightM;if(p.level=I?I.level+1:E?E.level:T?1:0,p.rake=Ls(p.rowDepths,p.frontDistance,p.height,p.plane.focalHeightM),!p.facesAction&&p.rowCount<os)p.rake=0;else if(p.level===0){let w=Math.max(1e-6,(p.backD-p.frontD)*$);p.rake=Math.min(p.rake,qi,Math.round(Math.atan($i/w)*1800/Math.PI)/10)}else p.rowCount>=2&&(p.rake=Math.max(p.rake,o[Math.min(p.level,o.length)-1]));let F=(p.backD-p.frontD)*$,k=I&&a.has(I)||E&&x?.has(E.id);if(b!==void 0&&k&&p.rowCount>=2&&(p.rake=b),n&&F>0&&p.height+F*Math.tan(p.rake*Math.PI/180)>p.plane.baseHeightM+Po){let w=Math.max(0,p.plane.baseHeightM+Po-p.height);p.rake=Math.max(Io,Math.round(Math.atan(w/F)*1800/Math.PI)/10)}e&&p.plane.stageDeck&&p.level>0&&(p.rake=Math.min(p.rake,ls)),p.backHeight=p.height+F*Math.tan(p.rake*Math.PI/180),g.set(p.id,I?.id??(E?g.get(E.id):void 0))}let _=p.plane.floorIndex;A.set(_,Math.min(A.get(_)??1/0,p.height)),S.push(p)}return g},l=s(new Map),u=new Map,c=d=>u.get(d)?.height??d.height;for(let d=!0,b=0;d&&b<t.length;b++){d=!1;for(let x of t)if(!(x.authored||a.has(x)))for(let g of t){let S=u.get(g)??g;g===x||S.height-S.plane.baseHeightM<Ss||S.height<=c(x)+.01||Xs(x,g)&&(u.set(x,S),d=!0)}}let f=new Map(t.map(d=>[d.id,d])),m=t.filter(d=>!d.authored&&d.rowCount>=2&&a.has(f.get(l.get(d.id)??""))),y=m.length?Qn(m.map(d=>d.rake)):void 0;if(!u.size&&y===void 0)return l;let h=new Map([...new Set(u.values())].map(d=>[d,{...d}]));return s(new Map([...u].map(([d,b])=>[d,h.get(b)])),y,new Set(m.map(d=>d.id)))}var qn=(t,n)=>!!t&&t.x===n.x&&t.y===n.y;function Bo(t,n={x:0,y:-40}){let e=Pn(t),r=new Map;for(let x of e){if(!x.sectionId)continue;let g=r.get(x.sectionId);g?g.push(x):r.set(x.sectionId,[x])}let o={focalInferred:!1,confident:!1,sections:[]},a=t.floors?.length?t.floors.map((x,g)=>({objects:x.objects,floorIndex:g,floorId:x.id,baseHeightM:x.baseHeightM??0,focal:x.focalPoint??t.focalPoint})):[{objects:t.objects,floorIndex:0,floorId:void 0,baseHeightM:0,focal:t.focalPoint}],i=new Set(a.flatMap(x=>x.objects.filter(g=>g.type==="table").map(g=>g.id))),s=[],l,u=new Set,c=a.map(x=>{let g=k=>!t.floors?.length||k.floorId===x.floorId,S=ks(e.filter(k=>!k.sectionId&&k.kind!=="booth"&&!i.has(k.rowId)&&g(k))),A=[];for(let k of S){let w=It(Et(Eo(k)),_s/$);if(e.some(C=>!g(C)&&te(C,w)))continue;let B=`${So}${x.floorIndex}-${A.length}`;u.add(B),r.set(B,k),A.push({type:"section",id:B,label:"",color:As,outline:w})}let M=A.length?{...x,objects:[...x.objects,...A]}:x,p=new Set(M.objects.filter(k=>k.type==="section").map(k=>k.logicalSectionId??k.id)),_=[...r.entries()].filter(([k])=>p.has(k)).flatMap(([,k])=>k),P=Os(M.objects,Jn(_),_),I=M.focal;(P||M.focal&&!qn(M.focal,n))&&(o.confident=!0),P&&(o.stage??={id:P.shape.id,inferred:P.inferred,...M.floorId?{floorId:M.floorId}:{}},(P.inferred||qn(M.focal,n))&&(I=P.centre,o.focalInferred=!0));let E=P&&(!P.inferred||ln(P.outline)*$*$<=Zn),T=P?void 0:l,F={tableIds:i,floorIndex:M.floorIndex,floorId:M.floorId,baseHeightM:M.baseHeightM,focal:T?.focal??I,outline:P?.outline??T?.outline,focalHeightM:T?.focalHeightM??M.baseHeightM+(P&&E?_t({...P.shape,role:"stage"}).heightM:0),stageDeck:T?.stageDeck??!!(P&&E&&ln(P.outline)*$*$<=Zn),middle:_.length?{x:_.reduce((k,w)=>k+w.x,0)/_.length,y:_.reduce((k,w)=>k+w.y,0)/_.length}:I};for(let k of M.objects){if(k.type!=="section")continue;let w=Fs(k,r.get(k.logicalSectionId??k.id)??[],F);w&&s.push(w)}return F.outline&&(l=F),qn(M.focal,F.focal)||(o.focal??=[]).push({...M.floorId?{floorId:M.floorId}:{},point:{...F.focal}}),{unit:M,plane:F,stage:P,planeSeats:_}}),f=a.flatMap(x=>x.objects).map(x=>x.type==="shape"&&!x.role&&(Kn(x.label)==="wall"||!Kn(x.label)&&Mo(x))?{...x,role:"wall"}:x),m=Kt({objects:f},e)!==null;m&&(o.indoor=!0);let y=new Set,h=js(s,m,Ns(e,c[0]?.plane.focal??n)<as,y),d=new Map(s.filter(x=>!x.authored).map(x=>[x.id,x])),b=c.map(({unit:x,plane:g,stage:S,planeSeats:A})=>x.objects.map(M=>{let p=M.type==="shape"&&!M.role&&M.id!==S?.shape.id?Kn(M.label):null;if(M.type==="shape"&&!M.role&&M.id!==S?.shape.id&&(p==="wall"||!p&&Mo(M))&&M.type==="shape"){(o.roles??=[]).push({id:M.id,...g.floorId?{floorId:g.floorId}:{},role:"wall"});let{fill:w,...B}=M;return{...B,role:"wall"}}if(p&&M.type==="shape")return(o.roles??=[]).push({id:M.id,...g.floorId?{floorId:g.floorId}:{},role:p}),{...M,role:p};let P=S?.inferred&&M.id===S.shape.id&&M.type==="shape"?Es(M,S.outline,x.objects,A):null;if(P&&M.type==="shape")return o.stage?.id===M.id&&(o.stage.field=P),{...M,role:"stage",stageKind:P};let I=M.type==="shape"&&M.id===S?.shape.id&&M.heightM===void 0&&!M.stageKind&&s.some(w=>w.plane===g&&(y.has(w.id)||w.level===0&&w.facesAction&&w.rake<=ds&&(w.frontDistance+w.backD-w.frontD)*$>=ps)),E=I?{heightM:ys}:{};if(S?.inferred&&M.id===S.shape.id&&M.type==="shape"&&ln(S.outline)*$*$<=Zn)return o.stage?.id===M.id&&(o.stage.deck=!0),{...M,role:"stage",...E};if(I&&M.type==="shape"&&M.role==="stage")return{...M,...E};let T=M.type==="section"?d.get(M.id):void 0;if(!T||M.type!=="section")return M;let F=T.rowCount>=2&&T.rake>0;u.has(T.id)?o.looseRowBlocks=(o.looseRowBlocks??0)+1:o.sections.push({id:T.id,floorId:g.floorId,surfaceKind:F?"rakedRows":"flat",height:T.height,rake:T.rake,stackedOn:h.get(T.id)});let k={status:"inferred",source:"public-2d-topology",note:Bs};return{...M,height:T.height,rake:T.rake,surfaceKind:F?"rakedRows":"flat",physical3dProvenance:{height:k,rake:k,surfaceKind:k}}}));if(t.floors?.length){let x=t.floors.map((g,S)=>({...g,objects:b[S],focalPoint:c[S].plane.focal}));return{doc:{...t,floors:x,objects:x[0].objects,focalPoint:x[0].focalPoint},report:o}}return{doc:{...t,objects:b[0],focalPoint:c[0].plane.focal},report:o}}function su(t,n,e){return e<0?n>1?t.filter(r=>r.kind==="floor"):[...t]:t.filter(r=>r.floorIndex===void 0||r.floorIndex===e)}function au(t,n){let e=[...t].sort((o,a)=>o.screen.y-a.screen.y),r=[];for(let o of e){let a=r.find(i=>i.some(s=>Math.abs(s.screen.x-o.screen.x)<104&&Math.abs(s.screen.y-o.screen.y)<34));a?a.push(o):r.push([o])}return r.flatMap(o=>o.length<2?o:o.map((a,i)=>({...a,screen:{...a.screen,x:Math.max(54,Math.min(n-54,a.screen.x+(i-(o.length-1)/2)*104))}})))}var Us=1.15,Ws=2.75,Ys=4.5,zs=.85,Vs=.5,Ks=.26;function cu(t,n,e){let r=Math.max(1e-6,n),o=t/r,a=e?.hasZoneLabels??!0,i=new Set(["stage","gate"]);return o>=.75&&i.add("floor"),o>=Us&&i.add("zone"),o<=(a?Ws:Ys)&&(i.add("section"),i.add("ga")),o<=zs&&(i.add("annotation"),i.add("booth")),o<=Vs&&i.add("row"),o<=Ks&&i.add("seat"),i}function lu(t,n,e,r,o,a=6){let i=a+n,s=r-a-n,l=a+e,u=o-a-e;return{...t,x:i>s?r/2:Math.max(i,Math.min(s,t.x)),y:l>u?o/2:Math.max(l,Math.min(u,t.y))}}function uu(t,n,e,r){let o=t,a=n[0],i=n[1],s=n[2],l=o[0]*a+o[4]*i+o[8]*s+o[12],u=o[1]*a+o[5]*i+o[9]*s+o[13],c=o[2]*a+o[6]*i+o[10]*s+o[14],f=o[3]*a+o[7]*i+o[11]*s+o[15];if(!(f>1e-6))return{x:0,y:0,depth:1/0,visible:!1};let m=l/f,y=u/f,h=c/f,d=m>=-1.05&&m<=1.05&&y>=-1.05&&y<=1.05&&h<=1;return{x:(m*.5+.5)*e,y:(1-(y*.5+.5))*r,depth:h,visible:d}}function fu(t,n,e=n){let r=[],o=[...t].sort((a,i)=>a.screen.depth-i.screen.depth);for(let a of o){let i=!1;for(let s of r)if(ee(a,s,n,e)){i=!0;break}i||r.push(a)}return r}var Zs=6;function ee(t,n,e,r){let o=Math.abs(t.screen.x-n.screen.x),a=Math.abs(t.screen.y-n.screen.y),i=t.halfWidth!=null&&n.halfWidth!=null?Math.max(e,t.halfWidth+n.halfWidth+Zs):e;return o<i&&a<r}function mu(t,n,e){return t.length*n*.58+(e?14:0)}var qs={row:8,seat:14};function hu(t){return t<480?{row:5,seat:8}:t<768?{row:6,seat:10}:qs}function yu(t,n,e,r){let o=Math.max(1,Math.min(e,r)*.5),a=Math.min(2,Math.hypot(t.x-e/2,t.y-r/2)/o);return n*(1+1.5*a)}function du(t,n,e,r,o=[]){let a=[...t].sort((s,l)=>(l.priority??0)-(s.priority??0)||s.focus-l.focus),i=[];for(let s of a){if(i.length>=r)break;let l=!1;for(let u of o)if(ee(s,u,n,e)){l=!0;break}if(!l){for(let u of i)if(ee(s,u,n,e)){l=!0;break}}l||i.push(s)}return i}function pu(t,n,e,r){let o=t[3]*n[0]+t[7]*n[1]+t[11]*n[2]+t[15];return o<=0||!(e>0)?0:e*Math.hypot(t[0],t[4],t[8])*r/(2*o)}function Zt(t,n,e){if(t.length!==4||e<=n)return null;let r=bt(t),o=Math.hypot(r[1].x-r[0].x,r[1].y-r[0].y)*R,a=Math.hypot(r[3].x-r[0].x,r[3].y-r[0].y)*R;if(o<1e-6||a<1e-6)return null;let i=Math.min(.22/o,.16),s=Math.min(.28,(e-n)*.13),l=Math.min(.065/a,.2);return{quad:r,side:i,face:l,opening:dt(r,i,1-i),openingTop:e-s}}function oe(t,n,e){if(t.length!==4||e-n<=.2)return null;let r=bt(t),o=Math.hypot(r[1].x-r[0].x,r[1].y-r[0].y)*R;if(o<=1e-6)return null;let a=Math.min(.14,(e-n)*.08,o*.08),i=a/o,s=dt(r,i,1-i);return{quad:r,side:i,trim:a,inner:s,panel:an(s,.15,.85),bottom:n+a,top:e-a}}function To(t,n,e,r){let o=oe(t,n,e);if(!o)return;let{panel:a}=o,i=(g,S)=>({x:(g.x+S.x)/2,y:(g.y+S.y)/2}),s=i(a[0],a[1]),l=i(a[3],a[2]),u=Math.hypot(s.x-r.x,s.y-r.y)<=Math.hypot(l.x-r.x,l.y-r.y),[c,f]=u?[a[0],a[1]]:[a[3],a[2]],m=u?{x:s.x-l.x,y:s.y-l.y}:{x:l.x-s.x,y:l.y-s.y},y=Math.hypot(m.x,m.y);if(y<1e-6)return;-(f.y-c.y)*m.x+(f.x-c.x)*m.y<0&&([c,f]=[f,c]);let h=Math.min(.006,y*R*.05),d=m.x/y*h,b=m.y/y*h,x=(g,S)=>[g.x*R+d,S,g.y*R+b];return[x(c,o.bottom),x(f,o.bottom),x(c,o.top),x(f,o.top)]}import Qs from"polygon-clipping";import $s from"polygon-clipping";function Ot(t,n,e,r,o,a,i,s={}){let l=Tt(n),u=s.ao??V,c=o.flatMap(d=>{if(d.role!=="entrance"&&d.role!=="exit")return[];let b=ut(d);if(!b||b.length!==4||!zt(l,Tt(b)))return[];let x=s.portalBase??e,g=Zt(b,x,x+_t(d).heightM);if(!g)return[];let S=Math.min(r,g.openingTop);return S<=e?[]:[{poly:g.opening,height:S}]});if(!c.length)return!1;let f=d=>d.map(b=>[b.x,b.y]),m=[f(n),...(s.holes??[]).map(f)],y=[e,...new Set(c.map(d=>d.height)),r].sort((d,b)=>d-b),h=[];try{for(let d=1;d<y.length;d++){let b=y[d-1],x=y[d];if(x-b<1e-6)continue;let g=c.filter(A=>A.height>b+1e-6).map(A=>[f(A.poly)]),S=g.length?$s.difference(m,...g):[m];h.push({low:b,high:x,polys:S})}}catch{return!1}for(let d of h)for(let b of d.polys){let[x,...g]=b.map(A=>A.map(([M,p])=>({x:M,y:p}))),S=A=>u.wallBottom+(u.top-u.wallBottom)*(A-e)/(r-e);Z(t,x,g,()=>d.high,d.low,a,i,{...u,top:S(d.high),wallBottom:S(d.low)})}return!0}var re={depthM:1.6,thicknessM:.35,minWallM:6};function Oo(t,n,e,r,o,a,i,s){let l=r-e;if(l<=0)return;let u=s&&l>=re.minWallM?Js(n,s):null,c=u?r-re.thicknessM:r,f=c-e,m=f<1.5?[[e,c,1]]:u?[[e,e+Math.min(.9,f*.18),.82],[e+Math.min(.9,f*.18),c,1]]:[[e,e+Math.min(.9,f*.18),.82],[e+Math.min(.9,f*.18),c-.1,1],[c-.1,c,1.1]],y=h=>V.wallBottom+(V.top-V.wallBottom)*(h-e)/l;for(let[h,d,b]of m){let x={...V,top:y(d),wallBottom:y(h)},g=K(a,b),S=K(i,b);Ot(t,n,h,d,o,g,S,{portalBase:e,ao:x})||Z(t,n,void 0,()=>d,h,g,S,x)}for(let[h,...d]of u??[])Z(t,h,d.length?d:void 0,()=>r,c,K(a,1.12),K(i,.78),V)}function Js(t,n){let e=re.depthM/R,r=t.map(i=>{let s=n.x-i.x,l=n.y-i.y,u=Math.hypot(s,l)||1;return{x:i.x+s/u*e,y:i.y+l/u*e}}),o=i=>{let s=i.map(l=>[l.x,l.y]);return s.push(s[0]),s},a=[[o(t)],[o(r)]];for(let i=0;i<t.length;i++){let s=(i+1)%t.length;a.push([o([t[i],t[s],r[s],r[i]])])}try{let[i,...s]=a,l=Qs.union(i,...s);return l.length?l.map(u=>u.map(c=>c.slice(0,-1).map(([f,m])=>({x:f,y:m})))):null}catch{return null}}function un(t,n,e){let r=at(n.stroke?.color),o=n.stroke?.width??0;if(!r||!Number.isFinite(o)||o<=0)return;let a=n.kind==="line"||n.kind==="polyline",i=a?Bn(n.points??[],n.rotation):ut(n);if(!i||i.length<2)return;let s=a?i.length-1:i.length,l=o*.5;for(let u=0;u<s;u++){let c=i[u],f=i[(u+1)%i.length],m=Math.hypot(f.x-c.x,f.y-c.y);if(m<1e-6)continue;let y=-(f.y-c.y)/m*l,h=(f.x-c.x)/m*l,d=[(c.x+y)*R,e,(c.y+h)*R],b=[(f.x+y)*R,e,(f.y+h)*R],x=[(f.x-y)*R,e,(f.y-h)*R],g=[(c.x-y)*R,e,(c.y-h)*R];t.tri(d,b,x,[0,1,0],r),t.tri(d,x,g,[0,1,0],r)}}function Co(t){return t==="bar"||t==="concession"||t==="coat"||t==="restroom"}var qt=(t,n,e)=>({x:t.x+(n.x-t.x)*e,y:t.y+(n.y-t.y)*e});function Tn(t,n,e,r){let[o,a,i,s]=n?t:[t[3],t[2],t[1],t[0]];return[qt(o,s,e),qt(a,i,e),qt(a,i,r),qt(o,s,r)]}function ko(t,n,e,r,o,a,i,s,l=!1){if(e.length!==4||o-r<.4)return!1;let u=P=>l?Math.min(P,o):P,c=bt(e),f=Math.hypot(c[3].x-c[0].x,c[3].y-c[0].y)*R;if(f<.4)return!1;let m=qt(c[0],c[1],.5),y=qt(c[3],c[2],.5),h=Math.hypot(m.x-s.x,m.y-s.y)<=Math.hypot(y.x-s.x,y.y-s.y),d=it(i,[.92,.9,.86],.35),b=K(a,.72),x=o-r;if(n==="restroom"){let P=Math.min(.18,x*.08);return ot(t,c,o-P,r,i,a),ot(t,c,o,o-P,d,d),!0}let g=r+Math.min(1.1,x),S=n==="coat"?1:Math.min(.5,.75/f),A=Tn(c,h,0,S);if(ot(t,A,g-.05,r,b,a),ot(t,A,g,g-.05,d,d),n==="coat"||f<1.2)return!0;if(n==="bar"){let P=Tn(c,h,Math.max(S+.2,1-.45/f),1),I=u(r+Math.max(Math.min(2.2,x*2),g-r+.6));return ot(t,P,I,r,i,b),!0}let M=Tn(c,h,Math.max(S+.25,.55),1),p=u(r+Math.max(2.6,g-r+1.4));if(p-.14<=g)return!0;ot(t,M,p-.14,r,i,a),ot(t,c,p,p-.14,d,b);let _=Math.min(.08,.1/Math.max(.1,Math.hypot(c[1].x-c[0].x,c[1].y-c[0].y)*R));for(let[P,I]of[[0,_],[1-_,1]])ot(t,Tn(dt(c,P,I),h,0,Math.min(.08,.1/f)),p-.14,g,b,b);return!0}var Dt=.06,ta=.05,Lo=.05,Fo=.15,ie=25;function vo(t,n,e){let r=new Map,o=new Array(n.length).fill(null),a=new Float64Array(n.length),i=new Array(n.length).fill(void 0),s=new Array(n.length).fill(void 0),l=new Map,u=[],c=new Set;for(let m=0;m<t.length;m+=1){let y=t[m];for(let h of y.objects){if(h.type==="table"&&c.add(h.id),h.type!=="section"||!h.outline||h.outline.length<3)continue;let d=It(h.outline,St);l.set(h.id,{section:h,unit:y,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),u.push({id:h.id,floorIndex:m,box:Tt(d),section:h,unit:y,outline:d})}}let f=new Map;for(let m of u){let y=f.get(m.floorIndex);y?y.push(m):f.set(m.floorIndex,[m])}for(let m=0;m<n.length;m++){let y=n[m],h=e?f.get(e[m])??[]:u,d=y.sectionId?h.find(x=>x.id===y.sectionId)??h.find(x=>x.section.logicalSectionId===y.sectionId&&wt({x:y.x,y:y.y},x.outline,x.section.holes)):void 0,b=d?[d]:h;for(let x of b){if(e&&x.floorIndex!==e[m]||!d&&(y.x<x.box.minX||y.x>x.box.maxX||y.y<x.box.minY||y.y>x.box.maxY||!wt({x:y.x,y:y.y},x.outline,x.section.holes)))continue;o[m]=x.id;let g=l.get(x.id);g.hasSeats=!0;let S=y.focalPoint??x.unit.focal,A=Math.hypot(y.x-S.x,y.y-S.y);A<g.frontU&&(g.frontU=A),g.seatIndices.push(m);let M=y.rowId||`__seat-${m}`,p=g.rows.get(M);p?p.push({x:y.x,y:y.y}):g.rows.set(M,[{x:y.x,y:y.y}]);break}}for(let[m,y]of l){let h=Wt(y.section,{floorBaseHeightM:y.unit.baseHeightM}),d=y.unit.baseHeightM,b=h.rake>0?Math.tan(h.rake*Math.PI/180):0,x=h.rake<=.01&&h.height<=d+.001,g=y.section.surfaceKind,S=g==="flat"?!0:g==="rakedRows"&&h.rake>.01?!1:x,A=y.hasSeats?Ie(m,n,y.seatIndices,y.unit.focal):{sectionId:m,rows:[],blockCount:0},p=A.rows.length<2?ve([...y.rows.values()].map(O=>({points:O})),y.unit.focal):null,_=1/0;if(p){if(y.hasSeats)for(let O of y.rows.values())for(let N of O){let H=p.depthAt(N.x,N.y);H<_&&(_=H)}if(!y.hasSeats||!Number.isFinite(_)){_=1/0;for(let O of y.section.outline){let N=p.depthAt(O.x,O.y);N<_&&(_=N)}}}let P=d+ta,I=Math.max(P,h.height),E=O=>{let N=Math.max(0,O-_)*$,H=Math.min(N*b,ie);return Math.max(P,h.height+H)},T=O=>{let N=Math.max(0,O)*$,H=Math.min(N*b,ie);return Math.max(P,h.height+H)},F=S?[]:A.rows.map(O=>({pts:O.pts,y:T(O.blockDepth),depth:O.blockDepth,blockId:O.blockId,...c.has(O.id)?{patch:eo(O.pts,St)}:{}})),k=F.length?F[0].y:I,w=F.map(O=>{let N=O.patch&&O.patch.length>=3?O.patch:O.pts,H=0,j=0;for(let X of N)H+=X.x,j+=X.y;let G=N.length||1;H/=G,j/=G;let U=0;for(let X of N){let W=Math.hypot(X.x-H,X.y-j);W>U&&(U=W)}return{cx:H,cy:j,rad:U}}),B=S?()=>I:F.length>=2?(O,N)=>{let H=1/0,j=k;for(let G=0;G<F.length;G++){let U=w[G];if(Math.hypot(O-U.cx,N-U.cy)-U.rad>=H)continue;let X=F[G].patch,W=X&&X.length>=3?xt(X,O,N)?0:gn(X,O,N):gn(F[G].pts,O,N);W<H&&(H=W,j=F[G].y)}return j}:(O,N)=>p?E(p.depthAt(O,N)):I,C=[0,1,0],v=F.length>=2||S?()=>C:(O,N)=>{if(!p)return C;let H=p.depthAt(O,N);if(H<=_)return C;let j=(H-_)*$;if(j*b>=ie||h.height+j*b<=P)return C;let[G,U]=p.gradientAt(O,N);if(G===0&&U===0)return C;let X=1/Math.hypot(b,1);return[-G*b*X,X,-U*b*X]};if(!S)for(let O of A.rows){let N=T(O.blockDepth);for(let H of O.seatIndices)i[H]=N}for(let O of A.rows){let N=[];for(let X=1;X<O.pts.length;X++){let W=Math.hypot(O.pts[X].x-O.pts[X-1].x,O.pts[X].y-O.pts[X-1].y);W>1e-6&&N.push(W)}N.sort((X,W)=>X-W);let H=N.length?N[Math.floor(N.length/2)]:1/0,j=1/0,G=O.pts[Math.floor(O.pts.length/2)];if(G)for(let X of A.rows){if(X===O||X.blockId!==O.blockId)continue;let W=gn(X.pts,G.x,G.y);W>1e-6&&W<j&&(j=W)}let U=Math.min(H,Math.max(j,H*.5));if(Number.isFinite(U)&&U>0)for(let X of O.seatIndices)s[X]=U}r.set(m,{sectionId:m,deckAt:B,normalAt:v,flat:S,bottomY:d,rowLevels:F,landingY:k})}for(let m=0;m<n.length;m++){let y=o[m],h=n[m];if(y){let x=i[m];a[m]=(x??r.get(y).deckAt(h.x,h.y))+Fo;continue}let d=h.eyeHeightM,b=Number.isFinite(d)?Math.max(0,d-bn):0;a[m]=h.kind==="booth"?b+Dt+Fo:b}return{bySection:r,seatOwner:o,seatDeckY:m=>a[m],seatPitchU:m=>s[m]}}var na=[.12,.38,.16],ea=[.72,.62,.45],oa=[.88,.93,.96],Do=[.95,.95,.94],ra=[.66,.29,.22],se={length:20.12,width:3.05},ia=.14,sa=9.76,Ct=[.93,.94,.95],On=[.1,.11,.13],aa=[.45,.85,1.25],ca=1.45,No=.012,Go=.004,la=1.07,ua=.15;function Qt(t,n,e,r,o,a){t.setMaterial(a),Z(t,n,e?[e.slice().reverse()]:void 0,()=>r,r-.004,o,o,V)}var Ho=(t,n)=>Lt(t,n/R);function Xo(t,n,e){let r=n.x-t.x,o=n.y-t.y,a=Math.hypot(r,o);if(a<1e-9)return null;let i=-o/a*e,s=r/a*e;return[{x:t.x+i,y:t.y+s},{x:n.x+i,y:n.y+s},{x:n.x-i,y:n.y-s},{x:t.x-i,y:t.y-s}]}function fa(t,n,e,r){let o=n.map(a=>[a.x*R,e,a.y*R]);t.tri(o[0],o[1],o[2],[0,1,0],r),t.tri(o[0],o[2],o[3],[0,1,0],r)}function Cn(t,n,e,r,o,a){let i=e/R,s=[{x:n.x-i,y:n.y-i},{x:n.x+i,y:n.y-i},{x:n.x+i,y:n.y+i},{x:n.x-i,y:n.y+i}];Z(t,s,void 0,()=>o,r,a,K(a,.85),V)}function $t(t,n,e,r,o,a,i){let s=Xo(n,e,r/R);s&&Z(t,s,void 0,()=>a,o,i,K(i,.85),V)}function kn(t){let n=bt(t),e={x:(n[0].x+n[2].x)/2,y:(n[0].y+n[2].y)/2},r=Math.hypot(n[1].x-n[0].x,n[1].y-n[0].y)||1,o=Math.hypot(n[3].x-n[0].x,n[3].y-n[0].y)||1,a={x:(n[1].x-n[0].x)/r,y:(n[1].y-n[0].y)/r},i={x:(n[3].x-n[0].x)/o,y:(n[3].y-n[0].y)/o};return{at:(l,u)=>({x:e.x+(a.x*l+i.x*u)/R,y:e.y+(a.y*l+i.y*u)/R}),lengthM:r*R,widthM:o*R}}function jo(t,n,e){let r=we(n);if(!r.length)return;let o=1/0,a=-1/0,i=1/0,s=-1/0;for(let S of n.points??[])o=Math.min(o,S.x),a=Math.max(a,S.x),i=Math.min(i,S.y),s=Math.max(s,S.y);let l=(n.rotation??0)*Math.PI/180,u=Math.cos(l),c=Math.sin(l),f=(o+a)/2,m=(i+s)/2,y=S=>l?{x:f+(S.x-f)*u-(S.y-m)*c,y:m+(S.x-f)*c+(S.y-m)*u}:S,h=Math.min(a-o,s-i)*R,d=Math.max(.04,Math.min(.3,h*.004))/R,b=0;t.setMaterial(0);for(let S of r){if(!S.fill)continue;let A=S.points.map(y);Qt(t,A,null,e+No+b*Go,at(S.fill)??Ct,0),b++}let x=r.filter(S=>!(S.fill&&S.ink===S.fill)),g=[...new Set(x.map(S=>S.ink??Xn))];for(let S of g){let A=e+No+b++*Go,M=at(S)??Ct;for(let p of x){if((p.ink??Xn)!==S)continue;let _=p.points.map(y),P=p.closed?_.length:_.length-1;for(let I=0;I<P;I++){let E=Xo(_[I],_[(I+1)%_.length],d);E&&fa(t,E,A,M)}}}}function Uo(t,n,e,r,o){if(n.length<3)return!1;let a=r+.006,i=o??na;if(e==="oval-cricket"){let s=n.reduce((M,p)=>M+p.x,0)/n.length,l=n.reduce((M,p)=>M+p.y,0)/n.length,u=M=>n.map(p=>({x:s+(p.x-s)*M,y:l+(p.y-l)*M})),c=8;for(let M=0;M<c;M++){let p=u(1-M/c),_=M===c-1?null:u(1-(M+1)/c);Qt(t,p,_,a,K(i,M%2?1.04:.96),4)}let f=n[0];for(let M of n)Math.hypot(M.x-s,M.y-l)>Math.hypot(f.x-s,f.y-l)&&(f=M);let m=Math.hypot(f.x-s,f.y-l)||1,y=(f.x-s)/m,h=(f.y-l)/m,d=-h,b=y,x=Math.min(1,2*m*R*ia/se.length),g=se.length*x/2/R,S=se.width*x/2/R,A=[[-g,-S],[g,-S],[g,S],[-g,S]].map(([M,p])=>({x:s+y*M+d*p,y:l+h*M+b*p}));return Qt(t,A,null,a+.004,ea,0),t.setMaterial(0),!0}if(e==="rink-hockey"){let s=Ho(n,ua);return Qt(t,s,null,a,oa,0),t.setMaterial(0),Z(t,n,[s.slice().reverse()],()=>r+la,r,Do,K(Do,.9),V),!0}if(e==="ring-boxing"&&n.length===4){let{at:s}=kn(n),l=[s(-3.05,-3.05),s(3.05,-3.05),s(3.05,3.05),s(-3.05,3.05)],u=[[.77,.19,.19],Ct,[.17,.42,.69],Ct];t.setMaterial(0),l.forEach((c,f)=>Cn(t,c,.07,r,r+ca,u[f]));for(let c of aa)for(let f=0;f<4;f++)$t(t,l[f],l[(f+1)%4],.025,r+c-.025,r+c+.025,Ct);return!0}if(e==="court-tennis"&&n.length===4){let{at:s}=kn(n);t.setMaterial(0),$t(t,s(0,-6.4),s(0,6.4),.015,r,r+.95,On),$t(t,s(0,-6.4),s(0,6.4),.03,r+.95,r+1,Ct);for(let l of[-1,1])Cn(t,s(0,l*6.4),.05,r,r+1.07,On);return!0}if(e==="court-basketball"&&n.length===4){let{at:s,lengthM:l}=kn(n),u=Math.min(14,l/2-.5);t.setMaterial(0);for(let c of[-1,1]){let f=s(c*(u+1.2),0),m=s(c*(u-1.2),0);Cn(t,f,.12,r,r+3.4,On),$t(t,f,m,.06,r+3.25,r+3.4,On),$t(t,s(c*(u-1.2),-.9),s(c*(u-1.2),.9),.03,r+2.9,r+3.95,Ct)}return!0}if(e==="pitch-rugby"&&n.length===4){let{at:s,lengthM:l}=kn(n),u=l*(50/120);t.setMaterial(0);for(let c of[-1,1]){for(let f of[-2.8,2.8])Cn(t,s(c*u,f),.07,r,r+12,Ct);$t(t,s(c*u,-2.8),s(c*u,2.8),.06,r+2.94,r+3.06,Ct)}return!0}if(e==="track-athletics"){let s=Ho(n,sa);return s.length<3?!1:(Qt(t,n,s,a,ra,0),Qt(t,s,null,a,i,4),t.setMaterial(0),!0)}return!1}var Wo=[.19,.4,.15],ma=.012,vn=2.4,ha=1,ya=.75,da=.15;function At(t){if(t.points&&t.points.length>=3)return t.points;let{center:n,width:e,height:r,rotation:o}=t;if(!e||!r)return null;let a=(o??0)*Math.PI/180,i=Math.cos(a),s=Math.sin(a),l=e/2,u=r/2;return[[-l,-u],[l,-u],[l,u],[-l,u]].map(([c,f])=>({x:n.x+c*i-f*s,y:n.y+c*s+f*i}))}function qo(t,n,e,r,o,a,i=!1){let s=At(n);if(s){if(i){let l=Xt(r,o.boothTop),u=Et([...s]);Z(t,It(u,pa/R),[u.slice().reverse()],()=>e+.03,e,l,K(l,.8),V);return}if(!(!n.points&&a&&ba(t,s,e,r,a))){if(!n.points&&a&&s.length===4){xa(t,s,e,r,a);return}Z(t,s,void 0,()=>e+vn,e,Xt(r,o.boothTop),o.boothWall,V)}}}var ae=1.1,Yo=[.9,.9,.88],pa=.1,Fn=[.87,.87,.85],zo=.08;function $o(t,n){let e=l=>({x:(t[l].x+t[(l+1)%4].x)/2,y:(t[l].y+t[(l+1)%4].y)/2}),r=0,o=1/0;for(let l=0;l<4;l++){let u=e(l),c=Math.hypot(u.x-n.x,u.y-n.y);c<o&&(o=c,r=l)}let a=[0,1,2,3].map(l=>t[(r+l)%4]),i=(l,u,c)=>({x:l.x+(u.x-l.x)*c,y:l.y+(u.y-l.y)*c});return{q:a,part:(l,u,c,f)=>{let m=i(a[0],a[1],l),y=i(a[0],a[1],u),h=i(a[3],a[2],l),d=i(a[3],a[2],u);return[i(m,h,c),i(y,d,c),i(y,d,f),i(m,h,f)]},depthM:Math.hypot(a[3].x-a[0].x,a[3].y-a[0].y)*R,widthM:Math.hypot(a[1].x-a[0].x,a[1].y-a[0].y)*R}}function xa(t,n,e,r,o){let{q:a,part:i}=$o(n,o),s=r??[.35,.42,.55],l=it(s,[.78,.78,.77],.62),u=it(s,[.95,.95,.94],.45);ot(t,a,e+Dt,e,l,K(l,.8)),ot(t,i(.05,.95,.72,.98),e+ae-.05,e+Dt,u,K(u,.8)),ot(t,i(.03,.97,.7,1),e+ae,e+ae-.05,Yo,K(Yo,.9))}function ba(t,n,e,r,o){if(n.length!==4)return!1;let{q:a,part:i,depthM:s,widthM:l}=$o(n,o);if(s<1||l<1)return!1;let u=r??[.35,.42,.55],c=it(u,[.78,.78,.77],.62),f=e+vn,m=zo/l,y=zo/s;ot(t,a,e+Dt,e,c,K(c,.8)),ot(t,i(0,1,1-y,1),f,e+Dt,Fn,K(Fn,.9));for(let[b,x]of[[0,m],[1-m,1]])ot(t,i(b,x,0,1-y),f,e+Dt,Fn,K(Fn,.9));ot(t,i(m,1-m,0,Math.min(.5,.06/s)),f,f-.3,u,K(u,.85));let h=Math.min(.4,.6/l),d=Math.min(.12,.3/s);return ot(t,i(.5-h,.5+h,.72-d,.72+d),e+ha,e+Dt,it(u,[.95,.95,.94],.7),K(u,.75)),!0}function Dn(t){if(t.shape==="round"){let c=t.radius;return c?_n(t.center.x,t.center.y,c,c,24):null}let{width:n,height:e,rotation:r,center:o}=t;if(!n||!e)return null;let a=(r??0)*Math.PI/180,i=Math.cos(a),s=Math.sin(a),l=n/2,u=e/2;return[[-l,-u],[l,-u],[l,u],[-l,u]].map(([c,f])=>({x:o.x+c*i-f*s,y:o.y+c*s+f*i}))}function Qo(t,n,e,r,o,a=!0){let i=Dn(n);if(!i)return;let s=i.reduce((m,y)=>m+y.x,0)/i.length,l=i.reduce((m,y)=>m+y.y,0)/i.length,u=m=>i.map(y=>({x:s+(y.x-s)*m,y:l+(y.y-l)*m})),c=a&&r?Xt(r,o.tableTop):ga,f=e+ya;Z(t,i,void 0,()=>f,e+Ma,c,K(c,.86),V),Z(t,u(.12),void 0,()=>f+.12,f,Vo,K(Vo,.8),V)}var ga=[.93,.92,.89],Vo=[.78,.66,.42],Ma=.25,fn={armM:1.1,widthM:.28,insideM:1.4,low:.043,high:.048};function Pa(t,n,e){let r=t.reduce((x,g)=>x+g.x,0)/4,o=t.reduce((x,g)=>x+g.y,0)/4,a=t[3].x-t[0].x,i=t[3].y-t[0].y,s=Math.hypot(a,i)||1;a/=s,i/=s,a*(n.x-r)+i*(n.y-o)<0&&(a=-a,i=-i);let l=-i,u=a,c=fn.armM/R,f=fn.widthM/R,m=s/2+fn.insideM/R,y=e?-1:1,h=r+a*(m+(e?0:c)),d=o+i*(m+(e?0:c)),b=(x,g)=>({x:h+a*x*y+l*g,y:d+i*x*y+u*g});return[b(0,0),b(-c,c),b(-c-f,c),b(-f,0),b(-c-f,-c),b(-c,-c)]}function Sa(t,n,e,r,o){let a=[.94,.95,.96];Z(t,Pa(n,r,o),void 0,()=>e+fn.high,e+fn.low,a,a,V)}function Jo(t,n,e,r,o,a,i,s,l=[]){let u=ut(n);if(!n.role&&(!n.fill||n.fill==="none"||n.fill==="transparent")||!u){un(t,n,e+r+ma);return}let f=s?s.kind==="stage":n.role==="stage",m=s?s.kind==="screen":n.role==="screen",y=s?{kind:f?"stage":"solid",heightM:s.topY-s.baseY}:_t(n),h=s?.baseY??e,d=s?.topY??e+r;if(f&&i){let P=1/0,I=-1/0,E=1/0,T=-1/0;for(let F of u)F.x<P&&(P=F.x),F.x>I&&(I=F.x),F.y<E&&(E=F.y),F.y>T&&(T=F.y);i.push({cx:(P+I)/2*R,cz:(E+T)/2*R,y:d,halfX:Math.max((I-P)/2*R,.5),halfZ:Math.max((T-E)/2*R,.5)})}let b=at(n.fill),x=n.role==="wall"||n.role==="entrance"||n.role==="exit",g=x?b?K(Rt(b,.12),.95):o.tierTop:f&&b?it(o.stageTop,K(Rt(b,.18),.9),.9):!n.role&&b?b:Xt(b,f?o.stageTop:o.decorTop),S=m?b:null,A=x?b?K(Rt(b,.12),.85):o.tierWall:f?b?it(o.stageWall,K(b,.58),.82):o.stageWall:m?S?it(K(S,1.42),[.24,.46,.82],.08):[.24,.46,.82]:Xt(at(n.fill),o.decorWall);if(n.role==="wall"&&!s){Oo(t,u,h,d,l,g,A,a),un(t,n,d+.012);return}if(m&&u.length===4&&d-h>.2){let P=oe(u,h,d);if(!P)return;let{quad:I,side:E,trim:T,inner:F,panel:k}=P,w=[.12,.15,.18];for(let[B,C]of[[0,E],[1-E,1]])ot(t,dt(I,B,C),d,h,w,w);ot(t,F,h+T,h,w,w),ot(t,F,d,d-T,w,w),ot(t,k,d-T,h+T,A,A),un(t,n,d+.012);return}let M=b?K(Rt(b,.15),.82):A,p=b?K(Rt(b,.1),1.02):g;if(Co(n.role)&&!s&&ko(t,n.role,u,h,d,M,p,a,n.heightM!==void 0))return;if((n.role==="sound"||s?.kind==="sound_desk")&&u.length===4&&d-h>.3){let P=bt(u),I=Math.hypot(P[1].x-P[0].x,P[1].y-P[0].y)*R,E=Math.min(.12,.09/Math.max(I,.001)),T=[.18,.21,.24],F=d-Math.min(.12,(d-h)*.15);for(let[k,w]of[[0,E],[1-E,1]])ot(t,dt(P,k,w),F,h,T,T);ot(t,P,d,F,g,T);return}if(n.role==="rail"&&u.length===4&&d>h){let P=bt(u),I=Math.hypot(P[1].x-P[0].x,P[1].y-P[0].y)*R,E=Math.max(1,Math.min(128,Math.ceil(I/1.4))),T=Math.min(.08,.055/Math.max(.055,I)),F=[.58,.64,.66];for(let k=0;k<=E;k++){let w=k/E,B=Math.min(1-T,Math.max(0,w-T/2));ot(t,dt(P,B,B+T),d,h,F,K(F,.8))}for(let k of[.52,1]){let w=h+(d-h)*k;ot(t,P,w,Math.max(h,w-.055),F,K(F,.8))}return}if(n.role==="goal"&&u.length===4){let P=bt(u),I=Math.hypot(P[1].x-P[0].x,P[1].y-P[0].y)*R,E=Math.min(.12,.1/Math.max(.1,I)),T=[.9,.94,.94];for(let[F,k]of[[0,E],[1-E,1]])ot(t,dt(P,F,k),Math.max(h,d-.1),h,T,T);ot(t,P,d,Math.max(h,d-.1),T,T);return}if(y.kind==="portal"&&u.length===4){let P=Zt(u,h,d);if(!P)return;let{quad:I,side:E,face:T,openingTop:F}=P;for(let[k,w,B]of[[0,T,1],[T,1-T,.67],[1-T,1,1]]){let C=an(I,k,w),v=K(g,B),O=K(A,B);for(let[N,H]of[[0,E],[1-E,1]])ot(t,dt(C,N,H),F,h,v,O);ot(t,C,d,F,v,O)}(n.role==="entrance"||n.role==="exit")&&Sa(t,I,h,a,n.role==="exit");return}if(y.kind==="suite"&&u.length===4){let P=u.map((T,F)=>{let k=u[(F+1)%4],w=(T.x+k.x)/2,B=(T.y+k.y)/2;return Math.hypot(w-a.x,B-a.y)}),I=P.indexOf(Math.min(...P)),E=[0,1,2,3].map(T=>u[(I+T)%4]);ot(t,dt(E,0,.08),d,h,g,A),ot(t,dt(E,.92,1),d,h,g,A),ot(t,an(E,.88,1),d,h,g,A),ot(t,E,d,Math.max(h,d-.18),g,A);return}if(f&&!n.stageKind?.startsWith("pitch-")&&d-h>.12){let P=d-Math.min(.06,(d-h)*.15);ot(t,u,P,h,g,A),ot(t,u,d,P,g,it(g,A,.2))}else ot(t,u,d,h,g,A);if((n.stageKind==="pitch-football"||n.stageKind==="pitch-rugby")&&u.length===4){t.setMaterial(4);let P=bt(u),I=it(b??Wo,Wo,b?.45:0);for(let E=0;E<12;E++){let T=dt(P,E/12,(E+1)/12),F=K(I,E%2?1.09:.91),k=T.map(w=>[w.x*R,d+.006,w.y*R]);t.tri(k[0],k[1],k[2],[0,1,0],F),t.tri(k[0],k[2],k[3],[0,1,0],F)}}n.stageKind&&n.stageKind!=="pitch-football"&&Uo(t,u,n.stageKind,d,b),f&&Yt(n.stageKind)&&jo(t,n,d),t.setMaterial(m?1:0),un(t,n,d+.012)}function Nn(t){let{x:n,y:e,width:r,height:o}=t;if(!r||!o)return null;let a=n+r/2,i=e+o/2,s=(t.rotation??0)*Math.PI/180,l=Math.cos(s),u=Math.sin(s),c=r/2,f=o/2;return[[-c,-f],[c,-f],[c,f],[-c,f]].map(([m,y])=>({x:a+m*l-y*u,y:i+m*u+y*l}))}function Ra(t){if(!t||!t.startsWith("data:image/svg+xml"))return null;let n=t.slice(t.indexOf(",")+1);if(/;base64/i.test(t.slice(0,t.indexOf(","))))try{n=atob(n)}catch{return null}else try{n=decodeURIComponent(n)}catch{}let e=n.match(/<(?:rect|path)\b[^>]*\bfill="([^"]+)"/i);if(!e)return null;let r=e[1].trim();if(r==="none"||r==="transparent")return null;let o=r.match(/^url\(#([^)]+)\)$/);if(!o)return at(r);let a=n.match(new RegExp(`<(?:linear|radial)Gradient\\b[^>]*\\bid="${o[1]}"[^>]*>([\\s\\S]*?)</(?:linear|radial)Gradient>`,"i"));if(!a)return null;let i=[];for(let s of a[1].matchAll(/stop-color="([^"]+)"/gi)){let l=at(s[1].trim());l&&i.push(l)}return i.length?i.reduce((s,l,u)=>it(s,l,1/(u+1)),i[0]):null}function tr(t,n,e,r){if(n.layer==="foreground")return;let o=Nn(n);if(!o)return;let a=e+da,i=Xt(Ra(n.href),r.decorTop),s=Math.max(0,Math.min(1,n.opacity??1));s<1&&(i=it(r.ground,i,s)),Z(t,o,void 0,()=>a,e,i,it(i,r.decorWall,.5),V)}function nr(t,n,e,r,o){if(!n.points||n.points.length<3)return;let a=Ke(r,o.gaTop);Z(t,n.points,n.holes,()=>e+Ko,e,a,o.gaWall,V),Aa(t,n.points,e+Ko)}var Ko=.15,Ln=[.72,.74,.76],ce=1.1,Zo=.12,le=.05,Ia=.06,_a=2.4;function Aa(t,n,e){let r=Et([...n]),o=Lt(r,Zo/R),a=Lt(r,(Zo+le)/R);if(o.length<3||a.length<3)return;for(let s of[e+ce,e+ce*.5])Z(t,o,[a.slice().reverse()],()=>s,s-le,Ln,K(Ln,.85),V);let i=Ia/2/R;for(let s=0;s<o.length;s++){let l=o[s],u=o[(s+1)%o.length],c=Math.hypot(u.x-l.x,u.y-l.y)*R,f=Math.max(1,Math.round(c/_a));for(let m=0;m<f;m++){let y=m/f,h=l.x+(u.x-l.x)*y,d=l.y+(u.y-l.y)*y,b=[{x:h-i,y:d-i},{x:h+i,y:d-i},{x:h+i,y:d+i},{x:h-i,y:d+i}];Z(t,b,void 0,()=>e+ce-le,e,Ln,K(Ln,.8),V)}}}var wa=6,Ea=2.2,er=.1,Ba=new Set(["stage","entrance","exit","screen","suite","obstruction","sound","bar","concession","restroom","coat"]),Ta=.3,Oa=1.8,Ca=.9,ka=.55,Fa=1,or=4e3,La=6,rr="#d8a425",va="#e8c15a",ue="#1c1608";function ir(t){let n=Da(t);if(!n)return null;let e=Ee(t).find(r=>r.icon===n.icon);return{...n,name:e?.titleFallback??n.icon}}function Da(t){let n=t.accessibility;if(n?.length)return{icon:n.includes("wheelchair")?"wheelchair":n[0],color:xn(n)};let e=t.commercial;return e?.obstructedView?{icon:"obstructedView",color:rr,ink:ue}:e?.restrictedView?{icon:"restrictedView",color:rr,ink:ue}:e?.premium?{icon:"premium",color:va,ink:ue}:null}function Na(t,n){if(!t)return;let e,r=0;for(let[a,i]of t)i>r&&(r=i,e=a);let o=n.categories?.find(a=>a.key===e)?.color;return o&&/^#[0-9a-f]{6}$/i.test(o)?o:void 0}var Ga=6e3;function ar(t){let{doc:n,units:e,seats:r,surfaces:o,focal:a}=t,i=n.zones??[],s=[];if(i.length){let l=new Map;for(let c of e)for(let f of c.objects)f.type==="section"&&f.zone&&l.set(f.id,f.zone);let u=new Map;for(let c=0;c<r.length;c++){let f=r[c],m=o.seatOwner[c],y=f.zoneId??(m?l.get(m):void 0);if(!y)continue;let h=u.get(y);h||(h={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},u.set(y,h)),h.n++,f.x<h.minX&&(h.minX=f.x),f.y<h.minY&&(h.minY=f.y),f.x>h.maxX&&(h.maxX=f.x),f.y>h.maxY&&(h.maxY=f.y),h.sumY+=o.seatDeckY(c)}for(let c of i){let f=u.get(c.id),m=[];for(let[y,h]of l)h===c.id&&m.push(y);if(!f||f.n===0){s.push({id:c.id,label:c.label,color:at(c.color),sectionIds:m,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(c.focalPoint??a).x*R,1.5,(c.focalPoint??a).y*R]});continue}s.push({id:c.id,label:c.label,color:at(c.color),sectionIds:m,seatCount:f.n,center:[(f.minX+f.maxX)/2*R,f.sumY/f.n,(f.minY+f.maxY)/2*R],radius:.5*Math.hypot((f.maxX-f.minX)*R,(f.maxY-f.minY)*R)||1,focalWorld:[(c.focalPoint??a).x*R,1.5,(c.focalPoint??a).y*R]})}}return s}function cr(t){let{doc:n,units:e,seats:r,surfaces:o,seatData:a,hintedSeatFloor:i,zones:s,focal:l}=t,u=[],c=[],f=[],m=new Map;for(let y of e)for(let h of y.objects){if(h.type!=="section"||!h.zone)continue;let d=(h.displayLabel||h.label||"").trim().toLocaleLowerCase();if(!d)continue;let b=n.floors?.[y.index]?.name?.trim().toLocaleLowerCase();if(e.length>1&&b===d)continue;let x=m.get(h.zone);x||m.set(h.zone,x=new Set),x.add(d)}for(let y of s)y.seatCount!==0&&(m.get(y.id)?.has(y.label.trim().toLocaleLowerCase())||u.push({id:`zone:${y.id}`,kind:"zone",text:y.label,anchor:[y.center[0],y.center[1]+wa,y.center[2]],color:n.zones?.find(h=>h.id===y.id)?.color}));{let y=new Map,h=new Map,d=new Map,b=new Map;for(let x=0;x<r.length;x++){let g=o.seatOwner[x];if(!g)continue;let S=y.get(g);S||(S={n:0,x:0,y:0,deck:0},y.set(g,S)),S.n++,S.x+=r[x].x,S.y+=r[x].y,S.deck+=o.seatDeckY(x);let A=r[x].categoryKey;if(A){let p=h.get(g);p||(p=new Map,h.set(g,p)),p.set(A,(p.get(A)??0)+1)}if(r[x].accessibility?.includes("wheelchair")){let p=d.get(g);p?p.push(x):d.set(g,[x])}let M=b.get(g);M||(M={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0,minDeck:1/0,maxDeck:-1/0},b.set(g,M)),M.minDeck=Math.min(M.minDeck,o.seatDeckY(x)),M.maxDeck=Math.max(M.maxDeck,o.seatDeckY(x)),r[x].x<M.minX&&(M.minX=r[x].x),r[x].x>M.maxX&&(M.maxX=r[x].x),r[x].y<M.minY&&(M.minY=r[x].y),r[x].y>M.maxY&&(M.maxY=r[x].y)}for(let x of e)for(let g of x.objects){if(g.type!=="section"||Ro(g))continue;let S=y.get(g.id);if(!S||S.n===0)continue;let A=b.get(g.id),M=[S.x/S.n*R,S.deck/S.n,S.y/S.n*R],p=g.displayLabel||g.label||g.id;c.push({id:g.id,floorIndex:x.index,label:p,seatCount:S.n,center:M,radius:Math.max(1,Math.hypot(A.maxX-A.minX,A.maxY-A.minY)*.5*R),box:{min:[A.minX*R-.4,A.minDeck,A.minY*R-.4],max:[A.maxX*R+.4,A.maxDeck+1,A.maxY*R+.4]},focalWorld:[x.focal.x*R,x.baseHeightM+1.5,x.focal.y*R]});let _=n.floors?.[x.index]?.name?.trim().toLocaleLowerCase();if(!(e.length>1&&_===p.trim().toLocaleLowerCase())){let P=Na(h.get(g.id),n),I=d.get(g.id);u.push({id:`section:${g.id}`,kind:"section",text:p,anchor:[M[0],M[1]+Ea,M[2]],floorIndex:x.index,...P?{tint:P}:{},...I?{wheelchairSeats:I}:{}})}}}{for(let M of e)for(let p of M.objects){if(p.type!=="gaArea")continue;let _=nn(p.points);if(!_)continue;let P=p.displayLabel||p.label||p.id;u.push({id:`ga:${p.id}`,kind:"ga",text:p.capacity>0?`${P} \xB7 ${p.capacity.toLocaleString()}`:P,anchor:[_.x*R,M.baseHeightM+Oa,_.y*R],floorIndex:M.index})}let y=new Map,h=new Map;for(let M of e)for(let p of M.objects)if(p.type==="section"&&y.set(p.id,p.displayLabel||p.label||p.id),p.type==="row"){let _=p.displayLabel?.trim()||p.segmentedRow?.displayLabel?.trim();_&&h.set(p.id,_)}let d=new Map;for(let M=0;M<r.length;M++){let p=r[M],_=Math.hypot(p.x-l.x,p.y-l.y),P=d.get(p.rowId);(!P||_>P.far)&&d.set(p.rowId,{seat:p,index:M,far:_})}for(let[M,p]of d){let _=o.seatOwner[p.index]??p.seat.sectionId,P=sr(p.seat.label,M,y.get(_??""),h.get(M));P&&u.push({id:`row:${M}`,kind:"row",text:P,anchor:[p.seat.x*R,o.seatDeckY(p.index)+Ca,p.seat.y*R],floorIndex:i[p.index]})}let b=new Map;for(let M=0;M<r.length;M++){let p=r[M],_=b.get(p.rowId);_||(_={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:sr(p.label,p.rowId,y.get(o.seatOwner[M]??p.sectionId??""),h.get(p.rowId)),sectionId:o.seatOwner[M]??p.sectionId},b.set(p.rowId,_));let P=M*3,I=a.iPosition[P],E=a.iPosition[P+1],T=a.iPosition[P+2];_.n++,_.x+=I,_.y+=E,_.z+=T,_.minX=Math.min(_.minX,I),_.maxX=Math.max(_.maxX,I),_.minZ=Math.min(_.minZ,T),_.maxZ=Math.max(_.maxZ,T)}for(let[M,p]of b)f.push({id:M,label:p.label,sectionId:p.sectionId,seatCount:p.n,center:[p.x/p.n,p.y/p.n,p.z/p.n],radius:Math.max(.8,Math.hypot(p.maxX-p.minX,p.maxZ-p.minZ)*.5)});let x=0,g=(M,p)=>{x++,u.push({id:`access:${r[M].id}`,kind:"access",text:p.name,icon:p.icon,color:p.color,...p.ink?{ink:p.ink}:{},seatWidthM:a.iChairWidth[M]*2,anchor:[r[M].x*R,o.seatDeckY(M)+Fa,r[M].y*R],floorIndex:i[M],rowId:r[M].rowId})},S=null,A=()=>{if(S){let M=ir(r[S.seats[0]]),p=S.seats.length,_=Math.max(1,Math.round(p/La));for(let P=0;P<_&&x<or;P++)g(S.seats[Math.min(p-1,Math.floor((P+.5)*p/_))],M)}S=null};for(let M=0;M<r.length&&x<or;M++){let p=ir(r[M]);if(p&&r[M].accessibility?.length){A(),g(M,p);continue}if(!p){A();continue}S&&S.rowId===r[M].rowId&&S.icon===p.icon?S.seats.push(M):(A(),S={rowId:r[M].rowId,icon:p.icon,seats:[M]})}if(A(),r.length<=Ga)for(let M=0;M<r.length;M++){let p=r[M],_=Ha(p.displayLabel||p.label);_&&u.push({id:`seat:${p.id}`,kind:"seat",seatWidthM:a.iChairWidth[M]*2,text:_,anchor:[p.x*R,o.seatDeckY(M)+ka,p.y*R],floorIndex:i[M],rowId:p.rowId})}}for(let y of e)for(let h of y.objects)if(h.type==="shape"&&h.role&&Ba.has(h.role)){let d=ut(h),b=d?nn(d):null;if(!b||!h.label)continue;u.push({id:`architecture:${h.id}`,kind:h.role==="stage"?"stage":h.role==="entrance"||h.role==="exit"?"gate":"annotation",text:h.label,...h.role==="entrance"||h.role==="exit"?{icon:h.role}:{},anchor:[b.x*R,y.baseHeightM+_t(h).heightM+er,b.y*R],color:h.fill,floorIndex:y.index})}else if(h.type==="text"){if(!h.text)continue;u.push({id:`text:${h.id}`,kind:"annotation",text:h.text,anchor:[h.position.x*R,y.baseHeightM+er,h.position.y*R],color:h.color,rotation:h.rotation,floorIndex:y.index})}else if(h.type==="booth"){let d=At(h);if(!d)continue;let b=nn(d);if(!b)continue;u.push({id:`booth:${h.id}`,kind:"booth",text:h.displayLabel||h.label||h.id,anchor:[b.x*R,y.baseHeightM+vn+Ta,b.y*R],floorIndex:y.index})}return{labels:u,sections:c,rows:f}}function lr(t,n){if(n.length>1)for(let e of n)t.push({id:`floor:${e.id}`,kind:"floor",text:e.label,anchor:[e.center[0],e.box.max[1]+1.2,e.center[2]],floorIndex:e.index})}function Ha(t){let n=t.lastIndexOf("-");return n>=0&&n<t.length-1?t.slice(n+1):t}function sr(t,n,e,r){if(r?.trim())return r.trim();let o=t?t.lastIndexOf("-"):-1,a=o>0?t.slice(0,o):n;return a&&ke(a,e)}var mn=3,jt=.38,hn=.24;function Xa(t){if(t.length<3)return null;let n=t[0],e=t[Math.floor(t.length/2)],r=t[t.length-1],o=(e.x-n.x)*R,a=(e.y-n.y)*R,i=(r.x-n.x)*R,s=(r.y-n.y)*R,l=2*(o*s-a*i);if(Math.abs(l)<1e-7)return null;let u=o*o+a*a,c=i*i+s*s,f=(u*s-c*a)/l+n.x*R,m=(o*c-i*u)/l+n.y*R,y=Math.hypot(n.x*R-f,n.y*R-m);return y<1||y>200||!Number.isFinite(y)||t.some(h=>Math.abs(Math.hypot(h.x*R-f,h.y*R-m)-y)>.03)?null:{x:f,z:m,radius:y}}function ur(t){let n=[],e=new Map,r=(l,u)=>`${Math.floor(l/mn)},${Math.floor(u/mn)}`;for(let l of t)for(let u of l.rows){for(let f of u.pts){let m=f.x*R,y=f.y*R,h=r(m,y),d=e.get(h)??[];d.push({x:m,z:y,y:u.y,floor:l.floorIndex}),e.set(h,d)}if(u.patch||u.pts.length<2)continue;let c=Xa(u.pts);for(let f of[0,u.pts.length-1]){let m=u.pts[f],y=u.pts[f===0?1:f-1],h=m.x-y.x,d=m.y-y.y,b=Math.hypot(h,d);b<1e-6||n.push({sectionId:l.sectionId,floorIndex:l.floorIndex,curve:c,row:u,point:m,x:m.x*R,z:m.y*R,dx:h/b,dz:d/b})}}let o=new Map;n.forEach((l,u)=>{let c=r(l.x,l.z),f=o.get(c)??[];f.push(u),o.set(c,f)});let a=(l,u)=>{let c=Math.floor(l/mn),f=Math.floor(u/mn);return[-1,0,1].flatMap(m=>[-1,0,1].map(y=>`${c+m},${f+y}`))},i=new Map;n.forEach((l,u)=>{let c=-1,f=1/0,m=!1;for(let y of a(l.x,l.z))for(let h of o.get(y)??[]){let d=n[h];if(l.sectionId===d.sectionId&&l.row.blockId===d.row.blockId||l.floorIndex!==d.floorIndex||Math.abs(l.row.y-d.row.y)>.05)continue;let b=d.x-l.x,x=d.z-l.z,g=Math.hypot(b,x);if(g<jt*2+.45||g>mn)continue;let S=l.curve&&d.curve&&Math.hypot(l.curve.x-d.curve.x,l.curve.z-d.curve.z)<=.05&&Math.abs(l.curve.radius-d.curve.radius)<=.05,A=Math.min((b*l.dx+x*l.dz)/g,(-b*d.dx-x*d.dz)/g);(S?A<.8:A<.98)||!S&&(Math.abs(b*l.dz-x*l.dx)>.15||Math.abs(b*d.dz-x*d.dx)>.15)||(g<f-.02?(c=h,f=g,m=!1):Math.abs(g-f)<=.02&&(m=!0))}c>=0&&!m&&i.set(u,c)});let s=[];for(let[l,u]of i){if(l>=u||i.get(u)!==l)continue;let c=n[l],f=n[u],m=Math.hypot(f.x-c.x,f.z-c.z),y=(f.x-c.x)/m,h=(f.z-c.z)/m,d=!1;for(let x of a((c.x+f.x)/2,(c.z+f.z)/2))for(let g of e.get(x)??[]){if(g.floor!==c.floorIndex||Math.abs(g.y-c.row.y)>.75)continue;let S=(g.x-c.x)*y+(g.z-c.z)*h,A=Math.abs((g.x-c.x)*h-(g.z-c.z)*y);S>.01&&S<m-.01&&A<hn+jt&&(d=!0)}if(d)continue;let b=(x,g)=>({x:(c.x+y*x-h*g)/R,y:(c.z+h*x+y*g)/R});s.push({sections:[c.sectionId,f.sectionId],blocks:[c.row.blockId,f.row.blockId],floorIndex:c.floorIndex,ends:[c.point,f.point],clearWidthM:m-2*jt,heightM:(c.row.y+f.row.y)/2,outline:[b(jt,-hn),b(m-jt,-hn),b(m-jt,hn),b(jt,hn)]})}return s}var ja=.15,Ua=.9,Wa=1.76;function fr(t){return!!t&&t[0]*.2126+t[1]*.7152+t[2]*.0722>.55?{zenith:[.36,.58,.84],horizon:[.82,.88,.94]}:{zenith:[.05,.08,.15],horizon:[.3,.38,.5]}}function Ya(){return{background:{top:[...Wn.top],bottom:[...Wn.bottom]},sky:fr(null),structure:Un,seatStates:{...He},seatScale:1,materials:{seat:null,shell:null,roughness:.78}}}function za(t){return!!t&&t[0]*.2126+t[1]*.7152+t[2]*.0722>.55?{deck:"#c9ccc8",fascia:"#b4bab8",shell:"#c3c9c8",roughness:.87}:{deck:"#69747b",fascia:"#3e4d58",shell:"#526572",roughness:.87}}function mr(t){let n=Ya();t??={};let e=at(t.background);if(e){n.background={top:K(e,Ua),bottom:K(e,Wa)},n.sky=fr(e);let s={};for(let[u,c]of Object.entries(Un))s[u]=it(c,e,ja);e[0]*.2126+e[1]*.7152+e[2]*.0722>.55&&(s.ground=K(e,.86)),n.structure=s}let r=at(t.selectionColor)??at(t.accent);r&&(n.seatStates={...n.seatStates,selected:r});let o=t.seatScale;typeof o=="number"&&Number.isFinite(o)&&(n.seatScale=Le(o));let a=Object.fromEntries(Object.entries(t.venue3d??{}).filter(([,s])=>s!=null)),i={...za(e),...a};if(i){let s=at(i.deck),l=at(i.fascia);s&&(n.structure={...n.structure,tierTop:s,gaTop:s}),l&&(n.structure={...n.structure,tierWall:l,gaWall:l}),n.materials.seat=at(i.seat),n.materials.shell=at(i.shell),typeof i.roughness=="number"&&Number.isFinite(i.roughness)&&(n.materials.roughness=Math.min(1,Math.max(0,i.roughness)))}return n}function hr(t,n){let e=[];for(let r of n)e.push(...t.seatStates[r]);return e}var fe=.6,yr=3,Va=.25;function Ka(t,n){if(xt(n,t.x,t.y))return 0;let e=1/0;for(let r=0,o=n.length-1;r<n.length;o=r++){let a=n[o],i=n[r],s=i.x-a.x,l=i.y-a.y,u=s*s+l*l||1,c=Math.max(0,Math.min(1,((t.x-a.x)*s+(t.y-a.y)*l)/u));e=Math.min(e,Math.hypot(t.x-(a.x+c*s),t.y-(a.y+c*l)))}return e}function dr(t,n){let e=t.map(i=>({booth:i,ring:At(i)})).filter(i=>!!i.ring&&i.ring.length===4&&!i.booth.points),r=e.map(({ring:i})=>({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))})),o=(yr+fe)/R,a=new Map;return e.forEach(({booth:i,ring:s},l)=>{let u={x:s.reduce((y,h)=>y+h.x,0)/4,y:s.reduce((y,h)=>y+h.y,0)/4},c=[0,1,2,3].map(y=>{let h=s[y],d=s[(y+1)%4],b={x:(h.x+d.x)/2,y:(h.y+d.y)/2},x=b.x-u.x,g=b.y-u.y,S=Math.hypot(x,g)||1,A={x:b.x+x/S*fe/R,y:b.y+g/S*fe/R},M=yr/R;return r.forEach((p,_)=>{_===l||A.x<p.minX-o||A.x>p.maxX+o||A.y<p.minY-o||A.y>p.maxY+o||(M=Math.min(M,Ka(A,e[_].ring)))}),{open:M*R,toward:{x:b.x+x/S*10/R,y:b.y+g/S*10/R},focal:Math.hypot(b.x-n.x,b.y-n.y)}}),f=Math.max(...c.map(y=>y.open)),m=c.filter(y=>y.open>=f-Va).sort((y,h)=>y.focal-h.focal)[0];a.set(i.id,m.toward)}),a}import Za from"polygon-clipping";var qa=.45,$a=1500,Qa=200;function pr(t,n){if(t.role!=="stage"||Yt(t.stageKind))return t;let e=ut(t);if(!e||e.length<3||Math.abs(pt(e))*R*R>$a)return t;let r=n.filter(i=>xt(e,i.x,i.y));if(!r.length||r.length>Qa)return t;let o=qa/R,a=r.map(i=>[[[i.x-o,i.y-o],[i.x+o,i.y-o],[i.x+o,i.y+o],[i.x-o,i.y+o],[i.x-o,i.y-o]]]);try{let i=Za.difference([[...e.map(u=>[u.x,u.y]),[e[0].x,e[0].y]]],...a),s=null,l=0;for(let u of i){let c=u[0].slice(0,-1).map(([m,y])=>({x:m,y})),f=Math.abs(pt(c));f>l&&(l=f,s=c)}return!s||s.length<3?t:{...t,kind:"polygon",points:s,rotation:0}}catch{return t}}function me(t,n,e,r,o,a,i,s,l,u=[],c=o){if(n.length!==e.length||n.length<2||a-o<1.5)return;let f=(d,b,x)=>{Ot(t,d,b,x,u,i,s,{portalBase:c,ao:l})||Z(t,d,void 0,()=>x,b,i,s,l)},m=(d,b,x)=>({x:d.x+(b.x-d.x)*x,y:d.y+(b.y-d.y)*x}),y=r?n.length:n.length-1,h=0;for(let d=0;d<y;d++){let b=(d+1)%n.length,x=Math.hypot(e[b].x-e[d].x,e[b].y-e[d].y)*$;if(x<1e-5)continue;let g=(p,_)=>[m(n[d],n[b],p),m(n[d],n[b],_),m(e[d],e[b],_),m(e[d],e[b],p)];f(g(0,1),o,o+.95),f(g(0,1),a-.22,a);let S=Math.ceil((h-.32)/6)*6,A=!1,M=!1;for(let p=S;p<h+x;p+=6){let _=Math.max(0,(p-h)/x),P=Math.min(1,(p+.32-h)/x);P<=_||(f(g(_,P),o+.95,a-.22),A||=_<1e-6,M||=P>1-1e-6)}if(!r&&(d===0&&!A||d===y-1&&!M)){let p=Math.min(1,.32/x);f(g(d===0?0:1-p,d===0?p:1),o+.95,a-.22)}h+=x}}import Ut from"polygon-clipping";var dn=.65;function he(t,n){let e=1/0;for(let r of n)for(let o=0;o<r.length;o++){let a=r[o],i=r[(o+1)%r.length],s=i.x-a.x,l=i.y-a.y,u=Math.max(0,Math.min(1,((t.x-a.x)*s+(t.y-a.y)*l)/(s*s+l*l||1)));e=Math.min(e,Math.hypot(t.x-a.x-u*s,t.y-a.y-u*l))}return e}var ye=.01;function xr(t,n,e,r,o,a,i,s=[],l=!0,u={bays:[],walls:[]}){if(r-o<=1e-5)return;let c=r-o>=3,f=c?r-dn:o;t.setMaterial(5);let m=c?[]:s.filter(p=>{if(p.role!=="entrance"&&p.role!=="exit")return!1;let _=ut(p);if(!_)return!1;let P=Zt(_,o,o+_t(p).heightM);return P!==null&&P.openingTop<=r-.12});if((!m.length||!Ot(t,n,f,r,m,a,i,{holes:e,portalBase:o}))&&Z(t,n,e,()=>r,f,a,i,V,void 0,()=>[0,1,0]),!c){t.setMaterial(0);return}let y=l&&u.bays.length?Ja(n,e,Lt(n,yn/R),u):null,h=6/R,d=.22/R,b=s.flatMap(p=>{if(p.role!=="entrance"&&p.role!=="exit")return[];let _=ut(p);return _?.length?[{minX:Math.min(..._.map(P=>P.x)),maxX:Math.max(..._.map(P=>P.x)),minY:Math.min(..._.map(P=>P.y)),maxY:Math.max(..._.map(P=>P.y))}]:[]}),x=Math.min(...n.map(p=>p.x)),g=Math.max(...n.map(p=>p.x)),S=Math.min(...n.map(p=>p.y)),A=Math.max(...n.map(p=>p.y));for(let p=x+h/2;p<g;p+=h)for(let _=S+h/2;_<A;_+=h){if(b.some(I=>p+d>=I.minX&&p-d<=I.maxX&&_+d>=I.minY&&_-d<=I.maxY))continue;let P=[{x:p-d,y:_-d},{x:p+d,y:_-d},{x:p+d,y:_+d},{x:p-d,y:_+d}];!wt({x:p,y:_},n,e)||he({x:p,y:_},[n,...e??[]])<d*Math.SQRT2+(l?yn/R:0)||y&&he({x:p,y:_},y.flat())<d*Math.SQRT2+yn/R||Z(t,P,void 0,()=>f,o,a,i,V)}if(y){for(let[p,..._]of y)Z(t,p,_,()=>f,o-ye,a,i,V);t.setMaterial(0);return}let M=Lt(n,yn/R);if(l&&M.length>=3){let p=s.filter(I=>{if(I.role!=="entrance"&&I.role!=="exit")return!1;let E=ut(I);return!!E&&E.some(T=>!wt(T,n,void 0)||he(T,[n])<=yn/R)}),_=[M.slice().reverse()],P=o-ye;(!p.length||!Ot(t,n,P,f,p,a,i,{holes:_,portalBase:o+ye}))&&Z(t,n,_,()=>f,P,a,i,V)}t.setMaterial(0)}var de=.25,yn=de;function Ja(t,n,e,r){if(e.length<3)return null;let o=i=>{let s=i.map(l=>[l.x,l.y]);return s.push(s[0]),s},a=i=>{let[s,...l]=i.map(u=>[o(u)]);return Ut.union(s,...l)};try{let i=[o(t),...(n??[]).map(o)],s=Ut.difference(i,[o(e)]),l=Ut.intersection(i,a(r.bays));if(!l.length)return null;let u=Ut.difference(Ut.intersection(i,a(r.walls)),l);return Ut.union(Ut.difference(s,l),u).map(f=>f.map(m=>m.slice(0,-1).map(([y,h])=>({x:y,y:h}))))}catch{return null}}var tc=.02,nc=.25,ec=1.2,oc=.6,rc=.45,ic=2.3,sc=Math.PI/180,br=.005;function Bt(t,n,e){let r=e*sc;return{x:t.x+n*Math.sin(r),y:t.y+n*Math.cos(r)}}function ac(t,n){let e=n.rings[n.rings.length-1];if(!e)return!1;let r=e.outerRMedian*.85;for(let o of t){if(o.role!=="wall")continue;let a=o.points&&o.points.length>=2?o.points:o.x!==void 0&&o.y!==void 0&&o.width!==void 0&&o.height!==void 0?[{x:o.x,y:o.y},{x:o.x+o.width,y:o.y},{x:o.x+o.width,y:o.y+o.height},{x:o.x,y:o.y+o.height}]:[];if(a.length<2)continue;let i=0;for(let s of a)Math.hypot(s.x-n.centre.x,s.y-n.centre.y)>=r&&i++;if(i>=a.length/2)return!0}return!1}var cc=24,lc=.01;function uc(t,n,e,r,o,a,i,s,l){let u=e.binCount,c=cc,f=$,m=a+.02,y=a-lc,h=[];for(let w=0;w<u;w++){let B=(e.startBin+w+.5)*n.binStepDeg,C=new Float64Array(c+1);for(let v=0;v<=c;v++){let O=r[w]+(o[w]-r[w])*v/c;C[v]=Math.max(m,Ne(n,e,B,O)-nc)}h.push(C)}if(l){let w=0;for(let B=0;B+1<u;B++)for(let C=0;C<c;C++){let v=Bt(n.centre,r[B]+(o[B]-r[B])*C/c,(e.startBin+B+.5)*n.binStepDeg),O=Bt(n.centre,r[B+1]+(o[B+1]-r[B+1])*(C+1)/c,(e.startBin+B+1.5)*n.binStepDeg);w=Math.max(w,Math.hypot(O.x-v.x,O.y-v.y))}for(let B=0;B<u;B++){let C=(e.startBin+B+.5)*n.binStepDeg;for(let v=0;v<=c;v++){let O=Bt(n.centre,r[B]+(o[B]-r[B])*v/c,C),N=l(O.x,O.y,w*1.01);N!==null&&(h[B][v]=Math.min(h[B][v],Math.max(y+br,N-br)))}}}let d=[i.bandTop[0]*s.top,i.bandTop[1]*s.top,i.bandTop[2]*s.top],b=[i.bandTop[0]*s.bottomCap,i.bandTop[1]*s.bottomCap,i.bandTop[2]*s.bottomCap],x=[i.bandWall[0]*s.top,i.bandWall[1]*s.top,i.bandWall[2]*s.top],g=[i.bandWall[0]*s.wallBottom,i.bandWall[1]*s.wallBottom,i.bandWall[2]*s.wallBottom],S=(w,B)=>{let C=(e.startBin+w+.5)*n.binStepDeg,v=r[w]+(o[w]-r[w])*B/c,O=Bt(n.centre,v,C);return[O.x*f,h[w][B],O.y*f]};{let w=Math.tan(12*Math.PI/180);for(let B=0;B<6;B++){let C=!1;for(let O=0;O<u;O++)for(let N=c-1;N>=0;N--)h[O][N]>h[O][N+1]&&(h[O][N]=h[O][N+1],C=!0);let v=e.closed?u:u-1;for(let O=0;O<v;O++){let N=(O+1)%u;for(let H=0;H<=c;H++){let j=h[N][H]-h[O][H];if(Math.abs(j)>1)continue;let G=r[O]+(o[O]-r[O])*H/c,U=r[N]+(o[N]-r[N])*H/c,X=Bt(n.centre,G,(e.startBin+O+.5)*n.binStepDeg),W=Bt(n.centre,U,(e.startBin+N+.5)*n.binStepDeg),nt=w*Math.hypot(W.x-X.x,W.y-X.y)*f;j>nt?(h[N][H]=h[O][H]+nt,C=!0):-j>nt&&(h[O][H]=h[N][H]+nt,C=!0)}}if(!C)break}}let A=1,M=(w,B)=>{for(let C=0;C<=c;C+=4)if(Math.abs(h[w][C]-h[B][C])>A)return!0;return Math.abs(h[w][c]-h[B][c])>A},p=Math.tan(38*Math.PI/180),_=w=>(o[w]-r[w])/c*f,P=(w,B)=>h[w][B+1]-h[w][B]>p*Math.max(1e-6,_(w)),I=(w,B)=>{let C=e.closed?(w-1+u)%u:Math.max(0,w-1),v=e.closed?(w+1)%u:Math.min(u-1,w+1);Math.abs(h[C][B]-h[w][B])>A&&(C=w),Math.abs(h[v][B]-h[w][B])>A&&(v=w);let O=Math.max(0,B-1),N=Math.min(c,B+1);O<B&&P(w,O)&&(O=B),N>B&&P(w,B)&&(N=B);let H=S(C,B),j=S(v,B),G=S(w,O),U=S(w,N),X=j[0]-H[0],W=j[1]-H[1],nt=j[2]-H[2],rt=U[0]-G[0],q=U[1]-G[1],Q=U[2]-G[2],J=W*Q-nt*q,L=nt*rt-X*Q,D=X*q-W*rt,Y=Math.hypot(J,L,D);return Y>1e-12?(J/=Y,L/=Y,D/=Y,L<0&&(J=-J,L=-L,D=-D),[J,L,D]):[0,1,0]},E=(w,B,C=!1)=>{let v=C&&Math.min(w[1],B[1])-a>=3,O=[w[0],v?w[1]-dn:y,w[2]],N=[B[0],v?B[1]-dn:y,B[2]],H=B[0]-w[0],j=B[2]-w[2],G=Math.hypot(H,j);if(!(G>1e-12))return;let U=[j/G,0,-H/G];t.tri(w,B,N,U,x,x,g),t.tri(w,N,O,U,x,g,g)},T=.05*Pt,F=w=>o[w]-r[w]<T,k=e.closed?u:u-1;for(let w=0;w<k;w++){let B=(w+1)%u;if(F(w)||F(B))continue;if(M(w,B)){let j=(e.startBin+w+1)*n.binStepDeg,G=(q,Q)=>{let J=(r[w]+r[B])/2,L=(o[w]+o[B])/2,D=J+(L-J)*Q/c,Y=Bt(n.centre,D,j);return[Y.x*f,h[q][Q],Y.y*f]};for(let q=0;q<c;q++){let Q=S(w,q),J=S(w,q+1),L=G(w,q),D=G(w,q+1),Y=I(w,q),ct=I(w,q+1);t.triN(Q,L,D,Y,Y,ct,d),t.triN(Q,D,J,Y,ct,ct,d);let ft=S(B,q),st=S(B,q+1),tt=G(B,q),et=G(B,q+1),ht=I(B,q),z=I(B,q+1);t.triN(tt,ft,st,ht,ht,z,d),t.triN(tt,st,et,ht,z,z,d);let mt=G(w,q),yt=G(w,q+1),Nt=G(B,q+1),Gt=G(B,q),kt=yt[0]-mt[0],Ft=yt[2]-mt[2],tn=Math.hypot(kt,Ft);if(tn>1e-12){let pn=[Ft/tn,0,-kt/tn];t.tri(mt,yt,Nt,pn,x),t.tri(mt,Nt,Gt,pn,x)}}let U=S(w,0),X=S(B,0),W=S(B,c),nt=S(w,c),rt=q=>[q[0],y,q[2]];Math.min(U[1],X[1])-a<3&&(t.tri(rt(U),rt(W),rt(X),[0,-1,0],b),t.tri(rt(U),rt(nt),rt(W),[0,-1,0],b)),E(U,X,!0),E(nt,W,!0);continue}for(let j=0;j<c;j++){let G=I(w,j),U=I(B,j),X=I(B,j+1),W=I(w,j+1);if(P(w,j)||P(B,j)){let J=(yt,Nt)=>{let Gt=(e.startBin+yt+.5)*n.binStepDeg,kt=r[yt]+(o[yt]-r[yt])*(j+.5)/c,Ft=Bt(n.centre,kt,Gt);return[Ft.x*f,Nt,Ft.y*f]},L=S(w,j),D=S(B,j),Y=J(w,h[w][j]),ct=J(B,h[B][j]);t.triN(L,D,ct,G,U,U,d),t.triN(L,ct,Y,G,U,G,d);let ft=S(B,j+1),st=S(w,j+1),tt=J(w,h[w][j+1]),et=J(B,h[B][j+1]);t.triN(tt,et,ft,W,X,X,d),t.triN(tt,ft,st,W,X,W,d);let ht=ct[0]-Y[0],z=ct[2]-Y[2],mt=Math.hypot(ht,z);if(mt>1e-12){let yt=[-z/mt,0,ht/mt];t.tri(Y,ct,et,yt,x),t.tri(Y,et,tt,yt,x)}continue}let nt=S(w,j),rt=S(B,j),q=S(B,j+1),Q=S(w,j+1);t.triN(nt,rt,q,G,U,X,d),t.triN(nt,q,Q,G,X,W,d)}let C=S(w,0),v=S(B,0),O=S(B,c),N=S(w,c),H=j=>[j[0],y,j[2]];Math.min(C[1],v[1])-a<3&&(t.tri(H(C),H(O),H(v),[0,-1,0],b),t.tri(H(C),H(N),H(O),[0,-1,0],b)),E(C,v,!0),E(N,O,!0)}if(!e.closed)for(let w of[0,u-1])for(let B=0;B<c;B++)E(S(w,B),S(w,B+1))}function gr(t,n,e){let{bottomY:r,colors:o,ao:a}=e,i=new Float64Array(n.binCount).fill(-1/0);for(let c of n.rings)for(let f of c.arcs){let m=new Float64Array(f.binCount),y=new Float64Array(f.binCount);for(let d=0;d<f.binCount;d++){let b=(f.startBin+d)%n.binCount,x=Math.max(0,f.innerR[d]-St);m[d]=Math.max(x,i[b]+.001),y[d]=Math.max(m[d]+.001,f.outerR[d]+St)}let h=0;for(let d=0;d<f.binCount;d++){let b=f.topLevelM[d]-r;b>h&&(h=b)}h>=ec&&uc(t,n,f,m,y,r,o,a,e.standTopNear);for(let d=0;d<f.binCount;d++){let b=(f.startBin+d)%n.binCount;y[d]>i[b]&&(i[b]=y[d])}}if(e.deriveShell===!1||ac(e.shapes,n))return;let s=n.rings[n.rings.length-1],l=oc*Pt,u=rc*Pt;for(let c of s.arcs){let f=[],m=[];for(let I=0;I<c.binCount;I++){let E=(c.startBin+I+.5)*n.binStepDeg,T=c.outerR[I]+St+l;f.push(Bt(n.centre,T,E)),m.push(Bt(n.centre,T+u,E))}let y=-1/0;for(let I=0;I<c.binCount;I++)c.topLevelM[I]>y&&(y=c.topLevelM[I]);let h=y+ic,d=c.closed?m:[...m,...f.slice().reverse()],b=c.closed?[f.slice().reverse()]:void 0,x=it(o.shellWall,[.66,.71,.72],.62),g=(I,E,T,F,k)=>{let w=Math.abs(F-y)<1e-6?F-tc:F;Ot(t,I,T,w,e.shapes,o.shellTop,k,{holes:E,portalBase:r,ao:a})||Z(t,I,E,()=>w,T,o.shellTop,k,a)},S=Math.max(1,Math.ceil((y-r)/4.5)),A=(y-r)/S,M=new Set,p=e.tierFrontLevels??n.rings.map(I=>{let E=I.arcs.flatMap(T=>Array.from(T.frontLevelM)).filter(Number.isFinite).sort((T,F)=>T-F);return E[Math.floor(E.length/2)]});for(let I of p)Number.isFinite(I)&&I-r>=3&&I<y&&M.add(Math.max(0,Math.min(S-1,Math.floor((I-r)/A))));let _=Math.min(...p.filter(I=>Number.isFinite(I)&&I-r>=3&&I<y));for(let I=0;I<S;I++)r+(I+1)*A<=_-dn&&Number.isFinite(_)&&M.add(I);for(let I=0;I<S;I++){let E=r+(y-r)*I/S,T=r+(y-r)*(I+1)/S;M.has(I)&&T-E>=3.2?(g(d,b,E,E+.45,x),me(t,f,m,c.closed,E+.45,T-.16,o.shellTop,x,a,e.shapes,r)):g(d,b,E,T-.16,x),g(d,b,T-.16,T,K(x,.62))}me(t,f,m,c.closed,y,h,o.shellTop,x,a,e.shapes,r);let P=8;for(let I=1;I<m.length;I++){if(P+=Math.hypot(m[I].x-m[I-1].x,m[I].y-m[I-1].y)*$,P<8)continue;P=0;let E=m[I],T=m[I-1],F=E.x-T.x,k=E.y-T.y,w=Math.max(1,Math.hypot(F,k)),B=F/w*.16*Pt,C=k/w*.16*Pt,v=Math.max(1,Math.hypot(E.x-n.centre.x,E.y-n.centre.y)),O=(E.x-n.centre.x)/v*.24*Pt,N=(E.y-n.centre.y)/v*.24*Pt,H=[{x:E.x-B,y:E.y-C},{x:E.x+B,y:E.y+C},{x:E.x+B+O,y:E.y+C+N},{x:E.x-B+O,y:E.y-C+N}];g(H,void 0,r,y,K(x,1.12))}}}var fc=2.5,Mr=.65,mc=2,hc=.03;function yc(t,n){let e=()=>{let r=n;for(;t.length>2;){let o=t[0],a=t[1],i=Math.hypot(a.x-o.x,a.y-o.y);if(i>r){t[0]={x:o.x+(a.x-o.x)/i*r,y:o.y+(a.y-o.y)/i*r};return}r-=i,t.shift()}};e(),t.reverse(),e(),t.reverse()}function be(t,n,e){let r=new Map;for(let a of t){let i=r.get(a.blockId);(!i||a.depth<i.depth)&&r.set(a.blockId,a)}let o=[];for(let[a,i]of r){if(i.y-e<fc||i.pts.length<2)continue;let s=i.pts.map(c=>{let f=c.x-n.x,m=c.y-n.y,y=Math.max(1,Math.hypot(f,m));return{x:c.x-f/y*Mr/R,y:c.y-m/y*Mr/R}}),l=[],u=[s[0]];for(let c=1;c<s.length;c++){let f=s[c-1],m=s[c];Math.hypot(m.x-f.x,m.y-f.y)*R>mc?(u.length>=2&&l.push(u),u=[m]):u.push(m)}u.length>=2&&l.push(u);for(let c of l)yc(c,hc/R);l.length&&o.push({blockId:a,y:i.y,runs:l})}return o}var Pr=.1,dc=1.1,pc=.22,pe=.95,xe=.05,Sr=1.8;function Rr(t,n,e,r){let o=[.72,.72,.69],a=[.48,.55,.57];for(let i of be(n,e,r)){let s=i.y;for(let l of i.runs){let u=Sr;for(let c=1;c<l.length;c++){let f=l[c-1],m=l[c],y=m.x-f.x,h=m.y-f.y,d=Math.hypot(y,h);if(d<1e-5)continue;let b=x=>{let g=-h/d*x/R/2,S=y/d*x/R/2;return[{x:f.x+g,y:f.y+S},{x:m.x+g,y:m.y+S},{x:m.x-g,y:m.y-S},{x:f.x-g,y:f.y-S}]};if(Z(t,b(pc),void 0,()=>s+Pr,s-dc,o,o,V),Z(t,b(xe),void 0,()=>s+pe,s+pe-xe,a,a,V),u+=d*R,u>=Sr||c===l.length-1){u=0;let x=.028/R,g=[{x:f.x-x,y:f.y-x},{x:f.x+x,y:f.y-x},{x:f.x+x,y:f.y+x},{x:f.x-x,y:f.y+x}];Z(t,g,void 0,()=>s+pe-xe,s+Pr,a,a,V)}}}}}var xc=.9,bc=1.5,gc=.3;function Ir(t,n,e){let r=[],o=[],a=xc/R,i=bc/R,s=gc/R;for(let l of t)for(let u of l.runs){if(u.length<2)continue;let c=u.slice(),f=(b,x)=>{let g=c[b],S=c[x],A=Math.hypot(g.x-S.x,g.y-S.y)||1;c[b]={x:g.x+(g.x-S.x)/A*s,y:g.y+(g.y-S.y)/A*s}};f(0,1),f(c.length-1,c.length-2);let m=c.map((b,x)=>{let g=c[Math.max(0,x-1)],S=c[Math.min(c.length-1,x+1)],A=S.x-g.x,M=S.y-g.y,p=Math.hypot(A,M)||1,_=-M/p,P=A/p;return _*(b.x-n.x)+P*(b.y-n.y)<0&&(_=-_,P=-P),{nx:_,ny:P}}),y=c.map((b,x)=>({x:b.x-m[x].nx*i,y:b.y-m[x].ny*i})),h=c.map((b,x)=>({x:b.x+m[x].nx*a,y:b.y+m[x].ny*a})),d=c.map((b,x)=>({x:b.x+m[x].nx*(a+e/R),y:b.y+m[x].ny*(a+e/R)}));r.push([...y,...h.slice().reverse()]),o.push([...h,...d.reverse()])}return{bays:r,walls:o}}var ge=.88,Gn=.27,Mc=1.2,Pc=.01;function _r(t,n,e,r,o){let a=[.67,.71,.68],i=[a[0]*ge,a[1]*ge,a[2]*ge],s=l=>!!o&&o.some((u,c)=>c!==l&&u?.belowY!=null&&Math.abs(u.belowY-n[l].y)<1e-6&&n[c].blockId===n[l].blockId);for(let l=0;l<n.length;l++){let u=n[l];if(!(u.pts.length<2))for(let c of[0,u.pts.length-1]){let f=u.pts[c],m=u.pts[c===0?1:c-1],y=f.x-m.x,h=f.y-m.y,d=Math.hypot(y,h);if(d<1e-5)continue;y/=d,h/=d;let b=1/0;for(let B=0;B<e.length;B++){let C=e[B],v=e[(B+1)%e.length],O=v.x-C.x,N=v.y-C.y,H=y*N-h*O;if(Math.abs(H)<1e-8)continue;let j=C.x-f.x,G=C.y-f.y,U=(j*N-G*O)/H,X=(j*h-G*y)/H;U>0&&X>=0&&X<=1&&(b=Math.min(b,U))}let x=.3/R,g=b-.04/R;if(!Number.isFinite(b)||b*R>2||g-x<.12/R)continue;let S=!!r&&s(l),A=o?.[l]?.pitch,M=S&&A&&Number.isFinite(A)?Math.min(Mc/R,Math.max(Gn/R,A-Gn/R-Pc/R)):Gn/R,p=-h,_=y;r&&p*(r.x-f.x)+_*(r.y-f.y)<0&&(p=-p,_=-_);let P=Gn/R,I=[{x:f.x+y*x+p*P,y:f.y+h*x+_*P},{x:f.x+y*g+p*P,y:f.y+h*g+_*P},{x:f.x+y*g-p*M,y:f.y+h*g-_*M},{x:f.x+y*x-p*M,y:f.y+h*x-_*M}];if(!I.every(B=>xt(e,B.x,B.y)))continue;let E=o?.[l]?.belowY,T=E==null?0:u.y-E,F=!!r&&T>.03&&T<=.65;if(F&&r){let B=(C,v)=>Math.hypot((C.x+v.x)/2-r.x,(C.y+v.y)/2-r.y);B(I[0],I[1])>B(I[3],I[2])&&(I=[I[3],I[2],I[1],I[0]])}let k=F?Math.ceil((T-1e-8)/.2):1,w=(B,C,v)=>({x:B.x+(C.x-B.x)*v,y:B.y+(C.y-B.y)*v});for(let B=0;B<k;B++){let C=B/k,v=(B+1)/k,O=[w(I[0],I[3],C),w(I[1],I[2],C),w(I[1],I[2],v),w(I[0],I[3],v)],N=u.y+.008-(F?T*(1-v):0);Z(t,O,void 0,()=>N,N-(F?T/k+.1:.16),a,i,V)}}}}function Ar(t,n,e,r,o,a,i,s,l=!1){if(!n.outline||n.outline.length<3)return;let u=e.baseHeightM,c=e.objects.filter(g=>g.type==="shape"&&(g.role==="entrance"||g.role==="exit")),f=Ze(r,s.tierTop);if(!o)return;let m=g=>o.deckAt(g.x,g.y),y=mo(n,i),h=y[0]??n.outline;if(o.rowLevels.length>=2){let g=wn(o.rowLevels),S=ho(so(o.rowLevels,e.focal,g),y),A=Ir(be(o.rowLevels,e.focal,u),e.focal,de);for(let p of S){let _=Math.max(u,p.topY-wr);for(let P of a.subtract(p.outline,_))xr(t,P,p.holes,_,u,s.tierTop,s.tierWall,c,!l,A)}S.length||Z(t,h,n.holes,()=>o.landingY,u,f,s.tierWall,V);let M={tread:[f[0]*V.top,f[1]*V.top,f[2]*V.top],riser:[f[0]*.72,f[1]*.72,f[2]*.72]};for(let p of y.length?y:[h])co(t,o.rowLevels,e.focal,o.landingY,M,p,g);Rr(t,o.rowLevels,e.focal,u),_r(t,o.rowLevels,n.outline,e.focal,g);return}let d=o.flat?1/0:Lo,b=g=>o.normalAt(g.x,g.y),x=o.flat?o.landingY:void 0;for(let g of a.subtract(h,x))Z(t,g,n.holes,m,u,f,s.tierWall,V,d,b)}function Sc(t,n,e){let r=new Set;for(let i of t.objects)i.type==="section"&&r.add(i.id);let o=new Map;for(let i=0;i<n.length;i++){let s=e.seatOwner[i];if(!s||!r.has(s))continue;let l=e.bySection.get(s);if(l&&l.rowLevels.length>=2)continue;let u=n[i];if(u.kind==="booth")continue;let c=o.get(s);c||(c=new Map,o.set(s,c));let f=u.rowId||`__seat-${i}`,m=c.get(f);m||(m={pts:[],levelM:0,n:0},c.set(f,m)),m.pts.push({x:u.x,y:u.y}),m.levelM+=e.seatDeckY(i),m.n++}let a=[];for(let i of t.objects){if(i.type!=="section")continue;let s=e.bySection.get(i.id);if(s&&s.rowLevels.length>=2){let u=s.rowLevels.filter(c=>!c.patch).map(c=>({pts:c.pts,levelM:c.y}));u.length>=2&&a.push({sectionId:i.id,rows:u});continue}let l=o.get(i.id);l&&a.push({sectionId:i.id,rows:[...l.values()].map(u=>({pts:u.pts,levelM:u.levelM/u.n}))})}return a}function Rc(t,n){let e=1/0;for(let r=0;r<n.length;r++){let o=n[r],a=n[(r+1)%n.length],i=a.x-o.x,s=a.y-o.y,l=Math.max(0,Math.min(1,((t.x-o.x)*i+(t.y-o.y)*s)/(i*i+s*s||1)));e=Math.min(e,Math.hypot(t.x-o.x-l*i,t.y-o.y-l*s))}return e}var wr=.02;function Ic(t,n){let e=t.objects.filter(r=>r.type==="section"&&!!r.outline&&r.outline.length>=3).flatMap(r=>{let o=n.bySection.get(r.id);if(!o)return[];let a=1/0,i=-1/0,s=1/0,l=-1/0;for(let c of r.outline)c.x<a&&(a=c.x),c.x>i&&(i=c.x),c.y<s&&(s=c.y),c.y>l&&(l=c.y);let u=o.landingY;for(let c of o.rowLevels)u=Math.min(u,c.y-wr);return[{outline:r.outline,holes:r.holes,surface:o,floorTop:u,minX:a,maxX:i,minY:s,maxY:l}]});return(r,o,a)=>{let i=null;for(let s of e){if(r<s.minX-a||r>s.maxX+a||o<s.minY-a||o>s.maxY+a)continue;let l={x:r,y:o};if(!wt(l,s.outline,s.holes)&&Rc(l,s.outline)>a)continue;let u=Math.min(s.surface.deckAt(r,o),s.floorTop);(i===null||u<i)&&(i=u)}return i}}var _c=3,Ac=.4;function Er(t,n,e,r,o,a,i=!0){let s=Sc(n,e,r);if(s.length<_c)return;let l=De(s,n.focal);if(!l)return;let u=Math.max(0,...l.rings.map(c=>c.arcs.reduce((f,m)=>f+m.binCount,0)))/l.binCount;t.setMaterial(5),gr(t,l,{bottomY:n.baseHeightM,tierFrontLevels:s.map(c=>Math.min(...c.rows.map(f=>f.levelM))),colors:{bandTop:K(o.tierTop,.8),bandWall:o.tierWall,shellTop:a??K(o.tierWall,1.15),shellWall:a??o.tierWall},ao:V,shapes:n.objects.filter(c=>c.type==="shape"),deriveShell:i&&u>=Ac,standTopNear:Ic(n,r)}),t.setMaterial(0)}function Br(t){let{doc:n,units:e,seats:r,surfaces:o,solids:a,hintedSeatFloor:i,seatFloor:s}=t,l=[];{let u=e.map(()=>({minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}));for(let m=0;m<a.floor.length;m+=1){let y=Math.max(0,Math.min(e.length-1,Math.round(a.floor[m]))),h=m*3,d=u[y];d.minX=Math.min(d.minX,a.position[h]),d.minY=Math.min(d.minY,a.position[h+1]),d.minZ=Math.min(d.minZ,a.position[h+2]),d.maxX=Math.max(d.maxX,a.position[h]),d.maxY=Math.max(d.maxY,a.position[h+1]),d.maxZ=Math.max(d.maxZ,a.position[h+2])}let c=new Map;for(let m=0;m<e.length;m++)for(let y of e[m].objects)y.type==="section"&&c.set(y.id,m);let f=e.map(()=>({n:0,minX:1/0,minY:1/0,minDeck:1/0,maxX:-1/0,maxY:-1/0,maxDeck:-1/0,sumX:0,sumDeck:0,sumZ:0}));for(let m=0;m<r.length;m++){let y=o.seatOwner[m],h=(y!==null?c.get(y):void 0)??i[m];if(h===void 0)continue;let d=f[h],b=r[m];d.n++,b.x<d.minX&&(d.minX=b.x),b.y<d.minY&&(d.minY=b.y),b.x>d.maxX&&(d.maxX=b.x),b.y>d.maxY&&(d.maxY=b.y);let x=o.seatDeckY(m);d.sumX+=b.x*R,d.sumDeck+=x,d.sumZ+=b.y*R,d.minDeck=Math.min(d.minDeck,x),d.maxDeck=Math.max(d.maxDeck,x+1.6),s[m]=h}for(let m=0;m<e.length;m++){let y=f[m],h=n.floors?.[m],d=u[m],b=Math.min(y.n?y.minX*R:e[m].focal.x*R-1,Number.isFinite(d.minX)?d.minX:1/0),x=Math.max(y.n?y.maxX*R:e[m].focal.x*R+1,Number.isFinite(d.maxX)?d.maxX:-1/0),g=Math.min(y.n?y.minY*R:e[m].focal.y*R-1,Number.isFinite(d.minZ)?d.minZ:1/0),S=Math.max(y.n?y.maxY*R:e[m].focal.y*R+1,Number.isFinite(d.maxZ)?d.maxZ:-1/0),A=Math.min(y.n?Math.min(e[m].baseHeightM,y.minDeck):e[m].baseHeightM,Number.isFinite(d.minY)?d.minY:1/0),M=Math.max(y.n?Math.max(y.maxDeck,A+.5):A+.5,Number.isFinite(d.maxY)?d.maxY:-1/0),p=[y.n?y.sumX/y.n:(b+x)/2,y.n?y.sumDeck/y.n:(A+M)/2,y.n?y.sumZ/y.n:(g+S)/2],_=Math.max(1,.5*Math.hypot(x-b,M-A,S-g));l.push({index:m,id:h?.id??`floor-${m}`,label:h?.name??(e.length>1?`Floor ${m+1}`:"Venue"),seatCount:y.n,center:p,radius:_,box:{min:[b,A,g],max:[x,M,S]},focalWorld:[e[m].focal.x*R,e[m].baseHeightM+1.5,e[m].focal.y*R]})}}return l}function Me(t,n){let e=1/0,r=1/0,o=-1/0,a=-1/0,i=(s,l)=>{s<e&&(e=s),l<r&&(r=l),s>o&&(o=s),l>a&&(a=l)};for(let s of n)i(s.x,s.y);for(let s of t)for(let l of s.objects)if(l.type==="section")for(let u of l.outline)i(u.x,u.y);else if(l.type==="shape"&&l.points)for(let u of l.points)i(u.x,u.y);else if(l.type==="gaArea")for(let u of l.points)i(u.x,u.y);else if(l.type==="booth"){let u=At(l);if(u)for(let c of u)i(c.x,c.y)}else if(l.type==="table"){let u=Dn(l);if(u)for(let c of u)i(c.x,c.y)}else if(l.type==="decorImage"){let u=Nn(l);if(u)for(let c of u)i(c.x,c.y)}return Number.isFinite(e)||(e=-100,r=-100,o=100,a=100),{minX:e,minY:r,maxX:o,maxY:a}}function Lr(t,n,e,r,o,a,i){if(n.length===1){let s=e.map(m=>({x:m.x,y:m.y}));for(let m of n[0].objects)m.type==="section"?s.push(...m.outline):m.type==="shape"?s.push(...ut(m)??m.points??[]):m.type==="gaArea"?s.push(...m.points):m.type==="booth"?s.push(...At(m)??[]):m.type==="table"?s.push(...Dn(m)??[]):m.type==="decorImage"&&s.push(...Nn(m)??[]);if(Cr(t,n[0],e,a)||Fr(t,n[0],e,s,a))return!1;if(i&&Or(t,n[0].baseHeightM,s,a,i))return!0;let l=cn(s),u=(o.minX+o.maxX)/2,c=(o.minY+o.maxY)/2,f=l.length>=3?l.map(m=>{let y=m.x-u,h=m.y-c,d=Math.max(1,Math.hypot(y,h));return{x:m.x+y/d*80,y:m.y+h/d*80}}):sn(o.minX-28,o.minY-28,o.maxX-o.minX+56,o.maxY-o.minY+56);return Z(t,f,void 0,()=>-.04,-.22,a.ground,a.ground,V),!1}else{let s=n.reduce((b,x)=>x.baseHeightM<b.baseHeightM?x:b);t.setFloor(s.index);let l={...s,objects:n.flatMap(b=>b.objects)},u=e.map(b=>({x:b.x,y:b.y}));for(let b of l.objects)b.type==="section"&&u.push(...b.outline);if(Cr(t,l,e,a)||Fr(t,l,e,u,a))return!1;if(i&&Or(t,s.baseHeightM,u,a,i))return!0;let c=e.filter((b,x)=>r[x]===s.index),f=Me([s],c),m=Math.hypot(f.maxX-f.minX,f.maxY-f.minY),y=Math.max(28,Math.min(80,m*.04)),h=sn(f.minX-y,f.minY-y,f.maxX-f.minX+y*2,f.maxY-f.minY+y*2),d=s.baseHeightM-.03;return Z(t,h,void 0,()=>d,d-.22,a.ground,a.ground,V),!1}}function Pe(t,n,e,r){let{cx:o,cz:a,radius:i}=e,s=1/0,l=1/0,u=1/0,c=-1/0,f=-1/0,m=-1/0,y=(b,x,g)=>{s=Math.min(s,b),c=Math.max(c,b),l=Math.min(l,x),f=Math.max(f,x),u=Math.min(u,g),m=Math.max(m,g)};for(let b=0;b<t.position.length;b+=3){let x=b/3;r&&x>=r[0]&&x<r[1]||y(t.position[b],t.position[b+1],t.position[b+2])}for(let b=0;b<n.count;b++){let x=b*3,g=n.iPosition[x],S=n.iPosition[x+1],A=n.iPosition[x+2],M=Math.max(.35,n.iMaxRadius[b]??.35);y(g-M,S,A-M),y(g+M,S+1.6,A+M)}Number.isFinite(s)||(s=o-i,c=o+i,l=0,f=i*.16,u=a-i,m=a+i);let h=[(s+c)/2,(l+f)/2,(u+m)/2],d=Math.max(1,.5*Math.hypot(c-s,f-l,m-u));return{center:h,radius:d,minY:l,maxY:f}}var wc=4096;function vr(t,n,e=[]){let r=Math.max(1,Math.ceil(t.count/wc)),o=Math.ceil(t.count/r),a=new Float32Array((o*2+n.length*4+e.length)*3),i=0;for(let s=0;s<t.count;s+=r){let l=t.iPosition[s*3],u=t.iPosition[s*3+1],c=t.iPosition[s*3+2];a[i++]=l,a[i++]=u,a[i++]=c,a[i++]=l,a[i++]=0,a[i++]=c}for(let[s,l,u]of e)a[i++]=s,a[i++]=l,a[i++]=u;for(let s of n)for(let[l,u]of[[-1,-1],[1,-1],[1,1],[-1,1]])a[i++]=s.cx+l*s.halfX,a[i++]=s.y,a[i++]=s.cz+u*s.halfZ;return a.subarray(0,i)}function Dr(t,n,e,r,o,a,i=[]){let s=1/0,l=1/0,u=-1/0,c=-1/0;for(let M=0;M<t.count;M++){let p=M*3,_=t.iPosition[p],P=t.iPosition[p+2];_<s&&(s=_),_>u&&(u=_),P<l&&(l=P),P>c&&(c=P)}for(let[M,,p]of i)M<s&&(s=M),M>u&&(u=M),p<l&&(l=p),p>c&&(c=p);for(let M of n)s=Math.min(s,M.cx-M.halfX),u=Math.max(u,M.cx+M.halfX),l=Math.min(l,M.cz-M.halfZ),c=Math.max(c,M.cz+M.halfZ);let f=e.minX*R,m=e.maxX*R,y=e.minY*R,h=e.maxY*R,d=f,b=m,x=y,g=h;if(Number.isFinite(s)){let M=Math.max(2,.06*Math.hypot(u-s,c-l));d=Math.max(f,s-M),b=Math.min(m,u+M),x=Math.max(y,l-M),g=Math.min(h,c+M)}let S=Math.min(0,r),A=Math.max(o,a*.05);return{min:[d,S,x],max:[b,A,g]}}var Tr=12,Ec=.6,Bc=40;function Or(t,n,e,r,o){let a=cn([...e]);if(a.length<3)return!1;let i=1/0,s=1/0,l=-1/0,u=-1/0;for(let A of a)i=Math.min(i,A.x),l=Math.max(l,A.x),s=Math.min(s,A.y),u=Math.max(u,A.y);let c=Math.hypot(l-i,u-s)*R,f=It(a,Tr/R,1.2),m=Math.max(Bc,c*Ec),y=It(a,(Tr+m)/R,1.2);if(f.length!==y.length)return!1;let h=it(r.ground,[.78,.76,.72],.35),d=it(r.ground,[.56,.62,.52],.3);Z(t,f,void 0,()=>n-.04,n-.22,h,h,V);let b=n-.05,x=f.map(A=>[A.x*R,b,A.y*R]),g=y.map(A=>[A.x*R,b,A.y*R]),S=[0,1,0];for(let A=0;A<x.length;A++){let M=(A+1)%x.length;t.tri(x[A],g[M],g[A],S,d,o,o),t.tri(x[A],x[M],g[M],S,d,d,o)}return!0}function Cr(t,n,e,r){let o=Kt(n,e);if(!o)return!1;let a=n.baseHeightM,i=it(r.ground,[.62,.55,.47],.4);return Z(t,o,void 0,()=>a-.04,a-.22,i,i,V),!0}var Tc=3e3,Oc=20,kr=1.5,Cc=1.2,kc=.25;function Fr(t,n,e,r,o){if(!e.length||e.length>Tc||r.length<3)return!1;for(let I of n.objects){if(I.type==="shape"&&Mn(I.stageKind))return!1;if(I.type==="section"){let{height:E}=Wt(I,{floorBaseHeightM:n.baseHeightM});if(E-n.baseHeightM>Oc)return!1}}let a=0,i=0;for(let I of r)a+=I.x,i+=I.y;a/=r.length,i/=r.length;let s=0,l=0,u=0;for(let I of r){let E=I.x-a,T=I.y-i;s+=E*E,l+=T*T,u+=E*T}let c=.5*Math.atan2(2*u,s-l),f=Math.cos(c),m=Math.sin(c),y=-m,h=f,d=1/0,b=-1/0,x=1/0,g=-1/0;for(let I of r){let E=(I.x-a)*f+(I.y-i)*m,T=(I.x-a)*y+(I.y-i)*h;d=Math.min(d,E),b=Math.max(b,E),x=Math.min(x,T),g=Math.max(g,T)}let S=I=>[[d-I,x-I],[b+I,x-I],[b+I,g+I],[d-I,g+I]].map(([E,T])=>({x:a+f*E+y*T,y:i+m*E+h*T})),A=S(kr/R),M=S((kr+kc)/R),p=n.baseHeightM,_=it(o.ground,[.62,.55,.47],.4),P=it(o.ground,[.86,.86,.84],.55);return Z(t,M,void 0,()=>p-.04,p-.22,_,_,V),Z(t,M,[A.slice().reverse()],()=>p+Cc,p-.04,it(P,[1,1,1],.2),P,V),!0}function Nr(t,n,e){let r=()=>({byObjectId:new Map,elements:[]});if(!n||!t)return r();let o=Se(n);if(!o.ok||o.value.id!==t)return r();let a=new Map;for(let f of e)for(let m of f.objects)m.type==="shape"&&a.set(m.id,{shape:m,unit:f});let i=new Set,s=new Set,l=new Map((n.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 o.value.overlay.productionElements??[]){let m=a.get(f.objectId),y=m?ut(m.shape):null,h=f.baseElevationM??0;if(!m||!y||y.length<3||!f.id||i.has(f.id)||s.has(f.objectId)||!Number.isFinite(f.heightM)||f.heightM<.05||f.heightM>50||!Number.isFinite(h)||h<-10||h>100)return r();i.add(f.id),s.add(f.objectId);let d=y.map(P=>P.x*R),b=y.map(P=>P.y*R),x=m.unit.baseHeightM+h,g=Math.min(...d),S=Math.max(...d),A=Math.min(...b),M=Math.max(...b),p,_=l.get(f.id)??f.contentImageUrl;if(f.kind==="screen"&&_&&(p=To(y,x,x+f.heightM,m.unit.focal),!p))if(S-g>=M-A){let P=Math.abs(A-m.unit.focal.y*R)<=Math.abs(M-m.unit.focal.y*R)?A-.006:M+.006;p=[[g,x,P],[S,x,P],[g,x+f.heightM,P],[S,x+f.heightM,P]]}else{let P=Math.abs(g-m.unit.focal.x*R)<=Math.abs(S-m.unit.focal.x*R)?g-.006:S+.006;p=[[P,x,A],[P,x,M],[P,x+f.heightM,A],[P,x+f.heightM,M]]}u.push({id:f.id,objectId:f.objectId,kind:f.kind,floorIndex:m.unit.index,baseY:x,topY:x+f.heightM,bounds:{min:[g,x,A],max:[S,x+f.heightM,M]},occlusion:f.occlusion,..._?{contentImageUrl:_}:{},...p?{contentPlane:p}:{}})}let c=u.sort((f,m)=>f.id.localeCompare(m.id));return{byObjectId:new Map(c.map(f=>[f.objectId,f])),elements:c}}var Gr=[.13,.14,.17],Jt=[.4,.43,.47],Fc=.18,Lc=.02,vc=2.4,Dc=1500,Nc=240,Gc=.25;function Hr(t,n,e,r){let o=n.stageKind??"";if(Yt(o)||o==="round"||!r.length)return;let a=ut(n);if(!a||a.length<3)return;let i={x:a.reduce((C,v)=>C+v.x,0)/a.length,y:a.reduce((C,v)=>C+v.y,0)/a.length},s=0,l=0,u=new Set;for(let C of r)s+=C.x,l+=C.y,u.add(Math.floor(Math.atan2(C.y-i.y,C.x-i.x)*180/Math.PI/10));let c=i.x-s/r.length,f=i.y-l/r.length,m=Math.hypot(c,f);if(m<1e-6)return;let y=r.reduce((C,v)=>C+Math.hypot(v.x-i.x,v.y-i.y),0)/r.length;if(u.size*10>Nc&&m<Gc*y)return;let h=c/m,d=f/m,b=-d,x=h,g=-1/0,S=1/0,A=1/0,M=-1/0;for(let C of a){let v=(C.x-i.x)*h+(C.y-i.y)*d,O=(C.x-i.x)*b+(C.y-i.y)*x;g=Math.max(g,v),S=Math.min(S,v),A=Math.min(A,O),M=Math.max(M,O)}let p=(M-A)*R,_=(g-S)*R;if(p<3||_<1.5||p*_>Dc)return;let P=Fc/R,I=(C,v)=>({x:i.x+h*C+b*v,y:i.y+d*C+x*v}),E=(C,v,O,N)=>[I(C,O),I(C,N),I(v,N),I(v,O)],T=e+Math.max(3.5,Math.min(8,p*.35)),F=e+Math.min(vc,T-e-1),k=.2/R,w=S+Math.min(_*.25,1.5)/R,B=Lc/R;Z(t,E(g-2*P+B,g-P-B,A+P+k,M-P-k),void 0,()=>F,e,Gr,Gr,V);for(let[C,v]of[[A+P,A+P+k],[M-P-k,M-P]])Z(t,E(g-2*P,g-P,C,v),void 0,()=>T+.3,e,Jt,Jt,V),Z(t,E(w+k,g-2*P,C,v),void 0,()=>T+.3,T,Jt,Jt,V);Z(t,E(w,w+k,A+P,M-P),void 0,()=>T+.3,T,Jt,Jt,V)}function Mt(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function gt(t){return Array.isArray(t)?t:[]}function Hc(t){let n=[t];for(;n.length;){let e=n.pop();if(Array.isArray(e)){n.push(...e);continue}if(!Mt(e))continue;let r=Mt(e.extensions)?e.extensions:null;if(r&&Object.prototype.hasOwnProperty.call(r,"KHR_draco_mesh_compression"))return!0;n.push(...Object.values(e))}return!1}function Hn(t,n){return!Array.isArray(t)||t.length!==n||!t.every(e=>typeof e=="number"&&Number.isFinite(e))?null:t}function Xc(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function jc(t,n){let e=new Array(16).fill(0);for(let r=0;r<4;r++)for(let o=0;o<4;o++)for(let a=0;a<4;a++)e[r*4+o]+=t[a*4+o]*n[r*4+a];return e}function Uc(t){let n=Hn(t.matrix,16);if(n)return n;if(t.matrix!==void 0)return null;let e=t.translation===void 0?[0,0,0]:Hn(t.translation,3),r=t.rotation===void 0?[0,0,0,1]:Hn(t.rotation,4),o=t.scale===void 0?[1,1,1]:Hn(t.scale,3);if(!e||!r||!o)return null;let[a,i,s,l]=r,u=Math.hypot(a,i,s,l);if(!(u>1e-8))return null;let c=a/u,f=i/u,m=s/u,y=l/u,h=c+c,d=f+f,b=m+m,x=c*h,g=c*d,S=c*b,A=f*d,M=f*b,p=m*b,_=y*h,P=y*d,I=y*b;return[(1-(A+p))*o[0],(g+I)*o[0],(S-P)*o[0],0,(g-I)*o[1],(1-(x+p))*o[1],(M+_)*o[1],0,(S+P)*o[2],(M-_)*o[2],(1-(x+A))*o[2],0,e[0],e[1],e[2],1]}function Wc(t,n,e,r){return[t[0]*n+t[4]*e+t[8]*r+t[12],t[1]*n+t[5]*e+t[9]*r+t[13],t[2]*n+t[6]*e+t[10]*r+t[14]]}function Yc(t){let n=t[0],e=t[4],r=t[8],o=t[1],a=t[5],i=t[9],s=t[2],l=t[6],u=t[10],c=a*u-i*l,f=i*s-o*u,m=o*l-a*s,y=n*c+e*f+r*m;if(Math.abs(y)<1e-12)return null;let h=1/y;return[c*h,f*h,m*h,(r*l-e*u)*h,(n*u-r*s)*h,(e*s-n*l)*h,(e*i-r*a)*h,(r*o-n*i)*h,(n*a-e*o)*h]}function Xr(t,n,e,r){let o=t[0]*n+t[1]*e+t[2]*r,a=t[3]*n+t[4]*e+t[5]*r,i=t[6]*n+t[7]*e+t[8]*r,s=Math.hypot(o,a,i)||1;return o/=s,a/=s,i/=s,[o,a,i]}function zc(t){if(t.byteLength<20||t.byteLength>8388608)return null;let n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0,!0)!==1179937895||n.getUint32(4,!0)!==2||n.getUint32(8,!0)!==t.byteLength)return null;let e=12,r=null,o=null;for(;e+8<=t.byteLength;){let a=n.getUint32(e,!0),i=n.getUint32(e+4,!0);if(e+=8,a%4!==0||e+a>t.byteLength)return null;let s=t.subarray(e,e+a);if(i===1313821514&&!r)try{let l=JSON.parse(new TextDecoder().decode(s).replace(/[\u0000 ]+$/g,""));if(!Mt(l))return null;r=l}catch{return null}else if(i===5130562&&!o)o=s;else return null;e+=a}return e===t.byteLength&&r&&o?{json:r,bin:o}:null}function Vc(t){return t===5120||t===5121?1:t===5122||t===5123?2:t===5125||t===5126?4:0}function Kc(t){return t==="SCALAR"?1:t==="VEC2"?2:t==="VEC3"?3:t==="VEC4"?4:0}function Zc(t,n,e){return e===5120?t.getInt8(n):e===5121?t.getUint8(n):e===5122?t.getInt16(n,!0):e===5123?t.getUint16(n,!0):e===5125?t.getUint32(n,!0):t.getFloat32(n,!0)}function qc(t){let n=t instanceof Uint8Array?t:new Uint8Array(t),e=zc(n);if(!e)return{ok:!1,issue:"invalid_glb"};let{json:r,bin:o}=e;if(!Mt(r.asset)||r.asset.version!=="2.0")return{ok:!1,issue:"unsupported_glb"};let a=gt(r.extensionsUsed).filter(A=>typeof A=="string");if(a.includes("KHR_draco_mesh_compression")||Hc(r))return{ok:!1,issue:"draco_not_allowed"};if(a.length||gt(r.extensionsRequired).length)return{ok:!1,issue:"unsupported_glb"};if(gt(r.images).length||gt(r.textures).length)return{ok:!1,issue:"external_resource"};let i=gt(r.buffers);if(i.length!==1||!Mt(i[0])||i[0].uri!==void 0||typeof i[0].byteLength!="number"||!Number.isInteger(i[0].byteLength)||i[0].byteLength<0||i[0].byteLength>o.byteLength)return{ok:!1,issue:"external_resource"};let s=gt(r.accessors),l=gt(r.bufferViews),u=gt(r.meshes),c=gt(r.nodes),f=gt(r.scenes),m=typeof r.scene=="number"?r.scene:0;if(!Mt(f[m]))return{ok:!1,issue:"unsupported_glb"};let y=new DataView(o.buffer,o.byteOffset,o.byteLength),h=(A,M,p)=>{if(typeof A!="number"||!Number.isInteger(A)||!Mt(s[A]))return null;let _=s[A];if(_.type!==M||_.sparse!==void 0||_.normalized===!0||typeof _.count!="number"||!Number.isInteger(_.count)||_.count<1||typeof _.componentType!="number"||!p.includes(_.componentType)||typeof _.bufferView!="number")return null;let P=l[_.bufferView];if(!Mt(P)||P.buffer!==0||typeof P.byteLength!="number"||!Number.isInteger(P.byteLength)||P.byteLength<0)return null;let I=Kc(_.type),E=Vc(_.componentType),T=typeof P.byteStride=="number"?P.byteStride:I*E,F=typeof P.byteOffset=="number"?P.byteOffset:0,k=typeof _.byteOffset=="number"?_.byteOffset:0,w=F+k,B=k+(_.count-1)*T+I*E;if(!Number.isInteger(T)||!Number.isInteger(F)||!Number.isInteger(k)||T<I*E||F<0||k<0||F+P.byteLength>o.byteLength||B>P.byteLength)return null;let C=[];for(let v=0;v<_.count;v++){let O=[];for(let N=0;N<I;N++){let H=Zc(y,w+v*T+N*E,_.componentType);if(!Number.isFinite(H))return null;O.push(H)}C.push(O)}return C},d=[],b=[],x=0,g=new Set,S=(A,M)=>{if(typeof A!="number"||!Number.isInteger(A)||!Mt(c[A])||g.has(A))return!1;g.add(A);let p=c[A],_=Uc(p);if(!_)return!1;let P=jc(M,_),I=Yc(P);if(!I)return!1;if(p.mesh!==void 0){if(typeof p.mesh!="number")return!1;let E=u[p.mesh];if(!Mt(E))return!1;for(let T of gt(E.primitives)){if(!Mt(T)||T.mode!==void 0&&T.mode!==4||!Mt(T.attributes))return!1;let F=h(T.attributes.POSITION,"VEC3",[5126]),k=T.attributes.NORMAL===void 0?null:h(T.attributes.NORMAL,"VEC3",[5126]);if(!F||T.attributes.NORMAL!==void 0&&!k)return!1;let w=F.length;if(T.indices!==void 0){let C=typeof T.indices=="number"?s[T.indices]:null;w=Mt(C)?C.count:void 0}if(typeof w!="number"||!Number.isInteger(w)||w%3!==0||(x+=w/3,x>1e5))return!1;let B=T.indices===void 0?F.map((C,v)=>[v]):h(T.indices,"SCALAR",[5121,5123,5125]);if(!B||B.length%3!==0||B.length!==w)return!1;for(let C=0;C<B.length;C+=3){let v=[B[C][0],B[C+1][0],B[C+2][0]];if(v.some(H=>!Number.isInteger(H)||H<0||H>=F.length))return!1;let O=v.map(H=>Wc(P,...F[H])),N=null;if(!k){let H=O[1][0]-O[0][0],j=O[1][1]-O[0][1],G=O[1][2]-O[0][2],U=O[2][0]-O[0][0],X=O[2][1]-O[0][1],W=O[2][2]-O[0][2];N=Xr([1,0,0,0,1,0,0,0,1],j*W-G*X,G*U-H*W,H*X-j*U)}for(let H=0;H<3;H++)d.push(...O[H]),b.push(...k?Xr(I,...k[v[H]]):N)}}}for(let E of gt(p.children))if(!S(E,P))return!1;return g.delete(A),!0};for(let A of gt(f[m].nodes))if(!S(A,Xc()))return{ok:!1,issue:x>1e5?"triangle_limit":"unsupported_glb"};return!x||d.length!==x*9||b.length!==d.length?{ok:!1,issue:"unsupported_glb"}:{ok:!0,triangleCount:x,position:new Float32Array(d),normal:new Float32Array(b)}}function jr(t){try{return qc(t)}catch{return{ok:!1,issue:"invalid_glb"}}}function kh(t){let{doc:n}=t,e=mr(n.theme),r=e.structure,o=fo(n,t.eventConfigurationId??n.eventConfigurationId),a=Nr(t.eventConfigurationId,t.eventConfiguration,o),i=t.seats,s=new In,l=null;if(t.registeredShellGlb){let L=jr(t.registeredShellGlb);if(L.ok){let D=L.position.length/3,Y=new Float32Array(L.position.length),ct=e.materials.shell??r.tierWall;for(let ft=0;ft<D;ft++){let st=L.normal[ft*3+1],tt=st<-.25?.4:.62+.38*Math.max(0,st);Y[ft*3]=ct[0]*tt,Y[ft*3+1]=ct[1]*tt,Y[ft*3+2]=ct[2]*tt}l={position:L.position,normal:L.normal,color:Y,floor:new Float32Array(D).fill(-2),material:new Float32Array(D),count:D}}}let u=new Map;for(let L of o)for(let D of L.objects)u.set(D.id,L.index),D.type==="section"&&u.set(D.logicalSectionId??D.id,L.index);let c=i.map(L=>u.get(L.sectionId??"")??u.get(L.rowId??"")??0),f=Me(o,i),m=s.vertexCount,h=Lr(s,o,i,c,f,r,it(e.background.top,e.background.bottom,.5))?s.vertexCount:m,d=qe(n,i),b=new Map,x=new Map;for(let L of n.categories??[])b.set(L.key,L.color),L.seatGlyph&&x.set(L.key,L.seatGlyph);let g=[],S=vo(o,i,c),A=new Map;i.forEach((L,D)=>{let Y=S.seatDeckY(D);Number.isFinite(Y)&&A.set(L.rowId,Math.min(A.get(L.rowId)??1/0,Y))});let M=new Float32Array(i.length),p=[],_=new Map((n.floors??[]).map((L,D)=>[L.id,D])),P=o.map(()=>[]);for(let L of i){let D=L.floorId?_.get(L.floorId)??0:0;P[Math.min(D,P.length-1)]?.push(L)}let I=(L,D)=>{if(!D||D.length<3)return!1;let Y=Math.min(...D.map(tt=>tt.x)),ct=Math.max(...D.map(tt=>tt.x)),ft=Math.min(...D.map(tt=>tt.y)),st=Math.max(...D.map(tt=>tt.y));for(let tt=0;tt<L;tt++)for(let et of P[tt])if(!(et.x<Y||et.x>ct||et.y<ft||et.y>st)&&wt(et,D,void 0))return!0;return!1},E=null,T=L=>o.length===1?i:i.filter((D,Y)=>c[Y]===L),F=(L,D)=>{let Y=At(L);if(!Y)return!1;let ct=1/0,ft=1/0,st=-1/0,tt=-1/0;for(let et of Y)ct=Math.min(ct,et.x),st=Math.max(st,et.x),ft=Math.min(ft,et.y),tt=Math.max(tt,et.y);return i.some((et,ht)=>et.kind!=="booth"&&(o.length===1||c[ht]===D)&&et.x>ct&&et.x<st&&et.y>ft&&et.y<tt&&xt(Y,et.x,et.y))},k;for(let L=0;L<o.length;L++){let D=o[L];s.setFloor(L);let Y=Kt(D,T(L)),ct=0;if(Y){let z=0;for(let mt of D.objects)if(mt.type==="section")for(let yt of S.bySection.get(mt.id)?.rowLevels??[])z=Math.max(z,yt.y-D.baseHeightM);if(ct=bo(z),!k){let mt=go(Y);k={centre:[mt.x*R,mt.y*R]}}}let ft=new En,st=[],tt=D.objects.filter(z=>z.type==="shape"&&(z.role==="entrance"||z.role==="exit")),et=D.objects.filter(z=>z.type==="section"&&!!z.outline&&z.outline.length>=3),ht=dr(D.objects.filter(z=>z.type==="booth"),D.focal);for(let z of D.objects)if(z.type==="section"){let mt=s.vertexCount;Ar(s,z,D,$e(z,d),S.bySection.get(z.id),ft,et,r,L>0&&I(L,z.outline));let yt=s.vertexCount-mt;yt>0&&p.push({sectionId:z.id,start:mt,count:yt})}else if(z.type==="shape"){let mt=a.byObjectId.get(z.id),yt=g.length,Nt=Y!==null&&z.role==="wall"&&!mt;s.setMaterial(Nt?xo:(mt?.kind??z.role)==="screen"?1:0);let Gt=z.role==="stage"&&!mt?pr(z,T(L)):Nt&&z.heightM===void 0?{...z,heightM:ct}:z,kt=yo(Gt,st);if(Jo(s,Gt,D.baseHeightM+kt.supportOffsetM,kt.topOffsetM-kt.supportOffsetM,r,D.focal,g,mt,tt),s.setMaterial(0),z.role==="stage"&&!mt&&g.length>yt&&(E??L)===L){E=L;let Ft=n.floors?.[L]?.id,tn=o.length>1&&Ft?i.filter(pn=>pn.floorId===Ft):i;Hr(s,Gt,g[g.length-1].y,tn)}}else z.type==="gaArea"?nr(s,z,D.baseHeightM,at(b.get(z.categoryKey)),r):z.type==="booth"?qo(s,z,D.baseHeightM,at(b.get(z.categoryKey)),r,ht.get(z.id)??D.focal,F(z,L)):z.type==="table"?Qo(s,z,Math.max(D.baseHeightM,A.get(z.id)??D.baseHeightM),at(z.fill??n.theme?.decorFill??"#232c40"),r,!!(z.fill??n.theme?.decorFill)):z.type==="decorImage"&&tr(s,z,D.baseHeightM,r);Er(s,D,i,S,r,e.materials.shell,!l)}let w=o.length>1?{x:o.reduce((L,D)=>L+D.focal.x,0)/o.length,y:o.reduce((L,D)=>L+D.focal.y,0)/o.length}:n.focalPoint??{x:(f.minX+f.maxX)/2,y:(f.minY+f.maxY)/2},B=Ue(l?[s.build(),l]:[s.build()]),C=Ve(i,t.initialState,S,M,b,x),v=ar({doc:n,units:o,seats:i,surfaces:S,focal:w}),{labels:O,sections:N,rows:H}=cr({doc:n,units:o,seats:i,surfaces:S,seatData:C,hintedSeatFloor:c,zones:v,focal:w}),j=new Map(N.map((L,D)=>[L.id,D]));S.seatOwner.forEach((L,D)=>{C.iSection[D]=L?j.get(L)??-1:-1});let G=Br({doc:n,units:o,seats:i,surfaces:S,solids:B,hintedSeatFloor:c,seatFloor:M});lr(O,G),C.iYaw=ze(C.iPosition,i.length,L=>i[L].rowId,L=>{let D=o[M[L]]?.focal??w;return[D.x*R,D.y*R]});let U=(f.minX+f.maxX)/2*R,X=(f.minY+f.maxY)/2*R,W=.5*Math.hypot((f.maxX-f.minX)*R,(f.maxY-f.minY)*R)||10,nt=Pe(B,C,{cx:U,cz:X,radius:W},[m,h]),rt=Pe(B,C,{cx:U,cz:X,radius:W}),q=$c(o),Q=Dr(C,g,f,nt.minY,nt.maxY,W,q);return{sharedAisles:ur(o.flatMap(L=>L.objects.flatMap(D=>{if(D.type!=="section")return[];let Y=S.bySection.get(D.id);return Y?[{sectionId:D.id,floorIndex:L.index,rows:Y.rowLevels}]:[]}))),solids:B,sectionSolidRanges:p,seats:C,seatSectionIds:S.seatOwner,bounds:{center:[(Q.min[0]+Q.max[0])/2,(Q.min[1]+Q.max[1])/2,(Q.min[2]+Q.max[2])/2],radius:W,groundY:0,box:Q,fitPoints:vr(C,g,q)},...k?{room:k}:{},...!k&&o.some(L=>L.objects.some(D=>D.type==="shape"&&Mn(D.stageKind)))?{outdoor:!0}:{},renderBounds:{center:nt.center,radius:nt.radius},clipBounds:{center:rt.center,radius:rt.radius},stateColorLUT:hr(e,en),theme:e,seatCount:i.length,focalWorld:[w.x*R,1.5,w.y*R],zones:v,stages:g,productionElements:a.elements,sections:N,rows:H,labels:O,floors:G}}function $c(t){let n=[];for(let e of t)for(let r of e.objects){let o=r.type==="gaArea"?r.points:r.type==="booth"?At(r):null;for(let a of o??[])n.push([a.x*R,e.baseHeightM,a.y*R])}return n}function Qc(t,n){let{doc:e,report:r}=Bo(t),o=r.confident&&(r.sections.length>0||!!r.looseRowBlocks);if(!o&&!r.roles?.length)return null;if(!o){let l=new Map(r.roles.map(y=>[y.id,y.role])),u=y=>y.map(h=>h.type==="shape"&&l.has(h.id)?{...h,role:l.get(h.id)}:h),c=t.floors?.map(y=>({...y,objects:u(y.objects)})),f=new Float64Array(n.length).fill(Number.NaN),m=new Float64Array(n.length*2).fill(Number.NaN);return n.forEach((y,h)=>{y.eyeHeightM!==void 0&&(f[h]=y.eyeHeightM),y.focalPoint&&(m[h*2]=y.focalPoint.x,m[h*2+1]=y.focalPoint.y)}),{doc:{...t,objects:c?.[0]?.objects??u(t.objects),...c?{floors:c}:{}},report:r,eyeHeightM:f,focal:m}}let a=new Map(Pn(e).map(l=>[l.id,l])),i=new Float64Array(n.length).fill(Number.NaN),s=new Float64Array(n.length*2).fill(Number.NaN);return n.forEach((l,u)=>{let c=a.get(l.id)??l;c.eyeHeightM!==void 0&&(i[u]=c.eyeHeightM),c.focalPoint&&(s[u*2]=c.focalPoint.x,s[u*2+1]=c.focalPoint.y)}),{doc:e,report:r,eyeHeightM:i,focal:s}}function Jc(t,n){return t.map((e,r)=>{let o=n.eyeHeightM[r],a=n.focal[r*2],i=n.focal[r*2+1],s={...e};return Number.isNaN(o)?delete s.eyeHeightM:s.eyeHeightM=o,Number.isNaN(a)?delete s.focalPoint:s.focalPoint={x:a,y:i},s})}function Dh(t){let n=t.estimate===!1?null:Qc(t.doc,t.seats);return n?{input:{...t,doc:n.doc,seats:Jc(t.seats,n)},estimate:n}:{input:t}}export{ll as a,ei as b,oi as c,We as d,ri as e,ul as f,en as g,jn as h,nl as i,Wn as j,R as k,An as l,gl as m,Ml as n,Bo as o,su as p,au as q,cu as r,lu as s,uu as t,fu as u,ee as v,mu as w,hu as x,yu as y,du as z,pu as A,Ha as B,kh as C,Qc as D,Jc as E,Dh as F};
@@ -1 +0,0 @@
1
- var s=24,h=2,M={facilities:"Facilities","food-drink":"Food & drink",navigation:"Getting around",accessibility:"Accessibility"},c=["facilities","food-drink","navigation","accessibility"],n="M13 4.6a1.6 1.6 0 1 0-3.2 0 1.6 1.6 0 0 0 3.2 0 M11 6.5V13h5l2.4 6 M15 16.4A5 5 0 1 1 9 11.3",a=[{key:"restroom-men",label:"Men's restroom",group:"facilities",path:"M16 7a4 4 0 1 0-8 0 4 4 0 0 0 8 0 M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"},{key:"restroom-women",label:"Women's restroom",group:"facilities",path:"M15 5a3 3 0 1 0-6 0 3 3 0 0 0 6 0 M12 8l-4 10h8l-4-10 M10 18v4 M14 18v4"},{key:"restroom-accessible",label:"Accessible restroom",group:"facilities",path:n},{key:"first-aid",label:"First aid",group:"facilities",path:"M5 4h14a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1Z M12 8v8 M8 12h8"},{key:"coat-check",label:"Coat check",group:"facilities",path:"M12 6a2 2 0 0 1 0-4 2 2 0 0 1 1.6 3.2L21 13H3l8.4-7.8 M3 13h18"},{key:"atm",label:"ATM / cash",group:"facilities",path:"M2 6h20v12H2V6Z M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0 M6 9h.01 M18 15h.01"},{key:"info",label:"Info point",group:"facilities",path:"M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18 M12 11v5 M12 8h.01"},{key:"lost-found",label:"Lost & found",group:"facilities",path:"M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14 M16 16l5 5 M9 8.5a2 2 0 1 1 3 1.7c-.8.5-1 .8-1 1.8 M11 15h.01"},{key:"restrooms",label:"Restrooms",group:"facilities",path:"M6 3h12a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z M12 8a2 2 0 1 0 0 4 2 2 0 0 0 0-4 M9 18v-3.5a3 3 0 0 1 6 0V18"},{key:"charging",label:"Charging point",group:"facilities",path:"M3 8h13v8H3V8Z M16 10h3v4h-3 M9.6 9l-2 3.5h2.5l-1.5 3"},{key:"smoking",label:"Smoking area",group:"facilities",path:"M2 15h13v3H2v-3Z M18 16h2 M19 8c0 1 1 1.5 1 2.5S19 12 19 13"},{key:"no-smoking",label:"No smoking",group:"facilities",path:"M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18 M5.6 5.6l12.8 12.8 M7 13h6v2H7v-2Z"},{key:"food",label:"Food",group:"food-drink",path:"M7 3v6a2 2 0 0 0 4 0V3 M9 11v10 M17 3c-1.6 1-2.2 3-2.2 6 0 2 .9 3.2 2.2 3.6V21"},{key:"bar",label:"Bar",group:"food-drink",path:"M4 5h16l-8 8-8-8Z M12 13v6 M8 20h8"},{key:"coffee",label:"Caf\xE9 / coffee",group:"food-drink",path:"M4 8h13v4a5 5 0 0 1-5 5H9a5 5 0 0 1-5-5V8Z M17 9h2a2 2 0 0 1 0 4h-2 M8 2v2 M11 2v2 M4 21h14"},{key:"water",label:"Water / drinks",group:"food-drink",path:"M12 22a7 7 0 0 1-7-7c0-5 7-12 7-12s7 7 7 12a7 7 0 0 1-7 7Z"},{key:"merch",label:"Merch / shop",group:"food-drink",path:"M6 8h12l-1 12H7L6 8Z M9 8V6a3 3 0 0 1 6 0v2"},{key:"screen",label:"Screen",group:"facilities",path:"M3 4h18v12H3V4Z M9 20h6 M12 16v4 M10 8l4 2-4 2V8Z"},{key:"sound-booth",label:"Sound booth",group:"facilities",path:"M6 4v16 M6 14a2 2 0 1 0 0-4 2 2 0 0 0 0 4 M12 4v16 M12 8a2 2 0 1 0 0 4 2 2 0 0 0 0-4 M18 4v16 M18 12a2 2 0 1 0 0 4 2 2 0 0 0 0-4"},{key:"entrance",label:"Entrance",group:"navigation",path:"M14 3h5a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1h-5 M3 12h11 M10 8l4 4-4 4"},{key:"exit",label:"Exit",group:"navigation",path:"M10 3H5a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h5 M14 12h7 M17 8l4 4-4 4"},{key:"emergency-exit",label:"Emergency exit",group:"navigation",path:"M14 4.6a1.5 1.5 0 1 0-3 0 1.5 1.5 0 0 0 3 0 M12.5 8l-3.5 2 1.6 3.6-2 4.4 M12.5 10l3.5 1.5 M9 10.5l-3.5 1 M15 12h6 M18 9l3 3-3 3"},{key:"stairs",label:"Stairs",group:"navigation",path:"M3 20v-4h4v-4h4v-4h4V4h5"},{key:"elevator",label:"Elevator",group:"navigation",path:"M5 3h14a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z M8 11l1.5-2 1.5 2 M8 14l1.5 2 1.5-2 M15 8v8"},{key:"parking",label:"Parking",group:"navigation",path:"M5 3h14a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z M9 17V7h4a3 3 0 0 1 0 6H9"},{key:"wheelchair",label:"Wheelchair access",group:"accessibility",path:n},{key:"hearing",label:"Hearing assistance",group:"accessibility",path:"M8 20a4 4 0 0 1-2-3c0-1 .5-2 .5-3a4.5 4.5 0 1 1 9 0c0 1.4-1 2-2 2.4-1.2.5-1.5 1-1.5 2.2 M17 6a5 5 0 0 1 1 6 M19.5 4a8 8 0 0 1 1.2 9"}],u={wall:"M3 5h18v14H3V5Z M3 9.7h18 M3 14.3h18 M9 5v4.7 M15 5v4.7 M6 9.7v4.6 M12 9.7v4.6 M18 9.7v4.6 M9 14.3v4.7 M15 14.3v4.7",rail:"M3 7h18 M4 17h16 M6 7v10 M10 7v10 M14 7v10 M18 7v10",suite:"M3 4h18v16H3V4Z M6 17v-5h12v5 M8 12V9h8v3",obstruction:"M8 3h8l-1 4v10l1 4H8l1-4V7L8 3Z M9 7h6 M9 17h6"},i=new Map(a.map(e=>[e.key,e]));function t(e){return e?i.get(e):void 0}function g(e){return t(e)?.path}function v(e){return typeof e=="string"&&i.has(e)}var d=a.map(e=>e.key);var y=["butt","round","square"],E=["miter","round","bevel"],k=["none","arrow"],r="round",l="round",o="none";function p(e){return e==="line"||e==="polyline"}function b(e){return e==="polygon"||p(e)}function S(e){return{lineCap:e.lineCap??r,lineJoin:e.lineJoin??l,startEnding:e.startEnding??o,endEnding:e.endEnding??o}}function V(e){return{pointerLength:Math.min(48,Math.max(8,e*3)),pointerWidth:Math.min(40,Math.max(8,e*2.25))}}export{s as a,h as b,M as c,c as d,a as e,u as f,t as g,g as h,v as i,d as j,y as k,E as l,k as m,r as n,l as o,o as p,p as q,b as r,S as s,V as t};
@@ -1 +0,0 @@
1
- import{h as Ie,i as ce}from"./chunk-5ITK5236.js";import{c as Pe}from"./chunk-CRCGO52K.js";var Wn=2e6,Mt=/^data:image\/(?:png|jpe?g|webp|gif|avif);base64,[a-z0-9+/]+={0,2}$/i,St=/[\s"'<>`\\]/;function vt(e){if(typeof e!="string"||!e||e.length>2e6||e!==e.trim())return!1;if(e.startsWith("data:"))return Mt.test(e);if(St.test(e))return!1;try{let t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}}function Ce(e){let t=e.trim();return vt(t)?t:null}var wt=2e5,qn=1e5,Et="large_venue_inventory";function Qn(e){return e?.includes(Et)?2e5:1e5}var Z="seatlayer.event-configuration/1",le="seatlayer.event-configuration-export/1",K=100,It=120,Pt=2e5,Ct=1e4,ke=/^[a-f0-9]{64}$/,_t=new Set(["stage","screen","barrier","camera_platform","sound_desk","rigging_truss"]);function Y(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function H(e,t){return typeof e=="string"&&e.length>=1&&e.length<=t&&e.normalize("NFKC").trim()===e}function Re(e){return typeof e=="number"&&Number.isInteger(e)&&e>0}function _e(e){return!Array.isArray(e)||e.length>Pt||!e.every(t=>H(t,K))?null:[...new Set(e)].sort()}function Te(e){return!Y(e)||!H(e.chartId,K)||!H(e.version,K)||e.sha256!==void 0&&(typeof e.sha256!="string"||!ke.test(e.sha256))?null:{chartId:e.chartId,version:e.version,...typeof e.sha256=="string"?{sha256:e.sha256}:{}}}function ue(e,t,n){return typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=n}function kt(e){return Y(e)?e.mode==="none"||e.mode==="opaque"?e.opacity===void 0?{mode:e.mode}:null:e.mode==="partial"&&ue(e.opacity,.01,.99)?{mode:"partial",opacity:e.opacity}:null:null}function Rt(e,t){if(e===void 0)return;if(!Array.isArray(e)||e.length>Ct)return null;let n=new Set(t),i=new Set,o=new Set,r=0,s=[];for(let l of e){if(!Y(l)||!H(l.id,K)||!H(l.objectId,K)||!n.has(l.objectId)||!_t.has(String(l.kind))||!ue(l.heightM,.05,50)||l.baseElevationM!==void 0&&!ue(l.baseElevationM,-10,100))return null;let m=kt(l.occlusion);if(!m||i.has(l.id)||o.has(l.objectId))return null;let a=l.contentImageUrl===void 0?void 0:typeof l.contentImageUrl=="string"?Ce(l.contentImageUrl):null;if(l.contentImageUrl!==void 0&&(!a||l.kind!=="screen"||++r>1))return null;i.add(l.id),o.add(l.objectId),s.push({id:l.id,objectId:l.objectId,kind:l.kind,heightM:l.heightM,...l.baseElevationM!==void 0?{baseElevationM:l.baseElevationM}:{},occlusion:m,...a?{contentImageUrl:a}:{}})}return s.sort((l,m)=>l.id.localeCompare(m.id))}function Oe(e){let t=[];if(!Y(e))return{issues:[{code:"invalid_export",path:"configuration",message:"Configuration must be an object"}]};e.schema!==Z&&t.push({code:"unsupported_schema",path:"configuration.schema",message:`Configuration schema must be ${Z}`}),H(e.id,K)||t.push({code:"invalid_id",path:"configuration.id",message:"Configuration id must contain 1 to 100 normalized characters"}),H(e.label,It)||t.push({code:"invalid_label",path:"configuration.label",message:"Configuration label must contain 1 to 120 normalized characters"}),Re(e.version)||t.push({code:"invalid_version",path:"configuration.version",message:"Configuration version must be a positive integer"});let n=Te(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 i=Y(e.overlay)?e.overlay:null,o=_e(i?.objectIds),r=_e(i?.productionKillSeatIds),s=o?Rt(i?.productionElements,o):null;return(!i||!o||!r)&&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||!o||!r||s===null?{issues:t}:{issues:t,value:{schema:Z,id:e.id,label:e.label,version:e.version,baseVenue:n,overlay:{objectIds:o,productionKillSeatIds:r,...s!==void 0?{productionElements:s}:{}}}}}function eo(e){let t=Oe(e);return t.value?{ok:!0,value:t.value}:{ok:!1,issues:t.issues}}function to(e){if(!Y(e))return{ok:!1,issues:[{code:"invalid_export",path:"",message:"Export must be an object"}]};let t=[];e.schema!==le&&t.push({code:"unsupported_schema",path:"schema",message:`Export schema must be ${le}`}),(typeof e.contentSha256!="string"||!ke.test(e.contentSha256))&&t.push({code:"invalid_checksum",path:"contentSha256",message:"Export checksum must be a lowercase SHA-256 digest"});let n=Oe(e.configuration);return t.push(...n.issues),t.length||!n.value||typeof e.contentSha256!="string"?{ok:!1,issues:t}:{ok:!0,value:{schema:le,configuration:n.value,contentSha256:e.contentSha256}}}function no(e){return JSON.stringify({schema:Z,id:e.id,label:e.label,version:e.version,baseVenue:{chartId:e.baseVenue.chartId,version:e.baseVenue.version,...e.baseVenue.sha256?{sha256:e.baseVenue.sha256}:{}},overlay:{objectIds:[...new Set(e.overlay.objectIds)].sort(),productionKillSeatIds:[...new Set(e.overlay.productionKillSeatIds)].sort(),...e.overlay.productionElements!==void 0?{productionElements:[...e.overlay.productionElements].sort((t,n)=>t.id.localeCompare(n.id)).map(t=>({id:t.id,objectId:t.objectId,kind:t.kind,heightM:t.heightM,...t.baseElevationM!==void 0?{baseElevationM:t.baseElevationM}:{},occlusion:t.occlusion,...t.contentImageUrl?{contentImageUrl:t.contentImageUrl}:{}}))}:{}}})}function oo(e,t){let n=[];e.baseVenue.chartId!==t.chartId&&n.push({code:"base_venue_mismatch",message:"Configuration belongs to a different base venue"}),e.baseVenue.version!==t.version&&n.push({code:"base_venue_version_mismatch",message:"Configuration was authored against a different venue version"}),e.baseVenue.sha256&&!t.sha256?n.push({code:"base_venue_checksum_missing",message:"Venue checksum is required for this configuration"}):e.baseVenue.sha256&&e.baseVenue.sha256!==t.sha256&&n.push({code:"base_venue_checksum_mismatch",message:"Venue bytes do not match the configuration base"});let i=new Set(t.objectIds);for(let r of e.overlay.objectIds)i.has(r)||n.push({code:"overlay_object_missing",message:`Production object ${r} is missing from the base venue`,targetId:r});if(t.objectTypes)for(let r of e.overlay.productionElements??[])t.objectTypes.get(r.objectId)!=="shape"&&n.push({code:"production_element_not_shape",message:`Production element ${r.id} must reference base-venue shape geometry`,targetId:r.objectId});let o=new Set(t.seatIds);for(let r of e.overlay.productionKillSeatIds)o.has(r)||n.push({code:"production_kill_seat_missing",message:`Production-kill seat ${r} is missing from the base venue`,targetId:r});return{compatible:n.length===0,issues:n}}var Tt={draft:new Set(["review","archived"]),review:new Set(["draft","approved","archived"]),approved:new Set(["published","archived"]),published:new Set(["archived"]),archived:new Set};function io(e,t){return e===t||Tt[e].has(t)}function ro(e,t,n){return!Re(n)||n>=t.version?null:e.find(i=>i.id===t.id&&i.version===n&&i.status==="published")??null}function Ot(e){return e.floors?.length?e.floors.flatMap(t=>t.objects):e.objects}function de(e,t,n){if(!(!e||typeof e!="object")){if(Array.isArray(e)){for(let i of e)de(i,t,n);return}for(let[i,o]of Object.entries(e)){if(i==="eventConfigurationId"){H(o,K)?t.add(o):o!==void 0&&n.add(String(o));continue}if(i==="eventConfigurationIds"){if(!Array.isArray(o))n.add(String(o));else for(let r of o)H(r,K)?t.add(r):n.add(String(r));continue}de(o,t,n)}}}function so(e,t){let n=Te(t);if(!n)return{ok:!1,invalidIds:["baseVenue"]};let i=new Set,o=new Set;if(de(e,i,o),o.size)return{ok:!1,invalidIds:[...o].sort()};let r=Ot(e);return{ok:!0,configurations:[...i].sort().map(s=>({schema:Z,id:s,label:s,version:1,baseVenue:n,overlay:{objectIds:r.filter(l=>l.type==="shape"&&l.eventConfigurationIds?.includes(s)).map(l=>l.id).sort(),productionKillSeatIds:[]}}))}}var co=40,lo=1200,uo=.8,fo=3,ho=-2,mo=20,po=.1,bo=40,yo=40,Ae=e=>Math.max(1,e.fontSize*.6+(e.letterSpacing??0));function At(e,t){let n=e.text.split(/\r?\n/);if(!e.width)return Math.max(1,n.length);let i=Math.max(1,Math.floor(t/Ae(e))),o=0;for(let r of n){if(!r.length){o+=1;continue}let s=0;for(let l of r.split(/\s+/)){let m=l.length;s&&s+1+m<=i?s+=1+m:(o+=Math.max(1,Math.ceil(m/i)),s=m%i)}}return Math.max(1,o)}function Ne(e){let t=e.background?.padding??0,n=e.text.split(/\r?\n/),i=Math.max(1,...n.map(l=>l.length))*Ae(e),o=e.width??i+t*2,r=Math.max(1,o-t*2),s=At(e,r);return{width:o,height:s*e.fontSize*(e.lineHeight??1.2)+t*2,lineCount:s,padding:t}}var Nt=Math.PI/180;function T(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function jt(e,t,n){let i=Math.cos(n),o=Math.sin(n),r=e.x-t.x,s=e.y-t.y;return{x:t.x+r*i-s*o,y:t.y+r*o+s*i}}function xo(e,t){return jt(e,{x:0,y:0},t*Nt)}function L(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function Lt(e){let t=0,n=0;for(let o of e)t+=o.x,n+=o.y;let i=e.length||1;return{x:t/i,y:n/i}}function Mo(e){return e.length?Lt(e):null}function fe(e,t){let n=1-t,i=n*n*n,o=3*n*n*t,r=3*n*t*t,s=t*t*t;return{x:i*e.start.x+o*e.control1.x+r*e.control2.x+s*e.end.x,y:i*e.start.y+o*e.control1.y+r*e.control2.y+s*e.end.y}}function wo(e,t,n){let i={x:(e.x+t.x)/2,y:(e.y+t.y)/2},o={x:(n.x-i.x)*4/3,y:(n.y-i.y)*4/3};return{start:{...e},control1:{x:e.x+(t.x-e.x)/3+o.x,y:e.y+(t.y-e.y)/3+o.y},control2:{x:e.x+(t.x-e.x)*2/3+o.x,y:e.y+(t.y-e.y)*2/3+o.y},end:{...t}}}function Fe(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[fe(e,.5)];let i=Array.from({length:n+1},(m,a)=>fe(e,a/n)),o=new Float64Array(i.length);for(let m=1;m<i.length;m+=1){let a=i[m].x-i[m-1].x,c=i[m].y-i[m-1].y;o[m]=o[m-1]+Math.hypot(a,c)}let r=o[o.length-1];if(r<=1e-9)return Array.from({length:t},()=>({...e.start}));let s=[],l=1;for(let m=0;m<t;m+=1){let a=r*m/(t-1);for(;l<o.length-1&&o[l]<a;)l+=1;let c=o[l-1],u=o[l],h=u===c?0:(a-c)/(u-c);s.push({x:i[l-1].x+(i[l].x-i[l-1].x)*h,y:i[l-1].y+(i[l].y-i[l-1].y)*h})}return s}function F(e,t){return{x:e.x+t.x,y:e.y+t.y}}function ee(e,t){return{x:e.x-t.x,y:e.y-t.y}}function D(e,t){return{x:e.x*t,y:e.y*t}}function oe(e,t=13){return Array.from({length:t},(n,i)=>fe(e,i/(t-1)))}function je(e,t){let n=Math.max(0,Math.min(1,t))*(e.length-1),i=Math.min(e.length-2,Math.floor(n));return L(e[i],e[i+1],n-i)}function Le(e,t,n){let i=Math.max(0,Math.min(1,t)),o=Math.max(i,Math.min(1,n)),r=[je(e,i)];for(let s=1;s<e.length-1;s+=1){let l=s/(e.length-1);l>i+1e-9&&l<o-1e-9&&r.push(e[s])}return r.push(je(e,o)),r}function De(e,t){let n=[[0,1],[1,2],[2,3],[3,0]],i=0,o=Number.POSITIVE_INFINITY;n.forEach(([h,d],b)=>{let f=T(L(e[h],e[d],.5),t);f<o&&(o=f,i=b)});let r=e[i],s=e[(i+1)%4],l=e[(i+2)%4],m=e[(i+3)%4],a=L(r,s,.5),c=ee(t,a),u=Math.max(1e-9,Math.hypot(c.x,c.y));return{p0:r,p1:s,p2:l,p3:m,normal:D(c,1/u),depth:(T(r,m)+T(s,l))/2}}function Ve(e){let{p0:t,p1:n,p2:i,p3:o,normal:r,depth:s}=e,l=ee(n,t),m=ee(i,o),a=s*.22,c=s*.12;return{nearPath:{start:t,control1:F(F(t,D(l,1/3)),D(r,a)),control2:F(F(t,D(l,2/3)),D(r,a)),end:n},farPath:{start:i,control1:F(F(o,D(m,2/3)),D(r,c)),control2:F(F(o,D(m,1/3)),D(r,c)),end:o}}}function Eo(e,t,n){if(e.length!==4)throw new Error("A section shell requires four mapped bounds corners");let i=e.reduce((b,f)=>F(b,f),{x:0,y:0});i.x/=4,i.y/=4;let o=T(e[0],e[1]),r=T(e[0],e[3]),s=n==="auto"?o>r*1.25&&T(i,t)>r?"bezier":"tapered":n;if(s==="rectangle")return{mode:s,outline:e.map(b=>({...b}))};let l=De(e,t),{p0:m,p1:a,p2:c,p3:u}=l;if(s==="tapered")return{mode:s,outline:[F(m,D(ee(a,m),.14)),F(m,D(ee(a,m),1-.14)),c,u]};let{nearPath:h,farPath:d}=Ve(l);return{mode:s,outline:[...oe(h),...oe(d).slice(1)]}}function Io(e,t,n,i){if(e.length!==4)throw new Error("Aisle generation requires four mapped bounds corners");if(!Number.isInteger(n)||n<0||n>3)throw new Error("Aisle count must be an integer from 0 to 3");if(n===0)return[];let o=De(e,t),{p0:r,p1:s,p2:l,p3:m}=o,a=i==="bezier"?Ve(o):null,c=a?oe(a.nearPath):null,u=a?oe(a.farPath).reverse():null,h=Math.min(.055,.18/(n+1));return Array.from({length:n},(d,b)=>{let f=(b+1)/(n+1),g=f-h/2,w=f+h/2;return c&&u?[...Le(c,g,w),...Le(u,g,w).reverse()]:[L(r,s,g),L(r,s,w),L(m,l,w),L(m,l,g)]})}function Ft(e,t,n){let i=n.x-t.x,o=n.y-t.y,r=i*i+o*o,s=r?Math.max(0,Math.min(1,((e.x-t.x)*i+(e.y-t.y)*o)/r)):0;return Math.hypot(e.x-(t.x+s*i),e.y-(t.y+s*o))}function Dt(e,t){let n=1/0;for(let i of t)if(!(i.length<2))for(let o=0,r=i.length-1;o<i.length;r=o++){let s=Ft(e,i[r],i[o]);s<n&&(n=s)}return n}function He(e,t){let n=!1;for(let i=0,o=t.length-1;i<t.length;o=i++){let r=t[i].x,s=t[i].y,l=t[o].x,m=t[o].y;s>e.y!=m>e.y&&e.x<(l-r)*(e.y-s)/(m-s)+r&&(n=!n)}return n}function Ke(e){return Array.isArray(e)?e.filter(t=>Array.isArray(t)&&t.length>=3):[]}function Vt(e,t,n){let i=He(e,t)&&!n.some(r=>He(e,r)),o=Dt(e,[t,...n]);return i?o:-o}function z(e,t,n,i,o){let r=Vt({x:e,y:t},i,o);return{x:e,y:t,h:n,d:r,max:r+n*Math.SQRT2}}var he=class{constructor(){this.items=[]}get size(){return this.items.length}push(t){let n=this.items;n.push(t);let i=n.length-1;for(;i>0;){let o=i-1>>1;if(n[o].max>=n[i].max)break;[n[o],n[i]]=[n[i],n[o]],i=o}}pop(){let t=this.items,n=t[0],i=t.pop();if(t.length&&i){t[0]=i;let o=0;for(;;){let r=o*2+1,s=r+1,l=o;if(r<t.length&&t[r].max>t[l].max&&(l=r),s<t.length&&t[s].max>t[l].max&&(l=s),l===o)break;[t[l],t[o]]=[t[o],t[l]],o=l}}return n}};function Ue(e){if(e.length<3)return 0;let t=0;for(let n=0,i=e.length-1;n<e.length;i=n++)t+=(e[i].x+e[n].x)*(e[i].y-e[n].y);return Math.abs(t)/2}function Co(e,t){return Math.max(0,Ue(e)-Ke(t).reduce((n,i)=>n+Ue(i),0))}function Ge(e,t){let n=Ke(t);if(!e.length)return{point:{x:0,y:0},radius:0};if(e.length<3){let f=e.reduce((w,E)=>w+E.x,0)/e.length,g=e.reduce((w,E)=>w+E.y,0)/e.length;return{point:{x:f,y:g},radius:0}}let i=1/0,o=1/0,r=-1/0,s=-1/0;for(let f of e)f.x<i&&(i=f.x),f.y<o&&(o=f.y),f.x>r&&(r=f.x),f.y>s&&(s=f.y);let l=r-i,m=s-o,a=Math.min(l,m);if(!(a>0))return{point:{x:(i+r)/2,y:(o+s)/2},radius:0};let c=Math.max(l,m)/150,u=new he,h=a/2;for(let f=i;f<r;f+=a)for(let g=o;g<s;g+=a)u.push(z(f+h,g+h,h,e,n));let d=z(i+l/2,o+m/2,0,e,n),b=0;for(;u.size;){let f=u.pop();if(!f)break;f.d>d.d&&(d=f),!(f.max-d.d<=c)&&(b>=4e3||(b+=1,h=f.h/2,u.push(z(f.x-h,f.y-h,h,e,n)),u.push(z(f.x+h,f.y-h,h,e,n)),u.push(z(f.x-h,f.y+h,h,e,n)),u.push(z(f.x+h,f.y+h,h,e,n))))}return{point:{x:d.x,y:d.y},radius:Math.max(0,d.d)}}function Ht(e,t,n){return Math.max(t,Math.min(n,e))}function ko(e,t,n){return e<t?t:e>n?n:e}function Ut(e){return Ht(e,0,1)}function Xe(e){let t=Ut(e);return t*t*(3-2*t)}var W=Math.PI*2;function $(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}function Kt(e,t,n){let i=t-e;if(n){for(;i<0;)i+=W;for(;i>=W;)i-=W}else{for(;i>0;)i-=W;for(;i<=-W;)i+=W}return i}function Ao(e){return e.end}function ze(e){if(e.version!==1||e.closed!==!0||!$(e.start)||!Array.isArray(e.segments)||e.segments.length<2||e.segments.length>512)return!1;let t=e.start;for(let n of e.segments){if(!n||!$(n.end))return!1;if(n.kind==="line"){if(T(t,n.end)<=1e-9)return!1}else if(n.kind==="bezier"){if(!$(n.control1)||!$(n.control2)||T(t,n.end)<=1e-9)return!1}else if(n.kind==="arc"){if(!$(n.center)||!Number.isFinite(n.radius)||n.radius<=1e-6||Math.abs(T(t,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||Math.abs(T(n.end,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||T(t,n.end)<=1e-9)return!1}else return!1;t=n.end}return T(t,e.start)<=1e-4}function Gt(e,t,n){let i=1-n;return{x:i**3*e.x+3*i**2*n*t.control1.x+3*i*n**2*t.control2.x+n**3*t.end.x,y:i**3*e.y+3*i**2*n*t.control1.y+3*i*n**2*t.control2.y+n**3*t.end.y}}function No(e,t=2){if(!ze(e))throw new Error("Section outline path is invalid");let n=Math.max(.25,t),i=[{...e.start}],o=e.start;for(let r of e.segments){if(r.kind==="line")i.push({...r.end});else if(r.kind==="arc"){let s=Math.atan2(o.y-r.center.y,o.x-r.center.x),l=Math.atan2(r.end.y-r.center.y,r.end.x-r.center.x),m=Kt(s,l,r.clockwise),a=Math.max(2,Math.ceil(Math.abs(m)*r.radius/n));for(let c=1;c<=a;c+=1){let u=s+m*c/a;i.push({x:r.center.x+Math.cos(u)*r.radius,y:r.center.y+Math.sin(u)*r.radius})}}else{let s=T(o,r.control1)+T(r.control1,r.control2)+T(r.control2,r.end),l=Math.max(2,Math.ceil(s/n));for(let m=1;m<=l;m+=1)i.push(Gt(o,r,m/l))}o=r.end}return T(i[i.length-1],i[0])<=1e-4&&i.pop(),i}function We(e,t,n){return Xt(e,o=>({x:o.x+t,y:o.y+n}))}function Xt(e,t,n=1,i=!1){return{...e,start:t(e.start),segments:e.segments.map(o=>o.kind==="line"?{...o,end:t(o.end)}:o.kind==="arc"?{...o,center:t(o.center),radius:o.radius*Math.abs(n),clockwise:i?!o.clockwise:o.clockwise,end:t(o.end)}:{...o,control1:t(o.control1),control2:t(o.control2),end:t(o.end)})}}var Bt=45,me=150,Yt=60;function zt(e){let t=Bt/100;if(e<=t)return me;let n=Math.min(1,(e-t)/(1-t));return me-n*(me-Yt)}var Be=.5523;function Ye(e,t){return Math.abs(e.x-t.x)<=1e-6&&Math.abs(e.y-t.y)<=1e-6}function Wt(e){let t=[],n=[];for(e.forEach((i,o)=>{$(i)&&(t.length&&Ye(t[t.length-1],i)||(t.push({x:i.x,y:i.y}),n.push(o)))});t.length>1&&Ye(t[0],t[t.length-1]);)t.pop(),n.pop();return{points:t,sourceIndex:n}}function jo(e,t,n){return Jt(e,{cornerSmoothing:t,...n})}var $t=.5,qt=4/3;function Qt(e,t,n){let i=t.x-e.x,o=t.y-e.y,r=Math.hypot(i,o);if(r<=1e-9)return{kind:"line",end:{...t}};let s=-o/r,l=i/r,m=n*qt;return{kind:"bezier",control1:{x:e.x+i/3+s*m,y:e.y+o/3+l*m},control2:{x:e.x+i*2/3+s*m,y:e.y+o*2/3+l*m},end:{...t}}}function Jt(e,t){let{points:n,sourceIndex:i}=Wt(e),o=n.length;if(o<3)return null;let r=Math.min(100,Math.max(0,t.cornerSmoothing??0))/100,s=t.edgeCurvature,l=new Array(o).fill(0);if(s?.length)for(let x=0;x<o;x+=1){let M=s[i[x]];l[x]=Number.isFinite(M)?Math.min(100,Math.max(-100,M))/100:0}let m=l.some(x=>Math.abs(x)>1e-6);if(r<=0&&!m)return null;let a=t.wideAngleThresholdDeg??zt(r),c=[];for(let x=0;x<o;x+=1)c[x]=T(n[x],n[(x+1)%o]);let u=new Array(o).fill(0);for(let x=0;x<o;x+=1){let M=n[(x-1+o)%o],p=n[x],y=n[(x+1)%o],v={x:M.x-p.x,y:M.y-p.y},S={x:y.x-p.x,y:y.y-p.y},C=Math.hypot(v.x,v.y),O=Math.hypot(S.x,S.y);if(C<=1e-9||O<=1e-9)continue;let I=Math.min(1,Math.max(-1,(v.x*S.x+v.y*S.y)/(C*O))),_=Math.acos(I)*180/Math.PI;if(_<a)continue;let k=Xe((_-a)/(180-a));u[x]=r*k*.5*Math.min(C,O)}for(let x=0;x<o;x+=1){let M=(x+1)%o,p=u[x]+u[M];if(p>c[x]&&p>1e-9){let y=c[x]/p;u[x]*=y,u[M]*=y}}let h=new Array(o),d=new Array(o);for(let x=0;x<o;x+=1){let M=n[(x-1+o)%o],p=n[x],y=n[(x+1)%o];if(u[x]<=1e-6){h[x]={...p},d[x]={...p};continue}let v=T(p,M)||1,S=T(p,y)||1;h[x]={x:p.x+(M.x-p.x)/v*u[x],y:p.y+(M.y-p.y)/v*u[x]},d[x]={x:p.x+(y.x-p.x)/S*u[x],y:p.y+(y.y-p.y)/S*u[x]}}if(u.every(x=>x<=1e-6)&&!m)return null;let b=[],f={...d[0]},g=f,w=(x,M)=>{if(T(g,x)<=1e-9)return;let p=l[M];Math.abs(p)>1e-6?b.push(Qt(g,x,p*$t*c[M])):b.push({kind:"line",end:{...x}}),g=x};for(let x=1;x<=o;x+=1){let M=x%o,p=n[M];w(h[M],(x-1)%o),u[M]>1e-6&&T(h[M],d[M])>1e-9&&(b.push({kind:"bezier",control1:L(h[M],p,Be),control2:L(d[M],p,Be),end:{...d[M]}}),g=d[M])}if(!b.length)return null;let E=b[b.length-1];T(E.end,f)>1e-9&&(E.kind==="line"?E.end={...f}:b.push({kind:"line",end:{...f}}));let P={version:1,closed:!0,start:f,segments:b};return ze(P)?P:null}function Lo(e){let t=[],n=e.start;for(let o of e.segments)t.push(n),n=o.end;let i=[];for(let o=e.segments.length-1;o>=0;o-=1){let r=e.segments[o],s=t[o];r.kind==="line"?i.push({kind:"line",end:{...s}}):r.kind==="arc"?i.push({kind:"arc",center:{...r.center},radius:r.radius,clockwise:!r.clockwise,end:{...s}}):i.push({kind:"bezier",control1:{...r.control2},control2:{...r.control1},end:{...s}})}return{version:1,closed:!0,start:{...e.start},segments:i}}function Do(e,t,n){let i=[];for(let o=0;o<e.length-1;o+=1){let r=e[o],s=e[o+1],l=Math.hypot(s.x-r.x,s.y-r.y);if(l<=0)continue;let m=Math.max(1,Math.round(l/n)),a=l/m,c=Math.atan2(s.y-r.y,s.x-r.x),u=o===0,d=(o>0?t[o-1]:void 0)==="break"?2:1,b=u?{...r}:{x:r.x+Math.cos(c)*a*d,y:r.y+Math.sin(c)*a*d},f=u?m+1:Math.max(1,m-(d-1));i.push({origin:b,rotation:c*180/Math.PI,seatCount:f,seatSpacing:a})}return i}function Vo(e){let t=e.rotation*Math.PI/180,n={x:Math.cos(t),y:Math.sin(t)};return Array.from({length:e.seatCount},(i,o)=>({x:e.origin.x+n.x*o*e.seatSpacing,y:e.origin.y+n.y*o*e.seatSpacing}))}function Ho(e){return e.reduce((t,n)=>t+n.seatCount,0)}function $e(e){let t=new Map,n=new Map;for(let i of e){if(i.type!=="row"||!i.segmentedRow)continue;let o=n.get(i.segmentedRow.groupId)??[];o.push(i),n.set(i.segmentedRow.groupId,o)}for(let[i,o]of n){let r=o.slice().sort((h,d)=>h.segmentedRow.componentIndex-d.segmentedRow.componentIndex),s=r[0]?.segmentedRow?.componentCount??0,l=r[0]?.segmentedRow;if(!l||!(s>=2&&r.length===s&&l?.boundaryBefore==="start"&&r.every((h,d)=>h.segmentedRow?.kind==="segmented-row-v1"&&h.segmentedRow.groupId===i&&h.segmentedRow.componentCount===s&&h.segmentedRow.componentIndex===d&&h.segmentedRow.repeatLabelOnComponents===l.repeatLabelOnComponents&&(d===0?h.segmentedRow.boundaryBefore==="start":h.segmentedRow.boundaryBefore!=="start")&&h.segmentedRow.displayLabel===l.displayLabel)))continue;let a=r.reduce((h,d)=>h+d.seatCount,0),c=0,u=0;for(let h of r)h.segmentedRow.boundaryBefore==="break"&&(c+=1),t.set(h.id,{groupId:i,adjacencyOffset:c,displayOffset:u,displayLabel:l.displayLabel,totalSeats:a,canonical:r[0],viewFromSeatUrl:l.viewFromSeatUrl,viewFromSeatMeta:l.viewFromSeatMeta,confidenceEvidence:l.confidenceEvidence}),c+=h.seatCount,u+=h.seatCount}return t}var q=.02291666666666667,Ko=1/q,Zt=58,en=Zt*q,qe=0,Je=3,Qe=0,pe=120,tn=0,nn=45,on=7,Q=1.2;function be(e,t,n,i){return Number.isFinite(e)?Math.max(t,Math.min(n,e)):i}function Go(e){return Number.isFinite(e)?Math.max(qe,Math.min(Je,Math.round(e))):qe}function rn(e){return!Number.isFinite(e)||!Number.isInteger(e)||e<0?0:e<=on?e:Je}function Ze(e,t={}){let n=be(t.floorBaseHeightM,Qe,pe,0),i=Math.min(pe,n+rn(e.elevation)*en),o=e.height===void 0?i:be(e.height,Qe,pe,i),r=be(e.rake,tn,nn,0);return{height:o,rake:r}}function et(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 tt(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 i=1/0;for(let o=0;o+1<e.length;o++){let r=e[o],s=e[o+1],l=s.x-r.x,m=s.y-r.y,a=l*l+m*m,c=a>1e-12?((t-r.x)*l+(n-r.y)*m)/a:0;c<0?c=0:c>1&&(c=1);let u=t-(r.x+c*l),h=n-(r.y+c*m);if(Math.abs(u)>=i||Math.abs(h)>=i)continue;let d=Math.hypot(u,h);d<i&&(i=d)}return i}function sn(e){let t=0,n=0;for(let r of e)t+=r.x,n+=r.y;let i=e.length||1;t/=i,n/=i;let o=0;for(let r of e){let s=Math.hypot(r.x-t,r.y-n);s>o&&(o=s)}return{cx:t,cy:n,r:o}}function nt(e,t){return Math.hypot(e.cx-t.cx,e.cy-t.cy)-e.r-t.r}function ye(e,t){let n=1/0;for(let i of et(e)){let o=tt(t,i.x,i.y);o<n&&(n=o)}for(let i of et(t)){let o=tt(e,i.x,i.y);o<n&&(n=o)}return n}function an(e,t){if(e.length<3)return{pts:e,seatIndices:t};let n=0,i=0;for(let c of e)n+=c.x,i+=c.y;n/=e.length,i/=e.length;let o=-1,r=e[0];for(let c of e){let u=Math.hypot(c.x-n,c.y-i);u>o&&(o=u,r=c)}let s=r.x-n,l=r.y-i,m=Math.hypot(s,l);m>1e-9?(s/=m,l/=m):(s=1,l=0);let a=e.map((c,u)=>({p:c,i:u,t:(c.x-n)*s+(c.y-i)*l})).sort((c,u)=>c.t-u.t);return{pts:a.map(c=>c.p),seatIndices:a.map(c=>t[c.i])}}function cn(e){let t=e.length;if(t<3)return null;let n=0,i=0;for(let E of e)n+=E.x,i+=E.y;n/=t,i/=t;let o=0,r=0,s=0,l=0,m=0,a=0,c=0;for(let E of e){let P=E.x-n,x=E.y-i;o+=P*P,s+=x*x,r+=P*x,l+=P*P*P,m+=x*x*x,a+=P*x*x,c+=x*P*P}let u=o*s-r*r;if(Math.abs(u)<1e-9)return null;let h=(l+a)/2,d=(m+c)/2,b=(h*s-d*r)/u,f=(d*o-h*r)/u,g=b+n,w=f+i;return!Number.isFinite(g)||!Number.isFinite(w)?null:{cx:g,cy:w}}var ln=.15;function un(e){if(e.length<2)return null;let t=e.map(M=>{let p=0,y=0;for(let v of M.pts)p+=v.x,y+=v.y;return{x:p/M.pts.length,y:y/M.pts.length}}),n=0,i=0;for(let M of t)n+=M.x,i+=M.y;n/=t.length,i/=t.length;let o=0,r=0,s=0;for(let M of t){let p=M.x-n,y=M.y-i;o+=p*p,r+=p*y,s+=y*y}let l=o+s,m=o*s-r*r,a=l/2+Math.sqrt(Math.max(0,l*l/4-m)),c,u;Math.abs(r)>1e-12?(c=a-s,u=r):o>=s?(c=1,u=0):(c=0,u=1);let h=Math.hypot(c,u);if(!(h>1e-12))return null;c/=h,u/=h;let d=0,b=0,f=0;for(let M of e){if(M.pts.length<2)continue;let p=M.pts[0],y=M.pts[M.pts.length-1],v=y.x-p.x,S=y.y-p.y,C=Math.hypot(v,S);if(!(C>1e-9))continue;let O=v/C,I=S/C;d+=(O*O-I*I)*C,b+=2*O*I*C,f+=C}if(f>0&&Math.hypot(d,b)>=fn*f){let M=Math.atan2(b,d)/2,p=Math.cos(M),y=Math.sin(M);Math.abs(c*p+u*y)>hn&&(c=-y,u=p)}let g=1/0,w=-1/0,E=[];for(let M of e){let p=1/0,y=-1/0;for(let v of M.pts){let S=v.x*c+v.y*u;S<p&&(p=S),S>y&&(y=S),S<g&&(g=S),S>w&&(w=S)}E.push(y-p)}let P=w-g;return P>1e-9?(E.sort((M,p)=>M-p),E[Math.min(E.length-1,Math.floor(E.length*.9))]/P<=dn?{x:c,y:u}:null):null}var dn=.35,fn=.8,hn=.7;function ot(e,t,n,i){let o=new Map;for(let p of n){let y=t[p],v=y.rowId||`__seat-${p}`,S=o.get(v);S||(S={pts:[],idx:[]},o.set(v,S)),S.pts.push({x:y.x,y:y.y}),S.idx.push(p)}if(!o.size)return{sectionId:e,rows:[],blockCount:0};let r=[];for(let[p,y]of o){let v=an(y.pts,y.idx),S=0;for(let C of v.pts)S+=Math.hypot(C.x-i.x,C.y-i.y);r.push({id:p,pts:v.pts,seatIndices:v.seatIndices,blockId:-1,ordinal:0,blockDepth:0,focalDistance:S/v.pts.length})}let s=r.map(p=>sn(p.pts)),l=r.length<=256?r.length*(r.length-1)/2:0,m=l?new Float64Array(l):null;m?.fill(Number.NaN);let a=m?new Map(r.map((p,y)=>[p,y])):null,c=(p,y)=>(p>y&&([p,y]=[y,p]),p*(2*r.length-p-1)/2+(y-p-1)),u=(p,y)=>{if(!m)return ye(r[p].pts,r[y].pts);let v=c(p,y),S=m[v];if(!Number.isNaN(S))return S;let C=ye(r[p].pts,r[y].pts);return m[v]=C,C},h=(p,y)=>a?u(a.get(p),a.get(y)):ye(p.pts,y.pts),d=[];for(let p=0;p<r.length;p++){let y=1/0;for(let v=0;v<r.length;v++){if(p===v||nt(s[p],s[v])>=y)continue;let S=u(p,v);S<y&&(y=S)}Number.isFinite(y)&&d.push(y)}d.sort((p,y)=>p-y);let b=d.length?d[Math.floor(d.length/2)]:1,f=Math.max(b*1.8,1e-6),g=r.map(()=>[]);for(let p=0;p<r.length;p++)for(let y=p+1;y<r.length;y++)nt(s[p],s[y])>f||u(p,y)<=f&&(g[p].push(y),g[y].push(p));let w=0;for(let p=0;p<r.length;p++){if(r[p].blockId!==-1)continue;let y=w++,v=[p];for(r[p].blockId=y;v.length;){let S=v.pop();for(let C of g[S])r[C].blockId===-1&&(r[C].blockId=y,v.push(C))}}let E=new Map;for(let p of r){let y=E.get(p.blockId)??[];y.push(p),E.set(p.blockId,y)}let P=[];for(let p of r){if(p.pts.length<4)continue;let y=cn(p.pts);y&&(!Number.isFinite(y.cx)||!Number.isFinite(y.cy)||P.push({x:y.cx,y:y.cy}))}let x=P.length>=2?(()=>{let p=P.map(S=>S.x).sort((S,C)=>S-C),y=P.map(S=>S.y).sort((S,C)=>S-C),v=Math.floor(P.length/2);return{cx:p[v],cy:y[v]}})():null;if(x){let p=I=>Math.hypot(I.x-x.cx,I.y-x.cy),y=1/0,v=-1/0,S=[];for(let I of r){let _=1/0,k=-1/0;for(let N of I.pts){let A=p(N);A<_&&(_=A),A>k&&(k=A)}S.push(k-_),_<y&&(y=_),k>v&&(v=k)}let C=v-y;S.sort((I,_)=>I-_);let O=S[Math.min(S.length-1,Math.floor(S.length*.9))];if(C>1e-9&&O/C<=ln){let I=r.map(R=>{let ne=0;for(let xt of R.pts)ne+=p(xt);return{row:R,radius:ne/R.pts.length}}),_=0,k=0;for(let R of I)_+=R.radius,k+=R.row.focalDistance;_/=I.length,k/=I.length;let N=0;for(let R of I)N+=(R.radius-_)*(R.row.focalDistance-k);if(N<0)for(let R of I)R.radius=-R.radius;let j=1/0;for(let R of I)R.radius<j&&(j=R.radius);I.sort((R,ne)=>R.radius-ne.radius);let V=-1,B=-1/0,gt=C/Math.max(1,I.length)*.5,Ee=[];for(let R of I)R.radius-B>gt&&(V++,B=R.radius),R.row.ordinal=V,R.row.blockDepth=R.radius-j,Ee.push(R.row);return{sectionId:e,rows:Ee,blockCount:w}}}let M=[];for(let[,p]of E){let y=un(p);if(y){let v=I=>{let _=0;for(let k of I.pts)_+=k.x*y.x+k.y*y.y;return _/I.pts.length};p.sort((I,_)=>v(I)-v(_)),p.length>=2&&p[0].focalDistance>p[p.length-1].focalDistance&&p.reverse();let S=[],C=b*.5;for(let I of p){let _=S[S.length-1];_&&Math.abs(v(I)-v(_[0]))<C?_.push(I):S.push([I])}let O=0;for(let I=0;I<S.length;I++){if(I>0){let _=1/0;for(let k of S[I-1])for(let N of S[I])_=Math.min(_,h(k,N));O+=_}for(let _ of S[I])_.ordinal=I,_.blockDepth=O,M.push(_)}}else{let v=1/0;for(let S of p)S.focalDistance<v&&(v=S.focalDistance);p.sort((S,C)=>S.focalDistance-C.focalDistance);for(let S=0;S<p.length;S++)p[S].ordinal=S,p[S].blockDepth=Math.max(0,p[S].focalDistance-v),M.push(p[S])}}return{sectionId:e,rows:M,blockCount:w}}var Yo=[{key:"rect",label:"Flat stage",blurb:"Classic proscenium box."},{key:"rounded",label:"Rounded",blurb:"Softened corners."},{key:"arc",label:"Curved front",blurb:"Front edge bows toward the audience."},{key:"thrust",label:"Thrust (T)",blurb:"Central tongue projects into the crowd."},{key:"runway",label:"Runway",blurb:"Long catwalk into the audience."},{key:"round",label:"In the round",blurb:"Central platform, audience all around."},{key:"pitch-football",label:"Football pitch",blurb:"105 \xD7 68 m pitch with centre circle and penalty boxes."},{key:"rink-hockey",label:"Hockey rink",blurb:"60 \xD7 30 m ice rink with blue lines and faceoff circles."},{key:"track-athletics",label:"Athletics track",blurb:"400 m track: two straights, two semicircles, eight lanes."},{key:"oval-cricket",label:"Cricket oval",blurb:"~150 \xD7 140 m oval with boundary rope and pitch strip."},{key:"pitch-rugby",label:"Rugby pitch",blurb:"100 \xD7 70 m field of play with in-goal areas, 22 m and 10 m lines."},{key:"diamond-baseball",label:"Baseball field",blurb:"Diamond, infield, mound and foul lines out to 99 m poles."},{key:"court-basketball",label:"Basketball court",blurb:"28 \xD7 15 m court with keys and three-point lines."},{key:"court-tennis",label:"Tennis court",blurb:"23.77 \xD7 10.97 m doubles court with run-off and net."},{key:"ring-boxing",label:"Boxing ring",blurb:"Raised ring, 6.1 m inside the ropes, coloured corners."}],mn=new Set(["pitch-football","rink-hockey","track-athletics","oval-cricket","pitch-rugby","diamond-baseball","court-basketball","court-tennis","ring-boxing"]),pn=new Set(["pitch-football","track-athletics","oval-cricket","pitch-rugby","diamond-baseball"]);function bn(e){return!!e&&mn.has(e)}function zo(e){return!!e&&pn.has(e)}var it=1.1,yn={"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}},gn={"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 rt=Math.PI*2;function st(e,t,n,i,o,r){return{x:o+e*n-t*i,y:r+e*i+t*n}}function Wo(e){let{kind:t,cx:n,cy:i,width:o,height:r}=e,s=(e.rotation??0)*Math.PI/180,l=Math.cos(s),m=Math.sin(s),a=o/2,c=r/2,u=[],h=(d,b)=>{u.push({x:d,y:b})};switch(t){case"rect":{h(-a,-c),h(a,-c),h(a,c),h(-a,c);break}case"rounded":{let d=Math.min(o,r)*.18,b=5,f=(g,w,E)=>{for(let P=0;P<=b;P++){let x=E+P/b*(Math.PI/2);h(g+d*Math.cos(x),w+d*Math.sin(x))}};f(a-d,-c+d,-Math.PI/2),f(a-d,c-d,0),f(-a+d,c-d,Math.PI/2),f(-a+d,-c+d,Math.PI);break}case"arc":{let d=r*.45;h(-a,-c),h(a,-c);let b=24;for(let f=0;f<=b;f++){let g=f/b,w=a-g*o,E=c+d*(1-Math.pow(2*w/o,2));h(w,E)}break}case"thrust":{let d=o*.18,b=r*1.1;h(-a,-c),h(a,-c),h(a,c),h(d,c),h(d,c+b),h(-d,c+b),h(-d,c),h(-a,c);break}case"runway":{let d=o*.1,b=r*3;h(-a,-c),h(a,-c),h(a,c),h(d,c),h(d,c+b),h(-d,c+b),h(-d,c),h(-a,c);break}case"round":case"oval-cricket":{for(let b=0;b<40;b++){let f=b/40*rt;h(a*Math.cos(f),c*Math.sin(f))}break}case"pitch-football":case"pitch-rugby":case"court-basketball":case"court-tennis":case"ring-boxing":{h(-a,-c),h(a,-c),h(a,c),h(-a,c);break}case"diamond-baseball":{for(let d of Mn(a,c))h(d.x,d.y);break}case"rink-hockey":{for(let d of xn(a,c,a*(8.5/60),c*(8.5/30)))h(d.x,d.y);break}case"track-athletics":{for(let d of ge(a,c))h(d.x,d.y);break}}return u.map(d=>st(d.x,d.y,l,m,n,i))}function xn(e,t,n,i){let o=[],s=(l,m,a)=>{for(let c=0;c<=8;c++){let u=a+c/8*(Math.PI/2);o.push({x:l+n*Math.cos(u),y:m+i*Math.sin(u)})}};return s(e-n,-t+i,-Math.PI/2),s(e-n,t-i,0),s(-e+n,t-i,Math.PI/2),s(-e+n,-t+i,Math.PI),o}function ge(e,t){let n=Math.max(0,e-t),i=[],o=20;for(let r=0;r<=o;r++){let s=-Math.PI/2+r/o*Math.PI;i.push({x:n+t*Math.cos(s),y:t*Math.sin(s)})}for(let r=0;r<=o;r++){let s=Math.PI/2+r/o*Math.PI;i.push({x:-n+t*Math.cos(s),y:t*Math.sin(s)})}return i}var X=(()=>{let t={x:0,y:52},n=25,i={x:70,y:t.y-70},o=(i.x*i.x+i.y*i.y-4900)/(2*(i.y+70)),r=o+70,s=[],l=Math.atan2(i.y-o,i.x),m=Math.atan2(i.y-o,-i.x);for(let a=0;a<=24;a++){let c=l+(m-l)*a/24;s.push({x:r*Math.cos(c),y:o+r*Math.sin(c)})}return{half:70,home:t,backstop:n,fence:s}})();function Mn(e,t){let n=e/X.half,i=t/X.half;return[{x:-X.backstop*n,y:t},{x:X.backstop*n,y:t},...X.fence.map(o=>({x:o.x*n,y:o.y*i}))]}var Sn="#f1f5f9";function xe(e){return bn(e)}function G(e,t,n,i,o=32){let r=[];for(let s=0;s<o;s++){let l=s/o*rt;r.push({x:e+n*Math.cos(l),y:t+i*Math.sin(l)})}return r}function U(e,t,n,i){return[{x:e-n,y:t-i},{x:e+n,y:t-i},{x:e+n,y:t+i},{x:e-n,y:t+i}]}function vn(e){let{kind:t,cx:n,cy:i,width:o,height:r}=e,s=(e.rotation??0)*Math.PI/180,l=Math.cos(s),m=Math.sin(s),a=o/2,c=r/2,u=[],h=yn[t],d=f=>h?f/h.width*o:0,b=f=>h?f/h.height*r:0;switch(t){case"pitch-football":{u.push({points:[{x:0,y:-c},{x:0,y:c}],closed:!1}),u.push({points:G(0,0,d(9.15),b(9.15)),closed:!0});for(let f of[-1,1])u.push({points:U(f*(a-d(16.5)/2),0,d(16.5)/2,b(40.32)/2),closed:!0}),u.push({points:U(f*(a-d(5.5)/2),0,d(5.5)/2,b(18.32)/2),closed:!0});break}case"rink-hockey":{u.push({points:[{x:0,y:-c},{x:0,y:c}],closed:!1,ink:"#d63b3b"});for(let f of[-1,1]){u.push({points:[{x:f*d(7.5),y:-c},{x:f*d(7.5),y:c}],closed:!1,ink:"#2f6ecb"}),u.push({points:[{x:f*(a-d(4)),y:-b(11)},{x:f*(a-d(4)),y:b(11)}],closed:!1,ink:"#d63b3b"});for(let g of[-1,1])u.push({points:G(f*d(20.5),g*b(7),d(4.5),b(4.5)),closed:!0,ink:"#2f6ecb"})}u.push({points:G(0,0,d(4.5),b(4.5)),closed:!0,ink:"#2f6ecb"});break}case"track-athletics":{let g=c-b(1.22)*8;g>0&&u.push({points:ge(a-d(1.22)*8,g),closed:!0,fill:"#2f7d4f"});for(let w=1;w<8;w++){let E=b(1.22)*w,P=c-E;if(P<=0)break;u.push({points:ge(a-d(1.22)*w,P),closed:!0})}break}case"oval-cricket":{u.push({points:G(0,0,d(27.4),b(27.4+20.12/2),40),closed:!0}),u.push({points:U(0,0,d(3.05)/2,b(20.12)/2),closed:!0,ink:"#d8cfae"});break}case"pitch-rugby":{let f=g=>({points:[{x:d(g),y:-c},{x:d(g),y:c}],closed:!1});u.push(f(0));for(let g of[-1,1]){u.push(f(g*50),f(g*28));for(let w=-35;w<35;w+=4)u.push({points:[{x:d(g*10),y:b(w)},{x:d(g*10),y:b(Math.min(35,w+2))}],closed:!1})}break}case"diamond-baseball":{let f=(A,j)=>({x:d(A),y:b(j)}),{home:g}=X,w=27.43,E=w/Math.SQRT2,P={x:g.x+E,y:g.y-E},x={x:g.x,y:g.y-2*E},M={x:g.x-E,y:g.y-E},p={x:g.x,y:g.y-18.44},y="#b98a59",v=gn["diamond-baseball"],S=38.94,C=[f(g.x,g.y)],O=Math.atan2(g.y-S/Math.SQRT2-p.y,S/Math.SQRT2),I=Math.PI-O;for(let A=0;A<=16;A++){let j=O-(O+Math.PI*2-I)%(Math.PI*2)*(A/16);C.push(f(p.x+29*Math.cos(j),p.y+29*Math.sin(j)))}u.push({points:C,closed:!0,fill:y,ink:y});let _={x:g.x,y:g.y-E},k=[{x:g.x,y:g.y},P,x,M].map(A=>f(_.x+(A.x-_.x)*.84,_.y+(A.y-_.y)*.84));u.push({points:k,closed:!0,fill:v,ink:v}),u.push({points:G(d(p.x),b(p.y),d(2.74),b(2.74),20),closed:!0,fill:y,ink:y}),u.push({points:G(d(g.x),b(g.y),d(3.96),b(3.96),20),closed:!0,fill:y,ink:y});let N=X.fence;u.push({points:[f(g.x,g.y),f(N[0].x,N[0].y)],closed:!1}),u.push({points:[f(g.x,g.y),f(N[N.length-1].x,N[N.length-1].y)],closed:!1});for(let A of[P,x,M])u.push({points:U(d(A.x),b(A.y),d(.3),b(.3)),closed:!0,fill:Sn});break}case"court-basketball":{u.push({points:U(0,0,d(14),b(7.5)),closed:!0}),u.push({points:[{x:0,y:-b(7.5)},{x:0,y:b(7.5)}],closed:!1}),u.push({points:G(0,0,d(1.8),b(1.8),24),closed:!0});for(let f of[-1,1]){let g=f*14,w=f*(14-5.8),E=f*(14-1.575);u.push({points:U(d((g+w)/2),0,d(2.9),b(2.45)),closed:!0,fill:"#2f5d8a"}),u.push({points:G(d(w),0,d(1.8),b(1.8),24),closed:!0});let P=Math.sqrt(6.75*6.75-6.6*6.6),x=[{x:d(g),y:-b(6.6)}],M=Math.atan2(-6.6,-f*P),p=2*Math.atan2(6.6,P);for(let y=0;y<=16;y++){let v=M-f*p*(y/16);x.push({x:d(E+6.75*Math.cos(v)),y:b(6.75*Math.sin(v))})}x.push({x:d(g),y:b(6.6)}),u.push({points:x,closed:!1})}break}case"court-tennis":{u.push({points:U(0,0,d(11.885),b(5.485)),closed:!0,fill:"#2b5f99"});for(let f of[-1,1])u.push({points:[{x:-d(11.885),y:f*b(4.115)},{x:d(11.885),y:f*b(4.115)}],closed:!1}),u.push({points:[{x:f*d(6.4),y:-b(4.115)},{x:f*d(6.4),y:b(4.115)}],closed:!1});u.push({points:[{x:-d(6.4),y:0},{x:d(6.4),y:0}],closed:!1}),u.push({points:[{x:0,y:-b(6.4)},{x:0,y:b(6.4)}],closed:!1,ink:"#d1d5db"});break}case"ring-boxing":{u.push({points:U(0,0,d(3.05),b(3.05)),closed:!0});let w=[[-1,-1,"#c53030"],[1,1,"#2b6cb0"],[1,-1,"#e2e8f0"],[-1,1,"#e2e8f0"]];for(let[E,P,x]of w)u.push({points:U(E*d(3.05),P*b(3.05),d(.3),b(.3)),closed:!0,fill:x,ink:x});break}default:return[]}return u.map(f=>({...f,points:f.points.map(g=>st(g.x,g.y,l,m,n,i))}))}function $o(e){if(e.role!=="stage"||!xe(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(c=>c.x),i=e.points.map(c=>c.y),o=Math.min(...n),r=Math.max(...n),s=Math.min(...i),l=Math.max(...i),m=Math.max(1,r-o),a=Math.max(1,l-s);t={cx:o+m/2,cy:s+a/2,width:m,height:a}}return t?vn({kind:e.stageKind,...t}):[]}function wn(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,i=e.width,o=e.height;return[{x:t,y:n},{x:t+i,y:n},{x:t+i,y:n+o},{x:t,y:n+o}]}function En(e,t,n){let i=n*Math.PI/180,o=Math.cos(i),r=Math.sin(i),s=e.x-t.x,l=e.y-t.y;return{x:t.x+s*o-l*r,y:t.y+s*r+l*o}}function at(e){let t=wn(e);if(!t||t.length<2)return null;let n=e.rotation??0,i=Math.abs(n)<1e-6?t:t.map(m=>En(m,{x:t.reduce((a,c)=>a+c.x,0)/t.length,y:t.reduce((a,c)=>a+c.y,0)/t.length},n)),o=1/0,r=1/0,s=-1/0,l=-1/0;for(let m of i)o=Math.min(o,m.x),r=Math.min(r,m.y),s=Math.max(s,m.x),l=Math.max(l,m.y);return!Number.isFinite(o)||s-o<1e-6||l-r<1e-6?null:{minX:o,minY:r,maxX:s,maxY:l}}var In=5,Pn=3,Cn=.92,_n=1.9,kn=2,Rn=.6,Tn=1,On=.06;function An(e){return e.heightM!==void 0?e.heightM:e.stageKind==="ring-boxing"?it:xe(e.stageKind)?On:Tn}function ct(e){let t=1/0,n=1/0,i=-1/0,o=-1/0,r=-1/0;for(let s of Me(e)){let l=s.baseHeightM??0;for(let m of s.objects){if(m.type!=="shape"||m.role!=="stage")continue;let a=at(m);a&&(t=Math.min(t,a.minX),n=Math.min(n,a.minY),i=Math.max(i,a.maxX),o=Math.max(o,a.maxY),r=Math.max(r,l+An(m)))}}return!Number.isFinite(t)||!Number.isFinite(r)?null:{minX:t,minY:n,maxX:i,maxY:o,deckTopM:r}}function Nn(e,t,n,i){let o=1/0,r=1/0,s=-1/0,l=-1/0;for(let d of e)Number.isFinite(d.eyeHeightM)&&(o=Math.min(o,d.x),s=Math.max(s,d.x),r=Math.min(r,d.y),l=Math.max(l,d.y));if(!Number.isFinite(o))return null;let m=o*t,a=r*t,c=Math.max(1,Math.ceil((s-o)*t/n)+1),u=Math.max(1,Math.ceil((l-r)*t/n)+1),h=new Float64Array(c*u).fill(-1/0);for(let d of e){if(!Number.isFinite(d.eyeHeightM))continue;let b=d.eyeHeightM-Q,f=Math.min(c-1,Math.max(0,Math.floor((d.x*t-m)/n))),w=Math.min(u-1,Math.max(0,Math.floor((d.y*t-a)/n)))*c+f,E=b+i;E>h[w]&&(h[w]=E)}return{cellM:n,minX:m,minY:a,cols:c,rows:u,top:h}}function jn(e,t,n){let i=Math.floor((t-e.minX)/e.cellM),o=Math.floor((n-e.minY)/e.cellM);return i<0||o<0||i>=e.cols||o>=e.rows?-1/0:e.top[o*e.cols+i]}function lt(e,t,n={}){let i=new Map;if(!t||!e.length)return i;let o=n.metresPerChartUnit??q,r=n.cellM??Rn,s=n.chairBackM??Cn,l=n.selfRowSkipM??kn,m=n.clearThreshold??.9,a=n.partialThreshold??.25,c=Math.max(1,n.columns??In),u=Math.max(1,n.rows??Pn),h=Nn(e,o,r,s);if(!h)return i;let d=(t.maxX-t.minX)*o,b=(t.maxY-t.minY)*o,f=d>=b,g=(t.minX+t.maxX)/2*o,w=(t.minY+t.maxY)/2*o,E=[];for(let x=0;x<c;x++){let M=(x+.5)/c-.5,p=f?g+M*d:g,y=f?w:w+M*b;for(let v=0;v<u;v++){let S=t.deckTopM+(u===1?0:v/(u-1)*_n);E.push({x:p,y,z:S})}}let P=r/2;for(let x of e){if(!Number.isFinite(x.eyeHeightM))continue;let M=x.x*o,p=x.y*o,y=x.eyeHeightM,v=0,S=1/0;for(let O of E){let I=O.x-M,_=O.y-p,k=Math.hypot(I,_);if(!(k>l)){v++;continue}let N=I/k,A=_/k,j=0;for(let V=l;V<k;V+=P){let B=jn(h,M+N*V,p+A*V);if(!(!Number.isFinite(B)||B>=y)&&B>y+(O.z-y)*V/k){j=V;break}}j?S=Math.min(S,j):v++}let C=v/E.length;C>=m||i.set(x.id,{seatId:x.id,mark:C<a?"obstructedView":"restrictedView",visibleFraction:C,totalRays:E.length,atDistanceM:Number.isFinite(S)?S:0})}return i}function ut(e,t){if(!t.size)return 0;let n=0;for(let i of e){let o=t.get(i.id);if(!o)continue;let r=i.commercial;r?.restrictedView!==void 0||r?.obstructedView!==void 0||(i.commercial={...r,[o.mark]:!0},n++)}return n}function Se(e){return e?e.accessibility?.length?e.wheelchairSpaceType&&!e.accessibility.includes("wheelchair")?["wheelchair",...e.accessibility]:e.accessibility:e.wheelchairSpaceType?["wheelchair"]:e.accessible?["wheelchair"]:[]:[]}var se=Math.PI/180,Ln=9,J=16;function ve(e,t,n,i){let o=n*se,r=Math.cos(o),s=Math.sin(o);return{x:i.x+e*r-t*s,y:i.y+e*s+t*r}}function we(e){let{seatCount:t,seatSpacing:n,curve:i,rotation:o,origin:r}=e,s=[];if(e.path)return Fe(e.path,t);if(t<=1)return t===1&&s.push({x:r.x,y:r.y}),s;if(i===0){for(let a=0;a<t;a++)s.push(ve(a*n,0,o,r));return s}let l=i/(t-1)*se,m=n/(2*Math.sin(Math.abs(l)/2));for(let a=0;a<t;a++){let c=a*l,u=m*Math.sin(c),h=-m+m*Math.cos(c);s.push(ve(u,h,o,r))}return s}function pt(e){let t=new Map;if(e.overrides)for(let n of e.overrides)t.set(n.index,n);return t}function yi(e){let t=new Set((e.overrides??[]).filter(n=>n.skip&&Number.isInteger(n.index)&&n.index>=0&&n.index<e.seatCount).map(n=>n.index));return Math.max(0,e.seatCount-t.size)}function Fn(e,t){let n=pt(e);return we(e).map((i,o)=>{let r=n.get(o),s=Se(r),l=Ie(e,o,r),m={...e.commercial,...r?.commercial};return{index:o,x:i.x+(r?.dx??0),y:i.y+(r?.dy??0),label:l,displayLabel:ce(e,o,t,r),categoryKey:r?.categoryKey??e.categoryKey,skipped:!!r?.skip,accessible:s.length>0,accessibility:s,wheelchairSpaceType:r?.wheelchairSpaceType,commercial:Object.values(m).some(a=>a!==void 0&&a!==!1&&a!=="")?m:void 0,glyph:r?.glyph,viewUrl:r?.viewFromSeatUrl??e.viewFromSeatUrl,viewMeta:r?.viewFromSeatUrl?r.viewFromSeatMeta:e.viewFromSeatMeta,labelStyle:r?.labelStyle??e.seatLabelStyle}})}function Dn(e){let t=[];for(let n of Fn(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 Vn(e){if(e.seatCountsBySide)return{...e.seatCountsBySide};let t=e.sides&&e.sides.length?e.sides:["top","bottom"],n=["top","bottom","left","right"].filter(r=>t.includes(r)),i={top:0,bottom:0,left:0,right:0};if(!n.length)return i;let o=Math.max(0,Math.round(e.seatCount));for(let r=0;r<o;r++)i[n[r%n.length]]+=1;return i}function bt(e){let t=[],n=Math.max(0,Math.round(e.seatCount));if(n===0)return t;let i=new Map((e.overrides??[]).map(c=>[c.index,c])),o=(c,u,h,d)=>{let b=i.get(c),f=Se(b),g=b?.label??`${e.label}-${c+1}`,w=e.displayLabel??e.label;return{index:c,label:g,displayLabel:b?.displayLabel??`${w}-${c+1}`,x:u+(b?.dx??0),y:h+(b?.dy??0),categoryKey:b?.categoryKey??e.categoryKey,skipped:!!b?.skip,accessible:f.length>0,accessibility:f,wheelchairSpaceType:b?.wheelchairSpaceType,commercial:b?.commercial,glyph:b?.glyph,viewUrl:b?.viewFromSeatUrl,viewMeta:b?.viewFromSeatUrl?b.viewFromSeatMeta:void 0,labelStyle:b?.labelStyle,...d?{side:d}:{}}};if(e.shape==="round"){let c=(e.radius??40)+J,u=e.rotation*se,h=Math.max(0,Math.min(360,e.seatArc??360));if(h>=360||n===1){for(let g=0;g<n;g++){let w=u+g/n*2*Math.PI;t.push(o(g,e.center.x+c*Math.cos(w),e.center.y+c*Math.sin(w)))}return t}let d=h*se,b=(2*Math.PI-d)/2,f=u+b;for(let g=0;g<n;g++){let w=f+g/(n-1)*d;t.push(o(g,e.center.x+c*Math.cos(w),e.center.y+c*Math.sin(w)))}return t}let r=e.width??80,s=e.height??50,l=Vn(e),m=["top","bottom","left","right"],a=0;for(let c of m){let u=l[c];for(let h=0;h<u;h++){let d,b;c==="top"?(d=-r/2+(h+.5)*r/u,b=-s/2-J):c==="bottom"?(d=-r/2+(h+.5)*r/u,b=s/2+J):c==="left"?(d=-r/2-J,b=-s/2+(h+.5)*s/u):(d=r/2+J,b=-s/2+(h+.5)*s/u);let f=ve(d,b,e.rotation,e.center);t.push(o(a++,f.x,f.y,c))}}return t}function gi(e){return e.bookAsWhole||e.variableOccupancy?Math.max(0,Math.round(e.seatCount)):bt(e).filter(t=>!t.skipped).length}function Hn(e){return bt(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 Un(e){return[{id:`${e.id}:0`,label:e.label,...e.displayLabel&&e.displayLabel!==e.label?{displayLabel:e.displayLabel}:{},x:e.center.x,y:e.center.y,rowId:e.id,categoryKey:e.categoryKey,kind:"booth"}]}function dt(e,t){let n=!1;for(let i=0,o=t.length-1;i<t.length;o=i++){let r=t[i].x,s=t[i].y,l=t[o].x,m=t[o].y;s>e.y!=m>e.y&&e.x<(l-r)*(e.y-s)/(m-s)+r&&(n=!n)}return n}function Kn(e,t){return t.some((n,i)=>{let o=t[(i+1)%t.length],r=(e.y-n.y)*(o.x-n.x)-(e.x-n.x)*(o.y-n.y);if(Math.abs(r)>1e-7)return!1;let s=(e.x-n.x)*(o.x-n.x)+(e.y-n.y)*(o.y-n.y),l=(o.x-n.x)**2+(o.y-n.y)**2;return s>=-1e-7&&s<=l+1e-7})}function te(e){return Array.isArray(e)?e.filter(t=>Array.isArray(t)&&t.length>=3):[]}function ae(e,t,n){return dt(e,t)&&!te(n).some(i=>dt(e,i)||Kn(e,i))}function xi(e,t){return Ge(e,t).point}function re(e){if(!e.length)return{x:0,y:0};let t=0,n=0;for(let i of e)t+=i.x,n+=i.y;return{x:t/e.length,y:n/e.length}}function yt(e){switch(e.type){case"row":{let t=we(e),n=pt(e),i=0,o=0,r=0;for(let s=0;s<t.length;s++){let l=n.get(s);l?.skip||(i+=t[s].x+(l?.dx??0),o+=t[s].y+(l?.dy??0),r++)}return r?{x:i/r,y:o/r}:{x:e.origin.x,y:e.origin.y}}case"table":case"booth":return{x:e.center.x,y:e.center.y};case"gaArea":return re(e.points);case"section":return re(e.outline);case"text":return{x:e.position.x,y:e.position.y};case"shape":return e.points&&e.points.length?re(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 ft(e,t){return e.length===t.length&&e.every((n,i)=>n.x===t[i].x&&n.y===t[i].y)}function Gn(e,t){if(e.type!=="gaArea"||!ft(e.points,t.outline))return!1;let n=te(e.holes),i=te(t.holes);return n.length===i.length&&n.every((o,r)=>ft(o,i[r]))}function Xn(e,t,n=e.filter(o=>o.type==="section"),i=yt(t)){let o="referenceInventorySource"in t?t.referenceInventorySource?.logicalSectionId:void 0;return(o?n.find(s=>(s.logicalSectionId??s.id)===o&&(Gn(t,s)||ae(i,s.outline,s.holes))):void 0)??n.find(s=>ae(i,s.outline,s.holes))}function Me(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 Mi(e,t){let n=Me(e);return(t?n.find(i=>i.id===t):n[0])?.objects??[]}function Bn(e){return e.floors&&e.floors.length?e.floors.flatMap(t=>t.objects):e.objects}function Yn(e,t,n){let i=r=>({x:r.x+t,y:r.y+n}),o=r=>r.map(i);switch(e.type){case"row":return{...e,origin:i(e.origin)};case"table":case"booth":return{...e,center:i(e.center)};case"gaArea":return{...e,points:o(e.points),...e.holes?{holes:te(e.holes).map(o)}:{}};case"section":return{...e,outline:o(e.outline),...e.outlinePath?{outlinePath:We(e.outlinePath,t,n)}:{},...e.holes?{holes:te(e.holes).map(o)}:{}};case"text":return{...e,position:i(e.position)};case"shape":return{...e,...e.points?{points:o(e.points)}:{},...e.x!=null?{x:e.x+t}:{},...e.y!=null?{y:e.y+n}:{}};case"decorImage":return{...e,x:e.x+t,y:e.y+n}}}function Si(e,t=900){if(!e.floors||e.floors.length<2)return e;let n=[];return e.floors.forEach((i,o)=>{let r=-o*t;for(let s of i.objects)n.push(r===0?s:Yn(s,0,r))}),{...e,objects:n,floors:void 0}}function ht(e,t,n,i,o,r,s,l,m){let a=[],c=e.filter(f=>f.type==="section"),u=$e(e),h=f=>!f?.eventConfigurationId||f.eventConfigurationId===i&&(f.eventConfigurationVersion===void 0||f.eventConfigurationVersion===m),d=f=>Pe(f,{activeConfigurationId:i,activeConfigurationVersion:m,activeBasisSha256:o,now:l}),b=(f,g)=>d(f)?{...f,coverage:g}:void 0;for(let f of e){let g=[];if(f.type==="row"?g=Dn(f):f.type==="table"?g=Hn(f):f.type==="booth"&&(g=Un(f)),!g.length)continue;for(let M of g)M.viewUrl&&!h(M.viewMeta)&&(M.viewUrl=void 0,M.viewMeta=void 0);if(f.type==="row"){let M=u.get(f.id);if(M){let p=new Map((f.overrides??[]).map(y=>[y.index,y]));for(let y of g){let v=Number(y.id.slice(y.id.lastIndexOf(":")+1));if(!Number.isInteger(v))continue;y.logicalRowId=M.groupId,y.logicalSeatIndex=M.adjacencyOffset+v,p.get(v)?.displayLabel||(y.displayLabel=ce(f,v,M)),!y.viewUrl&&M.viewFromSeatUrl&&h(M.viewFromSeatMeta)&&(y.viewUrl=M.viewFromSeatUrl,y.viewMeta=M.viewFromSeatMeta);let S=p.get(v)?.confidenceEvidence;y.confidenceEvidence=b(S,"exact-seat")??b(f.confidenceEvidence,"row-representative")??b(M.confidenceEvidence,"row-representative")}}}let w=Xn(e,f,c,f.type==="row"?re(g):yt(f)),E=w?.viewFromSeatUrl,x=(w?.zone?t?.find(M=>M.id===w.zone):void 0)?.focalPoint??n;for(let M of g){if(!M.confidenceEvidence){let p=Number(M.id.slice(M.id.lastIndexOf(":")+1)),y=(f.type==="row"||f.type==="table")&&Number.isInteger(p)?f.overrides?.find(v=>v.index===p)?.confidenceEvidence:void 0;M.confidenceEvidence=b(y,"exact-seat")??(f.type==="row"?b(f.confidenceEvidence,"row-representative"):void 0)}M.confidenceEvidence??=b(w?.confidenceEvidence,"section-representative")??(s?b(s.evidence,s.coverage):void 0),!M.viewUrl&&E&&h(w?.viewFromSeatMeta)&&(M.viewUrl=E,M.viewMeta=w?.viewFromSeatMeta),!M.viewUrl&&r&&h(r.meta)&&(M.viewUrl=r.url,M.viewMeta=r.meta),w&&(M.sectionId=w.logicalSectionId??w.id),w?.zone&&(M.zoneId=w.zone),x&&(M.focalPoint={...x})}a.push(...g)}return a}function vi(e,t={}){if(e.floors?.length){let i=[];for(let o of e.floors){let r=o.focalPoint??e.focalPoint,s=o.viewFromSeatUrl?{url:o.viewFromSeatUrl,meta:o.viewFromSeatMeta}:e.viewFromSeatUrl?{url:e.viewFromSeatUrl,meta:e.viewFromSeatMeta}:void 0,l=o.confidenceEvidence?{evidence:o.confidenceEvidence,coverage:"floor-representative"}:e.confidenceEvidence?{evidence:e.confidenceEvidence,coverage:"venue-representative"}:void 0,m=ht(o.objects,e.zones,r,e.eventConfigurationId,e.confidenceBasisSha256,s,l,t.now,t.eventConfigurationVersion??e.eventConfigurationVersion);t.resolveEyeHeights!==!1&&mt(o.objects,o.focalPoint??e.focalPoint,o.baseHeightM??0,m);for(let a of m)a.floorId=o.id;for(let a of m)i.push(a)}return i}let n=ht(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&&mt(e.objects,e.focalPoint,t.floorBaseHeightM??0,n),zn(e,n,t)}function zn(e,t,n){return!n.deriveRestrictedView||e.derivedRestrictedView===!1||n.resolveEyeHeights===!1||ut(t,lt(t,ct(e))),t}function mt(e,t,n,i){let o=e.filter(u=>u.type==="section"),r=n>0||o.some(u=>u.height!==void 0||u.rake!==void 0||(u.elevation??0)>0);if(!o.length||!r||!t){for(let u of i)u.eyeHeightM=n+Q;return}let s=new Array(i.length),l=new Map;for(let u of o)l.has(u.id)||l.set(u.id,u);let m=new Map,a=new Map;for(let u=0;u<i.length;u++){let h=i[u],b=(h.sectionId?l.get(h.sectionId)??o.find(g=>g.logicalSectionId===h.sectionId&&ae({x:h.x,y:h.y},g.outline,g.holes)):void 0)??o.find(g=>ae({x:h.x,y:h.y},g.outline,g.holes))??null;if(s[u]=b,!b)continue;m.has(b.id)||m.set(b.id,Ze(b,{floorBaseHeightM:n}));let f=a.get(b.id);f?f.push(u):a.set(b.id,[u])}let c=new Array(i.length).fill(void 0);for(let[u,h]of a){let d=m.get(u);if(!d)continue;let b=d.rake>0?Math.tan(d.rake*Math.PI/180):0,f=ot(u,i,h,t);for(let g of f.rows){let w=g.blockDepth*q*b,E=d.height+w;for(let P of g.seatIndices)c[P]=E}}for(let u=0;u<i.length;u++){let h=i[u],d=s[u];if(!d){h.eyeHeightM=n+Q;continue}let b=m.get(d.id);h.eyeHeightM=(c[u]??b.height)+Q}}var ie=40;function wi(e,t){let n=t?.freeText==="exclude",i=1/0,o=1/0,r=-1/0,s=-1/0,l=(a,c)=>{a<i&&(i=a),c<o&&(o=c),a>r&&(r=a),c>s&&(s=c)},m=a=>{if(Array.isArray(a))for(let c of a)!c||typeof c!="object"||l(c.x,c.y)};for(let a of Bn(e))if(a.type==="row"){let c=new Map((a.overrides??[]).map(u=>[u.index,u]));we(a).forEach((u,h)=>{let d=c.get(h);d?.skip||l(u.x+(d?.dx??0),u.y+(d?.dy??0))})}else if(a.type==="gaArea")m(a.points);else if(a.type==="section")m(a.outline);else if(a.type==="decorImage")l(a.x,a.y),l(a.x+a.width,a.y+a.height);else if(a.type==="shape")a.points&&a.points.length?m(a.points):a.x!=null&&a.y!=null&&a.width!=null&&a.height!=null&&(l(a.x,a.y),l(a.x+a.width,a.y+a.height));else if(a.type==="table"){let c=J+Ln,u=a.shape==="round"?(a.radius??40)+c:Math.max((a.width??80)/2,(a.height??50)/2)+c;l(a.center.x-u,a.center.y-u),l(a.center.x+u,a.center.y+u)}else if(a.type==="booth"){let c=Math.max(a.width,a.height)/2;l(a.center.x-c,a.center.y-c),l(a.center.x+c,a.center.y+c)}else if(a.type==="text"){if(n)continue;let c=Ne(a);l(a.position.x,a.position.y),l(a.position.x+c.width,a.position.y+c.height)}for(let a of[e.referenceImage,e.backgroundImage]){if(!a)continue;let{center:c,width:u}=a;if(!c||!Number.isFinite(c.x)||!Number.isFinite(c.y)||!Number.isFinite(u))continue;let h=u*3/4;l(c.x-u/2,c.y-h/2),l(c.x+u/2,c.y+h/2)}if(!isFinite(i)){let a=e.focalPoint??{x:0,y:0};return{x:a.x-200,y:a.y-200,width:400,height:400}}return{x:i-ie,y:o-ie,width:r-i+ie*2,height:s-o+ie*2}}export{Wn as a,vt as b,Ce as c,wt as d,qn as e,Et as f,Qn as g,Z as h,le as i,eo as j,to as k,no as l,oo as m,io as n,ro as o,so as p,co as q,lo as r,uo as s,fo as t,ho as u,mo as v,po as w,bo as x,yo as y,Ne as z,xo as A,Lt as B,Mo as C,fe as D,wo as E,Fe as F,Eo as G,Io as H,Dt as I,Ue as J,Co as K,Ge as L,Ht as M,ko as N,Ao as O,ze as P,No as Q,We as R,Xt as S,Bt as T,zt as U,jo as V,$t as W,Jt as X,Lo as Y,Do as Z,Vo as _,Ho as $,$e as aa,q as ba,Ko as ca,en as da,qe as ea,Je as fa,Qe as ga,pe as ha,tn as ia,nn as ja,on as ka,Q as la,Go as ma,Ze as na,tt as oa,cn as pa,ot as qa,Yo as ra,bn as sa,zo as ta,it as ua,Wo as va,Sn as wa,xe as xa,$o as ya,Se as za,J as Aa,we as Ba,yi as Ca,Fn as Da,Dn as Ea,Vn as Fa,bt as Ga,gi as Ha,Hn as Ia,Un as Ja,dt as Ka,te as La,ae as Ma,xi as Na,yt as Oa,Xn as Pa,Me as Qa,Mi as Ra,Bn as Sa,Yn as Ta,Si as Ua,vi as Va,wi as Wa};