@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.
- package/dist/ar-D6ASWQBI.js +1 -0
- package/dist/be-T23MSCFC.js +1 -0
- package/dist/bg-2MMSY43I.js +1 -0
- package/dist/ca-EXRTYE33.js +1 -0
- package/dist/{categoryInventory-H77A_8pF.d.cts → categoryInventory-D_gpkfsq.d.cts} +1 -1
- package/dist/{categoryInventory-DZ5IcDOy.d.ts → categoryInventory-i-mGCBD3.d.ts} +1 -1
- package/dist/chunk-2STEWCI2.js +1 -0
- package/dist/chunk-33SRM2CP.js +1 -0
- package/dist/chunk-3W4ZMU4G.js +1 -0
- package/dist/chunk-76AUT55N.js +1 -0
- package/dist/chunk-B75VUM6L.js +1 -0
- package/dist/{chunk-L34T3APU.js → chunk-FAY7ARLB.js} +1 -1
- package/dist/{chunk-2RNZOV5I.js → chunk-GPZFVQXV.js} +1 -1
- package/dist/chunk-JRZHC75P.js +1 -0
- package/dist/chunk-KTMZ3QAO.js +1 -0
- package/dist/chunk-NWRHKTMV.js +1 -0
- package/dist/{chunk-5HXTEMRE.js → chunk-QG7ZFUNX.js} +1 -1
- package/dist/{chunk-GLGXP5I7.js → chunk-R2TRYVOY.js} +1 -1
- package/dist/chunk-RF4QU72N.js +1 -0
- package/dist/chunk-TFYAMLCK.js +1 -0
- package/dist/chunk-TZBJCAXH.js +1 -0
- package/dist/chunk-UEDS3HJ3.js +1 -0
- package/dist/chunk-UEYHH7Y5.js +1 -0
- package/dist/chunk-WH2EVBIG.js +1 -0
- package/dist/chunk-WKWXU5QM.js +1 -0
- package/dist/{chunk-P4J57TK6.js → chunk-YPVYZYMH.js} +1 -1
- package/dist/core/chart-ops/index.cjs +1 -1
- package/dist/core/chart-ops/index.d.cts +491 -18
- package/dist/core/chart-ops/index.d.ts +491 -18
- package/dist/core/chart-ops/index.js +1 -1
- package/dist/core/color.d.cts +1 -1
- package/dist/core/color.d.ts +1 -1
- package/dist/core/inventory/index.cjs +1 -1
- package/dist/core/inventory/index.d.cts +72 -5
- package/dist/core/inventory/index.d.ts +72 -5
- package/dist/core/inventory/index.js +1 -1
- package/dist/core/layout/index.cjs +1 -1
- package/dist/core/layout/index.d.cts +63 -6
- package/dist/core/layout/index.d.ts +63 -6
- package/dist/core/layout/index.js +1 -1
- package/dist/core/quality/index.cjs +1 -1
- package/dist/core/quality/index.d.cts +18 -4
- package/dist/core/quality/index.d.ts +18 -4
- package/dist/core/quality/index.js +1 -1
- package/dist/core/render-assets/index.cjs +1 -1
- package/dist/core/render-assets/index.d.cts +45 -5
- package/dist/core/render-assets/index.d.ts +45 -5
- package/dist/core/render-assets/index.js +1 -1
- package/dist/core/seatConfidence.d.cts +1 -1
- package/dist/core/seatConfidence.d.ts +1 -1
- package/dist/core/sections/index.cjs +1 -1
- package/dist/core/sections/index.d.cts +5 -5
- package/dist/core/sections/index.d.ts +5 -5
- package/dist/core/sections/index.js +1 -1
- package/dist/cs-L5EG7LLR.js +1 -0
- package/dist/cy-AB2Q6XHI.js +1 -0
- package/dist/da-EGJO7W4Q.js +1 -0
- package/dist/de-Q56NNVPD.js +1 -0
- package/dist/el-JW2YADAL.js +1 -0
- package/dist/es-N35HVHMD.js +1 -0
- package/dist/et-53UYPQR7.js +1 -0
- package/dist/{eventConfigurations-ClFqXQi9.d.cts → eventConfigurations-C0x_OtjQ.d.cts} +1 -1
- package/dist/{eventConfigurations-B6aS6c-_.d.ts → eventConfigurations-CDPqKz_8.d.ts} +1 -1
- package/dist/fa-JL3HW42Q.js +1 -0
- package/dist/fi-ZFWROLPU.js +1 -0
- package/dist/fr-6EKBGKIT.js +1 -0
- package/dist/he-KSOTIRJW.js +1 -0
- package/dist/hi-RWHSYCVV.js +1 -0
- package/dist/hr-ECH5LYKR.js +1 -0
- package/dist/hu-BAXHRRWC.js +1 -0
- package/dist/id-ECFNLK3G.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +65 -17
- package/dist/index.d.ts +65 -17
- package/dist/index.js +1 -1
- package/dist/it-HT57FDFI.js +1 -0
- package/dist/ja-LHVHSM5J.js +1 -0
- package/dist/ko-G2HVHBKT.js +1 -0
- package/dist/ku-MNPV6BJJ.js +1 -0
- package/dist/{labeling-ByEZkLee.d.cts → labeling-20iLar-Q.d.ts} +11 -3
- package/dist/{labeling-CP3GhUrf.d.ts → labeling-DW_pEMgl.d.cts} +11 -3
- package/dist/localeLoaders-L36RHPNS.js +1 -0
- package/dist/lt-GB2GJDNS.js +1 -0
- package/dist/lv-3ZE6IM47.js +1 -0
- package/dist/ms-YH2PYOHG.js +1 -0
- package/dist/nl-D4FX7T7U.js +1 -0
- package/dist/no-5YNLYHN4.js +1 -0
- package/dist/pl-RUXCR6JV.js +1 -0
- package/dist/pt-TKFGIUL6.js +1 -0
- package/dist/{renderedQuality--H0toc-2.d.cts → renderedQuality-BIWwSRMS.d.cts} +1 -1
- package/dist/{renderedQuality-Bo4k99GE.d.ts → renderedQuality-CdpKQidA.d.ts} +1 -1
- package/dist/{renderer-BPhSZUGh.d.cts → renderer-BSjyHBDK.d.cts} +8 -1
- package/dist/{renderer-CWbam_zr.d.ts → renderer-BurPZ2Io.d.ts} +8 -1
- package/dist/ro-UFIOIOVH.js +1 -0
- package/dist/ru-VMRD53B7.js +1 -0
- package/dist/{seatTypeIcons-CSt1isBY.d.ts → seatTypeIcons-BlEzPXFf.d.cts} +2 -2
- package/dist/{seatTypeIcons-B2tvcQ0H.d.cts → seatTypeIcons-D_T5HfJs.d.ts} +2 -2
- package/dist/{sections-C_AKwOIh.d.cts → sections-BySKMsFE.d.ts} +5 -2
- package/dist/{sections-JHox6Lsw.d.ts → sections-DXUcW0ZT.d.cts} +5 -2
- package/dist/{segmentedRowModel-DQO0vHR1.d.ts → segmentedRowModel-C5qFY6jJ.d.ts} +1 -1
- package/dist/{segmentedRowModel-CZ0Ciea-.d.cts → segmentedRowModel-CyW-LFuI.d.cts} +1 -1
- package/dist/sk-XIK2KO3F.js +1 -0
- package/dist/sl-CDZGH6C6.js +1 -0
- package/dist/sr-A3TESNV3.js +1 -0
- package/dist/sv-HKGKDGSG.js +1 -0
- package/dist/{tableSizing-ClgbhNks.d.ts → tableSizing-Bos5ueqg.d.cts} +5 -4
- package/dist/{tableSizing-Cp5T_6Lw.d.cts → tableSizing-CAiE_oii.d.ts} +5 -4
- package/dist/th-ZPGRIY7D.js +1 -0
- package/dist/{ticketRestrictions-DUdzkp4F.d.ts → ticketRestrictions-DKdJWh9u.d.cts} +39 -3
- package/dist/{ticketRestrictions-BHNbxzFT.d.cts → ticketRestrictions-DRDtAVKw.d.ts} +39 -3
- package/dist/tr-IUB54G3R.js +1 -0
- package/dist/{types-5AlKCD4j.d.ts → types-ZviQR7ch.d.cts} +194 -9
- package/dist/{types-5AlKCD4j.d.cts → types-ZviQR7ch.d.ts} +194 -9
- package/dist/uk-JQKEV42K.js +1 -0
- package/dist/vi-KRM5S2Q7.js +1 -0
- package/dist/view3d/crossfade/panorama.d.cts +1 -1
- package/dist/view3d/crossfade/panorama.d.ts +1 -1
- package/dist/view3d/index.cjs +54 -54
- package/dist/view3d/index.d.cts +13 -3
- package/dist/view3d/index.d.ts +13 -3
- package/dist/view3d/index.js +44 -44
- package/dist/view3d/scene/scene.worker.cjs +1 -1
- package/dist/view3d/scene/scene.worker.js +1 -1
- package/dist/zh-Hans-FEUYIOYS.js +1 -0
- package/dist/zh-Hant-PK2XOE2G.js +1 -0
- package/package.json +1 -1
- package/dist/ar-Q44JP5JY.js +0 -1
- package/dist/be-CGFFSIQL.js +0 -1
- package/dist/bg-WOYK6OLH.js +0 -1
- package/dist/ca-77ZVI3X5.js +0 -1
- package/dist/chunk-52XO3LA7.js +0 -1
- package/dist/chunk-5BMXWOE7.js +0 -1
- package/dist/chunk-5ITK5236.js +0 -1
- package/dist/chunk-5N4H3KMR.js +0 -1
- package/dist/chunk-5PFYIYM5.js +0 -1
- package/dist/chunk-CTIGUXXK.js +0 -1
- package/dist/chunk-D723OZEY.js +0 -1
- package/dist/chunk-FLZKBXHA.js +0 -1
- package/dist/chunk-HO4MFTVX.js +0 -1
- package/dist/chunk-JK3DUFRX.js +0 -1
- package/dist/chunk-N4J4CT6P.js +0 -1
- package/dist/chunk-NO6OLVTT.js +0 -1
- package/dist/chunk-TQN2VWQO.js +0 -1
- package/dist/chunk-UISTXRO5.js +0 -1
- package/dist/cs-OSBZYCSR.js +0 -1
- package/dist/cy-ZCOJW2WH.js +0 -1
- package/dist/da-2PDK6JTR.js +0 -1
- package/dist/de-R5LLVFUU.js +0 -1
- package/dist/el-ZPFVDCWA.js +0 -1
- package/dist/es-7YASJP32.js +0 -1
- package/dist/et-J4TV6KQL.js +0 -1
- package/dist/fa-4TEO7UGM.js +0 -1
- package/dist/fi-GIUDDKMH.js +0 -1
- package/dist/fr-J5J2XJLA.js +0 -1
- package/dist/he-OCEHSVUJ.js +0 -1
- package/dist/hi-EK5CTBW5.js +0 -1
- package/dist/hr-SLDTQOYC.js +0 -1
- package/dist/hu-2QNE77NO.js +0 -1
- package/dist/id-LGDAFQJK.js +0 -1
- package/dist/it-DT4Y3IYB.js +0 -1
- package/dist/ja-D5EY2XCQ.js +0 -1
- package/dist/ko-DD2NV45Q.js +0 -1
- package/dist/ku-KZCMVLBE.js +0 -1
- package/dist/localeLoaders-GGAKX22E.js +0 -1
- package/dist/lt-QWGTJ47Y.js +0 -1
- package/dist/lv-LYAIG3VK.js +0 -1
- package/dist/ms-XTF4KNGD.js +0 -1
- package/dist/nl-QEXY6XHS.js +0 -1
- package/dist/no-HCOXN2CN.js +0 -1
- package/dist/pl-BWY53TSD.js +0 -1
- package/dist/pt-2UJUBCPL.js +0 -1
- package/dist/ro-GGXOLTED.js +0 -1
- package/dist/ru-ZTFK3WCU.js +0 -1
- package/dist/sk-KU543Y2U.js +0 -1
- package/dist/sl-FT576R7A.js +0 -1
- package/dist/sr-WE3J46JE.js +0 -1
- package/dist/sv-YEAOPSEB.js +0 -1
- package/dist/th-BEBRDHJA.js +0 -1
- package/dist/tr-LOAHUPSH.js +0 -1
- package/dist/uk-2GMICSHN.js +0 -1
- package/dist/vi-TC5B6AUR.js +0 -1
- package/dist/zh-Hans-TSZWTZQY.js +0 -1
- package/dist/zh-Hant-TLB4FZYM.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var cr=Object.create;var Ue=Object.defineProperty;var lr=Object.getOwnPropertyDescriptor;var dr=Object.getOwnPropertyNames;var ur=Object.getPrototypeOf,fr=Object.prototype.hasOwnProperty;var gr=(e,t)=>{for(var n in t)Ue(e,n,{get:t[n],enumerable:!0})},fn=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of dr(t))!fr.call(e,i)&&i!==n&&Ue(e,i,{get:()=>t[i],enumerable:!(o=lr(t,i))||o.enumerable});return e};var br=(e,t,n)=>(n=e!=null?cr(ur(e)):{},fn(t||!e||!e.__esModule?Ue(n,"default",{value:e,enumerable:!0}):n,e)),hr=e=>fn(Ue({},"__esModule",{value:!0}),e);var ic={};gr(ic,{COLORBLIND_SAFE_PALETTE:()=>qt,ChartOperationError:()=>u,DEFAULT_FLOOR_HEIGHT_STEP_M:()=>Et,DEFAULT_SECTION_CORNER_SMOOTHING:()=>Rt,MAX_BUYER_IMAGE_URL_LENGTH:()=>Nr,MAX_FLOOR_BASE_HEIGHT_M:()=>ot,addArcFanRows:()=>Ga,addBookableGridArray:()=>ps,addBoothArray:()=>qa,addChartCategory:()=>So,addChartFloor:()=>ui,addChartZone:()=>hi,addGAArea:()=>Ha,addRowBlock:()=>Ba,addTableArray:()=>Va,applyPolygonHole:()=>ea,applyReferenceScanRows:()=>gs,applySectionCornerSmoothing:()=>ca,applySectionEstimates:()=>la,applySectionOutlineShaping:()=>fo,applySectionRowFit:()=>Zi,approveConfidenceEvidence:()=>oc,arcFanInputForGroup:()=>Co,assignSectionInventoryCategory:()=>oa,automaticPlacementCenter:()=>Ta,clearConfidenceEvidence:()=>nc,compactChartDoc:()=>ei,compactRowOverrides:()=>Kn,compactTableOverrides:()=>$n,confidenceEvidenceChangeRequiresPublish:()=>Xs,confidenceEvidenceChanges:()=>ir,confidenceEvidenceIndex:()=>Hs,confirmReferenceCategoryOutputColor:()=>ma,convertGeneratedSectionToPolygon:()=>ra,countCoveredInventory:()=>ct,detectSeatLabelRun:()=>Dn,dropRedundantSeatOverrideFields:()=>Ze,familyCategoryLabel:()=>Io,gaAreaFootprint:()=>Po,groupRowsAsSegmented:()=>Xt,insertSeatingBlock:()=>qi,isSafeBuyerImageUrl:()=>Pn,joinGAAreas:()=>Ks,mergeRows:()=>js,mirrorFirstFloor:()=>ue,normalizeBuyerImageUrl:()=>re,normalizeDraftEvidence:()=>sr,parseSeatRefId:()=>ws,pickColorblindSafeCategoryColor:()=>xo,planCreationCategory:()=>vo,previewArcFanRows:()=>Jt,previewBookableGridArray:()=>hs,previewGeneratedSectionPolygonConversion:()=>lo,previewJoinGAAreas:()=>Gs,previewPolygonHole:()=>dt,previewRemovePolygonHole:()=>ao,previewRowCubicPath:()=>oo,previewSectionRowFit:()=>ro,reassignColorblindSafeCategoryColors:()=>ya,relabelChartRows:()=>Vi,removeChartCategory:()=>Aa,removeChartFloor:()=>bi,removeChartObjects:()=>Ui,removeChartZone:()=>yi,removePolygonHole:()=>ta,renameChartFloor:()=>fi,renameDirectSeatImportCategory:()=>ga,reorderChartCategories:()=>ba,replaceArcFanRows:()=>Ka,replaceRowBlock:()=>Ya,resetSeatOverrides:()=>Is,resizeShapes:()=>Bs,resolveCreationCategory:()=>Pa,retractConfidenceEvidence:()=>rc,roundBuyerCoordinates:()=>ni,seatRefId:()=>$e,seatSemanticsSignature:()=>At,sectionInventorySelectionSummary:()=>co,setConfidenceEvidence:()=>tc,setRowBlockSpacing:()=>ks,splitRow:()=>Ls,straightenAndSpaceRows:()=>Es,transformSectionBoundary:()=>ia,transformSectionBoundaryObject:()=>uo,ungroupSegmentedRow:()=>Ja,updateBooths:()=>Bi,updateCategoryDefinitions:()=>wo,updateChartFloorBaseHeight:()=>gi,updateChartTheme:()=>ka,updateChartZones:()=>pi,updateGAAreas:()=>zi,updateRowCubicPath:()=>Xi,updateRows:()=>vs,updateSeatOverrides:()=>nn,updateSectionExactPath:()=>aa,updateSectionMetadata:()=>Kt,updateSegmentedRow:()=>Xa,updateShapes:()=>$s,updateStageKinds:()=>zs,updateTables:()=>$i,updateTextObjects:()=>Hi,updateViewFromSeatFallback:()=>Ea});module.exports=hr(ic);var gn=e=>Math.max(1,e.fontSize*.6+(e.letterSpacing??0));function pr(e,t){let n=e.text.split(/\r?\n/);if(!e.width)return Math.max(1,n.length);let o=Math.max(1,Math.floor(t/gn(e))),i=0;for(let a of n){if(!a.length){i+=1;continue}let r=0;for(let s of a.split(/\s+/)){let l=s.length;r&&r+1+l<=o?r+=1+l:(i+=Math.max(1,Math.ceil(l/o)),r=l%o)}}return Math.max(1,i)}function bn(e){let t=e.background?.padding??0,n=e.text.split(/\r?\n/),o=Math.max(1,...n.map(s=>s.length))*gn(e),i=e.width??o+t*2,a=Math.max(1,i-t*2),r=pr(e,a);return{width:i,height:r*e.fontSize*(e.lineHeight??1.2)+t*2,lineCount:r,padding:t}}var cc=Math.PI/180;function B(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function It(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function hn(e,t){let n=1-t,o=n*n*n,i=3*n*n*t,a=3*n*t*t,r=t*t*t;return{x:o*e.start.x+i*e.control1.x+a*e.control2.x+r*e.end.x,y:o*e.start.y+i*e.control1.y+a*e.control2.y+r*e.end.y}}function He(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[hn(e,.5)];let o=Array.from({length:n+1},(l,c)=>hn(e,c/n)),i=new Float64Array(o.length);for(let l=1;l<o.length;l+=1){let c=o[l].x-o[l-1].x,d=o[l].y-o[l-1].y;i[l]=i[l-1]+Math.hypot(c,d)}let a=i[i.length-1];if(a<=1e-9)return Array.from({length:t},()=>({...e.start}));let r=[],s=1;for(let l=0;l<t;l+=1){let c=a*l/(t-1);for(;s<i.length-1&&i[s]<c;)s+=1;let d=i[s-1],g=i[s],b=g===d?0:(c-d)/(g-d);r.push({x:o[s-1].x+(o[s].x-o[s-1].x)*b,y:o[s-1].y+(o[s].y-o[s-1].y)*b})}return r}function Re(e){if(e.length<3)return 0;let t=0;for(let n=0,o=e.length-1;n<e.length;o=n++)t+=(e[o].x+e[n].x)*(e[o].y-e[n].y);return Math.abs(t)/2}function Pe(e,t,n){return Math.max(t,Math.min(n,e))}function yr(e){return Pe(e,0,1)}function pn(e){let t=yr(e);return t*t*(3-2*t)}var ge=Math.PI*2;function be(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}function mr(e,t,n){let o=t-e;if(n){for(;o<0;)o+=ge;for(;o>=ge;)o-=ge}else{for(;o>0;)o-=ge;for(;o<=-ge;)o+=ge}return o}function Ve(e){if(e.version!==1||e.closed!==!0||!be(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||!be(n.end))return!1;if(n.kind==="line"){if(B(t,n.end)<=1e-9)return!1}else if(n.kind==="bezier"){if(!be(n.control1)||!be(n.control2)||B(t,n.end)<=1e-9)return!1}else if(n.kind==="arc"){if(!be(n.center)||!Number.isFinite(n.radius)||n.radius<=1e-6||Math.abs(B(t,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||Math.abs(B(n.end,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||B(t,n.end)<=1e-9)return!1}else return!1;t=n.end}return B(t,e.start)<=1e-4}function wr(e,t,n){let o=1-n;return{x:o**3*e.x+3*o**2*n*t.control1.x+3*o*n**2*t.control2.x+n**3*t.end.x,y:o**3*e.y+3*o**2*n*t.control1.y+3*o*n**2*t.control2.y+n**3*t.end.y}}function Ct(e,t=2){if(!Ve(e))throw new Error("Section outline path is invalid");let n=Math.max(.25,t),o=[{...e.start}],i=e.start;for(let a of e.segments){if(a.kind==="line")o.push({...a.end});else if(a.kind==="arc"){let r=Math.atan2(i.y-a.center.y,i.x-a.center.x),s=Math.atan2(a.end.y-a.center.y,a.end.x-a.center.x),l=mr(r,s,a.clockwise),c=Math.max(2,Math.ceil(Math.abs(l)*a.radius/n));for(let d=1;d<=c;d+=1){let g=r+l*d/c;o.push({x:a.center.x+Math.cos(g)*a.radius,y:a.center.y+Math.sin(g)*a.radius})}}else{let r=B(i,a.control1)+B(a.control1,a.control2)+B(a.control2,a.end),s=Math.max(2,Math.ceil(r/n));for(let l=1;l<=s;l+=1)o.push(wr(i,a,l/s))}i=a.end}return B(o[o.length-1],o[0])<=1e-4&&o.pop(),o}function wn(e,t,n){return Ot(e,i=>({x:i.x+t,y:i.y+n}))}function Ot(e,t,n=1,o=!1){return{...e,start:t(e.start),segments:e.segments.map(i=>i.kind==="line"?{...i,end:t(i.end)}:i.kind==="arc"?{...i,center:t(i.center),radius:i.radius*Math.abs(n),clockwise:o?!i.clockwise:i.clockwise,end:t(i.end)}:{...i,control1:t(i.control1),control2:t(i.control2),end:t(i.end)})}}var Rt=45,vt=150,xr=60;function Sr(e){let t=Rt/100;if(e<=t)return vt;let n=Math.min(1,(e-t)/(1-t));return vt-n*(vt-xr)}var yn=.5523;function mn(e,t){return Math.abs(e.x-t.x)<=1e-6&&Math.abs(e.y-t.y)<=1e-6}function Ir(e){let t=[],n=[];for(e.forEach((o,i)=>{be(o)&&(t.length&&mn(t[t.length-1],o)||(t.push({x:o.x,y:o.y}),n.push(i)))});t.length>1&&mn(t[0],t[t.length-1]);)t.pop(),n.pop();return{points:t,sourceIndex:n}}var vr=.5,Cr=4/3;function Or(e,t,n){let o=t.x-e.x,i=t.y-e.y,a=Math.hypot(o,i);if(a<=1e-9)return{kind:"line",end:{...t}};let r=-i/a,s=o/a,l=n*Cr;return{kind:"bezier",control1:{x:e.x+o/3+r*l,y:e.y+i/3+s*l},control2:{x:e.x+o*2/3+r*l,y:e.y+i*2/3+s*l},end:{...t}}}function xn(e,t){let{points:n,sourceIndex:o}=Ir(e),i=n.length;if(i<3)return null;let a=Math.min(100,Math.max(0,t.cornerSmoothing??0))/100,r=t.edgeCurvature,s=new Array(i).fill(0);if(r?.length)for(let w=0;w<i;w+=1){let S=r[o[w]];s[w]=Number.isFinite(S)?Math.min(100,Math.max(-100,S))/100:0}let l=s.some(w=>Math.abs(w)>1e-6);if(a<=0&&!l)return null;let c=t.wideAngleThresholdDeg??Sr(a),d=[];for(let w=0;w<i;w+=1)d[w]=B(n[w],n[(w+1)%i]);let g=new Array(i).fill(0);for(let w=0;w<i;w+=1){let S=n[(w-1+i)%i],I=n[w],C=n[(w+1)%i],j={x:S.x-I.x,y:S.y-I.y},L={x:C.x-I.x,y:C.y-I.y},T=Math.hypot(j.x,j.y),G=Math.hypot(L.x,L.y);if(T<=1e-9||G<=1e-9)continue;let M=Math.min(1,Math.max(-1,(j.x*L.x+j.y*L.y)/(T*G))),z=Math.acos(M)*180/Math.PI;if(z<c)continue;let P=pn((z-c)/(180-c));g[w]=a*P*.5*Math.min(T,G)}for(let w=0;w<i;w+=1){let S=(w+1)%i,I=g[w]+g[S];if(I>d[w]&&I>1e-9){let C=d[w]/I;g[w]*=C,g[S]*=C}}let b=new Array(i),f=new Array(i);for(let w=0;w<i;w+=1){let S=n[(w-1+i)%i],I=n[w],C=n[(w+1)%i];if(g[w]<=1e-6){b[w]={...I},f[w]={...I};continue}let j=B(I,S)||1,L=B(I,C)||1;b[w]={x:I.x+(S.x-I.x)/j*g[w],y:I.y+(S.y-I.y)/j*g[w]},f[w]={x:I.x+(C.x-I.x)/L*g[w],y:I.y+(C.y-I.y)/L*g[w]}}if(g.every(w=>w<=1e-6)&&!l)return null;let y=[],m={...f[0]},x=m,v=(w,S)=>{if(B(x,w)<=1e-9)return;let I=s[S];Math.abs(I)>1e-6?y.push(Or(x,w,I*vr*d[S])):y.push({kind:"line",end:{...w}}),x=w};for(let w=1;w<=i;w+=1){let S=w%i,I=n[S];v(b[S],(w-1)%i),g[S]>1e-6&&B(b[S],f[S])>1e-9&&(y.push({kind:"bezier",control1:It(b[S],I,yn),control2:It(f[S],I,yn),end:{...f[S]}}),x=f[S])}if(!y.length)return null;let h=y[y.length-1];B(h.end,m)>1e-9&&(h.kind==="line"?h.end={...m}:y.push({kind:"line",end:{...m}}));let p={version:1,closed:!0,start:m,segments:y};return Ve(p)?p:null}var Sn="ABCDEFGHIJKLMNOPQRSTUVWXYZ",Rr="ABCDEFGHJKLMNPQRSTUVWXYZ",Pr="abcdefghijklmnopqrstuvwxyz";function In(e,t){let n=t.length,o=e+1,i="";for(;o>0;){o-=1;let a=o%n;i=t[a]+i,o=Math.floor(o/n)}return i}function Mr(e,t){let n=t.startAt-1,o=e+n;if(t.scheme==="numbers")return String(o+1);let i=t.skipAmbiguous?Rr:Sn;return In(o,i)}function Pt(e,t=!1){let n=t?Pr:Sn;return In(Math.max(0,Math.floor(e)-1),n)}var _r=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];function vn(e){if(!Number.isFinite(e)||e<=0)return String(e);let t=Math.floor(e),n="";for(let[o,i]of _r)for(;t>=o;)n+=i,t-=o;return n}function Cn(e,t){let n=e.length;return e.map((o,i)=>{let a=t.reverse?n-1-i:i;return{...o,label:Mr(a,t)}})}function Ar(e){let t=new Array(e);return Array.from({length:e},(n,o)=>o).sort((n,o)=>Math.abs(2*n-(e-1))-Math.abs(2*o-(e-1))||n-o).forEach((n,o)=>t[n]=o),t}function he(e,t){let n=e.seatLabelStart??1,o=e.seatNumbering?.direction??"ltr",i=e.seatNumbering?.step??1,a=e.seatNumbering?.scheme??"decimal",r=e.seatNumbering?.prefix??"",s=e.seatNumbering?.endAt,l=e.seatCount;if(a==="updown"||a==="updown-descending"){let f=Math.ceil(l/2),y=a==="updown"?t<f?n+2*t:n-1+2*(l-t):t<f?n+2*(f-1-t):n+1+2*(t-f);return`${r}${y}`}let c=a==="odd"||a==="even"?2:i,d=s!=null&&Number.isFinite(s)?s-(l-1)*c:n,g=o==="center"?Ar(l)[t]:o==="rtl"?l-1-t:t,b;switch(a){case"odd":{let f=d%2===1?d:d+1;b=String(f+g*2);break}case"even":{let f=d%2===0?d:d+1;b=String(f+g*2);break}case"roman":b=vn(d+g*i);break;case"letters-upper":b=Pt(d+g*i,!1);break;case"letters-lower":b=Pt(d+g*i,!0);break;default:b=String(d+g*i);break}return`${r}${b}`}function jr(e){return{...e.canonical,seatCount:e.totalSeats,label:e.displayLabel,displayLabel:e.displayLabel}}function te(e,t,n){return n?.label??`${e.seatLabelBase??e.label}-${he(e,t)}`}function Me(e,t,n,o){if(o?.displayLabel)return o.displayLabel;if(e.seatDisplayLabelMode==="number")return he(e,t);if(!n)return`${e.displayLabel||e.label}-${he(e,t)}`;let i=jr(n),a=n.displayOffset+t;return`${n.displayLabel}-${he(i,a)}`}var On=[{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."}];var Lr=Math.PI*2;function kr(e,t,n,o,i,a){return{x:i+e*n-t*o,y:a+e*o+t*n}}function Rn(e){let{kind:t,cx:n,cy:o,width:i,height:a}=e,r=(e.rotation??0)*Math.PI/180,s=Math.cos(r),l=Math.sin(r),c=i/2,d=a/2,g=[],b=(f,y)=>{g.push({x:f,y})};switch(t){case"rect":{b(-c,-d),b(c,-d),b(c,d),b(-c,d);break}case"rounded":{let f=Math.min(i,a)*.18,y=5,m=(x,v,h)=>{for(let p=0;p<=y;p++){let w=h+p/y*(Math.PI/2);b(x+f*Math.cos(w),v+f*Math.sin(w))}};m(c-f,-d+f,-Math.PI/2),m(c-f,d-f,0),m(-c+f,d-f,Math.PI/2),m(-c+f,-d+f,Math.PI);break}case"arc":{let f=a*.45;b(-c,-d),b(c,-d);let y=24;for(let m=0;m<=y;m++){let x=m/y,v=c-x*i,h=d+f*(1-Math.pow(2*v/i,2));b(v,h)}break}case"thrust":{let f=i*.18,y=a*1.1;b(-c,-d),b(c,-d),b(c,d),b(f,d),b(f,d+y),b(-f,d+y),b(-f,d),b(-c,d);break}case"runway":{let f=i*.1,y=a*3;b(-c,-d),b(c,-d),b(c,d),b(f,d),b(f,d+y),b(-f,d+y),b(-f,d),b(-c,d);break}case"round":case"oval-cricket":{for(let y=0;y<40;y++){let m=y/40*Lr;b(c*Math.cos(m),d*Math.sin(m))}break}case"pitch-football":case"pitch-rugby":case"court-basketball":case"court-tennis":case"ring-boxing":{b(-c,-d),b(c,-d),b(c,d),b(-c,d);break}case"diamond-baseball":{for(let f of Fr(c,d))b(f.x,f.y);break}case"rink-hockey":{for(let f of Er(c,d,c*(8.5/60),d*(8.5/30)))b(f.x,f.y);break}case"track-athletics":{for(let f of Tr(c,d))b(f.x,f.y);break}}return g.map(f=>kr(f.x,f.y,s,l,n,o))}function Er(e,t,n,o){let i=[],r=(s,l,c)=>{for(let d=0;d<=8;d++){let g=c+d/8*(Math.PI/2);i.push({x:s+n*Math.cos(g),y:l+o*Math.sin(g)})}};return r(e-n,-t+o,-Math.PI/2),r(e-n,t-o,0),r(-e+n,t-o,Math.PI/2),r(-e+n,-t+o,Math.PI),i}function Tr(e,t){let n=Math.max(0,e-t),o=[],i=20;for(let a=0;a<=i;a++){let r=-Math.PI/2+a/i*Math.PI;o.push({x:n+t*Math.cos(r),y:t*Math.sin(r)})}for(let a=0;a<=i;a++){let r=Math.PI/2+a/i*Math.PI;o.push({x:-n+t*Math.cos(r),y:t*Math.sin(r)})}return o}var _e=(()=>{let t={x:0,y:52},n=25,o={x:70,y:t.y-70},i=(o.x*o.x+o.y*o.y-4900)/(2*(o.y+70)),a=i+70,r=[],s=Math.atan2(o.y-i,o.x),l=Math.atan2(o.y-i,-o.x);for(let c=0;c<=24;c++){let d=s+(l-s)*c/24;r.push({x:a*Math.cos(d),y:i+a*Math.sin(d)})}return{half:70,home:t,backstop:n,fence:r}})();function Fr(e,t){let n=e/_e.half,o=t/_e.half;return[{x:-_e.backstop*n,y:t},{x:_e.backstop*n,y:t},..._e.fence.map(i=>({x:i.x*n,y:i.y*o}))]}var Nr=2e6,Dr=/^data:image\/(?:png|jpe?g|webp|gif|avif);base64,[a-z0-9+/]+={0,2}$/i,Gr=/[\s"'<>`\\]/;function Pn(e){if(typeof e!="string"||!e||e.length>2e6||e!==e.trim())return!1;if(e.startsWith("data:"))return Dr.test(e);if(Gr.test(e))return!1;try{let t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}}function re(e){let t=e.trim();return Pn(t)?t:null}function Ae(e){return e?e.accessibility?.length?e.wheelchairSpaceType&&!e.accessibility.includes("wheelchair")?["wheelchair",...e.accessibility]:e.accessibility:e.wheelchairSpaceType?["wheelchair"]:e.accessible?["wheelchair"]:[]:[]}var Je=Math.PI/180,Kr=9,ie=16;function _t(e,t,n,o){let i=n*Je,a=Math.cos(i),r=Math.sin(i);return{x:o.x+e*a-t*r,y:o.y+e*r+t*a}}function Y(e){let{seatCount:t,seatSpacing:n,curve:o,rotation:i,origin:a}=e,r=[];if(e.path)return He(e.path,t);if(t<=1)return t===1&&r.push({x:a.x,y:a.y}),r;if(o===0){for(let c=0;c<t;c++)r.push(_t(c*n,0,i,a));return r}let s=o/(t-1)*Je,l=n/(2*Math.sin(Math.abs(s)/2));for(let c=0;c<t;c++){let d=c*s,g=l*Math.sin(d),b=-l+l*Math.cos(d);r.push(_t(g,b,i,a))}return r}function An(e){let t=new Map;if(e.overrides)for(let n of e.overrides)t.set(n.index,n);return t}function $r(e,t){let n=An(e);return Y(e).map((o,i)=>{let a=n.get(i),r=Ae(a),s=te(e,i,a),l={...e.commercial,...a?.commercial};return{index:i,x:o.x+(a?.dx??0),y:o.y+(a?.dy??0),label:s,displayLabel:Me(e,i,t,a),categoryKey:a?.categoryKey??e.categoryKey,skipped:!!a?.skip,accessible:r.length>0,accessibility:r,wheelchairSpaceType:a?.wheelchairSpaceType,commercial:Object.values(l).some(c=>c!==void 0&&c!==!1&&c!=="")?l:void 0,glyph:a?.glyph,viewUrl:a?.viewFromSeatUrl??e.viewFromSeatUrl,viewMeta:a?.viewFromSeatUrl?a.viewFromSeatMeta:e.viewFromSeatMeta,labelStyle:a?.labelStyle??e.seatLabelStyle}})}function X(e){let t=[];for(let n of $r(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 Br(e){if(e.seatCountsBySide)return{...e.seatCountsBySide};let t=e.sides&&e.sides.length?e.sides:["top","bottom"],n=["top","bottom","left","right"].filter(a=>t.includes(a)),o={top:0,bottom:0,left:0,right:0};if(!n.length)return o;let i=Math.max(0,Math.round(e.seatCount));for(let a=0;a<i;a++)o[n[a%n.length]]+=1;return o}function zr(e){let t=[],n=Math.max(0,Math.round(e.seatCount));if(n===0)return t;let o=new Map((e.overrides??[]).map(d=>[d.index,d])),i=(d,g,b,f)=>{let y=o.get(d),m=Ae(y),x=y?.label??`${e.label}-${d+1}`,v=e.displayLabel??e.label;return{index:d,label:x,displayLabel:y?.displayLabel??`${v}-${d+1}`,x:g+(y?.dx??0),y:b+(y?.dy??0),categoryKey:y?.categoryKey??e.categoryKey,skipped:!!y?.skip,accessible:m.length>0,accessibility:m,wheelchairSpaceType:y?.wheelchairSpaceType,commercial:y?.commercial,glyph:y?.glyph,viewUrl:y?.viewFromSeatUrl,viewMeta:y?.viewFromSeatUrl?y.viewFromSeatMeta:void 0,labelStyle:y?.labelStyle,...f?{side:f}:{}}};if(e.shape==="round"){let d=(e.radius??40)+ie,g=e.rotation*Je,b=Math.max(0,Math.min(360,e.seatArc??360));if(b>=360||n===1){for(let x=0;x<n;x++){let v=g+x/n*2*Math.PI;t.push(i(x,e.center.x+d*Math.cos(v),e.center.y+d*Math.sin(v)))}return t}let f=b*Je,y=(2*Math.PI-f)/2,m=g+y;for(let x=0;x<n;x++){let v=m+x/(n-1)*f;t.push(i(x,e.center.x+d*Math.cos(v),e.center.y+d*Math.sin(v)))}return t}let a=e.width??80,r=e.height??50,s=Br(e),l=["top","bottom","left","right"],c=0;for(let d of l){let g=s[d];for(let b=0;b<g;b++){let f,y;d==="top"?(f=-a/2+(b+.5)*a/g,y=-r/2-ie):d==="bottom"?(f=-a/2+(b+.5)*a/g,y=r/2+ie):d==="left"?(f=-a/2-ie,y=-r/2+(b+.5)*r/g):(f=a/2+ie,y=-r/2+(b+.5)*r/g);let m=_t(f,y,e.rotation,e.center);t.push(i(c++,m.x,m.y,d))}}return t}function ce(e){return zr(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 jn(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 Mn(e,t){let n=!1;for(let o=0,i=t.length-1;o<t.length;i=o++){let a=t[o].x,r=t[o].y,s=t[i].x,l=t[i].y;r>e.y!=l>e.y&&e.x<(s-a)*(e.y-r)/(l-r)+a&&(n=!n)}return n}function Ur(e,t){return t.some((n,o)=>{let i=t[(o+1)%t.length],a=(e.y-n.y)*(i.x-n.x)-(e.x-n.x)*(i.y-n.y);if(Math.abs(a)>1e-7)return!1;let r=(e.x-n.x)*(i.x-n.x)+(e.y-n.y)*(i.y-n.y),s=(i.x-n.x)**2+(i.y-n.y)**2;return r>=-1e-7&&r<=s+1e-7})}function ae(e){return Array.isArray(e)?e.filter(t=>Array.isArray(t)&&t.length>=3):[]}function $(e,t,n){return Mn(e,t)&&!ae(n).some(o=>Mn(e,o)||Ur(e,o))}function Mt(e){if(!e.length)return{x:0,y:0};let t=0,n=0;for(let o of e)t+=o.x,n+=o.y;return{x:t/e.length,y:n/e.length}}function F(e){switch(e.type){case"row":{let t=Y(e),n=An(e),o=0,i=0,a=0;for(let r=0;r<t.length;r++){let s=n.get(r);s?.skip||(o+=t[r].x+(s?.dx??0),i+=t[r].y+(s?.dy??0),a++)}return a?{x:o/a,y:i/a}:{x:e.origin.x,y:e.origin.y}}case"table":case"booth":return{x:e.center.x,y:e.center.y};case"gaArea":return Mt(e.points);case"section":return Mt(e.outline);case"text":return{x:e.position.x,y:e.position.y};case"shape":return e.points&&e.points.length?Mt(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 _n(e,t){return e.length===t.length&&e.every((n,o)=>n.x===t[o].x&&n.y===t[o].y)}function Hr(e,t){if(e.type!=="gaArea"||!_n(e.points,t.outline))return!1;let n=ae(e.holes),o=ae(t.holes);return n.length===o.length&&n.every((i,a)=>_n(i,o[a]))}function Ln(e,t,n=e.filter(i=>i.type==="section"),o=F(t)){let i="referenceInventorySource"in t?t.referenceInventorySource?.logicalSectionId:void 0;return(i?n.find(r=>(r.logicalSectionId??r.id)===i&&(Hr(t,r)||$(o,r.outline,r.holes))):void 0)??n.find(r=>$(o,r.outline,r.holes))}function k(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 H(e){return e.floors&&e.floors.length?e.floors.flatMap(t=>t.objects):e.objects}var qe=40;function kn(e,t){let n=t?.freeText==="exclude",o=1/0,i=1/0,a=-1/0,r=-1/0,s=(c,d)=>{c<o&&(o=c),d<i&&(i=d),c>a&&(a=c),d>r&&(r=d)},l=c=>{if(Array.isArray(c))for(let d of c)!d||typeof d!="object"||s(d.x,d.y)};for(let c of H(e))if(c.type==="row"){let d=new Map((c.overrides??[]).map(g=>[g.index,g]));Y(c).forEach((g,b)=>{let f=d.get(b);f?.skip||s(g.x+(f?.dx??0),g.y+(f?.dy??0))})}else if(c.type==="gaArea")l(c.points);else if(c.type==="section")l(c.outline);else if(c.type==="decorImage")s(c.x,c.y),s(c.x+c.width,c.y+c.height);else if(c.type==="shape")c.points&&c.points.length?l(c.points):c.x!=null&&c.y!=null&&c.width!=null&&c.height!=null&&(s(c.x,c.y),s(c.x+c.width,c.y+c.height));else if(c.type==="table"){let d=ie+Kr,g=c.shape==="round"?(c.radius??40)+d:Math.max((c.width??80)/2,(c.height??50)/2)+d;s(c.center.x-g,c.center.y-g),s(c.center.x+g,c.center.y+g)}else if(c.type==="booth"){let d=Math.max(c.width,c.height)/2;s(c.center.x-d,c.center.y-d),s(c.center.x+d,c.center.y+d)}else if(c.type==="text"){if(n)continue;let d=bn(c);s(c.position.x,c.position.y),s(c.position.x+d.width,c.position.y+d.height)}for(let c of[e.referenceImage,e.backgroundImage]){if(!c)continue;let{center:d,width:g}=c;if(!d||!Number.isFinite(d.x)||!Number.isFinite(d.y)||!Number.isFinite(g))continue;let b=g*3/4;s(d.x-g/2,d.y-b/2),s(d.x+g/2,d.y+b/2)}if(!isFinite(o)){let c=e.focalPoint??{x:0,y:0};return{x:c.x-200,y:c.y-200,width:400,height:400}}return{x:o-qe,y:i-qe,width:a-o+qe*2,height:r-i+qe*2}}function Xe(e){return(e.type==="shape"||e.type==="text")&&(e.referenceAnnotationSource?.kind==="direct-landmark-v1"||e.referenceAnnotationSource?.kind==="direct-stage-v1")&&(e.referenceAnnotationSource.ownership="organizer"),e}var Vr=["skip","dx","dy","glyph","accessible","accessibility","wheelchairSpaceType","commercial","viewFromSeatUrl","viewFromSeatMeta","confidenceEvidence"];function Nn(e,t){return!e||!t?!e&&!t:e.size===t.size&&e.color===t.color}function Le(e){let t=new Map;for(let n of e.overrides??[])t.set(n.index,n);return t}function At(e){let t=Le(e),n=[];for(let o=0;o<e.seatCount;o+=1){let i=t.get(o),a={};for(let r of Vr){let s=i?.[r];s!==void 0&&(a[r]=s)}n.push([te(e,o,i),Me(e,o,void 0,i),i?.categoryKey??e.categoryKey,i?.labelStyle??e.seatLabelStyle??null,a])}return JSON.stringify(n)}function qr(e){return JSON.parse(JSON.stringify(e))}function Ye(e,t){let n=qr(e);return t(n)&&At(n)===At(e)?n:e}function Jr(e){if(e.seatLabelStyle||e.seatCount<1)return!1;let t=Le(e);if(t.size<e.seatCount)return!1;let n;for(let o=0;o<e.seatCount;o+=1){let i=t.get(o)?.labelStyle;if(!i)return!1;if(!n)n=i;else if(!Nn(n,i))return!1}if(!n)return!1;e.seatLabelStyle={...n};for(let o of e.overrides??[])delete o.labelStyle;return!0}function Xr(e){if(!/^-?\d+$/.test(e))return;let t=Number(e);return Number.isSafeInteger(t)&&String(t)===e?t:void 0}function Dn(e){if(!e.length)return;let t=e[0].lastIndexOf("-");if(t<=0)return;let n=e[0].slice(0,t),o=[];for(let a of e){if(!a.startsWith(`${n}-`))return;let r=Xr(a.slice(n.length+1));if(r===void 0)return;o.push(r)}if(o.length===1)return{base:n,start:o[0],direction:"ltr"};let i=o[1]-o[0];if(!(i!==1&&i!==-1)){for(let a=1;a<o.length;a+=1)if(o[a]-o[a-1]!==i)return;return i===1?{base:n,start:o[0],direction:"ltr"}:{base:n,start:o[o.length-1],direction:"rtl"}}}function Yr(e){if(e.seatCount<1)return!1;let t=Le(e);if(!(e.overrides??[]).some(i=>i.label!==void 0))return!1;let n=[];for(let i=0;i<e.seatCount;i+=1)n.push(te(e,i,t.get(i)));let o=Dn(n);if(!o)return!1;o.base===e.label?delete e.seatLabelBase:e.seatLabelBase=o.base,o.start===1?delete e.seatLabelStart:e.seatLabelStart=o.start,o.direction==="ltr"?delete e.seatNumbering:e.seatNumbering={direction:"rtl"};for(let i of e.overrides??[])delete i.label;return!0}function Qr(e){if(e.seatDisplayLabelMode||e.seatCount<1)return!1;let t=Le(e);for(let n=0;n<e.seatCount;n+=1){let o=t.get(n)?.displayLabel;if(o===void 0||o!==he(e,n))return!1}e.seatDisplayLabelMode="number";for(let n of e.overrides??[])delete n.displayLabel;return!0}function Ze(e,t){t.categoryKey===e.categoryKey&&delete t.categoryKey,t.labelStyle&&Nn(t.labelStyle,e.seatLabelStyle)&&delete t.labelStyle,t.label!==void 0&&t.label===te(e,t.index)&&delete t.label,(!e.segmentedRow||e.seatDisplayLabelMode==="number")&&t.displayLabel!==void 0&&t.displayLabel===Me(e,t.index)&&delete t.displayLabel}function Gn(e){return Object.keys(e).every(t=>t==="index")}function Zr(e){if(!e.overrides?.length)return!1;for(let n of e.overrides)Ze(e,n);let t=e.overrides.filter(n=>!Gn(n));return t.length?e.overrides=t:delete e.overrides,!0}function Wr(e,t){if(!t.segmentedRow||JSON.stringify([e.seatNumbering,e.seatLabelStart])===JSON.stringify([t.seatNumbering,t.seatLabelStart])||t.seatDisplayLabelMode==="number")return!0;let o=Le(t);for(let i=0;i<t.seatCount;i+=1)if(o.get(i)?.displayLabel===void 0)return!1;return!0}function Kn(e){if(e.type!=="row")return e;let t=Ye(e,Jr);return t=Ye(t,Yr),t=Ye(t,Qr),t=Ye(t,Zr),Wr(e,t)?t:e}function $n(e){if(!e.overrides?.length)return e;let t=e.displayLabel??e.label,n=[];for(let i of e.overrides){let a={...i};a.label===`${e.label}-${a.index+1}`&&delete a.label,a.displayLabel===`${t}-${a.index+1}`&&delete a.displayLabel,a.categoryKey===e.categoryKey&&delete a.categoryKey,a.dx===0&&delete a.dx,a.dy===0&&delete a.dy,Gn(a)||n.push(a)}let o={...e};return n.length?o.overrides=n:delete o.overrides,o}function En(e){return e.type==="row"?Kn(e):e.type==="table"?$n(e):e}function ei(e){let t=e.objects.map(En),n=e.floors?.map(o=>({...o,objects:o.objects.map(En)}));return{...e,objects:t,...n?{floors:n}:{}}}var Tn=2,ti=3,Fn=6;function je(e,t){if(!Number.isFinite(e))return e;let n=10**t,o=Math.round(e*n)/n;return Object.is(o,-0)?0:o}function Qe(e){return{...e,x:je(e.x,Tn),y:je(e.y,Tn)}}function ni(e){let t={...e};t.origin&&typeof t.origin=="object"&&(t.origin=Qe(t.origin)),Array.isArray(t.outline)&&(t.outline=t.outline.map(Qe)),Array.isArray(t.points)&&(t.points=t.points.map(Qe)),typeof t.rotation=="number"&&(t.rotation=je(t.rotation,Fn)),typeof t.seatSpacing=="number"&&(t.seatSpacing=je(t.seatSpacing,Fn));let n=t.labelPresentation;return n?.position&&(t.labelPresentation={...n,position:Qe(n.position)}),Array.isArray(t.overrides)&&(t.overrides=t.overrides.map(o=>{let i={...o};for(let a of["dx","dy"]){let r=i[a];if(typeof r!="number")continue;let s=je(r,ti);s===0?delete i[a]:i[a]=s}return i})),t}var oi=36,ri=160;function Bn(e,t=360){let n=Pe(Math.round(Number.isFinite(e)?e:1),1,40),o=Pe(Number.isFinite(t)?t:360,120,360);return Math.round(Pe(n*4*(360/o),oi,ri))}var zn=["horizontal","vertical","auto"];var ke=[{key:"wheelchair",label:"Wheelchair space",short:"Wheelchair",icon:"\u267F"},{key:"companion",label:"Companion seat",short:"Companion",icon:"\u{1F9D1}\u200D\u{1F91D}\u200D\u{1F9D1}"},{key:"semi-ambulatory",label:"Semi-ambulatory (limited mobility)",short:"Limited mobility",icon:"\u{1F9AF}"},{key:"designated-aisle",label:"Designated aisle / transfer seat",short:"Aisle transfer",icon:"AS"},{key:"step-free",label:"Step-free accessible seat",short:"Step-free",icon:"SF"},{key:"hearing",label:"Assistive listening",short:"Hearing",icon:"\u{1F9BB}"},{key:"cart",label:"CART live-caption view",short:"CART captions",icon:"CC"},{key:"sign-language",label:"Sign-language view",short:"Sign language",icon:"\u{1F91F}"},{key:"low-vision",label:"Blind / low-vision viewing",short:"Low vision",icon:"LV"},{key:"sensory-friendly",label:"Quiet / sensory-friendly seating",short:"Sensory-friendly",icon:"QS"},{key:"plus-size",label:"Plus-size seat",short:"Plus-size",icon:"\u{1F4BA}"},{key:"lift-armrest",label:"Lift-up armrest",short:"Lift armrest",icon:"\u2195\uFE0F"}],kc=new Map(ke.map(e=>[e.key,e]));var ii=[{key:"obstructedView",label:"Obstructed view",short:"Obstructed",icon:"\u26D4"},{key:"restrictedView",label:"Restricted view",short:"Restricted",icon:"\u{1F441}"},{key:"premium",label:"Premium seat",short:"Premium",icon:"\u2605"}],Ec=new Map(ii.map(e=>[e.key,e]));var pe=8,jt=24,ai=["reference-focal","bar","entrance","exit","restroom","screen","sound","concession","coat","wall","rail","suite","obstruction"],Tc=new Set(ai);var u=class extends Error{constructor(n,o,i={}){super(o);this.code=n;this.details=i;this.name="ChartOperationError"}};function O(e,t){let n=k(e),o=t?n.find(i=>i.id===t):n[0];if(!o)throw new u("floor_not_found",`Unknown chart floor: ${t}`,{floorId:t});return{floorId:o.id,objects:o.objects}}function E(e,t){if(!e.categories.some(n=>n.key===t))throw new u("category_not_found",`Unknown chart category: ${t}. Call get_chart to list valid category keys.`,{categoryKey:t})}function A(e,t,n,o){let i=new Set([...o,...e.categories.map(a=>a.key),...e.zones?.map(a=>a.id)??[],...e.floors?.map(a=>a.id)??[],...e.floors?.length?e.floors.flatMap(a=>a.objects.map(r=>r.id)):e.objects.map(a=>a.id)]);for(let a=0;a<100;a++){let r=n(t);if(r&&!i.has(r))return o.add(r),r}throw new u("id_generation_failed",`Unable to allocate a unique ${t} id`)}function si(e){let t=e.slice().sort((a,r)=>a.x-r.x||a.y-r.y);if(t.length<3)return t;let n=(a,r,s)=>(r.x-a.x)*(s.y-a.y)-(r.y-a.y)*(s.x-a.x),o=[];for(let a of t){for(;o.length>=2&&n(o[o.length-2],o[o.length-1],a)<=0;)o.pop();o.push(a)}let i=[];for(let a=t.length-1;a>=0;a--){let r=t[a];for(;i.length>=2&&n(i[i.length-2],i[i.length-1],r)<=0;)i.pop();i.push(r)}return o.pop(),i.pop(),o.concat(i)}function ci(e,t){if(!e.length)return e;let n={x:e.reduce((o,i)=>o+i.x,0)/e.length,y:e.reduce((o,i)=>o+i.y,0)/e.length};return e.map(o=>{let i=o.x-n.x,a=o.y-n.y,r=Math.hypot(i,a)||1;return{x:o.x+i/r*t,y:o.y+a/r*t}})}function le(e){let t=[];for(let o of e)o.type==="row"?t.push(...X(o).map(i=>({x:i.x,y:i.y}))):o.type==="table"?t.push(...ce(o).map(i=>({x:i.x,y:i.y}))):o.type==="gaArea"?t.push(...o.points):o.type==="booth"&&t.push(o.center);if(t.length<3)return null;let n=ci(si(t),22);return n.length>=3?n:null}function We(e,t){let n=O(e,t),o=k(e).find(i=>i.id===n.floorId);return{...e,objects:n.objects,floors:void 0,focalPoint:o.focalPoint,referenceImage:o.referenceImage,backgroundImage:o.backgroundImage}}var Un=24,Hn=80;function Lt(e,t){let n=e.normalize("NFKC").trim();if(n.length>Un)throw new u("invalid_operation",`${t} displayed type must be at most ${Un} characters`);return n}function et(e,t){if(e.displayType===void 0)return!1;let n=Lt(e.displayType,t);return n?(e.displayType=n,!1):(delete e.displayType,!0)}function ye(e,t){if(e.displayLabel===void 0)return!1;let n=e.displayLabel.normalize("NFKC").trim();if(n.length>Hn)throw new u("invalid_operation",`${t} displayed label must be at most ${Hn} characters`);return n?(e.displayLabel=n,!1):(delete e.displayLabel,!0)}function N(e,t){let n=e.trim().toLowerCase();if(!/^#[0-9a-f]{6}$/.test(n))throw new u("invalid_operation",`${t} must use a six-digit hex color`);return n}function Vn(e,t){if(!Number.isFinite(e)||e<pe||e>jt)throw new u("invalid_operation",`${t} label size must be from ${pe} to ${jt}`)}function me(e,t){e.size!==void 0&&e.size!==null&&Vn(e.size,t),e.color!==void 0&&e.color!==null&&N(e.color,`${t} label color`)}function tt(e,t){if(e?.positionPreset!==void 0&&!["start","end","both","none"].includes(e.positionPreset))throw new u("invalid_operation",`${t} label positionPreset must be one of start, end, both, none`);let n=e?.labelStyle;n&&(n.size!==void 0&&Vn(n.size,t),n.color!==void 0&&N(n.color,`${t} label color`))}function nt(e,t){let n=e?structuredClone(e):{},o=n.labelStyle?{...n.labelStyle}:{};return t.size===null?delete o.size:t.size!==void 0&&(o.size=t.size),t.color===null?delete o.color:t.color!==void 0&&(o.color=N(t.color,"Label color")),o.size===void 0&&o.color===void 0?delete n.labelStyle:n.labelStyle=o,t.visible!==void 0&&(n.visible=t.visible),Object.keys(n).length?n:void 0}function kt(e,t,n){let o=t.normalize("NFKC").trim();if(!o||o.length>80)throw new u("invalid_operation","Zone labels must contain 1 to 80 characters");if((e.zones??[]).some(i=>i.id!==n&&i.label.normalize("NFKC").trim().toLocaleLowerCase("en")===o.toLocaleLowerCase("en")))throw new u("invalid_operation",`Zone label already exists: ${o}`);return o}function Ee(e,t){if(!Number.isFinite(e?.x)||!Number.isFinite(e?.y))throw new u("invalid_operation",`${t} must contain finite x and y values`);return{x:e.x,y:e.y}}function Q(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}var ne=Math.PI/180,Z=Math.PI/180;function de(e){return e.type==="row"||e.type==="table"?e.seatCount:e.type==="gaArea"?Math.max(0,Math.floor(e.capacity)):e.type==="booth"?1:0}function ue(e){if(e.floors?.length){let t=e.floors[0];e.objects=t.objects,e.focalPoint=t.focalPoint,e.referenceImage=t.referenceImage,e.backgroundImage=t.backgroundImage}return e}var li=0,ot=120,Et=4;function di(e){if(!Number.isFinite(e)||e<li||e>ot)throw new u("invalid_operation","Floor base height must be a number from 0 to 120 metres")}function ui(e,t){let n=k(e);if(n.length>=5)throw new u("invalid_operation","A chart can contain at most five physical floors");let o=(t.name??String(n.length+1)).normalize("NFKC").trim();if(!o||o.length>80)throw new u("invalid_operation","Floor names must contain 1 to 80 characters");if(n.some(l=>l.name.toLocaleLowerCase("en")===o.toLocaleLowerCase("en")))throw new u("invalid_operation",`Floor name already exists: ${o}`);e.floors?.length||(e.floors=[{id:"floor-0",name:"1",objects:e.objects,baseHeightM:0,focalPoint:e.focalPoint,referenceImage:e.referenceImage,backgroundImage:e.backgroundImage}]);let a=e.floors[e.floors.length-1].baseHeightM??Math.min(ot,(e.floors.length-1)*Et),r=Math.min(ot,a+Et),s=A(e,"floor",t.idFactory,new Set);return e.floors.push({id:s,name:o,baseHeightM:r,objects:[],focalPoint:{...e.focalPoint}}),ue(e),{changed:!0,floorId:s,floorCount:e.floors.length,baseHeightM:r}}function fi(e,t){let n=k(e),o=n.find(r=>r.id===t.floorId);if(!o)throw new u("floor_not_found",`Unknown chart floor: ${t.floorId}`,{floorId:t.floorId});let i=t.name.normalize("NFKC").trim();if(!i||i.length>80)throw new u("invalid_operation","Floor names must contain 1 to 80 characters");if(n.some(r=>r.id!==o.id&&r.name.toLocaleLowerCase("en")===i.toLocaleLowerCase("en")))throw new u("invalid_operation",`Floor name already exists: ${i}`);let a=o.name!==i;return a&&(o.name=i),{changed:a,floorId:o.id,floorName:i}}function gi(e,t){if(!e.floors?.length)throw new u("invalid_operation","A single-floor chart has an implicit base height of 0 metres");let n=e.floors.find(i=>i.id===t.floorId);if(!n)throw new u("floor_not_found",`Unknown chart floor: ${t.floorId}`,{floorId:t.floorId});di(t.baseHeightM);let o=n.baseHeightM!==t.baseHeightM;return o&&(n.baseHeightM=t.baseHeightM,n.physical3dProvenance={...n.physical3dProvenance,baseHeightM:{status:"confirmed",source:"user-review",note:"Physical floor height reviewed through the shared Designer/Copilot operation."}}),{changed:o,floorId:n.id,baseHeightM:t.baseHeightM}}function bi(e,t){if(!e.floors?.length)throw new u("invalid_operation","A single-floor chart cannot remove its only floor");let n=e.floors.findIndex(i=>i.id===t.floorId);if(n<0)throw new u("floor_not_found",`Unknown chart floor: ${t.floorId}`,{floorId:t.floorId});let[o]=e.floors.splice(n,1);if(e.floors.length===1){let[i]=e.floors;e.objects=i.objects,e.focalPoint=i.focalPoint,e.referenceImage=i.referenceImage,e.backgroundImage=i.backgroundImage,e.floors=void 0}else ue(e);return{changed:!0,floorId:o.id,removedObjects:o.objects.length,floorCount:k(e).length}}function hi(e,t){if((e.zones?.length??0)>=100)throw new u("invalid_operation","A chart supports at most 100 zones");let n={id:A(e,"zone",t.idFactory,new Set),label:kt(e,t.label),color:N(t.color,"Zone color"),...t.focalPoint?{focalPoint:Ee(t.focalPoint,"Zone focal point")}:{}};return(e.zones??=[]).push(n),{changed:!0,zone:structuredClone(n)}}function pi(e,t){if(!t.updates.length)throw new u("invalid_operation","At least one zone update is required");let n=t.updates.map(l=>l.zoneId);if(new Set(n).size!==n.length)throw new u("invalid_operation","Zone ids must be unique");let o=new Map((e.zones??[]).map(l=>[l.id,l])),i=n.filter(l=>!o.has(l));if(i.length)throw new u("object_not_found",`Unknown zone id(s): ${i.join(", ")}. Call get_chart to list current zone ids.`,{zoneIds:i});let a=structuredClone(e),r=new Map((a.zones??[]).map(l=>[l.id,l]));for(let l of t.updates){if(!Object.keys(l.patch).length)throw new u("invalid_operation",`Zone ${l.zoneId} has no changes`);let d=r.get(l.zoneId);l.patch.label!==void 0&&(d.label=kt(a,l.patch.label,d.id)),l.patch.color!==void 0&&(d.color=N(l.patch.color,"Zone color")),l.patch.focalPoint!==void 0&&(d.focalPoint=Ee(l.patch.focalPoint,"Zone focal point"))}let s=JSON.stringify(a.zones??[])!==JSON.stringify(e.zones??[]);return s&&(e.zones=a.zones),{changed:s,zoneIds:n,zones:n.map(l=>structuredClone(r.get(l)))}}function yi(e,t){let n=(e.zones??[]).findIndex(a=>a.id===t.zoneId);if(n<0)throw new u("object_not_found",`Unknown chart zone: ${t.zoneId}`,{zoneId:t.zoneId});let o=k(e).flatMap(a=>a.objects).filter(a=>a.type==="section"&&a.zone===t.zoneId);if(o.length&&t.clearSectionAssignments!==!0)throw new u("invalid_operation",`Zone ${t.zoneId} is assigned to ${o.length} section(s)`,{zoneId:t.zoneId,sectionIds:o.map(a=>a.id),requiresClearSectionAssignments:!0});let i=o.map(a=>a.id);for(let a of o)delete a.zone;return e.zones.splice(n,1),e.zones.length||delete e.zones,ue(e),{changed:!0,zoneId:t.zoneId,clearedSectionIds:i,zoneCount:e.zones?.length??0}}var rt=[{key:"row-seats",label:"row seats",suffix:"rows",labelSuffix:"Rows",creationWord:"Seats",objectType:"row"},{key:"table-chairs",label:"table chairs",suffix:"tables",labelSuffix:"Tables",creationWord:"Tables",objectType:"table"},{key:"booth-units",label:"booth units",suffix:"booths",labelSuffix:"Booths",creationWord:"Booths",objectType:"booth"},{key:"ga-capacity",label:"GA capacity",suffix:"ga",labelSuffix:"GA",creationWord:"Standing",objectType:"gaArea"}];function it(e){let t=new Map,n=Math.max(0,Math.floor(e.seatCount)),o=new Map((e.overrides??[]).filter(a=>Number.isInteger(a.index)&&a.index>=0&&a.index<e.seatCount).map(a=>[a.index,a])),i=(a,r=1)=>{a&&r>0&&t.set(a,(t.get(a)??0)+r)};i(e.categoryKey,n-o.size);for(let a of o.values())a.skip||i(a.categoryKey??e.categoryKey);return t}var Tt="__sl_ga__";function Te(e){return e.startsWith(Tt)}var mi=Tt,W=1e5;function wi(e,t){return`${mi}${encodeURIComponent(e)}__${t+1}`}function Ft(e){let t=e.inventorySegments;if(t===void 0)return!0;if(!Array.isArray(t)||t.length<1||t.length>256)return!1;let n=0,o=new Map;for(let i of t){if(!i||typeof i.sourceAreaId!="string"||!i.sourceAreaId.trim()||i.sourceAreaId.length>160||!Number.isInteger(i.startIndex)||i.startIndex<0||!Number.isInteger(i.count)||i.count<1||i.startIndex+i.count>W||(n+=i.count,n>W))return!1;let a=o.get(i.sourceAreaId)??[],r=i.startIndex+i.count;if(a.some(s=>i.startIndex<s.end&&r>s.start))return!1;a.push({start:i.startIndex,end:r}),o.set(i.sourceAreaId,a)}return n===e.capacity}function at(e){let t=Math.min(W,Math.max(0,Math.floor(e.capacity)));return e.inventorySegments===void 0?t?[{sourceAreaId:e.id,startIndex:0,count:t}]:[]:Ft(e)?e.inventorySegments.map(n=>({...n})):[]}function oe(e){return at(e).flatMap(t=>Array.from({length:t.count},(n,o)=>wi(t.sourceAreaId,t.startIndex+o)))}function Nt(e,t){if(e.inventorySegments===void 0||t===e.capacity)return e.inventorySegments;if(t<e.capacity)return;let n=at(e);if(!n.length)return;let o=t-e.capacity;if(!o)return n;let a=n.filter(s=>s.sourceAreaId===e.id).reduce((s,l)=>Math.max(s,l.startIndex+l.count),0),r=n[n.length-1];if(r?.sourceAreaId===e.id&&r.startIndex+r.count===a)r.count+=o;else{if(n.length>=256)return;n.push({sourceAreaId:e.id,startIndex:a,count:o})}return n}var xi="__ungrouped__";function Si(e){return e.type==="row"?X(e).map(t=>t.label):e.type==="table"?ce(e).map(t=>t.label):e.type==="booth"?jn(e).map(t=>t.label):e.type==="gaArea"?oe(e):[]}function Ii(e){return e.type==="row"||e.type==="table"||e.type==="booth"||e.type==="gaArea"}function vi(e){return e.displayLabel||e.label||"Section"}function Ci(e){let t=new Map;for(let n of H(e)){if(n.type!=="section")continue;let o=n.logicalSectionId??n.id;t.has(o)||t.set(o,{id:o,label:vi(n),zone:n.zone})}return t}function Oi(e,t){let n=H(e),o=n.filter(s=>s.type==="section"),i=new Map;for(let[s,l]of Ci(e))i.set(s,{id:s,label:l.label,zone:l.zone,seatCount:0,objectIds:[],seatLabels:[]});let a={id:xi,label:"Other seats",seatCount:0,objectIds:[],seatLabels:[]},r=new Map;for(let s of n){if(!Ii(s))continue;let l=Si(s);if(l.length===0)continue;let c;if(t)c=t.get(s.id);else{let g=Ln(n,s,o);c=g?g.logicalSectionId??g.id:void 0}let d=c?i.get(c):a;d.seatCount+=l.length,d.objectIds.push(s.id),d.seatLabels.push(...l),r.set(s.id,d.id)}return{sections:[...i.values()],ungrouped:a.objectIds.length?a:null,objectToSection:r}}function Fe(e){return Oi(e,null)}var fe={vip:{key:"vip",label:"VIP",color:"#e5484d",price:120},premium:{key:"premium",label:"Premium",color:"#a86b00",price:80},standard:{key:"standard",label:"Standard",color:"#6e7bff",price:45},balcony:{key:"balcony",label:"Balcony",color:"#22a06b",price:30}};function Ne(e,t,n,o,i,a,r=0){return{type:"row",id:e,label:t,origin:{x:-(o-1)*i/2,y:n},rotation:0,curve:r,seatCount:o,seatSpacing:i,categoryKey:a}}function Ri(e,t,n,o,i,a){return{type:"table",id:e,label:t,center:n,shape:"round",seatCount:o,rotation:0,radius:i,categoryKey:a}}function qn(e,t,n,o,i,a){let r=n/2,s=o/2;return{type:"gaArea",id:e,label:t,points:[{x:-r,y:-s},{x:r,y:-s},{x:r,y:s},{x:-r,y:s}],capacity:i,categoryKey:a}}function Pi(e,t,n,o,i){let a=n*2,r=[];for(let s=0;s<a;s++){let l=s%2===0,c=l?["wheelchair"]:["companion"];r.push(l?{index:s,accessibility:c,wheelchairSpaceType:"no-seat"}:{index:s,accessibility:c})}return{type:"row",id:e,label:t,origin:{x:-(a-1)*o/2,y:0},rotation:0,curve:0,seatCount:a,seatSpacing:o,categoryKey:i,overrides:r}}var Jn=[{key:"balcony",label:"Balcony",icon:"\u2312",blurb:"Insert four curved rows inside a section.",categories:[fe.balcony],sectionLabel:"Balcony",build:()=>[Ne("blk-b0","A",-45,18,24,"balcony",18),Ne("blk-b1","B",-15,20,24,"balcony",18),Ne("blk-b2","C",15,22,24,"balcony",18),Ne("blk-b3","D",45,24,24,"balcony",18)]},{key:"rows",label:"Row block",icon:"\u2261",blurb:"Insert six straight rows inside a section.",categories:[fe.standard],sectionLabel:"Section",build:()=>Array.from({length:6},(e,t)=>Ne(`blk-r${t}`,"ABCDEF"[t],-80+t*32,12,26,"standard"))},{key:"ga-pen",label:"GA pen",icon:"\u25A8",blurb:"Insert a standing area for 250 people.",categories:[fe.standard],build:()=>[qn("blk-ga","Standing",320,180,250,"standard")]},{key:"tables",label:"Tables",icon:"\u283F",blurb:"Insert six round tables with eight bookable seats each.",categories:[fe.premium],build:()=>Array.from({length:6},(e,t)=>Ri(`blk-t${t}`,`T${t+1}`,{x:-150+t%3*150,y:t<3?-70:70},8,34,"premium"))},{key:"boxes",label:"Boxes",icon:"\u25A3",blurb:"Insert two private boxes with four bookable seats each.",categories:[fe.vip],build:()=>[{type:"table",id:"blk-x0",label:"Box 1",center:{x:-70,y:0},shape:"rect",seatCount:4,rotation:0,width:110,height:56,categoryKey:"vip"},{type:"table",id:"blk-x1",label:"Box 2",center:{x:70,y:0},shape:"rect",seatCount:4,rotation:0,width:110,height:56,categoryKey:"vip"}]},{key:"terrace",label:"Terrace",icon:"\u2263",blurb:"Insert a standing terrace for 500 people.",categories:[fe.standard],build:()=>[qn("blk-terrace","Terrace",520,200,500,"standard")]},{key:"wheelchair-platform",label:"Wheelchair platform",icon:"\u267F",blurb:"Insert four wheelchair spaces, each with its companion seat.",categories:[fe.standard],build:()=>[Pi("blk-wc","A",4,40,"standard")]}];function V(e){let t="",n=e;do t=String.fromCharCode(65+n%26)+t,n=Math.floor(n/26)-1;while(n>=0);return t}function Xn(e){if(!/^[A-Z]+$/.test(e))return null;let t=0;for(let n of e)t=t*26+(n.charCodeAt(0)-64);return t-1}var Yn="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",Qn=[{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:Yn},{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:Yn},{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"}];var Mi=new Map(Qn.map(e=>[e.key,e]));function Zn(e){return typeof e=="string"&&Mi.has(e)}var al=Qn.map(e=>e.key);function Dt(e){let t=(e%360+360)%360,n=t>=180?t-360:t;return Object.is(n,-0)||Math.abs(n)<1e-9?0:n}function Wn(e,t,n){let o=i=>({x:i.x+t,y:i.y+n});switch(e.type){case"row":e.origin=o(e.origin),e.path&&(e.path={start:o(e.path.start),control1:o(e.path.control1),control2:o(e.path.control2),end:o(e.path.end)});break;case"table":case"booth":e.center=o(e.center);break;case"text":e.position=o(e.position);break;case"gaArea":e.points=e.points.map(o),e.holes&&(e.holes=ae(e.holes).map(i=>i.map(o)));break;case"section":e.outline=e.outline.map(o),e.sourceOutline&&(e.sourceOutline=e.sourceOutline.map(o)),e.outlinePath&&(e.outlinePath=wn(e.outlinePath,t,n)),e.holes&&(e.holes=ae(e.holes).map(i=>i.map(o))),e.labelPresentation?.position&&(e.labelPresentation.position=o(e.labelPresentation.position));break;case"shape":e.points&&(e.points=e.points.map(o)),e.x!=null&&(e.x+=t),e.y!=null&&(e.y+=n);break;case"decorImage":e.x+=t,e.y+=n;break}}function _i(e,t){return Math.abs(e.x-t.x)<=1e-7&&Math.abs(e.y-t.y)<=1e-7}function De(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}function st(e,t,n){let o=De(t,n,e);return Math.abs(o)>1e-7?!1:e.x>=Math.min(t.x,n.x)-1e-7&&e.x<=Math.max(t.x,n.x)+1e-7&&e.y>=Math.min(t.y,n.y)-1e-7&&e.y<=Math.max(t.y,n.y)+1e-7}function Ai(e,t,n,o){let i=De(e,t,n),a=De(e,t,o),r=De(n,o,e),s=De(n,o,t);return(i>1e-7&&a<-1e-7||i<-1e-7&&a>1e-7)&&(r>1e-7&&s<-1e-7||r<-1e-7&&s>1e-7)?!0:Math.abs(i)<=1e-7&&st(n,e,t)||Math.abs(a)<=1e-7&&st(o,e,t)||Math.abs(r)<=1e-7&&st(e,n,o)||Math.abs(s)<=1e-7&&st(t,n,o)}function ji(e){return e.reduce((t,n,o)=>{let i=e[(o+1)%e.length];return t+n.x*i.y-i.x*n.y},0)}function Li(e){for(let t=0;t<e.length;t+=1){let n=(t+1)%e.length;for(let o=t+1;o<e.length;o+=1){let i=(o+1)%e.length;if(!(t===o||n===o||i===t)&&Ai(e[t],e[n],e[o],e[i]))return!0}}return!1}function eo(e){return e.length<3?{ok:!1,code:"too_few_vertices",message:"Add at least three vertices to create a polygon."}:e.length>256?{ok:!1,code:"too_many_vertices",message:"A polygon can contain at most 256 vertices."}:e.some(t=>!Number.isFinite(t.x)||!Number.isFinite(t.y)||Math.abs(t.x)>1e7||Math.abs(t.y)>1e7)?{ok:!1,code:"invalid_coordinate",message:"Every polygon vertex must use a finite coordinate inside the safe chart range."}:e.some((t,n)=>_i(t,e[(n+1)%e.length]))?{ok:!1,code:"duplicate_vertex",message:"Move or remove duplicate neighbouring vertices."}:Math.abs(ji(e))<2?{ok:!1,code:"degenerate_polygon",message:"The polygon needs a visible enclosed area."}:Li(e)?{ok:!1,code:"self_intersection",message:"Polygon edges cannot cross or touch each other."}:{ok:!0}}function $i(e,t){let n=O(e,t.floorId),o=[...new Set(t.tableIds)];if(!o.length)throw new u("invalid_operation","At least one table id is required");let i=o.map(h=>n.objects.find(p=>p.type==="table"&&p.id===h)),a=o.filter((h,p)=>!i[p]);if(a.length)throw new u("object_not_found",`Unknown table id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current table ids.`,{tableIds:a});let r=structuredClone(t.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one table change is required");if(r.label!==void 0){if(r.label=r.label.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","label can be changed only for one table at a time");if(!r.label||r.label.length>80)throw new u("invalid_operation","Table labels must contain 1 to 80 characters")}r.categoryKey!==void 0&&E(e,r.categoryKey),r.fill!==void 0&&r.fill!==null&&(r.fill=N(r.fill,"Table surface color"));let s=r.seatCount!==void 0,l=r.seatCountsBySide!==void 0;if(l){if(r.sides!==void 0)throw new u("invalid_operation","Use seatCountsBySide for exact rectangular counts; do not also supply legacy sides");if(r.shape==="round")throw new u("invalid_operation","seatCountsBySide can be used only with rectangular tables");let h=["top","bottom","left","right"],p=Object.keys(r.seatCountsBySide);if(p.length!==h.length||p.some(S=>!h.includes(S)))throw new u("invalid_operation","seatCountsBySide must contain exactly top, bottom, left, and right");for(let S of h){let I=r.seatCountsBySide[S];if(!Number.isInteger(I)||I<0||I>40)throw new u("invalid_operation",`seatCountsBySide.${S} must be a whole number from 0 to 40`)}let w=h.reduce((S,I)=>S+r.seatCountsBySide[I],0);if(w<1||w>40)throw new u("invalid_operation","Rectangular table side counts must total from 1 to 40 chairs");if(s&&r.seatCount!==w)throw new u("invalid_operation",`seatCount must equal the ${w}-chair seatCountsBySide total`);r.seatCount=w,r.sides=h.filter(S=>r.seatCountsBySide[S]>0)}if(r.seatCount!==void 0&&(!Number.isInteger(r.seatCount)||r.seatCount<1||r.seatCount>40))throw new u("invalid_operation","seatCount must be an integer from 1 to 40");if(r.shape!==void 0&&r.shape!=="round"&&r.shape!=="rect")throw new u("invalid_operation","Table shape must be round or rect");if(r.automaticRadius!==void 0&&typeof r.automaticRadius!="boolean")throw new u("invalid_operation","automaticRadius must be true or false");if(r.shape==="rect"&&r.automaticRadius===!0)throw new u("invalid_operation","Automatic radius can be used only with round tables");if(r.bookAsWhole===!0&&r.variableOccupancy===!0)throw new u("invalid_operation","A table cannot use whole-table and variable-occupancy selling at the same time");if(r.variableOccupancy===!1&&(r.minOccupancy!==void 0||r.maxOccupancy!==void 0))throw new u("invalid_operation","Guest bounds can be supplied only with variable-occupancy selling");let c=(h,p,w,S)=>{if(p!==void 0&&(!Number.isFinite(p)||p<w||p>S))throw new u("invalid_operation",`${String(h)} must be from ${w} to ${S}`)};if(c("rotation",r.rotation,0,360),c("radius",r.radius,24,160),c("seatArc",r.seatArc,120,360),c("width",r.width,40,320),c("height",r.height,30,240),r.minOccupancy!==void 0&&(!Number.isInteger(r.minOccupancy)||r.minOccupancy<1||r.minOccupancy>40))throw new u("invalid_operation","minOccupancy must be a whole number from 1 to 40");if(r.maxOccupancy!==void 0&&(!Number.isInteger(r.maxOccupancy)||r.maxOccupancy<1||r.maxOccupancy>40))throw new u("invalid_operation","maxOccupancy must be a whole number from 1 to 40");if(r.sides!==void 0){let h=new Set(["top","bottom","left","right"]);if(!r.sides.length||r.sides.length>4||new Set(r.sides).size!==r.sides.length||r.sides.some(p=>!h.has(p)))throw new u("invalid_operation","Table sides must contain one to four unique perimeter sides")}let d=ye(r,"Table"),g=et(r,"Table"),b=i.map(h=>{if(h.seatCountsBySide&&!l&&(s||t.patch.sides!==void 0))throw new u("invalid_operation",`Table "${h.label}" has exact per-side counts; update seatCountsBySide instead of aggregate seatCount or legacy sides`,{tableId:h.id});let p=structuredClone(h);if(Object.assign(p,r),r.fill===null&&delete p.fill,p.shape==="round")delete p.seatCountsBySide,p.automaticRadius===!0?p.radius=Bn(p.seatCount,p.seatArc):delete p.automaticRadius;else{if(r.automaticRadius===!0)throw new u("invalid_operation",`Table "${p.label}" is rectangular and cannot use automatic radius`,{tableId:p.id});delete p.automaticRadius}if(p.overrides&&r.seatCount!==void 0&&(p.overrides=p.overrides.filter(w=>w.index<p.seatCount),p.overrides.length||delete p.overrides),r.bookAsWhole===!1&&delete p.bookAsWhole,r.variableOccupancy===!1&&(delete p.variableOccupancy,delete p.minOccupancy,delete p.maxOccupancy),p.bookAsWhole||delete p.bookAsWhole,p.variableOccupancy||delete p.variableOccupancy,p.bookAsWhole&&p.variableOccupancy)throw new u("invalid_operation",`Table "${p.label}" cannot use whole-table and variable-occupancy selling at the same time`,{tableId:p.id});if((p.bookAsWhole||p.variableOccupancy)&&p.overrides?.length)throw new u("invalid_operation",`Table "${p.label}" has individual-chair overrides; reset them before choosing grouped table selling`,{tableId:p.id,overriddenChairIndices:p.overrides.map(w=>w.index)});if(p.bookAsWhole)delete p.minOccupancy,delete p.maxOccupancy;else if(p.variableOccupancy){if(!Number.isInteger(p.minOccupancy)||!Number.isInteger(p.maxOccupancy)||p.minOccupancy<1||p.maxOccupancy<p.minOccupancy||p.maxOccupancy>p.seatCount)throw new u("invalid_operation",`Table "${p.label}" needs whole-number minimum and maximum guests from 1 to its ${p.seatCount}-chair capacity`,{tableId:p.id,seatCount:p.seatCount})}else{if(r.minOccupancy!==void 0||r.maxOccupancy!==void 0)throw new u("invalid_operation","Guest bounds can be changed only on a variable-occupancy table",{tableId:p.id});delete p.minOccupancy,delete p.maxOccupancy}if(g&&delete p.displayType,d&&delete p.displayLabel,p.shape==="rect"){if(p.width??=80,p.height??=50,p.seatCountsBySide){let w=["top","bottom","left","right"],S=w.reduce((I,C)=>I+p.seatCountsBySide[C],0);if(S!==p.seatCount)throw new u("invalid_operation",`Table "${p.label}" side counts total ${S}, but seatCount is ${p.seatCount}`,{tableId:p.id,seatCount:p.seatCount,seatCountsBySide:p.seatCountsBySide});p.sides=w.filter(I=>p.seatCountsBySide[I]>0)}}else p.radius??=40;if((p.bookAsWhole||p.variableOccupancy)&&Te(p.label))throw new u("invalid_operation",`Grouped table label "${p.label}" uses SeatLayer's reserved GA namespace`,{tableId:p.id});return p}),f=new Map(b.map(h=>[h.id,h])),y=new Set(o),m=new Map;for(let h of k(e))for(let p of h.objects){let w=p.type==="table"?f.get(p.id)??p:p,S=[];w.type==="row"?S=X(w).map(I=>I.label):w.type==="table"?S=w.bookAsWhole||w.variableOccupancy?[w.label]:ce(w).map(I=>I.label):w.type==="booth"?S=[w.label]:w.type==="gaArea"&&(S=oe(w));for(let I of S){let C=m.get(I);if(C&&(y.has(C)||y.has(w.id)))throw new u("invalid_operation",`Inventory label "${I}" is already in use; grouped table labels must be unique`,{tableIds:o,inventoryLabel:I,conflictingObjectIds:[C,w.id]});m.set(I,C??w.id)}}let x=!1,v=["bookAsWhole","variableOccupancy","minOccupancy","maxOccupancy","displayLabel","displayType","fill","seatCountsBySide","overrides","automaticRadius"];for(let[h,p]of i.entries()){let w=b[h],S=JSON.stringify(p);for(let I of v)I in w||delete p[I];Object.assign(p,w),JSON.stringify(p)!==S&&(x=!0)}return{floorId:n.floorId,changed:x,tableIds:o}}function Bi(e,t){let n=O(e,t.floorId),o=[...new Set(t.boothIds)];if(!o.length)throw new u("invalid_operation","At least one booth id is required");let i=o.map(f=>n.objects.find(y=>y.type==="booth"&&y.id===f)),a=o.filter((f,y)=>!i[y]);if(a.length)throw new u("object_not_found",`Unknown booth id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current booth ids.`,{boothIds:a});let r=structuredClone(t.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one booth change is required");if(r.label!==void 0){if(r.label=r.label.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","label can be changed only for one booth at a time");if(!r.label||r.label.length>80)throw new u("invalid_operation","Booth labels must contain 1 to 80 characters")}r.categoryKey!==void 0&&E(e,r.categoryKey);let s=(f,y,m,x)=>{if(y!==void 0&&(!Number.isFinite(y)||y<m||y>x))throw new u("invalid_operation",`${f} must be from ${m} to ${x}`)};s("width",r.width,30,400),s("height",r.height,30,400),s("rotation",r.rotation,0,360);let l=r.points===null;if(r.points!=null){if(o.length!==1)throw new u("invalid_operation","points can be changed only for one booth at a time");let f=eo(r.points);if(!f.ok)throw new u("invalid_operation",f.message??"The booth outline is not a valid simple polygon")}let c=r.points!=null?r.points.map(f=>({x:f.x,y:f.y})):void 0;delete r.points;let d=ye(r,"Booth"),g=et(r,"Booth"),b=!1;for(let f of i){let y=JSON.stringify(f);Object.assign(f,r),d&&delete f.displayLabel,g&&delete f.displayType,l?delete f.points:c&&(f.points=c),JSON.stringify(f)!==y&&(b=!0)}return{floorId:n.floorId,changed:b,boothIds:o}}function zi(e,t){let n=O(e,t.floorId),o=[...new Set(t.gaAreaIds)];if(!o.length)throw new u("invalid_operation","At least one GA area id is required");let i=o.map(d=>n.objects.find(g=>g.type==="gaArea"&&g.id===d)),a=o.filter((d,g)=>!i[g]);if(a.length)throw new u("object_not_found","One or more GA area ids do not exist on the selected floor",{gaAreaIds:a});let r=structuredClone(t.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one GA area change is required");if(r.label!==void 0){if(r.label=r.label.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","label can be changed only for one GA area at a time");if(!r.label||r.label.length>80)throw new u("invalid_operation","GA area labels must contain 1 to 80 characters")}if(r.categoryKey!==void 0&&E(e,r.categoryKey),r.capacity!==void 0&&(!Number.isInteger(r.capacity)||r.capacity<1||r.capacity>W))throw new u("invalid_operation",`capacity must be an integer from 1 to ${W}`);if(r.cornerRadius!==void 0&&(!Number.isFinite(r.cornerRadius)||r.cornerRadius<0||r.cornerRadius>2e3))throw new u("invalid_operation","cornerRadius must be from 0 to 2000");let s=ye(r,"GA area"),l=et(r,"GA area");if(r.capacity!==void 0)for(let d of i){if(d.inventorySegments!==void 0&&r.capacity<d.capacity)throw new u("invalid_operation",`Joined GA area "${d.label}" cannot be reduced below ${d.capacity}; shrinking would delete stable inventory identities. Create or split a new surface instead.`,{gaAreaId:d.id,currentCapacity:d.capacity,requestedCapacity:r.capacity});if(d.inventorySegments!==void 0&&r.capacity>d.capacity&&Nt(d,r.capacity)===void 0)throw new u("invalid_operation",`Joined GA area "${d.label}" cannot append that capacity safely`,{gaAreaId:d.id})}let c=!1;for(let d of i){let g=JSON.stringify(d),b=r.capacity===void 0?d.inventorySegments:Nt(d,r.capacity);Object.assign(d,r),b!==void 0&&(d.inventorySegments=b),s&&delete d.displayLabel,l&&delete d.displayType,JSON.stringify(d)!==g&&(c=!0)}return{floorId:n.floorId,changed:c,gaAreaIds:o}}function ct(e,t){if(t.length<3)return 0;let n=i=>$(i,t,void 0),o=0;for(let i of e)n(F(i))&&(i.type==="row"?o+=X(i).length:i.type==="table"?o+=ce(i).length:(i.type==="gaArea"||i.type==="booth")&&(o+=de(i)));return o}function Ui(e,t){let n=O(e,t.floorId);if(!t.objectIds.length)throw new u("invalid_operation","At least one chart object id is required");if(new Set(t.objectIds).size!==t.objectIds.length)throw new u("invalid_operation","Chart object ids must be unique");let o=t.objectIds.map(s=>n.objects.find(l=>l.id===s)),i=t.objectIds.filter((s,l)=>!o[l]);if(i.length)throw new u("object_not_found","One or more chart object ids do not exist on the selected floor",{objectIds:i});let a=o,r=new Set(t.objectIds);for(let s=n.objects.length-1;s>=0;s--)r.has(n.objects[s].id)&&n.objects.splice(s,1);return{floorId:n.floorId,changed:!0,removedObjects:a.map(s=>({id:s.id,type:s.type})),removedInventory:a.reduce((s,l)=>s+de(l),0),remainingObjectCount:n.objects.length}}function Hi(e,t){let n=O(e,t.floorId),o=[...new Set(t.textIds)];if(!o.length)throw new u("invalid_operation","At least one text id is required");let i=o.map(c=>n.objects.find(d=>d.type==="text"&&d.id===c)),a=o.filter((c,d)=>!i[d]);if(a.length)throw new u("object_not_found",`Unknown text id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current text ids.`,{textIds:a});let r=structuredClone(t.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one text change is required");if(r.text!==void 0){if(r.text=r.text.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","content can be changed only for one text object at a time");if(!r.text||r.text.length>240)throw new u("invalid_operation","Text content must contain 1 to 240 characters")}if(r.fontSize!==void 0&&(!Number.isFinite(r.fontSize)||r.fontSize<8||r.fontSize>72))throw new u("invalid_operation","Text fontSize must be from 8 to 72");if(r.fontFamily!==void 0&&r.fontFamily!==null&&(r.fontFamily=r.fontFamily.normalize("NFKC").trim(),!r.fontFamily||r.fontFamily.length>120))throw new u("invalid_operation","Text fontFamily must contain 1 to 120 characters");if(r.rotation!==void 0&&(!Number.isFinite(r.rotation)||r.rotation<0||r.rotation>360))throw new u("invalid_operation","Text rotation must be from 0 to 360");if(r.color!==void 0&&r.color!==null&&(r.color=N(r.color,"Text color")),r.bold!==void 0&&typeof r.bold!="boolean")throw new u("invalid_operation","Text bold must be a boolean");if(r.italic!==void 0&&typeof r.italic!="boolean")throw new u("invalid_operation","Text italic must be a boolean");if(r.width!==void 0&&r.width!==null&&(!Number.isFinite(r.width)||r.width<40||r.width>1200))throw new u("invalid_operation",`Text width must be from ${40} to ${1200}`);if(r.align!==void 0&&!["left","center","right"].includes(r.align))throw new u("invalid_operation","Text align must be left, center, or right");if(r.lineHeight!==void 0&&(!Number.isFinite(r.lineHeight)||r.lineHeight<.8||r.lineHeight>3))throw new u("invalid_operation",`Text lineHeight must be from ${.8} to ${3}`);if(r.letterSpacing!==void 0&&(!Number.isFinite(r.letterSpacing)||r.letterSpacing<-2||r.letterSpacing>20))throw new u("invalid_operation",`Text letterSpacing must be from ${-2} to ${20}`);if(r.underline!==void 0&&typeof r.underline!="boolean")throw new u("invalid_operation","Text underline must be a boolean");if(r.opacity!==void 0&&(!Number.isFinite(r.opacity)||r.opacity<.1||r.opacity>1))throw new u("invalid_operation",`Text opacity must be from ${.1} to 1`);if(r.background!==void 0&&r.background!==null){r.background.color=N(r.background.color,"Text background color");let{padding:c=6,cornerRadius:d=4,opacity:g=.9}=r.background;if(!Number.isFinite(c)||c<0||c>40)throw new u("invalid_operation",`Text background padding must be from 0 to ${40}`);if(!Number.isFinite(d)||d<0||d>40)throw new u("invalid_operation",`Text background cornerRadius must be from 0 to ${40}`);if(!Number.isFinite(g)||g<.1||g>1)throw new u("invalid_operation",`Text background opacity must be from ${.1} to 1`)}if(["width","align","lineHeight","letterSpacing","underline","opacity","background"].some(c=>Object.prototype.hasOwnProperty.call(r,c))&&i.some(c=>c.semanticKind==="icon"))throw new u("invalid_operation","Text layout fields cannot be applied to venue icons");if(r.labelImportance!==void 0&&r.labelImportance!==null&&r.labelImportance!=="orientation"&&r.labelImportance!=="detail")throw new u("invalid_operation","Text labelImportance must be 'orientation', 'detail' or null");if(r.iconKey!==void 0){if(!Zn(r.iconKey))throw new u("invalid_operation","iconKey must be a known venue-icon registry key");if(i.some(c=>c.semanticKind!=="icon"))throw new u("invalid_operation",'iconKey can be set only on venue-icon objects (semanticKind "icon")')}let l=!1;for(let c of i){let d=JSON.stringify(c);r.iconKey!==void 0&&(c.iconKey=r.iconKey),r.text!==void 0&&(c.text=r.text),r.fontSize!==void 0&&(c.fontSize=r.fontSize),r.fontFamily===null?delete c.fontFamily:r.fontFamily!==void 0&&(c.fontFamily=r.fontFamily),r.rotation!==void 0&&(c.rotation=r.rotation),r.color===null?delete c.color:r.color!==void 0&&(c.color=r.color),r.bold!==void 0&&(r.bold?c.bold=!0:delete c.bold),r.italic!==void 0&&(r.italic?c.italic=!0:delete c.italic),r.width===null?delete c.width:r.width!==void 0&&(c.width=r.width),r.align!==void 0&&(r.align==="left"?delete c.align:c.align=r.align),r.lineHeight!==void 0&&(r.lineHeight===1.2?delete c.lineHeight:c.lineHeight=r.lineHeight),r.letterSpacing!==void 0&&(r.letterSpacing===0?delete c.letterSpacing:c.letterSpacing=r.letterSpacing),r.underline!==void 0&&(r.underline?c.underline=!0:delete c.underline),r.opacity!==void 0&&(r.opacity===1?delete c.opacity:c.opacity=r.opacity),r.background===null?delete c.background:r.background!==void 0&&(c.background=r.background),r.labelImportance===null?delete c.labelImportance:r.labelImportance!==void 0&&(c.labelImportance=r.labelImportance),JSON.stringify(c)!==d&&(Xe(c),l=!0)}return{floorId:n.floorId,changed:l,textIds:o}}function Vi(e,t){let n=O(e,t.floorId),o=[...new Set(t.rowIds)],i=o.map(b=>n.objects.find(f=>f.type==="row"&&f.id===b)),a=o.filter((b,f)=>!i[f]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let r=i.slice().sort((b,f)=>b.origin.y-f.origin.y||b.origin.x-f.origin.x),s=b=>b.segmentedRow?.displayLabel??b.displayLabel??b.label,l=Cn(r.map(b=>({label:s(b)})),t.options),c=t.displayType==null?void 0:t.displayType.normalize("NFKC").replace(/\s+/g," ").trim().slice(0,24),d=c===void 0||c===""||c==="Row"?t.displayType===void 0?void 0:null:c,g=!1;return r.forEach((b,f)=>{let y=l[f].label.normalize("NFKC").replace(/\s+/g," ").trim();if(s(b)!==y&&(g=!0,b.segmentedRow?b.segmentedRow.displayLabel=y:b.displayLabel=y),d!==void 0){if(d===null){b.displayType!==void 0&&(g=!0,delete b.displayType);return}b.displayType!==d&&(g=!0,b.displayType=d)}}),{floorId:n.floorId,changed:g,rows:r.map(b=>({id:b.id,displayLabel:s(b),...b.displayType?{displayType:b.displayType}:{}}))}}function qi(e,t){let n=Jn.find(c=>c.key===t.blockKey);if(!n)throw new u("invalid_operation",`Unknown seating block: ${t.blockKey}`,{blockKey:t.blockKey});let o=O(e,t.floorId),i=new Set,a=n.build().map(c=>structuredClone(c));for(let c of a)c.id=A(e,c.type,t.idFactory,i),Wn(c,t.center.x,t.center.y);for(let c of n.categories)e.categories.some(d=>d.key===c.key)||e.categories.push({...c});let r=a.filter(c=>c.type==="row");if(r.length){let c=0;for(let d of o.objects){if(d.type!=="row")continue;let g=Xn(d.label);g!=null&&(c=Math.max(c,g+1))}for(let d of r)d.label=V(c++)}let s=new Set(o.objects.flatMap(c=>"label"in c&&c.label?[c.label]:[]));for(let c of a){if((c.type==="table"||c.type==="booth")&&s.has(c.label)){let d=/^(.*?)(\d+)$/.exec(c.label),g=d?d[1]:`${c.label} `,b=d?Number.parseInt(d[2],10):1;do b++;while(s.has(`${g}${b}`));c.label=`${g}${b}`}"label"in c&&c.label&&s.add(c.label)}o.objects.push(...a);let l=null;if(n.sectionLabel&&t.wrapInSection!==!1){let c=le(a);if(c){let d={type:"section",id:A(e,"sec",t.idFactory,i),label:n.sectionLabel,outline:c};o.objects.push(d),l=d.id}}return{floorId:o.floorId,blockKey:n.key,createdIds:[...a.map(c=>c.id),...l?[l]:[]],sectionId:l}}function Ji(e){let t=structuredClone(e);if([t.start,t.control1,t.control2,t.end].some(a=>!Number.isFinite(a.x)||!Number.isFinite(a.y)))throw new u("invalid_operation","Exact row path points must be finite");let o=He(t,97),i=o.slice(1).reduce((a,r,s)=>a+Math.hypot(r.x-o[s].x,r.y-o[s].y),0);if(!Number.isFinite(i)||i<1)throw new u("invalid_operation","Exact row path must have at least one chart unit of usable length");return{path:t,length:i}}function oo(e,t){let n=O(e,t.floorId),o=n.objects.find(d=>d.type==="row"&&d.id===t.rowId);if(!o)throw new u("object_not_found",`Unknown row id: ${t.rowId}`,{rowId:t.rowId});let i=Ji(t.path),a=X(o),r=structuredClone(o);r.path=i.path,r.origin={...i.path.start};let s=X(r),l=a.map((d,g)=>Math.hypot(d.x-s[g].x,d.y-s[g].y)),c=JSON.stringify(o.path)!==JSON.stringify(i.path)||o.origin.x!==i.path.start.x||o.origin.y!==i.path.start.y;return{floorId:n.floorId,rowId:o.id,seatCount:o.seatCount,pathLength:i.length,averageSeatMovement:l.length?l.reduce((d,g)=>d+g,0)/l.length:0,maxSeatMovement:l.length?Math.max(...l):0,convertingFromParametric:!o.path,changed:c,preservesStableId:!0,preservesSeatMetadata:!0,preservesInventoryUnits:o.seatCount}}function Xi(e,t){let n=oo(e,t);if(!n.changed)return n;let i=O(e,n.floorId).objects.find(a=>a.type==="row"&&a.id===n.rowId);return i.path=structuredClone(t.path),i.origin={...t.path.start},delete i.arcFanGeneration,delete i.rowBlockGeneration,n}function Yi(e,t){let n=e.map((o,i)=>[...o,t[i]]);for(let o=0;o<3;o++){let i=o;for(let r=o+1;r<3;r++)Math.abs(n[r][o])>Math.abs(n[i][o])&&(i=r);if(Math.abs(n[i][o])<1e-9)return null;[n[o],n[i]]=[n[i],n[o]];let a=n[o][o];for(let r=o;r<4;r++)n[o][r]/=a;for(let r=0;r<3;r++){if(r===o)continue;let s=n[r][o];for(let l=o;l<4;l++)n[r][l]-=s*n[o][l]}}return[n[0][3],n[1][3],n[2][3]]}function Qi(e){if(e.length<3)return null;let t=[[0,0,0],[0,0,0],[0,0,0]],n=[0,0,0];for(let i of e){if(!Number.isFinite(i.x)||!Number.isFinite(i.y))return null;let a=[2*i.x,2*i.y,1],r=i.x**2+i.y**2;for(let s=0;s<3;s++){n[s]+=a[s]*r;for(let l=0;l<3;l++)t[s][l]+=a[s]*a[l]}}let o=Yi(t,n);return o?{x:o[0],y:o[1]}:null}function to(e){let t=((e+180)%360+360)%360-180;return t===-180&&(t=180),t}function ro(e,t){let n=O(e,t.floorId),o=n.objects.find(f=>f.type==="section"&&f.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});let i=t.strength??100;if(!Number.isFinite(i)||i<0||i>100)throw new u("invalid_operation","Section row-fit strength must be from 0 to 100");let a=k(e).find(f=>f.id===n.floorId),r=t.mode==="outline"?Qi(o.outline):t.focalPoint??a.focalPoint??e.focalPoint;if(!r||!Number.isFinite(r.x)||!Number.isFinite(r.y))throw new u("invalid_operation",`Section ${t.mode} fit has no finite center`);let s=n.objects.filter(f=>f.type==="row"&&$(F(f),o.outline,o.holes)),l=s.filter(f=>!!f.path).map(f=>f.id),c=[],d=[],g=i/100;for(let f of s){if(f.path)continue;if(f.seatCount<2){c.push(f.id);continue}let y=Math.hypot(f.origin.x-r.x,f.origin.y-r.y);if(y<=f.seatSpacing/2+1e-6){c.push(f.id);continue}let m=2*Math.asin(f.seatSpacing/(2*y))/ne,x=X(f),v=Math.atan2(f.origin.x-r.x,f.origin.y-r.y)/ne,p=(f.curve!==0?Math.sign(f.curve):x.length>1&&Math.sign(to(Math.atan2(x[1].x-r.x,x[1].y-r.y)/ne-v))||1)*m*(f.seatCount-1);if(Math.abs(p)>320){c.push(f.id);continue}let w=-v,S=f.curve+(p-f.curve)*g,I=f.rotation+to(w-f.rotation)*g,C={...f,curve:S,rotation:I},L=X(C).map((T,G)=>Math.hypot(T.x-x[G].x,T.y-x[G].y));d.push({rowId:f.id,fromCurve:f.curve,targetCurve:p,resultCurve:S,fromRotation:f.rotation,resultRotation:I,rmsMovement:Math.sqrt(L.reduce((T,G)=>T+G**2,0)/L.length),maxMovement:Math.max(...L)})}let b=d.map(f=>f.rmsMovement);return{floorId:n.floorId,sectionId:o.id,mode:t.mode,fitCenter:{...r},strength:i,rows:d,skippedPathRowIds:l,skippedInvalidRowIds:c,averageMovement:b.length?b.reduce((f,y)=>f+y,0)/b.length:0,maxMovement:d.length?Math.max(...d.map(f=>f.maxMovement)):0}}function Zi(e,t){let n=ro(e,t),o=O(e,n.floorId),i=o.objects.find(r=>r.type==="section"&&r.id===n.sectionId),a=!1;for(let r of n.rows){let s=o.objects.find(l=>l.type==="row"&&l.id===r.rowId);(s.curve!==r.resultCurve||s.rotation!==r.resultRotation)&&(s.curve=r.resultCurve,s.rotation=r.resultRotation,delete s.arcFanGeneration,delete s.rowBlockGeneration,a=!0)}return(i.smoothing??0)!==n.strength&&(i.smoothing=n.strength,a=!0),{...n,changed:a}}function io(e,t,n,o){let i=Q(e,t,n),a=Q(e,t,o),r=Q(n,o,e),s=Q(n,o,t);return i*a<-1e-9&&r*s<-1e-9}function no(e,t){return e.some((n,o)=>{let i=e[(o+1)%e.length];return t.some((a,r)=>io(n,i,a,t[(r+1)%t.length]))})}function Wi(e){if(e.length<3||e.length>256||Math.abs(Re(e))<1||e.some(t=>!Number.isFinite(t.x)||!Number.isFinite(t.y)))return!1;for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++)if(!(n===t+1||t===0&&n===e.length-1)&&io(e[t],e[(t+1)%e.length],e[n],e[(n+1)%e.length]))return!1;return!0}function lt(e,t,n){let o=O(e,t),i=o.objects.find(a=>(a.type==="section"||a.type==="gaArea")&&a.id===n);if(!i)throw new u("object_not_found",`Unknown polygon object id: ${n}`,{objectId:n});return{target:o,object:i,outer:i.type==="section"?i.outline:i.points}}function dt(e,t){let{target:n,object:o,outer:i}=lt(e,t.floorId,t.objectId),a=structuredClone(t.points);if(!Wi(a))throw new u("invalid_operation","Opening must be a finite, non-self-intersecting shape with 3\u2013256 corners");if(a.some(c=>!$(c,i,void 0)))throw new u("invalid_operation","Every opening corner must stay inside the outer boundary");if(no(a,i))throw new u("invalid_operation","Opening edges cannot cross the outer boundary");let r=o.holes??[],s=t.holeIndex??r.length;if(!Number.isInteger(s)||s<0||s>r.length||t.holeIndex!=null&&s>=r.length)throw new u("invalid_operation","Opening not found");for(let c=0;c<r.length;c++){if(c===t.holeIndex)continue;let d=r[c];if(no(a,d)||$(a[0],d,void 0)||$(d[0],a,void 0))throw new u("invalid_operation","Openings cannot overlap or contain one another")}let l=n.objects.filter(c=>c.id!==o.id&&c.type!=="section"&&$(F(c),a,void 0));return{floorId:n.floorId,objectId:o.id,objectType:o.type,holeIndex:s,vertexCount:a.length,excludedObjectIds:l.map(c=>c.id),excludedInventoryUnits:ct(n.objects.filter(c=>c.id!==o.id),a),preservesExactOuterPath:o.type==="section"&&!!o.outlinePath}}function ea(e,t){let n=dt(e,t),{object:o}=lt(e,n.floorId,n.objectId);return o.holes??=[],t.holeIndex==null?o.holes.push(structuredClone(t.points)):o.holes[t.holeIndex]=structuredClone(t.points),{...n,changed:!0}}function ao(e,t){let{target:n,object:o}=lt(e,t.floorId,t.objectId);if(!Number.isInteger(t.holeIndex)||t.holeIndex<0||t.holeIndex>=(o.holes?.length??0))throw new u("invalid_operation","Opening not found");let i=o.holes[t.holeIndex],a=n.objects.filter(r=>r.id!==o.id&&r.type!=="section"&&$(F(r),i,void 0));return{floorId:n.floorId,objectId:o.id,objectType:o.type,holeIndex:t.holeIndex,vertexCount:i.length,excludedObjectIds:a.map(r=>r.id),excludedInventoryUnits:ct(n.objects.filter(r=>r.id!==o.id),i),preservesExactOuterPath:o.type==="section"&&!!o.outlinePath}}function ta(e,t){let n=ao(e,t),{object:o}=lt(e,n.floorId,n.objectId);return o.holes.splice(t.holeIndex,1),o.holes.length||delete o.holes,{...n,changed:!0}}function na(e){let t=re(e);if(!t)throw new u("invalid_operation","Section view photo must be a safe HTTPS or base64 raster image reference");return t}function so(e,t){let n=[...new Set(t)];if(!n.length)throw new u("invalid_operation","At least one section id is required");let o=n.map(r=>e.find(s=>s.type==="section"&&s.id===r)),i=n.filter((r,s)=>!o[s]);if(i.length)throw new u("object_not_found",`Unknown section id(s): ${i.join(", ")} on the selected floor. Call get_chart to list current section ids.`,{sectionIds:i});let a=o;return{requested:n,sections:a,logicalSectionIds:[...new Set(a.map(r=>r.logicalSectionId??r.id))]}}function co(e,t){let n=O(e,t.floorId),o=so(n.objects,t.sectionIds),i=Fe(We(e,n.floorId)),a=new Map(i.sections.map(f=>[f.id,f])),r=new Map(n.objects.map(f=>[f.id,f])),s=o.logicalSectionIds.flatMap(f=>a.get(f)?.objectIds??[]),l=new Set,c=new Set(o.logicalSectionIds),d=new Set(n.objects.filter(f=>f.type==="section"&&c.has(f.logicalSectionId??f.id)).flatMap(f=>f.editor?.defaultCategoryKey?[f.editor.defaultCategoryKey]:[]));for(let f of s){let y=r.get(f);if(y)if(y.type==="row"||y.type==="table")for(let m of it(y).keys())l.add(m);else(y.type==="booth"||y.type==="gaArea")&&l.add(y.categoryKey)}let g=o.logicalSectionIds.every(f=>(a.get(f)?.seatCount??0)>0),b=o.logicalSectionIds.every(f=>a.get(f)?.objectIds.some(y=>{let m=r.get(y);return m?.type==="row"||m?.type==="table"||m?.type==="booth"})===!0);return{floorId:n.floorId,sectionIds:o.requested,logicalSectionIds:o.logicalSectionIds,objectIds:s,categoryApplicable:g,...g&&l.size===1?{categoryKey:[...l][0]}:!g&&!s.length&&d.size===1?{categoryKey:[...d][0]}:{},categoryMixed:g?l.size!==1:!s.length&&d.size>1,viewApplicable:b}}function oa(e,t){E(e,t.categoryKey);let n=co(e,t);if(!n.categoryApplicable&&n.objectIds.length)throw new u("invalid_operation","A mixed selection of empty and occupied logical sections cannot be assigned together",{logicalSectionIds:n.logicalSectionIds});let o=O(e,n.floorId),i=new Set(n.objectIds),a=!1,r=0,s=new Set(n.logicalSectionIds);for(let l of o.objects)l.type!=="section"||!s.has(l.logicalSectionId??l.id)||l.editor?.defaultCategoryKey!==t.categoryKey&&(l.editor={...l.editor,defaultCategoryKey:t.categoryKey},a=!0);for(let l of o.objects){if(!i.has(l.id)||l.type!=="row"&&l.type!=="table"&&l.type!=="booth"&&l.type!=="gaArea"||(l.categoryKey!==t.categoryKey&&(l.categoryKey=t.categoryKey,a=!0),l.type!=="row"&&l.type!=="table"||!l.overrides?.length))continue;let c=l.overrides.flatMap(d=>{if(d.categoryKey===void 0)return[d];let g={...d};return delete g.categoryKey,r++,a=!0,Object.keys(g).some(b=>b!=="index")?[g]:[]});c.length?l.overrides=c:delete l.overrides}return{...n,changed:a,categoryKey:t.categoryKey,categoryMixed:!1,clearedSeatOverrideCount:r}}function Kt(e,t){let n=O(e,t.floorId),o=so(n.objects,t.sectionIds),{requested:i}=o,a=structuredClone(t.patch),r=new Set(["label","displayLabel","entrance","viewFromSeatUrl","viewFromSeatMeta","labelPresentation","labelStyle","zone","elevation","height","rake","surfaceKind","color"]),s=Object.keys(a).filter(f=>!r.has(f));if(s.length)throw new u("invalid_operation",`Unsupported section metadata field(s): ${s.join(", ")}`);if(!Object.keys(a).length)throw new u("invalid_operation","At least one section metadata change is required");if(a.label!==void 0){if(a.label=a.label.normalize("NFKC").trim(),i.length!==1)throw new u("invalid_operation","label can be changed only for one section at a time");if(!a.label||a.label.length>80)throw new u("invalid_operation","Section labels must contain 1 to 80 characters")}if(a.displayLabel!==void 0&&a.displayLabel!==null){if(a.displayLabel=a.displayLabel.normalize("NFKC").trim(),i.length!==1)throw new u("invalid_operation","displayLabel can be changed only for one section at a time");if(!a.displayLabel||a.displayLabel.length>80)throw new u("invalid_operation","Section display labels must contain 1 to 80 characters")}if(a.entrance!==void 0&&a.entrance!==null&&(a.entrance=a.entrance.normalize("NFKC").trim(),a.entrance.length>40))throw new u("invalid_operation","Section entrance must be at most 40 characters");if(a.viewFromSeatUrl!==void 0&&a.viewFromSeatUrl!==null&&(a.viewFromSeatUrl=na(a.viewFromSeatUrl)),a.labelPresentation?.position&&(!Number.isFinite(a.labelPresentation.position.x)||!Number.isFinite(a.labelPresentation.position.y)))throw new u("invalid_operation","Section label position must be finite");if(a.labelPresentation?.rotation!=null&&!Number.isFinite(a.labelPresentation.rotation))throw new u("invalid_operation","Section label rotation must be finite");if(a.labelPresentation!==void 0&&tt(a.labelPresentation,"Section"),a.labelStyle!==void 0&&me(a.labelStyle,"Section"),a.zone!==void 0&&a.zone!==null&&!(e.zones??[]).some(f=>f.id===a.zone))throw new u("object_not_found",`Unknown chart zone: ${a.zone}`,{zoneId:a.zone});if(a.elevation!==void 0&&(!Number.isInteger(a.elevation)||a.elevation<0||a.elevation>3))throw new u("invalid_operation","Section elevation must be an integer from 0 to 3");if(a.height!==void 0&&a.height!==null&&(!Number.isFinite(a.height)||a.height<0||a.height>120))throw new u("invalid_operation","Section height must be a number from 0 to 120 metres");if(a.rake!==void 0&&a.rake!==null&&(!Number.isFinite(a.rake)||a.rake<0||a.rake>45))throw new u("invalid_operation","Section rake must be a number from 0 to 45 degrees");if(a.surfaceKind!==void 0&&a.surfaceKind!==null&&a.surfaceKind!=="flat"&&a.surfaceKind!=="rakedRows")throw new u("invalid_operation","Section surfaceKind must be 'flat' or 'rakedRows'");a.color!==void 0&&a.color!==null&&(a.color=N(a.color,"Section color"));let l=a.displayLabel!==void 0||a.entrance!==void 0||a.viewFromSeatUrl!==void 0||a.viewFromSeatMeta!==void 0||a.labelStyle!==void 0||a.zone!==void 0,c=new Set(o.logicalSectionIds),d=l?n.objects.filter(f=>f.type==="section"&&c.has(f.logicalSectionId??f.id)):[],g=new Set,b=!1;for(let f of o.sections){let y=JSON.stringify(f);a.label!==void 0&&(f.label=a.label),a.labelPresentation===null?delete f.labelPresentation:a.labelPresentation!==void 0&&(f.labelPresentation=a.labelPresentation),a.elevation!==void 0&&(f.elevation=a.elevation);let m=x=>{f.physical3dProvenance&&(delete f.physical3dProvenance[x],Object.keys(f.physical3dProvenance).length===0&&delete f.physical3dProvenance)};a.height===null?(delete f.height,m("height")):a.height!==void 0&&(f.height=a.height,f.physical3dProvenance={...f.physical3dProvenance,height:{status:"confirmed",source:"user-review",note:"Section front-edge height reviewed through the shared Designer/Copilot operation."}}),a.rake===null?(delete f.rake,m("rake")):a.rake!==void 0&&(f.rake=a.rake,f.physical3dProvenance={...f.physical3dProvenance,rake:{status:"confirmed",source:"user-review",note:"Section rake reviewed through the shared Designer/Copilot operation."}}),a.surfaceKind===null?(delete f.surfaceKind,m("surfaceKind")):a.surfaceKind!==void 0&&(f.surfaceKind=a.surfaceKind,f.physical3dProvenance={...f.physical3dProvenance,surfaceKind:{status:"confirmed",source:"user-review",note:"Section surface behavior reviewed through the shared Designer/Copilot operation."}}),a.color===null?delete f.color:a.color!==void 0&&(f.color=a.color),JSON.stringify(f)!==y&&(b=!0,g.add(f.id))}for(let f of d){let y=JSON.stringify(f),m=f.viewFromSeatUrl;if(a.displayLabel===null?delete f.displayLabel:a.displayLabel!==void 0&&(f.displayLabel=a.displayLabel),a.entrance===null||a.entrance===""?delete f.entrance:a.entrance!==void 0&&(f.entrance=a.entrance),a.viewFromSeatUrl===null||a.viewFromSeatUrl===""?delete f.viewFromSeatUrl:a.viewFromSeatUrl!==void 0&&(f.viewFromSeatUrl=a.viewFromSeatUrl),!f.viewFromSeatUrl||a.viewFromSeatMeta===null?delete f.viewFromSeatMeta:a.viewFromSeatMeta!==void 0?f.viewFromSeatMeta=structuredClone(a.viewFromSeatMeta):a.viewFromSeatUrl!==void 0&&f.viewFromSeatUrl!==m&&delete f.viewFromSeatMeta,a.labelStyle!==void 0){let x=nt(f.labelPresentation,a.labelStyle);x?f.labelPresentation=x:delete f.labelPresentation}a.zone===null?delete f.zone:a.zone!==void 0&&(f.zone=a.zone),JSON.stringify(f)!==y&&(b=!0,g.add(f.id))}return{floorId:n.floorId,changed:b,sectionIds:i,affectedSectionIds:[...g]}}function lo(e,t){let n=O(e,t.floorId),o=n.objects.find(a=>a.type==="section"&&a.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});if(o.outlinePath)throw new u("invalid_operation",`Section ${o.id} has an exact path; polygon conversion requires a separate loss review`,{sectionId:o.id,representation:"exact-path"});if(!o.geometry)throw new u("invalid_operation",`Section ${o.id} is already a manual polygon`,{sectionId:o.id,representation:"manual-polygon"});let i=n.objects.filter(a=>a.id!==o.id&&a.type!=="section"&&$(F(a),o.outline,o.holes));return{floorId:n.floorId,sectionId:o.id,sectionLabel:o.label,source:{representation:"generated-polygon",generator:structuredClone(o.geometry)},target:{representation:"manual-polygon"},geometryChanged:!1,preserved:{stableId:!0,outlineVertexCount:o.outline.length,holeCount:o.holes?.length??0,memberObjectIds:i.map(a=>a.id),inventoryUnits:i.reduce((a,r)=>a+de(r),0),durableReferenceSource:!!o.referenceSource,inventoryExclusionEvidence:!!o.referenceInventoryExclusion},removedFields:["geometry"]}}function ra(e,t){let n=lo(e,t),i=O(e,n.floorId).objects.find(a=>a.type==="section"&&a.id===n.sectionId);return delete i.geometry,{...n,changed:!0}}function uo(e,t){let n=(...s)=>s.every(Number.isFinite),o,i=1,a=!1,r=!0;if(t.kind==="translate"){if(!n(t.dx,t.dy))throw new u("invalid_operation","Section translation must be finite");r=t.dx!==0||t.dy!==0,o=s=>({x:s.x+t.dx,y:s.y+t.dy})}else if(t.kind==="scale"){if(!n(t.factor)||t.factor<=0||t.factor>100)throw new u("invalid_operation","Section scale factor must be finite and greater than 0");r=t.factor!==1,i=t.factor;let s=F(e);o=l=>({x:s.x+(l.x-s.x)*t.factor,y:s.y+(l.y-s.y)*t.factor})}else if(t.kind==="rotate"){if(!n(t.degrees))throw new u("invalid_operation","Section rotation must be finite");r=(t.degrees%360+360)%360!==0;let l=t.degrees*Math.PI/180,c=Math.cos(l),d=Math.sin(l),g=F(e);o=b=>{let f=b.x-g.x,y=b.y-g.y;return{x:g.x+f*c-y*d,y:g.y+f*d+y*c}}}else{if(!n(t.coordinate))throw new u("invalid_operation","Section reflection coordinate must be finite");a=!0,o=t.axis==="h"?s=>({x:2*t.coordinate-s.x,y:s.y}):s=>({x:s.x,y:2*t.coordinate-s.y})}return r&&(e.outline=e.outline.map(o),e.sourceOutline&&(e.sourceOutline=e.sourceOutline.map(o)),e.outlinePath&&(e.outlinePath=Ot(e.outlinePath,o,i,a)),e.holes&&(e.holes=ae(e.holes).map(s=>s.map(o)))),{changed:r,sectionId:e.id,representation:e.outlinePath?"exact-path":"polygon",outlineVertexCount:e.outline.length,holeCount:e.holes?.length??0,pathSegmentKinds:e.outlinePath?.segments.map(s=>s.kind)??[]}}function ia(e,t){let n=O(e,t.floorId),o=n.objects.find(i=>i.type==="section"&&i.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});return{floorId:n.floorId,...uo(o,t.transform)}}function aa(e,t){let n=O(e,t.floorId),o=n.objects.find(s=>s.type==="section"&&s.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});let i=structuredClone(t.path);if(!Ve(i))throw new u("invalid_operation","Exact section path is not finite, continuous, closed, or radius-correct");let a=Ct(i),r=JSON.stringify(o.outlinePath)!==JSON.stringify(i)||JSON.stringify(o.outline)!==JSON.stringify(a)||o.sourceOutline!==void 0||o.cornerSmoothing!==void 0;return r&&(o.outlinePath=i,o.outline=a,delete o.geometry,delete o.sourceOutline,delete o.cornerSmoothing),{floorId:n.floorId,sectionId:o.id,changed:r,segmentKinds:i.segments.map(s=>s.kind),sampledVertexCount:a.length,holeCount:o.holes?.length??0}}function sa(e){return e.geometry?null:e.sourceOutline?.length?e.sourceOutline:e.outlinePath?null:e.outline?.length?e.outline:null}function ca(e,t){return fo(e,{floorId:t.floorId,sectionIds:t.sectionIds,cornerSmoothing:t.strength})}function fo(e,t){let n=O(e,t.floorId);if(t.cornerSmoothing!==void 0&&!Number.isFinite(t.cornerSmoothing))throw new u("invalid_operation","Corner smoothing must be a number from 0 to 100");if(t.edgeCurvature!=null&&t.edgeCurvature.some(s=>!Number.isFinite(s)))throw new u("invalid_operation","Edge curvature values must be numbers from -100 to 100");let o=[...new Set(t.sectionIds)],i=new Set,a=new Map,r=!1;try{for(let s of o){let l=n.objects.find(h=>h.type==="section"&&h.id===s);if(!l||!sa(l))continue;let d=structuredClone(l);a.set(l.id,{section:l,snapshot:d});let g=JSON.stringify(l),b=(l.sourceOutline??l.outline).map(h=>({...h})),f=Math.min(100,Math.max(0,t.cornerSmoothing??l.cornerSmoothing??0)),m=(t.edgeCurvature===void 0?l.edgeCurvature:t.edgeCurvature??void 0)?.map(h=>Math.min(100,Math.max(-100,h))),x=m?.some(h=>Math.abs(h)>.5)===!0,v=f>.5||x?xn(b,{cornerSmoothing:f,...x?{edgeCurvature:m}:{}}):null;v?(l.sourceOutline=b,l.outlinePath=v,l.outline=Ct(v),f>.5?l.cornerSmoothing=f:delete l.cornerSmoothing,x?l.edgeCurvature=[...m]:delete l.edgeCurvature):(l.outline=b,delete l.outlinePath,delete l.sourceOutline,delete l.cornerSmoothing,delete l.edgeCurvature);for(let h=0;h<(l.holes?.length??0);h+=1)dt(e,{floorId:n.floorId,objectId:l.id,points:l.holes[h],holeIndex:h});JSON.stringify(l)!==g&&(r=!0,i.add(l.id))}}catch(s){for(let{section:l,snapshot:c}of a.values()){let d=l;for(let g of Object.keys(d))delete d[g];Object.assign(l,structuredClone(c))}throw s}return{floorId:n.floorId,changed:r,sectionIds:o,affectedSectionIds:[...i]}}function la(e,t,n={}){let o=!1;for(let i of t){let a=Kt(e,{floorId:i.floorId,sectionIds:[i.sectionId],patch:{height:i.height,rake:i.rake,surfaceKind:i.surfaceKind}});o||=a.changed}if(n.stage){let i=O(e,n.stage.floorId).objects.find(a=>a.type==="shape"&&a.id===n.stage.shapeId);i&&i.role!=="stage"&&(i.role="stage",o=!0),i&&n.stage.stageKind&&!i.stageKind&&(i.stageKind=n.stage.stageKind,o=!0)}for(let{shapeId:i,floorId:a,role:r}of n.roles??[]){let s=O(e,a).objects.find(l=>l.type==="shape"&&l.id===i);s&&!s.role&&(s.role=r,o=!0)}for(let{floorId:i,point:a}of n.focal??[]){let r=Ee(a,"focalPoint"),s=i?e.floors?.find(c=>c.id===i):void 0,l=s?s.focalPoint:e.focalPoint;l?.x===r.x&&l?.y===r.y||(s?s.focalPoint=r:e.focalPoint=r,o=!0)}return e.floors?.length&&ue(e),{changed:o}}var $t=.15,Bt=1.6;var da=/^#?([\da-f]{3}|[\da-f]{6})$/i;function Ut(e){let t=da.exec((e??"").trim());if(!t)return null;let n=t[1].length===3?t[1].split("").map(i=>i+i).join(""):t[1],o=parseInt(n,16);return[o>>16&255,o>>8&255,o&255]}function Ht(e,t){let n=a=>{let r=Ut(a);if(!r)return null;let s=h=>{let p=h/255;return p<=.04045?p/12.92:((p+.055)/1.055)**2.4},l=s(r[0]),c=s(r[1]),d=s(r[2]),g=(.4124*l+.3576*c+.1805*d)/.95047,b=.2126*l+.7152*c+.0722*d,f=(.0193*l+.1192*c+.9505*d)/1.08883,y=h=>h>.008856?Math.cbrt(h):7.787*h+16/116,m=y(g),x=y(b),v=y(f);return[116*x-16,500*(m-x),200*(x-v)]},o=n(e),i=n(t);return o&&i?Math.hypot(o[0]-i[0],o[1]-i[1],o[2]-i[2]):null}function zt(e){let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function go(e){return .2126*zt(e[0])+.7152*zt(e[1])+.0722*zt(e[2])}function ut(e,t){let n=Ut(e),o=Ut(t);if(!n||!o)return null;let i=go(n),a=go(o);return(Math.max(i,a)+.05)/(Math.min(i,a)+.05)}var bo=["butt","round","square"],ho=["miter","round","bevel"],po=["none","arrow"];function Vt(e){return e==="line"||e==="polyline"}var yo=[{key:"circle",label:"Standard seat",shortLabel:"Standard",useCase:"General assigned seating",group:"general",path:null,bounds:null,mark:null},{key:"theatre",label:"Theatre chair",shortLabel:"Theatre",useCase:"Auditoriums, arenas and stadium stands",group:"fixed",path:"M4.5 3.5 Q4.5 1.5 6.5 1.5 L17.5 1.5 Q19.5 1.5 19.5 3.5 L19.5 13 L4.5 13 Z M3.5 12 L20.5 12 Q22.5 12 22.5 14 L22.5 21 Q22.5 22.5 21 22.5 Q19.5 22.5 19.5 21 L19.5 17.5 L4.5 17.5 L4.5 21 Q4.5 22.5 3 22.5 Q1.5 22.5 1.5 21 L1.5 14 Q1.5 12 3.5 12 Z",bounds:{x:1.5,y:1.5,width:21,height:21},mark:{x:12,y:10,radius:6}},{key:"dining",label:"Dining chair",shortLabel:"Dining",useCase:"Banquets, restaurants and table seating",group:"flexible",path:"M7 1 Q6 1 6 2.5 L6.75 10.5 L5 10.5 Q4 10.5 4 12 L4 14 Q4 15 5.25 15 L6 15 L4 23 L7 23 L9.5 15 L14.5 15 L17 23 L20 23 L18 15 L18.75 15 Q20 15 20 14 L20 12 Q20 10.5 19 10.5 L17.25 10.5 L18 2.5 Q18 1 17 1 Z",bounds:{x:4,y:1,width:16,height:22},mark:{x:12,y:10,radius:4.5}},{key:"folding",label:"Folding chair",shortLabel:"Folding",useCase:"Concert floors, ceremonies and conferences",group:"flexible",path:"M6 2 Q5 2 5 3 L6 8 L18 8 L19 3 Q19 2 18 2 Z M5 9 L19 9 Q20 9 20 10.5 L19 13 L5 13 L4 10.5 Q4 9 5 9 Z M6 12 L9 12 L12 17 L15 12 L18 12 L14 19 L17 23 L14 23 L12 21 L10 23 L7 23 L10 19 Z",bounds:{x:4,y:2,width:16,height:21},mark:{x:12,y:5,radius:3}},{key:"armchair",label:"Premium armchair",shortLabel:"Armchair",useCase:"Boxes, lounges and club seating",group:"premium",path:"M3.5 4 Q3.5 1.5 6 1.5 L18 1.5 Q20.5 1.5 20.5 4 L20.5 13 L3.5 13 Z M1.5 12.5 Q1.5 10 3.25 10 Q5 10 5 12.5 L5 13.5 L19 13.5 L19 12.5 Q19 10 20.75 10 Q22.5 10 22.5 12.5 L22.5 19.5 Q22.5 22 20 22 L4 22 Q1.5 22 1.5 19.5 Z",bounds:{x:1.5,y:1.5,width:21,height:20.5},mark:{x:12,y:7.5,radius:5.5}},{key:"recliner",label:"Recliner",shortLabel:"Recliner",useCase:"Luxury cinemas and premium clubs",group:"premium",path:"M7 2 Q7 1 8.5 1 L15.5 1 Q17 1 17 2 L19 13 L5 13 Z M4 9 Q2 9 2 11.5 L2 16 Q2 18 4 18 L6 18 L6 15 L18 15 L18 18 L20 18 Q22 18 22 16 L22 11.5 Q22 9 20 9 Q18 9 18 11 L18 13 L6 13 L6 11 Q6 9 4 9 Z M7 17 L17 17 Q18 17 18.5 18.5 L19.5 22.5 L4.5 22.5 L5.5 18.5 Q6 17 7 17 Z",bounds:{x:2,y:1,width:20,height:21.5},mark:{x:12,y:8,radius:5}},{key:"stool",label:"Stool",shortLabel:"Stool",useCase:"Bars, high-tops and seating rails",group:"flexible",path:"M6 2.5 L18 2.5 Q22 2.5 22 6.5 L22 12 Q22 16 18 16 L6 16 Q2 16 2 12 L2 6.5 Q2 2.5 6 2.5 Z M6 15.5 L9.5 15.5 L7.5 22.5 L3 22.5 Z M14.5 15.5 L18 15.5 L20.5 22.5 L16 22.5 Z",bounds:{x:2,y:2.5,width:20,height:20},mark:{x:12,y:9.25,radius:6.5}},{key:"bench",label:"Bench place",shortLabel:"Bench",useCase:"Pews, bleachers and terraces",group:"fixed",path:"M2.5 0.5 L21.5 0.5 Q23 0.5 23 2 L23 5 Q23 6.5 21.5 6.5 L2.5 6.5 Q1 6.5 1 5 L1 2 Q1 0.5 2.5 0.5 Z M2 7.5 L22 7.5 Q23.5 7.5 23.5 9 L23.5 15.5 Q23.5 17 22 17 L18 17 L18 21.5 Q18 22.5 16.75 22.5 Q15.5 22.5 15.5 21.5 L15.5 17 L8.5 17 L8.5 21.5 Q8.5 22.5 7.25 22.5 Q6 22.5 6 21.5 L6 17 L2 17 Q0.5 17 0.5 15.5 L0.5 9 Q0.5 7.5 2 7.5 Z",bounds:{x:.5,y:.5,width:23,height:22},mark:{x:12,y:12.25,radius:4.75}}],Jl=yo.map(e=>e.key),ua=new Map(yo.map(e=>[e.key,e]));function Ge(e){return typeof e=="string"&&ua.has(e)}var fa=new Set(["companion","child","senior","student","membership","custom"]);function we(e){if(!e.length)throw new u("invalid_operation","A chart must have at least one category");let t=new Set,n=new Map,o=structuredClone(e);for(let i of o){let a=i.key.trim(),r=i.label.normalize("NFKC").trim();if(!a||a.length>160||t.has(a))throw new u("invalid_operation",`Category keys must be non-empty and unique: ${a}`,{categoryKey:a});if(t.add(a),!r||r.length>80)throw new u("invalid_operation",`Category labels must contain 1 to 80 characters: ${a}`,{categoryKey:a});let s=r.toLocaleLowerCase("en"),l=n.get(s);if(l)throw new u("duplicate_category_label",`Categories ${l} and ${a} share the same label`,{categoryKeys:[l,a],label:r});if(n.set(s,a),!/^#[0-9a-fA-F]{6}$/.test(i.color))throw new u("invalid_operation",`Category ${a} must use a six-digit hex color`,{categoryKey:a});if(i.referenceDirectSeatImport!==void 0){let c=i.referenceDirectSeatImport;if(c.assetId!==c.assetId.trim()||c.assetId.length>160||!c.assetId||c.familyId!==c.familyId.trim()||!/^source-color:(?:#[0-9a-f]{6}(?:\+#[0-9a-f]{6})*|unclassified)$/i.test(c.familyId))throw new u("invalid_operation",`Category ${a} has invalid direct-seat import provenance`,{categoryKey:a})}if(i.price!=null&&(!Number.isFinite(i.price)||i.price<0||i.price>1e6))throw new u("invalid_operation",`Category ${a} price must be from 0 to 1000000`,{categoryKey:a});if(i.seatGlyph!=null&&!Ge(i.seatGlyph))throw new u("invalid_operation",`Category ${a} has an unknown seat glyph`,{categoryKey:a,seatGlyph:i.seatGlyph});if((i.seatGlyph==null||i.seatGlyph==="circle")&&delete i.seatGlyph,i.tiers!=null)if(!i.tiers.length)delete i.tiers;else{if(i.tiers.length>20)throw new u("invalid_operation",`Category ${a} supports at most 20 ticket tiers`);let c=new Set,d=new Set;for(let g of i.tiers){let b=g.id.trim(),f=g.name.normalize("NFKC").trim(),y=f.toLocaleLowerCase("en");if(!b||b.length>160||c.has(b))throw new u("invalid_operation",`Ticket tier ids must be non-empty and unique in category ${a}`,{categoryKey:a,tierId:b});if(!f||f.length>80||d.has(y))throw new u("invalid_operation",`Ticket tier names must be non-empty and unique in category ${a}`,{categoryKey:a,tierName:f});if(!Number.isFinite(g.price)||g.price<0||g.price>1e6)throw new u("invalid_operation",`Ticket tier ${b} price must be from 0 to 1000000`,{categoryKey:a,tierId:b});if(g.restriction!=null&&!fa.has(g.restriction))throw new u("invalid_operation",`Ticket tier ${b} has an unknown restriction`,{categoryKey:a,tierId:b});if(g.buyerMessage!=null){if(g.buyerMessage=g.buyerMessage.normalize("NFKC").trim(),!g.buyerMessage)delete g.buyerMessage;else if(g.buyerMessage.length>240)throw new u("invalid_operation",`Ticket tier ${b} buyer guidance must be at most 240 characters`,{categoryKey:a,tierId:b})}if(g.currency!=null&&(g.currency=g.currency.trim().toUpperCase(),!/^[A-Z]{3}$/.test(g.currency)))throw new u("invalid_operation",`Ticket tier ${b} must use a three-letter ISO currency`,{categoryKey:a,tierId:b});if(g.applicability!=null){let m=g.applicability.seatLabels?.map(v=>v.normalize("NFKC").trim()),x=g.applicability.accessibility;if(m&&(!m.length||m.length>1e4||m.some(v=>!v||v.length>160)||new Set(m).size!==m.length)||x&&(!x.length||x.some(v=>!ke.some(h=>h.key===v))||new Set(x).size!==x.length))throw new u("invalid_operation",`Ticket tier ${b} has invalid seat applicability`,{categoryKey:a,tierId:b});g.applicability={...m?{seatLabels:m}:{},...x?{accessibility:[...x]}:{}},!g.applicability.seatLabels&&!g.applicability.accessibility&&delete g.applicability}if(g.evidence!=null){if(!["public-host","public-event","user-confirmed"].includes(g.evidence.provenance)||typeof g.evidence.sourceDescription!="string")throw new u("invalid_operation",`Ticket tier ${b} has invalid evidence provenance`,{categoryKey:a,tierId:b});if(g.evidence.sourceDescription=g.evidence.sourceDescription.normalize("NFKC").trim(),!g.evidence.sourceDescription||g.evidence.sourceDescription.length>240||g.evidence.capturedAt!==void 0&&(g.evidence.capturedAt.length>40||!Number.isFinite(Date.parse(g.evidence.capturedAt))))throw new u("invalid_operation",`Ticket tier ${b} has invalid evidence provenance`,{categoryKey:a,tierId:b})}c.add(b),d.add(y)}}}return o}function wo(e,t){let n=new Set,o=structuredClone(e.categories);for(let r of t.updates){if(n.has(r.categoryKey))throw new u("invalid_operation",`Category ${r.categoryKey} may be updated only once`);n.add(r.categoryKey);let s=o.find(g=>g.key===r.categoryKey);if(!s)throw new u("category_not_found",`Unknown chart category: ${r.categoryKey}. Call get_chart to list valid category keys.`,{categoryKey:r.categoryKey});let l=structuredClone(r.patch),{tiers:c,...d}=l;typeof d.label=="string"&&(d.label=d.label.normalize("NFKC").trim()),typeof d.color=="string"&&(d.color=d.color.toLowerCase()),Object.assign(s,d),s.notForSale===!1&&delete s.notForSale,Object.prototype.hasOwnProperty.call(l,"tiers")&&(c==null?delete s.tiers:s.tiers=c?.map(g=>{let b={...g,id:g.id.trim(),name:g.name.normalize("NFKC").trim()};return g.buyerMessage?.trim()?b.buyerMessage=g.buyerMessage.normalize("NFKC").trim():delete b.buyerMessage,b})),delete s.referenceDirectSeatImport}let i=we(o),a=JSON.stringify(i)!==JSON.stringify(e.categories);return a&&(e.categories=i),{changed:a,categoryKeys:[...n],categories:e.categories}}function ga(e,t){let n=structuredClone(e.categories),o=n.find(r=>r.key===t.categoryKey);if(!o||o.referenceDirectSeatImport?.assetId!==t.source.assetId||o.referenceDirectSeatImport.familyId!==t.source.familyId)throw new u("invalid_operation","The prior direct-seat import category is no longer available for this reference");o.label=t.label.normalize("NFKC").trim();let i=we(n),a=JSON.stringify(i)!==JSON.stringify(e.categories);return a&&(e.categories=i),{changed:a,category:e.categories.find(r=>r.key===t.categoryKey),categories:e.categories}}function ba(e,t){let n=t.categoryKeys.map(l=>l.trim()),o=e.categories.map(l=>l.key);if(n.length!==o.length||new Set(n).size!==n.length)throw new u("invalid_operation","Category order must contain every stable category key exactly once",{categoryKeys:n,expectedCategoryKeys:o});let i=new Set(o),a=o.filter(l=>!n.includes(l)),r=n.filter(l=>!i.has(l));if(a.length||r.length)throw new u(r.length?"category_not_found":"invalid_operation","Category order must be an exact permutation of the current stable keys",{categoryKeys:n,missingCategoryKeys:a,unknownCategoryKeys:r});if(n.every((l,c)=>l===o[c]))return{changed:!1,categoryKeys:o,categories:e.categories};let s=new Map(e.categories.map(l=>[l.key,l]));return e.categories=we(n.map((l,c)=>{let d=structuredClone(s.get(l));return l!==o[c]&&delete d.referenceDirectSeatImport,d})),{changed:!0,categoryKeys:n,categories:e.categories}}var qt=["#e69f00","#56b4e9","#009e73","#f0e442","#0072b2","#d55e00","#cc79a7"];function mo(e){let t=/^#?([0-9a-f]{6}|[0-9a-f]{3})$/i.exec(e.trim());if(!t)return null;let n=t[1];return n.length===3&&(n=n.split("").map(o=>o+o).join("")),[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)]}function ha(e,t){let n=mo(e),o=mo(t);return!n||!o?1/0:(n[0]-o[0])**2+(n[1]-o[1])**2+(n[2]-o[2])**2}var pa=3600;function xo(e,t,n=qt){return n.find(i=>e.every(a=>ha(i,a)>=pa))??n[t%n.length]}function ya(e,t){let n=t?.palette??qt;if(!e.categories.length)return{changed:[],categories:e.categories};let o=new Map(e.categories.map(r=>[r.key,r.color.toLowerCase()])),i=e.categories.map((r,s)=>({categoryKey:r.key,patch:{color:n[s%n.length]}}));return wo(e,{updates:i}),{changed:e.categories.map(r=>({key:r.key,from:o.get(r.key),to:r.color})).filter(r=>r.from!==r.to),categories:e.categories}}function ma(e,t){let n=t.color.trim().toLowerCase(),o=t.sourceDescription.normalize("NFKC").trim();if(!/^#[0-9a-f]{6}$/.test(n))throw new u("invalid_operation","Sampled category color must be a six-digit hex color");if(!o||o.length>240)throw new u("invalid_operation","Color confirmation evidence must contain 1 to 240 characters");let i=structuredClone(e.categories),a=i.find(l=>l.key===t.categoryKey);if(!a)throw new u("category_not_found",`Unknown chart category: ${t.categoryKey}. Call get_chart to list valid category keys.`,{categoryKey:t.categoryKey});a.color=n,delete a.referenceDirectSeatImport,a.referenceCategorySource&&(a.referenceCategorySource.outputColorEvidence="user-confirmed",a.referenceCategorySource.outputColorSourceDescription=o);let r=we(i),s=JSON.stringify(r)!==JSON.stringify(e.categories);return s&&(e.categories=r),{changed:s,category:e.categories.find(l=>l.key===t.categoryKey),categories:e.categories}}function So(e,t){let n=new Set(e.categories.map(r=>r.key)),o="";for(let r=0;r<100;r++){let l=t.idFactory("cat").trim();if(l&&!n.has(l)){o=l;break}}if(!o)throw new u("id_generation_failed","Unable to allocate a unique category id");let i={key:o,label:t.label.normalize("NFKC").trim(),color:t.color.toLowerCase(),price:t.price,tiers:t.tiers?.map(r=>({...r,id:r.id.trim(),name:r.name.normalize("NFKC").trim()})),...t.referenceDirectSeatImport?{referenceDirectSeatImport:structuredClone(t.referenceDirectSeatImport)}:{}},a=we([...e.categories,i]);return e.categories=a,{changed:!0,category:a.find(r=>r.key===o),categories:a}}var wa=["#e5484d","#a86b00","#8b5cf6","#d6336c","#4d7c0f","#dc2626","#c026d3"],xa={row:"#e5484d",table:"#a86b00",booth:"#8b5cf6",gaArea:"#4d7c0f"};function Sa(e,t){let n=xa[e];return!n||!t.includes(n)?t:[n,...t.filter(o=>o!==n)]}var Ia=26;function va(e,t,n){let o=(1-Math.abs(2*n-1))*t,i=(e%360+360)%360/60,a=o*(1-Math.abs(i%2-1)),[r,s,l]=i<1?[o,a,0]:i<2?[a,o,0]:i<3?[0,o,a]:i<4?[0,a,o]:i<5?[a,0,o]:[o,0,a],c=n-o/2,d=g=>Math.round((g+c)*255).toString(16).padStart(2,"0");return`#${d(r)}${d(s)}${d(l)}`}function Ca(e,t,n){let o=r=>e.every(s=>{let l=Ht(r,s);return l==null||l>=Ia}),i=r=>{let s=ut(r,"#12151d"),l=ut(r,"#ffffff");return(s??0)>=3||(l??0)>=3},a=t.find(r=>o(r)&&i(r));if(a)return a;for(let r=0;r<360;r+=12)for(let s of[.52,.44,.6]){let l=va(r,.62,s);if(o(l)&&i(l))return l}return n}function Io(e,t){let n=rt.find(i=>i.objectType===t).creationWord;return`${e.replace(/\s*[–-]\s*(Tables|Booths|Standing|Seats)$/i,"").trim()||e.trim()} \u2013 ${n}`}function Oa(e){let t=new Map;for(let n of k(e))for(let o of n.objects){let i=rt.find(r=>r.objectType===o.type);if(!i)continue;let a=new Set;if(o.type==="row"||o.type==="table")for(let r of it(o).keys())a.add(r);else"categoryKey"in o&&o.categoryKey&&a.add(o.categoryKey);for(let r of a){let s=t.get(r)??new Set;s.add(i.objectType),t.set(r,s)}}return t}function Ra(e,t){let n=new Set(e.categories.map(i=>i.label.toLowerCase())),o=t;for(let i=2;n.has(o.toLowerCase());i+=1)o=`${t} ${i}`;return o}function vo(e,t,n){let o=Oa(e),i=c=>{let d=o.get(c);return!d||d.size===0||d.size===1&&d.has(n)},a=e.categories.find(c=>c.key===t);if(a&&i(a.key))return{kind:"existing",categoryKey:a.key,label:a.label};if(!a){let c=e.categories.find(d=>{let g=o.get(d.key);return g?.size===1&&g.has(n)});if(c)return{kind:"existing",categoryKey:c.key,label:c.label}}let r=rt.find(c=>c.objectType===n),s=a?Io(a.label,n):n==="gaArea"?"General Admission":r.creationWord,l=e.categories.find(c=>c.label.toLowerCase()===s.toLowerCase()&&i(c.key));return l?{kind:"existing",categoryKey:l.key,label:l.label}:{kind:"mint",...a?{baseCategoryKey:a.key}:{},label:Ra(e,s)}}function Pa(e,t,n,o){let i=vo(e,t,n);if(i.kind==="existing")return i.categoryKey;let a=i.baseCategoryKey?e.categories.find(r=>r.key===i.baseCategoryKey):void 0;return Ma(e,n,a,i.label,o)}function Ma(e,t,n,o,i){let a=i.palette??wa,r=e.categories.map(d=>d.color),s=i.suggestColor?.(r.map(d=>d.toLowerCase()))??xo(r,e.categories.length),l=Ca(r,Sa(t,a),s),c=So(e,{label:o,color:l,...n?.price!==void 0?{price:n.price}:{},...n?.tiers?.length?{tiers:n.tiers}:{},idFactory:i.idFactory});return e.categories=c.categories,c.category.key}function _a(e,t){let n=new Set;for(let o of k(e))for(let i of o.objects)"categoryKey"in i&&i.categoryKey===t&&n.add(i.id),i.type==="section"&&i.editor?.defaultCategoryKey===t&&n.add(i.id),(i.type==="row"||i.type==="table")&&i.overrides?.some(a=>a.categoryKey===t)&&n.add(i.id);return[...n]}function Aa(e,t){let n=e.categories.find(a=>a.key===t.categoryKey);if(!n)throw new u("category_not_found",`Unknown chart category: ${t.categoryKey}. Call get_chart to list valid category keys.`,{categoryKey:t.categoryKey});if(e.categories.length<=1)throw new u("invalid_operation","A chart must retain at least one category");let o=_a(e,t.categoryKey);if(o.length)throw new u("category_in_use",`Category ${t.categoryKey} is still assigned to chart inventory`,{categoryKey:t.categoryKey,objectIds:o});if(n.referenceCategorySource)throw new u("reference_category_protected",`Reference-backed category ${t.categoryKey} cannot be deleted through a generic catalog operation`,{categoryKey:t.categoryKey});let i=we(e.categories.filter(a=>a.key!==t.categoryKey));return e.categories=i,{changed:!0,categoryKey:t.categoryKey,categories:i}}var ja=["background","seatLabelColor","rowLabelColor","selectionColor","decorFill","textColor","accent","accentInk"],La=["seat","deck","shell","fascia"];function ka(e,t){let n=t.patch;if(!Object.keys(n).length)throw new u("invalid_operation","At least one theme field is required");let o=JSON.stringify(e.theme??null),i={...e.theme??{}};for(let a of ja){let r=n[a];r===null?delete i[a]:r!==void 0&&(i[a]=N(r,`Theme ${a}`))}if(n.fontFamily===null)delete i.fontFamily;else if(n.fontFamily!==void 0){let a=n.fontFamily.normalize("NFKC").trim();if(!a||a.length>120)throw new u("invalid_operation","Theme fontFamily must contain 1 to 120 characters");i.fontFamily=a}if(n.seatScale===null)delete i.seatScale;else if(n.seatScale!==void 0){if(!Number.isFinite(n.seatScale)||n.seatScale<$t||n.seatScale>Bt)throw new u("invalid_operation",`Theme seatScale must be from ${$t} to ${Bt}`);i.seatScale=n.seatScale}if(n.logoUrl===null)delete i.logoUrl;else if(n.logoUrl!==void 0){let a=re(n.logoUrl);if(!a)throw new u("invalid_operation","Theme logoUrl must be a safe HTTPS or base64 raster image reference");i.logoUrl=a}if(n.brandName===null)delete i.brandName;else if(n.brandName!==void 0){let a=n.brandName.normalize("NFKC").trim();if(!a||a.length>80)throw new u("invalid_operation","Theme brandName must contain 1 to 80 characters");i.brandName=a}if(n.hideBadge===null||n.hideBadge===!1?delete i.hideBadge:n.hideBadge===!0&&(i.hideBadge=!0),n.venue3d===null)delete i.venue3d;else if(n.venue3d!==void 0){let a={...i.venue3d??{}};for(let s of La){let l=n.venue3d[s];l===null?delete a[s]:l!==void 0&&(a[s]=N(l,`3D venue ${s}`))}let r=n.venue3d.roughness;if(r===null)delete a.roughness;else if(r!==void 0){if(!Number.isFinite(r)||r<0||r>1)throw new u("invalid_operation","3D venue roughness must be from 0 to 1");a.roughness=r}i.venue3d=Object.keys(a).length?a:void 0,i.venue3d||delete i.venue3d}return e.theme=Object.keys(i).length?i:void 0,{changed:JSON.stringify(e.theme??null)!==o,theme:e.theme??null}}function Ea(e,t){let n=t.url===null?null:re(t.url);if(t.url!==null&&!n)throw new u("invalid_operation","View-from-seat photo must be a safe HTTPS or base64 raster image reference");let o=n??void 0;if(t.floorId!==void 0){let s=e.floors?.find(g=>g.id===t.floorId);if(!s)throw new u("invalid_operation",`Unknown floor: ${t.floorId}`);let l=(s.viewFromSeatUrl??void 0)===o,c=o?t.metadata===null?void 0:t.metadata??(l?s.viewFromSeatMeta:void 0):void 0,d=!l||JSON.stringify(s.viewFromSeatMeta??null)!==JSON.stringify(c??null);return s.viewFromSeatUrl=o,s.viewFromSeatMeta=c,{changed:d,scope:"floor",floorId:t.floorId,url:s.viewFromSeatUrl??null}}let i=(e.viewFromSeatUrl??void 0)===o,a=o?t.metadata===null?void 0:t.metadata??(i?e.viewFromSeatMeta:void 0):void 0,r=!i||JSON.stringify(e.viewFromSeatMeta??null)!==JSON.stringify(a??null);return e.viewFromSeatUrl=o,e.viewFromSeatMeta=a,{changed:r,scope:"venue",url:e.viewFromSeatUrl??null}}function Ta(e,t){let n=We(e,t.floorId),o=kn(n),i=t.placement==="auto"||t.placement==null?"rear":t.placement,a=96;return i==="front"?{x:o.x+o.width/2,y:o.y-a-t.height/2}:i==="left"?{x:o.x-a-t.width/2,y:o.y+o.height/2}:i==="right"?{x:o.x+o.width+a+t.width/2,y:o.y+o.height/2}:{x:o.x+o.width/2,y:o.y+o.height+a+t.height/2}}function ft(e,t){E(e,t.categoryKey);let n=(...d)=>d.every(Number.isFinite);if(!n(t.center.x,t.center.y,t.innerRadius,t.rowGap,t.startAngle,t.endAngle,t.seatPitch))throw new u("invalid_operation","Arc/Fan geometry values must be finite");if(!Number.isInteger(t.rowCount)||t.rowCount<1||t.rowCount>100)throw new u("invalid_operation","Arc/Fan rowCount must be an integer from 1 to 100");if(t.innerRadius<40||t.innerRadius>2e4||t.rowGap<12||t.rowGap>500)throw new u("invalid_operation","Arc/Fan radius must be 40\u201320000 and row gap 12\u2013500");let o=t.endAngle-t.startAngle;if(Math.abs(o)<5||Math.abs(o)>320)throw new u("invalid_operation","Arc/Fan sweep must be from 5\xB0 to 320\xB0");if(t.seatPitch<14||t.seatPitch>80)throw new u("invalid_operation","Arc/Fan seat pitch must be from 14 to 80 chart units");let i=t.fit??"seat-pitch";if(i==="fixed-count"&&(!Number.isInteger(t.seatsPerRow)||t.seatsPerRow<2||t.seatsPerRow>300))throw new u("invalid_operation","Fixed Arc/Fan rows require seatsPerRow from 2 to 300");let a=t.taperDegrees??0,r=t.skewDegrees??0;if(!n(a,r)||Math.abs(a)>120||Math.abs(r)>180)throw new u("invalid_operation","Arc/Fan taper must be within \xB1120\xB0 and skew within \xB1180\xB0");let s={left:t.aisleGaps?.left??0,center:t.aisleGaps?.center??0,right:t.aisleGaps?.right??0};if(!n(s.left,s.center,s.right)||Object.values(s).some(d=>d<0||d>200))throw new u("invalid_operation","Arc/Fan aisle widths must be from 0 to 200 chart units");let c=O(e,t.floorId).objects.filter(d=>d.type==="row").length;return{...t,fit:i,facing:t.facing??"inward",taperDegrees:a,skewDegrees:r,aisleGaps:s,rowLabelStart:t.rowLabelStart??c,seatLabelStart:t.seatLabelStart??1}}function Fa(e,t,n){let o=n*ne;return{x:e.x+t*Math.sin(o),y:e.y+t*Math.cos(o)}}function Na(e,t,n,o){let i=Math.abs(o-n)*ne,a=[["left",.25],["center",.5],["right",.75]].flatMap(([c,d])=>{let g=e.aisleGaps[c];if(!g)return[];let b=g/t/i/2;return[[Math.max(0,d-b),Math.min(1,d+b)]]}).sort((c,d)=>c[0]-d[0]),r=[];for(let c of a){let d=r[r.length-1];d&&c[0]<=d[1]?d[1]=Math.max(d[1],c[1]):r.push([...c])}let s=[],l=0;for(let c of r)c[0]-l>1e-6&&s.push([l,c[0]]),l=Math.max(l,c[1]);return 1-l>1e-6&&s.push([l,1]),s.filter(([c,d])=>t*i*(d-c)>=e.seatPitch*.75)}function Da(e,t){let n=e.length*2;if(t<n)throw new u("invalid_operation",`Fixed seat count must be at least ${n} for ${e.length} aisle-separated row segments`);let o=t-n,i=e.reduce((l,c)=>l+c,0),a=e.map(l=>o*l/i),r=a.map(l=>2+Math.floor(l)),s=t-r.reduce((l,c)=>l+c,0);return a.map((l,c)=>({index:c,fraction:l-Math.floor(l)})).sort((l,c)=>c.fraction-l.fraction||l.index-c.index).forEach(({index:l})=>{s-- >0&&r[l]++}),r}function gt(e,t,n){let o=[];for(let i=0;i<e.rowCount;i++){let a=e.rowCount===1?0:i/(e.rowCount-1),r=e.innerRadius+i*e.rowGap,s=Math.sign(e.endAngle-e.startAngle)||1,l=e.startAngle+s*e.taperDegrees*a+e.skewDegrees*a,c=e.endAngle-s*e.taperDegrees*a+e.skewDegrees*a;if(Math.sign(c-l)!==Math.sign(e.endAngle-e.startAngle)||Math.abs(c-l)<5)throw new u("invalid_operation",`Arc/Fan taper collapses row ${i+1} below a 5\xB0 sweep`);let d=Na(e,r,l,c);if(!d.length)throw new u("invalid_operation",`Arc/Fan aisles leave no usable span in row ${i+1}`);e.facing==="outward"&&(d=d.slice().reverse());let g=d.map(([y,m])=>r*Math.abs(c-l)*ne*(m-y)),b=e.fit==="fixed-count"?Da(g,e.seatsPerRow):g.map(y=>Math.max(2,Math.round(y/e.seatPitch)+1)),f=e.seatLabelStart;d.forEach(([y,m],x)=>{let v=l+(c-l)*y,h=l+(c-l)*m;e.facing==="outward"&&([v,h]=[h,v]);let p=b[x];if(p>300)throw new u("invalid_operation","An Arc/Fan row segment cannot exceed 300 seats");let w=Math.abs(h-v)*ne/(p-1),S=2*r*Math.sin(w/2),I={type:"row",id:n(i,x),label:V(e.rowLabelStart+i),origin:Fa(e.center,r,v),rotation:-v,curve:h-v,seatCount:p,seatSpacing:S,categoryKey:e.categoryKey,seatLabelStart:f,arcFanGeneration:{kind:"arc-fan-v1",groupId:t,center:{...e.center},innerRadius:e.innerRadius,rowCount:e.rowCount,rowGap:e.rowGap,startAngle:e.startAngle,endAngle:e.endAngle,seatPitch:e.seatPitch,fit:e.fit,...e.seatsPerRow!=null?{seatsPerRow:e.seatsPerRow}:{},facing:e.facing,taperDegrees:e.taperDegrees,skewDegrees:e.skewDegrees,aisleGaps:{...e.aisleGaps},rowLabelStart:e.rowLabelStart,seatLabelStart:e.seatLabelStart,rowIndex:i,segmentIndex:x}};o.push(I),f+=p})}return o}function Jt(e,t){let n=ft(e,t),o=O(e,t.floorId),i=gt(n,"preview-arc-fan",(l,c)=>`preview-fan-${l}-${c}`),a=i.map(l=>l.seatSpacing),r=Math.max(...a.map(l=>Math.abs(l-n.seatPitch))),s=[];return r>n.seatPitch*.12&&s.push(`Seat fitting deviates from the requested pitch by up to ${r.toFixed(1)} chart units`),i.length>n.rowCount*3&&s.push("Three aisles split each logical row into four separately editable segments"),{floorId:o.floorId,rows:i,logicalRowCount:n.rowCount,rowSegmentCount:i.length,totalSeats:i.reduce((l,c)=>l+c.seatCount,0),innerRadius:n.innerRadius,outerRadius:n.innerRadius+(n.rowCount-1)*n.rowGap,minSeatSpacing:Math.min(...a),maxSeatSpacing:Math.max(...a),maxPitchDeviation:r,aisleCount:Object.values(n.aisleGaps).filter(l=>l>0).length,warnings:s}}function Ga(e,t){let n=ft(e,t),o=O(e,t.floorId),i=new Set,a=A(e,"fan",t.idFactory,i),r=gt(n,a,()=>A(e,"r",t.idFactory,i)),s=Jt(e,t),l=null,c=t.sectionLabel?.normalize("NFKC").trim(),d=null;if(c){if(c.length>80)throw new u("invalid_operation","Arc/Fan section label must contain at most 80 characters");let g=le(r);g&&(l=A(e,"sec",t.idFactory,i),d={type:"section",id:l,label:c,outline:g,arcFanGroupId:a})}return o.objects.push(...r,...d?[d]:[]),{floorId:o.floorId,rowIds:r.map(g=>g.id),sectionId:l,groupId:a,logicalRowCount:s.logicalRowCount,rowSegmentCount:s.rowSegmentCount,totalSeats:s.totalSeats,innerRadius:s.innerRadius,outerRadius:s.outerRadius,minSeatSpacing:s.minSeatSpacing,maxSeatSpacing:s.maxSeatSpacing,maxPitchDeviation:s.maxPitchDeviation,aisleCount:s.aisleCount,warnings:s.warnings}}function Co(e,t){let n=O(e,t.floorId),o=n.objects.filter(g=>g.type==="row"&&g.arcFanGeneration?.groupId===t.groupId);if(!o.length)throw new u("object_not_found",`Unknown Arc/Fan group: ${t.groupId}`,{groupId:t.groupId});let i=o[0].arcFanGeneration,a=g=>{let b=g.arcFanGeneration;return JSON.stringify({center:b.center,innerRadius:b.innerRadius,rowCount:b.rowCount,rowGap:b.rowGap,startAngle:b.startAngle,endAngle:b.endAngle,seatPitch:b.seatPitch,fit:b.fit,seatsPerRow:b.seatsPerRow,facing:b.facing,taperDegrees:b.taperDegrees,skewDegrees:b.skewDegrees,aisleGaps:b.aisleGaps,rowLabelStart:b.rowLabelStart,seatLabelStart:b.seatLabelStart})};if(o.some(g=>a(g)!==a(o[0])))throw new u("invalid_operation","Arc/Fan group provenance no longer agrees across all row segments",{groupId:t.groupId});let r=n.objects.find(g=>g.type==="section"&&g.arcFanGroupId===t.groupId),s={floorId:n.floorId,center:{...i.center},innerRadius:i.innerRadius,rowCount:i.rowCount,rowGap:i.rowGap,startAngle:i.startAngle,endAngle:i.endAngle,seatPitch:i.seatPitch,fit:i.fit,seatsPerRow:i.seatsPerRow,facing:i.facing,taperDegrees:i.taperDegrees,skewDegrees:i.skewDegrees,aisleGaps:{...i.aisleGaps},categoryKey:o[0].categoryKey,rowLabelStart:i.rowLabelStart,seatLabelStart:i.seatLabelStart,sectionLabel:r?.label},l=ft(e,s),c=new Set(gt(l,t.groupId,(g,b)=>`${g}:${b}`).map(g=>`${g.arcFanGeneration.rowIndex}:${g.arcFanGeneration.segmentIndex}`)),d=new Set(o.map(g=>`${g.arcFanGeneration.rowIndex}:${g.arcFanGeneration.segmentIndex}`));if(c.size!==d.size||[...c].some(g=>!d.has(g)))throw new u("invalid_operation","Arc/Fan group is incomplete and cannot be regenerated safely",{groupId:t.groupId});return s}function Ka(e,t){Co(e,{floorId:t.floorId,groupId:t.groupId});let n=ft(e,t),o=O(e,t.floorId),i=o.objects.filter(m=>m.type==="row"&&m.arcFanGeneration?.groupId===t.groupId),a=o.objects.find(m=>m.type==="section"&&m.arcFanGroupId===t.groupId),r=new Map(i.map(m=>[`${m.arcFanGeneration.rowIndex}:${m.arcFanGeneration.segmentIndex}`,m.id])),s=new Set,l=gt(n,t.groupId,(m,x)=>r.get(`${m}:${x}`)??A(e,"r",t.idFactory,s)),c=Jt(e,t),d=t.sectionLabel?.normalize("NFKC").trim(),g=null;if(d){if(d.length>80)throw new u("invalid_operation","Arc/Fan section label must contain at most 80 characters");let m=le(l);m&&(g={type:"section",id:a?.id??A(e,"sec",t.idFactory,s),label:d,outline:m,arcFanGroupId:t.groupId})}let b=new Set([...i.map(m=>m.id),...a?[a.id]:[]]),f=Math.min(...o.objects.map((m,x)=>b.has(m.id)?x:1/0)),y=o.objects.filter(m=>!b.has(m.id));return y.splice(Number.isFinite(f)?f:y.length,0,...l,...g?[g]:[]),o.objects.splice(0,o.objects.length,...y),{floorId:o.floorId,rowIds:l.map(m=>m.id),sectionId:g?.id??null,groupId:t.groupId,logicalRowCount:c.logicalRowCount,rowSegmentCount:c.rowSegmentCount,totalSeats:c.totalSeats,innerRadius:c.innerRadius,outerRadius:c.outerRadius,minSeatSpacing:c.minSeatSpacing,maxSeatSpacing:c.maxSeatSpacing,maxPitchDeviation:c.maxPitchDeviation,aisleCount:c.aisleCount,warnings:c.warnings}}function $a(e){let t=new Set(H(e).filter(o=>o.type==="row"||o.type==="table"||o.type==="booth").map(o=>o.label).filter(o=>typeof o=="string")),n=0;return()=>{for(;t.has(V(n));)n+=1;let o=V(n);return t.add(o),n+=1,o}}function Oo(e){return JSON.stringify(["row-block-v1",e.style,e.origin.x,e.origin.y,e.rotation,e.rowCount,e.seatsPerRow,e.rowGap,e.seatSpacing,e.curve])}function Ba(e,t){if(E(e,t.categoryKey),!Number.isInteger(t.rowCount)||t.rowCount<1||t.rowCount>100)throw new u("invalid_operation","rowCount must be an integer from 1 to 100");if(!Number.isInteger(t.seatsPerRow)||t.seatsPerRow<1||t.seatsPerRow>300)throw new u("invalid_operation","seatsPerRow must be an integer from 1 to 300");let n=t.rowGap??28,o=t.seatSpacing??24;if(!Number.isFinite(n)||n<=0||!Number.isFinite(o)||o<=0)throw new u("invalid_operation","Row and seat spacing must be positive finite values");if(t.rotation!==void 0&&!Number.isFinite(t.rotation))throw new u("invalid_operation","rotation must be a finite number of degrees");let i=O(e,t.floorId),a=new Set,r=$a(e),s=Dt(t.rotation??0),l=t.curve??0,c=t.style,d=c?A(e,"rowblock",t.idFactory,a):void 0,g=c?Oo({style:c,origin:t.origin,rotation:s,rowCount:t.rowCount,seatsPerRow:t.seatsPerRow,rowGap:n,seatSpacing:o,curve:l}):void 0,b={x:Math.cos(s*Z),y:Math.sin(s*Z)},f={x:-b.y,y:b.x},y=Array.from({length:t.rowCount},(v,h)=>{let p=c==="intertwined"&&h%2===1?o/2:0,w={type:"row",id:A(e,"r",t.idFactory,a),label:r(),origin:{x:t.origin.x+f.x*h*n+b.x*p,y:t.origin.y+f.y*h*n+b.y*p},rotation:s,curve:l,seatCount:t.seatsPerRow,seatSpacing:o,categoryKey:t.categoryKey};return c&&d&&g&&(w.rowBlockGeneration={kind:"row-block-v1",groupId:d,style:c,rowIndex:h,rowCount:t.rowCount,seatsPerRow:t.seatsPerRow,origin:{...t.origin},rotation:s,rowGap:n,seatSpacing:o,curve:l,signature:g}),w});i.objects.push(...y);let m=null,x=t.sectionLabel?.trim();if(x){let v=le(y);if(v){let h={type:"section",id:A(e,"sec",t.idFactory,a),label:x,outline:v};i.objects.push(h),m=h.id}}return{floorId:i.floorId,rowIds:y.map(v=>v.id),sectionId:m,createdIds:[...y.map(v=>v.id),...m?[m]:[]]}}function Ro(e,t){let n=new Set(H(e).filter(i=>i.type==="row"||i.type==="table"||i.type==="booth").map(i=>i.label).filter(i=>typeof i=="string")),o=1;return()=>{for(;n.has(`${t}${o}`);)o+=1;let i=`${t}${o}`;return n.add(i),o+=1,i}}function za(e,t){let n=new Set(H(e).filter(i=>i.type==="gaArea").map(i=>i.label));if(!n.has(t))return t;let o=2;for(;n.has(`${t} ${o}`);)o+=1;return`${t} ${o}`}var Ua=456;function Po(e){let t=Math.sqrt(Math.max(1,e)*Ua);return{width:Math.round(t*1.027),height:Math.round(t/1.027)}}function Ha(e,t){if(E(e,t.categoryKey),!Number.isInteger(t.capacity)||t.capacity<1)throw new u("invalid_operation","capacity must be a positive integer");if(!Number.isFinite(t.center.x)||!Number.isFinite(t.center.y))throw new u("invalid_operation","GA area center must be finite");let n=O(e,t.floorId),o=new Set,{width:i,height:a}=Po(t.capacity),r=za(e,(t.label??"General Admission").trim()||"General Admission"),s={type:"gaArea",id:A(e,"ga",t.idFactory,o),label:r,...t.displayLabel?.trim()?{displayLabel:t.displayLabel.trim()}:{},points:[{x:t.center.x-i/2,y:t.center.y-a/2},{x:t.center.x+i/2,y:t.center.y-a/2},{x:t.center.x+i/2,y:t.center.y+a/2},{x:t.center.x-i/2,y:t.center.y+a/2}],capacity:t.capacity,categoryKey:t.categoryKey};return n.objects.push(s),{floorId:n.floorId,gaAreaId:s.id,label:r,createdIds:[s.id]}}function Va(e,t){if(E(e,t.categoryKey),!Number.isInteger(t.tableRows)||t.tableRows<1||t.tableRows>20||!Number.isInteger(t.tableColumns)||t.tableColumns<1||t.tableColumns>20)throw new u("invalid_operation","tableRows and tableColumns must be integers from 1 to 20");if(!Number.isInteger(t.seatsPerTable)||t.seatsPerTable<1||t.seatsPerTable>20)throw new u("invalid_operation","seatsPerTable must be an integer from 1 to 20");let n=t.gapX??155,o=t.gapY??150;if(!Number.isFinite(n)||n<80||!Number.isFinite(o)||o<80)throw new u("invalid_operation","Table spacing must be at least 80 chart units");if(!Number.isFinite(t.center.x)||!Number.isFinite(t.center.y))throw new u("invalid_operation","Table array center must be finite");let i=O(e,t.floorId),a=new Set,r=Ro(e,"T"),s=[];for(let l=0;l<t.tableRows;l+=1)for(let c=0;c<t.tableColumns;c+=1)s.push({type:"table",id:A(e,"t",t.idFactory,a),label:r(),center:{x:t.center.x+(c-(t.tableColumns-1)/2)*n,y:t.center.y+(l-(t.tableRows-1)/2)*o},rotation:0,categoryKey:t.categoryKey,seatCount:t.seatsPerTable,...t.shape==="round"?{shape:"round",radius:46}:{shape:"rect",sides:["top","bottom"],width:120,height:58}});return i.objects.push(...s),{floorId:i.floorId,tableIds:s.map(l=>l.id),createdIds:s.map(l=>l.id)}}function qa(e,t){if(E(e,t.categoryKey),!Number.isInteger(t.boothRows)||t.boothRows<1||t.boothRows>30||!Number.isInteger(t.boothColumns)||t.boothColumns<1||t.boothColumns>30)throw new u("invalid_operation","boothRows and boothColumns must be integers from 1 to 30");let n=t.gapX??88,o=t.gapY??82;if(!Number.isFinite(n)||n<62||!Number.isFinite(o)||o<52)throw new u("invalid_operation","Booth spacing must clear the 62\xD752 booth footprint");if(!Number.isFinite(t.center.x)||!Number.isFinite(t.center.y))throw new u("invalid_operation","Booth array center must be finite");let i=O(e,t.floorId),a=new Set,r=Ro(e,"B"),s=[];for(let l=0;l<t.boothRows;l+=1)for(let c=0;c<t.boothColumns;c+=1)s.push({type:"booth",id:A(e,"booth",t.idFactory,a),label:r(),center:{x:t.center.x+(c-(t.boothColumns-1)/2)*n,y:t.center.y+(l-(t.boothRows-1)/2)*o},width:62,height:52,rotation:0,categoryKey:t.categoryKey});return i.objects.push(...s),{floorId:i.floorId,boothIds:s.map(l=>l.id),createdIds:s.map(l=>l.id)}}function Xt(e,t){let n=O(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2||o.length>64)throw new u("invalid_operation","A segmented row requires 2 to 64 ordered component rows");if(t.boundaries.length!==o.length-1||t.boundaries.some(b=>b!=="continuous"&&b!=="break"))throw new u("invalid_operation","Declare one continuous or break boundary between every pair of row components");let i=o.map(b=>n.objects.find(f=>f.type==="row"&&f.id===b)),a=o.filter((b,f)=>!i[f]);if(a.length)throw new u("object_not_found","One or more segmented-row components do not exist on the selected floor",{rowIds:a});let r=i,s=r.filter(b=>b.segmentedRow);if(s.length)throw new u("invalid_operation","Ungroup existing segmented rows before combining their components again",{rowIds:s.map(b=>b.id)});let l=(t.displayLabel??r[0].displayLabel??r[0].label).normalize("NFKC").trim();if(!l||l.length>80)throw new u("invalid_operation","Segmented-row display label must contain 1 to 80 characters");let c=new Set(n.objects.flatMap(b=>b.type==="row"?[b.segmentedRow?.groupId,b.rowBlockGeneration?.groupId].filter(f=>!!f):[])),d="";for(let b=0;b<100;b+=1){let f=t.idFactory("rowgroup");if(f&&!c.has(f)){d=f;break}}if(!d)throw new u("id_generation_failed","Unable to allocate a segmented-row group id");let g=r[0];return r.forEach((b,f)=>{b.segmentedRow={kind:"segmented-row-v1",groupId:d,componentIndex:f,componentCount:r.length,boundaryBefore:f===0?"start":t.boundaries[f-1],displayLabel:l,...g.displayType?{displayType:g.displayType}:{},...g.labelPresentation?{labelPresentation:structuredClone(g.labelPresentation)}:{},...g.viewFromSeatUrl?{viewFromSeatUrl:g.viewFromSeatUrl}:{},...g.viewFromSeatMeta?{viewFromSeatMeta:structuredClone(g.viewFromSeatMeta)}:{},...g.confidenceEvidence?{confidenceEvidence:structuredClone(g.confidenceEvidence)}:{}}}),{floorId:n.floorId,groupId:d,rowIds:o,changed:!0}}function Ja(e,t){let n=O(e,t.floorId),o=t.groupId?n.objects.find(s=>s.type==="row"&&s.segmentedRow?.groupId===t.groupId):n.objects.find(s=>s.type==="row"&&s.id===t.rowId),i=t.groupId??o?.segmentedRow?.groupId;if(!i)throw new u("object_not_found","The segmented row does not exist on the selected floor");let a=n.objects.filter(s=>s.type==="row"&&s.segmentedRow?.groupId===i);if(!a.length)throw new u("object_not_found","The segmented row does not exist on the selected floor");let r=a.sort((s,l)=>s.segmentedRow.componentIndex-l.segmentedRow.componentIndex).map(s=>s.id);for(let s of a)delete s.segmentedRow;return{floorId:n.floorId,groupId:i,rowIds:r,changed:!0}}function Xa(e,t){let n=O(e,t.floorId),o=n.objects.filter(r=>r.type==="row"&&r.segmentedRow?.groupId===t.groupId).sort((r,s)=>r.segmentedRow.componentIndex-s.segmentedRow.componentIndex);if(o.length<2)throw new u("object_not_found","The segmented row is incomplete or missing on the selected floor");if(t.boundaries&&(t.boundaries.length!==o.length-1||t.boundaries.some(r=>r!=="continuous"&&r!=="break")))throw new u("invalid_operation","Declare one continuous or break boundary between every pair of row components");let i=t.displayLabel?.normalize("NFKC").trim();if(i!==void 0&&(!i||i.length>80))throw new u("invalid_operation","Segmented-row display label must contain 1 to 80 characters");let a=JSON.stringify(o.map(r=>r.segmentedRow));return o.forEach((r,s)=>{let l=r.segmentedRow,c=l.viewFromSeatUrl;i!==void 0&&(l.displayLabel=i),t.boundaries&&s>0&&(l.boundaryBefore=t.boundaries[s-1]),t.smoothing!==void 0&&(l.smoothing=t.smoothing||void 0),t.viewFromSeatUrl===null?delete l.viewFromSeatUrl:t.viewFromSeatUrl!==void 0&&(l.viewFromSeatUrl=t.viewFromSeatUrl),!l.viewFromSeatUrl||t.viewFromSeatMeta===null?delete l.viewFromSeatMeta:t.viewFromSeatMeta!==void 0?l.viewFromSeatMeta=structuredClone(t.viewFromSeatMeta):t.viewFromSeatUrl!==void 0&&l.viewFromSeatUrl!==c&&delete l.viewFromSeatMeta}),{floorId:n.floorId,groupId:t.groupId,rowIds:o.map(r=>r.id),changed:JSON.stringify(o.map(r=>r.segmentedRow))!==a}}function Ya(e,t){if(typeof t.groupId!="string"||!t.groupId)throw new u("invalid_operation","This row block was edited manually or is incomplete; repair or recreate it before regeneration",{groupId:t.groupId});let n=O(e,t.floorId),o=n.objects.filter(M=>M.type==="row"&&M.rowBlockGeneration?.groupId===t.groupId).sort((M,z)=>M.rowBlockGeneration.rowIndex-z.rowBlockGeneration.rowIndex),i=o[0]?.rowBlockGeneration;if(!i||o.length!==i.rowCount||o.some((M,z)=>{let P=M.rowBlockGeneration;return P.kind!=="row-block-v1"||P.rowIndex!==z||P.signature!==i.signature||JSON.stringify(P)!==JSON.stringify({...i,rowIndex:z})}))throw new u("invalid_operation","This row block was edited manually or is incomplete; repair or recreate it before regeneration",{groupId:t.groupId});let a=JSON.stringify(o),r=t.style??i.style,s=t.rowCount??i.rowCount,l=t.seatsPerRow??i.seatsPerRow,c=t.rowGap??i.rowGap,d=t.seatSpacing??i.seatSpacing,g=t.curve??i.curve,b=Number.isFinite(t.rotation??i.rotation)?Dt(t.rotation??i.rotation):t.rotation??i.rotation,f=t.origin?{...t.origin}:{...i.origin};if(!Number.isInteger(s)||s<1||s>100)throw new u("invalid_operation","rowCount must be an integer from 1 to 100");if(!Number.isInteger(l)||l<1||l>300)throw new u("invalid_operation","seatsPerRow must be an integer from 1 to 300");if(![c,d].every(M=>Number.isFinite(M)&&M>0)||!Number.isFinite(g)||!Number.isFinite(b)||!Number.isFinite(f.x)||!Number.isFinite(f.y))throw new u("invalid_operation","Row-block geometry must use positive spacing and finite origin, rotation, and curve values");let y=Oo({style:r,origin:f,rotation:b,rowCount:s,seatsPerRow:l,rowGap:c,seatSpacing:d,curve:g}),m={x:Math.cos(b*Z),y:Math.sin(b*Z)},x={x:-m.y,y:m.x},v=new Map(o.map(M=>[M.rowBlockGeneration.rowIndex,M])),h=new Set,p=new Set(n.objects.filter(M=>M.type==="row").filter(M=>!o.includes(M)).map(M=>M.label)),w=n.objects.filter(M=>M.type==="row").length,S=()=>{for(;p.has(V(w));)w+=1;let M=V(w);return p.add(M),w+=1,M},I=[],C=[];for(let M=0;M<s;M+=1){let z=r==="intertwined"&&M%2===1?d/2:0,P=v.get(M);P||(P={type:"row",id:A(e,"r",t.idFactory,h),label:S(),origin:{...f},rotation:b,curve:g,seatCount:l,seatSpacing:d,categoryKey:o[0].categoryKey},C.push(P.id)),P.origin={x:f.x+x.x*M*c+m.x*z,y:f.y+x.y*M*c+m.y*z},P.rotation=b,P.curve=g,P.seatCount=l,P.seatSpacing=d,delete P.path,delete P.arcFanGeneration,P.overrides&&(P.overrides=P.overrides.filter(q=>q.index<l),P.overrides.length||delete P.overrides),P.rowBlockGeneration={kind:"row-block-v1",groupId:t.groupId,style:r,rowIndex:M,rowCount:s,seatsPerRow:l,origin:{...f},rotation:b,rowGap:c,seatSpacing:d,curve:g,signature:y},I.push(P)}let j=o.slice(s).map(M=>M.id),L=Math.min(...o.map(M=>n.objects.indexOf(M))),T=new Set(o.map(M=>M.id)),G=n.objects.filter(M=>!T.has(M.id));return G.splice(L,0,...I),n.objects.splice(0,n.objects.length,...G),{floorId:n.floorId,groupId:t.groupId,rowIds:I.map(M=>M.id),createdRowIds:C,removedRowIds:j,changed:a!==JSON.stringify(I)||C.length>0||j.length>0}}function Mo(e){let t=0;for(let n=1;n<e.length;n+=1)t+=Math.hypot(e[n].x-e[n-1].x,e[n].y-e[n-1].y);return t/Math.max(1,e.length-1)}function Qa(e){let t=e.length,n=e.reduce((v,h)=>v+h.x,0)/t,o=e.reduce((v,h)=>v+h.y,0)/t,i=0,a=0,r=0,s=0,l=0,c=0,d=0;for(let v of e){let h=v.x-n,p=v.y-o;i+=h*h,a+=p*p,r+=h*p,s+=h*h*h,l+=p*p*p,c+=h*p*p,d+=p*h*h}let g=i*a-r*r;if(Math.abs(g)<1e-9)return null;let b=(s+c)/2,f=(l+d)/2,y=(b*a-f*r)/g,m=(f*i-b*r)/g,x=Math.sqrt(y*y+m*m+(i+a)/t);return Number.isFinite(x)?{center:{x:y+n,y:m+o},radius:x}:null}function Ke(e){let t=e[0],n=e[e.length-1],o=Math.hypot(n.x-t.x,n.y-t.y),i=e.length;return{origin:{...t},rotation:o>0?Math.atan2(n.y-t.y,n.x-t.x)*180/Math.PI:0,curve:0,seatSpacing:i>1&&o>0?o/(i-1):Mo(e),seatCount:i,ordered:e}}function Za(e){if(e.length<3)return Ke(e);let t=e[0],n=e[e.length-1],o=Math.hypot(n.x-t.x,n.y-t.y),i=Mo(e);if(o<=0||i<=0)return Ke(e);let a=0;for(let b of e){let f=Math.abs((n.x-t.x)*(t.y-b.y)-(t.x-b.x)*(n.y-t.y))/o;a=Math.max(a,f)}if(a<i*.2)return Ke(e);let r=Qa(e);if(!r||r.radius<=i/2)return Ke(e);let s=b=>{let f=b[0],y=b[1],m=f.x-r.center.x,v=-(f.y-r.center.y),h=m;v*(y.x-f.x)+h*(y.y-f.y)<0&&(v=-v,h=-h);let p=Math.hypot(v,h)||1;v/=p,h/=p;let w=(r.center.x-f.x)*h+(r.center.y-f.y)*-v;return{tx:v,ty:h,centreSide:w}},l=e,c=s(l);c.centreSide<0&&(l=[...e].reverse(),c=s(l));let g=2*Math.asin(Math.min(1,i/(2*r.radius)))*(l.length-1)*180/Math.PI;return!Number.isFinite(g)||g>=359?Ke(e):{origin:{...l[0]},rotation:Math.atan2(c.ty,c.tx)*180/Math.PI,curve:g,seatSpacing:i,seatCount:l.length,ordered:l}}function bt(e,t){let n=Za(e);if(e.length<6)return[n];let o=t(n),i=-1,a=0;if(n.ordered.forEach((s,l)=>{let c=o[l]?Math.hypot(s.x-o[l].x,s.y-o[l].y):1/0;c>a&&(a=c,i=l)}),a<=n.seatSpacing/3)return[n];let r=Math.min(n.ordered.length-3,Math.max(3,i));return[...bt(n.ordered.slice(0,r),t),...bt(n.ordered.slice(r),t)]}function Yt(e){return e.normalize("NFKC").replace(/\s+/g," ").trim()}function Qt(e,t){let n="";for(let o of e){if(n.length+o.length>t)break;n+=o}return n.trim()}function Zt(e){return Qt(Yt(e),40)}function _o(e,t=39){return Qt(Yt(e),Math.max(1,t))}function xe(e,t=80){return Qt(Yt(e),Math.max(1,t))}function Ao(e){return xe(e).toLocaleLowerCase("en")}function Wt(e){return Ao(e)}function jo(e){return new Map((e??[]).map(t=>[t.index,t]))}function Wa(e){let t=jo(e.overrides),n=[];for(let o=0;o<e.seatCount;o+=1){let i=t.get(o);i?.skip||n.push(te(e,o,i))}return n}function es(e){if(e.bookAsWhole||e.variableOccupancy)return[e.label];let t=jo(e.overrides),n=[];for(let o=0;o<e.seatCount;o+=1){let i=t.get(o);i?.skip||n.push(i?.label??`${e.label}-${o+1}`)}return n}function ts(e){return e.type==="row"?[e.label,...Wa(e)]:e.type==="table"?[e.label,...es(e)]:e.type==="booth"?[e.label]:e.type==="gaArea"?[e.label,...oe(e)]:[]}function Lo(e,t){let n=new Set;for(let o of e)if(!t?.has(o.id))for(let i of ts(o)){let a=Wt(i);a&&n.add(a)}return n}function ns(e,t){if(!Number.isInteger(t)||t<1)return[];let n={label:e,seatCount:t},o=[Wt(e)];for(let i=0;i<t;i+=1)o.push(Wt(te(n,i)));return o.filter(Boolean)}function ko(e,t,n){let o=ns(t,n);if(!o.length||o.some(i=>e.has(i)||Te(i)))return!1;for(let i of o)e.add(i);return!0}var os=1e-6,rs=160,is=.001,as=1e-5;function Se(e){if(typeof e!="string")return;let t=e.normalize("NFKC").replace(/\s+/g," ").trim();if(!t||t.length>rs)return;for(let a of t){let r=a.codePointAt(0)??0;if(r<32||r===127)return}let n=t.lastIndexOf(":"),o=t.slice(0,n),i=t.slice(n+1);if(!(!o||!/^(0|[1-9]\d*)$/.test(i)||!Number.isSafeInteger(Number(i))))return t}function Eo(e){return typeof e=="string"&&_o(e)||void 0}function To(e,t){if(e.seatCount!==t.seatCount||e.seatCount<1||!(en(e.origin)&&en(t.start)&&en(t.end)&&Number.isFinite(e.rotation)&&Number.isFinite(e.seatSpacing)&&e.seatSpacing>0)||e.curve!==0||e.path)return!1;let n=e.rotation*Math.PI/180,o={x:e.origin.x+Math.cos(n)*e.seatSpacing*(e.seatCount-1),y:e.origin.y+Math.sin(n)*e.seatSpacing*(e.seatCount-1)},i=Math.hypot(t.end.x-t.start.x,t.end.y-t.start.y),a=is+Math.max(1,i)*as;if(Math.hypot(e.origin.x-t.start.x,e.origin.y-t.start.y)>a||Math.hypot(o.x-t.end.x,o.y-t.end.y)>a)return!1;if(e.seatCount<2||i<=os)return!0;let r=i/(e.seatCount-1);if(Math.abs(e.seatSpacing-r)>a)return!1;let s=Math.atan2(t.end.y-t.start.y,t.end.x-t.start.x)*180/Math.PI,l=Math.abs(((e.rotation-s)%360+540)%360-180),c=Math.max(.001,Math.atan2(a,Math.max(1,i))*180/Math.PI);return l<=c}function en(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}var ss=300;function cs(e){let t=new Set(H(e).filter(i=>i.type==="row"||i.type==="table"||i.type==="booth").map(i=>i.label).filter(Boolean)),n=0,o=()=>{for(;t.has(V(n));)n+=1;let i=V(n);return n+=1,t.add(i),i};return i=>{let a=Zt(i),r=0;return()=>{for(;a&&r<4096;r+=1){let s=`${a}-${V(r)}`;if(!t.has(s))return t.add(s),r+=1,s}return o()}}}function ls(e){let t=Lo(H(e));return(n,o)=>{let i=xe(n);for(let a=1;a<4096;a+=1){let r=a===1?"":` ${a}`,s=r?`${xe(i,80-r.length)}${r}`:i;if(s&&ko(t,s,o))return s}throw new Error("No collision-safe row identity is available for this reviewed direct seating row")}}function ds(e){return{ordinaryFor:cs(e),direct:ls(e)}}function tn(e,t,n){return e.type==="row"&&e.referenceScan?.assetId===t&&(!n||e.referenceScan.sectionId===n)}function Fo(e,t,n){return e.type==="table"&&e.referenceScan?.assetId===t&&(!n||e.referenceScan.sectionId===n)}function us(e,t,n){let o=new Map;for(let r of t.sections)if(!(n&&r.sectionId!==n)&&r.sourceGroupId)for(let[s,l]of r.rows.entries()){let c=Se(`${r.sourceGroupId}:${s}`),d=c&&Se(l.directSourceRowId)===c?c:void 0;d&&o.set(d,o.has(d)?null:l)}let i=new Map;for(let r of e){let s=Se(r.referenceScan?.directSourceRowId);if(!s){if(!r.overrides?.length)continue;throw new u("invalid_operation","This earlier imported row has seat overrides but no immutable source-row id. Keep it, remove its overrides, or restore the original import before rereading.",{rowId:r.id})}let l=i.get(s)??[];l.push(r),i.set(s,l)}let a=new Map;for(let[r,s]of i){let l=s.filter(b=>b.overrides?.length);if(!l.length)continue;let c=o.get(r),d=l[0],g=d.overrides;if(s.length!==1||l.length!==1||!g||!c||!To(d,c))throw new u("invalid_operation","This reread would replace a row with seat overrides using different source geometry. Keep the existing row or remove its overrides before rereading.",{sourceRowId:r,rowIds:s.map(b=>b.id)});a.set(r,structuredClone(g))}return a}function No(e,t,n){return e.filter(o=>(o.type==="row"||o.type==="table"||o.type==="booth"||o.type==="gaArea")&&!tn(o,t,n)&&!Fo(o,t,n))}function fs(e,t,n,o,i,a,r){let s=e.sectionId?t.find(d=>d.type==="section"&&d.id===e.sectionId):void 0;if(s){let d=No(t,n,r).filter(g=>$(F(g),s.outline,s.holes));if(d.length)return{skip:{sectionId:s.id,name:e.name,reason:"section_not_empty",objectIds:d.map(g=>g.id)},rows:[],seats:0}}let l=[],c=0;for(let[d,g]of e.rows.entries()){let b=Math.min(ss,Math.max(1,Math.round(g.seatCount)));if(!Number.isFinite(b)||b<1)continue;let f=g.end.x-g.start.x,y=g.end.y-g.start.y,m=Math.hypot(f,y),x=b>1&&m>0?m/(b-1):o>0?o:24;if(!Number.isFinite(x)||x<=0)continue;let v=m>0?Math.atan2(y,f)*180/Math.PI:0,h={x:g.start.x,y:g.start.y},p=0,w=x,S,I=g.seats?.length===b&&g.seats.every(P=>Number.isFinite(P.x)&&Number.isFinite(P.y))?g.seats:null;if(I&&g.table&&b>=3){let P=g.table.center,q=I.reduce((K,J)=>K+Math.hypot(J.x-P.x,J.y-P.y),0)/b,ee=I.map(K=>Math.atan2(K.y-P.y,K.x-P.x)).sort((K,J)=>K-J),se=0,R=0;ee.forEach((K,J)=>{let un=J+1<ee.length?ee[J+1]:ee[0]+Math.PI*2;un-K>se&&(se=un-K,R=(J+1)%ee.length)});let _=se>1.6*(Math.PI*2/b),U=_?(Math.PI*2-se)*180/Math.PI:void 0;S={center:{...P},radius:Math.max(1,q-ie),...U!==void 0?{seatArc:U}:{}},v=_?(ee[R]-se/2)*180/Math.PI:ee[0]*180/Math.PI,h={...P}}let C=[];if(I&&!S&&b>=3){C=bt(I,q=>Y({origin:q.origin,rotation:q.rotation,curve:q.curve,seatCount:q.seatCount,seatSpacing:q.seatSpacing}));let P=C[0];h=P.origin,v=P.rotation,p=P.curve,w=P.seatSpacing}if(!Number.isFinite(w)||w<=0)continue;let j=e.sourceGroupId?Se(`${e.sourceGroupId}:${d}`):void 0,L=j&&Se(g.directSourceRowId)===j?j:void 0,T=L?Eo(g.directReviewedSuffix):void 0,G=e.sourceGroupId&&g.rowLabel?xe(g.rowLabel):"",M=e.sourceGroupId&&g.rowDisplayLabel?xe(g.rowDisplayLabel):"",z=!!e.sourceGroupId&&g.rowDisplayLabel==="";l.push({label:G?a(G,b):i(),displayLabel:M||(z?"":String(d+1)),origin:h,rotation:v,curve:p,seatCount:C[0]?.seatCount??b,seatSpacing:w,...S?{table:S}:{},...I&&!S?{measured:!0}:{},...L?{directSourceRowId:L}:{},...T?{directReviewedSuffix:T}:{}});for(let P of C.slice(1))l.push({label:i(),displayLabel:String(d+1),origin:P.origin,rotation:P.rotation,curve:P.curve,seatCount:P.seatCount,seatSpacing:P.seatSpacing,measured:!0});c+=b}return{skip:null,rows:l,seats:c}}function gs(e,t,n){E(e,n.categoryKey);let o=O(e,n.floorId),i=t.assetId,a=n.sectionId?o.objects.find(h=>h.type==="section"&&h.id===n.sectionId):void 0;if(n.sectionId&&!a)throw new Error("The opened section no longer exists on this floor");let r=new Map;for(let h of t.sections){if(a&&h.sectionId!==a.id)continue;let p=n.categoryKeyForSection?.(h)??n.categoryKey;E(e,p),r.set(h,p)}if(a&&!t.sections.some(h=>h.sectionId===a.id&&h.seatCount>0))return{floorId:o.floorId,assetId:i,createdRowIds:[],removedRowIds:[],totalSeats:0,perSection:[],skipped:[]};let s=a?t.sections.find(h=>h.sectionId===a.id&&h.seatCount>0):void 0;if(a&&s){let h=No(o.objects,i,a.id).filter(p=>$(F(p),a.outline,a.holes));if(h.length)return{floorId:o.floorId,assetId:i,createdRowIds:[],removedRowIds:[],totalSeats:0,perSection:[],skipped:[{sectionId:a.id,name:s.name,reason:"section_not_empty",objectIds:h.map(p=>p.id)}]}}let l=o.objects.filter(h=>tn(h,i,a?.id)),c=us(l,t,a?.id),d=[],g=o.objects.filter(h=>tn(h,i,a?.id)||Fo(h,i,a?.id)?(d.push(h.id),!1):!0);o.objects.splice(0,o.objects.length,...g);let b=[],f=[],y=[],m=new Set,x=0,v=ds(e);for(let h of t.sections){if(a&&h.sectionId!==a.id)continue;let p=fs(h,o.objects,i,t.seatPitch,v.ordinaryFor(h.name),v.direct,a?.id);if(p.skip){f.push(p.skip);continue}let w=[],S=[],I=0;for(let C of p.rows){let j={assetId:i,...h.sectionId?{sectionId:h.sectionId}:{}},L=r.get(h)??n.categoryKey;if(C.table){I+=1,w.push({type:"table",id:A(e,"t",n.idFactory,m),referenceScan:j,label:C.label,displayLabel:String(I),center:C.table.center,shape:"round",radius:C.table.radius,...C.table.seatArc!==void 0?{seatArc:C.table.seatArc}:{},rotation:C.rotation,seatCount:C.seatCount,categoryKey:L});continue}let T={type:"row",id:A(e,"r",n.idFactory,m),referenceScan:{...j,...C.directSourceRowId?{directSourceRowId:C.directSourceRowId}:{},...C.directReviewedSuffix?{directReviewedSuffix:C.directReviewedSuffix}:{}},label:C.label,...C.displayLabel!==void 0?{displayLabel:C.displayLabel}:{},origin:C.origin,rotation:C.rotation,curve:C.curve,seatCount:C.seatCount,seatSpacing:C.seatSpacing,categoryKey:L,...C.directSourceRowId&&c.has(C.directSourceRowId)?{overrides:structuredClone(c.get(C.directSourceRowId))}:{}};w.push(T),C.measured&&S.push(T)}if(o.objects.push(...w),S.length&&!h.sourceGroupId){let C=k(e).find(j=>j.id===o.floorId);bs(e,S,C?.focalPoint??e.focalPoint,o.floorId,n.idFactory)}for(let C of w)y.push(C.id);b.push({sectionId:h.sectionId,name:h.name,seats:p.seats,rows:w.length}),x+=p.seats}return{floorId:o.floorId,assetId:i,createdRowIds:y,removedRowIds:d,totalSeats:x,perSection:b,skipped:f}}function bs(e,t,n,o,i){let a=t.map(f=>Y(f)),r=a.flat(),s=n??{x:r.reduce((f,y)=>f+y.x,0)/r.length,y:Math.min(...r.map(f=>f.y))-1},l=t.map((f,y)=>{let m=a[y],x=m.map((h,p)=>{let w=m[Math.max(0,p-1)],S=m[Math.min(m.length-1,p+1)],I=Math.hypot(S.x-w.x,S.y-w.y);return I<=0?Math.hypot(h.x-s.x,h.y-s.y):Math.abs((h.x-s.x)*(-(S.y-w.y)/I)+(h.y-s.y)*((S.x-w.x)/I))}).sort((h,p)=>h-p),v=m.reduce((h,p)=>h+p.x,0)/m.length;return{row:f,depth:x[Math.floor(x.length/2)],along:v}}).sort((f,y)=>f.depth-y.depth||f.along-y.along),c=l.slice(1).map((f,y)=>f.depth-l[y].depth).filter(f=>f>1e-6).sort((f,y)=>f-y),d=c.length?c[Math.floor(c.length*.75)]:1/0,g=[],b=-1/0;for(let f of l)(!g.length||f.depth-b>d*.45)&&(g.push([]),b=f.depth),g[g.length-1].push(f.row);g.forEach((f,y)=>{let m=V(y);f.sort((x,v)=>{let h=Y(x),p=Y(v);return h.reduce((w,S)=>w+S.x,0)/h.length-p.reduce((w,S)=>w+S.x,0)/p.length});for(let x of f)x.displayLabel=m;f.length>=2&&f.length<=64&&Xt(e,{floorId:o,rowIds:f.map(x=>x.id),boundaries:f.slice(1).map(()=>"break"),displayLabel:m,idFactory:i})})}function Go(e,t,n={}){let o=O(e,t.floorId),i=[...new Set(t.objectIds)];if(!i.length)throw new u("invalid_operation","Select at least one table or booth to repeat");let a=i.map(m=>o.objects.find(x=>(x.type==="table"||x.type==="booth")&&x.id===m)),r=i.filter((m,x)=>!a[x]);if(r.length)throw new u("object_not_found","One or more grid sources do not exist on the selected floor",{objectIds:r});let s=a[0].type;if(a.some(m=>m.type!==s))throw new u("invalid_operation","A grid array must contain only tables or only booths");for(let[m,x,v]of[["rows",t.rows,30],["columns",t.columns,30]])if(!Number.isInteger(x)||x<1||x>v)throw new u("invalid_operation",`${m} must be a whole number from 1 to ${v}`);for(let[m,x]of[["stepX",t.stepX],["stepY",t.stepY]])if(!Number.isFinite(x)||x<30||x>2e3)throw new u("invalid_operation",`${m} must be from 30 to 2000 chart units`);let l=t.rows*t.columns;if(l<2)throw new u("invalid_operation","Choose at least two grid cells");let c=i.length*(l-1);if(c>5e3)throw new u("invalid_operation","A grid array can add at most 5000 objects");let d=a.reduce((m,x)=>m+(x.type==="table"?x.seatCount:1),0),b=(e.floors?.length?e.floors.flatMap(m=>m.objects):e.objects).reduce((m,x)=>m+(x.type==="row"||x.type==="table"?x.seatCount:x.type==="gaArea"?Math.max(0,Math.floor(x.capacity)):x.type==="booth"?1:0),0),f=d*(l-1),y=n.maxInventory??1e5;if(b+f>y)throw new u("invalid_operation",`Grid inventory would exceed the ${y} unit event limit`);return{target:o,sources:a,preview:{floorId:o.floorId,kind:s,sourceIds:i,sourceCount:i.length,cells:l,createdCount:c,addedInventory:f,resultingInventory:b+f,provenanceRemovedCount:a.filter(m=>!!m.referenceInventorySource).length*(l-1)}}}function hs(e,t,n={}){return Go(e,t,n).preview}function ps(e,t,n={}){let{target:o,sources:i,preview:a}=Go(e,t,n),r=new Set,s=new Set((e.floors?.length?e.floors.flatMap(g=>g.objects):e.objects).flatMap(g=>"label"in g&&g.label?[g.label]:[])),l=[],c=(g,b)=>{let f=Math.max(2,b),y=x=>{let v=`-${x}`;return`${g.slice(0,Math.max(1,80-v.length))}${v}`},m=y(f);for(;s.has(m);)m=y(++f);return s.add(m),m},d=1;for(let g=0;g<t.rows;g++)for(let b=0;b<t.columns;b++)if(!(g===0&&b===0)){d+=1;for(let f of i){let y=structuredClone(f);y.id=A(e,y.type,t.idFactory,r),y.label=c(f.label,d),y.center={x:f.center.x+b*t.stepX,y:f.center.y+g*t.stepY},delete y.referenceInventorySource,l.push(y)}}return o.objects.push(...l),{...a,createdIds:l.map(g=>g.id)}}function ys(e,t){let n=e?{...e}:{};return t.size===null?delete n.size:t.size!==void 0&&(n.size=t.size),t.color===null?delete n.color:t.color!==void 0&&(n.color=N(t.color,"Seat label color")),n.size===void 0&&n.color===void 0?void 0:n}var ms=new Set(ke.map(e=>e.key));function $e(e){return`${e.rowId}:${e.index}`}function ws(e){let t=e.lastIndexOf(":"),n=t>0?e.slice(0,t):"",o=t>0?Number(e.slice(t+1)):Number.NaN;if(!n||!Number.isInteger(o)||o<0)throw new u("invalid_operation",`Invalid stable seat id: ${e}`,{seatId:e});return{rowId:n,index:o}}function xs(e,t){e.label||delete e.label,e.displayLabel||delete e.displayLabel,e.dx||delete e.dx,e.dy||delete e.dy,e.skip||delete e.skip,e.categoryKey||delete e.categoryKey,Ge(e.glyph)||delete e.glyph;let n=Ae(e);if(n.length?e.accessibility=n:delete e.accessibility,delete e.accessible,e.commercial){let o=e.commercial.note?.normalize("NFKC").trim(),i={};typeof e.commercial.restrictedView=="boolean"&&(i.restrictedView=e.commercial.restrictedView),typeof e.commercial.obstructedView=="boolean"&&(i.obstructedView=e.commercial.obstructedView),typeof e.commercial.premium=="boolean"&&(i.premium=e.commercial.premium),o&&(i.note=o),Object.keys(i).length?e.commercial=i:delete e.commercial}e.viewFromSeatUrl||(delete e.viewFromSeatUrl,delete e.viewFromSeatMeta),e.labelStyle&&e.labelStyle.size===void 0&&e.labelStyle.color===void 0&&delete e.labelStyle,t?.type==="row"&&Ze(t,e)}function Ss(e){return Object.keys(e).every(t=>t==="index")}function Ko(e,t,n){if(!n.length)throw new u("invalid_operation","At least one seat is required");let o=O(e,t),i=[],a=new Set,r=new Map;for(let s of n){let l=$e(s);if(a.has(l))continue;a.add(l);let c=o.objects.find(d=>(d.type==="row"||d.type==="table")&&d.id===s.rowId);if(!c)throw new u("object_not_found",`Unknown row or table for seat: ${l}`,{seatId:l,objectId:s.rowId});if(c.type==="table"&&(c.bookAsWhole||c.variableOccupancy))throw new u("invalid_operation",`Table "${c.label}" is sold as one grouped unit; switch it to individual-chair selling before editing chairs`,{seatId:l,tableId:c.id});if(!Number.isInteger(s.index)||s.index<0||s.index>=c.seatCount)throw new u("invalid_operation",c.type==="row"?`Seat index is outside row bounds: ${l}`:`Chair index is outside table bounds: ${l}`,{seatId:l,objectId:s.rowId,index:s.index,seatCount:c.seatCount});i.push({rowId:s.rowId,index:s.index}),r.set(c.id,c)}return{floorId:o.floorId,refs:i,owners:r}}function nn(e,t){let n=Ko(e,t.floorId,t.seats),o=Object.keys(t.patch);if(!o.length&&t.labelPrefix===void 0&&t.displayLabelPrefix===void 0)throw new u("invalid_operation","At least one seat override field is required");if(t.labelPrefix!==void 0&&Object.prototype.hasOwnProperty.call(t.patch,"label"))throw new u("invalid_operation","Use either label or labelPrefix, not both");if(t.displayLabelPrefix!==void 0&&Object.prototype.hasOwnProperty.call(t.patch,"displayLabel"))throw new u("invalid_operation","Use either displayLabel or displayLabelPrefix, not both");if(n.refs.length>1&&t.patch.label!=null)throw new u("invalid_operation","A literal label can only be assigned to one seat; use labelPrefix for a bulk sequence");if(n.refs.length>1&&t.patch.displayLabel!=null)throw new u("invalid_operation","A literal display label can only be assigned to one seat; use displayLabelPrefix for a bulk sequence");if(t.patch.categoryKey&&E(e,t.patch.categoryKey),t.patch.glyph!=null&&!Ge(t.patch.glyph))throw new u("invalid_operation","Unknown seat glyph",{glyph:t.patch.glyph});if(t.patch.accessibility){let a=t.patch.accessibility.filter(r=>!ms.has(r));if(a.length)throw new u("invalid_operation","Unknown accessibility type",{accessibility:a})}if(t.patch.wheelchairSpaceType!==void 0&&t.patch.wheelchairSpaceType!==null&&t.patch.wheelchairSpaceType!=="seat-present"&&t.patch.wheelchairSpaceType!=="no-seat")throw new u("invalid_operation","wheelchairSpaceType must be seat-present, no-seat, or null");if(t.patch.wheelchairSpaceType&&t.patch.skip===!0)throw new u("invalid_operation","A wheelchair-space physical type cannot also be skipped inventory");for(let a of n.refs){let r=n.owners.get(a.rowId)?.overrides?.find(c=>c.index===a.index),s=t.patch.wheelchairSpaceType===null?void 0:t.patch.wheelchairSpaceType??r?.wheelchairSpaceType,l=t.patch.skip===null?!1:t.patch.skip??r?.skip??!1;if(s&&l)throw new u("invalid_operation","A wheelchair-space physical type cannot also be skipped inventory",{seatId:$e(a)})}if(t.patch.commercial?.note&&t.patch.commercial.note.normalize("NFKC").trim().length>160)throw new u("invalid_operation","Commercial note supports at most 160 characters");if(t.patch.viewFromSeatUrl!=null){let a=re(t.patch.viewFromSeatUrl);if(!a)throw new u("invalid_operation","Seat view photo must be a safe HTTPS or base64 raster image reference");t.patch.viewFromSeatUrl=a}for(let a of["dx","dy"]){let r=t.patch[a];if(r!=null&&!Number.isFinite(r))throw new u("invalid_operation",`${a} must be finite`,{[a]:r})}t.patch.labelStyle!=null&&me(t.patch.labelStyle,"Seat");let i=!1;return n.refs.forEach((a,r)=>{let s=n.owners.get(a.rowId),l=JSON.stringify(s.overrides??[]),c=s.overrides??(s.overrides=[]),d=c.find(b=>b.index===a.index);d||(d={index:a.index},c.push(d));let g=d.viewFromSeatUrl;for(let b of o){let f=t.patch[b];if(b==="wheelchairSpaceType"&&f==null)delete d.wheelchairSpaceType,d.accessibility&&(d.accessibility=d.accessibility.filter(y=>y!=="wheelchair"),d.accessibility.length||delete d.accessibility),delete d.accessible;else if(f==null)delete d[b];else if(b==="accessibility")d.accessibility=[...new Set(f)],delete d.accessible;else if(b==="commercial")d.commercial={...d.commercial,...f};else if(b==="labelStyle"){let y=ys(d.labelStyle,f);y?d.labelStyle=y:delete d.labelStyle}else Object.assign(d,{[b]:f})}t.patch.viewFromSeatMeta===void 0&&t.patch.viewFromSeatUrl!==void 0&&d.viewFromSeatUrl!==g&&delete d.viewFromSeatMeta,t.labelPrefix!==void 0&&(d.label=`${t.labelPrefix}${r+1}`),t.displayLabelPrefix!==void 0&&(d.displayLabel=`${t.displayLabelPrefix}${r+1}`),xs(d,s),Ss(d)&&(s.overrides=c.filter(b=>b!==d)),s.overrides?.length||delete s.overrides,JSON.stringify(s.overrides??[])!==l&&(i=!0)}),{floorId:n.floorId,changed:i,seatIds:n.refs.map($e)}}function Is(e,t){let n=Ko(e,t.floorId,t.seats),o=!1;for(let[i,a]of n.owners){if(!a.overrides?.length)continue;let r=new Set(n.refs.filter(l=>l.rowId===i).map(l=>l.index)),s=a.overrides.filter(l=>!r.has(l.index));s.length!==a.overrides.length&&(o=!0),a.overrides=s,a.overrides.length||delete a.overrides}return{floorId:n.floorId,changed:o,seatIds:n.refs.map($e)}}function vs(e,t){let n=O(e,t.floorId),o=[...new Set(t.rowIds)],i=o.map(h=>n.objects.find(p=>p.type==="row"&&p.id===h)),a=o.filter((h,p)=>!i[p]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});if(t.patch.categoryKey!==void 0&&E(e,t.patch.categoryKey),t.patch.seatCount!==void 0&&(!Number.isInteger(t.patch.seatCount)||t.patch.seatCount<1||t.patch.seatCount>300))throw new u("invalid_operation","seatCount must be an integer from 1 to 300");if(t.patch.seatNumbering!==void 0){let h=t.patch.seatNumbering,p=["decimal","odd","even","updown","updown-descending","roman","letters-upper","letters-lower"];if(h.scheme!==void 0&&!p.includes(h.scheme))throw new u("invalid_operation",`Unknown seat numbering scheme: ${h.scheme}. Expected one of ${p.join(", ")}.`);if(h.prefix!==void 0&&(typeof h.prefix!="string"||h.prefix.length>8))throw new u("invalid_operation","Seat label prefix must be a string of at most 8 characters");if(h.endAt!==void 0&&h.endAt!==null&&(!Number.isInteger(h.endAt)||h.endAt<0||h.endAt>9999))throw new u("invalid_operation","Seat numbering endAt must be an integer from 0 to 9999")}let{labelStyle:r,labelPosition:s,labelRotation:l,labelStyleShape:c,displayLabel:d,displayType:g,...b}=t.patch,f=d===void 0?{}:{displayLabel:d},y=ye(f,"Row"),m=g===void 0?void 0:Lt(g,"Row");if(r!==void 0&&me(r,"Row"),s!==void 0&&!["start","end","both","none"].includes(s))throw new u("invalid_operation","Row labelPosition must be one of start, end, both, none");if(l!=null&&(!Number.isFinite(l)||l<-180||l>180))throw new u("invalid_operation","Row labelRotation must be a number from -180 to 180");if(c!==void 0&&c!=="plain"&&c!=="pill")throw new u("invalid_operation","Row labelStyleShape must be plain or pill");b.labelPresentation!==void 0&&tt(b.labelPresentation,"Row");let x=h=>JSON.stringify({origin:h.origin,rotation:h.rotation,curve:h.curve,seatCount:h.seatCount,seatSpacing:h.seatSpacing,path:h.path??null}),v=!1;for(let h of i){let p=JSON.stringify(h),w=x(h),S=t.preserveCenterOnSeatCountChange&&t.patch.seatCount!==void 0?F(h):null;if(Object.assign(h,structuredClone(b)),h.overrides&&t.patch.seatCount!==void 0&&(h.overrides=h.overrides.filter(I=>I.index<h.seatCount),h.overrides.length||(h.overrides=void 0)),S){let I=F(h);h.origin={x:h.origin.x+S.x-I.x,y:h.origin.y+S.y-I.y}}if(JSON.stringify(h)!==p&&(v=!0),x(h)!==w&&(delete h.arcFanGeneration,delete h.rowBlockGeneration),r!==void 0){let I=JSON.stringify(h.labelPresentation??null),C=nt(h.labelPresentation,r);C?h.labelPresentation=C:delete h.labelPresentation,JSON.stringify(h.labelPresentation??null)!==I&&(v=!0)}if(s!==void 0){let I=JSON.stringify(h.labelPresentation??null),C=h.labelPresentation?structuredClone(h.labelPresentation):{};C.positionPreset=s,C.visible=s!=="none",delete C.position,h.labelPresentation=C,JSON.stringify(h.labelPresentation??null)!==I&&(v=!0)}if(l!==void 0||c!==void 0){let I=JSON.stringify(h.labelPresentation??null),C=h.labelPresentation?structuredClone(h.labelPresentation):{};l===null?delete C.rotation:l!==void 0&&(C.rotation=l),c!==void 0&&(C.style=c),h.labelPresentation=C,JSON.stringify(h.labelPresentation??null)!==I&&(v=!0)}if(m!==void 0){let I=h.displayType;m?h.displayType=m:delete h.displayType,h.displayType!==I&&(v=!0)}if(d!==void 0){let I=h.displayLabel;y?delete h.displayLabel:h.displayLabel=f.displayLabel,h.displayLabel!==I&&(v=!0)}}return{floorId:n.floorId,changed:v,rowIds:o}}var Cs=3;function ht(e){return(e%360+360)%360}function Os(e){let t=e.rotation*Z;return{x:Math.cos(t),y:Math.sin(t)}}function Rs(e,t){let n=Math.abs(ht(e-t));return n>180&&(n=360-n),n}function Ie(e,t,n){return(e.x-t.x)*n.x+(e.y-t.y)*n.y}function $o(e){let t=0,n=0;for(let i of e){let a=2*i.rotation*Z;t+=Math.cos(a),n+=Math.sin(a)}let o=(t===0&&n===0?0:Math.atan2(n,t))/2;return{x:Math.cos(o),y:Math.sin(o)}}function Ps(e,t,n){if(e.origin={x:e.origin.x+t,y:e.origin.y+n},e.path){let o=i=>({x:i.x+t,y:i.y+n});e.path={start:o(e.path.start),control1:o(e.path.control1),control2:o(e.path.control2),end:o(e.path.end)}}}function Bo(e,t){let n=$o(e),o={x:-n.y,y:n.x},i=F(e[0]),a=e.map(l=>({row:l,coord:Ie(F(l),i,o)})).sort((l,c)=>l.coord-c.coord),r=a[0].coord,s=!1;return a.forEach((l,c)=>{let d=r+c*t-l.coord;Math.abs(d)>1e-6&&(Ps(l.row,o.x*d,o.y*d),delete l.row.arcFanGeneration,delete l.row.rowBlockGeneration,s=!0)}),s}function Ms(e,t){let n={x:-t.y,y:t.x},o=F(e[0]),i=e.map(r=>Ie(F(r),o,n)).sort((r,s)=>r-s);if(i.length<2)return 28;let a=(i[i.length-1]-i[0])/(i.length-1);return a>.5?a:28}function _s(e){if(e.seatCount<2){e.curve=0,delete e.path,delete e.arcFanGeneration,delete e.rowBlockGeneration;return}let t=Y(e),n=t[0],o=t[t.length-1],i=o.x-n.x,a=o.y-n.y,r=Math.hypot(i,a);e.path&&(e.origin={...n},e.seatSpacing=Math.max(1,r/(e.seatCount-1))),r>1e-6&&(e.rotation=ht(Math.atan2(a,i)/Z)),e.curve=0,delete e.path,delete e.arcFanGeneration,delete e.rowBlockGeneration}function As(e,t){let n=new Set(e.filter(o=>o.type==="row").map(o=>o.label));for(let o=2;o<1e4;o++){let i=`${t}${o}`.slice(0,80);if(!n.has(i))return i}return`${t}-${Date.now().toString(36)}`}function js(e,t){let n=O(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2)throw new u("invalid_operation","Select at least two rows to merge");let i=o.map(S=>n.objects.find(I=>I.type==="row"&&I.id===S)),a=o.filter((S,I)=>!i[I]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let r=i,s=r.filter(S=>S.path||S.curve!==0);if(s.length)throw new u("invalid_operation","Only straight rows can be merged. Straighten the rows first, then merge.",{rowIds:s.map(S=>S.id)});let l=r[0],c=r.find(S=>Rs(S.rotation,l.rotation)>Cs);if(c)throw new u("invalid_operation","Rows must be parallel to merge. They point in different directions.",{rowIds:[l.id,c.id]});let d=Os(l),g={x:-d.y,y:d.x},b=Math.max(8,l.seatSpacing*.6),f=r.find(S=>Math.abs(Ie(S.origin,l.origin,g))>b);if(f){let S=Math.round(Math.abs(Ie(f.origin,l.origin,g)));throw new u("invalid_operation",`Rows must lie on the same line to merge: a selected row is offset ${S} units from the first.`,{rowIds:[l.id,f.id]})}let y=r.slice().sort((S,I)=>Ie(S.origin,l.origin,d)-Ie(I.origin,l.origin,d)),m=y.reduce((S,I)=>S+I.seatCount,0);if(m>300)throw new u("invalid_operation",`A merged row would have ${m} seats, over the 300-seat row limit. Merge fewer rows.`);let x=y[0],v=[],h=0;for(let S of y){if(S.overrides)for(let I of S.overrides)v.push({...structuredClone(I),index:I.index+h});h+=S.seatCount}x.seatCount=m,x.curve=0,delete x.path,v.length?x.overrides=v:delete x.overrides,delete x.arcFanGeneration,delete x.rowBlockGeneration;let p=y.slice(1).map(S=>S.id),w=new Set(p);for(let S=n.objects.length-1;S>=0;S--)w.has(n.objects[S].id)&&n.objects.splice(S,1);return{floorId:n.floorId,changed:!0,rowId:x.id,removedRowIds:p,seatCount:m}}function Ls(e,t){let n=O(e,t.floorId),o=n.objects.find(f=>f.type==="row"&&f.id===t.rowId);if(!o)throw new u("object_not_found","The row id does not exist on the selected floor",{rowIds:[t.rowId]});if(o.path)throw new u("invalid_operation","Cannot split a free-form curved row. Straighten it first, then split.",{rowIds:[o.id]});let i=o.seatCount,a=t.index;if(!Number.isInteger(a)||a<1||a>i-1)throw new u("invalid_operation",`Split position must be a whole number from 1 to ${i-1} (the seat where the second row begins)`);let r=Y(o),s=i>1?o.curve/(i-1):0,l=i-a,c={type:"row",id:A(e,"r",t.idFactory,new Set),label:As(n.objects,o.label),origin:{...r[a]},rotation:ht(o.rotation-s*a),curve:s*(l-1),seatCount:l,seatSpacing:o.seatSpacing,categoryKey:o.categoryKey};if(o.seatNumbering&&(c.seatNumbering=structuredClone(o.seatNumbering)),o.seatLabelStart!=null&&(c.seatLabelStart=o.seatLabelStart),o.commercial&&(c.commercial=structuredClone(o.commercial)),o.viewFromSeatUrl&&(c.viewFromSeatUrl=o.viewFromSeatUrl),o.viewFromSeatMeta&&(c.viewFromSeatMeta=structuredClone(o.viewFromSeatMeta)),o.confidenceEvidence&&(c.confidenceEvidence=structuredClone(o.confidenceEvidence)),o.labelPresentation){let f=structuredClone(o.labelPresentation);delete f.position,c.labelPresentation=f}let d=[],g=[];if(o.overrides)for(let f of o.overrides)f.index<a?d.push(structuredClone(f)):g.push({...structuredClone(f),index:f.index-a});o.seatCount=a,o.curve=s*(a-1),d.length?o.overrides=d:delete o.overrides,delete o.arcFanGeneration,delete o.rowBlockGeneration,g.length&&(c.overrides=g);let b=n.objects.indexOf(o);return n.objects.splice(b+1,0,c),{floorId:n.floorId,changed:!0,rowId:o.id,newRowId:c.id,firstSeatCount:a,secondSeatCount:l,newLabel:c.label}}function ks(e,t){let n=O(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2)throw new u("invalid_operation","Select at least two rows to set row spacing");if(!Number.isFinite(t.gap)||t.gap<=0||t.gap>4e3)throw new u("invalid_operation","Row spacing must be a positive value up to 4000 chart units");let i=o.map(s=>n.objects.find(l=>l.type==="row"&&l.id===s)),a=o.filter((s,l)=>!i[l]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let r=Bo(i,t.gap);return{floorId:n.floorId,changed:r,rowIds:o,gap:t.gap}}function Es(e,t){let n=O(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2)throw new u("invalid_operation","Select at least two rows to straighten and space evenly");let i=o.map(b=>n.objects.find(f=>f.type==="row"&&f.id===b)),a=o.filter((b,f)=>!i[f]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let r=i,s=()=>JSON.stringify(r.map(b=>[b.origin,b.rotation,b.curve,b.path??null,b.seatSpacing])),l=s();for(let b of r)_s(b);let c=$o(r),d=ht(Math.atan2(c.y,c.x)/Z);for(let b of r)b.rotation=d;let g=Ms(r,c);return Bo(r,g),{floorId:n.floorId,changed:s()!==l,rowIds:o,gap:g}}var yt=br(require("polygon-clipping"),1),zo=100,Uo=512,on=8192,Zo=64,Ho=1e7,D=1e-7;function Wo(e,t){return Math.abs(e.x-t.x)<=D&&Math.abs(e.y-t.y)<=D}function er(e){let t=e.map(n=>({x:n.x,y:n.y}));for(;t.length>1&&Wo(t[0],t[t.length-1]);)t.pop();return t}function Be(e,t,n){let o=Q(t,n,e);return Math.abs(o)>D?!1:e.x>=Math.min(t.x,n.x)-D&&e.x<=Math.max(t.x,n.x)+D&&e.y>=Math.min(t.y,n.y)-D&&e.y<=Math.max(t.y,n.y)+D}function tr(e,t,n,o){let i=Q(e,t,n),a=Q(e,t,o),r=Q(n,o,e),s=Q(n,o,t);return(i>D&&a<-D||i<-D&&a>D)&&(r>D&&s<-D||r<-D&&s>D)?!0:Math.abs(i)<=D&&Be(n,e,t)||Math.abs(a)<=D&&Be(o,e,t)||Math.abs(r)<=D&&Be(e,n,o)||Math.abs(s)<=D&&Be(t,n,o)}function Ts(e){for(let t=0;t<e.length;t+=1){let n=(t+1)%e.length;for(let o=t+1;o<e.length;o+=1){let i=(o+1)%e.length;if(!(t===o||n===o||i===t)&&tr(e[t],e[n],e[o],e[i]))return!0}}return!1}function Vo(e,t){return e.some((n,o)=>t.some((i,a)=>tr(n,e[(o+1)%e.length],i,t[(a+1)%t.length])))}function rn(e,t){return!t.some((n,o)=>Be(e,n,t[(o+1)%t.length]))&&$(e,t,void 0)}function mt(e,t,n){let o=er(e);if(o.length<3||o.length>Uo||o.some((i,a)=>!Number.isFinite(i.x)||!Number.isFinite(i.y)||Math.abs(i.x)>Ho||Math.abs(i.y)>Ho||Wo(i,o[(a+1)%o.length]))||Math.abs(Re(o))<=D||Ts(o))throw new u("invalid_operation",`GA area ${n} has an invalid or self-intersecting ${t}; Join Areas accepts 3\u2013${Uo} finite vertices per ring.`,{gaAreaId:n,ring:t});return o}function Fs(e){let t=mt(e.points,"outline",e.id),n=e.holes??[];if(!Array.isArray(n)||n.length>Zo)throw new u("invalid_operation",`GA area ${e.id} has too many cutouts to join`,{gaAreaId:e.id});let o=n.map(i=>mt(i,"cutout",e.id));for(let i=0;i<o.length;i+=1){let a=o[i];if(!a.flatMap((s,l)=>{let c=a[(l+1)%a.length];return[s,{x:(s.x+c.x)/2,y:(s.y+c.y)/2}]}).every(s=>rn(s,t))||Vo(a,t))throw new u("invalid_operation",`GA area ${e.id} has a cutout outside its outline`,{gaAreaId:e.id,holeIndex:i});for(let s=i+1;s<o.length;s+=1)if(Vo(a,o[s])||rn(a[0],o[s])||rn(o[s][0],a))throw new u("invalid_operation",`GA area ${e.id} has overlapping cutouts`,{gaAreaId:e.id,holeIndex:i})}return{outer:t,holes:o}}function pt(e){return e.map(t=>[t.x,t.y])}function qo(e){return er(e.map(([t,n])=>({x:t,y:n})))}function Jo(e){return Math.abs(e.reduce((t,n,o)=>{let i=e[(o+1)%e.length];return t+n[0]*i[1]-i[0]*n[1]},0))/2}function Ns(e){return e.reduce((t,n)=>t+(Jo(n[0]??[])-n.slice(1).reduce((o,i)=>o+Jo(i),0)),0)}function an(e){if(e===void 0)return"undefined";if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(an).join(",")}]`;let t=e;return`{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${an(t[n])}`).join(",")}}`}function Xo(e,t,n){let o=e[t];if(o===void 0)return null;let i=o.normalize("NFKC").trim();if(!i||i!==o||i.length>n)throw new u("invalid_operation",`GA area ${e.id} has an invalid ${t}; normalize it to 1\u2013${n} characters before joining.`,{gaAreaId:e.id,field:t});return i}function Yo(e){return an({categoryKey:e.categoryKey,displayLabel:Xo(e,"displayLabel",80),displayType:Xo(e,"displayType",24),referenceInventorySource:e.referenceInventorySource??null})}function Qo(e,t){let n=Math.min(...e.points.map(i=>i.y)),o=Math.min(...e.points.map(i=>i.x));return[n,o,t]}function Ds(e,t){return e[0]-t[0]||e[1]-t[1]||e[2]-t[2]}function nr(e,t,n={}){let o=O(e,t.floorId),i=[...new Set(t.gaAreaIds)];if(i.length<2)throw new u("invalid_operation","Select at least two GA areas to join");if(i.length>zo)throw new u("invalid_operation",`Join Areas supports at most ${zo} areas at once`);let a=i.map(R=>o.objects.find(_=>_.type==="gaArea"&&_.id===R)),r=i.filter((R,_)=>!a[_]);if(r.length)throw new u("object_not_found","One or more GA area ids do not exist on the selected floor",{gaAreaIds:r});let s=a;E(e,s[0].categoryKey);let l=Yo(s[0]),c=s.find(R=>Yo(R)!==l);if(c)throw new u("invalid_operation","GA areas must use the same category, displayed label, displayed type, and reference-inventory provenance before they can be joined.",{gaAreaIds:[s[0].id,c.id]});let d=Fe(e).objectToSection,g=d.get(s[0].id)??"__ungrouped__",b=s.find(R=>(d.get(R.id)??"__ungrouped__")!==g);if(b)throw new u("invalid_operation","GA areas must belong to the same buyer section before they can be joined.",{gaAreaIds:[s[0].id,b.id],sectionIds:[g,d.get(b.id)??"__ungrouped__"]});let f=s.reduce((R,_)=>{if(!Number.isInteger(_.capacity)||_.capacity<1||_.capacity>W)throw new u("invalid_operation",`GA area ${_.id} has invalid capacity`,{gaAreaId:_.id});return R+_.capacity},0);if(f>W)throw new u("invalid_operation",`Joined GA capacity would be ${f}, over the ${W}-unit area limit`,{capacity:f});let y=H(e).reduce((R,_)=>R+de(_),0),m=n.maxInventory??1e5;if(y>m)throw new u("invalid_operation",`Chart inventory exceeds the ${m}-unit publication limit`,{inventory:y});let x=s.map(Fs),v=x.reduce((R,_)=>R+_.outer.length+_.holes.reduce((U,K)=>U+K.length,0),0);if(v>on)throw new u("invalid_operation",`Join Areas supports at most ${on} source vertices`,{vertexCount:v});let h;try{let R=x.map(K=>[pt(K.outer)]);if(h=yt.default.union(R[0],...R.slice(1)),h.length!==1)throw new u("invalid_operation","Selected GA areas must overlap or share an edge. Disconnected or point-only contact cannot produce one sellable surface.",{surfaceCount:h.length});let _=x.flatMap(K=>K.holes.map(J=>[pt(J)]));_.length&&(h=yt.default.difference(h,..._));let U=x.findIndex(K=>{let J=[pt(K.outer),...K.holes.map(pt)];return Ns(yt.default.intersection(J,h))<=D});if(U>=0)throw new u("invalid_operation",`GA area ${s[U].id} contributes no sellable surface after preserving every source cutout.`,{gaAreaId:s[U].id})}catch(R){throw R instanceof u?R:new u("invalid_operation","The selected GA boundaries could not be joined safely",{reason:R instanceof Error?R.message:"polygon_union_failed"})}if(h.length!==1||!h[0]?.length)throw new u("invalid_operation","Joining these boundaries would create disconnected sellable surfaces; adjust the outlines or cutouts first.",{surfaceCount:h.length});let p=qo(h[0][0]),w=h[0].slice(1).map(qo),S=p.length+w.reduce((R,_)=>R+_.length,0);if(w.length>Zo||S>on)throw new u("invalid_operation","The joined boundary is too complex to store safely",{holeCount:w.length,vertexCount:S});mt(p,"outline",s[0].id),w.forEach(R=>mt(R,"cutout",s[0].id));let I=new Map(o.objects.map((R,_)=>[R.id,_])),C=s.slice().sort((R,_)=>Ds(Qo(R,I.get(R.id)??Number.MAX_SAFE_INTEGER),Qo(_,I.get(_.id)??Number.MAX_SAFE_INTEGER))),j=C[0],L=structuredClone(e),T=O(L,o.floorId),G=T.objects.find(R=>R.type==="gaArea"&&R.id===j.id);G.points=structuredClone(p),w.length?G.holes=structuredClone(w):delete G.holes;let M=new Set(C.slice(1).map(R=>R.id));for(let R=T.objects.length-1;R>=0;R-=1)M.has(T.objects[R].id)&&T.objects.splice(R,1);let z=Fe(L).objectToSection.get(j.id)??"__ungrouped__";if(z!==g)throw new u("invalid_operation","The joined surface would change buyer-section ownership; adjust the GA or section boundaries first.",{gaAreaId:j.id,beforeSectionId:g,afterSectionId:z});let P=[],q=new Set;for(let R of C){if(!Ft(R))throw new u("invalid_operation",`GA area ${R.id} has invalid inventory provenance and cannot be joined`,{gaAreaId:R.id});let _=oe(R);if(_.length!==R.capacity||_.some(U=>q.has(U)))throw new u("invalid_operation","Selected GA areas contain duplicated or incomplete stable inventory identities",{gaAreaId:R.id});_.forEach(U=>q.add(U)),P.push(...at(R))}if(P.length>256)throw new u("invalid_operation","Joined inventory provenance would exceed 256 durable source ranges");let ee=new Set(s.map(R=>R.id));for(let R of H(e).filter(_=>_.type==="gaArea"&&!ee.has(_.id))){let _=oe(R).find(U=>q.has(U));if(_)throw new u("invalid_operation","A stable GA inventory identity is already owned by another area",{label:_,gaAreaId:R.id})}let se=C.slice(1).map(R=>R.id);return{floorId:o.floorId,areaId:j.id,survivorLabel:j.label,removedAreaIds:se,sourceAreaCount:C.length,capacity:f,inventorySegmentCount:P.length,outerVertexCount:p.length,holeCount:w.length,sectionId:g,points:p,...w.length?{holes:w}:{},segments:P}}function Gs(e,t,n={}){let{segments:o,...i}=nr(e,t,n);return i}function Ks(e,t,n={}){let o=nr(e,t,n),i=O(e,o.floorId),a=i.objects.find(c=>c.type==="gaArea"&&c.id===o.areaId);a.points=structuredClone(o.points),o.holes?.length?a.holes=structuredClone(o.holes):delete a.holes,a.capacity=o.capacity,a.inventorySegments=structuredClone(o.segments);let r=new Set(o.removedAreaIds);for(let c=i.objects.length-1;c>=0;c-=1)r.has(i.objects[c].id)&&i.objects.splice(c,1);let{segments:s,...l}=o;return{...l,changed:!0}}function $s(e,t){let n=O(e,t.floorId),o=[...new Set(t.shapeIds)];if(!o.length)throw new u("invalid_operation","At least one shape id is required");let i=o.map(c=>n.objects.find(d=>d.type==="shape"&&d.id===c)),a=o.filter((c,d)=>!i[d]);if(a.length)throw new u("object_not_found",`Unknown shape id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current shape ids.`,{shapeIds:a});let r=structuredClone(t.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one shape change is required");if(r.label!==void 0){if(o.length!==1)throw new u("invalid_operation","label can be changed only for one shape at a time");if(r.label!==null){if(r.label=r.label.normalize("NFKC").trim(),!r.label)r.label=null;else if(r.label.length>80)throw new u("invalid_operation","Shape labels support at most 80 characters")}}if(r.labelStyle!==void 0){let c=i.filter(d=>d.role!=="stage");if(c.length)throw new u("invalid_operation","Shape label styling applies only to stages",{shapeIds:c.map(d=>d.id)});if(r.labelStyle.size!==void 0&&r.labelStyle.size!==null&&(!Number.isFinite(r.labelStyle.size)||r.labelStyle.size<pe||r.labelStyle.size>72))throw new u("invalid_operation",`Stage label size must be from ${pe} to ${72}`);if(r.labelStyle.color!==void 0&&r.labelStyle.color!==null&&(r.labelStyle.color=N(r.labelStyle.color,"Shape label color")),r.labelStyle.fontFamily!==void 0&&r.labelStyle.fontFamily!==null&&(r.labelStyle.fontFamily=r.labelStyle.fontFamily.normalize("NFKC").trim(),!r.labelStyle.fontFamily||r.labelStyle.fontFamily.length>120))throw new u("invalid_operation","Stage label fontFamily must contain 1 to 120 characters");if(r.labelStyle.direction!==void 0&&r.labelStyle.direction!==null&&!zn.includes(r.labelStyle.direction))throw new u("invalid_operation","Stage label direction must be horizontal, vertical, or auto");for(let d of["bold","italic","underline"]){let g=r.labelStyle[d];if(g!=null&&typeof g!="boolean")throw new u("invalid_operation",`Stage label ${d} must be a boolean`)}}if(r.fill!==void 0&&r.fill!==null&&(r.fill=N(r.fill,"Shape fill")),r.kind!==void 0&&!["rect","ellipse","polygon","line","polyline"].includes(r.kind))throw new u("invalid_operation","Shape kind must be rect, ellipse, polygon, line, or polyline");if(r.stroke!==void 0&&r.stroke!==null){if(!Number.isFinite(r.stroke.width)||r.stroke.width<.5||r.stroke.width>40)throw new u("invalid_operation","Shape stroke width must be from 0.5 to 40 chart units");r.stroke={color:N(r.stroke.color,"Shape stroke"),width:r.stroke.width}}if(r.cornerRadius!==void 0&&r.cornerRadius!==null&&(!Number.isFinite(r.cornerRadius)||r.cornerRadius<0||r.cornerRadius>5e3))throw new u("invalid_operation","Shape cornerRadius must be from 0 to 5000 chart units");if(r.opacity!==void 0&&r.opacity!==null&&(!Number.isFinite(r.opacity)||r.opacity<.1||r.opacity>1))throw new u("invalid_operation","Shape opacity must be from 0.1 to 1");if(r.heightM!==void 0&&r.heightM!==null&&(!Number.isFinite(r.heightM)||r.heightM<.05||r.heightM>50))throw new u("invalid_operation","Shape heightM must be from 0.05 to 50 metres");if(r.eventConfigurationIds!==void 0&&r.eventConfigurationIds!==null){let c=r.eventConfigurationIds.map(d=>d.normalize("NFKC").trim());if(!c.length||c.length>20||c.some(d=>!d||d.length>100)||new Set(c).size!==c.length)throw new u("invalid_operation","Shape event configurations must contain 1 to 20 unique ids");r.eventConfigurationIds=c}if(r.lineCap!==void 0&&r.lineCap!==null&&!bo.includes(r.lineCap))throw new u("invalid_operation","Shape lineCap must be butt, round, or square");if(r.lineJoin!==void 0&&r.lineJoin!==null&&!ho.includes(r.lineJoin))throw new u("invalid_operation","Shape lineJoin must be miter, round, or bevel");for(let[c,d]of[["startEnding",r.startEnding],["endEnding",r.endEnding]])if(d!=null&&!po.includes(d))throw new u("invalid_operation",`Shape ${c} must be none or arrow`);if(r.lineCap!=null||r.lineJoin!=null||r.startEnding!=null||r.endEnding!=null){let c=i.filter(d=>!Vt(r.kind??d.kind));if(c.length)throw new u("invalid_operation","Line caps, joins, and start/end decorations apply only to open line or polyline shapes",{shapeIds:c.map(d=>d.id)})}let l=!1;for(let c of i){let d=JSON.stringify(c);if(r.label===null?delete c.label:r.label!==void 0&&(c.label=r.label),r.labelStyle!==void 0){let g={...c.labelStyle};r.labelStyle.size===null?delete g.size:r.labelStyle.size!==void 0&&(g.size=r.labelStyle.size),r.labelStyle.color===null?delete g.color:r.labelStyle.color!==void 0&&(g.color=r.labelStyle.color),r.labelStyle.fontFamily===null?delete g.fontFamily:r.labelStyle.fontFamily!==void 0&&(g.fontFamily=r.labelStyle.fontFamily),r.labelStyle.bold===null?delete g.bold:r.labelStyle.bold!==void 0&&(g.bold=r.labelStyle.bold),r.labelStyle.italic===null||r.labelStyle.italic===!1?delete g.italic:r.labelStyle.italic===!0&&(g.italic=!0),r.labelStyle.underline===null||r.labelStyle.underline===!1?delete g.underline:r.labelStyle.underline===!0&&(g.underline=!0),r.labelStyle.direction===null||r.labelStyle.direction==="horizontal"?delete g.direction:r.labelStyle.direction!==void 0&&(g.direction=r.labelStyle.direction),Object.keys(g).length?c.labelStyle=g:delete c.labelStyle}if(r.fill===null?delete c.fill:r.fill!==void 0&&(c.fill=r.fill),r.kind!==void 0&&(c.kind=r.kind,Vt(c.kind)||(delete c.lineCap,delete c.lineJoin,delete c.startEnding,delete c.endEnding)),r.stroke===null?delete c.stroke:r.stroke!==void 0&&(c.stroke={...r.stroke}),r.opacity===null?delete c.opacity:r.opacity!==void 0&&(c.opacity=r.opacity),r.heightM===null?delete c.heightM:r.heightM!==void 0&&(c.heightM=r.heightM),r.eventConfigurationIds===null?delete c.eventConfigurationIds:r.eventConfigurationIds!==void 0&&(c.eventConfigurationIds=[...r.eventConfigurationIds]),r.lineCap===null?delete c.lineCap:r.lineCap!==void 0&&(c.lineCap=r.lineCap),r.lineJoin===null?delete c.lineJoin:r.lineJoin!==void 0&&(c.lineJoin=r.lineJoin),r.startEnding===null?delete c.startEnding:r.startEnding!==void 0&&(c.startEnding=r.startEnding),r.endEnding===null?delete c.endEnding:r.endEnding!==void 0&&(c.endEnding=r.endEnding),r.cornerRadius===null)delete c.cornerRadius;else if(r.cornerRadius!==void 0){let g=Math.min(c.width??1/0,c.height??1/0),b=Number.isFinite(g)?g/2:r.cornerRadius;c.cornerRadius=c.kind==="rect"?Math.max(0,Math.min(r.cornerRadius,b)):r.cornerRadius}JSON.stringify(c)!==d&&(Xe(c),l=!0)}return{floorId:n.floorId,changed:l,shapeIds:o}}function rr(e){if(e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null){if(![e.x,e.y,e.width,e.height].every(Number.isFinite)||e.width<=0||e.height<=0)throw new u("invalid_operation",`Stage ${e.id} has an invalid stored base box`,{stageId:e.id});return{cx:e.x+e.width/2,cy:e.y+e.height/2,width:e.width,height:e.height}}let t=e.points??[];if(t.length<3||t.some(d=>!Number.isFinite(d.x)||!Number.isFinite(d.y)))throw new u("invalid_operation",`Stage ${e.id} has no valid geometry from which to derive its base box`,{stageId:e.id});let n=t.map(d=>d.x),o=t.map(d=>d.y),i=Math.min(...n),a=Math.max(...n),r=Math.min(...o),s=Math.max(...o),l=Math.max(1,a-i),c=Math.max(1,s-r);return{cx:i+l/2,cy:r+c/2,width:l,height:c}}function Bs(e,t){let n=O(e,t.floorId);if(!t.updates.length)throw new u("invalid_operation","At least one shape resize is required");let o=t.updates.map(r=>r.shapeId);if(new Set(o).size!==o.length)throw new u("invalid_operation","Shape ids must be unique");let i=t.updates.map(r=>{if(![r.width,r.height].every(Number.isFinite)||r.width<8||r.height<8||r.width>1e4||r.height>1e4)throw new u("invalid_operation","Shape width and height must be between 8 and 10000 chart units",{shapeId:r.shapeId});let s=n.objects.find(c=>c.type==="shape"&&c.id===r.shapeId);if(!s)throw new u("object_not_found",`Unknown shape id: ${r.shapeId}`,{shapeId:r.shapeId});let l=s.role==="stage"?rr(s):(s.kind==="rect"||s.kind==="ellipse")&&s.x!=null&&s.y!=null&&s.width!=null&&s.height!=null?{cx:s.x+s.width/2,cy:s.y+s.height/2,width:s.width,height:s.height}:(()=>{let c=s.points??[];if(c.length<3||c.some(x=>!Number.isFinite(x.x)||!Number.isFinite(x.y)))throw new u("invalid_operation",`Shape ${s.id} has no resizable geometry`,{shapeId:s.id});let d=c.map(x=>x.x),g=c.map(x=>x.y),b=Math.min(...d),f=Math.max(...d),y=Math.min(...g),m=Math.max(...g);return{cx:(b+f)/2,cy:(y+m)/2,width:Math.max(1,f-b),height:Math.max(1,m-y)}})();return{shape:s,update:r,box:l}}),a=!1;for(let{shape:r,update:s,box:l}of i)if(!(Math.abs(l.width-s.width)<1e-9&&Math.abs(l.height-s.height)<1e-9)){if(r.kind==="rect"||r.kind==="ellipse")r.x=l.cx-s.width/2,r.y=l.cy-s.height/2,r.width=s.width,r.height=s.height;else{let c=s.width/l.width,d=s.height/l.height;r.points=(r.points??[]).map(g=>({x:l.cx+(g.x-l.cx)*c,y:l.cy+(g.y-l.cy)*d})),(r.x!=null||r.y!=null||r.width!=null||r.height!=null||r.role==="stage")&&(r.x=l.cx-s.width/2,r.y=l.cy-s.height/2,r.width=s.width,r.height=s.height)}a=!0}return{floorId:n.floorId,changed:a,shapes:i.map(({shape:r,update:s})=>({id:r.id,width:s.width,height:s.height}))}}function zs(e,t){let n=O(e,t.floorId);if(!t.updates.length)throw new u("invalid_operation","At least one stage update is required");let o=t.updates.map(s=>s.stageId);if(new Set(o).size!==o.length)throw new u("invalid_operation","Stage ids must be unique");let i=new Set(On.map(s=>s.key)),a=t.updates.map(s=>{if(!i.has(s.stageKind))throw new u("invalid_operation",`Unknown stage kind: ${s.stageKind}`,{stageKind:s.stageKind});let l=n.objects.find(c=>c.type==="shape"&&c.id===s.stageId);if(!l)throw new u("object_not_found",`Unknown stage id: ${s.stageId}. Call get_chart to list current stage ids.`,{stageId:s.stageId});if(l.role!=="stage")throw new u("invalid_operation",`Shape ${s.stageId} is not tagged as a stage`,{stageId:s.stageId});return{shape:l,stageKind:s.stageKind,box:l.stageKind===s.stageKind?null:rr(l)}}),r=!1;for(let s of a)s.box&&(s.shape.points=Rn({kind:s.stageKind,...s.box}),s.shape.kind="polygon",s.shape.stageKind=s.stageKind,r=!0);return{floorId:n.floorId,changed:r,stages:a.map(s=>({id:s.shape.id,stageKind:s.stageKind}))}}function Hs(e){return[...dn(e)].map(([t,n])=>({key:t,...n}))}function Vs(e){if(!Array.isArray(e))return dn(e);let t=new Map;for(let{key:n,target:o,evidence:i}of e)t.set(n,{target:o,evidence:i});return t}function dn(e){let t=new Map;e.confidenceEvidence&&t.set("venue",{target:{scope:"venue"},evidence:e.confidenceEvidence});for(let n of k(e)){n.confidenceEvidence&&t.set(`floor:${n.id}`,{target:{scope:"floor",floorId:n.id},evidence:n.confidenceEvidence});for(let o of n.objects){let i=`floor:${n.id}:object:${o.id}`;if((o.type==="row"||o.type==="section")&&o.confidenceEvidence&&t.set(i,{target:{scope:o.type,floorId:n.id,objectId:o.id},evidence:o.confidenceEvidence}),o.type==="row"&&o.segmentedRow?.confidenceEvidence&&t.set(`${i}:segmented`,{target:{scope:"row",floorId:n.id,objectId:o.id},evidence:o.segmentedRow.confidenceEvidence}),o.type==="row"||o.type==="table")for(let a of o.overrides??[])a.confidenceEvidence&&t.set(`${i}:seat:${a.index}`,{target:{scope:"seat",floorId:n.id,objectId:o.id,seatIndex:a.index},evidence:a.confidenceEvidence})}}return t}function wt(e){return Array.isArray(e)?e.map(wt):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>[t,wt(n)]))}function qs(e,t){return JSON.stringify(wt(e))===JSON.stringify(wt(t))}function sn(e){return!!e&&e.status!=="draft"&&e.status!=="retracted"}function Js(e){return e?e.status==="retracted"?"retract":sn(e)?"approve":"set":"clear"}function ir(e,t){let n=Vs(e),o=dn(t),i=[...new Set([...n.keys(),...o.keys()])].sort(),a=[];for(let r of i){let s=n.get(r),l=o.get(r);if(s&&l&&qs(s.evidence,l.evidence))continue;let c=l?.target??s?.target;c&&a.push({...c,operation:Js(l?.evidence),...s?{before:s.evidence}:{},...l?{after:l.evidence}:{}})}return a}function Xs(e,t){return ir(e,t).some(n=>sn(n.before)||sn(n.after))}var Ys=new Set(["synthetic-model","organizer-approved","calibrated-provider"]),Qs=new Set(["generated","geometry-verified","configuration-verified"]),Zs=new Set(["none","comparable-build-reference","actual-build-checked"]),Ws=new Set(["clear","partial","obstructed"]);function cn(e){return e.toISOString().slice(0,10)}function ln(e,t){return typeof e=="string"&&e.normalize("NFKC").trim()===e&&e.length>0&&e.length<=t}function Ce(e,t,n){if(!ln(e,t))throw new u("invalid_operation",`Confidence evidence ${n} is invalid`,{field:n});return e}function ve(e,t,n){if(e!==void 0)return Ce(e,t,n)}function xt(e,t,n){let o=n?[O(e,n)]:k(e).map(i=>({floorId:i.id,objects:i.objects}));for(let i of o){let a=i.objects.find(r=>r.id===t);if(a)return{floorId:i.floorId,object:a}}throw new u("object_not_found",`Unknown chart object: ${t}`,{objectId:t,floorId:n})}function ar(e,t){let n=k(e),o=t?n.find(i=>i.id===t):n[0];if(!o)throw new u("floor_not_found",`Unknown chart floor: ${t}`,{floorId:t});return o}function ze(e,t){if(t.scope==="venue")return e.confidenceEvidence;if(t.scope==="floor")return ar(e,t.floorId).confidenceEvidence;if(t.scope==="seat"){if(!t.objectId||t.seatIndex===void 0)throw new u("invalid_operation","Seat evidence requires objectId and seatIndex");let o=xt(e,t.objectId,t.floorId);if(o.object.type!=="row"&&o.object.type!=="table")throw new u("invalid_operation","Seat evidence can be stored only on a row or table",{objectId:t.objectId});return o.object.overrides?.find(i=>i.index===t.seatIndex)?.confidenceEvidence}if(!t.objectId)throw new u("invalid_operation",`${t.scope} evidence requires objectId`);let n=xt(e,t.objectId,t.floorId);if(t.scope==="row"&&n.object.type!=="row")throw new u("invalid_operation","Row evidence requires a row id",{objectId:t.objectId});if(t.scope==="section"&&n.object.type!=="section")throw new u("invalid_operation","Section evidence requires a section id",{objectId:t.objectId});if(n.object.type==="row"||n.object.type==="section")return n.object.confidenceEvidence;throw new u("invalid_operation",`${t.scope} evidence is not supported on this object`,{objectId:t.objectId,type:n.object.type})}function St(e,t,n){if(t.scope==="venue")return n?e.confidenceEvidence=n:delete e.confidenceEvidence,{};if(t.scope==="floor"){let i=ar(e,t.floorId);return n?i.confidenceEvidence=n:delete i.confidenceEvidence,{floorId:i.id}}if(t.scope==="seat"){if(!t.objectId||t.seatIndex===void 0)throw new u("invalid_operation","Seat evidence requires objectId and seatIndex");let i=xt(e,t.objectId,t.floorId);return nn(e,{floorId:i.floorId,seats:[{rowId:t.objectId,index:t.seatIndex}],patch:{confidenceEvidence:n??null}}),{floorId:i.floorId,objectId:t.objectId}}if(!t.objectId)throw new u("invalid_operation",`${t.scope} evidence requires objectId`);let o=xt(e,t.objectId,t.floorId);if(o.object.type!=="row"&&o.object.type!=="section")throw new u("invalid_operation",`${t.scope} evidence is not supported on this object`,{objectId:t.objectId,type:o.object.type});return n?o.object.confidenceEvidence=n:delete o.object.confidenceEvidence,{floorId:o.floorId,objectId:o.object.id}}function ec(e){if(e===void 0)return;if(!e||typeof e!="object")throw new u("invalid_operation","Confidence evidence modeledTarget is invalid");if(!ln(e.label,80)||!ln(e.methodLabel,100))throw new u("invalid_operation","Confidence evidence modeledTarget labels are invalid");if(!Number.isInteger(e.totalRayCount)||e.totalRayCount<1||e.totalRayCount>1e3||!Number.isInteger(e.clearRayCount)||e.clearRayCount<0||e.clearRayCount>e.totalRayCount)throw new u("invalid_operation","Confidence evidence modeledTarget ray counts are invalid");if(!Ws.has(e.classification))throw new u("invalid_operation","Confidence evidence modeledTarget classification is invalid");let t=e.occluderLabels?.map(n=>Ce(n,80,"occluder label"));return{label:e.label,methodLabel:e.methodLabel,totalRayCount:e.totalRayCount,clearRayCount:e.clearRayCount,classification:e.classification,...t?.length?{occluderLabels:t}:{}}}function sr(e,t=new Date){if(e.schema!==void 0&&e.schema!=="seatlayer.seat-confidence/1")throw new u("invalid_operation","Confidence evidence schema must be seatlayer.seat-confidence/1");if(!Ys.has(e.evidenceKind))throw new u("invalid_operation","Confidence evidence kind is invalid");if(!Qs.has(e.modelLevel))throw new u("invalid_operation","Confidence evidence model level is invalid");let n=e.realityLevel??"none";if(!Zs.has(n))throw new u("invalid_operation","Confidence evidence reality level is invalid");if(e.evidenceKind==="synthetic-model"&&(e.modelLevel!=="generated"||n!=="none"))throw new u("invalid_operation","Synthetic evidence cannot claim verification or reality checks");let o=ve(e.eventConfigurationId,100,"eventConfigurationId");if(e.eventConfigurationVersion!==void 0&&(!Number.isInteger(e.eventConfigurationVersion)||e.eventConfigurationVersion<1))throw new u("invalid_operation","Confidence evidence eventConfigurationVersion is invalid");if(e.modelLevel==="configuration-verified"&&!o)throw new u("invalid_operation","Configuration-verified evidence requires eventConfigurationId");let i=e.limitations?.map(g=>Ce(g,160,"limitation"));if(i&&i.length>6)throw new u("invalid_operation","Confidence evidence accepts at most 6 limitations");let a=ve(e.assessedAt,40,"assessedAt")??cn(t),r=Date.parse(a);if(!Number.isFinite(r))throw new u("invalid_operation","Confidence evidence assessedAt is invalid");let s=ve(e.validUntil,40,"validUntil")??(e.modelLevel==="generated"?void 0:cn(new Date(r+365*24*60*60*1e3))),l=s?Date.parse(s):Number.NaN;if(s&&(!Number.isFinite(l)||l<r||l>r+366*24*60*60*1e3))throw new u("invalid_operation",`Confidence evidence validity must end within ${366} days of assessment`);let c=ve(e.approvedByRole,100,"approvedByRole");if(e.modelLevel!=="generated"&&!c)throw new u("invalid_operation","Verified model levels require approvedByRole");let d=ve(e.sourceLabel,120,"sourceLabel");if(n!=="none"&&!d)throw new u("invalid_operation","Real-world evidence requires a buyer-safe source describing what was checked");if(n==="actual-build-checked"&&(e.modelLevel!=="configuration-verified"||!o))throw new u("invalid_operation","An actual-build check requires a configuration-verified model and an event configuration");return{schema:"seatlayer.seat-confidence/1",evidenceId:Ce(e.evidenceId,120,"evidenceId"),modelVersion:Ce(e.modelVersion,120,"modelVersion"),evidenceKind:e.evidenceKind,modelLevel:e.modelLevel,realityLevel:n,status:"draft",assessedAt:a,...o?{eventConfigurationId:o}:{},...e.eventConfigurationVersion!==void 0?{eventConfigurationVersion:e.eventConfigurationVersion}:{},...s?{validUntil:s}:{},...c?{approvedByRole:c}:{},...d?{sourceLabel:e.sourceLabel}:{},...i?.length?{limitations:i}:{},...e.modeledTarget?{modeledTarget:ec(e.modeledTarget)}:{}}}function Oe(e,t={}){return{changed:t.changed??!0,scope:e.scope,...e.objectId?{objectId:e.objectId}:{},...e.floorId?{floorId:e.floorId}:{},...e.seatIndex!==void 0?{seatIndex:e.seatIndex}:{},...t}}function tc(e,t){let n=sr(t.evidence,t.now),o=JSON.stringify(ze(e,t)??null),i=St(e,t,n),a=JSON.stringify(ze(e,t)??null);return Oe(t,{changed:o!==a,...i,evidenceId:n.evidenceId,status:"draft"})}function nc(e,t){let n=ze(e,t);if(!n)return Oe(t,{changed:!1});let o=St(e,t,void 0);return Oe(t,{changed:!0,...o,evidenceId:n.evidenceId})}function oc(e,t){let n=ze(e,t);if(!n)throw new u("invalid_operation","There is no confidence evidence at this scope to approve",{scope:t.scope,objectId:t.objectId});if(n.status==="retracted")throw new u("invalid_operation","Retracted evidence cannot be approved; author a new draft first");let o=Ce(t.approvedByRole.normalize("NFKC").trim(),100,"approvedByRole"),i=ve(t.eventConfigurationId,100,"eventConfigurationId")??n.eventConfigurationId;if(n.modelLevel==="configuration-verified"&&!i)throw new u("invalid_operation","Configuration-verified evidence requires eventConfigurationId");let a=t.eventConfigurationVersion??n.eventConfigurationVersion;if(a!==void 0&&(!Number.isInteger(a)||a<1))throw new u("invalid_operation","Confidence evidence eventConfigurationVersion is invalid");let r={...n,status:"approved",approvedByRole:o,assessedAt:cn(t.now??new Date),...i?{eventConfigurationId:i}:{},...a!==void 0?{eventConfigurationVersion:a}:{}};delete r.basisSha256;let s=t.basisSha256??e.confidenceBasisSha256;s&&(r.basisSha256=s);let l=JSON.stringify(n),c=St(e,t,r);return Oe(t,{changed:l!==JSON.stringify(r),...c,evidenceId:r.evidenceId,status:"approved"})}function rc(e,t){let n=ze(e,t);if(!n)throw new u("invalid_operation","There is no confidence evidence at this scope to retract",{scope:t.scope,objectId:t.objectId});if(n.status==="retracted")return Oe(t,{changed:!1,evidenceId:n.evidenceId,status:"retracted"});let o={...n,status:"retracted"};delete o.basisSha256;let i=St(e,t,o);return Oe(t,{changed:!0,...i,evidenceId:n.evidenceId,status:"retracted"})}0&&(module.exports={COLORBLIND_SAFE_PALETTE,ChartOperationError,DEFAULT_FLOOR_HEIGHT_STEP_M,DEFAULT_SECTION_CORNER_SMOOTHING,MAX_BUYER_IMAGE_URL_LENGTH,MAX_FLOOR_BASE_HEIGHT_M,addArcFanRows,addBookableGridArray,addBoothArray,addChartCategory,addChartFloor,addChartZone,addGAArea,addRowBlock,addTableArray,applyPolygonHole,applyReferenceScanRows,applySectionCornerSmoothing,applySectionEstimates,applySectionOutlineShaping,applySectionRowFit,approveConfidenceEvidence,arcFanInputForGroup,assignSectionInventoryCategory,automaticPlacementCenter,clearConfidenceEvidence,compactChartDoc,compactRowOverrides,compactTableOverrides,confidenceEvidenceChangeRequiresPublish,confidenceEvidenceChanges,confidenceEvidenceIndex,confirmReferenceCategoryOutputColor,convertGeneratedSectionToPolygon,countCoveredInventory,detectSeatLabelRun,dropRedundantSeatOverrideFields,familyCategoryLabel,gaAreaFootprint,groupRowsAsSegmented,insertSeatingBlock,isSafeBuyerImageUrl,joinGAAreas,mergeRows,mirrorFirstFloor,normalizeBuyerImageUrl,normalizeDraftEvidence,parseSeatRefId,pickColorblindSafeCategoryColor,planCreationCategory,previewArcFanRows,previewBookableGridArray,previewGeneratedSectionPolygonConversion,previewJoinGAAreas,previewPolygonHole,previewRemovePolygonHole,previewRowCubicPath,previewSectionRowFit,reassignColorblindSafeCategoryColors,relabelChartRows,removeChartCategory,removeChartFloor,removeChartObjects,removeChartZone,removePolygonHole,renameChartFloor,renameDirectSeatImportCategory,reorderChartCategories,replaceArcFanRows,replaceRowBlock,resetSeatOverrides,resizeShapes,resolveCreationCategory,retractConfidenceEvidence,roundBuyerCoordinates,seatRefId,seatSemanticsSignature,sectionInventorySelectionSummary,setConfidenceEvidence,setRowBlockSpacing,splitRow,straightenAndSpaceRows,transformSectionBoundary,transformSectionBoundaryObject,ungroupSegmentedRow,updateBooths,updateCategoryDefinitions,updateChartFloorBaseHeight,updateChartTheme,updateChartZones,updateGAAreas,updateRowCubicPath,updateRows,updateSeatOverrides,updateSectionExactPath,updateSectionMetadata,updateSegmentedRow,updateShapes,updateStageKinds,updateTables,updateTextObjects,updateViewFromSeatFallback});
|
|
1
|
+
"use strict";var os=Object.create;var Ft=Object.defineProperty;var rs=Object.getOwnPropertyDescriptor;var is=Object.getOwnPropertyNames;var as=Object.getPrototypeOf,ss=Object.prototype.hasOwnProperty;var cs=(e,t)=>{for(var n in t)Ft(e,n,{get:t[n],enumerable:!0})},Vo=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of is(t))!ss.call(e,r)&&r!==n&&Ft(e,r,{get:()=>t[r],enumerable:!(o=rs(t,r))||o.enumerable});return e};var ls=(e,t,n)=>(n=e!=null?os(as(e)):{},Vo(t||!e||!e.__esModule?Ft(n,"default",{value:e,enumerable:!0}):n,e)),ds=e=>Vo(Ft({},"__esModule",{value:!0}),e);var Rf={};cs(Rf,{COLORBLIND_SAFE_PALETTE:()=>Se,ChartOperationError:()=>u,DECOR_UNITS_PER_METRE:()=>Ha,DEFAULT_FLOOR_HEIGHT_STEP_M:()=>Hn,DEFAULT_ROUTE_NAME:()=>ao,DEFAULT_SECTION_CORNER_SMOOTHING:()=>Tn,FIRST_CATEGORY_COLOURS:()=>ea,MAX_BUYER_IMAGE_URL_LENGTH:()=>Ys,MAX_FLOOR_BASE_HEIGHT_M:()=>Qt,NAMED_AREA_FILL:()=>Xa,ROUTE_STROKE:()=>io,ROW_CURVE_DEGREES:()=>Wa,addArcFanRows:()=>So,addArea:()=>sf,addBookableGridArray:()=>Zd,addBoothArray:()=>Po,addChartCategories:()=>gd,addChartCategory:()=>mn,addChartFloor:()=>Ic,addChartZone:()=>Pc,addCurvedRows:()=>Mf,addGAArea:()=>Co,addGate:()=>ll,addIcon:()=>af,addLandmark:()=>ef,addPlacedBoothArray:()=>Cf,addPlacedGAArea:()=>wf,addPlacedRowBlocks:()=>gf,addPlacedTableArray:()=>yf,addRoute:()=>gl,addRowBlock:()=>vo,addStage:()=>Qu,addTableArray:()=>Oo,addText:()=>rf,applyPolygonHole:()=>Nl,applyReferenceScanRows:()=>Yd,applySectionCornerSmoothing:()=>Hl,applySectionEstimates:()=>Vl,applySectionOutlineShaping:()=>Hi,applySectionRowFit:()=>jl,approveConfidenceEvidence:()=>$u,arcFanInputForGroup:()=>ra,assignSectionInventoryCategory:()=>$l,automaticPlacementCenter:()=>_e,blockSectionLabels:()=>bf,clearConfidenceEvidence:()=>Gu,compactChartDoc:()=>uc,compactRowOverrides:()=>Ar,compactTableOverrides:()=>Mr,confidenceEvidenceChangeRequiresPublish:()=>ku,confidenceEvidenceChanges:()=>$a,confidenceEvidenceIndex:()=>Mu,confirmReferenceCategoryOutputColor:()=>ed,convertGeneratedSectionToPolygon:()=>Bl,convertShapeToOutline:()=>vu,countCoveredInventory:()=>uo,curvedRowsPlacement:()=>es,decorPlacement:()=>nt,decorPlacementCenter:()=>Wu,detectSeatLabelRun:()=>Or,dropRedundantSeatOverrideFields:()=>Jt,familyCategoryLabel:()=>ta,gaAreaFootprint:()=>wn,gateShape:()=>ki,groupRowsAsSegmented:()=>Ao,insertSeatingBlock:()=>_l,isSafeBuyerImageUrl:()=>mr,joinGAAreas:()=>Iu,landmarkRoles:()=>cf,makeGate:()=>ul,mergeRows:()=>hu,mirrorFirstFloor:()=>Pe,normalizeBuyerImageUrl:()=>ye,normalizeDraftEvidence:()=>Ka,parseSeatRefId:()=>tu,pickColorblindSafeCategoryColor:()=>Qi,planCreationCategory:()=>na,previewArcFanRows:()=>xo,previewBookableGridArray:()=>Wd,previewGeneratedSectionPolygonConversion:()=>zi,previewJoinGAAreas:()=>Su,previewPolygonHole:()=>gn,previewRemovePolygonHole:()=>$i,previewRowCubicPath:()=>Fi,previewSectionRowFit:()=>Ni,reassignColorblindSafeCategoryColors:()=>Ql,relabelChartRows:()=>Rl,releaseGateReferences:()=>co,remapGateReferences:()=>hl,removeCategoryMovingInventory:()=>bd,removeChartCategory:()=>wo,removeChartFloor:()=>Oc,removeChartObjects:()=>Al,removeChartZone:()=>Mc,removePolygonHole:()=>Dl,renameChartFloor:()=>vc,renameDirectSeatImportCategory:()=>Yl,reorderChartCategories:()=>Jl,replaceArcFanRows:()=>vd,replaceRowBlock:()=>kd,resetSeatOverrides:()=>ru,resizeShapes:()=>Ou,resolveCreationCategory:()=>ud,retractConfidenceEvidence:()=>Bu,roundBuyerCoordinates:()=>hc,routeShape:()=>Ei,seatRefId:()=>At,seatSemanticsSignature:()=>Bn,sectionInventorySelectionSummary:()=>Ki,setConfidenceEvidence:()=>Du,setObjectEntrance:()=>fl,setRoute:()=>bl,setRowBlockSpacing:()=>bu,splitRow:()=>gu,straightenAndSpaceRows:()=>mu,transformSectionBoundary:()=>Kl,transformSectionBoundaryObject:()=>Ui,ungroupSegmentedRow:()=>_d,uniqueCategoryLabel:()=>oa,updateBooths:()=>Ol,updateCategoryDefinitions:()=>bn,updateChartFloorBaseHeight:()=>Cc,updateChartTheme:()=>yd,updateChartZones:()=>Ac,updateGAAreas:()=>Pl,updateGate:()=>dl,updateRowCubicPath:()=>kl,updateRows:()=>iu,updateSeatOverrides:()=>To,updateSectionExactPath:()=>zl,updateSectionMetadata:()=>fo,updateSegmentedRow:()=>Ld,updateShapes:()=>Cu,updateStageKinds:()=>Pu,updateTables:()=>Cl,updateTextObjects:()=>Ml,updateViewFromSeatFallback:()=>wd});module.exports=ds(Rf);var Xo=e=>Math.max(1,e.fontSize*.6+(e.letterSpacing??0));function us(e,t){let n=e.text.split(/\r?\n/);if(!e.width)return Math.max(1,n.length);let o=Math.max(1,Math.floor(t/Xo(e))),r=0;for(let a of n){if(!a.length){r+=1;continue}let i=0;for(let s of a.split(/\s+/)){let c=s.length;i&&i+1+c<=o?i+=1+c:(r+=Math.max(1,Math.ceil(c/o)),i=c%o)}}return Math.max(1,r)}function qo(e){let t=e.background?.padding??0,n=e.text.split(/\r?\n/),o=Math.max(1,...n.map(s=>s.length))*Xo(e),r=e.width??o+t*2,a=Math.max(1,r-t*2),i=us(e,a);return{width:r,height:i*e.fontSize*(e.lineHeight??1.2)+t*2,lineCount:i,padding:t}}var fs=Math.PI/180;function Z(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function hs(e,t,n){let o=Math.cos(n),r=Math.sin(n),a=e.x-t.x,i=e.y-t.y;return{x:t.x+a*o-i*r,y:t.y+a*r+i*o}}function Yo(e,t,n){return n?hs(e,t,n*fs):e}function kn(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function Jo(e,t){let n=1-t,o=n*n*n,r=3*n*n*t,a=3*n*t*t,i=t*t*t;return{x:o*e.start.x+r*e.control1.x+a*e.control2.x+i*e.end.x,y:o*e.start.y+r*e.control1.y+a*e.control2.y+i*e.end.y}}function Nt(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[Jo(e,.5)];let o=Array.from({length:n+1},(c,l)=>Jo(e,l/n)),r=new Float64Array(o.length);for(let c=1;c<o.length;c+=1){let l=o[c].x-o[c-1].x,d=o[c].y-o[c-1].y;r[c]=r[c-1]+Math.hypot(l,d)}let a=r[r.length-1];if(a<=1e-9)return Array.from({length:t},()=>({...e.start}));let i=[],s=1;for(let c=0;c<t;c+=1){let l=a*c/(t-1);for(;s<r.length-1&&r[s]<l;)s+=1;let d=r[s-1],f=r[s],g=f===d?0:(l-d)/(f-d);i.push({x:o[s-1].x+(o[s].x-o[s-1].x)*g,y:o[s-1].y+(o[s].y-o[s-1].y)*g})}return i}function ot(e){if(e.length<3)return 0;let t=0;for(let n=0,o=e.length-1;n<e.length;o=n++)t+=(e[o].x+e[n].x)*(e[o].y-e[n].y);return Math.abs(t)/2}function rt(e,t,n){return Math.max(t,Math.min(n,e))}function gs(e){return rt(e,0,1)}function Wo(e){let t=gs(e);return t*t*(3-2*t)}var Ee=Math.PI*2;function Te(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}function bs(e,t,n){let o=t-e;if(n){for(;o<0;)o+=Ee;for(;o>=Ee;)o-=Ee}else{for(;o>0;)o-=Ee;for(;o<=-Ee;)o+=Ee}return o}function Dt(e){if(e.version!==1||e.closed!==!0||!Te(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||!Te(n.end))return!1;if(n.kind==="line"){if(Z(t,n.end)<=1e-9)return!1}else if(n.kind==="bezier"){if(!Te(n.control1)||!Te(n.control2)||Z(t,n.end)<=1e-9)return!1}else if(n.kind==="arc"){if(!Te(n.center)||!Number.isFinite(n.radius)||n.radius<=1e-6||Math.abs(Z(t,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||Math.abs(Z(n.end,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||Z(t,n.end)<=1e-9)return!1}else return!1;t=n.end}return Z(t,e.start)<=1e-4}function ms(e,t,n){let o=1-n;return{x:o**3*e.x+3*o**2*n*t.control1.x+3*o*n**2*t.control2.x+n**3*t.end.x,y:o**3*e.y+3*o**2*n*t.control1.y+3*o*n**2*t.control2.y+n**3*t.end.y}}function it(e,t=2){if(!Dt(e))throw new Error("Section outline path is invalid");let n=Math.max(.25,t),o=[{...e.start}],r=e.start;for(let a of e.segments){if(a.kind==="line")o.push({...a.end});else if(a.kind==="arc"){let i=Math.atan2(r.y-a.center.y,r.x-a.center.x),s=Math.atan2(a.end.y-a.center.y,a.end.x-a.center.x),c=bs(i,s,a.clockwise),l=Math.max(2,Math.ceil(Math.abs(c)*a.radius/n));for(let d=1;d<=l;d+=1){let f=i+c*d/l;o.push({x:a.center.x+Math.cos(f)*a.radius,y:a.center.y+Math.sin(f)*a.radius})}}else{let i=Z(r,a.control1)+Z(a.control1,a.control2)+Z(a.control2,a.end),s=Math.max(2,Math.ceil(i/n));for(let c=1;c<=s;c+=1)o.push(ms(r,a,c/s))}r=a.end}return Z(o[o.length-1],o[0])<=1e-4&&o.pop(),o}function er(e,t,n){return at(e,r=>({x:r.x+t,y:r.y+n}))}function at(e,t,n=1,o=!1){return{...e,start:t(e.start),segments:e.segments.map(r=>r.kind==="line"?{...r,end:t(r.end)}:r.kind==="arc"?{...r,center:t(r.center),radius:r.radius*Math.abs(n),clockwise:o?!r.clockwise:r.clockwise,end:t(r.end)}:{...r,control1:t(r.control1),control2:t(r.control2),end:t(r.end)})}}function tr(e){return e.map(t=>t===0?0:-t)}var Tn=45,En=150,ps=60;function ys(e){let t=Tn/100;if(e<=t)return En;let n=Math.min(1,(e-t)/(1-t));return En-n*(En-ps)}var Zo=.5523;function Qo(e,t){return Math.abs(e.x-t.x)<=1e-6&&Math.abs(e.y-t.y)<=1e-6}function ws(e){let t=[],n=[];for(e.forEach((o,r)=>{Te(o)&&(t.length&&Qo(t[t.length-1],o)||(t.push({x:o.x,y:o.y}),n.push(r)))});t.length>1&&Qo(t[0],t[t.length-1]);)t.pop(),n.pop();return{points:t,sourceIndex:n}}var xs=.5,Ss=4/3;function Is(e,t,n){let o=t.x-e.x,r=t.y-e.y,a=Math.hypot(o,r);if(a<=1e-9)return{kind:"line",end:{...t}};let i=-r/a,s=o/a,c=n*Ss;return{kind:"bezier",control1:{x:e.x+o/3+i*c,y:e.y+r/3+s*c},control2:{x:e.x+o*2/3+i*c,y:e.y+r*2/3+s*c},end:{...t}}}function Gt(e,t){let{points:n,sourceIndex:o}=ws(e),r=n.length;if(r<3)return null;let a=Math.min(100,Math.max(0,t.cornerSmoothing??0))/100,i=t.edgeCurvature,s=new Array(r).fill(0);if(i?.length)for(let S=0;S<r;S+=1){let m=i[o[S]];s[S]=Number.isFinite(m)?Math.min(100,Math.max(-100,m))/100:0}let c=s.some(S=>Math.abs(S)>1e-6);if(a<=0&&!c)return null;let l=t.wideAngleThresholdDeg??ys(a),d=[];for(let S=0;S<r;S+=1)d[S]=Z(n[S],n[(S+1)%r]);let f=new Array(r).fill(0);for(let S=0;S<r;S+=1){let m=n[(S-1+r)%r],v=n[S],C=n[(S+1)%r],P={x:m.x-v.x,y:m.y-v.y},j={x:C.x-v.x,y:C.y-v.y},q=Math.hypot(P.x,P.y),Y=Math.hypot(j.x,j.y);if(q<=1e-9||Y<=1e-9)continue;let M=Math.min(1,Math.max(-1,(P.x*j.x+P.y*j.y)/(q*Y))),ne=Math.acos(M)*180/Math.PI;if(ne<l)continue;let R=Wo((ne-l)/(180-l));f[S]=a*R*.5*Math.min(q,Y)}for(let S=0;S<r;S+=1){let m=(S+1)%r,v=f[S]+f[m];if(v>d[S]&&v>1e-9){let C=d[S]/v;f[S]*=C,f[m]*=C}}let g=new Array(r),h=new Array(r);for(let S=0;S<r;S+=1){let m=n[(S-1+r)%r],v=n[S],C=n[(S+1)%r];if(f[S]<=1e-6){g[S]={...v},h[S]={...v};continue}let P=Z(v,m)||1,j=Z(v,C)||1;g[S]={x:v.x+(m.x-v.x)/P*f[S],y:v.y+(m.y-v.y)/P*f[S]},h[S]={x:v.x+(C.x-v.x)/j*f[S],y:v.y+(C.y-v.y)/j*f[S]}}if(f.every(S=>S<=1e-6)&&!c)return null;let b=[],p={...h[0]},x=p,I=(S,m)=>{if(Z(x,S)<=1e-9)return;let v=s[m];Math.abs(v)>1e-6?b.push(Is(x,S,v*xs*d[m])):b.push({kind:"line",end:{...S}}),x=S};for(let S=1;S<=r;S+=1){let m=S%r,v=n[m];I(g[m],(S-1)%r),f[m]>1e-6&&Z(g[m],h[m])>1e-9&&(b.push({kind:"bezier",control1:kn(g[m],v,Zo),control2:kn(h[m],v,Zo),end:{...h[m]}}),x=h[m])}if(!b.length)return null;let y=b[b.length-1];Z(y.end,p)>1e-9&&(y.kind==="line"?y.end={...p}:b.push({kind:"line",end:{...p}}));let w={version:1,closed:!0,start:p,segments:b};return Dt(w)?w:null}function vs(e,t){return Math.abs(e.x-t.x)<=1e-7&&Math.abs(e.y-t.y)<=1e-7}function st(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}function $t(e,t,n){let o=st(t,n,e);return Math.abs(o)>1e-7?!1:e.x>=Math.min(t.x,n.x)-1e-7&&e.x<=Math.max(t.x,n.x)+1e-7&&e.y>=Math.min(t.y,n.y)-1e-7&&e.y<=Math.max(t.y,n.y)+1e-7}function Cs(e,t,n,o){let r=st(e,t,n),a=st(e,t,o),i=st(n,o,e),s=st(n,o,t);return(r>1e-7&&a<-1e-7||r<-1e-7&&a>1e-7)&&(i>1e-7&&s<-1e-7||i<-1e-7&&s>1e-7)?!0:Math.abs(r)<=1e-7&&$t(n,e,t)||Math.abs(a)<=1e-7&&$t(o,e,t)||Math.abs(i)<=1e-7&&$t(e,n,o)||Math.abs(s)<=1e-7&&$t(t,n,o)}function Os(e){return e.reduce((t,n,o)=>{let r=e[(o+1)%e.length];return t+n.x*r.y-r.x*n.y},0)}function Ps(e){for(let t=0;t<e.length;t+=1){let n=(t+1)%e.length;for(let o=t+1;o<e.length;o+=1){let r=(o+1)%e.length;if(!(t===o||n===o||r===t)&&Cs(e[t],e[n],e[o],e[r]))return!0}}return!1}function nr(e){return e.length<3?{ok:!1,code:"too_few_vertices",message:"Add at least three vertices to create a polygon."}:e.length>256?{ok:!1,code:"too_many_vertices",message:"A polygon can contain at most 256 vertices."}:e.some(t=>!Number.isFinite(t.x)||!Number.isFinite(t.y)||Math.abs(t.x)>1e7||Math.abs(t.y)>1e7)?{ok:!1,code:"invalid_coordinate",message:"Every polygon vertex must use a finite coordinate inside the safe chart range."}:e.some((t,n)=>vs(t,e[(n+1)%e.length]))?{ok:!1,code:"duplicate_vertex",message:"Move or remove duplicate neighbouring vertices."}:Math.abs(Os(e))<2?{ok:!1,code:"degenerate_polygon",message:"The polygon needs a visible enclosed area."}:Ps(e)?{ok:!1,code:"self_intersection",message:"Polygon edges cannot cross or touch each other."}:{ok:!0}}var jn=64;function As(e){let t=e.points??[];if(e.kind!=="polygon"||t.length<3||!Array.isArray(e.edgeCurvature))return[];let n=t.map((o,r)=>{let a=e.edgeCurvature[r];return Number.isFinite(a)?Math.min(100,Math.max(-100,a)):0});return n.some(o=>Math.abs(o)>.5)?n:[]}function Ms(e){let t=As(e);return t.length?Gt(e.points,{edgeCurvature:t}):null}function ct(e,t=2){let n=Ms(e);return n?it(n,t):e.points??[]}function or(e){return e.kind==="polygon"?Q(e.holes):[]}function rr(e,t){let n=ct(e);return n.length<3||t.length<3||!t.flatMap((r,a)=>{let i=t[(a+1)%t.length];return[r,{x:(r.x+i.x)/2,y:(r.y+i.y)/2}]}).every(r=>Bt(r,n)||Fn(r,n))?!1:!t.some((r,a)=>{let i=t[(a+1)%t.length];return n.some((s,c)=>Rs(r,i,s,n[(c+1)%n.length]))})}function Rs(e,t,n,o){let r=(l,d,f)=>(d.x-l.x)*(f.y-l.y)-(d.y-l.y)*(f.x-l.x),a=r(e,t,n),i=r(e,t,o),s=r(n,o,e),c=r(n,o,t);return a*i<-1e-9&&s*c<-1e-9}var ir="ABCDEFGHIJKLMNOPQRSTUVWXYZ",_s="ABCDEFGHJKLMNPQRSTUVWXYZ",Ls="abcdefghijklmnopqrstuvwxyz";function ar(e,t){let n=t.length,o=e+1,r="";for(;o>0;){o-=1;let a=o%n;r=t[a]+r,o=Math.floor(o/n)}return r}function ks(e,t){let n=t.startAt-1,o=e+n;if(t.scheme==="numbers")return String(o+1);let r=t.skipAmbiguous?_s:ir;return ar(o,r)}function lt(e,t=!1){let n=t?Ls:ir;return ar(Math.max(0,Math.floor(e)-1),n)}var Es=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];function sr(e){if(!Number.isFinite(e)||e<=0)return String(e);let t=Math.floor(e),n="";for(let[o,r]of Es)for(;t>=o;)n+=r,t-=o;return n}function cr(e,t){let n=e.length;return e.map((o,r)=>{let a=t.reverse?n-1-r:r;return{...o,label:ks(a,t)}})}function Ts(e){let t=new Array(e);return Array.from({length:e},(n,o)=>o).sort((n,o)=>Math.abs(2*n-(e-1))-Math.abs(2*o-(e-1))||n-o).forEach((n,o)=>t[n]=o),t}function je(e,t){let n=e.seatLabelStart??1,o=e.seatNumbering?.direction??"ltr",r=e.seatNumbering?.step??1,a=e.seatNumbering?.scheme??"decimal",i=e.seatNumbering?.prefix??"",s=e.seatNumbering?.endAt,c=e.seatCount;if(a==="updown"||a==="updown-descending"){let h=Math.ceil(c/2),b=a==="updown"?t<h?n+2*t:n-1+2*(c-t):t<h?n+2*(h-1-t):n+1+2*(t-h);return`${i}${b}`}let l=a==="odd"||a==="even"?2:r,d=s!=null&&Number.isFinite(s)?s-(c-1)*l:n,f=o==="center"?Ts(c)[t]:o==="rtl"?c-1-t:t,g;switch(a){case"odd":{let h=d%2===1?d:d+1;g=String(h+f*2);break}case"even":{let h=d%2===0?d:d+1;g=String(h+f*2);break}case"roman":g=sr(d+f*r);break;case"letters-upper":g=lt(d+f*r,!1);break;case"letters-lower":g=lt(d+f*r,!0);break;default:g=String(d+f*r);break}return`${i}${g}`}function js(e){return{...e.canonical,seatCount:e.totalSeats,label:e.displayLabel,displayLabel:e.displayLabel}}function ge(e,t,n){return n?.label??`${e.seatLabelBase??e.label}-${je(e,t)}`}function dt(e,t,n,o){if(o?.displayLabel)return o.displayLabel;if(e.seatDisplayLabelMode==="number")return je(e,t);if(!n)return`${e.displayLabel||e.label}-${je(e,t)}`;let r=js(n),a=n.displayOffset+t;return`${n.displayLabel}-${je(r,a)}`}var lr=999,Fs=["clockwise","anticlockwise"],Ns=["table-number","number","letter"];function Kt(e,t){return`${e.label}-${t+1}`}function Ds(e,t,n){return e?.direction==="anticlockwise"?Math.max(0,t-1-n):n}function Gs(e,t){let n=e.chairNumbering,o=n?.start??1,r=Ds(n,Math.max(0,Math.round(e.seatCount)),t);return n?.format==="letter"?lt(Math.max(1,o)+r):String(o+r)}function zt(e,t){let n=Gs(e,t);return(e.chairNumbering?.format??"table-number")==="table-number"?`${e.displayLabel??e.label}-${n}`:n}function dr(e){if(e===void 0)return null;if(!e||typeof e!="object"||Array.isArray(e))return"chairNumbering must be an object";let t=e,n=Object.keys(t).filter(o=>!["start","direction","format"].includes(o));return n.length?`chairNumbering has unsupported field(s): ${n.join(", ")}`:t.start!==void 0&&(!Number.isInteger(t.start)||t.start<0||t.start>lr)?`chairNumbering.start must be a whole number from 0 to ${lr}`:t.direction!==void 0&&!Fs.includes(t.direction)?"chairNumbering.direction must be clockwise or anticlockwise":t.format!==void 0&&!Ns.includes(t.format)?"chairNumbering.format must be table-number, number or letter":null}function ur(e){let t={};return e.start!==void 0&&e.start!==1&&(t.start=e.start),e.direction==="anticlockwise"&&(t.direction="anticlockwise"),e.format&&e.format!=="table-number"&&(t.format=e.format),Object.keys(t).length?t:void 0}var Ut=.02291666666666667,Nn=1/Ut,$s=58,qf=$s*Ut;var fr=[{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."}];var Bs={"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}},Ks={"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"};function hr(e){let t=Bs[e];return t?{width:t.width*Nn,height:t.height*Nn}:{width:300,height:70}}var zs="#232c40",Us=Math.PI*2;function Hs(e,t,n,o,r,a){return{x:r+e*n-t*o,y:a+e*o+t*n}}function Dn(e){let{kind:t,cx:n,cy:o,width:r,height:a}=e,i=(e.rotation??0)*Math.PI/180,s=Math.cos(i),c=Math.sin(i),l=r/2,d=a/2,f=[],g=(h,b)=>{f.push({x:h,y:b})};switch(t){case"rect":{g(-l,-d),g(l,-d),g(l,d),g(-l,d);break}case"rounded":{let h=Math.min(r,a)*.18,b=5,p=(x,I,y)=>{for(let w=0;w<=b;w++){let S=y+w/b*(Math.PI/2);g(x+h*Math.cos(S),I+h*Math.sin(S))}};p(l-h,-d+h,-Math.PI/2),p(l-h,d-h,0),p(-l+h,d-h,Math.PI/2),p(-l+h,-d+h,Math.PI);break}case"arc":{let h=a*.45;g(-l,-d),g(l,-d);let b=24;for(let p=0;p<=b;p++){let x=p/b,I=l-x*r,y=d+h*(1-Math.pow(2*I/r,2));g(I,y)}break}case"thrust":{let h=r*.18,b=a*1.1;g(-l,-d),g(l,-d),g(l,d),g(h,d),g(h,d+b),g(-h,d+b),g(-h,d),g(-l,d);break}case"runway":{let h=r*.1,b=a*3;g(-l,-d),g(l,-d),g(l,d),g(h,d),g(h,d+b),g(-h,d+b),g(-h,d),g(-l,d);break}case"round":case"oval-cricket":{for(let b=0;b<40;b++){let p=b/40*Us;g(l*Math.cos(p),d*Math.sin(p))}break}case"pitch-football":case"pitch-rugby":case"court-basketball":case"court-tennis":case"ring-boxing":{g(-l,-d),g(l,-d),g(l,d),g(-l,d);break}case"diamond-baseball":{for(let h of qs(l,d))g(h.x,h.y);break}case"rink-hockey":{for(let h of Vs(l,d,l*(8.5/60),d*(8.5/30)))g(h.x,h.y);break}case"track-athletics":{for(let h of Xs(l,d))g(h.x,h.y);break}}return f.map(h=>Hs(h.x,h.y,s,c,n,o))}function gr(e,t="stage"){return{type:"shape",id:t,kind:"polygon",points:Dn(e),fill:e.fill??Ks[e.kind]??zs,label:e.label??"STAGE",role:"stage",stageKind:e.kind}}function Vs(e,t,n,o){let r=[],i=(s,c,l)=>{for(let d=0;d<=8;d++){let f=l+d/8*(Math.PI/2);r.push({x:s+n*Math.cos(f),y:c+o*Math.sin(f)})}};return i(e-n,-t+o,-Math.PI/2),i(e-n,t-o,0),i(-e+n,t-o,Math.PI/2),i(-e+n,-t+o,Math.PI),r}function Xs(e,t){let n=Math.max(0,e-t),o=[],r=20;for(let a=0;a<=r;a++){let i=-Math.PI/2+a/r*Math.PI;o.push({x:n+t*Math.cos(i),y:t*Math.sin(i)})}for(let a=0;a<=r;a++){let i=Math.PI/2+a/r*Math.PI;o.push({x:-n+t*Math.cos(i),y:t*Math.sin(i)})}return o}var ut=(()=>{let t={x:0,y:52},n=25,o={x:70,y:t.y-70},r=(o.x*o.x+o.y*o.y-4900)/(2*(o.y+70)),a=r+70,i=[],s=Math.atan2(o.y-r,o.x),c=Math.atan2(o.y-r,-o.x);for(let l=0;l<=24;l++){let d=s+(c-s)*l/24;i.push({x:a*Math.cos(d),y:r+a*Math.sin(d)})}return{half:70,home:t,backstop:n,fence:i}})();function qs(e,t){let n=e/ut.half,o=t/ut.half;return[{x:-ut.backstop*n,y:t},{x:ut.backstop*n,y:t},...ut.fence.map(r=>({x:r.x*n,y:r.y*o}))]}function br(e){switch(e){case"pitch-football":return"PITCH";case"rink-hockey":return"RINK";case"track-athletics":return"TRACK";case"oval-cricket":return"OVAL";case"pitch-rugby":return"PITCH";case"diamond-baseball":return"FIELD";case"court-basketball":case"court-tennis":return"COURT";case"ring-boxing":return"RING";default:return"STAGE"}}var Ys=2e6,Js=/^data:image\/(?:png|jpe?g|webp|gif|avif);base64,[a-z0-9+/]+={0,2}$/i,Ws=/[\s"'<>`\\]/;function mr(e){if(typeof e!="string"||!e||e.length>2e6||e!==e.trim())return!1;if(e.startsWith("data:"))return Js.test(e);if(Ws.test(e))return!1;try{let t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}}function ye(e){let t=e.trim();return mr(t)?t:null}function ft(e){return e?e.accessibility?.length?e.wheelchairSpaceType&&!e.accessibility.includes("wheelchair")?["wheelchair",...e.accessibility]:e.accessibility:e.wheelchairSpaceType?["wheelchair"]:e.accessible?["wheelchair"]:[]:[]}var Vt=Math.PI/180,Zs=9,we=16;function $n(e,t,n,o){let r=n*Vt,a=Math.cos(r),i=Math.sin(r);return{x:o.x+e*a-t*i,y:o.y+e*i+t*a}}function ae(e){let{seatCount:t,seatSpacing:n,curve:o,rotation:r,origin:a}=e,i=[];if(e.path)return Nt(e.path,t);if(t<=1)return t===1&&i.push({x:a.x,y:a.y}),i;if(o===0){for(let l=0;l<t;l++)i.push($n(l*n,0,r,a));return i}let s=o/(t-1)*Vt,c=n/(2*Math.sin(Math.abs(s)/2));for(let l=0;l<t;l++){let d=l*s,f=c*Math.sin(d),g=-c+c*Math.cos(d);i.push($n(f,g,r,a))}return i}function yr(e){let t=new Map;if(e.overrides)for(let n of e.overrides)t.set(n.index,n);return t}function Qs(e,t){let n=yr(e);return ae(e).map((o,r)=>{let a=n.get(r),i=ft(a),s=ge(e,r,a),c={...e.commercial,...a?.commercial};return{index:r,x:o.x+(a?.dx??0),y:o.y+(a?.dy??0),label:s,displayLabel:dt(e,r,t,a),categoryKey:a?.categoryKey??e.categoryKey,skipped:!!a?.skip,accessible:i.length>0,accessibility:i,wheelchairSpaceType:a?.wheelchairSpaceType,commercial:Object.values(c).some(l=>l!==void 0&&l!==!1&&l!=="")?c:void 0,glyph:a?.glyph,viewUrl:a?.viewFromSeatUrl??e.viewFromSeatUrl,viewMeta:a?.viewFromSeatUrl?a.viewFromSeatMeta:e.viewFromSeatMeta,labelStyle:a?.labelStyle??e.seatLabelStyle}})}function re(e){let t=[];for(let n of Qs(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 ec(e){if(e.seatCountsBySide)return{...e.seatCountsBySide};let t=e.sides&&e.sides.length?e.sides:["top","bottom"],n=["top","bottom","left","right"].filter(a=>t.includes(a)),o={top:0,bottom:0,left:0,right:0};if(!n.length)return o;let r=Math.max(0,Math.round(e.seatCount));for(let a=0;a<r;a++)o[n[a%n.length]]+=1;return o}function tc(e){let t=[],n=Math.max(0,Math.round(e.seatCount));if(n===0)return t;let o=new Map((e.overrides??[]).map(d=>[d.index,d])),r=(d,f,g,h)=>{let b=o.get(d),p=ft(b),x=b?.label??Kt(e,d);return{index:d,label:x,displayLabel:b?.displayLabel??zt(e,d),x:f+(b?.dx??0),y:g+(b?.dy??0),categoryKey:b?.categoryKey??e.categoryKey,skipped:!!b?.skip,accessible:p.length>0,accessibility:p,wheelchairSpaceType:b?.wheelchairSpaceType,commercial:b?.commercial,glyph:b?.glyph,viewUrl:b?.viewFromSeatUrl,viewMeta:b?.viewFromSeatUrl?b.viewFromSeatMeta:void 0,labelStyle:b?.labelStyle,...h?{side:h}:{}}};if(e.shape==="round"){let d=(e.radius??40)+we,f=e.rotation*Vt,g=Math.max(0,Math.min(360,e.seatArc??360));if(g>=360||n===1){for(let x=0;x<n;x++){let I=f+x/n*2*Math.PI;t.push(r(x,e.center.x+d*Math.cos(I),e.center.y+d*Math.sin(I)))}return t}let h=g*Vt,b=(2*Math.PI-h)/2,p=f+b;for(let x=0;x<n;x++){let I=p+x/(n-1)*h;t.push(r(x,e.center.x+d*Math.cos(I),e.center.y+d*Math.sin(I)))}return t}let a=e.width??80,i=e.height??50,s=ec(e),c=["top","bottom","left","right"],l=0;for(let d of c){let f=s[d];for(let g=0;g<f;g++){let h,b;d==="top"?(h=-a/2+(g+.5)*a/f,b=-i/2-we):d==="bottom"?(h=-a/2+(g+.5)*a/f,b=i/2+we):d==="left"?(h=-a/2-we,b=-i/2+(g+.5)*i/f):(h=a/2+we,b=-i/2+(g+.5)*i/f);let p=$n(h,b,e.rotation,e.center);t.push(r(l++,p.x,p.y,d))}}return t}function be(e){return tc(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 wr(e){return[{id:`${e.id}:0`,label:e.label,...e.displayLabel&&e.displayLabel!==e.label?{displayLabel:e.displayLabel}:{},x:e.center.x,y:e.center.y,rowId:e.id,categoryKey:e.categoryKey,kind:"booth",...e.commercial?.note?{commercial:{note:e.commercial.note}}:{}}]}function Bt(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let a=t[o].x,i=t[o].y,s=t[r].x,c=t[r].y;i>e.y!=c>e.y&&e.x<(s-a)*(e.y-i)/(c-i)+a&&(n=!n)}return n}function Fn(e,t){return t.some((n,o)=>{let r=t[(o+1)%t.length],a=(e.y-n.y)*(r.x-n.x)-(e.x-n.x)*(r.y-n.y);if(Math.abs(a)>1e-7)return!1;let i=(e.x-n.x)*(r.x-n.x)+(e.y-n.y)*(r.y-n.y),s=(r.x-n.x)**2+(r.y-n.y)**2;return i>=-1e-7&&i<=s+1e-7})}function Q(e){return Array.isArray(e)?e.filter(t=>Array.isArray(t)&&t.length>=3):[]}function J(e,t,n){return Bt(e,t)&&!Q(n).some(o=>Bt(e,o)||Fn(e,o))}function Gn(e){if(!e.length)return{x:0,y:0};let t=0,n=0;for(let o of e)t+=o.x,n+=o.y;return{x:t/e.length,y:n/e.length}}function H(e){switch(e.type){case"row":{let t=ae(e),n=yr(e),o=0,r=0,a=0;for(let i=0;i<t.length;i++){let s=n.get(i);s?.skip||(o+=t[i].x+(s?.dx??0),r+=t[i].y+(s?.dy??0),a++)}return a?{x:o/a,y:r/a}:{x:e.origin.x,y:e.origin.y}}case"table":case"booth":return{x:e.center.x,y:e.center.y};case"gaArea":return Gn(e.points);case"section":return Gn(e.outline);case"text":return{x:e.position.x,y:e.position.y};case"shape":return e.points&&e.points.length?Gn(e.points):e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null?{x:e.x+e.width/2,y:e.y+e.height/2}:{x:e.x??0,y:e.y??0};case"decorImage":return{x:e.x+e.width/2,y:e.y+e.height/2}}}function pr(e,t){return e.length===t.length&&e.every((n,o)=>n.x===t[o].x&&n.y===t[o].y)}function nc(e,t){if(e.type!=="gaArea"||!pr(e.points,t.outline))return!1;let n=Q(e.holes),o=Q(t.holes);return n.length===o.length&&n.every((r,a)=>pr(r,o[a]))}function Xt(e,t,n=e.filter(r=>r.type==="section"),o=H(t)){let r="referenceInventorySource"in t?t.referenceInventorySource?.logicalSectionId:void 0;return(r?n.find(i=>(i.logicalSectionId??i.id)===r&&(nc(t,i)||J(o,i.outline,i.holes))):void 0)??n.find(i=>J(o,i.outline,i.holes))}function T(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 ee(e){return e.floors&&e.floors.length?e.floors.flatMap(t=>t.objects):e.objects}var Ht=40;function ue(e,t){let n=t?.freeText==="exclude",o=1/0,r=1/0,a=-1/0,i=-1/0,s=(l,d)=>{l<o&&(o=l),d<r&&(r=d),l>a&&(a=l),d>i&&(i=d)},c=l=>{if(Array.isArray(l))for(let d of l)!d||typeof d!="object"||s(d.x,d.y)};for(let l of ee(e))if(l.type==="row"){let d=new Map((l.overrides??[]).map(f=>[f.index,f]));ae(l).forEach((f,g)=>{let h=d.get(g);h?.skip||s(f.x+(h?.dx??0),f.y+(h?.dy??0))})}else if(l.type==="gaArea")c(l.points);else if(l.type==="section")c(l.outline);else if(l.type==="decorImage")s(l.x,l.y),s(l.x+l.width,l.y+l.height);else if(l.type==="shape")l.points&&l.points.length?c(ct(l)):l.x!=null&&l.y!=null&&l.width!=null&&l.height!=null&&(s(l.x,l.y),s(l.x+l.width,l.y+l.height));else if(l.type==="table"){let d=we+Zs,f=l.shape==="round"?(l.radius??40)+d:Math.max((l.width??80)/2,(l.height??50)/2)+d;s(l.center.x-f,l.center.y-f),s(l.center.x+f,l.center.y+f)}else if(l.type==="booth"){let d=Math.max(l.width,l.height)/2;s(l.center.x-d,l.center.y-d),s(l.center.x+d,l.center.y+d)}else if(l.type==="text"){if(n)continue;let d=qo(l);s(l.position.x,l.position.y),s(l.position.x+d.width,l.position.y+d.height)}for(let l of[e.referenceImage,e.backgroundImage]){if(!l)continue;let{center:d,width:f}=l;if(!d||!Number.isFinite(d.x)||!Number.isFinite(d.y)||!Number.isFinite(f))continue;let g=f*3/4;s(d.x-f/2,d.y-g/2),s(d.x+f/2,d.y+g/2)}if(!isFinite(o)){let l=e.focalPoint??{x:0,y:0};return{x:l.x-200,y:l.y-200,width:400,height:400}}return{x:o-Ht,y:r-Ht,width:a-o+Ht*2,height:i-r+Ht*2}}function ht(e){return(e.type==="shape"||e.type==="text")&&(e.referenceAnnotationSource?.kind==="direct-landmark-v1"||e.referenceAnnotationSource?.kind==="direct-stage-v1")&&(e.referenceAnnotationSource.ownership="organizer"),e}function xr(e){return e.type!=="shape"&&e.type!=="text"||e.labelImportance==="detail"?!1:e.labelImportance==="orientation"||e.referenceAnnotationSource?.kind==="direct-landmark-v1"}var oc=["skip","dx","dy","glyph","accessible","accessibility","wheelchairSpaceType","commercial","viewFromSeatUrl","viewFromSeatMeta","confidenceEvidence"];function Cr(e,t){return!e||!t?!e&&!t:e.size===t.size&&e.color===t.color}function bt(e){let t=new Map;for(let n of e.overrides??[])t.set(n.index,n);return t}function Bn(e){let t=bt(e),n=[];for(let o=0;o<e.seatCount;o+=1){let r=t.get(o),a={};for(let i of oc){let s=r?.[i];s!==void 0&&(a[i]=s)}n.push([ge(e,o,r),dt(e,o,void 0,r),r?.categoryKey??e.categoryKey,r?.labelStyle??e.seatLabelStyle??null,a])}return JSON.stringify(n)}function rc(e){return JSON.parse(JSON.stringify(e))}function qt(e,t){let n=rc(e);return t(n)&&Bn(n)===Bn(e)?n:e}function ic(e){if(e.seatLabelStyle||e.seatCount<1)return!1;let t=bt(e);if(t.size<e.seatCount)return!1;let n;for(let o=0;o<e.seatCount;o+=1){let r=t.get(o)?.labelStyle;if(!r)return!1;if(!n)n=r;else if(!Cr(n,r))return!1}if(!n)return!1;e.seatLabelStyle={...n};for(let o of e.overrides??[])delete o.labelStyle;return!0}function ac(e){if(!/^-?\d+$/.test(e))return;let t=Number(e);return Number.isSafeInteger(t)&&String(t)===e?t:void 0}function Or(e){if(!e.length)return;let t=e[0].lastIndexOf("-");if(t<=0)return;let n=e[0].slice(0,t),o=[];for(let a of e){if(!a.startsWith(`${n}-`))return;let i=ac(a.slice(n.length+1));if(i===void 0)return;o.push(i)}if(o.length===1)return{base:n,start:o[0],direction:"ltr"};let r=o[1]-o[0];if(!(r!==1&&r!==-1)){for(let a=1;a<o.length;a+=1)if(o[a]-o[a-1]!==r)return;return r===1?{base:n,start:o[0],direction:"ltr"}:{base:n,start:o[o.length-1],direction:"rtl"}}}function sc(e){if(e.seatCount<1)return!1;let t=bt(e);if(!(e.overrides??[]).some(r=>r.label!==void 0))return!1;let n=[];for(let r=0;r<e.seatCount;r+=1)n.push(ge(e,r,t.get(r)));let o=Or(n);if(!o)return!1;o.base===e.label?delete e.seatLabelBase:e.seatLabelBase=o.base,o.start===1?delete e.seatLabelStart:e.seatLabelStart=o.start,o.direction==="ltr"?delete e.seatNumbering:e.seatNumbering={direction:"rtl"};for(let r of e.overrides??[])delete r.label;return!0}function cc(e){if(e.seatDisplayLabelMode||e.seatCount<1)return!1;let t=bt(e);for(let n=0;n<e.seatCount;n+=1){let o=t.get(n)?.displayLabel;if(o===void 0||o!==je(e,n))return!1}e.seatDisplayLabelMode="number";for(let n of e.overrides??[])delete n.displayLabel;return!0}function Jt(e,t){t.categoryKey===e.categoryKey&&delete t.categoryKey,t.labelStyle&&Cr(t.labelStyle,e.seatLabelStyle)&&delete t.labelStyle,t.label!==void 0&&t.label===ge(e,t.index)&&delete t.label,(!e.segmentedRow||e.seatDisplayLabelMode==="number")&&t.displayLabel!==void 0&&t.displayLabel===dt(e,t.index)&&delete t.displayLabel}function Pr(e){return Object.keys(e).every(t=>t==="index")}function lc(e){if(!e.overrides?.length)return!1;for(let n of e.overrides)Jt(e,n);let t=e.overrides.filter(n=>!Pr(n));return t.length?e.overrides=t:delete e.overrides,!0}function dc(e,t){if(!t.segmentedRow||JSON.stringify([e.seatNumbering,e.seatLabelStart])===JSON.stringify([t.seatNumbering,t.seatLabelStart])||t.seatDisplayLabelMode==="number")return!0;let o=bt(t);for(let r=0;r<t.seatCount;r+=1)if(o.get(r)?.displayLabel===void 0)return!1;return!0}function Ar(e){if(e.type!=="row")return e;let t=qt(e,ic);return t=qt(t,sc),t=qt(t,cc),t=qt(t,lc),dc(e,t)?t:e}function Mr(e){if(!e.overrides?.length)return e;let t=[];for(let o of e.overrides){let r={...o};r.label===Kt(e,r.index)&&delete r.label,r.displayLabel===zt(e,r.index)&&delete r.displayLabel,r.categoryKey===e.categoryKey&&delete r.categoryKey,r.dx===0&&delete r.dx,r.dy===0&&delete r.dy,Pr(r)||t.push(r)}let n={...e};return t.length?n.overrides=t:delete n.overrides,n}function Sr(e){return e.type==="row"?Ar(e):e.type==="table"?Mr(e):e}function uc(e){let t=e.objects.map(Sr),n=e.floors?.map(o=>({...o,objects:o.objects.map(Sr)}));return{...e,objects:t,...n?{floors:n}:{}}}var Ir=2,fc=3,vr=6;function gt(e,t){if(!Number.isFinite(e))return e;let n=10**t,o=Math.round(e*n)/n;return Object.is(o,-0)?0:o}function Yt(e){return{...e,x:gt(e.x,Ir),y:gt(e.y,Ir)}}function hc(e){let t={...e};t.origin&&typeof t.origin=="object"&&(t.origin=Yt(t.origin)),Array.isArray(t.outline)&&(t.outline=t.outline.map(Yt)),Array.isArray(t.points)&&(t.points=t.points.map(Yt)),typeof t.rotation=="number"&&(t.rotation=gt(t.rotation,vr)),typeof t.seatSpacing=="number"&&(t.seatSpacing=gt(t.seatSpacing,vr));let n=t.labelPresentation;return n?.position&&(t.labelPresentation={...n,position:Yt(n.position)}),Array.isArray(t.overrides)&&(t.overrides=t.overrides.map(o=>{let r={...o};for(let a of["dx","dy"]){let i=r[a];if(typeof i!="number")continue;let s=gt(i,fc);s===0?delete r[a]:r[a]=s}return r})),t}function Rr(e){let t=e.backgroundImage;return t?.url&&!t.assetId?t:void 0}var gc=36,bc=160;function _r(e,t=360){let n=rt(Math.round(Number.isFinite(e)?e:1),1,40),o=rt(Number.isFinite(t)?t:360,120,360);return Math.round(rt(n*4*(360/o),gc,bc))}var Lr=["horizontal","vertical","auto"];var mt=[{key:"wheelchair",label:"Wheelchair space",short:"Wheelchair",icon:"\u267F"},{key:"companion",label:"Companion seat",short:"Companion",icon:"\u{1F9D1}\u200D\u{1F91D}\u200D\u{1F9D1}"},{key:"semi-ambulatory",label:"Semi-ambulatory (limited mobility)",short:"Limited mobility",icon:"\u{1F9AF}"},{key:"designated-aisle",label:"Designated aisle / transfer seat",short:"Aisle transfer",icon:"AS"},{key:"step-free",label:"Step-free accessible seat",short:"Step-free",icon:"SF"},{key:"hearing",label:"Assistive listening",short:"Hearing",icon:"\u{1F9BB}"},{key:"cart",label:"CART live-caption view",short:"CART captions",icon:"CC"},{key:"sign-language",label:"Sign-language view",short:"Sign language",icon:"\u{1F91F}"},{key:"low-vision",label:"Blind / low-vision viewing",short:"Low vision",icon:"LV"},{key:"sensory-friendly",label:"Quiet / sensory-friendly seating",short:"Sensory-friendly",icon:"QS"},{key:"plus-size",label:"Plus-size seat",short:"Plus-size",icon:"\u{1F4BA}"},{key:"lift-armrest",label:"Lift-up armrest",short:"Lift armrest",icon:"\u2195\uFE0F"}],bh=new Map(mt.map(e=>[e.key,e]));var mc=[{key:"obstructedView",label:"Obstructed view",short:"Obstructed",icon:"\u26D4"},{key:"restrictedView",label:"Restricted view",short:"Restricted",icon:"\u{1F441}"},{key:"premium",label:"Premium seat",short:"Premium",icon:"\u2605"}],mh=new Map(mc.map(e=>[e.key,e]));var Fe=8,Kn=24,kr=["start","end","both","none"],Er=["inline","corner","peninsula","island"],pc=["reference-focal","bar","entrance","exit","restroom","screen","sound","concession","coat","wall","rail","suite","obstruction"],ph=new Set(pc);var u=class extends Error{constructor(n,o,r={}){super(o);this.code=n;this.details=r;this.name="ChartOperationError"}};function O(e,t){let n=T(e),o=t?n.find(r=>r.id===t):n[0];if(!o)throw new u("floor_not_found",`Unknown chart floor: ${t}`,{floorId:t});return{floorId:o.id,objects:o.objects}}function D(e,t){if(!e.categories.some(n=>n.key===t))throw new u("category_not_found",`Unknown chart category: ${t}. Call get_chart to list valid category keys.`,{categoryKey:t})}function E(e,t,n,o){let r=new Set([...o,...e.categories.map(a=>a.key),...e.zones?.map(a=>a.id)??[],...e.floors?.map(a=>a.id)??[],...e.floors?.length?e.floors.flatMap(a=>a.objects.map(i=>i.id)):e.objects.map(a=>a.id)]);for(let a=0;a<100;a++){let i=n(t);if(i&&!r.has(i))return o.add(i),i}throw new u("id_generation_failed",`Unable to allocate a unique ${t} id`)}function yc(e){let t=e.slice().sort((a,i)=>a.x-i.x||a.y-i.y);if(t.length<3)return t;let n=(a,i,s)=>(i.x-a.x)*(s.y-a.y)-(i.y-a.y)*(s.x-a.x),o=[];for(let a of t){for(;o.length>=2&&n(o[o.length-2],o[o.length-1],a)<=0;)o.pop();o.push(a)}let r=[];for(let a=t.length-1;a>=0;a--){let i=t[a];for(;r.length>=2&&n(r[r.length-2],r[r.length-1],i)<=0;)r.pop();r.push(i)}return o.pop(),r.pop(),o.concat(r)}function wc(e,t){if(!e.length)return e;let n={x:e.reduce((o,r)=>o+r.x,0)/e.length,y:e.reduce((o,r)=>o+r.y,0)/e.length};return e.map(o=>{let r=o.x-n.x,a=o.y-n.y,i=Math.hypot(r,a)||1;return{x:o.x+r/i*t,y:o.y+a/i*t}})}function Ce(e){let t=[];for(let o of e)o.type==="row"?t.push(...re(o).map(r=>({x:r.x,y:r.y}))):o.type==="table"?t.push(...be(o).map(r=>({x:r.x,y:r.y}))):o.type==="gaArea"?t.push(...o.points):o.type==="booth"&&t.push(o.center);if(t.length<3)return null;let n=wc(yc(t),22);return n.length>=3?n:null}function me(e,t){let n=O(e,t),o=T(e).find(r=>r.id===n.floorId);return{...e,objects:n.objects,floors:void 0,focalPoint:o.focalPoint,referenceImage:o.referenceImage,backgroundImage:o.backgroundImage}}var Tr=24,jr=80;function zn(e,t){let n=e.normalize("NFKC").trim();if(n.length>Tr)throw new u("invalid_operation",`${t} displayed type must be at most ${Tr} characters`);return n}function Wt(e,t){if(e.displayType===void 0)return!1;let n=zn(e.displayType,t);return n?(e.displayType=n,!1):(delete e.displayType,!0)}function Ne(e,t){if(e.displayLabel===void 0)return!1;let n=e.displayLabel.normalize("NFKC").trim();if(n.length>jr)throw new u("invalid_operation",`${t} displayed label must be at most ${jr} characters`);return n?(e.displayLabel=n,!1):(delete e.displayLabel,!0)}function N(e,t){let n=e.trim().toLowerCase();if(!/^#[0-9a-f]{6}$/.test(n))throw new u("invalid_operation",`${t} must use a six-digit hex color`);return n}function Fr(e,t){if(!Number.isFinite(e)||e<Fe||e>Kn)throw new u("invalid_operation",`${t} label size must be from ${Fe} to ${Kn}`)}function xe(e,t){e.size!==void 0&&e.size!==null&&Fr(e.size,t),e.color!==void 0&&e.color!==null&&N(e.color,`${t} label color`)}function Zt(e,t){if(e?.positionPreset!==void 0&&!["start","end","both","none"].includes(e.positionPreset))throw new u("invalid_operation",`${t} label positionPreset must be one of start, end, both, none`);let n=e?.labelStyle;n&&(n.size!==void 0&&Fr(n.size,t),n.color!==void 0&&N(n.color,`${t} label color`))}function De(e,t){let n=e?structuredClone(e):{},o=n.labelStyle?{...n.labelStyle}:{};return t.size===null?delete o.size:t.size!==void 0&&(o.size=t.size),t.color===null?delete o.color:t.color!==void 0&&(o.color=N(t.color,"Label color")),o.size===void 0&&o.color===void 0?delete n.labelStyle:n.labelStyle=o,t.visible!==void 0&&(n.visible=t.visible),Object.keys(n).length?n:void 0}function Un(e,t,n){let o=t.normalize("NFKC").trim();if(!o||o.length>80)throw new u("invalid_operation","Zone labels must contain 1 to 80 characters");if((e.zones??[]).some(r=>r.id!==n&&r.label.normalize("NFKC").trim().toLocaleLowerCase("en")===o.toLocaleLowerCase("en")))throw new u("invalid_operation",`Zone label already exists: ${o}`);return o}function pt(e,t){if(!Number.isFinite(e?.x)||!Number.isFinite(e?.y))throw new u("invalid_operation",`${t} must contain finite x and y values`);return{x:e.x,y:e.y}}function ce(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}var pe=Math.PI/180,fe=Math.PI/180;function Oe(e){return e.type==="row"||e.type==="table"?e.seatCount:e.type==="gaArea"?Math.max(0,Math.floor(e.capacity)):e.type==="booth"?1:0}function Pe(e){if(e.floors?.length){let t=e.floors[0];e.objects=t.objects,e.focalPoint=t.focalPoint,e.referenceImage=t.referenceImage,e.backgroundImage=t.backgroundImage}return e}var xc=0,Qt=120,Hn=4;function Sc(e){if(!Number.isFinite(e)||e<xc||e>Qt)throw new u("invalid_operation","Floor base height must be a number from 0 to 120 metres")}function Ic(e,t){let n=T(e);if(n.length>=5)throw new u("invalid_operation","A chart can contain at most five physical floors");let o=(t.name??String(n.length+1)).normalize("NFKC").trim();if(!o||o.length>80)throw new u("invalid_operation","Floor names must contain 1 to 80 characters");if(n.some(c=>c.name.toLocaleLowerCase("en")===o.toLocaleLowerCase("en")))throw new u("invalid_operation",`Floor name already exists: ${o}`);e.floors?.length||(e.floors=[{id:"floor-0",name:"1",objects:e.objects,baseHeightM:0,focalPoint:e.focalPoint,referenceImage:e.referenceImage,backgroundImage:e.backgroundImage}]);let a=e.floors[e.floors.length-1].baseHeightM??Math.min(Qt,(e.floors.length-1)*Hn),i=Math.min(Qt,a+Hn),s=E(e,"floor",t.idFactory,new Set);return e.floors.push({id:s,name:o,baseHeightM:i,objects:[],focalPoint:{...e.focalPoint}}),Pe(e),{changed:!0,floorId:s,floorCount:e.floors.length,baseHeightM:i}}function vc(e,t){let n=T(e),o=n.find(i=>i.id===t.floorId);if(!o)throw new u("floor_not_found",`Unknown chart floor: ${t.floorId}`,{floorId:t.floorId});let r=t.name.normalize("NFKC").trim();if(!r||r.length>80)throw new u("invalid_operation","Floor names must contain 1 to 80 characters");if(n.some(i=>i.id!==o.id&&i.name.toLocaleLowerCase("en")===r.toLocaleLowerCase("en")))throw new u("invalid_operation",`Floor name already exists: ${r}`);let a=o.name!==r;return a&&(o.name=r),{changed:a,floorId:o.id,floorName:r}}function Cc(e,t){if(!e.floors?.length)throw new u("invalid_operation","A single-floor chart has an implicit base height of 0 metres");let n=e.floors.find(r=>r.id===t.floorId);if(!n)throw new u("floor_not_found",`Unknown chart floor: ${t.floorId}`,{floorId:t.floorId});Sc(t.baseHeightM);let o=n.baseHeightM!==t.baseHeightM;return o&&(n.baseHeightM=t.baseHeightM,n.physical3dProvenance={...n.physical3dProvenance,baseHeightM:{status:"confirmed",source:"user-review",note:"Physical floor height reviewed through the shared Designer/Copilot operation."}}),{changed:o,floorId:n.id,baseHeightM:t.baseHeightM}}function Oc(e,t){if(!e.floors?.length)throw new u("invalid_operation","A single-floor chart cannot remove its only floor");let n=e.floors.findIndex(r=>r.id===t.floorId);if(n<0)throw new u("floor_not_found",`Unknown chart floor: ${t.floorId}`,{floorId:t.floorId});let[o]=e.floors.splice(n,1);if(e.floors.length===1){let[r]=e.floors;e.objects=r.objects,e.focalPoint=r.focalPoint,e.referenceImage=r.referenceImage,e.backgroundImage=r.backgroundImage,e.floors=void 0}else Pe(e);return{changed:!0,floorId:o.id,removedObjects:o.objects.length,floorCount:T(e).length}}function Pc(e,t){if((e.zones?.length??0)>=100)throw new u("invalid_operation","A chart supports at most 100 zones");let n={id:E(e,"zone",t.idFactory,new Set),label:Un(e,t.label),color:N(t.color,"Zone color"),...t.focalPoint?{focalPoint:pt(t.focalPoint,"Zone focal point")}:{}};return(e.zones??=[]).push(n),{changed:!0,zone:structuredClone(n)}}function Ac(e,t){if(!t.updates.length)throw new u("invalid_operation","At least one zone update is required");let n=t.updates.map(c=>c.zoneId);if(new Set(n).size!==n.length)throw new u("invalid_operation","Zone ids must be unique");let o=new Map((e.zones??[]).map(c=>[c.id,c])),r=n.filter(c=>!o.has(c));if(r.length)throw new u("object_not_found",`Unknown zone id(s): ${r.join(", ")}. Call get_chart to list current zone ids.`,{zoneIds:r});let a=structuredClone(e),i=new Map((a.zones??[]).map(c=>[c.id,c]));for(let c of t.updates){if(!Object.keys(c.patch).length)throw new u("invalid_operation",`Zone ${c.zoneId} has no changes`);let d=i.get(c.zoneId);c.patch.label!==void 0&&(d.label=Un(a,c.patch.label,d.id)),c.patch.color!==void 0&&(d.color=N(c.patch.color,"Zone color")),c.patch.focalPoint!==void 0&&(d.focalPoint=pt(c.patch.focalPoint,"Zone focal point"))}let s=JSON.stringify(a.zones??[])!==JSON.stringify(e.zones??[]);return s&&(e.zones=a.zones),{changed:s,zoneIds:n,zones:n.map(c=>structuredClone(i.get(c)))}}function Mc(e,t){let n=(e.zones??[]).findIndex(a=>a.id===t.zoneId);if(n<0)throw new u("object_not_found",`Unknown chart zone: ${t.zoneId}`,{zoneId:t.zoneId});let o=T(e).flatMap(a=>a.objects).filter(a=>a.type==="section"&&a.zone===t.zoneId);if(o.length&&t.clearSectionAssignments!==!0)throw new u("invalid_operation",`Zone ${t.zoneId} is assigned to ${o.length} section(s)`,{zoneId:t.zoneId,sectionIds:o.map(a=>a.id),requiresClearSectionAssignments:!0});let r=o.map(a=>a.id);for(let a of o)delete a.zone;return e.zones.splice(n,1),e.zones.length||delete e.zones,Pe(e),{changed:!0,zoneId:t.zoneId,clearedSectionIds:r,zoneCount:e.zones?.length??0}}var yt=[{key:"row-seats",label:"row seats",suffix:"rows",labelSuffix:"Rows",creationWord:"Seats",objectType:"row"},{key:"table-chairs",label:"table chairs",suffix:"tables",labelSuffix:"Tables",creationWord:"Tables",objectType:"table"},{key:"booth-units",label:"booth units",suffix:"booths",labelSuffix:"Booths",creationWord:"Booths",objectType:"booth"},{key:"ga-capacity",label:"GA capacity",suffix:"ga",labelSuffix:"GA",creationWord:"Standing",objectType:"gaArea"}];function en(e){let t=new Map,n=Math.max(0,Math.floor(e.seatCount)),o=new Map((e.overrides??[]).filter(a=>Number.isInteger(a.index)&&a.index>=0&&a.index<e.seatCount).map(a=>[a.index,a])),r=(a,i=1)=>{a&&i>0&&t.set(a,(t.get(a)??0)+i)};r(e.categoryKey,n-o.size);for(let a of o.values())a.skip||r(a.categoryKey??e.categoryKey);return t}var Vn="__sl_ga__";function Ae(e){return e.startsWith(Vn)}var Rc=Vn,te=1e5;function _c(e,t){return`${Rc}${encodeURIComponent(e)}__${t+1}`}function Xn(e){let t=e.inventorySegments;if(t===void 0)return!0;if(!Array.isArray(t)||t.length<1||t.length>256)return!1;let n=0,o=new Map;for(let r of t){if(!r||typeof r.sourceAreaId!="string"||!r.sourceAreaId.trim()||r.sourceAreaId.length>160||!Number.isInteger(r.startIndex)||r.startIndex<0||!Number.isInteger(r.count)||r.count<1||r.startIndex+r.count>te||(n+=r.count,n>te))return!1;let a=o.get(r.sourceAreaId)??[],i=r.startIndex+r.count;if(a.some(s=>r.startIndex<s.end&&i>s.start))return!1;a.push({start:r.startIndex,end:i}),o.set(r.sourceAreaId,a)}return n===e.capacity}function tn(e){let t=Math.min(te,Math.max(0,Math.floor(e.capacity)));return e.inventorySegments===void 0?t?[{sourceAreaId:e.id,startIndex:0,count:t}]:[]:Xn(e)?e.inventorySegments.map(n=>({...n})):[]}var nn=100,Nr=`An area sold to one party holds at most ${nn} guests.`;function Ge(e){return e.variableOccupancy?"variable":e.bookAsWhole?"whole":null}function le(e){return Lc(e,2)}function Lc(e,t){return t===2&&Ge(e)&&e.inventorySegments===void 0?e.label.trim()?[e.label]:[]:tn(e).flatMap(n=>Array.from({length:n.count},(o,r)=>_c(n.sourceAreaId,n.startIndex+r)))}function qn(e,t){if(e.inventorySegments===void 0||t===e.capacity)return e.inventorySegments;if(t<e.capacity)return;let n=tn(e);if(!n.length)return;let o=t-e.capacity;if(!o)return n;let a=n.filter(s=>s.sourceAreaId===e.id).reduce((s,c)=>Math.max(s,c.startIndex+c.count),0),i=n[n.length-1];if(i?.sourceAreaId===e.id&&i.startIndex+i.count===a)i.count+=o;else{if(n.length>=256)return;n.push({sourceAreaId:e.id,startIndex:a,count:o})}return n}var kc="__ungrouped__";function Ec(e){return e.type==="row"?re(e).map(t=>t.label):e.type==="table"?be(e).map(t=>t.label):e.type==="booth"?wr(e).map(t=>t.label):e.type==="gaArea"?le(e):[]}function Tc(e){return e.type==="row"||e.type==="table"||e.type==="booth"||e.type==="gaArea"}function jc(e){return e.displayLabel||e.label||"Section"}function Fc(e){let t=new Map;for(let n of ee(e)){if(n.type!=="section")continue;let o=n.logicalSectionId??n.id;t.has(o)||t.set(o,{id:o,label:jc(n),zone:n.zone})}return t}function Nc(e,t){let n=ee(e),o=n.filter(s=>s.type==="section"),r=new Map;for(let[s,c]of Fc(e))r.set(s,{id:s,label:c.label,zone:c.zone,seatCount:0,objectIds:[],seatLabels:[]});let a={id:kc,label:"Other seats",seatCount:0,objectIds:[],seatLabels:[]},i=new Map;for(let s of n){if(!Tc(s))continue;let c=Ec(s);if(c.length===0)continue;let l;if(t)l=t.get(s.id);else{let f=Xt(n,s,o);l=f?f.logicalSectionId??f.id:void 0}let d=l?r.get(l):a;d.seatCount+=c.length,d.objectIds.push(s.id),d.seatLabels.push(...c),i.set(s.id,d.id)}return{sections:[...r.values()],ungrouped:a.objectIds.length?a:null,objectToSection:i}}function wt(e){return Nc(e,null)}var Me={vip:{key:"vip",label:"VIP",color:"#e5484d",price:120},premium:{key:"premium",label:"Premium",color:"#a86b00",price:80},standard:{key:"standard",label:"Standard",color:"#6e7bff",price:45},balcony:{key:"balcony",label:"Balcony",color:"#22a06b",price:30}};function xt(e,t,n,o,r,a,i=0){return{type:"row",id:e,label:t,origin:{x:-(o-1)*r/2,y:n},rotation:0,curve:i,seatCount:o,seatSpacing:r,categoryKey:a}}function Dc(e,t,n,o,r,a){return{type:"table",id:e,label:t,center:n,shape:"round",seatCount:o,rotation:0,radius:r,categoryKey:a}}function Dr(e,t,n,o,r,a){let i=n/2,s=o/2;return{type:"gaArea",id:e,label:t,points:[{x:-i,y:-s},{x:i,y:-s},{x:i,y:s},{x:-i,y:s}],capacity:r,categoryKey:a}}function Gc(e,t,n,o,r){let a=n*2,i=[];for(let s=0;s<a;s++){let c=s%2===0,l=c?["wheelchair"]:["companion"];i.push(c?{index:s,accessibility:l,wheelchairSpaceType:"no-seat"}:{index:s,accessibility:l})}return{type:"row",id:e,label:t,origin:{x:-(a-1)*o/2,y:0},rotation:0,curve:0,seatCount:a,seatSpacing:o,categoryKey:r,overrides:i}}var Gr=[{key:"balcony",label:"Balcony",icon:"\u2312",blurb:"Insert four curved rows inside a section.",categories:[Me.balcony],sectionLabel:"Balcony",build:()=>[xt("blk-b0","A",-45,18,24,"balcony",18),xt("blk-b1","B",-15,20,24,"balcony",18),xt("blk-b2","C",15,22,24,"balcony",18),xt("blk-b3","D",45,24,24,"balcony",18)]},{key:"rows",label:"Row block",icon:"\u2261",blurb:"Insert six straight rows inside a section.",categories:[Me.standard],sectionLabel:"Section",build:()=>Array.from({length:6},(e,t)=>xt(`blk-r${t}`,"ABCDEF"[t],-80+t*32,12,26,"standard"))},{key:"ga-pen",label:"GA pen",icon:"\u25A8",blurb:"Insert a standing area for 250 people.",categories:[Me.standard],build:()=>[Dr("blk-ga","Standing",320,180,250,"standard")]},{key:"tables",label:"Tables",icon:"\u283F",blurb:"Insert six round tables with eight bookable seats each.",categories:[Me.premium],build:()=>Array.from({length:6},(e,t)=>Dc(`blk-t${t}`,`T${t+1}`,{x:-150+t%3*150,y:t<3?-70:70},8,34,"premium"))},{key:"boxes",label:"Boxes",icon:"\u25A3",blurb:"Insert two private boxes with four bookable seats each.",categories:[Me.vip],build:()=>[{type:"table",id:"blk-x0",label:"Box 1",center:{x:-70,y:0},shape:"rect",seatCount:4,rotation:0,width:110,height:56,categoryKey:"vip"},{type:"table",id:"blk-x1",label:"Box 2",center:{x:70,y:0},shape:"rect",seatCount:4,rotation:0,width:110,height:56,categoryKey:"vip"}]},{key:"terrace",label:"Terrace",icon:"\u2263",blurb:"Insert a standing terrace for 500 people.",categories:[Me.standard],build:()=>[Dr("blk-terrace","Terrace",520,200,500,"standard")]},{key:"wheelchair-platform",label:"Wheelchair platform",icon:"\u267F",blurb:"Insert four wheelchair spaces, each with its companion seat.",categories:[Me.standard],build:()=>[Gc("blk-wc","A",4,40,"standard")]}];function B(e){let t="",n=e;do t=String.fromCharCode(65+n%26)+t,n=Math.floor(n/26)-1;while(n>=0);return t}function on(e){if(!/^[A-Z]+$/.test(e))return null;let t=0;for(let n of e)t=t*26+(n.charCodeAt(0)-64);return t-1}var Se=["#e69f00","#56b4e9","#009e73","#f0e442","#0072b2","#d55e00","#cc79a7"],$r="#a4508b";var $c=/^#?([\da-f]{3}|[\da-f]{6})$/i;function Bc(e){let t=e.replace("#","");return{r:parseInt(t.slice(0,2),16),g:parseInt(t.slice(2,4),16),b:parseInt(t.slice(4,6),16)}}function Be(e){let t=$c.exec((e??"").trim());if(!t)return null;let n=t[1].length===3?t[1].split("").map(r=>r+r).join(""):t[1],o=parseInt(n,16);return[o>>16&255,o>>8&255,o&255]}function Jn(e,t){let n=a=>{let i=Be(a);if(!i)return null;let s=y=>{let w=y/255;return w<=.04045?w/12.92:((w+.055)/1.055)**2.4},c=s(i[0]),l=s(i[1]),d=s(i[2]),f=(.4124*c+.3576*l+.1805*d)/.95047,g=.2126*c+.7152*l+.0722*d,h=(.0193*c+.1192*l+.9505*d)/1.08883,b=y=>y>.008856?Math.cbrt(y):7.787*y+16/116,p=b(f),x=b(g),I=b(h);return[116*x-16,500*(p-x),200*(x-I)]},o=n(e),r=n(t);return o&&r?Math.hypot(o[0]-r[0],o[1]-r[1],o[2]-r[2]):null}function $e(e){let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function Br(e){let{r:t,g:n,b:o}=Bc(e);return .2126*$e(t)+.7152*$e(n)+.0722*$e(o)}function Yn(e){return .2126*$e(e[0])+.7152*$e(e[1])+.0722*$e(e[2])}function rn(e,t){let n=Br(e),o=Br(t);return(Math.max(n,o)+.05)/(Math.min(n,o)+.05)}function St(e,t){let n=Be(e),o=Be(t);if(!n||!o)return null;let r=Yn(n),a=Yn(o);return(Math.max(r,a)+.05)/(Math.min(r,a)+.05)}function Kr(e,t,n){return rn(t,e)>=rn(n,e)?t:n}var zr=.85,Kc=12;function Ur(e,t){return e*t>=Kc}var zc={wheelchair:"M7.8 4.5a2.2 2.2 0 1 0 4.4 0a2.2 2.2 0 1 0 -4.4 0zM8 7L10.5 7L10.5 15L8 15ZM8 12.5L18 12.5L18 15L8 15ZM16 15L18 15L18 18L16 18ZM5.5 16a5.5 5.5 0 1 0 11 0a5.5 5.5 0 1 0 -11 0zM8 16a3 3 0 1 1 6 0a3 3 0 1 1 -6 0z",companion:"M5.5 6.5a3 3 0 1 0 6 0a3 3 0 1 0 -6 0zM4.5 18.5L6 11.5L11 11.5L12.5 18.5ZM12.5 7.5a3 3 0 1 0 6 0a3 3 0 1 0 -6 0zM11.5 19L13 12.5L18 12.5L19.5 19Z","semi-ambulatory":"M8.3 3.8a2.2 2.2 0 1 0 4.4 0a2.2 2.2 0 1 0 -4.4 0zM9 6.2L12 6.6L11 13.5L8.6 13L9 6.2ZM8.6 13L11 13L9.5 21L7 21ZM10.4 13L12.6 13L13.6 21L11.2 21ZM11.2 7.2L14 8L14.6 9.6L11.9 8.9ZM14.4 6.8L15.9 6.8L16.4 21L14.8 21Z","designated-aisle":"M3 5L6 5L6 14L3 14ZM3 12L13 12L13 15L3 15ZM5 15L7 15L7 20L5 20ZM11 15L13 15L13 20L11 20ZM13 7L20 7L17 4L19 4L23 8.5L19 13L17 13L20 10L13 10Z","step-free":"M4 4.5a2.2 2.2 0 1 0 4.4 0a2.2 2.2 0 1 0 -4.4 0zM4.4 7L7.5 7L7.5 13L11 15L9.5 17L5 14L4.4 7ZM2 19L8 19L17 10L22 10L22 13L18 13L10 21L2 21Z",hearing:"M15.5 3.5C9 2.2 5.5 6 5.5 11.5C5.5 16 8 19.5 10.5 21C13.2 22.6 16.4 20.8 15.4 18C14.8 16.4 12.9 16.1 13 14C13.1 11.9 15.8 11.4 15.8 8.5C15.8 5.4 13 4 15.5 3.5Z",cart:"M5.5 6L18.5 6a2.5 2.5 0 0 1 2.5 2.5L21 15.5a2.5 2.5 0 0 1 -2.5 2.5L11 18L7 20.5L7.5 18L5.5 18a2.5 2.5 0 0 1 -2.5 -2.5L3 8.5a2.5 2.5 0 0 1 2.5 -2.5zM6.5 11L17.5 11L17.5 12.6L6.5 12.6zM6.5 14L17.5 14L17.5 15.6L6.5 15.6z","sign-language":"M7 11L17 11L17 18a2 2 0 0 1 -2 2L9 20a2 2 0 0 1 -2 -2zM7.6 5L9.4 5L9.4 12L7.6 12zM9.9 3.5L11.7 3.5L11.7 12L9.9 12zM12.3 3.5L14.1 3.5L14.1 12L12.3 12zM14.6 5L16.4 5L16.4 12L14.6 12zM7.2 12.5L5 10.2L6.4 8.9L8.6 11.2Z","low-vision":"M2.5 12C6 6 18 6 21.5 12C18 18 6 18 2.5 12ZM9 12a3 3 0 1 0 6 0a3 3 0 1 0 -6 0zM17.5 3L19 3L19 6L17.5 6ZM19 4L22 4L22 5.5L19 5.5Z","sensory-friendly":"M4 11C4 5 7 2.5 12 2.5S20 5 20 11L17 11C17 7 15.5 5.5 12 5.5S7 7 7 11ZM3 10L8 10L8 19L5 19a2 2 0 0 1 -2 -2ZM16 10L21 10L21 17a2 2 0 0 1 -2 2L16 19ZM9 12L15 12L15 14L9 14ZM10 16L14 16L14 18L10 18Z","plus-size":"M9.4 4.3a2.6 2.6 0 1 0 5.2 0a2.6 2.6 0 1 0 -5.2 0zM5 20L4 13C4 10.5 7 9.5 12 9.5C17 9.5 20 10.5 20 13L19 20Z","lift-armrest":"M5 6L8 6L8 19L5 19zM5 16L18 16L18 19L5 19zM8 12L17 12L17 14.5L8 14.5zM14 7L16 7L16 12L14 12zM12 7L18 7L15 3Z"},Vh=zc.wheelchair;function Hr(e,t,n){let o=Be(e),r=Be(t);if(!o||!r)return t;let a=Math.max(0,Math.min(1,n));return`#${o.map((s,c)=>Math.round(s*a+r[c]*(1-a))).map(s=>s.toString(16).padStart(2,"0")).join("")}`}var Wn={facilities:$r,"food-drink":Se[5],navigation:Se[2],accessibility:Se[4]};var Yh={minDiameterPx:12,glyphScale:.66,ringRatio:1/14,largeFromPx:24};var G=e=>{let t=Math.round(e*100)/100;return Object.is(t,-0)?"0":String(t)},He=e=>`${G(e[0])} ${G(e[1])}`,Ue=(e,t,n,o)=>[e+n*Math.cos(o*Math.PI/180),t+n*Math.sin(o*Math.PI/180)];function ri(e){let t=`M${He(e.from)}`;for(let n of e.segs)t+=n.arc?`A${G(n.arc.r)} ${G(n.arc.r)} 0 ${n.arc.large} ${n.arc.sweep} ${He(n.to)}`:`L${He(n.to)}`;return`${t}Z`}function K(e){let t=[e.from,...e.segs.map(o=>o.to)],n=[];for(let o=e.segs.length-1;o>=0;o--){let r=e.segs[o].arc;n.push({to:t[o],arc:r&&{...r,sweep:r.sweep?0:1}})}return{from:t[t.length-1],segs:n}}function z(e,t,n){let o={r:n,large:0,sweep:1};return{from:[e-n,t],segs:[{to:[e+n,t],arc:o},{to:[e-n,t],arc:o}]}}function _(e,t,n,o,r){let a=Math.min(r,n/2,o/2),i={r:a,large:0,sweep:1};return a<=0?X([[e,t],[e+n,t],[e+n,t+o],[e,t+o]]):{from:[e+a,t],segs:[{to:[e+n-a,t]},{to:[e+n,t+a],arc:i},{to:[e+n,t+o-a]},{to:[e+n-a,t+o],arc:i},{to:[e+a,t+o]},{to:[e,t+o-a],arc:i},{to:[e,t+a]},{to:[e+a,t],arc:i}]}}function X(e){let t=0;for(let o=0;o<e.length;o++){let[r,a]=e[o],[i,s]=e[(o+1)%e.length];t+=r*s-i*a}let n=t>0?e:[...e].reverse();return{from:n[0],segs:[...n.slice(1).map(o=>({to:o})),{to:n[0]}]}}function F(e,t,n){let o=n/2,r=t[0]-e[0],a=t[1]-e[1],i=Math.hypot(r,a);if(i<1e-6)return z(e[0],e[1],o);let s=[a/i*o,-r/i*o],c={r:o,large:0,sweep:1},l=[e[0]+s[0],e[1]+s[1]];return{from:l,segs:[{to:[t[0]+s[0],t[1]+s[1]]},{to:[t[0]-s[0],t[1]-s[1]],arc:c},{to:[e[0]-s[0],e[1]-s[1]]},{to:l,arc:c}]}}function V(e,t,n=!1){let o=[],r=n?e.length:e.length-1;for(let a=0;a<r;a++)o.push(F(e[a],e[(a+1)%e.length],t));return o}function de(e,t,n,o,r,a){let i=a/2,s=r-o>180?1:0,c={r:i,large:0,sweep:1},l=Ue(e,t,n+i,o);return{from:l,segs:[{to:Ue(e,t,n+i,r),arc:{r:n+i,large:s,sweep:1}},{to:Ue(e,t,n-i,r),arc:c},{to:Ue(e,t,n-i,o),arc:{r:n-i,large:s,sweep:0}},{to:l,arc:c}]}}var L=(...e)=>e.flat().map(ri).join(" "),ie=(e,t,n)=>`M${G(e-n)} ${G(t)}a${G(n)} ${G(n)} 0 1 0 ${G(2*n)} 0a${G(n)} ${G(n)} 0 1 0 ${G(-2*n)} 0`,he=(e,t,n,o,r)=>ri(_(e,t,n,o,r)),sn=e=>`M${e.map(He).join("L")}`,an=(e,t,n,o,r)=>`M${He(Ue(e,t,n,o))}A${G(n)} ${G(n)} 0 ${r-o>180?1:0} 1 ${He(Ue(e,t,n,r))}`;function Ke(e,t,n,o=1){let r=a=>[a[0]*o+t,a[1]*o+n];return{head:[e.head[0]*o+t,e.head[1]*o+n,e.head[2]*o],limbs:e.limbs.map(a=>a.map(r)),arcs:e.arcs?.map(([a,i,s,c,l])=>[a*o+t,i*o+n,s*o,c,l])}}function It(e){return[ie(e.head[0],e.head[1],e.head[2]),...e.limbs.map(sn),...(e.arcs??[]).map(([t,n,o,r,a])=>an(t,n,o,r,a))].join(" ")}function ze(e,t=2.6){return[z(e.head[0],e.head[1],e.head[2]+1),...e.limbs.flatMap(n=>V(n,t)),...(e.arcs??[]).map(([n,o,r,a,i])=>de(n,o,r,a,i,t-.2))]}var Re={head:[10,4,2],limbs:[[[10,8.2],[10,14],[15.5,14],[18,19.5],[20.5,19.5]],[[10,10.6],[14.5,10.6]]],arcs:[[9.5,16,5.5,35,235]]},Vr={head:[10.6,3.9,1.9],limbs:[[[9.6,7.8],[7.6,12]],[[5.4,8.2],[9.4,8.4],[12.8,10]],[[4,15.6],[7.6,12],[11,13.6],[10.6,16.4]]]},Xr={cx:12,hr:1.9,arm:5,leg:3,r:2},qr={cx:12,hr:1.9,sh:2.2,hem:6,leg:3},Yr={cx:6.2,hr:1.8,arm:3.6,leg:2.2,r:1.4},Jr={cx:17.8,hr:1.8,sh:1.4,hem:4.1,leg:2.2};function Wr({cx:e,hr:t,arm:n,leg:o,r}){return[ie(e,2+t,t),`M${G(e-n+r)} 8.5H${G(e+n-r)}a${r} ${r} 0 0 1 ${r} ${r}V15H${G(e+o)}V22H${G(e-o)}V15H${G(e-n)}V${G(8.5+r)}a${r} ${r} 0 0 1 ${r} ${-r}Z`,`M${G(e)} 15V22`].join(" ")}function Zr({cx:e,hr:t,arm:n,leg:o,r}){return[z(e,2+t,t+1),_(e-n-.5,7.8,2*n+1,7.7,r+.5),_(e-o-.5,13,o,9.5,1),_(e+.5,13,o,9.5,1)]}function Qr({cx:e,hr:t,sh:n,hem:o,leg:r}){return[ie(e,2+t,t),sn([[e-n,8.5],[e+n,8.5],[e+o,16],[e+r,16],[e+r,22],[e-r,22],[e-r,16],[e-o,16]])+"Z",`M${G(e)} 16V22`].join(" ")}function ei({cx:e,hr:t,sh:n,hem:o,leg:r}){return[z(e,2+t,t+1),X([[e-n-.6,7.8],[e+n+.6,7.8],[e+o+.9,16.8],[e-o-.9,16.8]]),_(e-r-.1,15,r-.4,7.5,.9),_(e+.5,15,r-.4,7.5,.9)]}var Uc=[[14.6,1.5],[5.2,13.6],[11,13.6],[9.4,22.5],[18.8,10.4],[13,10.4]],Hc="M8.5 3.5 4 5.5l-1.5 5 3 1 1-2v11h11v-11l1 2 3-1-1.5-5-4.5-2c-.5 1.5-1.8 2.5-3.5 2.5s-3-1-3.5-2.5Z",Vc="M12 2.5S5 9.5 5 14.5a7 7 0 0 0 14 0c0-5-7-12-7-12Z",Xc="M2.5 21.5h19V3h-6v6.2H9.2v6.2H2.5Z",ti=[[9,3],[15,3],[15,9],[21,9],[21,15],[15,15],[15,21],[9,21],[9,15],[3,15],[3,9],[9,9]],qc={from:[3.8,5.2],segs:[{to:[20.2,5.2]},{to:[22,7],arc:{r:1.8,large:0,sweep:1}},{to:[22,9.7]},{to:[22,14.3],arc:{r:2.3,large:0,sweep:0}},{to:[22,17]},{to:[20.2,18.8],arc:{r:1.8,large:0,sweep:1}},{to:[3.8,18.8]},{to:[2,17],arc:{r:1.8,large:0,sweep:1}},{to:[2,14.3]},{to:[2,9.7],arc:{r:2.3,large:0,sweep:0}},{to:[2,7]},{to:[3.8,5.2],arc:{r:1.8,large:0,sweep:1}}]},Yc={from:[12,1.6],segs:[{to:[20.4,4.9]},{to:[20.4,11.2]},{to:[12,22.4],arc:{r:13,large:0,sweep:1}},{to:[3.6,11.2],arc:{r:13,large:0,sweep:1}},{to:[3.6,4.9]},{to:[12,1.6]}]};function ni(e,t,n){return{from:[e-n,t],segs:[{to:[e+n,t],arc:{r:n,large:0,sweep:1}},{to:[e-n,t]}]}}var oi={head:[13.2,4.3,2.2],limbs:[[[12.6,8.6],[11.2,15],[17.8,18.4],[9.4,18.4]],[[12.4,9.8],[16,14.4]]]},Jc=[[6,10.5],[15,10.5],[16.5,7],[18.5,5.5],[20,6.5],[21.5,8.5],[19.5,10],[18,12],[18,19],[16.5,19],[15.5,14],[9.5,14],[8.5,19],[7,19],[6.5,13]],Wc=[[5.4,9.8],[14.6,9.8],[16.1,6.4],[18.4,4.6],[20.5,5.9],[22.4,8.6],[19.9,10.6],[18.8,12.3],[18.8,19.8],[15.8,19.8],[15,14.8],[10.1,14.8],[9.2,19.8],[6.2,19.8],[5.6,13.2]],Zn=[{key:"restroom-men",label:"Men's restroom",group:"facilities",path:Wr(Xr),solid:L(Zr(Xr))},{key:"restroom-women",label:"Women's restroom",group:"facilities",path:Qr(qr),solid:L(ei(qr))},{key:"restroom-accessible",label:"Accessible restroom",group:"facilities",path:[he(2.5,2.5,19,19,3.5),It(Ke(Re,4.6,4.3,.66))].join(" "),solid:L(ze(Re)),solidLarge:L(_(1.5,1.5,21,21,4.5),K(_(3.9,3.9,16.2,16.2,2.6)),ze(Ke(Re,4.9,4.7,.62),2.2))},{key:"first-aid",label:"First aid",group:"facilities",path:sn(ti)+"Z",solid:L(X(ti.map(([e,t])=>[e+(e-12)*.08,t+(t-12)*.08])))},{key:"coat-check",label:"Coat check",group:"facilities",path:"M10 6.5a2 2 0 1 1 2 2V10 M12 10 3.4 16.9a1.4 1.4 0 0 0 .9 2.6h15.4a1.4 1.4 0 0 0 .9-2.6Z",solid:L(de(12,6.2,2.2,180,450,2.3),F([12,8.4],[12,10.5],2.3),V([[12,10.2],[3.2,18.8],[20.8,18.8]],2.8,!0))},{key:"atm",label:"ATM / cash",group:"facilities",path:[he(2,6,20,12,2),ie(12,12,2.75),"M6 12h.01 M18 12h.01"].join(" "),solid:L(_(1.5,5.5,21,13,2.4),K(z(12,12,3.2)))},{key:"info",label:"Info point",group:"facilities",path:[ie(12,12,9.5),"M10.8 11H12v5.8 M12 7.6h.01"].join(" "),solid:L(z(12,4.9,2.4),_(10.3,9.2,3.4,12.3,1),_(8.2,9.2,4,3,1),_(8.2,18.5,7.6,3,1))},{key:"lost-found",label:"Lost & found",group:"facilities",path:[ie(10.5,10.5,7.5),"M16 16l5.5 5.5","M8.4 8.4a2.1 2.1 0 1 1 3 1.9c-.6.4-.9.8-.9 1.6 M10.5 14.6h.01"].join(" "),solid:L(de(12,7.6,4.2,180,405,3.4),V([[14.97,10.57],[12,13],[12,15]],3.4),z(12,20,2.1))},{key:"restrooms",label:"Toilets",group:"facilities",path:[Wr(Yr),Qr(Jr)].join(" "),solid:L(Zr(Yr),ei(Jr))},{key:"charging",label:"Charging point",group:"facilities",path:[he(6,2,12,20,2.5),"M13.2 6.2 9.6 12h4.8l-3.6 5.8"].join(" "),solid:L(X(Uc))},{key:"smoking",label:"Smoking area",group:"facilities",path:[he(2,14.5,14.5,4,1),"M6.5 14.5v4","M15.5 11.5c0-1.4 1.5-1.9 1.5-3.4s-1.5-2-1.5-3.4 M19 11.5c0-1.4 1.5-1.9 1.5-3.4s-1.5-2-1.5-3.4"].join(" "),solid:L(_(1.5,14,4.2,5,1.2),_(6.8,14,10.4,5,1.2),V([[15.9,11.4],[17.3,8.9],[15.9,6.4],[17.1,3.9]],2.2),V([[19.6,11.4],[21,8.9],[19.6,6.4],[20.8,3.9]],2.2))},{key:"no-smoking",label:"No smoking",group:"facilities",path:[ie(12,12,9.5),"M5.3 5.3l13.4 13.4","M5.5 10.5h13v3h-13Z"].join(" "),solid:L(z(12,12,10.6),K(z(12,12,8)),F([6,6],[18,18],2.8),_(5,10.4,3,3.2,.6),_(16,10.4,3,3.2,.6))},{key:"food",label:"Food",group:"food-drink",path:"M5 2.5V8a2.5 2.5 0 0 0 5 0V2.5 M7.5 2.5v19 M18.5 13.5h-2c-1.3 0-2-1-2-2.5 0-4 1.5-7 4-8.5v19",solid:L(V([[4.9,2.6],[4.9,8]],2.2),V([[10.1,2.6],[10.1,8]],2.2),V([[7.5,2.6],[7.5,8]],2.2),de(7.5,8,2.6,0,180,2.2),F([7.5,10],[7.5,21.4],3),X([[19.4,2.2],[19.4,14.2],[16.2,14.2],[14.1,12],[14.1,9.4],[15.2,5.8],[17.3,3.3]]),F([18,13],[18,21.4],3))},{key:"bar",label:"Bar",group:"food-drink",path:"M3.5 3.5h17L12 13Z M6.2 6.5h11.6 M12 13v7.5 M8 20.5h8",solid:L(X([[2.8,3],[21.2,3],[12,13.6]]),F([12,12],[12,20.6],2.8),F([7.4,21],[16.6,21],2.8))},{key:"coffee",label:"Caf\xE9 / coffee",group:"food-drink",path:"M4 9h12v4.5a5.5 5.5 0 0 1-5.5 5.5h-1A5.5 5.5 0 0 1 4 13.5Z M16 10.5h1.2a2.75 2.75 0 0 1 0 5.5H16 M8 3v3 M12 3v3 M3 21.5h14",solid:L({from:[3.4,8.4],segs:[{to:[16.6,8.4]},{to:[16.6,13.4]},{to:[11,19.4],arc:{r:5.8,large:0,sweep:1}},{to:[9,19.4]},{to:[3.4,13.4],arc:{r:5.8,large:0,sweep:1}},{to:[3.4,8.4]}]},de(17.2,13.25,2.5,270,450,2.4),F([7.8,2.6],[7.8,5.6],2.4),F([12.2,2.6],[12.2,5.6],2.4),F([2.6,21.6],[17.4,21.6],2.6))},{key:"water",label:"Water / drinks",group:"food-drink",path:Vc,solid:"M12 1.2S4 8.9 4 14.5a8 8 0 0 0 16 0c0-5.6-8-13.3-8-13.3Z"},{key:"merch",label:"Merch / shop",group:"food-drink",path:Hc,solid:"M8.4 2.8 3.5 5l-1.9 6 4.2 1.4.4-.8v9.4h11.6v-9.4l.4.8 4.2-1.4-1.9-6-4.9-2.2c-.4 1.5-1.8 2.6-3.6 2.6s-3.2-1.1-3.6-2.6Z"},{key:"screen",label:"Screen",group:"facilities",path:[he(2,3.5,20,13.5,2),"M12 17v3.5 M8 20.5h8","M10 7.8v5.9l5-2.95Z"].join(" "),solid:L(_(1.5,3,21,14.4,2.4),K(X([[9.6,6.7],[16,10.2],[9.6,13.7]])),_(10.6,16.5,2.8,4,0),F([7.4,21],[16.6,21],2.8))},{key:"sound-booth",label:"Sound booth",group:"facilities",path:["M6 3v9 M6 16v5 M12 3v3 M12 10v11 M18 3v10 M18 17v4",ie(6,14,2),ie(12,8,2),ie(18,15,2)].join(" "),solid:L(F([6,2.8],[6,21.2],1.8),F([12,2.8],[12,21.2],1.8),F([18,2.8],[18,21.2],1.8),_(3.2,11.6,5.6,4.8,1.4),_(9.2,5.6,5.6,4.8,1.4),_(15.2,12.6,5.6,4.8,1.4))},{key:"entrance",label:"Entrance",group:"navigation",path:"M11 7V3.5a1 1 0 0 1 1-1h8a1 1 0 0 1 1 1v17a1 1 0 0 1-1 1h-8a1 1 0 0 1-1-1V17 M2.5 12h13.5 M12.5 8.5 16 12l-3.5 3.5",solid:L(V([[11,6.5],[11,2.6],[21,2.6],[21,21.4],[11,21.4],[11,17.5]],2.6),F([2.8,12],[13.5,12],3.2),X([[12.6,7.8],[18,12],[12.6,16.2]]))},{key:"exit",label:"Exit",group:"navigation",path:"M13 7V3.5a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v17a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V17 M8 12h13.5 M18 8.5l3.5 3.5-3.5 3.5",solid:L(V([[13,6.5],[13,2.6],[3,2.6],[3,21.4],[13,21.4],[13,17.5]],2.6),F([7.2,12],[17,12],3.2),X([[16.2,7.8],[21.6,12],[16.2,16.2]]))},{key:"emergency-exit",label:"Emergency exit",group:"navigation",path:[It(Ke(Vr,-2,1.4,1.15)),"M15.5 13h6 M19 10.5l2.5 2.5-2.5 2.5"].join(" "),solid:L(ze(Ke(Vr,-2,1.4,1.15),2.7),F([15.6,13],[19.5,13],2.8),X([[18.4,9.4],[22.4,13],[18.4,16.6]]))},{key:"stairs",label:"Stairs",group:"navigation",path:Xc,solid:"M1.5 22.5h21V2h-7.8v6.4H8.4v6.4H1.5Z"},{key:"elevator",label:"Elevator",group:"navigation",path:[he(3.5,2.5,17,19,2.5),"M8.5 9.5 12 5.5l3.5 4Z M8.5 14.5l3.5 4 3.5-4Z"].join(" "),solid:L(X([[12,1.6],[19.6,10.2],[4.4,10.2]]),X([[4.4,13.8],[19.6,13.8],[12,22.4]]))},{key:"parking",label:"Parking",group:"navigation",path:[he(3,3,18,18,3),"M9.5 17V7h3.75a3 3 0 0 1 0 6H9.5"].join(" "),solid:"M6.5 21V3H12a5.5 5.5 0 0 1 0 11h-1.9v7Z M10.1 6.6v3.8H12a1.9 1.9 0 0 0 0-3.8Z"},{key:"wheelchair",label:"Wheelchair access",group:"accessibility",path:It(Re),solid:L(ze(Re))},{key:"hearing",label:"Hearing assistance",group:"accessibility",path:["M4 9a6 6 0 1 1 12 0c0 3-1.8 4.3-3 5.2-1.1.8-1.6 1.7-1.6 3.1a3.6 3.6 0 0 1-6.2 2.1","M7.5 9a2.5 2.5 0 0 1 5 0c0 1.2-.7 1.9-1.6 2.5","M18.5 5.5a6.5 6.5 0 0 1 0 8"].join(" "),solid:L(de(10,9,6,180,380,3),V([[15.64,11.05],[12.8,14.3],[11.5,17.2]],3),de(8.2,17.2,3.3,0,150,3),de(10,9,2.2,180,400,2.4),de(13.38,9.5,6.5,322,398,2.6))},{key:"box-office",label:"Box office / tickets",group:"navigation",path:"M3 7.5A1.5 1.5 0 0 1 4.5 6h15A1.5 1.5 0 0 1 21 7.5V10a2 2 0 0 0 0 4v2.5a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 3 16.5V14a2 2 0 0 0 0-4Z M15 6v2 M15 11v2 M15 16v2",solid:L(qc,K(_(14.1,7,1.8,2.2,.9)),K(_(14.1,10.9,1.8,2.2,.9)),K(_(14.1,14.8,1.8,2.2,.9)))},{key:"escalator",label:"Escalator",group:"navigation",path:"M2.5 17H7l9-9h5.5v4h-4l-9 9h-6Z M11 4.5h.01 M11 8.2v3.3",solid:L(X([[2,16.4],[6.8,16.4],[15.8,7.4],[22,7.4],[22,12.6],[17.8,12.6],[8.8,21.6],[2,21.6]]),z(11,4.3,2.3),F([11,8],[11,11],2.6))},{key:"ramp",label:"Ramp",group:"navigation",path:"M2.5 19.5h19v-10Z M4.5 13.2 14 8.2 M10.53 7.76 14 8.2l-1.6 3.11",solid:L(X([[1.6,20.4],[22.4,20.4],[22.4,8.6]]),F([4.2,13.4],[13.2,8.6],2.6),X([[15.4,7.5],[13.16,11.84],[10.56,6.88]]))},{key:"taxi",label:"Taxi / rideshare",group:"navigation",path:["M9.5 2.5h5V5h-5Z M6.5 11 8 7h8l1.5 4",he(3.5,11,17,6,2),"M6.5 17v2.5 M17.5 17v2.5 M7 14h.01 M17 14h.01"].join(" "),solid:L(_(9,1.8,6,3.4,.8),X([[6,11.4],[7.6,6.4],[16.4,6.4],[18,11.4]]),_(2.8,10.6,18.4,7,2.2),K(z(6.8,14,1.3)),K(z(17.2,14,1.3)),_(4.8,16,3.6,5.2,1.2),_(15.6,16,3.6,5.2,1.2))},{key:"transit",label:"Bus / transit",group:"navigation",path:[he(4.5,2.5,15,16,3),"M4.5 10.5h15 M9 5.5h6 M7.5 18.5V21 M16.5 18.5V21 M8 14.5h.01 M16 14.5h.01"].join(" "),solid:L(_(4,2,16,17,3.2),K(_(6.2,5.8,11.6,5,1)),K(z(8,14.5,1.3)),K(z(16,14.5,1.3)),_(6,17,3.4,5,1.2),_(14.6,17,3.4,5,1.2))},{key:"bike-parking",label:"Bike parking",group:"navigation",path:[ie(6,14.5,4),ie(18,14.5,4),"M6 14.5 9 7.5h6.5L18 14.5 M9 7.5l2.5 7H6 M11.5 14.5l4-7 M7.5 6h3 M15.5 7.5 15 5.5h2"].join(" "),solid:L(z(6,14.5,4.9),K(z(6,14.5,2.7)),z(18,14.5,4.9),K(z(18,14.5,2.7)),V([[6,14.5],[9,7.5],[15.5,7.5],[18,14.5]],2.2),V([[9,7.5],[11.5,14.5],[15.5,7.5]],2.2),F([6,14.5],[11.5,14.5],2.2),F([7.2,5.8],[10.6,5.8],2.2),V([[15.4,7.3],[15,5.4],[17.2,5.4]],2.2))},{key:"meeting-point",label:"Meeting point",group:"navigation",path:["M9.5 2.5 12 5l2.5-2.5 M9.5 21.5 12 19l2.5 2.5 M2.5 9.5 5 12l-2.5 2.5 M21.5 9.5 19 12l2.5 2.5",ie(10,9.6,1.5),ie(14,9.6,1.5),"M7.5 15.5a2.5 2.5 0 0 1 5 0 M11.5 15.5a2.5 2.5 0 0 1 5 0"].join(" "),solid:L(V([[9.4,2.4],[12,5],[14.6,2.4]],2.6),V([[9.4,21.6],[12,19],[14.6,21.6]],2.6),V([[2.4,9.4],[5,12],[2.4,14.6]],2.6),V([[21.6,9.4],[19,12],[21.6,14.6]],2.6),z(9.7,9.3,2.2),z(14.3,9.3,2.2),ni(9.7,16,3),ni(14.3,16,3))},{key:"security",label:"Security / bag check",group:"facilities",path:"M12 2.5 19.5 5.5v6c0 4.6-3.2 8.4-7.5 10-4.3-1.6-7.5-5.4-7.5-10v-6Z M8.5 12l2.5 2.5 4.5-5",solid:L(Yc,K(X([[7.4,12.2],[9,10.6],[10.9,12.5],[15,8.4],[16.6,10],[10.9,15.7]])))},{key:"lockers",label:"Lockers",group:"facilities",path:[he(3.5,2.5,17,19,1.5),"M12 2.5v19 M6 6h3 M15 6h3 M9.5 11.5v2.5 M14.5 11.5v2.5"].join(" "),solid:L(_(3,2,8.4,20,1.4),K(_(5,5,4.4,1.7,.8)),K(_(8.6,10.8,1.5,3.8,.7)),_(12.6,2,8.4,20,1.4),K(_(14.6,5,4.4,1.7,.8)),K(_(13.9,10.8,1.5,3.8,.7)))},{key:"baby-change",label:"Baby change",group:"facilities",path:"M10 6.5l.8-3.3a1.2 1.2 0 0 1 2.4 0l.8 3.3 M8.5 6.5h7 M9.5 6.5l-.9 2.2a3 3 0 0 0-.1.9V19a2.5 2.5 0 0 0 2.5 2.5h2a2.5 2.5 0 0 0 2.5-2.5V9.6a3 3 0 0 0-.1-.9l-.9-2.2 M8.5 12.5h3 M8.5 16h3",solid:L(X([[9.6,6.2],[10.6,1.8],[13.4,1.8],[14.4,6.2]]),_(7.6,5.4,8.8,2.6,1),_(7.8,7.4,8.4,15,2.6),K(_(7.8,11.8,3.4,1.5,0)),K(_(7.8,15.4,3.4,1.5,0)))},{key:"prayer-room",label:"Prayer room",group:"facilities",path:[It(oi),"M3 21.5h18"].join(" "),solid:L(ze(oi),_(2.4,20.2,19.2,2.6,1.3))},{key:"quiet-room",label:"Quiet room",group:"facilities",path:"M4 9h3.5l5-4v14l-5-4H4Z M15.5 9.5l5 5 M20.5 9.5l-5 5",solid:L(X([[2.6,8.4],[7.2,8.4],[13,3.6],[13,20.4],[7.2,15.6],[2.6,15.6]]),F([15.4,9.2],[20.8,14.8],2.8),F([20.8,9.2],[15.4,14.8],2.8))},{key:"wifi",label:"Wi-Fi",group:"facilities",path:[an(12,19,11.5,218,322),an(12,19,7.5,218,322),an(12,19,3.5,218,322),"M12 19h.01"].join(" "),solid:L(de(12,19.2,11,218,322,2.8),de(12,19.2,6.9,218,322,2.8),z(12,19.2,2.2))},{key:"vip-lounge",label:"VIP lounge",group:"facilities",path:["M6.5 11V7a2 2 0 0 1 2-2h7a2 2 0 0 1 2 2v4","M3.5 11.5a1.5 1.5 0 0 1 3 0V14h11v-2.5a1.5 1.5 0 0 1 3 0v6h-17Z","M5.5 17.5V20 M18.5 17.5V20"].join(" "),solid:L(_(6,4,12,8.5,2.2),_(2.4,9.6,4.6,9,2.2),_(17,9.6,4.6,9,2.2),_(6,13.2,12,5.4,.6),F([5,18],[5,20.6],2.4),F([19,18],[19,20.6],2.4))},{key:"accessible-entrance",label:"Accessible entrance",group:"accessibility",path:[It(Ke(Re,.3,5,.62)),"M12.5 3.5H20a1 1 0 0 1 1 1v15a1 1 0 0 1-1 1h-7.5"].join(" "),solid:L(ze(Ke(Re,.3,5,.62),2.2),V([[13,2.8],[21.2,2.8],[21.2,21.2],[13,21.2]],2.6))},{key:"assistance-dog",label:"Assistance-dog area",group:"accessibility",path:[sn(Jc)+"Z","M6 10.8 3.5 7.5","M10.5 10.5V6h4.5l1 2.5"].join(" "),solid:L(X(Wc),F([6.2,11],[3.2,7.2],2.4),V([[10.5,11],[10.5,5.6],[15.2,5.6],[16.2,8.2]],2.2))}],Jh=new Map(Zn.map(e=>[e.key,e]));var ii=Zn;var ai=new Map(ii.map(e=>[e.key,e]));function si(e){return e?ai.get(e):void 0}function ci(e){return typeof e=="string"&&ai.has(e)}var Qh=ii.map(e=>e.key);function Zc(e){if(!Number.isFinite(e))return 0;let t=(e%360+360)%360;return Object.is(t,-0)||Math.abs(t)<1e-9?0:t}function cn(e){let t=(e%360+360)%360,n=t>=180?t-360:t;return Object.is(n,-0)||Math.abs(n)<1e-9?0:n}function Qc(e){return e==="row"?"signed180":"unsigned360"}function Ie(e,t){return Qc(e)==="signed180"?cn(t):Zc(t)}function Ve(e,t,n){let o=r=>({x:r.x+t,y:r.y+n});switch(e.type){case"row":e.origin=o(e.origin),e.path&&(e.path={start:o(e.path.start),control1:o(e.path.control1),control2:o(e.path.control2),end:o(e.path.end)});break;case"table":case"booth":e.center=o(e.center);break;case"text":e.position=o(e.position);break;case"gaArea":e.points=e.points.map(o),e.holes&&(e.holes=Q(e.holes).map(r=>r.map(o)));break;case"section":e.outline=e.outline.map(o),e.sourceOutline&&(e.sourceOutline=e.sourceOutline.map(o)),e.outlinePath&&(e.outlinePath=er(e.outlinePath,t,n)),e.holes&&(e.holes=Q(e.holes).map(r=>r.map(o))),e.labelPresentation?.position&&(e.labelPresentation.position=o(e.labelPresentation.position));break;case"shape":e.points&&(e.points=e.points.map(o)),e.holes&&(e.holes=Q(e.holes).map(r=>r.map(o))),e.x!=null&&(e.x+=t),e.y!=null&&(e.y+=n);break;case"decorImage":e.x+=t,e.y+=n;break}}function ln(e,t,n){return n?Yo(e,t,n):{x:e.x,y:e.y}}function el(e,t,n){let o=r=>ln(r,t,n);e.outline=e.outline.map(o),e.sourceOutline&&(e.sourceOutline=e.sourceOutline.map(o)),e.outlinePath&&(e.outlinePath=at(e.outlinePath,o,1,!1)),e.holes&&(e.holes=Q(e.holes).map(r=>r.map(o)))}function tl(e,t,n){let o=e.rotation??0;if(e.points?.length){let r={x:e.points.reduce((s,c)=>s+c.x,0)/e.points.length,y:e.points.reduce((s,c)=>s+c.y,0)/e.points.length},a=ln(r,t,n),i=s=>({x:s.x+a.x-r.x,y:s.y+a.y-r.y});e.points=e.points.map(i),e.holes&&(e.holes=Q(e.holes).map(s=>s.map(i)))}else if(e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null){let r={x:e.x+e.width/2,y:e.y+e.height/2},a=ln(r,t,n);e.x+=a.x-r.x,e.y+=a.y-r.y}e.rotation=Ie("shape",o+n)}function li(e,t,n){if(!Number.isFinite(n)||!Number.isFinite(t.x)||!Number.isFinite(t.y))throw new RangeError("group_rotation_must_be_finite");if(n===0)return;let o=r=>ln(r,t,n);switch(e.type){case"row":e.origin=o(e.origin),e.path&&(e.path={start:o(e.path.start),control1:o(e.path.control1),control2:o(e.path.control2),end:o(e.path.end)}),e.rotation=Ie("row",e.rotation+n);break;case"table":case"booth":e.center=o(e.center),e.rotation=Ie(e.type,e.rotation+n);break;case"gaArea":e.points=e.points.map(o),e.holes&&(e.holes=Q(e.holes).map(r=>r.map(o)));break;case"section":el(e,t,n);break;case"shape":tl(e,t,n);break;case"text":e.position=o(e.position),e.rotation=Ie("text",e.rotation+n);break;case"decorImage":{let r={x:e.x+e.width/2,y:e.y+e.height/2},a=o(r);e.x+=a.x-r.x,e.y+=a.y-r.y,e.rotation=Ie("decorImage",(e.rotation??0)+n);break}}}var nl=["bookAsWhole","variableOccupancy","minOccupancy","maxOccupancy","wheelchairPlaces"],di=(e,t,n)=>Number.isInteger(e)&&e>=t&&e<=n;function ui(e){let t={};for(let n of nl){if(!(n in e))continue;let o=e[n];delete e[n],o!==void 0&&(t[n]=o)}for(let n of["bookAsWhole","variableOccupancy"])if(t[n]!==void 0&&typeof t[n]!="boolean")throw new u("invalid_operation",`${n} must be true or false`);if(t.bookAsWhole===!0&&t.variableOccupancy===!0)throw new u("invalid_operation","A standing area cannot be sold whole and by party size at the same time");if(t.variableOccupancy===!1&&(t.minOccupancy!==void 0||t.maxOccupancy!==void 0))throw new u("invalid_operation","Guest bounds can be supplied only with party-size selling");for(let n of["minOccupancy","maxOccupancy"])if(t[n]!==void 0&&!di(t[n],1,te))throw new u("invalid_operation",`${n} must be a whole number from 1 to ${te}`);if(t.wheelchairPlaces!==void 0&&!di(t.wheelchairPlaces,0,te))throw new u("invalid_operation",`wheelchairPlaces must be a whole number from 0 to ${te}`);return t}function fi(e,t){if(Object.assign(e,t),t.bookAsWhole===!0&&delete e.variableOccupancy,t.variableOccupancy===!0&&delete e.bookAsWhole,e.bookAsWhole||delete e.bookAsWhole,!e.variableOccupancy){if(t.minOccupancy!==void 0||t.maxOccupancy!==void 0)throw new u("invalid_operation","Guest bounds can be changed only on an area sold by party size",{gaAreaId:e.id});delete e.variableOccupancy,delete e.minOccupancy,delete e.maxOccupancy}e.wheelchairPlaces||delete e.wheelchairPlaces;let n=Ge(e);if(n&&e.inventorySegments!==void 0)throw new u("invalid_operation",`Joined area "${e.label}" is sold per person: its places keep the identities of the areas it was joined from, so it cannot become one box`,{gaAreaId:e.id});if(n&&e.capacity>nn)throw new u("invalid_operation",Nr,{gaAreaId:e.id,capacity:e.capacity,max:nn});if(n&&Ae(e.label))throw new u("invalid_operation",`Area label "${e.label}" uses SeatLayer's reserved GA namespace`,{gaAreaId:e.id});if(n==="variable"&&(!Number.isInteger(e.minOccupancy)||!Number.isInteger(e.maxOccupancy)||e.minOccupancy<1||e.maxOccupancy<e.minOccupancy||e.maxOccupancy>e.capacity))throw new u("invalid_operation",`Area "${e.label}" needs whole-number fewest and most guests from 1 to its ${e.capacity}-person capacity`,{gaAreaId:e.id,capacity:e.capacity});if(e.wheelchairPlaces!==void 0&&e.wheelchairPlaces>e.capacity)throw new u("invalid_operation",`Area "${e.label}" has ${e.capacity} places, so at most ${e.capacity} can be wheelchair places`,{gaAreaId:e.id,capacity:e.capacity})}function hi(e,t){let n=t.filter(a=>Ge(a));if(!n.length)return;let o=new Map(t.map(a=>[a.id,a])),r=new Map(n.map(a=>[a.label,a.id]));for(let a of T(e))for(let i of a.objects){let s=i.type==="gaArea"?o.get(i.id)??i:i,c=[];s.type==="row"?c=re(s).map(l=>l.label):s.type==="table"?c=s.bookAsWhole||s.variableOccupancy?[s.label]:be(s).map(l=>l.label):s.type==="booth"?c=[s.label]:s.type==="gaArea"&&(c=le(s));for(let l of c){let d=r.get(l);if(d&&d!==s.id)throw new u("invalid_operation",`Inventory label "${l}" is already in use; an area sold as one box needs a unique label`,{gaAreaId:d,inventoryLabel:l,conflictingObjectId:s.id})}}}var gi=40,bi=160;function ol(e,t){let n=e.normalize("NFKC").trim();if(n.length>gi)throw new u("invalid_operation",`${t} entrance must be at most ${gi} characters`);return n}function dn(e,t){let n={};if("labelStyle"in e){let o=e.labelStyle;if(delete e.labelStyle,o!==void 0){if(o.color!==void 0)throw new u("invalid_operation",`${t} names use the chart's label colour; only visible and size can change`);if(xe(o,t),o.visible!==void 0&&typeof o.visible!="boolean")throw new u("invalid_operation",`${t} name visibility must be true or false`);n.labelStyle=o}}if("entrance"in e){let o=e.entrance;if(delete e.entrance,o===null)n.entrance=null;else if(o!==void 0){if(typeof o!="string")throw new u("invalid_operation",`${t} entrance must be text`);n.entrance=ol(o,t)||null}}return n}function un(e,t){if(t.labelStyle){let o=De(e.labelPresentation,t.labelStyle);o?.visible===!0&&delete o.visible,o&&Object.keys(o).length?e.labelPresentation=o:delete e.labelPresentation}let n=e.entrance;t.entrance===null?delete e.entrance:t.entrance!==void 0&&(e.entrance=t.entrance),e.entrance!==n&&delete e.entranceGateId}function mi(e){if(!("chairNumbering"in e))return;let t=e.chairNumbering;if(delete e.chairNumbering,t===null)return null;let n=dr(t);if(n)throw new u("invalid_operation",n);return t}function pi(e,t){if(t===void 0)return;let n=t===null?void 0:ur({...e.chairNumbering,...t});n?e.chairNumbering=n:delete e.chairNumbering}function yi(e){let t={};if("boothType"in e){let n=e.boothType;if(delete e.boothType,n===null)t.boothType=null;else if(n!==void 0){if(!Er.includes(n))throw new u("invalid_operation","boothType must be inline, corner, peninsula or island");t.boothType=n}}if("commercial"in e){let n=e.commercial;if(delete e.commercial,n===null)t.note=null;else if(n!==void 0){let o=Object.keys(n).filter(r=>r!=="note");if(o.length)throw new u("invalid_operation",`Booth commercial supports only a note (got ${o.join(", ")})`);if(n.note===null)t.note=null;else if(n.note!==void 0){if(typeof n.note!="string")throw new u("invalid_operation","Booth note must be text");let r=n.note.normalize("NFKC").trim();if(r.length>bi)throw new u("invalid_operation",`Booth note supports at most ${bi} characters`);t.note=r||null}}}return t}function wi(e,t){t.boothType===null?delete e.boothType:t.boothType!==void 0&&(e.boothType=t.boothType),t.note===null?delete e.commercial:t.note!==void 0&&(e.commercial={note:t.note})}var rl=[{role:"bar",label:"Bar",icon:"\u{1F378}",kind:"rect",width:160,height:44,fill:"#3a2f4a",blurb:"Drinks counter.",heightM:1.1},{role:"entrance",label:"Entrance",icon:"\u21E5",kind:"rect",width:90,height:30,fill:"#26433a",blurb:"Way in.",heightM:2.7},{role:"exit",label:"Exit",icon:"\u21E4",kind:"rect",width:90,height:30,fill:"#4a2f2f",blurb:"Emergency / way out.",heightM:2.7},{role:"restroom",label:"Restrooms",icon:"\u{1F6BB}",kind:"rect",width:90,height:60,fill:"#2b3550",blurb:"Toilets.",heightM:2.4},{role:"screen",label:"Screen",icon:"\u{1F4FD}\uFE0F",kind:"rect",width:320,height:18,fill:"#203454",blurb:"Projection surface.",heightM:6},{role:"sound",label:"Sound booth",icon:"\u{1F39B}\uFE0F",kind:"rect",width:70,height:50,fill:"#2b2b3a",blurb:"FOH / mixing desk.",heightM:1.45},{role:"concession",label:"Concession",icon:"\u{1F37F}",kind:"rect",width:120,height:44,fill:"#4a3f26",blurb:"Food stand.",heightM:1.1},{role:"coat",label:"Coat check",icon:"\u{1F9E5}",kind:"rect",width:90,height:40,fill:"#2f3a4a",blurb:"Cloakroom.",heightM:1.1},{role:"wall",label:"Wall",icon:"",kind:"rect",width:220,height:14,fill:"#1b2233",blurb:"Structural divider.",heightM:2.8},{role:"rail",label:"Safety rail",icon:"",kind:"rect",width:220,height:7,fill:"#5b6472",blurb:"Guardrail along a tier or balcony edge.",heightM:1.1},{role:"suite",label:"Suite",icon:"\u25C7",kind:"rect",width:180,height:90,fill:"#31394a",blurb:"Open-front hospitality suite.",heightM:3},{role:"obstruction",label:"Obstruction",icon:"\u25CF",kind:"ellipse",width:28,height:28,fill:"#343943",blurb:"Pillar or sightline obstruction.",heightM:4.5}],xi=new Map(rl.map(e=>[e.role,e]));function vt(e){return xi.get(e)}function Si(e,t,n){let o=xi.get(e);if(!o)throw new Error(`unknown d\xE9cor role: ${e}`);let r=o.icon?`${o.icon} ${o.label}`:o.label;return{type:"shape",id:n,kind:o.kind,x:t.x-o.width/2,y:t.y-o.height/2,width:o.width,height:o.height,fill:o.fill,label:o.role==="wall"?void 0:r,role:e,...o.heightM!==void 0?{heightM:o.heightM}:{}}}var Ii=["in","out","both"];function Qn(e){return e?.type==="shape"&&e.gate!=null&&typeof e.gate=="object"}function vi(e){return e?.type==="shape"&&!e.gate&&(e.role==="entrance"||e.role==="exit")&&e.kind!=="line"&&e.kind!=="polyline"}function Xe(e){return e.type==="row"||e.type==="section"||e.type==="table"||e.type==="booth"||e.type==="gaArea"}function Ci(e){return e==="out"?"exit":"entrance"}function il(e){return e.floors?.length?e.floors.flatMap(t=>t.objects):e.objects}function eo(e){let t=new Map;for(let n of il(e))Qn(n)&&t.set(n.id,n);return t}function to(e){if(e.gate.hideFromBuyers)return;let t=e.label?.normalize("NFKC").trim();return t?t.slice(0,40):void 0}function no(e){let t=new Set([...eo(e).values()].map(n=>n.label?.trim().toLowerCase()));for(let n=0;n<26;n++){let o=`Gate ${String.fromCharCode(65+n)}`;if(!t.has(o.toLowerCase()))return o}for(let n=27;;n++)if(!t.has(`gate ${n}`))return`Gate ${n}`}function Oi(e,t,n){let o=t*.46,r=Math.max(e.length,2)*o*.6,a=n?o*1.25:0;return Math.round(r+a+t)}var io={color:Wn.accessibility,width:4},ao="Step-free route";function fn(e,t,n){if(typeof e!="string")throw new u("invalid_operation",`${n} must be text`);let o=e.normalize("NFKC").trim();if(!o)throw new u("invalid_operation",`${n} cannot be empty`);if(o.length>t)throw new u("invalid_operation",`${n} must be at most ${t} characters`);return o}function sl(e){if(!Ii.includes(e))throw new u("invalid_operation","Gate use must be in, out or both")}function ro(e,t){if(typeof e!="boolean")throw new u("invalid_operation",`${t} must be true or false`)}function Ct(e){return T(e).flatMap(t=>t.objects)}function Ri(e,t){let n=eo(e).get(t);if(!n)throw new u("object_not_found",`Unknown gate id: ${t}. Call get_chart to list gate ids.`,{gateId:t});return n}function _i(e){let t=e.height??40,n=Oi(e.label??"",t,e.gate?.stepFree===!0),o=(e.x??0)+(e.width??n)/2;e.x=o-n/2,e.width=n,e.kind==="rect"&&(e.cornerRadius=t/2)}function Li(e,t){e.type!=="row"&&(t?e.entrance=t:delete e.entrance)}var Pi=e=>e.type==="row"?void 0:e.entrance;function cl(e,t){let n=to(t),o=[];for(let r of Ct(e))!Xe(r)||r.entranceGateId!==t.id||(Li(r,n),o.push(r.id));return o}function so(e,t,n){n.name!==void 0&&(e.label=fn(n.name,40,"Gate name")),n.use!==void 0&&(sl(n.use),t.use=n.use),n.stepFree!==void 0&&(ro(n.stepFree,"Step-free"),n.stepFree?t.stepFree=!0:delete t.stepFree),n.opens!==void 0&&(n.opens===null||typeof n.opens=="string"&&!n.opens.trim()?delete t.opens:t.opens=fn(n.opens,40,"Opening time")),n.hideFromBuyers!==void 0&&(ro(n.hideFromBuyers,"Hide from buyers"),n.hideFromBuyers?t.hideFromBuyers=!0:delete t.hideFromBuyers),e.gate=t,e.role=Ci(t.use)}function ki(e,t,n,o=0){let r={type:"shape",id:e,kind:"rect",x:t.x,y:t.y-40/2,width:0,height:40,fill:Wn.navigation,...o?{rotation:o}:{},heightM:vt("entrance")?.heightM??2.7};return so(r,{use:"in"},n),_i(r),r}function ll(e,t){let n=O(e,t.floorId);if(!Number.isFinite(t.center?.x)||!Number.isFinite(t.center?.y))throw new u("invalid_operation","A gate needs a finite centre point");if(t.rotation!==void 0&&(!Number.isFinite(t.rotation)||t.rotation<0||t.rotation>360))throw new u("invalid_operation","Gate rotation must be from 0 to 360");let o=E(e,"gate",t.idFactory,new Set),r=ki(o,t.center,{...t,name:t.name??no(e)},t.rotation??0);return n.objects.push(r),{changed:!0,floorId:n.floorId,gate:structuredClone(r)}}function dl(e,t){let n=Ri(e,t.gateId);if(!Object.keys(t.patch).length)throw new u("invalid_operation","At least one gate change is required");let o=JSON.stringify(n),r=structuredClone(n);so(r,r.gate,t.patch),(t.patch.name!==void 0||t.patch.stepFree!==void 0)&&_i(r);let a=JSON.stringify(r)!==o;a&&Object.assign(n,r);let i=cl(e,n);return{changed:a,gate:structuredClone(n),servedObjectIds:i}}function ul(e,t){let n=Ct(e).find(a=>a.id===t.shapeId);if(!n)throw new u("object_not_found",`Unknown shape id: ${t.shapeId}`,{shapeId:t.shapeId});if(n.type!=="shape"||!vi(n))throw new u("invalid_operation","Only an Entrance or Exit landmark can become a gate");let o=n.label?.replace(/^[^\p{L}\p{N}]+/u,"").trim(),r=!o||/^(entrance|exit)$/i.test(o);return so(n,{use:n.role==="exit"?"out":"in"},{...t,name:t.name??(r?no(e):o.slice(0,40))}),{changed:!0,gate:structuredClone(n)}}function fl(e,t){if(!t.objectIds.length)throw new u("invalid_operation","At least one object id is required");let n=Ct(e),o=new Map(n.map(f=>[f.id,f])),r=t.objectIds.filter(f=>!o.has(f));if(r.length)throw new u("object_not_found",`Unknown object id(s): ${r.join(", ")}`,{objectIds:r});let a=t.objectIds.filter(f=>!Xe(o.get(f)));if(a.length)throw new u("invalid_operation","Only sections, rows, tables, booths and standing areas have an entrance",{objectIds:a});let i=t.gateId===null?null:Ri(e,t.gateId),s=new Set(t.objectIds.flatMap(f=>{let g=o.get(f);return g.type==="section"?[g.logicalSectionId??g.id]:[]})),c=n.filter(f=>Xe(f)&&(t.objectIds.includes(f.id)||f.type==="section"&&s.has(f.logicalSectionId??f.id))),l=i?to(i):void 0,d=!1;for(let f of c){let g=`${f.entranceGateId??""}|${Pi(f)??""}`;i?f.entranceGateId=i.id:delete f.entranceGateId,Li(f,l),`${f.entranceGateId??""}|${Pi(f)??""}`!==g&&(d=!0)}return{changed:d,objectIds:c.map(f=>f.id)}}function co(e,t){let n=new Map(t.filter(Qn).map(r=>[r.id,r.label?.trim()??""]));if(!n.size)return[];let o=[];for(let r of Ct(e))!Xe(r)||!r.entranceGateId||!n.has(r.entranceGateId)||(r.type!=="row"&&r.entrance?.trim()===n.get(r.entranceGateId)&&delete r.entrance,delete r.entranceGateId,o.push(r.id));return o}function hl(e,t){for(let n of e){if(!Xe(n)||!n.entranceGateId)continue;let o=t.get(n.entranceGateId);o&&(n.entranceGateId=o)}}function Ei(e,t,n=ao,o=!0){return{type:"shape",id:e,kind:t.length===2?"line":"polyline",label:fn(n,40,"Route name"),points:t.map(r=>({x:r.x,y:r.y})),stroke:{...io},lineCap:"round",lineJoin:"round",endEnding:"arrow",route:o?{stepFree:!0}:{}}}function gl(e,t){let n=O(e,t.floorId);if(!Array.isArray(t.points)||t.points.length<2||t.points.length>200||t.points.some(r=>!Number.isFinite(r?.x)||!Number.isFinite(r?.y)))throw new u("invalid_operation","A route needs 2 to 200 finite points");let o=Ei(E(e,"route",t.idFactory,new Set),t.points,t.name,t.stepFree??!0);return n.objects.push(o),{changed:!0,floorId:n.floorId,route:structuredClone(o)}}function bl(e,t){let n=Ct(e).find(r=>r.type==="shape"&&r.id===t.shapeId);if(!n)throw new u("object_not_found",`Unknown shape id: ${t.shapeId}`,{shapeId:t.shapeId});if(n.kind!=="line"&&n.kind!=="polyline")throw new u("invalid_operation","Only a line or path can be a route");let o=JSON.stringify(n);if(t.route===null)delete n.route;else{let r={...n.route??{}};t.route.stepFree!==void 0?(ro(t.route.stepFree,"Step-free"),t.route.stepFree?r.stepFree=!0:delete r.stepFree):n.route||(r.stepFree=!0),t.route.name!==void 0?n.label=fn(t.route.name,40,"Route name"):n.label?.trim()||(n.label=ao),n.route||(n.stroke={...io}),n.route=r}return{changed:JSON.stringify(n)!==o,shape:structuredClone(n)}}function Cl(e,t){let n=O(e,t.floorId),o=[...new Set(t.tableIds)];if(!o.length)throw new u("invalid_operation","At least one table id is required");let r=o.map(S=>n.objects.find(m=>m.type==="table"&&m.id===S)),a=o.filter((S,m)=>!r[m]);if(a.length)throw new u("object_not_found",`Unknown table id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current table ids.`,{tableIds:a});let i=structuredClone(t.patch);if(!Object.keys(i).length)throw new u("invalid_operation","At least one table change is required");if(i.label!==void 0){if(i.label=i.label.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","label can be changed only for one table at a time");if(!i.label||i.label.length>80)throw new u("invalid_operation","Table labels must contain 1 to 80 characters")}i.categoryKey!==void 0&&D(e,i.categoryKey),i.fill!==void 0&&i.fill!==null&&(i.fill=N(i.fill,"Table surface color"));let s=i.seatCount!==void 0,c=i.seatCountsBySide!==void 0;if(c){if(i.sides!==void 0)throw new u("invalid_operation","Use seatCountsBySide for exact rectangular counts; do not also supply legacy sides");if(i.shape==="round")throw new u("invalid_operation","seatCountsBySide can be used only with rectangular tables");let S=["top","bottom","left","right"],m=Object.keys(i.seatCountsBySide);if(m.length!==S.length||m.some(C=>!S.includes(C)))throw new u("invalid_operation","seatCountsBySide must contain exactly top, bottom, left, and right");for(let C of S){let P=i.seatCountsBySide[C];if(!Number.isInteger(P)||P<0||P>40)throw new u("invalid_operation",`seatCountsBySide.${C} must be a whole number from 0 to 40`)}let v=S.reduce((C,P)=>C+i.seatCountsBySide[P],0);if(v<1||v>40)throw new u("invalid_operation","Rectangular table side counts must total from 1 to 40 chairs");if(s&&i.seatCount!==v)throw new u("invalid_operation",`seatCount must equal the ${v}-chair seatCountsBySide total`);i.seatCount=v,i.sides=S.filter(C=>i.seatCountsBySide[C]>0)}if(i.seatCount!==void 0&&(!Number.isInteger(i.seatCount)||i.seatCount<1||i.seatCount>40))throw new u("invalid_operation","seatCount must be an integer from 1 to 40");if(i.shape!==void 0&&i.shape!=="round"&&i.shape!=="rect")throw new u("invalid_operation","Table shape must be round or rect");if(i.automaticRadius!==void 0&&typeof i.automaticRadius!="boolean")throw new u("invalid_operation","automaticRadius must be true or false");if(i.shape==="rect"&&i.automaticRadius===!0)throw new u("invalid_operation","Automatic radius can be used only with round tables");if(i.bookAsWhole===!0&&i.variableOccupancy===!0)throw new u("invalid_operation","A table cannot use whole-table and variable-occupancy selling at the same time");if(i.variableOccupancy===!1&&(i.minOccupancy!==void 0||i.maxOccupancy!==void 0))throw new u("invalid_operation","Guest bounds can be supplied only with variable-occupancy selling");let l=(S,m,v,C)=>{if(m!==void 0&&(!Number.isFinite(m)||m<v||m>C))throw new u("invalid_operation",`${String(S)} must be from ${v} to ${C}`)};if(l("rotation",i.rotation,0,360),l("radius",i.radius,24,160),l("seatArc",i.seatArc,120,360),l("width",i.width,40,320),l("height",i.height,30,240),i.minOccupancy!==void 0&&(!Number.isInteger(i.minOccupancy)||i.minOccupancy<1||i.minOccupancy>40))throw new u("invalid_operation","minOccupancy must be a whole number from 1 to 40");if(i.maxOccupancy!==void 0&&(!Number.isInteger(i.maxOccupancy)||i.maxOccupancy<1||i.maxOccupancy>40))throw new u("invalid_operation","maxOccupancy must be a whole number from 1 to 40");if(i.sides!==void 0){let S=new Set(["top","bottom","left","right"]);if(!i.sides.length||i.sides.length>4||new Set(i.sides).size!==i.sides.length||i.sides.some(m=>!S.has(m)))throw new u("invalid_operation","Table sides must contain one to four unique perimeter sides")}let d=Ne(i,"Table"),f=Wt(i,"Table"),g=dn(i,"Table"),h=mi(i),b=r.map(S=>{if(S.seatCountsBySide&&!c&&(s||t.patch.sides!==void 0))throw new u("invalid_operation",`Table "${S.label}" has exact per-side counts; update seatCountsBySide instead of aggregate seatCount or legacy sides`,{tableId:S.id});let m=structuredClone(S);if(Object.assign(m,i),un(m,g),pi(m,h),i.fill===null&&delete m.fill,m.shape==="round")delete m.seatCountsBySide,m.automaticRadius===!0?m.radius=_r(m.seatCount,m.seatArc):delete m.automaticRadius;else{if(i.automaticRadius===!0)throw new u("invalid_operation",`Table "${m.label}" is rectangular and cannot use automatic radius`,{tableId:m.id});delete m.automaticRadius}if(m.overrides&&i.seatCount!==void 0&&(m.overrides=m.overrides.filter(v=>v.index<m.seatCount),m.overrides.length||delete m.overrides),i.bookAsWhole===!1&&delete m.bookAsWhole,i.variableOccupancy===!1&&(delete m.variableOccupancy,delete m.minOccupancy,delete m.maxOccupancy),m.bookAsWhole||delete m.bookAsWhole,m.variableOccupancy||delete m.variableOccupancy,m.bookAsWhole&&m.variableOccupancy)throw new u("invalid_operation",`Table "${m.label}" cannot use whole-table and variable-occupancy selling at the same time`,{tableId:m.id});if((m.bookAsWhole||m.variableOccupancy)&&m.overrides?.length)throw new u("invalid_operation",`Table "${m.label}" has individual-chair overrides; reset them before choosing grouped table selling`,{tableId:m.id,overriddenChairIndices:m.overrides.map(v=>v.index)});if(m.bookAsWhole)delete m.minOccupancy,delete m.maxOccupancy;else if(m.variableOccupancy){if(!Number.isInteger(m.minOccupancy)||!Number.isInteger(m.maxOccupancy)||m.minOccupancy<1||m.maxOccupancy<m.minOccupancy||m.maxOccupancy>m.seatCount)throw new u("invalid_operation",`Table "${m.label}" needs whole-number minimum and maximum guests from 1 to its ${m.seatCount}-chair capacity`,{tableId:m.id,seatCount:m.seatCount})}else{if(i.minOccupancy!==void 0||i.maxOccupancy!==void 0)throw new u("invalid_operation","Guest bounds can be changed only on a variable-occupancy table",{tableId:m.id});delete m.minOccupancy,delete m.maxOccupancy}if(f&&delete m.displayType,d&&delete m.displayLabel,m.shape==="rect"){if(m.width??=80,m.height??=50,m.seatCountsBySide){let v=["top","bottom","left","right"],C=v.reduce((P,j)=>P+m.seatCountsBySide[j],0);if(C!==m.seatCount)throw new u("invalid_operation",`Table "${m.label}" side counts total ${C}, but seatCount is ${m.seatCount}`,{tableId:m.id,seatCount:m.seatCount,seatCountsBySide:m.seatCountsBySide});m.sides=v.filter(P=>m.seatCountsBySide[P]>0)}}else m.radius??=40;if((m.bookAsWhole||m.variableOccupancy)&&Ae(m.label))throw new u("invalid_operation",`Grouped table label "${m.label}" uses SeatLayer's reserved GA namespace`,{tableId:m.id});return m}),p=new Map(b.map(S=>[S.id,S])),x=new Set(o),I=new Map;for(let S of T(e))for(let m of S.objects){let v=m.type==="table"?p.get(m.id)??m:m,C=[];v.type==="row"?C=re(v).map(P=>P.label):v.type==="table"?C=v.bookAsWhole||v.variableOccupancy?[v.label]:be(v).map(P=>P.label):v.type==="booth"?C=[v.label]:v.type==="gaArea"&&(C=le(v));for(let P of C){let j=I.get(P);if(j&&(x.has(j)||x.has(v.id)))throw new u("invalid_operation",`Inventory label "${P}" is already in use; grouped table labels must be unique`,{tableIds:o,inventoryLabel:P,conflictingObjectIds:[j,v.id]});I.set(P,j??v.id)}}let y=!1,w=["bookAsWhole","variableOccupancy","minOccupancy","maxOccupancy","displayLabel","displayType","fill","seatCountsBySide","overrides","automaticRadius","chairNumbering","labelPresentation","entrance"];for(let[S,m]of r.entries()){let v=b[S],C=JSON.stringify(m);for(let P of w)P in v||delete m[P];Object.assign(m,v),JSON.stringify(m)!==C&&(y=!0)}return{floorId:n.floorId,changed:y,tableIds:o}}function Ol(e,t){let n=O(e,t.floorId),o=[...new Set(t.boothIds)];if(!o.length)throw new u("invalid_operation","At least one booth id is required");let r=o.map(p=>n.objects.find(x=>x.type==="booth"&&x.id===p)),a=o.filter((p,x)=>!r[x]);if(a.length)throw new u("object_not_found",`Unknown booth id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current booth ids.`,{boothIds:a});let i=structuredClone(t.patch);if(!Object.keys(i).length)throw new u("invalid_operation","At least one booth change is required");if(i.label!==void 0){if(i.label=i.label.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","label can be changed only for one booth at a time");if(!i.label||i.label.length>80)throw new u("invalid_operation","Booth labels must contain 1 to 80 characters")}i.categoryKey!==void 0&&D(e,i.categoryKey);let s=(p,x,I,y)=>{if(x!==void 0&&(!Number.isFinite(x)||x<I||x>y))throw new u("invalid_operation",`${p} must be from ${I} to ${y}`)};s("width",i.width,30,400),s("height",i.height,30,400),s("rotation",i.rotation,0,360);let c=i.points===null;if(i.points!=null){if(o.length!==1)throw new u("invalid_operation","points can be changed only for one booth at a time");let p=nr(i.points);if(!p.ok)throw new u("invalid_operation",p.message??"The booth outline is not a valid simple polygon")}let l=i.points!=null?i.points.map(p=>({x:p.x,y:p.y})):void 0;delete i.points;let d=Ne(i,"Booth"),f=Wt(i,"Booth"),g=dn(i,"Booth"),h=yi(i),b=!1;for(let p of r){let x=JSON.stringify(p);Object.assign(p,i),un(p,g),wi(p,h),d&&delete p.displayLabel,f&&delete p.displayType,c?delete p.points:l&&(p.points=l),JSON.stringify(p)!==x&&(b=!0)}return{floorId:n.floorId,changed:b,boothIds:o}}function Pl(e,t){let n=O(e,t.floorId),o=[...new Set(t.gaAreaIds)];if(!o.length)throw new u("invalid_operation","At least one GA area id is required");let r=o.map(h=>n.objects.find(b=>b.type==="gaArea"&&b.id===h)),a=o.filter((h,b)=>!r[b]);if(a.length)throw new u("object_not_found","One or more GA area ids do not exist on the selected floor",{gaAreaIds:a});let i=structuredClone(t.patch);if(!Object.keys(i).length)throw new u("invalid_operation","At least one GA area change is required");if(i.label!==void 0){if(i.label=i.label.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","label can be changed only for one GA area at a time");if(!i.label||i.label.length>80)throw new u("invalid_operation","GA area labels must contain 1 to 80 characters")}if(i.categoryKey!==void 0&&D(e,i.categoryKey),i.capacity!==void 0&&(!Number.isInteger(i.capacity)||i.capacity<1||i.capacity>te))throw new u("invalid_operation",`capacity must be an integer from 1 to ${te}`);if(i.cornerRadius!==void 0&&(!Number.isFinite(i.cornerRadius)||i.cornerRadius<0||i.cornerRadius>2e3))throw new u("invalid_operation","cornerRadius must be from 0 to 2000");let s=Ne(i,"GA area"),c=Wt(i,"GA area"),l=dn(i,"GA area"),d=ui(i);if(i.capacity!==void 0)for(let h of r){if(h.inventorySegments!==void 0&&i.capacity<h.capacity)throw new u("invalid_operation",`Joined GA area "${h.label}" cannot be reduced below ${h.capacity}; shrinking would delete stable inventory identities. Create or split a new surface instead.`,{gaAreaId:h.id,currentCapacity:h.capacity,requestedCapacity:i.capacity});if(h.inventorySegments!==void 0&&i.capacity>h.capacity&&qn(h,i.capacity)===void 0)throw new u("invalid_operation",`Joined GA area "${h.label}" cannot append that capacity safely`,{gaAreaId:h.id})}let f=r.map(h=>{let b=structuredClone(h),p=i.capacity===void 0?h.inventorySegments:qn(h,i.capacity);return Object.assign(b,i),un(b,l),fi(b,d),p!==void 0&&(b.inventorySegments=p),s&&delete b.displayLabel,c&&delete b.displayType,b});hi(e,f);let g=!1;for(let[h,b]of r.entries()){let p=f[h],x=JSON.stringify(b);for(let I of Object.keys(b))I in p||delete b[I];Object.assign(b,p),JSON.stringify(b)!==x&&(g=!0)}return{floorId:n.floorId,changed:g,gaAreaIds:o}}function uo(e,t){if(t.length<3)return 0;let n=r=>J(r,t,void 0),o=0;for(let r of e)n(H(r))&&(r.type==="row"?o+=re(r).length:r.type==="table"?o+=be(r).length:(r.type==="gaArea"||r.type==="booth")&&(o+=Oe(r)));return o}function Al(e,t){let n=O(e,t.floorId);if(!t.objectIds.length)throw new u("invalid_operation","At least one chart object id is required");if(new Set(t.objectIds).size!==t.objectIds.length)throw new u("invalid_operation","Chart object ids must be unique");let o=t.objectIds.map(s=>n.objects.find(c=>c.id===s)),r=t.objectIds.filter((s,c)=>!o[c]);if(r.length)throw new u("object_not_found","One or more chart object ids do not exist on the selected floor",{objectIds:r});let a=o,i=new Set(t.objectIds);for(let s=n.objects.length-1;s>=0;s--)i.has(n.objects[s].id)&&n.objects.splice(s,1);return co(e,a),{floorId:n.floorId,changed:!0,removedObjects:a.map(s=>({id:s.id,type:s.type})),removedInventory:a.reduce((s,c)=>s+Oe(c),0),remainingObjectCount:n.objects.length}}function Ml(e,t){let n=O(e,t.floorId),o=[...new Set(t.textIds)];if(!o.length)throw new u("invalid_operation","At least one text id is required");let r=o.map(l=>n.objects.find(d=>d.type==="text"&&d.id===l)),a=o.filter((l,d)=>!r[d]);if(a.length)throw new u("object_not_found",`Unknown text id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current text ids.`,{textIds:a});let i=structuredClone(t.patch);if(!Object.keys(i).length)throw new u("invalid_operation","At least one text change is required");if(i.text!==void 0){if(i.text=i.text.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","content can be changed only for one text object at a time");if(!i.text||i.text.length>240)throw new u("invalid_operation","Text content must contain 1 to 240 characters")}if(i.fontSize!==void 0&&(!Number.isFinite(i.fontSize)||i.fontSize<8||i.fontSize>72))throw new u("invalid_operation","Text fontSize must be from 8 to 72");if(i.fontFamily!==void 0&&i.fontFamily!==null&&(i.fontFamily=i.fontFamily.normalize("NFKC").trim(),!i.fontFamily||i.fontFamily.length>120))throw new u("invalid_operation","Text fontFamily must contain 1 to 120 characters");if(i.rotation!==void 0&&(!Number.isFinite(i.rotation)||i.rotation<0||i.rotation>360))throw new u("invalid_operation","Text rotation must be from 0 to 360");if(i.color!==void 0&&i.color!==null&&(i.color=N(i.color,"Text color")),i.bold!==void 0&&typeof i.bold!="boolean")throw new u("invalid_operation","Text bold must be a boolean");if(i.italic!==void 0&&typeof i.italic!="boolean")throw new u("invalid_operation","Text italic must be a boolean");if(i.width!==void 0&&i.width!==null&&(!Number.isFinite(i.width)||i.width<40||i.width>1200))throw new u("invalid_operation",`Text width must be from ${40} to ${1200}`);if(i.align!==void 0&&!["left","center","right"].includes(i.align))throw new u("invalid_operation","Text align must be left, center, or right");if(i.lineHeight!==void 0&&(!Number.isFinite(i.lineHeight)||i.lineHeight<.8||i.lineHeight>3))throw new u("invalid_operation",`Text lineHeight must be from ${.8} to ${3}`);if(i.letterSpacing!==void 0&&(!Number.isFinite(i.letterSpacing)||i.letterSpacing<-2||i.letterSpacing>20))throw new u("invalid_operation",`Text letterSpacing must be from ${-2} to ${20}`);if(i.underline!==void 0&&typeof i.underline!="boolean")throw new u("invalid_operation","Text underline must be a boolean");if(i.opacity!==void 0&&(!Number.isFinite(i.opacity)||i.opacity<.1||i.opacity>1))throw new u("invalid_operation",`Text opacity must be from ${.1} to 1`);if(i.background!==void 0&&i.background!==null){i.background.color=N(i.background.color,"Text background color");let{padding:l=6,cornerRadius:d=4,opacity:f=.9}=i.background;if(!Number.isFinite(l)||l<0||l>40)throw new u("invalid_operation",`Text background padding must be from 0 to ${40}`);if(!Number.isFinite(d)||d<0||d>40)throw new u("invalid_operation",`Text background cornerRadius must be from 0 to ${40}`);if(!Number.isFinite(f)||f<.1||f>1)throw new u("invalid_operation",`Text background opacity must be from ${.1} to 1`)}if(["width","align","lineHeight","letterSpacing","underline","opacity","background"].some(l=>Object.prototype.hasOwnProperty.call(i,l))&&r.some(l=>l.semanticKind==="icon"))throw new u("invalid_operation","Text layout fields cannot be applied to venue icons");if(i.labelImportance!==void 0&&i.labelImportance!==null&&i.labelImportance!=="orientation"&&i.labelImportance!=="detail")throw new u("invalid_operation","Text labelImportance must be 'orientation', 'detail' or null");if(i.iconKey!==void 0){if(!ci(i.iconKey))throw new u("invalid_operation","iconKey must be a known venue-icon registry key");if(r.some(l=>l.semanticKind!=="icon"))throw new u("invalid_operation",'iconKey can be set only on venue-icon objects (semanticKind "icon")')}let c=!1;for(let l of r){let d=JSON.stringify(l);i.iconKey!==void 0&&(l.iconKey=i.iconKey),i.text!==void 0&&(l.text=i.text),i.fontSize!==void 0&&(l.fontSize=i.fontSize),i.fontFamily===null?delete l.fontFamily:i.fontFamily!==void 0&&(l.fontFamily=i.fontFamily),i.rotation!==void 0&&(l.rotation=i.rotation),i.color===null?delete l.color:i.color!==void 0&&(l.color=i.color),i.bold!==void 0&&(i.bold?l.bold=!0:delete l.bold),i.italic!==void 0&&(i.italic?l.italic=!0:delete l.italic),i.width===null?delete l.width:i.width!==void 0&&(l.width=i.width),i.align!==void 0&&(i.align==="left"?delete l.align:l.align=i.align),i.lineHeight!==void 0&&(i.lineHeight===1.2?delete l.lineHeight:l.lineHeight=i.lineHeight),i.letterSpacing!==void 0&&(i.letterSpacing===0?delete l.letterSpacing:l.letterSpacing=i.letterSpacing),i.underline!==void 0&&(i.underline?l.underline=!0:delete l.underline),i.opacity!==void 0&&(i.opacity===1?delete l.opacity:l.opacity=i.opacity),i.background===null?delete l.background:i.background!==void 0&&(l.background=i.background),i.labelImportance===null?delete l.labelImportance:i.labelImportance!==void 0&&(l.labelImportance=i.labelImportance),JSON.stringify(l)!==d&&(ht(l),c=!0)}return{floorId:n.floorId,changed:c,textIds:o}}function Rl(e,t){let n=O(e,t.floorId),o=[...new Set(t.rowIds)],r=o.map(g=>n.objects.find(h=>h.type==="row"&&h.id===g)),a=o.filter((g,h)=>!r[h]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let i=r.slice().sort((g,h)=>g.origin.y-h.origin.y||g.origin.x-h.origin.x),s=g=>g.segmentedRow?.displayLabel??g.displayLabel??g.label,c=cr(i.map(g=>({label:s(g)})),t.options),l=t.displayType==null?void 0:t.displayType.normalize("NFKC").replace(/\s+/g," ").trim().slice(0,24),d=l===void 0||l===""||l==="Row"?t.displayType===void 0?void 0:null:l,f=!1;return i.forEach((g,h)=>{let b=c[h].label.normalize("NFKC").replace(/\s+/g," ").trim();if(s(g)!==b&&(f=!0,g.segmentedRow?g.segmentedRow.displayLabel=b:g.displayLabel=b),d!==void 0){if(d===null){g.displayType!==void 0&&(f=!0,delete g.displayType);return}g.displayType!==d&&(f=!0,g.displayType=d)}}),{floorId:n.floorId,changed:f,rows:i.map(g=>({id:g.id,displayLabel:s(g),...g.displayType?{displayType:g.displayType}:{}}))}}function _l(e,t){let n=Gr.find(d=>d.key===t.blockKey);if(!n)throw new u("invalid_operation",`Unknown seating block: ${t.blockKey}`,{blockKey:t.blockKey});let o=t.rotation??0;if(!Number.isFinite(o))throw new u("invalid_operation","Block rotation must be a finite number of degrees");let r=O(e,t.floorId),a=new Set,i=n.build().map(d=>structuredClone(d));for(let d of i)d.id=E(e,d.type,t.idFactory,a),Ve(d,t.center.x,t.center.y),o%360&&li(d,t.center,o);for(let d of n.categories)e.categories.some(f=>f.key===d.key)||e.categories.push({...d});let s=i.filter(d=>d.type==="row");if(s.length){let d=0;for(let f of r.objects){if(f.type!=="row")continue;let g=on(f.label);g!=null&&(d=Math.max(d,g+1))}for(let f of s)f.label=B(d++)}let c=new Set(r.objects.flatMap(d=>"label"in d&&d.label?[d.label]:[]));for(let d of i){if((d.type==="table"||d.type==="booth")&&c.has(d.label)){let f=/^(.*?)(\d+)$/.exec(d.label),g=f?f[1]:`${d.label} `,h=f?Number.parseInt(f[2],10):1;do h++;while(c.has(`${g}${h}`));d.label=`${g}${h}`}"label"in d&&d.label&&c.add(d.label)}r.objects.push(...i);let l=null;if(n.sectionLabel&&t.wrapInSection!==!1){let d=Ce(i);if(d){let f={type:"section",id:E(e,"sec",t.idFactory,a),label:n.sectionLabel,outline:d};r.objects.push(f),l=f.id}}return{floorId:r.floorId,blockKey:n.key,createdIds:[...i.map(d=>d.id),...l?[l]:[]],sectionId:l}}function Ll(e){let t=structuredClone(e);if([t.start,t.control1,t.control2,t.end].some(a=>!Number.isFinite(a.x)||!Number.isFinite(a.y)))throw new u("invalid_operation","Exact row path points must be finite");let o=Nt(t,97),r=o.slice(1).reduce((a,i,s)=>a+Math.hypot(i.x-o[s].x,i.y-o[s].y),0);if(!Number.isFinite(r)||r<1)throw new u("invalid_operation","Exact row path must have at least one chart unit of usable length");return{path:t,length:r}}function Fi(e,t){let n=O(e,t.floorId),o=n.objects.find(d=>d.type==="row"&&d.id===t.rowId);if(!o)throw new u("object_not_found",`Unknown row id: ${t.rowId}`,{rowId:t.rowId});let r=Ll(t.path),a=re(o),i=structuredClone(o);i.path=r.path,i.origin={...r.path.start};let s=re(i),c=a.map((d,f)=>Math.hypot(d.x-s[f].x,d.y-s[f].y)),l=JSON.stringify(o.path)!==JSON.stringify(r.path)||o.origin.x!==r.path.start.x||o.origin.y!==r.path.start.y;return{floorId:n.floorId,rowId:o.id,seatCount:o.seatCount,pathLength:r.length,averageSeatMovement:c.length?c.reduce((d,f)=>d+f,0)/c.length:0,maxSeatMovement:c.length?Math.max(...c):0,convertingFromParametric:!o.path,changed:l,preservesStableId:!0,preservesSeatMetadata:!0,preservesInventoryUnits:o.seatCount}}function kl(e,t){let n=Fi(e,t);if(!n.changed)return n;let r=O(e,n.floorId).objects.find(a=>a.type==="row"&&a.id===n.rowId);return r.path=structuredClone(t.path),r.origin={...t.path.start},delete r.arcFanGeneration,delete r.rowBlockGeneration,n}function El(e,t){let n=e.map((o,r)=>[...o,t[r]]);for(let o=0;o<3;o++){let r=o;for(let i=o+1;i<3;i++)Math.abs(n[i][o])>Math.abs(n[r][o])&&(r=i);if(Math.abs(n[r][o])<1e-9)return null;[n[o],n[r]]=[n[r],n[o]];let a=n[o][o];for(let i=o;i<4;i++)n[o][i]/=a;for(let i=0;i<3;i++){if(i===o)continue;let s=n[i][o];for(let c=o;c<4;c++)n[i][c]-=s*n[o][c]}}return[n[0][3],n[1][3],n[2][3]]}function Tl(e){if(e.length<3)return null;let t=[[0,0,0],[0,0,0],[0,0,0]],n=[0,0,0];for(let r of e){if(!Number.isFinite(r.x)||!Number.isFinite(r.y))return null;let a=[2*r.x,2*r.y,1],i=r.x**2+r.y**2;for(let s=0;s<3;s++){n[s]+=a[s]*i;for(let c=0;c<3;c++)t[s][c]+=a[s]*a[c]}}let o=El(t,n);return o?{x:o[0],y:o[1]}:null}function Ti(e){let t=((e+180)%360+360)%360-180;return t===-180&&(t=180),t}function Ni(e,t){let n=O(e,t.floorId),o=n.objects.find(h=>h.type==="section"&&h.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});let r=t.strength??100;if(!Number.isFinite(r)||r<0||r>100)throw new u("invalid_operation","Section row-fit strength must be from 0 to 100");let a=T(e).find(h=>h.id===n.floorId),i=t.mode==="outline"?Tl(o.outline):t.focalPoint??a.focalPoint??e.focalPoint;if(!i||!Number.isFinite(i.x)||!Number.isFinite(i.y))throw new u("invalid_operation",`Section ${t.mode} fit has no finite center`);let s=n.objects.filter(h=>h.type==="row"&&J(H(h),o.outline,o.holes)),c=s.filter(h=>!!h.path).map(h=>h.id),l=[],d=[],f=r/100;for(let h of s){if(h.path)continue;if(h.seatCount<2){l.push(h.id);continue}let b=Math.hypot(h.origin.x-i.x,h.origin.y-i.y);if(b<=h.seatSpacing/2+1e-6){l.push(h.id);continue}let p=2*Math.asin(h.seatSpacing/(2*b))/pe,x=re(h),I=Math.atan2(h.origin.x-i.x,h.origin.y-i.y)/pe,w=(h.curve!==0?Math.sign(h.curve):x.length>1&&Math.sign(Ti(Math.atan2(x[1].x-i.x,x[1].y-i.y)/pe-I))||1)*p*(h.seatCount-1);if(Math.abs(w)>320){l.push(h.id);continue}let S=-I,m=h.curve+(w-h.curve)*f,v=h.rotation+Ti(S-h.rotation)*f,C={...h,curve:m,rotation:v},j=re(C).map((q,Y)=>Math.hypot(q.x-x[Y].x,q.y-x[Y].y));d.push({rowId:h.id,fromCurve:h.curve,targetCurve:w,resultCurve:m,fromRotation:h.rotation,resultRotation:v,rmsMovement:Math.sqrt(j.reduce((q,Y)=>q+Y**2,0)/j.length),maxMovement:Math.max(...j)})}let g=d.map(h=>h.rmsMovement);return{floorId:n.floorId,sectionId:o.id,mode:t.mode,fitCenter:{...i},strength:r,rows:d,skippedPathRowIds:c,skippedInvalidRowIds:l,averageMovement:g.length?g.reduce((h,b)=>h+b,0)/g.length:0,maxMovement:d.length?Math.max(...d.map(h=>h.maxMovement)):0}}function jl(e,t){let n=Ni(e,t),o=O(e,n.floorId),r=o.objects.find(i=>i.type==="section"&&i.id===n.sectionId),a=!1;for(let i of n.rows){let s=o.objects.find(c=>c.type==="row"&&c.id===i.rowId);(s.curve!==i.resultCurve||s.rotation!==i.resultRotation)&&(s.curve=i.resultCurve,s.rotation=i.resultRotation,delete s.arcFanGeneration,delete s.rowBlockGeneration,a=!0)}return(r.smoothing??0)!==n.strength&&(r.smoothing=n.strength,a=!0),{...n,changed:a}}function Di(e,t,n,o){let r=ce(e,t,n),a=ce(e,t,o),i=ce(n,o,e),s=ce(n,o,t);return r*a<-1e-9&&i*s<-1e-9}function ji(e,t){return e.some((n,o)=>{let r=e[(o+1)%e.length];return t.some((a,i)=>Di(n,r,a,t[(i+1)%t.length]))})}function Fl(e){if(e.length<3||e.length>256||Math.abs(ot(e))<1||e.some(t=>!Number.isFinite(t.x)||!Number.isFinite(t.y)))return!1;for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++)if(!(n===t+1||t===0&&n===e.length-1)&&Di(e[t],e[(t+1)%e.length],e[n],e[(n+1)%e.length]))return!1;return!0}function hn(e,t,n){let o=O(e,t),r=o.objects.find(i=>(i.type==="section"||i.type==="gaArea"||i.type==="shape"&&i.kind==="polygon")&&i.id===n);if(!r)throw new u("object_not_found",`Unknown polygon object id: ${n}`,{objectId:n});let a=r.type==="section"?r.outline:r.type==="shape"?ct(r):r.points;return{target:o,object:r,outer:a}}function Gi(e,t,n){return t.type==="shape"?{ids:[],units:0}:{ids:e.objects.filter(r=>r.id!==t.id&&r.type!=="section"&&J(H(r),n,void 0)).map(r=>r.id),units:uo(e.objects.filter(r=>r.id!==t.id),n)}}function gn(e,t){let{target:n,object:o,outer:r}=hn(e,t.floorId,t.objectId),a=structuredClone(t.points);if(!Fl(a))throw new u("invalid_operation","Opening must be a finite, non-self-intersecting shape with 3\u2013256 corners");if(a.some(l=>!J(l,r,void 0)))throw new u("invalid_operation","Every opening corner must stay inside the outer boundary");if(ji(a,r))throw new u("invalid_operation","Opening edges cannot cross the outer boundary");let i=o.holes??[],s=t.holeIndex??i.length;if(o.type==="shape"&&t.holeIndex==null&&i.length>=jn)throw new u("invalid_operation",`A shape holds at most ${jn} cut-outs`);if(!Number.isInteger(s)||s<0||s>i.length||t.holeIndex!=null&&s>=i.length)throw new u("invalid_operation","Opening not found");for(let l=0;l<i.length;l++){if(l===t.holeIndex)continue;let d=i[l];if(ji(a,d)||J(a[0],d,void 0)||J(d[0],a,void 0))throw new u("invalid_operation","Openings cannot overlap or contain one another")}let c=Gi(n,o,a);return{floorId:n.floorId,objectId:o.id,objectType:o.type,holeIndex:s,vertexCount:a.length,excludedObjectIds:c.ids,excludedInventoryUnits:c.units,preservesExactOuterPath:o.type==="section"&&!!o.outlinePath}}function Nl(e,t){let n=gn(e,t),{object:o}=hn(e,n.floorId,n.objectId);return o.holes??=[],t.holeIndex==null?o.holes.push(structuredClone(t.points)):o.holes[t.holeIndex]=structuredClone(t.points),{...n,changed:!0}}function $i(e,t){let{target:n,object:o}=hn(e,t.floorId,t.objectId);if(!Number.isInteger(t.holeIndex)||t.holeIndex<0||t.holeIndex>=(o.holes?.length??0))throw new u("invalid_operation","Opening not found");let r=o.holes[t.holeIndex],a=Gi(n,o,r);return{floorId:n.floorId,objectId:o.id,objectType:o.type,holeIndex:t.holeIndex,vertexCount:r.length,excludedObjectIds:a.ids,excludedInventoryUnits:a.units,preservesExactOuterPath:o.type==="section"&&!!o.outlinePath}}function Dl(e,t){let n=$i(e,t),{object:o}=hn(e,n.floorId,n.objectId);return o.holes.splice(t.holeIndex,1),o.holes.length||delete o.holes,{...n,changed:!0}}function Gl(e){let t=ye(e);if(!t)throw new u("invalid_operation","Section view photo must be a safe HTTPS or base64 raster image reference");return t}function Bi(e,t){let n=[...new Set(t)];if(!n.length)throw new u("invalid_operation","At least one section id is required");let o=n.map(i=>e.find(s=>s.type==="section"&&s.id===i)),r=n.filter((i,s)=>!o[s]);if(r.length)throw new u("object_not_found",`Unknown section id(s): ${r.join(", ")} on the selected floor. Call get_chart to list current section ids.`,{sectionIds:r});let a=o;return{requested:n,sections:a,logicalSectionIds:[...new Set(a.map(i=>i.logicalSectionId??i.id))]}}function Ki(e,t){let n=O(e,t.floorId),o=Bi(n.objects,t.sectionIds),r=wt(me(e,n.floorId)),a=new Map(r.sections.map(h=>[h.id,h])),i=new Map(n.objects.map(h=>[h.id,h])),s=o.logicalSectionIds.flatMap(h=>a.get(h)?.objectIds??[]),c=new Set,l=new Set(o.logicalSectionIds),d=new Set(n.objects.filter(h=>h.type==="section"&&l.has(h.logicalSectionId??h.id)).flatMap(h=>h.editor?.defaultCategoryKey?[h.editor.defaultCategoryKey]:[]));for(let h of s){let b=i.get(h);if(b)if(b.type==="row"||b.type==="table")for(let p of en(b).keys())c.add(p);else(b.type==="booth"||b.type==="gaArea")&&c.add(b.categoryKey)}let f=o.logicalSectionIds.every(h=>(a.get(h)?.seatCount??0)>0),g=o.logicalSectionIds.every(h=>a.get(h)?.objectIds.some(b=>{let p=i.get(b);return p?.type==="row"||p?.type==="table"||p?.type==="booth"})===!0);return{floorId:n.floorId,sectionIds:o.requested,logicalSectionIds:o.logicalSectionIds,objectIds:s,categoryApplicable:f,...f&&c.size===1?{categoryKey:[...c][0]}:!f&&!s.length&&d.size===1?{categoryKey:[...d][0]}:{},categoryMixed:f?c.size!==1:!s.length&&d.size>1,viewApplicable:g}}function $l(e,t){D(e,t.categoryKey);let n=Ki(e,t);if(!n.categoryApplicable&&n.objectIds.length)throw new u("invalid_operation","A mixed selection of empty and occupied logical sections cannot be assigned together",{logicalSectionIds:n.logicalSectionIds});let o=O(e,n.floorId),r=new Set(n.objectIds),a=!1,i=0,s=new Set(n.logicalSectionIds);for(let c of o.objects)c.type!=="section"||!s.has(c.logicalSectionId??c.id)||c.editor?.defaultCategoryKey!==t.categoryKey&&(c.editor={...c.editor,defaultCategoryKey:t.categoryKey},a=!0);for(let c of o.objects){if(!r.has(c.id)||c.type!=="row"&&c.type!=="table"&&c.type!=="booth"&&c.type!=="gaArea"||(c.categoryKey!==t.categoryKey&&(c.categoryKey=t.categoryKey,a=!0),c.type!=="row"&&c.type!=="table"||!c.overrides?.length))continue;let l=c.overrides.flatMap(d=>{if(d.categoryKey===void 0)return[d];let f={...d};return delete f.categoryKey,i++,a=!0,Object.keys(f).some(g=>g!=="index")?[f]:[]});l.length?c.overrides=l:delete c.overrides}return{...n,changed:a,categoryKey:t.categoryKey,categoryMixed:!1,clearedSeatOverrideCount:i}}function fo(e,t){let n=O(e,t.floorId),o=Bi(n.objects,t.sectionIds),{requested:r}=o,a=structuredClone(t.patch),i=new Set(["label","displayLabel","entrance","viewFromSeatUrl","viewFromSeatMeta","labelPresentation","labelStyle","zone","elevation","height","rake","surfaceKind","color"]),s=Object.keys(a).filter(h=>!i.has(h));if(s.length)throw new u("invalid_operation",`Unsupported section metadata field(s): ${s.join(", ")}`);if(!Object.keys(a).length)throw new u("invalid_operation","At least one section metadata change is required");if(a.label!==void 0){if(a.label=a.label.normalize("NFKC").trim(),r.length!==1)throw new u("invalid_operation","label can be changed only for one section at a time");if(!a.label||a.label.length>80)throw new u("invalid_operation","Section labels must contain 1 to 80 characters")}if(a.displayLabel!==void 0&&a.displayLabel!==null){if(a.displayLabel=a.displayLabel.normalize("NFKC").trim(),r.length!==1)throw new u("invalid_operation","displayLabel can be changed only for one section at a time");if(!a.displayLabel||a.displayLabel.length>80)throw new u("invalid_operation","Section display labels must contain 1 to 80 characters")}if(a.entrance!==void 0&&a.entrance!==null&&(a.entrance=a.entrance.normalize("NFKC").trim(),a.entrance.length>40))throw new u("invalid_operation","Section entrance must be at most 40 characters");if(a.viewFromSeatUrl!==void 0&&a.viewFromSeatUrl!==null&&(a.viewFromSeatUrl=Gl(a.viewFromSeatUrl)),a.labelPresentation?.position&&(!Number.isFinite(a.labelPresentation.position.x)||!Number.isFinite(a.labelPresentation.position.y)))throw new u("invalid_operation","Section label position must be finite");if(a.labelPresentation?.rotation!=null&&!Number.isFinite(a.labelPresentation.rotation))throw new u("invalid_operation","Section label rotation must be finite");if(a.labelPresentation!==void 0&&Zt(a.labelPresentation,"Section"),a.labelStyle!==void 0&&xe(a.labelStyle,"Section"),a.zone!==void 0&&a.zone!==null&&!(e.zones??[]).some(h=>h.id===a.zone))throw new u("object_not_found",`Unknown chart zone: ${a.zone}`,{zoneId:a.zone});if(a.elevation!==void 0&&(!Number.isInteger(a.elevation)||a.elevation<0||a.elevation>3))throw new u("invalid_operation","Section elevation must be an integer from 0 to 3");if(a.height!==void 0&&a.height!==null&&(!Number.isFinite(a.height)||a.height<0||a.height>120))throw new u("invalid_operation","Section height must be a number from 0 to 120 metres");if(a.rake!==void 0&&a.rake!==null&&(!Number.isFinite(a.rake)||a.rake<0||a.rake>45))throw new u("invalid_operation","Section rake must be a number from 0 to 45 degrees");if(a.surfaceKind!==void 0&&a.surfaceKind!==null&&a.surfaceKind!=="flat"&&a.surfaceKind!=="rakedRows")throw new u("invalid_operation","Section surfaceKind must be 'flat' or 'rakedRows'");a.color!==void 0&&a.color!==null&&(a.color=N(a.color,"Section color"));let c=a.displayLabel!==void 0||a.entrance!==void 0||a.viewFromSeatUrl!==void 0||a.viewFromSeatMeta!==void 0||a.labelStyle!==void 0||a.zone!==void 0,l=new Set(o.logicalSectionIds),d=c?n.objects.filter(h=>h.type==="section"&&l.has(h.logicalSectionId??h.id)):[],f=new Set,g=!1;for(let h of o.sections){let b=JSON.stringify(h);a.label!==void 0&&(h.label=a.label),a.labelPresentation===null?delete h.labelPresentation:a.labelPresentation!==void 0&&(h.labelPresentation=a.labelPresentation),a.elevation!==void 0&&(h.elevation=a.elevation);let p=x=>{h.physical3dProvenance&&(delete h.physical3dProvenance[x],Object.keys(h.physical3dProvenance).length===0&&delete h.physical3dProvenance)};a.height===null?(delete h.height,p("height")):a.height!==void 0&&(h.height=a.height,h.physical3dProvenance={...h.physical3dProvenance,height:{status:"confirmed",source:"user-review",note:"Section front-edge height reviewed through the shared Designer/Copilot operation."}}),a.rake===null?(delete h.rake,p("rake")):a.rake!==void 0&&(h.rake=a.rake,h.physical3dProvenance={...h.physical3dProvenance,rake:{status:"confirmed",source:"user-review",note:"Section rake reviewed through the shared Designer/Copilot operation."}}),a.surfaceKind===null?(delete h.surfaceKind,p("surfaceKind")):a.surfaceKind!==void 0&&(h.surfaceKind=a.surfaceKind,h.physical3dProvenance={...h.physical3dProvenance,surfaceKind:{status:"confirmed",source:"user-review",note:"Section surface behavior reviewed through the shared Designer/Copilot operation."}}),a.color===null?delete h.color:a.color!==void 0&&(h.color=a.color),JSON.stringify(h)!==b&&(g=!0,f.add(h.id))}for(let h of d){let b=JSON.stringify(h),p=h.viewFromSeatUrl;a.displayLabel===null?delete h.displayLabel:a.displayLabel!==void 0&&(h.displayLabel=a.displayLabel);let x=h.entrance;if(a.entrance===null||a.entrance===""?delete h.entrance:a.entrance!==void 0&&(h.entrance=a.entrance),h.entrance!==x&&delete h.entranceGateId,a.viewFromSeatUrl===null||a.viewFromSeatUrl===""?delete h.viewFromSeatUrl:a.viewFromSeatUrl!==void 0&&(h.viewFromSeatUrl=a.viewFromSeatUrl),!h.viewFromSeatUrl||a.viewFromSeatMeta===null?delete h.viewFromSeatMeta:a.viewFromSeatMeta!==void 0?h.viewFromSeatMeta=structuredClone(a.viewFromSeatMeta):a.viewFromSeatUrl!==void 0&&h.viewFromSeatUrl!==p&&delete h.viewFromSeatMeta,a.labelStyle!==void 0){let I=De(h.labelPresentation,a.labelStyle);I?h.labelPresentation=I:delete h.labelPresentation}a.zone===null?delete h.zone:a.zone!==void 0&&(h.zone=a.zone),JSON.stringify(h)!==b&&(g=!0,f.add(h.id))}return{floorId:n.floorId,changed:g,sectionIds:r,affectedSectionIds:[...f]}}function zi(e,t){let n=O(e,t.floorId),o=n.objects.find(a=>a.type==="section"&&a.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});if(o.outlinePath)throw new u("invalid_operation",`Section ${o.id} has an exact path; polygon conversion requires a separate loss review`,{sectionId:o.id,representation:"exact-path"});if(!o.geometry)throw new u("invalid_operation",`Section ${o.id} is already a manual polygon`,{sectionId:o.id,representation:"manual-polygon"});let r=n.objects.filter(a=>a.id!==o.id&&a.type!=="section"&&J(H(a),o.outline,o.holes));return{floorId:n.floorId,sectionId:o.id,sectionLabel:o.label,source:{representation:"generated-polygon",generator:structuredClone(o.geometry)},target:{representation:"manual-polygon"},geometryChanged:!1,preserved:{stableId:!0,outlineVertexCount:o.outline.length,holeCount:o.holes?.length??0,memberObjectIds:r.map(a=>a.id),inventoryUnits:r.reduce((a,i)=>a+Oe(i),0),durableReferenceSource:!!o.referenceSource,inventoryExclusionEvidence:!!o.referenceInventoryExclusion},removedFields:["geometry"]}}function Bl(e,t){let n=zi(e,t),r=O(e,n.floorId).objects.find(a=>a.type==="section"&&a.id===n.sectionId);return delete r.geometry,{...n,changed:!0}}function Ui(e,t){let n=(...s)=>s.every(Number.isFinite),o,r=1,a=!1,i=!0;if(t.kind==="translate"){if(!n(t.dx,t.dy))throw new u("invalid_operation","Section translation must be finite");i=t.dx!==0||t.dy!==0,o=s=>({x:s.x+t.dx,y:s.y+t.dy})}else if(t.kind==="scale"){if(!n(t.factor)||t.factor<=0||t.factor>100)throw new u("invalid_operation","Section scale factor must be finite and greater than 0");i=t.factor!==1,r=t.factor;let s=H(e);o=c=>({x:s.x+(c.x-s.x)*t.factor,y:s.y+(c.y-s.y)*t.factor})}else if(t.kind==="rotate"){if(!n(t.degrees))throw new u("invalid_operation","Section rotation must be finite");i=(t.degrees%360+360)%360!==0;let c=t.degrees*Math.PI/180,l=Math.cos(c),d=Math.sin(c),f=H(e);o=g=>{let h=g.x-f.x,b=g.y-f.y;return{x:f.x+h*l-b*d,y:f.y+h*d+b*l}}}else{if(!n(t.coordinate))throw new u("invalid_operation","Section reflection coordinate must be finite");a=!0,o=t.axis==="h"?s=>({x:2*t.coordinate-s.x,y:s.y}):s=>({x:s.x,y:2*t.coordinate-s.y})}return i&&(e.outline=e.outline.map(o),e.sourceOutline&&(e.sourceOutline=e.sourceOutline.map(o)),e.outlinePath&&(e.outlinePath=at(e.outlinePath,o,r,a)),a&&e.edgeCurvature&&(e.edgeCurvature=tr(e.edgeCurvature)),e.holes&&(e.holes=Q(e.holes).map(s=>s.map(o)))),{changed:i,sectionId:e.id,representation:e.outlinePath?"exact-path":"polygon",outlineVertexCount:e.outline.length,holeCount:e.holes?.length??0,pathSegmentKinds:e.outlinePath?.segments.map(s=>s.kind)??[]}}function Kl(e,t){let n=O(e,t.floorId),o=n.objects.find(r=>r.type==="section"&&r.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});return{floorId:n.floorId,...Ui(o,t.transform)}}function zl(e,t){let n=O(e,t.floorId),o=n.objects.find(s=>s.type==="section"&&s.id===t.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${t.sectionId}`,{sectionId:t.sectionId});let r=structuredClone(t.path);if(!Dt(r))throw new u("invalid_operation","Exact section path is not finite, continuous, closed, or radius-correct");let a=it(r),i=JSON.stringify(o.outlinePath)!==JSON.stringify(r)||JSON.stringify(o.outline)!==JSON.stringify(a)||o.sourceOutline!==void 0||o.cornerSmoothing!==void 0;return i&&(o.outlinePath=r,o.outline=a,delete o.geometry,delete o.sourceOutline,delete o.cornerSmoothing),{floorId:n.floorId,sectionId:o.id,changed:i,segmentKinds:r.segments.map(s=>s.kind),sampledVertexCount:a.length,holeCount:o.holes?.length??0}}function Ul(e){return e.geometry?null:e.sourceOutline?.length?e.sourceOutline:e.outlinePath?null:e.outline?.length?e.outline:null}function Hl(e,t){return Hi(e,{floorId:t.floorId,sectionIds:t.sectionIds,cornerSmoothing:t.strength})}function Hi(e,t){let n=O(e,t.floorId);if(t.cornerSmoothing!==void 0&&!Number.isFinite(t.cornerSmoothing))throw new u("invalid_operation","Corner smoothing must be a number from 0 to 100");if(t.edgeCurvature!=null&&t.edgeCurvature.some(s=>!Number.isFinite(s)))throw new u("invalid_operation","Edge curvature values must be numbers from -100 to 100");let o=[...new Set(t.sectionIds)],r=new Set,a=new Map,i=!1;try{for(let s of o){let c=n.objects.find(y=>y.type==="section"&&y.id===s);if(!c||!Ul(c))continue;let d=structuredClone(c);a.set(c.id,{section:c,snapshot:d});let f=JSON.stringify(c),g=(c.sourceOutline??c.outline).map(y=>({...y})),h=Math.min(100,Math.max(0,t.cornerSmoothing??c.cornerSmoothing??0)),p=(t.edgeCurvature===void 0?c.edgeCurvature:t.edgeCurvature??void 0)?.map(y=>Math.min(100,Math.max(-100,y))),x=p?.some(y=>Math.abs(y)>.5)===!0,I=h>.5||x?Gt(g,{cornerSmoothing:h,...x?{edgeCurvature:p}:{}}):null;I?(c.sourceOutline=g,c.outlinePath=I,c.outline=it(I),h>.5?c.cornerSmoothing=h:delete c.cornerSmoothing,x?c.edgeCurvature=[...p]:delete c.edgeCurvature):(c.outline=g,delete c.outlinePath,delete c.sourceOutline,delete c.cornerSmoothing,delete c.edgeCurvature);for(let y=0;y<(c.holes?.length??0);y+=1)gn(e,{floorId:n.floorId,objectId:c.id,points:c.holes[y],holeIndex:y});JSON.stringify(c)!==f&&(i=!0,r.add(c.id))}}catch(s){for(let{section:c,snapshot:l}of a.values()){let d=c;for(let f of Object.keys(d))delete d[f];Object.assign(c,structuredClone(l))}throw s}return{floorId:n.floorId,changed:i,sectionIds:o,affectedSectionIds:[...r]}}function Vl(e,t,n={}){let o=!1;for(let r of t){let a=fo(e,{floorId:r.floorId,sectionIds:[r.sectionId],patch:{height:r.height,rake:r.rake,surfaceKind:r.surfaceKind}});o||=a.changed}if(n.stage){let r=O(e,n.stage.floorId).objects.find(a=>a.type==="shape"&&a.id===n.stage.shapeId);r&&r.role!=="stage"&&(r.role="stage",o=!0),r&&n.stage.stageKind&&!r.stageKind&&(r.stageKind=n.stage.stageKind,o=!0)}for(let{shapeId:r,floorId:a,role:i}of n.roles??[]){let s=O(e,a).objects.find(c=>c.type==="shape"&&c.id===r);s&&!s.role&&(s.role=i,o=!0)}for(let{floorId:r,point:a}of n.focal??[]){let i=pt(a,"focalPoint"),s=r?e.floors?.find(l=>l.id===r):void 0,c=s?s.focalPoint:e.focalPoint;c?.x===i.x&&c?.y===i.y||(s?s.focalPoint=i:e.focalPoint=i,o=!0)}return e.floors?.length&&Pe(e),{changed:o}}var ho=.15,go=1.6;function qe(e){return typeof e=="string"&&kr.includes(e)}function bo(e,t){return e&&t?"both":e?"start":t?"end":"none"}function mo(e){let t=qe(e.aisleSeats)?e.aisleSeats:"both";return{start:t==="start"||t==="both",end:t==="end"||t==="both"}}function po(e,t){t==="both"?delete e.aisleSeats:e.aisleSeats=t}function Vi(e,t,n){if(!qe(e.aisleSeats)){delete t.aisleSeats,delete n.aisleSeats;return}let o=mo(e);po(t,bo(o.start,!0)),po(n,bo(!0,o.end))}function Xi(e,t){let n=e[0],o=e[e.length-1];if(!n||!o||!qe(n.aisleSeats)&&!qe(o.aisleSeats)){delete t.aisleSeats;return}po(t,bo(mo(n).start,mo(o).end))}var qi=["butt","round","square"],Yi=["miter","round","bevel"],Ji=["none","arrow"];function yo(e){return e==="line"||e==="polyline"}var Wi=[{key:"circle",label:"Standard seat",shortLabel:"Standard",useCase:"General assigned seating",group:"general",path:null,bounds:null,mark:null},{key:"theatre",label:"Theatre chair",shortLabel:"Theatre",useCase:"Auditoriums, arenas and stadium stands",group:"fixed",path:"M4.5 3.5 Q4.5 1.5 6.5 1.5 L17.5 1.5 Q19.5 1.5 19.5 3.5 L19.5 13 L4.5 13 Z M3.5 12 L20.5 12 Q22.5 12 22.5 14 L22.5 21 Q22.5 22.5 21 22.5 Q19.5 22.5 19.5 21 L19.5 17.5 L4.5 17.5 L4.5 21 Q4.5 22.5 3 22.5 Q1.5 22.5 1.5 21 L1.5 14 Q1.5 12 3.5 12 Z",bounds:{x:1.5,y:1.5,width:21,height:21},mark:{x:12,y:10,radius:6}},{key:"dining",label:"Dining chair",shortLabel:"Dining",useCase:"Banquets, restaurants and table seating",group:"flexible",path:"M7 1 Q6 1 6 2.5 L6.75 10.5 L5 10.5 Q4 10.5 4 12 L4 14 Q4 15 5.25 15 L6 15 L4 23 L7 23 L9.5 15 L14.5 15 L17 23 L20 23 L18 15 L18.75 15 Q20 15 20 14 L20 12 Q20 10.5 19 10.5 L17.25 10.5 L18 2.5 Q18 1 17 1 Z",bounds:{x:4,y:1,width:16,height:22},mark:{x:12,y:10,radius:4.5}},{key:"folding",label:"Folding chair",shortLabel:"Folding",useCase:"Concert floors, ceremonies and conferences",group:"flexible",path:"M6 2 Q5 2 5 3 L6 8 L18 8 L19 3 Q19 2 18 2 Z M5 9 L19 9 Q20 9 20 10.5 L19 13 L5 13 L4 10.5 Q4 9 5 9 Z M6 12 L9 12 L12 17 L15 12 L18 12 L14 19 L17 23 L14 23 L12 21 L10 23 L7 23 L10 19 Z",bounds:{x:4,y:2,width:16,height:21},mark:{x:12,y:5,radius:3}},{key:"armchair",label:"Premium armchair",shortLabel:"Armchair",useCase:"Boxes, lounges and club seating",group:"premium",path:"M3.5 4 Q3.5 1.5 6 1.5 L18 1.5 Q20.5 1.5 20.5 4 L20.5 13 L3.5 13 Z M1.5 12.5 Q1.5 10 3.25 10 Q5 10 5 12.5 L5 13.5 L19 13.5 L19 12.5 Q19 10 20.75 10 Q22.5 10 22.5 12.5 L22.5 19.5 Q22.5 22 20 22 L4 22 Q1.5 22 1.5 19.5 Z",bounds:{x:1.5,y:1.5,width:21,height:20.5},mark:{x:12,y:7.5,radius:5.5}},{key:"recliner",label:"Recliner",shortLabel:"Recliner",useCase:"Luxury cinemas and premium clubs",group:"premium",path:"M7 2 Q7 1 8.5 1 L15.5 1 Q17 1 17 2 L19 13 L5 13 Z M4 9 Q2 9 2 11.5 L2 16 Q2 18 4 18 L6 18 L6 15 L18 15 L18 18 L20 18 Q22 18 22 16 L22 11.5 Q22 9 20 9 Q18 9 18 11 L18 13 L6 13 L6 11 Q6 9 4 9 Z M7 17 L17 17 Q18 17 18.5 18.5 L19.5 22.5 L4.5 22.5 L5.5 18.5 Q6 17 7 17 Z",bounds:{x:2,y:1,width:20,height:21.5},mark:{x:12,y:8,radius:5}},{key:"stool",label:"Stool",shortLabel:"Stool",useCase:"Bars, high-tops and seating rails",group:"flexible",path:"M6 2.5 L18 2.5 Q22 2.5 22 6.5 L22 12 Q22 16 18 16 L6 16 Q2 16 2 12 L2 6.5 Q2 2.5 6 2.5 Z M6 15.5 L9.5 15.5 L7.5 22.5 L3 22.5 Z M14.5 15.5 L18 15.5 L20.5 22.5 L16 22.5 Z",bounds:{x:2,y:2.5,width:20,height:20},mark:{x:12,y:9.25,radius:6.5}},{key:"bench",label:"Bench place",shortLabel:"Bench",useCase:"Pews, bleachers and terraces",group:"fixed",path:"M2.5 0.5 L21.5 0.5 Q23 0.5 23 2 L23 5 Q23 6.5 21.5 6.5 L2.5 6.5 Q1 6.5 1 5 L1 2 Q1 0.5 2.5 0.5 Z M2 7.5 L22 7.5 Q23.5 7.5 23.5 9 L23.5 15.5 Q23.5 17 22 17 L18 17 L18 21.5 Q18 22.5 16.75 22.5 Q15.5 22.5 15.5 21.5 L15.5 17 L8.5 17 L8.5 21.5 Q8.5 22.5 7.25 22.5 Q6 22.5 6 21.5 L6 17 L2 17 Q0.5 17 0.5 15.5 L0.5 9 Q0.5 7.5 2 7.5 Z",bounds:{x:.5,y:.5,width:23,height:22},mark:{x:12,y:12.25,radius:4.75}}],hb=Wi.map(e=>e.key),Xl=new Map(Wi.map(e=>[e.key,e]));function Ot(e){return typeof e=="string"&&Xl.has(e)}var ql=new Set(["companion","child","senior","student","membership","custom"]);function Ye(e){if(!e.length)throw new u("invalid_operation","A chart must have at least one category");let t=new Set,n=new Map,o=structuredClone(e);for(let r of o){let a=r.key.trim(),i=r.label.normalize("NFKC").trim();if(!a||a.length>160||t.has(a))throw new u("invalid_operation",`Category keys must be non-empty and unique: ${a}`,{categoryKey:a});if(t.add(a),!i||i.length>80)throw new u("invalid_operation",`Category labels must contain 1 to 80 characters: ${a}`,{categoryKey:a});let s=i.toLocaleLowerCase("en"),c=n.get(s);if(c)throw new u("duplicate_category_label",`Categories ${c} and ${a} share the same label`,{categoryKeys:[c,a],label:i});if(n.set(s,a),!/^#[0-9a-fA-F]{6}$/.test(r.color))throw new u("invalid_operation",`Category ${a} must use a six-digit hex color`,{categoryKey:a});if(r.referenceDirectSeatImport!==void 0){let l=r.referenceDirectSeatImport;if(l.assetId!==l.assetId.trim()||l.assetId.length>160||!l.assetId||l.familyId!==l.familyId.trim()||!/^source-color:(?:#[0-9a-f]{6}(?:\+#[0-9a-f]{6})*|unclassified)$/i.test(l.familyId))throw new u("invalid_operation",`Category ${a} has invalid direct-seat import provenance`,{categoryKey:a})}if(r.price!=null&&(!Number.isFinite(r.price)||r.price<0||r.price>1e6))throw new u("invalid_operation",`Category ${a} price must be from 0 to 1000000`,{categoryKey:a});if(r.seatGlyph!=null&&!Ot(r.seatGlyph))throw new u("invalid_operation",`Category ${a} has an unknown seat glyph`,{categoryKey:a,seatGlyph:r.seatGlyph});if((r.seatGlyph==null||r.seatGlyph==="circle")&&delete r.seatGlyph,r.tiers!=null)if(!r.tiers.length)delete r.tiers;else{if(r.tiers.length>20)throw new u("invalid_operation",`Category ${a} supports at most 20 ticket tiers`);let l=new Set,d=new Set;for(let f of r.tiers){let g=f.id.trim(),h=f.name.normalize("NFKC").trim(),b=h.toLocaleLowerCase("en");if(!g||g.length>160||l.has(g))throw new u("invalid_operation",`Ticket tier ids must be non-empty and unique in category ${a}`,{categoryKey:a,tierId:g});if(!h||h.length>80||d.has(b))throw new u("invalid_operation",`Ticket tier names must be non-empty and unique in category ${a}`,{categoryKey:a,tierName:h});if(!Number.isFinite(f.price)||f.price<0||f.price>1e6)throw new u("invalid_operation",`Ticket tier ${g} price must be from 0 to 1000000`,{categoryKey:a,tierId:g});if(f.restriction!=null&&!ql.has(f.restriction))throw new u("invalid_operation",`Ticket tier ${g} has an unknown restriction`,{categoryKey:a,tierId:g});if(f.buyerMessage!=null){if(f.buyerMessage=f.buyerMessage.normalize("NFKC").trim(),!f.buyerMessage)delete f.buyerMessage;else if(f.buyerMessage.length>240)throw new u("invalid_operation",`Ticket tier ${g} buyer guidance must be at most 240 characters`,{categoryKey:a,tierId:g})}if(f.currency!=null&&(f.currency=f.currency.trim().toUpperCase(),!/^[A-Z]{3}$/.test(f.currency)))throw new u("invalid_operation",`Ticket tier ${g} must use a three-letter ISO currency`,{categoryKey:a,tierId:g});if(f.applicability!=null){let p=f.applicability.seatLabels?.map(I=>I.normalize("NFKC").trim()),x=f.applicability.accessibility;if(p&&(!p.length||p.length>1e4||p.some(I=>!I||I.length>160)||new Set(p).size!==p.length)||x&&(!x.length||x.some(I=>!mt.some(y=>y.key===I))||new Set(x).size!==x.length))throw new u("invalid_operation",`Ticket tier ${g} has invalid seat applicability`,{categoryKey:a,tierId:g});f.applicability={...p?{seatLabels:p}:{},...x?{accessibility:[...x]}:{}},!f.applicability.seatLabels&&!f.applicability.accessibility&&delete f.applicability}if(f.evidence!=null){if(!["public-host","public-event","user-confirmed"].includes(f.evidence.provenance)||typeof f.evidence.sourceDescription!="string")throw new u("invalid_operation",`Ticket tier ${g} has invalid evidence provenance`,{categoryKey:a,tierId:g});if(f.evidence.sourceDescription=f.evidence.sourceDescription.normalize("NFKC").trim(),!f.evidence.sourceDescription||f.evidence.sourceDescription.length>240||f.evidence.capturedAt!==void 0&&(f.evidence.capturedAt.length>40||!Number.isFinite(Date.parse(f.evidence.capturedAt))))throw new u("invalid_operation",`Ticket tier ${g} has invalid evidence provenance`,{categoryKey:a,tierId:g})}l.add(g),d.add(b)}}}return o}function bn(e,t){let n=new Set,o=structuredClone(e.categories);for(let i of t.updates){if(n.has(i.categoryKey))throw new u("invalid_operation",`Category ${i.categoryKey} may be updated only once`);n.add(i.categoryKey);let s=o.find(f=>f.key===i.categoryKey);if(!s)throw new u("category_not_found",`Unknown chart category: ${i.categoryKey}. Call get_chart to list valid category keys.`,{categoryKey:i.categoryKey});let c=structuredClone(i.patch),{tiers:l,...d}=c;typeof d.label=="string"&&(d.label=d.label.normalize("NFKC").trim()),typeof d.color=="string"&&(d.color=d.color.toLowerCase()),Object.assign(s,d),s.notForSale===!1&&delete s.notForSale,Object.prototype.hasOwnProperty.call(c,"tiers")&&(l==null?delete s.tiers:s.tiers=l?.map(f=>{let g={...f,id:f.id.trim(),name:f.name.normalize("NFKC").trim()};return f.buyerMessage?.trim()?g.buyerMessage=f.buyerMessage.normalize("NFKC").trim():delete g.buyerMessage,g})),delete s.referenceDirectSeatImport}let r=Ye(o),a=JSON.stringify(r)!==JSON.stringify(e.categories);return a&&(e.categories=r),{changed:a,categoryKeys:[...n],categories:e.categories}}function Yl(e,t){let n=structuredClone(e.categories),o=n.find(i=>i.key===t.categoryKey);if(!o||o.referenceDirectSeatImport?.assetId!==t.source.assetId||o.referenceDirectSeatImport.familyId!==t.source.familyId)throw new u("invalid_operation","The prior direct-seat import category is no longer available for this reference");o.label=t.label.normalize("NFKC").trim();let r=Ye(n),a=JSON.stringify(r)!==JSON.stringify(e.categories);return a&&(e.categories=r),{changed:a,category:e.categories.find(i=>i.key===t.categoryKey),categories:e.categories}}function Jl(e,t){let n=t.categoryKeys.map(c=>c.trim()),o=e.categories.map(c=>c.key);if(n.length!==o.length||new Set(n).size!==n.length)throw new u("invalid_operation","Category order must contain every stable category key exactly once",{categoryKeys:n,expectedCategoryKeys:o});let r=new Set(o),a=o.filter(c=>!n.includes(c)),i=n.filter(c=>!r.has(c));if(a.length||i.length)throw new u(i.length?"category_not_found":"invalid_operation","Category order must be an exact permutation of the current stable keys",{categoryKeys:n,missingCategoryKeys:a,unknownCategoryKeys:i});if(n.every((c,l)=>c===o[l]))return{changed:!1,categoryKeys:o,categories:e.categories};let s=new Map(e.categories.map(c=>[c.key,c]));return e.categories=Ye(n.map((c,l)=>{let d=structuredClone(s.get(c));return c!==o[l]&&delete d.referenceDirectSeatImport,d})),{changed:!0,categoryKeys:n,categories:e.categories}}function Zi(e){let t=/^#?([0-9a-f]{6}|[0-9a-f]{3})$/i.exec(e.trim());if(!t)return null;let n=t[1];return n.length===3&&(n=n.split("").map(o=>o+o).join("")),[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)]}function Wl(e,t){let n=Zi(e),o=Zi(t);return!n||!o?1/0:(n[0]-o[0])**2+(n[1]-o[1])**2+(n[2]-o[2])**2}var Zl=3600;function Qi(e,t,n=Se){return n.find(r=>e.every(a=>Wl(r,a)>=Zl))??n[t%n.length]}function Ql(e,t){let n=t?.palette??Se;if(!e.categories.length)return{changed:[],categories:e.categories};let o=new Map(e.categories.map(i=>[i.key,i.color.toLowerCase()])),r=e.categories.map((i,s)=>({categoryKey:i.key,patch:{color:n[s%n.length]}}));return bn(e,{updates:r}),{changed:e.categories.map(i=>({key:i.key,from:o.get(i.key),to:i.color})).filter(i=>i.from!==i.to),categories:e.categories}}function ed(e,t){let n=t.color.trim().toLowerCase(),o=t.sourceDescription.normalize("NFKC").trim();if(!/^#[0-9a-f]{6}$/.test(n))throw new u("invalid_operation","Sampled category color must be a six-digit hex color");if(!o||o.length>240)throw new u("invalid_operation","Color confirmation evidence must contain 1 to 240 characters");let r=structuredClone(e.categories),a=r.find(c=>c.key===t.categoryKey);if(!a)throw new u("category_not_found",`Unknown chart category: ${t.categoryKey}. Call get_chart to list valid category keys.`,{categoryKey:t.categoryKey});a.color=n,delete a.referenceDirectSeatImport,a.referenceCategorySource&&(a.referenceCategorySource.outputColorEvidence="user-confirmed",a.referenceCategorySource.outputColorSourceDescription=o);let i=Ye(r),s=JSON.stringify(i)!==JSON.stringify(e.categories);return s&&(e.categories=i),{changed:s,category:e.categories.find(c=>c.key===t.categoryKey),categories:e.categories}}function mn(e,t){let n=new Set(e.categories.map(i=>i.key)),o="";for(let i=0;i<100;i++){let c=t.idFactory("cat").trim();if(c&&!n.has(c)){o=c;break}}if(!o)throw new u("id_generation_failed","Unable to allocate a unique category id");let r={key:o,label:t.label.normalize("NFKC").trim(),color:t.color.toLowerCase(),price:t.price,tiers:t.tiers?.map(i=>({...i,id:i.id.trim(),name:i.name.normalize("NFKC").trim()})),...t.referenceDirectSeatImport?{referenceDirectSeatImport:structuredClone(t.referenceDirectSeatImport)}:{}},a=Ye([...e.categories,r]);return e.categories=a,{changed:!0,category:a.find(i=>i.key===o),categories:a}}var ea=["#3e8e7e","#6e7ff0","#b0700f","#b05fc4"],td=[...ea,"#4d7c0f","#c026d3","#a86b00","#d6336c","#e5484d","#dc2626"],nd={row:"#6e7ff0",table:"#3e8e7e",booth:"#b05fc4",gaArea:"#b0700f"};function od(e,t){let n=nd[e];return!n||!t.includes(n)?t:[n,...t.filter(o=>o!==n)]}var rd="#f5f6f8",id="#f7f8fb",ad=26;function sd(e,t,n){let o=(1-Math.abs(2*n-1))*t,r=(e%360+360)%360/60,a=o*(1-Math.abs(r%2-1)),[i,s,c]=r<1?[o,a,0]:r<2?[a,o,0]:r<3?[0,o,a]:r<4?[0,a,o]:r<5?[a,0,o]:[o,0,a],l=n-o/2,d=f=>Math.round((f+l)*255).toString(16).padStart(2,"0");return`#${d(i)}${d(s)}${d(c)}`}function cd(e,t,n,o,r){let a=d=>e.every(f=>{let g=Jn(d,f);return g==null||g>=ad}),i=[rd,r??id],s=(d,f)=>St(Hr(d,f,zr),f)??0,c=d=>o==="gaArea"?[...i,"#12151d"].every(f=>s(d,f)>=3):i.every(f=>(St(d,f)??0)>=3),l=t.find(d=>a(d)&&c(d));if(l)return l;for(let d=0;d<360;d+=12)for(let f of[.52,.44,.6]){let g=sd(d,.62,f);if(a(g)&&c(g))return g}return n}function ta(e,t){let n=yt.find(a=>a.objectType===t).creationWord,o=e.replace(/\s*[–-]\s*(Tables|Booths|Standing|Seats)$/i,"").trim()||e.trim();return yt.some(a=>a.creationWord.toLowerCase()===o.toLowerCase())?n:`${o} \u2013 ${n}`}function ld(e){let t=new Map;for(let n of T(e))for(let o of n.objects){let r=yt.find(i=>i.objectType===o.type);if(!r)continue;let a=new Set;if(o.type==="row"||o.type==="table")for(let i of en(o).keys())a.add(i);else"categoryKey"in o&&o.categoryKey&&a.add(o.categoryKey);for(let i of a){let s=t.get(i)??new Set;s.add(r.objectType),t.set(i,s)}}return t}function dd(e,t){let n=new Set(e.categories.map(r=>r.label.toLowerCase())),o=t;for(let r=2;n.has(o.toLowerCase());r+=1)o=`${t} ${r}`;return o}function na(e,t,n){let o=ld(e),r=d=>{let f=o.get(d);return!f||f.size===0||f.size===1&&f.has(n)},a=e.categories.find(d=>d.key===t);if(a&&r(a.key))return{kind:"existing",categoryKey:a.key,label:a.label};let i=e.categories.find(d=>{let f=o.get(d.key);return f?.size===1&&f.has(n)});if(!a&&i)return{kind:"existing",categoryKey:i.key,label:i.label};let s=yt.find(d=>d.objectType===n),c=a?ta(a.label,n):s.creationWord,l=e.categories.find(d=>d.label.toLowerCase()===c.toLowerCase()&&r(d.key));return l?{kind:"existing",categoryKey:l.key,label:l.label}:i?{kind:"existing",categoryKey:i.key,label:i.label}:{kind:"mint",...a?{baseCategoryKey:a.key}:{},label:dd(e,c)}}function ud(e,t,n,o){let r=na(e,t,n);if(r.kind==="existing")return r.categoryKey;let a=r.baseCategoryKey?e.categories.find(i=>i.key===r.baseCategoryKey):void 0;return fd(e,n,a,r.label,o)}function fd(e,t,n,o,r){let a=r.palette??td,i=e.categories.map(d=>d.color),s=r.suggestColor?.(i.map(d=>d.toLowerCase()))??Qi(i,e.categories.length),c=cd(i,od(t,a),s,t,e.theme?.background),l=mn(e,{label:o,color:c,...n?.price!==void 0?{price:n.price}:{},...n?.tiers?.length?{tiers:n.tiers}:{},idFactory:r.idFactory});return e.categories=l.categories,l.category.key}function hd(e,t){let n=new Set;for(let o of T(e))for(let r of o.objects)"categoryKey"in r&&r.categoryKey===t&&n.add(r.id),r.type==="section"&&r.editor?.defaultCategoryKey===t&&n.add(r.id),(r.type==="row"||r.type==="table")&&r.overrides?.some(a=>a.categoryKey===t)&&n.add(r.id);return[...n]}function wo(e,t){let n=e.categories.find(a=>a.key===t.categoryKey);if(!n)throw new u("category_not_found",`Unknown chart category: ${t.categoryKey}. Call get_chart to list valid category keys.`,{categoryKey:t.categoryKey});if(e.categories.length<=1)throw new u("invalid_operation","A chart must retain at least one category");let o=hd(e,t.categoryKey);if(o.length)throw new u("category_in_use",`Category ${t.categoryKey} is still assigned to chart inventory`,{categoryKey:t.categoryKey,objectIds:o});if(n.referenceCategorySource)throw new u("reference_category_protected",`Reference-backed category ${t.categoryKey} cannot be deleted through a generic catalog operation`,{categoryKey:t.categoryKey});let r=Ye(e.categories.filter(a=>a.key!==t.categoryKey));return e.categories=r,{changed:!0,categoryKey:t.categoryKey,categories:r}}function gd(e,t){if(!t.drafts.length)throw new u("invalid_operation","Add at least one category");let n=[];for(let o of t.drafts){let r=oa(e.categories,o.label),a=mn(e,{label:r,color:o.color,...o.price!==void 0?{price:o.price}:{},...o.tiers?.length?{tiers:o.tiers}:{},idFactory:t.idFactory});n.push(a.category.key),(o.notForSale||o.seatGlyph)&&bn(e,{updates:[{categoryKey:a.category.key,patch:{...o.notForSale?{notForSale:!0}:{},...o.seatGlyph?{seatGlyph:o.seatGlyph}:{}}}]})}return{categoryKeys:n,categories:e.categories}}function oa(e,t){let n=t.normalize("NFKC").trim().slice(0,76)||"Category",o=new Set(e.map(r=>r.label.toLocaleLowerCase("en")));if(!o.has(n.toLocaleLowerCase("en")))return n;for(let r=2;r<1e4;r+=1){let a=`${n} ${r}`;if(!o.has(a.toLocaleLowerCase("en")))return a}return`${n} ${Date.now()}`}function bd(e,t){let{categoryKey:n,toCategoryKey:o}=t;if(!e.categories.some(i=>i.key===n))throw new u("category_not_found",`Unknown chart category: ${n}`,{categoryKey:n});if(o!==void 0){if(o===n)throw new u("invalid_operation","Move the seats to a different category");if(!e.categories.some(i=>i.key===o))throw new u("category_not_found",`Unknown chart category: ${o}`,{categoryKey:o})}let r=new Set;if(o!==void 0)for(let i of T(e))for(let s of i.objects){if((s.type==="row"||s.type==="table"||s.type==="booth"||s.type==="gaArea")&&s.categoryKey===n&&(s.categoryKey=o,r.add(s.id)),(s.type==="row"||s.type==="table")&&s.overrides?.length){for(let l of s.overrides)l.categoryKey===n&&(l.categoryKey=o,r.add(s.id));let c=s.overrides.flatMap(l=>{if(l.categoryKey!==s.categoryKey)return[l];let d={...l};return delete d.categoryKey,Object.keys(d).some(f=>f!=="index")?[d]:[]});c.length?s.overrides=c:delete s.overrides}s.type==="section"&&s.editor?.defaultCategoryKey===n&&(s.editor.defaultCategoryKey=o,r.add(s.id))}let a=wo(e,{categoryKey:n});return{movedObjectIds:[...r],categories:a.categories}}var md=["background","seatLabelColor","rowLabelColor","selectionColor","decorFill","textColor","accent","accentInk"],pd=["seat","deck","shell","fascia"];function yd(e,t){let n=t.patch;if(!Object.keys(n).length)throw new u("invalid_operation","At least one theme field is required");let o=JSON.stringify(e.theme??null),r={...e.theme??{}};for(let a of md){let i=n[a];i===null?delete r[a]:i!==void 0&&(r[a]=N(i,`Theme ${a}`))}if(n.fontFamily===null)delete r.fontFamily;else if(n.fontFamily!==void 0){let a=n.fontFamily.normalize("NFKC").trim();if(!a||a.length>120)throw new u("invalid_operation","Theme fontFamily must contain 1 to 120 characters");r.fontFamily=a}if(n.seatScale===null)delete r.seatScale;else if(n.seatScale!==void 0){if(!Number.isFinite(n.seatScale)||n.seatScale<ho||n.seatScale>go)throw new u("invalid_operation",`Theme seatScale must be from ${ho} to ${go}`);r.seatScale=n.seatScale}if(n.logoUrl===null)delete r.logoUrl;else if(n.logoUrl!==void 0){let a=ye(n.logoUrl);if(!a)throw new u("invalid_operation","Theme logoUrl must be a safe HTTPS or base64 raster image reference");r.logoUrl=a}if(n.brandName===null)delete r.brandName;else if(n.brandName!==void 0){let a=n.brandName.normalize("NFKC").trim();if(!a||a.length>80)throw new u("invalid_operation","Theme brandName must contain 1 to 80 characters");r.brandName=a}if(n.hideBadge===null||n.hideBadge===!1?delete r.hideBadge:n.hideBadge===!0&&(r.hideBadge=!0),n.venue3d===null)delete r.venue3d;else if(n.venue3d!==void 0){let a={...r.venue3d??{}};for(let s of pd){let c=n.venue3d[s];c===null?delete a[s]:c!==void 0&&(a[s]=N(c,`3D venue ${s}`))}let i=n.venue3d.roughness;if(i===null)delete a.roughness;else if(i!==void 0){if(!Number.isFinite(i)||i<0||i>1)throw new u("invalid_operation","3D venue roughness must be from 0 to 1");a.roughness=i}r.venue3d=Object.keys(a).length?a:void 0,r.venue3d||delete r.venue3d}return e.theme=Object.keys(r).length?r:void 0,{changed:JSON.stringify(e.theme??null)!==o,theme:e.theme??null}}function wd(e,t){let n=t.url===null?null:ye(t.url);if(t.url!==null&&!n)throw new u("invalid_operation","View-from-seat photo must be a safe HTTPS or base64 raster image reference");let o=n??void 0;if(t.floorId!==void 0){let s=e.floors?.find(f=>f.id===t.floorId);if(!s)throw new u("invalid_operation",`Unknown floor: ${t.floorId}`);let c=(s.viewFromSeatUrl??void 0)===o,l=o?t.metadata===null?void 0:t.metadata??(c?s.viewFromSeatMeta:void 0):void 0,d=!c||JSON.stringify(s.viewFromSeatMeta??null)!==JSON.stringify(l??null);return s.viewFromSeatUrl=o,s.viewFromSeatMeta=l,{changed:d,scope:"floor",floorId:t.floorId,url:s.viewFromSeatUrl??null}}let r=(e.viewFromSeatUrl??void 0)===o,a=o?t.metadata===null?void 0:t.metadata??(r?e.viewFromSeatMeta:void 0):void 0,i=!r||JSON.stringify(e.viewFromSeatMeta??null)!==JSON.stringify(a??null);return e.viewFromSeatUrl=o,e.viewFromSeatMeta=a,{changed:i,scope:"venue",url:e.viewFromSeatUrl??null}}function _e(e,t){let n=me(e,t.floorId),o=ue(n),r=t.placement==="auto"||t.placement==null?"rear":t.placement,a=96;return r==="front"?{x:o.x+o.width/2,y:o.y-a-t.height/2}:r==="left"?{x:o.x-a-t.width/2,y:o.y+o.height/2}:r==="right"?{x:o.x+o.width+a+t.width/2,y:o.y+o.height/2}:{x:o.x+o.width/2,y:o.y+o.height+a+t.height/2}}function pn(e,t){D(e,t.categoryKey);let n=(...d)=>d.every(Number.isFinite);if(!n(t.center.x,t.center.y,t.innerRadius,t.rowGap,t.startAngle,t.endAngle,t.seatPitch))throw new u("invalid_operation","Arc/Fan geometry values must be finite");if(!Number.isInteger(t.rowCount)||t.rowCount<1||t.rowCount>100)throw new u("invalid_operation","Arc/Fan rowCount must be an integer from 1 to 100");if(t.innerRadius<40||t.innerRadius>2e4||t.rowGap<12||t.rowGap>500)throw new u("invalid_operation","Arc/Fan radius must be 40\u201320000 and row gap 12\u2013500");let o=t.endAngle-t.startAngle;if(Math.abs(o)<5||Math.abs(o)>320)throw new u("invalid_operation","Arc/Fan sweep must be from 5\xB0 to 320\xB0");if(t.seatPitch<14||t.seatPitch>80)throw new u("invalid_operation","Arc/Fan seat pitch must be from 14 to 80 chart units");let r=t.fit??"seat-pitch";if(r==="fixed-count"&&(!Number.isInteger(t.seatsPerRow)||t.seatsPerRow<2||t.seatsPerRow>300))throw new u("invalid_operation","Fixed Arc/Fan rows require seatsPerRow from 2 to 300");let a=t.taperDegrees??0,i=t.skewDegrees??0;if(!n(a,i)||Math.abs(a)>120||Math.abs(i)>180)throw new u("invalid_operation","Arc/Fan taper must be within \xB1120\xB0 and skew within \xB1180\xB0");let s={left:t.aisleGaps?.left??0,center:t.aisleGaps?.center??0,right:t.aisleGaps?.right??0};if(!n(s.left,s.center,s.right)||Object.values(s).some(d=>d<0||d>200))throw new u("invalid_operation","Arc/Fan aisle widths must be from 0 to 200 chart units");let l=O(e,t.floorId).objects.filter(d=>d.type==="row").length;return{...t,fit:r,facing:t.facing??"inward",taperDegrees:a,skewDegrees:i,aisleGaps:s,rowLabelStart:t.rowLabelStart??l,seatLabelStart:t.seatLabelStart??1}}function xd(e,t,n){let o=n*pe;return{x:e.x+t*Math.sin(o),y:e.y+t*Math.cos(o)}}function Sd(e,t,n,o){let r=Math.abs(o-n)*pe,a=[["left",.25],["center",.5],["right",.75]].flatMap(([l,d])=>{let f=e.aisleGaps[l];if(!f)return[];let g=f/t/r/2;return[[Math.max(0,d-g),Math.min(1,d+g)]]}).sort((l,d)=>l[0]-d[0]),i=[];for(let l of a){let d=i[i.length-1];d&&l[0]<=d[1]?d[1]=Math.max(d[1],l[1]):i.push([...l])}let s=[],c=0;for(let l of i)l[0]-c>1e-6&&s.push([c,l[0]]),c=Math.max(c,l[1]);return 1-c>1e-6&&s.push([c,1]),s.filter(([l,d])=>t*r*(d-l)>=e.seatPitch*.75)}function Id(e,t){let n=e.length*2;if(t<n)throw new u("invalid_operation",`Fixed seat count must be at least ${n} for ${e.length} aisle-separated row segments`);let o=t-n,r=e.reduce((c,l)=>c+l,0),a=e.map(c=>o*c/r),i=a.map(c=>2+Math.floor(c)),s=t-i.reduce((c,l)=>c+l,0);return a.map((c,l)=>({index:l,fraction:c-Math.floor(c)})).sort((c,l)=>l.fraction-c.fraction||c.index-l.index).forEach(({index:c})=>{s-- >0&&i[c]++}),i}function yn(e,t,n){let o=[];for(let r=0;r<e.rowCount;r++){let a=e.rowCount===1?0:r/(e.rowCount-1),i=e.innerRadius+r*e.rowGap,s=Math.sign(e.endAngle-e.startAngle)||1,c=e.startAngle+s*e.taperDegrees*a+e.skewDegrees*a,l=e.endAngle-s*e.taperDegrees*a+e.skewDegrees*a;if(Math.sign(l-c)!==Math.sign(e.endAngle-e.startAngle)||Math.abs(l-c)<5)throw new u("invalid_operation",`Arc/Fan taper collapses row ${r+1} below a 5\xB0 sweep`);let d=Sd(e,i,c,l);if(!d.length)throw new u("invalid_operation",`Arc/Fan aisles leave no usable span in row ${r+1}`);e.facing==="outward"&&(d=d.slice().reverse());let f=d.map(([b,p])=>i*Math.abs(l-c)*pe*(p-b)),g=e.fit==="fixed-count"?Id(f,e.seatsPerRow):f.map(b=>Math.max(2,Math.round(b/e.seatPitch)+1)),h=e.seatLabelStart;d.forEach(([b,p],x)=>{let I=c+(l-c)*b,y=c+(l-c)*p;e.facing==="outward"&&([I,y]=[y,I]);let w=g[x];if(w>300)throw new u("invalid_operation","An Arc/Fan row segment cannot exceed 300 seats");let S=Math.abs(y-I)*pe/(w-1),m=2*i*Math.sin(S/2),v={type:"row",id:n(r,x),label:B(e.rowLabelStart+r),origin:xd(e.center,i,I),rotation:-I,curve:y-I,seatCount:w,seatSpacing:m,categoryKey:e.categoryKey,seatLabelStart:h,arcFanGeneration:{kind:"arc-fan-v1",groupId:t,center:{...e.center},innerRadius:e.innerRadius,rowCount:e.rowCount,rowGap:e.rowGap,startAngle:e.startAngle,endAngle:e.endAngle,seatPitch:e.seatPitch,fit:e.fit,...e.seatsPerRow!=null?{seatsPerRow:e.seatsPerRow}:{},facing:e.facing,taperDegrees:e.taperDegrees,skewDegrees:e.skewDegrees,aisleGaps:{...e.aisleGaps},rowLabelStart:e.rowLabelStart,seatLabelStart:e.seatLabelStart,rowIndex:r,segmentIndex:x}};o.push(v),h+=w})}return o}function xo(e,t){let n=pn(e,t),o=O(e,t.floorId),r=yn(n,"preview-arc-fan",(c,l)=>`preview-fan-${c}-${l}`),a=r.map(c=>c.seatSpacing),i=Math.max(...a.map(c=>Math.abs(c-n.seatPitch))),s=[];return i>n.seatPitch*.12&&s.push(`Seat spacing differs from the setting by up to ${Math.round(i*Ut*100)} cm, so each row keeps its seat count`),r.length>n.rowCount*3&&s.push("Three aisles split each logical row into four separately editable segments"),{floorId:o.floorId,rows:r,logicalRowCount:n.rowCount,rowSegmentCount:r.length,totalSeats:r.reduce((c,l)=>c+l.seatCount,0),innerRadius:n.innerRadius,outerRadius:n.innerRadius+(n.rowCount-1)*n.rowGap,minSeatSpacing:Math.min(...a),maxSeatSpacing:Math.max(...a),maxPitchDeviation:i,aisleCount:Object.values(n.aisleGaps).filter(c=>c>0).length,warnings:s}}function So(e,t){let n=pn(e,t),o=O(e,t.floorId),r=new Set,a=E(e,"fan",t.idFactory,r),i=yn(n,a,()=>E(e,"r",t.idFactory,r)),s=xo(e,t),c=null,l=t.sectionLabel?.normalize("NFKC").trim(),d=null;if(l){if(l.length>80)throw new u("invalid_operation","Arc/Fan section label must contain at most 80 characters");let f=Ce(i);f&&(c=E(e,"sec",t.idFactory,r),d={type:"section",id:c,label:l,outline:f,arcFanGroupId:a})}return o.objects.push(...i,...d?[d]:[]),{floorId:o.floorId,rowIds:i.map(f=>f.id),sectionId:c,groupId:a,logicalRowCount:s.logicalRowCount,rowSegmentCount:s.rowSegmentCount,totalSeats:s.totalSeats,innerRadius:s.innerRadius,outerRadius:s.outerRadius,minSeatSpacing:s.minSeatSpacing,maxSeatSpacing:s.maxSeatSpacing,maxPitchDeviation:s.maxPitchDeviation,aisleCount:s.aisleCount,warnings:s.warnings}}function ra(e,t){let n=O(e,t.floorId),o=n.objects.filter(f=>f.type==="row"&&f.arcFanGeneration?.groupId===t.groupId);if(!o.length)throw new u("object_not_found",`Unknown Arc/Fan group: ${t.groupId}`,{groupId:t.groupId});let r=o[0].arcFanGeneration,a=f=>{let g=f.arcFanGeneration;return JSON.stringify({center:g.center,innerRadius:g.innerRadius,rowCount:g.rowCount,rowGap:g.rowGap,startAngle:g.startAngle,endAngle:g.endAngle,seatPitch:g.seatPitch,fit:g.fit,seatsPerRow:g.seatsPerRow,facing:g.facing,taperDegrees:g.taperDegrees,skewDegrees:g.skewDegrees,aisleGaps:g.aisleGaps,rowLabelStart:g.rowLabelStart,seatLabelStart:g.seatLabelStart})};if(o.some(f=>a(f)!==a(o[0])))throw new u("invalid_operation","Arc/Fan group provenance no longer agrees across all row segments",{groupId:t.groupId});let i=n.objects.find(f=>f.type==="section"&&f.arcFanGroupId===t.groupId),s={floorId:n.floorId,center:{...r.center},innerRadius:r.innerRadius,rowCount:r.rowCount,rowGap:r.rowGap,startAngle:r.startAngle,endAngle:r.endAngle,seatPitch:r.seatPitch,fit:r.fit,seatsPerRow:r.seatsPerRow,facing:r.facing,taperDegrees:r.taperDegrees,skewDegrees:r.skewDegrees,aisleGaps:{...r.aisleGaps},categoryKey:o[0].categoryKey,rowLabelStart:r.rowLabelStart,seatLabelStart:r.seatLabelStart,sectionLabel:i?.label},c=pn(e,s),l=new Set(yn(c,t.groupId,(f,g)=>`${f}:${g}`).map(f=>`${f.arcFanGeneration.rowIndex}:${f.arcFanGeneration.segmentIndex}`)),d=new Set(o.map(f=>`${f.arcFanGeneration.rowIndex}:${f.arcFanGeneration.segmentIndex}`));if(l.size!==d.size||[...l].some(f=>!d.has(f)))throw new u("invalid_operation","Arc/Fan group is incomplete and cannot be regenerated safely",{groupId:t.groupId});return s}function vd(e,t){ra(e,{floorId:t.floorId,groupId:t.groupId});let n=pn(e,t),o=O(e,t.floorId),r=o.objects.filter(p=>p.type==="row"&&p.arcFanGeneration?.groupId===t.groupId),a=o.objects.find(p=>p.type==="section"&&p.arcFanGroupId===t.groupId),i=new Map(r.map(p=>[`${p.arcFanGeneration.rowIndex}:${p.arcFanGeneration.segmentIndex}`,p.id])),s=new Set,c=yn(n,t.groupId,(p,x)=>i.get(`${p}:${x}`)??E(e,"r",t.idFactory,s)),l=xo(e,t),d=t.sectionLabel?.normalize("NFKC").trim(),f=null;if(d){if(d.length>80)throw new u("invalid_operation","Arc/Fan section label must contain at most 80 characters");let p=Ce(c);p&&(f={type:"section",id:a?.id??E(e,"sec",t.idFactory,s),label:d,outline:p,arcFanGroupId:t.groupId})}let g=new Set([...r.map(p=>p.id),...a?[a.id]:[]]),h=Math.min(...o.objects.map((p,x)=>g.has(p.id)?x:1/0)),b=o.objects.filter(p=>!g.has(p.id));return b.splice(Number.isFinite(h)?h:b.length,0,...c,...f?[f]:[]),o.objects.splice(0,o.objects.length,...b),{floorId:o.floorId,rowIds:c.map(p=>p.id),sectionId:f?.id??null,groupId:t.groupId,logicalRowCount:l.logicalRowCount,rowSegmentCount:l.rowSegmentCount,totalSeats:l.totalSeats,innerRadius:l.innerRadius,outerRadius:l.outerRadius,minSeatSpacing:l.minSeatSpacing,maxSeatSpacing:l.maxSeatSpacing,maxPitchDeviation:l.maxPitchDeviation,aisleCount:l.aisleCount,warnings:l.warnings}}function ia(e,t){let n=Cd(e?.trim()??"");if(n){let r=n(1);for(let a=2;t.has(r)&&a<1e3;a+=1)r=n(a);if(!t.has(r))return r}let o=0;for(;t.has(B(o));)o+=1;return B(o)}function Cd(e){if(!e)return null;let t=/^([A-Za-z])\1+$/.exec(e);if(t){let i=e===e.toLowerCase(),s=t[1].toUpperCase().charCodeAt(0)-65;return c=>{let l=s+c,f=String.fromCharCode(65+l%26).repeat(e.length+Math.floor(l/26));return i?f.toLowerCase():f}}let n=/^(.*?)(\d+)$/.exec(e);if(n){let[,i,s]=n,c=s.startsWith("0")?s.length:0;return l=>`${i}${String(Number(s)+l).padStart(c,"0")}`}let o=e.toUpperCase(),r=on(o);if(r==null)return null;let a=e===e.toLowerCase();return i=>{let s=B(r+i);return a?s.toLowerCase():s}}function Io(e){return e.segmentedRow?.displayLabel??e.displayLabel??e.label}function Od(e,t=[]){let n=new Set([...ee(e),...t].filter(r=>r.type==="row"||r.type==="table"||r.type==="booth").map(r=>r.label).filter(r=>typeof r=="string")),o=0;return()=>{for(;n.has(B(o));)o+=1;let r=B(o);return n.add(r),o+=1,r}}function Pd(e){let t=new Set(e.flatMap(o=>o.type==="row"?[Io(o)]:o.type==="table"||o.type==="booth"?[o.label]:[])),n=0;return()=>{for(;t.has(B(n));)n+=1;let o=B(n);return t.add(o),o}}function Ad(e,t){let n=e.filter(c=>c.type==="section"),o=n.find(c=>J(t,c.outline,c.holes));if(!o)return Pd(e);let r=e.filter(c=>c.type==="row"&&Xt(e,c,n)===o),a=new Set(r.map(Io)),i=r[r.length-1],s=i?Io(i):void 0;return()=>{let c=ia(s,a);return a.add(c),s=c,c}}function aa(e,t){let n=t.pending??[],o=Od(e,n),r=Ad([...O(e,t.floorId).objects,...n],t.origin);return Array.from({length:Math.max(0,t.count)},()=>{let a=o(),i=r?.();return i&&i!==a?{label:a,displayLabel:i}:{label:a}})}function sa(e){return JSON.stringify(["row-block-v1",e.style,e.origin.x,e.origin.y,e.rotation,e.rowCount,e.seatsPerRow,e.rowGap,e.seatSpacing,e.curve])}function vo(e,t){if(D(e,t.categoryKey),!Number.isInteger(t.rowCount)||t.rowCount<1||t.rowCount>100)throw new u("invalid_operation","rowCount must be an integer from 1 to 100");if(!Number.isInteger(t.seatsPerRow)||t.seatsPerRow<1||t.seatsPerRow>300)throw new u("invalid_operation","seatsPerRow must be an integer from 1 to 300");let n=t.rowGap??28,o=t.seatSpacing??24;if(!Number.isFinite(n)||n<=0||!Number.isFinite(o)||o<=0)throw new u("invalid_operation","Row and seat spacing must be positive finite values");if(t.rotation!==void 0&&!Number.isFinite(t.rotation))throw new u("invalid_operation","rotation must be a finite number of degrees");let r=O(e,t.floorId),a=new Set,i=aa(e,{floorId:t.floorId,origin:t.origin,count:t.rowCount}),s=cn(t.rotation??0),c=t.curve??0,l=t.style,d=l?E(e,"rowblock",t.idFactory,a):void 0,f=l?sa({style:l,origin:t.origin,rotation:s,rowCount:t.rowCount,seatsPerRow:t.seatsPerRow,rowGap:n,seatSpacing:o,curve:c}):void 0,g={x:Math.cos(s*fe),y:Math.sin(s*fe)},h={x:-g.y,y:g.x},b=Array.from({length:t.rowCount},(I,y)=>{let w=l==="intertwined"&&y%2===1?o/2:0,S={type:"row",id:E(e,"r",t.idFactory,a),...i[y],origin:{x:t.origin.x+h.x*y*n+g.x*w,y:t.origin.y+h.y*y*n+g.y*w},rotation:s,curve:c,seatCount:t.seatsPerRow,seatSpacing:o,categoryKey:t.categoryKey};return l&&d&&f&&(S.rowBlockGeneration={kind:"row-block-v1",groupId:d,style:l,rowIndex:y,rowCount:t.rowCount,seatsPerRow:t.seatsPerRow,origin:{...t.origin},rotation:s,rowGap:n,seatSpacing:o,curve:c,signature:f}),S});r.objects.push(...b);let p=null,x=t.sectionLabel?.trim();if(x){let I=Ce(b);if(I){let y={type:"section",id:E(e,"sec",t.idFactory,a),label:x,outline:I};r.objects.push(y),p=y.id}}return{floorId:r.floorId,rowIds:b.map(I=>I.id),sectionId:p,createdIds:[...b.map(I=>I.id),...p?[p]:[]]}}function ca(e,t){let n=new Set(ee(e).filter(r=>r.type==="row"||r.type==="table"||r.type==="booth").map(r=>r.label).filter(r=>typeof r=="string")),o=1;return()=>{for(;n.has(`${t}${o}`);)o+=1;let r=`${t}${o}`;return n.add(r),o+=1,r}}function Md(e,t){let n=new Set(ee(e).filter(r=>r.type==="gaArea").map(r=>r.label));if(!n.has(t))return t;let o=2;for(;n.has(`${t} ${o}`);)o+=1;return`${t} ${o}`}var Rd=456;function wn(e){let t=Math.sqrt(Math.max(1,e)*Rd);return{width:Math.round(t*1.027),height:Math.round(t/1.027)}}function Co(e,t){if(D(e,t.categoryKey),!Number.isInteger(t.capacity)||t.capacity<1)throw new u("invalid_operation","capacity must be a positive integer");if(!Number.isFinite(t.center.x)||!Number.isFinite(t.center.y))throw new u("invalid_operation","GA area center must be finite");let n=O(e,t.floorId),o=new Set,{width:r,height:a}=wn(t.capacity),i=Md(e,(t.label??"General Admission").trim()||"General Admission"),s={type:"gaArea",id:E(e,"ga",t.idFactory,o),label:i,...t.displayLabel?.trim()?{displayLabel:t.displayLabel.trim()}:{},points:[{x:t.center.x-r/2,y:t.center.y-a/2},{x:t.center.x+r/2,y:t.center.y-a/2},{x:t.center.x+r/2,y:t.center.y+a/2},{x:t.center.x-r/2,y:t.center.y+a/2}],capacity:t.capacity,categoryKey:t.categoryKey};return n.objects.push(s),{floorId:n.floorId,gaAreaId:s.id,label:i,createdIds:[s.id]}}function Oo(e,t){if(D(e,t.categoryKey),!Number.isInteger(t.tableRows)||t.tableRows<1||t.tableRows>20||!Number.isInteger(t.tableColumns)||t.tableColumns<1||t.tableColumns>20)throw new u("invalid_operation","tableRows and tableColumns must be integers from 1 to 20");if(!Number.isInteger(t.seatsPerTable)||t.seatsPerTable<1||t.seatsPerTable>20)throw new u("invalid_operation","seatsPerTable must be an integer from 1 to 20");let n=t.gapX??155,o=t.gapY??150;if(!Number.isFinite(n)||n<80||!Number.isFinite(o)||o<80)throw new u("invalid_operation","Table spacing must be at least 80 chart units");if(!Number.isFinite(t.center.x)||!Number.isFinite(t.center.y))throw new u("invalid_operation","Table array center must be finite");let r=O(e,t.floorId),a=new Set,i=ca(e,"T"),s=[];for(let c=0;c<t.tableRows;c+=1)for(let l=0;l<t.tableColumns;l+=1)s.push({type:"table",id:E(e,"t",t.idFactory,a),label:i(),center:{x:t.center.x+(l-(t.tableColumns-1)/2)*n,y:t.center.y+(c-(t.tableRows-1)/2)*o},rotation:0,categoryKey:t.categoryKey,seatCount:t.seatsPerTable,...t.shape==="round"?{shape:"round",radius:46}:{shape:"rect",sides:["top","bottom"],width:120,height:58}});return r.objects.push(...s),{floorId:r.floorId,tableIds:s.map(c=>c.id),createdIds:s.map(c=>c.id)}}function Po(e,t){if(D(e,t.categoryKey),!Number.isInteger(t.boothRows)||t.boothRows<1||t.boothRows>30||!Number.isInteger(t.boothColumns)||t.boothColumns<1||t.boothColumns>30)throw new u("invalid_operation","boothRows and boothColumns must be integers from 1 to 30");let n=t.gapX??88,o=t.gapY??82;if(!Number.isFinite(n)||n<62||!Number.isFinite(o)||o<52)throw new u("invalid_operation","Booth spacing must clear the 62\xD752 booth footprint");if(!Number.isFinite(t.center.x)||!Number.isFinite(t.center.y))throw new u("invalid_operation","Booth array center must be finite");let r=O(e,t.floorId),a=new Set,i=ca(e,"B"),s=[];for(let c=0;c<t.boothRows;c+=1)for(let l=0;l<t.boothColumns;l+=1)s.push({type:"booth",id:E(e,"booth",t.idFactory,a),label:i(),center:{x:t.center.x+(l-(t.boothColumns-1)/2)*n,y:t.center.y+(c-(t.boothRows-1)/2)*o},width:62,height:52,rotation:0,categoryKey:t.categoryKey});return r.objects.push(...s),{floorId:r.floorId,boothIds:s.map(c=>c.id),createdIds:s.map(c=>c.id)}}function Ao(e,t){let n=O(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2||o.length>64)throw new u("invalid_operation","A segmented row requires 2 to 64 ordered component rows");if(t.boundaries.length!==o.length-1||t.boundaries.some(g=>g!=="continuous"&&g!=="break"))throw new u("invalid_operation","Declare one continuous or break boundary between every pair of row components");let r=o.map(g=>n.objects.find(h=>h.type==="row"&&h.id===g)),a=o.filter((g,h)=>!r[h]);if(a.length)throw new u("object_not_found","One or more segmented-row components do not exist on the selected floor",{rowIds:a});let i=r,s=i.filter(g=>g.segmentedRow);if(s.length)throw new u("invalid_operation","Ungroup existing segmented rows before combining their components again",{rowIds:s.map(g=>g.id)});let c=(t.displayLabel??i[0].displayLabel??i[0].label).normalize("NFKC").trim();if(!c||c.length>80)throw new u("invalid_operation","Segmented-row display label must contain 1 to 80 characters");let l=new Set(n.objects.flatMap(g=>g.type==="row"?[g.segmentedRow?.groupId,g.rowBlockGeneration?.groupId].filter(h=>!!h):[])),d="";for(let g=0;g<100;g+=1){let h=t.idFactory("rowgroup");if(h&&!l.has(h)){d=h;break}}if(!d)throw new u("id_generation_failed","Unable to allocate a segmented-row group id");let f=i[0];return i.forEach((g,h)=>{g.segmentedRow={kind:"segmented-row-v1",groupId:d,componentIndex:h,componentCount:i.length,boundaryBefore:h===0?"start":t.boundaries[h-1],displayLabel:c,...f.displayType?{displayType:f.displayType}:{},...f.labelPresentation?{labelPresentation:structuredClone(f.labelPresentation)}:{},...f.viewFromSeatUrl?{viewFromSeatUrl:f.viewFromSeatUrl}:{},...f.viewFromSeatMeta?{viewFromSeatMeta:structuredClone(f.viewFromSeatMeta)}:{},...f.confidenceEvidence?{confidenceEvidence:structuredClone(f.confidenceEvidence)}:{}}}),{floorId:n.floorId,groupId:d,rowIds:o,changed:!0}}function _d(e,t){let n=O(e,t.floorId),o=t.groupId?n.objects.find(s=>s.type==="row"&&s.segmentedRow?.groupId===t.groupId):n.objects.find(s=>s.type==="row"&&s.id===t.rowId),r=t.groupId??o?.segmentedRow?.groupId;if(!r)throw new u("object_not_found","The segmented row does not exist on the selected floor");let a=n.objects.filter(s=>s.type==="row"&&s.segmentedRow?.groupId===r);if(!a.length)throw new u("object_not_found","The segmented row does not exist on the selected floor");let i=a.sort((s,c)=>s.segmentedRow.componentIndex-c.segmentedRow.componentIndex).map(s=>s.id);for(let s of a)delete s.segmentedRow;return{floorId:n.floorId,groupId:r,rowIds:i,changed:!0}}function Ld(e,t){let n=O(e,t.floorId),o=n.objects.filter(i=>i.type==="row"&&i.segmentedRow?.groupId===t.groupId).sort((i,s)=>i.segmentedRow.componentIndex-s.segmentedRow.componentIndex);if(o.length<2)throw new u("object_not_found","The segmented row is incomplete or missing on the selected floor");if(t.boundaries&&(t.boundaries.length!==o.length-1||t.boundaries.some(i=>i!=="continuous"&&i!=="break")))throw new u("invalid_operation","Declare one continuous or break boundary between every pair of row components");let r=t.displayLabel?.normalize("NFKC").trim();if(r!==void 0&&(!r||r.length>80))throw new u("invalid_operation","Segmented-row display label must contain 1 to 80 characters");let a=JSON.stringify(o.map(i=>i.segmentedRow));return o.forEach((i,s)=>{let c=i.segmentedRow,l=c.viewFromSeatUrl;r!==void 0&&(c.displayLabel=r),t.boundaries&&s>0&&(c.boundaryBefore=t.boundaries[s-1]),t.smoothing!==void 0&&(c.smoothing=t.smoothing||void 0),t.viewFromSeatUrl===null?delete c.viewFromSeatUrl:t.viewFromSeatUrl!==void 0&&(c.viewFromSeatUrl=t.viewFromSeatUrl),!c.viewFromSeatUrl||t.viewFromSeatMeta===null?delete c.viewFromSeatMeta:t.viewFromSeatMeta!==void 0?c.viewFromSeatMeta=structuredClone(t.viewFromSeatMeta):t.viewFromSeatUrl!==void 0&&c.viewFromSeatUrl!==l&&delete c.viewFromSeatMeta}),{floorId:n.floorId,groupId:t.groupId,rowIds:o.map(i=>i.id),changed:JSON.stringify(o.map(i=>i.segmentedRow))!==a}}function kd(e,t){if(typeof t.groupId!="string"||!t.groupId)throw new u("invalid_operation","This row block was edited manually or is incomplete; repair or recreate it before regeneration",{groupId:t.groupId});let n=O(e,t.floorId),o=n.objects.filter(M=>M.type==="row"&&M.rowBlockGeneration?.groupId===t.groupId).sort((M,ne)=>M.rowBlockGeneration.rowIndex-ne.rowBlockGeneration.rowIndex),r=o[0]?.rowBlockGeneration;if(!r||o.length!==r.rowCount||o.some((M,ne)=>{let R=M.rowBlockGeneration;return R.kind!=="row-block-v1"||R.rowIndex!==ne||R.signature!==r.signature||JSON.stringify(R)!==JSON.stringify({...r,rowIndex:ne})}))throw new u("invalid_operation","This row block was edited manually or is incomplete; repair or recreate it before regeneration",{groupId:t.groupId});let a=JSON.stringify(o),i=t.style??r.style,s=t.rowCount??r.rowCount,c=t.seatsPerRow??r.seatsPerRow,l=t.rowGap??r.rowGap,d=t.seatSpacing??r.seatSpacing,f=t.curve??r.curve,g=Number.isFinite(t.rotation??r.rotation)?cn(t.rotation??r.rotation):t.rotation??r.rotation,h=t.origin?{...t.origin}:{...r.origin};if(!Number.isInteger(s)||s<1||s>100)throw new u("invalid_operation","rowCount must be an integer from 1 to 100");if(!Number.isInteger(c)||c<1||c>300)throw new u("invalid_operation","seatsPerRow must be an integer from 1 to 300");if(![l,d].every(M=>Number.isFinite(M)&&M>0)||!Number.isFinite(f)||!Number.isFinite(g)||!Number.isFinite(h.x)||!Number.isFinite(h.y))throw new u("invalid_operation","Row-block geometry must use positive spacing and finite origin, rotation, and curve values");let b=sa({style:i,origin:h,rotation:g,rowCount:s,seatsPerRow:c,rowGap:l,seatSpacing:d,curve:f}),p={x:Math.cos(g*fe),y:Math.sin(g*fe)},x={x:-p.y,y:p.x},I=new Map(o.map(M=>[M.rowBlockGeneration.rowIndex,M])),y=new Set,w=new Set(n.objects.filter(M=>M.type==="row").filter(M=>!o.includes(M)).map(M=>M.label)),S=n.objects.filter(M=>M.type==="row").length,m=()=>{for(;w.has(B(S));)S+=1;let M=B(S);return w.add(M),S+=1,M},v=[],C=[];for(let M=0;M<s;M+=1){let ne=i==="intertwined"&&M%2===1?d/2:0,R=I.get(M);R||(R={type:"row",id:E(e,"r",t.idFactory,y),label:m(),origin:{...h},rotation:g,curve:f,seatCount:c,seatSpacing:d,categoryKey:o[0].categoryKey},C.push(R.id)),R.origin={x:h.x+x.x*M*l+p.x*ne,y:h.y+x.y*M*l+p.y*ne},R.rotation=g,R.curve=f,R.seatCount=c,R.seatSpacing=d,delete R.path,delete R.arcFanGeneration,R.overrides&&(R.overrides=R.overrides.filter(oe=>oe.index<c),R.overrides.length||delete R.overrides),R.rowBlockGeneration={kind:"row-block-v1",groupId:t.groupId,style:i,rowIndex:M,rowCount:s,seatsPerRow:c,origin:{...h},rotation:g,rowGap:l,seatSpacing:d,curve:f,signature:b},v.push(R)}let P=o.slice(s).map(M=>M.id),j=Math.min(...o.map(M=>n.objects.indexOf(M))),q=new Set(o.map(M=>M.id)),Y=n.objects.filter(M=>!q.has(M.id));return Y.splice(j,0,...v),n.objects.splice(0,n.objects.length,...Y),{floorId:n.floorId,groupId:t.groupId,rowIds:v.map(M=>M.id),createdRowIds:C,removedRowIds:P,changed:a!==JSON.stringify(v)||C.length>0||P.length>0}}function la(e){let t=0;for(let n=1;n<e.length;n+=1)t+=Math.hypot(e[n].x-e[n-1].x,e[n].y-e[n-1].y);return t/Math.max(1,e.length-1)}function Ed(e){let t=e.length,n=e.reduce((I,y)=>I+y.x,0)/t,o=e.reduce((I,y)=>I+y.y,0)/t,r=0,a=0,i=0,s=0,c=0,l=0,d=0;for(let I of e){let y=I.x-n,w=I.y-o;r+=y*y,a+=w*w,i+=y*w,s+=y*y*y,c+=w*w*w,l+=y*w*w,d+=w*y*y}let f=r*a-i*i;if(Math.abs(f)<1e-9)return null;let g=(s+l)/2,h=(c+d)/2,b=(g*a-h*i)/f,p=(h*r-g*i)/f,x=Math.sqrt(b*b+p*p+(r+a)/t);return Number.isFinite(x)?{center:{x:b+n,y:p+o},radius:x}:null}function Pt(e){let t=e[0],n=e[e.length-1],o=Math.hypot(n.x-t.x,n.y-t.y),r=e.length;return{origin:{...t},rotation:o>0?Math.atan2(n.y-t.y,n.x-t.x)*180/Math.PI:0,curve:0,seatSpacing:r>1&&o>0?o/(r-1):la(e),seatCount:r,ordered:e}}function Td(e){if(e.length<3)return Pt(e);let t=e[0],n=e[e.length-1],o=Math.hypot(n.x-t.x,n.y-t.y),r=la(e);if(o<=0||r<=0)return Pt(e);let a=0;for(let g of e){let h=Math.abs((n.x-t.x)*(t.y-g.y)-(t.x-g.x)*(n.y-t.y))/o;a=Math.max(a,h)}if(a<r*.2)return Pt(e);let i=Ed(e);if(!i||i.radius<=r/2)return Pt(e);let s=g=>{let h=g[0],b=g[1],p=h.x-i.center.x,I=-(h.y-i.center.y),y=p;I*(b.x-h.x)+y*(b.y-h.y)<0&&(I=-I,y=-y);let w=Math.hypot(I,y)||1;I/=w,y/=w;let S=(i.center.x-h.x)*y+(i.center.y-h.y)*-I;return{tx:I,ty:y,centreSide:S}},c=e,l=s(c);l.centreSide<0&&(c=[...e].reverse(),l=s(c));let f=2*Math.asin(Math.min(1,r/(2*i.radius)))*(c.length-1)*180/Math.PI;return!Number.isFinite(f)||f>=359?Pt(e):{origin:{...c[0]},rotation:Math.atan2(l.ty,l.tx)*180/Math.PI,curve:f,seatSpacing:r,seatCount:c.length,ordered:c}}function xn(e,t){let n=Td(e);if(e.length<6)return[n];let o=t(n),r=-1,a=0;if(n.ordered.forEach((s,c)=>{let l=o[c]?Math.hypot(s.x-o[c].x,s.y-o[c].y):1/0;l>a&&(a=l,r=c)}),a<=n.seatSpacing/3)return[n];let i=Math.min(n.ordered.length-3,Math.max(3,r));return[...xn(n.ordered.slice(0,i),t),...xn(n.ordered.slice(i),t)]}function Mo(e){return e.normalize("NFKC").replace(/\s+/g," ").trim()}function Ro(e,t){let n="";for(let o of e){if(n.length+o.length>t)break;n+=o}return n.trim()}function _o(e){return Ro(Mo(e),40)}function da(e,t=39){return Ro(Mo(e),Math.max(1,t))}function Je(e,t=80){return Ro(Mo(e),Math.max(1,t))}function ua(e){return Je(e).toLocaleLowerCase("en")}function Lo(e){return ua(e)}function fa(e){return new Map((e??[]).map(t=>[t.index,t]))}function jd(e){let t=fa(e.overrides),n=[];for(let o=0;o<e.seatCount;o+=1){let r=t.get(o);r?.skip||n.push(ge(e,o,r))}return n}function Fd(e){if(e.bookAsWhole||e.variableOccupancy)return[e.label];let t=fa(e.overrides),n=[];for(let o=0;o<e.seatCount;o+=1){let r=t.get(o);r?.skip||n.push(r?.label??`${e.label}-${o+1}`)}return n}function Nd(e){return e.type==="row"?[e.label,...jd(e)]:e.type==="table"?[e.label,...Fd(e)]:e.type==="booth"?[e.label]:e.type==="gaArea"?[e.label,...le(e)]:[]}function ha(e,t){let n=new Set;for(let o of e)if(!t?.has(o.id))for(let r of Nd(o)){let a=Lo(r);a&&n.add(a)}return n}function Dd(e,t){if(!Number.isInteger(t)||t<1)return[];let n={label:e,seatCount:t},o=[Lo(e)];for(let r=0;r<t;r+=1)o.push(Lo(ge(n,r)));return o.filter(Boolean)}function ga(e,t,n){let o=Dd(t,n);if(!o.length||o.some(r=>e.has(r)||Ae(r)))return!1;for(let r of o)e.add(r);return!0}var Gd=1e-6,$d=160,Bd=.001,Kd=1e-5;function We(e){if(typeof e!="string")return;let t=e.normalize("NFKC").replace(/\s+/g," ").trim();if(!t||t.length>$d)return;for(let a of t){let i=a.codePointAt(0)??0;if(i<32||i===127)return}let n=t.lastIndexOf(":"),o=t.slice(0,n),r=t.slice(n+1);if(!(!o||!/^(0|[1-9]\d*)$/.test(r)||!Number.isSafeInteger(Number(r))))return t}function ba(e){return typeof e=="string"&&da(e)||void 0}function ma(e,t){if(e.seatCount!==t.seatCount||e.seatCount<1||!(ko(e.origin)&&ko(t.start)&&ko(t.end)&&Number.isFinite(e.rotation)&&Number.isFinite(e.seatSpacing)&&e.seatSpacing>0)||e.curve!==0||e.path)return!1;let n=e.rotation*Math.PI/180,o={x:e.origin.x+Math.cos(n)*e.seatSpacing*(e.seatCount-1),y:e.origin.y+Math.sin(n)*e.seatSpacing*(e.seatCount-1)},r=Math.hypot(t.end.x-t.start.x,t.end.y-t.start.y),a=Bd+Math.max(1,r)*Kd;if(Math.hypot(e.origin.x-t.start.x,e.origin.y-t.start.y)>a||Math.hypot(o.x-t.end.x,o.y-t.end.y)>a)return!1;if(e.seatCount<2||r<=Gd)return!0;let i=r/(e.seatCount-1);if(Math.abs(e.seatSpacing-i)>a)return!1;let s=Math.atan2(t.end.y-t.start.y,t.end.x-t.start.x)*180/Math.PI,c=Math.abs(((e.rotation-s)%360+540)%360-180),l=Math.max(.001,Math.atan2(a,Math.max(1,r))*180/Math.PI);return c<=l}function ko(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}var zd=300;function Ud(e){let t=new Set(ee(e).filter(r=>r.type==="row"||r.type==="table"||r.type==="booth").map(r=>r.label).filter(Boolean)),n=0,o=()=>{for(;t.has(B(n));)n+=1;let r=B(n);return n+=1,t.add(r),r};return r=>{let a=_o(r),i=0;return()=>{for(;a&&i<4096;i+=1){let s=`${a}-${B(i)}`;if(!t.has(s))return t.add(s),i+=1,s}return o()}}}function Hd(e){let t=ha(ee(e));return(n,o)=>{let r=Je(n);for(let a=1;a<4096;a+=1){let i=a===1?"":` ${a}`,s=i?`${Je(r,80-i.length)}${i}`:r;if(s&&ga(t,s,o))return s}throw new Error("No collision-safe row identity is available for this reviewed direct seating row")}}function Vd(e){return{ordinaryFor:Ud(e),direct:Hd(e)}}function Eo(e,t,n){return e.type==="row"&&e.referenceScan?.assetId===t&&(!n||e.referenceScan.sectionId===n)}function pa(e,t,n){return e.type==="table"&&e.referenceScan?.assetId===t&&(!n||e.referenceScan.sectionId===n)}function Xd(e,t,n){let o=new Map;for(let i of t.sections)if(!(n&&i.sectionId!==n)&&i.sourceGroupId)for(let[s,c]of i.rows.entries()){let l=We(`${i.sourceGroupId}:${s}`),d=l&&We(c.directSourceRowId)===l?l:void 0;d&&o.set(d,o.has(d)?null:c)}let r=new Map;for(let i of e){let s=We(i.referenceScan?.directSourceRowId);if(!s){if(!i.overrides?.length)continue;throw new u("invalid_operation","This earlier imported row has seat overrides but no immutable source-row id. Keep it, remove its overrides, or restore the original import before rereading.",{rowId:i.id})}let c=r.get(s)??[];c.push(i),r.set(s,c)}let a=new Map;for(let[i,s]of r){let c=s.filter(g=>g.overrides?.length);if(!c.length)continue;let l=o.get(i),d=c[0],f=d.overrides;if(s.length!==1||c.length!==1||!f||!l||!ma(d,l))throw new u("invalid_operation","This reread would replace a row with seat overrides using different source geometry. Keep the existing row or remove its overrides before rereading.",{sourceRowId:i,rowIds:s.map(g=>g.id)});a.set(i,structuredClone(f))}return a}function ya(e,t,n){return e.filter(o=>(o.type==="row"||o.type==="table"||o.type==="booth"||o.type==="gaArea")&&!Eo(o,t,n)&&!pa(o,t,n))}function qd(e,t,n,o,r,a,i){let s=e.sectionId?t.find(d=>d.type==="section"&&d.id===e.sectionId):void 0;if(s){let d=ya(t,n,i).filter(f=>J(H(f),s.outline,s.holes));if(d.length)return{skip:{sectionId:s.id,name:e.name,reason:"section_not_empty",objectIds:d.map(f=>f.id)},rows:[],seats:0}}let c=[],l=0;for(let[d,f]of e.rows.entries()){let g=Math.min(zd,Math.max(1,Math.round(f.seatCount)));if(!Number.isFinite(g)||g<1)continue;let h=f.end.x-f.start.x,b=f.end.y-f.start.y,p=Math.hypot(h,b),x=g>1&&p>0?p/(g-1):o>0?o:24;if(!Number.isFinite(x)||x<=0)continue;let I=p>0?Math.atan2(b,h)*180/Math.PI:0,y={x:f.start.x,y:f.start.y},w=0,S=x,m,v=f.seats?.length===g&&f.seats.every(R=>Number.isFinite(R.x)&&Number.isFinite(R.y))?f.seats:null;if(v&&f.table&&g>=3){let R=f.table.center,oe=v.reduce(($,W)=>$+Math.hypot(W.x-R.x,W.y-R.y),0)/g,se=v.map($=>Math.atan2($.y-R.y,$.x-R.x)).sort(($,W)=>$-W),ve=0,jt=0;se.forEach(($,W)=>{let ke=W+1<se.length?se[W+1]:se[0]+Math.PI*2;ke-$>ve&&(ve=ke-$,jt=(W+1)%se.length)});let A=ve>1.6*(Math.PI*2/g),k=A?(Math.PI*2-ve)*180/Math.PI:void 0;m={center:{...R},radius:Math.max(1,oe-we),...k!==void 0?{seatArc:k}:{}},I=A?(se[jt]-ve/2)*180/Math.PI:se[0]*180/Math.PI,y={...R}}let C=[];if(v&&!m&&g>=3){C=xn(v,oe=>ae({origin:oe.origin,rotation:oe.rotation,curve:oe.curve,seatCount:oe.seatCount,seatSpacing:oe.seatSpacing}));let R=C[0];y=R.origin,I=R.rotation,w=R.curve,S=R.seatSpacing}if(!Number.isFinite(S)||S<=0)continue;let P=e.sourceGroupId?We(`${e.sourceGroupId}:${d}`):void 0,j=P&&We(f.directSourceRowId)===P?P:void 0,q=j?ba(f.directReviewedSuffix):void 0,Y=e.sourceGroupId&&f.rowLabel?Je(f.rowLabel):"",M=e.sourceGroupId&&f.rowDisplayLabel?Je(f.rowDisplayLabel):"",ne=!!e.sourceGroupId&&f.rowDisplayLabel==="";c.push({label:Y?a(Y,g):r(),displayLabel:M||(ne?"":String(d+1)),origin:y,rotation:I,curve:w,seatCount:C[0]?.seatCount??g,seatSpacing:S,...m?{table:m}:{},...v&&!m?{measured:!0}:{},...j?{directSourceRowId:j}:{},...q?{directReviewedSuffix:q}:{}});for(let R of C.slice(1))c.push({label:r(),displayLabel:String(d+1),origin:R.origin,rotation:R.rotation,curve:R.curve,seatCount:R.seatCount,seatSpacing:R.seatSpacing,measured:!0});l+=g}return{skip:null,rows:c,seats:l}}function Yd(e,t,n){D(e,n.categoryKey);let o=O(e,n.floorId),r=t.assetId,a=n.sectionId?o.objects.find(y=>y.type==="section"&&y.id===n.sectionId):void 0;if(n.sectionId&&!a)throw new Error("The opened section no longer exists on this floor");let i=new Map;for(let y of t.sections){if(a&&y.sectionId!==a.id)continue;let w=n.categoryKeyForSection?.(y)??n.categoryKey;D(e,w),i.set(y,w)}if(a&&!t.sections.some(y=>y.sectionId===a.id&&y.seatCount>0))return{floorId:o.floorId,assetId:r,createdRowIds:[],removedRowIds:[],totalSeats:0,perSection:[],skipped:[]};let s=a?t.sections.find(y=>y.sectionId===a.id&&y.seatCount>0):void 0;if(a&&s){let y=ya(o.objects,r,a.id).filter(w=>J(H(w),a.outline,a.holes));if(y.length)return{floorId:o.floorId,assetId:r,createdRowIds:[],removedRowIds:[],totalSeats:0,perSection:[],skipped:[{sectionId:a.id,name:s.name,reason:"section_not_empty",objectIds:y.map(w=>w.id)}]}}let c=o.objects.filter(y=>Eo(y,r,a?.id)),l=Xd(c,t,a?.id),d=[],f=o.objects.filter(y=>Eo(y,r,a?.id)||pa(y,r,a?.id)?(d.push(y.id),!1):!0);o.objects.splice(0,o.objects.length,...f);let g=[],h=[],b=[],p=new Set,x=0,I=Vd(e);for(let y of t.sections){if(a&&y.sectionId!==a.id)continue;let w=qd(y,o.objects,r,t.seatPitch,I.ordinaryFor(y.name),I.direct,a?.id);if(w.skip){h.push(w.skip);continue}let S=[],m=[],v=0;for(let C of w.rows){let P={assetId:r,...y.sectionId?{sectionId:y.sectionId}:{}},j=i.get(y)??n.categoryKey;if(C.table){v+=1,S.push({type:"table",id:E(e,"t",n.idFactory,p),referenceScan:P,label:C.label,displayLabel:String(v),center:C.table.center,shape:"round",radius:C.table.radius,...C.table.seatArc!==void 0?{seatArc:C.table.seatArc}:{},rotation:C.rotation,seatCount:C.seatCount,categoryKey:j});continue}let q={type:"row",id:E(e,"r",n.idFactory,p),referenceScan:{...P,...C.directSourceRowId?{directSourceRowId:C.directSourceRowId}:{},...C.directReviewedSuffix?{directReviewedSuffix:C.directReviewedSuffix}:{}},label:C.label,...C.displayLabel!==void 0?{displayLabel:C.displayLabel}:{},origin:C.origin,rotation:C.rotation,curve:C.curve,seatCount:C.seatCount,seatSpacing:C.seatSpacing,categoryKey:j,...C.directSourceRowId&&l.has(C.directSourceRowId)?{overrides:structuredClone(l.get(C.directSourceRowId))}:{}};S.push(q),C.measured&&m.push(q)}if(o.objects.push(...S),m.length&&!y.sourceGroupId){let C=T(e).find(P=>P.id===o.floorId);Jd(e,m,C?.focalPoint??e.focalPoint,o.floorId,n.idFactory)}for(let C of S)b.push(C.id);g.push({sectionId:y.sectionId,name:y.name,seats:w.seats,rows:S.length}),x+=w.seats}return{floorId:o.floorId,assetId:r,createdRowIds:b,removedRowIds:d,totalSeats:x,perSection:g,skipped:h}}function Jd(e,t,n,o,r){let a=t.map(h=>ae(h)),i=a.flat(),s=n??{x:i.reduce((h,b)=>h+b.x,0)/i.length,y:Math.min(...i.map(h=>h.y))-1},c=t.map((h,b)=>{let p=a[b],x=p.map((y,w)=>{let S=p[Math.max(0,w-1)],m=p[Math.min(p.length-1,w+1)],v=Math.hypot(m.x-S.x,m.y-S.y);return v<=0?Math.hypot(y.x-s.x,y.y-s.y):Math.abs((y.x-s.x)*(-(m.y-S.y)/v)+(y.y-s.y)*((m.x-S.x)/v))}).sort((y,w)=>y-w),I=p.reduce((y,w)=>y+w.x,0)/p.length;return{row:h,depth:x[Math.floor(x.length/2)],along:I}}).sort((h,b)=>h.depth-b.depth||h.along-b.along),l=c.slice(1).map((h,b)=>h.depth-c[b].depth).filter(h=>h>1e-6).sort((h,b)=>h-b),d=l.length?l[Math.floor(l.length*.75)]:1/0,f=[],g=-1/0;for(let h of c)(!f.length||h.depth-g>d*.45)&&(f.push([]),g=h.depth),f[f.length-1].push(h.row);f.forEach((h,b)=>{let p=B(b);h.sort((x,I)=>{let y=ae(x),w=ae(I);return y.reduce((S,m)=>S+m.x,0)/y.length-w.reduce((S,m)=>S+m.x,0)/w.length});for(let x of h)x.displayLabel=p;h.length>=2&&h.length<=64&&Ao(e,{floorId:o,rowIds:h.map(x=>x.id),boundaries:h.slice(1).map(()=>"break"),displayLabel:p,idFactory:r})})}function xa(e,t,n={}){let o=O(e,t.floorId),r=[...new Set(t.objectIds)];if(!r.length)throw new u("invalid_operation","Select at least one table or booth to repeat");let a=r.map(p=>o.objects.find(x=>(x.type==="table"||x.type==="booth")&&x.id===p)),i=r.filter((p,x)=>!a[x]);if(i.length)throw new u("object_not_found","One or more grid sources do not exist on the selected floor",{objectIds:i});let s=a[0].type;if(a.some(p=>p.type!==s))throw new u("invalid_operation","A grid array must contain only tables or only booths");for(let[p,x,I]of[["rows",t.rows,30],["columns",t.columns,30]])if(!Number.isInteger(x)||x<1||x>I)throw new u("invalid_operation",`${p} must be a whole number from 1 to ${I}`);for(let[p,x]of[["stepX",t.stepX],["stepY",t.stepY]])if(!Number.isFinite(x)||x<30||x>2e3)throw new u("invalid_operation",`${p} must be from 30 to 2000 chart units`);let c=t.rows*t.columns;if(c<2)throw new u("invalid_operation","Choose at least two grid cells");let l=r.length*(c-1);if(l>5e3)throw new u("invalid_operation","A grid array can add at most 5000 objects");let d=a.reduce((p,x)=>p+(x.type==="table"?x.seatCount:1),0),g=(e.floors?.length?e.floors.flatMap(p=>p.objects):e.objects).reduce((p,x)=>p+(x.type==="row"||x.type==="table"?x.seatCount:x.type==="gaArea"?Math.max(0,Math.floor(x.capacity)):x.type==="booth"?1:0),0),h=d*(c-1),b=n.maxInventory??1e5;if(g+h>b)throw new u("invalid_operation",`Grid inventory would exceed the ${b} unit event limit`);return{target:o,sources:a,preview:{floorId:o.floorId,kind:s,sourceIds:r,sourceCount:r.length,cells:c,createdCount:l,addedInventory:h,resultingInventory:g+h,provenanceRemovedCount:a.filter(p=>!!p.referenceInventorySource).length*(c-1)}}}function Wd(e,t,n={}){return xa(e,t,n).preview}function Zd(e,t,n={}){let{target:o,sources:r,preview:a}=xa(e,t,n),i=new Set,s=new Set((e.floors?.length?e.floors.flatMap(f=>f.objects):e.objects).flatMap(f=>"label"in f&&f.label?[f.label]:[])),c=[],l=(f,g)=>{let h=Math.max(2,g),b=x=>{let I=`-${x}`;return`${f.slice(0,Math.max(1,80-I.length))}${I}`},p=b(h);for(;s.has(p);)p=b(++h);return s.add(p),p},d=1;for(let f=0;f<t.rows;f++)for(let g=0;g<t.columns;g++)if(!(f===0&&g===0)){d+=1;for(let h of r){let b=structuredClone(h);b.id=E(e,b.type,t.idFactory,i),b.label=l(h.label,d),b.center={x:h.center.x+g*t.stepX,y:h.center.y+f*t.stepY},delete b.referenceInventorySource,c.push(b)}}return o.objects.push(...c),{...a,createdIds:c.map(f=>f.id)}}function Qd(e,t){let n=e?{...e}:{};return t.size===null?delete n.size:t.size!==void 0&&(n.size=t.size),t.color===null?delete n.color:t.color!==void 0&&(n.color=N(t.color,"Seat label color")),n.size===void 0&&n.color===void 0?void 0:n}var eu=new Set(mt.map(e=>e.key));function At(e){return`${e.rowId}:${e.index}`}function tu(e){let t=e.lastIndexOf(":"),n=t>0?e.slice(0,t):"",o=t>0?Number(e.slice(t+1)):Number.NaN;if(!n||!Number.isInteger(o)||o<0)throw new u("invalid_operation",`Invalid stable seat id: ${e}`,{seatId:e});return{rowId:n,index:o}}function nu(e,t){e.label||delete e.label,e.displayLabel||delete e.displayLabel,e.dx||delete e.dx,e.dy||delete e.dy,e.skip||delete e.skip,e.categoryKey||delete e.categoryKey,Ot(e.glyph)||delete e.glyph;let n=ft(e);if(n.length?e.accessibility=n:delete e.accessibility,delete e.accessible,e.commercial){let o=e.commercial.note?.normalize("NFKC").trim(),r={};typeof e.commercial.restrictedView=="boolean"&&(r.restrictedView=e.commercial.restrictedView),typeof e.commercial.obstructedView=="boolean"&&(r.obstructedView=e.commercial.obstructedView),typeof e.commercial.premium=="boolean"&&(r.premium=e.commercial.premium),o&&(r.note=o),Object.keys(r).length?e.commercial=r:delete e.commercial}e.viewFromSeatUrl||(delete e.viewFromSeatUrl,delete e.viewFromSeatMeta),e.labelStyle&&e.labelStyle.size===void 0&&e.labelStyle.color===void 0&&delete e.labelStyle,t?.type==="row"&&Jt(t,e)}function ou(e){return Object.keys(e).every(t=>t==="index")}function Sa(e,t,n){if(!n.length)throw new u("invalid_operation","At least one seat is required");let o=O(e,t),r=[],a=new Set,i=new Map;for(let s of n){let c=At(s);if(a.has(c))continue;a.add(c);let l=o.objects.find(d=>(d.type==="row"||d.type==="table")&&d.id===s.rowId);if(!l)throw new u("object_not_found",`Unknown row or table for seat: ${c}`,{seatId:c,objectId:s.rowId});if(l.type==="table"&&(l.bookAsWhole||l.variableOccupancy))throw new u("invalid_operation",`Table "${l.label}" is sold as one grouped unit; switch it to individual-chair selling before editing chairs`,{seatId:c,tableId:l.id});if(!Number.isInteger(s.index)||s.index<0||s.index>=l.seatCount)throw new u("invalid_operation",l.type==="row"?`Seat index is outside row bounds: ${c}`:`Chair index is outside table bounds: ${c}`,{seatId:c,objectId:s.rowId,index:s.index,seatCount:l.seatCount});r.push({rowId:s.rowId,index:s.index}),i.set(l.id,l)}return{floorId:o.floorId,refs:r,owners:i}}function To(e,t){let n=Sa(e,t.floorId,t.seats),o=Object.keys(t.patch);if(!o.length&&t.labelPrefix===void 0&&t.displayLabelPrefix===void 0)throw new u("invalid_operation","At least one seat override field is required");if(t.labelPrefix!==void 0&&Object.prototype.hasOwnProperty.call(t.patch,"label"))throw new u("invalid_operation","Use either label or labelPrefix, not both");if(t.displayLabelPrefix!==void 0&&Object.prototype.hasOwnProperty.call(t.patch,"displayLabel"))throw new u("invalid_operation","Use either displayLabel or displayLabelPrefix, not both");if(n.refs.length>1&&t.patch.label!=null)throw new u("invalid_operation","A literal label can only be assigned to one seat; use labelPrefix for a bulk sequence");if(n.refs.length>1&&t.patch.displayLabel!=null)throw new u("invalid_operation","A literal display label can only be assigned to one seat; use displayLabelPrefix for a bulk sequence");if(t.patch.categoryKey&&D(e,t.patch.categoryKey),t.patch.glyph!=null&&!Ot(t.patch.glyph))throw new u("invalid_operation","Unknown seat glyph",{glyph:t.patch.glyph});if(t.patch.accessibility){let a=t.patch.accessibility.filter(i=>!eu.has(i));if(a.length)throw new u("invalid_operation","Unknown accessibility type",{accessibility:a})}if(t.patch.wheelchairSpaceType!==void 0&&t.patch.wheelchairSpaceType!==null&&t.patch.wheelchairSpaceType!=="seat-present"&&t.patch.wheelchairSpaceType!=="no-seat")throw new u("invalid_operation","wheelchairSpaceType must be seat-present, no-seat, or null");if(t.patch.wheelchairSpaceType&&t.patch.skip===!0)throw new u("invalid_operation","A wheelchair-space physical type cannot also be skipped inventory");for(let a of n.refs){let i=n.owners.get(a.rowId)?.overrides?.find(l=>l.index===a.index),s=t.patch.wheelchairSpaceType===null?void 0:t.patch.wheelchairSpaceType??i?.wheelchairSpaceType,c=t.patch.skip===null?!1:t.patch.skip??i?.skip??!1;if(s&&c)throw new u("invalid_operation","A wheelchair-space physical type cannot also be skipped inventory",{seatId:At(a)})}if(t.patch.commercial?.note&&t.patch.commercial.note.normalize("NFKC").trim().length>160)throw new u("invalid_operation","Commercial note supports at most 160 characters");if(t.patch.viewFromSeatUrl!=null){let a=ye(t.patch.viewFromSeatUrl);if(!a)throw new u("invalid_operation","Seat view photo must be a safe HTTPS or base64 raster image reference");t.patch.viewFromSeatUrl=a}for(let a of["dx","dy"]){let i=t.patch[a];if(i!=null&&!Number.isFinite(i))throw new u("invalid_operation",`${a} must be finite`,{[a]:i})}t.patch.labelStyle!=null&&xe(t.patch.labelStyle,"Seat");let r=!1;return n.refs.forEach((a,i)=>{let s=n.owners.get(a.rowId),c=JSON.stringify(s.overrides??[]),l=s.overrides??(s.overrides=[]),d=l.find(g=>g.index===a.index);d||(d={index:a.index},l.push(d));let f=d.viewFromSeatUrl;for(let g of o){let h=t.patch[g];if(g==="wheelchairSpaceType"&&h==null)delete d.wheelchairSpaceType,d.accessibility&&(d.accessibility=d.accessibility.filter(b=>b!=="wheelchair"),d.accessibility.length||delete d.accessibility),delete d.accessible;else if(h==null)delete d[g];else if(g==="accessibility")d.accessibility=[...new Set(h)],delete d.accessible;else if(g==="commercial")d.commercial={...d.commercial,...h};else if(g==="labelStyle"){let b=Qd(d.labelStyle,h);b?d.labelStyle=b:delete d.labelStyle}else Object.assign(d,{[g]:h})}t.patch.viewFromSeatMeta===void 0&&t.patch.viewFromSeatUrl!==void 0&&d.viewFromSeatUrl!==f&&delete d.viewFromSeatMeta,t.labelPrefix!==void 0&&(d.label=`${t.labelPrefix}${i+1}`),t.displayLabelPrefix!==void 0&&(d.displayLabel=`${t.displayLabelPrefix}${i+1}`),nu(d,s),ou(d)&&(s.overrides=l.filter(g=>g!==d)),s.overrides?.length||delete s.overrides,JSON.stringify(s.overrides??[])!==c&&(r=!0)}),{floorId:n.floorId,changed:r,seatIds:n.refs.map(At)}}function ru(e,t){let n=Sa(e,t.floorId,t.seats),o=!1;for(let[r,a]of n.owners){if(!a.overrides?.length)continue;let i=new Set(n.refs.filter(c=>c.rowId===r).map(c=>c.index)),s=a.overrides.filter(c=>!i.has(c.index));s.length!==a.overrides.length&&(o=!0),a.overrides=s,a.overrides.length||delete a.overrides}return{floorId:n.floorId,changed:o,seatIds:n.refs.map(At)}}function iu(e,t){let n=O(e,t.floorId),o=[...new Set(t.rowIds)],r=o.map(w=>n.objects.find(S=>S.type==="row"&&S.id===w)),a=o.filter((w,S)=>!r[S]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});if(t.patch.categoryKey!==void 0&&D(e,t.patch.categoryKey),t.patch.seatCount!==void 0&&(!Number.isInteger(t.patch.seatCount)||t.patch.seatCount<1||t.patch.seatCount>300))throw new u("invalid_operation","seatCount must be an integer from 1 to 300");if(t.patch.seatNumbering!==void 0){let w=t.patch.seatNumbering,S=["decimal","odd","even","updown","updown-descending","roman","letters-upper","letters-lower"];if(w.scheme!==void 0&&!S.includes(w.scheme))throw new u("invalid_operation",`Unknown seat numbering scheme: ${w.scheme}. Expected one of ${S.join(", ")}.`);if(w.prefix!==void 0&&(typeof w.prefix!="string"||w.prefix.length>8))throw new u("invalid_operation","Seat label prefix must be a string of at most 8 characters");if(w.endAt!==void 0&&w.endAt!==null&&(!Number.isInteger(w.endAt)||w.endAt<0||w.endAt>9999))throw new u("invalid_operation","Seat numbering endAt must be an integer from 0 to 9999")}let{labelStyle:i,labelPosition:s,labelRotation:c,labelStyleShape:l,displayLabel:d,displayType:f,aisleSeats:g,...h}=t.patch,b=d===void 0?{}:{displayLabel:d},p=Ne(b,"Row"),x=f===void 0?void 0:zn(f,"Row");if(i!==void 0&&xe(i,"Row"),s!==void 0&&!["start","end","both","none"].includes(s))throw new u("invalid_operation","Row labelPosition must be one of start, end, both, none");if(c!=null&&(!Number.isFinite(c)||c<-180||c>180))throw new u("invalid_operation","Row labelRotation must be a number from -180 to 180");if(l!==void 0&&l!=="plain"&&l!=="pill")throw new u("invalid_operation","Row labelStyleShape must be plain or pill");if(h.labelPresentation!==void 0&&Zt(h.labelPresentation,"Row"),g!=null&&!qe(g))throw new u("invalid_operation","Row aisleSeats must be one of start, end, both, none (or null for automatic)");let I=w=>JSON.stringify({origin:w.origin,rotation:w.rotation,curve:w.curve,seatCount:w.seatCount,seatSpacing:w.seatSpacing,path:w.path??null}),y=!1;for(let w of r){let S=JSON.stringify(w),m=I(w),v=t.preserveCenterOnSeatCountChange&&t.patch.seatCount!==void 0?H(w):null;if(Object.assign(w,structuredClone(h)),w.overrides&&t.patch.seatCount!==void 0&&(w.overrides=w.overrides.filter(C=>C.index<w.seatCount),w.overrides.length||(w.overrides=void 0)),v){let C=H(w);w.origin={x:w.origin.x+v.x-C.x,y:w.origin.y+v.y-C.y}}if(JSON.stringify(w)!==S&&(y=!0),I(w)!==m&&(delete w.arcFanGeneration,delete w.rowBlockGeneration),i!==void 0){let C=JSON.stringify(w.labelPresentation??null),P=De(w.labelPresentation,i);P?w.labelPresentation=P:delete w.labelPresentation,JSON.stringify(w.labelPresentation??null)!==C&&(y=!0)}if(s!==void 0){let C=JSON.stringify(w.labelPresentation??null),P=w.labelPresentation?structuredClone(w.labelPresentation):{};P.positionPreset=s,P.visible=s!=="none",delete P.position,w.labelPresentation=P,JSON.stringify(w.labelPresentation??null)!==C&&(y=!0)}if(c!==void 0||l!==void 0){let C=JSON.stringify(w.labelPresentation??null),P=w.labelPresentation?structuredClone(w.labelPresentation):{};c===null?delete P.rotation:c!==void 0&&(P.rotation=c),l!==void 0&&(P.style=l),w.labelPresentation=P,JSON.stringify(w.labelPresentation??null)!==C&&(y=!0)}if(x!==void 0){let C=w.displayType;x?w.displayType=x:delete w.displayType,w.displayType!==C&&(y=!0)}if(g!==void 0){let C=w.aisleSeats;g===null?delete w.aisleSeats:w.aisleSeats=g,w.aisleSeats!==C&&(y=!0)}if(d!==void 0){let C=w.displayLabel;p?delete w.displayLabel:w.displayLabel=b.displayLabel,w.displayLabel!==C&&(y=!0)}}return{floorId:n.floorId,changed:y,rowIds:o}}var au=3;function Sn(e){return(e%360+360)%360}function su(e){let t=e.rotation*fe;return{x:Math.cos(t),y:Math.sin(t)}}function cu(e,t){let n=Math.abs(Sn(e-t));return n>180&&(n=360-n),n}function Ze(e,t,n){return(e.x-t.x)*n.x+(e.y-t.y)*n.y}function Ia(e){let t=0,n=0;for(let r of e){let a=2*r.rotation*fe;t+=Math.cos(a),n+=Math.sin(a)}let o=(t===0&&n===0?0:Math.atan2(n,t))/2;return{x:Math.cos(o),y:Math.sin(o)}}function lu(e,t,n){if(e.origin={x:e.origin.x+t,y:e.origin.y+n},e.path){let o=r=>({x:r.x+t,y:r.y+n});e.path={start:o(e.path.start),control1:o(e.path.control1),control2:o(e.path.control2),end:o(e.path.end)}}}function va(e,t){let n=Ia(e),o={x:-n.y,y:n.x},r=H(e[0]),a=e.map(c=>({row:c,coord:Ze(H(c),r,o)})).sort((c,l)=>c.coord-l.coord),i=a[0].coord,s=!1;return a.forEach((c,l)=>{let d=i+l*t-c.coord;Math.abs(d)>1e-6&&(lu(c.row,o.x*d,o.y*d),delete c.row.arcFanGeneration,delete c.row.rowBlockGeneration,s=!0)}),s}function du(e,t){let n={x:-t.y,y:t.x},o=H(e[0]),r=e.map(i=>Ze(H(i),o,n)).sort((i,s)=>i-s);if(r.length<2)return 28;let a=(r[r.length-1]-r[0])/(r.length-1);return a>.5?a:28}function uu(e){if(e.seatCount<2){e.curve=0,delete e.path,delete e.arcFanGeneration,delete e.rowBlockGeneration;return}let t=ae(e),n=t[0],o=t[t.length-1],r=o.x-n.x,a=o.y-n.y,i=Math.hypot(r,a);e.path&&(e.origin={...n},e.seatSpacing=Math.max(1,i/(e.seatCount-1))),i>1e-6&&(e.rotation=Sn(Math.atan2(a,r)/fe)),e.curve=0,delete e.path,delete e.arcFanGeneration,delete e.rowBlockGeneration}function fu(e,t){let n=new Set(e.filter(o=>o.type==="row").map(o=>o.label));for(let o=2;o<1e4;o++){let r=`${t}${o}`.slice(0,80);if(!n.has(r))return r}return`${t}-${Date.now().toString(36)}`}function hu(e,t){let n=O(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2)throw new u("invalid_operation","Select at least two rows to merge");let r=o.map(m=>n.objects.find(v=>v.type==="row"&&v.id===m)),a=o.filter((m,v)=>!r[v]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let i=r,s=i.filter(m=>m.path||m.curve!==0);if(s.length)throw new u("invalid_operation","Only straight rows can be merged. Straighten the rows first, then merge.",{rowIds:s.map(m=>m.id)});let c=i[0],l=i.find(m=>cu(m.rotation,c.rotation)>au);if(l)throw new u("invalid_operation","Rows must be parallel to merge. They point in different directions.",{rowIds:[c.id,l.id]});let d=su(c),f={x:-d.y,y:d.x},g=Math.max(8,c.seatSpacing*.6),h=i.find(m=>Math.abs(Ze(m.origin,c.origin,f))>g);if(h){let m=Math.round(Math.abs(Ze(h.origin,c.origin,f)));throw new u("invalid_operation",`Rows must lie on the same line to merge: a selected row is offset ${m} units from the first.`,{rowIds:[c.id,h.id]})}let b=i.slice().sort((m,v)=>Ze(m.origin,c.origin,d)-Ze(v.origin,c.origin,d)),p=b.reduce((m,v)=>m+v.seatCount,0);if(p>300)throw new u("invalid_operation",`A merged row would have ${p} seats, over the 300-seat row limit. Merge fewer rows.`);let x=b[0];Xi(b,x);let I=[],y=0;for(let m of b){if(m.overrides)for(let v of m.overrides)I.push({...structuredClone(v),index:v.index+y});y+=m.seatCount}x.seatCount=p,x.curve=0,delete x.path,I.length?x.overrides=I:delete x.overrides,delete x.arcFanGeneration,delete x.rowBlockGeneration;let w=b.slice(1).map(m=>m.id),S=new Set(w);for(let m=n.objects.length-1;m>=0;m--)S.has(n.objects[m].id)&&n.objects.splice(m,1);return{floorId:n.floorId,changed:!0,rowId:x.id,removedRowIds:w,seatCount:p}}function gu(e,t){let n=O(e,t.floorId),o=n.objects.find(h=>h.type==="row"&&h.id===t.rowId);if(!o)throw new u("object_not_found","The row id does not exist on the selected floor",{rowIds:[t.rowId]});if(o.path)throw new u("invalid_operation","Cannot split a free-form curved row. Straighten it first, then split.",{rowIds:[o.id]});let r=o.seatCount,a=t.index;if(!Number.isInteger(a)||a<1||a>r-1)throw new u("invalid_operation",`Split position must be a whole number from 1 to ${r-1} (the seat where the second row begins)`);let i=ae(o),s=r>1?o.curve/(r-1):0,c=r-a,l={type:"row",id:E(e,"r",t.idFactory,new Set),label:fu(n.objects,o.label),origin:{...i[a]},rotation:Sn(o.rotation-s*a),curve:s*(c-1),seatCount:c,seatSpacing:o.seatSpacing,categoryKey:o.categoryKey};if(o.seatNumbering&&(l.seatNumbering=structuredClone(o.seatNumbering)),o.seatLabelStart!=null&&(l.seatLabelStart=o.seatLabelStart),o.commercial&&(l.commercial=structuredClone(o.commercial)),o.viewFromSeatUrl&&(l.viewFromSeatUrl=o.viewFromSeatUrl),o.viewFromSeatMeta&&(l.viewFromSeatMeta=structuredClone(o.viewFromSeatMeta)),o.confidenceEvidence&&(l.confidenceEvidence=structuredClone(o.confidenceEvidence)),o.labelPresentation){let h=structuredClone(o.labelPresentation);delete h.position,l.labelPresentation=h}let d=[],f=[];if(o.overrides)for(let h of o.overrides)h.index<a?d.push(structuredClone(h)):f.push({...structuredClone(h),index:h.index-a});Vi(o,o,l),o.seatCount=a,o.curve=s*(a-1),d.length?o.overrides=d:delete o.overrides,delete o.arcFanGeneration,delete o.rowBlockGeneration,f.length&&(l.overrides=f);let g=n.objects.indexOf(o);return n.objects.splice(g+1,0,l),{floorId:n.floorId,changed:!0,rowId:o.id,newRowId:l.id,firstSeatCount:a,secondSeatCount:c,newLabel:l.label}}function bu(e,t){let n=O(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2)throw new u("invalid_operation","Select at least two rows to set row spacing");if(!Number.isFinite(t.gap)||t.gap<=0||t.gap>4e3)throw new u("invalid_operation","Row spacing must be a positive value up to 4000 chart units");let r=o.map(s=>n.objects.find(c=>c.type==="row"&&c.id===s)),a=o.filter((s,c)=>!r[c]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let i=va(r,t.gap);return{floorId:n.floorId,changed:i,rowIds:o,gap:t.gap}}function mu(e,t){let n=O(e,t.floorId),o=[...new Set(t.rowIds)];if(o.length<2)throw new u("invalid_operation","Select at least two rows to straighten and space evenly");let r=o.map(g=>n.objects.find(h=>h.type==="row"&&h.id===g)),a=o.filter((g,h)=>!r[h]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let i=r,s=()=>JSON.stringify(i.map(g=>[g.origin,g.rotation,g.curve,g.path??null,g.seatSpacing])),c=s();for(let g of i)uu(g);let l=Ia(i),d=Sn(Math.atan2(l.y,l.x)/fe);for(let g of i)g.rotation=d;let f=du(i,l);return va(i,f),{floorId:n.floorId,changed:s()!==c,rowIds:o,gap:f}}var vn=ls(require("polygon-clipping"),1),Ca=100,Oa=512,jo=8192,Ea=64,Pa=1e7,U=1e-7;function Ta(e,t){return Math.abs(e.x-t.x)<=U&&Math.abs(e.y-t.y)<=U}function ja(e){let t=e.map(n=>({x:n.x,y:n.y}));for(;t.length>1&&Ta(t[0],t[t.length-1]);)t.pop();return t}function Mt(e,t,n){let o=ce(t,n,e);return Math.abs(o)>U?!1:e.x>=Math.min(t.x,n.x)-U&&e.x<=Math.max(t.x,n.x)+U&&e.y>=Math.min(t.y,n.y)-U&&e.y<=Math.max(t.y,n.y)+U}function Fa(e,t,n,o){let r=ce(e,t,n),a=ce(e,t,o),i=ce(n,o,e),s=ce(n,o,t);return(r>U&&a<-U||r<-U&&a>U)&&(i>U&&s<-U||i<-U&&s>U)?!0:Math.abs(r)<=U&&Mt(n,e,t)||Math.abs(a)<=U&&Mt(o,e,t)||Math.abs(i)<=U&&Mt(e,n,o)||Math.abs(s)<=U&&Mt(t,n,o)}function pu(e){for(let t=0;t<e.length;t+=1){let n=(t+1)%e.length;for(let o=t+1;o<e.length;o+=1){let r=(o+1)%e.length;if(!(t===o||n===o||r===t)&&Fa(e[t],e[n],e[o],e[r]))return!0}}return!1}function Aa(e,t){return e.some((n,o)=>t.some((r,a)=>Fa(n,e[(o+1)%e.length],r,t[(a+1)%t.length])))}function Fo(e,t){return!t.some((n,o)=>Mt(e,n,t[(o+1)%t.length]))&&J(e,t,void 0)}function Cn(e,t,n){let o=ja(e);if(o.length<3||o.length>Oa||o.some((r,a)=>!Number.isFinite(r.x)||!Number.isFinite(r.y)||Math.abs(r.x)>Pa||Math.abs(r.y)>Pa||Ta(r,o[(a+1)%o.length]))||Math.abs(ot(o))<=U||pu(o))throw new u("invalid_operation",`GA area ${n} has an invalid or self-intersecting ${t}; Join Areas accepts 3\u2013${Oa} finite vertices per ring.`,{gaAreaId:n,ring:t});return o}function yu(e){let t=Cn(e.points,"outline",e.id),n=e.holes??[];if(!Array.isArray(n)||n.length>Ea)throw new u("invalid_operation",`GA area ${e.id} has too many cutouts to join`,{gaAreaId:e.id});let o=n.map(r=>Cn(r,"cutout",e.id));for(let r=0;r<o.length;r+=1){let a=o[r];if(!a.flatMap((s,c)=>{let l=a[(c+1)%a.length];return[s,{x:(s.x+l.x)/2,y:(s.y+l.y)/2}]}).every(s=>Fo(s,t))||Aa(a,t))throw new u("invalid_operation",`GA area ${e.id} has a cutout outside its outline`,{gaAreaId:e.id,holeIndex:r});for(let s=r+1;s<o.length;s+=1)if(Aa(a,o[s])||Fo(a[0],o[s])||Fo(o[s][0],a))throw new u("invalid_operation",`GA area ${e.id} has overlapping cutouts`,{gaAreaId:e.id,holeIndex:r})}return{outer:t,holes:o}}function In(e){return e.map(t=>[t.x,t.y])}function Ma(e){return ja(e.map(([t,n])=>({x:t,y:n})))}function Ra(e){return Math.abs(e.reduce((t,n,o)=>{let r=e[(o+1)%e.length];return t+n[0]*r[1]-r[0]*n[1]},0))/2}function wu(e){return e.reduce((t,n)=>t+(Ra(n[0]??[])-n.slice(1).reduce((o,r)=>o+Ra(r),0)),0)}function No(e){if(e===void 0)return"undefined";if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(No).join(",")}]`;let t=e;return`{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${No(t[n])}`).join(",")}}`}function _a(e,t,n){let o=e[t];if(o===void 0)return null;let r=o.normalize("NFKC").trim();if(!r||r!==o||r.length>n)throw new u("invalid_operation",`GA area ${e.id} has an invalid ${t}; normalize it to 1\u2013${n} characters before joining.`,{gaAreaId:e.id,field:t});return r}function La(e){return No({categoryKey:e.categoryKey,displayLabel:_a(e,"displayLabel",80),displayType:_a(e,"displayType",24),referenceInventorySource:e.referenceInventorySource??null})}function ka(e,t){let n=Math.min(...e.points.map(r=>r.y)),o=Math.min(...e.points.map(r=>r.x));return[n,o,t]}function xu(e,t){return e[0]-t[0]||e[1]-t[1]||e[2]-t[2]}function Na(e,t,n={}){let o=O(e,t.floorId),r=[...new Set(t.gaAreaIds)];if(r.length<2)throw new u("invalid_operation","Select at least two GA areas to join");if(r.length>Ca)throw new u("invalid_operation",`Join Areas supports at most ${Ca} areas at once`);let a=r.map(A=>o.objects.find(k=>k.type==="gaArea"&&k.id===A)),i=r.filter((A,k)=>!a[k]);if(i.length)throw new u("object_not_found","One or more GA area ids do not exist on the selected floor",{gaAreaIds:i});let s=a,c=s.find(A=>Ge(A));if(c)throw new u("invalid_operation",`"${c.displayLabel??c.label}" is sold as one box. Only areas sold per person can be joined; switch it back to Standing first.`,{gaAreaId:c.id});D(e,s[0].categoryKey);let l=La(s[0]),d=s.find(A=>La(A)!==l);if(d)throw new u("invalid_operation","GA areas must use the same category, displayed label, displayed type, and reference-inventory provenance before they can be joined.",{gaAreaIds:[s[0].id,d.id]});let f=wt(e).objectToSection,g=f.get(s[0].id)??"__ungrouped__",h=s.find(A=>(f.get(A.id)??"__ungrouped__")!==g);if(h)throw new u("invalid_operation","GA areas must belong to the same buyer section before they can be joined.",{gaAreaIds:[s[0].id,h.id],sectionIds:[g,f.get(h.id)??"__ungrouped__"]});let b=s.reduce((A,k)=>{if(!Number.isInteger(k.capacity)||k.capacity<1||k.capacity>te)throw new u("invalid_operation",`GA area ${k.id} has invalid capacity`,{gaAreaId:k.id});return A+k.capacity},0);if(b>te)throw new u("invalid_operation",`Joined GA capacity would be ${b}, over the ${te}-unit area limit`,{capacity:b});let p=ee(e).reduce((A,k)=>A+Oe(k),0),x=n.maxInventory??1e5;if(p>x)throw new u("invalid_operation",`Chart inventory exceeds the ${x}-unit publication limit`,{inventory:p});let I=s.map(yu),y=I.reduce((A,k)=>A+k.outer.length+k.holes.reduce(($,W)=>$+W.length,0),0);if(y>jo)throw new u("invalid_operation",`Join Areas supports at most ${jo} source vertices`,{vertexCount:y});let w;try{let A=I.map(W=>[In(W.outer)]);if(w=vn.default.union(A[0],...A.slice(1)),w.length!==1)throw new u("invalid_operation","Selected GA areas must overlap or share an edge. Disconnected or point-only contact cannot produce one sellable surface.",{surfaceCount:w.length});let k=I.flatMap(W=>W.holes.map(ke=>[In(ke)]));k.length&&(w=vn.default.difference(w,...k));let $=I.findIndex(W=>{let ke=[In(W.outer),...W.holes.map(In)];return wu(vn.default.intersection(ke,w))<=U});if($>=0)throw new u("invalid_operation",`GA area ${s[$].id} contributes no sellable surface after preserving every source cutout.`,{gaAreaId:s[$].id})}catch(A){throw A instanceof u?A:new u("invalid_operation","The selected GA boundaries could not be joined safely",{reason:A instanceof Error?A.message:"polygon_union_failed"})}if(w.length!==1||!w[0]?.length)throw new u("invalid_operation","Joining these boundaries would create disconnected sellable surfaces; adjust the outlines or cutouts first.",{surfaceCount:w.length});let S=Ma(w[0][0]),m=w[0].slice(1).map(Ma),v=S.length+m.reduce((A,k)=>A+k.length,0);if(m.length>Ea||v>jo)throw new u("invalid_operation","The joined boundary is too complex to store safely",{holeCount:m.length,vertexCount:v});Cn(S,"outline",s[0].id),m.forEach(A=>Cn(A,"cutout",s[0].id));let C=new Map(o.objects.map((A,k)=>[A.id,k])),P=s.slice().sort((A,k)=>xu(ka(A,C.get(A.id)??Number.MAX_SAFE_INTEGER),ka(k,C.get(k.id)??Number.MAX_SAFE_INTEGER))),j=P[0],q=structuredClone(e),Y=O(q,o.floorId),M=Y.objects.find(A=>A.type==="gaArea"&&A.id===j.id);M.points=structuredClone(S),m.length?M.holes=structuredClone(m):delete M.holes;let ne=new Set(P.slice(1).map(A=>A.id));for(let A=Y.objects.length-1;A>=0;A-=1)ne.has(Y.objects[A].id)&&Y.objects.splice(A,1);let R=wt(q).objectToSection.get(j.id)??"__ungrouped__";if(R!==g)throw new u("invalid_operation","The joined surface would change buyer-section ownership; adjust the GA or section boundaries first.",{gaAreaId:j.id,beforeSectionId:g,afterSectionId:R});let oe=[],se=new Set;for(let A of P){if(!Xn(A))throw new u("invalid_operation",`GA area ${A.id} has invalid inventory provenance and cannot be joined`,{gaAreaId:A.id});let k=le(A);if(k.length!==A.capacity||k.some($=>se.has($)))throw new u("invalid_operation","Selected GA areas contain duplicated or incomplete stable inventory identities",{gaAreaId:A.id});k.forEach($=>se.add($)),oe.push(...tn(A))}if(oe.length>256)throw new u("invalid_operation","Joined inventory provenance would exceed 256 durable source ranges");let ve=new Set(s.map(A=>A.id));for(let A of ee(e).filter(k=>k.type==="gaArea"&&!ve.has(k.id))){let k=le(A).find($=>se.has($));if(k)throw new u("invalid_operation","A stable GA inventory identity is already owned by another area",{label:k,gaAreaId:A.id})}let jt=P.slice(1).map(A=>A.id);return{floorId:o.floorId,areaId:j.id,survivorLabel:j.label,removedAreaIds:jt,sourceAreaCount:P.length,capacity:b,inventorySegmentCount:oe.length,outerVertexCount:S.length,holeCount:m.length,sectionId:g,points:S,...m.length?{holes:m}:{},segments:oe}}function Su(e,t,n={}){let{segments:o,...r}=Na(e,t,n);return r}function Iu(e,t,n={}){let o=Na(e,t,n),r=O(e,o.floorId),a=r.objects.find(d=>d.type==="gaArea"&&d.id===o.areaId);a.points=structuredClone(o.points),o.holes?.length?a.holes=structuredClone(o.holes):delete a.holes;let i=r.objects.filter(d=>d.type==="gaArea"&&(d.id===o.areaId||o.removedAreaIds.includes(d.id))).reduce((d,f)=>d+(f.wheelchairPlaces??0),0);a.capacity=o.capacity,a.inventorySegments=structuredClone(o.segments),i>0&&(a.wheelchairPlaces=Math.min(i,o.capacity));let s=new Set(o.removedAreaIds);for(let d=r.objects.length-1;d>=0;d-=1)s.has(r.objects[d].id)&&r.objects.splice(d,1);let{segments:c,...l}=o;return{...l,changed:!0}}function vu(e,t){let n=O(e,t.floorId),o=n.objects.find(c=>c.type==="shape"&&c.id===t.shapeId);if(!o)throw new u("object_not_found",`Unknown shape id: ${t.shapeId}`,{shapeId:t.shapeId});if(o.role==="stage")throw new u("invalid_operation","A stage keeps its generated outline; turn it back into a shape first");if(o.kind==="polygon")return{floorId:n.floorId,changed:!1,shapeId:o.id};if(o.kind!=="rect"||o.x==null||o.y==null||o.width==null||o.height==null||![o.x,o.y,o.width,o.height].every(Number.isFinite)||o.width<=0||o.height<=0)throw new u("invalid_operation","Only a rectangle can become a custom outline");let{x:r,y:a,width:i,height:s}=o;return o.points=[{x:r,y:a},{x:r+i,y:a},{x:r+i,y:a+s},{x:r,y:a+s}],o.kind="polygon",delete o.x,delete o.y,delete o.width,delete o.height,delete o.cornerRadius,ht(o),{floorId:n.floorId,changed:!0,shapeId:o.id}}function Cu(e,t){let n=O(e,t.floorId),o=[...new Set(t.shapeIds)];if(!o.length)throw new u("invalid_operation","At least one shape id is required");let r=o.map(l=>n.objects.find(d=>d.type==="shape"&&d.id===l)),a=o.filter((l,d)=>!r[d]);if(a.length)throw new u("object_not_found",`Unknown shape id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current shape ids.`,{shapeIds:a});let i=structuredClone(t.patch);if(!Object.keys(i).length)throw new u("invalid_operation","At least one shape change is required");if(i.label!==void 0){if(o.length!==1)throw new u("invalid_operation","label can be changed only for one shape at a time");if(i.label!==null){if(i.label=i.label.normalize("NFKC").trim(),!i.label)i.label=null;else if(i.label.length>80)throw new u("invalid_operation","Shape labels support at most 80 characters")}}if(i.labelStyle!==void 0){let l=r.filter(d=>d.role!=="stage");if(l.length)throw new u("invalid_operation","Shape label styling applies only to stages",{shapeIds:l.map(d=>d.id)});if(i.labelStyle.size!==void 0&&i.labelStyle.size!==null&&(!Number.isFinite(i.labelStyle.size)||i.labelStyle.size<Fe||i.labelStyle.size>72))throw new u("invalid_operation",`Stage label size must be from ${Fe} to ${72}`);if(i.labelStyle.color!==void 0&&i.labelStyle.color!==null&&(i.labelStyle.color=N(i.labelStyle.color,"Shape label color")),i.labelStyle.fontFamily!==void 0&&i.labelStyle.fontFamily!==null&&(i.labelStyle.fontFamily=i.labelStyle.fontFamily.normalize("NFKC").trim(),!i.labelStyle.fontFamily||i.labelStyle.fontFamily.length>120))throw new u("invalid_operation","Stage label fontFamily must contain 1 to 120 characters");if(i.labelStyle.direction!==void 0&&i.labelStyle.direction!==null&&!Lr.includes(i.labelStyle.direction))throw new u("invalid_operation","Stage label direction must be horizontal, vertical, or auto");for(let d of["bold","italic","underline"]){let f=i.labelStyle[d];if(f!=null&&typeof f!="boolean")throw new u("invalid_operation",`Stage label ${d} must be a boolean`)}}if(i.fill!==void 0&&i.fill!==null&&(i.fill=N(i.fill,"Shape fill")),i.kind!==void 0&&!["rect","ellipse","polygon","line","polyline"].includes(i.kind))throw new u("invalid_operation","Shape kind must be rect, ellipse, polygon, line, or polyline");if(i.stroke!==void 0&&i.stroke!==null){if(!Number.isFinite(i.stroke.width)||i.stroke.width<.5||i.stroke.width>40)throw new u("invalid_operation","Shape stroke width must be from 0.5 to 40 chart units");i.stroke={color:N(i.stroke.color,"Shape stroke"),width:i.stroke.width}}if(i.cornerRadius!==void 0&&i.cornerRadius!==null&&(!Number.isFinite(i.cornerRadius)||i.cornerRadius<0||i.cornerRadius>5e3))throw new u("invalid_operation","Shape cornerRadius must be from 0 to 5000 chart units");if(i.opacity!==void 0&&i.opacity!==null&&(!Number.isFinite(i.opacity)||i.opacity<.1||i.opacity>1))throw new u("invalid_operation","Shape opacity must be from 0.1 to 1");if(i.heightM!==void 0&&i.heightM!==null&&(!Number.isFinite(i.heightM)||i.heightM<.05||i.heightM>50))throw new u("invalid_operation","Shape heightM must be from 0.05 to 50 metres");if(i.rotation!==void 0&&i.rotation!==null){if(!Number.isFinite(i.rotation))throw new u("invalid_operation","Shape rotation must be a finite number of degrees");i.rotation=Ie("shape",i.rotation)}if(i.edgeCurvature!==void 0){if(o.length!==1)throw new u("invalid_operation","edgeCurvature can be changed only for one shape at a time");let l=r[0];if((i.kind??l.kind)!=="polygon"||(l.points?.length??0)<3)throw new u("invalid_operation","Curved sides apply only to custom outline (polygon) shapes",{shapeIds:[l.id]});if(i.edgeCurvature!==null){if(!Array.isArray(i.edgeCurvature)||i.edgeCurvature.some(f=>!Number.isFinite(f)||f<-100||f>100))throw new u("invalid_operation","Edge curvature values must be numbers from -100 to 100");if(i.edgeCurvature.length&&i.edgeCurvature.length!==l.points.length)throw new u("invalid_operation",`edgeCurvature needs one value per side: this shape has ${l.points.length} sides`,{shapeIds:[l.id]});i.edgeCurvature.some(f=>Math.abs(f)>.5)||(i.edgeCurvature=null)}let d={kind:"polygon",points:l.points,edgeCurvature:i.edgeCurvature??void 0,holes:l.holes};or(d).forEach((f,g)=>{if(!rr(d,f))throw new u("invalid_operation",`That curve would cross cut-out ${g+1}. Move the cut-out or use less curve.`,{shapeIds:[l.id]})})}if(i.eventConfigurationIds!==void 0&&i.eventConfigurationIds!==null){let l=i.eventConfigurationIds.map(d=>d.normalize("NFKC").trim());if(!l.length||l.length>20||l.some(d=>!d||d.length>100)||new Set(l).size!==l.length)throw new u("invalid_operation","Shape event configurations must contain 1 to 20 unique ids");i.eventConfigurationIds=l}if(i.lineCap!==void 0&&i.lineCap!==null&&!qi.includes(i.lineCap))throw new u("invalid_operation","Shape lineCap must be butt, round, or square");if(i.lineJoin!==void 0&&i.lineJoin!==null&&!Yi.includes(i.lineJoin))throw new u("invalid_operation","Shape lineJoin must be miter, round, or bevel");for(let[l,d]of[["startEnding",i.startEnding],["endEnding",i.endEnding]])if(d!=null&&!Ji.includes(d))throw new u("invalid_operation",`Shape ${l} must be none or arrow`);if(i.lineCap!=null||i.lineJoin!=null||i.startEnding!=null||i.endEnding!=null){let l=r.filter(d=>!yo(i.kind??d.kind));if(l.length)throw new u("invalid_operation","Line caps, joins, and start/end decorations apply only to open line or polyline shapes",{shapeIds:l.map(d=>d.id)})}let c=!1;for(let l of r){let d=JSON.stringify(l);if(i.label===null?delete l.label:i.label!==void 0&&(l.label=i.label),i.labelStyle!==void 0){let f={...l.labelStyle};i.labelStyle.size===null?delete f.size:i.labelStyle.size!==void 0&&(f.size=i.labelStyle.size),i.labelStyle.color===null?delete f.color:i.labelStyle.color!==void 0&&(f.color=i.labelStyle.color),i.labelStyle.fontFamily===null?delete f.fontFamily:i.labelStyle.fontFamily!==void 0&&(f.fontFamily=i.labelStyle.fontFamily),i.labelStyle.bold===null?delete f.bold:i.labelStyle.bold!==void 0&&(f.bold=i.labelStyle.bold),i.labelStyle.italic===null||i.labelStyle.italic===!1?delete f.italic:i.labelStyle.italic===!0&&(f.italic=!0),i.labelStyle.underline===null||i.labelStyle.underline===!1?delete f.underline:i.labelStyle.underline===!0&&(f.underline=!0),i.labelStyle.direction===null||i.labelStyle.direction==="horizontal"?delete f.direction:i.labelStyle.direction!==void 0&&(f.direction=i.labelStyle.direction),Object.keys(f).length?l.labelStyle=f:delete l.labelStyle}if(i.fill===null?delete l.fill:i.fill!==void 0&&(l.fill=i.fill),i.kind!==void 0&&(l.kind=i.kind,yo(l.kind)||(delete l.lineCap,delete l.lineJoin,delete l.startEnding,delete l.endEnding)),i.stroke===null?delete l.stroke:i.stroke!==void 0&&(l.stroke={...i.stroke}),i.opacity===null?delete l.opacity:i.opacity!==void 0&&(l.opacity=i.opacity),i.heightM===null?delete l.heightM:i.heightM!==void 0&&(l.heightM=i.heightM),i.rotation===null||i.rotation===0?delete l.rotation:i.rotation!==void 0&&(l.rotation=i.rotation),i.edgeCurvature===null?delete l.edgeCurvature:i.edgeCurvature!==void 0&&(l.edgeCurvature=[...i.edgeCurvature]),i.kind!==void 0&&i.kind!=="polygon"&&(delete l.edgeCurvature,delete l.holes),i.eventConfigurationIds===null?delete l.eventConfigurationIds:i.eventConfigurationIds!==void 0&&(l.eventConfigurationIds=[...i.eventConfigurationIds]),i.lineCap===null?delete l.lineCap:i.lineCap!==void 0&&(l.lineCap=i.lineCap),i.lineJoin===null?delete l.lineJoin:i.lineJoin!==void 0&&(l.lineJoin=i.lineJoin),i.startEnding===null?delete l.startEnding:i.startEnding!==void 0&&(l.startEnding=i.startEnding),i.endEnding===null?delete l.endEnding:i.endEnding!==void 0&&(l.endEnding=i.endEnding),i.cornerRadius===null)delete l.cornerRadius;else if(i.cornerRadius!==void 0){let f=Math.min(l.width??1/0,l.height??1/0),g=Number.isFinite(f)?f/2:i.cornerRadius;l.cornerRadius=l.kind==="rect"?Math.max(0,Math.min(i.cornerRadius,g)):i.cornerRadius}JSON.stringify(l)!==d&&(ht(l),c=!0)}return{floorId:n.floorId,changed:c,shapeIds:o}}function Ga(e){if(e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null){if(![e.x,e.y,e.width,e.height].every(Number.isFinite)||e.width<=0||e.height<=0)throw new u("invalid_operation",`Stage ${e.id} has an invalid stored base box`,{stageId:e.id});return{cx:e.x+e.width/2,cy:e.y+e.height/2,width:e.width,height:e.height}}let t=e.points??[];if(t.length<3||t.some(d=>!Number.isFinite(d.x)||!Number.isFinite(d.y)))throw new u("invalid_operation",`Stage ${e.id} has no valid geometry from which to derive its base box`,{stageId:e.id});let n=t.map(d=>d.x),o=t.map(d=>d.y),r=Math.min(...n),a=Math.max(...n),i=Math.min(...o),s=Math.max(...o),c=Math.max(1,a-r),l=Math.max(1,s-i);return{cx:r+c/2,cy:i+l/2,width:c,height:l}}function Ou(e,t){let n=O(e,t.floorId);if(!t.updates.length)throw new u("invalid_operation","At least one shape resize is required");let o=t.updates.map(i=>i.shapeId);if(new Set(o).size!==o.length)throw new u("invalid_operation","Shape ids must be unique");let r=t.updates.map(i=>{if(![i.width,i.height].every(Number.isFinite)||i.width<8||i.height<8||i.width>1e4||i.height>1e4)throw new u("invalid_operation","Shape width and height must be between 8 and 10000 chart units",{shapeId:i.shapeId});let s=n.objects.find(l=>l.type==="shape"&&l.id===i.shapeId);if(!s)throw new u("object_not_found",`Unknown shape id: ${i.shapeId}`,{shapeId:i.shapeId});let c=s.role==="stage"?Ga(s):(s.kind==="rect"||s.kind==="ellipse")&&s.x!=null&&s.y!=null&&s.width!=null&&s.height!=null?{cx:s.x+s.width/2,cy:s.y+s.height/2,width:s.width,height:s.height}:(()=>{let l=s.points??[];if(l.length<3||l.some(x=>!Number.isFinite(x.x)||!Number.isFinite(x.y)))throw new u("invalid_operation",`Shape ${s.id} has no resizable geometry`,{shapeId:s.id});let d=l.map(x=>x.x),f=l.map(x=>x.y),g=Math.min(...d),h=Math.max(...d),b=Math.min(...f),p=Math.max(...f);return{cx:(g+h)/2,cy:(b+p)/2,width:Math.max(1,h-g),height:Math.max(1,p-b)}})();return{shape:s,update:i,box:c}}),a=!1;for(let{shape:i,update:s,box:c}of r)if(!(Math.abs(c.width-s.width)<1e-9&&Math.abs(c.height-s.height)<1e-9)){if(i.kind==="rect"||i.kind==="ellipse")i.x=c.cx-s.width/2,i.y=c.cy-s.height/2,i.width=s.width,i.height=s.height;else{let l=s.width/c.width,d=s.height/c.height,f=g=>({x:c.cx+(g.x-c.cx)*l,y:c.cy+(g.y-c.cy)*d});i.points=(i.points??[]).map(f),i.holes&&(i.holes=i.holes.map(g=>g.map(f))),(i.x!=null||i.y!=null||i.width!=null||i.height!=null||i.role==="stage")&&(i.x=c.cx-s.width/2,i.y=c.cy-s.height/2,i.width=s.width,i.height=s.height)}a=!0}return{floorId:n.floorId,changed:a,shapes:r.map(({shape:i,update:s})=>({id:i.id,width:s.width,height:s.height}))}}function Pu(e,t){let n=O(e,t.floorId);if(!t.updates.length)throw new u("invalid_operation","At least one stage update is required");let o=t.updates.map(s=>s.stageId);if(new Set(o).size!==o.length)throw new u("invalid_operation","Stage ids must be unique");let r=new Set(fr.map(s=>s.key)),a=t.updates.map(s=>{if(!r.has(s.stageKind))throw new u("invalid_operation",`Unknown stage kind: ${s.stageKind}`,{stageKind:s.stageKind});let c=n.objects.find(l=>l.type==="shape"&&l.id===s.stageId);if(!c)throw new u("object_not_found",`Unknown stage id: ${s.stageId}. Call get_chart to list current stage ids.`,{stageId:s.stageId});if(c.role!=="stage")throw new u("invalid_operation",`Shape ${s.stageId} is not tagged as a stage`,{stageId:s.stageId});return{shape:c,stageKind:s.stageKind,box:c.stageKind===s.stageKind?null:Ga(c)}}),i=!1;for(let s of a)s.box&&(s.shape.points=Dn({kind:s.stageKind,...s.box}),s.shape.kind="polygon",delete s.shape.edgeCurvature,delete s.shape.holes,s.shape.stageKind=s.stageKind,i=!0);return{floorId:n.floorId,changed:i,stages:a.map(s=>({id:s.shape.id,stageKind:s.stageKind}))}}function Mu(e){return[...Bo(e)].map(([t,n])=>({key:t,...n}))}function Ru(e){if(!Array.isArray(e))return Bo(e);let t=new Map;for(let{key:n,target:o,evidence:r}of e)t.set(n,{target:o,evidence:r});return t}function Bo(e){let t=new Map;e.confidenceEvidence&&t.set("venue",{target:{scope:"venue"},evidence:e.confidenceEvidence});for(let n of T(e)){n.confidenceEvidence&&t.set(`floor:${n.id}`,{target:{scope:"floor",floorId:n.id},evidence:n.confidenceEvidence});for(let o of n.objects){let r=`floor:${n.id}:object:${o.id}`;if((o.type==="row"||o.type==="section")&&o.confidenceEvidence&&t.set(r,{target:{scope:o.type,floorId:n.id,objectId:o.id},evidence:o.confidenceEvidence}),o.type==="row"&&o.segmentedRow?.confidenceEvidence&&t.set(`${r}:segmented`,{target:{scope:"row",floorId:n.id,objectId:o.id},evidence:o.segmentedRow.confidenceEvidence}),o.type==="row"||o.type==="table")for(let a of o.overrides??[])a.confidenceEvidence&&t.set(`${r}:seat:${a.index}`,{target:{scope:"seat",floorId:n.id,objectId:o.id,seatIndex:a.index},evidence:a.confidenceEvidence})}}return t}function On(e){return Array.isArray(e)?e.map(On):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>[t,On(n)]))}function _u(e,t){return JSON.stringify(On(e))===JSON.stringify(On(t))}function Do(e){return!!e&&e.status!=="draft"&&e.status!=="retracted"}function Lu(e){return e?e.status==="retracted"?"retract":Do(e)?"approve":"set":"clear"}function $a(e,t){let n=Ru(e),o=Bo(t),r=[...new Set([...n.keys(),...o.keys()])].sort(),a=[];for(let i of r){let s=n.get(i),c=o.get(i);if(s&&c&&_u(s.evidence,c.evidence))continue;let l=c?.target??s?.target;l&&a.push({...l,operation:Lu(c?.evidence),...s?{before:s.evidence}:{},...c?{after:c.evidence}:{}})}return a}function ku(e,t){return $a(e,t).some(n=>Do(n.before)||Do(n.after))}var Eu=new Set(["synthetic-model","organizer-approved","calibrated-provider"]),Tu=new Set(["generated","geometry-verified","configuration-verified"]),ju=new Set(["none","comparable-build-reference","actual-build-checked"]),Fu=new Set(["clear","partial","obstructed"]);function Go(e){return e.toISOString().slice(0,10)}function $o(e,t){return typeof e=="string"&&e.normalize("NFKC").trim()===e&&e.length>0&&e.length<=t}function et(e,t,n){if(!$o(e,t))throw new u("invalid_operation",`Confidence evidence ${n} is invalid`,{field:n});return e}function Qe(e,t,n){if(e!==void 0)return et(e,t,n)}function Pn(e,t,n){let o=n?[O(e,n)]:T(e).map(r=>({floorId:r.id,objects:r.objects}));for(let r of o){let a=r.objects.find(i=>i.id===t);if(a)return{floorId:r.floorId,object:a}}throw new u("object_not_found",`Unknown chart object: ${t}`,{objectId:t,floorId:n})}function Ba(e,t){let n=T(e),o=t?n.find(r=>r.id===t):n[0];if(!o)throw new u("floor_not_found",`Unknown chart floor: ${t}`,{floorId:t});return o}function Rt(e,t){if(t.scope==="venue")return e.confidenceEvidence;if(t.scope==="floor")return Ba(e,t.floorId).confidenceEvidence;if(t.scope==="seat"){if(!t.objectId||t.seatIndex===void 0)throw new u("invalid_operation","Seat evidence requires objectId and seatIndex");let o=Pn(e,t.objectId,t.floorId);if(o.object.type!=="row"&&o.object.type!=="table")throw new u("invalid_operation","Seat evidence can be stored only on a row or table",{objectId:t.objectId});return o.object.overrides?.find(r=>r.index===t.seatIndex)?.confidenceEvidence}if(!t.objectId)throw new u("invalid_operation",`${t.scope} evidence requires objectId`);let n=Pn(e,t.objectId,t.floorId);if(t.scope==="row"&&n.object.type!=="row")throw new u("invalid_operation","Row evidence requires a row id",{objectId:t.objectId});if(t.scope==="section"&&n.object.type!=="section")throw new u("invalid_operation","Section evidence requires a section id",{objectId:t.objectId});if(n.object.type==="row"||n.object.type==="section")return n.object.confidenceEvidence;throw new u("invalid_operation",`${t.scope} evidence is not supported on this object`,{objectId:t.objectId,type:n.object.type})}function An(e,t,n){if(t.scope==="venue")return n?e.confidenceEvidence=n:delete e.confidenceEvidence,{};if(t.scope==="floor"){let r=Ba(e,t.floorId);return n?r.confidenceEvidence=n:delete r.confidenceEvidence,{floorId:r.id}}if(t.scope==="seat"){if(!t.objectId||t.seatIndex===void 0)throw new u("invalid_operation","Seat evidence requires objectId and seatIndex");let r=Pn(e,t.objectId,t.floorId);return To(e,{floorId:r.floorId,seats:[{rowId:t.objectId,index:t.seatIndex}],patch:{confidenceEvidence:n??null}}),{floorId:r.floorId,objectId:t.objectId}}if(!t.objectId)throw new u("invalid_operation",`${t.scope} evidence requires objectId`);let o=Pn(e,t.objectId,t.floorId);if(o.object.type!=="row"&&o.object.type!=="section")throw new u("invalid_operation",`${t.scope} evidence is not supported on this object`,{objectId:t.objectId,type:o.object.type});return n?o.object.confidenceEvidence=n:delete o.object.confidenceEvidence,{floorId:o.floorId,objectId:o.object.id}}function Nu(e){if(e===void 0)return;if(!e||typeof e!="object")throw new u("invalid_operation","Confidence evidence modeledTarget is invalid");if(!$o(e.label,80)||!$o(e.methodLabel,100))throw new u("invalid_operation","Confidence evidence modeledTarget labels are invalid");if(!Number.isInteger(e.totalRayCount)||e.totalRayCount<1||e.totalRayCount>1e3||!Number.isInteger(e.clearRayCount)||e.clearRayCount<0||e.clearRayCount>e.totalRayCount)throw new u("invalid_operation","Confidence evidence modeledTarget ray counts are invalid");if(!Fu.has(e.classification))throw new u("invalid_operation","Confidence evidence modeledTarget classification is invalid");let t=e.occluderLabels?.map(n=>et(n,80,"occluder label"));return{label:e.label,methodLabel:e.methodLabel,totalRayCount:e.totalRayCount,clearRayCount:e.clearRayCount,classification:e.classification,...t?.length?{occluderLabels:t}:{}}}function Ka(e,t=new Date){if(e.schema!==void 0&&e.schema!=="seatlayer.seat-confidence/1")throw new u("invalid_operation","Confidence evidence schema must be seatlayer.seat-confidence/1");if(!Eu.has(e.evidenceKind))throw new u("invalid_operation","Confidence evidence kind is invalid");if(!Tu.has(e.modelLevel))throw new u("invalid_operation","Confidence evidence model level is invalid");let n=e.realityLevel??"none";if(!ju.has(n))throw new u("invalid_operation","Confidence evidence reality level is invalid");if(e.evidenceKind==="synthetic-model"&&(e.modelLevel!=="generated"||n!=="none"))throw new u("invalid_operation","Synthetic evidence cannot claim verification or reality checks");let o=Qe(e.eventConfigurationId,100,"eventConfigurationId");if(e.eventConfigurationVersion!==void 0&&(!Number.isInteger(e.eventConfigurationVersion)||e.eventConfigurationVersion<1))throw new u("invalid_operation","Confidence evidence eventConfigurationVersion is invalid");if(e.modelLevel==="configuration-verified"&&!o)throw new u("invalid_operation","Configuration-verified evidence requires eventConfigurationId");let r=e.limitations?.map(f=>et(f,160,"limitation"));if(r&&r.length>6)throw new u("invalid_operation","Confidence evidence accepts at most 6 limitations");let a=Qe(e.assessedAt,40,"assessedAt")??Go(t),i=Date.parse(a);if(!Number.isFinite(i))throw new u("invalid_operation","Confidence evidence assessedAt is invalid");let s=Qe(e.validUntil,40,"validUntil")??(e.modelLevel==="generated"?void 0:Go(new Date(i+365*24*60*60*1e3))),c=s?Date.parse(s):Number.NaN;if(s&&(!Number.isFinite(c)||c<i||c>i+366*24*60*60*1e3))throw new u("invalid_operation",`Confidence evidence validity must end within ${366} days of assessment`);let l=Qe(e.approvedByRole,100,"approvedByRole");if(e.modelLevel!=="generated"&&!l)throw new u("invalid_operation","Verified model levels require approvedByRole");let d=Qe(e.sourceLabel,120,"sourceLabel");if(n!=="none"&&!d)throw new u("invalid_operation","Real-world evidence requires a buyer-safe source describing what was checked");if(n==="actual-build-checked"&&(e.modelLevel!=="configuration-verified"||!o))throw new u("invalid_operation","An actual-build check requires a configuration-verified model and an event configuration");return{schema:"seatlayer.seat-confidence/1",evidenceId:et(e.evidenceId,120,"evidenceId"),modelVersion:et(e.modelVersion,120,"modelVersion"),evidenceKind:e.evidenceKind,modelLevel:e.modelLevel,realityLevel:n,status:"draft",assessedAt:a,...o?{eventConfigurationId:o}:{},...e.eventConfigurationVersion!==void 0?{eventConfigurationVersion:e.eventConfigurationVersion}:{},...s?{validUntil:s}:{},...l?{approvedByRole:l}:{},...d?{sourceLabel:e.sourceLabel}:{},...r?.length?{limitations:r}:{},...e.modeledTarget?{modeledTarget:Nu(e.modeledTarget)}:{}}}function tt(e,t={}){return{changed:t.changed??!0,scope:e.scope,...e.objectId?{objectId:e.objectId}:{},...e.floorId?{floorId:e.floorId}:{},...e.seatIndex!==void 0?{seatIndex:e.seatIndex}:{},...t}}function Du(e,t){let n=Ka(t.evidence,t.now),o=JSON.stringify(Rt(e,t)??null),r=An(e,t,n),a=JSON.stringify(Rt(e,t)??null);return tt(t,{changed:o!==a,...r,evidenceId:n.evidenceId,status:"draft"})}function Gu(e,t){let n=Rt(e,t);if(!n)return tt(t,{changed:!1});let o=An(e,t,void 0);return tt(t,{changed:!0,...o,evidenceId:n.evidenceId})}function $u(e,t){let n=Rt(e,t);if(!n)throw new u("invalid_operation","There is no confidence evidence at this scope to approve",{scope:t.scope,objectId:t.objectId});if(n.status==="retracted")throw new u("invalid_operation","Retracted evidence cannot be approved; author a new draft first");let o=et(t.approvedByRole.normalize("NFKC").trim(),100,"approvedByRole"),r=Qe(t.eventConfigurationId,100,"eventConfigurationId")??n.eventConfigurationId;if(n.modelLevel==="configuration-verified"&&!r)throw new u("invalid_operation","Configuration-verified evidence requires eventConfigurationId");let a=t.eventConfigurationVersion??n.eventConfigurationVersion;if(a!==void 0&&(!Number.isInteger(a)||a<1))throw new u("invalid_operation","Confidence evidence eventConfigurationVersion is invalid");let i={...n,status:"approved",approvedByRole:o,assessedAt:Go(t.now??new Date),...r?{eventConfigurationId:r}:{},...a!==void 0?{eventConfigurationVersion:a}:{}};delete i.basisSha256;let s=t.basisSha256??e.confidenceBasisSha256;s&&(i.basisSha256=s);let c=JSON.stringify(n),l=An(e,t,i);return tt(t,{changed:c!==JSON.stringify(i),...l,evidenceId:i.evidenceId,status:"approved"})}function Bu(e,t){let n=Rt(e,t);if(!n)throw new u("invalid_operation","There is no confidence evidence at this scope to retract",{scope:t.scope,objectId:t.objectId});if(n.status==="retracted")return tt(t,{changed:!1,evidenceId:n.evidenceId,status:"retracted"});let o={...n,status:"retracted"};delete o.basisSha256;let r=An(e,t,o);return tt(t,{changed:!0,...r,evidenceId:n.evidenceId,status:"retracted"})}var Ku={width:960,height:600};function zu(e,t,n=e){let o={...e,objects:t,floors:void 0,referenceImage:void 0,backgroundImage:Rr(n)},r=ue(o,{freeText:"exclude"}),{width:a,height:i}=Ku;return Math.min(a/Math.max(r.width,1e-6),i/Math.max(r.height,1e-6))}function Uu(e,t){return!e.text.trim()||e.semanticKind==="icon"||e.labelImportance==="detail"||xr(e)?!1:!Ur(e.fontSize,t)}function za(e){let t=[],n=!!e.floors?.length;for(let o of T(e)){let r=o.objects.filter(i=>i.type==="text");if(!r.length)continue;let a=zu(e,o.objects,n?o:e);for(let i of r)Uu(i,a)&&t.push({floorId:o.id,text:i,renderedPx:i.fontSize*a})}return t}var Mn=40,Ua=96,Hu=48,Le=24;function _t(e,t){let n=ue({...e,objects:[t],backgroundImage:void 0,referenceImage:void 0},{freeText:"include"});return{x:n.x+Mn,y:n.y+Mn,width:Math.max(0,n.width-2*Mn),height:Math.max(0,n.height-2*Mn)}}function Vu(e){if(!e.length)return null;let t=Math.min(...e.map(a=>a.x)),n=Math.min(...e.map(a=>a.y)),o=Math.max(...e.map(a=>a.x+a.width)),r=Math.max(...e.map(a=>a.y+a.height));return{x:t,y:n,width:o-t,height:r-n}}function Xu(e){return e.type==="row"||e.type==="table"||e.type==="booth"||e.type==="gaArea"||e.type==="section"}var Ko=e=>e.type==="shape"&&e.role==="stage";function qu(e,t){let n=t.x-(e.x+e.width/2),o=t.y-(e.y+e.height/2);return Math.abs(n)>Math.abs(o)?{dx:n>=0?1:-1,dy:0}:{dx:0,dy:o>=0?1:-1}}function Yu(e,t){return t.dy===1?e.y+e.height:t.dy===-1?-e.y:t.dx===1?e.x+e.width:-e.x}function zo(e,t){return t.dy===1?e.y:t.dy===-1?-(e.y+e.height):t.dx===1?e.x:-(e.x+e.width)}function Rn(e,t){let n=me(e,t.floorId),o=Vu(n.objects.filter(Ko).map(y=>_t(n,y)));if(!o)return null;let r=qu(o,n.focalPoint),a=r.dy!==0?t.height:t.width,i=Yu(o,r),s=n.objects.filter(y=>!Ko(y)&&Xu(y)).map(y=>_t(n,y)).filter(y=>zo(y,r)>=i-1),c=s.length?Math.min(...s.map(y=>zo(y,r))):1/0,l=Ua+a+Hu,d=c-i,f=()=>{let y=i+Ua+a/2;return r.dy!==0?{x:o.x+o.width/2,y:r.dy*y}:{x:r.dx*y,y:o.y+o.height/2}};if(!s.length)return{center:f(),movedBack:0};if(d>=a+2*Le){let y=i+d/2;return{center:r.dy!==0?{x:o.x+o.width/2,y:r.dy*y}:{x:r.dx*y,y:o.y+o.height/2},movedBack:0}}if(t.makeRoom){let y=l-d,w=O(e,t.floorId);for(let S of w.objects)Ko(S)||zo(_t(n,S),r)<i-1||Ve(S,r.dx*y,r.dy*y);return{center:f(),movedBack:y}}let g="No room between the stage and the seats, so it went beside the stage. Tell the user; moving seats to make room is done in the Designer.",h=t.width,b=t.height,p=o.x+o.width/2,x=o.y+o.height/2;if(r.dy!==0){let y=r.dy===1?Math.min(x,c-Le-b/2):Math.max(x,-c+Le+b/2);return{center:{x:o.x-Le-h/2,y},note:g,movedBack:0}}return{center:{x:r.dx===1?Math.min(p,c-Le-h/2):Math.max(p,-c+Le+h/2),y:o.y-Le-b/2},note:g,movedBack:0}}var Ha=40,Lt=24;function Ju(e,t,n){let{objects:o}=O(e,t),r=o.find(a=>a.id===n);if(!r)throw new u("object_not_found",`No object ${n} on this floor. Call get_chart for ids.`,{objectId:n});return r}function nt(e,t){if(!t.nearObjectId&&t.placement==="front"){let n=Rn(e,{floorId:t.floorId,width:t.width,height:t.height,makeRoom:t.makeRoom});if(n)return n.note?{center:n.center,note:n.note}:{center:n.center}}return{center:Va(e,t)}}function Wu(e,t){return nt(e,t).center}function Va(e,t){if(t.nearObjectId){let n=Ju(e,t.floorId,t.nearObjectId),o=_t(me(e,t.floorId),n),r=t.side??"rear";return r==="front"?{x:o.x+o.width/2,y:o.y-Lt-t.height/2}:r==="left"?{x:o.x-Lt-t.width/2,y:o.y+o.height/2}:r==="right"?{x:o.x+o.width+Lt+t.width/2,y:o.y+o.height/2}:{x:o.x+o.width/2,y:o.y+o.height+Lt+t.height/2}}if(t.placement==="center"){let n=ue(me(e,t.floorId),{freeText:"exclude"});return{x:n.x+n.width/2,y:n.y+n.height/2}}return _e(e,{floorId:t.floorId,width:t.width,height:t.height,placement:t.placement??"auto"})}function _n(e,t,n){if(e===void 0)return n;if(!Number.isFinite(e)||e<=0||e>400)throw new u("invalid_operation",`${t} must be between 0 and 400 metres`);return e*Ha}function Uo(e,t){if(e===void 0)return;let n=e.trim();if(!n||n.length>80)throw new u("invalid_operation",`${t} must be 1 to 80 characters`);return n}function Zu(e){return e.some(t=>t.type==="shape"&&t.role==="stage")}function Qu(e,t){let n=O(e,t.floorId),o=hr(t.kind),r=_n(t.widthM,"widthM",o.width),a=_n(t.depthM,"depthM",o.height),i=Va(e,{...t,placement:t.placement??"front",width:r,height:a}),s=Uo(t.label,"label")??br(t.kind),c=E(e,"stage",t.idFactory,new Set),l={...gr({kind:t.kind,cx:i.x,cy:i.y,width:r,height:a,label:s},c),x:i.x-r/2,y:i.y-a/2,width:r,height:a},d=Zu(n.objects);if(n.objects.push(l),!d){let f={x:i.x,y:i.y+a/2+Lt},g=T(e).find(h=>h.id===n.floorId);e.floors?.length&&g&&(g.focalPoint=f),(!e.floors?.length||e.floors[0]?.id===n.floorId)&&(e.focalPoint=f)}return{floorId:n.floorId,stageId:c,label:s,focalPointMoved:!d,createdIds:[c]}}function ef(e,t){let n=vt(t.role);if(!n)throw new u("invalid_operation",`Unknown landmark: ${t.role}`);let o=O(e,t.floorId),{center:r,note:a}=nt(e,{...t,width:n.width,height:n.height}),i=E(e,"decor",t.idFactory,new Set),s=Si(t.role,r,i),c=Uo(t.label,"label");return c&&s.label!==void 0&&(s.label=n.icon?`${n.icon} ${c}`:c),o.objects.push(s),{floorId:o.floorId,landmarkId:i,label:s.label??null,createdIds:[i],...a?{note:a}:{}}}var tf={small:16,medium:24,large:36};function Ln(e){if(e==="always")return"orientation";if(e==="close-up")return"detail"}var nf="#f7f8fb";function of(e){let t=e.theme?.background??nf,n=e.theme?.textColor;return n&&rn(n,t)>=4.5?n:Kr(t,"#0b1220","#e8ecf4")}function rf(e,t){let n=t.text.trim();if(!n||n.length>120)throw new u("invalid_operation","text must be 1 to 120 characters");let o=O(e,t.floorId),r=tf[t.size??"medium"],a=Math.max(r,n.length*r*.56),i=r*1.2,{center:s,note:c}=nt(e,{...t,width:a,height:i}),l=E(e,"txt",t.idFactory,new Set),d={type:"text",id:l,text:n,position:{x:s.x-a/2,y:s.y-i/2},fontSize:r,rotation:0,color:t.color?N(t.color,"color"):of(e),...t.bold?{bold:!0}:{},...Ln(t.showAt)?{labelImportance:Ln(t.showAt)}:{}};o.objects.push(d);let f=t.showAt===void 0&&za(e).some(h=>h.text.id===l)?'Buyers see this text only after zooming in. For a gate, entrance or anything they must see at once, set showAt "always" or size "large".':void 0,g=[c,f].filter(Boolean).join(" ");return{floorId:o.floorId,textId:l,createdIds:[l],...g?{note:g}:{}}}function af(e,t){let n=si(t.iconKey);if(!n)throw new u("invalid_operation",`Unknown icon: ${t.iconKey}`);let o=O(e,t.floorId),r=28,{center:a,note:i}=nt(e,{...t,width:r,height:r}),s=E(e,"icon",t.idFactory,new Set),c={type:"text",id:s,semanticKind:"icon",iconKey:n.key,text:n.label,position:a,fontSize:r,rotation:0,...Ln(t.showAt)?{labelImportance:Ln(t.showAt)}:{}};return o.objects.push(c),{floorId:o.floorId,iconId:s,createdIds:[s],...i?{note:i}:{}}}var Xa="#4b5568";function sf(e,t){let n=Uo(t.label,"label"),o=O(e,t.floorId),r=_n(t.widthM,"widthM",0),a=_n(t.depthM,"depthM",0),{center:i,note:s}=nt(e,{...t,width:r,height:a}),c=E(e,"shape",t.idFactory,new Set),l={type:"shape",id:c,kind:t.shape??"rect",x:i.x-r/2,y:i.y-a/2,width:r,height:a,fill:t.fill?N(t.fill,"fill"):Xa,...n?{label:n}:{},...t.shape!=="ellipse"?{cornerRadius:8}:{}};return o.objects.push(l),{floorId:o.floorId,areaId:c,createdIds:[c],...s?{note:s}:{}}}function cf(){return["bar","entrance","exit","restroom","screen","sound","concession","coat","wall","rail","suite","obstruction"].map(e=>({role:e,label:vt(e)?.label??e}))}var lf=100,df=300,up=lf*df;function qa(e,t,n){if(n==="horizontal"||!t||![e.x,e.y,t.x,t.y].every(Number.isFinite))return 0;let o=e.x-t.x,r=e.y-t.y,a=Math.hypot(o,r);if(a<=1e-6)return 0;let i={x:r/a,y:-o/a},s=Math.atan2(i.y,i.x)*180/Math.PI;return Object.is(s,-0)?0:s}function Tt(e,t){if(t.placement==="front"){let n=Rn(e,t);if(n)return n.note?{center:n.center,note:n.note}:{center:n.center}}return{center:_e(e,{floorId:t.floorId,width:t.width,height:t.height,placement:t.placement??"auto"})}}var Wa={straight:0,gentle:15,medium:30,strong:45},uf=24,ff=28,hf=48;function gf(e,t){let n=t.blocks??1;if(!Number.isInteger(n)||n<1||n>8)throw new u("invalid_operation","blocks must be a whole number from 1 to 8");if(t.sectionLabels&&t.sectionLabels.length!==n)throw new u("invalid_operation",`Give one section name per block (${n})`);if(t.blockSeats&&t.blockSeats.length!==n)throw new u("invalid_operation",`Give one seat count per block (${n})`);let o=I=>t.blockSeats?.[I]??t.seatsPerRow,r=I=>Math.max(24,(I-1)*uf),a=r(t.seatsPerRow),i=Math.max(28,(t.rowCount-1)*ff),s=t.aisleWidth??hf,c=t.placement??"auto",l=Wa[t.curveStyle??"straight"],d={floorId:"",rowIds:[],sectionIds:[],createdIds:[]},f=(I,y,w)=>{let S=vo(e,{floorId:t.floorId,origin:I,rowCount:t.rowCount,seatsPerRow:o(w),categoryKey:t.categoryKey,curve:l,...t.blockStyle?{style:t.blockStyle}:{},rotation:y,sectionLabel:t.sectionLabels?.[w],idFactory:t.idFactory});d.floorId=S.floorId,d.rowIds.push(...S.rowIds),S.sectionId&&d.sectionIds.push(S.sectionId),d.createdIds.push(...S.createdIds)};if(n===1&&c==="front"){let I=Tt(e,{floorId:t.floorId,width:a,height:i,placement:c,makeRoom:t.makeRoom});return I.note&&(d.note=I.note),f({x:I.center.x-a/2,y:I.center.y-i/2},0,0),d}if(n===1){let I=_e(e,{floorId:t.floorId,width:a,height:i,placement:c}),y=qa(I,e.focalPoint,t.orientation??"horizontal"),w=y*Math.PI/180,S=Math.abs(a*Math.cos(w))+Math.abs(i*Math.sin(w)),m=Math.abs(a*Math.sin(w))+Math.abs(i*Math.cos(w)),v=y===0?I:_e(e,{floorId:t.floorId,width:S,height:m,placement:c});return f({x:v.x-a/2,y:v.y-i/2},y,0),d}let g=Array.from({length:n},(I,y)=>r(o(y))),h=g.reduce((I,y)=>I+y,0)+(n-1)*s,b=Tt(e,{floorId:t.floorId,width:h,height:i,placement:c,makeRoom:t.makeRoom});b.note&&(d.note=b.note);let p=b.center,x=p.x-h/2;for(let I=0;I<n;I+=1)f({x,y:p.y-i/2},0,I),x+=g[I]+s;return d}function bf(e,t){return t===1?[e]:t===2?[`${e} Left`,`${e} Right`]:t===3?[`${e} Left`,`${e} Centre`,`${e} Right`]:Array.from({length:t},(n,o)=>`${e} ${o+1}`)}var mf=155,pf=150,Ya=110;function yf(e,t){let n=(t.tableColumns-1)*mf+Ya,o=(t.tableRows-1)*pf+Ya,{center:r,note:a}=Tt(e,{floorId:t.floorId,width:n,height:o,placement:t.placement,makeRoom:t.makeRoom}),i=Oo(e,{floorId:t.floorId,center:r,tableRows:t.tableRows,tableColumns:t.tableColumns,seatsPerTable:t.seatsPerTable??8,shape:t.shape??"round",categoryKey:t.categoryKey,idFactory:t.idFactory});return a?{...i,note:a}:i}function wf(e,t){let n=wn(t.capacity),{center:o,note:r}=Tt(e,{floorId:t.floorId,...n,placement:t.placement,makeRoom:t.makeRoom}),a=Co(e,{floorId:t.floorId,center:o,capacity:t.capacity,categoryKey:t.categoryKey,...t.label===void 0?{}:{label:t.label},...t.displayLabel===void 0?{}:{displayLabel:t.displayLabel},idFactory:t.idFactory});return r?{...a,note:r}:a}var xf=88,Sf=82,If=62,vf=52;function Cf(e,t){let n=(t.boothColumns-1)*xf+If,o=(t.boothRows-1)*Sf+vf,{center:r,note:a}=Tt(e,{floorId:t.floorId,width:n,height:o,placement:t.placement,makeRoom:t.makeRoom}),i=Po(e,{floorId:t.floorId,center:r,boothRows:t.boothRows,boothColumns:t.boothColumns,categoryKey:t.categoryKey,idFactory:t.idFactory});return a?{...i,note:a}:i}var Of=40,Za=30,Et=42,kt=48;function Qa(e){return e.type==="row"||e.type==="table"||e.type==="booth"||e.type==="gaArea"||e.type==="section"}function Ho(e,t){return ue({...e,floors:void 0,objects:[t],backgroundImage:void 0,referenceImage:void 0},{freeText:"include"})}function Pf(e){return[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x,y:e.y+e.height},{x:e.x+e.width,y:e.y+e.height}]}function es(e,t,n){let o=T(e),r=t?o.find(b=>b.id===t):o[0];if(!r)throw new u("floor_not_found",`Unknown chart floor: ${t}`,{floorId:t});let a=r.focalPoint??e.focalPoint,i=r.objects.filter(Qa),s=0;if(i.length){let b=0,p=0;for(let x of i){let I=Ho(e,x);b+=I.x+I.width/2-a.x,p+=I.y+I.height/2-a.y}Math.hypot(b,p)>1&&(s=Math.atan2(b,p)*180/Math.PI)}let c=n/2,l={x:Math.sin(s*Math.PI/180),y:Math.cos(s*Math.PI/180)},d=0,f=[],g=i.some(b=>b.type==="row");for(let b of i){if(b.type==="section"&&g)continue;let p=b.type==="row"?ae(b):Pf(Ho(e,b)),x=b.type==="row"?b.seatSpacing/2:0;for(let I of p){let y=I.x-a.x,w=I.y-a.y,S=Math.atan2(y,w)*180/Math.PI;if(Math.abs((S-s+540)%360-180)>c+10)continue;let v=Math.hypot(y,w)+x;d=Math.max(d,v),f.push({radius:v,depth:y*l.x+w*l.y+x})}}let h=b=>{let p=Math.cos(b/2*Math.PI/180);return p<.2||!f.length?0:(Math.max(...f.map(x=>x.depth))+Et)/p};return{center:a,bearing:s,occupiedRadius:d,floorId:r.id,clearRadius:h}}var ts=100;function Ja(e,t,n){return e===void 0||n<=0?ts:Math.min(180,Math.max(20,Math.round(ns(e,t)/n*(180/Math.PI))))}function ns(e,t){let n=t==="two"?2:t==="center"?1:0;return e*Za+n*kt}function Af(e,t,n,o){let r=[],a=o+Et-t.occupiedRadius;if(t.occupiedRadius<=0||a<=0)return r;let i=n/2+10;for(let s of O(e,t.floorId).objects){if(Qa(s)||s.type==="shape"&&s.role==="stage")continue;let c=Ho(e,s),l=c.x+c.width/2-t.center.x,d=c.y+c.height/2-t.center.y,f=Math.hypot(l,d);if(f<=t.occupiedRadius)continue;let g=Math.atan2(l,d)*180/Math.PI;Math.abs((g-t.bearing+540)%360-180)>i||(Ve(s,l/f*a,d/f*a),r.push(s.id))}return r}function Mf(e,t){let n=es(e,t.floorId,t.spreadDegrees??ts),o=Math.max((t.firstRowDistanceM??4)*Of,n.occupiedRadius>0?n.occupiedRadius+Et+kt:0),r=t.spreadDegrees??Ja(t.seatsPerRow,t.aisles,o),a=t.spreadDegrees!==void 0&&t.seatsPerRow!==void 0?ns(t.seatsPerRow,t.aisles)/(t.spreadDegrees*Math.PI/180):0,i=Math.max(o,a,n.clearRadius(r)),s=t.spreadDegrees??Ja(t.seatsPerRow,t.aisles,i),c=i+(t.rowCount-1)*Et,l=Af(e,n,s,c);return{...So(e,{floorId:n.floorId,center:n.center,innerRadius:i,rowCount:t.rowCount,rowGap:Et,startAngle:n.bearing-s/2,endAngle:n.bearing+s/2,seatPitch:Za,fit:t.seatsPerRow===void 0?"seat-pitch":"fixed-count",...t.seatsPerRow===void 0?{}:{seatsPerRow:t.seatsPerRow},facing:"inward",...t.aisles==="center"?{aisleGaps:{center:kt}}:t.aisles==="two"?{aisleGaps:{left:kt,right:kt}}:{},categoryKey:t.categoryKey,...t.sectionLabel===void 0?{}:{sectionLabel:t.sectionLabel},idFactory:t.idFactory}),spreadDegrees:s,movedBackIds:l}}0&&(module.exports={COLORBLIND_SAFE_PALETTE,ChartOperationError,DECOR_UNITS_PER_METRE,DEFAULT_FLOOR_HEIGHT_STEP_M,DEFAULT_ROUTE_NAME,DEFAULT_SECTION_CORNER_SMOOTHING,FIRST_CATEGORY_COLOURS,MAX_BUYER_IMAGE_URL_LENGTH,MAX_FLOOR_BASE_HEIGHT_M,NAMED_AREA_FILL,ROUTE_STROKE,ROW_CURVE_DEGREES,addArcFanRows,addArea,addBookableGridArray,addBoothArray,addChartCategories,addChartCategory,addChartFloor,addChartZone,addCurvedRows,addGAArea,addGate,addIcon,addLandmark,addPlacedBoothArray,addPlacedGAArea,addPlacedRowBlocks,addPlacedTableArray,addRoute,addRowBlock,addStage,addTableArray,addText,applyPolygonHole,applyReferenceScanRows,applySectionCornerSmoothing,applySectionEstimates,applySectionOutlineShaping,applySectionRowFit,approveConfidenceEvidence,arcFanInputForGroup,assignSectionInventoryCategory,automaticPlacementCenter,blockSectionLabels,clearConfidenceEvidence,compactChartDoc,compactRowOverrides,compactTableOverrides,confidenceEvidenceChangeRequiresPublish,confidenceEvidenceChanges,confidenceEvidenceIndex,confirmReferenceCategoryOutputColor,convertGeneratedSectionToPolygon,convertShapeToOutline,countCoveredInventory,curvedRowsPlacement,decorPlacement,decorPlacementCenter,detectSeatLabelRun,dropRedundantSeatOverrideFields,familyCategoryLabel,gaAreaFootprint,gateShape,groupRowsAsSegmented,insertSeatingBlock,isSafeBuyerImageUrl,joinGAAreas,landmarkRoles,makeGate,mergeRows,mirrorFirstFloor,normalizeBuyerImageUrl,normalizeDraftEvidence,parseSeatRefId,pickColorblindSafeCategoryColor,planCreationCategory,previewArcFanRows,previewBookableGridArray,previewGeneratedSectionPolygonConversion,previewJoinGAAreas,previewPolygonHole,previewRemovePolygonHole,previewRowCubicPath,previewSectionRowFit,reassignColorblindSafeCategoryColors,relabelChartRows,releaseGateReferences,remapGateReferences,removeCategoryMovingInventory,removeChartCategory,removeChartFloor,removeChartObjects,removeChartZone,removePolygonHole,renameChartFloor,renameDirectSeatImportCategory,reorderChartCategories,replaceArcFanRows,replaceRowBlock,resetSeatOverrides,resizeShapes,resolveCreationCategory,retractConfidenceEvidence,roundBuyerCoordinates,routeShape,seatRefId,seatSemanticsSignature,sectionInventorySelectionSummary,setConfidenceEvidence,setObjectEntrance,setRoute,setRowBlockSpacing,splitRow,straightenAndSpaceRows,transformSectionBoundary,transformSectionBoundaryObject,ungroupSegmentedRow,uniqueCategoryLabel,updateBooths,updateCategoryDefinitions,updateChartFloorBaseHeight,updateChartTheme,updateChartZones,updateGAAreas,updateGate,updateRowCubicPath,updateRows,updateSeatOverrides,updateSectionExactPath,updateSectionMetadata,updateSegmentedRow,updateShapes,updateStageKinds,updateTables,updateTextObjects,updateViewFromSeatFallback});
|