@zonetrix/viewer 2.10.6 → 2.10.7

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.
@@ -5,7 +5,9 @@ export interface SeatMapViewerProps {
5
5
  configUrl?: string;
6
6
  floorId?: string;
7
7
  onFloorChange?: (floorId: string) => void;
8
+ /** @deprecated Use otherReservedSeats instead (v2.4.0+) */
8
9
  reservedSeats?: string[];
10
+ otherReservedSeats?: string[];
9
11
  unavailableSeats?: string[];
10
12
  selectedSeats?: string[];
11
13
  myReservedSeats?: string[];
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),t=require("react"),X=require("react-konva"),W=require("firebase/database"),ot=require("@zonetrix/shared");function we(n){const[s,a]=t.useState(null),[r,h]=t.useState(!1),[u,o]=t.useState(null),w=async()=>{if(n){h(!0),o(null);try{const g=await fetch(n);if(!g.ok)throw new Error(`Failed to fetch config: ${g.statusText}`);const l=await g.json();a(l)}catch(g){const l=g instanceof Error?g:new Error("Unknown error occurred");o(l),console.error("Failed to fetch seat map config:",l)}finally{h(!1)}}};return t.useEffect(()=>{w()},[n]),{config:s,loading:r,error:u,refetch:w}}function Ce(n){const[s,a]=t.useState({width:0,height:0});return t.useEffect(()=>{const r=n.current;if(!r)return;const{width:h,height:u}=r.getBoundingClientRect();h>0&&u>0&&a({width:h,height:u});const o=new ResizeObserver(w=>{const g=w[0];if(!g)return;const{width:l,height:c}=g.contentRect;l>0&&c>0&&a(f=>f.width===l&&f.height===c?f:{width:l,height:c})});return o.observe(r),()=>{o.disconnect()}},[n]),s}function ve(n,s){return Math.sqrt(Math.pow(s.x-n.x,2)+Math.pow(s.y-n.y,2))}function me(n,s){return{x:(n.x+s.x)/2,y:(n.y+s.y)/2}}function Re(n,s){const a=t.useRef(null),r=t.useRef(null),h=t.useRef(1);t.useEffect(()=>{const u=n.current;if(!u||!s.enabled)return;const o=u.container(),w=c=>{if(c.touches.length===2){c.preventDefault();const f={x:c.touches[0].clientX,y:c.touches[0].clientY},p={x:c.touches[1].clientX,y:c.touches[1].clientY};a.current=ve(f,p),r.current=me(f,p),h.current=s.currentScale}},g=c=>{if(c.touches.length!==2)return;c.preventDefault();const f={x:c.touches[0].clientX,y:c.touches[0].clientY},p={x:c.touches[1].clientX,y:c.touches[1].clientY},b=ve(f,p),v=me(f,p);if(a.current!==null&&r.current!==null){const R=b/a.current,E=Math.min(Math.max(s.currentScale*R,s.minScale),s.maxScale),F=o.getBoundingClientRect(),M=v.x-F.left,j=v.y-F.top,z=s.currentScale,L={x:(M-s.currentPosition.x)/z,y:(j-s.currentPosition.y)/z},D=v.x-r.current.x,N=v.y-r.current.y,Q={x:M-L.x*E+D,y:j-L.y*E+N};s.onScaleChange(E,Q),a.current=b,r.current=v}},l=c=>{c.touches.length<2&&(a.current=null,r.current=null)};return o.addEventListener("touchstart",w,{passive:!1}),o.addEventListener("touchmove",g,{passive:!1}),o.addEventListener("touchend",l),()=>{o.removeEventListener("touchstart",w),o.removeEventListener("touchmove",g),o.removeEventListener("touchend",l)}},[n,s])}const je={canvasBackground:"#1a1a1a",stageColor:"#808080",seatAvailable:"#2C2B30",seatReserved:"#FCEA00",seatSelected:"#3A7DE5",seatUnavailable:"#6b7280",seatHidden:"#4a4a4a",gridLines:"#404040",currency:"KD"},Me=t.memo(({seat:n,state:s,colors:a,onClick:r,onMouseEnter:h,onMouseLeave:u})=>{const g={available:a.seatAvailable,reserved:a.seatReserved,selected:a.seatSelected,unavailable:a.seatUnavailable,hidden:a.seatHidden}[s],l=s==="available"||s==="selected",c=t.useCallback(()=>{l&&r(n)},[n,r,l]),f=t.useCallback(v=>{h(n,v);const R=v.target.getStage();R&&l&&(R.container().style.cursor="pointer")},[n,h,l]),p=t.useCallback(v=>{u();const R=v.target.getStage();R&&(R.container().style.cursor="grab")},[u]),b={x:n.position.x,y:n.position.y,fill:g,stroke:"#ffffff",strokeWidth:1,onClick:c,onTap:c,onMouseEnter:f,onMouseLeave:p};return n.shape==="circle"?i.jsx(X.Circle,{...b,radius:12}):i.jsx(X.Rect,{...b,width:24,height:24,offsetX:12,offsetY:12,cornerRadius:n.shape==="square"?0:4})});Me.displayName="ViewerSeat";const Ee=t.memo(({stage:n,stageColor:s})=>{const a=u=>({stage:"🎭",table:"⬜",wall:"▬",barrier:"🛡️","dj-booth":"🎵",bar:"🍷","entry-exit":"🚪",custom:"➕"})[u||"stage"]||"🎭",r=n.config.color||s,h=a(n.config.objectType);return i.jsxs(X.Group,{x:n.position.x,y:n.position.y,rotation:n.config.rotation||0,children:[i.jsx(X.Rect,{width:n.config.width,height:n.config.height,fill:r+"80",stroke:"#ffffff",strokeWidth:2,cornerRadius:10}),i.jsx(X.Text,{text:h,x:0,y:0,width:n.config.width,height:n.config.height*.4,fontSize:32,fill:"#ffffff",align:"center",verticalAlign:"middle"}),i.jsx(X.Text,{text:n.config.label,x:0,y:n.config.height*.4,width:n.config.width,height:n.config.height*.6,fontSize:20,fontStyle:"bold",fill:"#ffffff",align:"center",verticalAlign:"middle"})]})});Ee.displayName="ViewerStage";const Fe=t.memo(({floors:n,currentFloorId:s,onFloorChange:a,showAllOption:r,allLabel:h,position:u,className:o})=>{const w=t.useMemo(()=>[...n].sort((p,b)=>p.order-b.order),[n]),l={position:"absolute",display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",backgroundColor:"rgba(26, 26, 26, 0.95)",borderRadius:"8px",margin:"12px",zIndex:10,...{"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0}}[u]},c={padding:"10px 16px",fontSize:"14px",fontWeight:500,border:"1px solid #444",borderRadius:"6px",backgroundColor:"transparent",color:"#fff",cursor:"pointer",transition:"all 0.2s ease",minHeight:"44px",touchAction:"manipulation"},f={...c,backgroundColor:"#3A7DE5",borderColor:"#3A7DE5"};return i.jsxs("div",{className:o,style:l,children:[r&&i.jsx("button",{type:"button",onClick:()=>a(null),style:s===null?f:c,children:h}),w.map(p=>i.jsx("button",{type:"button",onClick:()=>a(p.id),style:s===p.id?f:c,children:p.name},p.id))]})});Fe.displayName="FloorSelectorBar";const ke=t.memo(({scale:n,minScale:s,maxScale:a,onZoomIn:r,onZoomOut:h,position:u,className:o})=>{const g={position:"absolute",display:"flex",flexDirection:"column",gap:"4px",padding:"8px",backgroundColor:"rgba(26, 26, 26, 0.95)",borderRadius:"8px",margin:"12px",zIndex:10,...{"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0}}[u]},l={width:"44px",height:"44px",minWidth:"44px",minHeight:"44px",fontSize:"22px",fontWeight:"bold",border:"1px solid #444",borderRadius:"6px",backgroundColor:"transparent",color:"#fff",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease",touchAction:"manipulation"},c={...l,opacity:.4,cursor:"not-allowed"},f=n<a,p=n>s;return i.jsxs("div",{className:o,style:g,children:[i.jsx("button",{type:"button",onClick:r,disabled:!f,style:f?l:c,title:"Zoom In",children:"+"}),i.jsx("button",{type:"button",onClick:h,disabled:!p,style:p?l:c,title:"Zoom Out",children:"−"})]})});ke.displayName="ZoomControls";const Ie=t.memo(({visible:n,x:s,y:a,seat:r,currency:h,state:u})=>{if(!n||!r)return null;const o=r.seatNumber||(r.rowLabel&&r.columnLabel?`${r.rowLabel}-${r.columnLabel}`:"N/A"),w={position:"fixed",left:`${s+15}px`,top:`${a+15}px`,zIndex:1e3,pointerEvents:"none"},g={backgroundColor:"rgba(26, 26, 26, 0.95)",color:"#fff",border:"1px solid #444",borderRadius:"8px",padding:"8px 12px",fontSize:"13px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.3)",minWidth:"140px"},l={color:"#9ca3af",marginRight:"4px"},c={fontWeight:600},f={color:"#4ade80",fontWeight:600},p={fontSize:"11px",color:"#6b7280",textTransform:"capitalize",marginTop:"4px"};return i.jsx("div",{style:w,children:i.jsxs("div",{style:g,children:[r.sectionName&&i.jsxs("div",{style:{marginBottom:"4px"},children:[i.jsx("span",{style:l,children:"Section:"}),i.jsx("span",{style:{...c,color:"#3b82f6"},children:r.sectionName})]}),i.jsxs("div",{style:{marginBottom:"4px"},children:[i.jsx("span",{style:l,children:"Seat:"}),i.jsx("span",{style:c,children:o})]}),r.price!==void 0&&r.price>0&&u==="available"&&i.jsxs("div",{style:{marginBottom:"4px"},children:[i.jsx("span",{style:l,children:"Price:"}),i.jsxs("span",{style:f,children:[h," ",r.price.toFixed(2)]})]}),i.jsxs("div",{style:p,children:["Status: ",u]})]})})});Ie.displayName="SeatTooltip";const it=({config:n,configUrl:s,floorId:a,onFloorChange:r,reservedSeats:h=[],unavailableSeats:u=[],selectedSeats:o,myReservedSeats:w=[],onSeatSelect:g,onSeatDeselect:l,onSelectionChange:c,colorOverrides:f,showTooltip:p=!0,zoomEnabled:b=!0,className:v="",onConfigLoad:R,onError:E,showFloorSelector:F,floorSelectorPosition:M="top-left",floorSelectorClassName:j,showAllFloorsOption:z=!0,allFloorsLabel:L="All",fitToView:D=!0,fitPadding:N=40,showZoomControls:Q=!0,zoomControlsPosition:De="bottom-right",zoomControlsClassName:ze,minZoom:be,maxZoom:Y=3,zoomStep:ee=.25,touchEnabled:Ne=!0})=>{const le=t.useRef(null),xe=t.useRef(null),k=Ce(xe),[U,Se]=t.useState(new Set),[I,H]=t.useState(1),[T,B]=t.useState({x:0,y:0}),[Ae,Xe]=t.useState(null),[Ye,Pe]=t.useState(1),te=t.useRef({width:0,height:0}),[q,ye]=t.useState({visible:!1,x:0,y:0,seat:null,state:"available"}),{config:We,loading:Be,error:_}=we(s),x=n||We,ue=a!==void 0,A=ue?a||null:Ae,ne=o!==void 0,$e=t.useCallback(e=>{ue||Xe(e),r?.(e)},[ue,r]),de=x?.floors||[],Ue=F!==void 0?F:de.length>1,se=t.useMemo(()=>x?{...x.colors,...f}:{...je,...f},[x,f]),O=t.useMemo(()=>{if(!x)return[];let e=x.seats.filter(d=>d.state!=="hidden");return A&&(e=e.filter(d=>d.floorId===A||!d.floorId&&A==="floor_default")),e},[x,A]),re=t.useMemo(()=>x?.stages?A?x.stages.filter(e=>e.floorId===A||!e.floorId&&A==="floor_default"):x.stages:[],[x,A]),P=t.useMemo(()=>{if(!x||O.length===0&&re.length===0)return null;const e=12;let d=1/0,S=1/0,y=-1/0,m=-1/0;return O.forEach(C=>{d=Math.min(d,C.position.x-e),S=Math.min(S,C.position.y-e),y=Math.max(y,C.position.x+e),m=Math.max(m,C.position.y+e)}),re.forEach(C=>{d=Math.min(d,C.position.x),S=Math.min(S,C.position.y),y=Math.max(y,C.position.x+(C.config?.width||200)),m=Math.max(m,C.position.y+(C.config?.height||100))}),{minX:d,minY:S,maxX:y,maxY:m,width:y-d,height:m-S}},[x,O,re]);t.useEffect(()=>{if(!D||!x||!P||k.width===0||k.height===0)return;const e=Math.abs(k.width-te.current.width),d=Math.abs(k.height-te.current.height);if(!(te.current.width===0)&&e<10&&d<10)return;te.current=k;const y=k.width,m=k.height,C=y-N*2,Z=m-N*2,oe=C/P.width,fe=Z/P.height,ie=Math.min(oe,fe,Y),Qe=P.minX+P.width/2,et=P.minY+P.height/2,tt=y/2,nt=m/2,st=tt-Qe*ie,rt=nt-et*ie;H(ie),B({x:st,y:rt}),Pe(ie)},[D,x,P,N,Y,k,A]);const $=t.useMemo(()=>{const e=new Set(h),d=new Set(u),S=new Set(w);return{reserved:e,unavailable:d,myReserved:S}},[h,u,w]),he=t.useMemo(()=>o?new Set(o):null,[o]),G=t.useCallback(e=>{const d=e.id,S=e.seatNumber||"";return $.unavailable.has(d)||$.unavailable.has(S)?"unavailable":$.reserved.has(d)||$.reserved.has(S)?"reserved":$.myReserved.has(d)||$.myReserved.has(S)||U.has(d)?"selected":e.state},[$,U]);t.useEffect(()=>{x&&R&&R(x)},[x,R]),t.useEffect(()=>{_&&E&&E(_)},[_,E]),t.useEffect(()=>{ne&&he&&Se(he)},[ne,he]);const Oe=t.useCallback(e=>{const d=G(e);if(d!=="available"&&d!=="selected")return;const S=U.has(e.id);ne||Se(y=>{const m=new Set(y);return S?m.delete(e.id):m.add(e.id),m}),S?l?.(e):(g?.(e),g||console.log("Seat selected:",e))},[G,U,ne,g,l]),K=t.useMemo(()=>x?O.filter(e=>U.has(e.id)):[],[O,U]);t.useEffect(()=>{c?.(K)},[K,c]);const V=be!==void 0?be:Ye,Ve=t.useCallback(()=>{if(!b)return;const e=Math.min(I+ee,Y);if(e!==I){const d=k.width||x?.canvas.width||800,S=k.height||x?.canvas.height||600,y=d/2,m=S/2,C={x:(y-T.x)/I,y:(m-T.y)/I};H(e),B({x:y-C.x*e,y:m-C.y*e})}},[b,I,ee,Y,k,x,T]),He=t.useCallback(()=>{if(!b)return;const e=Math.max(I-ee,V);if(e!==I){const d=k.width||x?.canvas.width||800,S=k.height||x?.canvas.height||600,y=d/2,m=S/2,C={x:(y-T.x)/I,y:(m-T.y)/I};H(e),B({x:y-C.x*e,y:m-C.y*e})}},[b,I,ee,V,k,x,T]),qe=t.useCallback(e=>{B({x:e.target.x(),y:e.target.y()})},[]),_e=t.useCallback(e=>{if(!b)return;e.evt.preventDefault();const d=le.current;if(!d)return;const S=d.scaleX(),y=d.getPointerPosition();if(!y)return;const m=1.1,C=e.evt.deltaY>0?S/m:S*m,Z=Math.min(Math.max(C,V),Y),oe={x:(y.x-T.x)/S,y:(y.y-T.y)/S},fe={x:y.x-oe.x*Z,y:y.y-oe.y*Z};H(Z),B(fe)},[b,T,V,Y]);Re(le,{enabled:Ne&&b,minScale:V,maxScale:Y,currentScale:I,currentPosition:T,onScaleChange:(e,d)=>{H(e),B(d)},onPositionChange:e=>{B(e)}});const Ge=t.useCallback((e,d)=>{if(!p)return;const S=d.target.getStage();if(!S)return;const y=S.getPointerPosition();if(!y)return;const m=S.container().getBoundingClientRect();ye({visible:!0,x:m.left+y.x,y:m.top+y.y,seat:e,state:G(e)})},[p,G]),Ke=t.useCallback(()=>{ye(e=>({...e,visible:!1}))},[]);if(Be)return i.jsx("div",{className:`flex items-center justify-center h-full ${v}`,children:i.jsx("p",{children:"Loading seat map..."})});if(_)return i.jsx("div",{className:`flex items-center justify-center h-full ${v}`,children:i.jsxs("p",{className:"text-red-500",children:["Error loading seat map: ",_.message]})});if(!x)return i.jsx("div",{className:`flex items-center justify-center h-full ${v}`,children:i.jsx("p",{children:"No configuration provided"})});const Ze=k.width||x.canvas.width,Je=k.height||x.canvas.height;return i.jsxs("div",{ref:xe,className:`relative ${v}`,style:{width:"100%",height:"100%"},children:[Ue&&de.length>0&&i.jsx(Fe,{floors:de,currentFloorId:A,onFloorChange:$e,showAllOption:z,allLabel:L,position:M,className:j}),i.jsxs(X.Stage,{ref:le,width:Ze,height:Je,scaleX:I,scaleY:I,x:T.x,y:T.y,draggable:!0,onDragEnd:qe,onWheel:_e,style:{backgroundColor:x.canvas.backgroundColor,cursor:"grab"},children:[i.jsx(X.Layer,{listening:!1,children:re.map(e=>i.jsx(Ee,{stage:e,stageColor:se.stageColor},e.id))}),i.jsx(X.Layer,{children:O.map(e=>i.jsx(Me,{seat:e,state:G(e),colors:se,onClick:Oe,onMouseEnter:Ge,onMouseLeave:Ke},e.id))})]}),p&&i.jsx(Ie,{visible:q.visible,x:q.x,y:q.y,seat:q.seat,currency:se.currency,state:q.state}),Q&&b&&i.jsx(ke,{scale:I,minScale:V,maxScale:Y,onZoomIn:Ve,onZoomOut:He,position:De,className:ze}),K.length>0&&i.jsxs("div",{className:"absolute top-4 right-4 bg-white dark:bg-gray-800 p-4 rounded shadow-lg",children:[i.jsxs("h3",{className:"font-semibold mb-2",children:["Selected Seats (",K.length,")"]}),i.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:K.map(e=>i.jsxs("div",{className:"text-sm",children:[e.seatNumber,e.price&&` - ${se.currency} ${e.price.toFixed(2)}`]},e.id))})]})]})};let J=null;function at(n){J=n}function pe(){if(!J)throw new Error("Firebase database not initialized. Call initializeFirebaseForViewer(db) first.");return J}function ce(){return J!==null}function ct(){J=null}function ge(n,s){if(n.length!==s.length)return!1;const a=[...n].sort(),r=[...s].sort();return a.every((h,u)=>h===r[u])}function lt(n,s){const a=[],r=[],h=[];return Object.entries(n).forEach(([u,o])=>{o&&typeof o=="object"&&o.state&&(o.state==="unavailable"?h.push(u):o.state==="reserved"&&(s&&o.userId===s?a.push(u):r.push(u)))}),{myReserved:a.sort(),otherReserved:r.sort(),unavailable:h.sort()}}const ae={states:null,loading:!0,error:null,lastUpdated:null,myReservedSeats:[],otherReservedSeats:[],unavailableSeats:[]};function Le(n){const{seatMapId:s,currentUserId:a,enabled:r=!0,onStateChange:h,onError:u}=n,o=t.useRef({...ae}),w=t.useRef(h),g=t.useRef(u),l=t.useRef(a);w.current=h,g.current=u,l.current=a;const c=t.useCallback(v=>{if(!r||!s)return(o.current.loading!==!1||o.current.states!==null)&&(o.current={...ae,loading:!1},v()),()=>{};if(!ce()){const j="Firebase not initialized. Call initializeFirebaseForViewer first.";return o.current.error?.message!==j&&(o.current={...ae,loading:!1,error:new Error(j)},v()),()=>{}}const R=pe(),E=W.ref(R,`seatmaps/${s}/seat_states`),F=j=>{const L=j.val()||{},D=lt(L,l.current),N=o.current;(N.loading||!ge(N.myReservedSeats,D.myReserved)||!ge(N.otherReservedSeats,D.otherReserved)||!ge(N.unavailableSeats,D.unavailable))&&(o.current={states:L,loading:!1,error:null,lastUpdated:Date.now(),myReservedSeats:D.myReserved,otherReservedSeats:D.otherReserved,unavailableSeats:D.unavailable},w.current?.(L),v())},M=j=>{o.current={...o.current,loading:!1,error:j},g.current?.(j),v()};return W.onValue(E,F,M),()=>{W.off(E)}},[s,r]),f=t.useCallback(()=>o.current,[]),p=t.useCallback(()=>ae,[]),b=t.useSyncExternalStore(c,f,p);return{states:b.states,loading:b.loading,error:b.error,lastUpdated:b.lastUpdated,myReservedSeats:b.myReservedSeats,otherReservedSeats:b.otherReservedSeats,unavailableSeats:b.unavailableSeats,reservedSeats:b.otherReservedSeats}}function Te(n){const{seatMapId:s,enabled:a=!0,subscribeToChanges:r=!1,onConfigLoad:h,onError:u}=n,[o,w]=t.useState(null),[g,l]=t.useState(!0),[c,f]=t.useState(null),p=t.useRef(h),b=t.useRef(u);p.current=h,b.current=u;const v=t.useCallback(async()=>{if(!s)return;if(!ce()){f(new Error("Firebase not initialized. Call initializeFirebaseForViewer first.")),l(!1);return}const R=pe(),E=W.ref(R,`seatmaps/${s}`);try{l(!0),f(null);const M=(await W.get(E)).val();if(M){const j=ot.fromFirebaseSeatMap(M);w(j),p.current?.(j)}else f(new Error(`Seat map ${s} not found in Firebase`))}catch(F){const M=F instanceof Error?F:new Error("Unknown error");f(M),b.current?.(M)}finally{l(!1)}},[s]);return t.useEffect(()=>{if(!a||!s){l(!1);return}if(v(),r&&ce()){const R=pe(),E=W.ref(R,`seatmaps/${s}/meta/updated_at`);let F=!0,M=null;const j=z=>{if(F){F=!1,M=z.val();return}const L=z.val();z.exists()&&L!==M&&(M=L,v())};return W.onValue(E,j),()=>{W.off(E)}}},[s,a,r]),{config:o,loading:g,error:c,refetch:v}}function ut(n){const{seatMapId:s,userId:a,enabled:r=!0,subscribeToDesignChanges:h=!1,onConfigLoad:u,onStateChange:o,onError:w}=n,{config:g,loading:l,error:c,refetch:f}=Te({seatMapId:s,enabled:r,subscribeToChanges:h,onConfigLoad:u,onError:w}),{states:p,loading:b,error:v,lastUpdated:R,myReservedSeats:E,otherReservedSeats:F,unavailableSeats:M,reservedSeats:j}=Le({seatMapId:s,currentUserId:a,enabled:r,onStateChange:o,onError:w});return{config:g,loading:l||b,error:c||v,myReservedSeats:E,otherReservedSeats:F,unavailableSeats:M,reservedSeats:j,seatStates:p,lastUpdated:R,refetch:f}}exports.DEFAULT_COLORS=je;exports.SeatMapViewer=it;exports.clearFirebaseInstance=ct;exports.initializeFirebaseForViewer=at;exports.isFirebaseInitialized=ce;exports.useConfigFetcher=we;exports.useContainerSize=Ce;exports.useFirebaseConfig=Te;exports.useFirebaseSeatStates=Le;exports.useRealtimeSeatMap=ut;exports.useTouchGestures=Re;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),t=require("react"),X=require("react-konva"),W=require("firebase/database"),at=require("@zonetrix/shared");function Ce(n){const[s,a]=t.useState(null),[r,h]=t.useState(!1),[u,o]=t.useState(null),v=async()=>{if(n){h(!0),o(null);try{const f=await fetch(n);if(!f.ok)throw new Error(`Failed to fetch config: ${f.statusText}`);const l=await f.json();a(l)}catch(f){const l=f instanceof Error?f:new Error("Unknown error occurred");o(l),console.error("Failed to fetch seat map config:",l)}finally{h(!1)}}};return t.useEffect(()=>{v()},[n]),{config:s,loading:r,error:u,refetch:v}}function Re(n){const[s,a]=t.useState({width:0,height:0});return t.useEffect(()=>{const r=n.current;if(!r)return;const{width:h,height:u}=r.getBoundingClientRect();h>0&&u>0&&a({width:h,height:u});const o=new ResizeObserver(v=>{const f=v[0];if(!f)return;const{width:l,height:c}=f.contentRect;l>0&&c>0&&a(g=>g.width===l&&g.height===c?g:{width:l,height:c})});return o.observe(r),()=>{o.disconnect()}},[n]),s}function me(n,s){return Math.sqrt(Math.pow(s.x-n.x,2)+Math.pow(s.y-n.y,2))}function we(n,s){return{x:(n.x+s.x)/2,y:(n.y+s.y)/2}}function je(n,s){const a=t.useRef(null),r=t.useRef(null),h=t.useRef(1);t.useEffect(()=>{const u=n.current;if(!u||!s.enabled)return;const o=u.container(),v=c=>{if(c.touches.length===2){c.preventDefault();const g={x:c.touches[0].clientX,y:c.touches[0].clientY},p={x:c.touches[1].clientX,y:c.touches[1].clientY};a.current=me(g,p),r.current=we(g,p),h.current=s.currentScale}},f=c=>{if(c.touches.length!==2)return;c.preventDefault();const g={x:c.touches[0].clientX,y:c.touches[0].clientY},p={x:c.touches[1].clientX,y:c.touches[1].clientY},m=me(g,p),x=we(g,p);if(a.current!==null&&r.current!==null){const R=m/a.current,E=Math.min(Math.max(s.currentScale*R,s.minScale),s.maxScale),F=o.getBoundingClientRect(),j=x.x-F.left,M=x.y-F.top,D=s.currentScale,L={x:(j-s.currentPosition.x)/D,y:(M-s.currentPosition.y)/D},z=x.x-r.current.x,A=x.y-r.current.y,$={x:j-L.x*E+z,y:M-L.y*E+A};s.onScaleChange(E,$),a.current=m,r.current=x}},l=c=>{c.touches.length<2&&(a.current=null,r.current=null)};return o.addEventListener("touchstart",v,{passive:!1}),o.addEventListener("touchmove",f,{passive:!1}),o.addEventListener("touchend",l),()=>{o.removeEventListener("touchstart",v),o.removeEventListener("touchmove",f),o.removeEventListener("touchend",l)}},[n,s])}const Me={canvasBackground:"#1a1a1a",stageColor:"#808080",seatAvailable:"#2C2B30",seatReserved:"#FCEA00",seatSelected:"#3A7DE5",seatUnavailable:"#6b7280",seatHidden:"#4a4a4a",gridLines:"#404040",currency:"KD"},Ee=t.memo(({seat:n,state:s,colors:a,onClick:r,onMouseEnter:h,onMouseLeave:u})=>{const f={available:a.seatAvailable,reserved:a.seatReserved,selected:a.seatSelected,unavailable:a.seatUnavailable,hidden:a.seatHidden}[s],l=s==="available"||s==="selected",c=t.useCallback(()=>{l&&r(n)},[n,r,l]),g=t.useCallback(x=>{h(n,x);const R=x.target.getStage();R&&l&&(R.container().style.cursor="pointer")},[n,h,l]),p=t.useCallback(x=>{u();const R=x.target.getStage();R&&(R.container().style.cursor="grab")},[u]),m={x:n.position.x,y:n.position.y,fill:f,stroke:"#ffffff",strokeWidth:1,onClick:c,onTap:c,onMouseEnter:g,onMouseLeave:p};return n.shape==="circle"?i.jsx(X.Circle,{...m,radius:12}):i.jsx(X.Rect,{...m,width:24,height:24,offsetX:12,offsetY:12,cornerRadius:n.shape==="square"?0:4})});Ee.displayName="ViewerSeat";const Fe=t.memo(({stage:n,stageColor:s})=>{const a=u=>({stage:"🎭",table:"⬜",wall:"▬",barrier:"🛡️","dj-booth":"🎵",bar:"🍷","entry-exit":"🚪",custom:"➕"})[u||"stage"]||"🎭",r=n.config.color||s,h=a(n.config.objectType);return i.jsxs(X.Group,{x:n.position.x,y:n.position.y,rotation:n.config.rotation||0,children:[i.jsx(X.Rect,{width:n.config.width,height:n.config.height,fill:r+"80",stroke:"#ffffff",strokeWidth:2,cornerRadius:10}),i.jsx(X.Text,{text:h,x:0,y:0,width:n.config.width,height:n.config.height*.4,fontSize:32,fill:"#ffffff",align:"center",verticalAlign:"middle"}),i.jsx(X.Text,{text:n.config.label,x:0,y:n.config.height*.4,width:n.config.width,height:n.config.height*.6,fontSize:20,fontStyle:"bold",fill:"#ffffff",align:"center",verticalAlign:"middle"})]})});Fe.displayName="ViewerStage";const ke=t.memo(({floors:n,currentFloorId:s,onFloorChange:a,showAllOption:r,allLabel:h,position:u,className:o})=>{const v=t.useMemo(()=>[...n].sort((p,m)=>p.order-m.order),[n]),l={position:"absolute",display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",backgroundColor:"rgba(26, 26, 26, 0.95)",borderRadius:"8px",margin:"12px",zIndex:10,...{"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0}}[u]},c={padding:"10px 16px",fontSize:"14px",fontWeight:500,border:"1px solid #444",borderRadius:"6px",backgroundColor:"transparent",color:"#fff",cursor:"pointer",transition:"all 0.2s ease",minHeight:"44px",touchAction:"manipulation"},g={...c,backgroundColor:"#3A7DE5",borderColor:"#3A7DE5"};return i.jsxs("div",{className:o,style:l,children:[r&&i.jsx("button",{type:"button",onClick:()=>a(null),style:s===null?g:c,children:h}),v.map(p=>i.jsx("button",{type:"button",onClick:()=>a(p.id),style:s===p.id?g:c,children:p.name},p.id))]})});ke.displayName="FloorSelectorBar";const Ie=t.memo(({scale:n,minScale:s,maxScale:a,onZoomIn:r,onZoomOut:h,position:u,className:o})=>{const f={position:"absolute",display:"flex",flexDirection:"column",gap:"4px",padding:"8px",backgroundColor:"rgba(26, 26, 26, 0.95)",borderRadius:"8px",margin:"12px",zIndex:10,...{"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0}}[u]},l={width:"44px",height:"44px",minWidth:"44px",minHeight:"44px",fontSize:"22px",fontWeight:"bold",border:"1px solid #444",borderRadius:"6px",backgroundColor:"transparent",color:"#fff",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease",touchAction:"manipulation"},c={...l,opacity:.4,cursor:"not-allowed"},g=n<a,p=n>s;return i.jsxs("div",{className:o,style:f,children:[i.jsx("button",{type:"button",onClick:r,disabled:!g,style:g?l:c,title:"Zoom In",children:"+"}),i.jsx("button",{type:"button",onClick:h,disabled:!p,style:p?l:c,title:"Zoom Out",children:"−"})]})});Ie.displayName="ZoomControls";const Le=t.memo(({visible:n,x:s,y:a,seat:r,currency:h,state:u})=>{if(!n||!r)return null;const o=r.seatNumber||(r.rowLabel&&r.columnLabel?`${r.rowLabel}-${r.columnLabel}`:"N/A"),v={position:"fixed",left:`${s+15}px`,top:`${a+15}px`,zIndex:1e3,pointerEvents:"none"},f={backgroundColor:"rgba(26, 26, 26, 0.95)",color:"#fff",border:"1px solid #444",borderRadius:"8px",padding:"8px 12px",fontSize:"13px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.3)",minWidth:"140px"},l={color:"#9ca3af",marginRight:"4px"},c={fontWeight:600},g={color:"#4ade80",fontWeight:600},p={fontSize:"11px",color:"#6b7280",textTransform:"capitalize",marginTop:"4px"};return i.jsx("div",{style:v,children:i.jsxs("div",{style:f,children:[r.sectionName&&i.jsxs("div",{style:{marginBottom:"4px"},children:[i.jsx("span",{style:l,children:"Section:"}),i.jsx("span",{style:{...c,color:"#3b82f6"},children:r.sectionName})]}),i.jsxs("div",{style:{marginBottom:"4px"},children:[i.jsx("span",{style:l,children:"Seat:"}),i.jsx("span",{style:c,children:o})]}),r.price!==void 0&&r.price>0&&u==="available"&&i.jsxs("div",{style:{marginBottom:"4px"},children:[i.jsx("span",{style:l,children:"Price:"}),i.jsxs("span",{style:g,children:[h," ",r.price.toFixed(2)]})]}),i.jsxs("div",{style:p,children:["Status: ",u]})]})})});Le.displayName="SeatTooltip";const ct=({config:n,configUrl:s,floorId:a,onFloorChange:r,reservedSeats:h=[],otherReservedSeats:u,unavailableSeats:o=[],selectedSeats:v,myReservedSeats:f=[],onSeatSelect:l,onSeatDeselect:c,onSelectionChange:g,colorOverrides:p,showTooltip:m=!0,zoomEnabled:x=!0,className:R="",onConfigLoad:E,onError:F,showFloorSelector:j,floorSelectorPosition:M="top-left",floorSelectorClassName:D,showAllFloorsOption:L=!0,allFloorsLabel:z="All",fitToView:A=!0,fitPadding:$=40,showZoomControls:ze=!0,zoomControlsPosition:Ne="bottom-right",zoomControlsClassName:Ae,minZoom:be,maxZoom:Y=3,zoomStep:ee=.25,touchEnabled:Xe=!0})=>{const te=u!==void 0?u:h;console.log("🔍 ZonetrixViewer received props:",{reservedSeats:h,otherReservedSeats:u,effectiveOtherReservedSeats:te,myReservedSeats:f,unavailableSeats:o});const ue=t.useRef(null),Se=t.useRef(null),k=Re(Se),[U,ye]=t.useState(new Set),[I,q]=t.useState(1),[T,B]=t.useState({x:0,y:0}),[Ye,Pe]=t.useState(null),[We,Be]=t.useState(1),ne=t.useRef({width:0,height:0}),[_,ve]=t.useState({visible:!1,x:0,y:0,seat:null,state:"available"}),{config:Oe,loading:$e,error:G}=Ce(s),b=n||Oe,de=a!==void 0,N=de?a||null:Ye,se=v!==void 0,Ue=t.useCallback(e=>{de||Pe(e),r?.(e)},[de,r]),he=b?.floors||[],Ve=j!==void 0?j:he.length>1,re=t.useMemo(()=>b?{...b.colors,...p}:{...Me,...p},[b,p]),V=t.useMemo(()=>{if(!b)return[];let e=b.seats.filter(d=>d.state!=="hidden");return N&&(e=e.filter(d=>d.floorId===N||!d.floorId&&N==="floor_default")),e},[b,N]),oe=t.useMemo(()=>b?.stages?N?b.stages.filter(e=>e.floorId===N||!e.floorId&&N==="floor_default"):b.stages:[],[b,N]),P=t.useMemo(()=>{if(!b||V.length===0&&oe.length===0)return null;const e=12;let d=1/0,S=1/0,y=-1/0,w=-1/0;return V.forEach(C=>{d=Math.min(d,C.position.x-e),S=Math.min(S,C.position.y-e),y=Math.max(y,C.position.x+e),w=Math.max(w,C.position.y+e)}),oe.forEach(C=>{d=Math.min(d,C.position.x),S=Math.min(S,C.position.y),y=Math.max(y,C.position.x+(C.config?.width||200)),w=Math.max(w,C.position.y+(C.config?.height||100))}),{minX:d,minY:S,maxX:y,maxY:w,width:y-d,height:w-S}},[b,V,oe]);t.useEffect(()=>{if(!A||!b||!P||k.width===0||k.height===0)return;const e=Math.abs(k.width-ne.current.width),d=Math.abs(k.height-ne.current.height);if(!(ne.current.width===0)&&e<10&&d<10)return;ne.current=k;const y=k.width,w=k.height,C=y-$*2,J=w-$*2,ie=C/P.width,ge=J/P.height,ae=Math.min(ie,ge,Y),tt=P.minX+P.width/2,nt=P.minY+P.height/2,st=y/2,rt=w/2,ot=st-tt*ae,it=rt-nt*ae;q(ae),B({x:ot,y:it}),Be(ae)},[A,b,P,$,Y,k,N]);const O=t.useMemo(()=>{console.log("🔍 Creating seatStateOverrides:",{effectiveOtherReservedSeats:te,myReservedSeats:f,unavailableSeats:o});const e=new Set(te),d=new Set(o),S=new Set(f);return{reserved:e,unavailable:d,myReserved:S}},[te,o,f]),fe=t.useMemo(()=>v?new Set(v):null,[v]),Z=t.useCallback(e=>{const d=e.id,S=e.seatNumber||"";return O.unavailable.has(d)||O.unavailable.has(S)?"unavailable":O.reserved.has(d)||O.reserved.has(S)?"reserved":O.myReserved.has(d)||O.myReserved.has(S)||U.has(d)?"selected":e.state},[O,U]);t.useEffect(()=>{b&&E&&E(b)},[b,E]),t.useEffect(()=>{G&&F&&F(G)},[G,F]),t.useEffect(()=>{se&&fe&&ye(fe)},[se,fe]);const He=t.useCallback(e=>{const d=Z(e);if(d!=="available"&&d!=="selected")return;const S=U.has(e.id);se||ye(y=>{const w=new Set(y);return S?w.delete(e.id):w.add(e.id),w}),S?c?.(e):(l?.(e),l||console.log("Seat selected:",e))},[Z,U,se,l,c]),K=t.useMemo(()=>b?V.filter(e=>U.has(e.id)):[],[V,U]);t.useEffect(()=>{g?.(K)},[K,g]);const H=be!==void 0?be:We,qe=t.useCallback(()=>{if(!x)return;const e=Math.min(I+ee,Y);if(e!==I){const d=k.width||b?.canvas.width||800,S=k.height||b?.canvas.height||600,y=d/2,w=S/2,C={x:(y-T.x)/I,y:(w-T.y)/I};q(e),B({x:y-C.x*e,y:w-C.y*e})}},[x,I,ee,Y,k,b,T]),_e=t.useCallback(()=>{if(!x)return;const e=Math.max(I-ee,H);if(e!==I){const d=k.width||b?.canvas.width||800,S=k.height||b?.canvas.height||600,y=d/2,w=S/2,C={x:(y-T.x)/I,y:(w-T.y)/I};q(e),B({x:y-C.x*e,y:w-C.y*e})}},[x,I,ee,H,k,b,T]),Ge=t.useCallback(e=>{B({x:e.target.x(),y:e.target.y()})},[]),Ze=t.useCallback(e=>{if(!x)return;e.evt.preventDefault();const d=ue.current;if(!d)return;const S=d.scaleX(),y=d.getPointerPosition();if(!y)return;const w=1.1,C=e.evt.deltaY>0?S/w:S*w,J=Math.min(Math.max(C,H),Y),ie={x:(y.x-T.x)/S,y:(y.y-T.y)/S},ge={x:y.x-ie.x*J,y:y.y-ie.y*J};q(J),B(ge)},[x,T,H,Y]);je(ue,{enabled:Xe&&x,minScale:H,maxScale:Y,currentScale:I,currentPosition:T,onScaleChange:(e,d)=>{q(e),B(d)},onPositionChange:e=>{B(e)}});const Ke=t.useCallback((e,d)=>{if(!m)return;const S=d.target.getStage();if(!S)return;const y=S.getPointerPosition();if(!y)return;const w=S.container().getBoundingClientRect();ve({visible:!0,x:w.left+y.x,y:w.top+y.y,seat:e,state:Z(e)})},[m,Z]),Je=t.useCallback(()=>{ve(e=>({...e,visible:!1}))},[]);if($e)return i.jsx("div",{className:`flex items-center justify-center h-full ${R}`,children:i.jsx("p",{children:"Loading seat map..."})});if(G)return i.jsx("div",{className:`flex items-center justify-center h-full ${R}`,children:i.jsxs("p",{className:"text-red-500",children:["Error loading seat map: ",G.message]})});if(!b)return i.jsx("div",{className:`flex items-center justify-center h-full ${R}`,children:i.jsx("p",{children:"No configuration provided"})});const Qe=k.width||b.canvas.width,et=k.height||b.canvas.height;return i.jsxs("div",{ref:Se,className:`relative ${R}`,style:{width:"100%",height:"100%"},children:[Ve&&he.length>0&&i.jsx(ke,{floors:he,currentFloorId:N,onFloorChange:Ue,showAllOption:L,allLabel:z,position:M,className:D}),i.jsxs(X.Stage,{ref:ue,width:Qe,height:et,scaleX:I,scaleY:I,x:T.x,y:T.y,draggable:!0,onDragEnd:Ge,onWheel:Ze,style:{backgroundColor:b.canvas.backgroundColor,cursor:"grab"},children:[i.jsx(X.Layer,{listening:!1,children:oe.map(e=>i.jsx(Fe,{stage:e,stageColor:re.stageColor},e.id))}),i.jsx(X.Layer,{children:V.map(e=>i.jsx(Ee,{seat:e,state:Z(e),colors:re,onClick:He,onMouseEnter:Ke,onMouseLeave:Je},e.id))})]}),m&&i.jsx(Le,{visible:_.visible,x:_.x,y:_.y,seat:_.seat,currency:re.currency,state:_.state}),ze&&x&&i.jsx(Ie,{scale:I,minScale:H,maxScale:Y,onZoomIn:qe,onZoomOut:_e,position:Ne,className:Ae}),K.length>0&&i.jsxs("div",{className:"absolute top-4 right-4 bg-white dark:bg-gray-800 p-4 rounded shadow-lg",children:[i.jsxs("h3",{className:"font-semibold mb-2",children:["Selected Seats (",K.length,")"]}),i.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:K.map(e=>i.jsxs("div",{className:"text-sm",children:[e.seatNumber,e.price&&` - ${re.currency} ${e.price.toFixed(2)}`]},e.id))})]})]})};let Q=null;function lt(n){Q=n}function xe(){if(!Q)throw new Error("Firebase database not initialized. Call initializeFirebaseForViewer(db) first.");return Q}function le(){return Q!==null}function ut(){Q=null}function pe(n,s){if(n.length!==s.length)return!1;const a=[...n].sort(),r=[...s].sort();return a.every((h,u)=>h===r[u])}function dt(n,s){const a=[],r=[],h=[];return Object.entries(n).forEach(([u,o])=>{o&&typeof o=="object"&&o.state&&(o.state==="unavailable"?h.push(u):o.state==="reserved"&&(s&&o.userId===s?a.push(u):r.push(u)))}),{myReserved:a.sort(),otherReserved:r.sort(),unavailable:h.sort()}}const ce={states:null,loading:!0,error:null,lastUpdated:null,myReservedSeats:[],otherReservedSeats:[],unavailableSeats:[]};function Te(n){const{seatMapId:s,currentUserId:a,enabled:r=!0,onStateChange:h,onError:u}=n,o=t.useRef({...ce}),v=t.useRef(h),f=t.useRef(u),l=t.useRef(a);v.current=h,f.current=u,l.current=a;const c=t.useCallback(x=>{if(!r||!s)return(o.current.loading!==!1||o.current.states!==null)&&(o.current={...ce,loading:!1},x()),()=>{};if(!le()){const M="Firebase not initialized. Call initializeFirebaseForViewer first.";return o.current.error?.message!==M&&(o.current={...ce,loading:!1,error:new Error(M)},x()),()=>{}}const R=xe(),E=W.ref(R,`seatmaps/${s}/seat_states`),F=M=>{const L=M.val()||{},z=dt(L,l.current),A=o.current;(A.loading||!pe(A.myReservedSeats,z.myReserved)||!pe(A.otherReservedSeats,z.otherReserved)||!pe(A.unavailableSeats,z.unavailable))&&(o.current={states:L,loading:!1,error:null,lastUpdated:Date.now(),myReservedSeats:z.myReserved,otherReservedSeats:z.otherReserved,unavailableSeats:z.unavailable},v.current?.(L),x())},j=M=>{o.current={...o.current,loading:!1,error:M},f.current?.(M),x()};return W.onValue(E,F,j),()=>{W.off(E)}},[s,r]),g=t.useCallback(()=>o.current,[]),p=t.useCallback(()=>ce,[]),m=t.useSyncExternalStore(c,g,p);return{states:m.states,loading:m.loading,error:m.error,lastUpdated:m.lastUpdated,myReservedSeats:m.myReservedSeats,otherReservedSeats:m.otherReservedSeats,unavailableSeats:m.unavailableSeats,reservedSeats:m.otherReservedSeats}}function De(n){const{seatMapId:s,enabled:a=!0,subscribeToChanges:r=!1,onConfigLoad:h,onError:u}=n,[o,v]=t.useState(null),[f,l]=t.useState(!0),[c,g]=t.useState(null),p=t.useRef(h),m=t.useRef(u);p.current=h,m.current=u;const x=t.useCallback(async()=>{if(!s)return;if(!le()){g(new Error("Firebase not initialized. Call initializeFirebaseForViewer first.")),l(!1);return}const R=xe(),E=W.ref(R,`seatmaps/${s}`);try{l(!0),g(null);const j=(await W.get(E)).val();if(j){const M=at.fromFirebaseSeatMap(j);v(M),p.current?.(M)}else g(new Error(`Seat map ${s} not found in Firebase`))}catch(F){const j=F instanceof Error?F:new Error("Unknown error");g(j),m.current?.(j)}finally{l(!1)}},[s]);return t.useEffect(()=>{if(!a||!s){l(!1);return}if(x(),r&&le()){const R=xe(),E=W.ref(R,`seatmaps/${s}/meta/updated_at`);let F=!0,j=null;const M=D=>{if(F){F=!1,j=D.val();return}const L=D.val();D.exists()&&L!==j&&(j=L,x())};return W.onValue(E,M),()=>{W.off(E)}}},[s,a,r]),{config:o,loading:f,error:c,refetch:x}}function ht(n){const{seatMapId:s,userId:a,enabled:r=!0,subscribeToDesignChanges:h=!1,onConfigLoad:u,onStateChange:o,onError:v}=n,{config:f,loading:l,error:c,refetch:g}=De({seatMapId:s,enabled:r,subscribeToChanges:h,onConfigLoad:u,onError:v}),{states:p,loading:m,error:x,lastUpdated:R,myReservedSeats:E,otherReservedSeats:F,unavailableSeats:j,reservedSeats:M}=Te({seatMapId:s,currentUserId:a,enabled:r,onStateChange:o,onError:v});return{config:f,loading:l||m,error:c||x,myReservedSeats:E,otherReservedSeats:F,unavailableSeats:j,reservedSeats:M,seatStates:p,lastUpdated:R,refetch:g}}exports.DEFAULT_COLORS=Me;exports.SeatMapViewer=ct;exports.clearFirebaseInstance=ut;exports.initializeFirebaseForViewer=lt;exports.isFirebaseInitialized=le;exports.useConfigFetcher=Ce;exports.useContainerSize=Re;exports.useFirebaseConfig=De;exports.useFirebaseSeatStates=Te;exports.useRealtimeSeatMap=ht;exports.useTouchGestures=je;
package/dist/index.mjs CHANGED
@@ -1,20 +1,20 @@
1
- import { jsx as y, jsxs as D } from "react/jsx-runtime";
2
- import { useState as T, useEffect as W, useRef as A, useCallback as F, useMemo as U, memo as ne, useSyncExternalStore as lt } from "react";
3
- import { Stage as dt, Layer as Me, Group as ut, Rect as Le, Text as Ee, Circle as ht } from "react-konva";
4
- import { ref as ve, onValue as De, off as Ne, get as ft } from "firebase/database";
5
- import { fromFirebaseSeatMap as gt } from "@zonetrix/shared";
6
- function pt(t) {
7
- const [n, i] = T(null), [r, d] = T(!1), [c, o] = T(null), x = async () => {
1
+ import { jsx as v, jsxs as D } from "react/jsx-runtime";
2
+ import { useState as T, useEffect as W, useRef as A, useCallback as L, useMemo as U, memo as re, useSyncExternalStore as ut } from "react";
3
+ import { Stage as ht, Layer as Ee, Group as ft, Rect as De, Text as Ie, Circle as gt } from "react-konva";
4
+ import { ref as me, onValue as Ne, off as Te, get as pt } from "firebase/database";
5
+ import { fromFirebaseSeatMap as bt } from "@zonetrix/shared";
6
+ function vt(t) {
7
+ const [n, i] = T(null), [r, d] = T(!1), [c, o] = T(null), m = async () => {
8
8
  if (t) {
9
9
  d(!0), o(null);
10
10
  try {
11
- const h = await fetch(t);
12
- if (!h.ok)
13
- throw new Error(`Failed to fetch config: ${h.statusText}`);
14
- const a = await h.json();
11
+ const u = await fetch(t);
12
+ if (!u.ok)
13
+ throw new Error(`Failed to fetch config: ${u.statusText}`);
14
+ const a = await u.json();
15
15
  i(a);
16
- } catch (h) {
17
- const a = h instanceof Error ? h : new Error("Unknown error occurred");
16
+ } catch (u) {
17
+ const a = u instanceof Error ? u : new Error("Unknown error occurred");
18
18
  o(a), console.error("Failed to fetch seat map config:", a);
19
19
  } finally {
20
20
  d(!1);
@@ -22,78 +22,78 @@ function pt(t) {
22
22
  }
23
23
  };
24
24
  return W(() => {
25
- x();
25
+ m();
26
26
  }, [t]), {
27
27
  config: n,
28
28
  loading: r,
29
29
  error: c,
30
- refetch: x
30
+ refetch: m
31
31
  };
32
32
  }
33
- function bt(t) {
33
+ function yt(t) {
34
34
  const [n, i] = T({ width: 0, height: 0 });
35
35
  return W(() => {
36
36
  const r = t.current;
37
37
  if (!r) return;
38
38
  const { width: d, height: c } = r.getBoundingClientRect();
39
39
  d > 0 && c > 0 && i({ width: d, height: c });
40
- const o = new ResizeObserver((x) => {
41
- const h = x[0];
42
- if (!h) return;
43
- const { width: a, height: s } = h.contentRect;
44
- a > 0 && s > 0 && i((u) => u.width === a && u.height === s ? u : { width: a, height: s });
40
+ const o = new ResizeObserver((m) => {
41
+ const u = m[0];
42
+ if (!u) return;
43
+ const { width: a, height: s } = u.contentRect;
44
+ a > 0 && s > 0 && i((h) => h.width === a && h.height === s ? h : { width: a, height: s });
45
45
  });
46
46
  return o.observe(r), () => {
47
47
  o.disconnect();
48
48
  };
49
49
  }, [t]), n;
50
50
  }
51
- function Ie(t, n) {
51
+ function Fe(t, n) {
52
52
  return Math.sqrt(Math.pow(n.x - t.x, 2) + Math.pow(n.y - t.y, 2));
53
53
  }
54
- function Fe(t, n) {
54
+ function Le(t, n) {
55
55
  return {
56
56
  x: (t.x + n.x) / 2,
57
57
  y: (t.y + n.y) / 2
58
58
  };
59
59
  }
60
- function yt(t, n) {
60
+ function mt(t, n) {
61
61
  const i = A(null), r = A(null), d = A(1);
62
62
  W(() => {
63
63
  const c = t.current;
64
64
  if (!c || !n.enabled) return;
65
- const o = c.container(), x = (s) => {
65
+ const o = c.container(), m = (s) => {
66
66
  if (s.touches.length === 2) {
67
67
  s.preventDefault();
68
- const u = { x: s.touches[0].clientX, y: s.touches[0].clientY }, f = { x: s.touches[1].clientX, y: s.touches[1].clientY };
69
- i.current = Ie(u, f), r.current = Fe(u, f), d.current = n.currentScale;
68
+ const h = { x: s.touches[0].clientX, y: s.touches[0].clientY }, f = { x: s.touches[1].clientX, y: s.touches[1].clientY };
69
+ i.current = Fe(h, f), r.current = Le(h, f), d.current = n.currentScale;
70
70
  }
71
- }, h = (s) => {
71
+ }, u = (s) => {
72
72
  if (s.touches.length !== 2) return;
73
73
  s.preventDefault();
74
- const u = { x: s.touches[0].clientX, y: s.touches[0].clientY }, f = { x: s.touches[1].clientX, y: s.touches[1].clientY }, g = Ie(u, f), m = Fe(u, f);
74
+ const h = { x: s.touches[0].clientX, y: s.touches[0].clientY }, f = { x: s.touches[1].clientX, y: s.touches[1].clientY }, S = Fe(h, f), g = Le(h, f);
75
75
  if (i.current !== null && r.current !== null) {
76
- const C = g / i.current, M = Math.min(
76
+ const C = S / i.current, E = Math.min(
77
77
  Math.max(n.currentScale * C, n.minScale),
78
78
  n.maxScale
79
- ), L = o.getBoundingClientRect(), E = m.x - L.left, R = m.y - L.top, Y = n.currentScale, k = {
80
- x: (E - n.currentPosition.x) / Y,
81
- y: (R - n.currentPosition.y) / Y
82
- }, X = m.x - r.current.x, j = m.y - r.current.y, re = {
83
- x: E - k.x * M + X,
84
- y: R - k.y * M + j
79
+ ), I = o.getBoundingClientRect(), R = g.x - I.left, M = g.y - I.top, X = n.currentScale, k = {
80
+ x: (R - n.currentPosition.x) / X,
81
+ y: (M - n.currentPosition.y) / X
82
+ }, Y = g.x - r.current.x, P = g.y - r.current.y, H = {
83
+ x: R - k.x * E + Y,
84
+ y: M - k.y * E + P
85
85
  };
86
- n.onScaleChange(M, re), i.current = g, r.current = m;
86
+ n.onScaleChange(E, H), i.current = S, r.current = g;
87
87
  }
88
88
  }, a = (s) => {
89
89
  s.touches.length < 2 && (i.current = null, r.current = null);
90
90
  };
91
- return o.addEventListener("touchstart", x, { passive: !1 }), o.addEventListener("touchmove", h, { passive: !1 }), o.addEventListener("touchend", a), () => {
92
- o.removeEventListener("touchstart", x), o.removeEventListener("touchmove", h), o.removeEventListener("touchend", a);
91
+ return o.addEventListener("touchstart", m, { passive: !1 }), o.addEventListener("touchmove", u, { passive: !1 }), o.addEventListener("touchend", a), () => {
92
+ o.removeEventListener("touchstart", m), o.removeEventListener("touchmove", u), o.removeEventListener("touchend", a);
93
93
  };
94
94
  }, [t, n]);
95
95
  }
96
- const vt = {
96
+ const St = {
97
97
  canvasBackground: "#1a1a1a",
98
98
  stageColor: "#808080",
99
99
  seatAvailable: "#2C2B30",
@@ -103,45 +103,45 @@ const vt = {
103
103
  seatHidden: "#4a4a4a",
104
104
  gridLines: "#404040",
105
105
  currency: "KD"
106
- }, Te = ne(({ seat: t, state: n, colors: i, onClick: r, onMouseEnter: d, onMouseLeave: c }) => {
107
- const h = {
106
+ }, ke = re(({ seat: t, state: n, colors: i, onClick: r, onMouseEnter: d, onMouseLeave: c }) => {
107
+ const u = {
108
108
  available: i.seatAvailable,
109
109
  reserved: i.seatReserved,
110
110
  selected: i.seatSelected,
111
111
  unavailable: i.seatUnavailable,
112
112
  hidden: i.seatHidden
113
113
  // Hidden seats are filtered out, but included for type safety
114
- }[n], a = n === "available" || n === "selected", s = F(() => {
114
+ }[n], a = n === "available" || n === "selected", s = L(() => {
115
115
  a && r(t);
116
- }, [t, r, a]), u = F((m) => {
117
- d(t, m);
118
- const C = m.target.getStage();
116
+ }, [t, r, a]), h = L((g) => {
117
+ d(t, g);
118
+ const C = g.target.getStage();
119
119
  C && a && (C.container().style.cursor = "pointer");
120
- }, [t, d, a]), f = F((m) => {
120
+ }, [t, d, a]), f = L((g) => {
121
121
  c();
122
- const C = m.target.getStage();
122
+ const C = g.target.getStage();
123
123
  C && (C.container().style.cursor = "grab");
124
- }, [c]), g = {
124
+ }, [c]), S = {
125
125
  x: t.position.x,
126
126
  y: t.position.y,
127
- fill: h,
127
+ fill: u,
128
128
  stroke: "#ffffff",
129
129
  strokeWidth: 1,
130
130
  onClick: s,
131
131
  onTap: s,
132
- onMouseEnter: u,
132
+ onMouseEnter: h,
133
133
  onMouseLeave: f
134
134
  };
135
- return t.shape === "circle" ? /* @__PURE__ */ y(
136
- ht,
135
+ return t.shape === "circle" ? /* @__PURE__ */ v(
136
+ gt,
137
137
  {
138
- ...g,
138
+ ...S,
139
139
  radius: 12
140
140
  }
141
- ) : /* @__PURE__ */ y(
142
- Le,
141
+ ) : /* @__PURE__ */ v(
142
+ De,
143
143
  {
144
- ...g,
144
+ ...S,
145
145
  width: 24,
146
146
  height: 24,
147
147
  offsetX: 12,
@@ -150,8 +150,8 @@ const vt = {
150
150
  }
151
151
  );
152
152
  });
153
- Te.displayName = "ViewerSeat";
154
- const ke = ne(({ stage: t, stageColor: n }) => {
153
+ ke.displayName = "ViewerSeat";
154
+ const ze = re(({ stage: t, stageColor: n }) => {
155
155
  const i = (c) => ({
156
156
  stage: "🎭",
157
157
  table: "⬜",
@@ -162,9 +162,9 @@ const ke = ne(({ stage: t, stageColor: n }) => {
162
162
  "entry-exit": "🚪",
163
163
  custom: "➕"
164
164
  })[c || "stage"] || "🎭", r = t.config.color || n, d = i(t.config.objectType);
165
- return /* @__PURE__ */ D(ut, { x: t.position.x, y: t.position.y, rotation: t.config.rotation || 0, children: [
166
- /* @__PURE__ */ y(
167
- Le,
165
+ return /* @__PURE__ */ D(ft, { x: t.position.x, y: t.position.y, rotation: t.config.rotation || 0, children: [
166
+ /* @__PURE__ */ v(
167
+ De,
168
168
  {
169
169
  width: t.config.width,
170
170
  height: t.config.height,
@@ -174,8 +174,8 @@ const ke = ne(({ stage: t, stageColor: n }) => {
174
174
  cornerRadius: 10
175
175
  }
176
176
  ),
177
- /* @__PURE__ */ y(
178
- Ee,
177
+ /* @__PURE__ */ v(
178
+ Ie,
179
179
  {
180
180
  text: d,
181
181
  x: 0,
@@ -188,8 +188,8 @@ const ke = ne(({ stage: t, stageColor: n }) => {
188
188
  verticalAlign: "middle"
189
189
  }
190
190
  ),
191
- /* @__PURE__ */ y(
192
- Ee,
191
+ /* @__PURE__ */ v(
192
+ Ie,
193
193
  {
194
194
  text: t.config.label,
195
195
  x: 0,
@@ -205,8 +205,8 @@ const ke = ne(({ stage: t, stageColor: n }) => {
205
205
  )
206
206
  ] });
207
207
  });
208
- ke.displayName = "ViewerStage";
209
- const ze = ne(({
208
+ ze.displayName = "ViewerStage";
209
+ const Ae = re(({
210
210
  floors: t,
211
211
  currentFloorId: n,
212
212
  onFloorChange: i,
@@ -215,8 +215,8 @@ const ze = ne(({
215
215
  position: c,
216
216
  className: o
217
217
  }) => {
218
- const x = U(
219
- () => [...t].sort((f, g) => f.order - g.order),
218
+ const m = U(
219
+ () => [...t].sort((f, S) => f.order - S.order),
220
220
  [t]
221
221
  ), a = {
222
222
  position: "absolute",
@@ -246,35 +246,35 @@ const ze = ne(({
246
246
  transition: "all 0.2s ease",
247
247
  minHeight: "44px",
248
248
  touchAction: "manipulation"
249
- }, u = {
249
+ }, h = {
250
250
  ...s,
251
251
  backgroundColor: "#3A7DE5",
252
252
  borderColor: "#3A7DE5"
253
253
  };
254
254
  return /* @__PURE__ */ D("div", { className: o, style: a, children: [
255
- r && /* @__PURE__ */ y(
255
+ r && /* @__PURE__ */ v(
256
256
  "button",
257
257
  {
258
258
  type: "button",
259
259
  onClick: () => i(null),
260
- style: n === null ? u : s,
260
+ style: n === null ? h : s,
261
261
  children: d
262
262
  }
263
263
  ),
264
- x.map((f) => /* @__PURE__ */ y(
264
+ m.map((f) => /* @__PURE__ */ v(
265
265
  "button",
266
266
  {
267
267
  type: "button",
268
268
  onClick: () => i(f.id),
269
- style: n === f.id ? u : s,
269
+ style: n === f.id ? h : s,
270
270
  children: f.name
271
271
  },
272
272
  f.id
273
273
  ))
274
274
  ] });
275
275
  });
276
- ze.displayName = "FloorSelectorBar";
277
- const Ae = ne(({
276
+ Ae.displayName = "FloorSelectorBar";
277
+ const Xe = re(({
278
278
  scale: t,
279
279
  minScale: n,
280
280
  maxScale: i,
@@ -283,7 +283,7 @@ const Ae = ne(({
283
283
  position: c,
284
284
  className: o
285
285
  }) => {
286
- const h = {
286
+ const u = {
287
287
  position: "absolute",
288
288
  display: "flex",
289
289
  flexDirection: "column",
@@ -320,20 +320,20 @@ const Ae = ne(({
320
320
  ...a,
321
321
  opacity: 0.4,
322
322
  cursor: "not-allowed"
323
- }, u = t < i, f = t > n;
324
- return /* @__PURE__ */ D("div", { className: o, style: h, children: [
325
- /* @__PURE__ */ y(
323
+ }, h = t < i, f = t > n;
324
+ return /* @__PURE__ */ D("div", { className: o, style: u, children: [
325
+ /* @__PURE__ */ v(
326
326
  "button",
327
327
  {
328
328
  type: "button",
329
329
  onClick: r,
330
- disabled: !u,
331
- style: u ? a : s,
330
+ disabled: !h,
331
+ style: h ? a : s,
332
332
  title: "Zoom In",
333
333
  children: "+"
334
334
  }
335
335
  ),
336
- /* @__PURE__ */ y(
336
+ /* @__PURE__ */ v(
337
337
  "button",
338
338
  {
339
339
  type: "button",
@@ -346,8 +346,8 @@ const Ae = ne(({
346
346
  )
347
347
  ] });
348
348
  });
349
- Ae.displayName = "ZoomControls";
350
- const Xe = ne(({
349
+ Xe.displayName = "ZoomControls";
350
+ const Ye = re(({
351
351
  visible: t,
352
352
  x: n,
353
353
  y: i,
@@ -356,13 +356,13 @@ const Xe = ne(({
356
356
  state: c
357
357
  }) => {
358
358
  if (!t || !r) return null;
359
- const o = r.seatNumber || (r.rowLabel && r.columnLabel ? `${r.rowLabel}-${r.columnLabel}` : "N/A"), x = {
359
+ const o = r.seatNumber || (r.rowLabel && r.columnLabel ? `${r.rowLabel}-${r.columnLabel}` : "N/A"), m = {
360
360
  position: "fixed",
361
361
  left: `${n + 15}px`,
362
362
  top: `${i + 15}px`,
363
363
  zIndex: 1e3,
364
364
  pointerEvents: "none"
365
- }, h = {
365
+ }, u = {
366
366
  backgroundColor: "rgba(26, 26, 26, 0.95)",
367
367
  color: "#fff",
368
368
  border: "1px solid #444",
@@ -376,7 +376,7 @@ const Xe = ne(({
376
376
  marginRight: "4px"
377
377
  }, s = {
378
378
  fontWeight: 600
379
- }, u = {
379
+ }, h = {
380
380
  color: "#4ade80",
381
381
  fontWeight: 600
382
382
  }, f = {
@@ -385,18 +385,18 @@ const Xe = ne(({
385
385
  textTransform: "capitalize",
386
386
  marginTop: "4px"
387
387
  };
388
- return /* @__PURE__ */ y("div", { style: x, children: /* @__PURE__ */ D("div", { style: h, children: [
388
+ return /* @__PURE__ */ v("div", { style: m, children: /* @__PURE__ */ D("div", { style: u, children: [
389
389
  r.sectionName && /* @__PURE__ */ D("div", { style: { marginBottom: "4px" }, children: [
390
- /* @__PURE__ */ y("span", { style: a, children: "Section:" }),
391
- /* @__PURE__ */ y("span", { style: { ...s, color: "#3b82f6" }, children: r.sectionName })
390
+ /* @__PURE__ */ v("span", { style: a, children: "Section:" }),
391
+ /* @__PURE__ */ v("span", { style: { ...s, color: "#3b82f6" }, children: r.sectionName })
392
392
  ] }),
393
393
  /* @__PURE__ */ D("div", { style: { marginBottom: "4px" }, children: [
394
- /* @__PURE__ */ y("span", { style: a, children: "Seat:" }),
395
- /* @__PURE__ */ y("span", { style: s, children: o })
394
+ /* @__PURE__ */ v("span", { style: a, children: "Seat:" }),
395
+ /* @__PURE__ */ v("span", { style: s, children: o })
396
396
  ] }),
397
397
  r.price !== void 0 && r.price > 0 && c === "available" && /* @__PURE__ */ D("div", { style: { marginBottom: "4px" }, children: [
398
- /* @__PURE__ */ y("span", { style: a, children: "Price:" }),
399
- /* @__PURE__ */ D("span", { style: u, children: [
398
+ /* @__PURE__ */ v("span", { style: a, children: "Price:" }),
399
+ /* @__PURE__ */ D("span", { style: h, children: [
400
400
  d,
401
401
  " ",
402
402
  r.price.toFixed(2)
@@ -408,307 +408,322 @@ const Xe = ne(({
408
408
  ] })
409
409
  ] }) });
410
410
  });
411
- Xe.displayName = "SeatTooltip";
412
- const It = ({
411
+ Ye.displayName = "SeatTooltip";
412
+ const Lt = ({
413
413
  config: t,
414
414
  configUrl: n,
415
415
  floorId: i,
416
416
  onFloorChange: r,
417
417
  reservedSeats: d = [],
418
- unavailableSeats: c = [],
419
- selectedSeats: o,
420
- myReservedSeats: x = [],
421
- onSeatSelect: h,
422
- onSeatDeselect: a,
423
- onSelectionChange: s,
424
- colorOverrides: u,
425
- showTooltip: f = !0,
418
+ otherReservedSeats: c,
419
+ // v2.4.0: New prop name (preferred)
420
+ unavailableSeats: o = [],
421
+ selectedSeats: m,
422
+ myReservedSeats: u = [],
423
+ onSeatSelect: a,
424
+ onSeatDeselect: s,
425
+ onSelectionChange: h,
426
+ colorOverrides: f,
427
+ showTooltip: S = !0,
426
428
  zoomEnabled: g = !0,
427
- className: m = "",
428
- onConfigLoad: C,
429
- onError: M,
429
+ className: C = "",
430
+ onConfigLoad: E,
431
+ onError: I,
430
432
  // Floor selector props
431
- showFloorSelector: L,
432
- floorSelectorPosition: E = "top-left",
433
- floorSelectorClassName: R,
434
- showAllFloorsOption: Y = !0,
435
- allFloorsLabel: k = "All",
436
- fitToView: X = !0,
437
- fitPadding: j = 40,
433
+ showFloorSelector: R,
434
+ floorSelectorPosition: M = "top-left",
435
+ floorSelectorClassName: X,
436
+ showAllFloorsOption: k = !0,
437
+ allFloorsLabel: Y = "All",
438
+ fitToView: P = !0,
439
+ fitPadding: H = 40,
438
440
  // Zoom controls
439
- showZoomControls: re = !0,
440
- zoomControlsPosition: Ye = "bottom-right",
441
- zoomControlsClassName: je,
442
- minZoom: xe,
441
+ showZoomControls: je = !0,
442
+ zoomControlsPosition: Pe = "bottom-right",
443
+ zoomControlsClassName: We,
444
+ minZoom: we,
443
445
  maxZoom: B = 3,
444
446
  zoomStep: oe = 0.25,
445
447
  // Touch gestures
446
- touchEnabled: Pe = !0
448
+ touchEnabled: Be = !0
447
449
  }) => {
448
- const he = A(null), we = A(null), I = bt(we), [O, Ce] = T(/* @__PURE__ */ new Set()), [N, G] = T(1), [z, H] = T({ x: 0, y: 0 }), [We, Be] = T(null), [$e, Ue] = T(1), ie = A({ width: 0, height: 0 }), [Z, Re] = T({ visible: !1, x: 0, y: 0, seat: null, state: "available" }), { config: He, loading: Ve, error: K } = pt(n), p = t || He, fe = i !== void 0, P = fe ? i || null : We, se = o !== void 0, Oe = F((e) => {
449
- fe || Be(e), r?.(e);
450
- }, [fe, r]), ge = p?.floors || [], _e = L !== void 0 ? L : ge.length > 1, ae = U(
451
- () => p ? { ...p.colors, ...u } : { ...vt, ...u },
452
- [p, u]
453
- ), _ = U(() => {
450
+ const ie = c !== void 0 ? c : d;
451
+ console.log("🔍 ZonetrixViewer received props:", {
452
+ reservedSeats: d,
453
+ otherReservedSeats: c,
454
+ effectiveOtherReservedSeats: ie,
455
+ myReservedSeats: u,
456
+ unavailableSeats: o
457
+ });
458
+ const fe = A(null), Ce = A(null), F = yt(Ce), [_, Re] = T(/* @__PURE__ */ new Set()), [N, G] = T(1), [z, O] = T({ x: 0, y: 0 }), [$e, Ue] = T(null), [Oe, Ve] = T(1), se = A({ width: 0, height: 0 }), [K, Me] = T({ visible: !1, x: 0, y: 0, seat: null, state: "available" }), { config: He, loading: _e, error: J } = vt(n), p = t || He, ge = i !== void 0, j = ge ? i || null : $e, ae = m !== void 0, qe = L((e) => {
459
+ ge || Ue(e), r?.(e);
460
+ }, [ge, r]), pe = p?.floors || [], Ze = R !== void 0 ? R : pe.length > 1, ce = U(
461
+ () => p ? { ...p.colors, ...f } : { ...St, ...f },
462
+ [p, f]
463
+ ), q = U(() => {
454
464
  if (!p) return [];
455
465
  let e = p.seats.filter((l) => l.state !== "hidden");
456
- return P && (e = e.filter(
457
- (l) => l.floorId === P || !l.floorId && P === "floor_default"
466
+ return j && (e = e.filter(
467
+ (l) => l.floorId === j || !l.floorId && j === "floor_default"
458
468
  )), e;
459
- }, [p, P]), ce = U(() => p?.stages ? P ? p.stages.filter(
460
- (e) => e.floorId === P || !e.floorId && P === "floor_default"
461
- ) : p.stages : [], [p, P]), $ = U(() => {
462
- if (!p || _.length === 0 && ce.length === 0)
469
+ }, [p, j]), le = U(() => p?.stages ? j ? p.stages.filter(
470
+ (e) => e.floorId === j || !e.floorId && j === "floor_default"
471
+ ) : p.stages : [], [p, j]), $ = U(() => {
472
+ if (!p || q.length === 0 && le.length === 0)
463
473
  return null;
464
474
  const e = 12;
465
- let l = 1 / 0, b = 1 / 0, v = -1 / 0, S = -1 / 0;
466
- return _.forEach((w) => {
467
- l = Math.min(l, w.position.x - e), b = Math.min(b, w.position.y - e), v = Math.max(v, w.position.x + e), S = Math.max(S, w.position.y + e);
468
- }), ce.forEach((w) => {
469
- l = Math.min(l, w.position.x), b = Math.min(b, w.position.y), v = Math.max(v, w.position.x + (w.config?.width || 200)), S = Math.max(S, w.position.y + (w.config?.height || 100));
470
- }), { minX: l, minY: b, maxX: v, maxY: S, width: v - l, height: S - b };
471
- }, [p, _, ce]);
475
+ let l = 1 / 0, b = 1 / 0, y = -1 / 0, x = -1 / 0;
476
+ return q.forEach((w) => {
477
+ l = Math.min(l, w.position.x - e), b = Math.min(b, w.position.y - e), y = Math.max(y, w.position.x + e), x = Math.max(x, w.position.y + e);
478
+ }), le.forEach((w) => {
479
+ l = Math.min(l, w.position.x), b = Math.min(b, w.position.y), y = Math.max(y, w.position.x + (w.config?.width || 200)), x = Math.max(x, w.position.y + (w.config?.height || 100));
480
+ }), { minX: l, minY: b, maxX: y, maxY: x, width: y - l, height: x - b };
481
+ }, [p, q, le]);
472
482
  W(() => {
473
- if (!X || !p || !$ || I.width === 0 || I.height === 0) return;
474
- const e = Math.abs(I.width - ie.current.width), l = Math.abs(I.height - ie.current.height);
475
- if (!(ie.current.width === 0) && e < 10 && l < 10) return;
476
- ie.current = I;
477
- const v = I.width, S = I.height, w = v - j * 2, ee = S - j * 2, le = w / $.width, be = ee / $.height, de = Math.min(le, be, B), rt = $.minX + $.width / 2, ot = $.minY + $.height / 2, it = v / 2, st = S / 2, at = it - rt * de, ct = st - ot * de;
478
- G(de), H({ x: at, y: ct }), Ue(de);
479
- }, [X, p, $, j, B, I, P]);
483
+ if (!P || !p || !$ || F.width === 0 || F.height === 0) return;
484
+ const e = Math.abs(F.width - se.current.width), l = Math.abs(F.height - se.current.height);
485
+ if (!(se.current.width === 0) && e < 10 && l < 10) return;
486
+ se.current = F;
487
+ const y = F.width, x = F.height, w = y - H * 2, te = x - H * 2, de = w / $.width, ve = te / $.height, ue = Math.min(de, ve, B), it = $.minX + $.width / 2, st = $.minY + $.height / 2, at = y / 2, ct = x / 2, lt = at - it * ue, dt = ct - st * ue;
488
+ G(ue), O({ x: lt, y: dt }), Ve(ue);
489
+ }, [P, p, $, H, B, F, j]);
480
490
  const V = U(() => {
481
- const e = new Set(d), l = new Set(c), b = new Set(x);
491
+ console.log("🔍 Creating seatStateOverrides:", {
492
+ effectiveOtherReservedSeats: ie,
493
+ myReservedSeats: u,
494
+ unavailableSeats: o
495
+ });
496
+ const e = new Set(ie), l = new Set(o), b = new Set(u);
482
497
  return { reserved: e, unavailable: l, myReserved: b };
483
- }, [d, c, x]), pe = U(() => o ? new Set(o) : null, [o]), J = F((e) => {
498
+ }, [ie, o, u]), be = U(() => m ? new Set(m) : null, [m]), Q = L((e) => {
484
499
  const l = e.id, b = e.seatNumber || "";
485
- return V.unavailable.has(l) || V.unavailable.has(b) ? "unavailable" : V.reserved.has(l) || V.reserved.has(b) ? "reserved" : V.myReserved.has(l) || V.myReserved.has(b) || O.has(l) ? "selected" : e.state;
486
- }, [V, O]);
500
+ return V.unavailable.has(l) || V.unavailable.has(b) ? "unavailable" : V.reserved.has(l) || V.reserved.has(b) ? "reserved" : V.myReserved.has(l) || V.myReserved.has(b) || _.has(l) ? "selected" : e.state;
501
+ }, [V, _]);
487
502
  W(() => {
488
- p && C && C(p);
489
- }, [p, C]), W(() => {
490
- K && M && M(K);
491
- }, [K, M]), W(() => {
492
- se && pe && Ce(pe);
493
- }, [se, pe]);
494
- const qe = F((e) => {
495
- const l = J(e);
503
+ p && E && E(p);
504
+ }, [p, E]), W(() => {
505
+ J && I && I(J);
506
+ }, [J, I]), W(() => {
507
+ ae && be && Re(be);
508
+ }, [ae, be]);
509
+ const Ge = L((e) => {
510
+ const l = Q(e);
496
511
  if (l !== "available" && l !== "selected")
497
512
  return;
498
- const b = O.has(e.id);
499
- se || Ce((v) => {
500
- const S = new Set(v);
501
- return b ? S.delete(e.id) : S.add(e.id), S;
502
- }), b ? a?.(e) : (h?.(e), h || console.log("Seat selected:", e));
503
- }, [J, O, se, h, a]), Q = U(() => p ? _.filter((e) => O.has(e.id)) : [], [_, O]);
513
+ const b = _.has(e.id);
514
+ ae || Re((y) => {
515
+ const x = new Set(y);
516
+ return b ? x.delete(e.id) : x.add(e.id), x;
517
+ }), b ? s?.(e) : (a?.(e), a || console.log("Seat selected:", e));
518
+ }, [Q, _, ae, a, s]), ee = U(() => p ? q.filter((e) => _.has(e.id)) : [], [q, _]);
504
519
  W(() => {
505
- s?.(Q);
506
- }, [Q, s]);
507
- const q = xe !== void 0 ? xe : $e, Ge = F(() => {
520
+ h?.(ee);
521
+ }, [ee, h]);
522
+ const Z = we !== void 0 ? we : Oe, Ke = L(() => {
508
523
  if (!g) return;
509
524
  const e = Math.min(N + oe, B);
510
525
  if (e !== N) {
511
- const l = I.width || p?.canvas.width || 800, b = I.height || p?.canvas.height || 600, v = l / 2, S = b / 2, w = {
512
- x: (v - z.x) / N,
513
- y: (S - z.y) / N
526
+ const l = F.width || p?.canvas.width || 800, b = F.height || p?.canvas.height || 600, y = l / 2, x = b / 2, w = {
527
+ x: (y - z.x) / N,
528
+ y: (x - z.y) / N
514
529
  };
515
- G(e), H({
516
- x: v - w.x * e,
517
- y: S - w.y * e
530
+ G(e), O({
531
+ x: y - w.x * e,
532
+ y: x - w.y * e
518
533
  });
519
534
  }
520
- }, [g, N, oe, B, I, p, z]), Ze = F(() => {
535
+ }, [g, N, oe, B, F, p, z]), Je = L(() => {
521
536
  if (!g) return;
522
- const e = Math.max(N - oe, q);
537
+ const e = Math.max(N - oe, Z);
523
538
  if (e !== N) {
524
- const l = I.width || p?.canvas.width || 800, b = I.height || p?.canvas.height || 600, v = l / 2, S = b / 2, w = {
525
- x: (v - z.x) / N,
526
- y: (S - z.y) / N
539
+ const l = F.width || p?.canvas.width || 800, b = F.height || p?.canvas.height || 600, y = l / 2, x = b / 2, w = {
540
+ x: (y - z.x) / N,
541
+ y: (x - z.y) / N
527
542
  };
528
- G(e), H({
529
- x: v - w.x * e,
530
- y: S - w.y * e
543
+ G(e), O({
544
+ x: y - w.x * e,
545
+ y: x - w.y * e
531
546
  });
532
547
  }
533
- }, [g, N, oe, q, I, p, z]), Ke = F((e) => {
534
- H({
548
+ }, [g, N, oe, Z, F, p, z]), Qe = L((e) => {
549
+ O({
535
550
  x: e.target.x(),
536
551
  y: e.target.y()
537
552
  });
538
- }, []), Je = F((e) => {
553
+ }, []), et = L((e) => {
539
554
  if (!g) return;
540
555
  e.evt.preventDefault();
541
- const l = he.current;
556
+ const l = fe.current;
542
557
  if (!l) return;
543
- const b = l.scaleX(), v = l.getPointerPosition();
544
- if (!v) return;
545
- const S = 1.1, w = e.evt.deltaY > 0 ? b / S : b * S, ee = Math.min(Math.max(w, q), B), le = {
546
- x: (v.x - z.x) / b,
547
- y: (v.y - z.y) / b
548
- }, be = {
549
- x: v.x - le.x * ee,
550
- y: v.y - le.y * ee
558
+ const b = l.scaleX(), y = l.getPointerPosition();
559
+ if (!y) return;
560
+ const x = 1.1, w = e.evt.deltaY > 0 ? b / x : b * x, te = Math.min(Math.max(w, Z), B), de = {
561
+ x: (y.x - z.x) / b,
562
+ y: (y.y - z.y) / b
563
+ }, ve = {
564
+ x: y.x - de.x * te,
565
+ y: y.y - de.y * te
551
566
  };
552
- G(ee), H(be);
553
- }, [g, z, q, B]);
554
- yt(he, {
555
- enabled: Pe && g,
556
- minScale: q,
567
+ G(te), O(ve);
568
+ }, [g, z, Z, B]);
569
+ mt(fe, {
570
+ enabled: Be && g,
571
+ minScale: Z,
557
572
  maxScale: B,
558
573
  currentScale: N,
559
574
  currentPosition: z,
560
575
  onScaleChange: (e, l) => {
561
- G(e), H(l);
576
+ G(e), O(l);
562
577
  },
563
578
  onPositionChange: (e) => {
564
- H(e);
579
+ O(e);
565
580
  }
566
581
  });
567
- const Qe = F((e, l) => {
568
- if (!f) return;
582
+ const tt = L((e, l) => {
583
+ if (!S) return;
569
584
  const b = l.target.getStage();
570
585
  if (!b) return;
571
- const v = b.getPointerPosition();
572
- if (!v) return;
573
- const S = b.container().getBoundingClientRect();
574
- Re({
586
+ const y = b.getPointerPosition();
587
+ if (!y) return;
588
+ const x = b.container().getBoundingClientRect();
589
+ Me({
575
590
  visible: !0,
576
- x: S.left + v.x,
577
- y: S.top + v.y,
591
+ x: x.left + y.x,
592
+ y: x.top + y.y,
578
593
  seat: e,
579
- state: J(e)
594
+ state: Q(e)
580
595
  });
581
- }, [f, J]), et = F(() => {
582
- Re((e) => ({ ...e, visible: !1 }));
596
+ }, [S, Q]), nt = L(() => {
597
+ Me((e) => ({ ...e, visible: !1 }));
583
598
  }, []);
584
- if (Ve)
585
- return /* @__PURE__ */ y("div", { className: `flex items-center justify-center h-full ${m}`, children: /* @__PURE__ */ y("p", { children: "Loading seat map..." }) });
586
- if (K)
587
- return /* @__PURE__ */ y("div", { className: `flex items-center justify-center h-full ${m}`, children: /* @__PURE__ */ D("p", { className: "text-red-500", children: [
599
+ if (_e)
600
+ return /* @__PURE__ */ v("div", { className: `flex items-center justify-center h-full ${C}`, children: /* @__PURE__ */ v("p", { children: "Loading seat map..." }) });
601
+ if (J)
602
+ return /* @__PURE__ */ v("div", { className: `flex items-center justify-center h-full ${C}`, children: /* @__PURE__ */ D("p", { className: "text-red-500", children: [
588
603
  "Error loading seat map: ",
589
- K.message
604
+ J.message
590
605
  ] }) });
591
606
  if (!p)
592
- return /* @__PURE__ */ y("div", { className: `flex items-center justify-center h-full ${m}`, children: /* @__PURE__ */ y("p", { children: "No configuration provided" }) });
593
- const tt = I.width || p.canvas.width, nt = I.height || p.canvas.height;
607
+ return /* @__PURE__ */ v("div", { className: `flex items-center justify-center h-full ${C}`, children: /* @__PURE__ */ v("p", { children: "No configuration provided" }) });
608
+ const rt = F.width || p.canvas.width, ot = F.height || p.canvas.height;
594
609
  return /* @__PURE__ */ D(
595
610
  "div",
596
611
  {
597
- ref: we,
598
- className: `relative ${m}`,
612
+ ref: Ce,
613
+ className: `relative ${C}`,
599
614
  style: { width: "100%", height: "100%" },
600
615
  children: [
601
- _e && ge.length > 0 && /* @__PURE__ */ y(
602
- ze,
616
+ Ze && pe.length > 0 && /* @__PURE__ */ v(
617
+ Ae,
603
618
  {
604
- floors: ge,
605
- currentFloorId: P,
606
- onFloorChange: Oe,
607
- showAllOption: Y,
608
- allLabel: k,
609
- position: E,
610
- className: R
619
+ floors: pe,
620
+ currentFloorId: j,
621
+ onFloorChange: qe,
622
+ showAllOption: k,
623
+ allLabel: Y,
624
+ position: M,
625
+ className: X
611
626
  }
612
627
  ),
613
628
  /* @__PURE__ */ D(
614
- dt,
629
+ ht,
615
630
  {
616
- ref: he,
617
- width: tt,
618
- height: nt,
631
+ ref: fe,
632
+ width: rt,
633
+ height: ot,
619
634
  scaleX: N,
620
635
  scaleY: N,
621
636
  x: z.x,
622
637
  y: z.y,
623
638
  draggable: !0,
624
- onDragEnd: Ke,
625
- onWheel: Je,
639
+ onDragEnd: Qe,
640
+ onWheel: et,
626
641
  style: { backgroundColor: p.canvas.backgroundColor, cursor: "grab" },
627
642
  children: [
628
- /* @__PURE__ */ y(Me, { listening: !1, children: ce.map((e) => /* @__PURE__ */ y(
629
- ke,
643
+ /* @__PURE__ */ v(Ee, { listening: !1, children: le.map((e) => /* @__PURE__ */ v(
644
+ ze,
630
645
  {
631
646
  stage: e,
632
- stageColor: ae.stageColor
647
+ stageColor: ce.stageColor
633
648
  },
634
649
  e.id
635
650
  )) }),
636
- /* @__PURE__ */ y(Me, { children: _.map((e) => /* @__PURE__ */ y(
637
- Te,
651
+ /* @__PURE__ */ v(Ee, { children: q.map((e) => /* @__PURE__ */ v(
652
+ ke,
638
653
  {
639
654
  seat: e,
640
- state: J(e),
641
- colors: ae,
642
- onClick: qe,
643
- onMouseEnter: Qe,
644
- onMouseLeave: et
655
+ state: Q(e),
656
+ colors: ce,
657
+ onClick: Ge,
658
+ onMouseEnter: tt,
659
+ onMouseLeave: nt
645
660
  },
646
661
  e.id
647
662
  )) })
648
663
  ]
649
664
  }
650
665
  ),
651
- f && /* @__PURE__ */ y(
652
- Xe,
666
+ S && /* @__PURE__ */ v(
667
+ Ye,
653
668
  {
654
- visible: Z.visible,
655
- x: Z.x,
656
- y: Z.y,
657
- seat: Z.seat,
658
- currency: ae.currency,
659
- state: Z.state
669
+ visible: K.visible,
670
+ x: K.x,
671
+ y: K.y,
672
+ seat: K.seat,
673
+ currency: ce.currency,
674
+ state: K.state
660
675
  }
661
676
  ),
662
- re && g && /* @__PURE__ */ y(
663
- Ae,
677
+ je && g && /* @__PURE__ */ v(
678
+ Xe,
664
679
  {
665
680
  scale: N,
666
- minScale: q,
681
+ minScale: Z,
667
682
  maxScale: B,
668
- onZoomIn: Ge,
669
- onZoomOut: Ze,
670
- position: Ye,
671
- className: je
683
+ onZoomIn: Ke,
684
+ onZoomOut: Je,
685
+ position: Pe,
686
+ className: We
672
687
  }
673
688
  ),
674
- Q.length > 0 && /* @__PURE__ */ D("div", { className: "absolute top-4 right-4 bg-white dark:bg-gray-800 p-4 rounded shadow-lg", children: [
689
+ ee.length > 0 && /* @__PURE__ */ D("div", { className: "absolute top-4 right-4 bg-white dark:bg-gray-800 p-4 rounded shadow-lg", children: [
675
690
  /* @__PURE__ */ D("h3", { className: "font-semibold mb-2", children: [
676
691
  "Selected Seats (",
677
- Q.length,
692
+ ee.length,
678
693
  ")"
679
694
  ] }),
680
- /* @__PURE__ */ y("div", { className: "max-h-48 overflow-y-auto space-y-1", children: Q.map((e) => /* @__PURE__ */ D("div", { className: "text-sm", children: [
695
+ /* @__PURE__ */ v("div", { className: "max-h-48 overflow-y-auto space-y-1", children: ee.map((e) => /* @__PURE__ */ D("div", { className: "text-sm", children: [
681
696
  e.seatNumber,
682
- e.price && ` - ${ae.currency} ${e.price.toFixed(2)}`
697
+ e.price && ` - ${ce.currency} ${e.price.toFixed(2)}`
683
698
  ] }, e.id)) })
684
699
  ] })
685
700
  ]
686
701
  }
687
702
  );
688
703
  };
689
- let te = null;
690
- function Ft(t) {
691
- te = t;
704
+ let ne = null;
705
+ function Dt(t) {
706
+ ne = t;
692
707
  }
693
- function me() {
694
- if (!te)
708
+ function Se() {
709
+ if (!ne)
695
710
  throw new Error(
696
711
  "Firebase database not initialized. Call initializeFirebaseForViewer(db) first."
697
712
  );
698
- return te;
713
+ return ne;
699
714
  }
700
- function Se() {
701
- return te !== null;
715
+ function xe() {
716
+ return ne !== null;
702
717
  }
703
- function Lt() {
704
- te = null;
718
+ function Nt() {
719
+ ne = null;
705
720
  }
706
721
  function ye(t, n) {
707
722
  if (t.length !== n.length) return !1;
708
723
  const i = [...t].sort(), r = [...n].sort();
709
724
  return i.every((d, c) => d === r[c]);
710
725
  }
711
- function mt(t, n) {
726
+ function xt(t, n) {
712
727
  const i = [], r = [], d = [];
713
728
  return Object.entries(t).forEach(([c, o]) => {
714
729
  o && typeof o == "object" && o.state && (o.state === "unavailable" ? d.push(c) : o.state === "reserved" && (n && o.userId === n ? i.push(c) : r.push(c)));
@@ -718,7 +733,7 @@ function mt(t, n) {
718
733
  unavailable: d.sort()
719
734
  };
720
735
  }
721
- const ue = {
736
+ const he = {
722
737
  states: null,
723
738
  loading: !0,
724
739
  error: null,
@@ -727,87 +742,87 @@ const ue = {
727
742
  otherReservedSeats: [],
728
743
  unavailableSeats: []
729
744
  };
730
- function St(t) {
731
- const { seatMapId: n, currentUserId: i, enabled: r = !0, onStateChange: d, onError: c } = t, o = A({ ...ue }), x = A(d), h = A(c), a = A(i);
732
- x.current = d, h.current = c, a.current = i;
733
- const s = F(
734
- (m) => {
745
+ function wt(t) {
746
+ const { seatMapId: n, currentUserId: i, enabled: r = !0, onStateChange: d, onError: c } = t, o = A({ ...he }), m = A(d), u = A(c), a = A(i);
747
+ m.current = d, u.current = c, a.current = i;
748
+ const s = L(
749
+ (g) => {
735
750
  if (!r || !n)
736
- return (o.current.loading !== !1 || o.current.states !== null) && (o.current = { ...ue, loading: !1 }, m()), () => {
751
+ return (o.current.loading !== !1 || o.current.states !== null) && (o.current = { ...he, loading: !1 }, g()), () => {
737
752
  };
738
- if (!Se()) {
739
- const R = "Firebase not initialized. Call initializeFirebaseForViewer first.";
740
- return o.current.error?.message !== R && (o.current = {
741
- ...ue,
753
+ if (!xe()) {
754
+ const M = "Firebase not initialized. Call initializeFirebaseForViewer first.";
755
+ return o.current.error?.message !== M && (o.current = {
756
+ ...he,
742
757
  loading: !1,
743
- error: new Error(R)
744
- }, m()), () => {
758
+ error: new Error(M)
759
+ }, g()), () => {
745
760
  };
746
761
  }
747
- const C = me(), M = ve(C, `seatmaps/${n}/seat_states`);
748
- return De(M, (R) => {
749
- const k = R.val() || {}, X = mt(k, a.current), j = o.current;
750
- (j.loading || !ye(j.myReservedSeats, X.myReserved) || !ye(j.otherReservedSeats, X.otherReserved) || !ye(j.unavailableSeats, X.unavailable)) && (o.current = {
762
+ const C = Se(), E = me(C, `seatmaps/${n}/seat_states`);
763
+ return Ne(E, (M) => {
764
+ const k = M.val() || {}, Y = xt(k, a.current), P = o.current;
765
+ (P.loading || !ye(P.myReservedSeats, Y.myReserved) || !ye(P.otherReservedSeats, Y.otherReserved) || !ye(P.unavailableSeats, Y.unavailable)) && (o.current = {
751
766
  states: k,
752
767
  loading: !1,
753
768
  error: null,
754
769
  lastUpdated: Date.now(),
755
- myReservedSeats: X.myReserved,
756
- otherReservedSeats: X.otherReserved,
757
- unavailableSeats: X.unavailable
758
- }, x.current?.(k), m());
759
- }, (R) => {
770
+ myReservedSeats: Y.myReserved,
771
+ otherReservedSeats: Y.otherReserved,
772
+ unavailableSeats: Y.unavailable
773
+ }, m.current?.(k), g());
774
+ }, (M) => {
760
775
  o.current = {
761
776
  ...o.current,
762
777
  loading: !1,
763
- error: R
764
- }, h.current?.(R), m();
778
+ error: M
779
+ }, u.current?.(M), g();
765
780
  }), () => {
766
- Ne(M);
781
+ Te(E);
767
782
  };
768
783
  },
769
784
  [n, r]
770
785
  // Don't include currentUserId - we use currentUserIdRef.current which is always up-to-date
771
- ), u = F(() => o.current, []), f = F(() => ue, []), g = lt(s, u, f);
786
+ ), h = L(() => o.current, []), f = L(() => he, []), S = ut(s, h, f);
772
787
  return {
773
- states: g.states,
774
- loading: g.loading,
775
- error: g.error,
776
- lastUpdated: g.lastUpdated,
777
- myReservedSeats: g.myReservedSeats,
778
- otherReservedSeats: g.otherReservedSeats,
779
- unavailableSeats: g.unavailableSeats,
788
+ states: S.states,
789
+ loading: S.loading,
790
+ error: S.error,
791
+ lastUpdated: S.lastUpdated,
792
+ myReservedSeats: S.myReservedSeats,
793
+ otherReservedSeats: S.otherReservedSeats,
794
+ unavailableSeats: S.unavailableSeats,
780
795
  // Legacy alias
781
- reservedSeats: g.otherReservedSeats
796
+ reservedSeats: S.otherReservedSeats
782
797
  };
783
798
  }
784
- function xt(t) {
799
+ function Ct(t) {
785
800
  const {
786
801
  seatMapId: n,
787
802
  enabled: i = !0,
788
803
  subscribeToChanges: r = !1,
789
804
  onConfigLoad: d,
790
805
  onError: c
791
- } = t, [o, x] = T(null), [h, a] = T(!0), [s, u] = T(null), f = A(d), g = A(c);
792
- f.current = d, g.current = c;
793
- const m = F(async () => {
806
+ } = t, [o, m] = T(null), [u, a] = T(!0), [s, h] = T(null), f = A(d), S = A(c);
807
+ f.current = d, S.current = c;
808
+ const g = L(async () => {
794
809
  if (!n) return;
795
- if (!Se()) {
796
- u(new Error("Firebase not initialized. Call initializeFirebaseForViewer first.")), a(!1);
810
+ if (!xe()) {
811
+ h(new Error("Firebase not initialized. Call initializeFirebaseForViewer first.")), a(!1);
797
812
  return;
798
813
  }
799
- const C = me(), M = ve(C, `seatmaps/${n}`);
814
+ const C = Se(), E = me(C, `seatmaps/${n}`);
800
815
  try {
801
- a(!0), u(null);
802
- const E = (await ft(M)).val();
803
- if (E) {
804
- const R = gt(E);
805
- x(R), f.current?.(R);
816
+ a(!0), h(null);
817
+ const R = (await pt(E)).val();
818
+ if (R) {
819
+ const M = bt(R);
820
+ m(M), f.current?.(M);
806
821
  } else
807
- u(new Error(`Seat map ${n} not found in Firebase`));
808
- } catch (L) {
809
- const E = L instanceof Error ? L : new Error("Unknown error");
810
- u(E), g.current?.(E);
822
+ h(new Error(`Seat map ${n} not found in Firebase`));
823
+ } catch (I) {
824
+ const R = I instanceof Error ? I : new Error("Unknown error");
825
+ h(R), S.current?.(R);
811
826
  } finally {
812
827
  a(!1);
813
828
  }
@@ -817,28 +832,28 @@ function xt(t) {
817
832
  a(!1);
818
833
  return;
819
834
  }
820
- if (m(), r && Se()) {
821
- const C = me(), M = ve(C, `seatmaps/${n}/meta/updated_at`);
822
- let L = !0, E = null;
823
- return De(M, (Y) => {
824
- if (L) {
825
- L = !1, E = Y.val();
835
+ if (g(), r && xe()) {
836
+ const C = Se(), E = me(C, `seatmaps/${n}/meta/updated_at`);
837
+ let I = !0, R = null;
838
+ return Ne(E, (X) => {
839
+ if (I) {
840
+ I = !1, R = X.val();
826
841
  return;
827
842
  }
828
- const k = Y.val();
829
- Y.exists() && k !== E && (E = k, m());
843
+ const k = X.val();
844
+ X.exists() && k !== R && (R = k, g());
830
845
  }), () => {
831
- Ne(M);
846
+ Te(E);
832
847
  };
833
848
  }
834
849
  }, [n, i, r]), {
835
850
  config: o,
836
- loading: h,
851
+ loading: u,
837
852
  error: s,
838
- refetch: m
853
+ refetch: g
839
854
  };
840
855
  }
841
- function Dt(t) {
856
+ function Tt(t) {
842
857
  const {
843
858
  seatMapId: n,
844
859
  userId: i,
@@ -846,57 +861,57 @@ function Dt(t) {
846
861
  subscribeToDesignChanges: d = !1,
847
862
  onConfigLoad: c,
848
863
  onStateChange: o,
849
- onError: x
864
+ onError: m
850
865
  } = t, {
851
- config: h,
866
+ config: u,
852
867
  loading: a,
853
868
  error: s,
854
- refetch: u
855
- } = xt({
869
+ refetch: h
870
+ } = Ct({
856
871
  seatMapId: n,
857
872
  enabled: r,
858
873
  subscribeToChanges: d,
859
874
  onConfigLoad: c,
860
- onError: x
875
+ onError: m
861
876
  }), {
862
877
  states: f,
863
- loading: g,
864
- error: m,
878
+ loading: S,
879
+ error: g,
865
880
  lastUpdated: C,
866
- myReservedSeats: M,
867
- otherReservedSeats: L,
868
- unavailableSeats: E,
869
- reservedSeats: R
870
- } = St({
881
+ myReservedSeats: E,
882
+ otherReservedSeats: I,
883
+ unavailableSeats: R,
884
+ reservedSeats: M
885
+ } = wt({
871
886
  seatMapId: n,
872
887
  currentUserId: i,
873
888
  enabled: r,
874
889
  onStateChange: o,
875
- onError: x
890
+ onError: m
876
891
  });
877
892
  return {
878
- config: h,
879
- loading: a || g,
880
- error: s || m,
881
- myReservedSeats: M,
882
- otherReservedSeats: L,
883
- unavailableSeats: E,
884
- reservedSeats: R,
893
+ config: u,
894
+ loading: a || S,
895
+ error: s || g,
896
+ myReservedSeats: E,
897
+ otherReservedSeats: I,
898
+ unavailableSeats: R,
899
+ reservedSeats: M,
885
900
  seatStates: f,
886
901
  lastUpdated: C,
887
- refetch: u
902
+ refetch: h
888
903
  };
889
904
  }
890
905
  export {
891
- vt as DEFAULT_COLORS,
892
- It as SeatMapViewer,
893
- Lt as clearFirebaseInstance,
894
- Ft as initializeFirebaseForViewer,
895
- Se as isFirebaseInitialized,
896
- pt as useConfigFetcher,
897
- bt as useContainerSize,
898
- xt as useFirebaseConfig,
899
- St as useFirebaseSeatStates,
900
- Dt as useRealtimeSeatMap,
901
- yt as useTouchGestures
906
+ St as DEFAULT_COLORS,
907
+ Lt as SeatMapViewer,
908
+ Nt as clearFirebaseInstance,
909
+ Dt as initializeFirebaseForViewer,
910
+ xe as isFirebaseInitialized,
911
+ vt as useConfigFetcher,
912
+ yt as useContainerSize,
913
+ Ct as useFirebaseConfig,
914
+ wt as useFirebaseSeatStates,
915
+ Tt as useRealtimeSeatMap,
916
+ mt as useTouchGestures
902
917
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zonetrix/viewer",
3
- "version": "2.10.6",
3
+ "version": "2.10.7",
4
4
  "type": "module",
5
5
  "description": "Lightweight React component for rendering interactive seat maps",
6
6
  "main": "./dist/index.js",
@@ -61,5 +61,8 @@
61
61
  "typescript": "^5.8.3",
62
62
  "vite": "^7.3.0",
63
63
  "vite-plugin-dts": "^4.5.4"
64
+ },
65
+ "dependencies": {
66
+ "@zonetrix/viewer": "file:../seat-map-studio/packages/viewer"
64
67
  }
65
68
  }