@seatlayer/core 0.57.0 → 0.59.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/{chunk-AQKYUJBX.js → chunk-4BVXDBFE.js} +1 -1
  2. package/dist/{chunk-6VTTBC5F.js → chunk-66HGMU7D.js} +1 -1
  3. package/dist/chunk-GHJUDU3U.js +1 -0
  4. package/dist/{chunk-55NOSZK5.js → chunk-IRFG5DVH.js} +1 -1
  5. package/dist/{chunk-7PT7OQUO.js → chunk-PMU3VPNK.js} +1 -1
  6. package/dist/{chunk-PXWKSYCK.js → chunk-PSHBUDSB.js} +1 -1
  7. package/dist/core/chart-ops/index.js +1 -1
  8. package/dist/core/inventory/index.cjs +1 -1
  9. package/dist/core/inventory/index.d.cts +2 -2
  10. package/dist/core/inventory/index.d.ts +2 -2
  11. package/dist/core/inventory/index.js +1 -1
  12. package/dist/core/layout/index.cjs +1 -1
  13. package/dist/core/layout/index.d.cts +2 -2
  14. package/dist/core/layout/index.d.ts +2 -2
  15. package/dist/core/layout/index.js +1 -1
  16. package/dist/core/quality/index.d.cts +2 -2
  17. package/dist/core/quality/index.d.ts +2 -2
  18. package/dist/core/sections/index.cjs +1 -1
  19. package/dist/core/sections/index.d.cts +1 -1
  20. package/dist/core/sections/index.d.ts +1 -1
  21. package/dist/core/sections/index.js +1 -1
  22. package/dist/index.cjs +1 -1
  23. package/dist/index.d.cts +9 -8
  24. package/dist/index.d.ts +9 -8
  25. package/dist/index.js +1 -1
  26. package/dist/{layout-Dlv5bIf2.d.cts → layout-Ds42yIZT.d.cts} +1 -1
  27. package/dist/{layout-ClQkmixY.d.ts → layout-GZ2DPliB.d.ts} +1 -1
  28. package/dist/{renderedQuality-bDkUOyBL.d.cts → renderedQuality-CU5I5Hrg.d.cts} +1 -1
  29. package/dist/{renderedQuality-B3jgdgPO.d.ts → renderedQuality-ChkM7pSo.d.ts} +1 -1
  30. package/dist/{renderer-B_g-W_QB.d.ts → renderer-Bk65QPKq.d.ts} +19 -6
  31. package/dist/{renderer-DySMcKAR.d.cts → renderer-C313N0nM.d.cts} +19 -6
  32. package/dist/{ticketRestrictions-CzchbX_o.d.cts → ticketRestrictions-C-ohIpd0.d.cts} +1 -1
  33. package/dist/{ticketRestrictions-DaYOCpEw.d.ts → ticketRestrictions-CC75C4L0.d.ts} +1 -1
  34. package/dist/view3d/index.cjs +25 -20
  35. package/dist/view3d/index.d.cts +1 -1
  36. package/dist/view3d/index.d.ts +1 -1
  37. package/dist/view3d/index.js +18 -13
  38. package/package.json +1 -1
  39. package/dist/chunk-VDZ24QVV.js +0 -1
@@ -1 +1 @@
1
- import{ma as b,qa as p,ra as h,wa as I,za as d}from"./chunk-VDZ24QVV.js";var m="__sl_ga__",f=1e5,v=1e5;function j(t,e){return`${m}${encodeURIComponent(t)}__${e+1}`}function S(t){let e=t.inventorySegments;if(e===void 0)return!0;if(!Array.isArray(e)||e.length<1||e.length>256)return!1;let r=0,i=new Map;for(let o of e){if(!o||typeof o.sourceAreaId!="string"||!o.sourceAreaId.trim()||o.sourceAreaId.length>160||!Number.isInteger(o.startIndex)||o.startIndex<0||!Number.isInteger(o.count)||o.count<1||o.startIndex+o.count>f||(r+=o.count,r>f))return!1;let u=i.get(o.sourceAreaId)??[],n=o.startIndex+o.count;if(u.some(s=>o.startIndex<s.end&&n>s.start))return!1;u.push({start:o.startIndex,end:n}),i.set(o.sourceAreaId,u)}return r===t.capacity}function A(t){let e=Math.min(f,Math.max(0,Math.floor(t.capacity)));return t.inventorySegments===void 0?e?[{sourceAreaId:t.id,startIndex:0,count:e}]:[]:S(t)?t.inventorySegments.map(r=>({...r})):[]}function y(t){return A(t).flatMap(e=>Array.from({length:e.count},(r,i)=>j(e.sourceAreaId,e.startIndex+i)))}function M(t,e){if(t.inventorySegments===void 0||e===t.capacity)return t.inventorySegments;if(e<t.capacity)return;let r=A(t);if(!r.length)return;let i=e-t.capacity;if(!i)return r;let u=r.filter(s=>s.sourceAreaId===t.id).reduce((s,a)=>Math.max(s,a.startIndex+a.count),0),n=r[r.length-1];if(n?.sourceAreaId===t.id&&n.startIndex+n.count===u)n.count+=i;else{if(r.length>=256)return;r.push({sourceAreaId:t.id,startIndex:u,count:i})}return r}function R(t){return d(t).filter(e=>e.type==="gaArea")}function N(t){return t.startsWith(m)}var g="__ungrouped__";function x(t){return t.type==="row"?b(t).map(e=>e.label):t.type==="table"?p(t).map(e=>e.label):t.type==="booth"?h(t).map(e=>e.label):t.type==="gaArea"?y(t):[]}function O(t){return t.type==="row"||t.type==="table"||t.type==="booth"||t.type==="gaArea"}function _(t){let e=d(t),r=e.filter(n=>n.type==="section"),i=new Map;for(let n of r){let s=n.logicalSectionId??n.id;i.get(s)||i.set(s,{id:s,label:n.displayLabel||n.label||"Section",zone:n.zone,seatCount:0,objectIds:[],seatLabels:[]})}let o={id:g,label:"Other seats",seatCount:0,objectIds:[],seatLabels:[]},u=new Map;for(let n of e){if(!O(n))continue;let s=x(n);if(s.length===0)continue;let a=I(e,n),c=a?i.get(a.logicalSectionId??a.id):o;c.seatCount+=s.length,c.objectIds.push(n.id),c.seatLabels.push(...s),u.set(n.id,c.id)}return{sections:[...i.values()],ungrouped:o.objectIds.length?o:null,objectToSection:u}}function C(t,e){return e.has(t.id)||!!t.logicalSectionId&&e.has(t.logicalSectionId)||!!t.zone&&e.has(t.zone)}function G(t,e){let r=new Set;if(!e.size)return r;let{sections:i,ungrouped:o,objectToSection:u}=_(t),n=new Set,s=new Map(i.map(c=>[c.id,c.zone]));for(let c of i){let l=s.get(c.id);(e.has(c.id)||l&&e.has(l))&&n.add(c.id)}let a=!!o&&e.has(g);for(let[c,l]of u)(n.has(l)||a&&l===g)&&r.add(c);return r}function U(t,e){if(!e.size)return t;let r=G(t,e),i=e instanceof Set?e:new Set(e),o=n=>!(r.has(n.id)||n.type==="section"&&C(n,i));if(t.floors&&t.floors.length){let n=!1,s=t.floors.map(a=>{let c=a.objects.filter(o);return c.length!==a.objects.length&&(n=!0),c.length===a.objects.length?a:{...a,objects:c}});return n?{...t,floors:s,objects:s[0].objects}:t}let u=t.objects.filter(o);return u.length===t.objects.length?t:{...t,objects:u}}export{f as a,v as b,j as c,S as d,A as e,y as f,M as g,R as h,N as i,g as j,_ as k,C as l,G as m,U as n};
1
+ import{ma as b,qa as p,ra as h,wa as I,za as d}from"./chunk-GHJUDU3U.js";var m="__sl_ga__",f=1e5,v=1e5;function j(t,e){return`${m}${encodeURIComponent(t)}__${e+1}`}function S(t){let e=t.inventorySegments;if(e===void 0)return!0;if(!Array.isArray(e)||e.length<1||e.length>256)return!1;let r=0,i=new Map;for(let o of e){if(!o||typeof o.sourceAreaId!="string"||!o.sourceAreaId.trim()||o.sourceAreaId.length>160||!Number.isInteger(o.startIndex)||o.startIndex<0||!Number.isInteger(o.count)||o.count<1||o.startIndex+o.count>f||(r+=o.count,r>f))return!1;let u=i.get(o.sourceAreaId)??[],n=o.startIndex+o.count;if(u.some(s=>o.startIndex<s.end&&n>s.start))return!1;u.push({start:o.startIndex,end:n}),i.set(o.sourceAreaId,u)}return r===t.capacity}function A(t){let e=Math.min(f,Math.max(0,Math.floor(t.capacity)));return t.inventorySegments===void 0?e?[{sourceAreaId:t.id,startIndex:0,count:e}]:[]:S(t)?t.inventorySegments.map(r=>({...r})):[]}function y(t){return A(t).flatMap(e=>Array.from({length:e.count},(r,i)=>j(e.sourceAreaId,e.startIndex+i)))}function M(t,e){if(t.inventorySegments===void 0||e===t.capacity)return t.inventorySegments;if(e<t.capacity)return;let r=A(t);if(!r.length)return;let i=e-t.capacity;if(!i)return r;let u=r.filter(s=>s.sourceAreaId===t.id).reduce((s,a)=>Math.max(s,a.startIndex+a.count),0),n=r[r.length-1];if(n?.sourceAreaId===t.id&&n.startIndex+n.count===u)n.count+=i;else{if(r.length>=256)return;r.push({sourceAreaId:t.id,startIndex:u,count:i})}return r}function R(t){return d(t).filter(e=>e.type==="gaArea")}function N(t){return t.startsWith(m)}var g="__ungrouped__";function x(t){return t.type==="row"?b(t).map(e=>e.label):t.type==="table"?p(t).map(e=>e.label):t.type==="booth"?h(t).map(e=>e.label):t.type==="gaArea"?y(t):[]}function O(t){return t.type==="row"||t.type==="table"||t.type==="booth"||t.type==="gaArea"}function _(t){let e=d(t),r=e.filter(n=>n.type==="section"),i=new Map;for(let n of r){let s=n.logicalSectionId??n.id;i.get(s)||i.set(s,{id:s,label:n.displayLabel||n.label||"Section",zone:n.zone,seatCount:0,objectIds:[],seatLabels:[]})}let o={id:g,label:"Other seats",seatCount:0,objectIds:[],seatLabels:[]},u=new Map;for(let n of e){if(!O(n))continue;let s=x(n);if(s.length===0)continue;let a=I(e,n),c=a?i.get(a.logicalSectionId??a.id):o;c.seatCount+=s.length,c.objectIds.push(n.id),c.seatLabels.push(...s),u.set(n.id,c.id)}return{sections:[...i.values()],ungrouped:o.objectIds.length?o:null,objectToSection:u}}function C(t,e){return e.has(t.id)||!!t.logicalSectionId&&e.has(t.logicalSectionId)||!!t.zone&&e.has(t.zone)}function G(t,e){let r=new Set;if(!e.size)return r;let{sections:i,ungrouped:o,objectToSection:u}=_(t),n=new Set,s=new Map(i.map(c=>[c.id,c.zone]));for(let c of i){let l=s.get(c.id);(e.has(c.id)||l&&e.has(l))&&n.add(c.id)}let a=!!o&&e.has(g);for(let[c,l]of u)(n.has(l)||a&&l===g)&&r.add(c);return r}function U(t,e){if(!e.size)return t;let r=G(t,e),i=e instanceof Set?e:new Set(e),o=n=>!(r.has(n.id)||n.type==="section"&&C(n,i));if(t.floors&&t.floors.length){let n=!1,s=t.floors.map(a=>{let c=a.objects.filter(o);return c.length!==a.objects.length&&(n=!0),c.length===a.objects.length?a:{...a,objects:c}});return n?{...t,floors:s,objects:s[0].objects}:t}let u=t.objects.filter(o);return u.length===t.objects.length?t:{...t,objects:u}}export{f as a,v as b,j as c,S as d,A as e,y as f,M as g,R as h,N as i,g as j,_ as k,C as l,G as m,U as n};
@@ -1 +1 @@
1
- import{x as X}from"./chunk-VDZ24QVV.js";var Y=9;function E(t){if(t.kind==="circle")return{hx:t.r,hy:t.r};let e=t.width/2,o=t.height/2,n=t.rotation??0;if(!n)return{hx:e,hy:o};let r=n*Math.PI/180,s=Math.abs(Math.cos(r)),c=Math.abs(Math.sin(r));return{hx:e*s+o*c,hy:e*c+o*s}}function B(t,e,o){let n=e-t.seat.x,r=o-t.seat.y;if(t.shape.kind==="circle")return n*n+r*r<=t.shape.r*t.shape.r;let s=t.shape.rotation??0,c=n,d=r;if(s){let u=-s*Math.PI/180,m=Math.cos(u),y=Math.sin(u);c=n*m-r*y,d=n*y+r*m}return Math.abs(c)<=t.shape.width/2&&Math.abs(d)<=t.shape.height/2}function L(t,e,o,n,r){if(t.shape.kind==="circle"){let h=Math.min(Math.max(t.seat.x,e),n),l=Math.min(Math.max(t.seat.y,o),r),x=t.seat.x-h,p=t.seat.y-l;return x*x+p*p<=t.shape.r*t.shape.r}let s=t.shape.rotation??0;if(!s)return t.seat.x-t.hx<=n&&t.seat.x+t.hx>=e&&t.seat.y-t.hy<=r&&t.seat.y+t.hy>=o;let c=s*Math.PI/180,d=Math.cos(c),u=Math.sin(c),m=t.shape.width/2,y=t.shape.height/2,f=[[-m,-y],[m,-y],[m,y],[-m,y]].map(([h,l])=>[t.seat.x+h*d-l*u,t.seat.y+h*u+l*d]),P=[[e,o],[n,o],[n,r],[e,r]],A=[[1,0],[0,1],[d,u],[-u,d]];for(let[h,l]of A){let x=1/0,p=-1/0;for(let[I,D]of f){let a=I*h+D*l;a<x&&(x=a),a>p&&(p=a)}let M=1/0,S=-1/0;for(let[I,D]of P){let a=I*h+D*l;a<M&&(M=a),a>S&&(S=a)}if(p<M||S<x)return!1}return!0}function j(t,e={}){let o=e.seatRadius??Y,n=t.length,r=new Array(n),s=1/0,c=1/0,d=-1/0,u=-1/0,m=0;for(let a=0;a<n;a++){let i=t[a],R=e.shapeOf?.(i)??{kind:"circle",r:o},{hx:w,hy:b}=E(R);r[a]={seat:i,shape:R,hx:w,hy:b},i.x-w<s&&(s=i.x-w),i.y-b<c&&(c=i.y-b),i.x+w>d&&(d=i.x+w),i.y+b>u&&(u=i.y+b),w>m&&(m=w),b>m&&(m=b)}n===0&&(s=0,c=0,d=0,u=0);let y=m>0?m*4:1,f=Math.max(d-s,0),P=Math.max(u-c,0),A=Math.max(64,e.maxCells??n*4),h=y,l=Math.max(1,Math.ceil(f/h)||1),x=Math.max(1,Math.ceil(P/h)||1);for(;l*x>A&&(l>1||x>1);)h*=2,l=Math.max(1,Math.ceil(f/h)||1),x=Math.max(1,Math.ceil(P/h)||1);let p=l*x,M=new Int32Array(p+1),S=0;for(let a=0;a<n;a++){let i=r[a],R=X(Math.floor((i.seat.x-i.hx-s)/h),0,l-1),w=X(Math.floor((i.seat.x+i.hx-s)/h),0,l-1),b=X(Math.floor((i.seat.y-i.hy-c)/h),0,x-1),k=X(Math.floor((i.seat.y+i.hy-c)/h),0,x-1);for(let C=b;C<=k;C++)for(let g=R;g<=w;g++)M[C*l+g+1]++,S++}for(let a=0;a<p;a++)M[a+1]+=M[a];let I=new Int32Array(S),D=M.slice(0,p);for(let a=0;a<n;a++){let i=r[a],R=X(Math.floor((i.seat.x-i.hx-s)/h),0,l-1),w=X(Math.floor((i.seat.x+i.hx-s)/h),0,l-1),b=X(Math.floor((i.seat.y-i.hy-c)/h),0,x-1),k=X(Math.floor((i.seat.y+i.hy-c)/h),0,x-1);for(let C=b;C<=k;C++)for(let g=R;g<=w;g++){let v=C*l+g;I[D[v]++]=a}}return{seats:t,entries:r,minX:s,minY:c,cell:h,cols:l,rows:x,cellStart:M,items:I,stamp:new Int32Array(n),epoch:0}}function q(t,e,o={}){let{cols:n,rows:r,cell:s,minX:c,minY:d,cellStart:u,items:m,entries:y}=t,f=Math.floor((e.x-c)/s),P=Math.floor((e.y-d)/s);if(f<0||P<0||f>=n||P>=r)return null;let A=P*n+f,h=u[A+1],l=-1,x=1/0;for(let p=u[A];p<h;p++){let M=m[p],S=y[M];if(o.filter&&!o.filter(S.seat.id,S.seat)||!B(S,e.x,e.y))continue;let I=e.x-S.seat.x,D=e.y-S.seat.y,a=I*I+D*D;(a<x||a===x&&M<l)&&(x=a,l=M)}return l<0?null:y[l].seat.id}function F(t,e,o,n={}){if(!(o>0))return null;let{cols:r,rows:s,cell:c,minX:d,minY:u,cellStart:m,items:y,entries:f}=t,P=Math.max(0,Math.floor((e.x-o-d)/c)),A=Math.min(r-1,Math.floor((e.x+o-d)/c)),h=Math.max(0,Math.floor((e.y-o-u)/c)),l=Math.min(s-1,Math.floor((e.y+o-u)/c));if(P>A||h>l)return null;let x=-1,p=o*o,M=t.stamp,S=++t.epoch;for(let I=h;I<=l;I++){let D=I*r;for(let a=P;a<=A;a++){let i=D+a,R=m[i+1];for(let w=m[i];w<R;w++){let b=y[w];if(M[b]===S)continue;M[b]=S;let k=f[b];if(n.filter&&!n.filter(k.seat.id,k.seat))continue;let C=e.x-k.seat.x,g=e.y-k.seat.y,v=C*C+g*g;(v<p||v===p&&b<x)&&(p=v,x=b)}}}return x<0?null:f[x].seat.id}function U(t,e,o={}){let n=Math.min(e.x,e.x+e.width),r=Math.max(e.x,e.x+e.width),s=Math.min(e.y,e.y+e.height),c=Math.max(e.y,e.y+e.height),d=o.mode??"center",{cols:u,rows:m,cell:y,minX:f,minY:P,cellStart:A,items:h,entries:l}=t,x=Math.max(0,Math.floor((n-f)/y)),p=Math.min(u-1,Math.floor((r-f)/y)),M=Math.max(0,Math.floor((s-P)/y)),S=Math.min(m-1,Math.floor((c-P)/y));if(x>p||M>S)return[];let I=[],D=t.stamp,a=++t.epoch;for(let i=M;i<=S;i++){let R=i*u;for(let w=x;w<=p;w++){let b=R+w,k=A[b+1];for(let C=A[b];C<k;C++){let g=h[C];if(D[g]===a)continue;D[g]=a;let v=l[g];if(o.filter&&!o.filter(v.seat.id,v.seat))continue;(d==="center"?v.seat.x>=n&&v.seat.x<=r&&v.seat.y>=s&&v.seat.y<=c:L(v,n,s,r,c))&&I.push(g)}}}return I.sort((i,R)=>i-R),I.map(i=>l[i].seat.id)}function _(t){let e=t.cols*t.rows,o=0,n=0;for(let s=0;s<e;s++){let c=t.cellStart[s+1]-t.cellStart[s];c>0&&o++,c>n&&(n=c)}let r=t.items.length;return{cell:t.cell,cols:t.cols,rows:t.rows,cells:e,occupiedCells:o,refs:r,maxPerCell:n,meanPerOccupiedCell:o?r/o:0}}function N(t,e=0){let o=Math.max(1,t.width,t.height),n={x:t.x+t.width/2,y:t.y+t.height/2},r=o*1.55,s=Math.max(o*.82,Math.max(0,e)+o*.45);return{target:n,distance:r,height:s,focalLength:Math.hypot(r,s),yawRad:-8*Math.PI/180}}function O(t,e,o=0){let n=e.x-t.target.x,r=e.y-t.target.y,s=Math.cos(t.yawRad),c=Math.sin(t.yawRad),d=n*s-r*c,m=n*c+r*s-t.distance,y=o-t.height,f=Math.hypot(t.distance,t.height),P=(-t.distance*m-t.height*y)/f,A=(-t.height*m+t.distance*y)/f,h=Math.max(f*.08,P),l=t.focalLength/h;return{x:t.target.x+d*l,y:t.target.y-A*l,depth:h,scale:l}}function W(t,e){return{x:t.a*e.x+t.c*e.y+t.e,y:t.b*e.x+t.d*e.y+t.f}}function Z(t){let e=t.a*t.d-t.b*t.c;if(!Number.isFinite(e)||Math.abs(e)<1e-9)throw new Error("perspective projection produced a singular affine");let o=t.d/e,n=-t.b/e,r=-t.c/e,s=t.a/e;return{a:o,b:n,c:r,d:s,e:-(o*t.e+r*t.f),f:-(n*t.e+s*t.f)}}function z(t,e){return{a:t.a*e.a+t.c*e.b,b:t.b*e.a+t.d*e.b,c:t.a*e.c+t.c*e.d,d:t.b*e.c+t.d*e.d,e:t.a*e.e+t.c*e.f+t.e,f:t.b*e.e+t.d*e.f+t.f}}function G(t,e,o=()=>0){let n=O(t,e,o(e)),r={x:e.x+1,y:e.y},s={x:e.x,y:e.y+1},c=O(t,r,o(r)),d=O(t,s,o(s)),u=c.x-n.x,m=c.y-n.y,y=d.x-n.x,f=d.y-n.y;return{a:u,b:m,c:y,d:f,e:n.x-u*e.x-y*e.y,f:n.y-m*e.x-f*e.y}}function J(t){let e=Math.hypot(t.a,t.b),o=t.a*t.d-t.b*t.c;return{rotationDeg:Math.atan2(t.b,t.a)*180/Math.PI,scaleX:e,scaleY:o/Math.max(e,1e-9),skewX:(t.a*t.c+t.b*t.d)/Math.max(o,1e-9)}}export{Y as a,j as b,q as c,F as d,U as e,_ as f,N as g,O as h,W as i,Z as j,z as k,G as l,J as m};
1
+ import{x as X}from"./chunk-GHJUDU3U.js";var Y=9;function E(t){if(t.kind==="circle")return{hx:t.r,hy:t.r};let e=t.width/2,o=t.height/2,n=t.rotation??0;if(!n)return{hx:e,hy:o};let r=n*Math.PI/180,s=Math.abs(Math.cos(r)),c=Math.abs(Math.sin(r));return{hx:e*s+o*c,hy:e*c+o*s}}function B(t,e,o){let n=e-t.seat.x,r=o-t.seat.y;if(t.shape.kind==="circle")return n*n+r*r<=t.shape.r*t.shape.r;let s=t.shape.rotation??0,c=n,d=r;if(s){let u=-s*Math.PI/180,m=Math.cos(u),y=Math.sin(u);c=n*m-r*y,d=n*y+r*m}return Math.abs(c)<=t.shape.width/2&&Math.abs(d)<=t.shape.height/2}function L(t,e,o,n,r){if(t.shape.kind==="circle"){let h=Math.min(Math.max(t.seat.x,e),n),l=Math.min(Math.max(t.seat.y,o),r),x=t.seat.x-h,p=t.seat.y-l;return x*x+p*p<=t.shape.r*t.shape.r}let s=t.shape.rotation??0;if(!s)return t.seat.x-t.hx<=n&&t.seat.x+t.hx>=e&&t.seat.y-t.hy<=r&&t.seat.y+t.hy>=o;let c=s*Math.PI/180,d=Math.cos(c),u=Math.sin(c),m=t.shape.width/2,y=t.shape.height/2,f=[[-m,-y],[m,-y],[m,y],[-m,y]].map(([h,l])=>[t.seat.x+h*d-l*u,t.seat.y+h*u+l*d]),P=[[e,o],[n,o],[n,r],[e,r]],A=[[1,0],[0,1],[d,u],[-u,d]];for(let[h,l]of A){let x=1/0,p=-1/0;for(let[I,D]of f){let a=I*h+D*l;a<x&&(x=a),a>p&&(p=a)}let M=1/0,S=-1/0;for(let[I,D]of P){let a=I*h+D*l;a<M&&(M=a),a>S&&(S=a)}if(p<M||S<x)return!1}return!0}function j(t,e={}){let o=e.seatRadius??Y,n=t.length,r=new Array(n),s=1/0,c=1/0,d=-1/0,u=-1/0,m=0;for(let a=0;a<n;a++){let i=t[a],R=e.shapeOf?.(i)??{kind:"circle",r:o},{hx:w,hy:b}=E(R);r[a]={seat:i,shape:R,hx:w,hy:b},i.x-w<s&&(s=i.x-w),i.y-b<c&&(c=i.y-b),i.x+w>d&&(d=i.x+w),i.y+b>u&&(u=i.y+b),w>m&&(m=w),b>m&&(m=b)}n===0&&(s=0,c=0,d=0,u=0);let y=m>0?m*4:1,f=Math.max(d-s,0),P=Math.max(u-c,0),A=Math.max(64,e.maxCells??n*4),h=y,l=Math.max(1,Math.ceil(f/h)||1),x=Math.max(1,Math.ceil(P/h)||1);for(;l*x>A&&(l>1||x>1);)h*=2,l=Math.max(1,Math.ceil(f/h)||1),x=Math.max(1,Math.ceil(P/h)||1);let p=l*x,M=new Int32Array(p+1),S=0;for(let a=0;a<n;a++){let i=r[a],R=X(Math.floor((i.seat.x-i.hx-s)/h),0,l-1),w=X(Math.floor((i.seat.x+i.hx-s)/h),0,l-1),b=X(Math.floor((i.seat.y-i.hy-c)/h),0,x-1),k=X(Math.floor((i.seat.y+i.hy-c)/h),0,x-1);for(let C=b;C<=k;C++)for(let g=R;g<=w;g++)M[C*l+g+1]++,S++}for(let a=0;a<p;a++)M[a+1]+=M[a];let I=new Int32Array(S),D=M.slice(0,p);for(let a=0;a<n;a++){let i=r[a],R=X(Math.floor((i.seat.x-i.hx-s)/h),0,l-1),w=X(Math.floor((i.seat.x+i.hx-s)/h),0,l-1),b=X(Math.floor((i.seat.y-i.hy-c)/h),0,x-1),k=X(Math.floor((i.seat.y+i.hy-c)/h),0,x-1);for(let C=b;C<=k;C++)for(let g=R;g<=w;g++){let v=C*l+g;I[D[v]++]=a}}return{seats:t,entries:r,minX:s,minY:c,cell:h,cols:l,rows:x,cellStart:M,items:I,stamp:new Int32Array(n),epoch:0}}function q(t,e,o={}){let{cols:n,rows:r,cell:s,minX:c,minY:d,cellStart:u,items:m,entries:y}=t,f=Math.floor((e.x-c)/s),P=Math.floor((e.y-d)/s);if(f<0||P<0||f>=n||P>=r)return null;let A=P*n+f,h=u[A+1],l=-1,x=1/0;for(let p=u[A];p<h;p++){let M=m[p],S=y[M];if(o.filter&&!o.filter(S.seat.id,S.seat)||!B(S,e.x,e.y))continue;let I=e.x-S.seat.x,D=e.y-S.seat.y,a=I*I+D*D;(a<x||a===x&&M<l)&&(x=a,l=M)}return l<0?null:y[l].seat.id}function F(t,e,o,n={}){if(!(o>0))return null;let{cols:r,rows:s,cell:c,minX:d,minY:u,cellStart:m,items:y,entries:f}=t,P=Math.max(0,Math.floor((e.x-o-d)/c)),A=Math.min(r-1,Math.floor((e.x+o-d)/c)),h=Math.max(0,Math.floor((e.y-o-u)/c)),l=Math.min(s-1,Math.floor((e.y+o-u)/c));if(P>A||h>l)return null;let x=-1,p=o*o,M=t.stamp,S=++t.epoch;for(let I=h;I<=l;I++){let D=I*r;for(let a=P;a<=A;a++){let i=D+a,R=m[i+1];for(let w=m[i];w<R;w++){let b=y[w];if(M[b]===S)continue;M[b]=S;let k=f[b];if(n.filter&&!n.filter(k.seat.id,k.seat))continue;let C=e.x-k.seat.x,g=e.y-k.seat.y,v=C*C+g*g;(v<p||v===p&&b<x)&&(p=v,x=b)}}}return x<0?null:f[x].seat.id}function U(t,e,o={}){let n=Math.min(e.x,e.x+e.width),r=Math.max(e.x,e.x+e.width),s=Math.min(e.y,e.y+e.height),c=Math.max(e.y,e.y+e.height),d=o.mode??"center",{cols:u,rows:m,cell:y,minX:f,minY:P,cellStart:A,items:h,entries:l}=t,x=Math.max(0,Math.floor((n-f)/y)),p=Math.min(u-1,Math.floor((r-f)/y)),M=Math.max(0,Math.floor((s-P)/y)),S=Math.min(m-1,Math.floor((c-P)/y));if(x>p||M>S)return[];let I=[],D=t.stamp,a=++t.epoch;for(let i=M;i<=S;i++){let R=i*u;for(let w=x;w<=p;w++){let b=R+w,k=A[b+1];for(let C=A[b];C<k;C++){let g=h[C];if(D[g]===a)continue;D[g]=a;let v=l[g];if(o.filter&&!o.filter(v.seat.id,v.seat))continue;(d==="center"?v.seat.x>=n&&v.seat.x<=r&&v.seat.y>=s&&v.seat.y<=c:L(v,n,s,r,c))&&I.push(g)}}}return I.sort((i,R)=>i-R),I.map(i=>l[i].seat.id)}function _(t){let e=t.cols*t.rows,o=0,n=0;for(let s=0;s<e;s++){let c=t.cellStart[s+1]-t.cellStart[s];c>0&&o++,c>n&&(n=c)}let r=t.items.length;return{cell:t.cell,cols:t.cols,rows:t.rows,cells:e,occupiedCells:o,refs:r,maxPerCell:n,meanPerOccupiedCell:o?r/o:0}}function N(t,e=0){let o=Math.max(1,t.width,t.height),n={x:t.x+t.width/2,y:t.y+t.height/2},r=o*1.55,s=Math.max(o*.82,Math.max(0,e)+o*.45);return{target:n,distance:r,height:s,focalLength:Math.hypot(r,s),yawRad:-8*Math.PI/180}}function O(t,e,o=0){let n=e.x-t.target.x,r=e.y-t.target.y,s=Math.cos(t.yawRad),c=Math.sin(t.yawRad),d=n*s-r*c,m=n*c+r*s-t.distance,y=o-t.height,f=Math.hypot(t.distance,t.height),P=(-t.distance*m-t.height*y)/f,A=(-t.height*m+t.distance*y)/f,h=Math.max(f*.08,P),l=t.focalLength/h;return{x:t.target.x+d*l,y:t.target.y-A*l,depth:h,scale:l}}function W(t,e){return{x:t.a*e.x+t.c*e.y+t.e,y:t.b*e.x+t.d*e.y+t.f}}function Z(t){let e=t.a*t.d-t.b*t.c;if(!Number.isFinite(e)||Math.abs(e)<1e-9)throw new Error("perspective projection produced a singular affine");let o=t.d/e,n=-t.b/e,r=-t.c/e,s=t.a/e;return{a:o,b:n,c:r,d:s,e:-(o*t.e+r*t.f),f:-(n*t.e+s*t.f)}}function z(t,e){return{a:t.a*e.a+t.c*e.b,b:t.b*e.a+t.d*e.b,c:t.a*e.c+t.c*e.d,d:t.b*e.c+t.d*e.d,e:t.a*e.e+t.c*e.f+t.e,f:t.b*e.e+t.d*e.f+t.f}}function G(t,e,o=()=>0){let n=O(t,e,o(e)),r={x:e.x+1,y:e.y},s={x:e.x,y:e.y+1},c=O(t,r,o(r)),d=O(t,s,o(s)),u=c.x-n.x,m=c.y-n.y,y=d.x-n.x,f=d.y-n.y;return{a:u,b:m,c:y,d:f,e:n.x-u*e.x-y*e.y,f:n.y-m*e.x-f*e.y}}function J(t){let e=Math.hypot(t.a,t.b),o=t.a*t.d-t.b*t.c;return{rotationDeg:Math.atan2(t.b,t.a)*180/Math.PI,scaleX:e,scaleY:o/Math.max(e,1e-9),skewX:(t.a*t.c+t.b*t.d)/Math.max(o,1e-9)}}export{Y as a,j as b,q as c,F as d,U as e,_ as f,N as g,O as h,W as i,Z as j,z as k,G as l,J as m};
@@ -0,0 +1 @@
1
+ var Ft=40,Ht=1200,Ut=.8,Bt=3,Gt=-2,Xt=20,zt=.1,Kt=40,$t=40,re=e=>Math.max(1,e.fontSize*.6+(e.letterSpacing??0));function Ge(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/re(e))),r=0;for(let i of n){if(!i.length){r+=1;continue}let s=0;for(let c of i.split(/\s+/)){let u=c.length;s&&s+1+u<=o?s+=1+u:(r+=Math.max(1,Math.ceil(u/o)),s=u%o)}}return Math.max(1,r)}function ie(e){let t=e.background?.padding??0,n=e.text.split(/\r?\n/),o=Math.max(1,...n.map(c=>c.length))*re(e),r=e.width??o+t*2,i=Math.max(1,r-t*2),s=Ge(e,i);return{width:r,height:s*e.fontSize*(e.lineHeight??1.2)+t*2,lineCount:s,padding:t}}var Xe=Math.PI/180;function v(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function ze(e,t,n){let o=Math.cos(n),r=Math.sin(n),i=e.x-t.x,s=e.y-t.y;return{x:t.x+i*o-s*r,y:t.y+i*r+s*o}}function Vt(e,t){return ze(e,{x:0,y:0},t*Xe)}function C(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function Ke(e){let t=0,n=0;for(let r of e)t+=r.x,n+=r.y;let o=e.length||1;return{x:t/o,y:n/o}}function Yt(e){return e.length?Ke(e):null}function W(e,t){let n=1-t,o=n*n*n,r=3*n*n*t,i=3*n*t*t,s=t*t*t;return{x:o*e.start.x+r*e.control1.x+i*e.control2.x+s*e.end.x,y:o*e.start.y+r*e.control1.y+i*e.control2.y+s*e.end.y}}function Qt(e,t,n){let o={x:(e.x+t.x)/2,y:(e.y+t.y)/2},r={x:(n.x-o.x)*4/3,y:(n.y-o.y)*4/3};return{start:{...e},control1:{x:e.x+(t.x-e.x)/3+r.x,y:e.y+(t.y-e.y)/3+r.y},control2:{x:e.x+(t.x-e.x)*2/3+r.x,y:e.y+(t.y-e.y)*2/3+r.y},end:{...t}}}function ae(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[W(e,.5)];let o=Array.from({length:n+1},(u,b)=>W(e,b/n)),r=new Float64Array(o.length);for(let u=1;u<o.length;u+=1){let b=o[u].x-o[u-1].x,a=o[u].y-o[u-1].y;r[u]=r[u-1]+Math.hypot(b,a)}let i=r[r.length-1];if(i<=1e-9)return Array.from({length:t},()=>({...e.start}));let s=[],c=1;for(let u=0;u<t;u+=1){let b=i*u/(t-1);for(;c<r.length-1&&r[c]<b;)c+=1;let a=r[c-1],f=r[c],l=f===a?0:(b-a)/(f-a);s.push({x:o[c-1].x+(o[c].x-o[c-1].x)*l,y:o[c-1].y+(o[c].y-o[c-1].y)*l})}return s}function R(e,t){return{x:e.x+t.x,y:e.y+t.y}}function D(e,t){return{x:e.x-t.x,y:e.y-t.y}}function T(e,t){return{x:e.x*t,y:e.y*t}}function G(e,t=13){return Array.from({length:t},(n,o)=>W(e,o/(t-1)))}function se(e,t){let n=Math.max(0,Math.min(1,t))*(e.length-1),o=Math.min(e.length-2,Math.floor(n));return C(e[o],e[o+1],n-o)}function ce(e,t,n){let o=Math.max(0,Math.min(1,t)),r=Math.max(o,Math.min(1,n)),i=[se(e,o)];for(let s=1;s<e.length-1;s+=1){let c=s/(e.length-1);c>o+1e-9&&c<r-1e-9&&i.push(e[s])}return i.push(se(e,r)),i}function le(e,t){let n=[[0,1],[1,2],[2,3],[3,0]],o=0,r=Number.POSITIVE_INFINITY;n.forEach(([l,p],x)=>{let g=v(C(e[l],e[p],.5),t);g<r&&(r=g,o=x)});let i=e[o],s=e[(o+1)%4],c=e[(o+2)%4],u=e[(o+3)%4],b=C(i,s,.5),a=D(t,b),f=Math.max(1e-9,Math.hypot(a.x,a.y));return{p0:i,p1:s,p2:c,p3:u,normal:T(a,1/f),depth:(v(i,u)+v(s,c))/2}}function ue(e){let{p0:t,p1:n,p2:o,p3:r,normal:i,depth:s}=e,c=D(n,t),u=D(o,r),b=s*.22,a=s*.12;return{nearPath:{start:t,control1:R(R(t,T(c,1/3)),T(i,b)),control2:R(R(t,T(c,2/3)),T(i,b)),end:n},farPath:{start:o,control1:R(R(r,T(u,2/3)),T(i,a)),control2:R(R(r,T(u,1/3)),T(i,a)),end:r}}}function Zt(e,t,n){if(e.length!==4)throw new Error("A section shell requires four mapped bounds corners");let o=e.reduce((x,g)=>R(x,g),{x:0,y:0});o.x/=4,o.y/=4;let r=v(e[0],e[1]),i=v(e[0],e[3]),s=n==="auto"?r>i*1.25&&v(o,t)>i?"bezier":"tapered":n;if(s==="rectangle")return{mode:s,outline:e.map(x=>({...x}))};let c=le(e,t),{p0:u,p1:b,p2:a,p3:f}=c;if(s==="tapered")return{mode:s,outline:[R(u,T(D(b,u),.14)),R(u,T(D(b,u),1-.14)),a,f]};let{nearPath:l,farPath:p}=ue(c);return{mode:s,outline:[...G(l),...G(p).slice(1)]}}function en(e,t,n,o){if(e.length!==4)throw new Error("Aisle generation requires four mapped bounds corners");if(!Number.isInteger(n)||n<0||n>3)throw new Error("Aisle count must be an integer from 0 to 3");if(n===0)return[];let r=le(e,t),{p0:i,p1:s,p2:c,p3:u}=r,b=o==="bezier"?ue(r):null,a=b?G(b.nearPath):null,f=b?G(b.farPath).reverse():null,l=Math.min(.055,.18/(n+1));return Array.from({length:n},(p,x)=>{let g=(x+1)/(n+1),h=g-l/2,m=g+l/2;return a&&f?[...ce(a,h,m),...ce(f,h,m).reverse()]:[C(i,s,h),C(i,s,m),C(u,c,m),C(u,c,h)]})}function $e(e,t,n){let o=n.x-t.x,r=n.y-t.y,i=o*o+r*r,s=i?Math.max(0,Math.min(1,((e.x-t.x)*o+(e.y-t.y)*r)/i)):0;return Math.hypot(e.x-(t.x+s*o),e.y-(t.y+s*r))}function We(e,t){let n=1/0;for(let o of t)if(!(o.length<2))for(let r=0,i=o.length-1;r<o.length;i=r++){let s=$e(e,o[i],o[r]);s<n&&(n=s)}return n}function fe(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[o].x,s=t[o].y,c=t[r].x,u=t[r].y;s>e.y!=u>e.y&&e.x<(c-i)*(e.y-s)/(u-s)+i&&(n=!n)}return n}function Ve(e,t,n){let o=fe(e,t)&&!n.some(i=>fe(e,i)),r=We(e,[t,...n]);return o?r:-r}function k(e,t,n,o,r){let i=Ve({x:e,y:t},o,r);return{x:e,y:t,h:n,d:i,max:i+n*Math.SQRT2}}var V=class{constructor(){this.items=[]}get size(){return this.items.length}push(t){let n=this.items;n.push(t);let o=n.length-1;for(;o>0;){let r=o-1>>1;if(n[r].max>=n[o].max)break;[n[r],n[o]]=[n[o],n[r]],o=r}}pop(){let t=this.items,n=t[0],o=t.pop();if(t.length&&o){t[0]=o;let r=0;for(;;){let i=r*2+1,s=i+1,c=r;if(i<t.length&&t[i].max>t[c].max&&(c=i),s<t.length&&t[s].max>t[c].max&&(c=s),c===r)break;[t[c],t[r]]=[t[r],t[c]],r=c}}return n}};function de(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 nn(e,t){return Math.max(0,de(e)-(t??[]).reduce((n,o)=>n+de(o),0))}function he(e,t){let n=t??[];if(!e.length)return{point:{x:0,y:0},radius:0};if(e.length<3){let g=e.reduce((m,S)=>m+S.x,0)/e.length,h=e.reduce((m,S)=>m+S.y,0)/e.length;return{point:{x:g,y:h},radius:0}}let o=1/0,r=1/0,i=-1/0,s=-1/0;for(let g of e)g.x<o&&(o=g.x),g.y<r&&(r=g.y),g.x>i&&(i=g.x),g.y>s&&(s=g.y);let c=i-o,u=s-r,b=Math.min(c,u);if(!(b>0))return{point:{x:(o+i)/2,y:(r+s)/2},radius:0};let a=Math.max(c,u)/150,f=new V,l=b/2;for(let g=o;g<i;g+=b)for(let h=r;h<s;h+=b)f.push(k(g+l,h+l,l,e,n));let p=k(o+c/2,r+u/2,0,e,n),x=0;for(;f.size;){let g=f.pop();if(!g)break;g.d>p.d&&(p=g),!(g.max-p.d<=a)&&(x>=4e3||(x+=1,l=g.h/2,f.push(k(g.x-l,g.y-l,l,e,n)),f.push(k(g.x+l,g.y-l,l,e,n)),f.push(k(g.x-l,g.y+l,l,e,n)),f.push(k(g.x+l,g.y+l,l,e,n))))}return{point:{x:p.x,y:p.y},radius:Math.max(0,p.d)}}function Ye(e,t,n){return Math.max(t,Math.min(n,e))}function rn(e,t,n){return e<t?t:e>n?n:e}function qe(e){return Ye(e,0,1)}function me(e){let t=qe(e);return t*t*(3-2*t)}var L=Math.PI*2;function j(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}function Je(e,t,n){let o=t-e;if(n){for(;o<0;)o+=L;for(;o>=L;)o-=L}else{for(;o>0;)o-=L;for(;o<=-L;)o+=L}return o}function ln(e){return e.end}function be(e){if(e.version!==1||e.closed!==!0||!j(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||!j(n.end))return!1;if(n.kind==="line"){if(v(t,n.end)<=1e-9)return!1}else if(n.kind==="bezier"){if(!j(n.control1)||!j(n.control2)||v(t,n.end)<=1e-9)return!1}else if(n.kind==="arc"){if(!j(n.center)||!Number.isFinite(n.radius)||n.radius<=1e-6||Math.abs(v(t,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||Math.abs(v(n.end,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||v(t,n.end)<=1e-9)return!1}else return!1;t=n.end}return v(t,e.start)<=1e-4}function Qe(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 un(e,t=2){if(!be(e))throw new Error("Section outline path is invalid");let n=Math.max(.25,t),o=[{...e.start}],r=e.start;for(let i of e.segments){if(i.kind==="line")o.push({...i.end});else if(i.kind==="arc"){let s=Math.atan2(r.y-i.center.y,r.x-i.center.x),c=Math.atan2(i.end.y-i.center.y,i.end.x-i.center.x),u=Je(s,c,i.clockwise),b=Math.max(2,Math.ceil(Math.abs(u)*i.radius/n));for(let a=1;a<=b;a+=1){let f=s+u*a/b;o.push({x:i.center.x+Math.cos(f)*i.radius,y:i.center.y+Math.sin(f)*i.radius})}}else{let s=v(r,i.control1)+v(i.control1,i.control2)+v(i.control2,i.end),c=Math.max(2,Math.ceil(s/n));for(let u=1;u<=c;u+=1)o.push(Qe(r,i,u/c))}r=i.end}return v(o[o.length-1],o[0])<=1e-4&&o.pop(),o}function xe(e,t,n){return Ze(e,r=>({x:r.x+t,y:r.y+n}))}function Ze(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)})}}var fn=45,et=150,pe=.5523;function ye(e,t){return Math.abs(e.x-t.x)<=1e-6&&Math.abs(e.y-t.y)<=1e-6}function tt(e){let t=[],n=[];for(e.forEach((o,r)=>{j(o)&&(t.length&&ye(t[t.length-1],o)||(t.push({x:o.x,y:o.y}),n.push(r)))});t.length>1&&ye(t[0],t[t.length-1]);)t.pop(),n.pop();return{points:t,sourceIndex:n}}function dn(e,t,n){return it(e,{cornerSmoothing:t,...n})}var nt=.5,ot=4/3;function rt(e,t,n){let o=t.x-e.x,r=t.y-e.y,i=Math.hypot(o,r);if(i<=1e-9)return{kind:"line",end:{...t}};let s=-r/i,c=o/i,u=n*ot;return{kind:"bezier",control1:{x:e.x+o/3+s*u,y:e.y+r/3+c*u},control2:{x:e.x+o*2/3+s*u,y:e.y+r*2/3+c*u},end:{...t}}}function it(e,t){let{points:n,sourceIndex:o}=tt(e),r=n.length;if(r<3)return null;let i=Math.min(100,Math.max(0,t.cornerSmoothing??0))/100,s=t.edgeCurvature,c=new Array(r).fill(0);if(s?.length)for(let d=0;d<r;d+=1){let P=s[o[d]];c[d]=Number.isFinite(P)?Math.min(100,Math.max(-100,P))/100:0}let u=c.some(d=>Math.abs(d)>1e-6);if(i<=0&&!u)return null;let b=t.wideAngleThresholdDeg??et,a=[];for(let d=0;d<r;d+=1)a[d]=v(n[d],n[(d+1)%r]);let f=new Array(r).fill(0);for(let d=0;d<r;d+=1){let P=n[(d-1+r)%r],w=n[d],M=n[(d+1)%r],E={x:P.x-w.x,y:P.y-w.y},A={x:M.x-w.x,y:M.y-w.y},O=Math.hypot(E.x,E.y),_=Math.hypot(A.x,A.y);if(O<=1e-9||_<=1e-9)continue;let F=Math.min(1,Math.max(-1,(E.x*A.x+E.y*A.y)/(O*_))),H=Math.acos(F)*180/Math.PI;if(H<b)continue;let U=me((H-b)/(180-b));f[d]=i*U*.5*Math.min(O,_)}for(let d=0;d<r;d+=1){let P=(d+1)%r,w=f[d]+f[P];if(w>a[d]&&w>1e-9){let M=a[d]/w;f[d]*=M,f[P]*=M}}let l=new Array(r),p=new Array(r);for(let d=0;d<r;d+=1){let P=n[(d-1+r)%r],w=n[d],M=n[(d+1)%r];if(f[d]<=1e-6){l[d]={...w},p[d]={...w};continue}let E=v(w,P)||1,A=v(w,M)||1;l[d]={x:w.x+(P.x-w.x)/E*f[d],y:w.y+(P.y-w.y)/E*f[d]},p[d]={x:w.x+(M.x-w.x)/A*f[d],y:w.y+(M.y-w.y)/A*f[d]}}if(f.every(d=>d<=1e-6)&&!u)return null;let x=[],g={...p[0]},h=g,m=(d,P)=>{if(v(h,d)<=1e-9)return;let w=c[P];Math.abs(w)>1e-6?x.push(rt(h,d,w*nt*a[P])):x.push({kind:"line",end:{...d}}),h=d};for(let d=1;d<=r;d+=1){let P=d%r,w=n[P];m(l[P],(d-1)%r),f[P]>1e-6&&v(l[P],p[P])>1e-9&&(x.push({kind:"bezier",control1:C(l[P],w,pe),control2:C(p[P],w,pe),end:{...p[P]}}),h=p[P])}if(!x.length)return null;let S=x[x.length-1];v(S.end,g)>1e-9&&(S.kind==="line"?S.end={...g}:x.push({kind:"line",end:{...g}}));let y={version:1,closed:!0,start:g,segments:x};return be(y)?y:null}function hn(e){let t=[],n=e.start;for(let r of e.segments)t.push(n),n=r.end;let o=[];for(let r=e.segments.length-1;r>=0;r-=1){let i=e.segments[r],s=t[r];i.kind==="line"?o.push({kind:"line",end:{...s}}):i.kind==="arc"?o.push({kind:"arc",center:{...i.center},radius:i.radius,clockwise:!i.clockwise,end:{...s}}):o.push({kind:"bezier",control1:{...i.control2},control2:{...i.control1},end:{...s}})}return{version:1,closed:!0,start:{...e.start},segments:o}}function pn(e,t,n){let o=[];for(let r=0;r<e.length-1;r+=1){let i=e[r],s=e[r+1],c=Math.hypot(s.x-i.x,s.y-i.y);if(c<=0)continue;let u=Math.max(1,Math.round(c/n)),b=c/u,a=Math.atan2(s.y-i.y,s.x-i.x),f=r===0,p=(r>0?t[r-1]:void 0)==="break"?2:1,x=f?{...i}:{x:i.x+Math.cos(a)*b*p,y:i.y+Math.sin(a)*b*p},g=f?u+1:Math.max(1,u-(p-1));o.push({origin:x,rotation:a*180/Math.PI,seatCount:g,seatSpacing:b})}return o}function yn(e){let t=e.rotation*Math.PI/180,n={x:Math.cos(t),y:Math.sin(t)};return Array.from({length:e.seatCount},(o,r)=>({x:e.origin.x+n.x*r*e.seatSpacing,y:e.origin.y+n.y*r*e.seatSpacing}))}function bn(e){return e.reduce((t,n)=>t+n.seatCount,0)}function ge(e){let t=new Map,n=new Map;for(let o of e){if(o.type!=="row"||!o.segmentedRow)continue;let r=n.get(o.segmentedRow.groupId)??[];r.push(o),n.set(o.segmentedRow.groupId,r)}for(let[o,r]of n){let i=r.slice().sort((l,p)=>l.segmentedRow.componentIndex-p.segmentedRow.componentIndex),s=i[0]?.segmentedRow?.componentCount??0,c=i[0]?.segmentedRow;if(!c||!(s>=2&&i.length===s&&c?.boundaryBefore==="start"&&i.every((l,p)=>l.segmentedRow?.kind==="segmented-row-v1"&&l.segmentedRow.groupId===o&&l.segmentedRow.componentCount===s&&l.segmentedRow.componentIndex===p&&l.segmentedRow.repeatLabelOnComponents===c.repeatLabelOnComponents&&(p===0?l.segmentedRow.boundaryBefore==="start":l.segmentedRow.boundaryBefore!=="start")&&l.segmentedRow.displayLabel===c.displayLabel)))continue;let b=i.reduce((l,p)=>l+p.seatCount,0),a=0,f=0;for(let l of i)l.segmentedRow.boundaryBefore==="break"&&(a+=1),t.set(l.id,{groupId:o,adjacencyOffset:a,displayOffset:f,displayLabel:c.displayLabel,totalSeats:b,canonical:i[0],viewFromSeatUrl:c.viewFromSeatUrl,viewFromSeatMeta:c.viewFromSeatMeta,confidenceEvidence:c.confidenceEvidence}),a+=l.seatCount,f+=l.seatCount}return t}var Se="ABCDEFGHIJKLMNOPQRSTUVWXYZ",st="ABCDEFGHJKLMNPQRSTUVWXYZ",ct="abcdefghijklmnopqrstuvwxyz";function we(e,t){let n=t.length,o=e+1,r="";for(;o>0;){o-=1;let i=o%n;r=t[i]+r,o=Math.floor(o/n)}return r}function at(e,t){let n=t.startAt-1,o=e+n;if(t.scheme==="numbers")return String(o+1);let r=t.skipAmbiguous?st:Se;return we(o,r)}function Y(e,t=!1){let n=t?ct:Se;return we(Math.max(0,Math.floor(e)-1),n)}var lt=[[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 Pe(e){if(!Number.isFinite(e)||e<=0)return String(e);let t=Math.floor(e),n="";for(let[o,r]of lt)for(;t>=o;)n+=r,t-=o;return n}function gn(e,t){let n=e.length;return e.map((o,r)=>{let i=t.reverse?n-1-r:r;return{...o,label:at(i,t)}})}function ut(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 q(e,t){let n=e.seatLabelStart??1,o=e.seatNumbering?.direction??"ltr",r=e.seatNumbering?.step??1,i=e.seatNumbering?.scheme??"decimal",s=e.seatNumbering?.prefix??"",c=e.seatNumbering?.endAt,u=e.seatCount;if(i==="updown"||i==="updown-descending"){let p=Math.ceil(u/2),x=i==="updown"?t<p?n+2*t:n-1+2*(u-t):t<p?n+2*(p-1-t):n+1+2*(t-p);return`${s}${x}`}let b=i==="odd"||i==="even"?2:r,a=c!=null&&Number.isFinite(c)?c-(u-1)*b:n,f=o==="center"?ut(u)[t]:o==="rtl"?u-1-t:t,l;switch(i){case"odd":{let p=a%2===1?a:a+1;l=String(p+f*2);break}case"even":{let p=a%2===0?a:a+1;l=String(p+f*2);break}case"roman":l=Pe(a+f*r);break;case"letters-upper":l=Y(a+f*r,!1);break;case"letters-lower":l=Y(a+f*r,!0);break;default:l=String(a+f*r);break}return`${s}${l}`}function ft(e){return{...e.canonical,seatCount:e.totalSeats,label:e.displayLabel,displayLabel:e.displayLabel}}function Me(e,t,n){return n?.label??`${e.label}-${q(e,t)}`}function J(e,t,n,o){if(o?.displayLabel)return o.displayLabel;if(!n)return`${e.displayLabel??e.label}-${q(e,t)}`;let r=ft(n),i=n.displayOffset+t;return`${n.displayLabel}-${q(r,i)}`}var X=.02291666666666667,Mn=1/X,dt=58,ht=dt*X,ve=0,Ee=3,Ie=0,Q=120,mt=0,pt=45,yt=7,z=1.2;function Z(e,t,n,o){return Number.isFinite(e)?Math.max(t,Math.min(n,e)):o}function vn(e){return Number.isFinite(e)?Math.max(ve,Math.min(Ee,Math.round(e))):ve}function bt(e){return!Number.isFinite(e)||!Number.isInteger(e)||e<0?0:e<=yt?e:Ee}function Oe(e,t={}){let n=Z(t.floorBaseHeightM,Ie,Q,0),o=Math.min(Q,n+bt(e.elevation)*ht),r=e.height===void 0?o:Z(e.height,Ie,Q,o),i=Z(e.rake,mt,pt,0);return{height:r,rake:i}}function Ce(e){let t=e.length;return t<=3?[...e]:[e[Math.floor(t*.25)],e[Math.floor(t*.5)],e[Math.floor(t*.75)]]}function Re(e,t,n){if(!e.length)return 1/0;if(e.length===1)return Math.hypot(t-e[0].x,n-e[0].y);let o=1/0;for(let r=0;r+1<e.length;r++){let i=e[r],s=e[r+1],c=s.x-i.x,u=s.y-i.y,b=c*c+u*u,a=b>1e-12?((t-i.x)*c+(n-i.y)*u)/b:0;a<0?a=0:a>1&&(a=1);let f=Math.hypot(t-(i.x+a*c),n-(i.y+a*u));f<o&&(o=f)}return o}function xt(e){let t=0,n=0;for(let i of e)t+=i.x,n+=i.y;let o=e.length||1;t/=o,n/=o;let r=0;for(let i of e){let s=Math.hypot(i.x-t,i.y-n);s>r&&(r=s)}return{cx:t,cy:n,r}}function Te(e,t){return Math.hypot(e.cx-t.cx,e.cy-t.cy)-e.r-t.r}function ee(e,t){let n=1/0;for(let o of Ce(e)){let r=Re(t,o.x,o.y);r<n&&(n=r)}for(let o of Ce(t)){let r=Re(e,o.x,o.y);r<n&&(n=r)}return n}function gt(e,t){if(e.length<3)return{pts:e,seatIndices:t};let n=0,o=0;for(let a of e)n+=a.x,o+=a.y;n/=e.length,o/=e.length;let r=-1,i=e[0];for(let a of e){let f=Math.hypot(a.x-n,a.y-o);f>r&&(r=f,i=a)}let s=i.x-n,c=i.y-o,u=Math.hypot(s,c);u>1e-9?(s/=u,c/=u):(s=1,c=0);let b=e.map((a,f)=>({p:a,i:f,t:(a.x-n)*s+(a.y-o)*c})).sort((a,f)=>a.t-f.t);return{pts:b.map(a=>a.p),seatIndices:b.map(a=>t[a.i])}}function St(e){let t=e.length;if(t<3)return null;let n=0,o=0;for(let S of e)n+=S.x,o+=S.y;n/=t,o/=t;let r=0,i=0,s=0,c=0,u=0,b=0,a=0;for(let S of e){let y=S.x-n,d=S.y-o;r+=y*y,s+=d*d,i+=y*d,c+=y*y*y,u+=d*d*d,b+=y*d*d,a+=d*y*y}let f=r*s-i*i;if(Math.abs(f)<1e-9)return null;let l=(c+b)/2,p=(u+a)/2,x=(l*s-p*i)/f,g=(p*r-l*i)/f,h=x+n,m=g+o;return!Number.isFinite(h)||!Number.isFinite(m)?null:{cx:h,cy:m}}var wt=.15;function Pt(e){if(e.length<2)return null;let t=e.map(S=>{let y=0,d=0;for(let P of S.pts)y+=P.x,d+=P.y;return{x:y/S.pts.length,y:d/S.pts.length}}),n=0,o=0;for(let S of t)n+=S.x,o+=S.y;n/=t.length,o/=t.length;let r=0,i=0,s=0;for(let S of t){let y=S.x-n,d=S.y-o;r+=y*y,i+=y*d,s+=d*d}let c=r+s,u=r*s-i*i,b=c/2+Math.sqrt(Math.max(0,c*c/4-u)),a,f;Math.abs(i)>1e-12?(a=b-s,f=i):r>=s?(a=1,f=0):(a=0,f=1);let l=Math.hypot(a,f);if(!(l>1e-12))return null;a/=l,f/=l;let p=1/0,x=-1/0,g=[];for(let S of e){let y=1/0,d=-1/0;for(let P of S.pts){let w=P.x*a+P.y*f;w<y&&(y=w),w>d&&(d=w),w<p&&(p=w),w>x&&(x=w)}g.push(d-y)}let h=x-p;return h>1e-9?(g.sort((S,y)=>S-y),g[Math.min(g.length-1,Math.floor(g.length*.9))]/h<=Mt?{x:a,y:f}:null):null}var Mt=.35;function Ae(e,t,n,o){let r=new Map;for(let h of n){let m=t[h],S=m.rowId||`__seat-${h}`,y=r.get(S);y||(y={pts:[],idx:[]},r.set(S,y)),y.pts.push({x:m.x,y:m.y}),y.idx.push(h)}if(!r.size)return{sectionId:e,rows:[],blockCount:0};let i=[];for(let[h,m]of r){let S=gt(m.pts,m.idx),y=0;for(let d of S.pts)y+=Math.hypot(d.x-o.x,d.y-o.y);i.push({id:h,pts:S.pts,seatIndices:S.seatIndices,blockId:-1,ordinal:0,blockDepth:0,focalDistance:y/S.pts.length})}let s=i.map(h=>xt(h.pts)),c=[];for(let h=0;h<i.length;h++){let m=1/0;for(let S=0;S<i.length;S++){if(h===S||Te(s[h],s[S])>=m)continue;let y=ee(i[h].pts,i[S].pts);y<m&&(m=y)}Number.isFinite(m)&&c.push(m)}c.sort((h,m)=>h-m);let u=c.length?c[Math.floor(c.length/2)]:1,b=Math.max(u*1.8,1e-6),a=i.map(()=>[]);for(let h=0;h<i.length;h++)for(let m=h+1;m<i.length;m++)Te(s[h],s[m])>b||ee(i[h].pts,i[m].pts)<=b&&(a[h].push(m),a[m].push(h));let f=0;for(let h=0;h<i.length;h++){if(i[h].blockId!==-1)continue;let m=f++,S=[h];for(i[h].blockId=m;S.length;){let y=S.pop();for(let d of a[y])i[d].blockId===-1&&(i[d].blockId=m,S.push(d))}}let l=new Map;for(let h of i){let m=l.get(h.blockId)??[];m.push(h),l.set(h.blockId,m)}let p=[];for(let h of i){if(h.pts.length<4)continue;let m=St(h.pts);m&&(!Number.isFinite(m.cx)||!Number.isFinite(m.cy)||p.push({x:m.cx,y:m.cy}))}let x=p.length>=2?(()=>{let h=p.map(y=>y.x).sort((y,d)=>y-d),m=p.map(y=>y.y).sort((y,d)=>y-d),S=Math.floor(p.length/2);return{cx:h[S],cy:m[S]}})():null;if(x){let h=w=>Math.hypot(w.x-x.cx,w.y-x.cy),m=1/0,S=-1/0,y=[];for(let w of i){let M=1/0,E=-1/0;for(let A of w.pts){let O=h(A);O<M&&(M=O),O>E&&(E=O)}y.push(E-M),M<m&&(m=M),E>S&&(S=E)}let d=S-m;y.sort((w,M)=>w-M);let P=y[Math.min(y.length-1,Math.floor(y.length*.9))];if(d>1e-9&&P/d<=wt){let w=i.map(I=>{let B=0;for(let Be of I.pts)B+=h(Be);return{row:I,radius:B/I.pts.length}}),M=w[0],E=w[0];for(let I of w)I.radius<M.radius&&(M=I),I.radius>E.radius&&(E=I);if(M.row.focalDistance>E.row.focalDistance)for(let I of w)I.radius=-I.radius;let O=1/0;for(let I of w)I.radius<O&&(O=I.radius);w.sort((I,B)=>I.radius-B.radius);let _=-1,F=-1/0,H=d/Math.max(1,w.length)*.5,U=[];for(let I of w)I.radius-F>H&&(_++,F=I.radius),I.row.ordinal=_,I.row.blockDepth=I.radius-O,U.push(I.row);return{sectionId:e,rows:U,blockCount:f}}}let g=[];for(let[,h]of l){let m=Pt(h);if(m){let S=d=>{let P=0;for(let w of d.pts)P+=w.x*m.x+w.y*m.y;return P/d.pts.length};h.sort((d,P)=>S(d)-S(P)),h.length>=2&&h[0].focalDistance>h[h.length-1].focalDistance&&h.reverse();let y=0;for(let d=0;d<h.length;d++)d>0&&(y+=ee(h[d-1].pts,h[d].pts)),h[d].ordinal=d,h[d].blockDepth=y,g.push(h[d])}else{let S=1/0;for(let y of h)y.focalDistance<S&&(S=y.focalDistance);h.sort((y,d)=>y.focalDistance-d.focalDistance);for(let y=0;y<h.length;y++)h[y].ordinal=y,h[y].blockDepth=Math.max(0,h[y].focalDistance-S),g.push(h[y])}}return{sectionId:e,rows:g,blockCount:f}}function Ne(e){return e?e.accessibility&&e.accessibility.length?e.wheelchairSpaceType&&!e.accessibility.includes("wheelchair")?["wheelchair",...e.accessibility]:e.accessibility:e.wheelchairSpaceType?["wheelchair"]:e.accessible?["wheelchair"]:[]:[]}var $=Math.PI/180,vt=9,N=16;function ne(e,t,n,o){let r=n*$,i=Math.cos(r),s=Math.sin(r);return{x:o.x+e*i-t*s,y:o.y+e*s+t*i}}function De(e){let{seatCount:t,seatSpacing:n,curve:o,rotation:r,origin:i}=e,s=[];if(e.path)return ae(e.path,t);if(t<=1)return t===1&&s.push({x:i.x,y:i.y}),s;if(o===0){for(let b=0;b<t;b++)s.push(ne(b*n,0,r,i));return s}let c=o/(t-1)*$,u=n/(2*Math.sin(Math.abs(c)/2));for(let b=0;b<t;b++){let a=b*c,f=u*Math.sin(a),l=-u+u*Math.cos(a);s.push(ne(f,l,r,i))}return s}function It(e){let t=new Map;if(e.overrides)for(let n of e.overrides)t.set(n.index,n);return t}function jn(e){let t=new Set((e.overrides??[]).filter(n=>n.skip&&Number.isInteger(n.index)&&n.index>=0&&n.index<e.seatCount).map(n=>n.index));return Math.max(0,e.seatCount-t.size)}function Et(e,t){let n=It(e);return De(e).map((o,r)=>{let i=n.get(r),s=Ne(i),c=Me(e,r,i),u={...e.commercial,...i?.commercial};return{index:r,x:o.x+(i?.dx??0),y:o.y+(i?.dy??0),label:c,displayLabel:J(e,r,t,i),categoryKey:i?.categoryKey??e.categoryKey,skipped:!!i?.skip,accessible:s.length>0,accessibility:s,wheelchairSpaceType:i?.wheelchairSpaceType,commercial:Object.values(u).some(b=>b!==void 0&&b!==!1&&b!=="")?u:void 0,viewUrl:i?.viewFromSeatUrl??e.viewFromSeatUrl,viewMeta:i?.viewFromSeatUrl?i.viewFromSeatMeta:e.viewFromSeatMeta,labelStyle:i?.labelStyle}})}function Fe(e){let t=[];for(let n of Et(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,viewUrl:n.viewUrl,viewMeta:n.viewMeta,labelStyle:n.labelStyle});return t}function Ot(e){if(e.seatCountsBySide)return{...e.seatCountsBySide};let t=e.sides&&e.sides.length?e.sides:["top","bottom"],n=["top","bottom","left","right"].filter(i=>t.includes(i)),o={top:0,bottom:0,left:0,right:0};if(!n.length)return o;let r=Math.max(0,Math.round(e.seatCount));for(let i=0;i<r;i++)o[n[i%n.length]]+=1;return o}function He(e){let t=[],n=Math.max(0,Math.round(e.seatCount));if(n===0)return t;let o=new Map((e.overrides??[]).map(a=>[a.index,a])),r=(a,f,l,p)=>{let x=o.get(a),g=Ne(x),h=x?.label??`${e.label}-${a+1}`,m=e.displayLabel??e.label;return{index:a,label:h,displayLabel:x?.displayLabel??`${m}-${a+1}`,x:f+(x?.dx??0),y:l+(x?.dy??0),categoryKey:x?.categoryKey??e.categoryKey,skipped:!!x?.skip,accessible:g.length>0,accessibility:g,wheelchairSpaceType:x?.wheelchairSpaceType,commercial:x?.commercial,viewUrl:x?.viewFromSeatUrl,viewMeta:x?.viewFromSeatUrl?x.viewFromSeatMeta:void 0,labelStyle:x?.labelStyle,...p?{side:p}:{}}};if(e.shape==="round"){let a=(e.radius??40)+N,f=e.rotation*$,l=Math.max(0,Math.min(360,e.seatArc??360));if(l>=360||n===1){for(let h=0;h<n;h++){let m=f+h/n*2*Math.PI;t.push(r(h,e.center.x+a*Math.cos(m),e.center.y+a*Math.sin(m)))}return t}let p=l*$,x=(2*Math.PI-p)/2,g=f+x;for(let h=0;h<n;h++){let m=g+h/(n-1)*p;t.push(r(h,e.center.x+a*Math.cos(m),e.center.y+a*Math.sin(m)))}return t}let i=e.width??80,s=e.height??50,c=Ot(e),u=["top","bottom","left","right"],b=0;for(let a of u){let f=c[a];for(let l=0;l<f;l++){let p,x;a==="top"?(p=-i/2+(l+.5)*i/f,x=-s/2-N):a==="bottom"?(p=-i/2+(l+.5)*i/f,x=s/2+N):a==="left"?(p=-i/2-N,x=-s/2+(l+.5)*s/f):(p=i/2+N,x=-s/2+(l+.5)*s/f);let g=ne(p,x,e.rotation,e.center);t.push(r(b++,g.x,g.y,a))}}return t}function Nn(e){return e.bookAsWhole||e.variableOccupancy?Math.max(0,Math.round(e.seatCount)):He(e).filter(t=>!t.skipped).length}function Ct(e){return He(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.viewUrl?{viewUrl:t.viewUrl}:{},...t.viewUrl&&t.viewMeta?{viewMeta:t.viewMeta}:{},...t.labelStyle?{labelStyle:t.labelStyle}:{}}))}function Rt(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 _e(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[o].x,s=t[o].y,c=t[r].x,u=t[r].y;s>e.y!=u>e.y&&e.x<(c-i)*(e.y-s)/(u-s)+i&&(n=!n)}return n}function Tt(e,t){return t.some((n,o)=>{let r=t[(o+1)%t.length],i=(e.y-n.y)*(r.x-n.x)-(e.x-n.x)*(r.y-n.y);if(Math.abs(i)>1e-7)return!1;let s=(e.x-n.x)*(r.x-n.x)+(e.y-n.y)*(r.y-n.y),c=(r.x-n.x)**2+(r.y-n.y)**2;return s>=-1e-7&&s<=c+1e-7})}function oe(e,t,n){return _e(e,t)&&!(n??[]).some(o=>_e(e,o)||Tt(e,o))}function Dn(e,t){return he(e,t).point}function te(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 At(e){switch(e.type){case"row":{let t=Fe(e);if(!t.length)return{x:e.origin.x,y:e.origin.y};let n=0,o=0;for(let r of t)n+=r.x,o+=r.y;return{x:n/t.length,y:o/t.length}}case"table":case"booth":return{x:e.center.x,y:e.center.y};case"gaArea":return te(e.points);case"section":return te(e.outline);case"text":return{x:e.position.x,y:e.position.y};case"shape":return e.points&&e.points.length?te(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 ke(e,t){return e.length===t.length&&e.every((n,o)=>n.x===t[o].x&&n.y===t[o].y)}function _t(e,t){if(e.type!=="gaArea"||!ke(e.points,t.outline))return!1;let n=e.holes??[],o=t.holes??[];return n.length===o.length&&n.every((r,i)=>ke(r,o[i]))}function kt(e,t){let n=e.filter(s=>s.type==="section"),o="referenceInventorySource"in t?t.referenceInventorySource?.logicalSectionId:void 0,r=At(t);return(o?n.find(s=>(s.logicalSectionId??s.id)===o&&(_t(t,s)||oe(r,s.outline,s.holes))):void 0)??n.find(s=>oe(r,s.outline,s.holes))}function Lt(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 Fn(e,t){let n=Lt(e);return(t?n.find(o=>o.id===t):n[0])?.objects??[]}function jt(e){return e.floors&&e.floors.length?e.floors.flatMap(t=>t.objects):e.objects}function Ue(e,t,n){let o=i=>({x:i.x+t,y:i.y+n}),r=i=>i.map(o);switch(e.type){case"row":return{...e,origin:o(e.origin)};case"table":case"booth":return{...e,center:o(e.center)};case"gaArea":return{...e,points:r(e.points),...e.holes?{holes:e.holes.map(r)}:{}};case"section":return{...e,outline:r(e.outline),...e.outlinePath?{outlinePath:xe(e.outlinePath,t,n)}:{},...e.holes?{holes:e.holes.map(r)}:{}};case"text":return{...e,position:o(e.position)};case"shape":return{...e,...e.points?{points:r(e.points)}:{},...e.x!=null?{x:e.x+t}:{},...e.y!=null?{y:e.y+n}:{}};case"decorImage":return{...e,x:e.x+t,y:e.y+n}}}function Hn(e,t=900){if(!e.floors||e.floors.length<2)return e;let n=[];return e.floors.forEach((o,r)=>{let i=-r*t;for(let s of o.objects)n.push(i===0?s:Ue(s,0,i))}),{...e,objects:n,floors:void 0}}function Un(e){let t=e.floors;if(!t||t.length<2)return e;let n=Nt(e),o=[];return t.forEach((r,i)=>{let{x:s,y:c}=n[i];for(let u of r.objects)o.push(Ue(u,s,c))}),{...e,objects:o,floors:void 0,referenceImage:void 0,backgroundImage:void 0}}function Nt(e){let t=e.floors;if(!t?.length)return[{x:0,y:0}];if(t.length<2)return t.map(()=>({x:0,y:0}));let n=t.map(l=>Dt({...e,objects:l.objects,floors:void 0,focalPoint:l.focalPoint,referenceImage:void 0,backgroundImage:void 0})),o=Math.max(1,...n.map(l=>Math.max(l.width,l.height))),r=Math.max(64,Math.min(240,o*.08)),i=16/10,s=null;for(let l=1;l<=t.length;l+=1){let p=Math.ceil(t.length/l),x=new Array(l).fill(0),g=new Array(p).fill(0);n.forEach((d,P)=>{let w=P%l,M=Math.floor(P/l);x[w]=Math.max(x[w],d.width),g[M]=Math.max(g[M],d.height)});let h=x.reduce((d,P)=>d+P,0)+r*(l-1),m=g.reduce((d,P)=>d+P,0)+r*(p-1),S=l*p-t.length,y=Math.abs(Math.log(h/Math.max(1,m)/i))+S*.04;(!s||y<s.score)&&(s={columns:l,columnWidths:x,rowHeights:g,score:y})}let{columns:c,columnWidths:u,rowHeights:b}=s,a=[],f=[];return u.reduce((l,p,x)=>(a[x]=l,l+p+r),0),b.reduce((l,p,x)=>(f[x]=l,l+p+r),0),t.map((l,p)=>{let x=n[p],g=p%c,h=Math.floor(p/c),m=a[g]+(u[g]-x.width)/2,S=f[h]+(b[h]-x.height)/2;return{x:m-x.x,y:S-x.y}})}function Le(e,t,n,o,r,i){let s=[],c=ge(e),u=f=>!f?.eventConfigurationId||f.eventConfigurationId===o,b=f=>!!f&&(!f.eventConfigurationId||f.eventConfigurationId===o),a=(f,l)=>b(f)?{...f,coverage:l}:void 0;for(let f of e){let l=[];if(f.type==="row"?l=Fe(f):f.type==="table"?l=Ct(f):f.type==="booth"&&(l=Rt(f)),!l.length)continue;for(let m of l)m.viewUrl&&!u(m.viewMeta)&&(m.viewUrl=void 0,m.viewMeta=void 0);if(f.type==="row"){let m=c.get(f.id);if(m){let S=new Map((f.overrides??[]).map(y=>[y.index,y]));for(let y of l){let d=Number(y.id.slice(y.id.lastIndexOf(":")+1));if(!Number.isInteger(d))continue;y.logicalRowId=m.groupId,y.logicalSeatIndex=m.adjacencyOffset+d,S.get(d)?.displayLabel||(y.displayLabel=J(f,d,m)),!y.viewUrl&&m.viewFromSeatUrl&&u(m.viewFromSeatMeta)&&(y.viewUrl=m.viewFromSeatUrl,y.viewMeta=m.viewFromSeatMeta);let P=S.get(d)?.confidenceEvidence;y.confidenceEvidence=a(P,"exact-seat")??a(f.confidenceEvidence,"row-representative")??a(m.confidenceEvidence,"row-representative")}}}let p=kt(e,f),x=p?.viewFromSeatUrl,h=(p?.zone?t?.find(m=>m.id===p.zone):void 0)?.focalPoint??n;for(let m of l){if(!m.confidenceEvidence){let S=Number(m.id.slice(m.id.lastIndexOf(":")+1)),y=(f.type==="row"||f.type==="table")&&Number.isInteger(S)?f.overrides?.find(d=>d.index===S)?.confidenceEvidence:void 0;m.confidenceEvidence=a(y,"exact-seat")??(f.type==="row"?a(f.confidenceEvidence,"row-representative"):void 0)}m.confidenceEvidence??=a(p?.confidenceEvidence,"section-representative")??(i?a(i.evidence,i.coverage):void 0),!m.viewUrl&&x&&u(p?.viewFromSeatMeta)&&(m.viewUrl=x,m.viewMeta=p?.viewFromSeatMeta),!m.viewUrl&&r&&u(r.meta)&&(m.viewUrl=r.url,m.viewMeta=r.meta),p&&(m.sectionId=p.logicalSectionId??p.id),p?.zone&&(m.zoneId=p.zone),h&&(m.focalPoint={...h})}s.push(...l)}return s}function Bn(e,t={}){if(e.floors?.length){let o=[];for(let r of e.floors){let i=r.focalPoint??e.focalPoint,s=r.viewFromSeatUrl?{url:r.viewFromSeatUrl,meta:r.viewFromSeatMeta}:e.viewFromSeatUrl?{url:e.viewFromSeatUrl,meta:e.viewFromSeatMeta}:void 0,c=r.confidenceEvidence?{evidence:r.confidenceEvidence,coverage:"floor-representative"}:e.confidenceEvidence?{evidence:e.confidenceEvidence,coverage:"venue-representative"}:void 0,u=Le(r.objects,e.zones,i,e.eventConfigurationId,s,c);t.resolveEyeHeights!==!1&&je(r.objects,r.focalPoint??e.focalPoint,r.baseHeightM??0,u),o.push(...u)}return o}let n=Le(e.objects,e.zones,e.focalPoint,e.eventConfigurationId,e.viewFromSeatUrl?{url:e.viewFromSeatUrl,meta:e.viewFromSeatMeta}:void 0,e.confidenceEvidence?{evidence:e.confidenceEvidence,coverage:"venue-representative"}:void 0);return t.resolveEyeHeights!==!1&&je(e.objects,e.focalPoint,t.floorBaseHeightM??0,n),n}function je(e,t,n,o){let r=e.filter(a=>a.type==="section"),i=n>0||r.some(a=>a.height!==void 0||a.rake!==void 0||(a.elevation??0)>0);if(!r.length||!i||!t){for(let a of o)a.eyeHeightM=n+z;return}let s=new Array(o.length),c=new Map,u=new Map;for(let a=0;a<o.length;a++){let f=o[a],l=r.find(x=>oe({x:f.x,y:f.y},x.outline,x.holes))??null;if(s[a]=l,!l)continue;c.has(l.id)||c.set(l.id,Oe(l,{floorBaseHeightM:n}));let p=u.get(l.id);p?p.push(a):u.set(l.id,[a])}let b=new Array(o.length).fill(void 0);for(let[a,f]of u){let l=c.get(a);if(!l)continue;let p=l.rake>0?Math.tan(l.rake*Math.PI/180):0,x=Ae(a,o,f,t);for(let g of x.rows){let h=g.blockDepth*X*p,m=l.height+h;for(let S of g.seatIndices)b[S]=m}}for(let a=0;a<o.length;a++){let f=o[a],l=s[a];if(!l){f.eyeHeightM=n+z;continue}let p=c.get(l.id);f.eyeHeightM=(b[a]??p.height)+z}}var K=40;function Dt(e){let t=1/0,n=1/0,o=-1/0,r=-1/0,i=(s,c)=>{s<t&&(t=s),c<n&&(n=c),s>o&&(o=s),c>r&&(r=c)};for(let s of jt(e))if(s.type==="row"){let c=new Map((s.overrides??[]).map(u=>[u.index,u]));De(s).forEach((u,b)=>{let a=c.get(b);a?.skip||i(u.x+(a?.dx??0),u.y+(a?.dy??0))})}else if(s.type==="gaArea")for(let c of s.points)i(c.x,c.y);else if(s.type==="section")for(let c of s.outline)i(c.x,c.y);else if(s.type==="decorImage")i(s.x,s.y),i(s.x+s.width,s.y+s.height);else if(s.type==="shape")if(s.points&&s.points.length)for(let c of s.points)i(c.x,c.y);else s.x!=null&&s.y!=null&&s.width!=null&&s.height!=null&&(i(s.x,s.y),i(s.x+s.width,s.y+s.height));else if(s.type==="table"){let c=N+vt,u=s.shape==="round"?(s.radius??40)+c:Math.max((s.width??80)/2,(s.height??50)/2)+c;i(s.center.x-u,s.center.y-u),i(s.center.x+u,s.center.y+u)}else if(s.type==="booth"){let c=Math.max(s.width,s.height)/2;i(s.center.x-c,s.center.y-c),i(s.center.x+c,s.center.y+c)}else if(s.type==="text"){let c=ie(s);i(s.position.x,s.position.y),i(s.position.x+c.width,s.position.y+c.height)}for(let s of[e.referenceImage,e.backgroundImage]){if(!s)continue;let{center:c,width:u}=s,b=u*3/4;i(c.x-u/2,c.y-b/2),i(c.x+u/2,c.y+b/2)}if(!isFinite(t)){let s=e.focalPoint??{x:0,y:0};return{x:s.x-200,y:s.y-200,width:400,height:400}}return{x:t-K,y:n-K,width:o-t+K*2,height:r-n+K*2}}export{Ft as a,Ht as b,Ut as c,Bt as d,Gt as e,Xt as f,zt as g,Kt as h,$t as i,ie as j,Vt as k,Ke as l,Yt as m,W as n,Qt as o,ae as p,Zt as q,en as r,We as s,de as t,nn as u,he as v,Ye as w,rn as x,ln as y,be as z,un as A,xe as B,Ze as C,fn as D,dn as E,nt as F,it as G,hn as H,pn as I,yn as J,bn as K,ge as L,we as M,at as N,Y as O,Pe as P,gn as Q,q as R,ft as S,Me as T,J as U,X as V,Mn as W,ht as X,ve as Y,Ee as Z,Ie as _,Q as $,mt as aa,pt as ba,yt as ca,z as da,vn as ea,Oe as fa,Re as ga,St as ha,Ae as ia,De as ja,jn as ka,Et as la,Fe as ma,Ot as na,He as oa,Nn as pa,Ct as qa,Rt as ra,_e as sa,oe as ta,Dn as ua,At as va,kt as wa,Lt as xa,Fn as ya,jt as za,Ue as Aa,Hn as Ba,Un as Ca,Nt as Da,Bn as Ea,Dt as Fa};
@@ -1 +1 @@
1
- import{ha as Y}from"./chunk-VDZ24QVV.js";function nn(c){return{kind:"radial",rowCount:0,rows:[],nearestRow:()=>-1,depthAt:(l,a)=>Math.hypot(l-c.x,a-c.y),gradientAt:(l,a)=>{let e=l-c.x,f=a-c.y,i=Math.hypot(e,f);return i<1e-9?[0,0]:[e/i,f/i]}}}function tn(c,l){if(!c.length)return null;let a=0,e=0,f=0;for(let n of c)a+=n.x,e+=n.y,f+=Math.hypot(n.x-l.x,n.y-l.y);let i=c.length;a/=i,e/=i,f/=i;let u=c[0],R=-1;for(let n of c){let o=Math.hypot(n.x-a,n.y-e);o>R&&(R=o,u=n)}let b=u.x-a,m=u.y-e,d=Math.hypot(b,m);d>1e-9?(b/=d,m/=d):(b=1,m=0);let y=[...c].sort((n,o)=>(n.x-a)*b+(n.y-e)*m-((o.x-a)*b+(o.y-e)*m)),t=0;for(let n of y){let o=Math.hypot(n.x-a,n.y-e);o>t&&(t=o)}return{pts:y,cx:a,cy:e,radius:t,depth:f}}function Z(c,l,a){let e=c.pts;if(e.length===1)return Math.hypot(l-e[0].x,a-e[0].y);let f=1/0;for(let i=0;i+1<e.length;i++){let u=e[i],R=e[i+1],b=R.x-u.x,m=R.y-u.y,d=b*b+m*m,y=d>1e-12?((l-u.x)*b+(a-u.y)*m)/d:0;y<0?y=0:y>1&&(y=1);let t=Math.hypot(l-(u.x+y*b),a-(u.y+y*m));t<f&&(f=t)}return f}var U=8;function en(c,l,a){let e=new Array(U).fill(1/0),f=new Array(U).fill(-1);for(let d=0;d<c.length;d++){let y=c[d],t=Math.hypot(l-y.cx,a-y.cy)-y.radius;for(let n=0;n<U;n++)if(t<e[n]){for(let o=U-1;o>n;o--)e[o]=e[o-1],f[o]=f[o-1];e[n]=t,f[n]=d;break}}let i=new Array(3).fill(1/0),u=new Array(3).fill(-1);for(let d of f){if(d<0)continue;let y=Z(c[d],l,a);for(let t=0;t<3;t++)if(y<i[t]){for(let n=2;n>t;n--)i[n]=i[n-1],u[n]=u[n-1];i[t]=y,u[t]=d;break}}if(u[0]<0)return 0;if(i[0]<1e-6)return c[u[0]].depth;let R=i[0]*2.2,b=0,m=0;for(let d=0;d<3;d++){let y=u[d];if(y<0||i[d]>R)continue;let t=1/(i[d]*i[d]);b+=t*c[y].depth,m+=t}return m>0?b/m:c[u[0]].depth}function on(c){let l=(e,f)=>en(c,e,f),a=(e,f)=>{let i=1/0,u=-1;for(let R=0;R<c.length;R++){let b=c[R];if(Math.hypot(e-b.cx,f-b.cy)-b.radius>=i)continue;let m=Z(b,e,f);m<i&&(i=m,u=R)}return u};return{kind:"rows",rowCount:c.length,rows:c,nearestRow:a,depthAt:l,gradientAt:(e,f)=>{let i=(l(e+.5,f)-l(e-.5,f))/1,u=(l(e,f+.5)-l(e,f-.5))/(2*.5),R=Math.hypot(i,u);return R<1e-9?[0,0]:[i/R,u/R]}}}function bn(c,l){let a=[];for(let e of c){let f=tn(e.points,l);f&&a.push(f)}return a.length<2?nn(l):(a.sort((e,f)=>e.depth-f.depth),on(a))}var rn=Math.PI/180,h=96,sn=6,ln=60,cn=150,$=.2,an=.35;function fn(c,l){let a=Math.atan2(l.x-c.x,l.y-c.y)/rn;return a<0?a+360:a}function z(c){if(!c.length)return NaN;let l=[...c].sort((a,e)=>a-e);return l[Math.floor(l.length/2)]}function J(c,l,a=2){let e=c.length,f=new Float64Array(e);for(let i=0;i<e;i++){let u=0,R=0;for(let b=-a;b<=a;b++){let m=i+b;if(l)m=(m%e+e)%e;else if(m<0||m>=e)continue;u+=c[m],R++}f[i]=u/R}return f}function hn(c,l){let a=c.filter(t=>t.rows.length>=1);if(a.length<1)return null;let e=[],f=0,i=0,u=0;for(let t of a)for(let n of t.rows){for(let o of n.pts)f+=o.x,i+=o.y,u++;if(n.pts.length>=4){let o=Y(n.pts);o&&Number.isFinite(o.cx)&&Number.isFinite(o.cy)&&e.push({x:o.cx,y:o.cy})}}if(!u)return null;let R={x:f/u,y:i/u},b=R;if(e.length>=8){let t=z(e.map(D=>D.x)),n=z(e.map(D=>D.y)),o=0;for(let D of a)for(let j of D.rows)for(let F of j.pts){let W=Math.hypot(F.x-R.x,F.y-R.y);W>o&&(o=W)}let B=0,S=o*.2;for(let D of a)for(let j of D.rows)for(let F of j.pts)Math.hypot(F.x-t,F.y-n)<S&&B++;Math.hypot(t-R.x,n-R.y)<=o&&B/u<.01&&(b={x:t,y:n})}let m=[];for(let t of a){let n={sectionId:t.sectionId,rMin:1/0,rMax:-1/0,samples:[]};for(let o of t.rows)for(let B of o.pts){let S=Math.hypot(B.x-b.x,B.y-b.y),D=Math.min(h-1,Math.floor(fn(b,B)/(360/h)));n.samples.push({r:S,bin:D,levelM:o.levelM}),S<n.rMin&&(n.rMin=S),S>n.rMax&&(n.rMax=S)}n.samples.length&&m.push(n)}if(!m.length)return null;m.sort((t,n)=>t.rMin+t.rMax-(n.rMin+n.rMax));let d=[];for(let t of m){let n=!1;for(let o of d){let B=Math.min(t.rMax,o.rMax)-Math.max(t.rMin,o.rMin),S=Math.min(t.rMax-t.rMin,o.rMax-o.rMin);if(S>1e-9&&B>=an*S){o.members.push(t),o.rMin=Math.min(o.rMin,t.rMin),o.rMax=Math.max(o.rMax,t.rMax),n=!0;break}}n||d.push({members:[t],rMin:t.rMin,rMax:t.rMax})}let y=[];for(let t of d){let n=new Array(h).fill(null);for(let r of t.members)for(let p of r.samples){let x=n[p.bin];x||(x={samples:[]},n[p.bin]=x),x.samples.push({r:p.r,levelM:p.levelM})}let o=n.map(r=>!!r);if(!o.filter(Boolean).length)continue;let S=[],D=[];for(let r of n){if(!r)continue;let p=1/0,x=-1/0;for(let A of r.samples)A.r<p&&(p=A.r),A.r>x&&(x=A.r);S.push(p),D.push(x)}let j=z(S),F=z(D);if(!(j>=$*F)||!(F>0))continue;let W=[...S].sort((r,p)=>r-p);if(!(W[Math.floor(W.length*.1)]>=$*F))continue;let V=n.map(r=>{if(!r)return null;let p=[...r.samples].sort((w,k)=>w.r-k.r),x=p[0].r,A=p[p.length-1].r,P=p[0].levelM,N=-1/0;for(let w of p)w.levelM>N&&(N=w.levelM);let M=[];for(let w of p){let k={r:w.r,l:w.levelM};for(;M.length&&Math.abs(M[M.length-1].r-k.r)<1e-9;){if(M[M.length-1].l<=k.l){k.skip=!0;break}M.pop()}if(!k.skip){for(;M.length>=2;){let L=M[M.length-2],v=M[M.length-1];if((v.r-L.r)*(k.l-L.l)-(v.l-L.l)*(k.r-L.r)<=0)M.pop();else break}M.push(k)}}let C=M.map(w=>w.r),_=M.map(w=>w.l);return{inner:x,outer:A,front:P,top:N,profile:{rs:C,ls:_}}}),O=o.slice();for(let r=0;r<h;r++){if(O[r])continue;let p=-1,x=-1,A=0;for(let s=1;s<=h;s++){let g=(r-s+h*2)%h;if(O[g]){p=g;break}}for(let s=1;s<=h;s++){let g=(r+s)%h;if(O[g]){x=g,A=s;break}}if(p<0||x<0)continue;let P=0;for(let s=1;s<=h;s++){let g=(r-s+h*2)%h;if(o[g]){P=s;break}}if(P-1+A>sn)continue;let M=V[p],C=V[x],_=P/(P+A),w=M.inner+(C.inner-M.inner)*_,k=M.outer+(C.outer-M.outer)*_,L=M.front+(C.front-M.front)*_,v=M.top+(C.top-M.top)*_;V[r]={inner:w,outer:k,front:L,top:v,profile:{rs:[w,k],ls:[L,v]}}}for(let r=0;r<h;r++)V[r]&&(O[r]=!0);let X=360/h,K=[],q=O.filter(Boolean).length,Q=[];if(q===h)Q.push({start:0,len:h});else{let r=0;for(;O[r];)r=(r+1)%h;let p=-1;for(let x=0;x<=h;x++){let A=(r+x)%h,P=x<h&&O[A];if(P&&p<0)p=A;else if(!P&&p>=0){let N=(A-p+h)%h||h;Q.push({start:p,len:N}),p=-1}}}for(let r of Q){if(r.len*X<ln&&r.len<h)continue;let p=r.len===h,x=new Float64Array(r.len),A=new Float64Array(r.len),P=new Float64Array(r.len),N=new Float64Array(r.len),M=[];for(let s=0;s<r.len;s++){let g=V[(r.start+s)%h];x[s]=g.inner,A[s]=g.outer,P[s]=g.front,N[s]=g.top,M.push(g.profile??{rs:[g.inner,g.outer],ls:[g.front,g.top]})}let C=J(x,p),_=J(A,p),w=J(P,p),k=J(N,p);for(let s=0;s<r.len;s++)C[s]>x[s]&&(C[s]=x[s]),_[s]<A[s]&&(_[s]=A[s]),C[s]>_[s]-1e-6&&(C[s]=Math.max(0,_[s]-1e-6)),k[s]<w[s]&&(k[s]=w[s]);let L={startBin:r.start,binCount:r.len,closed:p,innerR:C,outerR:_,frontLevelM:w,topLevelM:k,profiles:M},v=(s,g,I)=>{let H=M[s],T=H.rs,E=H.ls;if(g<=T[0]){E[0]>I&&(E[0]=I);return}if(g>=T[T.length-1]){E[E.length-1]>I&&(E[E.length-1]=I);return}for(let G=0;G+1<T.length;G++)if(g<=T[G+1]){E[G]>I&&(E[G]=I),E[G+1]>I&&(E[G+1]=I);return}};for(let s=0;s<r.len;s++){let g=n[(r.start+s)%h];if(g)for(let I of g.samples){v(s,I.r,I.levelM);let H=p?(s-1+r.len)%r.len:s-1,T=p?(s+1)%r.len:s+1;H>=0&&v(H,I.r,I.levelM),T<r.len&&v(T,I.r,I.levelM)}}K.push(L)}K.reduce((r,p)=>r+p.binCount*X,0)<cn||y.push({arcs:K,sectionIds:t.members.map(r=>r.sectionId),innerRMedian:j,outerRMedian:F})}if(!y.length)return null;if(y.sort((t,n)=>t.innerRMedian-n.innerRMedian),l){let t=y[y.length-1].outerRMedian;if(Math.hypot(l.x-b.x,l.y-b.y)>.9*t)return null}return{centre:b,binCount:h,binStepDeg:360/h,rings:y}}function dn(c,l,a,e){let f=c.binStepDeg,i=a/f-.5-l.startBin;i=(i%c.binCount+c.binCount)%c.binCount,i>l.binCount-1&&(l.closed?i=i-l.binCount<l.binCount-i?0:l.binCount-1:i=i-(l.binCount-1)<c.binCount-i?l.binCount-1:0);let u=Math.floor(i),R=l.closed?(u+1)%l.binCount:Math.min(l.binCount-1,u+1),b=i-u,m=d=>{let y=l.profiles[d],t=y.rs,n=y.ls;if(e<=t[0])return n[0];if(e>=t[t.length-1])return n[n.length-1];for(let o=0;o+1<t.length;o++)if(e<=t[o+1]){let B=t[o+1]-t[o],S=B>1e-9?(e-t[o])/B:0;return n[o]+(n[o+1]-n[o])*S}return n[n.length-1]};return m(u)*(1-b)+m(R)*b}export{bn as a,fn as b,hn as c,dn as d};
1
+ import{ha as Y}from"./chunk-GHJUDU3U.js";function nn(c){return{kind:"radial",rowCount:0,rows:[],nearestRow:()=>-1,depthAt:(l,a)=>Math.hypot(l-c.x,a-c.y),gradientAt:(l,a)=>{let e=l-c.x,f=a-c.y,i=Math.hypot(e,f);return i<1e-9?[0,0]:[e/i,f/i]}}}function tn(c,l){if(!c.length)return null;let a=0,e=0,f=0;for(let n of c)a+=n.x,e+=n.y,f+=Math.hypot(n.x-l.x,n.y-l.y);let i=c.length;a/=i,e/=i,f/=i;let u=c[0],R=-1;for(let n of c){let o=Math.hypot(n.x-a,n.y-e);o>R&&(R=o,u=n)}let b=u.x-a,m=u.y-e,d=Math.hypot(b,m);d>1e-9?(b/=d,m/=d):(b=1,m=0);let y=[...c].sort((n,o)=>(n.x-a)*b+(n.y-e)*m-((o.x-a)*b+(o.y-e)*m)),t=0;for(let n of y){let o=Math.hypot(n.x-a,n.y-e);o>t&&(t=o)}return{pts:y,cx:a,cy:e,radius:t,depth:f}}function Z(c,l,a){let e=c.pts;if(e.length===1)return Math.hypot(l-e[0].x,a-e[0].y);let f=1/0;for(let i=0;i+1<e.length;i++){let u=e[i],R=e[i+1],b=R.x-u.x,m=R.y-u.y,d=b*b+m*m,y=d>1e-12?((l-u.x)*b+(a-u.y)*m)/d:0;y<0?y=0:y>1&&(y=1);let t=Math.hypot(l-(u.x+y*b),a-(u.y+y*m));t<f&&(f=t)}return f}var U=8;function en(c,l,a){let e=new Array(U).fill(1/0),f=new Array(U).fill(-1);for(let d=0;d<c.length;d++){let y=c[d],t=Math.hypot(l-y.cx,a-y.cy)-y.radius;for(let n=0;n<U;n++)if(t<e[n]){for(let o=U-1;o>n;o--)e[o]=e[o-1],f[o]=f[o-1];e[n]=t,f[n]=d;break}}let i=new Array(3).fill(1/0),u=new Array(3).fill(-1);for(let d of f){if(d<0)continue;let y=Z(c[d],l,a);for(let t=0;t<3;t++)if(y<i[t]){for(let n=2;n>t;n--)i[n]=i[n-1],u[n]=u[n-1];i[t]=y,u[t]=d;break}}if(u[0]<0)return 0;if(i[0]<1e-6)return c[u[0]].depth;let R=i[0]*2.2,b=0,m=0;for(let d=0;d<3;d++){let y=u[d];if(y<0||i[d]>R)continue;let t=1/(i[d]*i[d]);b+=t*c[y].depth,m+=t}return m>0?b/m:c[u[0]].depth}function on(c){let l=(e,f)=>en(c,e,f),a=(e,f)=>{let i=1/0,u=-1;for(let R=0;R<c.length;R++){let b=c[R];if(Math.hypot(e-b.cx,f-b.cy)-b.radius>=i)continue;let m=Z(b,e,f);m<i&&(i=m,u=R)}return u};return{kind:"rows",rowCount:c.length,rows:c,nearestRow:a,depthAt:l,gradientAt:(e,f)=>{let i=(l(e+.5,f)-l(e-.5,f))/1,u=(l(e,f+.5)-l(e,f-.5))/(2*.5),R=Math.hypot(i,u);return R<1e-9?[0,0]:[i/R,u/R]}}}function bn(c,l){let a=[];for(let e of c){let f=tn(e.points,l);f&&a.push(f)}return a.length<2?nn(l):(a.sort((e,f)=>e.depth-f.depth),on(a))}var rn=Math.PI/180,h=96,sn=6,ln=60,cn=150,$=.2,an=.35;function fn(c,l){let a=Math.atan2(l.x-c.x,l.y-c.y)/rn;return a<0?a+360:a}function z(c){if(!c.length)return NaN;let l=[...c].sort((a,e)=>a-e);return l[Math.floor(l.length/2)]}function J(c,l,a=2){let e=c.length,f=new Float64Array(e);for(let i=0;i<e;i++){let u=0,R=0;for(let b=-a;b<=a;b++){let m=i+b;if(l)m=(m%e+e)%e;else if(m<0||m>=e)continue;u+=c[m],R++}f[i]=u/R}return f}function hn(c,l){let a=c.filter(t=>t.rows.length>=1);if(a.length<1)return null;let e=[],f=0,i=0,u=0;for(let t of a)for(let n of t.rows){for(let o of n.pts)f+=o.x,i+=o.y,u++;if(n.pts.length>=4){let o=Y(n.pts);o&&Number.isFinite(o.cx)&&Number.isFinite(o.cy)&&e.push({x:o.cx,y:o.cy})}}if(!u)return null;let R={x:f/u,y:i/u},b=R;if(e.length>=8){let t=z(e.map(D=>D.x)),n=z(e.map(D=>D.y)),o=0;for(let D of a)for(let j of D.rows)for(let F of j.pts){let W=Math.hypot(F.x-R.x,F.y-R.y);W>o&&(o=W)}let B=0,S=o*.2;for(let D of a)for(let j of D.rows)for(let F of j.pts)Math.hypot(F.x-t,F.y-n)<S&&B++;Math.hypot(t-R.x,n-R.y)<=o&&B/u<.01&&(b={x:t,y:n})}let m=[];for(let t of a){let n={sectionId:t.sectionId,rMin:1/0,rMax:-1/0,samples:[]};for(let o of t.rows)for(let B of o.pts){let S=Math.hypot(B.x-b.x,B.y-b.y),D=Math.min(h-1,Math.floor(fn(b,B)/(360/h)));n.samples.push({r:S,bin:D,levelM:o.levelM}),S<n.rMin&&(n.rMin=S),S>n.rMax&&(n.rMax=S)}n.samples.length&&m.push(n)}if(!m.length)return null;m.sort((t,n)=>t.rMin+t.rMax-(n.rMin+n.rMax));let d=[];for(let t of m){let n=!1;for(let o of d){let B=Math.min(t.rMax,o.rMax)-Math.max(t.rMin,o.rMin),S=Math.min(t.rMax-t.rMin,o.rMax-o.rMin);if(S>1e-9&&B>=an*S){o.members.push(t),o.rMin=Math.min(o.rMin,t.rMin),o.rMax=Math.max(o.rMax,t.rMax),n=!0;break}}n||d.push({members:[t],rMin:t.rMin,rMax:t.rMax})}let y=[];for(let t of d){let n=new Array(h).fill(null);for(let r of t.members)for(let p of r.samples){let x=n[p.bin];x||(x={samples:[]},n[p.bin]=x),x.samples.push({r:p.r,levelM:p.levelM})}let o=n.map(r=>!!r);if(!o.filter(Boolean).length)continue;let S=[],D=[];for(let r of n){if(!r)continue;let p=1/0,x=-1/0;for(let A of r.samples)A.r<p&&(p=A.r),A.r>x&&(x=A.r);S.push(p),D.push(x)}let j=z(S),F=z(D);if(!(j>=$*F)||!(F>0))continue;let W=[...S].sort((r,p)=>r-p);if(!(W[Math.floor(W.length*.1)]>=$*F))continue;let V=n.map(r=>{if(!r)return null;let p=[...r.samples].sort((w,k)=>w.r-k.r),x=p[0].r,A=p[p.length-1].r,P=p[0].levelM,N=-1/0;for(let w of p)w.levelM>N&&(N=w.levelM);let M=[];for(let w of p){let k={r:w.r,l:w.levelM};for(;M.length&&Math.abs(M[M.length-1].r-k.r)<1e-9;){if(M[M.length-1].l<=k.l){k.skip=!0;break}M.pop()}if(!k.skip){for(;M.length>=2;){let L=M[M.length-2],v=M[M.length-1];if((v.r-L.r)*(k.l-L.l)-(v.l-L.l)*(k.r-L.r)<=0)M.pop();else break}M.push(k)}}let C=M.map(w=>w.r),_=M.map(w=>w.l);return{inner:x,outer:A,front:P,top:N,profile:{rs:C,ls:_}}}),O=o.slice();for(let r=0;r<h;r++){if(O[r])continue;let p=-1,x=-1,A=0;for(let s=1;s<=h;s++){let g=(r-s+h*2)%h;if(O[g]){p=g;break}}for(let s=1;s<=h;s++){let g=(r+s)%h;if(O[g]){x=g,A=s;break}}if(p<0||x<0)continue;let P=0;for(let s=1;s<=h;s++){let g=(r-s+h*2)%h;if(o[g]){P=s;break}}if(P-1+A>sn)continue;let M=V[p],C=V[x],_=P/(P+A),w=M.inner+(C.inner-M.inner)*_,k=M.outer+(C.outer-M.outer)*_,L=M.front+(C.front-M.front)*_,v=M.top+(C.top-M.top)*_;V[r]={inner:w,outer:k,front:L,top:v,profile:{rs:[w,k],ls:[L,v]}}}for(let r=0;r<h;r++)V[r]&&(O[r]=!0);let X=360/h,K=[],q=O.filter(Boolean).length,Q=[];if(q===h)Q.push({start:0,len:h});else{let r=0;for(;O[r];)r=(r+1)%h;let p=-1;for(let x=0;x<=h;x++){let A=(r+x)%h,P=x<h&&O[A];if(P&&p<0)p=A;else if(!P&&p>=0){let N=(A-p+h)%h||h;Q.push({start:p,len:N}),p=-1}}}for(let r of Q){if(r.len*X<ln&&r.len<h)continue;let p=r.len===h,x=new Float64Array(r.len),A=new Float64Array(r.len),P=new Float64Array(r.len),N=new Float64Array(r.len),M=[];for(let s=0;s<r.len;s++){let g=V[(r.start+s)%h];x[s]=g.inner,A[s]=g.outer,P[s]=g.front,N[s]=g.top,M.push(g.profile??{rs:[g.inner,g.outer],ls:[g.front,g.top]})}let C=J(x,p),_=J(A,p),w=J(P,p),k=J(N,p);for(let s=0;s<r.len;s++)C[s]>x[s]&&(C[s]=x[s]),_[s]<A[s]&&(_[s]=A[s]),C[s]>_[s]-1e-6&&(C[s]=Math.max(0,_[s]-1e-6)),k[s]<w[s]&&(k[s]=w[s]);let L={startBin:r.start,binCount:r.len,closed:p,innerR:C,outerR:_,frontLevelM:w,topLevelM:k,profiles:M},v=(s,g,I)=>{let H=M[s],T=H.rs,E=H.ls;if(g<=T[0]){E[0]>I&&(E[0]=I);return}if(g>=T[T.length-1]){E[E.length-1]>I&&(E[E.length-1]=I);return}for(let G=0;G+1<T.length;G++)if(g<=T[G+1]){E[G]>I&&(E[G]=I),E[G+1]>I&&(E[G+1]=I);return}};for(let s=0;s<r.len;s++){let g=n[(r.start+s)%h];if(g)for(let I of g.samples){v(s,I.r,I.levelM);let H=p?(s-1+r.len)%r.len:s-1,T=p?(s+1)%r.len:s+1;H>=0&&v(H,I.r,I.levelM),T<r.len&&v(T,I.r,I.levelM)}}K.push(L)}K.reduce((r,p)=>r+p.binCount*X,0)<cn||y.push({arcs:K,sectionIds:t.members.map(r=>r.sectionId),innerRMedian:j,outerRMedian:F})}if(!y.length)return null;if(y.sort((t,n)=>t.innerRMedian-n.innerRMedian),l){let t=y[y.length-1].outerRMedian;if(Math.hypot(l.x-b.x,l.y-b.y)>.9*t)return null}return{centre:b,binCount:h,binStepDeg:360/h,rings:y}}function dn(c,l,a,e){let f=c.binStepDeg,i=a/f-.5-l.startBin;i=(i%c.binCount+c.binCount)%c.binCount,i>l.binCount-1&&(l.closed?i=i-l.binCount<l.binCount-i?0:l.binCount-1:i=i-(l.binCount-1)<c.binCount-i?l.binCount-1:0);let u=Math.floor(i),R=l.closed?(u+1)%l.binCount:Math.min(l.binCount-1,u+1),b=i-u,m=d=>{let y=l.profiles[d],t=y.rs,n=y.ls;if(e<=t[0])return n[0];if(e>=t[t.length-1])return n[n.length-1];for(let o=0;o+1<t.length;o++)if(e<=t[o+1]){let B=t[o+1]-t[o],S=B>1e-9?(e-t[o])/B:0;return n[o]+(n[o+1]-n[o])*S}return n[n.length-1]};return m(u)*(1-b)+m(R)*b}export{bn as a,fn as b,hn as c,dn as d};
@@ -1 +1 @@
1
- import{Ea as v,qa as _,za as A}from"./chunk-VDZ24QVV.js";function x(t){let n=Number(t.slice(t.lastIndexOf(":")+1));return Number.isFinite(n)?n:-1}function H(t,n,i){let e=new Map;for(let o of t){if(o.kind==="booth")continue;let a=e.get(o.rowId);a?a.push(o):e.set(o.rowId,[o])}let c=o=>i.has(o.id)||n(o.id)!=="free",l=[];for(let o of e.values())if(!(o.length<3)){o.sort((a,p)=>x(a.id)-x(p.id));for(let a=1;a<o.length-1;a++){let p=o[a];if(c(p))continue;let g=o[a-1],d=o[a+1];x(p.id)-x(g.id)!==1||x(d.id)-x(p.id)!==1||!c(g)||!c(d)||!i.has(g.id)&&!i.has(d.id)||l.push(p)}}return l}function C(t,n){if(Number.isInteger(t.logicalSeatIndex))return t.logicalSeatIndex;let i=t.id.lastIndexOf(":");if(i<0)return n;let e=Number(t.id.slice(i+1));return Number.isFinite(e)?e:n}function T(t,n){let i=t.x-n.x,e=t.y-n.y;return i*i+e*e}function N(t){let n=0,i=0;for(let e of t)n+=e.x,i+=e.y;return{x:n/t.length,y:i/t.length}}function M(t,n){return t.find(i=>i.focalPoint)?.focalPoint??n}function E(t){return t.commercial?.premium===!0}function q(t,n,i){let e=Math.floor(i.qty);if(!Number.isFinite(e)||e<=0)return{labels:[],reason:"sold_out"};let{categoryKey:c,zoneId:l,focal:o,preferPremium:a}=i,p=new Map,g=[];if(t.forEach((r,b)=>{let m=n.has(r.label)&&(!c||r.categoryKey===c)&&(!l||r.zoneId===l),f=r.logicalRowId??r.rowId,u=p.get(f);u||(u=[],p.set(f,u)),u.push({seat:r,index:C(r,b),elig:m}),m&&g.push(r)}),g.length===0)return{labels:[],reason:"sold_out"};let d=null,s=r=>{if(!d)return!0;if(a&&r.nonPremium!==d.nonPremium)return r.nonPremium<d.nonPremium;if(r.orphan!==d.orphan)return r.orphan<d.orphan;if(r.d2!==d.d2)return r.d2<d.d2;let b=r.rowId.localeCompare(d.rowId);return b!==0?b<0:r.startIndex<d.startIndex};for(let[r,b]of p){let m=[...b].sort((u,k)=>u.index-k.index),f=0;for(;f<m.length;){if(!m[f].elig){f++;continue}let u=f;for(;u<m.length&&m[u].elig&&(u===f||m[u].index===m[u-1].index+1);)u++;let k=u-f;for(let y=0;y+e<=k;y++){let B=y,j=k-(y+e),F=B===1||j===1?1:0,h=m.slice(f+y,f+y+e).map(I=>I.seat),O={labels:h.map(I=>I.label),seats:h,rowId:r,startIndex:m[f+y].index,orphan:F,nonPremium:a?h.reduce((I,L)=>I+(E(L)?0:1),0):0,d2:T(N(h),M(h,o))};s(O)&&(d=O)}f=u}}return d?{labels:d.labels}:g.length<e?{labels:[],reason:"not_enough_together"}:{labels:g.map((r,b)=>({seat:r,i:b,d2:T(r,r.focalPoint??o)})).sort((r,b)=>{if(a){let f=E(r.seat)?0:1,u=E(b.seat)?0:1;if(f!==u)return f-u}if(r.d2!==b.d2)return r.d2-b.d2;let m=(r.seat.logicalRowId??r.seat.rowId).localeCompare(b.seat.logicalRowId??b.seat.rowId);return m!==0?m:C(r.seat,r.i)-C(b.seat,b.i)}).slice(0,e).map(r=>r.seat.label)}}function $(t,n,i,e){let c=Math.floor(e.qty),l=q(t,i,e),a=n.filter(s=>s.bookingMode==="whole"&&s.capacity===c&&i.has(s.label)&&(!e.categoryKey||s.categoryKey===e.categoryKey)&&(!e.zoneId||s.zoneId===e.zoneId)).map(s=>({table:s,d2:T(s.center,s.focalPoint??e.focal)})).sort((s,w)=>s.d2-w.d2||s.table.label.localeCompare(w.table.label))[0];if(!a)return l;if(!l.labels.length)return{labels:[a.table.label]};let p=new Map(t.map(s=>[s.label,s])),g=l.labels.map(s=>p.get(s)).filter(s=>!!s),d=g.length?T(N(g),M(g,e.focal)):Number.POSITIVE_INFINITY;return a.d2<d?{labels:[a.table.label]}:l}function D(t){return{code:"ticket_option_not_applicable",labels:t,message:"That ticket choice is not available for the selected seat."}}function P(t,n){let i=t.applicability;return i?!(i.seatLabels?.length&&!i.seatLabels.includes(n.label)||i.accessibility?.length&&!i.accessibility.some(e=>n.accessibility?.includes(e))):!0}function Q(t,n){return(t.categories.find(i=>i.key===n.categoryKey)?.tiers??[]).filter(i=>P(i,n))}function K(t,n,i){let e=t.categories.find(l=>l.key===n.categoryKey)?.tiers;if(!e?.length)return{kind:"none"};let c=i==null?e.find(l=>P(l,n)):e.find(l=>l.id===i&&P(l,n));return c?{kind:"resolved",tier:c}:{kind:"invalid"}}function z(t,n){return(t.logicalRowId??t.rowId)===(n.logicalRowId??n.rowId)}function R(t){if(Number.isInteger(t.logicalSeatIndex))return t.logicalSeatIndex;let n=t.id.slice(t.id.lastIndexOf(":")+1),i=Number(n);return Number.isInteger(i)?i:void 0}function G(t,n){if(!z(t,n))return!1;let i=R(t),e=R(n);return i!=null&&e!=null&&Math.abs(i-e)===1}function U(t,n){if(!n.length)return null;let i=new Map(v(t,{resolveEyeHeights:!1}).map(o=>[o.label,o])),e=n.flatMap(o=>{let a=i.get(o.label);return a?[{selection:o,seat:a}]:[]}),c=e.map(({seat:o})=>o).filter(o=>o.accessibility?.includes("wheelchair")),l=[];for(let{selection:o,seat:a}of e){let p=K(t,a,o.tierId),g=p.kind==="resolved"?p.tier:void 0;(a.accessibility?.includes("companion")||g?.restriction==="companion")&&!c.some(s=>s.id!==a.id&&G(a,s))&&l.push(a.label)}return l.length?{code:"companion_pair_required",labels:l,message:"Select the adjacent wheelchair place with each companion ticket."}:null}function X(t,n){if(!n.length)return null;let i=new Map(v(t,{resolveEyeHeights:!1}).map(o=>[o.label,o])),e=new Set(t.categories.filter(o=>o.notForSale).map(o=>o.key)),c=[],l=[];for(let o of n){let a=i.get(o.label);if(!a)continue;if(e.has(a.categoryKey)){c.push(a.label);continue}K(t,a,o.tierId).kind==="invalid"&&l.push(a.label)}return c.length?{code:"not_for_sale",labels:c,message:"These seats are not for sale."}:l.length?D(l):U(t,n)}var S=class extends Error{constructor(i,e){super(e);this.objectId=i;this.name="GroupedTableProjectionError"}};function V(t){let n=t.minOccupancy,i=t.maxOccupancy;if(!Number.isInteger(n)||!Number.isInteger(i)||n<1||i<n||i>t.seatCount)throw new S(t.id,`Table "${t.label}" has invalid variable-occupancy bounds`);return{min:n,max:i}}function te(t,n){if(n!==2)return[];let i=[];for(let e of A(t)){if(e.type!=="table"||!e.bookAsWhole&&!e.variableOccupancy)continue;if(e.bookAsWhole&&e.variableOccupancy)throw new S(e.id,`Table "${e.label}" cannot be whole-table and variable-occupancy inventory`);if(!Number.isInteger(e.seatCount)||e.seatCount<1||!e.label.trim())throw new S(e.id,"Grouped tables require a label and at least one chair");let c=e.variableOccupancy?"variable":"whole",l=c==="variable"?V(e):{min:e.seatCount,max:e.seatCount};i.push({objectId:e.id,label:e.label,...e.displayLabel?{displayLabel:e.displayLabel}:{},...e.displayType?{displayType:e.displayType}:{},categoryKey:e.categoryKey,mode:c,capacity:e.seatCount,minOccupancy:l.min,maxOccupancy:l.max,chairs:_(e)})}return i}export{H as a,q as b,$ as c,D as d,P as e,Q as f,K as g,U as h,X as i,S as j,te as k};
1
+ import{Ea as v,qa as _,za as A}from"./chunk-GHJUDU3U.js";function x(t){let n=Number(t.slice(t.lastIndexOf(":")+1));return Number.isFinite(n)?n:-1}function H(t,n,i){let e=new Map;for(let o of t){if(o.kind==="booth")continue;let a=e.get(o.rowId);a?a.push(o):e.set(o.rowId,[o])}let c=o=>i.has(o.id)||n(o.id)!=="free",l=[];for(let o of e.values())if(!(o.length<3)){o.sort((a,p)=>x(a.id)-x(p.id));for(let a=1;a<o.length-1;a++){let p=o[a];if(c(p))continue;let g=o[a-1],d=o[a+1];x(p.id)-x(g.id)!==1||x(d.id)-x(p.id)!==1||!c(g)||!c(d)||!i.has(g.id)&&!i.has(d.id)||l.push(p)}}return l}function C(t,n){if(Number.isInteger(t.logicalSeatIndex))return t.logicalSeatIndex;let i=t.id.lastIndexOf(":");if(i<0)return n;let e=Number(t.id.slice(i+1));return Number.isFinite(e)?e:n}function T(t,n){let i=t.x-n.x,e=t.y-n.y;return i*i+e*e}function N(t){let n=0,i=0;for(let e of t)n+=e.x,i+=e.y;return{x:n/t.length,y:i/t.length}}function M(t,n){return t.find(i=>i.focalPoint)?.focalPoint??n}function E(t){return t.commercial?.premium===!0}function q(t,n,i){let e=Math.floor(i.qty);if(!Number.isFinite(e)||e<=0)return{labels:[],reason:"sold_out"};let{categoryKey:c,zoneId:l,focal:o,preferPremium:a}=i,p=new Map,g=[];if(t.forEach((r,b)=>{let m=n.has(r.label)&&(!c||r.categoryKey===c)&&(!l||r.zoneId===l),f=r.logicalRowId??r.rowId,u=p.get(f);u||(u=[],p.set(f,u)),u.push({seat:r,index:C(r,b),elig:m}),m&&g.push(r)}),g.length===0)return{labels:[],reason:"sold_out"};let d=null,s=r=>{if(!d)return!0;if(a&&r.nonPremium!==d.nonPremium)return r.nonPremium<d.nonPremium;if(r.orphan!==d.orphan)return r.orphan<d.orphan;if(r.d2!==d.d2)return r.d2<d.d2;let b=r.rowId.localeCompare(d.rowId);return b!==0?b<0:r.startIndex<d.startIndex};for(let[r,b]of p){let m=[...b].sort((u,k)=>u.index-k.index),f=0;for(;f<m.length;){if(!m[f].elig){f++;continue}let u=f;for(;u<m.length&&m[u].elig&&(u===f||m[u].index===m[u-1].index+1);)u++;let k=u-f;for(let y=0;y+e<=k;y++){let B=y,j=k-(y+e),F=B===1||j===1?1:0,h=m.slice(f+y,f+y+e).map(I=>I.seat),O={labels:h.map(I=>I.label),seats:h,rowId:r,startIndex:m[f+y].index,orphan:F,nonPremium:a?h.reduce((I,L)=>I+(E(L)?0:1),0):0,d2:T(N(h),M(h,o))};s(O)&&(d=O)}f=u}}return d?{labels:d.labels}:g.length<e?{labels:[],reason:"not_enough_together"}:{labels:g.map((r,b)=>({seat:r,i:b,d2:T(r,r.focalPoint??o)})).sort((r,b)=>{if(a){let f=E(r.seat)?0:1,u=E(b.seat)?0:1;if(f!==u)return f-u}if(r.d2!==b.d2)return r.d2-b.d2;let m=(r.seat.logicalRowId??r.seat.rowId).localeCompare(b.seat.logicalRowId??b.seat.rowId);return m!==0?m:C(r.seat,r.i)-C(b.seat,b.i)}).slice(0,e).map(r=>r.seat.label)}}function $(t,n,i,e){let c=Math.floor(e.qty),l=q(t,i,e),a=n.filter(s=>s.bookingMode==="whole"&&s.capacity===c&&i.has(s.label)&&(!e.categoryKey||s.categoryKey===e.categoryKey)&&(!e.zoneId||s.zoneId===e.zoneId)).map(s=>({table:s,d2:T(s.center,s.focalPoint??e.focal)})).sort((s,w)=>s.d2-w.d2||s.table.label.localeCompare(w.table.label))[0];if(!a)return l;if(!l.labels.length)return{labels:[a.table.label]};let p=new Map(t.map(s=>[s.label,s])),g=l.labels.map(s=>p.get(s)).filter(s=>!!s),d=g.length?T(N(g),M(g,e.focal)):Number.POSITIVE_INFINITY;return a.d2<d?{labels:[a.table.label]}:l}function D(t){return{code:"ticket_option_not_applicable",labels:t,message:"That ticket choice is not available for the selected seat."}}function P(t,n){let i=t.applicability;return i?!(i.seatLabels?.length&&!i.seatLabels.includes(n.label)||i.accessibility?.length&&!i.accessibility.some(e=>n.accessibility?.includes(e))):!0}function Q(t,n){return(t.categories.find(i=>i.key===n.categoryKey)?.tiers??[]).filter(i=>P(i,n))}function K(t,n,i){let e=t.categories.find(l=>l.key===n.categoryKey)?.tiers;if(!e?.length)return{kind:"none"};let c=i==null?e.find(l=>P(l,n)):e.find(l=>l.id===i&&P(l,n));return c?{kind:"resolved",tier:c}:{kind:"invalid"}}function z(t,n){return(t.logicalRowId??t.rowId)===(n.logicalRowId??n.rowId)}function R(t){if(Number.isInteger(t.logicalSeatIndex))return t.logicalSeatIndex;let n=t.id.slice(t.id.lastIndexOf(":")+1),i=Number(n);return Number.isInteger(i)?i:void 0}function G(t,n){if(!z(t,n))return!1;let i=R(t),e=R(n);return i!=null&&e!=null&&Math.abs(i-e)===1}function U(t,n){if(!n.length)return null;let i=new Map(v(t,{resolveEyeHeights:!1}).map(o=>[o.label,o])),e=n.flatMap(o=>{let a=i.get(o.label);return a?[{selection:o,seat:a}]:[]}),c=e.map(({seat:o})=>o).filter(o=>o.accessibility?.includes("wheelchair")),l=[];for(let{selection:o,seat:a}of e){let p=K(t,a,o.tierId),g=p.kind==="resolved"?p.tier:void 0;(a.accessibility?.includes("companion")||g?.restriction==="companion")&&!c.some(s=>s.id!==a.id&&G(a,s))&&l.push(a.label)}return l.length?{code:"companion_pair_required",labels:l,message:"Select the adjacent wheelchair place with each companion ticket."}:null}function X(t,n){if(!n.length)return null;let i=new Map(v(t,{resolveEyeHeights:!1}).map(o=>[o.label,o])),e=new Set(t.categories.filter(o=>o.notForSale).map(o=>o.key)),c=[],l=[];for(let o of n){let a=i.get(o.label);if(!a)continue;if(e.has(a.categoryKey)){c.push(a.label);continue}K(t,a,o.tierId).kind==="invalid"&&l.push(a.label)}return c.length?{code:"not_for_sale",labels:c,message:"These seats are not for sale."}:l.length?D(l):U(t,n)}var S=class extends Error{constructor(i,e){super(e);this.objectId=i;this.name="GroupedTableProjectionError"}};function V(t){let n=t.minOccupancy,i=t.maxOccupancy;if(!Number.isInteger(n)||!Number.isInteger(i)||n<1||i<n||i>t.seatCount)throw new S(t.id,`Table "${t.label}" has invalid variable-occupancy bounds`);return{min:n,max:i}}function te(t,n){if(n!==2)return[];let i=[];for(let e of A(t)){if(e.type!=="table"||!e.bookAsWhole&&!e.variableOccupancy)continue;if(e.bookAsWhole&&e.variableOccupancy)throw new S(e.id,`Table "${e.label}" cannot be whole-table and variable-occupancy inventory`);if(!Number.isInteger(e.seatCount)||e.seatCount<1||!e.label.trim())throw new S(e.id,"Grouped tables require a label and at least one chair");let c=e.variableOccupancy?"variable":"whole",l=c==="variable"?V(e):{min:e.seatCount,max:e.seatCount};i.push({objectId:e.id,label:e.label,...e.displayLabel?{displayLabel:e.displayLabel}:{},...e.displayType?{displayType:e.displayType}:{},categoryKey:e.categoryKey,mode:c,capacity:e.seatCount,minOccupancy:l.min,maxOccupancy:l.max,chairs:_(e)})}return i}export{H as a,q as b,$ as c,D as d,P as e,Q as f,K as g,U as h,X as i,S as j,te as k};