diff --git a/assets/css/sync.css b/assets/css/sync.css index 56747b7677..b5df682716 100644 --- a/assets/css/sync.css +++ b/assets/css/sync.css @@ -1,5 +1,306 @@ -#ep-sync-output { +.elasticpress_page_elasticpress-sync .button:disabled { + cursor: not-allowed; +} + +.ep-sync-box__progress-wrapper { + display: none; +} + +.ep-sync-box__output { + background-color: #1a1e24; display: none; + margin-bottom: 20px; + max-height: 200px; + overflow-y: scroll; + position: relative; +} + +.ep-sync-box__output_active { + display: block; +} + +.ep-sync-box__output-wrapper { + color: #fff; + margin-left: 30px; + min-height: 200px; +} + +.ep-sync-box__output-line { position: relative; - z-index: 2; +} + +.ep-sync-box__output-line-number { + background-color: #303030; + color: #999; + left: -30px; + min-width: 20px; + padding: 0 3px 0 5px; + position: absolute; + text-align: right; + white-space: nowrap; +} + +.ep-sync-box__output-line-text { + font-size: 12px; + padding-left: 14px; +} + +.ep-sync-box__output-tabs { + align-items: center; + display: flex; +} + +.ep-sync-box__output-tabs_hide { + display: none; +} + +.ep-sync-box__output-tab { + color: #1e1e1e; + padding: 16px; +} + +.ep-sync-box__output-tab:hover { + cursor: pointer; +} + +.ep-sync-box__output-tab_active { + border-bottom: 4px solid #00a0d2; + padding-bottom: 12px; +} + +.ep-sync-box__output-tab_active:hover { + cursor: default; +} + +.ep-sync-box__button-text { + height: 21px; +} + +.elasticpress_page_elasticpress-sync .card { + max-width: 1200px; + + & .ep-sync-box__description-actions { + display: flex; + flex-direction: column; + + @media (min-width: 768px) { + flex-direction: row; + justify-content: space-between; + } + } + + & .ep-sync-box__description { + + @media (min-width: 768px) { + width: 69%; + } + } + + & .ep-sync-box__action { + align-items: center; + display: flex; + flex-direction: column; + margin-top: 40px; + + @media (min-width: 768px) { + width: 30%; + } + + & .ep-sync-box__button { + align-items: center; + display: flex; + font-size: 24px; + font-weight: 700; + height: 68px; + justify-content: space-between; + padding: 20px 40px; + width: 228px; + } + + & .ep-sync-box__icon-button { + font-size: 28px; + height: 28px; + width: 28px; + + } + + & .ep-sync-box__learn-more-link { + margin-top: 19px; + } + + } + + & .ep-sync-box__description_text { + font-size: 18px; + } + + & .ep-last-sync { + margin-bottom: 12px; + } + + & .ep-last-sync__title { + font-size: 20px; + font-weight: 700; + margin-bottom: 0.5em; + } + + & .ep-last-sync__date { + background-color: #f1f1f1; + padding: 6px; + } + + & .ep-sync-box__buttons { + display: flex; + + } + + & .ep-sync-box__button-resume, + & .ep-sync-box__button-pause, + & .ep-sync-box__button-stop { + align-items: center; + display: none; + flex-direction: column; + height: 68px; + justify-content: center; + width: 100px; + } + + & .ep-sync-box__button-stop { + background-color: #00a0d2; + border-color: #00a0d2; + margin-left: 24px; + } + + & .ep-sync-box__progress { + align-items: normal; + display: flex; + flex-direction: column; + margin-bottom: 5px; + margin-top: 19px; + + @media (min-width: 768px) { + align-items: center; + flex-direction: row; + } + } + + & .ep-sync-box__sync-in-progress { + display: flex; + flex-direction: row; + + @media (min-width: 768px) { + width: 30%; + } + } + + & .ep-sync-box__progressbar { + background-color: #f1f1f1; + border-radius: 24px; + height: 20px; + margin: 15px 0; + position: relative; + width: 100%; + + @media (min-width: 768px) { + margin: 0; + width: 65%; + } + } + + & .ep-sync-box__progressbar_animated { + background-color: rgba(0, 160, 210, 0.3); + color: #333; + display: block; + height: 100%; + margin: 0; + text-align: center; + transition: width 0.5s ease-in-out; + width: 0; + } + + & .ep-sync-box__progressbar_complete { + background-color: #46b450; + color: #fff; + } + + & .ep-sync-box__sync-in-progress-info { + display: flex; + flex-direction: column; + margin-left: 12px; + } + + & .ep-sync-box__progress-info { + font-size: 14px; + font-weight: 500; + margin-bottom: 5px; + } + + & .ep-sync-box__start-time { + color: #00a0d2; + font-size: 14px; + } + + & .ep-sync-box__start-time-date { + color: #333; + } +} + +.elasticpress_page_elasticpress-sync .ep-delete-data-and-sync { + margin-top: 40px; + + & .card { + margin-top: 17px; + } + + & .ep-delete-data-and-sync__title { + color: #1d2327; + font-size: 18px; + font-weight: 400; + } + + & .ep-delete-data-and-sync__warning { + align-items: flex-start; + display: flex; + + @media (min-width: 768px) { + width: 69%; + } + } + + & .ep-delete-data-and-sync__warning-icon { + margin-right: 9px; + margin-top: 17px; + } + + & .ep-delete-data-and-sync__button { + background-color: rgba(181, 39, 39, 0.03); + border: 1px solid #b52727; + color: #b52727; + margin: 5px 0 12px; + } + + & .ep-delete-data-and-sync__button-cancel { + display: none; + } + + & .ep-sync-box__action { + flex-direction: column; + height: auto; + justify-content: center; + margin-top: 0; + width: 100%; + + @media (min-width: 768px) { + flex-direction: row; + height: 68px; + justify-content: space-between; + } + } + + & .ep-sync-box__buttons { + + @media (min-width: 768px) { + margin-right: 5%; + } + } } diff --git a/assets/js/sync.js b/assets/js/sync.js index b8af83ed74..43c899a832 100644 --- a/assets/js/sync.js +++ b/assets/js/sync.js @@ -1,26 +1,200 @@ +import apiFetch from '@wordpress/api-fetch'; + /* eslint-disable camelcase, no-use-before-define */ const { ajaxurl, epDash, history } = window; +const { __, sprintf } = wp.i18n; + +// Main elements of sync page +const syncBox = document.querySelector('.ep-sync-data'); +const deleteAndSyncBox = document.querySelector('.ep-delete-data-and-sync'); + +// It could be the syncBox or deleteAndSyncBox +let activeBox; + +// Buttons to start a sync or delete data +const syncButton = syncBox.querySelector('.ep-sync-box__button-sync'); +const deleteAndSyncButton = deleteAndSyncBox.querySelector( + '.ep-delete-data-and-sync__button-delete', +); + +// Log elements +const syncBoxFulllogTab = document.querySelector('.ep-sync-data .ep-sync-box__output-tab-fulllog'); +const syncBoxOutputFulllog = document.querySelector('.ep-sync-data .ep-sync-box__output-fulllog'); +const syncBoxErrorTab = document.querySelector('.ep-sync-data .ep-sync-box__output-tab-error'); +const syncBoxOutputError = document.querySelector('.ep-sync-data .ep-sync-box__output-error'); + +const deleteBoxFulllogTab = document.querySelector( + '.ep-delete-data-and-sync .ep-sync-box__output-tab-fulllog', +); +const deleteBoxErrorTab = document.querySelector( + '.ep-delete-data-and-sync .ep-sync-box__output-tab-error', +); +const deleteBoxOutputFulllog = document.querySelector( + '.ep-delete-data-and-sync .ep-sync-box__output-fulllog', +); +const deleteBoxOutputError = document.querySelector( + '.ep-delete-data-and-sync .ep-sync-box__output-error', +); + +syncButton.addEventListener('click', function () { + activeBox = syncBox; + + disableButtonsInDeleteBox(); + + syncButton.style.display = 'none'; + updateDisabledAttribute(syncButton, true); + + const learnMoreLink = activeBox.querySelector('.ep-sync-box__learn-more-link'); + learnMoreLink.style.display = 'none'; + + showPauseStopButtons(); + showProgress(); + addLineToOutput(__('Indexing data…', 'elasticpress')); + + const progressInfoElement = activeBox.querySelector('.ep-sync-box__progress-info'); + const progressBar = activeBox.querySelector('.ep-sync-box__progressbar_animated'); + const startDateTime = activeBox.querySelector('.ep-sync-box__start-time-date'); + + progressInfoElement.innerText = __('Sync in progress', 'elasticpress'); + + progressBar.style.width = `0`; + progressBar.innerText = ``; + + startDateTime.innerText = ''; + + startSyncProcess(); +}); + +deleteAndSyncButton.addEventListener('click', deleteAndSync); + +function deleteAndSync() { + activeBox = deleteAndSyncBox; + + disableButtonsInSyncBox(); + updateDisabledAttribute(deleteAndSyncButton, true); + showPauseStopButtons(); + showProgress(); + + addLineToOutput(__('Deleting data…', 'elasticpress')); + + const progressInfoElement = activeBox.querySelector('.ep-sync-box__progress-info'); + const progressBar = activeBox.querySelector('.ep-sync-box__progressbar_animated'); + const startDateTime = activeBox.querySelector('.ep-sync-box__start-time-date'); + + progressInfoElement.innerText = __('Deleting in progress', 'elasticpress'); + + progressBar.style.width = `0`; + progressBar.innerText = ``; + + startDateTime.innerText = ''; + + startSyncProcess(true); +} + +/** + * Show Pause and Stop buttons on the active box + */ +function showPauseStopButtons() { + if (activeBox) { + showStopButton(); + showPauseButton(); + } +} + +/** + * Hide Pause and Stop buttons on the active box + */ +function hidePauseStopButtons() { + hideStopButton(); + hidePauseButton(); +} + +/** + * Show Pause button on the active box + */ +function showPauseButton() { + if (activeBox) { + const pauseButton = activeBox.querySelector('.ep-sync-box__button-pause'); + + updateDisabledAttribute(pauseButton, false); + + pauseButton.style.display = 'flex'; + } +} + +/** + * Hide Pause button on the active box + */ +function hidePauseButton() { + if (activeBox) { + const pauseButton = activeBox.querySelector('.ep-sync-box__button-pause'); + + pauseButton.style.display = 'none'; + } +} + +/** + * Show Resume button on the active box + */ +function showResumeButton() { + if (activeBox) { + const resumeButton = activeBox.querySelector('.ep-sync-box__button-resume'); + + updateDisabledAttribute(resumeButton, false); + + resumeButton.style.display = 'flex'; + } +} + +/** + * Hide Pause button on the active box + */ +function hideResumeButton() { + if (activeBox) { + const resumeButton = activeBox.querySelector('.ep-sync-box__button-resume'); + + resumeButton.style.display = 'none'; + } +} + +/** + * Show Stop button on the active box + */ +function showStopButton() { + if (activeBox) { + const stopButton = activeBox.querySelector('.ep-sync-box__button-stop'); + + updateDisabledAttribute(stopButton, false); + + stopButton.style.display = 'flex'; + } +} -const overlay = document.querySelectorAll('.error-overlay'); -const progressBar = document.querySelectorAll('.progress-bar'); -const allButtons = { - start: document.querySelectorAll('.start-sync'), - resume: document.querySelectorAll('.resume-sync'), - pause: document.querySelectorAll('.pause-sync'), - cancel: document.querySelectorAll('.cancel-sync'), -}; -const syncStatusText = document.querySelectorAll('.sync-status'); -const $startSyncButton = jQuery(document.getElementsByClassName('start-sync')); -const $resumeSyncButton = jQuery(document.getElementsByClassName('resume-sync')); -const $pauseSyncButton = jQuery(document.getElementsByClassName('pause-sync')); -const $cancelSyncButton = jQuery(document.getElementsByClassName('cancel-sync')); -const epSyncOutput = document.getElementById('ep-sync-output'); +/** + * Hide Stop button on the active box + */ +function hideStopButton() { + if (activeBox) { + const stopButton = activeBox.querySelector('.ep-sync-box__button-stop'); + + stopButton.style.display = 'none'; + } +} + +function showProgress() { + const progressWrapper = activeBox?.querySelector('.ep-sync-box__progress-wrapper'); + + if (progressWrapper?.style) { + progressWrapper.style.display = 'block'; + } +} let syncStatus = 'sync'; -let currentSyncItem; let syncStack; let processed = 0; let toProcess = 0; +let totalProcessed = 0; +let totalErrors = 0; if (epDash.index_meta) { if (epDash.index_meta.method === 'cli') { @@ -34,11 +208,7 @@ if (epDash.index_meta) { processed = epDash.index_meta.offset; toProcess = epDash.index_meta.found_items; - if (epDash.index_meta.current_sync_item) { - currentSyncItem = epDash.index_meta.current_sync_item; - } - - if (epDash.index_meta.site_stack) { + if (epDash.index_meta.sync_stack) { syncStack = epDash.index_meta.sync_stack; } @@ -48,149 +218,87 @@ if (epDash.index_meta) { } else { syncStatus = 'pause'; } + activeBox = epDash.index_meta?.put_mapping ? deleteAndSyncBox : syncBox; + + disableButtonsInSyncBox(); + disableButtonsInDeleteBox(); + + if (activeBox === syncBox) { + syncButton.style.display = 'none'; + + const learnMoreLink = activeBox.querySelector('.ep-sync-box__learn-more-link'); + + learnMoreLink.style.display = 'none'; + } + + showResumeButton(); + showStopButton(); + + showProgress(); + updateSyncDash(); } } else if (epDash.auto_start_index) { - // Start a new sync automatically - syncStatus = 'initialsync'; - - updateSyncDash(); - - syncStatus = 'sync'; + deleteAndSync(); history.pushState( {}, document.title, document.location.pathname + document.location.search.replace(/&do_sync/, ''), ); - - sync(true); -} - -/** - * Show and hide buttons. - * - * @param {Array} visibleButtons Buttons that should be visible. - */ -function makeButtonsVisible(visibleButtons) { - Object.keys(allButtons).forEach((key) => { - allButtons[key].forEach((button) => { - button.style.display = visibleButtons.includes(key) ? 'inline' : 'none'; - }); - }); -} - -/** - * Change the sync status text and show/hide the element if needed. - * - * @param {string} newText New sync status text. - */ -function updateSyncText(newText) { - syncStatusText.forEach((syncStatus) => { - syncStatus.innerText = newText; - syncStatus.style.display = newText ? 'inline' : 'none'; - }); } /** - * Show or hide the progress bar(s). + * Change the disabled attribute of an element * - * @param {boolean} display Wheter the progress bar(s) should or should not be visible. + * @param {HTMLElement} element Element to be updated + * @param {boolean} value The value used in disabled attribute */ -function showProgressBar(display = true) { - progressBar.forEach((bar) => { - bar.style.display = display ? 'block' : 'none'; - }); -} - -/** - * Show or hide the overlay(s). - * - * @param {boolean} display Wheter the overlay(s) should or should not be visible. - */ -function showOverlay(display = true) { - overlay.forEach((overlay) => { - if (display) { - overlay.classList.add('syncing'); - } else { - overlay.classList.remove('syncing'); - } - }); -} - -/** - * Get the indexable label from the global object. If not set, default to the indexable slug. - * - * @param {string} indexableSlug The indexable slug - * @param {string} type Plural or singular. Defaults to plural. - * @return {string} The indexable label - */ -function getIndexableLabel(indexableSlug, type = 'plural') { - const labels = epDash.sync_indexable_labels[indexableSlug]; - - return labels?.[type].toLowerCase() || `${indexableSlug}s`; +function updateDisabledAttribute(element, value) { + element.disabled = value; } /** * Update dashboard with syncing information */ function updateSyncDash() { - let text; - - const progressBarWidth = - processed === 0 ? 1 : (parseInt(processed, 10) / parseInt(toProcess, 10)) * 100; - progressBar.forEach((bar) => { - bar.style.width = `${progressBarWidth}%`; - }); + const progressBar = activeBox.querySelector('.ep-sync-box__progressbar_animated'); + + const progressBarWidth = (parseInt(processed, 10) / parseInt(toProcess, 10)) * 100; + + if ( + typeof progressBarWidth === 'number' && + !Number.isNaN(progressBarWidth) && + Number.isFinite(progressBarWidth) + ) { + const width = Math.min(100, progressBarWidth); + progressBar.style.width = `${width}%`; + progressBar.innerText = `${Math.trunc(width)}%`; + } const isSyncing = ['initialsync', 'sync', 'pause', 'wpcli'].includes(syncStatus); if (isSyncing) { - showProgressBar(); - showOverlay(); + progressBar.classList.remove('ep-sync-box__progressbar_complete'); } else { - showProgressBar(false); - showOverlay(false); + const progressInfoElement = activeBox.querySelector('.ep-sync-box__progress-info'); - setTimeout(() => { - updateSyncText(''); - }, 7000); + progressInfoElement.innerText = 'Sync completed'; - makeButtonsVisible(['start']); - } + progressBar.classList.add('ep-sync-box__progressbar_complete'); - if (syncStatus === 'initialsync') { - updateSyncText(epDash.sync_initial); - makeButtonsVisible(['pause']); - } else if (syncStatus === 'sync') { - makeButtonsVisible(['pause']); - } else if (syncStatus === 'pause') { - text = epDash.sync_paused; - - updateSyncText(text); - makeButtonsVisible(['cancel', 'resume']); - } else if (syncStatus === 'wpcli') { - text = epDash.sync_wpcli; - - if (currentSyncItem?.indexable) { - text += ` ${parseInt(processed, 10)}/${parseInt(toProcess, 10)} ${getIndexableLabel( - currentSyncItem.indexable, - )}`; - } + updateDisabledAttribute(deleteAndSyncButton, false); + updateDisabledAttribute(syncButton, false); - if (currentSyncItem?.url) { - text += ` (${currentSyncItem.url})`; - } + hidePauseStopButtons(); + hideResumeButton(); + + syncButton.style.display = 'flex'; + + const learnMoreLink = activeBox.querySelector('.ep-sync-box__learn-more-link'); - updateSyncText(text); - makeButtonsVisible(['cancel']); - } else if (syncStatus === 'error') { - updateSyncText(epDash.sync_error); - } else if (syncStatus === 'cancel') { - updateSyncText(''); - } else if (syncStatus === 'finished') { - updateSyncText(epDash.sync_complete); - } else if (syncStatus === 'interrupt') { - updateSyncText(epDash.sync_interrupted); + if (learnMoreLink?.style) { + learnMoreLink.style.display = 'block'; + } } } @@ -198,51 +306,149 @@ function updateSyncDash() { * Cancel a sync */ function cancelSync() { - jQuery.ajax({ - method: 'post', - url: ajaxurl, - data: { + apiFetch({ + path: ajaxurl, + method: 'POST', + body: new URLSearchParams({ action: 'ep_cancel_index', nonce: epDash.nonce, - }, + }), + }).then(() => { + toProcess = 0; + processed = 0; + totalProcessed = 0; }); } function cliSync() { - jQuery - .ajax({ - method: 'post', - url: ajaxurl, - data: { - action: 'ep_cli_index', - nonce: epDash.nonce, - }, - }) - .done((response) => { - if (syncStatus === 'interrupt') { + const requestSettings = { + path: ajaxurl, + method: 'POST', + body: new URLSearchParams({ + action: 'ep_cli_index', + nonce: epDash.nonce, + }), + }; + + apiFetch(requestSettings).then((response) => { + if (syncStatus === 'interrupt') { + return; + } + + if (syncStatus === 'wpcli') { + toProcess = response.data?.total_items; + processed = response.data?.items_indexed; + + updateSyncDash(); + + if (response.data?.indexing) { + cliSync(); return; } + } - if (syncStatus === 'wpcli') { - toProcess = response.data?.total_items; - processed = response.data?.items_indexed; + syncStatus = 'finished'; + updateSyncDash(); + }); +} - currentSyncItem = { - indexable: response.data?.slug, - url: response.data?.url, - }; +/** + * Add a line to the active output + * + * @param {string} text Message to show on output + */ +function addLineToOutput(text) { + if (activeBox) { + const wrapperElement = activeBox.querySelector('.ep-sync-box__output-wrapper'); + + const lastLineNumberElement = activeBox.querySelector( + '.ep-sync-box__output-line:last-child .ep-sync-box__output-line-number', + ); + const lastLineNumber = Number(lastLineNumberElement?.innerText); + + const lineNumber = document.createElement('div'); + lineNumber.className = 'ep-sync-box__output-line-number'; + lineNumber.innerText = + typeof lastLineNumber === 'number' && !Number.isNaN(lastLineNumber) + ? lastLineNumber + 1 + : 1; + + const lineText = document.createElement('div'); + lineText.className = 'ep-sync-box__output-line-text'; + lineText.innerText = text; + + const line = document.createElement('div'); + line.className = 'ep-sync-box__output-line'; + line.append(lineNumber); + line.append(lineText); + + wrapperElement.append(line); + + const outputElement = activeBox.querySelector('.ep-sync-box__output_active'); + outputElement.scrollTo(0, wrapperElement.scrollHeight); + } +} - updateSyncDash(); +function addErrorToOutput(text) { + if (activeBox) { + const wrapperElement = activeBox.querySelector( + '.ep-sync-box__output-error .ep-sync-box__output-wrapper', + ); + + const lastLineNumberElement = activeBox.querySelector( + '.ep-sync-box__output-error .ep-sync-box__output-line:last-child .ep-sync-box__output-line-number', + ); + const lastLineNumber = Number(lastLineNumberElement?.innerText); + + const lineNumber = document.createElement('div'); + lineNumber.className = 'ep-sync-box__output-line-number'; + lineNumber.innerText = + typeof lastLineNumber === 'number' && !Number.isNaN(lastLineNumber) + ? lastLineNumber + 1 + : 1; + + const lineText = document.createElement('div'); + lineText.className = 'ep-sync-box__output-line-text'; + lineText.innerText = text; + + const line = document.createElement('div'); + line.className = 'ep-sync-box__output-line'; + line.append(lineNumber); + line.append(lineText); + + wrapperElement.append(line); + + const outputElement = activeBox.querySelector('.ep-sync-box__output-error'); + outputElement.scrollTo(0, wrapperElement.scrollHeight); + } +} - if (response.data?.indexing) { - cliSync(); - return; - } - } +/** + * Update the start date time on active box + * + * @param {string} value The date time value + */ +function updateStartDateTime(value) { + if (value) { + const startDateTime = activeBox.querySelector('.ep-sync-box__start-time-date'); - syncStatus = 'finished'; - updateSyncDash(); - }); + if (startDateTime) { + startDateTime.innerText = value; + } + } +} + +/** + * Interrupt the sync process + * + * @param {boolean} value True to interrupt the sync process + */ +function shouldInterruptSync(value) { + if (value) { + syncStatus = 'interrupt'; + updateSyncDash(); + cancelSync(); + } } /** @@ -251,26 +457,43 @@ function cliSync() { * @param {boolean} putMapping Whetever mapping should be sent or not. */ function sync(putMapping = false) { - jQuery - .ajax({ - method: 'post', - url: ajaxurl, - data: { - action: 'ep_index', - put_mapping: putMapping ? 1 : 0, - nonce: epDash.nonce, - }, - }) - .done((response) => { - epSyncOutput.innerHTML += `${response.data.message}\n`; - epSyncOutput.scrollTop = epSyncOutput.scrollHeight; - epSyncOutput.style.display = 'block'; - - if (response.data?.index_meta?.should_interrupt_sync) { - syncStatus = 'interrupt'; - updateSyncDash(); - cancelSync(); + const requestSettings = { + path: ajaxurl, + method: 'POST', + body: new URLSearchParams({ + action: 'ep_index', + put_mapping: putMapping ? 1 : 0, + nonce: epDash.nonce, + }), + }; + + apiFetch(requestSettings) + .then((response) => { + if (response.data.index_meta?.current_sync_item?.failed) { + const message = response.data?.message; + if (Array.isArray(message)) { + message.forEach((item) => { + addErrorToOutput(item); + addLineToOutput(item); + }); + const errorTab = activeBox.querySelector('.ep-sync-box__output-tab-error'); + + totalErrors += response.data.index_meta.current_sync_item.failed; + + errorTab.innerText = sprintf( + // translators: Number of errors + __('Errors (%d)', 'elasticpress'), + totalErrors, + ); + } else if (typeof message === 'string') { + addErrorToOutput(message); + addLineToOutput(message); + } + } else { + addLineToOutput(response.data.message); } + updateStartDateTime(response.data?.index_meta?.start_date_time); + shouldInterruptSync(response.data?.index_meta?.should_interrupt_sync); if (response.data?.method === 'cli') { syncStatus = 'wpcli'; @@ -284,36 +507,60 @@ function sync(putMapping = false) { if (!response.data.index_meta) { syncStatus = 'finished'; + + const lastSyncStatusIcon = document.querySelector('.ep-last-sync__icon-status'); + const lastSyncStatus = document.querySelector('.ep-last-sync__status'); + const lastSyncDate = document.querySelector('.ep-last-sync__date'); + + lastSyncStatusIcon.src = response.data.totals.failed + ? lastSyncStatusIcon.src?.replace(/thumbsup/, 'thumbsdown') + : lastSyncStatusIcon.src?.replace(/thumbsdown/, 'thumbsup'); + lastSyncStatus.innerText = response.data.totals.failed + ? __('Sync unsuccessful on ', 'elasticpress') + : __('Sync success on ', 'elasticpress'); + lastSyncDate.innerText = + response.data.totals.end_date_time || lastSyncDate.innerText; + updateSyncDash(); - epSyncOutput.innerHTML += `===============================\n`; - epSyncOutput.scrollTop = epSyncOutput.scrollHeight; + addLineToOutput('==============================='); if (epDash.install_sync) { document.location.replace(epDash.install_complete_url); } + activeBox = undefined; + + processed = 0; + toProcess = 0; + totalProcessed = 0; + totalErrors = 0; + return; } - toProcess = response.data.index_meta.found_items; - processed = response.data.index_meta.offset; + if (!toProcess) { + toProcess = response.data?.index_meta?.current_sync_item?.found_items; - if (response.data.sync_stack) { - syncStack = response.data.index_meta.sync_stack; + if (response.data?.index_meta?.sync_stack) { + syncStack = response.data.index_meta.sync_stack; + + toProcess = syncStack?.reduce((previousValue, currentSync) => { + return previousValue + currentSync.found_items; + }, toProcess); + } } - if (response.data.index_meta.current_sync_item) { - currentSyncItem = response.data.index_meta.current_sync_item; + if (response.data.index_meta.offset === 0 && processed > 0) { + totalProcessed = processed; } + processed = totalProcessed + response.data.index_meta.offset; + updateSyncDash(); - if (syncStatus === 'sync') { - updateSyncText(response.data.message); - } sync(putMapping); }) - .error((response) => { + .catch((response) => { if ( response && response.status && @@ -325,43 +572,154 @@ function sync(putMapping = false) { cancelSync(); } + + updateDisabledAttribute(syncButton, false); + updateDisabledAttribute(deleteAndSyncButton, false); }); } -$startSyncButton.on('click', (event) => { +/** + * Start sync process + * + * @param {boolean} putMapping Determines whether to send the mapping and delete all data before sync. + */ +function startSyncProcess(putMapping) { syncStatus = 'initialsync'; - updateSyncDash(); + const progressWrapperElement = activeBox.querySelector('.ep-sync-box__progress-wrapper'); + const progressInfoElement = activeBox.querySelector('.ep-sync-box__progress-info'); + const progressBar = activeBox.querySelector('.ep-sync-box__progressbar_animated'); + const startDateTime = activeBox.querySelector('.ep-sync-box__start-time-date'); + + progressWrapperElement.style.display = 'block'; + progressInfoElement.innerText = __('Sync in progress', 'elasticpress'); + + progressBar.style.width = `0`; + progressBar.innerText = ``; - // On initial sync, remove dashboard warnings that dont make sense - jQuery( - '[data-ep-notice="no-sync"], [data-ep-notice="auto-activate-sync"], [data-ep-notice="upgrade-sync"]', - ).remove(); + startDateTime.innerText = ''; + + updateSyncDash(); syncStatus = 'sync'; - const putMapping = event.target.classList.contains('start-sync-put-mapping'); sync(putMapping); +} + +/** + * Disable buttons in the Sync box + */ +function disableButtonsInSyncBox() { + const buttons = syncBox.querySelectorAll('.ep-sync-data button'); + + buttons.forEach((button) => updateDisabledAttribute(button, true)); +} + +/** + * Disable buttons in the Delete box + */ +function disableButtonsInDeleteBox() { + const buttons = deleteAndSyncBox.querySelectorAll('.ep-delete-data-and-sync button'); + + buttons.forEach((button) => updateDisabledAttribute(button, true)); +} + +document.querySelectorAll('.ep-sync-box__button-pause')?.forEach((button) => { + button?.addEventListener('click', function () { + syncStatus = 'pause'; + + const progressInfoElement = activeBox?.querySelector('.ep-sync-box__progress-info'); + + if (progressInfoElement?.innerText) { + progressInfoElement.innerText = __('Sync paused', 'elasticpress'); + } + + updateSyncDash(); + + hidePauseButton(); + showResumeButton(); + + addLineToOutput(__('Sync paused', 'elasticpress')); + }); }); -$pauseSyncButton.on('click', () => { - syncStatus = 'pause'; +document.querySelectorAll('.ep-sync-box__button-resume')?.forEach((button) => { + button?.addEventListener('click', function () { + syncStatus = 'sync'; - updateSyncDash(); + const progressInfoElement = activeBox.querySelector('.ep-sync-box__progress-info'); + + progressInfoElement.innerText = __('Sync in progress', 'elasticpress'); + + updateSyncDash(); + + hideResumeButton(); + showPauseButton(); + + sync(); + }); }); -$resumeSyncButton.on('click', () => { - syncStatus = 'sync'; +document.querySelectorAll('.ep-sync-box__button-stop')?.forEach((button) => { + button?.addEventListener('click', function () { + syncStatus = syncStatus === 'wpcli' ? 'interrupt' : 'cancel'; - updateSyncDash(); + const progressInfoElement = activeBox.querySelector('.ep-sync-box__progress-info'); + const progressBar = activeBox.querySelector('.ep-sync-box__progressbar_animated'); + + updateSyncDash(); + + cancelSync(); + + progressInfoElement.innerText = __('Sync stopped', 'elasticpress'); + + progressBar.style.width = `0`; + progressBar.innerText = ``; + + addLineToOutput(__('Sync stopped', 'elasticpress')); + }); +}); - sync(); +document.querySelectorAll('.ep-sync-box__show-hide-log')?.forEach((element) => { + element.addEventListener('click', function (event) { + event.preventDefault(); + + if (element.nextElementSibling?.classList?.toggle('ep-sync-box__output-tabs_hide')) { + element.innerText = __('Show log', 'elasticpress'); + } else { + element.innerText = __('Hide log', 'elasticpress'); + } + }); }); -$cancelSyncButton.on('click', () => { - syncStatus = syncStatus === 'wpcli' ? 'interrupt' : 'cancel'; +syncBoxFulllogTab.addEventListener('click', function () { + syncBoxFulllogTab.classList.add('ep-sync-box__output-tab_active'); + syncBoxOutputFulllog.classList.add('ep-sync-box__output_active'); - updateSyncDash(); + syncBoxErrorTab.classList.remove('ep-sync-box__output-tab_active'); + syncBoxOutputError.classList.remove('ep-sync-box__output_active'); +}); + +syncBoxErrorTab.addEventListener('click', function () { + syncBoxErrorTab.classList.add('ep-sync-box__output-tab_active'); + syncBoxOutputError.classList.add('ep-sync-box__output_active'); + + syncBoxFulllogTab.classList.remove('ep-sync-box__output-tab_active'); + syncBoxOutputFulllog.classList.remove('ep-sync-box__output_active'); +}); + +deleteBoxFulllogTab.addEventListener('click', function () { + deleteBoxFulllogTab.classList.add('ep-sync-box__output-tab_active'); + deleteBoxOutputFulllog.classList.add('ep-sync-box__output_active'); + + deleteBoxErrorTab.classList.remove('ep-sync-box__output-tab_active'); + deleteBoxOutputError.classList.remove('ep-sync-box__output_active'); +}); + +deleteBoxErrorTab.addEventListener('click', function () { + deleteBoxErrorTab.classList.add('ep-sync-box__output-tab_active'); + deleteBoxOutputError.classList.add('ep-sync-box__output_active'); - cancelSync(); + deleteBoxFulllogTab.classList.remove('ep-sync-box__output-tab_active'); + deleteBoxOutputFulllog.classList.remove('ep-sync-box__output_active'); }); diff --git a/dist/css/sync-styles.min.css b/dist/css/sync-styles.min.css index a088845c6a..374bfead75 100644 --- a/dist/css/sync-styles.min.css +++ b/dist/css/sync-styles.min.css @@ -1 +1 @@ -#ep-sync-output{display:none;position:relative;z-index:2} +.elasticpress_page_elasticpress-sync .button:disabled{cursor:not-allowed}.ep-sync-box__progress-wrapper{display:none}.ep-sync-box__output{background-color:#1a1e24;display:none;margin-bottom:20px;max-height:200px;overflow-y:scroll;position:relative}.ep-sync-box__output_active{display:block}.ep-sync-box__output-wrapper{color:#fff;margin-left:30px;min-height:200px}.ep-sync-box__output-line{position:relative}.ep-sync-box__output-line-number{background-color:#303030;color:#999;left:-30px;min-width:20px;padding:0 3px 0 5px;position:absolute;text-align:right;white-space:nowrap}.ep-sync-box__output-line-text{font-size:9pt;padding-left:14px}.ep-sync-box__output-tabs{-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex}.ep-sync-box__output-tabs_hide{display:none}.ep-sync-box__output-tab{color:#1e1e1e;padding:1pc}.ep-sync-box__output-tab:hover{cursor:pointer}.ep-sync-box__output-tab_active{border-bottom:4px solid #00a0d2;padding-bottom:9pt}.ep-sync-box__output-tab_active:hover{cursor:default}.ep-sync-box__button-text{height:21px}.elasticpress_page_elasticpress-sync .card{max-width:75pc}.elasticpress_page_elasticpress-sync .card .ep-sync-box__description-actions{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}@media (min-width:768px){.elasticpress_page_elasticpress-sync .card .ep-sync-box__description-actions{-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between}}@media (min-width:768px){.elasticpress_page_elasticpress-sync .card .ep-sync-box__description{width:69%}}.elasticpress_page_elasticpress-sync .card .ep-sync-box__action{-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;margin-top:40px}@media (min-width:768px){.elasticpress_page_elasticpress-sync .card .ep-sync-box__action{width:30%}}.elasticpress_page_elasticpress-sync .card .ep-sync-box__action .ep-sync-box__button{-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;font-size:24px;font-weight:700;height:68px;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;padding:20px 40px;width:228px}.elasticpress_page_elasticpress-sync .card .ep-sync-box__action .ep-sync-box__icon-button{font-size:28px;height:28px;width:28px}.elasticpress_page_elasticpress-sync .card .ep-sync-box__action .ep-sync-box__learn-more-link{margin-top:19px}.elasticpress_page_elasticpress-sync .card .ep-sync-box__description_text{font-size:18px}.elasticpress_page_elasticpress-sync .card .ep-last-sync{margin-bottom:9pt}.elasticpress_page_elasticpress-sync .card .ep-last-sync__title{font-size:20px;font-weight:700;margin-bottom:.5em}.elasticpress_page_elasticpress-sync .card .ep-last-sync__date{background-color:#f1f1f1;padding:6px}.elasticpress_page_elasticpress-sync .card .ep-sync-box__buttons{display:-webkit-box;display:-ms-flexbox;display:flex}.elasticpress_page_elasticpress-sync .card .ep-sync-box__button-pause,.elasticpress_page_elasticpress-sync .card .ep-sync-box__button-resume,.elasticpress_page_elasticpress-sync .card .ep-sync-box__button-stop{-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:none;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;height:68px;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;width:75pt}.elasticpress_page_elasticpress-sync .card .ep-sync-box__button-stop{background-color:#00a0d2;border-color:#00a0d2;margin-left:24px}.elasticpress_page_elasticpress-sync .card .ep-sync-box__progress{-webkit-box-align:normal;-ms-flex-align:normal;align-items:normal;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;margin-bottom:5px;margin-top:19px}@media (min-width:768px){.elasticpress_page_elasticpress-sync .card .ep-sync-box__progress{-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row}}.elasticpress_page_elasticpress-sync .card .ep-sync-box__sync-in-progress{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row}@media (min-width:768px){.elasticpress_page_elasticpress-sync .card .ep-sync-box__sync-in-progress{width:30%}}.elasticpress_page_elasticpress-sync .card .ep-sync-box__progressbar{background-color:#f1f1f1;border-radius:24px;height:20px;margin:15px 0;position:relative;width:100%}@media (min-width:768px){.elasticpress_page_elasticpress-sync .card .ep-sync-box__progressbar{margin:0;width:65%}}.elasticpress_page_elasticpress-sync .card .ep-sync-box__progressbar_animated{background-color:rgba(0,160,210,.3);color:#333;display:block;height:100%;margin:0;text-align:center;-webkit-transition:width .5s ease-in-out;transition:width .5s ease-in-out;width:0}.elasticpress_page_elasticpress-sync .card .ep-sync-box__progressbar_complete{background-color:#46b450;color:#fff}.elasticpress_page_elasticpress-sync .card .ep-sync-box__sync-in-progress-info{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;margin-left:9pt}.elasticpress_page_elasticpress-sync .card .ep-sync-box__progress-info{font-size:14px;font-weight:500;margin-bottom:5px}.elasticpress_page_elasticpress-sync .card .ep-sync-box__start-time{color:#00a0d2;font-size:14px}.elasticpress_page_elasticpress-sync .card .ep-sync-box__start-time-date{color:#333}.elasticpress_page_elasticpress-sync .ep-delete-data-and-sync{margin-top:40px}.elasticpress_page_elasticpress-sync .ep-delete-data-and-sync .card{margin-top:17px}.elasticpress_page_elasticpress-sync .ep-delete-data-and-sync .ep-delete-data-and-sync__title{color:#1d2327;font-size:18px;font-weight:400}.elasticpress_page_elasticpress-sync .ep-delete-data-and-sync .ep-delete-data-and-sync__warning{-webkit-box-align:start;-ms-flex-align:start;align-items:flex-start;display:-webkit-box;display:-ms-flexbox;display:flex}@media (min-width:768px){.elasticpress_page_elasticpress-sync .ep-delete-data-and-sync .ep-delete-data-and-sync__warning{width:69%}}.elasticpress_page_elasticpress-sync .ep-delete-data-and-sync .ep-delete-data-and-sync__warning-icon{margin-right:9px;margin-top:17px}.elasticpress_page_elasticpress-sync .ep-delete-data-and-sync .ep-delete-data-and-sync__button{background-color:rgba(181,39,39,.03);border:1px solid #b52727;color:#b52727;margin:5px 0 9pt}.elasticpress_page_elasticpress-sync .ep-delete-data-and-sync .ep-delete-data-and-sync__button-cancel{display:none}.elasticpress_page_elasticpress-sync .ep-delete-data-and-sync .ep-sync-box__action{-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;height:auto;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;margin-top:0;width:100%}@media (min-width:768px){.elasticpress_page_elasticpress-sync .ep-delete-data-and-sync .ep-sync-box__action{-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row;height:68px;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between}}@media (min-width:768px){.elasticpress_page_elasticpress-sync .ep-delete-data-and-sync .ep-sync-box__buttons{margin-right:5%}} diff --git a/dist/js/autosuggest-script.min.js b/dist/js/autosuggest-script.min.js index 444a732a64..54503a0f4b 100644 --- a/dist/js/autosuggest-script.min.js +++ b/dist/js/autosuggest-script.min.js @@ -1 +1 @@ -!function(){var t={9662:function(t,e,r){var n=r(7854),o=r(614),i=r(6330),a=n.TypeError;t.exports=function(t){if(o(t))return t;throw a(i(t)+" is not a function")}},9483:function(t,e,r){var n=r(7854),o=r(4411),i=r(6330),a=n.TypeError;t.exports=function(t){if(o(t))return t;throw a(i(t)+" is not a constructor")}},6077:function(t,e,r){var n=r(7854),o=r(614),i=n.String,a=n.TypeError;t.exports=function(t){if("object"==typeof t||o(t))return t;throw a("Can't set "+i(t)+" as a prototype")}},1223:function(t,e,r){var n=r(5112),o=r(30),i=r(3070),a=n("unscopables"),u=Array.prototype;void 0==u[a]&&i.f(u,a,{configurable:!0,value:o(null)}),t.exports=function(t){u[a][t]=!0}},1530:function(t,e,r){"use strict";var n=r(8710).charAt;t.exports=function(t,e,r){return e+(r?n(t,e).length:1)}},5787:function(t,e,r){var n=r(7854),o=r(7976),i=n.TypeError;t.exports=function(t,e){if(o(e,t))return t;throw i("Incorrect invocation")}},9670:function(t,e,r){var n=r(7854),o=r(111),i=n.String,a=n.TypeError;t.exports=function(t){if(o(t))return t;throw a(i(t)+" is not an object")}},8533:function(t,e,r){"use strict";var n=r(2092).forEach,o=r(9341)("forEach");t.exports=o?[].forEach:function(t){return n(this,t,arguments.length>1?arguments[1]:void 0)}},8457:function(t,e,r){"use strict";var n=r(7854),o=r(9974),i=r(6916),a=r(7908),u=r(3411),c=r(7659),s=r(4411),f=r(6244),l=r(6135),p=r(8554),h=r(1246),d=n.Array;t.exports=function(t){var e=a(t),r=s(this),n=arguments.length,v=n>1?arguments[1]:void 0,y=void 0!==v;y&&(v=o(v,n>2?arguments[2]:void 0));var g,m,b,x,w,E,S=h(e),O=0;if(!S||this==d&&c(S))for(g=f(e),m=r?new this(g):d(g);g>O;O++)E=y?v(e[O],O):e[O],l(m,O,E);else for(w=(x=p(e,S)).next,m=r?new this:[];!(b=i(w,x)).done;O++)E=y?u(x,v,[b.value,O],!0):b.value,l(m,O,E);return m.length=O,m}},1318:function(t,e,r){var n=r(5656),o=r(1400),i=r(6244),a=function(t){return function(e,r,a){var u,c=n(e),s=i(c),f=o(a,s);if(t&&r!=r){for(;s>f;)if((u=c[f++])!=u)return!0}else for(;s>f;f++)if((t||f in c)&&c[f]===r)return t||f||0;return!t&&-1}};t.exports={includes:a(!0),indexOf:a(!1)}},2092:function(t,e,r){var n=r(9974),o=r(1702),i=r(8361),a=r(7908),u=r(6244),c=r(5417),s=o([].push),f=function(t){var e=1==t,r=2==t,o=3==t,f=4==t,l=6==t,p=7==t,h=5==t||l;return function(d,v,y,g){for(var m,b,x=a(d),w=i(x),E=n(v,y),S=u(w),O=0,_=g||c,T=e?_(d,S):r||p?_(d,0):void 0;S>O;O++)if((h||O in w)&&(b=E(m=w[O],O,x),t))if(e)T[O]=b;else if(b)switch(t){case 3:return!0;case 5:return m;case 6:return O;case 2:s(T,m)}else switch(t){case 4:return!1;case 7:s(T,m)}return l?-1:o||f?f:T}};t.exports={forEach:f(0),map:f(1),filter:f(2),some:f(3),every:f(4),find:f(5),findIndex:f(6),filterReject:f(7)}},1194:function(t,e,r){var n=r(7293),o=r(5112),i=r(7392),a=o("species");t.exports=function(t){return i>=51||!n((function(){var e=[];return(e.constructor={})[a]=function(){return{foo:1}},1!==e[t](Boolean).foo}))}},9341:function(t,e,r){"use strict";var n=r(7293);t.exports=function(t,e){var r=[][t];return!!r&&n((function(){r.call(null,e||function(){throw 1},1)}))}},206:function(t,e,r){var n=r(1702);t.exports=n([].slice)},4362:function(t,e,r){var n=r(206),o=Math.floor,i=function(t,e){var r=t.length,c=o(r/2);return r<8?a(t,e):u(t,i(n(t,0,c),e),i(n(t,c),e),e)},a=function(t,e){for(var r,n,o=t.length,i=1;i0;)t[n]=t[--n];n!==i++&&(t[n]=r)}return t},u=function(t,e,r,n){for(var o=e.length,i=r.length,a=0,u=0;a0&&n[0]<4?1:+(n[0]+n[1])),!o&&a&&(!(n=a.match(/Edge\/(\d+)/))||n[1]>=74)&&(n=a.match(/Chrome\/(\d+)/))&&(o=+n[1]),t.exports=o},8008:function(t,e,r){var n=r(8113).match(/AppleWebKit\/(\d+)\./);t.exports=!!n&&+n[1]},748:function(t){t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},2109:function(t,e,r){var n=r(7854),o=r(1236).f,i=r(8880),a=r(1320),u=r(3505),c=r(9920),s=r(4705);t.exports=function(t,e){var r,f,l,p,h,d=t.target,v=t.global,y=t.stat;if(r=v?n:y?n[d]||u(d,{}):(n[d]||{}).prototype)for(f in e){if(p=e[f],l=t.noTargetGet?(h=o(r,f))&&h.value:r[f],!s(v?f:d+(y?".":"#")+f,t.forced)&&void 0!==l){if(typeof p==typeof l)continue;c(p,l)}(t.sham||l&&l.sham)&&i(p,"sham",!0),a(r,f,p,t)}}},7293:function(t){t.exports=function(t){try{return!!t()}catch(t){return!0}}},7007:function(t,e,r){"use strict";r(4916);var n=r(1702),o=r(1320),i=r(2261),a=r(7293),u=r(5112),c=r(8880),s=u("species"),f=RegExp.prototype;t.exports=function(t,e,r,l){var p=u(t),h=!a((function(){var e={};return e[p]=function(){return 7},7!=""[t](e)})),d=h&&!a((function(){var e=!1,r=/a/;return"split"===t&&((r={}).constructor={},r.constructor[s]=function(){return r},r.flags="",r[p]=/./[p]),r.exec=function(){return e=!0,null},r[p](""),!e}));if(!h||!d||r){var v=n(/./[p]),y=e(p,""[t],(function(t,e,r,o,a){var u=n(t),c=e.exec;return c===i||c===f.exec?h&&!a?{done:!0,value:v(e,r,o)}:{done:!0,value:u(r,e,o)}:{done:!1}}));o(String.prototype,t,y[0]),o(f,p,y[1])}l&&c(f[p],"sham",!0)}},2104:function(t){var e=Function.prototype,r=e.apply,n=e.bind,o=e.call;t.exports="object"==typeof Reflect&&Reflect.apply||(n?o.bind(r):function(){return o.apply(r,arguments)})},9974:function(t,e,r){var n=r(1702),o=r(9662),i=n(n.bind);t.exports=function(t,e){return o(t),void 0===e?t:i?i(t,e):function(){return t.apply(e,arguments)}}},6916:function(t){var e=Function.prototype.call;t.exports=e.bind?e.bind(e):function(){return e.apply(e,arguments)}},6530:function(t,e,r){var n=r(9781),o=r(2597),i=Function.prototype,a=n&&Object.getOwnPropertyDescriptor,u=o(i,"name"),c=u&&"something"===function(){}.name,s=u&&(!n||n&&a(i,"name").configurable);t.exports={EXISTS:u,PROPER:c,CONFIGURABLE:s}},1702:function(t){var e=Function.prototype,r=e.bind,n=e.call,o=r&&r.bind(n);t.exports=r?function(t){return t&&o(n,t)}:function(t){return t&&function(){return n.apply(t,arguments)}}},5005:function(t,e,r){var n=r(7854),o=r(614),i=function(t){return o(t)?t:void 0};t.exports=function(t,e){return arguments.length<2?i(n[t]):n[t]&&n[t][e]}},1246:function(t,e,r){var n=r(648),o=r(8173),i=r(7497),a=r(5112)("iterator");t.exports=function(t){if(void 0!=t)return o(t,a)||o(t,"@@iterator")||i[n(t)]}},8554:function(t,e,r){var n=r(7854),o=r(6916),i=r(9662),a=r(9670),u=r(6330),c=r(1246),s=n.TypeError;t.exports=function(t,e){var r=arguments.length<2?c(t):e;if(i(r))return a(o(r,t));throw s(u(t)+" is not iterable")}},8173:function(t,e,r){var n=r(9662);t.exports=function(t,e){var r=t[e];return null==r?void 0:n(r)}},647:function(t,e,r){var n=r(1702),o=r(7908),i=Math.floor,a=n("".charAt),u=n("".replace),c=n("".slice),s=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,f=/\$([$&'`]|\d{1,2})/g;t.exports=function(t,e,r,n,l,p){var h=r+t.length,d=n.length,v=f;return void 0!==l&&(l=o(l),v=s),u(p,v,(function(o,u){var s;switch(a(u,0)){case"$":return"$";case"&":return t;case"`":return c(e,0,r);case"'":return c(e,h);case"<":s=l[c(u,1,-1)];break;default:var f=+u;if(0===f)return o;if(f>d){var p=i(f/10);return 0===p?o:p<=d?void 0===n[p-1]?a(u,1):n[p-1]+a(u,1):o}s=n[f-1]}return void 0===s?"":s}))}},7854:function(t,e,r){var n=function(t){return t&&t.Math==Math&&t};t.exports=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof r.g&&r.g)||function(){return this}()||Function("return this")()},2597:function(t,e,r){var n=r(1702),o=r(7908),i=n({}.hasOwnProperty);t.exports=Object.hasOwn||function(t,e){return i(o(t),e)}},3501:function(t){t.exports={}},842:function(t,e,r){var n=r(7854);t.exports=function(t,e){var r=n.console;r&&r.error&&(1==arguments.length?r.error(t):r.error(t,e))}},490:function(t,e,r){var n=r(5005);t.exports=n("document","documentElement")},4664:function(t,e,r){var n=r(9781),o=r(7293),i=r(317);t.exports=!n&&!o((function(){return 7!=Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a}))},8361:function(t,e,r){var n=r(7854),o=r(1702),i=r(7293),a=r(4326),u=n.Object,c=o("".split);t.exports=i((function(){return!u("z").propertyIsEnumerable(0)}))?function(t){return"String"==a(t)?c(t,""):u(t)}:u},9587:function(t,e,r){var n=r(614),o=r(111),i=r(7674);t.exports=function(t,e,r){var a,u;return i&&n(a=e.constructor)&&a!==r&&o(u=a.prototype)&&u!==r.prototype&&i(t,u),t}},2788:function(t,e,r){var n=r(1702),o=r(614),i=r(5465),a=n(Function.toString);o(i.inspectSource)||(i.inspectSource=function(t){return a(t)}),t.exports=i.inspectSource},9909:function(t,e,r){var n,o,i,a=r(8536),u=r(7854),c=r(1702),s=r(111),f=r(8880),l=r(2597),p=r(5465),h=r(6200),d=r(3501),v="Object already initialized",y=u.TypeError,g=u.WeakMap;if(a||p.state){var m=p.state||(p.state=new g),b=c(m.get),x=c(m.has),w=c(m.set);n=function(t,e){if(x(m,t))throw new y(v);return e.facade=t,w(m,t,e),e},o=function(t){return b(m,t)||{}},i=function(t){return x(m,t)}}else{var E=h("state");d[E]=!0,n=function(t,e){if(l(t,E))throw new y(v);return e.facade=t,f(t,E,e),e},o=function(t){return l(t,E)?t[E]:{}},i=function(t){return l(t,E)}}t.exports={set:n,get:o,has:i,enforce:function(t){return i(t)?o(t):n(t,{})},getterFor:function(t){return function(e){var r;if(!s(e)||(r=o(e)).type!==t)throw y("Incompatible receiver, "+t+" required");return r}}}},7659:function(t,e,r){var n=r(5112),o=r(7497),i=n("iterator"),a=Array.prototype;t.exports=function(t){return void 0!==t&&(o.Array===t||a[i]===t)}},3157:function(t,e,r){var n=r(4326);t.exports=Array.isArray||function(t){return"Array"==n(t)}},614:function(t){t.exports=function(t){return"function"==typeof t}},4411:function(t,e,r){var n=r(1702),o=r(7293),i=r(614),a=r(648),u=r(5005),c=r(2788),s=function(){},f=[],l=u("Reflect","construct"),p=/^\s*(?:class|function)\b/,h=n(p.exec),d=!p.exec(s),v=function(t){if(!i(t))return!1;try{return l(s,f,t),!0}catch(t){return!1}};t.exports=!l||o((function(){var t;return v(v.call)||!v(Object)||!v((function(){t=!0}))||t}))?function(t){if(!i(t))return!1;switch(a(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}return d||!!h(p,c(t))}:v},4705:function(t,e,r){var n=r(7293),o=r(614),i=/#|\.prototype\./,a=function(t,e){var r=c[u(t)];return r==f||r!=s&&(o(e)?n(e):!!e)},u=a.normalize=function(t){return String(t).replace(i,".").toLowerCase()},c=a.data={},s=a.NATIVE="N",f=a.POLYFILL="P";t.exports=a},111:function(t,e,r){var n=r(614);t.exports=function(t){return"object"==typeof t?null!==t:n(t)}},1913:function(t){t.exports=!1},7850:function(t,e,r){var n=r(111),o=r(4326),i=r(5112)("match");t.exports=function(t){var e;return n(t)&&(void 0!==(e=t[i])?!!e:"RegExp"==o(t))}},2190:function(t,e,r){var n=r(7854),o=r(5005),i=r(614),a=r(7976),u=r(3307),c=n.Object;t.exports=u?function(t){return"symbol"==typeof t}:function(t){var e=o("Symbol");return i(e)&&a(e.prototype,c(t))}},408:function(t,e,r){var n=r(7854),o=r(9974),i=r(6916),a=r(9670),u=r(6330),c=r(7659),s=r(6244),f=r(7976),l=r(8554),p=r(1246),h=r(9212),d=n.TypeError,v=function(t,e){this.stopped=t,this.result=e},y=v.prototype;t.exports=function(t,e,r){var n,g,m,b,x,w,E,S=r&&r.that,O=!(!r||!r.AS_ENTRIES),_=!(!r||!r.IS_ITERATOR),T=!(!r||!r.INTERRUPTED),A=o(e,S),j=function(t){return n&&h(n,"normal",t),new v(!0,t)},P=function(t){return O?(a(t),T?A(t[0],t[1],j):A(t[0],t[1])):T?A(t,j):A(t)};if(_)n=t;else{if(!(g=p(t)))throw d(u(t)+" is not iterable");if(c(g)){for(m=0,b=s(t);b>m;m++)if((x=P(t[m]))&&f(y,x))return x;return new v(!1)}n=l(t,g)}for(w=n.next;!(E=i(w,n)).done;){try{x=P(E.value)}catch(t){h(n,"throw",t)}if("object"==typeof x&&x&&f(y,x))return x}return new v(!1)}},9212:function(t,e,r){var n=r(6916),o=r(9670),i=r(8173);t.exports=function(t,e,r){var a,u;o(t);try{if(!(a=i(t,"return"))){if("throw"===e)throw r;return r}a=n(a,t)}catch(t){u=!0,a=t}if("throw"===e)throw r;if(u)throw a;return o(a),r}},3383:function(t,e,r){"use strict";var n,o,i,a=r(7293),u=r(614),c=r(30),s=r(9518),f=r(1320),l=r(5112),p=r(1913),h=l("iterator"),d=!1;[].keys&&("next"in(i=[].keys())?(o=s(s(i)))!==Object.prototype&&(n=o):d=!0),void 0==n||a((function(){var t={};return n[h].call(t)!==t}))?n={}:p&&(n=c(n)),u(n[h])||f(n,h,(function(){return this})),t.exports={IteratorPrototype:n,BUGGY_SAFARI_ITERATORS:d}},7497:function(t){t.exports={}},6244:function(t,e,r){var n=r(7466);t.exports=function(t){return n(t.length)}},5948:function(t,e,r){var n,o,i,a,u,c,s,f,l=r(7854),p=r(9974),h=r(1236).f,d=r(261).set,v=r(6833),y=r(1528),g=r(1036),m=r(5268),b=l.MutationObserver||l.WebKitMutationObserver,x=l.document,w=l.process,E=l.Promise,S=h(l,"queueMicrotask"),O=S&&S.value;O||(n=function(){var t,e;for(m&&(t=w.domain)&&t.exit();o;){e=o.fn,o=o.next;try{e()}catch(t){throw o?a():i=void 0,t}}i=void 0,t&&t.enter()},v||m||g||!b||!x?!y&&E&&E.resolve?((s=E.resolve(void 0)).constructor=E,f=p(s.then,s),a=function(){f(n)}):m?a=function(){w.nextTick(n)}:(d=p(d,l),a=function(){d(n)}):(u=!0,c=x.createTextNode(""),new b(n).observe(c,{characterData:!0}),a=function(){c.data=u=!u})),t.exports=O||function(t){var e={fn:t,next:void 0};i&&(i.next=e),o||(o=e,a()),i=e}},3366:function(t,e,r){var n=r(7854);t.exports=n.Promise},133:function(t,e,r){var n=r(7392),o=r(7293);t.exports=!!Object.getOwnPropertySymbols&&!o((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&n&&n<41}))},8536:function(t,e,r){var n=r(7854),o=r(614),i=r(2788),a=n.WeakMap;t.exports=o(a)&&/native code/.test(i(a))},8523:function(t,e,r){"use strict";var n=r(9662),o=function(t){var e,r;this.promise=new t((function(t,n){if(void 0!==e||void 0!==r)throw TypeError("Bad Promise constructor");e=t,r=n})),this.resolve=n(e),this.reject=n(r)};t.exports.f=function(t){return new o(t)}},3929:function(t,e,r){var n=r(7854),o=r(7850),i=n.TypeError;t.exports=function(t){if(o(t))throw i("The method doesn't accept regular expressions");return t}},30:function(t,e,r){var n,o=r(9670),i=r(6048),a=r(748),u=r(3501),c=r(490),s=r(317),f=r(6200),l=f("IE_PROTO"),p=function(){},h=function(t){return"