window.tec=window.tec||{},tec.classicEditorEvents=tec.classicEditorEvents||{},tec.classicEditorEvents.lockedOptions=tec.classicEditorEvents.lockedOptions||{},dayjs.extend(window.dayjs_plugin_isoWeek),function(e,t){"use strict";t.selectors={eventStartDate:"#EventStartDate",recurrenceWeekDay:".custom-recurrence-weeks .tribe-button-field",recurrenceWeekDayInput:".custom-recurrence-weeks .tribe-button-field .tribe-button-input",recurrenceYearsDropdown:".custom-recurrence-years",weekDaysLock:".tec-events-pro-week-days-lock",weekDaysOverlay:".tec-events-pro-week-days-overlay"},t.classes={weekDayActive:"tribe-active",weekDayLocked:"tribe-button-field--locked"},t.setWeekDayActiveFromLockedState=function(e){const c=e.getAttribute("data-locked-week-day");if(!c)return;const s=e.querySelector(t.selectors.recurrenceWeekDayInput+'[value="'+c+'"]').parentNode,n=s.classList.contains(t.classes.weekDayLocked),o=s.classList.contains(t.classes.weekDayActive);n&&o||!n&&!o||s.click()},t.setWeekDayLockState=function(e,c){const s=e.classList.contains(t.classes.weekDayLocked);if(s&&c||!s&&!c)return;const n=e.classList.contains(t.classes.weekDayActive);c&&!s?(e.classList.add(t.classes.weekDayLocked),n||e.click()):!c&&s&&(e.classList.remove(t.classes.weekDayLocked),n&&e.click())},t.setLockedWeekDay=function(e){const c=e.querySelector(t.selectors.weekDaysOverlay);if(tecEventDetails?.isRdate)return;if(tec.classicEditorEvents.offStart.isRuleOffStart(e))return e.querySelectorAll(t.selectors.recurrenceWeekDayInput).forEach((function(e){t.setWeekDayLockState(e.parentNode,!1)})),e.removeAttribute("data-locked-week-day"),void c.removeAttribute("style");const s=e.getAttribute("data-locked-week-day"),n=tec.classicEditorEvents.eventDate.eventStart.moment.isoWeekday();if(s===n)return;const o=e.querySelector(t.selectors.recurrenceWeekDayInput+'[value="'+n+'"]').parentNode,r=o.offsetLeft,i=o.offsetWidth;if(r&&i){c.style.left=r+"px",c.style.width=i+"px";const s=r+i-14;e.querySelector(t.selectors.weekDaysLock).style.left=s+"px"}e.querySelectorAll(t.selectors.recurrenceWeekDayInput).forEach((function(e){const c=e.getAttribute("value")===String(n);t.setWeekDayLockState(e.parentNode,c)})),e.setAttribute("data-locked-week-day",n)},t.hideMonthInlineText=function(e){tec.classicEditorEvents.offStart.isRuleOffStart(e)||(e.querySelectorAll(".custom-recurrence-months > .tribe-field-inline-text:not(:first-child):not(:last-child):not(.first-label-in-line)").forEach((function(e){e.style.display="none"})),e.querySelector(".custom-recurrence-months .recurrence-month-on-the > .tribe-field-inline-text").style.display="none")},t.setLockedYearMonthIcon=function(c){if(tec.classicEditorEvents.offStart.isRuleOffStart(c))return;const s=e(c).find(t.selectors.recurrenceYearsDropdown).val(),n=String(tec.classicEditorEvents.eventDate.eventStart.moment.month()+1),o=s.indexOf(n);if(-1===o)return;const r=c.querySelectorAll(t.selectors.recurrenceYearsDropdown+" + .select2 .select2-selection__choice")[o];if(r.classList.contains("select2-selection__choice--locked")||r.classList.add("select2-selection__choice--locked"),!r.querySelector(".tec-events-pro-month-lock")){const e=document.createElement("span");e.classList.add("tec-events-pro-month-lock"),e.classList.add("dashicons"),e.classList.add("dashicons-lock"),e.title=tribe_events_pro_recurrence_strings.customTablesV1.recurrence.lockIconTooltip,r.appendChild(e)}},t.setLockedYearMonth=function(c){if(tec.classicEditorEvents.offStart.isRuleOffStart(c))return;const s=e(c).find(t.selectors.recurrenceYearsDropdown),n=s.val(),o=n.slice(),r=String(tec.classicEditorEvents.eventDate.eventStart.moment.month()+1);if(tec.classicEditorEvents.eventDate.didEventStartMonthChange()){const e=String(tec.classicEditorEvents.eventDate.eventStart.prevMoment.month()+1),t=o.indexOf(e);-1!==t&&o.splice(t,1)}o.includes(r)||o.push(r),o.every((function(e,t){return e===n[t]}))||s.val(o).trigger("change")},t.hideYearlyInlineText=function(e){tec.classicEditorEvents.offStart.isRuleOffStart(e)||e.querySelectorAll('[data-condition="Yearly"] .tribe-dame-day-select > span > .tribe-field-inline-text').forEach((function(e){e.style.display="none"}))},t.syncLockedOptionsRuleState=function(e){document.querySelectorAll(".tribe-event-"+e).forEach((function(e){const c=e.getAttribute("data-recurrence-type");if(["Weekly","Monthly","Yearly"].includes(c))switch(c){case"Weekly":t.setLockedWeekDay(e),t.setWeekDayActiveFromLockedState(e);break;case"Monthly":t.hideMonthInlineText(e),tec.classicEditorEvents.dayOfMonth.syncDateDropdown(e,c);break;case"Yearly":t.hideYearlyInlineText(e),t.setLockedYearMonth(e),t.setLockedYearMonthIcon(e),tec.classicEditorEvents.dayOfMonth.syncDateDropdown(e,c)}}))}}(jQuery,tec.classicEditorEvents.lockedOptions),window.tec=window.tec||{},window.tec.eventsPro=window.tec.eventsPro||{},window.tec.eventsPro.customTablesV1=window.tec.eventsPro.customTablesV1||{},window.tec.eventsPro.customTablesV1.classicEditorEventsLockedOptions={};