| Current File : /home/digitaw/www/wp-content/plugins/event-tickets/build/Seating/frontend/ticketsBlock.js |
(()=>{"use strict";var e,t={"0zfD":(e,t,n)=>{n.d(t,{ajaxNonce:()=>s,ajaxUrl:()=>a});const o=window?.tec?.tickets?.seating?.ajaxData,{ajaxUrl:a,ajaxNonce:s,ACTION_GET_SEAT_TYPES_BY_LAYOUT_ID:i,ACTION_INVALIDATE_MAPS_LAYOUTS_CACHE:c,ACTION_INVALIDATE_LAYOUTS_CACHE:r,ACTION_DELETE_MAP:l,ACTION_DELETE_LAYOUT:d,ACTION_ADD_NEW_LAYOUT:u,ACTION_DUPLICATE_LAYOUT:_,ACTION_POST_RESERVATIONS:f,ACTION_CLEAR_RESERVATIONS:m,ACTION_FETCH_ATTENDEES:p,ACTION_DELETE_RESERVATIONS:k,ACTION_SEAT_TYPES_UPDATED:g,ACTION_SEAT_TYPE_DELETED:y,ACTION_RESERVATIONS_UPDATED_FROM_SEAT_TYPES:h,ACTION_RESERVATION_CREATED:w,ACTION_RESERVATION_UPDATED:v,ACTION_EVENT_LAYOUT_UPDATED:T,ACTION_REMOVE_EVENT_LAYOUT:E}=o},Gn6f:(e,t,n)=>{n.d(t,{formatWithCurrency:()=>r});const{decimalSeparator:o,decimalNumbers:a,thousandSeparator:s,position:i,symbol:c}=window.tec.tickets.seating.currencyData;function r(e){const[t,n]=e.toString().split("."),r=n?"."+Number("."+n).toPrecision(a).toString().slice(2):"",l=t.toString().replace(/\./g,o).replace(/\B(?=(\d{3})+(?!\d))/g,s)+r;return"prefix"===i?`${c}${l}`:`${l}${c}`}},"Lc+o":(e,t,n)=>{function o(e,t){const n=e.replace(/{(\w*)}/g,(function(e,n){return t?.[n]||""})),o=document.createElement("template");return o.innerHTML=n.trim(),o.content.children[0]}n.d(t,{createHtmlComponentFromTemplateString:()=>o})},QiLJ:(e,t,n)=>{n.r(t),n.d(t,{addModalEventListeners:()=>fe,bootstrapIframe:()=>se,cancelReservations:()=>le,cancelReservationsViaBeacon:()=>ce,closeModal:()=>de,getReservationCancelRequest:()=>ie,setExpireDate:()=>_e});const o=window.tec.tickets.seating.serviceData,a=o.baseUrl.replace(/\/$/,""),s=o.mapsHomeUrl.replace(/\/$/,""),i=o.layoutsHomeUrl.replace(/\/$/,"");function c(){return a.split("?")[0]}o.associatedEventsUrl.replace(/\/$/,"");const r="app_postmessage_ready",l="app_postmessage_ready_for_data",d="host_postmessage_ready",u="host_postmessage_seat_type_tickets",_="app_postmessage_seats_selected",f="app_postmessage_map_created_updated",m="app_postmessage_layout_created_updated",p="app_postmessage_seat_type_created_updated",k="app_postmessage_goto_maps_home",g="app_postmessage_goto_layouts_home",y="host_postmessage_remove_reservations";var h=n("0zfD");function w(e){console.debug("Message received from service",e)}async function v(){const e=new URL(h.ajaxUrl);return e.searchParams.set("_ajax_nonce",h.ajaxNonce),e.searchParams.set("action","tec_tickets_seating_service_invalidate_layouts_cache"),200===(await fetch(e.toString(),{method:"POST"})).status||(console.error("Invalidation of layouts cache failed, clean the transients manually to fetch up-to-date layouts from the service."),!1)}const T={ready:!1,establishingReadiness:!1,actionsMap:{default:w,[f]:function(){!async function(){const e=new URL(h.ajaxUrl);e.searchParams.set("_ajax_nonce",h.ajaxNonce),e.searchParams.set("action","tec_tickets_seating_service_invalidate_maps_layouts_cache"),200===(await fetch(e.toString(),{method:"POST"})).status||console.error("Invalidation of maps and layouts cache failed, clean the transients manually to fetch up-to-date maps and layouts from the service.")}()},[m]:function(){v()},[p]:function(){v()},[k]:function(){s?window.location.href=s:console.error("Maps home url not found")},[g]:function(){i?window.location.href=i:console.error("Layouts home url not found")}},token:null};function E(e,t){T.actionsMap[e]=t}function b(e){delete T.actionsMap[e]}function S(){return T.token}let A=[];function I(e,t,n){const o=e.closest("[data-token]").dataset.token;o?e.contentWindow.postMessage({action:t,token:o,data:n||null},c()):console.error("No token found in iframe element")}function O(){if(0===A.length)return;const[e,t,n]=A[0],o=function(e){return async t=>{await e(t),A.shift(),O()}}(t);o(n.data.data)}function N(e){if(e.origin!==c()||!e.data.token||e.data.token!==S())return;const t=e.data.action;if(!t)return void console.error("No action found in message");const n=function(e){return T.actionsMap[e]||T.actionsMap.default||w}(t);A.push([t,n,e]),A.length>1||O()}async function L(e){let t;!function(e){const t=e.closest("[data-token]");if(!t)return void console.error("No token provider found in iframe element");const n=t.dataset.token;n?(function(e){T.token=e}(n),window.addEventListener("message",N)):console.error("No token found in token provider element")}(e);const n=new Promise(((n,a)=>{t=a,E(r,(()=>{b(r),T.ready=true,T.establishingReadiness=false,I(e,d),clearTimeout(o),console.debug("Readiness established."),n()}))})),o=setTimeout((()=>{t(new Error("Connection to service timed out"))}),3e3);return e.src=e.dataset.src,n}const{_x}=wp.i18n;async function C(e){if(!e)return!1;const t=e.closest(".tec-tickets-seating__iframe-container");if(!t)return!1;if(!t.dataset.token){const e=_x("Ephemeral token not found in iframe element.","Error message","event-tickets");return function(e){const t=document.getElementById("tec-tickets-seating-notice");(function(e){e&&(e.style.display="none",e.style.visibility="hidden")})(t),function(e,t){if(!e)return;const n=e.classList;n.remove("notice-success"),n.remove("notice-warning"),n.remove("notice-error"),n.add(t)}(t,"notice-error"),function(e,t){e&&(e.innerHTML="<p>"+t+"</p>")}(t,e),function(e){e&&(e.style.display="block",e.style.visibility="visible")}(t)}(t.dataset.error||e),!1}return await L(e),!0}var P=n("Lc+o");const x=window?.tec?.tickets?.seating?.frontend?.ticketsBlockData;var R=n("Gn6f");const D=window.wp.hooks,U=tec.tickets.seating.frontend.session;async function j(e){const t=new URLSearchParams(window.location.search);t.append("tec-tc-cart","redirect");const n=`${window.location.origin}${window.location.pathname}?${t}`,o=await fetch(n,{method:"POST",body:e});return!(!o.ok||!o.url||((0,U.setIsInterruptable)(!1),window.location.href=o.url,0))}const q=Object.values(x.seatTypeMap).reduce(((e,t)=>(e.push(...t.tickets.map((e=>e.ticketId))),e)),[]);(0,D.addFilter)("tec.tickets.tickets-block.getTickets","tec.tickets.seating",(function(){return q}));const{objectName:M,seatTypeMap:H,labels:V,providerClass:Y,postId:$,ajaxUrl:F,ajaxNonce:B,ACTION_POST_RESERVATIONS:W,ACTION_CLEAR_RESERVATIONS:J,sessionTimeout:G}=x;let z=null,Q=null,K=null;const X=".tec-tickets-seating__modal .tec-tickets-seating__sidebar-control--confirm";let Z=!1;const ee=Object.values(H).reduce(((e,t)=>(t.tickets.forEach((t=>{e[t.ticketId]=t})),e)),{});let te=new AbortController,ne=!0;function oe(e){e=e||document,Array.from(e.querySelectorAll(X)).forEach((e=>{e.disabled=!0}))}function ae(e,t){(e=e||document).querySelector(".tec-tickets-seating__ticket-rows").innerHTML="",t.forEach((t=>{!function(e,t){var n,o,a;e=e||document;const s=null!==(n=ee?.[t.ticketId]?.priceValue)&&void 0!==n?n:null,i=null!==(o=ee?.[t.ticketId]?.price)&&void 0!==o?o:null,c=null!==(a=ee?.[t.ticketId]?.name)&&void 0!==a?a:null;if(null===s||null===c)return;const r={seatTypeId:t.seatTypeId,ticketId:t.ticketId,price:s,color:t.seatColor,ticketName:c,seatLabel:t.seatLabel,formattedPrice:i};e.querySelector(".tec-tickets-seating__ticket-rows").appendChild(function(e){return(0,P.createHtmlComponentFromTemplateString)('<div class="tec-tickets-seating__ticket-row"\n\t\t\tdata-seat-type-id="{seatTypeId}"\n\t\t\tdata-ticket-id="{ticketId}"\n\t\t\tdata-price="{price}"\n\t\t\tdata-seat-label="{seatLabel}"\n\t\t\t>\n\t\t\t<div class="tec-tickets-seating__seat-color" style="background: {color}"></div>\n\n\t\t\t<div class="tec-tickets-seating__label">\n\t\t\t\t<div class="tec-tickets-seating__ticket-name">{ticketName}</div>\n\t\t\t\t<div class="tec-tickets-seating__seat-label">{seatLabel}</div>\n\t\t\t</div>\n\n\t\t\t<div class="tec-tickets-seating__ticket-price">{formattedPrice}</div>\n\t\t</div>',e)}(r))}(e,t)})),async function(e){await te.abort("New reservations data");const t=new AbortController,n=new URL(F);n.searchParams.set("_ajax_nonce",B),n.searchParams.set("action",W),n.searchParams.set("postId",$);let o=null;o=await fetch(n.toString(),{method:"POST",signal:t.signal,body:JSON.stringify({token:S(),reservations:e})}),te=t,o.ok||console.error("Failed to post reservations to backend")}(t.reduce(((e,t)=>(e[t.ticketId]=e[t.ticketId]||[],e[t.ticketId].push({reservationId:t.reservationId,seatTypeId:t.seatTypeId,seatLabel:t.seatLabel}),e)),{})),function(e){e=e||document;const t=Array.from(e.querySelectorAll(".tec-tickets-seating__ticket-row"));var n;t.length?function(e){e=e||document,Array.from(e.querySelectorAll(X)).forEach((e=>{e.disabled=!1}))}(e):oe(e),z.innerText=(0,R.formatWithCurrency)(t.reduce((function(e,t){return e+Number(t.dataset.price)}),0)),Q.innerText=1===(n=t.length)?V.oneTicket:V.multipleTickets.replace("{count}",n);const o=e.querySelector(".tec-tickets-seating__total");0===t.length?o.classList.add("tec-tickets-seating__total-hidden"):o.classList.remove("tec-tickets-seating__total-hidden")}(e)}async function se(e){const t=function(e){return(e=e||document).querySelector(".tec-tickets-seating__iframe-container iframe")}(e=e||document);if(!t)return console.error("Iframe element not found."),!1;!function(e){E(l,(()=>{b(l),I(e,u,H)})),E(_,(t=>{ae(e.closest(".event-tickets"),t.filter((e=>function(e){return e.seatTypeId&&e.ticketId&&e.seatColor&&e.seatLabel&&e.reservationId}(e)))),t.length?K.classList.add("tec-tickets-seating__empty-tickets-message-hidden"):K.classList.remove("tec-tickets-seating__empty-tickets-message-hidden")}))}(t);try{await async function(e){return await C(e),e}(t)}catch(e){return window.location.reload(),!1}!function(e){(e=e||document).querySelector(".tec-tickets-seating__sidebar-arrow").addEventListener("click",(()=>{const t=e.querySelector(".tec-tickets-seating__modal-sidebar");t&&t.classList.toggle("tec-tickets-seating__modal-sidebar-open")}))}(e),function(e){if(e=e||document,window&&window.innerWidth<=960){const t=e.querySelector(".tec-tickets-seating__iframe-container");t.style.height=t.clientHeight+"px",t.style.maxHeight=t.clientHeight+"px";const n=e.querySelector(".tec-tickets-seating__modal-sidebar_container");n.style.height=n.clientHeight+"px",n.style.minHeight=n.clientHeight+"px",n.style.maxHeight=n.clientHeight+"px";const o=n.querySelector(".tec-tickets-seating__modal-sidebar");o&&(o.style.position="absolute")}}(e),z=e.querySelector(".tec-tickets-seating__total-price"),Q=e.querySelector(".tec-tickets-seating__total-text"),K=e.querySelector(".tec-tickets-seating__empty-tickets-message")}function ie(){const e=new URL(F);return e.searchParams.set("_ajax_nonce",B),e.searchParams.set("action",J),e.searchParams.set("token",S()),e.searchParams.set("postId",$),e}function ce(){if(!ne)return;const e=ie();window.navigator.sendBeacon(e.toString())}function re(){Z&&(window.removeEventListener("beforeunload",ce),Z=!1)}async function le(e){if(!ne)return;const t=e?e.querySelector(".tec-tickets-seating__iframe-container iframe.tec-tickets-seating__iframe"):null;t&&I(t,y),await async function(){await te.abort("New reservations data");const e=new AbortController,t=ie(),n=await fetch(t.toString(),{signal:e.signal,method:"POST"});return te=e,!!n.ok||(console.error("Failed to remove reservations from backend"),!1)}(),(0,U.reset)(),Array.from(document.querySelectorAll(".tec-tickets-seating__ticket-rows .tec-tickets-seating__ticket-row")).forEach((e=>{e.remove()})),re()}function de(){const e=window?.[M];e&&e._hide()}async function ue(){ne=!1;const e=function(e){let t;switch(e){case"TECTicketsCommerceModule":case"TEC\\Tickets\\Commerce\\Module":t=j;break;default:t=null}return t=(0,D.applyFilters)("tec.tickets.seating.checkoutHandler",t,e),t}(Y);if(!e)return void console.error(`No checkout handler found for provider ${Y}`);re();const t=new FormData;t.append("provider",Y),t.append("attendee[optout]","1"),t.append("tickets_tickets_ar","1");const n=function(){const e=Array.from(document.querySelectorAll(".tec-tickets-seating__ticket-rows .tec-tickets-seating__ticket-row")).reduce(((e,t)=>{const n=t.dataset.ticketId;return e?.[n]?(e[n].quantity++,e[n].seat_labels=[...e[n].seat_labels,t.dataset.seatLabel]):e[n]={ticket_id:n,quantity:1,optout:"1",seat_labels:[t.dataset.seatLabel]},e}),{});return Object.values(e)}();t.append("tribe_tickets_saving_attendees","1"),t.append("tribe_tickets_ar_data",JSON.stringify({tribe_tickets_tickets:n,tribe_tickets_meta:[],tribe_tickets_post_id:$})),await e(t)||console.error("Failed to proceed to checkout."),ne=!0}function _e(e){const t=e?e?.node?.querySelector(".tec-tickets-seating__iframe-container iframe.tec-tickets-seating__iframe"):null;if(!t)return;const n=G?Number(G):900;t.src=t.src+"&expireDate="+(Date.now()+1e3*n)}function fe(){document.querySelector(".tec-tickets-seating__modal .tec-tickets-seating__sidebar-control--cancel")?.addEventListener("click",de),document.querySelector(X)?.addEventListener("click",ue),(0,U.start)();const e=window[M];e&&(e.on("hide",le),e.on("destroy",le),Z||(window.addEventListener("beforeunload",ce),Z=!0))}(async function(){return new Promise((e=>{const t=()=>{window[M]?e(window[M]):setTimeout(t,50)};t()}))})().then((e=>{e.on("show",(()=>{oe(),se(document),fe(),_e(e)}))}))}},n={};function o(e){var a=n[e];if(void 0!==a)return a.exports;var s=n[e]={exports:{}};return t[e](s,s.exports,o),s.exports}o.m=t,e=[],o.O=(t,n,a,s)=>{if(!n){var i=1/0;for(d=0;d<e.length;d++){for(var[n,a,s]=e[d],c=!0,r=0;r<n.length;r++)(!1&s||i>=s)&&Object.keys(o.O).every((e=>o.O[e](n[r])))?n.splice(r--,1):(c=!1,s<i&&(i=s));if(c){e.splice(d--,1);var l=a();void 0!==l&&(t=l)}}return t}s=s||0;for(var d=e.length;d>0&&e[d-1][2]>s;d--)e[d]=e[d-1];e[d]=[n,a,s]},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e={1490:0,4193:0,7018:0,7244:0,808:0};o.O.j=t=>0===e[t];var t=(t,n)=>{var a,s,[i,c,r]=n,l=0;if(i.some((t=>0!==e[t]))){for(a in c)o.o(c,a)&&(o.m[a]=c[a]);if(r)var d=r(o)}for(t&&t(n);l<i.length;l++)s=i[l],o.o(e,s)&&e[s]&&e[s][0](),e[s]=0;return o.O(d)},n=globalThis.webpackChunkevent_tickets=globalThis.webpackChunkevent_tickets||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})();var a=o.O(void 0,[808],(()=>o("QiLJ")));a=o.O(a),window.tec=window.tec||{},window.tec.tickets=window.tec.tickets||{},window.tec.tickets.seating=window.tec.tickets.seating||{},window.tec.tickets.seating.frontend=window.tec.tickets.seating.frontend||{},window.tec.tickets.seating.frontend.ticketsBlock=a})();