tribe.tickets=tribe.tickets||{},tribe.dialogs=tribe.dialogs||{},tribe.dialogs.events=tribe.dialogs.events||{},tribe.tickets.manualAttendees={},function(e,t){const i=e(document);t.selectors={modalWrapper:".tribe-modal__wrapper--manual-attendees",modalTitle:".tribe-modal__title",modalContent:".tribe-modal__content",formAddAttendeeTicketSelect:".tribe-tickets__manual-attendees-add-attendee-ticket-select",form:".tribe-tickets__manual-attendees-form",formFieldName:".tribe-tickets__manual-attendees-form-field-name",formFieldEmail:".tribe-tickets__manual-attendees-form-field-email",formFieldEmailResend:".tribe-tickets__manual-attendees-resend-email",formFieldEmailResendCheckbox:".tribe-tickets__manual-attendees-resend-email-input",hiddenElement:".tribe-common-a11y-hidden",validationNotice:".tribe-tickets__notice--error"},t.attendeeTicketEmail="",t.modalClose=function(i,n){const a=e(n).find(t.selectors.modalContent);t.unbindModalEvents(a)},t.bindModalClose=function(){e(tribe.dialogs.events).on("tribeDialogCloseManualAttendeesModal.tribeTickets",t.modalClose)},t.unbindModalEvents=function(e){e.find(t.selectors.formFieldEmail).off(),e.off("afterAjaxSuccess.tribeTicketsAdmin",t.bindModalEvents),e.off()},t.bindAddAttendeeTicketSelectChange=function(e,i){e.find(t.selectors.formAddAttendeeTicketSelect).on("change",(function(){const t={action:"tribe_tickets_admin_manager",request:i.request,attendeeId:i.attendeeId,eventId:i.eventId,ticketId:this.value,provider:i.provider};tribe.tickets.admin.manager.request(t,e)}))},t.bindModalEvents=function(e,i,n){const a=e.data.container,d=e.data.requestData;t.bindAddAttendeeTicketSelectChange(a,d),t.bindEmailEvents(a),t.bindForm(a)},t.handleFormSuccess=function(e,t,i){"submit"===e.data.requestData.step&&setTimeout((function(){location.reload()}),3e3)},t.handleFormSubmission=function(i){i.preventDefault();const n=e(this),a=n.closest(t.selectors.modalContent),d=a.find(t.selectors.validationNotice),o=n.serializeArray(),s=n.data("attendee-id")||null,l={action:"tribe_tickets_admin_manager",request:s?"tribe_tickets_manual_attendees_edit":"tribe_tickets_manual_attendees_add",attendeeId:s,eventId:n.data("event-id")||null,ticketId:n.data("ticket-id")||null,provider:n.data("provider")||null,step:"submit"};if(e(o).each((function(e,t){l[t.name]=t.value})),!tribe.tickets.meta.validateAttendeeTicket(a))return d.show(),void document.getElementById(t.selectors.form.className()).scrollIntoView({behavior:"smooth",block:"start"});d.hide(),tribe.tickets.admin.manager.request(l,a),a.on("afterAjaxSuccess.tribeTicketsAdmin",{container:a,requestData:l},t.handleFormSuccess)},t.bindForm=function(i){i.find(t.selectors.form).each((function(i,n){e(n).on("submit",t.handleFormSubmission)}))},t.bindEmailEvents=function(e){const i=e.find(t.selectors.formFieldEmail);t.attendeeTicketEmail=e.find(t.selectors.formFieldEmail).val()||"",i.on("input",t.handleEmailChangeCheck)},t.handleEmailChangeCheck=function(i){const n=e(i.target);t.attendeeTicketEmail.trim().toLowerCase()!==n.val().trim().toLowerCase()?t.emailReSendCheckboxShow(n):t.emailReSendCheckboxHide(n)},t.emailReSendCheckboxShow=function(e){const i=e.closest(t.selectors.form).find(t.selectors.formFieldEmailResend);i.find(t.selectors.formFieldEmailResendCheckbox).prop("checked",!0),i.removeClass(t.selectors.hiddenElement.className())},t.emailReSendCheckboxHide=function(e){const i=e.closest(t.selectors.form).find(t.selectors.formFieldEmailResend);i.find(t.selectors.formFieldEmailResendCheckbox).prop("checked",!1),i.addClass(t.selectors.hiddenElement.className())},t.modalOpen=function(i,n,a){const d=e(n),o=e(a.target).closest("button"),s=o.data("modal-title"),l=o.data("attendee-id")||null,r=o.data("event-id")||null,c=o.data("ticket-id")||null,m=o.data("provider")||null,u=l?"tribe_tickets_manual_attendees_edit":"tribe_tickets_manual_attendees_add";s&&d.find(t.selectors.modalTitle).html(s);const b=d.find(t.selectors.modalContent),f={action:"tribe_tickets_admin_manager",request:u,attendeeId:l,eventId:r,ticketId:c,provider:m};tribe.tickets.admin.manager.request(f,b),b.on("afterAjaxSuccess.tribeTicketsAdmin",{container:b,requestData:f},t.bindModalEvents)},t.bindModalOpen=function(){e(tribe.dialogs.events).on("tribeDialogShowManualAttendeesModal.tribeTickets",t.modalOpen)},t.ready=function(){t.bindModalOpen(),t.bindModalClose()},i.ready(t.ready)}(jQuery,tribe.tickets.manualAttendees),window.ticketsPlus=window.ticketsPlus||{},window.ticketsPlus.ticketsManualAttendees={};