@seatlayer/js 0.93.0 → 0.94.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.
@@ -0,0 +1 @@
1
+ import{t as C}from"@seatlayer/core";import{cdnAssetUrl as _}from"@seatlayer/core/core/cdnAsset";var A=/^data:image\/(?:png|jpe?g|webp|gif|avif);base64,[a-z0-9+/]+={0,2}$/i,T=/[\s"'<>`\\]/;function E(i){return i.startsWith("//")?!1:i.startsWith("/")||i.startsWith("./")||i.startsWith("../")}function S(){try{let i=typeof location>"u"?"":location.origin;return i&&i!=="null"?i:null}catch{return null}}function x(i){if(typeof i!="string"||!i||i.length>2e6||i!==i.trim())return!1;if(i.startsWith("data:"))return A.test(i);if(T.test(i))return!1;let t=S();if(E(i)){if(!t)return!1;try{let n=new URL(i,t);return n.origin===t&&!n.username&&!n.password}catch{return!1}}try{let n=new URL(i);return n.username||n.password?!1:n.protocol==="https:"||t!=null&&n.origin===t}catch{return!1}}import{SEATLAYER_MODULE_URL as ae}from"@seatlayer/core/core/cdnAsset";function d(i,t){let n=C(i);return n===i?t:n}function $(){return globalThis.matchMedia?.("(pointer: coarse)").matches??!1?d("picker.dragToLookTouch","Drag to look \xB7 pinch to zoom \xB7 tap \u2715 to close"):d("picker.dragToLookMouse","Drag to look \xB7 pinch or scroll to zoom \xB7 Esc to close")}function B(){return{rotate:d("picker.dragToRotateVenue","Drag to rotate the venue"),move:d("picker.dragToMoveVenue","Drag to move the venue"),zoomIn:d("picker.zoomIn","Zoom in"),zoomOut:d("picker.zoomOut","Zoom out"),fitView:d("picker.fitWholeVenue","Show whole venue")}}function X(i,t){let n=t?i.toLocaleUpperCase(t):i.toLocaleUpperCase(),e=t?i.toLocaleLowerCase(t):i.toLocaleLowerCase();if(i!==n||n===e)return i;let o=[...e][0]??"";return(t?o.toLocaleUpperCase(t):o.toLocaleUpperCase())+e.slice(o.length)}function G(i){if(typeof i=="string"){let t=document.querySelector(i);if(!t)throw new Error(`seatmap: container "${i}" not found`);return t}if(!(i instanceof HTMLElement))throw new Error("seatmap: container must be a CSS selector or an HTMLElement");return i}function K(i){return String(i??"").replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[t])}function q(i,t,n){let e=t.find(l=>x(l))??null;if(i.replaceChildren(),!e)return i.textContent=n.slice(0,1).toUpperCase(),null;let o=document.createElement("img");return o.alt="",o.referrerPolicy="no-referrer",o.src=e,i.appendChild(o),e}var v=null;function Z(){if(v!==null)return v;try{if(typeof document>"u")return v=!1;v=!!document.createElement("canvas").getContext("webgl2")}catch{v=!1}return v}function b(i){return _(i)}var y=null;function P(){return y||(y=(typeof __SEATLAYER_CDN__<"u"&&__SEATLAYER_CDN__?import(b("seatlayer-view3d.mjs")):import("@seatlayer/core/view3d")).catch(t=>{throw y=null,t}),y)}function j(){(typeof navigator>"u"?void 0:navigator.connection)?.saveData||P().catch(()=>{})}async function z(){return typeof __SEATLAYER_CDN__<"u"&&__SEATLAYER_CDN__?import(b("seatlayer-panorama.mjs")):import("@seatlayer/core")}async function J(){return typeof __SEATLAYER_CDN__<"u"&&__SEATLAYER_CDN__?import(b("seatlayer-checkout.mjs")):import("./hostedCheckout-GQQF4XDN.js")}function Q(i){return i==="unavailable_for_event"||i==="payments_off_for_event"?i:"not_configured"}function ee(i){return i.lineItems.reduce((t,n)=>t+n.quantity,0)}function L(i,t){if(i.objectType!=="ga")return i.displayLabel??i.label;let n=t.find(e=>e.id===i.objectId);return i.displayLabel??n?.displayLabel??n?.label??d("picker.generalAdmission","General admission")}var k=(i,t,n)=>C("picker.bookingForm.guestOfCount",{label:i,index:t,total:n});function R(i,t,n=[]){let e=new Map,o=[];for(let s of i.lineItems){let r=L(s,n),f=Math.max(1,Math.floor(s.quantity)||1);if(s.objectType!=="ga"&&!(s.objectType==="table"&&f>1)){o.push({key:s.label,name:r,unitIndex:1,quantity:1});continue}for(let h=1;h<=f;h+=1){let p=(e.get(s.label)??0)+1;e.set(s.label,p),o.push({key:`${s.label}#${p}`,name:r,unitIndex:h,quantity:f})}}let l=t?.ticketKeyDetails??[],a=t?.ticketKeys??l.map(s=>s.ticketKey),m=(a.length===o.length?a:o.map(s=>s.key)).map(s=>{let r=o.find(h=>h.key===s),f=l.find(h=>h.ticketKey===s);return{key:s,name:f?.displayLabel??r?.name,unitIndex:f?.unitIndex??r?.unitIndex??1,quantity:f?.quantity??r?.quantity??1}}),c=new Map;for(let s of m)s.name&&s.quantity<=1&&c.set(s.name,(c.get(s.name)??0)+1);let u=new Map;return m.map(({key:s,name:r,unitIndex:f,quantity:h})=>{if(!r)return{key:s};if(h>1)return{key:s,title:k(r,f,h)};let p=(u.get(r)??0)+1;u.set(r,p);let g=c.get(r)??1;return{key:s,title:g>1?k(r,p,g):r}})}function te(i,t,n,e,o=[]){let l=new Map;for(let a of i.lineItems){let m=L(a,o);l.set(m,(l.get(m)??0)+1)}return{kind:"pay",provider:t,order:{holdId:i.holdId,expiresAt:i.expiresAt,currency:i.currency,total:i.total,labels:[...l].map(([a,m])=>m>1?`${a} \xD7${m}`:a),tickets:R(i,e,o)},bookingForm:n?.bookingForm??null,...n?.bookingMode==="free"?{free:!0}:{}}}function ne(i){return String(i?.code).startsWith("booking_form_")}function ie(i,t,n){let e={month:"short",day:"numeric",hour:"numeric",minute:"2-digit"},o=new Date(i);if(t)try{return o.toLocaleString(n,{...e,timeZone:t})}catch{}return o.toLocaleString(n,e)}function se(i){return i.focusedSection!==null?i.deeperThanSectionFrame===!1?"venue":"section":i.atVenueFit!==void 0?i.atVenueFit?"none":"venue":i.seatsRevealed?"venue":"none"}import{pointInPolygon as I}from"@seatlayer/core";import{createMinimapTransform as D,minimapPointToWorld as H,minimapViewportPlan as V}from"@seatlayer/core/picker/minimapGeometry";function O(i){let t={inactive:0,available:1,selected:2},n=new Map;for(let o of i){let l=n.get(o.id);(!l||t[o.state]>t[l])&&n.set(o.id,o.state)}let e={selected:0,available:0,inactive:0};for(let o of n.values())e[o]+=1;return e}function W(i,t){return i.x<=t.x&&i.y<=t.y&&i.x+i.width>=t.x+t.width&&i.y+i.height>=t.y+t.height}function me(i,t){let n=new M(i);return n.build(t),n}var M=class{constructor(t){this.host=t;this.miniCanvas=null;this.miniBase=null;this.miniWrap=null;this.miniToggle=null;this.miniLabel=null;this.miniTf=null;this.miniDrag=null;this.miniSuppressClick=!1;this.userClosed=!1}dispose(){this.miniToggle?.remove(),this.miniWrap?.remove(),this.miniToggle=null,this.miniWrap=null,this.miniCanvas=null,this.miniBase=null,this.miniLabel=null,this.miniTf=null,this.miniDrag=null,this.host.root()?.removeAttribute("data-minimap-open")}build(t){if(!this.host.controller.getViewport())return;let e=document.createElement("button");e.type="button",e.className="sl-minimap-toggle",e.setAttribute("aria-label",d("picker.openVenueMap","Open venue overview map")),e.setAttribute("aria-expanded","false"),e.innerHTML='<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M3 6l5-2 8 3 5-2v13l-5 2-8-3-5 2zM8 4v13M16 7v13"/></svg>',t.appendChild(e),this.miniToggle=e;let o=document.createElement("div");o.className="sl-minimap",o.setAttribute("role","group");let l=document.createElement("div");l.className="sl-minimap-bar";let a=document.createElement("span");a.className="sl-minimap-label";let m=document.createElement("span");m.className="sl-minimap-key",m.setAttribute("aria-label",d("picker.minimapStateKey","Focused, selected, available, and inactive sections")),m.innerHTML='<i class="focused" title="Focused"></i><i class="selected" title="Selected"></i><i title="Available"></i><i class="inactive" title="Inactive"></i>';let c=document.createElement("button");c.type="button",c.className="sl-minimap-close",c.setAttribute("aria-label",d("picker.closeVenueMap","Close venue overview map")),c.textContent="\xD7",l.append(a,m,c);let u=document.createElement("canvas");u.tabIndex=0,u.setAttribute("role","application"),u.setAttribute("aria-label",d("picker.venueMapInstructions","Venue overview map. Drag the viewport, click a section, or use arrow keys to pan.")),o.append(l,u),t.appendChild(o),this.miniWrap=o,this.miniLabel=a,this.miniCanvas=u;let s=document.createElement("canvas");this.miniBase=s,e.addEventListener("click",()=>{let r=this.host.root()?.dataset.minimapOpen==="true";this.userClosed=r,this.setMinimapOpen(!r)}),c.addEventListener("click",()=>{this.userClosed=!0,this.setMinimapOpen(!1)}),u.addEventListener("click",r=>{if(this.miniSuppressClick){this.miniSuppressClick=!1;return}this.minimapJump(r)}),u.addEventListener("pointerdown",r=>this.minimapPointerDown(r)),u.addEventListener("pointermove",r=>this.minimapPointerMove(r)),u.addEventListener("pointerup",r=>this.minimapPointerUp(r)),u.addEventListener("pointercancel",r=>this.minimapPointerUp(r)),u.addEventListener("keydown",r=>this.minimapKeydown(r)),this.layoutMinimap(),this.syncMinimapLabel(),this.drawMinimapStatic(),this.drawMinimapRect()}setAutoOpen(t){if(this.miniWrap){if(!t){this.userClosed=!1,this.host.root()?.dataset.minimapOpen==="true"&&this.setMinimapOpen(!1,!1);return}this.userClosed||this.host.root()?.dataset.minimapOpen==="true"||this.setMinimapOpen(!0,!1)}}setMinimapOpen(t,n=!0){this.host.root()?.setAttribute("data-minimap-open",String(t)),this.miniToggle?.setAttribute("aria-expanded",String(t)),n&&(t?this.miniCanvas?.focus():this.miniToggle?.focus())}layoutMinimap(){let t=this.miniCanvas,n=this.miniBase,e=this.host.controller.getViewport()?.bounds;if(!t||!n||!e||!(e.width>0&&e.height>0))return;let o=196,l=146,a=6,m=e.width/Math.max(1,e.height),c=o,u=Math.round(o/m);u>l&&(u=l,c=Math.round(l*m)),c=Math.max(64,c),u=Math.max(48,u);let s=Math.min(2,window.devicePixelRatio||1);t.width=Math.round(c*s),t.height=Math.round(u*s),t.style.width=`${c}px`,t.style.height=`${u}px`,n.width=t.width,n.height=t.height,this.miniTf=D(e,t.width,t.height,s,a)}syncMinimapLabel(){if(!this.miniLabel||!this.miniWrap)return;let t=this.host.controller.getFloors(),n=this.host.controller.isFloorOverview()?d("picker.allFloors","All floors"):t.find(s=>s.id===this.host.controller.getActiveFloorId())?.name??d("picker.venueOverview","Venue overview"),e=this.host.controller.getMinimapSnapshot().sections,l=e.find(s=>s.active)?.label??this.host.focusedSectionLabel(),a=l?`${n} \xB7 ${l}`:n;this.miniLabel.textContent=a;let{selected:m,available:c,inactive:u}=O(e);this.miniWrap.setAttribute("aria-label",e.length?`${a}. ${m} selected, ${c} available, ${u} inactive sections.`:a),this.miniCanvas?.setAttribute("aria-label",e.length?`${a}. ${m} selected, ${c} available, ${u} inactive sections. ${d("picker.venueMapInstructions","The outlined region is the visible map area. Drag it, click a section, or use arrow keys to pan.")}`:`${a}. ${d("picker.venueMapInstructions","The outlined region is the visible map area. Drag it, click elsewhere, or use arrow keys to pan.")}`)}refreshMinimap(){this.miniBase&&(this.layoutMinimap(),this.syncMinimapLabel(),this.drawMinimapStatic(),this.drawMinimapRect())}drawMinimapStatic(){let t=this.miniBase,n=this.miniTf;if(!t||!n)return;let e=t.getContext("2d");if(!e)return;e.clearRect(0,0,t.width,t.height);let o=r=>r*n.scale+n.offX,l=r=>r*n.scale+n.offY,a=this.host.cssVar("--sl-line")||"rgba(139,147,167,.5)",m=this.host.cssVar("--sl-muted")||"#8b93a7",c=this.host.cssVar("--sl-accent")||"#6e7bff",u=this.host.cssVar("--sl-success")||"#22a06b",s=this.host.controller.getMinimapSnapshot();for(let r of s.sections){if(r.outline.length<3)continue;e.beginPath(),r.outline.forEach((h,p)=>p===0?e.moveTo(o(h.x),l(h.y)):e.lineTo(o(h.x),l(h.y))),e.closePath();let f=r.paint;if(e.globalAlpha=r.state==="inactive"?.5:.92,f?e.fillStyle=f.fill:(e.globalAlpha=r.state==="inactive"?.18:r.state==="selected"?.72:.34,e.fillStyle=r.state==="inactive"?m:r.state==="selected"?c:u),e.fill(),e.globalAlpha=.82,e.lineWidth=Math.max(1,n.dpr),e.strokeStyle=f?.stroke||a,e.stroke(),r.owned){e.globalAlpha=1,e.lineWidth=Math.max(2,n.dpr*1.5),e.strokeStyle=c,e.stroke();let h=r.outline.reduce((p,g)=>({x:p.x+g.x,y:p.y+g.y}),{x:0,y:0});e.beginPath(),e.arc(o(h.x/r.outline.length),l(h.y/r.outline.length),Math.max(1.5,n.dpr*1.6),0,Math.PI*2),e.fillStyle=c,e.fill(),e.beginPath(),r.outline.forEach((p,g)=>g===0?e.moveTo(o(p.x),l(p.y)):e.lineTo(o(p.x),l(p.y))),e.closePath()}r.active&&(e.globalAlpha=1,e.lineJoin="round",e.lineWidth=Math.max(4,n.dpr*3.5),e.strokeStyle=this.host.cssVar("--sl-surface")||"#fff",e.stroke(),e.lineWidth=Math.max(2,n.dpr*1.75),e.strokeStyle=c,e.stroke())}if(e.globalAlpha=1,!s.sections.length){let r=Math.max(1,n.dpr),f=new Map,h=p=>{let g=f.get(p);if(g)return g;let w=this.host.tint?.(p)||u;return f.set(p,w),w};for(let p of s.seats)e.globalAlpha=p.state==="inactive"?.22:.78,e.fillStyle=p.state==="inactive"?m:p.state==="selected"?c:h(p.categoryKey),e.beginPath(),e.arc(o(p.x),l(p.y),r,0,Math.PI*2),e.fill();e.globalAlpha=1}}drawMinimapRect(){let t=this.miniCanvas,n=this.miniBase,e=this.miniTf;if(!t||!n||!e)return;let o=t.getContext("2d");if(!o)return;o.clearRect(0,0,t.width,t.height),o.drawImage(n,0,0);let l=this.host.controller.getViewport();if(!l||W(l.visible,l.bounds))return;let a=V(l.visible,e,t.width,t.height,Math.max(2,e.dpr*2)),m=this.host.cssVar("--sl-text")||"#12151c",c=this.host.cssVar("--sl-surface")||"#fff";o.save(),o.globalAlpha=.1,o.fillStyle=m,o.fillRect(a.raw.x,a.raw.y,a.raw.width,a.raw.height),o.globalAlpha=.9,o.lineJoin="round",o.lineWidth=Math.max(4,e.dpr*3.25),o.strokeStyle=c,o.strokeRect(a.raw.x,a.raw.y,a.raw.width,a.raw.height),o.globalAlpha=1,o.lineWidth=Math.max(2,e.dpr*1.75),o.strokeStyle=m,o.strokeRect(a.raw.x,a.raw.y,a.raw.width,a.raw.height),a.clipped&&Object.values(a.clippedEdges).some(Boolean)&&(o.setLineDash([Math.max(3,e.dpr*3),Math.max(2,e.dpr*2)]),o.strokeRect(a.clipped.x,a.clipped.y,a.clipped.width,a.clipped.height)),o.restore()}minimapWorldPoint(t){let n=this.miniCanvas,e=this.miniTf;if(!n||!e)return null;let o=n.getBoundingClientRect(),l=(t.clientX-o.left)*(n.width/Math.max(1,o.width)),a=(t.clientY-o.top)*(n.height/Math.max(1,o.height));return{...H({x:l,y:a},e),px:l,py:a}}minimapPointerDown(t){let n=this.minimapWorldPoint(t),e=this.host.controller.getViewport()?.visible;!n||!e||!(n.x>=e.x&&n.x<=e.x+e.width&&n.y>=e.y&&n.y<=e.y+e.height)||(this.miniDrag={pointerId:t.pointerId,offsetX:n.x-(e.x+e.width/2),offsetY:n.y-(e.y+e.height/2),startX:t.clientX,startY:t.clientY,moved:!1},this.miniCanvas?.setPointerCapture(t.pointerId),this.miniCanvas?.classList.add("sl-dragging"),t.preventDefault())}minimapPointerMove(t){let n=this.miniDrag;if(!n||n.pointerId!==t.pointerId)return;let e=this.minimapWorldPoint(t);e&&(!n.moved&&Math.hypot(t.clientX-n.startX,t.clientY-n.startY)>2&&(n.moved=!0,this.host.controller.clearSectionFocus()),this.host.controller.panToWorld({x:e.x-n.offsetX,y:e.y-n.offsetY}),t.preventDefault())}minimapPointerUp(t){let n=this.miniDrag;!n||n.pointerId!==t.pointerId||(this.miniSuppressClick=n.moved,this.miniDrag=null,this.miniCanvas?.classList.remove("sl-dragging"),this.miniCanvas?.hasPointerCapture(t.pointerId)&&this.miniCanvas.releasePointerCapture(t.pointerId))}minimapKeydown(t){let n=this.host.controller.getViewport()?.visible;if(!n)return;if(t.key==="Home"){this.host.controller.overview(),t.preventDefault();return}let e=t.key==="ArrowLeft"?-n.width*.2:t.key==="ArrowRight"?n.width*.2:0,o=t.key==="ArrowUp"?-n.height*.2:t.key==="ArrowDown"?n.height*.2:0;!e&&!o||(this.host.controller.clearSectionFocus(),this.host.controller.panToWorld({x:n.x+n.width/2+e,y:n.y+n.height/2+o}),t.preventDefault())}minimapJump(t){let n=this.minimapWorldPoint(t);if(n){for(let e of this.host.controller.getMinimapSnapshot().sections)if(!(e.state==="inactive"||e.outline.length<3)&&I(n,e.outline)){this.host.controller.focusSection(e.id);return}this.host.controller.clearSectionFocus(),this.host.controller.panToWorld(n)}}};export{x as a,d as b,$ as c,B as d,X as e,G as f,K as g,q as h,Z as i,P as j,j as k,z as l,J as m,Q as n,ee as o,te as p,ne as q,ie as r,se as s,me as t};