@seatlayer/js 0.92.5 → 0.93.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/dist/hostedCheckout-GQQF4XDN.js +58 -0
- package/dist/index.cjs +28 -16
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +28 -16
- package/package.json +2 -2
- package/dist/hostedCheckout-K6C42MCF.js +0 -58
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seatlayer/js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.93.0",
|
|
4
4
|
"description": "SeatLayer's official JavaScript seating chart and seat map SDK — live availability, seat selection, temporary holds, and a typed API for any web ticketing app.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": {
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"typescript"
|
|
69
69
|
],
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@seatlayer/core": "0.
|
|
71
|
+
"@seatlayer/core": "0.93.0"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"tsup": "^8.5.1",
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import"./chunk-OSZ7DOEH.js";var ae=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,se=/^[0-9 +()-]{6,20}$/,le=/^(\d{4})-(\d{2})-(\d{2})$/,ce=["required","invalid","too_long"],de=[["attendeeName","name","picker.bookingForm.name","Name"],["attendeeEmail","email","picker.bookingForm.email","Email"],["attendeePhone","phone","picker.bookingForm.phone","Phone"]],ue={email:"email",phone:"tel",number:"number",date:"date"};function ee(e){return e===void 0||e===""||e===!1||Array.isArray(e)&&!e.length}function pe(e,r,o,l){if(ee(o))return r?"required":null;let p=x=>!!l?.some(E=>E.id===x);if(e==="number")return typeof o=="number"&&Number.isFinite(o)?null:"invalid";if(e==="checkbox")return o===!0?null:"invalid";if(e==="select")return p(o)?null:"invalid";if(e==="multiselect")return Array.isArray(o)&&o.length<=50&&o.every(p)?null:"invalid";if(typeof o!="string")return"invalid";if(e==="phone")return se.test(o)?null:"invalid";if(o.length>500)return"too_long";if(e==="email")return ae.test(o)?null:"invalid";if(e==="date"){let x=le.exec(o);if(!x)return"invalid";let[E,F,N]=[Number(x[1]),Number(x[2]),Number(x[3])],w=new Date(Date.UTC(E,F-1,N));return w.getUTCFullYear()===E&&w.getUTCMonth()===F-1&&w.getUTCDate()===N?null:"invalid"}return null}function v(e,r,o){let l=document.createElement(e);return r&&(l.className=r),o!==void 0&&(l.textContent=o),l}function Z(e,r){let o=e?.[r];return o==="optional"||o==="required"?o:"off"}function te(e){let{form:r,t:o,idPrefix:l}=e,p=(r?.questions??[]).filter(n=>n&&!n.archived).sort((n,t)=>n.position-t.position),x=de.filter(([n])=>Z(r,n)!=="off"),E=p.filter(n=>n.scope==="ticket"),F=p.filter(n=>n.scope!=="ticket"),N=x.length>0||E.length>0;if(!N&&!F.length)return{element:null,validate:()=>!0,payload:()=>({}),showServerErrors:()=>!1};let w=[],A=[],S=v("div","sl-hco-bf"),K=v("div"),_=v("p","sl-hco-status sl-hco-error");_.setAttribute("role","alert"),_.hidden=!0;let U=0,P=(n,t)=>t==="required"?o("picker.bookingForm.required","This is required."):t==="too_long"?o("picker.bookingForm.tooLong","This is too long."):n==="email"?o("picker.bookingForm.invalidEmail","Enter a valid email address."):n==="phone"?o("picker.bookingForm.invalidPhone","Enter a valid phone number."):o("picker.bookingForm.invalid","Check this answer."),$=(n,t)=>{n.error.textContent=t?P(n.kind,t):"",n.error.hidden=!t;let i=n.kind==="multiselect"?n.control.closest("fieldset")??n.control:n.control;t?i.setAttribute("aria-invalid","true"):i.removeAttribute("aria-invalid")},X=(n,t)=>{let i=`${l}-bf${U++}`,c=v("div","sl-hco-field"),s=t.required?t.label:o("picker.bookingForm.optional","{label} (optional)",{label:t.label}),g=t.help?v("p","sl-hco-help",t.help):null;g&&(g.id=`${i}-h`);let h=v("p","sl-hco-ferr");h.id=`${i}-e`,h.hidden=!0;let C=y=>{y.setAttribute("aria-describedby",g?`${g.id} ${h.id}`:h.id),t.required&&y.tagName!=="FIELDSET"&&y.setAttribute("aria-required","true")},M;if(t.kind==="checkbox"||t.kind==="multiselect"){let y=t.kind==="multiselect"?v("fieldset","sl-hco-group"):null,k=y?t.options??[]:[{id:"",label:s}];y&&(y.appendChild(v("legend",void 0,s)),g&&y.appendChild(g),C(y));let T=k.map((b,I)=>{let B=v("label","sl-hco-check"),R=v("input");return R.type="checkbox",R.value=b.id,y?I===0&&(R.id=i):(R.id=i,C(R)),B.append(R,v("span",void 0,b.label)),(y??c).appendChild(B),R});y?c.appendChild(y):g&&c.appendChild(g),M={...t,control:T[0]??y??c,error:h,read:y?()=>T.filter(b=>b.checked).map(b=>b.value):()=>!!T[0]?.checked}}else{let y=v("label","sl-hco-label",s);y.htmlFor=i;let k;if(t.kind==="textarea")k=v("textarea","sl-hco-input"),k.rows=3,k.maxLength=500;else if(t.kind==="select"){k=v("select","sl-hco-input"),k.appendChild(new Option(o("picker.bookingForm.choose","Choose\u2026"),""));for(let b of t.options??[])k.appendChild(new Option(b.label,b.id))}else k=v("input","sl-hco-input"),k.type=ue[t.kind]??"text",t.kind==="number"?(k.step="any",k.inputMode="decimal"):t.kind!=="date"&&(k.maxLength=t.kind==="phone"?20:500),t.autocomplete&&(k.autocomplete=t.autocomplete);k.id=i,C(k),c.append(y,...g?[g]:[],k);let T=k;M={...t,control:k,error:h,read:()=>{let b=T.value.trim();return t.kind!=="number"?b:T.validity?.badInput?Number.NaN:b===""?void 0:Number(b)},write:b=>{T.value=b}}}c.appendChild(h);let Q=()=>$(M,null);return c.addEventListener("input",Q),c.addEventListener("change",Q),n.appendChild(c),w.push(M),M},L=(n,t,i)=>X(n,{key:`question:${t.id}`,...i!==void 0?{ticketKey:i}:{},kind:t.type,label:t.label,required:!!t.required,help:t.helpText,options:t.options}),q=n=>{if(A.includes(n.key))return;let t=!A.length;A.push(n.key);let i=v("fieldset","sl-hco-block");i.appendChild(v("legend","sl-hco-legend",n.title||o("picker.bookingForm.ticket","Ticket {number}",{number:A.length})));let c={};if(t&&x.some(([,s])=>s!=="phone")){let s=v("button","sl-hco-use",o("picker.bookingForm.useMyDetails","Use my details"));s.type="button",s.addEventListener("click",()=>{let g=e.buyer();for(let h of["name","email"]){let C=c[h];C&&g[h]&&(C.write?.(g[h]),$(C,null))}}),i.appendChild(s)}for(let[s,g,h,C]of x){let M=X(i,{key:s,ticketKey:n.key,kind:g,label:o(h,C),required:Z(r,s)==="required",autocomplete:"off"});g!=="phone"&&(c[g]=M)}for(let s of E)L(i,s,n.key);K.appendChild(i)};N&&e.tickets.forEach(q),S.appendChild(K);for(let n of F)L(S,n);S.appendChild(_);let D=n=>(_.textContent=n?o("picker.bookingForm.fix","Some details need attention."):"",_.hidden=!n,n?.control.focus(),!!n);return{element:S,validate(){let n=null;for(let t of w){let i=pe(t.kind,t.required,t.read(),t.options);$(t,i),i&&!n&&(n=t)}return!D(n)},payload(){let n=new Map,t=[];for(let i of w){let c=i.read();if(!ee(c)){if(i.key.startsWith("question:"))t.push({questionId:i.key.slice(9),...i.ticketKey!==void 0?{ticketKey:i.ticketKey}:{},value:c});else if(i.ticketKey!==void 0){let s=n.get(i.ticketKey)??{ticketKey:i.ticketKey},g=i.key==="attendeeName"?"name":i.key==="attendeeEmail"?"email":"phone";s[g]=String(c),n.set(i.ticketKey,s)}}}return{...n.size?{attendees:[...n.values()]}:{},...t.length?{answers:t}:{}}},showServerErrors(n){let t=(Array.isArray(n)?n:[]).filter(c=>!!c&&typeof c.key=="string");if(N){for(let c of t)typeof c.ticketKey=="string"&&!A.includes(c.ticketKey)&&q({key:c.ticketKey});w.sort((c,s)=>c.control.compareDocumentPosition(s.control)&4?-1:1)}let i=null;for(let c of w){let s=t.find(h=>h.key===c.key&&(h.ticketKey??void 0)===(c.ticketKey??void 0)),g=s?ce.includes(s.code)?s.code:"invalid":null;$(c,g),g&&!i&&(i=c)}return i?D(i):(_.textContent=o("picker.bookingForm.fix","Some details need attention."),_.hidden=!1,!1)}}}var he=9e4,ge=2e3,ne="https://checkout.razorpay.com/v1/checkout.js",oe="seatlayer-checkout-style",fe="@seatlayer/pending-checkout/v1";function me(e,r){try{window.sessionStorage.setItem(fe,JSON.stringify({orderId:e,...r?{eventKey:r}:{},storedAt:Date.now()}))}catch{}}var ke=`
|
|
2
|
-
/* The card is centred, but max-height:100% lets a long form reach the bottom
|
|
3
|
-
edge \u2014 and on the hosted buyer page that edge is the phone's edge, with the
|
|
4
|
-
Pay button last in the scroll. Reserve the home-indicator gutter here too.
|
|
5
|
-
--sl-safe-b is declared on .sl-picker, which this overlay lives inside, so it
|
|
6
|
-
inherits; it resolves to 0px in any host that is not inset. */
|
|
7
|
-
.sl-hco{position:absolute;inset:0;z-index:60;display:flex;align-items:center;justify-content:center;
|
|
8
|
-
padding:16px 16px calc(16px + var(--sl-safe-b,0px));
|
|
9
|
-
background:color-mix(in srgb, var(--sl-bg) 82%, transparent);backdrop-filter:blur(3px)}
|
|
10
|
-
.sl-hco-card{width:100%;max-width:380px;max-height:100%;overflow:auto;padding:22px;
|
|
11
|
-
background:var(--sl-surface);color:var(--sl-text);border:1px solid var(--sl-line);
|
|
12
|
-
border-radius:var(--sl-radius);box-shadow:0 18px 48px rgba(0,0,0,.28)}
|
|
13
|
-
.sl-hco-title{margin:0 0 14px;font-size:19px;font-weight:650;letter-spacing:-.01em}
|
|
14
|
-
.sl-hco-summary{margin-bottom:16px;padding-bottom:14px;border-bottom:1px solid var(--sl-line)}
|
|
15
|
-
.sl-hco-seats{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:10px}
|
|
16
|
-
.sl-hco-seat{padding:3px 8px;font-size:12px;font-weight:600;border-radius:calc(var(--sl-radius) * .5);
|
|
17
|
-
background:var(--sl-bg);border:1px solid var(--sl-line)}
|
|
18
|
-
.sl-hco-total{display:flex;justify-content:space-between;align-items:baseline;font-size:14px}
|
|
19
|
-
.sl-hco-total strong{font-size:17px;font-weight:700}
|
|
20
|
-
.sl-hco-label{display:block;margin:12px 0 5px;font-size:12px;font-weight:600;color:var(--sl-muted)}
|
|
21
|
-
.sl-hco-input{width:100%;padding:10px 11px;font:inherit;font-size:15px;color:var(--sl-text);
|
|
22
|
-
background:var(--sl-bg);border:1px solid var(--sl-line);border-radius:calc(var(--sl-radius) * .55)}
|
|
23
|
-
.sl-hco-input:focus-visible{outline:2px solid var(--sl-accent);outline-offset:1px}
|
|
24
|
-
.sl-hco-pay{width:100%;margin-top:16px;padding:12px;font:inherit;font-size:15px;font-weight:650;
|
|
25
|
-
color:var(--sl-accent-ink);background:var(--sl-accent);border:0;
|
|
26
|
-
border-radius:calc(var(--sl-radius) * .55);cursor:pointer}
|
|
27
|
-
.sl-hco-pay[disabled]{opacity:.5;cursor:default}
|
|
28
|
-
.sl-hco-back{width:100%;margin-top:8px;padding:10px;font:inherit;font-size:14px;color:var(--sl-muted);
|
|
29
|
-
background:none;border:0;cursor:pointer;text-decoration:underline}
|
|
30
|
-
.sl-hco-note{margin:12px 0 0;font-size:12px;line-height:1.5;color:var(--sl-muted)}
|
|
31
|
-
.sl-hco-note a{color:inherit;text-decoration:underline;text-underline-offset:2px}
|
|
32
|
-
.sl-hco-status{margin:8px 0 0;font-size:14px;line-height:1.55}
|
|
33
|
-
.sl-hco-error{color:var(--sl-danger, #c0392b)}
|
|
34
|
-
.sl-hco-receipt{display:grid;grid-template-columns:auto 1fr;gap:4px 14px;margin:14px 0 0;font-size:13px}
|
|
35
|
-
.sl-hco-receipt dt{color:var(--sl-muted)}
|
|
36
|
-
.sl-hco-receipt dd{margin:0;text-align:right}
|
|
37
|
-
.sl-hco-ref{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;word-break:break-all}
|
|
38
|
-
.sl-hco-tickets{display:block;width:100%;margin-top:14px;padding:12px;font:inherit;font-size:15px;
|
|
39
|
-
font-weight:650;text-align:center;text-decoration:none;color:var(--sl-accent-ink);
|
|
40
|
-
background:var(--sl-accent);border-radius:calc(var(--sl-radius) * .55)}
|
|
41
|
-
/* Booking form: one fieldset per ticket, then the booking's own questions.
|
|
42
|
-
Controls reuse .sl-hco-label/.sl-hco-input so a host theme reaches them. */
|
|
43
|
-
.sl-hco-block{min-width:0;margin:16px 0 0;padding:4px 12px 14px;border:1px solid var(--sl-line);
|
|
44
|
-
border-radius:calc(var(--sl-radius) * .55)}
|
|
45
|
-
.sl-hco-legend{padding:0 6px;font-size:13px;font-weight:650}
|
|
46
|
-
.sl-hco-use{margin:4px 0 0;padding:0;font:inherit;font-size:13px;font-weight:600;color:var(--sl-accent);
|
|
47
|
-
background:none;border:0;cursor:pointer;text-decoration:underline;text-underline-offset:2px}
|
|
48
|
-
.sl-hco-help{margin:0 0 6px;font-size:12px;line-height:1.45;color:var(--sl-muted)}
|
|
49
|
-
.sl-hco-ferr{margin:5px 0 0;font-size:12px;line-height:1.4;color:var(--sl-danger, #c0392b)}
|
|
50
|
-
.sl-hco-input[aria-invalid="true"]{border-color:var(--sl-danger, #c0392b)}
|
|
51
|
-
textarea.sl-hco-input{min-height:72px;resize:vertical}
|
|
52
|
-
.sl-hco-group{min-width:0;margin:12px 0 0;padding:0;border:0}
|
|
53
|
-
.sl-hco-group legend{margin:0 0 5px;padding:0;font-size:12px;font-weight:600;color:var(--sl-muted)}
|
|
54
|
-
.sl-hco-group[aria-invalid="true"] legend{color:var(--sl-danger, #c0392b)}
|
|
55
|
-
.sl-hco-check{display:flex;gap:8px;align-items:flex-start;margin:8px 0 0;font-size:14px;line-height:1.4;cursor:pointer}
|
|
56
|
-
.sl-hco-check input{flex:none;width:18px;height:18px;margin:1px 0 0;accent-color:var(--sl-accent)}
|
|
57
|
-
.sl-hco-check input:focus-visible{outline:2px solid var(--sl-accent);outline-offset:2px}
|
|
58
|
-
`;function ye(){if(typeof document>"u"||document.getElementById(oe))return;let e=document.createElement("style");e.id=oe,e.textContent=ke,document.head.appendChild(e)}function be(e,r){let o=`${r} ${r===1?"seat is":"seats are"} held for a limited time.`;return e==="payments_off_for_event"?{title:"This event isn\u2019t sold online",body:`${o} The organiser isn\u2019t taking payment for this event here.`,detail:"Nothing has been charged. Check where you found this event for how to get tickets."}:e==="unavailable_for_event"?{title:"This event isn\u2019t taking payment yet",body:`${o} Online payment is not switched on for this event.`,detail:"Nothing has been charged. If you were sent here to pay, let the organiser know \u2014 only they can turn payment on for this event."}:{title:"Finish in the ticketing checkout",body:`${o} Payment for this event is taken elsewhere.`,detail:"Nothing has been charged. Continue in the checkout on this page to pay for your seats."}}var ve=3,xe=1,we=400,Ce=3e3;function re(e){if(!e||typeof e!="object")return!1;let r=e;return r.status!==503||r.code==="maintenance_mode"||r.reason==="maintenance_mode"?!1:r.code==="checkout_busy"||r.code==="database_busy"?!0:r.retryable===!0}function Ee(e,r=Math.random){let o=e?.retryAfterS,l=typeof o=="number"&&Number.isFinite(o)&&o>=0?o:xe,p=Math.floor(Math.max(0,Math.min(1,r()))*we);return Math.min(Ce,l*1e3+p)}function _e(e){return`${(typeof e?.notice=="string"?e.notice.trim():"")||(()=>{let l=e?.retryAfterS;if(typeof l!="number"||!Number.isFinite(l)||l<0)return"Booking is paused for a few minutes for maintenance. Please try again shortly.";let p=Math.max(1,Math.ceil(l/60));return`Booking is paused for maintenance. Please try again in about ${p} minute${p===1?"":"s"}.`})()} Nothing was charged \u2014 your seats are still held.`}function Y(e,r){if(e==="maintenance_mode")return _e(r);switch(e){case"checkout_busy":case"database_busy":return r?.free?"We couldn\u2019t confirm your booking yet because it\u2019s very busy. Nothing was charged \u2014 please try again.":"We couldn\u2019t start the payment yet because it\u2019s very busy. Nothing was charged \u2014 please try again.";case"gateway_not_connected":case"payments_not_enabled_for_event":return"This event is not taking online payments. Contact the organiser to buy these seats.";case"provider_mismatch":return"This event\u2019s payment setup changed while you were choosing. Nothing was charged \u2014 please try again.";case"hold_not_active":case"hold_not_found":return"Your seats were released before checkout started. Nothing was charged \u2014 please pick again.";case"checkout_already_started":return"A payment for these seats is already in progress. Finish that one, or wait for it to time out before starting again.";case"event_closed":return"Sales for this event have closed.";case"insufficient_hosted_credits":return"Ticket sales are temporarily paused while the organiser updates their SeatLayer balance. Nothing was charged \u2014 please try again later or contact the organiser.";case"gateway_currency_mismatch":case"unsupported_currency":case"mixed_currency_hold":case"price_unusable":return"These seats cannot be checked out right now because of a pricing configuration problem. Nothing was charged \u2014 please contact the organiser.";case"rate_limited":return"Too many attempts. Wait a moment and try again.";case"seats_unavailable":return"Those seats were taken while you were filling this in. Nothing was charged \u2014 please pick again.";case"booking_form_incomplete":return"The details this event asks for changed while you were choosing. Nothing was charged \u2014 please go back and try again.";default:return"We could not start the payment. Nothing was charged \u2014 please try again."}}function Te(){let e=window.Razorpay;return e?Promise.resolve(e):new Promise((r,o)=>{let l=document.querySelector(`script[src="${ne}"]`),p=l??document.createElement("script"),x=()=>{let E=window.Razorpay;E?r(E):o(new Error("razorpay_unavailable"))};p.addEventListener("load",x,{once:!0}),p.addEventListener("error",()=>o(new Error("razorpay_script_failed")),{once:!0}),!l&&(p.src=ne,p.async=!0,document.head.appendChild(p))})}function a(e,r,o){let l=document.createElement(e);return r&&(l.className=r),o!==void 0&&(l.textContent=o),l}function Me(e){ye();let r=!0,o=!1,l=(u,f,m)=>{let d=e.t?.(u,m);return d&&d!==u?d:m?f.replace(/\{(\w+)\}/g,(z,H)=>H in m?String(m[H]):z):f},p=a("div","sl-hco");p.setAttribute("role","dialog"),p.setAttribute("aria-modal","true");let x=a("div","sl-hco-card");p.appendChild(x);let E=()=>{r=!1,p.remove(),document.removeEventListener("keydown",N,!0)},F=()=>{E(),e.onCancel()};function N(u){u.key!=="Escape"||!p.isConnected||(u.stopPropagation(),u.preventDefault(),F())}document.addEventListener("keydown",N,!0);let w=a("h2","sl-hco-title","Checkout"),A=`sl-hco-t-${Math.random().toString(36).slice(2,8)}`;w.id=A,p.setAttribute("aria-labelledby",A);let S=(...u)=>{x.replaceChildren(w,...u)},K=u=>{if(!r)return;let f=a("p","sl-hco-status sl-hco-error",u);f.setAttribute("role","alert");let m=a("button","sl-hco-back","Back to seats");m.type="button",m.addEventListener("click",F),S(f,m)},_=u=>{if(!r)return;let f=a("p","sl-hco-status",u);f.setAttribute("role","status"),S(f)},U=async(u,f=!1)=>{_(f?l("checkout.confirmingSeats","Confirming your seats\u2026"):"Payment received \u2014 confirming your seats\u2026");let m=Date.now()+he;for(;r&&Date.now()<m;){try{let d=await e.orderStatus(u);if(!r)return;if(d.status==="confirmed"){o=!0,w.textContent="Your tickets are confirmed";let z=a("p","sl-hco-status",`${d.seatCount} ${d.seatCount===1?"seat":"seats"} confirmed. Your tickets \u2014 with their door QR codes \u2014 are in your email.`),H=a("dl","sl-hco-receipt"),G=(d.tickets??[]).map(O=>O.displayLabel||O.label);G.length&&H.append(a("dt",void 0,"Seats"),a("dd",void 0,G.join(", ")));let J=f||d.totalMinor===0;H.append(a("dt",void 0,J?l("checkout.price","Price"):"Paid"),a("dd",void 0,J?l("checkout.free","Free"):`${d.amountFormatted} ${d.currency}`),a("dt",void 0,"Order"),a("dd","sl-hco-ref",d.orderId));let W=a("button","sl-hco-back","Close");if(W.type="button",W.addEventListener("click",F),d.ticketUrl){let O=a("a","sl-hco-tickets","View tickets & QR codes");O.href=d.ticketUrl,O.target="_blank",O.rel="noreferrer",S(z,H,O,W)}else S(z,H,W);e.onConfirmed(d);return}if(d.status==="failed"||d.status==="expired"){K(d.status==="expired"?"Your seats were released before payment completed. Nothing was charged \u2014 please pick again.":"The payment did not complete. If you were charged, it has been refunded automatically.");return}}catch{}await new Promise(d=>setTimeout(d,ge))}!r||o||K(f?"Still confirming your booking. Once it is confirmed, your tickets will arrive by email. Nothing was charged.":"Still confirming with the payment provider. If your payment went through, your tickets will arrive by email shortly \u2014 you do not need to pay again.")};if(e.state.kind==="unavailable"){let u=be(e.state.reason,e.state.seatCount);w.textContent=u.title;let f=a("p","sl-hco-label","Seats held"),m=a("button","sl-hco-back","Back to seat map");return m.type="button",m.addEventListener("click",F),x.replaceChildren(f,w,a("p","sl-hco-status",u.body),a("p","sl-hco-note",u.detail),m),e.root.appendChild(p),m.focus(),{destroy:E}}if(e.state.kind==="resume")return e.root.appendChild(p),U(e.state.orderId),{destroy:E};let{order:P,provider:$,bookingForm:X}=e.state,L=e.state.free===!0,q=a("div","sl-hco-summary"),D=a("div","sl-hco-seats");for(let u of P.labels)D.appendChild(a("span","sl-hco-seat",u));let n=L?l("checkout.free","Free"):e.formatMoney(P.total,P.currency),t=a("div","sl-hco-total");t.append(a("span",void 0,"Total"),a("strong",void 0,n)),q.append(D,t);let i=a("form","sl-hco-form");i.noValidate=!0;let c=a("label","sl-hco-label","Email \u2014 your tickets go here"),s=a("input","sl-hco-input");s.type="email",s.required=!0,s.autocomplete="email",s.placeholder="you@example.com",s.id=`${A}-email`,c.htmlFor=s.id;let g=a("label","sl-hco-label","Name (optional)"),h=a("input","sl-hco-input");h.type="text",h.autocomplete="name",h.placeholder="Your name",h.id=`${A}-name`,g.htmlFor=h.id;let C=a("button","sl-hco-pay",L?l("checkout.confirmBooking","Confirm booking"):`Pay ${n}`);C.type="submit",C.disabled=!0;let M=a("button","sl-hco-back","Back to seats");M.type="button",M.addEventListener("click",F);let Q=new Date(P.expiresAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),y=a("p","sl-hco-note",L?`Your seats are held until ${Q}. ${l("checkout.freeNote","This event is free \u2014 nothing is charged.")}`:`Your seats are held until ${Q}. Payment is handled by ${$==="razorpay"?"Razorpay":"Stripe"} \u2014 we never see your card details.`),k=a("p","sl-hco-note");k.append("The event organizer and SeatLayer use your email to issue and manage your tickets. ");let T=a("a",void 0,"Privacy Policy");T.href="https://seatlayer.io/privacy/",T.target="_blank",T.rel="noreferrer",k.appendChild(T);let b=()=>/.+@.+\..+/.test(s.value.trim());s.addEventListener("input",()=>{C.disabled=!b()});let I=te({form:X,tickets:P.tickets??[],idPrefix:A,t:l,buyer:()=>({name:h.value.trim(),email:s.value.trim()})}),B=a("p","sl-hco-status sl-hco-error");B.setAttribute("role","alert"),B.hidden=!0;let R=u=>{B.textContent=u,B.hidden=!1},j=!1,ie=async()=>{if(!j){j=!0,C.disabled=!0,_(L?l("checkout.confirmingBooking","Confirming your booking\u2026"):"Opening secure payment\u2026");try{let u={holdId:P.holdId,buyerEmail:s.value.trim(),...h.value.trim()?{buyerName:h.value.trim()}:{},...I.payload(),bookingFormVersion:1},f=0,m;for(;;)try{m=await e.startSession(u);break}catch(d){if(!r)return;if(f>=ve||!re(d))throw d;if(f+=1,_(L?l("checkout.busyRetryingBooking","Busy right now \u2014 still confirming your booking\u2026"):l("checkout.busyRetryingPayment","Busy right now \u2014 still opening secure payment\u2026")),await new Promise(z=>setTimeout(z,Ee(d))),!r)return}if(!r)return;if(m.status==="confirmed"){U(m.orderId,!0);return}if(m.redirectUrl){me(m.orderId,e.eventKey),_("Taking you to secure payment\u2026"),window.location.assign(m.redirectUrl);return}if(m.clientPayload){let d=m.clientPayload,z=await Te();if(!r)return;_("Waiting for payment\u2026"),new z({key:d.key,order_id:d.orderId,amount:d.amount,currency:d.currency,name:d.name,prefill:d.prefill,handler:()=>{U(m.orderId)},modal:{ondismiss:()=>{r&&V()}}}).open();return}K(Y("gateway_unavailable"))}catch(u){e.onError?.(u);let f=u;if(f?.code==="booking_form_incomplete"&&I.element){V(),I.showServerErrors(f.fields);return}if(re(f)){V(),R(L?l("checkout.busyFailedBooking",Y("checkout_busy",{free:!0})):l("checkout.busyFailedPayment",Y("checkout_busy")));return}K(f?.code==="seats_unavailable"?l("checkout.seatsUnavailable",Y(f.code)):Y(f?.code,f))}}};i.addEventListener("submit",u=>{u.preventDefault(),b()&&I.validate()&&ie()}),i.append(c,s,g,h),I.element&&i.appendChild(I.element),i.append(k,B,C,M,y);let V=()=>{w.textContent="Checkout",B.hidden=!0,B.textContent="",j=!1,S(q,i),C.disabled=!b()};return V(),e.root.appendChild(p),s.focus(),{destroy:E}}export{ve as CHECKOUT_BUSY_MAX_RETRIES,Ee as checkoutBusyDelayMs,Y as errorCopy,re as isCheckoutBusy,Me as mountCheckout,be as unavailableCopy};
|